47481 lines
1.8 MiB
47481 lines
1.8 MiB
/*
|
||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||
if you want to view the source, please visit the github repository of this plugin
|
||
*/
|
||
|
||
var __create = Object.create;
|
||
var __defProp = Object.defineProperty;
|
||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||
var __getProtoOf = Object.getPrototypeOf;
|
||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||
var __commonJS = (cb, mod) => function __require() {
|
||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||
};
|
||
var __export = (target, all) => {
|
||
for (var name in all)
|
||
__defProp(target, name, { get: all[name], enumerable: true });
|
||
};
|
||
var __copyProps = (to, from, except, desc) => {
|
||
if (from && typeof from === "object" || typeof from === "function") {
|
||
for (let key of __getOwnPropNames(from))
|
||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||
}
|
||
return to;
|
||
};
|
||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||
|
||
// node_modules/react/cjs/react.development.js
|
||
var require_react_development = __commonJS({
|
||
"node_modules/react/cjs/react.development.js"(exports, module2) {
|
||
"use strict";
|
||
if (true) {
|
||
(function() {
|
||
"use strict";
|
||
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
||
}
|
||
var ReactVersion = "18.2.0";
|
||
var REACT_ELEMENT_TYPE = Symbol.for("react.element");
|
||
var REACT_PORTAL_TYPE = Symbol.for("react.portal");
|
||
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
||
var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
|
||
var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
||
var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
|
||
var REACT_CONTEXT_TYPE = Symbol.for("react.context");
|
||
var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
|
||
var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
|
||
var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
|
||
var REACT_MEMO_TYPE = Symbol.for("react.memo");
|
||
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
||
var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
|
||
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
||
var FAUX_ITERATOR_SYMBOL = "@@iterator";
|
||
function getIteratorFn(maybeIterable) {
|
||
if (maybeIterable === null || typeof maybeIterable !== "object") {
|
||
return null;
|
||
}
|
||
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
||
if (typeof maybeIterator === "function") {
|
||
return maybeIterator;
|
||
}
|
||
return null;
|
||
}
|
||
var ReactCurrentDispatcher = {
|
||
current: null
|
||
};
|
||
var ReactCurrentBatchConfig = {
|
||
transition: null
|
||
};
|
||
var ReactCurrentActQueue = {
|
||
current: null,
|
||
isBatchingLegacy: false,
|
||
didScheduleLegacyUpdate: false
|
||
};
|
||
var ReactCurrentOwner = {
|
||
current: null
|
||
};
|
||
var ReactDebugCurrentFrame = {};
|
||
var currentExtraStackFrame = null;
|
||
function setExtraStackFrame(stack) {
|
||
{
|
||
currentExtraStackFrame = stack;
|
||
}
|
||
}
|
||
{
|
||
ReactDebugCurrentFrame.setExtraStackFrame = function(stack) {
|
||
{
|
||
currentExtraStackFrame = stack;
|
||
}
|
||
};
|
||
ReactDebugCurrentFrame.getCurrentStack = null;
|
||
ReactDebugCurrentFrame.getStackAddendum = function() {
|
||
var stack = "";
|
||
if (currentExtraStackFrame) {
|
||
stack += currentExtraStackFrame;
|
||
}
|
||
var impl = ReactDebugCurrentFrame.getCurrentStack;
|
||
if (impl) {
|
||
stack += impl() || "";
|
||
}
|
||
return stack;
|
||
};
|
||
}
|
||
var enableScopeAPI = false;
|
||
var enableCacheElement = false;
|
||
var enableTransitionTracing = false;
|
||
var enableLegacyHidden = false;
|
||
var enableDebugTracing = false;
|
||
var ReactSharedInternals = {
|
||
ReactCurrentDispatcher,
|
||
ReactCurrentBatchConfig,
|
||
ReactCurrentOwner
|
||
};
|
||
{
|
||
ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
|
||
ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue;
|
||
}
|
||
function warn(format) {
|
||
{
|
||
{
|
||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||
args[_key - 1] = arguments[_key];
|
||
}
|
||
printWarning("warn", format, args);
|
||
}
|
||
}
|
||
}
|
||
function error(format) {
|
||
{
|
||
{
|
||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||
args[_key2 - 1] = arguments[_key2];
|
||
}
|
||
printWarning("error", format, args);
|
||
}
|
||
}
|
||
}
|
||
function printWarning(level, format, args) {
|
||
{
|
||
var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
|
||
var stack = ReactDebugCurrentFrame2.getStackAddendum();
|
||
if (stack !== "") {
|
||
format += "%s";
|
||
args = args.concat([stack]);
|
||
}
|
||
var argsWithFormat = args.map(function(item) {
|
||
return String(item);
|
||
});
|
||
argsWithFormat.unshift("Warning: " + format);
|
||
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
||
}
|
||
}
|
||
var didWarnStateUpdateForUnmountedComponent = {};
|
||
function warnNoop(publicInstance, callerName) {
|
||
{
|
||
var _constructor = publicInstance.constructor;
|
||
var componentName = _constructor && (_constructor.displayName || _constructor.name) || "ReactClass";
|
||
var warningKey = componentName + "." + callerName;
|
||
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
|
||
return;
|
||
}
|
||
error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.", callerName, componentName);
|
||
didWarnStateUpdateForUnmountedComponent[warningKey] = true;
|
||
}
|
||
}
|
||
var ReactNoopUpdateQueue = {
|
||
isMounted: function(publicInstance) {
|
||
return false;
|
||
},
|
||
enqueueForceUpdate: function(publicInstance, callback, callerName) {
|
||
warnNoop(publicInstance, "forceUpdate");
|
||
},
|
||
enqueueReplaceState: function(publicInstance, completeState, callback, callerName) {
|
||
warnNoop(publicInstance, "replaceState");
|
||
},
|
||
enqueueSetState: function(publicInstance, partialState, callback, callerName) {
|
||
warnNoop(publicInstance, "setState");
|
||
}
|
||
};
|
||
var assign = Object.assign;
|
||
var emptyObject = {};
|
||
{
|
||
Object.freeze(emptyObject);
|
||
}
|
||
function Component(props, context, updater) {
|
||
this.props = props;
|
||
this.context = context;
|
||
this.refs = emptyObject;
|
||
this.updater = updater || ReactNoopUpdateQueue;
|
||
}
|
||
Component.prototype.isReactComponent = {};
|
||
Component.prototype.setState = function(partialState, callback) {
|
||
if (typeof partialState !== "object" && typeof partialState !== "function" && partialState != null) {
|
||
throw new Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
|
||
}
|
||
this.updater.enqueueSetState(this, partialState, callback, "setState");
|
||
};
|
||
Component.prototype.forceUpdate = function(callback) {
|
||
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
|
||
};
|
||
{
|
||
var deprecatedAPIs = {
|
||
isMounted: ["isMounted", "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],
|
||
replaceState: ["replaceState", "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]
|
||
};
|
||
var defineDeprecationWarning = function(methodName, info) {
|
||
Object.defineProperty(Component.prototype, methodName, {
|
||
get: function() {
|
||
warn("%s(...) is deprecated in plain JavaScript React classes. %s", info[0], info[1]);
|
||
return void 0;
|
||
}
|
||
});
|
||
};
|
||
for (var fnName in deprecatedAPIs) {
|
||
if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
||
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
||
}
|
||
}
|
||
}
|
||
function ComponentDummy() {
|
||
}
|
||
ComponentDummy.prototype = Component.prototype;
|
||
function PureComponent(props, context, updater) {
|
||
this.props = props;
|
||
this.context = context;
|
||
this.refs = emptyObject;
|
||
this.updater = updater || ReactNoopUpdateQueue;
|
||
}
|
||
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
||
pureComponentPrototype.constructor = PureComponent;
|
||
assign(pureComponentPrototype, Component.prototype);
|
||
pureComponentPrototype.isPureReactComponent = true;
|
||
function createRef() {
|
||
var refObject = {
|
||
current: null
|
||
};
|
||
{
|
||
Object.seal(refObject);
|
||
}
|
||
return refObject;
|
||
}
|
||
var isArrayImpl = Array.isArray;
|
||
function isArray(a) {
|
||
return isArrayImpl(a);
|
||
}
|
||
function typeName(value) {
|
||
{
|
||
var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
|
||
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
||
return type;
|
||
}
|
||
}
|
||
function willCoercionThrow(value) {
|
||
{
|
||
try {
|
||
testStringCoercion(value);
|
||
return false;
|
||
} catch (e) {
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
function testStringCoercion(value) {
|
||
return "" + value;
|
||
}
|
||
function checkKeyStringCoercion(value) {
|
||
{
|
||
if (willCoercionThrow(value)) {
|
||
error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
|
||
return testStringCoercion(value);
|
||
}
|
||
}
|
||
}
|
||
function getWrappedName(outerType, innerType, wrapperName) {
|
||
var displayName = outerType.displayName;
|
||
if (displayName) {
|
||
return displayName;
|
||
}
|
||
var functionName = innerType.displayName || innerType.name || "";
|
||
return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
|
||
}
|
||
function getContextName(type) {
|
||
return type.displayName || "Context";
|
||
}
|
||
function getComponentNameFromType(type) {
|
||
if (type == null) {
|
||
return null;
|
||
}
|
||
{
|
||
if (typeof type.tag === "number") {
|
||
error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
if (typeof type === "function") {
|
||
return type.displayName || type.name || null;
|
||
}
|
||
if (typeof type === "string") {
|
||
return type;
|
||
}
|
||
switch (type) {
|
||
case REACT_FRAGMENT_TYPE:
|
||
return "Fragment";
|
||
case REACT_PORTAL_TYPE:
|
||
return "Portal";
|
||
case REACT_PROFILER_TYPE:
|
||
return "Profiler";
|
||
case REACT_STRICT_MODE_TYPE:
|
||
return "StrictMode";
|
||
case REACT_SUSPENSE_TYPE:
|
||
return "Suspense";
|
||
case REACT_SUSPENSE_LIST_TYPE:
|
||
return "SuspenseList";
|
||
}
|
||
if (typeof type === "object") {
|
||
switch (type.$$typeof) {
|
||
case REACT_CONTEXT_TYPE:
|
||
var context = type;
|
||
return getContextName(context) + ".Consumer";
|
||
case REACT_PROVIDER_TYPE:
|
||
var provider = type;
|
||
return getContextName(provider._context) + ".Provider";
|
||
case REACT_FORWARD_REF_TYPE:
|
||
return getWrappedName(type, type.render, "ForwardRef");
|
||
case REACT_MEMO_TYPE:
|
||
var outerName = type.displayName || null;
|
||
if (outerName !== null) {
|
||
return outerName;
|
||
}
|
||
return getComponentNameFromType(type.type) || "Memo";
|
||
case REACT_LAZY_TYPE: {
|
||
var lazyComponent = type;
|
||
var payload = lazyComponent._payload;
|
||
var init = lazyComponent._init;
|
||
try {
|
||
return getComponentNameFromType(init(payload));
|
||
} catch (x) {
|
||
return null;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
var hasOwnProperty2 = Object.prototype.hasOwnProperty;
|
||
var RESERVED_PROPS = {
|
||
key: true,
|
||
ref: true,
|
||
__self: true,
|
||
__source: true
|
||
};
|
||
var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;
|
||
{
|
||
didWarnAboutStringRefs = {};
|
||
}
|
||
function hasValidRef(config) {
|
||
{
|
||
if (hasOwnProperty2.call(config, "ref")) {
|
||
var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
|
||
if (getter && getter.isReactWarning) {
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
return config.ref !== void 0;
|
||
}
|
||
function hasValidKey(config) {
|
||
{
|
||
if (hasOwnProperty2.call(config, "key")) {
|
||
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
||
if (getter && getter.isReactWarning) {
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
return config.key !== void 0;
|
||
}
|
||
function defineKeyPropWarningGetter(props, displayName) {
|
||
var warnAboutAccessingKey = function() {
|
||
{
|
||
if (!specialPropKeyWarningShown) {
|
||
specialPropKeyWarningShown = true;
|
||
error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
||
}
|
||
}
|
||
};
|
||
warnAboutAccessingKey.isReactWarning = true;
|
||
Object.defineProperty(props, "key", {
|
||
get: warnAboutAccessingKey,
|
||
configurable: true
|
||
});
|
||
}
|
||
function defineRefPropWarningGetter(props, displayName) {
|
||
var warnAboutAccessingRef = function() {
|
||
{
|
||
if (!specialPropRefWarningShown) {
|
||
specialPropRefWarningShown = true;
|
||
error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
||
}
|
||
}
|
||
};
|
||
warnAboutAccessingRef.isReactWarning = true;
|
||
Object.defineProperty(props, "ref", {
|
||
get: warnAboutAccessingRef,
|
||
configurable: true
|
||
});
|
||
}
|
||
function warnIfStringRefCannotBeAutoConverted(config) {
|
||
{
|
||
if (typeof config.ref === "string" && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {
|
||
var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
|
||
if (!didWarnAboutStringRefs[componentName]) {
|
||
error('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref);
|
||
didWarnAboutStringRefs[componentName] = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var ReactElement = function(type, key, ref, self2, source, owner, props) {
|
||
var element = {
|
||
$$typeof: REACT_ELEMENT_TYPE,
|
||
type,
|
||
key,
|
||
ref,
|
||
props,
|
||
_owner: owner
|
||
};
|
||
{
|
||
element._store = {};
|
||
Object.defineProperty(element._store, "validated", {
|
||
configurable: false,
|
||
enumerable: false,
|
||
writable: true,
|
||
value: false
|
||
});
|
||
Object.defineProperty(element, "_self", {
|
||
configurable: false,
|
||
enumerable: false,
|
||
writable: false,
|
||
value: self2
|
||
});
|
||
Object.defineProperty(element, "_source", {
|
||
configurable: false,
|
||
enumerable: false,
|
||
writable: false,
|
||
value: source
|
||
});
|
||
if (Object.freeze) {
|
||
Object.freeze(element.props);
|
||
Object.freeze(element);
|
||
}
|
||
}
|
||
return element;
|
||
};
|
||
function createElement2(type, config, children) {
|
||
var propName;
|
||
var props = {};
|
||
var key = null;
|
||
var ref = null;
|
||
var self2 = null;
|
||
var source = null;
|
||
if (config != null) {
|
||
if (hasValidRef(config)) {
|
||
ref = config.ref;
|
||
{
|
||
warnIfStringRefCannotBeAutoConverted(config);
|
||
}
|
||
}
|
||
if (hasValidKey(config)) {
|
||
{
|
||
checkKeyStringCoercion(config.key);
|
||
}
|
||
key = "" + config.key;
|
||
}
|
||
self2 = config.__self === void 0 ? null : config.__self;
|
||
source = config.__source === void 0 ? null : config.__source;
|
||
for (propName in config) {
|
||
if (hasOwnProperty2.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
||
props[propName] = config[propName];
|
||
}
|
||
}
|
||
}
|
||
var childrenLength = arguments.length - 2;
|
||
if (childrenLength === 1) {
|
||
props.children = children;
|
||
} else if (childrenLength > 1) {
|
||
var childArray = Array(childrenLength);
|
||
for (var i = 0; i < childrenLength; i++) {
|
||
childArray[i] = arguments[i + 2];
|
||
}
|
||
{
|
||
if (Object.freeze) {
|
||
Object.freeze(childArray);
|
||
}
|
||
}
|
||
props.children = childArray;
|
||
}
|
||
if (type && type.defaultProps) {
|
||
var defaultProps = type.defaultProps;
|
||
for (propName in defaultProps) {
|
||
if (props[propName] === void 0) {
|
||
props[propName] = defaultProps[propName];
|
||
}
|
||
}
|
||
}
|
||
{
|
||
if (key || ref) {
|
||
var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
|
||
if (key) {
|
||
defineKeyPropWarningGetter(props, displayName);
|
||
}
|
||
if (ref) {
|
||
defineRefPropWarningGetter(props, displayName);
|
||
}
|
||
}
|
||
}
|
||
return ReactElement(type, key, ref, self2, source, ReactCurrentOwner.current, props);
|
||
}
|
||
function cloneAndReplaceKey(oldElement, newKey) {
|
||
var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
|
||
return newElement;
|
||
}
|
||
function cloneElement(element, config, children) {
|
||
if (element === null || element === void 0) {
|
||
throw new Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");
|
||
}
|
||
var propName;
|
||
var props = assign({}, element.props);
|
||
var key = element.key;
|
||
var ref = element.ref;
|
||
var self2 = element._self;
|
||
var source = element._source;
|
||
var owner = element._owner;
|
||
if (config != null) {
|
||
if (hasValidRef(config)) {
|
||
ref = config.ref;
|
||
owner = ReactCurrentOwner.current;
|
||
}
|
||
if (hasValidKey(config)) {
|
||
{
|
||
checkKeyStringCoercion(config.key);
|
||
}
|
||
key = "" + config.key;
|
||
}
|
||
var defaultProps;
|
||
if (element.type && element.type.defaultProps) {
|
||
defaultProps = element.type.defaultProps;
|
||
}
|
||
for (propName in config) {
|
||
if (hasOwnProperty2.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
||
if (config[propName] === void 0 && defaultProps !== void 0) {
|
||
props[propName] = defaultProps[propName];
|
||
} else {
|
||
props[propName] = config[propName];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var childrenLength = arguments.length - 2;
|
||
if (childrenLength === 1) {
|
||
props.children = children;
|
||
} else if (childrenLength > 1) {
|
||
var childArray = Array(childrenLength);
|
||
for (var i = 0; i < childrenLength; i++) {
|
||
childArray[i] = arguments[i + 2];
|
||
}
|
||
props.children = childArray;
|
||
}
|
||
return ReactElement(element.type, key, ref, self2, source, owner, props);
|
||
}
|
||
function isValidElement(object) {
|
||
return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
||
}
|
||
var SEPARATOR = ".";
|
||
var SUBSEPARATOR = ":";
|
||
function escape(key) {
|
||
var escapeRegex = /[=:]/g;
|
||
var escaperLookup = {
|
||
"=": "=0",
|
||
":": "=2"
|
||
};
|
||
var escapedString = key.replace(escapeRegex, function(match) {
|
||
return escaperLookup[match];
|
||
});
|
||
return "$" + escapedString;
|
||
}
|
||
var didWarnAboutMaps = false;
|
||
var userProvidedKeyEscapeRegex = /\/+/g;
|
||
function escapeUserProvidedKey(text) {
|
||
return text.replace(userProvidedKeyEscapeRegex, "$&/");
|
||
}
|
||
function getElementKey(element, index) {
|
||
if (typeof element === "object" && element !== null && element.key != null) {
|
||
{
|
||
checkKeyStringCoercion(element.key);
|
||
}
|
||
return escape("" + element.key);
|
||
}
|
||
return index.toString(36);
|
||
}
|
||
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
||
var type = typeof children;
|
||
if (type === "undefined" || type === "boolean") {
|
||
children = null;
|
||
}
|
||
var invokeCallback = false;
|
||
if (children === null) {
|
||
invokeCallback = true;
|
||
} else {
|
||
switch (type) {
|
||
case "string":
|
||
case "number":
|
||
invokeCallback = true;
|
||
break;
|
||
case "object":
|
||
switch (children.$$typeof) {
|
||
case REACT_ELEMENT_TYPE:
|
||
case REACT_PORTAL_TYPE:
|
||
invokeCallback = true;
|
||
}
|
||
}
|
||
}
|
||
if (invokeCallback) {
|
||
var _child = children;
|
||
var mappedChild = callback(_child);
|
||
var childKey = nameSoFar === "" ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
|
||
if (isArray(mappedChild)) {
|
||
var escapedChildKey = "";
|
||
if (childKey != null) {
|
||
escapedChildKey = escapeUserProvidedKey(childKey) + "/";
|
||
}
|
||
mapIntoArray(mappedChild, array, escapedChildKey, "", function(c) {
|
||
return c;
|
||
});
|
||
} else if (mappedChild != null) {
|
||
if (isValidElement(mappedChild)) {
|
||
{
|
||
if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {
|
||
checkKeyStringCoercion(mappedChild.key);
|
||
}
|
||
}
|
||
mappedChild = cloneAndReplaceKey(mappedChild, escapedPrefix + (mappedChild.key && (!_child || _child.key !== mappedChild.key) ? escapeUserProvidedKey("" + mappedChild.key) + "/" : "") + childKey);
|
||
}
|
||
array.push(mappedChild);
|
||
}
|
||
return 1;
|
||
}
|
||
var child;
|
||
var nextName;
|
||
var subtreeCount = 0;
|
||
var nextNamePrefix = nameSoFar === "" ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
||
if (isArray(children)) {
|
||
for (var i = 0; i < children.length; i++) {
|
||
child = children[i];
|
||
nextName = nextNamePrefix + getElementKey(child, i);
|
||
subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
|
||
}
|
||
} else {
|
||
var iteratorFn = getIteratorFn(children);
|
||
if (typeof iteratorFn === "function") {
|
||
var iterableChildren = children;
|
||
{
|
||
if (iteratorFn === iterableChildren.entries) {
|
||
if (!didWarnAboutMaps) {
|
||
warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead.");
|
||
}
|
||
didWarnAboutMaps = true;
|
||
}
|
||
}
|
||
var iterator = iteratorFn.call(iterableChildren);
|
||
var step;
|
||
var ii = 0;
|
||
while (!(step = iterator.next()).done) {
|
||
child = step.value;
|
||
nextName = nextNamePrefix + getElementKey(child, ii++);
|
||
subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
|
||
}
|
||
} else if (type === "object") {
|
||
var childrenString = String(children);
|
||
throw new Error("Objects are not valid as a React child (found: " + (childrenString === "[object Object]" ? "object with keys {" + Object.keys(children).join(", ") + "}" : childrenString) + "). If you meant to render a collection of children, use an array instead.");
|
||
}
|
||
}
|
||
return subtreeCount;
|
||
}
|
||
function mapChildren(children, func, context) {
|
||
if (children == null) {
|
||
return children;
|
||
}
|
||
var result = [];
|
||
var count = 0;
|
||
mapIntoArray(children, result, "", "", function(child) {
|
||
return func.call(context, child, count++);
|
||
});
|
||
return result;
|
||
}
|
||
function countChildren(children) {
|
||
var n = 0;
|
||
mapChildren(children, function() {
|
||
n++;
|
||
});
|
||
return n;
|
||
}
|
||
function forEachChildren(children, forEachFunc, forEachContext) {
|
||
mapChildren(children, function() {
|
||
forEachFunc.apply(this, arguments);
|
||
}, forEachContext);
|
||
}
|
||
function toArray(children) {
|
||
return mapChildren(children, function(child) {
|
||
return child;
|
||
}) || [];
|
||
}
|
||
function onlyChild(children) {
|
||
if (!isValidElement(children)) {
|
||
throw new Error("React.Children.only expected to receive a single React element child.");
|
||
}
|
||
return children;
|
||
}
|
||
function createContext(defaultValue) {
|
||
var context = {
|
||
$$typeof: REACT_CONTEXT_TYPE,
|
||
_currentValue: defaultValue,
|
||
_currentValue2: defaultValue,
|
||
_threadCount: 0,
|
||
Provider: null,
|
||
Consumer: null,
|
||
_defaultValue: null,
|
||
_globalName: null
|
||
};
|
||
context.Provider = {
|
||
$$typeof: REACT_PROVIDER_TYPE,
|
||
_context: context
|
||
};
|
||
var hasWarnedAboutUsingNestedContextConsumers = false;
|
||
var hasWarnedAboutUsingConsumerProvider = false;
|
||
var hasWarnedAboutDisplayNameOnConsumer = false;
|
||
{
|
||
var Consumer = {
|
||
$$typeof: REACT_CONTEXT_TYPE,
|
||
_context: context
|
||
};
|
||
Object.defineProperties(Consumer, {
|
||
Provider: {
|
||
get: function() {
|
||
if (!hasWarnedAboutUsingConsumerProvider) {
|
||
hasWarnedAboutUsingConsumerProvider = true;
|
||
error("Rendering <Context.Consumer.Provider> is not supported and will be removed in a future major release. Did you mean to render <Context.Provider> instead?");
|
||
}
|
||
return context.Provider;
|
||
},
|
||
set: function(_Provider) {
|
||
context.Provider = _Provider;
|
||
}
|
||
},
|
||
_currentValue: {
|
||
get: function() {
|
||
return context._currentValue;
|
||
},
|
||
set: function(_currentValue) {
|
||
context._currentValue = _currentValue;
|
||
}
|
||
},
|
||
_currentValue2: {
|
||
get: function() {
|
||
return context._currentValue2;
|
||
},
|
||
set: function(_currentValue2) {
|
||
context._currentValue2 = _currentValue2;
|
||
}
|
||
},
|
||
_threadCount: {
|
||
get: function() {
|
||
return context._threadCount;
|
||
},
|
||
set: function(_threadCount) {
|
||
context._threadCount = _threadCount;
|
||
}
|
||
},
|
||
Consumer: {
|
||
get: function() {
|
||
if (!hasWarnedAboutUsingNestedContextConsumers) {
|
||
hasWarnedAboutUsingNestedContextConsumers = true;
|
||
error("Rendering <Context.Consumer.Consumer> is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?");
|
||
}
|
||
return context.Consumer;
|
||
}
|
||
},
|
||
displayName: {
|
||
get: function() {
|
||
return context.displayName;
|
||
},
|
||
set: function(displayName) {
|
||
if (!hasWarnedAboutDisplayNameOnConsumer) {
|
||
warn("Setting `displayName` on Context.Consumer has no effect. You should set it directly on the context with Context.displayName = '%s'.", displayName);
|
||
hasWarnedAboutDisplayNameOnConsumer = true;
|
||
}
|
||
}
|
||
}
|
||
});
|
||
context.Consumer = Consumer;
|
||
}
|
||
{
|
||
context._currentRenderer = null;
|
||
context._currentRenderer2 = null;
|
||
}
|
||
return context;
|
||
}
|
||
var Uninitialized = -1;
|
||
var Pending = 0;
|
||
var Resolved = 1;
|
||
var Rejected = 2;
|
||
function lazyInitializer(payload) {
|
||
if (payload._status === Uninitialized) {
|
||
var ctor = payload._result;
|
||
var thenable = ctor();
|
||
thenable.then(function(moduleObject2) {
|
||
if (payload._status === Pending || payload._status === Uninitialized) {
|
||
var resolved = payload;
|
||
resolved._status = Resolved;
|
||
resolved._result = moduleObject2;
|
||
}
|
||
}, function(error2) {
|
||
if (payload._status === Pending || payload._status === Uninitialized) {
|
||
var rejected = payload;
|
||
rejected._status = Rejected;
|
||
rejected._result = error2;
|
||
}
|
||
});
|
||
if (payload._status === Uninitialized) {
|
||
var pending = payload;
|
||
pending._status = Pending;
|
||
pending._result = thenable;
|
||
}
|
||
}
|
||
if (payload._status === Resolved) {
|
||
var moduleObject = payload._result;
|
||
{
|
||
if (moduleObject === void 0) {
|
||
error("lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?", moduleObject);
|
||
}
|
||
}
|
||
{
|
||
if (!("default" in moduleObject)) {
|
||
error("lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))", moduleObject);
|
||
}
|
||
}
|
||
return moduleObject.default;
|
||
} else {
|
||
throw payload._result;
|
||
}
|
||
}
|
||
function lazy(ctor) {
|
||
var payload = {
|
||
_status: Uninitialized,
|
||
_result: ctor
|
||
};
|
||
var lazyType = {
|
||
$$typeof: REACT_LAZY_TYPE,
|
||
_payload: payload,
|
||
_init: lazyInitializer
|
||
};
|
||
{
|
||
var defaultProps;
|
||
var propTypes;
|
||
Object.defineProperties(lazyType, {
|
||
defaultProps: {
|
||
configurable: true,
|
||
get: function() {
|
||
return defaultProps;
|
||
},
|
||
set: function(newDefaultProps) {
|
||
error("React.lazy(...): It is not supported to assign `defaultProps` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it.");
|
||
defaultProps = newDefaultProps;
|
||
Object.defineProperty(lazyType, "defaultProps", {
|
||
enumerable: true
|
||
});
|
||
}
|
||
},
|
||
propTypes: {
|
||
configurable: true,
|
||
get: function() {
|
||
return propTypes;
|
||
},
|
||
set: function(newPropTypes) {
|
||
error("React.lazy(...): It is not supported to assign `propTypes` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it.");
|
||
propTypes = newPropTypes;
|
||
Object.defineProperty(lazyType, "propTypes", {
|
||
enumerable: true
|
||
});
|
||
}
|
||
}
|
||
});
|
||
}
|
||
return lazyType;
|
||
}
|
||
function forwardRef(render2) {
|
||
{
|
||
if (render2 != null && render2.$$typeof === REACT_MEMO_TYPE) {
|
||
error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...)).");
|
||
} else if (typeof render2 !== "function") {
|
||
error("forwardRef requires a render function but was given %s.", render2 === null ? "null" : typeof render2);
|
||
} else {
|
||
if (render2.length !== 0 && render2.length !== 2) {
|
||
error("forwardRef render functions accept exactly two parameters: props and ref. %s", render2.length === 1 ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined.");
|
||
}
|
||
}
|
||
if (render2 != null) {
|
||
if (render2.defaultProps != null || render2.propTypes != null) {
|
||
error("forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?");
|
||
}
|
||
}
|
||
}
|
||
var elementType = {
|
||
$$typeof: REACT_FORWARD_REF_TYPE,
|
||
render: render2
|
||
};
|
||
{
|
||
var ownName;
|
||
Object.defineProperty(elementType, "displayName", {
|
||
enumerable: false,
|
||
configurable: true,
|
||
get: function() {
|
||
return ownName;
|
||
},
|
||
set: function(name) {
|
||
ownName = name;
|
||
if (!render2.name && !render2.displayName) {
|
||
render2.displayName = name;
|
||
}
|
||
}
|
||
});
|
||
}
|
||
return elementType;
|
||
}
|
||
var REACT_MODULE_REFERENCE;
|
||
{
|
||
REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
|
||
}
|
||
function isValidElementType(type) {
|
||
if (typeof type === "string" || typeof type === "function") {
|
||
return true;
|
||
}
|
||
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
|
||
return true;
|
||
}
|
||
if (typeof type === "object" && type !== null) {
|
||
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
function memo(type, compare) {
|
||
{
|
||
if (!isValidElementType(type)) {
|
||
error("memo: The first argument must be a component. Instead received: %s", type === null ? "null" : typeof type);
|
||
}
|
||
}
|
||
var elementType = {
|
||
$$typeof: REACT_MEMO_TYPE,
|
||
type,
|
||
compare: compare === void 0 ? null : compare
|
||
};
|
||
{
|
||
var ownName;
|
||
Object.defineProperty(elementType, "displayName", {
|
||
enumerable: false,
|
||
configurable: true,
|
||
get: function() {
|
||
return ownName;
|
||
},
|
||
set: function(name) {
|
||
ownName = name;
|
||
if (!type.name && !type.displayName) {
|
||
type.displayName = name;
|
||
}
|
||
}
|
||
});
|
||
}
|
||
return elementType;
|
||
}
|
||
function resolveDispatcher() {
|
||
var dispatcher = ReactCurrentDispatcher.current;
|
||
{
|
||
if (dispatcher === null) {
|
||
error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.");
|
||
}
|
||
}
|
||
return dispatcher;
|
||
}
|
||
function useContext(Context) {
|
||
var dispatcher = resolveDispatcher();
|
||
{
|
||
if (Context._context !== void 0) {
|
||
var realContext = Context._context;
|
||
if (realContext.Consumer === Context) {
|
||
error("Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be removed in a future major release. Did you mean to call useContext(Context) instead?");
|
||
} else if (realContext.Provider === Context) {
|
||
error("Calling useContext(Context.Provider) is not supported. Did you mean to call useContext(Context) instead?");
|
||
}
|
||
}
|
||
}
|
||
return dispatcher.useContext(Context);
|
||
}
|
||
function useState2(initialState) {
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useState(initialState);
|
||
}
|
||
function useReducer(reducer, initialArg, init) {
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useReducer(reducer, initialArg, init);
|
||
}
|
||
function useRef(initialValue) {
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useRef(initialValue);
|
||
}
|
||
function useEffect(create, deps) {
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useEffect(create, deps);
|
||
}
|
||
function useInsertionEffect(create, deps) {
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useInsertionEffect(create, deps);
|
||
}
|
||
function useLayoutEffect(create, deps) {
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useLayoutEffect(create, deps);
|
||
}
|
||
function useCallback(callback, deps) {
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useCallback(callback, deps);
|
||
}
|
||
function useMemo(create, deps) {
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useMemo(create, deps);
|
||
}
|
||
function useImperativeHandle(ref, create, deps) {
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useImperativeHandle(ref, create, deps);
|
||
}
|
||
function useDebugValue(value, formatterFn) {
|
||
{
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useDebugValue(value, formatterFn);
|
||
}
|
||
}
|
||
function useTransition() {
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useTransition();
|
||
}
|
||
function useDeferredValue(value) {
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useDeferredValue(value);
|
||
}
|
||
function useId() {
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useId();
|
||
}
|
||
function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
|
||
var dispatcher = resolveDispatcher();
|
||
return dispatcher.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
||
}
|
||
var disabledDepth = 0;
|
||
var prevLog;
|
||
var prevInfo;
|
||
var prevWarn;
|
||
var prevError;
|
||
var prevGroup;
|
||
var prevGroupCollapsed;
|
||
var prevGroupEnd;
|
||
function disabledLog() {
|
||
}
|
||
disabledLog.__reactDisabledLog = true;
|
||
function disableLogs() {
|
||
{
|
||
if (disabledDepth === 0) {
|
||
prevLog = console.log;
|
||
prevInfo = console.info;
|
||
prevWarn = console.warn;
|
||
prevError = console.error;
|
||
prevGroup = console.group;
|
||
prevGroupCollapsed = console.groupCollapsed;
|
||
prevGroupEnd = console.groupEnd;
|
||
var props = {
|
||
configurable: true,
|
||
enumerable: true,
|
||
value: disabledLog,
|
||
writable: true
|
||
};
|
||
Object.defineProperties(console, {
|
||
info: props,
|
||
log: props,
|
||
warn: props,
|
||
error: props,
|
||
group: props,
|
||
groupCollapsed: props,
|
||
groupEnd: props
|
||
});
|
||
}
|
||
disabledDepth++;
|
||
}
|
||
}
|
||
function reenableLogs() {
|
||
{
|
||
disabledDepth--;
|
||
if (disabledDepth === 0) {
|
||
var props = {
|
||
configurable: true,
|
||
enumerable: true,
|
||
writable: true
|
||
};
|
||
Object.defineProperties(console, {
|
||
log: assign({}, props, {
|
||
value: prevLog
|
||
}),
|
||
info: assign({}, props, {
|
||
value: prevInfo
|
||
}),
|
||
warn: assign({}, props, {
|
||
value: prevWarn
|
||
}),
|
||
error: assign({}, props, {
|
||
value: prevError
|
||
}),
|
||
group: assign({}, props, {
|
||
value: prevGroup
|
||
}),
|
||
groupCollapsed: assign({}, props, {
|
||
value: prevGroupCollapsed
|
||
}),
|
||
groupEnd: assign({}, props, {
|
||
value: prevGroupEnd
|
||
})
|
||
});
|
||
}
|
||
if (disabledDepth < 0) {
|
||
error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
}
|
||
var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
|
||
var prefix;
|
||
function describeBuiltInComponentFrame(name, source, ownerFn) {
|
||
{
|
||
if (prefix === void 0) {
|
||
try {
|
||
throw Error();
|
||
} catch (x) {
|
||
var match = x.stack.trim().match(/\n( *(at )?)/);
|
||
prefix = match && match[1] || "";
|
||
}
|
||
}
|
||
return "\n" + prefix + name;
|
||
}
|
||
}
|
||
var reentry = false;
|
||
var componentFrameCache;
|
||
{
|
||
var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
|
||
componentFrameCache = new PossiblyWeakMap();
|
||
}
|
||
function describeNativeComponentFrame(fn, construct) {
|
||
if (!fn || reentry) {
|
||
return "";
|
||
}
|
||
{
|
||
var frame = componentFrameCache.get(fn);
|
||
if (frame !== void 0) {
|
||
return frame;
|
||
}
|
||
}
|
||
var control;
|
||
reentry = true;
|
||
var previousPrepareStackTrace = Error.prepareStackTrace;
|
||
Error.prepareStackTrace = void 0;
|
||
var previousDispatcher;
|
||
{
|
||
previousDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = null;
|
||
disableLogs();
|
||
}
|
||
try {
|
||
if (construct) {
|
||
var Fake = function() {
|
||
throw Error();
|
||
};
|
||
Object.defineProperty(Fake.prototype, "props", {
|
||
set: function() {
|
||
throw Error();
|
||
}
|
||
});
|
||
if (typeof Reflect === "object" && Reflect.construct) {
|
||
try {
|
||
Reflect.construct(Fake, []);
|
||
} catch (x) {
|
||
control = x;
|
||
}
|
||
Reflect.construct(fn, [], Fake);
|
||
} else {
|
||
try {
|
||
Fake.call();
|
||
} catch (x) {
|
||
control = x;
|
||
}
|
||
fn.call(Fake.prototype);
|
||
}
|
||
} else {
|
||
try {
|
||
throw Error();
|
||
} catch (x) {
|
||
control = x;
|
||
}
|
||
fn();
|
||
}
|
||
} catch (sample) {
|
||
if (sample && control && typeof sample.stack === "string") {
|
||
var sampleLines = sample.stack.split("\n");
|
||
var controlLines = control.stack.split("\n");
|
||
var s = sampleLines.length - 1;
|
||
var c = controlLines.length - 1;
|
||
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
|
||
c--;
|
||
}
|
||
for (; s >= 1 && c >= 0; s--, c--) {
|
||
if (sampleLines[s] !== controlLines[c]) {
|
||
if (s !== 1 || c !== 1) {
|
||
do {
|
||
s--;
|
||
c--;
|
||
if (c < 0 || sampleLines[s] !== controlLines[c]) {
|
||
var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
|
||
if (fn.displayName && _frame.includes("<anonymous>")) {
|
||
_frame = _frame.replace("<anonymous>", fn.displayName);
|
||
}
|
||
{
|
||
if (typeof fn === "function") {
|
||
componentFrameCache.set(fn, _frame);
|
||
}
|
||
}
|
||
return _frame;
|
||
}
|
||
} while (s >= 1 && c >= 0);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
} finally {
|
||
reentry = false;
|
||
{
|
||
ReactCurrentDispatcher$1.current = previousDispatcher;
|
||
reenableLogs();
|
||
}
|
||
Error.prepareStackTrace = previousPrepareStackTrace;
|
||
}
|
||
var name = fn ? fn.displayName || fn.name : "";
|
||
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
|
||
{
|
||
if (typeof fn === "function") {
|
||
componentFrameCache.set(fn, syntheticFrame);
|
||
}
|
||
}
|
||
return syntheticFrame;
|
||
}
|
||
function describeFunctionComponentFrame(fn, source, ownerFn) {
|
||
{
|
||
return describeNativeComponentFrame(fn, false);
|
||
}
|
||
}
|
||
function shouldConstruct(Component2) {
|
||
var prototype = Component2.prototype;
|
||
return !!(prototype && prototype.isReactComponent);
|
||
}
|
||
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
||
if (type == null) {
|
||
return "";
|
||
}
|
||
if (typeof type === "function") {
|
||
{
|
||
return describeNativeComponentFrame(type, shouldConstruct(type));
|
||
}
|
||
}
|
||
if (typeof type === "string") {
|
||
return describeBuiltInComponentFrame(type);
|
||
}
|
||
switch (type) {
|
||
case REACT_SUSPENSE_TYPE:
|
||
return describeBuiltInComponentFrame("Suspense");
|
||
case REACT_SUSPENSE_LIST_TYPE:
|
||
return describeBuiltInComponentFrame("SuspenseList");
|
||
}
|
||
if (typeof type === "object") {
|
||
switch (type.$$typeof) {
|
||
case REACT_FORWARD_REF_TYPE:
|
||
return describeFunctionComponentFrame(type.render);
|
||
case REACT_MEMO_TYPE:
|
||
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
||
case REACT_LAZY_TYPE: {
|
||
var lazyComponent = type;
|
||
var payload = lazyComponent._payload;
|
||
var init = lazyComponent._init;
|
||
try {
|
||
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
||
} catch (x) {
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
var loggedTypeFailures = {};
|
||
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
||
function setCurrentlyValidatingElement(element) {
|
||
{
|
||
if (element) {
|
||
var owner = element._owner;
|
||
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
||
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
||
} else {
|
||
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
||
}
|
||
}
|
||
}
|
||
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
||
{
|
||
var has = Function.call.bind(hasOwnProperty2);
|
||
for (var typeSpecName in typeSpecs) {
|
||
if (has(typeSpecs, typeSpecName)) {
|
||
var error$1 = void 0;
|
||
try {
|
||
if (typeof typeSpecs[typeSpecName] !== "function") {
|
||
var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
||
err.name = "Invariant Violation";
|
||
throw err;
|
||
}
|
||
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
||
} catch (ex) {
|
||
error$1 = ex;
|
||
}
|
||
if (error$1 && !(error$1 instanceof Error)) {
|
||
setCurrentlyValidatingElement(element);
|
||
error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
|
||
setCurrentlyValidatingElement(null);
|
||
}
|
||
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
||
loggedTypeFailures[error$1.message] = true;
|
||
setCurrentlyValidatingElement(element);
|
||
error("Failed %s type: %s", location, error$1.message);
|
||
setCurrentlyValidatingElement(null);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function setCurrentlyValidatingElement$1(element) {
|
||
{
|
||
if (element) {
|
||
var owner = element._owner;
|
||
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
||
setExtraStackFrame(stack);
|
||
} else {
|
||
setExtraStackFrame(null);
|
||
}
|
||
}
|
||
}
|
||
var propTypesMisspellWarningShown;
|
||
{
|
||
propTypesMisspellWarningShown = false;
|
||
}
|
||
function getDeclarationErrorAddendum() {
|
||
if (ReactCurrentOwner.current) {
|
||
var name = getComponentNameFromType(ReactCurrentOwner.current.type);
|
||
if (name) {
|
||
return "\n\nCheck the render method of `" + name + "`.";
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
function getSourceInfoErrorAddendum(source) {
|
||
if (source !== void 0) {
|
||
var fileName = source.fileName.replace(/^.*[\\\/]/, "");
|
||
var lineNumber = source.lineNumber;
|
||
return "\n\nCheck your code at " + fileName + ":" + lineNumber + ".";
|
||
}
|
||
return "";
|
||
}
|
||
function getSourceInfoErrorAddendumForProps(elementProps) {
|
||
if (elementProps !== null && elementProps !== void 0) {
|
||
return getSourceInfoErrorAddendum(elementProps.__source);
|
||
}
|
||
return "";
|
||
}
|
||
var ownerHasKeyUseWarning = {};
|
||
function getCurrentComponentErrorInfo(parentType) {
|
||
var info = getDeclarationErrorAddendum();
|
||
if (!info) {
|
||
var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
|
||
if (parentName) {
|
||
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
||
}
|
||
}
|
||
return info;
|
||
}
|
||
function validateExplicitKey(element, parentType) {
|
||
if (!element._store || element._store.validated || element.key != null) {
|
||
return;
|
||
}
|
||
element._store.validated = true;
|
||
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
||
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
||
return;
|
||
}
|
||
ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
||
var childOwner = "";
|
||
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
||
childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
|
||
}
|
||
{
|
||
setCurrentlyValidatingElement$1(element);
|
||
error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
||
setCurrentlyValidatingElement$1(null);
|
||
}
|
||
}
|
||
function validateChildKeys(node, parentType) {
|
||
if (typeof node !== "object") {
|
||
return;
|
||
}
|
||
if (isArray(node)) {
|
||
for (var i = 0; i < node.length; i++) {
|
||
var child = node[i];
|
||
if (isValidElement(child)) {
|
||
validateExplicitKey(child, parentType);
|
||
}
|
||
}
|
||
} else if (isValidElement(node)) {
|
||
if (node._store) {
|
||
node._store.validated = true;
|
||
}
|
||
} else if (node) {
|
||
var iteratorFn = getIteratorFn(node);
|
||
if (typeof iteratorFn === "function") {
|
||
if (iteratorFn !== node.entries) {
|
||
var iterator = iteratorFn.call(node);
|
||
var step;
|
||
while (!(step = iterator.next()).done) {
|
||
if (isValidElement(step.value)) {
|
||
validateExplicitKey(step.value, parentType);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function validatePropTypes(element) {
|
||
{
|
||
var type = element.type;
|
||
if (type === null || type === void 0 || typeof type === "string") {
|
||
return;
|
||
}
|
||
var propTypes;
|
||
if (typeof type === "function") {
|
||
propTypes = type.propTypes;
|
||
} else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_MEMO_TYPE)) {
|
||
propTypes = type.propTypes;
|
||
} else {
|
||
return;
|
||
}
|
||
if (propTypes) {
|
||
var name = getComponentNameFromType(type);
|
||
checkPropTypes(propTypes, element.props, "prop", name, element);
|
||
} else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
|
||
propTypesMisspellWarningShown = true;
|
||
var _name = getComponentNameFromType(type);
|
||
error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
|
||
}
|
||
if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
|
||
error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
||
}
|
||
}
|
||
}
|
||
function validateFragmentProps(fragment) {
|
||
{
|
||
var keys = Object.keys(fragment.props);
|
||
for (var i = 0; i < keys.length; i++) {
|
||
var key = keys[i];
|
||
if (key !== "children" && key !== "key") {
|
||
setCurrentlyValidatingElement$1(fragment);
|
||
error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
|
||
setCurrentlyValidatingElement$1(null);
|
||
break;
|
||
}
|
||
}
|
||
if (fragment.ref !== null) {
|
||
setCurrentlyValidatingElement$1(fragment);
|
||
error("Invalid attribute `ref` supplied to `React.Fragment`.");
|
||
setCurrentlyValidatingElement$1(null);
|
||
}
|
||
}
|
||
}
|
||
function createElementWithValidation(type, props, children) {
|
||
var validType = isValidElementType(type);
|
||
if (!validType) {
|
||
var info = "";
|
||
if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
|
||
info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
|
||
}
|
||
var sourceInfo = getSourceInfoErrorAddendumForProps(props);
|
||
if (sourceInfo) {
|
||
info += sourceInfo;
|
||
} else {
|
||
info += getDeclarationErrorAddendum();
|
||
}
|
||
var typeString;
|
||
if (type === null) {
|
||
typeString = "null";
|
||
} else if (isArray(type)) {
|
||
typeString = "array";
|
||
} else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
|
||
typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
|
||
info = " Did you accidentally export a JSX literal instead of a component?";
|
||
} else {
|
||
typeString = typeof type;
|
||
}
|
||
{
|
||
error("React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
|
||
}
|
||
}
|
||
var element = createElement2.apply(this, arguments);
|
||
if (element == null) {
|
||
return element;
|
||
}
|
||
if (validType) {
|
||
for (var i = 2; i < arguments.length; i++) {
|
||
validateChildKeys(arguments[i], type);
|
||
}
|
||
}
|
||
if (type === REACT_FRAGMENT_TYPE) {
|
||
validateFragmentProps(element);
|
||
} else {
|
||
validatePropTypes(element);
|
||
}
|
||
return element;
|
||
}
|
||
var didWarnAboutDeprecatedCreateFactory = false;
|
||
function createFactoryWithValidation(type) {
|
||
var validatedFactory = createElementWithValidation.bind(null, type);
|
||
validatedFactory.type = type;
|
||
{
|
||
if (!didWarnAboutDeprecatedCreateFactory) {
|
||
didWarnAboutDeprecatedCreateFactory = true;
|
||
warn("React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.");
|
||
}
|
||
Object.defineProperty(validatedFactory, "type", {
|
||
enumerable: false,
|
||
get: function() {
|
||
warn("Factory.type is deprecated. Access the class directly before passing it to createFactory.");
|
||
Object.defineProperty(this, "type", {
|
||
value: type
|
||
});
|
||
return type;
|
||
}
|
||
});
|
||
}
|
||
return validatedFactory;
|
||
}
|
||
function cloneElementWithValidation(element, props, children) {
|
||
var newElement = cloneElement.apply(this, arguments);
|
||
for (var i = 2; i < arguments.length; i++) {
|
||
validateChildKeys(arguments[i], newElement.type);
|
||
}
|
||
validatePropTypes(newElement);
|
||
return newElement;
|
||
}
|
||
function startTransition(scope, options) {
|
||
var prevTransition = ReactCurrentBatchConfig.transition;
|
||
ReactCurrentBatchConfig.transition = {};
|
||
var currentTransition = ReactCurrentBatchConfig.transition;
|
||
{
|
||
ReactCurrentBatchConfig.transition._updatedFibers = /* @__PURE__ */ new Set();
|
||
}
|
||
try {
|
||
scope();
|
||
} finally {
|
||
ReactCurrentBatchConfig.transition = prevTransition;
|
||
{
|
||
if (prevTransition === null && currentTransition._updatedFibers) {
|
||
var updatedFibersCount = currentTransition._updatedFibers.size;
|
||
if (updatedFibersCount > 10) {
|
||
warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.");
|
||
}
|
||
currentTransition._updatedFibers.clear();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var didWarnAboutMessageChannel = false;
|
||
var enqueueTaskImpl = null;
|
||
function enqueueTask(task) {
|
||
if (enqueueTaskImpl === null) {
|
||
try {
|
||
var requireString = ("require" + Math.random()).slice(0, 7);
|
||
var nodeRequire = module2 && module2[requireString];
|
||
enqueueTaskImpl = nodeRequire.call(module2, "timers").setImmediate;
|
||
} catch (_err) {
|
||
enqueueTaskImpl = function(callback) {
|
||
{
|
||
if (didWarnAboutMessageChannel === false) {
|
||
didWarnAboutMessageChannel = true;
|
||
if (typeof MessageChannel === "undefined") {
|
||
error("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning.");
|
||
}
|
||
}
|
||
}
|
||
var channel = new MessageChannel();
|
||
channel.port1.onmessage = callback;
|
||
channel.port2.postMessage(void 0);
|
||
};
|
||
}
|
||
}
|
||
return enqueueTaskImpl(task);
|
||
}
|
||
var actScopeDepth = 0;
|
||
var didWarnNoAwaitAct = false;
|
||
function act(callback) {
|
||
{
|
||
var prevActScopeDepth = actScopeDepth;
|
||
actScopeDepth++;
|
||
if (ReactCurrentActQueue.current === null) {
|
||
ReactCurrentActQueue.current = [];
|
||
}
|
||
var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy;
|
||
var result;
|
||
try {
|
||
ReactCurrentActQueue.isBatchingLegacy = true;
|
||
result = callback();
|
||
if (!prevIsBatchingLegacy && ReactCurrentActQueue.didScheduleLegacyUpdate) {
|
||
var queue = ReactCurrentActQueue.current;
|
||
if (queue !== null) {
|
||
ReactCurrentActQueue.didScheduleLegacyUpdate = false;
|
||
flushActQueue(queue);
|
||
}
|
||
}
|
||
} catch (error2) {
|
||
popActScope(prevActScopeDepth);
|
||
throw error2;
|
||
} finally {
|
||
ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
|
||
}
|
||
if (result !== null && typeof result === "object" && typeof result.then === "function") {
|
||
var thenableResult = result;
|
||
var wasAwaited = false;
|
||
var thenable = {
|
||
then: function(resolve, reject) {
|
||
wasAwaited = true;
|
||
thenableResult.then(function(returnValue2) {
|
||
popActScope(prevActScopeDepth);
|
||
if (actScopeDepth === 0) {
|
||
recursivelyFlushAsyncActWork(returnValue2, resolve, reject);
|
||
} else {
|
||
resolve(returnValue2);
|
||
}
|
||
}, function(error2) {
|
||
popActScope(prevActScopeDepth);
|
||
reject(error2);
|
||
});
|
||
}
|
||
};
|
||
{
|
||
if (!didWarnNoAwaitAct && typeof Promise !== "undefined") {
|
||
Promise.resolve().then(function() {
|
||
}).then(function() {
|
||
if (!wasAwaited) {
|
||
didWarnNoAwaitAct = true;
|
||
error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);");
|
||
}
|
||
});
|
||
}
|
||
}
|
||
return thenable;
|
||
} else {
|
||
var returnValue = result;
|
||
popActScope(prevActScopeDepth);
|
||
if (actScopeDepth === 0) {
|
||
var _queue = ReactCurrentActQueue.current;
|
||
if (_queue !== null) {
|
||
flushActQueue(_queue);
|
||
ReactCurrentActQueue.current = null;
|
||
}
|
||
var _thenable = {
|
||
then: function(resolve, reject) {
|
||
if (ReactCurrentActQueue.current === null) {
|
||
ReactCurrentActQueue.current = [];
|
||
recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
||
} else {
|
||
resolve(returnValue);
|
||
}
|
||
}
|
||
};
|
||
return _thenable;
|
||
} else {
|
||
var _thenable2 = {
|
||
then: function(resolve, reject) {
|
||
resolve(returnValue);
|
||
}
|
||
};
|
||
return _thenable2;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function popActScope(prevActScopeDepth) {
|
||
{
|
||
if (prevActScopeDepth !== actScopeDepth - 1) {
|
||
error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. ");
|
||
}
|
||
actScopeDepth = prevActScopeDepth;
|
||
}
|
||
}
|
||
function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
|
||
{
|
||
var queue = ReactCurrentActQueue.current;
|
||
if (queue !== null) {
|
||
try {
|
||
flushActQueue(queue);
|
||
enqueueTask(function() {
|
||
if (queue.length === 0) {
|
||
ReactCurrentActQueue.current = null;
|
||
resolve(returnValue);
|
||
} else {
|
||
recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
||
}
|
||
});
|
||
} catch (error2) {
|
||
reject(error2);
|
||
}
|
||
} else {
|
||
resolve(returnValue);
|
||
}
|
||
}
|
||
}
|
||
var isFlushing = false;
|
||
function flushActQueue(queue) {
|
||
{
|
||
if (!isFlushing) {
|
||
isFlushing = true;
|
||
var i = 0;
|
||
try {
|
||
for (; i < queue.length; i++) {
|
||
var callback = queue[i];
|
||
do {
|
||
callback = callback(true);
|
||
} while (callback !== null);
|
||
}
|
||
queue.length = 0;
|
||
} catch (error2) {
|
||
queue = queue.slice(i + 1);
|
||
throw error2;
|
||
} finally {
|
||
isFlushing = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var createElement$1 = createElementWithValidation;
|
||
var cloneElement$1 = cloneElementWithValidation;
|
||
var createFactory = createFactoryWithValidation;
|
||
var Children = {
|
||
map: mapChildren,
|
||
forEach: forEachChildren,
|
||
count: countChildren,
|
||
toArray,
|
||
only: onlyChild
|
||
};
|
||
exports.Children = Children;
|
||
exports.Component = Component;
|
||
exports.Fragment = REACT_FRAGMENT_TYPE;
|
||
exports.Profiler = REACT_PROFILER_TYPE;
|
||
exports.PureComponent = PureComponent;
|
||
exports.StrictMode = REACT_STRICT_MODE_TYPE;
|
||
exports.Suspense = REACT_SUSPENSE_TYPE;
|
||
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals;
|
||
exports.cloneElement = cloneElement$1;
|
||
exports.createContext = createContext;
|
||
exports.createElement = createElement$1;
|
||
exports.createFactory = createFactory;
|
||
exports.createRef = createRef;
|
||
exports.forwardRef = forwardRef;
|
||
exports.isValidElement = isValidElement;
|
||
exports.lazy = lazy;
|
||
exports.memo = memo;
|
||
exports.startTransition = startTransition;
|
||
exports.unstable_act = act;
|
||
exports.useCallback = useCallback;
|
||
exports.useContext = useContext;
|
||
exports.useDebugValue = useDebugValue;
|
||
exports.useDeferredValue = useDeferredValue;
|
||
exports.useEffect = useEffect;
|
||
exports.useId = useId;
|
||
exports.useImperativeHandle = useImperativeHandle;
|
||
exports.useInsertionEffect = useInsertionEffect;
|
||
exports.useLayoutEffect = useLayoutEffect;
|
||
exports.useMemo = useMemo;
|
||
exports.useReducer = useReducer;
|
||
exports.useRef = useRef;
|
||
exports.useState = useState2;
|
||
exports.useSyncExternalStore = useSyncExternalStore;
|
||
exports.useTransition = useTransition;
|
||
exports.version = ReactVersion;
|
||
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
|
||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
||
}
|
||
})();
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/react/index.js
|
||
var require_react = __commonJS({
|
||
"node_modules/react/index.js"(exports, module2) {
|
||
"use strict";
|
||
if (false) {
|
||
module2.exports = null;
|
||
} else {
|
||
module2.exports = require_react_development();
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/scheduler/cjs/scheduler.development.js
|
||
var require_scheduler_development = __commonJS({
|
||
"node_modules/scheduler/cjs/scheduler.development.js"(exports) {
|
||
"use strict";
|
||
if (true) {
|
||
(function() {
|
||
"use strict";
|
||
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
||
}
|
||
var enableSchedulerDebugging = false;
|
||
var enableProfiling = false;
|
||
var frameYieldMs = 5;
|
||
function push(heap, node) {
|
||
var index = heap.length;
|
||
heap.push(node);
|
||
siftUp(heap, node, index);
|
||
}
|
||
function peek(heap) {
|
||
return heap.length === 0 ? null : heap[0];
|
||
}
|
||
function pop(heap) {
|
||
if (heap.length === 0) {
|
||
return null;
|
||
}
|
||
var first = heap[0];
|
||
var last = heap.pop();
|
||
if (last !== first) {
|
||
heap[0] = last;
|
||
siftDown(heap, last, 0);
|
||
}
|
||
return first;
|
||
}
|
||
function siftUp(heap, node, i) {
|
||
var index = i;
|
||
while (index > 0) {
|
||
var parentIndex = index - 1 >>> 1;
|
||
var parent2 = heap[parentIndex];
|
||
if (compare(parent2, node) > 0) {
|
||
heap[parentIndex] = node;
|
||
heap[index] = parent2;
|
||
index = parentIndex;
|
||
} else {
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
function siftDown(heap, node, i) {
|
||
var index = i;
|
||
var length = heap.length;
|
||
var halfLength = length >>> 1;
|
||
while (index < halfLength) {
|
||
var leftIndex = (index + 1) * 2 - 1;
|
||
var left = heap[leftIndex];
|
||
var rightIndex = leftIndex + 1;
|
||
var right = heap[rightIndex];
|
||
if (compare(left, node) < 0) {
|
||
if (rightIndex < length && compare(right, left) < 0) {
|
||
heap[index] = right;
|
||
heap[rightIndex] = node;
|
||
index = rightIndex;
|
||
} else {
|
||
heap[index] = left;
|
||
heap[leftIndex] = node;
|
||
index = leftIndex;
|
||
}
|
||
} else if (rightIndex < length && compare(right, node) < 0) {
|
||
heap[index] = right;
|
||
heap[rightIndex] = node;
|
||
index = rightIndex;
|
||
} else {
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
function compare(a, b) {
|
||
var diff = a.sortIndex - b.sortIndex;
|
||
return diff !== 0 ? diff : a.id - b.id;
|
||
}
|
||
var ImmediatePriority = 1;
|
||
var UserBlockingPriority = 2;
|
||
var NormalPriority = 3;
|
||
var LowPriority = 4;
|
||
var IdlePriority = 5;
|
||
function markTaskErrored(task, ms) {
|
||
}
|
||
var hasPerformanceNow = typeof performance === "object" && typeof performance.now === "function";
|
||
if (hasPerformanceNow) {
|
||
var localPerformance = performance;
|
||
exports.unstable_now = function() {
|
||
return localPerformance.now();
|
||
};
|
||
} else {
|
||
var localDate = Date;
|
||
var initialTime = localDate.now();
|
||
exports.unstable_now = function() {
|
||
return localDate.now() - initialTime;
|
||
};
|
||
}
|
||
var maxSigned31BitInt = 1073741823;
|
||
var IMMEDIATE_PRIORITY_TIMEOUT = -1;
|
||
var USER_BLOCKING_PRIORITY_TIMEOUT = 250;
|
||
var NORMAL_PRIORITY_TIMEOUT = 5e3;
|
||
var LOW_PRIORITY_TIMEOUT = 1e4;
|
||
var IDLE_PRIORITY_TIMEOUT = maxSigned31BitInt;
|
||
var taskQueue = [];
|
||
var timerQueue = [];
|
||
var taskIdCounter = 1;
|
||
var currentTask = null;
|
||
var currentPriorityLevel = NormalPriority;
|
||
var isPerformingWork = false;
|
||
var isHostCallbackScheduled = false;
|
||
var isHostTimeoutScheduled = false;
|
||
var localSetTimeout = typeof setTimeout === "function" ? setTimeout : null;
|
||
var localClearTimeout = typeof clearTimeout === "function" ? clearTimeout : null;
|
||
var localSetImmediate = typeof setImmediate !== "undefined" ? setImmediate : null;
|
||
var isInputPending = typeof navigator !== "undefined" && navigator.scheduling !== void 0 && navigator.scheduling.isInputPending !== void 0 ? navigator.scheduling.isInputPending.bind(navigator.scheduling) : null;
|
||
function advanceTimers(currentTime) {
|
||
var timer = peek(timerQueue);
|
||
while (timer !== null) {
|
||
if (timer.callback === null) {
|
||
pop(timerQueue);
|
||
} else if (timer.startTime <= currentTime) {
|
||
pop(timerQueue);
|
||
timer.sortIndex = timer.expirationTime;
|
||
push(taskQueue, timer);
|
||
} else {
|
||
return;
|
||
}
|
||
timer = peek(timerQueue);
|
||
}
|
||
}
|
||
function handleTimeout(currentTime) {
|
||
isHostTimeoutScheduled = false;
|
||
advanceTimers(currentTime);
|
||
if (!isHostCallbackScheduled) {
|
||
if (peek(taskQueue) !== null) {
|
||
isHostCallbackScheduled = true;
|
||
requestHostCallback(flushWork);
|
||
} else {
|
||
var firstTimer = peek(timerQueue);
|
||
if (firstTimer !== null) {
|
||
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function flushWork(hasTimeRemaining, initialTime2) {
|
||
isHostCallbackScheduled = false;
|
||
if (isHostTimeoutScheduled) {
|
||
isHostTimeoutScheduled = false;
|
||
cancelHostTimeout();
|
||
}
|
||
isPerformingWork = true;
|
||
var previousPriorityLevel = currentPriorityLevel;
|
||
try {
|
||
if (enableProfiling) {
|
||
try {
|
||
return workLoop(hasTimeRemaining, initialTime2);
|
||
} catch (error) {
|
||
if (currentTask !== null) {
|
||
var currentTime = exports.unstable_now();
|
||
markTaskErrored(currentTask, currentTime);
|
||
currentTask.isQueued = false;
|
||
}
|
||
throw error;
|
||
}
|
||
} else {
|
||
return workLoop(hasTimeRemaining, initialTime2);
|
||
}
|
||
} finally {
|
||
currentTask = null;
|
||
currentPriorityLevel = previousPriorityLevel;
|
||
isPerformingWork = false;
|
||
}
|
||
}
|
||
function workLoop(hasTimeRemaining, initialTime2) {
|
||
var currentTime = initialTime2;
|
||
advanceTimers(currentTime);
|
||
currentTask = peek(taskQueue);
|
||
while (currentTask !== null && !enableSchedulerDebugging) {
|
||
if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) {
|
||
break;
|
||
}
|
||
var callback = currentTask.callback;
|
||
if (typeof callback === "function") {
|
||
currentTask.callback = null;
|
||
currentPriorityLevel = currentTask.priorityLevel;
|
||
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
|
||
var continuationCallback = callback(didUserCallbackTimeout);
|
||
currentTime = exports.unstable_now();
|
||
if (typeof continuationCallback === "function") {
|
||
currentTask.callback = continuationCallback;
|
||
} else {
|
||
if (currentTask === peek(taskQueue)) {
|
||
pop(taskQueue);
|
||
}
|
||
}
|
||
advanceTimers(currentTime);
|
||
} else {
|
||
pop(taskQueue);
|
||
}
|
||
currentTask = peek(taskQueue);
|
||
}
|
||
if (currentTask !== null) {
|
||
return true;
|
||
} else {
|
||
var firstTimer = peek(timerQueue);
|
||
if (firstTimer !== null) {
|
||
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
function unstable_runWithPriority(priorityLevel, eventHandler) {
|
||
switch (priorityLevel) {
|
||
case ImmediatePriority:
|
||
case UserBlockingPriority:
|
||
case NormalPriority:
|
||
case LowPriority:
|
||
case IdlePriority:
|
||
break;
|
||
default:
|
||
priorityLevel = NormalPriority;
|
||
}
|
||
var previousPriorityLevel = currentPriorityLevel;
|
||
currentPriorityLevel = priorityLevel;
|
||
try {
|
||
return eventHandler();
|
||
} finally {
|
||
currentPriorityLevel = previousPriorityLevel;
|
||
}
|
||
}
|
||
function unstable_next(eventHandler) {
|
||
var priorityLevel;
|
||
switch (currentPriorityLevel) {
|
||
case ImmediatePriority:
|
||
case UserBlockingPriority:
|
||
case NormalPriority:
|
||
priorityLevel = NormalPriority;
|
||
break;
|
||
default:
|
||
priorityLevel = currentPriorityLevel;
|
||
break;
|
||
}
|
||
var previousPriorityLevel = currentPriorityLevel;
|
||
currentPriorityLevel = priorityLevel;
|
||
try {
|
||
return eventHandler();
|
||
} finally {
|
||
currentPriorityLevel = previousPriorityLevel;
|
||
}
|
||
}
|
||
function unstable_wrapCallback(callback) {
|
||
var parentPriorityLevel = currentPriorityLevel;
|
||
return function() {
|
||
var previousPriorityLevel = currentPriorityLevel;
|
||
currentPriorityLevel = parentPriorityLevel;
|
||
try {
|
||
return callback.apply(this, arguments);
|
||
} finally {
|
||
currentPriorityLevel = previousPriorityLevel;
|
||
}
|
||
};
|
||
}
|
||
function unstable_scheduleCallback(priorityLevel, callback, options) {
|
||
var currentTime = exports.unstable_now();
|
||
var startTime2;
|
||
if (typeof options === "object" && options !== null) {
|
||
var delay = options.delay;
|
||
if (typeof delay === "number" && delay > 0) {
|
||
startTime2 = currentTime + delay;
|
||
} else {
|
||
startTime2 = currentTime;
|
||
}
|
||
} else {
|
||
startTime2 = currentTime;
|
||
}
|
||
var timeout;
|
||
switch (priorityLevel) {
|
||
case ImmediatePriority:
|
||
timeout = IMMEDIATE_PRIORITY_TIMEOUT;
|
||
break;
|
||
case UserBlockingPriority:
|
||
timeout = USER_BLOCKING_PRIORITY_TIMEOUT;
|
||
break;
|
||
case IdlePriority:
|
||
timeout = IDLE_PRIORITY_TIMEOUT;
|
||
break;
|
||
case LowPriority:
|
||
timeout = LOW_PRIORITY_TIMEOUT;
|
||
break;
|
||
case NormalPriority:
|
||
default:
|
||
timeout = NORMAL_PRIORITY_TIMEOUT;
|
||
break;
|
||
}
|
||
var expirationTime = startTime2 + timeout;
|
||
var newTask = {
|
||
id: taskIdCounter++,
|
||
callback,
|
||
priorityLevel,
|
||
startTime: startTime2,
|
||
expirationTime,
|
||
sortIndex: -1
|
||
};
|
||
if (startTime2 > currentTime) {
|
||
newTask.sortIndex = startTime2;
|
||
push(timerQueue, newTask);
|
||
if (peek(taskQueue) === null && newTask === peek(timerQueue)) {
|
||
if (isHostTimeoutScheduled) {
|
||
cancelHostTimeout();
|
||
} else {
|
||
isHostTimeoutScheduled = true;
|
||
}
|
||
requestHostTimeout(handleTimeout, startTime2 - currentTime);
|
||
}
|
||
} else {
|
||
newTask.sortIndex = expirationTime;
|
||
push(taskQueue, newTask);
|
||
if (!isHostCallbackScheduled && !isPerformingWork) {
|
||
isHostCallbackScheduled = true;
|
||
requestHostCallback(flushWork);
|
||
}
|
||
}
|
||
return newTask;
|
||
}
|
||
function unstable_pauseExecution() {
|
||
}
|
||
function unstable_continueExecution() {
|
||
if (!isHostCallbackScheduled && !isPerformingWork) {
|
||
isHostCallbackScheduled = true;
|
||
requestHostCallback(flushWork);
|
||
}
|
||
}
|
||
function unstable_getFirstCallbackNode() {
|
||
return peek(taskQueue);
|
||
}
|
||
function unstable_cancelCallback(task) {
|
||
task.callback = null;
|
||
}
|
||
function unstable_getCurrentPriorityLevel() {
|
||
return currentPriorityLevel;
|
||
}
|
||
var isMessageLoopRunning = false;
|
||
var scheduledHostCallback = null;
|
||
var taskTimeoutID = -1;
|
||
var frameInterval = frameYieldMs;
|
||
var startTime = -1;
|
||
function shouldYieldToHost() {
|
||
var timeElapsed = exports.unstable_now() - startTime;
|
||
if (timeElapsed < frameInterval) {
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
function requestPaint() {
|
||
}
|
||
function forceFrameRate(fps) {
|
||
if (fps < 0 || fps > 125) {
|
||
console["error"]("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported");
|
||
return;
|
||
}
|
||
if (fps > 0) {
|
||
frameInterval = Math.floor(1e3 / fps);
|
||
} else {
|
||
frameInterval = frameYieldMs;
|
||
}
|
||
}
|
||
var performWorkUntilDeadline = function() {
|
||
if (scheduledHostCallback !== null) {
|
||
var currentTime = exports.unstable_now();
|
||
startTime = currentTime;
|
||
var hasTimeRemaining = true;
|
||
var hasMoreWork = true;
|
||
try {
|
||
hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
|
||
} finally {
|
||
if (hasMoreWork) {
|
||
schedulePerformWorkUntilDeadline();
|
||
} else {
|
||
isMessageLoopRunning = false;
|
||
scheduledHostCallback = null;
|
||
}
|
||
}
|
||
} else {
|
||
isMessageLoopRunning = false;
|
||
}
|
||
};
|
||
var schedulePerformWorkUntilDeadline;
|
||
if (typeof localSetImmediate === "function") {
|
||
schedulePerformWorkUntilDeadline = function() {
|
||
localSetImmediate(performWorkUntilDeadline);
|
||
};
|
||
} else if (typeof MessageChannel !== "undefined") {
|
||
var channel = new MessageChannel();
|
||
var port = channel.port2;
|
||
channel.port1.onmessage = performWorkUntilDeadline;
|
||
schedulePerformWorkUntilDeadline = function() {
|
||
port.postMessage(null);
|
||
};
|
||
} else {
|
||
schedulePerformWorkUntilDeadline = function() {
|
||
localSetTimeout(performWorkUntilDeadline, 0);
|
||
};
|
||
}
|
||
function requestHostCallback(callback) {
|
||
scheduledHostCallback = callback;
|
||
if (!isMessageLoopRunning) {
|
||
isMessageLoopRunning = true;
|
||
schedulePerformWorkUntilDeadline();
|
||
}
|
||
}
|
||
function requestHostTimeout(callback, ms) {
|
||
taskTimeoutID = localSetTimeout(function() {
|
||
callback(exports.unstable_now());
|
||
}, ms);
|
||
}
|
||
function cancelHostTimeout() {
|
||
localClearTimeout(taskTimeoutID);
|
||
taskTimeoutID = -1;
|
||
}
|
||
var unstable_requestPaint = requestPaint;
|
||
var unstable_Profiling = null;
|
||
exports.unstable_IdlePriority = IdlePriority;
|
||
exports.unstable_ImmediatePriority = ImmediatePriority;
|
||
exports.unstable_LowPriority = LowPriority;
|
||
exports.unstable_NormalPriority = NormalPriority;
|
||
exports.unstable_Profiling = unstable_Profiling;
|
||
exports.unstable_UserBlockingPriority = UserBlockingPriority;
|
||
exports.unstable_cancelCallback = unstable_cancelCallback;
|
||
exports.unstable_continueExecution = unstable_continueExecution;
|
||
exports.unstable_forceFrameRate = forceFrameRate;
|
||
exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel;
|
||
exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode;
|
||
exports.unstable_next = unstable_next;
|
||
exports.unstable_pauseExecution = unstable_pauseExecution;
|
||
exports.unstable_requestPaint = unstable_requestPaint;
|
||
exports.unstable_runWithPriority = unstable_runWithPriority;
|
||
exports.unstable_scheduleCallback = unstable_scheduleCallback;
|
||
exports.unstable_shouldYield = shouldYieldToHost;
|
||
exports.unstable_wrapCallback = unstable_wrapCallback;
|
||
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
|
||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
||
}
|
||
})();
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/scheduler/index.js
|
||
var require_scheduler = __commonJS({
|
||
"node_modules/scheduler/index.js"(exports, module2) {
|
||
"use strict";
|
||
if (false) {
|
||
module2.exports = null;
|
||
} else {
|
||
module2.exports = require_scheduler_development();
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/react-dom/cjs/react-dom.development.js
|
||
var require_react_dom_development = __commonJS({
|
||
"node_modules/react-dom/cjs/react-dom.development.js"(exports) {
|
||
"use strict";
|
||
if (true) {
|
||
(function() {
|
||
"use strict";
|
||
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
||
}
|
||
var React2 = require_react();
|
||
var Scheduler = require_scheduler();
|
||
var ReactSharedInternals = React2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
||
var suppressWarning = false;
|
||
function setSuppressWarning(newSuppressWarning) {
|
||
{
|
||
suppressWarning = newSuppressWarning;
|
||
}
|
||
}
|
||
function warn(format) {
|
||
{
|
||
if (!suppressWarning) {
|
||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||
args[_key - 1] = arguments[_key];
|
||
}
|
||
printWarning("warn", format, args);
|
||
}
|
||
}
|
||
}
|
||
function error(format) {
|
||
{
|
||
if (!suppressWarning) {
|
||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||
args[_key2 - 1] = arguments[_key2];
|
||
}
|
||
printWarning("error", format, args);
|
||
}
|
||
}
|
||
}
|
||
function printWarning(level, format, args) {
|
||
{
|
||
var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
|
||
var stack = ReactDebugCurrentFrame2.getStackAddendum();
|
||
if (stack !== "") {
|
||
format += "%s";
|
||
args = args.concat([stack]);
|
||
}
|
||
var argsWithFormat = args.map(function(item) {
|
||
return String(item);
|
||
});
|
||
argsWithFormat.unshift("Warning: " + format);
|
||
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
||
}
|
||
}
|
||
var FunctionComponent = 0;
|
||
var ClassComponent = 1;
|
||
var IndeterminateComponent = 2;
|
||
var HostRoot = 3;
|
||
var HostPortal = 4;
|
||
var HostComponent = 5;
|
||
var HostText = 6;
|
||
var Fragment = 7;
|
||
var Mode = 8;
|
||
var ContextConsumer = 9;
|
||
var ContextProvider = 10;
|
||
var ForwardRef = 11;
|
||
var Profiler = 12;
|
||
var SuspenseComponent = 13;
|
||
var MemoComponent = 14;
|
||
var SimpleMemoComponent = 15;
|
||
var LazyComponent = 16;
|
||
var IncompleteClassComponent = 17;
|
||
var DehydratedFragment = 18;
|
||
var SuspenseListComponent = 19;
|
||
var ScopeComponent = 21;
|
||
var OffscreenComponent = 22;
|
||
var LegacyHiddenComponent = 23;
|
||
var CacheComponent = 24;
|
||
var TracingMarkerComponent = 25;
|
||
var enableClientRenderFallbackOnTextMismatch = true;
|
||
var enableNewReconciler = false;
|
||
var enableLazyContextPropagation = false;
|
||
var enableLegacyHidden = false;
|
||
var enableSuspenseAvoidThisFallback = false;
|
||
var disableCommentsAsDOMContainers = true;
|
||
var enableCustomElementPropertySupport = false;
|
||
var warnAboutStringRefs = false;
|
||
var enableSchedulingProfiler = true;
|
||
var enableProfilerTimer = true;
|
||
var enableProfilerCommitHooks = true;
|
||
var allNativeEvents = /* @__PURE__ */ new Set();
|
||
var registrationNameDependencies = {};
|
||
var possibleRegistrationNames = {};
|
||
function registerTwoPhaseEvent(registrationName, dependencies) {
|
||
registerDirectEvent(registrationName, dependencies);
|
||
registerDirectEvent(registrationName + "Capture", dependencies);
|
||
}
|
||
function registerDirectEvent(registrationName, dependencies) {
|
||
{
|
||
if (registrationNameDependencies[registrationName]) {
|
||
error("EventRegistry: More than one plugin attempted to publish the same registration name, `%s`.", registrationName);
|
||
}
|
||
}
|
||
registrationNameDependencies[registrationName] = dependencies;
|
||
{
|
||
var lowerCasedName = registrationName.toLowerCase();
|
||
possibleRegistrationNames[lowerCasedName] = registrationName;
|
||
if (registrationName === "onDoubleClick") {
|
||
possibleRegistrationNames.ondblclick = registrationName;
|
||
}
|
||
}
|
||
for (var i = 0; i < dependencies.length; i++) {
|
||
allNativeEvents.add(dependencies[i]);
|
||
}
|
||
}
|
||
var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
||
var hasOwnProperty2 = Object.prototype.hasOwnProperty;
|
||
function typeName(value) {
|
||
{
|
||
var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
|
||
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
||
return type;
|
||
}
|
||
}
|
||
function willCoercionThrow(value) {
|
||
{
|
||
try {
|
||
testStringCoercion(value);
|
||
return false;
|
||
} catch (e) {
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
function testStringCoercion(value) {
|
||
return "" + value;
|
||
}
|
||
function checkAttributeStringCoercion(value, attributeName) {
|
||
{
|
||
if (willCoercionThrow(value)) {
|
||
error("The provided `%s` attribute is an unsupported type %s. This value must be coerced to a string before before using it here.", attributeName, typeName(value));
|
||
return testStringCoercion(value);
|
||
}
|
||
}
|
||
}
|
||
function checkKeyStringCoercion(value) {
|
||
{
|
||
if (willCoercionThrow(value)) {
|
||
error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
|
||
return testStringCoercion(value);
|
||
}
|
||
}
|
||
}
|
||
function checkPropStringCoercion(value, propName) {
|
||
{
|
||
if (willCoercionThrow(value)) {
|
||
error("The provided `%s` prop is an unsupported type %s. This value must be coerced to a string before before using it here.", propName, typeName(value));
|
||
return testStringCoercion(value);
|
||
}
|
||
}
|
||
}
|
||
function checkCSSPropertyStringCoercion(value, propName) {
|
||
{
|
||
if (willCoercionThrow(value)) {
|
||
error("The provided `%s` CSS property is an unsupported type %s. This value must be coerced to a string before before using it here.", propName, typeName(value));
|
||
return testStringCoercion(value);
|
||
}
|
||
}
|
||
}
|
||
function checkHtmlStringCoercion(value) {
|
||
{
|
||
if (willCoercionThrow(value)) {
|
||
error("The provided HTML markup uses a value of unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
|
||
return testStringCoercion(value);
|
||
}
|
||
}
|
||
}
|
||
function checkFormFieldValueStringCoercion(value) {
|
||
{
|
||
if (willCoercionThrow(value)) {
|
||
error("Form field values (value, checked, defaultValue, or defaultChecked props) must be strings, not %s. This value must be coerced to a string before before using it here.", typeName(value));
|
||
return testStringCoercion(value);
|
||
}
|
||
}
|
||
}
|
||
var RESERVED = 0;
|
||
var STRING = 1;
|
||
var BOOLEANISH_STRING = 2;
|
||
var BOOLEAN = 3;
|
||
var OVERLOADED_BOOLEAN = 4;
|
||
var NUMERIC = 5;
|
||
var POSITIVE_NUMERIC = 6;
|
||
var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
||
var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
||
var VALID_ATTRIBUTE_NAME_REGEX = new RegExp("^[" + ATTRIBUTE_NAME_START_CHAR + "][" + ATTRIBUTE_NAME_CHAR + "]*$");
|
||
var illegalAttributeNameCache = {};
|
||
var validatedAttributeNameCache = {};
|
||
function isAttributeNameSafe(attributeName) {
|
||
if (hasOwnProperty2.call(validatedAttributeNameCache, attributeName)) {
|
||
return true;
|
||
}
|
||
if (hasOwnProperty2.call(illegalAttributeNameCache, attributeName)) {
|
||
return false;
|
||
}
|
||
if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
|
||
validatedAttributeNameCache[attributeName] = true;
|
||
return true;
|
||
}
|
||
illegalAttributeNameCache[attributeName] = true;
|
||
{
|
||
error("Invalid attribute name: `%s`", attributeName);
|
||
}
|
||
return false;
|
||
}
|
||
function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) {
|
||
if (propertyInfo !== null) {
|
||
return propertyInfo.type === RESERVED;
|
||
}
|
||
if (isCustomComponentTag) {
|
||
return false;
|
||
}
|
||
if (name.length > 2 && (name[0] === "o" || name[0] === "O") && (name[1] === "n" || name[1] === "N")) {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
|
||
if (propertyInfo !== null && propertyInfo.type === RESERVED) {
|
||
return false;
|
||
}
|
||
switch (typeof value) {
|
||
case "function":
|
||
case "symbol":
|
||
return true;
|
||
case "boolean": {
|
||
if (isCustomComponentTag) {
|
||
return false;
|
||
}
|
||
if (propertyInfo !== null) {
|
||
return !propertyInfo.acceptsBooleans;
|
||
} else {
|
||
var prefix2 = name.toLowerCase().slice(0, 5);
|
||
return prefix2 !== "data-" && prefix2 !== "aria-";
|
||
}
|
||
}
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) {
|
||
if (value === null || typeof value === "undefined") {
|
||
return true;
|
||
}
|
||
if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
|
||
return true;
|
||
}
|
||
if (isCustomComponentTag) {
|
||
return false;
|
||
}
|
||
if (propertyInfo !== null) {
|
||
switch (propertyInfo.type) {
|
||
case BOOLEAN:
|
||
return !value;
|
||
case OVERLOADED_BOOLEAN:
|
||
return value === false;
|
||
case NUMERIC:
|
||
return isNaN(value);
|
||
case POSITIVE_NUMERIC:
|
||
return isNaN(value) || value < 1;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
function getPropertyInfo(name) {
|
||
return properties.hasOwnProperty(name) ? properties[name] : null;
|
||
}
|
||
function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL2, removeEmptyString) {
|
||
this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
|
||
this.attributeName = attributeName;
|
||
this.attributeNamespace = attributeNamespace;
|
||
this.mustUseProperty = mustUseProperty;
|
||
this.propertyName = name;
|
||
this.type = type;
|
||
this.sanitizeURL = sanitizeURL2;
|
||
this.removeEmptyString = removeEmptyString;
|
||
}
|
||
var properties = {};
|
||
var reservedProps = [
|
||
"children",
|
||
"dangerouslySetInnerHTML",
|
||
"defaultValue",
|
||
"defaultChecked",
|
||
"innerHTML",
|
||
"suppressContentEditableWarning",
|
||
"suppressHydrationWarning",
|
||
"style"
|
||
];
|
||
reservedProps.forEach(function(name) {
|
||
properties[name] = new PropertyInfoRecord(name, RESERVED, false, name, null, false, false);
|
||
});
|
||
[["acceptCharset", "accept-charset"], ["className", "class"], ["htmlFor", "for"], ["httpEquiv", "http-equiv"]].forEach(function(_ref) {
|
||
var name = _ref[0], attributeName = _ref[1];
|
||
properties[name] = new PropertyInfoRecord(name, STRING, false, attributeName, null, false, false);
|
||
});
|
||
["contentEditable", "draggable", "spellCheck", "value"].forEach(function(name) {
|
||
properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, name.toLowerCase(), null, false, false);
|
||
});
|
||
["autoReverse", "externalResourcesRequired", "focusable", "preserveAlpha"].forEach(function(name) {
|
||
properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, name, null, false, false);
|
||
});
|
||
[
|
||
"allowFullScreen",
|
||
"async",
|
||
"autoFocus",
|
||
"autoPlay",
|
||
"controls",
|
||
"default",
|
||
"defer",
|
||
"disabled",
|
||
"disablePictureInPicture",
|
||
"disableRemotePlayback",
|
||
"formNoValidate",
|
||
"hidden",
|
||
"loop",
|
||
"noModule",
|
||
"noValidate",
|
||
"open",
|
||
"playsInline",
|
||
"readOnly",
|
||
"required",
|
||
"reversed",
|
||
"scoped",
|
||
"seamless",
|
||
"itemScope"
|
||
].forEach(function(name) {
|
||
properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, name.toLowerCase(), null, false, false);
|
||
});
|
||
[
|
||
"checked",
|
||
"multiple",
|
||
"muted",
|
||
"selected"
|
||
].forEach(function(name) {
|
||
properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, name, null, false, false);
|
||
});
|
||
[
|
||
"capture",
|
||
"download"
|
||
].forEach(function(name) {
|
||
properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, name, null, false, false);
|
||
});
|
||
[
|
||
"cols",
|
||
"rows",
|
||
"size",
|
||
"span"
|
||
].forEach(function(name) {
|
||
properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, name, null, false, false);
|
||
});
|
||
["rowSpan", "start"].forEach(function(name) {
|
||
properties[name] = new PropertyInfoRecord(name, NUMERIC, false, name.toLowerCase(), null, false, false);
|
||
});
|
||
var CAMELIZE = /[\-\:]([a-z])/g;
|
||
var capitalize = function(token) {
|
||
return token[1].toUpperCase();
|
||
};
|
||
[
|
||
"accent-height",
|
||
"alignment-baseline",
|
||
"arabic-form",
|
||
"baseline-shift",
|
||
"cap-height",
|
||
"clip-path",
|
||
"clip-rule",
|
||
"color-interpolation",
|
||
"color-interpolation-filters",
|
||
"color-profile",
|
||
"color-rendering",
|
||
"dominant-baseline",
|
||
"enable-background",
|
||
"fill-opacity",
|
||
"fill-rule",
|
||
"flood-color",
|
||
"flood-opacity",
|
||
"font-family",
|
||
"font-size",
|
||
"font-size-adjust",
|
||
"font-stretch",
|
||
"font-style",
|
||
"font-variant",
|
||
"font-weight",
|
||
"glyph-name",
|
||
"glyph-orientation-horizontal",
|
||
"glyph-orientation-vertical",
|
||
"horiz-adv-x",
|
||
"horiz-origin-x",
|
||
"image-rendering",
|
||
"letter-spacing",
|
||
"lighting-color",
|
||
"marker-end",
|
||
"marker-mid",
|
||
"marker-start",
|
||
"overline-position",
|
||
"overline-thickness",
|
||
"paint-order",
|
||
"panose-1",
|
||
"pointer-events",
|
||
"rendering-intent",
|
||
"shape-rendering",
|
||
"stop-color",
|
||
"stop-opacity",
|
||
"strikethrough-position",
|
||
"strikethrough-thickness",
|
||
"stroke-dasharray",
|
||
"stroke-dashoffset",
|
||
"stroke-linecap",
|
||
"stroke-linejoin",
|
||
"stroke-miterlimit",
|
||
"stroke-opacity",
|
||
"stroke-width",
|
||
"text-anchor",
|
||
"text-decoration",
|
||
"text-rendering",
|
||
"underline-position",
|
||
"underline-thickness",
|
||
"unicode-bidi",
|
||
"unicode-range",
|
||
"units-per-em",
|
||
"v-alphabetic",
|
||
"v-hanging",
|
||
"v-ideographic",
|
||
"v-mathematical",
|
||
"vector-effect",
|
||
"vert-adv-y",
|
||
"vert-origin-x",
|
||
"vert-origin-y",
|
||
"word-spacing",
|
||
"writing-mode",
|
||
"xmlns:xlink",
|
||
"x-height"
|
||
].forEach(function(attributeName) {
|
||
var name = attributeName.replace(CAMELIZE, capitalize);
|
||
properties[name] = new PropertyInfoRecord(name, STRING, false, attributeName, null, false, false);
|
||
});
|
||
[
|
||
"xlink:actuate",
|
||
"xlink:arcrole",
|
||
"xlink:role",
|
||
"xlink:show",
|
||
"xlink:title",
|
||
"xlink:type"
|
||
].forEach(function(attributeName) {
|
||
var name = attributeName.replace(CAMELIZE, capitalize);
|
||
properties[name] = new PropertyInfoRecord(name, STRING, false, attributeName, "http://www.w3.org/1999/xlink", false, false);
|
||
});
|
||
[
|
||
"xml:base",
|
||
"xml:lang",
|
||
"xml:space"
|
||
].forEach(function(attributeName) {
|
||
var name = attributeName.replace(CAMELIZE, capitalize);
|
||
properties[name] = new PropertyInfoRecord(name, STRING, false, attributeName, "http://www.w3.org/XML/1998/namespace", false, false);
|
||
});
|
||
["tabIndex", "crossOrigin"].forEach(function(attributeName) {
|
||
properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, attributeName.toLowerCase(), null, false, false);
|
||
});
|
||
var xlinkHref = "xlinkHref";
|
||
properties[xlinkHref] = new PropertyInfoRecord("xlinkHref", STRING, false, "xlink:href", "http://www.w3.org/1999/xlink", true, false);
|
||
["src", "href", "action", "formAction"].forEach(function(attributeName) {
|
||
properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, attributeName.toLowerCase(), null, true, true);
|
||
});
|
||
var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i;
|
||
var didWarn = false;
|
||
function sanitizeURL(url) {
|
||
{
|
||
if (!didWarn && isJavaScriptProtocol.test(url)) {
|
||
didWarn = true;
|
||
error("A future version of React will block javascript: URLs as a security precaution. Use event handlers instead if you can. If you need to generate unsafe HTML try using dangerouslySetInnerHTML instead. React was passed %s.", JSON.stringify(url));
|
||
}
|
||
}
|
||
}
|
||
function getValueForProperty(node, name, expected, propertyInfo) {
|
||
{
|
||
if (propertyInfo.mustUseProperty) {
|
||
var propertyName = propertyInfo.propertyName;
|
||
return node[propertyName];
|
||
} else {
|
||
{
|
||
checkAttributeStringCoercion(expected, name);
|
||
}
|
||
if (propertyInfo.sanitizeURL) {
|
||
sanitizeURL("" + expected);
|
||
}
|
||
var attributeName = propertyInfo.attributeName;
|
||
var stringValue = null;
|
||
if (propertyInfo.type === OVERLOADED_BOOLEAN) {
|
||
if (node.hasAttribute(attributeName)) {
|
||
var value = node.getAttribute(attributeName);
|
||
if (value === "") {
|
||
return true;
|
||
}
|
||
if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
|
||
return value;
|
||
}
|
||
if (value === "" + expected) {
|
||
return expected;
|
||
}
|
||
return value;
|
||
}
|
||
} else if (node.hasAttribute(attributeName)) {
|
||
if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
|
||
return node.getAttribute(attributeName);
|
||
}
|
||
if (propertyInfo.type === BOOLEAN) {
|
||
return expected;
|
||
}
|
||
stringValue = node.getAttribute(attributeName);
|
||
}
|
||
if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
|
||
return stringValue === null ? expected : stringValue;
|
||
} else if (stringValue === "" + expected) {
|
||
return expected;
|
||
} else {
|
||
return stringValue;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function getValueForAttribute(node, name, expected, isCustomComponentTag) {
|
||
{
|
||
if (!isAttributeNameSafe(name)) {
|
||
return;
|
||
}
|
||
if (!node.hasAttribute(name)) {
|
||
return expected === void 0 ? void 0 : null;
|
||
}
|
||
var value = node.getAttribute(name);
|
||
{
|
||
checkAttributeStringCoercion(expected, name);
|
||
}
|
||
if (value === "" + expected) {
|
||
return expected;
|
||
}
|
||
return value;
|
||
}
|
||
}
|
||
function setValueForProperty(node, name, value, isCustomComponentTag) {
|
||
var propertyInfo = getPropertyInfo(name);
|
||
if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) {
|
||
return;
|
||
}
|
||
if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) {
|
||
value = null;
|
||
}
|
||
if (isCustomComponentTag || propertyInfo === null) {
|
||
if (isAttributeNameSafe(name)) {
|
||
var _attributeName = name;
|
||
if (value === null) {
|
||
node.removeAttribute(_attributeName);
|
||
} else {
|
||
{
|
||
checkAttributeStringCoercion(value, name);
|
||
}
|
||
node.setAttribute(_attributeName, "" + value);
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
var mustUseProperty = propertyInfo.mustUseProperty;
|
||
if (mustUseProperty) {
|
||
var propertyName = propertyInfo.propertyName;
|
||
if (value === null) {
|
||
var type = propertyInfo.type;
|
||
node[propertyName] = type === BOOLEAN ? false : "";
|
||
} else {
|
||
node[propertyName] = value;
|
||
}
|
||
return;
|
||
}
|
||
var attributeName = propertyInfo.attributeName, attributeNamespace = propertyInfo.attributeNamespace;
|
||
if (value === null) {
|
||
node.removeAttribute(attributeName);
|
||
} else {
|
||
var _type = propertyInfo.type;
|
||
var attributeValue;
|
||
if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) {
|
||
attributeValue = "";
|
||
} else {
|
||
{
|
||
{
|
||
checkAttributeStringCoercion(value, attributeName);
|
||
}
|
||
attributeValue = "" + value;
|
||
}
|
||
if (propertyInfo.sanitizeURL) {
|
||
sanitizeURL(attributeValue.toString());
|
||
}
|
||
}
|
||
if (attributeNamespace) {
|
||
node.setAttributeNS(attributeNamespace, attributeName, attributeValue);
|
||
} else {
|
||
node.setAttribute(attributeName, attributeValue);
|
||
}
|
||
}
|
||
}
|
||
var REACT_ELEMENT_TYPE = Symbol.for("react.element");
|
||
var REACT_PORTAL_TYPE = Symbol.for("react.portal");
|
||
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
||
var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
|
||
var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
||
var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
|
||
var REACT_CONTEXT_TYPE = Symbol.for("react.context");
|
||
var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
|
||
var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
|
||
var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
|
||
var REACT_MEMO_TYPE = Symbol.for("react.memo");
|
||
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
||
var REACT_SCOPE_TYPE = Symbol.for("react.scope");
|
||
var REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for("react.debug_trace_mode");
|
||
var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
|
||
var REACT_LEGACY_HIDDEN_TYPE = Symbol.for("react.legacy_hidden");
|
||
var REACT_CACHE_TYPE = Symbol.for("react.cache");
|
||
var REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker");
|
||
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
||
var FAUX_ITERATOR_SYMBOL = "@@iterator";
|
||
function getIteratorFn(maybeIterable) {
|
||
if (maybeIterable === null || typeof maybeIterable !== "object") {
|
||
return null;
|
||
}
|
||
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
||
if (typeof maybeIterator === "function") {
|
||
return maybeIterator;
|
||
}
|
||
return null;
|
||
}
|
||
var assign = Object.assign;
|
||
var disabledDepth = 0;
|
||
var prevLog;
|
||
var prevInfo;
|
||
var prevWarn;
|
||
var prevError;
|
||
var prevGroup;
|
||
var prevGroupCollapsed;
|
||
var prevGroupEnd;
|
||
function disabledLog() {
|
||
}
|
||
disabledLog.__reactDisabledLog = true;
|
||
function disableLogs() {
|
||
{
|
||
if (disabledDepth === 0) {
|
||
prevLog = console.log;
|
||
prevInfo = console.info;
|
||
prevWarn = console.warn;
|
||
prevError = console.error;
|
||
prevGroup = console.group;
|
||
prevGroupCollapsed = console.groupCollapsed;
|
||
prevGroupEnd = console.groupEnd;
|
||
var props = {
|
||
configurable: true,
|
||
enumerable: true,
|
||
value: disabledLog,
|
||
writable: true
|
||
};
|
||
Object.defineProperties(console, {
|
||
info: props,
|
||
log: props,
|
||
warn: props,
|
||
error: props,
|
||
group: props,
|
||
groupCollapsed: props,
|
||
groupEnd: props
|
||
});
|
||
}
|
||
disabledDepth++;
|
||
}
|
||
}
|
||
function reenableLogs() {
|
||
{
|
||
disabledDepth--;
|
||
if (disabledDepth === 0) {
|
||
var props = {
|
||
configurable: true,
|
||
enumerable: true,
|
||
writable: true
|
||
};
|
||
Object.defineProperties(console, {
|
||
log: assign({}, props, {
|
||
value: prevLog
|
||
}),
|
||
info: assign({}, props, {
|
||
value: prevInfo
|
||
}),
|
||
warn: assign({}, props, {
|
||
value: prevWarn
|
||
}),
|
||
error: assign({}, props, {
|
||
value: prevError
|
||
}),
|
||
group: assign({}, props, {
|
||
value: prevGroup
|
||
}),
|
||
groupCollapsed: assign({}, props, {
|
||
value: prevGroupCollapsed
|
||
}),
|
||
groupEnd: assign({}, props, {
|
||
value: prevGroupEnd
|
||
})
|
||
});
|
||
}
|
||
if (disabledDepth < 0) {
|
||
error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
}
|
||
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
||
var prefix;
|
||
function describeBuiltInComponentFrame(name, source, ownerFn) {
|
||
{
|
||
if (prefix === void 0) {
|
||
try {
|
||
throw Error();
|
||
} catch (x) {
|
||
var match = x.stack.trim().match(/\n( *(at )?)/);
|
||
prefix = match && match[1] || "";
|
||
}
|
||
}
|
||
return "\n" + prefix + name;
|
||
}
|
||
}
|
||
var reentry = false;
|
||
var componentFrameCache;
|
||
{
|
||
var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
|
||
componentFrameCache = new PossiblyWeakMap();
|
||
}
|
||
function describeNativeComponentFrame(fn, construct) {
|
||
if (!fn || reentry) {
|
||
return "";
|
||
}
|
||
{
|
||
var frame = componentFrameCache.get(fn);
|
||
if (frame !== void 0) {
|
||
return frame;
|
||
}
|
||
}
|
||
var control;
|
||
reentry = true;
|
||
var previousPrepareStackTrace = Error.prepareStackTrace;
|
||
Error.prepareStackTrace = void 0;
|
||
var previousDispatcher;
|
||
{
|
||
previousDispatcher = ReactCurrentDispatcher.current;
|
||
ReactCurrentDispatcher.current = null;
|
||
disableLogs();
|
||
}
|
||
try {
|
||
if (construct) {
|
||
var Fake = function() {
|
||
throw Error();
|
||
};
|
||
Object.defineProperty(Fake.prototype, "props", {
|
||
set: function() {
|
||
throw Error();
|
||
}
|
||
});
|
||
if (typeof Reflect === "object" && Reflect.construct) {
|
||
try {
|
||
Reflect.construct(Fake, []);
|
||
} catch (x) {
|
||
control = x;
|
||
}
|
||
Reflect.construct(fn, [], Fake);
|
||
} else {
|
||
try {
|
||
Fake.call();
|
||
} catch (x) {
|
||
control = x;
|
||
}
|
||
fn.call(Fake.prototype);
|
||
}
|
||
} else {
|
||
try {
|
||
throw Error();
|
||
} catch (x) {
|
||
control = x;
|
||
}
|
||
fn();
|
||
}
|
||
} catch (sample) {
|
||
if (sample && control && typeof sample.stack === "string") {
|
||
var sampleLines = sample.stack.split("\n");
|
||
var controlLines = control.stack.split("\n");
|
||
var s = sampleLines.length - 1;
|
||
var c = controlLines.length - 1;
|
||
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
|
||
c--;
|
||
}
|
||
for (; s >= 1 && c >= 0; s--, c--) {
|
||
if (sampleLines[s] !== controlLines[c]) {
|
||
if (s !== 1 || c !== 1) {
|
||
do {
|
||
s--;
|
||
c--;
|
||
if (c < 0 || sampleLines[s] !== controlLines[c]) {
|
||
var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
|
||
if (fn.displayName && _frame.includes("<anonymous>")) {
|
||
_frame = _frame.replace("<anonymous>", fn.displayName);
|
||
}
|
||
{
|
||
if (typeof fn === "function") {
|
||
componentFrameCache.set(fn, _frame);
|
||
}
|
||
}
|
||
return _frame;
|
||
}
|
||
} while (s >= 1 && c >= 0);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
} finally {
|
||
reentry = false;
|
||
{
|
||
ReactCurrentDispatcher.current = previousDispatcher;
|
||
reenableLogs();
|
||
}
|
||
Error.prepareStackTrace = previousPrepareStackTrace;
|
||
}
|
||
var name = fn ? fn.displayName || fn.name : "";
|
||
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
|
||
{
|
||
if (typeof fn === "function") {
|
||
componentFrameCache.set(fn, syntheticFrame);
|
||
}
|
||
}
|
||
return syntheticFrame;
|
||
}
|
||
function describeClassComponentFrame(ctor, source, ownerFn) {
|
||
{
|
||
return describeNativeComponentFrame(ctor, true);
|
||
}
|
||
}
|
||
function describeFunctionComponentFrame(fn, source, ownerFn) {
|
||
{
|
||
return describeNativeComponentFrame(fn, false);
|
||
}
|
||
}
|
||
function shouldConstruct(Component) {
|
||
var prototype = Component.prototype;
|
||
return !!(prototype && prototype.isReactComponent);
|
||
}
|
||
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
||
if (type == null) {
|
||
return "";
|
||
}
|
||
if (typeof type === "function") {
|
||
{
|
||
return describeNativeComponentFrame(type, shouldConstruct(type));
|
||
}
|
||
}
|
||
if (typeof type === "string") {
|
||
return describeBuiltInComponentFrame(type);
|
||
}
|
||
switch (type) {
|
||
case REACT_SUSPENSE_TYPE:
|
||
return describeBuiltInComponentFrame("Suspense");
|
||
case REACT_SUSPENSE_LIST_TYPE:
|
||
return describeBuiltInComponentFrame("SuspenseList");
|
||
}
|
||
if (typeof type === "object") {
|
||
switch (type.$$typeof) {
|
||
case REACT_FORWARD_REF_TYPE:
|
||
return describeFunctionComponentFrame(type.render);
|
||
case REACT_MEMO_TYPE:
|
||
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
||
case REACT_LAZY_TYPE: {
|
||
var lazyComponent = type;
|
||
var payload = lazyComponent._payload;
|
||
var init = lazyComponent._init;
|
||
try {
|
||
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
||
} catch (x) {
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
function describeFiber(fiber) {
|
||
var owner = fiber._debugOwner ? fiber._debugOwner.type : null;
|
||
var source = fiber._debugSource;
|
||
switch (fiber.tag) {
|
||
case HostComponent:
|
||
return describeBuiltInComponentFrame(fiber.type);
|
||
case LazyComponent:
|
||
return describeBuiltInComponentFrame("Lazy");
|
||
case SuspenseComponent:
|
||
return describeBuiltInComponentFrame("Suspense");
|
||
case SuspenseListComponent:
|
||
return describeBuiltInComponentFrame("SuspenseList");
|
||
case FunctionComponent:
|
||
case IndeterminateComponent:
|
||
case SimpleMemoComponent:
|
||
return describeFunctionComponentFrame(fiber.type);
|
||
case ForwardRef:
|
||
return describeFunctionComponentFrame(fiber.type.render);
|
||
case ClassComponent:
|
||
return describeClassComponentFrame(fiber.type);
|
||
default:
|
||
return "";
|
||
}
|
||
}
|
||
function getStackByFiberInDevAndProd(workInProgress2) {
|
||
try {
|
||
var info = "";
|
||
var node = workInProgress2;
|
||
do {
|
||
info += describeFiber(node);
|
||
node = node.return;
|
||
} while (node);
|
||
return info;
|
||
} catch (x) {
|
||
return "\nError generating stack: " + x.message + "\n" + x.stack;
|
||
}
|
||
}
|
||
function getWrappedName(outerType, innerType, wrapperName) {
|
||
var displayName = outerType.displayName;
|
||
if (displayName) {
|
||
return displayName;
|
||
}
|
||
var functionName = innerType.displayName || innerType.name || "";
|
||
return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
|
||
}
|
||
function getContextName(type) {
|
||
return type.displayName || "Context";
|
||
}
|
||
function getComponentNameFromType(type) {
|
||
if (type == null) {
|
||
return null;
|
||
}
|
||
{
|
||
if (typeof type.tag === "number") {
|
||
error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
if (typeof type === "function") {
|
||
return type.displayName || type.name || null;
|
||
}
|
||
if (typeof type === "string") {
|
||
return type;
|
||
}
|
||
switch (type) {
|
||
case REACT_FRAGMENT_TYPE:
|
||
return "Fragment";
|
||
case REACT_PORTAL_TYPE:
|
||
return "Portal";
|
||
case REACT_PROFILER_TYPE:
|
||
return "Profiler";
|
||
case REACT_STRICT_MODE_TYPE:
|
||
return "StrictMode";
|
||
case REACT_SUSPENSE_TYPE:
|
||
return "Suspense";
|
||
case REACT_SUSPENSE_LIST_TYPE:
|
||
return "SuspenseList";
|
||
}
|
||
if (typeof type === "object") {
|
||
switch (type.$$typeof) {
|
||
case REACT_CONTEXT_TYPE:
|
||
var context = type;
|
||
return getContextName(context) + ".Consumer";
|
||
case REACT_PROVIDER_TYPE:
|
||
var provider = type;
|
||
return getContextName(provider._context) + ".Provider";
|
||
case REACT_FORWARD_REF_TYPE:
|
||
return getWrappedName(type, type.render, "ForwardRef");
|
||
case REACT_MEMO_TYPE:
|
||
var outerName = type.displayName || null;
|
||
if (outerName !== null) {
|
||
return outerName;
|
||
}
|
||
return getComponentNameFromType(type.type) || "Memo";
|
||
case REACT_LAZY_TYPE: {
|
||
var lazyComponent = type;
|
||
var payload = lazyComponent._payload;
|
||
var init = lazyComponent._init;
|
||
try {
|
||
return getComponentNameFromType(init(payload));
|
||
} catch (x) {
|
||
return null;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
function getWrappedName$1(outerType, innerType, wrapperName) {
|
||
var functionName = innerType.displayName || innerType.name || "";
|
||
return outerType.displayName || (functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName);
|
||
}
|
||
function getContextName$1(type) {
|
||
return type.displayName || "Context";
|
||
}
|
||
function getComponentNameFromFiber(fiber) {
|
||
var tag = fiber.tag, type = fiber.type;
|
||
switch (tag) {
|
||
case CacheComponent:
|
||
return "Cache";
|
||
case ContextConsumer:
|
||
var context = type;
|
||
return getContextName$1(context) + ".Consumer";
|
||
case ContextProvider:
|
||
var provider = type;
|
||
return getContextName$1(provider._context) + ".Provider";
|
||
case DehydratedFragment:
|
||
return "DehydratedFragment";
|
||
case ForwardRef:
|
||
return getWrappedName$1(type, type.render, "ForwardRef");
|
||
case Fragment:
|
||
return "Fragment";
|
||
case HostComponent:
|
||
return type;
|
||
case HostPortal:
|
||
return "Portal";
|
||
case HostRoot:
|
||
return "Root";
|
||
case HostText:
|
||
return "Text";
|
||
case LazyComponent:
|
||
return getComponentNameFromType(type);
|
||
case Mode:
|
||
if (type === REACT_STRICT_MODE_TYPE) {
|
||
return "StrictMode";
|
||
}
|
||
return "Mode";
|
||
case OffscreenComponent:
|
||
return "Offscreen";
|
||
case Profiler:
|
||
return "Profiler";
|
||
case ScopeComponent:
|
||
return "Scope";
|
||
case SuspenseComponent:
|
||
return "Suspense";
|
||
case SuspenseListComponent:
|
||
return "SuspenseList";
|
||
case TracingMarkerComponent:
|
||
return "TracingMarker";
|
||
case ClassComponent:
|
||
case FunctionComponent:
|
||
case IncompleteClassComponent:
|
||
case IndeterminateComponent:
|
||
case MemoComponent:
|
||
case SimpleMemoComponent:
|
||
if (typeof type === "function") {
|
||
return type.displayName || type.name || null;
|
||
}
|
||
if (typeof type === "string") {
|
||
return type;
|
||
}
|
||
break;
|
||
}
|
||
return null;
|
||
}
|
||
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
||
var current = null;
|
||
var isRendering = false;
|
||
function getCurrentFiberOwnerNameInDevOrNull() {
|
||
{
|
||
if (current === null) {
|
||
return null;
|
||
}
|
||
var owner = current._debugOwner;
|
||
if (owner !== null && typeof owner !== "undefined") {
|
||
return getComponentNameFromFiber(owner);
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
function getCurrentFiberStackInDev() {
|
||
{
|
||
if (current === null) {
|
||
return "";
|
||
}
|
||
return getStackByFiberInDevAndProd(current);
|
||
}
|
||
}
|
||
function resetCurrentFiber() {
|
||
{
|
||
ReactDebugCurrentFrame.getCurrentStack = null;
|
||
current = null;
|
||
isRendering = false;
|
||
}
|
||
}
|
||
function setCurrentFiber(fiber) {
|
||
{
|
||
ReactDebugCurrentFrame.getCurrentStack = fiber === null ? null : getCurrentFiberStackInDev;
|
||
current = fiber;
|
||
isRendering = false;
|
||
}
|
||
}
|
||
function getCurrentFiber() {
|
||
{
|
||
return current;
|
||
}
|
||
}
|
||
function setIsRendering(rendering) {
|
||
{
|
||
isRendering = rendering;
|
||
}
|
||
}
|
||
function toString(value) {
|
||
return "" + value;
|
||
}
|
||
function getToStringValue(value) {
|
||
switch (typeof value) {
|
||
case "boolean":
|
||
case "number":
|
||
case "string":
|
||
case "undefined":
|
||
return value;
|
||
case "object":
|
||
{
|
||
checkFormFieldValueStringCoercion(value);
|
||
}
|
||
return value;
|
||
default:
|
||
return "";
|
||
}
|
||
}
|
||
var hasReadOnlyValue = {
|
||
button: true,
|
||
checkbox: true,
|
||
image: true,
|
||
hidden: true,
|
||
radio: true,
|
||
reset: true,
|
||
submit: true
|
||
};
|
||
function checkControlledValueProps(tagName, props) {
|
||
{
|
||
if (!(hasReadOnlyValue[props.type] || props.onChange || props.onInput || props.readOnly || props.disabled || props.value == null)) {
|
||
error("You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.");
|
||
}
|
||
if (!(props.onChange || props.readOnly || props.disabled || props.checked == null)) {
|
||
error("You provided a `checked` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultChecked`. Otherwise, set either `onChange` or `readOnly`.");
|
||
}
|
||
}
|
||
}
|
||
function isCheckable(elem) {
|
||
var type = elem.type;
|
||
var nodeName = elem.nodeName;
|
||
return nodeName && nodeName.toLowerCase() === "input" && (type === "checkbox" || type === "radio");
|
||
}
|
||
function getTracker(node) {
|
||
return node._valueTracker;
|
||
}
|
||
function detachTracker(node) {
|
||
node._valueTracker = null;
|
||
}
|
||
function getValueFromNode(node) {
|
||
var value = "";
|
||
if (!node) {
|
||
return value;
|
||
}
|
||
if (isCheckable(node)) {
|
||
value = node.checked ? "true" : "false";
|
||
} else {
|
||
value = node.value;
|
||
}
|
||
return value;
|
||
}
|
||
function trackValueOnNode(node) {
|
||
var valueField = isCheckable(node) ? "checked" : "value";
|
||
var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField);
|
||
{
|
||
checkFormFieldValueStringCoercion(node[valueField]);
|
||
}
|
||
var currentValue = "" + node[valueField];
|
||
if (node.hasOwnProperty(valueField) || typeof descriptor === "undefined" || typeof descriptor.get !== "function" || typeof descriptor.set !== "function") {
|
||
return;
|
||
}
|
||
var get2 = descriptor.get, set2 = descriptor.set;
|
||
Object.defineProperty(node, valueField, {
|
||
configurable: true,
|
||
get: function() {
|
||
return get2.call(this);
|
||
},
|
||
set: function(value) {
|
||
{
|
||
checkFormFieldValueStringCoercion(value);
|
||
}
|
||
currentValue = "" + value;
|
||
set2.call(this, value);
|
||
}
|
||
});
|
||
Object.defineProperty(node, valueField, {
|
||
enumerable: descriptor.enumerable
|
||
});
|
||
var tracker = {
|
||
getValue: function() {
|
||
return currentValue;
|
||
},
|
||
setValue: function(value) {
|
||
{
|
||
checkFormFieldValueStringCoercion(value);
|
||
}
|
||
currentValue = "" + value;
|
||
},
|
||
stopTracking: function() {
|
||
detachTracker(node);
|
||
delete node[valueField];
|
||
}
|
||
};
|
||
return tracker;
|
||
}
|
||
function track(node) {
|
||
if (getTracker(node)) {
|
||
return;
|
||
}
|
||
node._valueTracker = trackValueOnNode(node);
|
||
}
|
||
function updateValueIfChanged(node) {
|
||
if (!node) {
|
||
return false;
|
||
}
|
||
var tracker = getTracker(node);
|
||
if (!tracker) {
|
||
return true;
|
||
}
|
||
var lastValue = tracker.getValue();
|
||
var nextValue = getValueFromNode(node);
|
||
if (nextValue !== lastValue) {
|
||
tracker.setValue(nextValue);
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
function getActiveElement(doc) {
|
||
doc = doc || (typeof document !== "undefined" ? document : void 0);
|
||
if (typeof doc === "undefined") {
|
||
return null;
|
||
}
|
||
try {
|
||
return doc.activeElement || doc.body;
|
||
} catch (e) {
|
||
return doc.body;
|
||
}
|
||
}
|
||
var didWarnValueDefaultValue = false;
|
||
var didWarnCheckedDefaultChecked = false;
|
||
var didWarnControlledToUncontrolled = false;
|
||
var didWarnUncontrolledToControlled = false;
|
||
function isControlled(props) {
|
||
var usesChecked = props.type === "checkbox" || props.type === "radio";
|
||
return usesChecked ? props.checked != null : props.value != null;
|
||
}
|
||
function getHostProps(element, props) {
|
||
var node = element;
|
||
var checked = props.checked;
|
||
var hostProps = assign({}, props, {
|
||
defaultChecked: void 0,
|
||
defaultValue: void 0,
|
||
value: void 0,
|
||
checked: checked != null ? checked : node._wrapperState.initialChecked
|
||
});
|
||
return hostProps;
|
||
}
|
||
function initWrapperState(element, props) {
|
||
{
|
||
checkControlledValueProps("input", props);
|
||
if (props.checked !== void 0 && props.defaultChecked !== void 0 && !didWarnCheckedDefaultChecked) {
|
||
error("%s contains an input of type %s with both checked and defaultChecked props. Input elements must be either controlled or uncontrolled (specify either the checked prop, or the defaultChecked prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://reactjs.org/link/controlled-components", getCurrentFiberOwnerNameInDevOrNull() || "A component", props.type);
|
||
didWarnCheckedDefaultChecked = true;
|
||
}
|
||
if (props.value !== void 0 && props.defaultValue !== void 0 && !didWarnValueDefaultValue) {
|
||
error("%s contains an input of type %s with both value and defaultValue props. Input elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://reactjs.org/link/controlled-components", getCurrentFiberOwnerNameInDevOrNull() || "A component", props.type);
|
||
didWarnValueDefaultValue = true;
|
||
}
|
||
}
|
||
var node = element;
|
||
var defaultValue = props.defaultValue == null ? "" : props.defaultValue;
|
||
node._wrapperState = {
|
||
initialChecked: props.checked != null ? props.checked : props.defaultChecked,
|
||
initialValue: getToStringValue(props.value != null ? props.value : defaultValue),
|
||
controlled: isControlled(props)
|
||
};
|
||
}
|
||
function updateChecked(element, props) {
|
||
var node = element;
|
||
var checked = props.checked;
|
||
if (checked != null) {
|
||
setValueForProperty(node, "checked", checked, false);
|
||
}
|
||
}
|
||
function updateWrapper(element, props) {
|
||
var node = element;
|
||
{
|
||
var controlled = isControlled(props);
|
||
if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) {
|
||
error("A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components");
|
||
didWarnUncontrolledToControlled = true;
|
||
}
|
||
if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) {
|
||
error("A component is changing a controlled input to be uncontrolled. This is likely caused by the value changing from a defined to undefined, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components");
|
||
didWarnControlledToUncontrolled = true;
|
||
}
|
||
}
|
||
updateChecked(element, props);
|
||
var value = getToStringValue(props.value);
|
||
var type = props.type;
|
||
if (value != null) {
|
||
if (type === "number") {
|
||
if (value === 0 && node.value === "" || node.value != value) {
|
||
node.value = toString(value);
|
||
}
|
||
} else if (node.value !== toString(value)) {
|
||
node.value = toString(value);
|
||
}
|
||
} else if (type === "submit" || type === "reset") {
|
||
node.removeAttribute("value");
|
||
return;
|
||
}
|
||
{
|
||
if (props.hasOwnProperty("value")) {
|
||
setDefaultValue(node, props.type, value);
|
||
} else if (props.hasOwnProperty("defaultValue")) {
|
||
setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
|
||
}
|
||
}
|
||
{
|
||
if (props.checked == null && props.defaultChecked != null) {
|
||
node.defaultChecked = !!props.defaultChecked;
|
||
}
|
||
}
|
||
}
|
||
function postMountWrapper(element, props, isHydrating2) {
|
||
var node = element;
|
||
if (props.hasOwnProperty("value") || props.hasOwnProperty("defaultValue")) {
|
||
var type = props.type;
|
||
var isButton = type === "submit" || type === "reset";
|
||
if (isButton && (props.value === void 0 || props.value === null)) {
|
||
return;
|
||
}
|
||
var initialValue = toString(node._wrapperState.initialValue);
|
||
if (!isHydrating2) {
|
||
{
|
||
if (initialValue !== node.value) {
|
||
node.value = initialValue;
|
||
}
|
||
}
|
||
}
|
||
{
|
||
node.defaultValue = initialValue;
|
||
}
|
||
}
|
||
var name = node.name;
|
||
if (name !== "") {
|
||
node.name = "";
|
||
}
|
||
{
|
||
node.defaultChecked = !node.defaultChecked;
|
||
node.defaultChecked = !!node._wrapperState.initialChecked;
|
||
}
|
||
if (name !== "") {
|
||
node.name = name;
|
||
}
|
||
}
|
||
function restoreControlledState(element, props) {
|
||
var node = element;
|
||
updateWrapper(node, props);
|
||
updateNamedCousins(node, props);
|
||
}
|
||
function updateNamedCousins(rootNode, props) {
|
||
var name = props.name;
|
||
if (props.type === "radio" && name != null) {
|
||
var queryRoot = rootNode;
|
||
while (queryRoot.parentNode) {
|
||
queryRoot = queryRoot.parentNode;
|
||
}
|
||
{
|
||
checkAttributeStringCoercion(name, "name");
|
||
}
|
||
var group = queryRoot.querySelectorAll("input[name=" + JSON.stringify("" + name) + '][type="radio"]');
|
||
for (var i = 0; i < group.length; i++) {
|
||
var otherNode = group[i];
|
||
if (otherNode === rootNode || otherNode.form !== rootNode.form) {
|
||
continue;
|
||
}
|
||
var otherProps = getFiberCurrentPropsFromNode(otherNode);
|
||
if (!otherProps) {
|
||
throw new Error("ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported.");
|
||
}
|
||
updateValueIfChanged(otherNode);
|
||
updateWrapper(otherNode, otherProps);
|
||
}
|
||
}
|
||
}
|
||
function setDefaultValue(node, type, value) {
|
||
if (type !== "number" || getActiveElement(node.ownerDocument) !== node) {
|
||
if (value == null) {
|
||
node.defaultValue = toString(node._wrapperState.initialValue);
|
||
} else if (node.defaultValue !== toString(value)) {
|
||
node.defaultValue = toString(value);
|
||
}
|
||
}
|
||
}
|
||
var didWarnSelectedSetOnOption = false;
|
||
var didWarnInvalidChild = false;
|
||
var didWarnInvalidInnerHTML = false;
|
||
function validateProps(element, props) {
|
||
{
|
||
if (props.value == null) {
|
||
if (typeof props.children === "object" && props.children !== null) {
|
||
React2.Children.forEach(props.children, function(child) {
|
||
if (child == null) {
|
||
return;
|
||
}
|
||
if (typeof child === "string" || typeof child === "number") {
|
||
return;
|
||
}
|
||
if (!didWarnInvalidChild) {
|
||
didWarnInvalidChild = true;
|
||
error("Cannot infer the option value of complex children. Pass a `value` prop or use a plain string as children to <option>.");
|
||
}
|
||
});
|
||
} else if (props.dangerouslySetInnerHTML != null) {
|
||
if (!didWarnInvalidInnerHTML) {
|
||
didWarnInvalidInnerHTML = true;
|
||
error("Pass a `value` prop if you set dangerouslyInnerHTML so React knows which value should be selected.");
|
||
}
|
||
}
|
||
}
|
||
if (props.selected != null && !didWarnSelectedSetOnOption) {
|
||
error("Use the `defaultValue` or `value` props on <select> instead of setting `selected` on <option>.");
|
||
didWarnSelectedSetOnOption = true;
|
||
}
|
||
}
|
||
}
|
||
function postMountWrapper$1(element, props) {
|
||
if (props.value != null) {
|
||
element.setAttribute("value", toString(getToStringValue(props.value)));
|
||
}
|
||
}
|
||
var isArrayImpl = Array.isArray;
|
||
function isArray(a) {
|
||
return isArrayImpl(a);
|
||
}
|
||
var didWarnValueDefaultValue$1;
|
||
{
|
||
didWarnValueDefaultValue$1 = false;
|
||
}
|
||
function getDeclarationErrorAddendum() {
|
||
var ownerName = getCurrentFiberOwnerNameInDevOrNull();
|
||
if (ownerName) {
|
||
return "\n\nCheck the render method of `" + ownerName + "`.";
|
||
}
|
||
return "";
|
||
}
|
||
var valuePropNames = ["value", "defaultValue"];
|
||
function checkSelectPropTypes(props) {
|
||
{
|
||
checkControlledValueProps("select", props);
|
||
for (var i = 0; i < valuePropNames.length; i++) {
|
||
var propName = valuePropNames[i];
|
||
if (props[propName] == null) {
|
||
continue;
|
||
}
|
||
var propNameIsArray = isArray(props[propName]);
|
||
if (props.multiple && !propNameIsArray) {
|
||
error("The `%s` prop supplied to <select> must be an array if `multiple` is true.%s", propName, getDeclarationErrorAddendum());
|
||
} else if (!props.multiple && propNameIsArray) {
|
||
error("The `%s` prop supplied to <select> must be a scalar value if `multiple` is false.%s", propName, getDeclarationErrorAddendum());
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function updateOptions(node, multiple, propValue, setDefaultSelected) {
|
||
var options2 = node.options;
|
||
if (multiple) {
|
||
var selectedValues = propValue;
|
||
var selectedValue = {};
|
||
for (var i = 0; i < selectedValues.length; i++) {
|
||
selectedValue["$" + selectedValues[i]] = true;
|
||
}
|
||
for (var _i = 0; _i < options2.length; _i++) {
|
||
var selected = selectedValue.hasOwnProperty("$" + options2[_i].value);
|
||
if (options2[_i].selected !== selected) {
|
||
options2[_i].selected = selected;
|
||
}
|
||
if (selected && setDefaultSelected) {
|
||
options2[_i].defaultSelected = true;
|
||
}
|
||
}
|
||
} else {
|
||
var _selectedValue = toString(getToStringValue(propValue));
|
||
var defaultSelected = null;
|
||
for (var _i2 = 0; _i2 < options2.length; _i2++) {
|
||
if (options2[_i2].value === _selectedValue) {
|
||
options2[_i2].selected = true;
|
||
if (setDefaultSelected) {
|
||
options2[_i2].defaultSelected = true;
|
||
}
|
||
return;
|
||
}
|
||
if (defaultSelected === null && !options2[_i2].disabled) {
|
||
defaultSelected = options2[_i2];
|
||
}
|
||
}
|
||
if (defaultSelected !== null) {
|
||
defaultSelected.selected = true;
|
||
}
|
||
}
|
||
}
|
||
function getHostProps$1(element, props) {
|
||
return assign({}, props, {
|
||
value: void 0
|
||
});
|
||
}
|
||
function initWrapperState$1(element, props) {
|
||
var node = element;
|
||
{
|
||
checkSelectPropTypes(props);
|
||
}
|
||
node._wrapperState = {
|
||
wasMultiple: !!props.multiple
|
||
};
|
||
{
|
||
if (props.value !== void 0 && props.defaultValue !== void 0 && !didWarnValueDefaultValue$1) {
|
||
error("Select elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled select element and remove one of these props. More info: https://reactjs.org/link/controlled-components");
|
||
didWarnValueDefaultValue$1 = true;
|
||
}
|
||
}
|
||
}
|
||
function postMountWrapper$2(element, props) {
|
||
var node = element;
|
||
node.multiple = !!props.multiple;
|
||
var value = props.value;
|
||
if (value != null) {
|
||
updateOptions(node, !!props.multiple, value, false);
|
||
} else if (props.defaultValue != null) {
|
||
updateOptions(node, !!props.multiple, props.defaultValue, true);
|
||
}
|
||
}
|
||
function postUpdateWrapper(element, props) {
|
||
var node = element;
|
||
var wasMultiple = node._wrapperState.wasMultiple;
|
||
node._wrapperState.wasMultiple = !!props.multiple;
|
||
var value = props.value;
|
||
if (value != null) {
|
||
updateOptions(node, !!props.multiple, value, false);
|
||
} else if (wasMultiple !== !!props.multiple) {
|
||
if (props.defaultValue != null) {
|
||
updateOptions(node, !!props.multiple, props.defaultValue, true);
|
||
} else {
|
||
updateOptions(node, !!props.multiple, props.multiple ? [] : "", false);
|
||
}
|
||
}
|
||
}
|
||
function restoreControlledState$1(element, props) {
|
||
var node = element;
|
||
var value = props.value;
|
||
if (value != null) {
|
||
updateOptions(node, !!props.multiple, value, false);
|
||
}
|
||
}
|
||
var didWarnValDefaultVal = false;
|
||
function getHostProps$2(element, props) {
|
||
var node = element;
|
||
if (props.dangerouslySetInnerHTML != null) {
|
||
throw new Error("`dangerouslySetInnerHTML` does not make sense on <textarea>.");
|
||
}
|
||
var hostProps = assign({}, props, {
|
||
value: void 0,
|
||
defaultValue: void 0,
|
||
children: toString(node._wrapperState.initialValue)
|
||
});
|
||
return hostProps;
|
||
}
|
||
function initWrapperState$2(element, props) {
|
||
var node = element;
|
||
{
|
||
checkControlledValueProps("textarea", props);
|
||
if (props.value !== void 0 && props.defaultValue !== void 0 && !didWarnValDefaultVal) {
|
||
error("%s contains a textarea with both value and defaultValue props. Textarea elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled textarea and remove one of these props. More info: https://reactjs.org/link/controlled-components", getCurrentFiberOwnerNameInDevOrNull() || "A component");
|
||
didWarnValDefaultVal = true;
|
||
}
|
||
}
|
||
var initialValue = props.value;
|
||
if (initialValue == null) {
|
||
var children = props.children, defaultValue = props.defaultValue;
|
||
if (children != null) {
|
||
{
|
||
error("Use the `defaultValue` or `value` props instead of setting children on <textarea>.");
|
||
}
|
||
{
|
||
if (defaultValue != null) {
|
||
throw new Error("If you supply `defaultValue` on a <textarea>, do not pass children.");
|
||
}
|
||
if (isArray(children)) {
|
||
if (children.length > 1) {
|
||
throw new Error("<textarea> can only have at most one child.");
|
||
}
|
||
children = children[0];
|
||
}
|
||
defaultValue = children;
|
||
}
|
||
}
|
||
if (defaultValue == null) {
|
||
defaultValue = "";
|
||
}
|
||
initialValue = defaultValue;
|
||
}
|
||
node._wrapperState = {
|
||
initialValue: getToStringValue(initialValue)
|
||
};
|
||
}
|
||
function updateWrapper$1(element, props) {
|
||
var node = element;
|
||
var value = getToStringValue(props.value);
|
||
var defaultValue = getToStringValue(props.defaultValue);
|
||
if (value != null) {
|
||
var newValue = toString(value);
|
||
if (newValue !== node.value) {
|
||
node.value = newValue;
|
||
}
|
||
if (props.defaultValue == null && node.defaultValue !== newValue) {
|
||
node.defaultValue = newValue;
|
||
}
|
||
}
|
||
if (defaultValue != null) {
|
||
node.defaultValue = toString(defaultValue);
|
||
}
|
||
}
|
||
function postMountWrapper$3(element, props) {
|
||
var node = element;
|
||
var textContent = node.textContent;
|
||
if (textContent === node._wrapperState.initialValue) {
|
||
if (textContent !== "" && textContent !== null) {
|
||
node.value = textContent;
|
||
}
|
||
}
|
||
}
|
||
function restoreControlledState$2(element, props) {
|
||
updateWrapper$1(element, props);
|
||
}
|
||
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
||
var MATH_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
||
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
||
function getIntrinsicNamespace(type) {
|
||
switch (type) {
|
||
case "svg":
|
||
return SVG_NAMESPACE;
|
||
case "math":
|
||
return MATH_NAMESPACE;
|
||
default:
|
||
return HTML_NAMESPACE;
|
||
}
|
||
}
|
||
function getChildNamespace(parentNamespace, type) {
|
||
if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) {
|
||
return getIntrinsicNamespace(type);
|
||
}
|
||
if (parentNamespace === SVG_NAMESPACE && type === "foreignObject") {
|
||
return HTML_NAMESPACE;
|
||
}
|
||
return parentNamespace;
|
||
}
|
||
var createMicrosoftUnsafeLocalFunction = function(func) {
|
||
if (typeof MSApp !== "undefined" && MSApp.execUnsafeLocalFunction) {
|
||
return function(arg0, arg1, arg2, arg3) {
|
||
MSApp.execUnsafeLocalFunction(function() {
|
||
return func(arg0, arg1, arg2, arg3);
|
||
});
|
||
};
|
||
} else {
|
||
return func;
|
||
}
|
||
};
|
||
var reusableSVGContainer;
|
||
var setInnerHTML = createMicrosoftUnsafeLocalFunction(function(node, html) {
|
||
if (node.namespaceURI === SVG_NAMESPACE) {
|
||
if (!("innerHTML" in node)) {
|
||
reusableSVGContainer = reusableSVGContainer || document.createElement("div");
|
||
reusableSVGContainer.innerHTML = "<svg>" + html.valueOf().toString() + "</svg>";
|
||
var svgNode = reusableSVGContainer.firstChild;
|
||
while (node.firstChild) {
|
||
node.removeChild(node.firstChild);
|
||
}
|
||
while (svgNode.firstChild) {
|
||
node.appendChild(svgNode.firstChild);
|
||
}
|
||
return;
|
||
}
|
||
}
|
||
node.innerHTML = html;
|
||
});
|
||
var ELEMENT_NODE = 1;
|
||
var TEXT_NODE = 3;
|
||
var COMMENT_NODE = 8;
|
||
var DOCUMENT_NODE = 9;
|
||
var DOCUMENT_FRAGMENT_NODE = 11;
|
||
var setTextContent = function(node, text) {
|
||
if (text) {
|
||
var firstChild = node.firstChild;
|
||
if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) {
|
||
firstChild.nodeValue = text;
|
||
return;
|
||
}
|
||
}
|
||
node.textContent = text;
|
||
};
|
||
var shorthandToLonghand = {
|
||
animation: ["animationDelay", "animationDirection", "animationDuration", "animationFillMode", "animationIterationCount", "animationName", "animationPlayState", "animationTimingFunction"],
|
||
background: ["backgroundAttachment", "backgroundClip", "backgroundColor", "backgroundImage", "backgroundOrigin", "backgroundPositionX", "backgroundPositionY", "backgroundRepeat", "backgroundSize"],
|
||
backgroundPosition: ["backgroundPositionX", "backgroundPositionY"],
|
||
border: ["borderBottomColor", "borderBottomStyle", "borderBottomWidth", "borderImageOutset", "borderImageRepeat", "borderImageSlice", "borderImageSource", "borderImageWidth", "borderLeftColor", "borderLeftStyle", "borderLeftWidth", "borderRightColor", "borderRightStyle", "borderRightWidth", "borderTopColor", "borderTopStyle", "borderTopWidth"],
|
||
borderBlockEnd: ["borderBlockEndColor", "borderBlockEndStyle", "borderBlockEndWidth"],
|
||
borderBlockStart: ["borderBlockStartColor", "borderBlockStartStyle", "borderBlockStartWidth"],
|
||
borderBottom: ["borderBottomColor", "borderBottomStyle", "borderBottomWidth"],
|
||
borderColor: ["borderBottomColor", "borderLeftColor", "borderRightColor", "borderTopColor"],
|
||
borderImage: ["borderImageOutset", "borderImageRepeat", "borderImageSlice", "borderImageSource", "borderImageWidth"],
|
||
borderInlineEnd: ["borderInlineEndColor", "borderInlineEndStyle", "borderInlineEndWidth"],
|
||
borderInlineStart: ["borderInlineStartColor", "borderInlineStartStyle", "borderInlineStartWidth"],
|
||
borderLeft: ["borderLeftColor", "borderLeftStyle", "borderLeftWidth"],
|
||
borderRadius: ["borderBottomLeftRadius", "borderBottomRightRadius", "borderTopLeftRadius", "borderTopRightRadius"],
|
||
borderRight: ["borderRightColor", "borderRightStyle", "borderRightWidth"],
|
||
borderStyle: ["borderBottomStyle", "borderLeftStyle", "borderRightStyle", "borderTopStyle"],
|
||
borderTop: ["borderTopColor", "borderTopStyle", "borderTopWidth"],
|
||
borderWidth: ["borderBottomWidth", "borderLeftWidth", "borderRightWidth", "borderTopWidth"],
|
||
columnRule: ["columnRuleColor", "columnRuleStyle", "columnRuleWidth"],
|
||
columns: ["columnCount", "columnWidth"],
|
||
flex: ["flexBasis", "flexGrow", "flexShrink"],
|
||
flexFlow: ["flexDirection", "flexWrap"],
|
||
font: ["fontFamily", "fontFeatureSettings", "fontKerning", "fontLanguageOverride", "fontSize", "fontSizeAdjust", "fontStretch", "fontStyle", "fontVariant", "fontVariantAlternates", "fontVariantCaps", "fontVariantEastAsian", "fontVariantLigatures", "fontVariantNumeric", "fontVariantPosition", "fontWeight", "lineHeight"],
|
||
fontVariant: ["fontVariantAlternates", "fontVariantCaps", "fontVariantEastAsian", "fontVariantLigatures", "fontVariantNumeric", "fontVariantPosition"],
|
||
gap: ["columnGap", "rowGap"],
|
||
grid: ["gridAutoColumns", "gridAutoFlow", "gridAutoRows", "gridTemplateAreas", "gridTemplateColumns", "gridTemplateRows"],
|
||
gridArea: ["gridColumnEnd", "gridColumnStart", "gridRowEnd", "gridRowStart"],
|
||
gridColumn: ["gridColumnEnd", "gridColumnStart"],
|
||
gridColumnGap: ["columnGap"],
|
||
gridGap: ["columnGap", "rowGap"],
|
||
gridRow: ["gridRowEnd", "gridRowStart"],
|
||
gridRowGap: ["rowGap"],
|
||
gridTemplate: ["gridTemplateAreas", "gridTemplateColumns", "gridTemplateRows"],
|
||
listStyle: ["listStyleImage", "listStylePosition", "listStyleType"],
|
||
margin: ["marginBottom", "marginLeft", "marginRight", "marginTop"],
|
||
marker: ["markerEnd", "markerMid", "markerStart"],
|
||
mask: ["maskClip", "maskComposite", "maskImage", "maskMode", "maskOrigin", "maskPositionX", "maskPositionY", "maskRepeat", "maskSize"],
|
||
maskPosition: ["maskPositionX", "maskPositionY"],
|
||
outline: ["outlineColor", "outlineStyle", "outlineWidth"],
|
||
overflow: ["overflowX", "overflowY"],
|
||
padding: ["paddingBottom", "paddingLeft", "paddingRight", "paddingTop"],
|
||
placeContent: ["alignContent", "justifyContent"],
|
||
placeItems: ["alignItems", "justifyItems"],
|
||
placeSelf: ["alignSelf", "justifySelf"],
|
||
textDecoration: ["textDecorationColor", "textDecorationLine", "textDecorationStyle"],
|
||
textEmphasis: ["textEmphasisColor", "textEmphasisStyle"],
|
||
transition: ["transitionDelay", "transitionDuration", "transitionProperty", "transitionTimingFunction"],
|
||
wordWrap: ["overflowWrap"]
|
||
};
|
||
var isUnitlessNumber = {
|
||
animationIterationCount: true,
|
||
aspectRatio: true,
|
||
borderImageOutset: true,
|
||
borderImageSlice: true,
|
||
borderImageWidth: true,
|
||
boxFlex: true,
|
||
boxFlexGroup: true,
|
||
boxOrdinalGroup: true,
|
||
columnCount: true,
|
||
columns: true,
|
||
flex: true,
|
||
flexGrow: true,
|
||
flexPositive: true,
|
||
flexShrink: true,
|
||
flexNegative: true,
|
||
flexOrder: true,
|
||
gridArea: true,
|
||
gridRow: true,
|
||
gridRowEnd: true,
|
||
gridRowSpan: true,
|
||
gridRowStart: true,
|
||
gridColumn: true,
|
||
gridColumnEnd: true,
|
||
gridColumnSpan: true,
|
||
gridColumnStart: true,
|
||
fontWeight: true,
|
||
lineClamp: true,
|
||
lineHeight: true,
|
||
opacity: true,
|
||
order: true,
|
||
orphans: true,
|
||
tabSize: true,
|
||
widows: true,
|
||
zIndex: true,
|
||
zoom: true,
|
||
fillOpacity: true,
|
||
floodOpacity: true,
|
||
stopOpacity: true,
|
||
strokeDasharray: true,
|
||
strokeDashoffset: true,
|
||
strokeMiterlimit: true,
|
||
strokeOpacity: true,
|
||
strokeWidth: true
|
||
};
|
||
function prefixKey(prefix2, key) {
|
||
return prefix2 + key.charAt(0).toUpperCase() + key.substring(1);
|
||
}
|
||
var prefixes = ["Webkit", "ms", "Moz", "O"];
|
||
Object.keys(isUnitlessNumber).forEach(function(prop) {
|
||
prefixes.forEach(function(prefix2) {
|
||
isUnitlessNumber[prefixKey(prefix2, prop)] = isUnitlessNumber[prop];
|
||
});
|
||
});
|
||
function dangerousStyleValue(name, value, isCustomProperty) {
|
||
var isEmpty = value == null || typeof value === "boolean" || value === "";
|
||
if (isEmpty) {
|
||
return "";
|
||
}
|
||
if (!isCustomProperty && typeof value === "number" && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
|
||
return value + "px";
|
||
}
|
||
{
|
||
checkCSSPropertyStringCoercion(value, name);
|
||
}
|
||
return ("" + value).trim();
|
||
}
|
||
var uppercasePattern = /([A-Z])/g;
|
||
var msPattern = /^ms-/;
|
||
function hyphenateStyleName(name) {
|
||
return name.replace(uppercasePattern, "-$1").toLowerCase().replace(msPattern, "-ms-");
|
||
}
|
||
var warnValidStyle = function() {
|
||
};
|
||
{
|
||
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
|
||
var msPattern$1 = /^-ms-/;
|
||
var hyphenPattern = /-(.)/g;
|
||
var badStyleValueWithSemicolonPattern = /;\s*$/;
|
||
var warnedStyleNames = {};
|
||
var warnedStyleValues = {};
|
||
var warnedForNaNValue = false;
|
||
var warnedForInfinityValue = false;
|
||
var camelize = function(string) {
|
||
return string.replace(hyphenPattern, function(_, character) {
|
||
return character.toUpperCase();
|
||
});
|
||
};
|
||
var warnHyphenatedStyleName = function(name) {
|
||
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
|
||
return;
|
||
}
|
||
warnedStyleNames[name] = true;
|
||
error("Unsupported style property %s. Did you mean %s?", name, camelize(name.replace(msPattern$1, "ms-")));
|
||
};
|
||
var warnBadVendoredStyleName = function(name) {
|
||
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
|
||
return;
|
||
}
|
||
warnedStyleNames[name] = true;
|
||
error("Unsupported vendor-prefixed style property %s. Did you mean %s?", name, name.charAt(0).toUpperCase() + name.slice(1));
|
||
};
|
||
var warnStyleValueWithSemicolon = function(name, value) {
|
||
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
|
||
return;
|
||
}
|
||
warnedStyleValues[value] = true;
|
||
error(`Style property values shouldn't contain a semicolon. Try "%s: %s" instead.`, name, value.replace(badStyleValueWithSemicolonPattern, ""));
|
||
};
|
||
var warnStyleValueIsNaN = function(name, value) {
|
||
if (warnedForNaNValue) {
|
||
return;
|
||
}
|
||
warnedForNaNValue = true;
|
||
error("`NaN` is an invalid value for the `%s` css style property.", name);
|
||
};
|
||
var warnStyleValueIsInfinity = function(name, value) {
|
||
if (warnedForInfinityValue) {
|
||
return;
|
||
}
|
||
warnedForInfinityValue = true;
|
||
error("`Infinity` is an invalid value for the `%s` css style property.", name);
|
||
};
|
||
warnValidStyle = function(name, value) {
|
||
if (name.indexOf("-") > -1) {
|
||
warnHyphenatedStyleName(name);
|
||
} else if (badVendoredStyleNamePattern.test(name)) {
|
||
warnBadVendoredStyleName(name);
|
||
} else if (badStyleValueWithSemicolonPattern.test(value)) {
|
||
warnStyleValueWithSemicolon(name, value);
|
||
}
|
||
if (typeof value === "number") {
|
||
if (isNaN(value)) {
|
||
warnStyleValueIsNaN(name, value);
|
||
} else if (!isFinite(value)) {
|
||
warnStyleValueIsInfinity(name, value);
|
||
}
|
||
}
|
||
};
|
||
}
|
||
var warnValidStyle$1 = warnValidStyle;
|
||
function createDangerousStringForStyles(styles) {
|
||
{
|
||
var serialized = "";
|
||
var delimiter = "";
|
||
for (var styleName in styles) {
|
||
if (!styles.hasOwnProperty(styleName)) {
|
||
continue;
|
||
}
|
||
var styleValue = styles[styleName];
|
||
if (styleValue != null) {
|
||
var isCustomProperty = styleName.indexOf("--") === 0;
|
||
serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ":";
|
||
serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);
|
||
delimiter = ";";
|
||
}
|
||
}
|
||
return serialized || null;
|
||
}
|
||
}
|
||
function setValueForStyles(node, styles) {
|
||
var style2 = node.style;
|
||
for (var styleName in styles) {
|
||
if (!styles.hasOwnProperty(styleName)) {
|
||
continue;
|
||
}
|
||
var isCustomProperty = styleName.indexOf("--") === 0;
|
||
{
|
||
if (!isCustomProperty) {
|
||
warnValidStyle$1(styleName, styles[styleName]);
|
||
}
|
||
}
|
||
var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);
|
||
if (styleName === "float") {
|
||
styleName = "cssFloat";
|
||
}
|
||
if (isCustomProperty) {
|
||
style2.setProperty(styleName, styleValue);
|
||
} else {
|
||
style2[styleName] = styleValue;
|
||
}
|
||
}
|
||
}
|
||
function isValueEmpty(value) {
|
||
return value == null || typeof value === "boolean" || value === "";
|
||
}
|
||
function expandShorthandMap(styles) {
|
||
var expanded = {};
|
||
for (var key in styles) {
|
||
var longhands = shorthandToLonghand[key] || [key];
|
||
for (var i = 0; i < longhands.length; i++) {
|
||
expanded[longhands[i]] = key;
|
||
}
|
||
}
|
||
return expanded;
|
||
}
|
||
function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) {
|
||
{
|
||
if (!nextStyles) {
|
||
return;
|
||
}
|
||
var expandedUpdates = expandShorthandMap(styleUpdates);
|
||
var expandedStyles = expandShorthandMap(nextStyles);
|
||
var warnedAbout = {};
|
||
for (var key in expandedUpdates) {
|
||
var originalKey = expandedUpdates[key];
|
||
var correctOriginalKey = expandedStyles[key];
|
||
if (correctOriginalKey && originalKey !== correctOriginalKey) {
|
||
var warningKey = originalKey + "," + correctOriginalKey;
|
||
if (warnedAbout[warningKey]) {
|
||
continue;
|
||
}
|
||
warnedAbout[warningKey] = true;
|
||
error("%s a style property during rerender (%s) when a conflicting property is set (%s) can lead to styling bugs. To avoid this, don't mix shorthand and non-shorthand properties for the same value; instead, replace the shorthand with separate values.", isValueEmpty(styleUpdates[originalKey]) ? "Removing" : "Updating", originalKey, correctOriginalKey);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var omittedCloseTags = {
|
||
area: true,
|
||
base: true,
|
||
br: true,
|
||
col: true,
|
||
embed: true,
|
||
hr: true,
|
||
img: true,
|
||
input: true,
|
||
keygen: true,
|
||
link: true,
|
||
meta: true,
|
||
param: true,
|
||
source: true,
|
||
track: true,
|
||
wbr: true
|
||
};
|
||
var voidElementTags = assign({
|
||
menuitem: true
|
||
}, omittedCloseTags);
|
||
var HTML = "__html";
|
||
function assertValidProps(tag, props) {
|
||
if (!props) {
|
||
return;
|
||
}
|
||
if (voidElementTags[tag]) {
|
||
if (props.children != null || props.dangerouslySetInnerHTML != null) {
|
||
throw new Error(tag + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.");
|
||
}
|
||
}
|
||
if (props.dangerouslySetInnerHTML != null) {
|
||
if (props.children != null) {
|
||
throw new Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
|
||
}
|
||
if (typeof props.dangerouslySetInnerHTML !== "object" || !(HTML in props.dangerouslySetInnerHTML)) {
|
||
throw new Error("`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information.");
|
||
}
|
||
}
|
||
{
|
||
if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) {
|
||
error("A component is `contentEditable` and contains `children` managed by React. It is now your responsibility to guarantee that none of those nodes are unexpectedly modified or duplicated. This is probably not intentional.");
|
||
}
|
||
}
|
||
if (props.style != null && typeof props.style !== "object") {
|
||
throw new Error("The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX.");
|
||
}
|
||
}
|
||
function isCustomComponent(tagName, props) {
|
||
if (tagName.indexOf("-") === -1) {
|
||
return typeof props.is === "string";
|
||
}
|
||
switch (tagName) {
|
||
case "annotation-xml":
|
||
case "color-profile":
|
||
case "font-face":
|
||
case "font-face-src":
|
||
case "font-face-uri":
|
||
case "font-face-format":
|
||
case "font-face-name":
|
||
case "missing-glyph":
|
||
return false;
|
||
default:
|
||
return true;
|
||
}
|
||
}
|
||
var possibleStandardNames = {
|
||
accept: "accept",
|
||
acceptcharset: "acceptCharset",
|
||
"accept-charset": "acceptCharset",
|
||
accesskey: "accessKey",
|
||
action: "action",
|
||
allowfullscreen: "allowFullScreen",
|
||
alt: "alt",
|
||
as: "as",
|
||
async: "async",
|
||
autocapitalize: "autoCapitalize",
|
||
autocomplete: "autoComplete",
|
||
autocorrect: "autoCorrect",
|
||
autofocus: "autoFocus",
|
||
autoplay: "autoPlay",
|
||
autosave: "autoSave",
|
||
capture: "capture",
|
||
cellpadding: "cellPadding",
|
||
cellspacing: "cellSpacing",
|
||
challenge: "challenge",
|
||
charset: "charSet",
|
||
checked: "checked",
|
||
children: "children",
|
||
cite: "cite",
|
||
class: "className",
|
||
classid: "classID",
|
||
classname: "className",
|
||
cols: "cols",
|
||
colspan: "colSpan",
|
||
content: "content",
|
||
contenteditable: "contentEditable",
|
||
contextmenu: "contextMenu",
|
||
controls: "controls",
|
||
controlslist: "controlsList",
|
||
coords: "coords",
|
||
crossorigin: "crossOrigin",
|
||
dangerouslysetinnerhtml: "dangerouslySetInnerHTML",
|
||
data: "data",
|
||
datetime: "dateTime",
|
||
default: "default",
|
||
defaultchecked: "defaultChecked",
|
||
defaultvalue: "defaultValue",
|
||
defer: "defer",
|
||
dir: "dir",
|
||
disabled: "disabled",
|
||
disablepictureinpicture: "disablePictureInPicture",
|
||
disableremoteplayback: "disableRemotePlayback",
|
||
download: "download",
|
||
draggable: "draggable",
|
||
enctype: "encType",
|
||
enterkeyhint: "enterKeyHint",
|
||
for: "htmlFor",
|
||
form: "form",
|
||
formmethod: "formMethod",
|
||
formaction: "formAction",
|
||
formenctype: "formEncType",
|
||
formnovalidate: "formNoValidate",
|
||
formtarget: "formTarget",
|
||
frameborder: "frameBorder",
|
||
headers: "headers",
|
||
height: "height",
|
||
hidden: "hidden",
|
||
high: "high",
|
||
href: "href",
|
||
hreflang: "hrefLang",
|
||
htmlfor: "htmlFor",
|
||
httpequiv: "httpEquiv",
|
||
"http-equiv": "httpEquiv",
|
||
icon: "icon",
|
||
id: "id",
|
||
imagesizes: "imageSizes",
|
||
imagesrcset: "imageSrcSet",
|
||
innerhtml: "innerHTML",
|
||
inputmode: "inputMode",
|
||
integrity: "integrity",
|
||
is: "is",
|
||
itemid: "itemID",
|
||
itemprop: "itemProp",
|
||
itemref: "itemRef",
|
||
itemscope: "itemScope",
|
||
itemtype: "itemType",
|
||
keyparams: "keyParams",
|
||
keytype: "keyType",
|
||
kind: "kind",
|
||
label: "label",
|
||
lang: "lang",
|
||
list: "list",
|
||
loop: "loop",
|
||
low: "low",
|
||
manifest: "manifest",
|
||
marginwidth: "marginWidth",
|
||
marginheight: "marginHeight",
|
||
max: "max",
|
||
maxlength: "maxLength",
|
||
media: "media",
|
||
mediagroup: "mediaGroup",
|
||
method: "method",
|
||
min: "min",
|
||
minlength: "minLength",
|
||
multiple: "multiple",
|
||
muted: "muted",
|
||
name: "name",
|
||
nomodule: "noModule",
|
||
nonce: "nonce",
|
||
novalidate: "noValidate",
|
||
open: "open",
|
||
optimum: "optimum",
|
||
pattern: "pattern",
|
||
placeholder: "placeholder",
|
||
playsinline: "playsInline",
|
||
poster: "poster",
|
||
preload: "preload",
|
||
profile: "profile",
|
||
radiogroup: "radioGroup",
|
||
readonly: "readOnly",
|
||
referrerpolicy: "referrerPolicy",
|
||
rel: "rel",
|
||
required: "required",
|
||
reversed: "reversed",
|
||
role: "role",
|
||
rows: "rows",
|
||
rowspan: "rowSpan",
|
||
sandbox: "sandbox",
|
||
scope: "scope",
|
||
scoped: "scoped",
|
||
scrolling: "scrolling",
|
||
seamless: "seamless",
|
||
selected: "selected",
|
||
shape: "shape",
|
||
size: "size",
|
||
sizes: "sizes",
|
||
span: "span",
|
||
spellcheck: "spellCheck",
|
||
src: "src",
|
||
srcdoc: "srcDoc",
|
||
srclang: "srcLang",
|
||
srcset: "srcSet",
|
||
start: "start",
|
||
step: "step",
|
||
style: "style",
|
||
summary: "summary",
|
||
tabindex: "tabIndex",
|
||
target: "target",
|
||
title: "title",
|
||
type: "type",
|
||
usemap: "useMap",
|
||
value: "value",
|
||
width: "width",
|
||
wmode: "wmode",
|
||
wrap: "wrap",
|
||
about: "about",
|
||
accentheight: "accentHeight",
|
||
"accent-height": "accentHeight",
|
||
accumulate: "accumulate",
|
||
additive: "additive",
|
||
alignmentbaseline: "alignmentBaseline",
|
||
"alignment-baseline": "alignmentBaseline",
|
||
allowreorder: "allowReorder",
|
||
alphabetic: "alphabetic",
|
||
amplitude: "amplitude",
|
||
arabicform: "arabicForm",
|
||
"arabic-form": "arabicForm",
|
||
ascent: "ascent",
|
||
attributename: "attributeName",
|
||
attributetype: "attributeType",
|
||
autoreverse: "autoReverse",
|
||
azimuth: "azimuth",
|
||
basefrequency: "baseFrequency",
|
||
baselineshift: "baselineShift",
|
||
"baseline-shift": "baselineShift",
|
||
baseprofile: "baseProfile",
|
||
bbox: "bbox",
|
||
begin: "begin",
|
||
bias: "bias",
|
||
by: "by",
|
||
calcmode: "calcMode",
|
||
capheight: "capHeight",
|
||
"cap-height": "capHeight",
|
||
clip: "clip",
|
||
clippath: "clipPath",
|
||
"clip-path": "clipPath",
|
||
clippathunits: "clipPathUnits",
|
||
cliprule: "clipRule",
|
||
"clip-rule": "clipRule",
|
||
color: "color",
|
||
colorinterpolation: "colorInterpolation",
|
||
"color-interpolation": "colorInterpolation",
|
||
colorinterpolationfilters: "colorInterpolationFilters",
|
||
"color-interpolation-filters": "colorInterpolationFilters",
|
||
colorprofile: "colorProfile",
|
||
"color-profile": "colorProfile",
|
||
colorrendering: "colorRendering",
|
||
"color-rendering": "colorRendering",
|
||
contentscripttype: "contentScriptType",
|
||
contentstyletype: "contentStyleType",
|
||
cursor: "cursor",
|
||
cx: "cx",
|
||
cy: "cy",
|
||
d: "d",
|
||
datatype: "datatype",
|
||
decelerate: "decelerate",
|
||
descent: "descent",
|
||
diffuseconstant: "diffuseConstant",
|
||
direction: "direction",
|
||
display: "display",
|
||
divisor: "divisor",
|
||
dominantbaseline: "dominantBaseline",
|
||
"dominant-baseline": "dominantBaseline",
|
||
dur: "dur",
|
||
dx: "dx",
|
||
dy: "dy",
|
||
edgemode: "edgeMode",
|
||
elevation: "elevation",
|
||
enablebackground: "enableBackground",
|
||
"enable-background": "enableBackground",
|
||
end: "end",
|
||
exponent: "exponent",
|
||
externalresourcesrequired: "externalResourcesRequired",
|
||
fill: "fill",
|
||
fillopacity: "fillOpacity",
|
||
"fill-opacity": "fillOpacity",
|
||
fillrule: "fillRule",
|
||
"fill-rule": "fillRule",
|
||
filter: "filter",
|
||
filterres: "filterRes",
|
||
filterunits: "filterUnits",
|
||
floodopacity: "floodOpacity",
|
||
"flood-opacity": "floodOpacity",
|
||
floodcolor: "floodColor",
|
||
"flood-color": "floodColor",
|
||
focusable: "focusable",
|
||
fontfamily: "fontFamily",
|
||
"font-family": "fontFamily",
|
||
fontsize: "fontSize",
|
||
"font-size": "fontSize",
|
||
fontsizeadjust: "fontSizeAdjust",
|
||
"font-size-adjust": "fontSizeAdjust",
|
||
fontstretch: "fontStretch",
|
||
"font-stretch": "fontStretch",
|
||
fontstyle: "fontStyle",
|
||
"font-style": "fontStyle",
|
||
fontvariant: "fontVariant",
|
||
"font-variant": "fontVariant",
|
||
fontweight: "fontWeight",
|
||
"font-weight": "fontWeight",
|
||
format: "format",
|
||
from: "from",
|
||
fx: "fx",
|
||
fy: "fy",
|
||
g1: "g1",
|
||
g2: "g2",
|
||
glyphname: "glyphName",
|
||
"glyph-name": "glyphName",
|
||
glyphorientationhorizontal: "glyphOrientationHorizontal",
|
||
"glyph-orientation-horizontal": "glyphOrientationHorizontal",
|
||
glyphorientationvertical: "glyphOrientationVertical",
|
||
"glyph-orientation-vertical": "glyphOrientationVertical",
|
||
glyphref: "glyphRef",
|
||
gradienttransform: "gradientTransform",
|
||
gradientunits: "gradientUnits",
|
||
hanging: "hanging",
|
||
horizadvx: "horizAdvX",
|
||
"horiz-adv-x": "horizAdvX",
|
||
horizoriginx: "horizOriginX",
|
||
"horiz-origin-x": "horizOriginX",
|
||
ideographic: "ideographic",
|
||
imagerendering: "imageRendering",
|
||
"image-rendering": "imageRendering",
|
||
in2: "in2",
|
||
in: "in",
|
||
inlist: "inlist",
|
||
intercept: "intercept",
|
||
k1: "k1",
|
||
k2: "k2",
|
||
k3: "k3",
|
||
k4: "k4",
|
||
k: "k",
|
||
kernelmatrix: "kernelMatrix",
|
||
kernelunitlength: "kernelUnitLength",
|
||
kerning: "kerning",
|
||
keypoints: "keyPoints",
|
||
keysplines: "keySplines",
|
||
keytimes: "keyTimes",
|
||
lengthadjust: "lengthAdjust",
|
||
letterspacing: "letterSpacing",
|
||
"letter-spacing": "letterSpacing",
|
||
lightingcolor: "lightingColor",
|
||
"lighting-color": "lightingColor",
|
||
limitingconeangle: "limitingConeAngle",
|
||
local: "local",
|
||
markerend: "markerEnd",
|
||
"marker-end": "markerEnd",
|
||
markerheight: "markerHeight",
|
||
markermid: "markerMid",
|
||
"marker-mid": "markerMid",
|
||
markerstart: "markerStart",
|
||
"marker-start": "markerStart",
|
||
markerunits: "markerUnits",
|
||
markerwidth: "markerWidth",
|
||
mask: "mask",
|
||
maskcontentunits: "maskContentUnits",
|
||
maskunits: "maskUnits",
|
||
mathematical: "mathematical",
|
||
mode: "mode",
|
||
numoctaves: "numOctaves",
|
||
offset: "offset",
|
||
opacity: "opacity",
|
||
operator: "operator",
|
||
order: "order",
|
||
orient: "orient",
|
||
orientation: "orientation",
|
||
origin: "origin",
|
||
overflow: "overflow",
|
||
overlineposition: "overlinePosition",
|
||
"overline-position": "overlinePosition",
|
||
overlinethickness: "overlineThickness",
|
||
"overline-thickness": "overlineThickness",
|
||
paintorder: "paintOrder",
|
||
"paint-order": "paintOrder",
|
||
panose1: "panose1",
|
||
"panose-1": "panose1",
|
||
pathlength: "pathLength",
|
||
patterncontentunits: "patternContentUnits",
|
||
patterntransform: "patternTransform",
|
||
patternunits: "patternUnits",
|
||
pointerevents: "pointerEvents",
|
||
"pointer-events": "pointerEvents",
|
||
points: "points",
|
||
pointsatx: "pointsAtX",
|
||
pointsaty: "pointsAtY",
|
||
pointsatz: "pointsAtZ",
|
||
prefix: "prefix",
|
||
preservealpha: "preserveAlpha",
|
||
preserveaspectratio: "preserveAspectRatio",
|
||
primitiveunits: "primitiveUnits",
|
||
property: "property",
|
||
r: "r",
|
||
radius: "radius",
|
||
refx: "refX",
|
||
refy: "refY",
|
||
renderingintent: "renderingIntent",
|
||
"rendering-intent": "renderingIntent",
|
||
repeatcount: "repeatCount",
|
||
repeatdur: "repeatDur",
|
||
requiredextensions: "requiredExtensions",
|
||
requiredfeatures: "requiredFeatures",
|
||
resource: "resource",
|
||
restart: "restart",
|
||
result: "result",
|
||
results: "results",
|
||
rotate: "rotate",
|
||
rx: "rx",
|
||
ry: "ry",
|
||
scale: "scale",
|
||
security: "security",
|
||
seed: "seed",
|
||
shaperendering: "shapeRendering",
|
||
"shape-rendering": "shapeRendering",
|
||
slope: "slope",
|
||
spacing: "spacing",
|
||
specularconstant: "specularConstant",
|
||
specularexponent: "specularExponent",
|
||
speed: "speed",
|
||
spreadmethod: "spreadMethod",
|
||
startoffset: "startOffset",
|
||
stddeviation: "stdDeviation",
|
||
stemh: "stemh",
|
||
stemv: "stemv",
|
||
stitchtiles: "stitchTiles",
|
||
stopcolor: "stopColor",
|
||
"stop-color": "stopColor",
|
||
stopopacity: "stopOpacity",
|
||
"stop-opacity": "stopOpacity",
|
||
strikethroughposition: "strikethroughPosition",
|
||
"strikethrough-position": "strikethroughPosition",
|
||
strikethroughthickness: "strikethroughThickness",
|
||
"strikethrough-thickness": "strikethroughThickness",
|
||
string: "string",
|
||
stroke: "stroke",
|
||
strokedasharray: "strokeDasharray",
|
||
"stroke-dasharray": "strokeDasharray",
|
||
strokedashoffset: "strokeDashoffset",
|
||
"stroke-dashoffset": "strokeDashoffset",
|
||
strokelinecap: "strokeLinecap",
|
||
"stroke-linecap": "strokeLinecap",
|
||
strokelinejoin: "strokeLinejoin",
|
||
"stroke-linejoin": "strokeLinejoin",
|
||
strokemiterlimit: "strokeMiterlimit",
|
||
"stroke-miterlimit": "strokeMiterlimit",
|
||
strokewidth: "strokeWidth",
|
||
"stroke-width": "strokeWidth",
|
||
strokeopacity: "strokeOpacity",
|
||
"stroke-opacity": "strokeOpacity",
|
||
suppresscontenteditablewarning: "suppressContentEditableWarning",
|
||
suppresshydrationwarning: "suppressHydrationWarning",
|
||
surfacescale: "surfaceScale",
|
||
systemlanguage: "systemLanguage",
|
||
tablevalues: "tableValues",
|
||
targetx: "targetX",
|
||
targety: "targetY",
|
||
textanchor: "textAnchor",
|
||
"text-anchor": "textAnchor",
|
||
textdecoration: "textDecoration",
|
||
"text-decoration": "textDecoration",
|
||
textlength: "textLength",
|
||
textrendering: "textRendering",
|
||
"text-rendering": "textRendering",
|
||
to: "to",
|
||
transform: "transform",
|
||
typeof: "typeof",
|
||
u1: "u1",
|
||
u2: "u2",
|
||
underlineposition: "underlinePosition",
|
||
"underline-position": "underlinePosition",
|
||
underlinethickness: "underlineThickness",
|
||
"underline-thickness": "underlineThickness",
|
||
unicode: "unicode",
|
||
unicodebidi: "unicodeBidi",
|
||
"unicode-bidi": "unicodeBidi",
|
||
unicoderange: "unicodeRange",
|
||
"unicode-range": "unicodeRange",
|
||
unitsperem: "unitsPerEm",
|
||
"units-per-em": "unitsPerEm",
|
||
unselectable: "unselectable",
|
||
valphabetic: "vAlphabetic",
|
||
"v-alphabetic": "vAlphabetic",
|
||
values: "values",
|
||
vectoreffect: "vectorEffect",
|
||
"vector-effect": "vectorEffect",
|
||
version: "version",
|
||
vertadvy: "vertAdvY",
|
||
"vert-adv-y": "vertAdvY",
|
||
vertoriginx: "vertOriginX",
|
||
"vert-origin-x": "vertOriginX",
|
||
vertoriginy: "vertOriginY",
|
||
"vert-origin-y": "vertOriginY",
|
||
vhanging: "vHanging",
|
||
"v-hanging": "vHanging",
|
||
videographic: "vIdeographic",
|
||
"v-ideographic": "vIdeographic",
|
||
viewbox: "viewBox",
|
||
viewtarget: "viewTarget",
|
||
visibility: "visibility",
|
||
vmathematical: "vMathematical",
|
||
"v-mathematical": "vMathematical",
|
||
vocab: "vocab",
|
||
widths: "widths",
|
||
wordspacing: "wordSpacing",
|
||
"word-spacing": "wordSpacing",
|
||
writingmode: "writingMode",
|
||
"writing-mode": "writingMode",
|
||
x1: "x1",
|
||
x2: "x2",
|
||
x: "x",
|
||
xchannelselector: "xChannelSelector",
|
||
xheight: "xHeight",
|
||
"x-height": "xHeight",
|
||
xlinkactuate: "xlinkActuate",
|
||
"xlink:actuate": "xlinkActuate",
|
||
xlinkarcrole: "xlinkArcrole",
|
||
"xlink:arcrole": "xlinkArcrole",
|
||
xlinkhref: "xlinkHref",
|
||
"xlink:href": "xlinkHref",
|
||
xlinkrole: "xlinkRole",
|
||
"xlink:role": "xlinkRole",
|
||
xlinkshow: "xlinkShow",
|
||
"xlink:show": "xlinkShow",
|
||
xlinktitle: "xlinkTitle",
|
||
"xlink:title": "xlinkTitle",
|
||
xlinktype: "xlinkType",
|
||
"xlink:type": "xlinkType",
|
||
xmlbase: "xmlBase",
|
||
"xml:base": "xmlBase",
|
||
xmllang: "xmlLang",
|
||
"xml:lang": "xmlLang",
|
||
xmlns: "xmlns",
|
||
"xml:space": "xmlSpace",
|
||
xmlnsxlink: "xmlnsXlink",
|
||
"xmlns:xlink": "xmlnsXlink",
|
||
xmlspace: "xmlSpace",
|
||
y1: "y1",
|
||
y2: "y2",
|
||
y: "y",
|
||
ychannelselector: "yChannelSelector",
|
||
z: "z",
|
||
zoomandpan: "zoomAndPan"
|
||
};
|
||
var ariaProperties = {
|
||
"aria-current": 0,
|
||
"aria-description": 0,
|
||
"aria-details": 0,
|
||
"aria-disabled": 0,
|
||
"aria-hidden": 0,
|
||
"aria-invalid": 0,
|
||
"aria-keyshortcuts": 0,
|
||
"aria-label": 0,
|
||
"aria-roledescription": 0,
|
||
"aria-autocomplete": 0,
|
||
"aria-checked": 0,
|
||
"aria-expanded": 0,
|
||
"aria-haspopup": 0,
|
||
"aria-level": 0,
|
||
"aria-modal": 0,
|
||
"aria-multiline": 0,
|
||
"aria-multiselectable": 0,
|
||
"aria-orientation": 0,
|
||
"aria-placeholder": 0,
|
||
"aria-pressed": 0,
|
||
"aria-readonly": 0,
|
||
"aria-required": 0,
|
||
"aria-selected": 0,
|
||
"aria-sort": 0,
|
||
"aria-valuemax": 0,
|
||
"aria-valuemin": 0,
|
||
"aria-valuenow": 0,
|
||
"aria-valuetext": 0,
|
||
"aria-atomic": 0,
|
||
"aria-busy": 0,
|
||
"aria-live": 0,
|
||
"aria-relevant": 0,
|
||
"aria-dropeffect": 0,
|
||
"aria-grabbed": 0,
|
||
"aria-activedescendant": 0,
|
||
"aria-colcount": 0,
|
||
"aria-colindex": 0,
|
||
"aria-colspan": 0,
|
||
"aria-controls": 0,
|
||
"aria-describedby": 0,
|
||
"aria-errormessage": 0,
|
||
"aria-flowto": 0,
|
||
"aria-labelledby": 0,
|
||
"aria-owns": 0,
|
||
"aria-posinset": 0,
|
||
"aria-rowcount": 0,
|
||
"aria-rowindex": 0,
|
||
"aria-rowspan": 0,
|
||
"aria-setsize": 0
|
||
};
|
||
var warnedProperties = {};
|
||
var rARIA = new RegExp("^(aria)-[" + ATTRIBUTE_NAME_CHAR + "]*$");
|
||
var rARIACamel = new RegExp("^(aria)[A-Z][" + ATTRIBUTE_NAME_CHAR + "]*$");
|
||
function validateProperty(tagName, name) {
|
||
{
|
||
if (hasOwnProperty2.call(warnedProperties, name) && warnedProperties[name]) {
|
||
return true;
|
||
}
|
||
if (rARIACamel.test(name)) {
|
||
var ariaName = "aria-" + name.slice(4).toLowerCase();
|
||
var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
|
||
if (correctName == null) {
|
||
error("Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.", name);
|
||
warnedProperties[name] = true;
|
||
return true;
|
||
}
|
||
if (name !== correctName) {
|
||
error("Invalid ARIA attribute `%s`. Did you mean `%s`?", name, correctName);
|
||
warnedProperties[name] = true;
|
||
return true;
|
||
}
|
||
}
|
||
if (rARIA.test(name)) {
|
||
var lowerCasedName = name.toLowerCase();
|
||
var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
|
||
if (standardName == null) {
|
||
warnedProperties[name] = true;
|
||
return false;
|
||
}
|
||
if (name !== standardName) {
|
||
error("Unknown ARIA attribute `%s`. Did you mean `%s`?", name, standardName);
|
||
warnedProperties[name] = true;
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
function warnInvalidARIAProps(type, props) {
|
||
{
|
||
var invalidProps = [];
|
||
for (var key in props) {
|
||
var isValid = validateProperty(type, key);
|
||
if (!isValid) {
|
||
invalidProps.push(key);
|
||
}
|
||
}
|
||
var unknownPropString = invalidProps.map(function(prop) {
|
||
return "`" + prop + "`";
|
||
}).join(", ");
|
||
if (invalidProps.length === 1) {
|
||
error("Invalid aria prop %s on <%s> tag. For details, see https://reactjs.org/link/invalid-aria-props", unknownPropString, type);
|
||
} else if (invalidProps.length > 1) {
|
||
error("Invalid aria props %s on <%s> tag. For details, see https://reactjs.org/link/invalid-aria-props", unknownPropString, type);
|
||
}
|
||
}
|
||
}
|
||
function validateProperties(type, props) {
|
||
if (isCustomComponent(type, props)) {
|
||
return;
|
||
}
|
||
warnInvalidARIAProps(type, props);
|
||
}
|
||
var didWarnValueNull = false;
|
||
function validateProperties$1(type, props) {
|
||
{
|
||
if (type !== "input" && type !== "textarea" && type !== "select") {
|
||
return;
|
||
}
|
||
if (props != null && props.value === null && !didWarnValueNull) {
|
||
didWarnValueNull = true;
|
||
if (type === "select" && props.multiple) {
|
||
error("`value` prop on `%s` should not be null. Consider using an empty array when `multiple` is set to `true` to clear the component or `undefined` for uncontrolled components.", type);
|
||
} else {
|
||
error("`value` prop on `%s` should not be null. Consider using an empty string to clear the component or `undefined` for uncontrolled components.", type);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var validateProperty$1 = function() {
|
||
};
|
||
{
|
||
var warnedProperties$1 = {};
|
||
var EVENT_NAME_REGEX = /^on./;
|
||
var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
|
||
var rARIA$1 = new RegExp("^(aria)-[" + ATTRIBUTE_NAME_CHAR + "]*$");
|
||
var rARIACamel$1 = new RegExp("^(aria)[A-Z][" + ATTRIBUTE_NAME_CHAR + "]*$");
|
||
validateProperty$1 = function(tagName, name, value, eventRegistry) {
|
||
if (hasOwnProperty2.call(warnedProperties$1, name) && warnedProperties$1[name]) {
|
||
return true;
|
||
}
|
||
var lowerCasedName = name.toLowerCase();
|
||
if (lowerCasedName === "onfocusin" || lowerCasedName === "onfocusout") {
|
||
error("React uses onFocus and onBlur instead of onFocusIn and onFocusOut. All React events are normalized to bubble, so onFocusIn and onFocusOut are not needed/supported by React.");
|
||
warnedProperties$1[name] = true;
|
||
return true;
|
||
}
|
||
if (eventRegistry != null) {
|
||
var registrationNameDependencies2 = eventRegistry.registrationNameDependencies, possibleRegistrationNames2 = eventRegistry.possibleRegistrationNames;
|
||
if (registrationNameDependencies2.hasOwnProperty(name)) {
|
||
return true;
|
||
}
|
||
var registrationName = possibleRegistrationNames2.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames2[lowerCasedName] : null;
|
||
if (registrationName != null) {
|
||
error("Invalid event handler property `%s`. Did you mean `%s`?", name, registrationName);
|
||
warnedProperties$1[name] = true;
|
||
return true;
|
||
}
|
||
if (EVENT_NAME_REGEX.test(name)) {
|
||
error("Unknown event handler property `%s`. It will be ignored.", name);
|
||
warnedProperties$1[name] = true;
|
||
return true;
|
||
}
|
||
} else if (EVENT_NAME_REGEX.test(name)) {
|
||
if (INVALID_EVENT_NAME_REGEX.test(name)) {
|
||
error("Invalid event handler property `%s`. React events use the camelCase naming convention, for example `onClick`.", name);
|
||
}
|
||
warnedProperties$1[name] = true;
|
||
return true;
|
||
}
|
||
if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
|
||
return true;
|
||
}
|
||
if (lowerCasedName === "innerhtml") {
|
||
error("Directly setting property `innerHTML` is not permitted. For more information, lookup documentation on `dangerouslySetInnerHTML`.");
|
||
warnedProperties$1[name] = true;
|
||
return true;
|
||
}
|
||
if (lowerCasedName === "aria") {
|
||
error("The `aria` attribute is reserved for future use in React. Pass individual `aria-` attributes instead.");
|
||
warnedProperties$1[name] = true;
|
||
return true;
|
||
}
|
||
if (lowerCasedName === "is" && value !== null && value !== void 0 && typeof value !== "string") {
|
||
error("Received a `%s` for a string attribute `is`. If this is expected, cast the value to a string.", typeof value);
|
||
warnedProperties$1[name] = true;
|
||
return true;
|
||
}
|
||
if (typeof value === "number" && isNaN(value)) {
|
||
error("Received NaN for the `%s` attribute. If this is expected, cast the value to a string.", name);
|
||
warnedProperties$1[name] = true;
|
||
return true;
|
||
}
|
||
var propertyInfo = getPropertyInfo(name);
|
||
var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED;
|
||
if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
|
||
var standardName = possibleStandardNames[lowerCasedName];
|
||
if (standardName !== name) {
|
||
error("Invalid DOM property `%s`. Did you mean `%s`?", name, standardName);
|
||
warnedProperties$1[name] = true;
|
||
return true;
|
||
}
|
||
} else if (!isReserved && name !== lowerCasedName) {
|
||
error("React does not recognize the `%s` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `%s` instead. If you accidentally passed it from a parent component, remove it from the DOM element.", name, lowerCasedName);
|
||
warnedProperties$1[name] = true;
|
||
return true;
|
||
}
|
||
if (typeof value === "boolean" && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
|
||
if (value) {
|
||
error('Received `%s` for a non-boolean attribute `%s`.\n\nIf you want to write it to the DOM, pass a string instead: %s="%s" or %s={value.toString()}.', value, name, name, value, name);
|
||
} else {
|
||
error('Received `%s` for a non-boolean attribute `%s`.\n\nIf you want to write it to the DOM, pass a string instead: %s="%s" or %s={value.toString()}.\n\nIf you used to conditionally omit it with %s={condition && value}, pass %s={condition ? value : undefined} instead.', value, name, name, value, name, name, name);
|
||
}
|
||
warnedProperties$1[name] = true;
|
||
return true;
|
||
}
|
||
if (isReserved) {
|
||
return true;
|
||
}
|
||
if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
|
||
warnedProperties$1[name] = true;
|
||
return false;
|
||
}
|
||
if ((value === "false" || value === "true") && propertyInfo !== null && propertyInfo.type === BOOLEAN) {
|
||
error("Received the string `%s` for the boolean attribute `%s`. %s Did you mean %s={%s}?", value, name, value === "false" ? "The browser will interpret it as a truthy value." : 'Although this works, it will not work as expected if you pass the string "false".', name, value);
|
||
warnedProperties$1[name] = true;
|
||
return true;
|
||
}
|
||
return true;
|
||
};
|
||
}
|
||
var warnUnknownProperties = function(type, props, eventRegistry) {
|
||
{
|
||
var unknownProps = [];
|
||
for (var key in props) {
|
||
var isValid = validateProperty$1(type, key, props[key], eventRegistry);
|
||
if (!isValid) {
|
||
unknownProps.push(key);
|
||
}
|
||
}
|
||
var unknownPropString = unknownProps.map(function(prop) {
|
||
return "`" + prop + "`";
|
||
}).join(", ");
|
||
if (unknownProps.length === 1) {
|
||
error("Invalid value for prop %s on <%s> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM. For details, see https://reactjs.org/link/attribute-behavior ", unknownPropString, type);
|
||
} else if (unknownProps.length > 1) {
|
||
error("Invalid values for props %s on <%s> tag. Either remove them from the element, or pass a string or number value to keep them in the DOM. For details, see https://reactjs.org/link/attribute-behavior ", unknownPropString, type);
|
||
}
|
||
}
|
||
};
|
||
function validateProperties$2(type, props, eventRegistry) {
|
||
if (isCustomComponent(type, props)) {
|
||
return;
|
||
}
|
||
warnUnknownProperties(type, props, eventRegistry);
|
||
}
|
||
var IS_EVENT_HANDLE_NON_MANAGED_NODE = 1;
|
||
var IS_NON_DELEGATED = 1 << 1;
|
||
var IS_CAPTURE_PHASE = 1 << 2;
|
||
var SHOULD_NOT_PROCESS_POLYFILL_EVENT_PLUGINS = IS_EVENT_HANDLE_NON_MANAGED_NODE | IS_NON_DELEGATED | IS_CAPTURE_PHASE;
|
||
var currentReplayingEvent = null;
|
||
function setReplayingEvent(event) {
|
||
{
|
||
if (currentReplayingEvent !== null) {
|
||
error("Expected currently replaying event to be null. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
currentReplayingEvent = event;
|
||
}
|
||
function resetReplayingEvent() {
|
||
{
|
||
if (currentReplayingEvent === null) {
|
||
error("Expected currently replaying event to not be null. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
currentReplayingEvent = null;
|
||
}
|
||
function isReplayingEvent(event) {
|
||
return event === currentReplayingEvent;
|
||
}
|
||
function getEventTarget(nativeEvent) {
|
||
var target = nativeEvent.target || nativeEvent.srcElement || window;
|
||
if (target.correspondingUseElement) {
|
||
target = target.correspondingUseElement;
|
||
}
|
||
return target.nodeType === TEXT_NODE ? target.parentNode : target;
|
||
}
|
||
var restoreImpl = null;
|
||
var restoreTarget = null;
|
||
var restoreQueue = null;
|
||
function restoreStateOfTarget(target) {
|
||
var internalInstance = getInstanceFromNode(target);
|
||
if (!internalInstance) {
|
||
return;
|
||
}
|
||
if (typeof restoreImpl !== "function") {
|
||
throw new Error("setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
var stateNode = internalInstance.stateNode;
|
||
if (stateNode) {
|
||
var _props = getFiberCurrentPropsFromNode(stateNode);
|
||
restoreImpl(internalInstance.stateNode, internalInstance.type, _props);
|
||
}
|
||
}
|
||
function setRestoreImplementation(impl) {
|
||
restoreImpl = impl;
|
||
}
|
||
function enqueueStateRestore(target) {
|
||
if (restoreTarget) {
|
||
if (restoreQueue) {
|
||
restoreQueue.push(target);
|
||
} else {
|
||
restoreQueue = [target];
|
||
}
|
||
} else {
|
||
restoreTarget = target;
|
||
}
|
||
}
|
||
function needsStateRestore() {
|
||
return restoreTarget !== null || restoreQueue !== null;
|
||
}
|
||
function restoreStateIfNeeded() {
|
||
if (!restoreTarget) {
|
||
return;
|
||
}
|
||
var target = restoreTarget;
|
||
var queuedTargets = restoreQueue;
|
||
restoreTarget = null;
|
||
restoreQueue = null;
|
||
restoreStateOfTarget(target);
|
||
if (queuedTargets) {
|
||
for (var i = 0; i < queuedTargets.length; i++) {
|
||
restoreStateOfTarget(queuedTargets[i]);
|
||
}
|
||
}
|
||
}
|
||
var batchedUpdatesImpl = function(fn, bookkeeping) {
|
||
return fn(bookkeeping);
|
||
};
|
||
var flushSyncImpl = function() {
|
||
};
|
||
var isInsideEventHandler = false;
|
||
function finishEventHandler() {
|
||
var controlledComponentsHavePendingUpdates = needsStateRestore();
|
||
if (controlledComponentsHavePendingUpdates) {
|
||
flushSyncImpl();
|
||
restoreStateIfNeeded();
|
||
}
|
||
}
|
||
function batchedUpdates(fn, a, b) {
|
||
if (isInsideEventHandler) {
|
||
return fn(a, b);
|
||
}
|
||
isInsideEventHandler = true;
|
||
try {
|
||
return batchedUpdatesImpl(fn, a, b);
|
||
} finally {
|
||
isInsideEventHandler = false;
|
||
finishEventHandler();
|
||
}
|
||
}
|
||
function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushSyncImpl) {
|
||
batchedUpdatesImpl = _batchedUpdatesImpl;
|
||
flushSyncImpl = _flushSyncImpl;
|
||
}
|
||
function isInteractive(tag) {
|
||
return tag === "button" || tag === "input" || tag === "select" || tag === "textarea";
|
||
}
|
||
function shouldPreventMouseEvent(name, type, props) {
|
||
switch (name) {
|
||
case "onClick":
|
||
case "onClickCapture":
|
||
case "onDoubleClick":
|
||
case "onDoubleClickCapture":
|
||
case "onMouseDown":
|
||
case "onMouseDownCapture":
|
||
case "onMouseMove":
|
||
case "onMouseMoveCapture":
|
||
case "onMouseUp":
|
||
case "onMouseUpCapture":
|
||
case "onMouseEnter":
|
||
return !!(props.disabled && isInteractive(type));
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
function getListener(inst, registrationName) {
|
||
var stateNode = inst.stateNode;
|
||
if (stateNode === null) {
|
||
return null;
|
||
}
|
||
var props = getFiberCurrentPropsFromNode(stateNode);
|
||
if (props === null) {
|
||
return null;
|
||
}
|
||
var listener = props[registrationName];
|
||
if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
|
||
return null;
|
||
}
|
||
if (listener && typeof listener !== "function") {
|
||
throw new Error("Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type.");
|
||
}
|
||
return listener;
|
||
}
|
||
var passiveBrowserEventsSupported = false;
|
||
if (canUseDOM) {
|
||
try {
|
||
var options = {};
|
||
Object.defineProperty(options, "passive", {
|
||
get: function() {
|
||
passiveBrowserEventsSupported = true;
|
||
}
|
||
});
|
||
window.addEventListener("test", options, options);
|
||
window.removeEventListener("test", options, options);
|
||
} catch (e) {
|
||
passiveBrowserEventsSupported = false;
|
||
}
|
||
}
|
||
function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) {
|
||
var funcArgs = Array.prototype.slice.call(arguments, 3);
|
||
try {
|
||
func.apply(context, funcArgs);
|
||
} catch (error2) {
|
||
this.onError(error2);
|
||
}
|
||
}
|
||
var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
|
||
{
|
||
if (typeof window !== "undefined" && typeof window.dispatchEvent === "function" && typeof document !== "undefined" && typeof document.createEvent === "function") {
|
||
var fakeNode = document.createElement("react");
|
||
invokeGuardedCallbackImpl = function invokeGuardedCallbackDev(name, func, context, a, b, c, d, e, f) {
|
||
if (typeof document === "undefined" || document === null) {
|
||
throw new Error("The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous.");
|
||
}
|
||
var evt = document.createEvent("Event");
|
||
var didCall = false;
|
||
var didError = true;
|
||
var windowEvent = window.event;
|
||
var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, "event");
|
||
function restoreAfterDispatch() {
|
||
fakeNode.removeEventListener(evtType, callCallback2, false);
|
||
if (typeof window.event !== "undefined" && window.hasOwnProperty("event")) {
|
||
window.event = windowEvent;
|
||
}
|
||
}
|
||
var funcArgs = Array.prototype.slice.call(arguments, 3);
|
||
function callCallback2() {
|
||
didCall = true;
|
||
restoreAfterDispatch();
|
||
func.apply(context, funcArgs);
|
||
didError = false;
|
||
}
|
||
var error2;
|
||
var didSetError = false;
|
||
var isCrossOriginError = false;
|
||
function handleWindowError(event) {
|
||
error2 = event.error;
|
||
didSetError = true;
|
||
if (error2 === null && event.colno === 0 && event.lineno === 0) {
|
||
isCrossOriginError = true;
|
||
}
|
||
if (event.defaultPrevented) {
|
||
if (error2 != null && typeof error2 === "object") {
|
||
try {
|
||
error2._suppressLogging = true;
|
||
} catch (inner) {
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var evtType = "react-" + (name ? name : "invokeguardedcallback");
|
||
window.addEventListener("error", handleWindowError);
|
||
fakeNode.addEventListener(evtType, callCallback2, false);
|
||
evt.initEvent(evtType, false, false);
|
||
fakeNode.dispatchEvent(evt);
|
||
if (windowEventDescriptor) {
|
||
Object.defineProperty(window, "event", windowEventDescriptor);
|
||
}
|
||
if (didCall && didError) {
|
||
if (!didSetError) {
|
||
error2 = new Error(`An error was thrown inside one of your components, but React doesn't know what it was. This is likely due to browser flakiness. React does its best to preserve the "Pause on exceptions" behavior of the DevTools, which requires some DEV-mode only tricks. It's possible that these don't work in your browser. Try triggering the error in production mode, or switching to a modern browser. If you suspect that this is actually an issue with React, please file an issue.`);
|
||
} else if (isCrossOriginError) {
|
||
error2 = new Error("A cross-origin error was thrown. React doesn't have access to the actual error object in development. See https://reactjs.org/link/crossorigin-error for more information.");
|
||
}
|
||
this.onError(error2);
|
||
}
|
||
window.removeEventListener("error", handleWindowError);
|
||
if (!didCall) {
|
||
restoreAfterDispatch();
|
||
return invokeGuardedCallbackProd.apply(this, arguments);
|
||
}
|
||
};
|
||
}
|
||
}
|
||
var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
|
||
var hasError = false;
|
||
var caughtError = null;
|
||
var hasRethrowError = false;
|
||
var rethrowError = null;
|
||
var reporter = {
|
||
onError: function(error2) {
|
||
hasError = true;
|
||
caughtError = error2;
|
||
}
|
||
};
|
||
function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
|
||
hasError = false;
|
||
caughtError = null;
|
||
invokeGuardedCallbackImpl$1.apply(reporter, arguments);
|
||
}
|
||
function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) {
|
||
invokeGuardedCallback.apply(this, arguments);
|
||
if (hasError) {
|
||
var error2 = clearCaughtError();
|
||
if (!hasRethrowError) {
|
||
hasRethrowError = true;
|
||
rethrowError = error2;
|
||
}
|
||
}
|
||
}
|
||
function rethrowCaughtError() {
|
||
if (hasRethrowError) {
|
||
var error2 = rethrowError;
|
||
hasRethrowError = false;
|
||
rethrowError = null;
|
||
throw error2;
|
||
}
|
||
}
|
||
function hasCaughtError() {
|
||
return hasError;
|
||
}
|
||
function clearCaughtError() {
|
||
if (hasError) {
|
||
var error2 = caughtError;
|
||
hasError = false;
|
||
caughtError = null;
|
||
return error2;
|
||
} else {
|
||
throw new Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
function get(key) {
|
||
return key._reactInternals;
|
||
}
|
||
function has(key) {
|
||
return key._reactInternals !== void 0;
|
||
}
|
||
function set(key, value) {
|
||
key._reactInternals = value;
|
||
}
|
||
var NoFlags = 0;
|
||
var PerformedWork = 1;
|
||
var Placement = 2;
|
||
var Update = 4;
|
||
var ChildDeletion = 16;
|
||
var ContentReset = 32;
|
||
var Callback = 64;
|
||
var DidCapture = 128;
|
||
var ForceClientRender = 256;
|
||
var Ref = 512;
|
||
var Snapshot = 1024;
|
||
var Passive = 2048;
|
||
var Hydrating = 4096;
|
||
var Visibility = 8192;
|
||
var StoreConsistency = 16384;
|
||
var LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot | StoreConsistency;
|
||
var HostEffectMask = 32767;
|
||
var Incomplete = 32768;
|
||
var ShouldCapture = 65536;
|
||
var ForceUpdateForLegacySuspense = 131072;
|
||
var Forked = 1048576;
|
||
var RefStatic = 2097152;
|
||
var LayoutStatic = 4194304;
|
||
var PassiveStatic = 8388608;
|
||
var MountLayoutDev = 16777216;
|
||
var MountPassiveDev = 33554432;
|
||
var BeforeMutationMask = Update | Snapshot | 0;
|
||
var MutationMask = Placement | Update | ChildDeletion | ContentReset | Ref | Hydrating | Visibility;
|
||
var LayoutMask = Update | Callback | Ref | Visibility;
|
||
var PassiveMask = Passive | ChildDeletion;
|
||
var StaticMask = LayoutStatic | PassiveStatic | RefStatic;
|
||
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
||
function getNearestMountedFiber(fiber) {
|
||
var node = fiber;
|
||
var nearestMounted = fiber;
|
||
if (!fiber.alternate) {
|
||
var nextNode = node;
|
||
do {
|
||
node = nextNode;
|
||
if ((node.flags & (Placement | Hydrating)) !== NoFlags) {
|
||
nearestMounted = node.return;
|
||
}
|
||
nextNode = node.return;
|
||
} while (nextNode);
|
||
} else {
|
||
while (node.return) {
|
||
node = node.return;
|
||
}
|
||
}
|
||
if (node.tag === HostRoot) {
|
||
return nearestMounted;
|
||
}
|
||
return null;
|
||
}
|
||
function getSuspenseInstanceFromFiber(fiber) {
|
||
if (fiber.tag === SuspenseComponent) {
|
||
var suspenseState = fiber.memoizedState;
|
||
if (suspenseState === null) {
|
||
var current2 = fiber.alternate;
|
||
if (current2 !== null) {
|
||
suspenseState = current2.memoizedState;
|
||
}
|
||
}
|
||
if (suspenseState !== null) {
|
||
return suspenseState.dehydrated;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
function getContainerFromFiber(fiber) {
|
||
return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null;
|
||
}
|
||
function isFiberMounted(fiber) {
|
||
return getNearestMountedFiber(fiber) === fiber;
|
||
}
|
||
function isMounted(component) {
|
||
{
|
||
var owner = ReactCurrentOwner.current;
|
||
if (owner !== null && owner.tag === ClassComponent) {
|
||
var ownerFiber = owner;
|
||
var instance = ownerFiber.stateNode;
|
||
if (!instance._warnedAboutRefsInRender) {
|
||
error("%s is accessing isMounted inside its render() function. render() should be a pure function of props and state. It should never access something that requires stale data from the previous render, such as refs. Move this logic to componentDidMount and componentDidUpdate instead.", getComponentNameFromFiber(ownerFiber) || "A component");
|
||
}
|
||
instance._warnedAboutRefsInRender = true;
|
||
}
|
||
}
|
||
var fiber = get(component);
|
||
if (!fiber) {
|
||
return false;
|
||
}
|
||
return getNearestMountedFiber(fiber) === fiber;
|
||
}
|
||
function assertIsMounted(fiber) {
|
||
if (getNearestMountedFiber(fiber) !== fiber) {
|
||
throw new Error("Unable to find node on an unmounted component.");
|
||
}
|
||
}
|
||
function findCurrentFiberUsingSlowPath(fiber) {
|
||
var alternate = fiber.alternate;
|
||
if (!alternate) {
|
||
var nearestMounted = getNearestMountedFiber(fiber);
|
||
if (nearestMounted === null) {
|
||
throw new Error("Unable to find node on an unmounted component.");
|
||
}
|
||
if (nearestMounted !== fiber) {
|
||
return null;
|
||
}
|
||
return fiber;
|
||
}
|
||
var a = fiber;
|
||
var b = alternate;
|
||
while (true) {
|
||
var parentA = a.return;
|
||
if (parentA === null) {
|
||
break;
|
||
}
|
||
var parentB = parentA.alternate;
|
||
if (parentB === null) {
|
||
var nextParent = parentA.return;
|
||
if (nextParent !== null) {
|
||
a = b = nextParent;
|
||
continue;
|
||
}
|
||
break;
|
||
}
|
||
if (parentA.child === parentB.child) {
|
||
var child = parentA.child;
|
||
while (child) {
|
||
if (child === a) {
|
||
assertIsMounted(parentA);
|
||
return fiber;
|
||
}
|
||
if (child === b) {
|
||
assertIsMounted(parentA);
|
||
return alternate;
|
||
}
|
||
child = child.sibling;
|
||
}
|
||
throw new Error("Unable to find node on an unmounted component.");
|
||
}
|
||
if (a.return !== b.return) {
|
||
a = parentA;
|
||
b = parentB;
|
||
} else {
|
||
var didFindChild = false;
|
||
var _child = parentA.child;
|
||
while (_child) {
|
||
if (_child === a) {
|
||
didFindChild = true;
|
||
a = parentA;
|
||
b = parentB;
|
||
break;
|
||
}
|
||
if (_child === b) {
|
||
didFindChild = true;
|
||
b = parentA;
|
||
a = parentB;
|
||
break;
|
||
}
|
||
_child = _child.sibling;
|
||
}
|
||
if (!didFindChild) {
|
||
_child = parentB.child;
|
||
while (_child) {
|
||
if (_child === a) {
|
||
didFindChild = true;
|
||
a = parentB;
|
||
b = parentA;
|
||
break;
|
||
}
|
||
if (_child === b) {
|
||
didFindChild = true;
|
||
b = parentB;
|
||
a = parentA;
|
||
break;
|
||
}
|
||
_child = _child.sibling;
|
||
}
|
||
if (!didFindChild) {
|
||
throw new Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.");
|
||
}
|
||
}
|
||
}
|
||
if (a.alternate !== b) {
|
||
throw new Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
if (a.tag !== HostRoot) {
|
||
throw new Error("Unable to find node on an unmounted component.");
|
||
}
|
||
if (a.stateNode.current === a) {
|
||
return fiber;
|
||
}
|
||
return alternate;
|
||
}
|
||
function findCurrentHostFiber(parent2) {
|
||
var currentParent = findCurrentFiberUsingSlowPath(parent2);
|
||
return currentParent !== null ? findCurrentHostFiberImpl(currentParent) : null;
|
||
}
|
||
function findCurrentHostFiberImpl(node) {
|
||
if (node.tag === HostComponent || node.tag === HostText) {
|
||
return node;
|
||
}
|
||
var child = node.child;
|
||
while (child !== null) {
|
||
var match = findCurrentHostFiberImpl(child);
|
||
if (match !== null) {
|
||
return match;
|
||
}
|
||
child = child.sibling;
|
||
}
|
||
return null;
|
||
}
|
||
function findCurrentHostFiberWithNoPortals(parent2) {
|
||
var currentParent = findCurrentFiberUsingSlowPath(parent2);
|
||
return currentParent !== null ? findCurrentHostFiberWithNoPortalsImpl(currentParent) : null;
|
||
}
|
||
function findCurrentHostFiberWithNoPortalsImpl(node) {
|
||
if (node.tag === HostComponent || node.tag === HostText) {
|
||
return node;
|
||
}
|
||
var child = node.child;
|
||
while (child !== null) {
|
||
if (child.tag !== HostPortal) {
|
||
var match = findCurrentHostFiberWithNoPortalsImpl(child);
|
||
if (match !== null) {
|
||
return match;
|
||
}
|
||
}
|
||
child = child.sibling;
|
||
}
|
||
return null;
|
||
}
|
||
var scheduleCallback = Scheduler.unstable_scheduleCallback;
|
||
var cancelCallback = Scheduler.unstable_cancelCallback;
|
||
var shouldYield = Scheduler.unstable_shouldYield;
|
||
var requestPaint = Scheduler.unstable_requestPaint;
|
||
var now = Scheduler.unstable_now;
|
||
var getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel;
|
||
var ImmediatePriority = Scheduler.unstable_ImmediatePriority;
|
||
var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
|
||
var NormalPriority = Scheduler.unstable_NormalPriority;
|
||
var LowPriority = Scheduler.unstable_LowPriority;
|
||
var IdlePriority = Scheduler.unstable_IdlePriority;
|
||
var unstable_yieldValue = Scheduler.unstable_yieldValue;
|
||
var unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue;
|
||
var rendererID = null;
|
||
var injectedHook = null;
|
||
var injectedProfilingHooks = null;
|
||
var hasLoggedError = false;
|
||
var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined";
|
||
function injectInternals(internals) {
|
||
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") {
|
||
return false;
|
||
}
|
||
var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||
if (hook.isDisabled) {
|
||
return true;
|
||
}
|
||
if (!hook.supportsFiber) {
|
||
{
|
||
error("The installed version of React DevTools is too old and will not work with the current version of React. Please update React DevTools. https://reactjs.org/link/react-devtools");
|
||
}
|
||
return true;
|
||
}
|
||
try {
|
||
if (enableSchedulingProfiler) {
|
||
internals = assign({}, internals, {
|
||
getLaneLabelMap,
|
||
injectProfilingHooks
|
||
});
|
||
}
|
||
rendererID = hook.inject(internals);
|
||
injectedHook = hook;
|
||
} catch (err) {
|
||
{
|
||
error("React instrumentation encountered an error: %s.", err);
|
||
}
|
||
}
|
||
if (hook.checkDCE) {
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
function onScheduleRoot(root2, children) {
|
||
{
|
||
if (injectedHook && typeof injectedHook.onScheduleFiberRoot === "function") {
|
||
try {
|
||
injectedHook.onScheduleFiberRoot(rendererID, root2, children);
|
||
} catch (err) {
|
||
if (!hasLoggedError) {
|
||
hasLoggedError = true;
|
||
error("React instrumentation encountered an error: %s", err);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function onCommitRoot(root2, eventPriority) {
|
||
if (injectedHook && typeof injectedHook.onCommitFiberRoot === "function") {
|
||
try {
|
||
var didError = (root2.current.flags & DidCapture) === DidCapture;
|
||
if (enableProfilerTimer) {
|
||
var schedulerPriority;
|
||
switch (eventPriority) {
|
||
case DiscreteEventPriority:
|
||
schedulerPriority = ImmediatePriority;
|
||
break;
|
||
case ContinuousEventPriority:
|
||
schedulerPriority = UserBlockingPriority;
|
||
break;
|
||
case DefaultEventPriority:
|
||
schedulerPriority = NormalPriority;
|
||
break;
|
||
case IdleEventPriority:
|
||
schedulerPriority = IdlePriority;
|
||
break;
|
||
default:
|
||
schedulerPriority = NormalPriority;
|
||
break;
|
||
}
|
||
injectedHook.onCommitFiberRoot(rendererID, root2, schedulerPriority, didError);
|
||
} else {
|
||
injectedHook.onCommitFiberRoot(rendererID, root2, void 0, didError);
|
||
}
|
||
} catch (err) {
|
||
{
|
||
if (!hasLoggedError) {
|
||
hasLoggedError = true;
|
||
error("React instrumentation encountered an error: %s", err);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function onPostCommitRoot(root2) {
|
||
if (injectedHook && typeof injectedHook.onPostCommitFiberRoot === "function") {
|
||
try {
|
||
injectedHook.onPostCommitFiberRoot(rendererID, root2);
|
||
} catch (err) {
|
||
{
|
||
if (!hasLoggedError) {
|
||
hasLoggedError = true;
|
||
error("React instrumentation encountered an error: %s", err);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function onCommitUnmount(fiber) {
|
||
if (injectedHook && typeof injectedHook.onCommitFiberUnmount === "function") {
|
||
try {
|
||
injectedHook.onCommitFiberUnmount(rendererID, fiber);
|
||
} catch (err) {
|
||
{
|
||
if (!hasLoggedError) {
|
||
hasLoggedError = true;
|
||
error("React instrumentation encountered an error: %s", err);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function setIsStrictModeForDevtools(newIsStrictMode) {
|
||
{
|
||
if (typeof unstable_yieldValue === "function") {
|
||
unstable_setDisableYieldValue(newIsStrictMode);
|
||
setSuppressWarning(newIsStrictMode);
|
||
}
|
||
if (injectedHook && typeof injectedHook.setStrictMode === "function") {
|
||
try {
|
||
injectedHook.setStrictMode(rendererID, newIsStrictMode);
|
||
} catch (err) {
|
||
{
|
||
if (!hasLoggedError) {
|
||
hasLoggedError = true;
|
||
error("React instrumentation encountered an error: %s", err);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function injectProfilingHooks(profilingHooks) {
|
||
injectedProfilingHooks = profilingHooks;
|
||
}
|
||
function getLaneLabelMap() {
|
||
{
|
||
var map = /* @__PURE__ */ new Map();
|
||
var lane = 1;
|
||
for (var index2 = 0; index2 < TotalLanes; index2++) {
|
||
var label = getLabelForLane(lane);
|
||
map.set(lane, label);
|
||
lane *= 2;
|
||
}
|
||
return map;
|
||
}
|
||
}
|
||
function markCommitStarted(lanes) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markCommitStarted === "function") {
|
||
injectedProfilingHooks.markCommitStarted(lanes);
|
||
}
|
||
}
|
||
}
|
||
function markCommitStopped() {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markCommitStopped === "function") {
|
||
injectedProfilingHooks.markCommitStopped();
|
||
}
|
||
}
|
||
}
|
||
function markComponentRenderStarted(fiber) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentRenderStarted === "function") {
|
||
injectedProfilingHooks.markComponentRenderStarted(fiber);
|
||
}
|
||
}
|
||
}
|
||
function markComponentRenderStopped() {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentRenderStopped === "function") {
|
||
injectedProfilingHooks.markComponentRenderStopped();
|
||
}
|
||
}
|
||
}
|
||
function markComponentPassiveEffectMountStarted(fiber) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectMountStarted === "function") {
|
||
injectedProfilingHooks.markComponentPassiveEffectMountStarted(fiber);
|
||
}
|
||
}
|
||
}
|
||
function markComponentPassiveEffectMountStopped() {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectMountStopped === "function") {
|
||
injectedProfilingHooks.markComponentPassiveEffectMountStopped();
|
||
}
|
||
}
|
||
}
|
||
function markComponentPassiveEffectUnmountStarted(fiber) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectUnmountStarted === "function") {
|
||
injectedProfilingHooks.markComponentPassiveEffectUnmountStarted(fiber);
|
||
}
|
||
}
|
||
}
|
||
function markComponentPassiveEffectUnmountStopped() {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectUnmountStopped === "function") {
|
||
injectedProfilingHooks.markComponentPassiveEffectUnmountStopped();
|
||
}
|
||
}
|
||
}
|
||
function markComponentLayoutEffectMountStarted(fiber) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectMountStarted === "function") {
|
||
injectedProfilingHooks.markComponentLayoutEffectMountStarted(fiber);
|
||
}
|
||
}
|
||
}
|
||
function markComponentLayoutEffectMountStopped() {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectMountStopped === "function") {
|
||
injectedProfilingHooks.markComponentLayoutEffectMountStopped();
|
||
}
|
||
}
|
||
}
|
||
function markComponentLayoutEffectUnmountStarted(fiber) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectUnmountStarted === "function") {
|
||
injectedProfilingHooks.markComponentLayoutEffectUnmountStarted(fiber);
|
||
}
|
||
}
|
||
}
|
||
function markComponentLayoutEffectUnmountStopped() {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectUnmountStopped === "function") {
|
||
injectedProfilingHooks.markComponentLayoutEffectUnmountStopped();
|
||
}
|
||
}
|
||
}
|
||
function markComponentErrored(fiber, thrownValue, lanes) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentErrored === "function") {
|
||
injectedProfilingHooks.markComponentErrored(fiber, thrownValue, lanes);
|
||
}
|
||
}
|
||
}
|
||
function markComponentSuspended(fiber, wakeable, lanes) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentSuspended === "function") {
|
||
injectedProfilingHooks.markComponentSuspended(fiber, wakeable, lanes);
|
||
}
|
||
}
|
||
}
|
||
function markLayoutEffectsStarted(lanes) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markLayoutEffectsStarted === "function") {
|
||
injectedProfilingHooks.markLayoutEffectsStarted(lanes);
|
||
}
|
||
}
|
||
}
|
||
function markLayoutEffectsStopped() {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markLayoutEffectsStopped === "function") {
|
||
injectedProfilingHooks.markLayoutEffectsStopped();
|
||
}
|
||
}
|
||
}
|
||
function markPassiveEffectsStarted(lanes) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markPassiveEffectsStarted === "function") {
|
||
injectedProfilingHooks.markPassiveEffectsStarted(lanes);
|
||
}
|
||
}
|
||
}
|
||
function markPassiveEffectsStopped() {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markPassiveEffectsStopped === "function") {
|
||
injectedProfilingHooks.markPassiveEffectsStopped();
|
||
}
|
||
}
|
||
}
|
||
function markRenderStarted(lanes) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markRenderStarted === "function") {
|
||
injectedProfilingHooks.markRenderStarted(lanes);
|
||
}
|
||
}
|
||
}
|
||
function markRenderYielded() {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markRenderYielded === "function") {
|
||
injectedProfilingHooks.markRenderYielded();
|
||
}
|
||
}
|
||
}
|
||
function markRenderStopped() {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markRenderStopped === "function") {
|
||
injectedProfilingHooks.markRenderStopped();
|
||
}
|
||
}
|
||
}
|
||
function markRenderScheduled(lane) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markRenderScheduled === "function") {
|
||
injectedProfilingHooks.markRenderScheduled(lane);
|
||
}
|
||
}
|
||
}
|
||
function markForceUpdateScheduled(fiber, lane) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markForceUpdateScheduled === "function") {
|
||
injectedProfilingHooks.markForceUpdateScheduled(fiber, lane);
|
||
}
|
||
}
|
||
}
|
||
function markStateUpdateScheduled(fiber, lane) {
|
||
{
|
||
if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markStateUpdateScheduled === "function") {
|
||
injectedProfilingHooks.markStateUpdateScheduled(fiber, lane);
|
||
}
|
||
}
|
||
}
|
||
var NoMode = 0;
|
||
var ConcurrentMode = 1;
|
||
var ProfileMode = 2;
|
||
var StrictLegacyMode = 8;
|
||
var StrictEffectsMode = 16;
|
||
var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback;
|
||
var log = Math.log;
|
||
var LN2 = Math.LN2;
|
||
function clz32Fallback(x) {
|
||
var asUint = x >>> 0;
|
||
if (asUint === 0) {
|
||
return 32;
|
||
}
|
||
return 31 - (log(asUint) / LN2 | 0) | 0;
|
||
}
|
||
var TotalLanes = 31;
|
||
var NoLanes = 0;
|
||
var NoLane = 0;
|
||
var SyncLane = 1;
|
||
var InputContinuousHydrationLane = 2;
|
||
var InputContinuousLane = 4;
|
||
var DefaultHydrationLane = 8;
|
||
var DefaultLane = 16;
|
||
var TransitionHydrationLane = 32;
|
||
var TransitionLanes = 4194240;
|
||
var TransitionLane1 = 64;
|
||
var TransitionLane2 = 128;
|
||
var TransitionLane3 = 256;
|
||
var TransitionLane4 = 512;
|
||
var TransitionLane5 = 1024;
|
||
var TransitionLane6 = 2048;
|
||
var TransitionLane7 = 4096;
|
||
var TransitionLane8 = 8192;
|
||
var TransitionLane9 = 16384;
|
||
var TransitionLane10 = 32768;
|
||
var TransitionLane11 = 65536;
|
||
var TransitionLane12 = 131072;
|
||
var TransitionLane13 = 262144;
|
||
var TransitionLane14 = 524288;
|
||
var TransitionLane15 = 1048576;
|
||
var TransitionLane16 = 2097152;
|
||
var RetryLanes = 130023424;
|
||
var RetryLane1 = 4194304;
|
||
var RetryLane2 = 8388608;
|
||
var RetryLane3 = 16777216;
|
||
var RetryLane4 = 33554432;
|
||
var RetryLane5 = 67108864;
|
||
var SomeRetryLane = RetryLane1;
|
||
var SelectiveHydrationLane = 134217728;
|
||
var NonIdleLanes = 268435455;
|
||
var IdleHydrationLane = 268435456;
|
||
var IdleLane = 536870912;
|
||
var OffscreenLane = 1073741824;
|
||
function getLabelForLane(lane) {
|
||
{
|
||
if (lane & SyncLane) {
|
||
return "Sync";
|
||
}
|
||
if (lane & InputContinuousHydrationLane) {
|
||
return "InputContinuousHydration";
|
||
}
|
||
if (lane & InputContinuousLane) {
|
||
return "InputContinuous";
|
||
}
|
||
if (lane & DefaultHydrationLane) {
|
||
return "DefaultHydration";
|
||
}
|
||
if (lane & DefaultLane) {
|
||
return "Default";
|
||
}
|
||
if (lane & TransitionHydrationLane) {
|
||
return "TransitionHydration";
|
||
}
|
||
if (lane & TransitionLanes) {
|
||
return "Transition";
|
||
}
|
||
if (lane & RetryLanes) {
|
||
return "Retry";
|
||
}
|
||
if (lane & SelectiveHydrationLane) {
|
||
return "SelectiveHydration";
|
||
}
|
||
if (lane & IdleHydrationLane) {
|
||
return "IdleHydration";
|
||
}
|
||
if (lane & IdleLane) {
|
||
return "Idle";
|
||
}
|
||
if (lane & OffscreenLane) {
|
||
return "Offscreen";
|
||
}
|
||
}
|
||
}
|
||
var NoTimestamp = -1;
|
||
var nextTransitionLane = TransitionLane1;
|
||
var nextRetryLane = RetryLane1;
|
||
function getHighestPriorityLanes(lanes) {
|
||
switch (getHighestPriorityLane(lanes)) {
|
||
case SyncLane:
|
||
return SyncLane;
|
||
case InputContinuousHydrationLane:
|
||
return InputContinuousHydrationLane;
|
||
case InputContinuousLane:
|
||
return InputContinuousLane;
|
||
case DefaultHydrationLane:
|
||
return DefaultHydrationLane;
|
||
case DefaultLane:
|
||
return DefaultLane;
|
||
case TransitionHydrationLane:
|
||
return TransitionHydrationLane;
|
||
case TransitionLane1:
|
||
case TransitionLane2:
|
||
case TransitionLane3:
|
||
case TransitionLane4:
|
||
case TransitionLane5:
|
||
case TransitionLane6:
|
||
case TransitionLane7:
|
||
case TransitionLane8:
|
||
case TransitionLane9:
|
||
case TransitionLane10:
|
||
case TransitionLane11:
|
||
case TransitionLane12:
|
||
case TransitionLane13:
|
||
case TransitionLane14:
|
||
case TransitionLane15:
|
||
case TransitionLane16:
|
||
return lanes & TransitionLanes;
|
||
case RetryLane1:
|
||
case RetryLane2:
|
||
case RetryLane3:
|
||
case RetryLane4:
|
||
case RetryLane5:
|
||
return lanes & RetryLanes;
|
||
case SelectiveHydrationLane:
|
||
return SelectiveHydrationLane;
|
||
case IdleHydrationLane:
|
||
return IdleHydrationLane;
|
||
case IdleLane:
|
||
return IdleLane;
|
||
case OffscreenLane:
|
||
return OffscreenLane;
|
||
default:
|
||
{
|
||
error("Should have found matching lanes. This is a bug in React.");
|
||
}
|
||
return lanes;
|
||
}
|
||
}
|
||
function getNextLanes(root2, wipLanes) {
|
||
var pendingLanes = root2.pendingLanes;
|
||
if (pendingLanes === NoLanes) {
|
||
return NoLanes;
|
||
}
|
||
var nextLanes = NoLanes;
|
||
var suspendedLanes = root2.suspendedLanes;
|
||
var pingedLanes = root2.pingedLanes;
|
||
var nonIdlePendingLanes = pendingLanes & NonIdleLanes;
|
||
if (nonIdlePendingLanes !== NoLanes) {
|
||
var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes;
|
||
if (nonIdleUnblockedLanes !== NoLanes) {
|
||
nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes);
|
||
} else {
|
||
var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes;
|
||
if (nonIdlePingedLanes !== NoLanes) {
|
||
nextLanes = getHighestPriorityLanes(nonIdlePingedLanes);
|
||
}
|
||
}
|
||
} else {
|
||
var unblockedLanes = pendingLanes & ~suspendedLanes;
|
||
if (unblockedLanes !== NoLanes) {
|
||
nextLanes = getHighestPriorityLanes(unblockedLanes);
|
||
} else {
|
||
if (pingedLanes !== NoLanes) {
|
||
nextLanes = getHighestPriorityLanes(pingedLanes);
|
||
}
|
||
}
|
||
}
|
||
if (nextLanes === NoLanes) {
|
||
return NoLanes;
|
||
}
|
||
if (wipLanes !== NoLanes && wipLanes !== nextLanes && (wipLanes & suspendedLanes) === NoLanes) {
|
||
var nextLane = getHighestPriorityLane(nextLanes);
|
||
var wipLane = getHighestPriorityLane(wipLanes);
|
||
if (nextLane >= wipLane || nextLane === DefaultLane && (wipLane & TransitionLanes) !== NoLanes) {
|
||
return wipLanes;
|
||
}
|
||
}
|
||
if ((nextLanes & InputContinuousLane) !== NoLanes) {
|
||
nextLanes |= pendingLanes & DefaultLane;
|
||
}
|
||
var entangledLanes = root2.entangledLanes;
|
||
if (entangledLanes !== NoLanes) {
|
||
var entanglements = root2.entanglements;
|
||
var lanes = nextLanes & entangledLanes;
|
||
while (lanes > 0) {
|
||
var index2 = pickArbitraryLaneIndex(lanes);
|
||
var lane = 1 << index2;
|
||
nextLanes |= entanglements[index2];
|
||
lanes &= ~lane;
|
||
}
|
||
}
|
||
return nextLanes;
|
||
}
|
||
function getMostRecentEventTime(root2, lanes) {
|
||
var eventTimes = root2.eventTimes;
|
||
var mostRecentEventTime = NoTimestamp;
|
||
while (lanes > 0) {
|
||
var index2 = pickArbitraryLaneIndex(lanes);
|
||
var lane = 1 << index2;
|
||
var eventTime = eventTimes[index2];
|
||
if (eventTime > mostRecentEventTime) {
|
||
mostRecentEventTime = eventTime;
|
||
}
|
||
lanes &= ~lane;
|
||
}
|
||
return mostRecentEventTime;
|
||
}
|
||
function computeExpirationTime(lane, currentTime) {
|
||
switch (lane) {
|
||
case SyncLane:
|
||
case InputContinuousHydrationLane:
|
||
case InputContinuousLane:
|
||
return currentTime + 250;
|
||
case DefaultHydrationLane:
|
||
case DefaultLane:
|
||
case TransitionHydrationLane:
|
||
case TransitionLane1:
|
||
case TransitionLane2:
|
||
case TransitionLane3:
|
||
case TransitionLane4:
|
||
case TransitionLane5:
|
||
case TransitionLane6:
|
||
case TransitionLane7:
|
||
case TransitionLane8:
|
||
case TransitionLane9:
|
||
case TransitionLane10:
|
||
case TransitionLane11:
|
||
case TransitionLane12:
|
||
case TransitionLane13:
|
||
case TransitionLane14:
|
||
case TransitionLane15:
|
||
case TransitionLane16:
|
||
return currentTime + 5e3;
|
||
case RetryLane1:
|
||
case RetryLane2:
|
||
case RetryLane3:
|
||
case RetryLane4:
|
||
case RetryLane5:
|
||
return NoTimestamp;
|
||
case SelectiveHydrationLane:
|
||
case IdleHydrationLane:
|
||
case IdleLane:
|
||
case OffscreenLane:
|
||
return NoTimestamp;
|
||
default:
|
||
{
|
||
error("Should have found matching lanes. This is a bug in React.");
|
||
}
|
||
return NoTimestamp;
|
||
}
|
||
}
|
||
function markStarvedLanesAsExpired(root2, currentTime) {
|
||
var pendingLanes = root2.pendingLanes;
|
||
var suspendedLanes = root2.suspendedLanes;
|
||
var pingedLanes = root2.pingedLanes;
|
||
var expirationTimes = root2.expirationTimes;
|
||
var lanes = pendingLanes;
|
||
while (lanes > 0) {
|
||
var index2 = pickArbitraryLaneIndex(lanes);
|
||
var lane = 1 << index2;
|
||
var expirationTime = expirationTimes[index2];
|
||
if (expirationTime === NoTimestamp) {
|
||
if ((lane & suspendedLanes) === NoLanes || (lane & pingedLanes) !== NoLanes) {
|
||
expirationTimes[index2] = computeExpirationTime(lane, currentTime);
|
||
}
|
||
} else if (expirationTime <= currentTime) {
|
||
root2.expiredLanes |= lane;
|
||
}
|
||
lanes &= ~lane;
|
||
}
|
||
}
|
||
function getHighestPriorityPendingLanes(root2) {
|
||
return getHighestPriorityLanes(root2.pendingLanes);
|
||
}
|
||
function getLanesToRetrySynchronouslyOnError(root2) {
|
||
var everythingButOffscreen = root2.pendingLanes & ~OffscreenLane;
|
||
if (everythingButOffscreen !== NoLanes) {
|
||
return everythingButOffscreen;
|
||
}
|
||
if (everythingButOffscreen & OffscreenLane) {
|
||
return OffscreenLane;
|
||
}
|
||
return NoLanes;
|
||
}
|
||
function includesSyncLane(lanes) {
|
||
return (lanes & SyncLane) !== NoLanes;
|
||
}
|
||
function includesNonIdleWork(lanes) {
|
||
return (lanes & NonIdleLanes) !== NoLanes;
|
||
}
|
||
function includesOnlyRetries(lanes) {
|
||
return (lanes & RetryLanes) === lanes;
|
||
}
|
||
function includesOnlyNonUrgentLanes(lanes) {
|
||
var UrgentLanes = SyncLane | InputContinuousLane | DefaultLane;
|
||
return (lanes & UrgentLanes) === NoLanes;
|
||
}
|
||
function includesOnlyTransitions(lanes) {
|
||
return (lanes & TransitionLanes) === lanes;
|
||
}
|
||
function includesBlockingLane(root2, lanes) {
|
||
var SyncDefaultLanes = InputContinuousHydrationLane | InputContinuousLane | DefaultHydrationLane | DefaultLane;
|
||
return (lanes & SyncDefaultLanes) !== NoLanes;
|
||
}
|
||
function includesExpiredLane(root2, lanes) {
|
||
return (lanes & root2.expiredLanes) !== NoLanes;
|
||
}
|
||
function isTransitionLane(lane) {
|
||
return (lane & TransitionLanes) !== NoLanes;
|
||
}
|
||
function claimNextTransitionLane() {
|
||
var lane = nextTransitionLane;
|
||
nextTransitionLane <<= 1;
|
||
if ((nextTransitionLane & TransitionLanes) === NoLanes) {
|
||
nextTransitionLane = TransitionLane1;
|
||
}
|
||
return lane;
|
||
}
|
||
function claimNextRetryLane() {
|
||
var lane = nextRetryLane;
|
||
nextRetryLane <<= 1;
|
||
if ((nextRetryLane & RetryLanes) === NoLanes) {
|
||
nextRetryLane = RetryLane1;
|
||
}
|
||
return lane;
|
||
}
|
||
function getHighestPriorityLane(lanes) {
|
||
return lanes & -lanes;
|
||
}
|
||
function pickArbitraryLane(lanes) {
|
||
return getHighestPriorityLane(lanes);
|
||
}
|
||
function pickArbitraryLaneIndex(lanes) {
|
||
return 31 - clz32(lanes);
|
||
}
|
||
function laneToIndex(lane) {
|
||
return pickArbitraryLaneIndex(lane);
|
||
}
|
||
function includesSomeLane(a, b) {
|
||
return (a & b) !== NoLanes;
|
||
}
|
||
function isSubsetOfLanes(set2, subset) {
|
||
return (set2 & subset) === subset;
|
||
}
|
||
function mergeLanes(a, b) {
|
||
return a | b;
|
||
}
|
||
function removeLanes(set2, subset) {
|
||
return set2 & ~subset;
|
||
}
|
||
function intersectLanes(a, b) {
|
||
return a & b;
|
||
}
|
||
function laneToLanes(lane) {
|
||
return lane;
|
||
}
|
||
function higherPriorityLane(a, b) {
|
||
return a !== NoLane && a < b ? a : b;
|
||
}
|
||
function createLaneMap(initial) {
|
||
var laneMap = [];
|
||
for (var i = 0; i < TotalLanes; i++) {
|
||
laneMap.push(initial);
|
||
}
|
||
return laneMap;
|
||
}
|
||
function markRootUpdated(root2, updateLane, eventTime) {
|
||
root2.pendingLanes |= updateLane;
|
||
if (updateLane !== IdleLane) {
|
||
root2.suspendedLanes = NoLanes;
|
||
root2.pingedLanes = NoLanes;
|
||
}
|
||
var eventTimes = root2.eventTimes;
|
||
var index2 = laneToIndex(updateLane);
|
||
eventTimes[index2] = eventTime;
|
||
}
|
||
function markRootSuspended(root2, suspendedLanes) {
|
||
root2.suspendedLanes |= suspendedLanes;
|
||
root2.pingedLanes &= ~suspendedLanes;
|
||
var expirationTimes = root2.expirationTimes;
|
||
var lanes = suspendedLanes;
|
||
while (lanes > 0) {
|
||
var index2 = pickArbitraryLaneIndex(lanes);
|
||
var lane = 1 << index2;
|
||
expirationTimes[index2] = NoTimestamp;
|
||
lanes &= ~lane;
|
||
}
|
||
}
|
||
function markRootPinged(root2, pingedLanes, eventTime) {
|
||
root2.pingedLanes |= root2.suspendedLanes & pingedLanes;
|
||
}
|
||
function markRootFinished(root2, remainingLanes) {
|
||
var noLongerPendingLanes = root2.pendingLanes & ~remainingLanes;
|
||
root2.pendingLanes = remainingLanes;
|
||
root2.suspendedLanes = NoLanes;
|
||
root2.pingedLanes = NoLanes;
|
||
root2.expiredLanes &= remainingLanes;
|
||
root2.mutableReadLanes &= remainingLanes;
|
||
root2.entangledLanes &= remainingLanes;
|
||
var entanglements = root2.entanglements;
|
||
var eventTimes = root2.eventTimes;
|
||
var expirationTimes = root2.expirationTimes;
|
||
var lanes = noLongerPendingLanes;
|
||
while (lanes > 0) {
|
||
var index2 = pickArbitraryLaneIndex(lanes);
|
||
var lane = 1 << index2;
|
||
entanglements[index2] = NoLanes;
|
||
eventTimes[index2] = NoTimestamp;
|
||
expirationTimes[index2] = NoTimestamp;
|
||
lanes &= ~lane;
|
||
}
|
||
}
|
||
function markRootEntangled(root2, entangledLanes) {
|
||
var rootEntangledLanes = root2.entangledLanes |= entangledLanes;
|
||
var entanglements = root2.entanglements;
|
||
var lanes = rootEntangledLanes;
|
||
while (lanes) {
|
||
var index2 = pickArbitraryLaneIndex(lanes);
|
||
var lane = 1 << index2;
|
||
if (lane & entangledLanes | entanglements[index2] & entangledLanes) {
|
||
entanglements[index2] |= entangledLanes;
|
||
}
|
||
lanes &= ~lane;
|
||
}
|
||
}
|
||
function getBumpedLaneForHydration(root2, renderLanes2) {
|
||
var renderLane = getHighestPriorityLane(renderLanes2);
|
||
var lane;
|
||
switch (renderLane) {
|
||
case InputContinuousLane:
|
||
lane = InputContinuousHydrationLane;
|
||
break;
|
||
case DefaultLane:
|
||
lane = DefaultHydrationLane;
|
||
break;
|
||
case TransitionLane1:
|
||
case TransitionLane2:
|
||
case TransitionLane3:
|
||
case TransitionLane4:
|
||
case TransitionLane5:
|
||
case TransitionLane6:
|
||
case TransitionLane7:
|
||
case TransitionLane8:
|
||
case TransitionLane9:
|
||
case TransitionLane10:
|
||
case TransitionLane11:
|
||
case TransitionLane12:
|
||
case TransitionLane13:
|
||
case TransitionLane14:
|
||
case TransitionLane15:
|
||
case TransitionLane16:
|
||
case RetryLane1:
|
||
case RetryLane2:
|
||
case RetryLane3:
|
||
case RetryLane4:
|
||
case RetryLane5:
|
||
lane = TransitionHydrationLane;
|
||
break;
|
||
case IdleLane:
|
||
lane = IdleHydrationLane;
|
||
break;
|
||
default:
|
||
lane = NoLane;
|
||
break;
|
||
}
|
||
if ((lane & (root2.suspendedLanes | renderLanes2)) !== NoLane) {
|
||
return NoLane;
|
||
}
|
||
return lane;
|
||
}
|
||
function addFiberToLanesMap(root2, fiber, lanes) {
|
||
if (!isDevToolsPresent) {
|
||
return;
|
||
}
|
||
var pendingUpdatersLaneMap = root2.pendingUpdatersLaneMap;
|
||
while (lanes > 0) {
|
||
var index2 = laneToIndex(lanes);
|
||
var lane = 1 << index2;
|
||
var updaters = pendingUpdatersLaneMap[index2];
|
||
updaters.add(fiber);
|
||
lanes &= ~lane;
|
||
}
|
||
}
|
||
function movePendingFibersToMemoized(root2, lanes) {
|
||
if (!isDevToolsPresent) {
|
||
return;
|
||
}
|
||
var pendingUpdatersLaneMap = root2.pendingUpdatersLaneMap;
|
||
var memoizedUpdaters = root2.memoizedUpdaters;
|
||
while (lanes > 0) {
|
||
var index2 = laneToIndex(lanes);
|
||
var lane = 1 << index2;
|
||
var updaters = pendingUpdatersLaneMap[index2];
|
||
if (updaters.size > 0) {
|
||
updaters.forEach(function(fiber) {
|
||
var alternate = fiber.alternate;
|
||
if (alternate === null || !memoizedUpdaters.has(alternate)) {
|
||
memoizedUpdaters.add(fiber);
|
||
}
|
||
});
|
||
updaters.clear();
|
||
}
|
||
lanes &= ~lane;
|
||
}
|
||
}
|
||
function getTransitionsForLanes(root2, lanes) {
|
||
{
|
||
return null;
|
||
}
|
||
}
|
||
var DiscreteEventPriority = SyncLane;
|
||
var ContinuousEventPriority = InputContinuousLane;
|
||
var DefaultEventPriority = DefaultLane;
|
||
var IdleEventPriority = IdleLane;
|
||
var currentUpdatePriority = NoLane;
|
||
function getCurrentUpdatePriority() {
|
||
return currentUpdatePriority;
|
||
}
|
||
function setCurrentUpdatePriority(newPriority) {
|
||
currentUpdatePriority = newPriority;
|
||
}
|
||
function runWithPriority(priority, fn) {
|
||
var previousPriority = currentUpdatePriority;
|
||
try {
|
||
currentUpdatePriority = priority;
|
||
return fn();
|
||
} finally {
|
||
currentUpdatePriority = previousPriority;
|
||
}
|
||
}
|
||
function higherEventPriority(a, b) {
|
||
return a !== 0 && a < b ? a : b;
|
||
}
|
||
function lowerEventPriority(a, b) {
|
||
return a === 0 || a > b ? a : b;
|
||
}
|
||
function isHigherEventPriority(a, b) {
|
||
return a !== 0 && a < b;
|
||
}
|
||
function lanesToEventPriority(lanes) {
|
||
var lane = getHighestPriorityLane(lanes);
|
||
if (!isHigherEventPriority(DiscreteEventPriority, lane)) {
|
||
return DiscreteEventPriority;
|
||
}
|
||
if (!isHigherEventPriority(ContinuousEventPriority, lane)) {
|
||
return ContinuousEventPriority;
|
||
}
|
||
if (includesNonIdleWork(lane)) {
|
||
return DefaultEventPriority;
|
||
}
|
||
return IdleEventPriority;
|
||
}
|
||
function isRootDehydrated(root2) {
|
||
var currentState = root2.current.memoizedState;
|
||
return currentState.isDehydrated;
|
||
}
|
||
var _attemptSynchronousHydration;
|
||
function setAttemptSynchronousHydration(fn) {
|
||
_attemptSynchronousHydration = fn;
|
||
}
|
||
function attemptSynchronousHydration(fiber) {
|
||
_attemptSynchronousHydration(fiber);
|
||
}
|
||
var attemptContinuousHydration;
|
||
function setAttemptContinuousHydration(fn) {
|
||
attemptContinuousHydration = fn;
|
||
}
|
||
var attemptHydrationAtCurrentPriority;
|
||
function setAttemptHydrationAtCurrentPriority(fn) {
|
||
attemptHydrationAtCurrentPriority = fn;
|
||
}
|
||
var getCurrentUpdatePriority$1;
|
||
function setGetCurrentUpdatePriority(fn) {
|
||
getCurrentUpdatePriority$1 = fn;
|
||
}
|
||
var attemptHydrationAtPriority;
|
||
function setAttemptHydrationAtPriority(fn) {
|
||
attemptHydrationAtPriority = fn;
|
||
}
|
||
var hasScheduledReplayAttempt = false;
|
||
var queuedDiscreteEvents = [];
|
||
var queuedFocus = null;
|
||
var queuedDrag = null;
|
||
var queuedMouse = null;
|
||
var queuedPointers = /* @__PURE__ */ new Map();
|
||
var queuedPointerCaptures = /* @__PURE__ */ new Map();
|
||
var queuedExplicitHydrationTargets = [];
|
||
var discreteReplayableEvents = [
|
||
"mousedown",
|
||
"mouseup",
|
||
"touchcancel",
|
||
"touchend",
|
||
"touchstart",
|
||
"auxclick",
|
||
"dblclick",
|
||
"pointercancel",
|
||
"pointerdown",
|
||
"pointerup",
|
||
"dragend",
|
||
"dragstart",
|
||
"drop",
|
||
"compositionend",
|
||
"compositionstart",
|
||
"keydown",
|
||
"keypress",
|
||
"keyup",
|
||
"input",
|
||
"textInput",
|
||
"copy",
|
||
"cut",
|
||
"paste",
|
||
"click",
|
||
"change",
|
||
"contextmenu",
|
||
"reset",
|
||
"submit"
|
||
];
|
||
function isDiscreteEventThatRequiresHydration(eventType) {
|
||
return discreteReplayableEvents.indexOf(eventType) > -1;
|
||
}
|
||
function createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) {
|
||
return {
|
||
blockedOn,
|
||
domEventName,
|
||
eventSystemFlags,
|
||
nativeEvent,
|
||
targetContainers: [targetContainer]
|
||
};
|
||
}
|
||
function clearIfContinuousEvent(domEventName, nativeEvent) {
|
||
switch (domEventName) {
|
||
case "focusin":
|
||
case "focusout":
|
||
queuedFocus = null;
|
||
break;
|
||
case "dragenter":
|
||
case "dragleave":
|
||
queuedDrag = null;
|
||
break;
|
||
case "mouseover":
|
||
case "mouseout":
|
||
queuedMouse = null;
|
||
break;
|
||
case "pointerover":
|
||
case "pointerout": {
|
||
var pointerId = nativeEvent.pointerId;
|
||
queuedPointers.delete(pointerId);
|
||
break;
|
||
}
|
||
case "gotpointercapture":
|
||
case "lostpointercapture": {
|
||
var _pointerId = nativeEvent.pointerId;
|
||
queuedPointerCaptures.delete(_pointerId);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
function accumulateOrCreateContinuousQueuedReplayableEvent(existingQueuedEvent, blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) {
|
||
if (existingQueuedEvent === null || existingQueuedEvent.nativeEvent !== nativeEvent) {
|
||
var queuedEvent = createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent);
|
||
if (blockedOn !== null) {
|
||
var _fiber2 = getInstanceFromNode(blockedOn);
|
||
if (_fiber2 !== null) {
|
||
attemptContinuousHydration(_fiber2);
|
||
}
|
||
}
|
||
return queuedEvent;
|
||
}
|
||
existingQueuedEvent.eventSystemFlags |= eventSystemFlags;
|
||
var targetContainers = existingQueuedEvent.targetContainers;
|
||
if (targetContainer !== null && targetContainers.indexOf(targetContainer) === -1) {
|
||
targetContainers.push(targetContainer);
|
||
}
|
||
return existingQueuedEvent;
|
||
}
|
||
function queueIfContinuousEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) {
|
||
switch (domEventName) {
|
||
case "focusin": {
|
||
var focusEvent = nativeEvent;
|
||
queuedFocus = accumulateOrCreateContinuousQueuedReplayableEvent(queuedFocus, blockedOn, domEventName, eventSystemFlags, targetContainer, focusEvent);
|
||
return true;
|
||
}
|
||
case "dragenter": {
|
||
var dragEvent = nativeEvent;
|
||
queuedDrag = accumulateOrCreateContinuousQueuedReplayableEvent(queuedDrag, blockedOn, domEventName, eventSystemFlags, targetContainer, dragEvent);
|
||
return true;
|
||
}
|
||
case "mouseover": {
|
||
var mouseEvent = nativeEvent;
|
||
queuedMouse = accumulateOrCreateContinuousQueuedReplayableEvent(queuedMouse, blockedOn, domEventName, eventSystemFlags, targetContainer, mouseEvent);
|
||
return true;
|
||
}
|
||
case "pointerover": {
|
||
var pointerEvent = nativeEvent;
|
||
var pointerId = pointerEvent.pointerId;
|
||
queuedPointers.set(pointerId, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointers.get(pointerId) || null, blockedOn, domEventName, eventSystemFlags, targetContainer, pointerEvent));
|
||
return true;
|
||
}
|
||
case "gotpointercapture": {
|
||
var _pointerEvent = nativeEvent;
|
||
var _pointerId2 = _pointerEvent.pointerId;
|
||
queuedPointerCaptures.set(_pointerId2, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointerCaptures.get(_pointerId2) || null, blockedOn, domEventName, eventSystemFlags, targetContainer, _pointerEvent));
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
function attemptExplicitHydrationTarget(queuedTarget) {
|
||
var targetInst = getClosestInstanceFromNode(queuedTarget.target);
|
||
if (targetInst !== null) {
|
||
var nearestMounted = getNearestMountedFiber(targetInst);
|
||
if (nearestMounted !== null) {
|
||
var tag = nearestMounted.tag;
|
||
if (tag === SuspenseComponent) {
|
||
var instance = getSuspenseInstanceFromFiber(nearestMounted);
|
||
if (instance !== null) {
|
||
queuedTarget.blockedOn = instance;
|
||
attemptHydrationAtPriority(queuedTarget.priority, function() {
|
||
attemptHydrationAtCurrentPriority(nearestMounted);
|
||
});
|
||
return;
|
||
}
|
||
} else if (tag === HostRoot) {
|
||
var root2 = nearestMounted.stateNode;
|
||
if (isRootDehydrated(root2)) {
|
||
queuedTarget.blockedOn = getContainerFromFiber(nearestMounted);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
queuedTarget.blockedOn = null;
|
||
}
|
||
function queueExplicitHydrationTarget(target) {
|
||
var updatePriority = getCurrentUpdatePriority$1();
|
||
var queuedTarget = {
|
||
blockedOn: null,
|
||
target,
|
||
priority: updatePriority
|
||
};
|
||
var i = 0;
|
||
for (; i < queuedExplicitHydrationTargets.length; i++) {
|
||
if (!isHigherEventPriority(updatePriority, queuedExplicitHydrationTargets[i].priority)) {
|
||
break;
|
||
}
|
||
}
|
||
queuedExplicitHydrationTargets.splice(i, 0, queuedTarget);
|
||
if (i === 0) {
|
||
attemptExplicitHydrationTarget(queuedTarget);
|
||
}
|
||
}
|
||
function attemptReplayContinuousQueuedEvent(queuedEvent) {
|
||
if (queuedEvent.blockedOn !== null) {
|
||
return false;
|
||
}
|
||
var targetContainers = queuedEvent.targetContainers;
|
||
while (targetContainers.length > 0) {
|
||
var targetContainer = targetContainers[0];
|
||
var nextBlockedOn = findInstanceBlockingEvent(queuedEvent.domEventName, queuedEvent.eventSystemFlags, targetContainer, queuedEvent.nativeEvent);
|
||
if (nextBlockedOn === null) {
|
||
{
|
||
var nativeEvent = queuedEvent.nativeEvent;
|
||
var nativeEventClone = new nativeEvent.constructor(nativeEvent.type, nativeEvent);
|
||
setReplayingEvent(nativeEventClone);
|
||
nativeEvent.target.dispatchEvent(nativeEventClone);
|
||
resetReplayingEvent();
|
||
}
|
||
} else {
|
||
var _fiber3 = getInstanceFromNode(nextBlockedOn);
|
||
if (_fiber3 !== null) {
|
||
attemptContinuousHydration(_fiber3);
|
||
}
|
||
queuedEvent.blockedOn = nextBlockedOn;
|
||
return false;
|
||
}
|
||
targetContainers.shift();
|
||
}
|
||
return true;
|
||
}
|
||
function attemptReplayContinuousQueuedEventInMap(queuedEvent, key, map) {
|
||
if (attemptReplayContinuousQueuedEvent(queuedEvent)) {
|
||
map.delete(key);
|
||
}
|
||
}
|
||
function replayUnblockedEvents() {
|
||
hasScheduledReplayAttempt = false;
|
||
if (queuedFocus !== null && attemptReplayContinuousQueuedEvent(queuedFocus)) {
|
||
queuedFocus = null;
|
||
}
|
||
if (queuedDrag !== null && attemptReplayContinuousQueuedEvent(queuedDrag)) {
|
||
queuedDrag = null;
|
||
}
|
||
if (queuedMouse !== null && attemptReplayContinuousQueuedEvent(queuedMouse)) {
|
||
queuedMouse = null;
|
||
}
|
||
queuedPointers.forEach(attemptReplayContinuousQueuedEventInMap);
|
||
queuedPointerCaptures.forEach(attemptReplayContinuousQueuedEventInMap);
|
||
}
|
||
function scheduleCallbackIfUnblocked(queuedEvent, unblocked) {
|
||
if (queuedEvent.blockedOn === unblocked) {
|
||
queuedEvent.blockedOn = null;
|
||
if (!hasScheduledReplayAttempt) {
|
||
hasScheduledReplayAttempt = true;
|
||
Scheduler.unstable_scheduleCallback(Scheduler.unstable_NormalPriority, replayUnblockedEvents);
|
||
}
|
||
}
|
||
}
|
||
function retryIfBlockedOn(unblocked) {
|
||
if (queuedDiscreteEvents.length > 0) {
|
||
scheduleCallbackIfUnblocked(queuedDiscreteEvents[0], unblocked);
|
||
for (var i = 1; i < queuedDiscreteEvents.length; i++) {
|
||
var queuedEvent = queuedDiscreteEvents[i];
|
||
if (queuedEvent.blockedOn === unblocked) {
|
||
queuedEvent.blockedOn = null;
|
||
}
|
||
}
|
||
}
|
||
if (queuedFocus !== null) {
|
||
scheduleCallbackIfUnblocked(queuedFocus, unblocked);
|
||
}
|
||
if (queuedDrag !== null) {
|
||
scheduleCallbackIfUnblocked(queuedDrag, unblocked);
|
||
}
|
||
if (queuedMouse !== null) {
|
||
scheduleCallbackIfUnblocked(queuedMouse, unblocked);
|
||
}
|
||
var unblock = function(queuedEvent2) {
|
||
return scheduleCallbackIfUnblocked(queuedEvent2, unblocked);
|
||
};
|
||
queuedPointers.forEach(unblock);
|
||
queuedPointerCaptures.forEach(unblock);
|
||
for (var _i = 0; _i < queuedExplicitHydrationTargets.length; _i++) {
|
||
var queuedTarget = queuedExplicitHydrationTargets[_i];
|
||
if (queuedTarget.blockedOn === unblocked) {
|
||
queuedTarget.blockedOn = null;
|
||
}
|
||
}
|
||
while (queuedExplicitHydrationTargets.length > 0) {
|
||
var nextExplicitTarget = queuedExplicitHydrationTargets[0];
|
||
if (nextExplicitTarget.blockedOn !== null) {
|
||
break;
|
||
} else {
|
||
attemptExplicitHydrationTarget(nextExplicitTarget);
|
||
if (nextExplicitTarget.blockedOn === null) {
|
||
queuedExplicitHydrationTargets.shift();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
|
||
var _enabled = true;
|
||
function setEnabled(enabled) {
|
||
_enabled = !!enabled;
|
||
}
|
||
function isEnabled() {
|
||
return _enabled;
|
||
}
|
||
function createEventListenerWrapperWithPriority(targetContainer, domEventName, eventSystemFlags) {
|
||
var eventPriority = getEventPriority(domEventName);
|
||
var listenerWrapper;
|
||
switch (eventPriority) {
|
||
case DiscreteEventPriority:
|
||
listenerWrapper = dispatchDiscreteEvent;
|
||
break;
|
||
case ContinuousEventPriority:
|
||
listenerWrapper = dispatchContinuousEvent;
|
||
break;
|
||
case DefaultEventPriority:
|
||
default:
|
||
listenerWrapper = dispatchEvent;
|
||
break;
|
||
}
|
||
return listenerWrapper.bind(null, domEventName, eventSystemFlags, targetContainer);
|
||
}
|
||
function dispatchDiscreteEvent(domEventName, eventSystemFlags, container, nativeEvent) {
|
||
var previousPriority = getCurrentUpdatePriority();
|
||
var prevTransition = ReactCurrentBatchConfig.transition;
|
||
ReactCurrentBatchConfig.transition = null;
|
||
try {
|
||
setCurrentUpdatePriority(DiscreteEventPriority);
|
||
dispatchEvent(domEventName, eventSystemFlags, container, nativeEvent);
|
||
} finally {
|
||
setCurrentUpdatePriority(previousPriority);
|
||
ReactCurrentBatchConfig.transition = prevTransition;
|
||
}
|
||
}
|
||
function dispatchContinuousEvent(domEventName, eventSystemFlags, container, nativeEvent) {
|
||
var previousPriority = getCurrentUpdatePriority();
|
||
var prevTransition = ReactCurrentBatchConfig.transition;
|
||
ReactCurrentBatchConfig.transition = null;
|
||
try {
|
||
setCurrentUpdatePriority(ContinuousEventPriority);
|
||
dispatchEvent(domEventName, eventSystemFlags, container, nativeEvent);
|
||
} finally {
|
||
setCurrentUpdatePriority(previousPriority);
|
||
ReactCurrentBatchConfig.transition = prevTransition;
|
||
}
|
||
}
|
||
function dispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent) {
|
||
if (!_enabled) {
|
||
return;
|
||
}
|
||
{
|
||
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay(domEventName, eventSystemFlags, targetContainer, nativeEvent);
|
||
}
|
||
}
|
||
function dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay(domEventName, eventSystemFlags, targetContainer, nativeEvent) {
|
||
var blockedOn = findInstanceBlockingEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent);
|
||
if (blockedOn === null) {
|
||
dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, return_targetInst, targetContainer);
|
||
clearIfContinuousEvent(domEventName, nativeEvent);
|
||
return;
|
||
}
|
||
if (queueIfContinuousEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent)) {
|
||
nativeEvent.stopPropagation();
|
||
return;
|
||
}
|
||
clearIfContinuousEvent(domEventName, nativeEvent);
|
||
if (eventSystemFlags & IS_CAPTURE_PHASE && isDiscreteEventThatRequiresHydration(domEventName)) {
|
||
while (blockedOn !== null) {
|
||
var fiber = getInstanceFromNode(blockedOn);
|
||
if (fiber !== null) {
|
||
attemptSynchronousHydration(fiber);
|
||
}
|
||
var nextBlockedOn = findInstanceBlockingEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent);
|
||
if (nextBlockedOn === null) {
|
||
dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, return_targetInst, targetContainer);
|
||
}
|
||
if (nextBlockedOn === blockedOn) {
|
||
break;
|
||
}
|
||
blockedOn = nextBlockedOn;
|
||
}
|
||
if (blockedOn !== null) {
|
||
nativeEvent.stopPropagation();
|
||
}
|
||
return;
|
||
}
|
||
dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, null, targetContainer);
|
||
}
|
||
var return_targetInst = null;
|
||
function findInstanceBlockingEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent) {
|
||
return_targetInst = null;
|
||
var nativeEventTarget = getEventTarget(nativeEvent);
|
||
var targetInst = getClosestInstanceFromNode(nativeEventTarget);
|
||
if (targetInst !== null) {
|
||
var nearestMounted = getNearestMountedFiber(targetInst);
|
||
if (nearestMounted === null) {
|
||
targetInst = null;
|
||
} else {
|
||
var tag = nearestMounted.tag;
|
||
if (tag === SuspenseComponent) {
|
||
var instance = getSuspenseInstanceFromFiber(nearestMounted);
|
||
if (instance !== null) {
|
||
return instance;
|
||
}
|
||
targetInst = null;
|
||
} else if (tag === HostRoot) {
|
||
var root2 = nearestMounted.stateNode;
|
||
if (isRootDehydrated(root2)) {
|
||
return getContainerFromFiber(nearestMounted);
|
||
}
|
||
targetInst = null;
|
||
} else if (nearestMounted !== targetInst) {
|
||
targetInst = null;
|
||
}
|
||
}
|
||
}
|
||
return_targetInst = targetInst;
|
||
return null;
|
||
}
|
||
function getEventPriority(domEventName) {
|
||
switch (domEventName) {
|
||
case "cancel":
|
||
case "click":
|
||
case "close":
|
||
case "contextmenu":
|
||
case "copy":
|
||
case "cut":
|
||
case "auxclick":
|
||
case "dblclick":
|
||
case "dragend":
|
||
case "dragstart":
|
||
case "drop":
|
||
case "focusin":
|
||
case "focusout":
|
||
case "input":
|
||
case "invalid":
|
||
case "keydown":
|
||
case "keypress":
|
||
case "keyup":
|
||
case "mousedown":
|
||
case "mouseup":
|
||
case "paste":
|
||
case "pause":
|
||
case "play":
|
||
case "pointercancel":
|
||
case "pointerdown":
|
||
case "pointerup":
|
||
case "ratechange":
|
||
case "reset":
|
||
case "resize":
|
||
case "seeked":
|
||
case "submit":
|
||
case "touchcancel":
|
||
case "touchend":
|
||
case "touchstart":
|
||
case "volumechange":
|
||
case "change":
|
||
case "selectionchange":
|
||
case "textInput":
|
||
case "compositionstart":
|
||
case "compositionend":
|
||
case "compositionupdate":
|
||
case "beforeblur":
|
||
case "afterblur":
|
||
case "beforeinput":
|
||
case "blur":
|
||
case "fullscreenchange":
|
||
case "focus":
|
||
case "hashchange":
|
||
case "popstate":
|
||
case "select":
|
||
case "selectstart":
|
||
return DiscreteEventPriority;
|
||
case "drag":
|
||
case "dragenter":
|
||
case "dragexit":
|
||
case "dragleave":
|
||
case "dragover":
|
||
case "mousemove":
|
||
case "mouseout":
|
||
case "mouseover":
|
||
case "pointermove":
|
||
case "pointerout":
|
||
case "pointerover":
|
||
case "scroll":
|
||
case "toggle":
|
||
case "touchmove":
|
||
case "wheel":
|
||
case "mouseenter":
|
||
case "mouseleave":
|
||
case "pointerenter":
|
||
case "pointerleave":
|
||
return ContinuousEventPriority;
|
||
case "message": {
|
||
var schedulerPriority = getCurrentPriorityLevel();
|
||
switch (schedulerPriority) {
|
||
case ImmediatePriority:
|
||
return DiscreteEventPriority;
|
||
case UserBlockingPriority:
|
||
return ContinuousEventPriority;
|
||
case NormalPriority:
|
||
case LowPriority:
|
||
return DefaultEventPriority;
|
||
case IdlePriority:
|
||
return IdleEventPriority;
|
||
default:
|
||
return DefaultEventPriority;
|
||
}
|
||
}
|
||
default:
|
||
return DefaultEventPriority;
|
||
}
|
||
}
|
||
function addEventBubbleListener(target, eventType, listener) {
|
||
target.addEventListener(eventType, listener, false);
|
||
return listener;
|
||
}
|
||
function addEventCaptureListener(target, eventType, listener) {
|
||
target.addEventListener(eventType, listener, true);
|
||
return listener;
|
||
}
|
||
function addEventCaptureListenerWithPassiveFlag(target, eventType, listener, passive) {
|
||
target.addEventListener(eventType, listener, {
|
||
capture: true,
|
||
passive
|
||
});
|
||
return listener;
|
||
}
|
||
function addEventBubbleListenerWithPassiveFlag(target, eventType, listener, passive) {
|
||
target.addEventListener(eventType, listener, {
|
||
passive
|
||
});
|
||
return listener;
|
||
}
|
||
var root = null;
|
||
var startText = null;
|
||
var fallbackText = null;
|
||
function initialize(nativeEventTarget) {
|
||
root = nativeEventTarget;
|
||
startText = getText();
|
||
return true;
|
||
}
|
||
function reset() {
|
||
root = null;
|
||
startText = null;
|
||
fallbackText = null;
|
||
}
|
||
function getData() {
|
||
if (fallbackText) {
|
||
return fallbackText;
|
||
}
|
||
var start;
|
||
var startValue = startText;
|
||
var startLength = startValue.length;
|
||
var end;
|
||
var endValue = getText();
|
||
var endLength = endValue.length;
|
||
for (start = 0; start < startLength; start++) {
|
||
if (startValue[start] !== endValue[start]) {
|
||
break;
|
||
}
|
||
}
|
||
var minEnd = startLength - start;
|
||
for (end = 1; end <= minEnd; end++) {
|
||
if (startValue[startLength - end] !== endValue[endLength - end]) {
|
||
break;
|
||
}
|
||
}
|
||
var sliceTail = end > 1 ? 1 - end : void 0;
|
||
fallbackText = endValue.slice(start, sliceTail);
|
||
return fallbackText;
|
||
}
|
||
function getText() {
|
||
if ("value" in root) {
|
||
return root.value;
|
||
}
|
||
return root.textContent;
|
||
}
|
||
function getEventCharCode(nativeEvent) {
|
||
var charCode;
|
||
var keyCode = nativeEvent.keyCode;
|
||
if ("charCode" in nativeEvent) {
|
||
charCode = nativeEvent.charCode;
|
||
if (charCode === 0 && keyCode === 13) {
|
||
charCode = 13;
|
||
}
|
||
} else {
|
||
charCode = keyCode;
|
||
}
|
||
if (charCode === 10) {
|
||
charCode = 13;
|
||
}
|
||
if (charCode >= 32 || charCode === 13) {
|
||
return charCode;
|
||
}
|
||
return 0;
|
||
}
|
||
function functionThatReturnsTrue() {
|
||
return true;
|
||
}
|
||
function functionThatReturnsFalse() {
|
||
return false;
|
||
}
|
||
function createSyntheticEvent(Interface) {
|
||
function SyntheticBaseEvent(reactName, reactEventType, targetInst, nativeEvent, nativeEventTarget) {
|
||
this._reactName = reactName;
|
||
this._targetInst = targetInst;
|
||
this.type = reactEventType;
|
||
this.nativeEvent = nativeEvent;
|
||
this.target = nativeEventTarget;
|
||
this.currentTarget = null;
|
||
for (var _propName in Interface) {
|
||
if (!Interface.hasOwnProperty(_propName)) {
|
||
continue;
|
||
}
|
||
var normalize = Interface[_propName];
|
||
if (normalize) {
|
||
this[_propName] = normalize(nativeEvent);
|
||
} else {
|
||
this[_propName] = nativeEvent[_propName];
|
||
}
|
||
}
|
||
var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
|
||
if (defaultPrevented) {
|
||
this.isDefaultPrevented = functionThatReturnsTrue;
|
||
} else {
|
||
this.isDefaultPrevented = functionThatReturnsFalse;
|
||
}
|
||
this.isPropagationStopped = functionThatReturnsFalse;
|
||
return this;
|
||
}
|
||
assign(SyntheticBaseEvent.prototype, {
|
||
preventDefault: function() {
|
||
this.defaultPrevented = true;
|
||
var event = this.nativeEvent;
|
||
if (!event) {
|
||
return;
|
||
}
|
||
if (event.preventDefault) {
|
||
event.preventDefault();
|
||
} else if (typeof event.returnValue !== "unknown") {
|
||
event.returnValue = false;
|
||
}
|
||
this.isDefaultPrevented = functionThatReturnsTrue;
|
||
},
|
||
stopPropagation: function() {
|
||
var event = this.nativeEvent;
|
||
if (!event) {
|
||
return;
|
||
}
|
||
if (event.stopPropagation) {
|
||
event.stopPropagation();
|
||
} else if (typeof event.cancelBubble !== "unknown") {
|
||
event.cancelBubble = true;
|
||
}
|
||
this.isPropagationStopped = functionThatReturnsTrue;
|
||
},
|
||
persist: function() {
|
||
},
|
||
isPersistent: functionThatReturnsTrue
|
||
});
|
||
return SyntheticBaseEvent;
|
||
}
|
||
var EventInterface = {
|
||
eventPhase: 0,
|
||
bubbles: 0,
|
||
cancelable: 0,
|
||
timeStamp: function(event) {
|
||
return event.timeStamp || Date.now();
|
||
},
|
||
defaultPrevented: 0,
|
||
isTrusted: 0
|
||
};
|
||
var SyntheticEvent = createSyntheticEvent(EventInterface);
|
||
var UIEventInterface = assign({}, EventInterface, {
|
||
view: 0,
|
||
detail: 0
|
||
});
|
||
var SyntheticUIEvent = createSyntheticEvent(UIEventInterface);
|
||
var lastMovementX;
|
||
var lastMovementY;
|
||
var lastMouseEvent;
|
||
function updateMouseMovementPolyfillState(event) {
|
||
if (event !== lastMouseEvent) {
|
||
if (lastMouseEvent && event.type === "mousemove") {
|
||
lastMovementX = event.screenX - lastMouseEvent.screenX;
|
||
lastMovementY = event.screenY - lastMouseEvent.screenY;
|
||
} else {
|
||
lastMovementX = 0;
|
||
lastMovementY = 0;
|
||
}
|
||
lastMouseEvent = event;
|
||
}
|
||
}
|
||
var MouseEventInterface = assign({}, UIEventInterface, {
|
||
screenX: 0,
|
||
screenY: 0,
|
||
clientX: 0,
|
||
clientY: 0,
|
||
pageX: 0,
|
||
pageY: 0,
|
||
ctrlKey: 0,
|
||
shiftKey: 0,
|
||
altKey: 0,
|
||
metaKey: 0,
|
||
getModifierState: getEventModifierState,
|
||
button: 0,
|
||
buttons: 0,
|
||
relatedTarget: function(event) {
|
||
if (event.relatedTarget === void 0)
|
||
return event.fromElement === event.srcElement ? event.toElement : event.fromElement;
|
||
return event.relatedTarget;
|
||
},
|
||
movementX: function(event) {
|
||
if ("movementX" in event) {
|
||
return event.movementX;
|
||
}
|
||
updateMouseMovementPolyfillState(event);
|
||
return lastMovementX;
|
||
},
|
||
movementY: function(event) {
|
||
if ("movementY" in event) {
|
||
return event.movementY;
|
||
}
|
||
return lastMovementY;
|
||
}
|
||
});
|
||
var SyntheticMouseEvent = createSyntheticEvent(MouseEventInterface);
|
||
var DragEventInterface = assign({}, MouseEventInterface, {
|
||
dataTransfer: 0
|
||
});
|
||
var SyntheticDragEvent = createSyntheticEvent(DragEventInterface);
|
||
var FocusEventInterface = assign({}, UIEventInterface, {
|
||
relatedTarget: 0
|
||
});
|
||
var SyntheticFocusEvent = createSyntheticEvent(FocusEventInterface);
|
||
var AnimationEventInterface = assign({}, EventInterface, {
|
||
animationName: 0,
|
||
elapsedTime: 0,
|
||
pseudoElement: 0
|
||
});
|
||
var SyntheticAnimationEvent = createSyntheticEvent(AnimationEventInterface);
|
||
var ClipboardEventInterface = assign({}, EventInterface, {
|
||
clipboardData: function(event) {
|
||
return "clipboardData" in event ? event.clipboardData : window.clipboardData;
|
||
}
|
||
});
|
||
var SyntheticClipboardEvent = createSyntheticEvent(ClipboardEventInterface);
|
||
var CompositionEventInterface = assign({}, EventInterface, {
|
||
data: 0
|
||
});
|
||
var SyntheticCompositionEvent = createSyntheticEvent(CompositionEventInterface);
|
||
var SyntheticInputEvent = SyntheticCompositionEvent;
|
||
var normalizeKey = {
|
||
Esc: "Escape",
|
||
Spacebar: " ",
|
||
Left: "ArrowLeft",
|
||
Up: "ArrowUp",
|
||
Right: "ArrowRight",
|
||
Down: "ArrowDown",
|
||
Del: "Delete",
|
||
Win: "OS",
|
||
Menu: "ContextMenu",
|
||
Apps: "ContextMenu",
|
||
Scroll: "ScrollLock",
|
||
MozPrintableKey: "Unidentified"
|
||
};
|
||
var translateToKey = {
|
||
"8": "Backspace",
|
||
"9": "Tab",
|
||
"12": "Clear",
|
||
"13": "Enter",
|
||
"16": "Shift",
|
||
"17": "Control",
|
||
"18": "Alt",
|
||
"19": "Pause",
|
||
"20": "CapsLock",
|
||
"27": "Escape",
|
||
"32": " ",
|
||
"33": "PageUp",
|
||
"34": "PageDown",
|
||
"35": "End",
|
||
"36": "Home",
|
||
"37": "ArrowLeft",
|
||
"38": "ArrowUp",
|
||
"39": "ArrowRight",
|
||
"40": "ArrowDown",
|
||
"45": "Insert",
|
||
"46": "Delete",
|
||
"112": "F1",
|
||
"113": "F2",
|
||
"114": "F3",
|
||
"115": "F4",
|
||
"116": "F5",
|
||
"117": "F6",
|
||
"118": "F7",
|
||
"119": "F8",
|
||
"120": "F9",
|
||
"121": "F10",
|
||
"122": "F11",
|
||
"123": "F12",
|
||
"144": "NumLock",
|
||
"145": "ScrollLock",
|
||
"224": "Meta"
|
||
};
|
||
function getEventKey(nativeEvent) {
|
||
if (nativeEvent.key) {
|
||
var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
|
||
if (key !== "Unidentified") {
|
||
return key;
|
||
}
|
||
}
|
||
if (nativeEvent.type === "keypress") {
|
||
var charCode = getEventCharCode(nativeEvent);
|
||
return charCode === 13 ? "Enter" : String.fromCharCode(charCode);
|
||
}
|
||
if (nativeEvent.type === "keydown" || nativeEvent.type === "keyup") {
|
||
return translateToKey[nativeEvent.keyCode] || "Unidentified";
|
||
}
|
||
return "";
|
||
}
|
||
var modifierKeyToProp = {
|
||
Alt: "altKey",
|
||
Control: "ctrlKey",
|
||
Meta: "metaKey",
|
||
Shift: "shiftKey"
|
||
};
|
||
function modifierStateGetter(keyArg) {
|
||
var syntheticEvent = this;
|
||
var nativeEvent = syntheticEvent.nativeEvent;
|
||
if (nativeEvent.getModifierState) {
|
||
return nativeEvent.getModifierState(keyArg);
|
||
}
|
||
var keyProp = modifierKeyToProp[keyArg];
|
||
return keyProp ? !!nativeEvent[keyProp] : false;
|
||
}
|
||
function getEventModifierState(nativeEvent) {
|
||
return modifierStateGetter;
|
||
}
|
||
var KeyboardEventInterface = assign({}, UIEventInterface, {
|
||
key: getEventKey,
|
||
code: 0,
|
||
location: 0,
|
||
ctrlKey: 0,
|
||
shiftKey: 0,
|
||
altKey: 0,
|
||
metaKey: 0,
|
||
repeat: 0,
|
||
locale: 0,
|
||
getModifierState: getEventModifierState,
|
||
charCode: function(event) {
|
||
if (event.type === "keypress") {
|
||
return getEventCharCode(event);
|
||
}
|
||
return 0;
|
||
},
|
||
keyCode: function(event) {
|
||
if (event.type === "keydown" || event.type === "keyup") {
|
||
return event.keyCode;
|
||
}
|
||
return 0;
|
||
},
|
||
which: function(event) {
|
||
if (event.type === "keypress") {
|
||
return getEventCharCode(event);
|
||
}
|
||
if (event.type === "keydown" || event.type === "keyup") {
|
||
return event.keyCode;
|
||
}
|
||
return 0;
|
||
}
|
||
});
|
||
var SyntheticKeyboardEvent = createSyntheticEvent(KeyboardEventInterface);
|
||
var PointerEventInterface = assign({}, MouseEventInterface, {
|
||
pointerId: 0,
|
||
width: 0,
|
||
height: 0,
|
||
pressure: 0,
|
||
tangentialPressure: 0,
|
||
tiltX: 0,
|
||
tiltY: 0,
|
||
twist: 0,
|
||
pointerType: 0,
|
||
isPrimary: 0
|
||
});
|
||
var SyntheticPointerEvent = createSyntheticEvent(PointerEventInterface);
|
||
var TouchEventInterface = assign({}, UIEventInterface, {
|
||
touches: 0,
|
||
targetTouches: 0,
|
||
changedTouches: 0,
|
||
altKey: 0,
|
||
metaKey: 0,
|
||
ctrlKey: 0,
|
||
shiftKey: 0,
|
||
getModifierState: getEventModifierState
|
||
});
|
||
var SyntheticTouchEvent = createSyntheticEvent(TouchEventInterface);
|
||
var TransitionEventInterface = assign({}, EventInterface, {
|
||
propertyName: 0,
|
||
elapsedTime: 0,
|
||
pseudoElement: 0
|
||
});
|
||
var SyntheticTransitionEvent = createSyntheticEvent(TransitionEventInterface);
|
||
var WheelEventInterface = assign({}, MouseEventInterface, {
|
||
deltaX: function(event) {
|
||
return "deltaX" in event ? event.deltaX : "wheelDeltaX" in event ? -event.wheelDeltaX : 0;
|
||
},
|
||
deltaY: function(event) {
|
||
return "deltaY" in event ? event.deltaY : "wheelDeltaY" in event ? -event.wheelDeltaY : "wheelDelta" in event ? -event.wheelDelta : 0;
|
||
},
|
||
deltaZ: 0,
|
||
deltaMode: 0
|
||
});
|
||
var SyntheticWheelEvent = createSyntheticEvent(WheelEventInterface);
|
||
var END_KEYCODES = [9, 13, 27, 32];
|
||
var START_KEYCODE = 229;
|
||
var canUseCompositionEvent = canUseDOM && "CompositionEvent" in window;
|
||
var documentMode = null;
|
||
if (canUseDOM && "documentMode" in document) {
|
||
documentMode = document.documentMode;
|
||
}
|
||
var canUseTextInputEvent = canUseDOM && "TextEvent" in window && !documentMode;
|
||
var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11);
|
||
var SPACEBAR_CODE = 32;
|
||
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
|
||
function registerEvents() {
|
||
registerTwoPhaseEvent("onBeforeInput", ["compositionend", "keypress", "textInput", "paste"]);
|
||
registerTwoPhaseEvent("onCompositionEnd", ["compositionend", "focusout", "keydown", "keypress", "keyup", "mousedown"]);
|
||
registerTwoPhaseEvent("onCompositionStart", ["compositionstart", "focusout", "keydown", "keypress", "keyup", "mousedown"]);
|
||
registerTwoPhaseEvent("onCompositionUpdate", ["compositionupdate", "focusout", "keydown", "keypress", "keyup", "mousedown"]);
|
||
}
|
||
var hasSpaceKeypress = false;
|
||
function isKeypressCommand(nativeEvent) {
|
||
return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && !(nativeEvent.ctrlKey && nativeEvent.altKey);
|
||
}
|
||
function getCompositionEventType(domEventName) {
|
||
switch (domEventName) {
|
||
case "compositionstart":
|
||
return "onCompositionStart";
|
||
case "compositionend":
|
||
return "onCompositionEnd";
|
||
case "compositionupdate":
|
||
return "onCompositionUpdate";
|
||
}
|
||
}
|
||
function isFallbackCompositionStart(domEventName, nativeEvent) {
|
||
return domEventName === "keydown" && nativeEvent.keyCode === START_KEYCODE;
|
||
}
|
||
function isFallbackCompositionEnd(domEventName, nativeEvent) {
|
||
switch (domEventName) {
|
||
case "keyup":
|
||
return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
|
||
case "keydown":
|
||
return nativeEvent.keyCode !== START_KEYCODE;
|
||
case "keypress":
|
||
case "mousedown":
|
||
case "focusout":
|
||
return true;
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
function getDataFromCustomEvent(nativeEvent) {
|
||
var detail = nativeEvent.detail;
|
||
if (typeof detail === "object" && "data" in detail) {
|
||
return detail.data;
|
||
}
|
||
return null;
|
||
}
|
||
function isUsingKoreanIME(nativeEvent) {
|
||
return nativeEvent.locale === "ko";
|
||
}
|
||
var isComposing = false;
|
||
function extractCompositionEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget) {
|
||
var eventType;
|
||
var fallbackData;
|
||
if (canUseCompositionEvent) {
|
||
eventType = getCompositionEventType(domEventName);
|
||
} else if (!isComposing) {
|
||
if (isFallbackCompositionStart(domEventName, nativeEvent)) {
|
||
eventType = "onCompositionStart";
|
||
}
|
||
} else if (isFallbackCompositionEnd(domEventName, nativeEvent)) {
|
||
eventType = "onCompositionEnd";
|
||
}
|
||
if (!eventType) {
|
||
return null;
|
||
}
|
||
if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) {
|
||
if (!isComposing && eventType === "onCompositionStart") {
|
||
isComposing = initialize(nativeEventTarget);
|
||
} else if (eventType === "onCompositionEnd") {
|
||
if (isComposing) {
|
||
fallbackData = getData();
|
||
}
|
||
}
|
||
}
|
||
var listeners = accumulateTwoPhaseListeners(targetInst, eventType);
|
||
if (listeners.length > 0) {
|
||
var event = new SyntheticCompositionEvent(eventType, domEventName, null, nativeEvent, nativeEventTarget);
|
||
dispatchQueue.push({
|
||
event,
|
||
listeners
|
||
});
|
||
if (fallbackData) {
|
||
event.data = fallbackData;
|
||
} else {
|
||
var customData = getDataFromCustomEvent(nativeEvent);
|
||
if (customData !== null) {
|
||
event.data = customData;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function getNativeBeforeInputChars(domEventName, nativeEvent) {
|
||
switch (domEventName) {
|
||
case "compositionend":
|
||
return getDataFromCustomEvent(nativeEvent);
|
||
case "keypress":
|
||
var which = nativeEvent.which;
|
||
if (which !== SPACEBAR_CODE) {
|
||
return null;
|
||
}
|
||
hasSpaceKeypress = true;
|
||
return SPACEBAR_CHAR;
|
||
case "textInput":
|
||
var chars = nativeEvent.data;
|
||
if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
|
||
return null;
|
||
}
|
||
return chars;
|
||
default:
|
||
return null;
|
||
}
|
||
}
|
||
function getFallbackBeforeInputChars(domEventName, nativeEvent) {
|
||
if (isComposing) {
|
||
if (domEventName === "compositionend" || !canUseCompositionEvent && isFallbackCompositionEnd(domEventName, nativeEvent)) {
|
||
var chars = getData();
|
||
reset();
|
||
isComposing = false;
|
||
return chars;
|
||
}
|
||
return null;
|
||
}
|
||
switch (domEventName) {
|
||
case "paste":
|
||
return null;
|
||
case "keypress":
|
||
if (!isKeypressCommand(nativeEvent)) {
|
||
if (nativeEvent.char && nativeEvent.char.length > 1) {
|
||
return nativeEvent.char;
|
||
} else if (nativeEvent.which) {
|
||
return String.fromCharCode(nativeEvent.which);
|
||
}
|
||
}
|
||
return null;
|
||
case "compositionend":
|
||
return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data;
|
||
default:
|
||
return null;
|
||
}
|
||
}
|
||
function extractBeforeInputEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget) {
|
||
var chars;
|
||
if (canUseTextInputEvent) {
|
||
chars = getNativeBeforeInputChars(domEventName, nativeEvent);
|
||
} else {
|
||
chars = getFallbackBeforeInputChars(domEventName, nativeEvent);
|
||
}
|
||
if (!chars) {
|
||
return null;
|
||
}
|
||
var listeners = accumulateTwoPhaseListeners(targetInst, "onBeforeInput");
|
||
if (listeners.length > 0) {
|
||
var event = new SyntheticInputEvent("onBeforeInput", "beforeinput", null, nativeEvent, nativeEventTarget);
|
||
dispatchQueue.push({
|
||
event,
|
||
listeners
|
||
});
|
||
event.data = chars;
|
||
}
|
||
}
|
||
function extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
|
||
extractCompositionEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
|
||
extractBeforeInputEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
|
||
}
|
||
var supportedInputTypes = {
|
||
color: true,
|
||
date: true,
|
||
datetime: true,
|
||
"datetime-local": true,
|
||
email: true,
|
||
month: true,
|
||
number: true,
|
||
password: true,
|
||
range: true,
|
||
search: true,
|
||
tel: true,
|
||
text: true,
|
||
time: true,
|
||
url: true,
|
||
week: true
|
||
};
|
||
function isTextInputElement(elem) {
|
||
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
|
||
if (nodeName === "input") {
|
||
return !!supportedInputTypes[elem.type];
|
||
}
|
||
if (nodeName === "textarea") {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
function isEventSupported(eventNameSuffix) {
|
||
if (!canUseDOM) {
|
||
return false;
|
||
}
|
||
var eventName = "on" + eventNameSuffix;
|
||
var isSupported = eventName in document;
|
||
if (!isSupported) {
|
||
var element = document.createElement("div");
|
||
element.setAttribute(eventName, "return;");
|
||
isSupported = typeof element[eventName] === "function";
|
||
}
|
||
return isSupported;
|
||
}
|
||
function registerEvents$1() {
|
||
registerTwoPhaseEvent("onChange", ["change", "click", "focusin", "focusout", "input", "keydown", "keyup", "selectionchange"]);
|
||
}
|
||
function createAndAccumulateChangeEvent(dispatchQueue, inst, nativeEvent, target) {
|
||
enqueueStateRestore(target);
|
||
var listeners = accumulateTwoPhaseListeners(inst, "onChange");
|
||
if (listeners.length > 0) {
|
||
var event = new SyntheticEvent("onChange", "change", null, nativeEvent, target);
|
||
dispatchQueue.push({
|
||
event,
|
||
listeners
|
||
});
|
||
}
|
||
}
|
||
var activeElement = null;
|
||
var activeElementInst = null;
|
||
function shouldUseChangeEvent(elem) {
|
||
var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
|
||
return nodeName === "select" || nodeName === "input" && elem.type === "file";
|
||
}
|
||
function manualDispatchChangeEvent(nativeEvent) {
|
||
var dispatchQueue = [];
|
||
createAndAccumulateChangeEvent(dispatchQueue, activeElementInst, nativeEvent, getEventTarget(nativeEvent));
|
||
batchedUpdates(runEventInBatch, dispatchQueue);
|
||
}
|
||
function runEventInBatch(dispatchQueue) {
|
||
processDispatchQueue(dispatchQueue, 0);
|
||
}
|
||
function getInstIfValueChanged(targetInst) {
|
||
var targetNode = getNodeFromInstance(targetInst);
|
||
if (updateValueIfChanged(targetNode)) {
|
||
return targetInst;
|
||
}
|
||
}
|
||
function getTargetInstForChangeEvent(domEventName, targetInst) {
|
||
if (domEventName === "change") {
|
||
return targetInst;
|
||
}
|
||
}
|
||
var isInputEventSupported = false;
|
||
if (canUseDOM) {
|
||
isInputEventSupported = isEventSupported("input") && (!document.documentMode || document.documentMode > 9);
|
||
}
|
||
function startWatchingForValueChange(target, targetInst) {
|
||
activeElement = target;
|
||
activeElementInst = targetInst;
|
||
activeElement.attachEvent("onpropertychange", handlePropertyChange);
|
||
}
|
||
function stopWatchingForValueChange() {
|
||
if (!activeElement) {
|
||
return;
|
||
}
|
||
activeElement.detachEvent("onpropertychange", handlePropertyChange);
|
||
activeElement = null;
|
||
activeElementInst = null;
|
||
}
|
||
function handlePropertyChange(nativeEvent) {
|
||
if (nativeEvent.propertyName !== "value") {
|
||
return;
|
||
}
|
||
if (getInstIfValueChanged(activeElementInst)) {
|
||
manualDispatchChangeEvent(nativeEvent);
|
||
}
|
||
}
|
||
function handleEventsForInputEventPolyfill(domEventName, target, targetInst) {
|
||
if (domEventName === "focusin") {
|
||
stopWatchingForValueChange();
|
||
startWatchingForValueChange(target, targetInst);
|
||
} else if (domEventName === "focusout") {
|
||
stopWatchingForValueChange();
|
||
}
|
||
}
|
||
function getTargetInstForInputEventPolyfill(domEventName, targetInst) {
|
||
if (domEventName === "selectionchange" || domEventName === "keyup" || domEventName === "keydown") {
|
||
return getInstIfValueChanged(activeElementInst);
|
||
}
|
||
}
|
||
function shouldUseClickEvent(elem) {
|
||
var nodeName = elem.nodeName;
|
||
return nodeName && nodeName.toLowerCase() === "input" && (elem.type === "checkbox" || elem.type === "radio");
|
||
}
|
||
function getTargetInstForClickEvent(domEventName, targetInst) {
|
||
if (domEventName === "click") {
|
||
return getInstIfValueChanged(targetInst);
|
||
}
|
||
}
|
||
function getTargetInstForInputOrChangeEvent(domEventName, targetInst) {
|
||
if (domEventName === "input" || domEventName === "change") {
|
||
return getInstIfValueChanged(targetInst);
|
||
}
|
||
}
|
||
function handleControlledInputBlur(node) {
|
||
var state = node._wrapperState;
|
||
if (!state || !state.controlled || node.type !== "number") {
|
||
return;
|
||
}
|
||
{
|
||
setDefaultValue(node, "number", node.value);
|
||
}
|
||
}
|
||
function extractEvents$1(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
|
||
var targetNode = targetInst ? getNodeFromInstance(targetInst) : window;
|
||
var getTargetInstFunc, handleEventFunc;
|
||
if (shouldUseChangeEvent(targetNode)) {
|
||
getTargetInstFunc = getTargetInstForChangeEvent;
|
||
} else if (isTextInputElement(targetNode)) {
|
||
if (isInputEventSupported) {
|
||
getTargetInstFunc = getTargetInstForInputOrChangeEvent;
|
||
} else {
|
||
getTargetInstFunc = getTargetInstForInputEventPolyfill;
|
||
handleEventFunc = handleEventsForInputEventPolyfill;
|
||
}
|
||
} else if (shouldUseClickEvent(targetNode)) {
|
||
getTargetInstFunc = getTargetInstForClickEvent;
|
||
}
|
||
if (getTargetInstFunc) {
|
||
var inst = getTargetInstFunc(domEventName, targetInst);
|
||
if (inst) {
|
||
createAndAccumulateChangeEvent(dispatchQueue, inst, nativeEvent, nativeEventTarget);
|
||
return;
|
||
}
|
||
}
|
||
if (handleEventFunc) {
|
||
handleEventFunc(domEventName, targetNode, targetInst);
|
||
}
|
||
if (domEventName === "focusout") {
|
||
handleControlledInputBlur(targetNode);
|
||
}
|
||
}
|
||
function registerEvents$2() {
|
||
registerDirectEvent("onMouseEnter", ["mouseout", "mouseover"]);
|
||
registerDirectEvent("onMouseLeave", ["mouseout", "mouseover"]);
|
||
registerDirectEvent("onPointerEnter", ["pointerout", "pointerover"]);
|
||
registerDirectEvent("onPointerLeave", ["pointerout", "pointerover"]);
|
||
}
|
||
function extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
|
||
var isOverEvent = domEventName === "mouseover" || domEventName === "pointerover";
|
||
var isOutEvent = domEventName === "mouseout" || domEventName === "pointerout";
|
||
if (isOverEvent && !isReplayingEvent(nativeEvent)) {
|
||
var related = nativeEvent.relatedTarget || nativeEvent.fromElement;
|
||
if (related) {
|
||
if (getClosestInstanceFromNode(related) || isContainerMarkedAsRoot(related)) {
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
if (!isOutEvent && !isOverEvent) {
|
||
return;
|
||
}
|
||
var win;
|
||
if (nativeEventTarget.window === nativeEventTarget) {
|
||
win = nativeEventTarget;
|
||
} else {
|
||
var doc = nativeEventTarget.ownerDocument;
|
||
if (doc) {
|
||
win = doc.defaultView || doc.parentWindow;
|
||
} else {
|
||
win = window;
|
||
}
|
||
}
|
||
var from;
|
||
var to;
|
||
if (isOutEvent) {
|
||
var _related = nativeEvent.relatedTarget || nativeEvent.toElement;
|
||
from = targetInst;
|
||
to = _related ? getClosestInstanceFromNode(_related) : null;
|
||
if (to !== null) {
|
||
var nearestMounted = getNearestMountedFiber(to);
|
||
if (to !== nearestMounted || to.tag !== HostComponent && to.tag !== HostText) {
|
||
to = null;
|
||
}
|
||
}
|
||
} else {
|
||
from = null;
|
||
to = targetInst;
|
||
}
|
||
if (from === to) {
|
||
return;
|
||
}
|
||
var SyntheticEventCtor = SyntheticMouseEvent;
|
||
var leaveEventType = "onMouseLeave";
|
||
var enterEventType = "onMouseEnter";
|
||
var eventTypePrefix = "mouse";
|
||
if (domEventName === "pointerout" || domEventName === "pointerover") {
|
||
SyntheticEventCtor = SyntheticPointerEvent;
|
||
leaveEventType = "onPointerLeave";
|
||
enterEventType = "onPointerEnter";
|
||
eventTypePrefix = "pointer";
|
||
}
|
||
var fromNode = from == null ? win : getNodeFromInstance(from);
|
||
var toNode = to == null ? win : getNodeFromInstance(to);
|
||
var leave = new SyntheticEventCtor(leaveEventType, eventTypePrefix + "leave", from, nativeEvent, nativeEventTarget);
|
||
leave.target = fromNode;
|
||
leave.relatedTarget = toNode;
|
||
var enter = null;
|
||
var nativeTargetInst = getClosestInstanceFromNode(nativeEventTarget);
|
||
if (nativeTargetInst === targetInst) {
|
||
var enterEvent = new SyntheticEventCtor(enterEventType, eventTypePrefix + "enter", to, nativeEvent, nativeEventTarget);
|
||
enterEvent.target = toNode;
|
||
enterEvent.relatedTarget = fromNode;
|
||
enter = enterEvent;
|
||
}
|
||
accumulateEnterLeaveTwoPhaseListeners(dispatchQueue, leave, enter, from, to);
|
||
}
|
||
function is(x, y) {
|
||
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
|
||
}
|
||
var objectIs = typeof Object.is === "function" ? Object.is : is;
|
||
function shallowEqual(objA, objB) {
|
||
if (objectIs(objA, objB)) {
|
||
return true;
|
||
}
|
||
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
||
return false;
|
||
}
|
||
var keysA = Object.keys(objA);
|
||
var keysB = Object.keys(objB);
|
||
if (keysA.length !== keysB.length) {
|
||
return false;
|
||
}
|
||
for (var i = 0; i < keysA.length; i++) {
|
||
var currentKey = keysA[i];
|
||
if (!hasOwnProperty2.call(objB, currentKey) || !objectIs(objA[currentKey], objB[currentKey])) {
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
function getLeafNode(node) {
|
||
while (node && node.firstChild) {
|
||
node = node.firstChild;
|
||
}
|
||
return node;
|
||
}
|
||
function getSiblingNode(node) {
|
||
while (node) {
|
||
if (node.nextSibling) {
|
||
return node.nextSibling;
|
||
}
|
||
node = node.parentNode;
|
||
}
|
||
}
|
||
function getNodeForCharacterOffset(root2, offset) {
|
||
var node = getLeafNode(root2);
|
||
var nodeStart = 0;
|
||
var nodeEnd = 0;
|
||
while (node) {
|
||
if (node.nodeType === TEXT_NODE) {
|
||
nodeEnd = nodeStart + node.textContent.length;
|
||
if (nodeStart <= offset && nodeEnd >= offset) {
|
||
return {
|
||
node,
|
||
offset: offset - nodeStart
|
||
};
|
||
}
|
||
nodeStart = nodeEnd;
|
||
}
|
||
node = getLeafNode(getSiblingNode(node));
|
||
}
|
||
}
|
||
function getOffsets(outerNode) {
|
||
var ownerDocument = outerNode.ownerDocument;
|
||
var win = ownerDocument && ownerDocument.defaultView || window;
|
||
var selection = win.getSelection && win.getSelection();
|
||
if (!selection || selection.rangeCount === 0) {
|
||
return null;
|
||
}
|
||
var anchorNode = selection.anchorNode, anchorOffset = selection.anchorOffset, focusNode = selection.focusNode, focusOffset = selection.focusOffset;
|
||
try {
|
||
anchorNode.nodeType;
|
||
focusNode.nodeType;
|
||
} catch (e) {
|
||
return null;
|
||
}
|
||
return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset);
|
||
}
|
||
function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) {
|
||
var length = 0;
|
||
var start = -1;
|
||
var end = -1;
|
||
var indexWithinAnchor = 0;
|
||
var indexWithinFocus = 0;
|
||
var node = outerNode;
|
||
var parentNode = null;
|
||
outer:
|
||
while (true) {
|
||
var next = null;
|
||
while (true) {
|
||
if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) {
|
||
start = length + anchorOffset;
|
||
}
|
||
if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) {
|
||
end = length + focusOffset;
|
||
}
|
||
if (node.nodeType === TEXT_NODE) {
|
||
length += node.nodeValue.length;
|
||
}
|
||
if ((next = node.firstChild) === null) {
|
||
break;
|
||
}
|
||
parentNode = node;
|
||
node = next;
|
||
}
|
||
while (true) {
|
||
if (node === outerNode) {
|
||
break outer;
|
||
}
|
||
if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) {
|
||
start = length;
|
||
}
|
||
if (parentNode === focusNode && ++indexWithinFocus === focusOffset) {
|
||
end = length;
|
||
}
|
||
if ((next = node.nextSibling) !== null) {
|
||
break;
|
||
}
|
||
node = parentNode;
|
||
parentNode = node.parentNode;
|
||
}
|
||
node = next;
|
||
}
|
||
if (start === -1 || end === -1) {
|
||
return null;
|
||
}
|
||
return {
|
||
start,
|
||
end
|
||
};
|
||
}
|
||
function setOffsets(node, offsets) {
|
||
var doc = node.ownerDocument || document;
|
||
var win = doc && doc.defaultView || window;
|
||
if (!win.getSelection) {
|
||
return;
|
||
}
|
||
var selection = win.getSelection();
|
||
var length = node.textContent.length;
|
||
var start = Math.min(offsets.start, length);
|
||
var end = offsets.end === void 0 ? start : Math.min(offsets.end, length);
|
||
if (!selection.extend && start > end) {
|
||
var temp = end;
|
||
end = start;
|
||
start = temp;
|
||
}
|
||
var startMarker = getNodeForCharacterOffset(node, start);
|
||
var endMarker = getNodeForCharacterOffset(node, end);
|
||
if (startMarker && endMarker) {
|
||
if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) {
|
||
return;
|
||
}
|
||
var range = doc.createRange();
|
||
range.setStart(startMarker.node, startMarker.offset);
|
||
selection.removeAllRanges();
|
||
if (start > end) {
|
||
selection.addRange(range);
|
||
selection.extend(endMarker.node, endMarker.offset);
|
||
} else {
|
||
range.setEnd(endMarker.node, endMarker.offset);
|
||
selection.addRange(range);
|
||
}
|
||
}
|
||
}
|
||
function isTextNode(node) {
|
||
return node && node.nodeType === TEXT_NODE;
|
||
}
|
||
function containsNode(outerNode, innerNode) {
|
||
if (!outerNode || !innerNode) {
|
||
return false;
|
||
} else if (outerNode === innerNode) {
|
||
return true;
|
||
} else if (isTextNode(outerNode)) {
|
||
return false;
|
||
} else if (isTextNode(innerNode)) {
|
||
return containsNode(outerNode, innerNode.parentNode);
|
||
} else if ("contains" in outerNode) {
|
||
return outerNode.contains(innerNode);
|
||
} else if (outerNode.compareDocumentPosition) {
|
||
return !!(outerNode.compareDocumentPosition(innerNode) & 16);
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
function isInDocument(node) {
|
||
return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node);
|
||
}
|
||
function isSameOriginFrame(iframe) {
|
||
try {
|
||
return typeof iframe.contentWindow.location.href === "string";
|
||
} catch (err) {
|
||
return false;
|
||
}
|
||
}
|
||
function getActiveElementDeep() {
|
||
var win = window;
|
||
var element = getActiveElement();
|
||
while (element instanceof win.HTMLIFrameElement) {
|
||
if (isSameOriginFrame(element)) {
|
||
win = element.contentWindow;
|
||
} else {
|
||
return element;
|
||
}
|
||
element = getActiveElement(win.document);
|
||
}
|
||
return element;
|
||
}
|
||
function hasSelectionCapabilities(elem) {
|
||
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
|
||
return nodeName && (nodeName === "input" && (elem.type === "text" || elem.type === "search" || elem.type === "tel" || elem.type === "url" || elem.type === "password") || nodeName === "textarea" || elem.contentEditable === "true");
|
||
}
|
||
function getSelectionInformation() {
|
||
var focusedElem = getActiveElementDeep();
|
||
return {
|
||
focusedElem,
|
||
selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection(focusedElem) : null
|
||
};
|
||
}
|
||
function restoreSelection(priorSelectionInformation) {
|
||
var curFocusedElem = getActiveElementDeep();
|
||
var priorFocusedElem = priorSelectionInformation.focusedElem;
|
||
var priorSelectionRange = priorSelectionInformation.selectionRange;
|
||
if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
|
||
if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) {
|
||
setSelection(priorFocusedElem, priorSelectionRange);
|
||
}
|
||
var ancestors = [];
|
||
var ancestor = priorFocusedElem;
|
||
while (ancestor = ancestor.parentNode) {
|
||
if (ancestor.nodeType === ELEMENT_NODE) {
|
||
ancestors.push({
|
||
element: ancestor,
|
||
left: ancestor.scrollLeft,
|
||
top: ancestor.scrollTop
|
||
});
|
||
}
|
||
}
|
||
if (typeof priorFocusedElem.focus === "function") {
|
||
priorFocusedElem.focus();
|
||
}
|
||
for (var i = 0; i < ancestors.length; i++) {
|
||
var info = ancestors[i];
|
||
info.element.scrollLeft = info.left;
|
||
info.element.scrollTop = info.top;
|
||
}
|
||
}
|
||
}
|
||
function getSelection(input) {
|
||
var selection;
|
||
if ("selectionStart" in input) {
|
||
selection = {
|
||
start: input.selectionStart,
|
||
end: input.selectionEnd
|
||
};
|
||
} else {
|
||
selection = getOffsets(input);
|
||
}
|
||
return selection || {
|
||
start: 0,
|
||
end: 0
|
||
};
|
||
}
|
||
function setSelection(input, offsets) {
|
||
var start = offsets.start;
|
||
var end = offsets.end;
|
||
if (end === void 0) {
|
||
end = start;
|
||
}
|
||
if ("selectionStart" in input) {
|
||
input.selectionStart = start;
|
||
input.selectionEnd = Math.min(end, input.value.length);
|
||
} else {
|
||
setOffsets(input, offsets);
|
||
}
|
||
}
|
||
var skipSelectionChangeEvent = canUseDOM && "documentMode" in document && document.documentMode <= 11;
|
||
function registerEvents$3() {
|
||
registerTwoPhaseEvent("onSelect", ["focusout", "contextmenu", "dragend", "focusin", "keydown", "keyup", "mousedown", "mouseup", "selectionchange"]);
|
||
}
|
||
var activeElement$1 = null;
|
||
var activeElementInst$1 = null;
|
||
var lastSelection = null;
|
||
var mouseDown = false;
|
||
function getSelection$1(node) {
|
||
if ("selectionStart" in node && hasSelectionCapabilities(node)) {
|
||
return {
|
||
start: node.selectionStart,
|
||
end: node.selectionEnd
|
||
};
|
||
} else {
|
||
var win = node.ownerDocument && node.ownerDocument.defaultView || window;
|
||
var selection = win.getSelection();
|
||
return {
|
||
anchorNode: selection.anchorNode,
|
||
anchorOffset: selection.anchorOffset,
|
||
focusNode: selection.focusNode,
|
||
focusOffset: selection.focusOffset
|
||
};
|
||
}
|
||
}
|
||
function getEventTargetDocument(eventTarget) {
|
||
return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument;
|
||
}
|
||
function constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget) {
|
||
var doc = getEventTargetDocument(nativeEventTarget);
|
||
if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) {
|
||
return;
|
||
}
|
||
var currentSelection = getSelection$1(activeElement$1);
|
||
if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
|
||
lastSelection = currentSelection;
|
||
var listeners = accumulateTwoPhaseListeners(activeElementInst$1, "onSelect");
|
||
if (listeners.length > 0) {
|
||
var event = new SyntheticEvent("onSelect", "select", null, nativeEvent, nativeEventTarget);
|
||
dispatchQueue.push({
|
||
event,
|
||
listeners
|
||
});
|
||
event.target = activeElement$1;
|
||
}
|
||
}
|
||
}
|
||
function extractEvents$3(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
|
||
var targetNode = targetInst ? getNodeFromInstance(targetInst) : window;
|
||
switch (domEventName) {
|
||
case "focusin":
|
||
if (isTextInputElement(targetNode) || targetNode.contentEditable === "true") {
|
||
activeElement$1 = targetNode;
|
||
activeElementInst$1 = targetInst;
|
||
lastSelection = null;
|
||
}
|
||
break;
|
||
case "focusout":
|
||
activeElement$1 = null;
|
||
activeElementInst$1 = null;
|
||
lastSelection = null;
|
||
break;
|
||
case "mousedown":
|
||
mouseDown = true;
|
||
break;
|
||
case "contextmenu":
|
||
case "mouseup":
|
||
case "dragend":
|
||
mouseDown = false;
|
||
constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget);
|
||
break;
|
||
case "selectionchange":
|
||
if (skipSelectionChangeEvent) {
|
||
break;
|
||
}
|
||
case "keydown":
|
||
case "keyup":
|
||
constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget);
|
||
}
|
||
}
|
||
function makePrefixMap(styleProp, eventName) {
|
||
var prefixes2 = {};
|
||
prefixes2[styleProp.toLowerCase()] = eventName.toLowerCase();
|
||
prefixes2["Webkit" + styleProp] = "webkit" + eventName;
|
||
prefixes2["Moz" + styleProp] = "moz" + eventName;
|
||
return prefixes2;
|
||
}
|
||
var vendorPrefixes = {
|
||
animationend: makePrefixMap("Animation", "AnimationEnd"),
|
||
animationiteration: makePrefixMap("Animation", "AnimationIteration"),
|
||
animationstart: makePrefixMap("Animation", "AnimationStart"),
|
||
transitionend: makePrefixMap("Transition", "TransitionEnd")
|
||
};
|
||
var prefixedEventNames = {};
|
||
var style = {};
|
||
if (canUseDOM) {
|
||
style = document.createElement("div").style;
|
||
if (!("AnimationEvent" in window)) {
|
||
delete vendorPrefixes.animationend.animation;
|
||
delete vendorPrefixes.animationiteration.animation;
|
||
delete vendorPrefixes.animationstart.animation;
|
||
}
|
||
if (!("TransitionEvent" in window)) {
|
||
delete vendorPrefixes.transitionend.transition;
|
||
}
|
||
}
|
||
function getVendorPrefixedEventName(eventName) {
|
||
if (prefixedEventNames[eventName]) {
|
||
return prefixedEventNames[eventName];
|
||
} else if (!vendorPrefixes[eventName]) {
|
||
return eventName;
|
||
}
|
||
var prefixMap = vendorPrefixes[eventName];
|
||
for (var styleProp in prefixMap) {
|
||
if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
|
||
return prefixedEventNames[eventName] = prefixMap[styleProp];
|
||
}
|
||
}
|
||
return eventName;
|
||
}
|
||
var ANIMATION_END = getVendorPrefixedEventName("animationend");
|
||
var ANIMATION_ITERATION = getVendorPrefixedEventName("animationiteration");
|
||
var ANIMATION_START = getVendorPrefixedEventName("animationstart");
|
||
var TRANSITION_END = getVendorPrefixedEventName("transitionend");
|
||
var topLevelEventsToReactNames = /* @__PURE__ */ new Map();
|
||
var simpleEventPluginEvents = ["abort", "auxClick", "cancel", "canPlay", "canPlayThrough", "click", "close", "contextMenu", "copy", "cut", "drag", "dragEnd", "dragEnter", "dragExit", "dragLeave", "dragOver", "dragStart", "drop", "durationChange", "emptied", "encrypted", "ended", "error", "gotPointerCapture", "input", "invalid", "keyDown", "keyPress", "keyUp", "load", "loadedData", "loadedMetadata", "loadStart", "lostPointerCapture", "mouseDown", "mouseMove", "mouseOut", "mouseOver", "mouseUp", "paste", "pause", "play", "playing", "pointerCancel", "pointerDown", "pointerMove", "pointerOut", "pointerOver", "pointerUp", "progress", "rateChange", "reset", "resize", "seeked", "seeking", "stalled", "submit", "suspend", "timeUpdate", "touchCancel", "touchEnd", "touchStart", "volumeChange", "scroll", "toggle", "touchMove", "waiting", "wheel"];
|
||
function registerSimpleEvent(domEventName, reactName) {
|
||
topLevelEventsToReactNames.set(domEventName, reactName);
|
||
registerTwoPhaseEvent(reactName, [domEventName]);
|
||
}
|
||
function registerSimpleEvents() {
|
||
for (var i = 0; i < simpleEventPluginEvents.length; i++) {
|
||
var eventName = simpleEventPluginEvents[i];
|
||
var domEventName = eventName.toLowerCase();
|
||
var capitalizedEvent = eventName[0].toUpperCase() + eventName.slice(1);
|
||
registerSimpleEvent(domEventName, "on" + capitalizedEvent);
|
||
}
|
||
registerSimpleEvent(ANIMATION_END, "onAnimationEnd");
|
||
registerSimpleEvent(ANIMATION_ITERATION, "onAnimationIteration");
|
||
registerSimpleEvent(ANIMATION_START, "onAnimationStart");
|
||
registerSimpleEvent("dblclick", "onDoubleClick");
|
||
registerSimpleEvent("focusin", "onFocus");
|
||
registerSimpleEvent("focusout", "onBlur");
|
||
registerSimpleEvent(TRANSITION_END, "onTransitionEnd");
|
||
}
|
||
function extractEvents$4(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
|
||
var reactName = topLevelEventsToReactNames.get(domEventName);
|
||
if (reactName === void 0) {
|
||
return;
|
||
}
|
||
var SyntheticEventCtor = SyntheticEvent;
|
||
var reactEventType = domEventName;
|
||
switch (domEventName) {
|
||
case "keypress":
|
||
if (getEventCharCode(nativeEvent) === 0) {
|
||
return;
|
||
}
|
||
case "keydown":
|
||
case "keyup":
|
||
SyntheticEventCtor = SyntheticKeyboardEvent;
|
||
break;
|
||
case "focusin":
|
||
reactEventType = "focus";
|
||
SyntheticEventCtor = SyntheticFocusEvent;
|
||
break;
|
||
case "focusout":
|
||
reactEventType = "blur";
|
||
SyntheticEventCtor = SyntheticFocusEvent;
|
||
break;
|
||
case "beforeblur":
|
||
case "afterblur":
|
||
SyntheticEventCtor = SyntheticFocusEvent;
|
||
break;
|
||
case "click":
|
||
if (nativeEvent.button === 2) {
|
||
return;
|
||
}
|
||
case "auxclick":
|
||
case "dblclick":
|
||
case "mousedown":
|
||
case "mousemove":
|
||
case "mouseup":
|
||
case "mouseout":
|
||
case "mouseover":
|
||
case "contextmenu":
|
||
SyntheticEventCtor = SyntheticMouseEvent;
|
||
break;
|
||
case "drag":
|
||
case "dragend":
|
||
case "dragenter":
|
||
case "dragexit":
|
||
case "dragleave":
|
||
case "dragover":
|
||
case "dragstart":
|
||
case "drop":
|
||
SyntheticEventCtor = SyntheticDragEvent;
|
||
break;
|
||
case "touchcancel":
|
||
case "touchend":
|
||
case "touchmove":
|
||
case "touchstart":
|
||
SyntheticEventCtor = SyntheticTouchEvent;
|
||
break;
|
||
case ANIMATION_END:
|
||
case ANIMATION_ITERATION:
|
||
case ANIMATION_START:
|
||
SyntheticEventCtor = SyntheticAnimationEvent;
|
||
break;
|
||
case TRANSITION_END:
|
||
SyntheticEventCtor = SyntheticTransitionEvent;
|
||
break;
|
||
case "scroll":
|
||
SyntheticEventCtor = SyntheticUIEvent;
|
||
break;
|
||
case "wheel":
|
||
SyntheticEventCtor = SyntheticWheelEvent;
|
||
break;
|
||
case "copy":
|
||
case "cut":
|
||
case "paste":
|
||
SyntheticEventCtor = SyntheticClipboardEvent;
|
||
break;
|
||
case "gotpointercapture":
|
||
case "lostpointercapture":
|
||
case "pointercancel":
|
||
case "pointerdown":
|
||
case "pointermove":
|
||
case "pointerout":
|
||
case "pointerover":
|
||
case "pointerup":
|
||
SyntheticEventCtor = SyntheticPointerEvent;
|
||
break;
|
||
}
|
||
var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0;
|
||
{
|
||
var accumulateTargetOnly = !inCapturePhase && domEventName === "scroll";
|
||
var _listeners = accumulateSinglePhaseListeners(targetInst, reactName, nativeEvent.type, inCapturePhase, accumulateTargetOnly);
|
||
if (_listeners.length > 0) {
|
||
var _event = new SyntheticEventCtor(reactName, reactEventType, null, nativeEvent, nativeEventTarget);
|
||
dispatchQueue.push({
|
||
event: _event,
|
||
listeners: _listeners
|
||
});
|
||
}
|
||
}
|
||
}
|
||
registerSimpleEvents();
|
||
registerEvents$2();
|
||
registerEvents$1();
|
||
registerEvents$3();
|
||
registerEvents();
|
||
function extractEvents$5(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
|
||
extractEvents$4(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
|
||
var shouldProcessPolyfillPlugins = (eventSystemFlags & SHOULD_NOT_PROCESS_POLYFILL_EVENT_PLUGINS) === 0;
|
||
if (shouldProcessPolyfillPlugins) {
|
||
extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
|
||
extractEvents$1(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
|
||
extractEvents$3(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
|
||
extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
|
||
}
|
||
}
|
||
var mediaEventTypes = ["abort", "canplay", "canplaythrough", "durationchange", "emptied", "encrypted", "ended", "error", "loadeddata", "loadedmetadata", "loadstart", "pause", "play", "playing", "progress", "ratechange", "resize", "seeked", "seeking", "stalled", "suspend", "timeupdate", "volumechange", "waiting"];
|
||
var nonDelegatedEvents = new Set(["cancel", "close", "invalid", "load", "scroll", "toggle"].concat(mediaEventTypes));
|
||
function executeDispatch(event, listener, currentTarget) {
|
||
var type = event.type || "unknown-event";
|
||
event.currentTarget = currentTarget;
|
||
invokeGuardedCallbackAndCatchFirstError(type, listener, void 0, event);
|
||
event.currentTarget = null;
|
||
}
|
||
function processDispatchQueueItemsInOrder(event, dispatchListeners, inCapturePhase) {
|
||
var previousInstance;
|
||
if (inCapturePhase) {
|
||
for (var i = dispatchListeners.length - 1; i >= 0; i--) {
|
||
var _dispatchListeners$i = dispatchListeners[i], instance = _dispatchListeners$i.instance, currentTarget = _dispatchListeners$i.currentTarget, listener = _dispatchListeners$i.listener;
|
||
if (instance !== previousInstance && event.isPropagationStopped()) {
|
||
return;
|
||
}
|
||
executeDispatch(event, listener, currentTarget);
|
||
previousInstance = instance;
|
||
}
|
||
} else {
|
||
for (var _i = 0; _i < dispatchListeners.length; _i++) {
|
||
var _dispatchListeners$_i = dispatchListeners[_i], _instance = _dispatchListeners$_i.instance, _currentTarget = _dispatchListeners$_i.currentTarget, _listener = _dispatchListeners$_i.listener;
|
||
if (_instance !== previousInstance && event.isPropagationStopped()) {
|
||
return;
|
||
}
|
||
executeDispatch(event, _listener, _currentTarget);
|
||
previousInstance = _instance;
|
||
}
|
||
}
|
||
}
|
||
function processDispatchQueue(dispatchQueue, eventSystemFlags) {
|
||
var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0;
|
||
for (var i = 0; i < dispatchQueue.length; i++) {
|
||
var _dispatchQueue$i = dispatchQueue[i], event = _dispatchQueue$i.event, listeners = _dispatchQueue$i.listeners;
|
||
processDispatchQueueItemsInOrder(event, listeners, inCapturePhase);
|
||
}
|
||
rethrowCaughtError();
|
||
}
|
||
function dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) {
|
||
var nativeEventTarget = getEventTarget(nativeEvent);
|
||
var dispatchQueue = [];
|
||
extractEvents$5(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
|
||
processDispatchQueue(dispatchQueue, eventSystemFlags);
|
||
}
|
||
function listenToNonDelegatedEvent(domEventName, targetElement) {
|
||
{
|
||
if (!nonDelegatedEvents.has(domEventName)) {
|
||
error('Did not expect a listenToNonDelegatedEvent() call for "%s". This is a bug in React. Please file an issue.', domEventName);
|
||
}
|
||
}
|
||
var isCapturePhaseListener = false;
|
||
var listenerSet = getEventListenerSet(targetElement);
|
||
var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener);
|
||
if (!listenerSet.has(listenerSetKey)) {
|
||
addTrappedEventListener(targetElement, domEventName, IS_NON_DELEGATED, isCapturePhaseListener);
|
||
listenerSet.add(listenerSetKey);
|
||
}
|
||
}
|
||
function listenToNativeEvent(domEventName, isCapturePhaseListener, target) {
|
||
{
|
||
if (nonDelegatedEvents.has(domEventName) && !isCapturePhaseListener) {
|
||
error('Did not expect a listenToNativeEvent() call for "%s" in the bubble phase. This is a bug in React. Please file an issue.', domEventName);
|
||
}
|
||
}
|
||
var eventSystemFlags = 0;
|
||
if (isCapturePhaseListener) {
|
||
eventSystemFlags |= IS_CAPTURE_PHASE;
|
||
}
|
||
addTrappedEventListener(target, domEventName, eventSystemFlags, isCapturePhaseListener);
|
||
}
|
||
var listeningMarker = "_reactListening" + Math.random().toString(36).slice(2);
|
||
function listenToAllSupportedEvents(rootContainerElement) {
|
||
if (!rootContainerElement[listeningMarker]) {
|
||
rootContainerElement[listeningMarker] = true;
|
||
allNativeEvents.forEach(function(domEventName) {
|
||
if (domEventName !== "selectionchange") {
|
||
if (!nonDelegatedEvents.has(domEventName)) {
|
||
listenToNativeEvent(domEventName, false, rootContainerElement);
|
||
}
|
||
listenToNativeEvent(domEventName, true, rootContainerElement);
|
||
}
|
||
});
|
||
var ownerDocument = rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument;
|
||
if (ownerDocument !== null) {
|
||
if (!ownerDocument[listeningMarker]) {
|
||
ownerDocument[listeningMarker] = true;
|
||
listenToNativeEvent("selectionchange", false, ownerDocument);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function addTrappedEventListener(targetContainer, domEventName, eventSystemFlags, isCapturePhaseListener, isDeferredListenerForLegacyFBSupport) {
|
||
var listener = createEventListenerWrapperWithPriority(targetContainer, domEventName, eventSystemFlags);
|
||
var isPassiveListener = void 0;
|
||
if (passiveBrowserEventsSupported) {
|
||
if (domEventName === "touchstart" || domEventName === "touchmove" || domEventName === "wheel") {
|
||
isPassiveListener = true;
|
||
}
|
||
}
|
||
targetContainer = targetContainer;
|
||
var unsubscribeListener;
|
||
if (isCapturePhaseListener) {
|
||
if (isPassiveListener !== void 0) {
|
||
unsubscribeListener = addEventCaptureListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener);
|
||
} else {
|
||
unsubscribeListener = addEventCaptureListener(targetContainer, domEventName, listener);
|
||
}
|
||
} else {
|
||
if (isPassiveListener !== void 0) {
|
||
unsubscribeListener = addEventBubbleListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener);
|
||
} else {
|
||
unsubscribeListener = addEventBubbleListener(targetContainer, domEventName, listener);
|
||
}
|
||
}
|
||
}
|
||
function isMatchingRootContainer(grandContainer, targetContainer) {
|
||
return grandContainer === targetContainer || grandContainer.nodeType === COMMENT_NODE && grandContainer.parentNode === targetContainer;
|
||
}
|
||
function dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) {
|
||
var ancestorInst = targetInst;
|
||
if ((eventSystemFlags & IS_EVENT_HANDLE_NON_MANAGED_NODE) === 0 && (eventSystemFlags & IS_NON_DELEGATED) === 0) {
|
||
var targetContainerNode = targetContainer;
|
||
if (targetInst !== null) {
|
||
var node = targetInst;
|
||
mainLoop:
|
||
while (true) {
|
||
if (node === null) {
|
||
return;
|
||
}
|
||
var nodeTag = node.tag;
|
||
if (nodeTag === HostRoot || nodeTag === HostPortal) {
|
||
var container = node.stateNode.containerInfo;
|
||
if (isMatchingRootContainer(container, targetContainerNode)) {
|
||
break;
|
||
}
|
||
if (nodeTag === HostPortal) {
|
||
var grandNode = node.return;
|
||
while (grandNode !== null) {
|
||
var grandTag = grandNode.tag;
|
||
if (grandTag === HostRoot || grandTag === HostPortal) {
|
||
var grandContainer = grandNode.stateNode.containerInfo;
|
||
if (isMatchingRootContainer(grandContainer, targetContainerNode)) {
|
||
return;
|
||
}
|
||
}
|
||
grandNode = grandNode.return;
|
||
}
|
||
}
|
||
while (container !== null) {
|
||
var parentNode = getClosestInstanceFromNode(container);
|
||
if (parentNode === null) {
|
||
return;
|
||
}
|
||
var parentTag = parentNode.tag;
|
||
if (parentTag === HostComponent || parentTag === HostText) {
|
||
node = ancestorInst = parentNode;
|
||
continue mainLoop;
|
||
}
|
||
container = container.parentNode;
|
||
}
|
||
}
|
||
node = node.return;
|
||
}
|
||
}
|
||
}
|
||
batchedUpdates(function() {
|
||
return dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, ancestorInst);
|
||
});
|
||
}
|
||
function createDispatchListener(instance, listener, currentTarget) {
|
||
return {
|
||
instance,
|
||
listener,
|
||
currentTarget
|
||
};
|
||
}
|
||
function accumulateSinglePhaseListeners(targetFiber, reactName, nativeEventType, inCapturePhase, accumulateTargetOnly, nativeEvent) {
|
||
var captureName = reactName !== null ? reactName + "Capture" : null;
|
||
var reactEventName = inCapturePhase ? captureName : reactName;
|
||
var listeners = [];
|
||
var instance = targetFiber;
|
||
var lastHostComponent = null;
|
||
while (instance !== null) {
|
||
var _instance2 = instance, stateNode = _instance2.stateNode, tag = _instance2.tag;
|
||
if (tag === HostComponent && stateNode !== null) {
|
||
lastHostComponent = stateNode;
|
||
if (reactEventName !== null) {
|
||
var listener = getListener(instance, reactEventName);
|
||
if (listener != null) {
|
||
listeners.push(createDispatchListener(instance, listener, lastHostComponent));
|
||
}
|
||
}
|
||
}
|
||
if (accumulateTargetOnly) {
|
||
break;
|
||
}
|
||
instance = instance.return;
|
||
}
|
||
return listeners;
|
||
}
|
||
function accumulateTwoPhaseListeners(targetFiber, reactName) {
|
||
var captureName = reactName + "Capture";
|
||
var listeners = [];
|
||
var instance = targetFiber;
|
||
while (instance !== null) {
|
||
var _instance3 = instance, stateNode = _instance3.stateNode, tag = _instance3.tag;
|
||
if (tag === HostComponent && stateNode !== null) {
|
||
var currentTarget = stateNode;
|
||
var captureListener = getListener(instance, captureName);
|
||
if (captureListener != null) {
|
||
listeners.unshift(createDispatchListener(instance, captureListener, currentTarget));
|
||
}
|
||
var bubbleListener = getListener(instance, reactName);
|
||
if (bubbleListener != null) {
|
||
listeners.push(createDispatchListener(instance, bubbleListener, currentTarget));
|
||
}
|
||
}
|
||
instance = instance.return;
|
||
}
|
||
return listeners;
|
||
}
|
||
function getParent(inst) {
|
||
if (inst === null) {
|
||
return null;
|
||
}
|
||
do {
|
||
inst = inst.return;
|
||
} while (inst && inst.tag !== HostComponent);
|
||
if (inst) {
|
||
return inst;
|
||
}
|
||
return null;
|
||
}
|
||
function getLowestCommonAncestor(instA, instB) {
|
||
var nodeA = instA;
|
||
var nodeB = instB;
|
||
var depthA = 0;
|
||
for (var tempA = nodeA; tempA; tempA = getParent(tempA)) {
|
||
depthA++;
|
||
}
|
||
var depthB = 0;
|
||
for (var tempB = nodeB; tempB; tempB = getParent(tempB)) {
|
||
depthB++;
|
||
}
|
||
while (depthA - depthB > 0) {
|
||
nodeA = getParent(nodeA);
|
||
depthA--;
|
||
}
|
||
while (depthB - depthA > 0) {
|
||
nodeB = getParent(nodeB);
|
||
depthB--;
|
||
}
|
||
var depth = depthA;
|
||
while (depth--) {
|
||
if (nodeA === nodeB || nodeB !== null && nodeA === nodeB.alternate) {
|
||
return nodeA;
|
||
}
|
||
nodeA = getParent(nodeA);
|
||
nodeB = getParent(nodeB);
|
||
}
|
||
return null;
|
||
}
|
||
function accumulateEnterLeaveListenersForEvent(dispatchQueue, event, target, common, inCapturePhase) {
|
||
var registrationName = event._reactName;
|
||
var listeners = [];
|
||
var instance = target;
|
||
while (instance !== null) {
|
||
if (instance === common) {
|
||
break;
|
||
}
|
||
var _instance4 = instance, alternate = _instance4.alternate, stateNode = _instance4.stateNode, tag = _instance4.tag;
|
||
if (alternate !== null && alternate === common) {
|
||
break;
|
||
}
|
||
if (tag === HostComponent && stateNode !== null) {
|
||
var currentTarget = stateNode;
|
||
if (inCapturePhase) {
|
||
var captureListener = getListener(instance, registrationName);
|
||
if (captureListener != null) {
|
||
listeners.unshift(createDispatchListener(instance, captureListener, currentTarget));
|
||
}
|
||
} else if (!inCapturePhase) {
|
||
var bubbleListener = getListener(instance, registrationName);
|
||
if (bubbleListener != null) {
|
||
listeners.push(createDispatchListener(instance, bubbleListener, currentTarget));
|
||
}
|
||
}
|
||
}
|
||
instance = instance.return;
|
||
}
|
||
if (listeners.length !== 0) {
|
||
dispatchQueue.push({
|
||
event,
|
||
listeners
|
||
});
|
||
}
|
||
}
|
||
function accumulateEnterLeaveTwoPhaseListeners(dispatchQueue, leaveEvent, enterEvent, from, to) {
|
||
var common = from && to ? getLowestCommonAncestor(from, to) : null;
|
||
if (from !== null) {
|
||
accumulateEnterLeaveListenersForEvent(dispatchQueue, leaveEvent, from, common, false);
|
||
}
|
||
if (to !== null && enterEvent !== null) {
|
||
accumulateEnterLeaveListenersForEvent(dispatchQueue, enterEvent, to, common, true);
|
||
}
|
||
}
|
||
function getListenerSetKey(domEventName, capture) {
|
||
return domEventName + "__" + (capture ? "capture" : "bubble");
|
||
}
|
||
var didWarnInvalidHydration = false;
|
||
var DANGEROUSLY_SET_INNER_HTML = "dangerouslySetInnerHTML";
|
||
var SUPPRESS_CONTENT_EDITABLE_WARNING = "suppressContentEditableWarning";
|
||
var SUPPRESS_HYDRATION_WARNING = "suppressHydrationWarning";
|
||
var AUTOFOCUS = "autoFocus";
|
||
var CHILDREN = "children";
|
||
var STYLE = "style";
|
||
var HTML$1 = "__html";
|
||
var warnedUnknownTags;
|
||
var validatePropertiesInDevelopment;
|
||
var warnForPropDifference;
|
||
var warnForExtraAttributes;
|
||
var warnForInvalidEventListener;
|
||
var canDiffStyleForHydrationWarning;
|
||
var normalizeHTML;
|
||
{
|
||
warnedUnknownTags = {
|
||
dialog: true,
|
||
webview: true
|
||
};
|
||
validatePropertiesInDevelopment = function(type, props) {
|
||
validateProperties(type, props);
|
||
validateProperties$1(type, props);
|
||
validateProperties$2(type, props, {
|
||
registrationNameDependencies,
|
||
possibleRegistrationNames
|
||
});
|
||
};
|
||
canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode;
|
||
warnForPropDifference = function(propName, serverValue, clientValue) {
|
||
if (didWarnInvalidHydration) {
|
||
return;
|
||
}
|
||
var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue);
|
||
var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue);
|
||
if (normalizedServerValue === normalizedClientValue) {
|
||
return;
|
||
}
|
||
didWarnInvalidHydration = true;
|
||
error("Prop `%s` did not match. Server: %s Client: %s", propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue));
|
||
};
|
||
warnForExtraAttributes = function(attributeNames) {
|
||
if (didWarnInvalidHydration) {
|
||
return;
|
||
}
|
||
didWarnInvalidHydration = true;
|
||
var names = [];
|
||
attributeNames.forEach(function(name) {
|
||
names.push(name);
|
||
});
|
||
error("Extra attributes from the server: %s", names);
|
||
};
|
||
warnForInvalidEventListener = function(registrationName, listener) {
|
||
if (listener === false) {
|
||
error("Expected `%s` listener to be a function, instead got `false`.\n\nIf you used to conditionally omit it with %s={condition && value}, pass %s={condition ? value : undefined} instead.", registrationName, registrationName, registrationName);
|
||
} else {
|
||
error("Expected `%s` listener to be a function, instead got a value of `%s` type.", registrationName, typeof listener);
|
||
}
|
||
};
|
||
normalizeHTML = function(parent2, html) {
|
||
var testElement = parent2.namespaceURI === HTML_NAMESPACE ? parent2.ownerDocument.createElement(parent2.tagName) : parent2.ownerDocument.createElementNS(parent2.namespaceURI, parent2.tagName);
|
||
testElement.innerHTML = html;
|
||
return testElement.innerHTML;
|
||
};
|
||
}
|
||
var NORMALIZE_NEWLINES_REGEX = /\r\n?/g;
|
||
var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g;
|
||
function normalizeMarkupForTextOrAttribute(markup) {
|
||
{
|
||
checkHtmlStringCoercion(markup);
|
||
}
|
||
var markupString = typeof markup === "string" ? markup : "" + markup;
|
||
return markupString.replace(NORMALIZE_NEWLINES_REGEX, "\n").replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, "");
|
||
}
|
||
function checkForUnmatchedText(serverText, clientText, isConcurrentMode, shouldWarnDev) {
|
||
var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText);
|
||
var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText);
|
||
if (normalizedServerText === normalizedClientText) {
|
||
return;
|
||
}
|
||
if (shouldWarnDev) {
|
||
{
|
||
if (!didWarnInvalidHydration) {
|
||
didWarnInvalidHydration = true;
|
||
error('Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText);
|
||
}
|
||
}
|
||
}
|
||
if (isConcurrentMode && enableClientRenderFallbackOnTextMismatch) {
|
||
throw new Error("Text content does not match server-rendered HTML.");
|
||
}
|
||
}
|
||
function getOwnerDocumentFromRootContainer(rootContainerElement) {
|
||
return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument;
|
||
}
|
||
function noop() {
|
||
}
|
||
function trapClickOnNonInteractiveElement(node) {
|
||
node.onclick = noop;
|
||
}
|
||
function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
|
||
for (var propKey in nextProps) {
|
||
if (!nextProps.hasOwnProperty(propKey)) {
|
||
continue;
|
||
}
|
||
var nextProp = nextProps[propKey];
|
||
if (propKey === STYLE) {
|
||
{
|
||
if (nextProp) {
|
||
Object.freeze(nextProp);
|
||
}
|
||
}
|
||
setValueForStyles(domElement, nextProp);
|
||
} else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
|
||
var nextHtml = nextProp ? nextProp[HTML$1] : void 0;
|
||
if (nextHtml != null) {
|
||
setInnerHTML(domElement, nextHtml);
|
||
}
|
||
} else if (propKey === CHILDREN) {
|
||
if (typeof nextProp === "string") {
|
||
var canSetTextContent = tag !== "textarea" || nextProp !== "";
|
||
if (canSetTextContent) {
|
||
setTextContent(domElement, nextProp);
|
||
}
|
||
} else if (typeof nextProp === "number") {
|
||
setTextContent(domElement, "" + nextProp);
|
||
}
|
||
} else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING)
|
||
;
|
||
else if (propKey === AUTOFOCUS)
|
||
;
|
||
else if (registrationNameDependencies.hasOwnProperty(propKey)) {
|
||
if (nextProp != null) {
|
||
if (typeof nextProp !== "function") {
|
||
warnForInvalidEventListener(propKey, nextProp);
|
||
}
|
||
if (propKey === "onScroll") {
|
||
listenToNonDelegatedEvent("scroll", domElement);
|
||
}
|
||
}
|
||
} else if (nextProp != null) {
|
||
setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
|
||
}
|
||
}
|
||
}
|
||
function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
|
||
for (var i = 0; i < updatePayload.length; i += 2) {
|
||
var propKey = updatePayload[i];
|
||
var propValue = updatePayload[i + 1];
|
||
if (propKey === STYLE) {
|
||
setValueForStyles(domElement, propValue);
|
||
} else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
|
||
setInnerHTML(domElement, propValue);
|
||
} else if (propKey === CHILDREN) {
|
||
setTextContent(domElement, propValue);
|
||
} else {
|
||
setValueForProperty(domElement, propKey, propValue, isCustomComponentTag);
|
||
}
|
||
}
|
||
}
|
||
function createElement2(type, props, rootContainerElement, parentNamespace) {
|
||
var isCustomComponentTag;
|
||
var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
|
||
var domElement;
|
||
var namespaceURI = parentNamespace;
|
||
if (namespaceURI === HTML_NAMESPACE) {
|
||
namespaceURI = getIntrinsicNamespace(type);
|
||
}
|
||
if (namespaceURI === HTML_NAMESPACE) {
|
||
{
|
||
isCustomComponentTag = isCustomComponent(type, props);
|
||
if (!isCustomComponentTag && type !== type.toLowerCase()) {
|
||
error("<%s /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.", type);
|
||
}
|
||
}
|
||
if (type === "script") {
|
||
var div = ownerDocument.createElement("div");
|
||
div.innerHTML = "<script><\/script>";
|
||
var firstChild = div.firstChild;
|
||
domElement = div.removeChild(firstChild);
|
||
} else if (typeof props.is === "string") {
|
||
domElement = ownerDocument.createElement(type, {
|
||
is: props.is
|
||
});
|
||
} else {
|
||
domElement = ownerDocument.createElement(type);
|
||
if (type === "select") {
|
||
var node = domElement;
|
||
if (props.multiple) {
|
||
node.multiple = true;
|
||
} else if (props.size) {
|
||
node.size = props.size;
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
domElement = ownerDocument.createElementNS(namespaceURI, type);
|
||
}
|
||
{
|
||
if (namespaceURI === HTML_NAMESPACE) {
|
||
if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === "[object HTMLUnknownElement]" && !hasOwnProperty2.call(warnedUnknownTags, type)) {
|
||
warnedUnknownTags[type] = true;
|
||
error("The tag <%s> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.", type);
|
||
}
|
||
}
|
||
}
|
||
return domElement;
|
||
}
|
||
function createTextNode(text, rootContainerElement) {
|
||
return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text);
|
||
}
|
||
function setInitialProperties(domElement, tag, rawProps, rootContainerElement) {
|
||
var isCustomComponentTag = isCustomComponent(tag, rawProps);
|
||
{
|
||
validatePropertiesInDevelopment(tag, rawProps);
|
||
}
|
||
var props;
|
||
switch (tag) {
|
||
case "dialog":
|
||
listenToNonDelegatedEvent("cancel", domElement);
|
||
listenToNonDelegatedEvent("close", domElement);
|
||
props = rawProps;
|
||
break;
|
||
case "iframe":
|
||
case "object":
|
||
case "embed":
|
||
listenToNonDelegatedEvent("load", domElement);
|
||
props = rawProps;
|
||
break;
|
||
case "video":
|
||
case "audio":
|
||
for (var i = 0; i < mediaEventTypes.length; i++) {
|
||
listenToNonDelegatedEvent(mediaEventTypes[i], domElement);
|
||
}
|
||
props = rawProps;
|
||
break;
|
||
case "source":
|
||
listenToNonDelegatedEvent("error", domElement);
|
||
props = rawProps;
|
||
break;
|
||
case "img":
|
||
case "image":
|
||
case "link":
|
||
listenToNonDelegatedEvent("error", domElement);
|
||
listenToNonDelegatedEvent("load", domElement);
|
||
props = rawProps;
|
||
break;
|
||
case "details":
|
||
listenToNonDelegatedEvent("toggle", domElement);
|
||
props = rawProps;
|
||
break;
|
||
case "input":
|
||
initWrapperState(domElement, rawProps);
|
||
props = getHostProps(domElement, rawProps);
|
||
listenToNonDelegatedEvent("invalid", domElement);
|
||
break;
|
||
case "option":
|
||
validateProps(domElement, rawProps);
|
||
props = rawProps;
|
||
break;
|
||
case "select":
|
||
initWrapperState$1(domElement, rawProps);
|
||
props = getHostProps$1(domElement, rawProps);
|
||
listenToNonDelegatedEvent("invalid", domElement);
|
||
break;
|
||
case "textarea":
|
||
initWrapperState$2(domElement, rawProps);
|
||
props = getHostProps$2(domElement, rawProps);
|
||
listenToNonDelegatedEvent("invalid", domElement);
|
||
break;
|
||
default:
|
||
props = rawProps;
|
||
}
|
||
assertValidProps(tag, props);
|
||
setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag);
|
||
switch (tag) {
|
||
case "input":
|
||
track(domElement);
|
||
postMountWrapper(domElement, rawProps, false);
|
||
break;
|
||
case "textarea":
|
||
track(domElement);
|
||
postMountWrapper$3(domElement);
|
||
break;
|
||
case "option":
|
||
postMountWrapper$1(domElement, rawProps);
|
||
break;
|
||
case "select":
|
||
postMountWrapper$2(domElement, rawProps);
|
||
break;
|
||
default:
|
||
if (typeof props.onClick === "function") {
|
||
trapClickOnNonInteractiveElement(domElement);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) {
|
||
{
|
||
validatePropertiesInDevelopment(tag, nextRawProps);
|
||
}
|
||
var updatePayload = null;
|
||
var lastProps;
|
||
var nextProps;
|
||
switch (tag) {
|
||
case "input":
|
||
lastProps = getHostProps(domElement, lastRawProps);
|
||
nextProps = getHostProps(domElement, nextRawProps);
|
||
updatePayload = [];
|
||
break;
|
||
case "select":
|
||
lastProps = getHostProps$1(domElement, lastRawProps);
|
||
nextProps = getHostProps$1(domElement, nextRawProps);
|
||
updatePayload = [];
|
||
break;
|
||
case "textarea":
|
||
lastProps = getHostProps$2(domElement, lastRawProps);
|
||
nextProps = getHostProps$2(domElement, nextRawProps);
|
||
updatePayload = [];
|
||
break;
|
||
default:
|
||
lastProps = lastRawProps;
|
||
nextProps = nextRawProps;
|
||
if (typeof lastProps.onClick !== "function" && typeof nextProps.onClick === "function") {
|
||
trapClickOnNonInteractiveElement(domElement);
|
||
}
|
||
break;
|
||
}
|
||
assertValidProps(tag, nextProps);
|
||
var propKey;
|
||
var styleName;
|
||
var styleUpdates = null;
|
||
for (propKey in lastProps) {
|
||
if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) {
|
||
continue;
|
||
}
|
||
if (propKey === STYLE) {
|
||
var lastStyle = lastProps[propKey];
|
||
for (styleName in lastStyle) {
|
||
if (lastStyle.hasOwnProperty(styleName)) {
|
||
if (!styleUpdates) {
|
||
styleUpdates = {};
|
||
}
|
||
styleUpdates[styleName] = "";
|
||
}
|
||
}
|
||
} else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN)
|
||
;
|
||
else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING)
|
||
;
|
||
else if (propKey === AUTOFOCUS)
|
||
;
|
||
else if (registrationNameDependencies.hasOwnProperty(propKey)) {
|
||
if (!updatePayload) {
|
||
updatePayload = [];
|
||
}
|
||
} else {
|
||
(updatePayload = updatePayload || []).push(propKey, null);
|
||
}
|
||
}
|
||
for (propKey in nextProps) {
|
||
var nextProp = nextProps[propKey];
|
||
var lastProp = lastProps != null ? lastProps[propKey] : void 0;
|
||
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) {
|
||
continue;
|
||
}
|
||
if (propKey === STYLE) {
|
||
{
|
||
if (nextProp) {
|
||
Object.freeze(nextProp);
|
||
}
|
||
}
|
||
if (lastProp) {
|
||
for (styleName in lastProp) {
|
||
if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) {
|
||
if (!styleUpdates) {
|
||
styleUpdates = {};
|
||
}
|
||
styleUpdates[styleName] = "";
|
||
}
|
||
}
|
||
for (styleName in nextProp) {
|
||
if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) {
|
||
if (!styleUpdates) {
|
||
styleUpdates = {};
|
||
}
|
||
styleUpdates[styleName] = nextProp[styleName];
|
||
}
|
||
}
|
||
} else {
|
||
if (!styleUpdates) {
|
||
if (!updatePayload) {
|
||
updatePayload = [];
|
||
}
|
||
updatePayload.push(propKey, styleUpdates);
|
||
}
|
||
styleUpdates = nextProp;
|
||
}
|
||
} else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
|
||
var nextHtml = nextProp ? nextProp[HTML$1] : void 0;
|
||
var lastHtml = lastProp ? lastProp[HTML$1] : void 0;
|
||
if (nextHtml != null) {
|
||
if (lastHtml !== nextHtml) {
|
||
(updatePayload = updatePayload || []).push(propKey, nextHtml);
|
||
}
|
||
}
|
||
} else if (propKey === CHILDREN) {
|
||
if (typeof nextProp === "string" || typeof nextProp === "number") {
|
||
(updatePayload = updatePayload || []).push(propKey, "" + nextProp);
|
||
}
|
||
} else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING)
|
||
;
|
||
else if (registrationNameDependencies.hasOwnProperty(propKey)) {
|
||
if (nextProp != null) {
|
||
if (typeof nextProp !== "function") {
|
||
warnForInvalidEventListener(propKey, nextProp);
|
||
}
|
||
if (propKey === "onScroll") {
|
||
listenToNonDelegatedEvent("scroll", domElement);
|
||
}
|
||
}
|
||
if (!updatePayload && lastProp !== nextProp) {
|
||
updatePayload = [];
|
||
}
|
||
} else {
|
||
(updatePayload = updatePayload || []).push(propKey, nextProp);
|
||
}
|
||
}
|
||
if (styleUpdates) {
|
||
{
|
||
validateShorthandPropertyCollisionInDev(styleUpdates, nextProps[STYLE]);
|
||
}
|
||
(updatePayload = updatePayload || []).push(STYLE, styleUpdates);
|
||
}
|
||
return updatePayload;
|
||
}
|
||
function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) {
|
||
if (tag === "input" && nextRawProps.type === "radio" && nextRawProps.name != null) {
|
||
updateChecked(domElement, nextRawProps);
|
||
}
|
||
var wasCustomComponentTag = isCustomComponent(tag, lastRawProps);
|
||
var isCustomComponentTag = isCustomComponent(tag, nextRawProps);
|
||
updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag);
|
||
switch (tag) {
|
||
case "input":
|
||
updateWrapper(domElement, nextRawProps);
|
||
break;
|
||
case "textarea":
|
||
updateWrapper$1(domElement, nextRawProps);
|
||
break;
|
||
case "select":
|
||
postUpdateWrapper(domElement, nextRawProps);
|
||
break;
|
||
}
|
||
}
|
||
function getPossibleStandardName(propName) {
|
||
{
|
||
var lowerCasedName = propName.toLowerCase();
|
||
if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) {
|
||
return null;
|
||
}
|
||
return possibleStandardNames[lowerCasedName] || null;
|
||
}
|
||
}
|
||
function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement, isConcurrentMode, shouldWarnDev) {
|
||
var isCustomComponentTag;
|
||
var extraAttributeNames;
|
||
{
|
||
isCustomComponentTag = isCustomComponent(tag, rawProps);
|
||
validatePropertiesInDevelopment(tag, rawProps);
|
||
}
|
||
switch (tag) {
|
||
case "dialog":
|
||
listenToNonDelegatedEvent("cancel", domElement);
|
||
listenToNonDelegatedEvent("close", domElement);
|
||
break;
|
||
case "iframe":
|
||
case "object":
|
||
case "embed":
|
||
listenToNonDelegatedEvent("load", domElement);
|
||
break;
|
||
case "video":
|
||
case "audio":
|
||
for (var i = 0; i < mediaEventTypes.length; i++) {
|
||
listenToNonDelegatedEvent(mediaEventTypes[i], domElement);
|
||
}
|
||
break;
|
||
case "source":
|
||
listenToNonDelegatedEvent("error", domElement);
|
||
break;
|
||
case "img":
|
||
case "image":
|
||
case "link":
|
||
listenToNonDelegatedEvent("error", domElement);
|
||
listenToNonDelegatedEvent("load", domElement);
|
||
break;
|
||
case "details":
|
||
listenToNonDelegatedEvent("toggle", domElement);
|
||
break;
|
||
case "input":
|
||
initWrapperState(domElement, rawProps);
|
||
listenToNonDelegatedEvent("invalid", domElement);
|
||
break;
|
||
case "option":
|
||
validateProps(domElement, rawProps);
|
||
break;
|
||
case "select":
|
||
initWrapperState$1(domElement, rawProps);
|
||
listenToNonDelegatedEvent("invalid", domElement);
|
||
break;
|
||
case "textarea":
|
||
initWrapperState$2(domElement, rawProps);
|
||
listenToNonDelegatedEvent("invalid", domElement);
|
||
break;
|
||
}
|
||
assertValidProps(tag, rawProps);
|
||
{
|
||
extraAttributeNames = /* @__PURE__ */ new Set();
|
||
var attributes = domElement.attributes;
|
||
for (var _i = 0; _i < attributes.length; _i++) {
|
||
var name = attributes[_i].name.toLowerCase();
|
||
switch (name) {
|
||
case "value":
|
||
break;
|
||
case "checked":
|
||
break;
|
||
case "selected":
|
||
break;
|
||
default:
|
||
extraAttributeNames.add(attributes[_i].name);
|
||
}
|
||
}
|
||
}
|
||
var updatePayload = null;
|
||
for (var propKey in rawProps) {
|
||
if (!rawProps.hasOwnProperty(propKey)) {
|
||
continue;
|
||
}
|
||
var nextProp = rawProps[propKey];
|
||
if (propKey === CHILDREN) {
|
||
if (typeof nextProp === "string") {
|
||
if (domElement.textContent !== nextProp) {
|
||
if (rawProps[SUPPRESS_HYDRATION_WARNING] !== true) {
|
||
checkForUnmatchedText(domElement.textContent, nextProp, isConcurrentMode, shouldWarnDev);
|
||
}
|
||
updatePayload = [CHILDREN, nextProp];
|
||
}
|
||
} else if (typeof nextProp === "number") {
|
||
if (domElement.textContent !== "" + nextProp) {
|
||
if (rawProps[SUPPRESS_HYDRATION_WARNING] !== true) {
|
||
checkForUnmatchedText(domElement.textContent, nextProp, isConcurrentMode, shouldWarnDev);
|
||
}
|
||
updatePayload = [CHILDREN, "" + nextProp];
|
||
}
|
||
}
|
||
} else if (registrationNameDependencies.hasOwnProperty(propKey)) {
|
||
if (nextProp != null) {
|
||
if (typeof nextProp !== "function") {
|
||
warnForInvalidEventListener(propKey, nextProp);
|
||
}
|
||
if (propKey === "onScroll") {
|
||
listenToNonDelegatedEvent("scroll", domElement);
|
||
}
|
||
}
|
||
} else if (shouldWarnDev && true && typeof isCustomComponentTag === "boolean") {
|
||
var serverValue = void 0;
|
||
var propertyInfo = isCustomComponentTag && enableCustomElementPropertySupport ? null : getPropertyInfo(propKey);
|
||
if (rawProps[SUPPRESS_HYDRATION_WARNING] === true)
|
||
;
|
||
else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING || propKey === "value" || propKey === "checked" || propKey === "selected")
|
||
;
|
||
else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
|
||
var serverHTML = domElement.innerHTML;
|
||
var nextHtml = nextProp ? nextProp[HTML$1] : void 0;
|
||
if (nextHtml != null) {
|
||
var expectedHTML = normalizeHTML(domElement, nextHtml);
|
||
if (expectedHTML !== serverHTML) {
|
||
warnForPropDifference(propKey, serverHTML, expectedHTML);
|
||
}
|
||
}
|
||
} else if (propKey === STYLE) {
|
||
extraAttributeNames.delete(propKey);
|
||
if (canDiffStyleForHydrationWarning) {
|
||
var expectedStyle = createDangerousStringForStyles(nextProp);
|
||
serverValue = domElement.getAttribute("style");
|
||
if (expectedStyle !== serverValue) {
|
||
warnForPropDifference(propKey, serverValue, expectedStyle);
|
||
}
|
||
}
|
||
} else if (isCustomComponentTag && !enableCustomElementPropertySupport) {
|
||
extraAttributeNames.delete(propKey.toLowerCase());
|
||
serverValue = getValueForAttribute(domElement, propKey, nextProp);
|
||
if (nextProp !== serverValue) {
|
||
warnForPropDifference(propKey, serverValue, nextProp);
|
||
}
|
||
} else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) {
|
||
var isMismatchDueToBadCasing = false;
|
||
if (propertyInfo !== null) {
|
||
extraAttributeNames.delete(propertyInfo.attributeName);
|
||
serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo);
|
||
} else {
|
||
var ownNamespace = parentNamespace;
|
||
if (ownNamespace === HTML_NAMESPACE) {
|
||
ownNamespace = getIntrinsicNamespace(tag);
|
||
}
|
||
if (ownNamespace === HTML_NAMESPACE) {
|
||
extraAttributeNames.delete(propKey.toLowerCase());
|
||
} else {
|
||
var standardName = getPossibleStandardName(propKey);
|
||
if (standardName !== null && standardName !== propKey) {
|
||
isMismatchDueToBadCasing = true;
|
||
extraAttributeNames.delete(standardName);
|
||
}
|
||
extraAttributeNames.delete(propKey);
|
||
}
|
||
serverValue = getValueForAttribute(domElement, propKey, nextProp);
|
||
}
|
||
var dontWarnCustomElement = enableCustomElementPropertySupport;
|
||
if (!dontWarnCustomElement && nextProp !== serverValue && !isMismatchDueToBadCasing) {
|
||
warnForPropDifference(propKey, serverValue, nextProp);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
{
|
||
if (shouldWarnDev) {
|
||
if (extraAttributeNames.size > 0 && rawProps[SUPPRESS_HYDRATION_WARNING] !== true) {
|
||
warnForExtraAttributes(extraAttributeNames);
|
||
}
|
||
}
|
||
}
|
||
switch (tag) {
|
||
case "input":
|
||
track(domElement);
|
||
postMountWrapper(domElement, rawProps, true);
|
||
break;
|
||
case "textarea":
|
||
track(domElement);
|
||
postMountWrapper$3(domElement);
|
||
break;
|
||
case "select":
|
||
case "option":
|
||
break;
|
||
default:
|
||
if (typeof rawProps.onClick === "function") {
|
||
trapClickOnNonInteractiveElement(domElement);
|
||
}
|
||
break;
|
||
}
|
||
return updatePayload;
|
||
}
|
||
function diffHydratedText(textNode, text, isConcurrentMode) {
|
||
var isDifferent = textNode.nodeValue !== text;
|
||
return isDifferent;
|
||
}
|
||
function warnForDeletedHydratableElement(parentNode, child) {
|
||
{
|
||
if (didWarnInvalidHydration) {
|
||
return;
|
||
}
|
||
didWarnInvalidHydration = true;
|
||
error("Did not expect server HTML to contain a <%s> in <%s>.", child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase());
|
||
}
|
||
}
|
||
function warnForDeletedHydratableText(parentNode, child) {
|
||
{
|
||
if (didWarnInvalidHydration) {
|
||
return;
|
||
}
|
||
didWarnInvalidHydration = true;
|
||
error('Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase());
|
||
}
|
||
}
|
||
function warnForInsertedHydratedElement(parentNode, tag, props) {
|
||
{
|
||
if (didWarnInvalidHydration) {
|
||
return;
|
||
}
|
||
didWarnInvalidHydration = true;
|
||
error("Expected server HTML to contain a matching <%s> in <%s>.", tag, parentNode.nodeName.toLowerCase());
|
||
}
|
||
}
|
||
function warnForInsertedHydratedText(parentNode, text) {
|
||
{
|
||
if (text === "") {
|
||
return;
|
||
}
|
||
if (didWarnInvalidHydration) {
|
||
return;
|
||
}
|
||
didWarnInvalidHydration = true;
|
||
error('Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase());
|
||
}
|
||
}
|
||
function restoreControlledState$3(domElement, tag, props) {
|
||
switch (tag) {
|
||
case "input":
|
||
restoreControlledState(domElement, props);
|
||
return;
|
||
case "textarea":
|
||
restoreControlledState$2(domElement, props);
|
||
return;
|
||
case "select":
|
||
restoreControlledState$1(domElement, props);
|
||
return;
|
||
}
|
||
}
|
||
var validateDOMNesting = function() {
|
||
};
|
||
var updatedAncestorInfo = function() {
|
||
};
|
||
{
|
||
var specialTags = ["address", "applet", "area", "article", "aside", "base", "basefont", "bgsound", "blockquote", "body", "br", "button", "caption", "center", "col", "colgroup", "dd", "details", "dir", "div", "dl", "dt", "embed", "fieldset", "figcaption", "figure", "footer", "form", "frame", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "iframe", "img", "input", "isindex", "li", "link", "listing", "main", "marquee", "menu", "menuitem", "meta", "nav", "noembed", "noframes", "noscript", "object", "ol", "p", "param", "plaintext", "pre", "script", "section", "select", "source", "style", "summary", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "title", "tr", "track", "ul", "wbr", "xmp"];
|
||
var inScopeTags = [
|
||
"applet",
|
||
"caption",
|
||
"html",
|
||
"table",
|
||
"td",
|
||
"th",
|
||
"marquee",
|
||
"object",
|
||
"template",
|
||
"foreignObject",
|
||
"desc",
|
||
"title"
|
||
];
|
||
var buttonScopeTags = inScopeTags.concat(["button"]);
|
||
var impliedEndTags = ["dd", "dt", "li", "option", "optgroup", "p", "rp", "rt"];
|
||
var emptyAncestorInfo = {
|
||
current: null,
|
||
formTag: null,
|
||
aTagInScope: null,
|
||
buttonTagInScope: null,
|
||
nobrTagInScope: null,
|
||
pTagInButtonScope: null,
|
||
listItemTagAutoclosing: null,
|
||
dlItemTagAutoclosing: null
|
||
};
|
||
updatedAncestorInfo = function(oldInfo, tag) {
|
||
var ancestorInfo = assign({}, oldInfo || emptyAncestorInfo);
|
||
var info = {
|
||
tag
|
||
};
|
||
if (inScopeTags.indexOf(tag) !== -1) {
|
||
ancestorInfo.aTagInScope = null;
|
||
ancestorInfo.buttonTagInScope = null;
|
||
ancestorInfo.nobrTagInScope = null;
|
||
}
|
||
if (buttonScopeTags.indexOf(tag) !== -1) {
|
||
ancestorInfo.pTagInButtonScope = null;
|
||
}
|
||
if (specialTags.indexOf(tag) !== -1 && tag !== "address" && tag !== "div" && tag !== "p") {
|
||
ancestorInfo.listItemTagAutoclosing = null;
|
||
ancestorInfo.dlItemTagAutoclosing = null;
|
||
}
|
||
ancestorInfo.current = info;
|
||
if (tag === "form") {
|
||
ancestorInfo.formTag = info;
|
||
}
|
||
if (tag === "a") {
|
||
ancestorInfo.aTagInScope = info;
|
||
}
|
||
if (tag === "button") {
|
||
ancestorInfo.buttonTagInScope = info;
|
||
}
|
||
if (tag === "nobr") {
|
||
ancestorInfo.nobrTagInScope = info;
|
||
}
|
||
if (tag === "p") {
|
||
ancestorInfo.pTagInButtonScope = info;
|
||
}
|
||
if (tag === "li") {
|
||
ancestorInfo.listItemTagAutoclosing = info;
|
||
}
|
||
if (tag === "dd" || tag === "dt") {
|
||
ancestorInfo.dlItemTagAutoclosing = info;
|
||
}
|
||
return ancestorInfo;
|
||
};
|
||
var isTagValidWithParent = function(tag, parentTag) {
|
||
switch (parentTag) {
|
||
case "select":
|
||
return tag === "option" || tag === "optgroup" || tag === "#text";
|
||
case "optgroup":
|
||
return tag === "option" || tag === "#text";
|
||
case "option":
|
||
return tag === "#text";
|
||
case "tr":
|
||
return tag === "th" || tag === "td" || tag === "style" || tag === "script" || tag === "template";
|
||
case "tbody":
|
||
case "thead":
|
||
case "tfoot":
|
||
return tag === "tr" || tag === "style" || tag === "script" || tag === "template";
|
||
case "colgroup":
|
||
return tag === "col" || tag === "template";
|
||
case "table":
|
||
return tag === "caption" || tag === "colgroup" || tag === "tbody" || tag === "tfoot" || tag === "thead" || tag === "style" || tag === "script" || tag === "template";
|
||
case "head":
|
||
return tag === "base" || tag === "basefont" || tag === "bgsound" || tag === "link" || tag === "meta" || tag === "title" || tag === "noscript" || tag === "noframes" || tag === "style" || tag === "script" || tag === "template";
|
||
case "html":
|
||
return tag === "head" || tag === "body" || tag === "frameset";
|
||
case "frameset":
|
||
return tag === "frame";
|
||
case "#document":
|
||
return tag === "html";
|
||
}
|
||
switch (tag) {
|
||
case "h1":
|
||
case "h2":
|
||
case "h3":
|
||
case "h4":
|
||
case "h5":
|
||
case "h6":
|
||
return parentTag !== "h1" && parentTag !== "h2" && parentTag !== "h3" && parentTag !== "h4" && parentTag !== "h5" && parentTag !== "h6";
|
||
case "rp":
|
||
case "rt":
|
||
return impliedEndTags.indexOf(parentTag) === -1;
|
||
case "body":
|
||
case "caption":
|
||
case "col":
|
||
case "colgroup":
|
||
case "frameset":
|
||
case "frame":
|
||
case "head":
|
||
case "html":
|
||
case "tbody":
|
||
case "td":
|
||
case "tfoot":
|
||
case "th":
|
||
case "thead":
|
||
case "tr":
|
||
return parentTag == null;
|
||
}
|
||
return true;
|
||
};
|
||
var findInvalidAncestorForTag = function(tag, ancestorInfo) {
|
||
switch (tag) {
|
||
case "address":
|
||
case "article":
|
||
case "aside":
|
||
case "blockquote":
|
||
case "center":
|
||
case "details":
|
||
case "dialog":
|
||
case "dir":
|
||
case "div":
|
||
case "dl":
|
||
case "fieldset":
|
||
case "figcaption":
|
||
case "figure":
|
||
case "footer":
|
||
case "header":
|
||
case "hgroup":
|
||
case "main":
|
||
case "menu":
|
||
case "nav":
|
||
case "ol":
|
||
case "p":
|
||
case "section":
|
||
case "summary":
|
||
case "ul":
|
||
case "pre":
|
||
case "listing":
|
||
case "table":
|
||
case "hr":
|
||
case "xmp":
|
||
case "h1":
|
||
case "h2":
|
||
case "h3":
|
||
case "h4":
|
||
case "h5":
|
||
case "h6":
|
||
return ancestorInfo.pTagInButtonScope;
|
||
case "form":
|
||
return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope;
|
||
case "li":
|
||
return ancestorInfo.listItemTagAutoclosing;
|
||
case "dd":
|
||
case "dt":
|
||
return ancestorInfo.dlItemTagAutoclosing;
|
||
case "button":
|
||
return ancestorInfo.buttonTagInScope;
|
||
case "a":
|
||
return ancestorInfo.aTagInScope;
|
||
case "nobr":
|
||
return ancestorInfo.nobrTagInScope;
|
||
}
|
||
return null;
|
||
};
|
||
var didWarn$1 = {};
|
||
validateDOMNesting = function(childTag, childText, ancestorInfo) {
|
||
ancestorInfo = ancestorInfo || emptyAncestorInfo;
|
||
var parentInfo = ancestorInfo.current;
|
||
var parentTag = parentInfo && parentInfo.tag;
|
||
if (childText != null) {
|
||
if (childTag != null) {
|
||
error("validateDOMNesting: when childText is passed, childTag should be null");
|
||
}
|
||
childTag = "#text";
|
||
}
|
||
var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
|
||
var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo);
|
||
var invalidParentOrAncestor = invalidParent || invalidAncestor;
|
||
if (!invalidParentOrAncestor) {
|
||
return;
|
||
}
|
||
var ancestorTag = invalidParentOrAncestor.tag;
|
||
var warnKey = !!invalidParent + "|" + childTag + "|" + ancestorTag;
|
||
if (didWarn$1[warnKey]) {
|
||
return;
|
||
}
|
||
didWarn$1[warnKey] = true;
|
||
var tagDisplayName = childTag;
|
||
var whitespaceInfo = "";
|
||
if (childTag === "#text") {
|
||
if (/\S/.test(childText)) {
|
||
tagDisplayName = "Text nodes";
|
||
} else {
|
||
tagDisplayName = "Whitespace text nodes";
|
||
whitespaceInfo = " Make sure you don't have any extra whitespace between tags on each line of your source code.";
|
||
}
|
||
} else {
|
||
tagDisplayName = "<" + childTag + ">";
|
||
}
|
||
if (invalidParent) {
|
||
var info = "";
|
||
if (ancestorTag === "table" && childTag === "tr") {
|
||
info += " Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by the browser.";
|
||
}
|
||
error("validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s", tagDisplayName, ancestorTag, whitespaceInfo, info);
|
||
} else {
|
||
error("validateDOMNesting(...): %s cannot appear as a descendant of <%s>.", tagDisplayName, ancestorTag);
|
||
}
|
||
};
|
||
}
|
||
var SUPPRESS_HYDRATION_WARNING$1 = "suppressHydrationWarning";
|
||
var SUSPENSE_START_DATA = "$";
|
||
var SUSPENSE_END_DATA = "/$";
|
||
var SUSPENSE_PENDING_START_DATA = "$?";
|
||
var SUSPENSE_FALLBACK_START_DATA = "$!";
|
||
var STYLE$1 = "style";
|
||
var eventsEnabled = null;
|
||
var selectionInformation = null;
|
||
function getRootHostContext(rootContainerInstance) {
|
||
var type;
|
||
var namespace;
|
||
var nodeType = rootContainerInstance.nodeType;
|
||
switch (nodeType) {
|
||
case DOCUMENT_NODE:
|
||
case DOCUMENT_FRAGMENT_NODE: {
|
||
type = nodeType === DOCUMENT_NODE ? "#document" : "#fragment";
|
||
var root2 = rootContainerInstance.documentElement;
|
||
namespace = root2 ? root2.namespaceURI : getChildNamespace(null, "");
|
||
break;
|
||
}
|
||
default: {
|
||
var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance;
|
||
var ownNamespace = container.namespaceURI || null;
|
||
type = container.tagName;
|
||
namespace = getChildNamespace(ownNamespace, type);
|
||
break;
|
||
}
|
||
}
|
||
{
|
||
var validatedTag = type.toLowerCase();
|
||
var ancestorInfo = updatedAncestorInfo(null, validatedTag);
|
||
return {
|
||
namespace,
|
||
ancestorInfo
|
||
};
|
||
}
|
||
}
|
||
function getChildHostContext(parentHostContext, type, rootContainerInstance) {
|
||
{
|
||
var parentHostContextDev = parentHostContext;
|
||
var namespace = getChildNamespace(parentHostContextDev.namespace, type);
|
||
var ancestorInfo = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type);
|
||
return {
|
||
namespace,
|
||
ancestorInfo
|
||
};
|
||
}
|
||
}
|
||
function getPublicInstance(instance) {
|
||
return instance;
|
||
}
|
||
function prepareForCommit(containerInfo) {
|
||
eventsEnabled = isEnabled();
|
||
selectionInformation = getSelectionInformation();
|
||
var activeInstance = null;
|
||
setEnabled(false);
|
||
return activeInstance;
|
||
}
|
||
function resetAfterCommit(containerInfo) {
|
||
restoreSelection(selectionInformation);
|
||
setEnabled(eventsEnabled);
|
||
eventsEnabled = null;
|
||
selectionInformation = null;
|
||
}
|
||
function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
|
||
var parentNamespace;
|
||
{
|
||
var hostContextDev = hostContext;
|
||
validateDOMNesting(type, null, hostContextDev.ancestorInfo);
|
||
if (typeof props.children === "string" || typeof props.children === "number") {
|
||
var string = "" + props.children;
|
||
var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
|
||
validateDOMNesting(null, string, ownAncestorInfo);
|
||
}
|
||
parentNamespace = hostContextDev.namespace;
|
||
}
|
||
var domElement = createElement2(type, props, rootContainerInstance, parentNamespace);
|
||
precacheFiberNode(internalInstanceHandle, domElement);
|
||
updateFiberProps(domElement, props);
|
||
return domElement;
|
||
}
|
||
function appendInitialChild(parentInstance, child) {
|
||
parentInstance.appendChild(child);
|
||
}
|
||
function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) {
|
||
setInitialProperties(domElement, type, props, rootContainerInstance);
|
||
switch (type) {
|
||
case "button":
|
||
case "input":
|
||
case "select":
|
||
case "textarea":
|
||
return !!props.autoFocus;
|
||
case "img":
|
||
return true;
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) {
|
||
{
|
||
var hostContextDev = hostContext;
|
||
if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === "string" || typeof newProps.children === "number")) {
|
||
var string = "" + newProps.children;
|
||
var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
|
||
validateDOMNesting(null, string, ownAncestorInfo);
|
||
}
|
||
}
|
||
return diffProperties(domElement, type, oldProps, newProps);
|
||
}
|
||
function shouldSetTextContent(type, props) {
|
||
return type === "textarea" || type === "noscript" || typeof props.children === "string" || typeof props.children === "number" || typeof props.dangerouslySetInnerHTML === "object" && props.dangerouslySetInnerHTML !== null && props.dangerouslySetInnerHTML.__html != null;
|
||
}
|
||
function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) {
|
||
{
|
||
var hostContextDev = hostContext;
|
||
validateDOMNesting(null, text, hostContextDev.ancestorInfo);
|
||
}
|
||
var textNode = createTextNode(text, rootContainerInstance);
|
||
precacheFiberNode(internalInstanceHandle, textNode);
|
||
return textNode;
|
||
}
|
||
function getCurrentEventPriority() {
|
||
var currentEvent = window.event;
|
||
if (currentEvent === void 0) {
|
||
return DefaultEventPriority;
|
||
}
|
||
return getEventPriority(currentEvent.type);
|
||
}
|
||
var scheduleTimeout = typeof setTimeout === "function" ? setTimeout : void 0;
|
||
var cancelTimeout = typeof clearTimeout === "function" ? clearTimeout : void 0;
|
||
var noTimeout = -1;
|
||
var localPromise = typeof Promise === "function" ? Promise : void 0;
|
||
var scheduleMicrotask = typeof queueMicrotask === "function" ? queueMicrotask : typeof localPromise !== "undefined" ? function(callback) {
|
||
return localPromise.resolve(null).then(callback).catch(handleErrorInNextTick);
|
||
} : scheduleTimeout;
|
||
function handleErrorInNextTick(error2) {
|
||
setTimeout(function() {
|
||
throw error2;
|
||
});
|
||
}
|
||
function commitMount(domElement, type, newProps, internalInstanceHandle) {
|
||
switch (type) {
|
||
case "button":
|
||
case "input":
|
||
case "select":
|
||
case "textarea":
|
||
if (newProps.autoFocus) {
|
||
domElement.focus();
|
||
}
|
||
return;
|
||
case "img": {
|
||
if (newProps.src) {
|
||
domElement.src = newProps.src;
|
||
}
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) {
|
||
updateProperties(domElement, updatePayload, type, oldProps, newProps);
|
||
updateFiberProps(domElement, newProps);
|
||
}
|
||
function resetTextContent(domElement) {
|
||
setTextContent(domElement, "");
|
||
}
|
||
function commitTextUpdate(textInstance, oldText, newText) {
|
||
textInstance.nodeValue = newText;
|
||
}
|
||
function appendChild(parentInstance, child) {
|
||
parentInstance.appendChild(child);
|
||
}
|
||
function appendChildToContainer(container, child) {
|
||
var parentNode;
|
||
if (container.nodeType === COMMENT_NODE) {
|
||
parentNode = container.parentNode;
|
||
parentNode.insertBefore(child, container);
|
||
} else {
|
||
parentNode = container;
|
||
parentNode.appendChild(child);
|
||
}
|
||
var reactRootContainer = container._reactRootContainer;
|
||
if ((reactRootContainer === null || reactRootContainer === void 0) && parentNode.onclick === null) {
|
||
trapClickOnNonInteractiveElement(parentNode);
|
||
}
|
||
}
|
||
function insertBefore(parentInstance, child, beforeChild) {
|
||
parentInstance.insertBefore(child, beforeChild);
|
||
}
|
||
function insertInContainerBefore(container, child, beforeChild) {
|
||
if (container.nodeType === COMMENT_NODE) {
|
||
container.parentNode.insertBefore(child, beforeChild);
|
||
} else {
|
||
container.insertBefore(child, beforeChild);
|
||
}
|
||
}
|
||
function removeChild(parentInstance, child) {
|
||
parentInstance.removeChild(child);
|
||
}
|
||
function removeChildFromContainer(container, child) {
|
||
if (container.nodeType === COMMENT_NODE) {
|
||
container.parentNode.removeChild(child);
|
||
} else {
|
||
container.removeChild(child);
|
||
}
|
||
}
|
||
function clearSuspenseBoundary(parentInstance, suspenseInstance) {
|
||
var node = suspenseInstance;
|
||
var depth = 0;
|
||
do {
|
||
var nextNode = node.nextSibling;
|
||
parentInstance.removeChild(node);
|
||
if (nextNode && nextNode.nodeType === COMMENT_NODE) {
|
||
var data = nextNode.data;
|
||
if (data === SUSPENSE_END_DATA) {
|
||
if (depth === 0) {
|
||
parentInstance.removeChild(nextNode);
|
||
retryIfBlockedOn(suspenseInstance);
|
||
return;
|
||
} else {
|
||
depth--;
|
||
}
|
||
} else if (data === SUSPENSE_START_DATA || data === SUSPENSE_PENDING_START_DATA || data === SUSPENSE_FALLBACK_START_DATA) {
|
||
depth++;
|
||
}
|
||
}
|
||
node = nextNode;
|
||
} while (node);
|
||
retryIfBlockedOn(suspenseInstance);
|
||
}
|
||
function clearSuspenseBoundaryFromContainer(container, suspenseInstance) {
|
||
if (container.nodeType === COMMENT_NODE) {
|
||
clearSuspenseBoundary(container.parentNode, suspenseInstance);
|
||
} else if (container.nodeType === ELEMENT_NODE) {
|
||
clearSuspenseBoundary(container, suspenseInstance);
|
||
}
|
||
retryIfBlockedOn(container);
|
||
}
|
||
function hideInstance(instance) {
|
||
instance = instance;
|
||
var style2 = instance.style;
|
||
if (typeof style2.setProperty === "function") {
|
||
style2.setProperty("display", "none", "important");
|
||
} else {
|
||
style2.display = "none";
|
||
}
|
||
}
|
||
function hideTextInstance(textInstance) {
|
||
textInstance.nodeValue = "";
|
||
}
|
||
function unhideInstance(instance, props) {
|
||
instance = instance;
|
||
var styleProp = props[STYLE$1];
|
||
var display = styleProp !== void 0 && styleProp !== null && styleProp.hasOwnProperty("display") ? styleProp.display : null;
|
||
instance.style.display = dangerousStyleValue("display", display);
|
||
}
|
||
function unhideTextInstance(textInstance, text) {
|
||
textInstance.nodeValue = text;
|
||
}
|
||
function clearContainer(container) {
|
||
if (container.nodeType === ELEMENT_NODE) {
|
||
container.textContent = "";
|
||
} else if (container.nodeType === DOCUMENT_NODE) {
|
||
if (container.documentElement) {
|
||
container.removeChild(container.documentElement);
|
||
}
|
||
}
|
||
}
|
||
function canHydrateInstance(instance, type, props) {
|
||
if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) {
|
||
return null;
|
||
}
|
||
return instance;
|
||
}
|
||
function canHydrateTextInstance(instance, text) {
|
||
if (text === "" || instance.nodeType !== TEXT_NODE) {
|
||
return null;
|
||
}
|
||
return instance;
|
||
}
|
||
function canHydrateSuspenseInstance(instance) {
|
||
if (instance.nodeType !== COMMENT_NODE) {
|
||
return null;
|
||
}
|
||
return instance;
|
||
}
|
||
function isSuspenseInstancePending(instance) {
|
||
return instance.data === SUSPENSE_PENDING_START_DATA;
|
||
}
|
||
function isSuspenseInstanceFallback(instance) {
|
||
return instance.data === SUSPENSE_FALLBACK_START_DATA;
|
||
}
|
||
function getSuspenseInstanceFallbackErrorDetails(instance) {
|
||
var dataset = instance.nextSibling && instance.nextSibling.dataset;
|
||
var digest, message, stack;
|
||
if (dataset) {
|
||
digest = dataset.dgst;
|
||
{
|
||
message = dataset.msg;
|
||
stack = dataset.stck;
|
||
}
|
||
}
|
||
{
|
||
return {
|
||
message,
|
||
digest,
|
||
stack
|
||
};
|
||
}
|
||
}
|
||
function registerSuspenseInstanceRetry(instance, callback) {
|
||
instance._reactRetry = callback;
|
||
}
|
||
function getNextHydratable(node) {
|
||
for (; node != null; node = node.nextSibling) {
|
||
var nodeType = node.nodeType;
|
||
if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) {
|
||
break;
|
||
}
|
||
if (nodeType === COMMENT_NODE) {
|
||
var nodeData = node.data;
|
||
if (nodeData === SUSPENSE_START_DATA || nodeData === SUSPENSE_FALLBACK_START_DATA || nodeData === SUSPENSE_PENDING_START_DATA) {
|
||
break;
|
||
}
|
||
if (nodeData === SUSPENSE_END_DATA) {
|
||
return null;
|
||
}
|
||
}
|
||
}
|
||
return node;
|
||
}
|
||
function getNextHydratableSibling(instance) {
|
||
return getNextHydratable(instance.nextSibling);
|
||
}
|
||
function getFirstHydratableChild(parentInstance) {
|
||
return getNextHydratable(parentInstance.firstChild);
|
||
}
|
||
function getFirstHydratableChildWithinContainer(parentContainer) {
|
||
return getNextHydratable(parentContainer.firstChild);
|
||
}
|
||
function getFirstHydratableChildWithinSuspenseInstance(parentInstance) {
|
||
return getNextHydratable(parentInstance.nextSibling);
|
||
}
|
||
function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle, shouldWarnDev) {
|
||
precacheFiberNode(internalInstanceHandle, instance);
|
||
updateFiberProps(instance, props);
|
||
var parentNamespace;
|
||
{
|
||
var hostContextDev = hostContext;
|
||
parentNamespace = hostContextDev.namespace;
|
||
}
|
||
var isConcurrentMode = (internalInstanceHandle.mode & ConcurrentMode) !== NoMode;
|
||
return diffHydratedProperties(instance, type, props, parentNamespace, rootContainerInstance, isConcurrentMode, shouldWarnDev);
|
||
}
|
||
function hydrateTextInstance(textInstance, text, internalInstanceHandle, shouldWarnDev) {
|
||
precacheFiberNode(internalInstanceHandle, textInstance);
|
||
var isConcurrentMode = (internalInstanceHandle.mode & ConcurrentMode) !== NoMode;
|
||
return diffHydratedText(textInstance, text);
|
||
}
|
||
function hydrateSuspenseInstance(suspenseInstance, internalInstanceHandle) {
|
||
precacheFiberNode(internalInstanceHandle, suspenseInstance);
|
||
}
|
||
function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) {
|
||
var node = suspenseInstance.nextSibling;
|
||
var depth = 0;
|
||
while (node) {
|
||
if (node.nodeType === COMMENT_NODE) {
|
||
var data = node.data;
|
||
if (data === SUSPENSE_END_DATA) {
|
||
if (depth === 0) {
|
||
return getNextHydratableSibling(node);
|
||
} else {
|
||
depth--;
|
||
}
|
||
} else if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) {
|
||
depth++;
|
||
}
|
||
}
|
||
node = node.nextSibling;
|
||
}
|
||
return null;
|
||
}
|
||
function getParentSuspenseInstance(targetInstance) {
|
||
var node = targetInstance.previousSibling;
|
||
var depth = 0;
|
||
while (node) {
|
||
if (node.nodeType === COMMENT_NODE) {
|
||
var data = node.data;
|
||
if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) {
|
||
if (depth === 0) {
|
||
return node;
|
||
} else {
|
||
depth--;
|
||
}
|
||
} else if (data === SUSPENSE_END_DATA) {
|
||
depth++;
|
||
}
|
||
}
|
||
node = node.previousSibling;
|
||
}
|
||
return null;
|
||
}
|
||
function commitHydratedContainer(container) {
|
||
retryIfBlockedOn(container);
|
||
}
|
||
function commitHydratedSuspenseInstance(suspenseInstance) {
|
||
retryIfBlockedOn(suspenseInstance);
|
||
}
|
||
function shouldDeleteUnhydratedTailInstances(parentType) {
|
||
return parentType !== "head" && parentType !== "body";
|
||
}
|
||
function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text, isConcurrentMode) {
|
||
var shouldWarnDev = true;
|
||
checkForUnmatchedText(textInstance.nodeValue, text, isConcurrentMode, shouldWarnDev);
|
||
}
|
||
function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text, isConcurrentMode) {
|
||
if (parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
|
||
var shouldWarnDev = true;
|
||
checkForUnmatchedText(textInstance.nodeValue, text, isConcurrentMode, shouldWarnDev);
|
||
}
|
||
}
|
||
function didNotHydrateInstanceWithinContainer(parentContainer, instance) {
|
||
{
|
||
if (instance.nodeType === ELEMENT_NODE) {
|
||
warnForDeletedHydratableElement(parentContainer, instance);
|
||
} else if (instance.nodeType === COMMENT_NODE)
|
||
;
|
||
else {
|
||
warnForDeletedHydratableText(parentContainer, instance);
|
||
}
|
||
}
|
||
}
|
||
function didNotHydrateInstanceWithinSuspenseInstance(parentInstance, instance) {
|
||
{
|
||
var parentNode = parentInstance.parentNode;
|
||
if (parentNode !== null) {
|
||
if (instance.nodeType === ELEMENT_NODE) {
|
||
warnForDeletedHydratableElement(parentNode, instance);
|
||
} else if (instance.nodeType === COMMENT_NODE)
|
||
;
|
||
else {
|
||
warnForDeletedHydratableText(parentNode, instance);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function didNotHydrateInstance(parentType, parentProps, parentInstance, instance, isConcurrentMode) {
|
||
{
|
||
if (isConcurrentMode || parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
|
||
if (instance.nodeType === ELEMENT_NODE) {
|
||
warnForDeletedHydratableElement(parentInstance, instance);
|
||
} else if (instance.nodeType === COMMENT_NODE)
|
||
;
|
||
else {
|
||
warnForDeletedHydratableText(parentInstance, instance);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function didNotFindHydratableInstanceWithinContainer(parentContainer, type, props) {
|
||
{
|
||
warnForInsertedHydratedElement(parentContainer, type);
|
||
}
|
||
}
|
||
function didNotFindHydratableTextInstanceWithinContainer(parentContainer, text) {
|
||
{
|
||
warnForInsertedHydratedText(parentContainer, text);
|
||
}
|
||
}
|
||
function didNotFindHydratableInstanceWithinSuspenseInstance(parentInstance, type, props) {
|
||
{
|
||
var parentNode = parentInstance.parentNode;
|
||
if (parentNode !== null)
|
||
warnForInsertedHydratedElement(parentNode, type);
|
||
}
|
||
}
|
||
function didNotFindHydratableTextInstanceWithinSuspenseInstance(parentInstance, text) {
|
||
{
|
||
var parentNode = parentInstance.parentNode;
|
||
if (parentNode !== null)
|
||
warnForInsertedHydratedText(parentNode, text);
|
||
}
|
||
}
|
||
function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props, isConcurrentMode) {
|
||
{
|
||
if (isConcurrentMode || parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
|
||
warnForInsertedHydratedElement(parentInstance, type);
|
||
}
|
||
}
|
||
}
|
||
function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text, isConcurrentMode) {
|
||
{
|
||
if (isConcurrentMode || parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
|
||
warnForInsertedHydratedText(parentInstance, text);
|
||
}
|
||
}
|
||
}
|
||
function errorHydratingContainer(parentContainer) {
|
||
{
|
||
error("An error occurred during hydration. The server HTML was replaced with client content in <%s>.", parentContainer.nodeName.toLowerCase());
|
||
}
|
||
}
|
||
function preparePortalMount(portalInstance) {
|
||
listenToAllSupportedEvents(portalInstance);
|
||
}
|
||
var randomKey = Math.random().toString(36).slice(2);
|
||
var internalInstanceKey = "__reactFiber$" + randomKey;
|
||
var internalPropsKey = "__reactProps$" + randomKey;
|
||
var internalContainerInstanceKey = "__reactContainer$" + randomKey;
|
||
var internalEventHandlersKey = "__reactEvents$" + randomKey;
|
||
var internalEventHandlerListenersKey = "__reactListeners$" + randomKey;
|
||
var internalEventHandlesSetKey = "__reactHandles$" + randomKey;
|
||
function detachDeletedInstance(node) {
|
||
delete node[internalInstanceKey];
|
||
delete node[internalPropsKey];
|
||
delete node[internalEventHandlersKey];
|
||
delete node[internalEventHandlerListenersKey];
|
||
delete node[internalEventHandlesSetKey];
|
||
}
|
||
function precacheFiberNode(hostInst, node) {
|
||
node[internalInstanceKey] = hostInst;
|
||
}
|
||
function markContainerAsRoot(hostRoot, node) {
|
||
node[internalContainerInstanceKey] = hostRoot;
|
||
}
|
||
function unmarkContainerAsRoot(node) {
|
||
node[internalContainerInstanceKey] = null;
|
||
}
|
||
function isContainerMarkedAsRoot(node) {
|
||
return !!node[internalContainerInstanceKey];
|
||
}
|
||
function getClosestInstanceFromNode(targetNode) {
|
||
var targetInst = targetNode[internalInstanceKey];
|
||
if (targetInst) {
|
||
return targetInst;
|
||
}
|
||
var parentNode = targetNode.parentNode;
|
||
while (parentNode) {
|
||
targetInst = parentNode[internalContainerInstanceKey] || parentNode[internalInstanceKey];
|
||
if (targetInst) {
|
||
var alternate = targetInst.alternate;
|
||
if (targetInst.child !== null || alternate !== null && alternate.child !== null) {
|
||
var suspenseInstance = getParentSuspenseInstance(targetNode);
|
||
while (suspenseInstance !== null) {
|
||
var targetSuspenseInst = suspenseInstance[internalInstanceKey];
|
||
if (targetSuspenseInst) {
|
||
return targetSuspenseInst;
|
||
}
|
||
suspenseInstance = getParentSuspenseInstance(suspenseInstance);
|
||
}
|
||
}
|
||
return targetInst;
|
||
}
|
||
targetNode = parentNode;
|
||
parentNode = targetNode.parentNode;
|
||
}
|
||
return null;
|
||
}
|
||
function getInstanceFromNode(node) {
|
||
var inst = node[internalInstanceKey] || node[internalContainerInstanceKey];
|
||
if (inst) {
|
||
if (inst.tag === HostComponent || inst.tag === HostText || inst.tag === SuspenseComponent || inst.tag === HostRoot) {
|
||
return inst;
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
function getNodeFromInstance(inst) {
|
||
if (inst.tag === HostComponent || inst.tag === HostText) {
|
||
return inst.stateNode;
|
||
}
|
||
throw new Error("getNodeFromInstance: Invalid argument.");
|
||
}
|
||
function getFiberCurrentPropsFromNode(node) {
|
||
return node[internalPropsKey] || null;
|
||
}
|
||
function updateFiberProps(node, props) {
|
||
node[internalPropsKey] = props;
|
||
}
|
||
function getEventListenerSet(node) {
|
||
var elementListenerSet = node[internalEventHandlersKey];
|
||
if (elementListenerSet === void 0) {
|
||
elementListenerSet = node[internalEventHandlersKey] = /* @__PURE__ */ new Set();
|
||
}
|
||
return elementListenerSet;
|
||
}
|
||
var loggedTypeFailures = {};
|
||
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
||
function setCurrentlyValidatingElement(element) {
|
||
{
|
||
if (element) {
|
||
var owner = element._owner;
|
||
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
||
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
||
} else {
|
||
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
||
}
|
||
}
|
||
}
|
||
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
||
{
|
||
var has2 = Function.call.bind(hasOwnProperty2);
|
||
for (var typeSpecName in typeSpecs) {
|
||
if (has2(typeSpecs, typeSpecName)) {
|
||
var error$1 = void 0;
|
||
try {
|
||
if (typeof typeSpecs[typeSpecName] !== "function") {
|
||
var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
||
err.name = "Invariant Violation";
|
||
throw err;
|
||
}
|
||
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
||
} catch (ex) {
|
||
error$1 = ex;
|
||
}
|
||
if (error$1 && !(error$1 instanceof Error)) {
|
||
setCurrentlyValidatingElement(element);
|
||
error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
|
||
setCurrentlyValidatingElement(null);
|
||
}
|
||
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
||
loggedTypeFailures[error$1.message] = true;
|
||
setCurrentlyValidatingElement(element);
|
||
error("Failed %s type: %s", location, error$1.message);
|
||
setCurrentlyValidatingElement(null);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var valueStack = [];
|
||
var fiberStack;
|
||
{
|
||
fiberStack = [];
|
||
}
|
||
var index = -1;
|
||
function createCursor(defaultValue) {
|
||
return {
|
||
current: defaultValue
|
||
};
|
||
}
|
||
function pop(cursor, fiber) {
|
||
if (index < 0) {
|
||
{
|
||
error("Unexpected pop.");
|
||
}
|
||
return;
|
||
}
|
||
{
|
||
if (fiber !== fiberStack[index]) {
|
||
error("Unexpected Fiber popped.");
|
||
}
|
||
}
|
||
cursor.current = valueStack[index];
|
||
valueStack[index] = null;
|
||
{
|
||
fiberStack[index] = null;
|
||
}
|
||
index--;
|
||
}
|
||
function push(cursor, value, fiber) {
|
||
index++;
|
||
valueStack[index] = cursor.current;
|
||
{
|
||
fiberStack[index] = fiber;
|
||
}
|
||
cursor.current = value;
|
||
}
|
||
var warnedAboutMissingGetChildContext;
|
||
{
|
||
warnedAboutMissingGetChildContext = {};
|
||
}
|
||
var emptyContextObject = {};
|
||
{
|
||
Object.freeze(emptyContextObject);
|
||
}
|
||
var contextStackCursor = createCursor(emptyContextObject);
|
||
var didPerformWorkStackCursor = createCursor(false);
|
||
var previousContext = emptyContextObject;
|
||
function getUnmaskedContext(workInProgress2, Component, didPushOwnContextIfProvider) {
|
||
{
|
||
if (didPushOwnContextIfProvider && isContextProvider(Component)) {
|
||
return previousContext;
|
||
}
|
||
return contextStackCursor.current;
|
||
}
|
||
}
|
||
function cacheContext(workInProgress2, unmaskedContext, maskedContext) {
|
||
{
|
||
var instance = workInProgress2.stateNode;
|
||
instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
|
||
instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
|
||
}
|
||
}
|
||
function getMaskedContext(workInProgress2, unmaskedContext) {
|
||
{
|
||
var type = workInProgress2.type;
|
||
var contextTypes = type.contextTypes;
|
||
if (!contextTypes) {
|
||
return emptyContextObject;
|
||
}
|
||
var instance = workInProgress2.stateNode;
|
||
if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
|
||
return instance.__reactInternalMemoizedMaskedChildContext;
|
||
}
|
||
var context = {};
|
||
for (var key in contextTypes) {
|
||
context[key] = unmaskedContext[key];
|
||
}
|
||
{
|
||
var name = getComponentNameFromFiber(workInProgress2) || "Unknown";
|
||
checkPropTypes(contextTypes, context, "context", name);
|
||
}
|
||
if (instance) {
|
||
cacheContext(workInProgress2, unmaskedContext, context);
|
||
}
|
||
return context;
|
||
}
|
||
}
|
||
function hasContextChanged() {
|
||
{
|
||
return didPerformWorkStackCursor.current;
|
||
}
|
||
}
|
||
function isContextProvider(type) {
|
||
{
|
||
var childContextTypes = type.childContextTypes;
|
||
return childContextTypes !== null && childContextTypes !== void 0;
|
||
}
|
||
}
|
||
function popContext(fiber) {
|
||
{
|
||
pop(didPerformWorkStackCursor, fiber);
|
||
pop(contextStackCursor, fiber);
|
||
}
|
||
}
|
||
function popTopLevelContextObject(fiber) {
|
||
{
|
||
pop(didPerformWorkStackCursor, fiber);
|
||
pop(contextStackCursor, fiber);
|
||
}
|
||
}
|
||
function pushTopLevelContextObject(fiber, context, didChange) {
|
||
{
|
||
if (contextStackCursor.current !== emptyContextObject) {
|
||
throw new Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
push(contextStackCursor, context, fiber);
|
||
push(didPerformWorkStackCursor, didChange, fiber);
|
||
}
|
||
}
|
||
function processChildContext(fiber, type, parentContext) {
|
||
{
|
||
var instance = fiber.stateNode;
|
||
var childContextTypes = type.childContextTypes;
|
||
if (typeof instance.getChildContext !== "function") {
|
||
{
|
||
var componentName = getComponentNameFromFiber(fiber) || "Unknown";
|
||
if (!warnedAboutMissingGetChildContext[componentName]) {
|
||
warnedAboutMissingGetChildContext[componentName] = true;
|
||
error("%s.childContextTypes is specified but there is no getChildContext() method on the instance. You can either define getChildContext() on %s or remove childContextTypes from it.", componentName, componentName);
|
||
}
|
||
}
|
||
return parentContext;
|
||
}
|
||
var childContext = instance.getChildContext();
|
||
for (var contextKey in childContext) {
|
||
if (!(contextKey in childContextTypes)) {
|
||
throw new Error((getComponentNameFromFiber(fiber) || "Unknown") + '.getChildContext(): key "' + contextKey + '" is not defined in childContextTypes.');
|
||
}
|
||
}
|
||
{
|
||
var name = getComponentNameFromFiber(fiber) || "Unknown";
|
||
checkPropTypes(childContextTypes, childContext, "child context", name);
|
||
}
|
||
return assign({}, parentContext, childContext);
|
||
}
|
||
}
|
||
function pushContextProvider(workInProgress2) {
|
||
{
|
||
var instance = workInProgress2.stateNode;
|
||
var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject;
|
||
previousContext = contextStackCursor.current;
|
||
push(contextStackCursor, memoizedMergedChildContext, workInProgress2);
|
||
push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress2);
|
||
return true;
|
||
}
|
||
}
|
||
function invalidateContextProvider(workInProgress2, type, didChange) {
|
||
{
|
||
var instance = workInProgress2.stateNode;
|
||
if (!instance) {
|
||
throw new Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
if (didChange) {
|
||
var mergedContext = processChildContext(workInProgress2, type, previousContext);
|
||
instance.__reactInternalMemoizedMergedChildContext = mergedContext;
|
||
pop(didPerformWorkStackCursor, workInProgress2);
|
||
pop(contextStackCursor, workInProgress2);
|
||
push(contextStackCursor, mergedContext, workInProgress2);
|
||
push(didPerformWorkStackCursor, didChange, workInProgress2);
|
||
} else {
|
||
pop(didPerformWorkStackCursor, workInProgress2);
|
||
push(didPerformWorkStackCursor, didChange, workInProgress2);
|
||
}
|
||
}
|
||
}
|
||
function findCurrentUnmaskedContext(fiber) {
|
||
{
|
||
if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) {
|
||
throw new Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
var node = fiber;
|
||
do {
|
||
switch (node.tag) {
|
||
case HostRoot:
|
||
return node.stateNode.context;
|
||
case ClassComponent: {
|
||
var Component = node.type;
|
||
if (isContextProvider(Component)) {
|
||
return node.stateNode.__reactInternalMemoizedMergedChildContext;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
node = node.return;
|
||
} while (node !== null);
|
||
throw new Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
var LegacyRoot = 0;
|
||
var ConcurrentRoot = 1;
|
||
var syncQueue = null;
|
||
var includesLegacySyncCallbacks = false;
|
||
var isFlushingSyncQueue = false;
|
||
function scheduleSyncCallback(callback) {
|
||
if (syncQueue === null) {
|
||
syncQueue = [callback];
|
||
} else {
|
||
syncQueue.push(callback);
|
||
}
|
||
}
|
||
function scheduleLegacySyncCallback(callback) {
|
||
includesLegacySyncCallbacks = true;
|
||
scheduleSyncCallback(callback);
|
||
}
|
||
function flushSyncCallbacksOnlyInLegacyMode() {
|
||
if (includesLegacySyncCallbacks) {
|
||
flushSyncCallbacks();
|
||
}
|
||
}
|
||
function flushSyncCallbacks() {
|
||
if (!isFlushingSyncQueue && syncQueue !== null) {
|
||
isFlushingSyncQueue = true;
|
||
var i = 0;
|
||
var previousUpdatePriority = getCurrentUpdatePriority();
|
||
try {
|
||
var isSync = true;
|
||
var queue = syncQueue;
|
||
setCurrentUpdatePriority(DiscreteEventPriority);
|
||
for (; i < queue.length; i++) {
|
||
var callback = queue[i];
|
||
do {
|
||
callback = callback(isSync);
|
||
} while (callback !== null);
|
||
}
|
||
syncQueue = null;
|
||
includesLegacySyncCallbacks = false;
|
||
} catch (error2) {
|
||
if (syncQueue !== null) {
|
||
syncQueue = syncQueue.slice(i + 1);
|
||
}
|
||
scheduleCallback(ImmediatePriority, flushSyncCallbacks);
|
||
throw error2;
|
||
} finally {
|
||
setCurrentUpdatePriority(previousUpdatePriority);
|
||
isFlushingSyncQueue = false;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
var forkStack = [];
|
||
var forkStackIndex = 0;
|
||
var treeForkProvider = null;
|
||
var treeForkCount = 0;
|
||
var idStack = [];
|
||
var idStackIndex = 0;
|
||
var treeContextProvider = null;
|
||
var treeContextId = 1;
|
||
var treeContextOverflow = "";
|
||
function isForkedChild(workInProgress2) {
|
||
warnIfNotHydrating();
|
||
return (workInProgress2.flags & Forked) !== NoFlags;
|
||
}
|
||
function getForksAtLevel(workInProgress2) {
|
||
warnIfNotHydrating();
|
||
return treeForkCount;
|
||
}
|
||
function getTreeId() {
|
||
var overflow = treeContextOverflow;
|
||
var idWithLeadingBit = treeContextId;
|
||
var id = idWithLeadingBit & ~getLeadingBit(idWithLeadingBit);
|
||
return id.toString(32) + overflow;
|
||
}
|
||
function pushTreeFork(workInProgress2, totalChildren) {
|
||
warnIfNotHydrating();
|
||
forkStack[forkStackIndex++] = treeForkCount;
|
||
forkStack[forkStackIndex++] = treeForkProvider;
|
||
treeForkProvider = workInProgress2;
|
||
treeForkCount = totalChildren;
|
||
}
|
||
function pushTreeId(workInProgress2, totalChildren, index2) {
|
||
warnIfNotHydrating();
|
||
idStack[idStackIndex++] = treeContextId;
|
||
idStack[idStackIndex++] = treeContextOverflow;
|
||
idStack[idStackIndex++] = treeContextProvider;
|
||
treeContextProvider = workInProgress2;
|
||
var baseIdWithLeadingBit = treeContextId;
|
||
var baseOverflow = treeContextOverflow;
|
||
var baseLength = getBitLength(baseIdWithLeadingBit) - 1;
|
||
var baseId = baseIdWithLeadingBit & ~(1 << baseLength);
|
||
var slot = index2 + 1;
|
||
var length = getBitLength(totalChildren) + baseLength;
|
||
if (length > 30) {
|
||
var numberOfOverflowBits = baseLength - baseLength % 5;
|
||
var newOverflowBits = (1 << numberOfOverflowBits) - 1;
|
||
var newOverflow = (baseId & newOverflowBits).toString(32);
|
||
var restOfBaseId = baseId >> numberOfOverflowBits;
|
||
var restOfBaseLength = baseLength - numberOfOverflowBits;
|
||
var restOfLength = getBitLength(totalChildren) + restOfBaseLength;
|
||
var restOfNewBits = slot << restOfBaseLength;
|
||
var id = restOfNewBits | restOfBaseId;
|
||
var overflow = newOverflow + baseOverflow;
|
||
treeContextId = 1 << restOfLength | id;
|
||
treeContextOverflow = overflow;
|
||
} else {
|
||
var newBits = slot << baseLength;
|
||
var _id = newBits | baseId;
|
||
var _overflow = baseOverflow;
|
||
treeContextId = 1 << length | _id;
|
||
treeContextOverflow = _overflow;
|
||
}
|
||
}
|
||
function pushMaterializedTreeId(workInProgress2) {
|
||
warnIfNotHydrating();
|
||
var returnFiber = workInProgress2.return;
|
||
if (returnFiber !== null) {
|
||
var numberOfForks = 1;
|
||
var slotIndex = 0;
|
||
pushTreeFork(workInProgress2, numberOfForks);
|
||
pushTreeId(workInProgress2, numberOfForks, slotIndex);
|
||
}
|
||
}
|
||
function getBitLength(number) {
|
||
return 32 - clz32(number);
|
||
}
|
||
function getLeadingBit(id) {
|
||
return 1 << getBitLength(id) - 1;
|
||
}
|
||
function popTreeContext(workInProgress2) {
|
||
while (workInProgress2 === treeForkProvider) {
|
||
treeForkProvider = forkStack[--forkStackIndex];
|
||
forkStack[forkStackIndex] = null;
|
||
treeForkCount = forkStack[--forkStackIndex];
|
||
forkStack[forkStackIndex] = null;
|
||
}
|
||
while (workInProgress2 === treeContextProvider) {
|
||
treeContextProvider = idStack[--idStackIndex];
|
||
idStack[idStackIndex] = null;
|
||
treeContextOverflow = idStack[--idStackIndex];
|
||
idStack[idStackIndex] = null;
|
||
treeContextId = idStack[--idStackIndex];
|
||
idStack[idStackIndex] = null;
|
||
}
|
||
}
|
||
function getSuspendedTreeContext() {
|
||
warnIfNotHydrating();
|
||
if (treeContextProvider !== null) {
|
||
return {
|
||
id: treeContextId,
|
||
overflow: treeContextOverflow
|
||
};
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
function restoreSuspendedTreeContext(workInProgress2, suspendedContext) {
|
||
warnIfNotHydrating();
|
||
idStack[idStackIndex++] = treeContextId;
|
||
idStack[idStackIndex++] = treeContextOverflow;
|
||
idStack[idStackIndex++] = treeContextProvider;
|
||
treeContextId = suspendedContext.id;
|
||
treeContextOverflow = suspendedContext.overflow;
|
||
treeContextProvider = workInProgress2;
|
||
}
|
||
function warnIfNotHydrating() {
|
||
{
|
||
if (!getIsHydrating()) {
|
||
error("Expected to be hydrating. This is a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
}
|
||
var hydrationParentFiber = null;
|
||
var nextHydratableInstance = null;
|
||
var isHydrating = false;
|
||
var didSuspendOrErrorDEV = false;
|
||
var hydrationErrors = null;
|
||
function warnIfHydrating() {
|
||
{
|
||
if (isHydrating) {
|
||
error("We should not be hydrating here. This is a bug in React. Please file a bug.");
|
||
}
|
||
}
|
||
}
|
||
function markDidThrowWhileHydratingDEV() {
|
||
{
|
||
didSuspendOrErrorDEV = true;
|
||
}
|
||
}
|
||
function didSuspendOrErrorWhileHydratingDEV() {
|
||
{
|
||
return didSuspendOrErrorDEV;
|
||
}
|
||
}
|
||
function enterHydrationState(fiber) {
|
||
var parentInstance = fiber.stateNode.containerInfo;
|
||
nextHydratableInstance = getFirstHydratableChildWithinContainer(parentInstance);
|
||
hydrationParentFiber = fiber;
|
||
isHydrating = true;
|
||
hydrationErrors = null;
|
||
didSuspendOrErrorDEV = false;
|
||
return true;
|
||
}
|
||
function reenterHydrationStateFromDehydratedSuspenseInstance(fiber, suspenseInstance, treeContext) {
|
||
nextHydratableInstance = getFirstHydratableChildWithinSuspenseInstance(suspenseInstance);
|
||
hydrationParentFiber = fiber;
|
||
isHydrating = true;
|
||
hydrationErrors = null;
|
||
didSuspendOrErrorDEV = false;
|
||
if (treeContext !== null) {
|
||
restoreSuspendedTreeContext(fiber, treeContext);
|
||
}
|
||
return true;
|
||
}
|
||
function warnUnhydratedInstance(returnFiber, instance) {
|
||
{
|
||
switch (returnFiber.tag) {
|
||
case HostRoot: {
|
||
didNotHydrateInstanceWithinContainer(returnFiber.stateNode.containerInfo, instance);
|
||
break;
|
||
}
|
||
case HostComponent: {
|
||
var isConcurrentMode = (returnFiber.mode & ConcurrentMode) !== NoMode;
|
||
didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance, isConcurrentMode);
|
||
break;
|
||
}
|
||
case SuspenseComponent: {
|
||
var suspenseState = returnFiber.memoizedState;
|
||
if (suspenseState.dehydrated !== null)
|
||
didNotHydrateInstanceWithinSuspenseInstance(suspenseState.dehydrated, instance);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function deleteHydratableInstance(returnFiber, instance) {
|
||
warnUnhydratedInstance(returnFiber, instance);
|
||
var childToDelete = createFiberFromHostInstanceForDeletion();
|
||
childToDelete.stateNode = instance;
|
||
childToDelete.return = returnFiber;
|
||
var deletions = returnFiber.deletions;
|
||
if (deletions === null) {
|
||
returnFiber.deletions = [childToDelete];
|
||
returnFiber.flags |= ChildDeletion;
|
||
} else {
|
||
deletions.push(childToDelete);
|
||
}
|
||
}
|
||
function warnNonhydratedInstance(returnFiber, fiber) {
|
||
{
|
||
if (didSuspendOrErrorDEV) {
|
||
return;
|
||
}
|
||
switch (returnFiber.tag) {
|
||
case HostRoot: {
|
||
var parentContainer = returnFiber.stateNode.containerInfo;
|
||
switch (fiber.tag) {
|
||
case HostComponent:
|
||
var type = fiber.type;
|
||
var props = fiber.pendingProps;
|
||
didNotFindHydratableInstanceWithinContainer(parentContainer, type);
|
||
break;
|
||
case HostText:
|
||
var text = fiber.pendingProps;
|
||
didNotFindHydratableTextInstanceWithinContainer(parentContainer, text);
|
||
break;
|
||
}
|
||
break;
|
||
}
|
||
case HostComponent: {
|
||
var parentType = returnFiber.type;
|
||
var parentProps = returnFiber.memoizedProps;
|
||
var parentInstance = returnFiber.stateNode;
|
||
switch (fiber.tag) {
|
||
case HostComponent: {
|
||
var _type = fiber.type;
|
||
var _props = fiber.pendingProps;
|
||
var isConcurrentMode = (returnFiber.mode & ConcurrentMode) !== NoMode;
|
||
didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props, isConcurrentMode);
|
||
break;
|
||
}
|
||
case HostText: {
|
||
var _text = fiber.pendingProps;
|
||
var _isConcurrentMode = (returnFiber.mode & ConcurrentMode) !== NoMode;
|
||
didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text, _isConcurrentMode);
|
||
break;
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
case SuspenseComponent: {
|
||
var suspenseState = returnFiber.memoizedState;
|
||
var _parentInstance = suspenseState.dehydrated;
|
||
if (_parentInstance !== null)
|
||
switch (fiber.tag) {
|
||
case HostComponent:
|
||
var _type2 = fiber.type;
|
||
var _props2 = fiber.pendingProps;
|
||
didNotFindHydratableInstanceWithinSuspenseInstance(_parentInstance, _type2);
|
||
break;
|
||
case HostText:
|
||
var _text2 = fiber.pendingProps;
|
||
didNotFindHydratableTextInstanceWithinSuspenseInstance(_parentInstance, _text2);
|
||
break;
|
||
}
|
||
break;
|
||
}
|
||
default:
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
function insertNonHydratedInstance(returnFiber, fiber) {
|
||
fiber.flags = fiber.flags & ~Hydrating | Placement;
|
||
warnNonhydratedInstance(returnFiber, fiber);
|
||
}
|
||
function tryHydrate(fiber, nextInstance) {
|
||
switch (fiber.tag) {
|
||
case HostComponent: {
|
||
var type = fiber.type;
|
||
var props = fiber.pendingProps;
|
||
var instance = canHydrateInstance(nextInstance, type);
|
||
if (instance !== null) {
|
||
fiber.stateNode = instance;
|
||
hydrationParentFiber = fiber;
|
||
nextHydratableInstance = getFirstHydratableChild(instance);
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
case HostText: {
|
||
var text = fiber.pendingProps;
|
||
var textInstance = canHydrateTextInstance(nextInstance, text);
|
||
if (textInstance !== null) {
|
||
fiber.stateNode = textInstance;
|
||
hydrationParentFiber = fiber;
|
||
nextHydratableInstance = null;
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
case SuspenseComponent: {
|
||
var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
|
||
if (suspenseInstance !== null) {
|
||
var suspenseState = {
|
||
dehydrated: suspenseInstance,
|
||
treeContext: getSuspendedTreeContext(),
|
||
retryLane: OffscreenLane
|
||
};
|
||
fiber.memoizedState = suspenseState;
|
||
var dehydratedFragment = createFiberFromDehydratedFragment(suspenseInstance);
|
||
dehydratedFragment.return = fiber;
|
||
fiber.child = dehydratedFragment;
|
||
hydrationParentFiber = fiber;
|
||
nextHydratableInstance = null;
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
function shouldClientRenderOnMismatch(fiber) {
|
||
return (fiber.mode & ConcurrentMode) !== NoMode && (fiber.flags & DidCapture) === NoFlags;
|
||
}
|
||
function throwOnHydrationMismatch(fiber) {
|
||
throw new Error("Hydration failed because the initial UI does not match what was rendered on the server.");
|
||
}
|
||
function tryToClaimNextHydratableInstance(fiber) {
|
||
if (!isHydrating) {
|
||
return;
|
||
}
|
||
var nextInstance = nextHydratableInstance;
|
||
if (!nextInstance) {
|
||
if (shouldClientRenderOnMismatch(fiber)) {
|
||
warnNonhydratedInstance(hydrationParentFiber, fiber);
|
||
throwOnHydrationMismatch();
|
||
}
|
||
insertNonHydratedInstance(hydrationParentFiber, fiber);
|
||
isHydrating = false;
|
||
hydrationParentFiber = fiber;
|
||
return;
|
||
}
|
||
var firstAttemptedInstance = nextInstance;
|
||
if (!tryHydrate(fiber, nextInstance)) {
|
||
if (shouldClientRenderOnMismatch(fiber)) {
|
||
warnNonhydratedInstance(hydrationParentFiber, fiber);
|
||
throwOnHydrationMismatch();
|
||
}
|
||
nextInstance = getNextHydratableSibling(firstAttemptedInstance);
|
||
var prevHydrationParentFiber = hydrationParentFiber;
|
||
if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
|
||
insertNonHydratedInstance(hydrationParentFiber, fiber);
|
||
isHydrating = false;
|
||
hydrationParentFiber = fiber;
|
||
return;
|
||
}
|
||
deleteHydratableInstance(prevHydrationParentFiber, firstAttemptedInstance);
|
||
}
|
||
}
|
||
function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
|
||
var instance = fiber.stateNode;
|
||
var shouldWarnIfMismatchDev = !didSuspendOrErrorDEV;
|
||
var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber, shouldWarnIfMismatchDev);
|
||
fiber.updateQueue = updatePayload;
|
||
if (updatePayload !== null) {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
function prepareToHydrateHostTextInstance(fiber) {
|
||
var textInstance = fiber.stateNode;
|
||
var textContent = fiber.memoizedProps;
|
||
var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
|
||
if (shouldUpdate) {
|
||
var returnFiber = hydrationParentFiber;
|
||
if (returnFiber !== null) {
|
||
switch (returnFiber.tag) {
|
||
case HostRoot: {
|
||
var parentContainer = returnFiber.stateNode.containerInfo;
|
||
var isConcurrentMode = (returnFiber.mode & ConcurrentMode) !== NoMode;
|
||
didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent, isConcurrentMode);
|
||
break;
|
||
}
|
||
case HostComponent: {
|
||
var parentType = returnFiber.type;
|
||
var parentProps = returnFiber.memoizedProps;
|
||
var parentInstance = returnFiber.stateNode;
|
||
var _isConcurrentMode2 = (returnFiber.mode & ConcurrentMode) !== NoMode;
|
||
didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent, _isConcurrentMode2);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return shouldUpdate;
|
||
}
|
||
function prepareToHydrateHostSuspenseInstance(fiber) {
|
||
var suspenseState = fiber.memoizedState;
|
||
var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
|
||
if (!suspenseInstance) {
|
||
throw new Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
hydrateSuspenseInstance(suspenseInstance, fiber);
|
||
}
|
||
function skipPastDehydratedSuspenseInstance(fiber) {
|
||
var suspenseState = fiber.memoizedState;
|
||
var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
|
||
if (!suspenseInstance) {
|
||
throw new Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
|
||
}
|
||
function popToNextHostParent(fiber) {
|
||
var parent2 = fiber.return;
|
||
while (parent2 !== null && parent2.tag !== HostComponent && parent2.tag !== HostRoot && parent2.tag !== SuspenseComponent) {
|
||
parent2 = parent2.return;
|
||
}
|
||
hydrationParentFiber = parent2;
|
||
}
|
||
function popHydrationState(fiber) {
|
||
if (fiber !== hydrationParentFiber) {
|
||
return false;
|
||
}
|
||
if (!isHydrating) {
|
||
popToNextHostParent(fiber);
|
||
isHydrating = true;
|
||
return false;
|
||
}
|
||
if (fiber.tag !== HostRoot && (fiber.tag !== HostComponent || shouldDeleteUnhydratedTailInstances(fiber.type) && !shouldSetTextContent(fiber.type, fiber.memoizedProps))) {
|
||
var nextInstance = nextHydratableInstance;
|
||
if (nextInstance) {
|
||
if (shouldClientRenderOnMismatch(fiber)) {
|
||
warnIfUnhydratedTailNodes(fiber);
|
||
throwOnHydrationMismatch();
|
||
} else {
|
||
while (nextInstance) {
|
||
deleteHydratableInstance(fiber, nextInstance);
|
||
nextInstance = getNextHydratableSibling(nextInstance);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
popToNextHostParent(fiber);
|
||
if (fiber.tag === SuspenseComponent) {
|
||
nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber);
|
||
} else {
|
||
nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
|
||
}
|
||
return true;
|
||
}
|
||
function hasUnhydratedTailNodes() {
|
||
return isHydrating && nextHydratableInstance !== null;
|
||
}
|
||
function warnIfUnhydratedTailNodes(fiber) {
|
||
var nextInstance = nextHydratableInstance;
|
||
while (nextInstance) {
|
||
warnUnhydratedInstance(fiber, nextInstance);
|
||
nextInstance = getNextHydratableSibling(nextInstance);
|
||
}
|
||
}
|
||
function resetHydrationState() {
|
||
hydrationParentFiber = null;
|
||
nextHydratableInstance = null;
|
||
isHydrating = false;
|
||
didSuspendOrErrorDEV = false;
|
||
}
|
||
function upgradeHydrationErrorsToRecoverable() {
|
||
if (hydrationErrors !== null) {
|
||
queueRecoverableErrors(hydrationErrors);
|
||
hydrationErrors = null;
|
||
}
|
||
}
|
||
function getIsHydrating() {
|
||
return isHydrating;
|
||
}
|
||
function queueHydrationError(error2) {
|
||
if (hydrationErrors === null) {
|
||
hydrationErrors = [error2];
|
||
} else {
|
||
hydrationErrors.push(error2);
|
||
}
|
||
}
|
||
var ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
|
||
var NoTransition = null;
|
||
function requestCurrentTransition() {
|
||
return ReactCurrentBatchConfig$1.transition;
|
||
}
|
||
var ReactStrictModeWarnings = {
|
||
recordUnsafeLifecycleWarnings: function(fiber, instance) {
|
||
},
|
||
flushPendingUnsafeLifecycleWarnings: function() {
|
||
},
|
||
recordLegacyContextWarning: function(fiber, instance) {
|
||
},
|
||
flushLegacyContextWarning: function() {
|
||
},
|
||
discardPendingWarnings: function() {
|
||
}
|
||
};
|
||
{
|
||
var findStrictRoot = function(fiber) {
|
||
var maybeStrictRoot = null;
|
||
var node = fiber;
|
||
while (node !== null) {
|
||
if (node.mode & StrictLegacyMode) {
|
||
maybeStrictRoot = node;
|
||
}
|
||
node = node.return;
|
||
}
|
||
return maybeStrictRoot;
|
||
};
|
||
var setToSortedString = function(set2) {
|
||
var array = [];
|
||
set2.forEach(function(value) {
|
||
array.push(value);
|
||
});
|
||
return array.sort().join(", ");
|
||
};
|
||
var pendingComponentWillMountWarnings = [];
|
||
var pendingUNSAFE_ComponentWillMountWarnings = [];
|
||
var pendingComponentWillReceivePropsWarnings = [];
|
||
var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
||
var pendingComponentWillUpdateWarnings = [];
|
||
var pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
||
var didWarnAboutUnsafeLifecycles = /* @__PURE__ */ new Set();
|
||
ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function(fiber, instance) {
|
||
if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
|
||
return;
|
||
}
|
||
if (typeof instance.componentWillMount === "function" && instance.componentWillMount.__suppressDeprecationWarning !== true) {
|
||
pendingComponentWillMountWarnings.push(fiber);
|
||
}
|
||
if (fiber.mode & StrictLegacyMode && typeof instance.UNSAFE_componentWillMount === "function") {
|
||
pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
|
||
}
|
||
if (typeof instance.componentWillReceiveProps === "function" && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
|
||
pendingComponentWillReceivePropsWarnings.push(fiber);
|
||
}
|
||
if (fiber.mode & StrictLegacyMode && typeof instance.UNSAFE_componentWillReceiveProps === "function") {
|
||
pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
|
||
}
|
||
if (typeof instance.componentWillUpdate === "function" && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
|
||
pendingComponentWillUpdateWarnings.push(fiber);
|
||
}
|
||
if (fiber.mode & StrictLegacyMode && typeof instance.UNSAFE_componentWillUpdate === "function") {
|
||
pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
|
||
}
|
||
};
|
||
ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function() {
|
||
var componentWillMountUniqueNames = /* @__PURE__ */ new Set();
|
||
if (pendingComponentWillMountWarnings.length > 0) {
|
||
pendingComponentWillMountWarnings.forEach(function(fiber) {
|
||
componentWillMountUniqueNames.add(getComponentNameFromFiber(fiber) || "Component");
|
||
didWarnAboutUnsafeLifecycles.add(fiber.type);
|
||
});
|
||
pendingComponentWillMountWarnings = [];
|
||
}
|
||
var UNSAFE_componentWillMountUniqueNames = /* @__PURE__ */ new Set();
|
||
if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
|
||
pendingUNSAFE_ComponentWillMountWarnings.forEach(function(fiber) {
|
||
UNSAFE_componentWillMountUniqueNames.add(getComponentNameFromFiber(fiber) || "Component");
|
||
didWarnAboutUnsafeLifecycles.add(fiber.type);
|
||
});
|
||
pendingUNSAFE_ComponentWillMountWarnings = [];
|
||
}
|
||
var componentWillReceivePropsUniqueNames = /* @__PURE__ */ new Set();
|
||
if (pendingComponentWillReceivePropsWarnings.length > 0) {
|
||
pendingComponentWillReceivePropsWarnings.forEach(function(fiber) {
|
||
componentWillReceivePropsUniqueNames.add(getComponentNameFromFiber(fiber) || "Component");
|
||
didWarnAboutUnsafeLifecycles.add(fiber.type);
|
||
});
|
||
pendingComponentWillReceivePropsWarnings = [];
|
||
}
|
||
var UNSAFE_componentWillReceivePropsUniqueNames = /* @__PURE__ */ new Set();
|
||
if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
|
||
pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function(fiber) {
|
||
UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentNameFromFiber(fiber) || "Component");
|
||
didWarnAboutUnsafeLifecycles.add(fiber.type);
|
||
});
|
||
pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
||
}
|
||
var componentWillUpdateUniqueNames = /* @__PURE__ */ new Set();
|
||
if (pendingComponentWillUpdateWarnings.length > 0) {
|
||
pendingComponentWillUpdateWarnings.forEach(function(fiber) {
|
||
componentWillUpdateUniqueNames.add(getComponentNameFromFiber(fiber) || "Component");
|
||
didWarnAboutUnsafeLifecycles.add(fiber.type);
|
||
});
|
||
pendingComponentWillUpdateWarnings = [];
|
||
}
|
||
var UNSAFE_componentWillUpdateUniqueNames = /* @__PURE__ */ new Set();
|
||
if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
|
||
pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function(fiber) {
|
||
UNSAFE_componentWillUpdateUniqueNames.add(getComponentNameFromFiber(fiber) || "Component");
|
||
didWarnAboutUnsafeLifecycles.add(fiber.type);
|
||
});
|
||
pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
||
}
|
||
if (UNSAFE_componentWillMountUniqueNames.size > 0) {
|
||
var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
|
||
error("Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n* Move code with side effects to componentDidMount, and set initial state in the constructor.\n\nPlease update the following components: %s", sortedNames);
|
||
}
|
||
if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
|
||
var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames);
|
||
error("Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n* Move data fetching code or side effects to componentDidUpdate.\n* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n\nPlease update the following components: %s", _sortedNames);
|
||
}
|
||
if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
|
||
var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames);
|
||
error("Using UNSAFE_componentWillUpdate in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n* Move data fetching code or side effects to componentDidUpdate.\n\nPlease update the following components: %s", _sortedNames2);
|
||
}
|
||
if (componentWillMountUniqueNames.size > 0) {
|
||
var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
|
||
warn("componentWillMount has been renamed, and is not recommended for use. See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n* Move code with side effects to componentDidMount, and set initial state in the constructor.\n* Rename componentWillMount to UNSAFE_componentWillMount to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n\nPlease update the following components: %s", _sortedNames3);
|
||
}
|
||
if (componentWillReceivePropsUniqueNames.size > 0) {
|
||
var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames);
|
||
warn("componentWillReceiveProps has been renamed, and is not recommended for use. See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n* Move data fetching code or side effects to componentDidUpdate.\n* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n\nPlease update the following components: %s", _sortedNames4);
|
||
}
|
||
if (componentWillUpdateUniqueNames.size > 0) {
|
||
var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
|
||
warn("componentWillUpdate has been renamed, and is not recommended for use. See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n* Move data fetching code or side effects to componentDidUpdate.\n* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n\nPlease update the following components: %s", _sortedNames5);
|
||
}
|
||
};
|
||
var pendingLegacyContextWarning = /* @__PURE__ */ new Map();
|
||
var didWarnAboutLegacyContext = /* @__PURE__ */ new Set();
|
||
ReactStrictModeWarnings.recordLegacyContextWarning = function(fiber, instance) {
|
||
var strictRoot = findStrictRoot(fiber);
|
||
if (strictRoot === null) {
|
||
error("Expected to find a StrictMode component in a strict mode tree. This error is likely caused by a bug in React. Please file an issue.");
|
||
return;
|
||
}
|
||
if (didWarnAboutLegacyContext.has(fiber.type)) {
|
||
return;
|
||
}
|
||
var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
|
||
if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === "function") {
|
||
if (warningsForRoot === void 0) {
|
||
warningsForRoot = [];
|
||
pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
|
||
}
|
||
warningsForRoot.push(fiber);
|
||
}
|
||
};
|
||
ReactStrictModeWarnings.flushLegacyContextWarning = function() {
|
||
pendingLegacyContextWarning.forEach(function(fiberArray, strictRoot) {
|
||
if (fiberArray.length === 0) {
|
||
return;
|
||
}
|
||
var firstFiber = fiberArray[0];
|
||
var uniqueNames = /* @__PURE__ */ new Set();
|
||
fiberArray.forEach(function(fiber) {
|
||
uniqueNames.add(getComponentNameFromFiber(fiber) || "Component");
|
||
didWarnAboutLegacyContext.add(fiber.type);
|
||
});
|
||
var sortedNames = setToSortedString(uniqueNames);
|
||
try {
|
||
setCurrentFiber(firstFiber);
|
||
error("Legacy context API has been detected within a strict-mode tree.\n\nThe old API will be supported in all 16.x releases, but applications using it should migrate to the new version.\n\nPlease update the following components: %s\n\nLearn more about this warning here: https://reactjs.org/link/legacy-context", sortedNames);
|
||
} finally {
|
||
resetCurrentFiber();
|
||
}
|
||
});
|
||
};
|
||
ReactStrictModeWarnings.discardPendingWarnings = function() {
|
||
pendingComponentWillMountWarnings = [];
|
||
pendingUNSAFE_ComponentWillMountWarnings = [];
|
||
pendingComponentWillReceivePropsWarnings = [];
|
||
pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
||
pendingComponentWillUpdateWarnings = [];
|
||
pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
||
pendingLegacyContextWarning = /* @__PURE__ */ new Map();
|
||
};
|
||
}
|
||
function resolveDefaultProps(Component, baseProps) {
|
||
if (Component && Component.defaultProps) {
|
||
var props = assign({}, baseProps);
|
||
var defaultProps = Component.defaultProps;
|
||
for (var propName in defaultProps) {
|
||
if (props[propName] === void 0) {
|
||
props[propName] = defaultProps[propName];
|
||
}
|
||
}
|
||
return props;
|
||
}
|
||
return baseProps;
|
||
}
|
||
var valueCursor = createCursor(null);
|
||
var rendererSigil;
|
||
{
|
||
rendererSigil = {};
|
||
}
|
||
var currentlyRenderingFiber = null;
|
||
var lastContextDependency = null;
|
||
var lastFullyObservedContext = null;
|
||
var isDisallowedContextReadInDEV = false;
|
||
function resetContextDependencies() {
|
||
currentlyRenderingFiber = null;
|
||
lastContextDependency = null;
|
||
lastFullyObservedContext = null;
|
||
{
|
||
isDisallowedContextReadInDEV = false;
|
||
}
|
||
}
|
||
function enterDisallowedContextReadInDEV() {
|
||
{
|
||
isDisallowedContextReadInDEV = true;
|
||
}
|
||
}
|
||
function exitDisallowedContextReadInDEV() {
|
||
{
|
||
isDisallowedContextReadInDEV = false;
|
||
}
|
||
}
|
||
function pushProvider(providerFiber, context, nextValue) {
|
||
{
|
||
push(valueCursor, context._currentValue, providerFiber);
|
||
context._currentValue = nextValue;
|
||
{
|
||
if (context._currentRenderer !== void 0 && context._currentRenderer !== null && context._currentRenderer !== rendererSigil) {
|
||
error("Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.");
|
||
}
|
||
context._currentRenderer = rendererSigil;
|
||
}
|
||
}
|
||
}
|
||
function popProvider(context, providerFiber) {
|
||
var currentValue = valueCursor.current;
|
||
pop(valueCursor, providerFiber);
|
||
{
|
||
{
|
||
context._currentValue = currentValue;
|
||
}
|
||
}
|
||
}
|
||
function scheduleContextWorkOnParentPath(parent2, renderLanes2, propagationRoot) {
|
||
var node = parent2;
|
||
while (node !== null) {
|
||
var alternate = node.alternate;
|
||
if (!isSubsetOfLanes(node.childLanes, renderLanes2)) {
|
||
node.childLanes = mergeLanes(node.childLanes, renderLanes2);
|
||
if (alternate !== null) {
|
||
alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes2);
|
||
}
|
||
} else if (alternate !== null && !isSubsetOfLanes(alternate.childLanes, renderLanes2)) {
|
||
alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes2);
|
||
}
|
||
if (node === propagationRoot) {
|
||
break;
|
||
}
|
||
node = node.return;
|
||
}
|
||
{
|
||
if (node !== propagationRoot) {
|
||
error("Expected to find the propagation root when scheduling context work. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
}
|
||
function propagateContextChange(workInProgress2, context, renderLanes2) {
|
||
{
|
||
propagateContextChange_eager(workInProgress2, context, renderLanes2);
|
||
}
|
||
}
|
||
function propagateContextChange_eager(workInProgress2, context, renderLanes2) {
|
||
var fiber = workInProgress2.child;
|
||
if (fiber !== null) {
|
||
fiber.return = workInProgress2;
|
||
}
|
||
while (fiber !== null) {
|
||
var nextFiber = void 0;
|
||
var list = fiber.dependencies;
|
||
if (list !== null) {
|
||
nextFiber = fiber.child;
|
||
var dependency = list.firstContext;
|
||
while (dependency !== null) {
|
||
if (dependency.context === context) {
|
||
if (fiber.tag === ClassComponent) {
|
||
var lane = pickArbitraryLane(renderLanes2);
|
||
var update = createUpdate(NoTimestamp, lane);
|
||
update.tag = ForceUpdate;
|
||
var updateQueue = fiber.updateQueue;
|
||
if (updateQueue === null)
|
||
;
|
||
else {
|
||
var sharedQueue = updateQueue.shared;
|
||
var pending = sharedQueue.pending;
|
||
if (pending === null) {
|
||
update.next = update;
|
||
} else {
|
||
update.next = pending.next;
|
||
pending.next = update;
|
||
}
|
||
sharedQueue.pending = update;
|
||
}
|
||
}
|
||
fiber.lanes = mergeLanes(fiber.lanes, renderLanes2);
|
||
var alternate = fiber.alternate;
|
||
if (alternate !== null) {
|
||
alternate.lanes = mergeLanes(alternate.lanes, renderLanes2);
|
||
}
|
||
scheduleContextWorkOnParentPath(fiber.return, renderLanes2, workInProgress2);
|
||
list.lanes = mergeLanes(list.lanes, renderLanes2);
|
||
break;
|
||
}
|
||
dependency = dependency.next;
|
||
}
|
||
} else if (fiber.tag === ContextProvider) {
|
||
nextFiber = fiber.type === workInProgress2.type ? null : fiber.child;
|
||
} else if (fiber.tag === DehydratedFragment) {
|
||
var parentSuspense = fiber.return;
|
||
if (parentSuspense === null) {
|
||
throw new Error("We just came from a parent so we must have had a parent. This is a bug in React.");
|
||
}
|
||
parentSuspense.lanes = mergeLanes(parentSuspense.lanes, renderLanes2);
|
||
var _alternate = parentSuspense.alternate;
|
||
if (_alternate !== null) {
|
||
_alternate.lanes = mergeLanes(_alternate.lanes, renderLanes2);
|
||
}
|
||
scheduleContextWorkOnParentPath(parentSuspense, renderLanes2, workInProgress2);
|
||
nextFiber = fiber.sibling;
|
||
} else {
|
||
nextFiber = fiber.child;
|
||
}
|
||
if (nextFiber !== null) {
|
||
nextFiber.return = fiber;
|
||
} else {
|
||
nextFiber = fiber;
|
||
while (nextFiber !== null) {
|
||
if (nextFiber === workInProgress2) {
|
||
nextFiber = null;
|
||
break;
|
||
}
|
||
var sibling = nextFiber.sibling;
|
||
if (sibling !== null) {
|
||
sibling.return = nextFiber.return;
|
||
nextFiber = sibling;
|
||
break;
|
||
}
|
||
nextFiber = nextFiber.return;
|
||
}
|
||
}
|
||
fiber = nextFiber;
|
||
}
|
||
}
|
||
function prepareToReadContext(workInProgress2, renderLanes2) {
|
||
currentlyRenderingFiber = workInProgress2;
|
||
lastContextDependency = null;
|
||
lastFullyObservedContext = null;
|
||
var dependencies = workInProgress2.dependencies;
|
||
if (dependencies !== null) {
|
||
{
|
||
var firstContext = dependencies.firstContext;
|
||
if (firstContext !== null) {
|
||
if (includesSomeLane(dependencies.lanes, renderLanes2)) {
|
||
markWorkInProgressReceivedUpdate();
|
||
}
|
||
dependencies.firstContext = null;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function readContext(context) {
|
||
{
|
||
if (isDisallowedContextReadInDEV) {
|
||
error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");
|
||
}
|
||
}
|
||
var value = context._currentValue;
|
||
if (lastFullyObservedContext === context)
|
||
;
|
||
else {
|
||
var contextItem = {
|
||
context,
|
||
memoizedValue: value,
|
||
next: null
|
||
};
|
||
if (lastContextDependency === null) {
|
||
if (currentlyRenderingFiber === null) {
|
||
throw new Error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");
|
||
}
|
||
lastContextDependency = contextItem;
|
||
currentlyRenderingFiber.dependencies = {
|
||
lanes: NoLanes,
|
||
firstContext: contextItem
|
||
};
|
||
} else {
|
||
lastContextDependency = lastContextDependency.next = contextItem;
|
||
}
|
||
}
|
||
return value;
|
||
}
|
||
var concurrentQueues = null;
|
||
function pushConcurrentUpdateQueue(queue) {
|
||
if (concurrentQueues === null) {
|
||
concurrentQueues = [queue];
|
||
} else {
|
||
concurrentQueues.push(queue);
|
||
}
|
||
}
|
||
function finishQueueingConcurrentUpdates() {
|
||
if (concurrentQueues !== null) {
|
||
for (var i = 0; i < concurrentQueues.length; i++) {
|
||
var queue = concurrentQueues[i];
|
||
var lastInterleavedUpdate = queue.interleaved;
|
||
if (lastInterleavedUpdate !== null) {
|
||
queue.interleaved = null;
|
||
var firstInterleavedUpdate = lastInterleavedUpdate.next;
|
||
var lastPendingUpdate = queue.pending;
|
||
if (lastPendingUpdate !== null) {
|
||
var firstPendingUpdate = lastPendingUpdate.next;
|
||
lastPendingUpdate.next = firstInterleavedUpdate;
|
||
lastInterleavedUpdate.next = firstPendingUpdate;
|
||
}
|
||
queue.pending = lastInterleavedUpdate;
|
||
}
|
||
}
|
||
concurrentQueues = null;
|
||
}
|
||
}
|
||
function enqueueConcurrentHookUpdate(fiber, queue, update, lane) {
|
||
var interleaved = queue.interleaved;
|
||
if (interleaved === null) {
|
||
update.next = update;
|
||
pushConcurrentUpdateQueue(queue);
|
||
} else {
|
||
update.next = interleaved.next;
|
||
interleaved.next = update;
|
||
}
|
||
queue.interleaved = update;
|
||
return markUpdateLaneFromFiberToRoot(fiber, lane);
|
||
}
|
||
function enqueueConcurrentHookUpdateAndEagerlyBailout(fiber, queue, update, lane) {
|
||
var interleaved = queue.interleaved;
|
||
if (interleaved === null) {
|
||
update.next = update;
|
||
pushConcurrentUpdateQueue(queue);
|
||
} else {
|
||
update.next = interleaved.next;
|
||
interleaved.next = update;
|
||
}
|
||
queue.interleaved = update;
|
||
}
|
||
function enqueueConcurrentClassUpdate(fiber, queue, update, lane) {
|
||
var interleaved = queue.interleaved;
|
||
if (interleaved === null) {
|
||
update.next = update;
|
||
pushConcurrentUpdateQueue(queue);
|
||
} else {
|
||
update.next = interleaved.next;
|
||
interleaved.next = update;
|
||
}
|
||
queue.interleaved = update;
|
||
return markUpdateLaneFromFiberToRoot(fiber, lane);
|
||
}
|
||
function enqueueConcurrentRenderForLane(fiber, lane) {
|
||
return markUpdateLaneFromFiberToRoot(fiber, lane);
|
||
}
|
||
var unsafe_markUpdateLaneFromFiberToRoot = markUpdateLaneFromFiberToRoot;
|
||
function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
|
||
sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane);
|
||
var alternate = sourceFiber.alternate;
|
||
if (alternate !== null) {
|
||
alternate.lanes = mergeLanes(alternate.lanes, lane);
|
||
}
|
||
{
|
||
if (alternate === null && (sourceFiber.flags & (Placement | Hydrating)) !== NoFlags) {
|
||
warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber);
|
||
}
|
||
}
|
||
var node = sourceFiber;
|
||
var parent2 = sourceFiber.return;
|
||
while (parent2 !== null) {
|
||
parent2.childLanes = mergeLanes(parent2.childLanes, lane);
|
||
alternate = parent2.alternate;
|
||
if (alternate !== null) {
|
||
alternate.childLanes = mergeLanes(alternate.childLanes, lane);
|
||
} else {
|
||
{
|
||
if ((parent2.flags & (Placement | Hydrating)) !== NoFlags) {
|
||
warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber);
|
||
}
|
||
}
|
||
}
|
||
node = parent2;
|
||
parent2 = parent2.return;
|
||
}
|
||
if (node.tag === HostRoot) {
|
||
var root2 = node.stateNode;
|
||
return root2;
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
var UpdateState = 0;
|
||
var ReplaceState = 1;
|
||
var ForceUpdate = 2;
|
||
var CaptureUpdate = 3;
|
||
var hasForceUpdate = false;
|
||
var didWarnUpdateInsideUpdate;
|
||
var currentlyProcessingQueue;
|
||
{
|
||
didWarnUpdateInsideUpdate = false;
|
||
currentlyProcessingQueue = null;
|
||
}
|
||
function initializeUpdateQueue(fiber) {
|
||
var queue = {
|
||
baseState: fiber.memoizedState,
|
||
firstBaseUpdate: null,
|
||
lastBaseUpdate: null,
|
||
shared: {
|
||
pending: null,
|
||
interleaved: null,
|
||
lanes: NoLanes
|
||
},
|
||
effects: null
|
||
};
|
||
fiber.updateQueue = queue;
|
||
}
|
||
function cloneUpdateQueue(current2, workInProgress2) {
|
||
var queue = workInProgress2.updateQueue;
|
||
var currentQueue = current2.updateQueue;
|
||
if (queue === currentQueue) {
|
||
var clone = {
|
||
baseState: currentQueue.baseState,
|
||
firstBaseUpdate: currentQueue.firstBaseUpdate,
|
||
lastBaseUpdate: currentQueue.lastBaseUpdate,
|
||
shared: currentQueue.shared,
|
||
effects: currentQueue.effects
|
||
};
|
||
workInProgress2.updateQueue = clone;
|
||
}
|
||
}
|
||
function createUpdate(eventTime, lane) {
|
||
var update = {
|
||
eventTime,
|
||
lane,
|
||
tag: UpdateState,
|
||
payload: null,
|
||
callback: null,
|
||
next: null
|
||
};
|
||
return update;
|
||
}
|
||
function enqueueUpdate(fiber, update, lane) {
|
||
var updateQueue = fiber.updateQueue;
|
||
if (updateQueue === null) {
|
||
return null;
|
||
}
|
||
var sharedQueue = updateQueue.shared;
|
||
{
|
||
if (currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate) {
|
||
error("An update (setState, replaceState, or forceUpdate) was scheduled from inside an update function. Update functions should be pure, with zero side-effects. Consider using componentDidUpdate or a callback.");
|
||
didWarnUpdateInsideUpdate = true;
|
||
}
|
||
}
|
||
if (isUnsafeClassRenderPhaseUpdate()) {
|
||
var pending = sharedQueue.pending;
|
||
if (pending === null) {
|
||
update.next = update;
|
||
} else {
|
||
update.next = pending.next;
|
||
pending.next = update;
|
||
}
|
||
sharedQueue.pending = update;
|
||
return unsafe_markUpdateLaneFromFiberToRoot(fiber, lane);
|
||
} else {
|
||
return enqueueConcurrentClassUpdate(fiber, sharedQueue, update, lane);
|
||
}
|
||
}
|
||
function entangleTransitions(root2, fiber, lane) {
|
||
var updateQueue = fiber.updateQueue;
|
||
if (updateQueue === null) {
|
||
return;
|
||
}
|
||
var sharedQueue = updateQueue.shared;
|
||
if (isTransitionLane(lane)) {
|
||
var queueLanes = sharedQueue.lanes;
|
||
queueLanes = intersectLanes(queueLanes, root2.pendingLanes);
|
||
var newQueueLanes = mergeLanes(queueLanes, lane);
|
||
sharedQueue.lanes = newQueueLanes;
|
||
markRootEntangled(root2, newQueueLanes);
|
||
}
|
||
}
|
||
function enqueueCapturedUpdate(workInProgress2, capturedUpdate) {
|
||
var queue = workInProgress2.updateQueue;
|
||
var current2 = workInProgress2.alternate;
|
||
if (current2 !== null) {
|
||
var currentQueue = current2.updateQueue;
|
||
if (queue === currentQueue) {
|
||
var newFirst = null;
|
||
var newLast = null;
|
||
var firstBaseUpdate = queue.firstBaseUpdate;
|
||
if (firstBaseUpdate !== null) {
|
||
var update = firstBaseUpdate;
|
||
do {
|
||
var clone = {
|
||
eventTime: update.eventTime,
|
||
lane: update.lane,
|
||
tag: update.tag,
|
||
payload: update.payload,
|
||
callback: update.callback,
|
||
next: null
|
||
};
|
||
if (newLast === null) {
|
||
newFirst = newLast = clone;
|
||
} else {
|
||
newLast.next = clone;
|
||
newLast = clone;
|
||
}
|
||
update = update.next;
|
||
} while (update !== null);
|
||
if (newLast === null) {
|
||
newFirst = newLast = capturedUpdate;
|
||
} else {
|
||
newLast.next = capturedUpdate;
|
||
newLast = capturedUpdate;
|
||
}
|
||
} else {
|
||
newFirst = newLast = capturedUpdate;
|
||
}
|
||
queue = {
|
||
baseState: currentQueue.baseState,
|
||
firstBaseUpdate: newFirst,
|
||
lastBaseUpdate: newLast,
|
||
shared: currentQueue.shared,
|
||
effects: currentQueue.effects
|
||
};
|
||
workInProgress2.updateQueue = queue;
|
||
return;
|
||
}
|
||
}
|
||
var lastBaseUpdate = queue.lastBaseUpdate;
|
||
if (lastBaseUpdate === null) {
|
||
queue.firstBaseUpdate = capturedUpdate;
|
||
} else {
|
||
lastBaseUpdate.next = capturedUpdate;
|
||
}
|
||
queue.lastBaseUpdate = capturedUpdate;
|
||
}
|
||
function getStateFromUpdate(workInProgress2, queue, update, prevState, nextProps, instance) {
|
||
switch (update.tag) {
|
||
case ReplaceState: {
|
||
var payload = update.payload;
|
||
if (typeof payload === "function") {
|
||
{
|
||
enterDisallowedContextReadInDEV();
|
||
}
|
||
var nextState = payload.call(instance, prevState, nextProps);
|
||
{
|
||
if (workInProgress2.mode & StrictLegacyMode) {
|
||
setIsStrictModeForDevtools(true);
|
||
try {
|
||
payload.call(instance, prevState, nextProps);
|
||
} finally {
|
||
setIsStrictModeForDevtools(false);
|
||
}
|
||
}
|
||
exitDisallowedContextReadInDEV();
|
||
}
|
||
return nextState;
|
||
}
|
||
return payload;
|
||
}
|
||
case CaptureUpdate: {
|
||
workInProgress2.flags = workInProgress2.flags & ~ShouldCapture | DidCapture;
|
||
}
|
||
case UpdateState: {
|
||
var _payload = update.payload;
|
||
var partialState;
|
||
if (typeof _payload === "function") {
|
||
{
|
||
enterDisallowedContextReadInDEV();
|
||
}
|
||
partialState = _payload.call(instance, prevState, nextProps);
|
||
{
|
||
if (workInProgress2.mode & StrictLegacyMode) {
|
||
setIsStrictModeForDevtools(true);
|
||
try {
|
||
_payload.call(instance, prevState, nextProps);
|
||
} finally {
|
||
setIsStrictModeForDevtools(false);
|
||
}
|
||
}
|
||
exitDisallowedContextReadInDEV();
|
||
}
|
||
} else {
|
||
partialState = _payload;
|
||
}
|
||
if (partialState === null || partialState === void 0) {
|
||
return prevState;
|
||
}
|
||
return assign({}, prevState, partialState);
|
||
}
|
||
case ForceUpdate: {
|
||
hasForceUpdate = true;
|
||
return prevState;
|
||
}
|
||
}
|
||
return prevState;
|
||
}
|
||
function processUpdateQueue(workInProgress2, props, instance, renderLanes2) {
|
||
var queue = workInProgress2.updateQueue;
|
||
hasForceUpdate = false;
|
||
{
|
||
currentlyProcessingQueue = queue.shared;
|
||
}
|
||
var firstBaseUpdate = queue.firstBaseUpdate;
|
||
var lastBaseUpdate = queue.lastBaseUpdate;
|
||
var pendingQueue = queue.shared.pending;
|
||
if (pendingQueue !== null) {
|
||
queue.shared.pending = null;
|
||
var lastPendingUpdate = pendingQueue;
|
||
var firstPendingUpdate = lastPendingUpdate.next;
|
||
lastPendingUpdate.next = null;
|
||
if (lastBaseUpdate === null) {
|
||
firstBaseUpdate = firstPendingUpdate;
|
||
} else {
|
||
lastBaseUpdate.next = firstPendingUpdate;
|
||
}
|
||
lastBaseUpdate = lastPendingUpdate;
|
||
var current2 = workInProgress2.alternate;
|
||
if (current2 !== null) {
|
||
var currentQueue = current2.updateQueue;
|
||
var currentLastBaseUpdate = currentQueue.lastBaseUpdate;
|
||
if (currentLastBaseUpdate !== lastBaseUpdate) {
|
||
if (currentLastBaseUpdate === null) {
|
||
currentQueue.firstBaseUpdate = firstPendingUpdate;
|
||
} else {
|
||
currentLastBaseUpdate.next = firstPendingUpdate;
|
||
}
|
||
currentQueue.lastBaseUpdate = lastPendingUpdate;
|
||
}
|
||
}
|
||
}
|
||
if (firstBaseUpdate !== null) {
|
||
var newState = queue.baseState;
|
||
var newLanes = NoLanes;
|
||
var newBaseState = null;
|
||
var newFirstBaseUpdate = null;
|
||
var newLastBaseUpdate = null;
|
||
var update = firstBaseUpdate;
|
||
do {
|
||
var updateLane = update.lane;
|
||
var updateEventTime = update.eventTime;
|
||
if (!isSubsetOfLanes(renderLanes2, updateLane)) {
|
||
var clone = {
|
||
eventTime: updateEventTime,
|
||
lane: updateLane,
|
||
tag: update.tag,
|
||
payload: update.payload,
|
||
callback: update.callback,
|
||
next: null
|
||
};
|
||
if (newLastBaseUpdate === null) {
|
||
newFirstBaseUpdate = newLastBaseUpdate = clone;
|
||
newBaseState = newState;
|
||
} else {
|
||
newLastBaseUpdate = newLastBaseUpdate.next = clone;
|
||
}
|
||
newLanes = mergeLanes(newLanes, updateLane);
|
||
} else {
|
||
if (newLastBaseUpdate !== null) {
|
||
var _clone = {
|
||
eventTime: updateEventTime,
|
||
lane: NoLane,
|
||
tag: update.tag,
|
||
payload: update.payload,
|
||
callback: update.callback,
|
||
next: null
|
||
};
|
||
newLastBaseUpdate = newLastBaseUpdate.next = _clone;
|
||
}
|
||
newState = getStateFromUpdate(workInProgress2, queue, update, newState, props, instance);
|
||
var callback = update.callback;
|
||
if (callback !== null && update.lane !== NoLane) {
|
||
workInProgress2.flags |= Callback;
|
||
var effects = queue.effects;
|
||
if (effects === null) {
|
||
queue.effects = [update];
|
||
} else {
|
||
effects.push(update);
|
||
}
|
||
}
|
||
}
|
||
update = update.next;
|
||
if (update === null) {
|
||
pendingQueue = queue.shared.pending;
|
||
if (pendingQueue === null) {
|
||
break;
|
||
} else {
|
||
var _lastPendingUpdate = pendingQueue;
|
||
var _firstPendingUpdate = _lastPendingUpdate.next;
|
||
_lastPendingUpdate.next = null;
|
||
update = _firstPendingUpdate;
|
||
queue.lastBaseUpdate = _lastPendingUpdate;
|
||
queue.shared.pending = null;
|
||
}
|
||
}
|
||
} while (true);
|
||
if (newLastBaseUpdate === null) {
|
||
newBaseState = newState;
|
||
}
|
||
queue.baseState = newBaseState;
|
||
queue.firstBaseUpdate = newFirstBaseUpdate;
|
||
queue.lastBaseUpdate = newLastBaseUpdate;
|
||
var lastInterleaved = queue.shared.interleaved;
|
||
if (lastInterleaved !== null) {
|
||
var interleaved = lastInterleaved;
|
||
do {
|
||
newLanes = mergeLanes(newLanes, interleaved.lane);
|
||
interleaved = interleaved.next;
|
||
} while (interleaved !== lastInterleaved);
|
||
} else if (firstBaseUpdate === null) {
|
||
queue.shared.lanes = NoLanes;
|
||
}
|
||
markSkippedUpdateLanes(newLanes);
|
||
workInProgress2.lanes = newLanes;
|
||
workInProgress2.memoizedState = newState;
|
||
}
|
||
{
|
||
currentlyProcessingQueue = null;
|
||
}
|
||
}
|
||
function callCallback(callback, context) {
|
||
if (typeof callback !== "function") {
|
||
throw new Error("Invalid argument passed as callback. Expected a function. Instead " + ("received: " + callback));
|
||
}
|
||
callback.call(context);
|
||
}
|
||
function resetHasForceUpdateBeforeProcessing() {
|
||
hasForceUpdate = false;
|
||
}
|
||
function checkHasForceUpdateAfterProcessing() {
|
||
return hasForceUpdate;
|
||
}
|
||
function commitUpdateQueue(finishedWork, finishedQueue, instance) {
|
||
var effects = finishedQueue.effects;
|
||
finishedQueue.effects = null;
|
||
if (effects !== null) {
|
||
for (var i = 0; i < effects.length; i++) {
|
||
var effect = effects[i];
|
||
var callback = effect.callback;
|
||
if (callback !== null) {
|
||
effect.callback = null;
|
||
callCallback(callback, instance);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var fakeInternalInstance = {};
|
||
var emptyRefsObject = new React2.Component().refs;
|
||
var didWarnAboutStateAssignmentForComponent;
|
||
var didWarnAboutUninitializedState;
|
||
var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
|
||
var didWarnAboutLegacyLifecyclesAndDerivedState;
|
||
var didWarnAboutUndefinedDerivedState;
|
||
var warnOnUndefinedDerivedState;
|
||
var warnOnInvalidCallback;
|
||
var didWarnAboutDirectlyAssigningPropsToState;
|
||
var didWarnAboutContextTypeAndContextTypes;
|
||
var didWarnAboutInvalidateContextType;
|
||
{
|
||
didWarnAboutStateAssignmentForComponent = /* @__PURE__ */ new Set();
|
||
didWarnAboutUninitializedState = /* @__PURE__ */ new Set();
|
||
didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = /* @__PURE__ */ new Set();
|
||
didWarnAboutLegacyLifecyclesAndDerivedState = /* @__PURE__ */ new Set();
|
||
didWarnAboutDirectlyAssigningPropsToState = /* @__PURE__ */ new Set();
|
||
didWarnAboutUndefinedDerivedState = /* @__PURE__ */ new Set();
|
||
didWarnAboutContextTypeAndContextTypes = /* @__PURE__ */ new Set();
|
||
didWarnAboutInvalidateContextType = /* @__PURE__ */ new Set();
|
||
var didWarnOnInvalidCallback = /* @__PURE__ */ new Set();
|
||
warnOnInvalidCallback = function(callback, callerName) {
|
||
if (callback === null || typeof callback === "function") {
|
||
return;
|
||
}
|
||
var key = callerName + "_" + callback;
|
||
if (!didWarnOnInvalidCallback.has(key)) {
|
||
didWarnOnInvalidCallback.add(key);
|
||
error("%s(...): Expected the last optional `callback` argument to be a function. Instead received: %s.", callerName, callback);
|
||
}
|
||
};
|
||
warnOnUndefinedDerivedState = function(type, partialState) {
|
||
if (partialState === void 0) {
|
||
var componentName = getComponentNameFromType(type) || "Component";
|
||
if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
|
||
didWarnAboutUndefinedDerivedState.add(componentName);
|
||
error("%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. You have returned undefined.", componentName);
|
||
}
|
||
}
|
||
};
|
||
Object.defineProperty(fakeInternalInstance, "_processChildContext", {
|
||
enumerable: false,
|
||
value: function() {
|
||
throw new Error("_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal).");
|
||
}
|
||
});
|
||
Object.freeze(fakeInternalInstance);
|
||
}
|
||
function applyDerivedStateFromProps(workInProgress2, ctor, getDerivedStateFromProps, nextProps) {
|
||
var prevState = workInProgress2.memoizedState;
|
||
var partialState = getDerivedStateFromProps(nextProps, prevState);
|
||
{
|
||
if (workInProgress2.mode & StrictLegacyMode) {
|
||
setIsStrictModeForDevtools(true);
|
||
try {
|
||
partialState = getDerivedStateFromProps(nextProps, prevState);
|
||
} finally {
|
||
setIsStrictModeForDevtools(false);
|
||
}
|
||
}
|
||
warnOnUndefinedDerivedState(ctor, partialState);
|
||
}
|
||
var memoizedState = partialState === null || partialState === void 0 ? prevState : assign({}, prevState, partialState);
|
||
workInProgress2.memoizedState = memoizedState;
|
||
if (workInProgress2.lanes === NoLanes) {
|
||
var updateQueue = workInProgress2.updateQueue;
|
||
updateQueue.baseState = memoizedState;
|
||
}
|
||
}
|
||
var classComponentUpdater = {
|
||
isMounted,
|
||
enqueueSetState: function(inst, payload, callback) {
|
||
var fiber = get(inst);
|
||
var eventTime = requestEventTime();
|
||
var lane = requestUpdateLane(fiber);
|
||
var update = createUpdate(eventTime, lane);
|
||
update.payload = payload;
|
||
if (callback !== void 0 && callback !== null) {
|
||
{
|
||
warnOnInvalidCallback(callback, "setState");
|
||
}
|
||
update.callback = callback;
|
||
}
|
||
var root2 = enqueueUpdate(fiber, update, lane);
|
||
if (root2 !== null) {
|
||
scheduleUpdateOnFiber(root2, fiber, lane, eventTime);
|
||
entangleTransitions(root2, fiber, lane);
|
||
}
|
||
{
|
||
markStateUpdateScheduled(fiber, lane);
|
||
}
|
||
},
|
||
enqueueReplaceState: function(inst, payload, callback) {
|
||
var fiber = get(inst);
|
||
var eventTime = requestEventTime();
|
||
var lane = requestUpdateLane(fiber);
|
||
var update = createUpdate(eventTime, lane);
|
||
update.tag = ReplaceState;
|
||
update.payload = payload;
|
||
if (callback !== void 0 && callback !== null) {
|
||
{
|
||
warnOnInvalidCallback(callback, "replaceState");
|
||
}
|
||
update.callback = callback;
|
||
}
|
||
var root2 = enqueueUpdate(fiber, update, lane);
|
||
if (root2 !== null) {
|
||
scheduleUpdateOnFiber(root2, fiber, lane, eventTime);
|
||
entangleTransitions(root2, fiber, lane);
|
||
}
|
||
{
|
||
markStateUpdateScheduled(fiber, lane);
|
||
}
|
||
},
|
||
enqueueForceUpdate: function(inst, callback) {
|
||
var fiber = get(inst);
|
||
var eventTime = requestEventTime();
|
||
var lane = requestUpdateLane(fiber);
|
||
var update = createUpdate(eventTime, lane);
|
||
update.tag = ForceUpdate;
|
||
if (callback !== void 0 && callback !== null) {
|
||
{
|
||
warnOnInvalidCallback(callback, "forceUpdate");
|
||
}
|
||
update.callback = callback;
|
||
}
|
||
var root2 = enqueueUpdate(fiber, update, lane);
|
||
if (root2 !== null) {
|
||
scheduleUpdateOnFiber(root2, fiber, lane, eventTime);
|
||
entangleTransitions(root2, fiber, lane);
|
||
}
|
||
{
|
||
markForceUpdateScheduled(fiber, lane);
|
||
}
|
||
}
|
||
};
|
||
function checkShouldComponentUpdate(workInProgress2, ctor, oldProps, newProps, oldState, newState, nextContext) {
|
||
var instance = workInProgress2.stateNode;
|
||
if (typeof instance.shouldComponentUpdate === "function") {
|
||
var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
|
||
{
|
||
if (workInProgress2.mode & StrictLegacyMode) {
|
||
setIsStrictModeForDevtools(true);
|
||
try {
|
||
shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
|
||
} finally {
|
||
setIsStrictModeForDevtools(false);
|
||
}
|
||
}
|
||
if (shouldUpdate === void 0) {
|
||
error("%s.shouldComponentUpdate(): Returned undefined instead of a boolean value. Make sure to return true or false.", getComponentNameFromType(ctor) || "Component");
|
||
}
|
||
}
|
||
return shouldUpdate;
|
||
}
|
||
if (ctor.prototype && ctor.prototype.isPureReactComponent) {
|
||
return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
|
||
}
|
||
return true;
|
||
}
|
||
function checkClassInstance(workInProgress2, ctor, newProps) {
|
||
var instance = workInProgress2.stateNode;
|
||
{
|
||
var name = getComponentNameFromType(ctor) || "Component";
|
||
var renderPresent = instance.render;
|
||
if (!renderPresent) {
|
||
if (ctor.prototype && typeof ctor.prototype.render === "function") {
|
||
error("%s(...): No `render` method found on the returned component instance: did you accidentally return an object from the constructor?", name);
|
||
} else {
|
||
error("%s(...): No `render` method found on the returned component instance: you may have forgotten to define `render`.", name);
|
||
}
|
||
}
|
||
if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) {
|
||
error("getInitialState was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Did you mean to define a state property instead?", name);
|
||
}
|
||
if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) {
|
||
error("getDefaultProps was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Use a static property to define defaultProps instead.", name);
|
||
}
|
||
if (instance.propTypes) {
|
||
error("propTypes was defined as an instance property on %s. Use a static property to define propTypes instead.", name);
|
||
}
|
||
if (instance.contextType) {
|
||
error("contextType was defined as an instance property on %s. Use a static property to define contextType instead.", name);
|
||
}
|
||
{
|
||
if (instance.contextTypes) {
|
||
error("contextTypes was defined as an instance property on %s. Use a static property to define contextTypes instead.", name);
|
||
}
|
||
if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
|
||
didWarnAboutContextTypeAndContextTypes.add(ctor);
|
||
error("%s declares both contextTypes and contextType static properties. The legacy contextTypes property will be ignored.", name);
|
||
}
|
||
}
|
||
if (typeof instance.componentShouldUpdate === "function") {
|
||
error("%s has a method called componentShouldUpdate(). Did you mean shouldComponentUpdate()? The name is phrased as a question because the function is expected to return a value.", name);
|
||
}
|
||
if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== "undefined") {
|
||
error("%s has a method called shouldComponentUpdate(). shouldComponentUpdate should not be used when extending React.PureComponent. Please extend React.Component if shouldComponentUpdate is used.", getComponentNameFromType(ctor) || "A pure component");
|
||
}
|
||
if (typeof instance.componentDidUnmount === "function") {
|
||
error("%s has a method called componentDidUnmount(). But there is no such lifecycle method. Did you mean componentWillUnmount()?", name);
|
||
}
|
||
if (typeof instance.componentDidReceiveProps === "function") {
|
||
error("%s has a method called componentDidReceiveProps(). But there is no such lifecycle method. If you meant to update the state in response to changing props, use componentWillReceiveProps(). If you meant to fetch data or run side-effects or mutations after React has updated the UI, use componentDidUpdate().", name);
|
||
}
|
||
if (typeof instance.componentWillRecieveProps === "function") {
|
||
error("%s has a method called componentWillRecieveProps(). Did you mean componentWillReceiveProps()?", name);
|
||
}
|
||
if (typeof instance.UNSAFE_componentWillRecieveProps === "function") {
|
||
error("%s has a method called UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?", name);
|
||
}
|
||
var hasMutatedProps = instance.props !== newProps;
|
||
if (instance.props !== void 0 && hasMutatedProps) {
|
||
error("%s(...): When calling super() in `%s`, make sure to pass up the same props that your component's constructor was passed.", name, name);
|
||
}
|
||
if (instance.defaultProps) {
|
||
error("Setting defaultProps as an instance property on %s is not supported and will be ignored. Instead, define defaultProps as a static property on %s.", name, name);
|
||
}
|
||
if (typeof instance.getSnapshotBeforeUpdate === "function" && typeof instance.componentDidUpdate !== "function" && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
|
||
didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
|
||
error("%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). This component defines getSnapshotBeforeUpdate() only.", getComponentNameFromType(ctor));
|
||
}
|
||
if (typeof instance.getDerivedStateFromProps === "function") {
|
||
error("%s: getDerivedStateFromProps() is defined as an instance method and will be ignored. Instead, declare it as a static method.", name);
|
||
}
|
||
if (typeof instance.getDerivedStateFromError === "function") {
|
||
error("%s: getDerivedStateFromError() is defined as an instance method and will be ignored. Instead, declare it as a static method.", name);
|
||
}
|
||
if (typeof ctor.getSnapshotBeforeUpdate === "function") {
|
||
error("%s: getSnapshotBeforeUpdate() is defined as a static method and will be ignored. Instead, declare it as an instance method.", name);
|
||
}
|
||
var _state = instance.state;
|
||
if (_state && (typeof _state !== "object" || isArray(_state))) {
|
||
error("%s.state: must be set to an object or null", name);
|
||
}
|
||
if (typeof instance.getChildContext === "function" && typeof ctor.childContextTypes !== "object") {
|
||
error("%s.getChildContext(): childContextTypes must be defined in order to use getChildContext().", name);
|
||
}
|
||
}
|
||
}
|
||
function adoptClassInstance(workInProgress2, instance) {
|
||
instance.updater = classComponentUpdater;
|
||
workInProgress2.stateNode = instance;
|
||
set(instance, workInProgress2);
|
||
{
|
||
instance._reactInternalInstance = fakeInternalInstance;
|
||
}
|
||
}
|
||
function constructClassInstance(workInProgress2, ctor, props) {
|
||
var isLegacyContextConsumer = false;
|
||
var unmaskedContext = emptyContextObject;
|
||
var context = emptyContextObject;
|
||
var contextType = ctor.contextType;
|
||
{
|
||
if ("contextType" in ctor) {
|
||
var isValid = contextType === null || contextType !== void 0 && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === void 0;
|
||
if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
|
||
didWarnAboutInvalidateContextType.add(ctor);
|
||
var addendum = "";
|
||
if (contextType === void 0) {
|
||
addendum = " However, it is set to undefined. This can be caused by a typo or by mixing up named and default imports. This can also happen due to a circular dependency, so try moving the createContext() call to a separate file.";
|
||
} else if (typeof contextType !== "object") {
|
||
addendum = " However, it is set to a " + typeof contextType + ".";
|
||
} else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
|
||
addendum = " Did you accidentally pass the Context.Provider instead?";
|
||
} else if (contextType._context !== void 0) {
|
||
addendum = " Did you accidentally pass the Context.Consumer instead?";
|
||
} else {
|
||
addendum = " However, it is set to an object with keys {" + Object.keys(contextType).join(", ") + "}.";
|
||
}
|
||
error("%s defines an invalid contextType. contextType should point to the Context object returned by React.createContext().%s", getComponentNameFromType(ctor) || "Component", addendum);
|
||
}
|
||
}
|
||
}
|
||
if (typeof contextType === "object" && contextType !== null) {
|
||
context = readContext(contextType);
|
||
} else {
|
||
unmaskedContext = getUnmaskedContext(workInProgress2, ctor, true);
|
||
var contextTypes = ctor.contextTypes;
|
||
isLegacyContextConsumer = contextTypes !== null && contextTypes !== void 0;
|
||
context = isLegacyContextConsumer ? getMaskedContext(workInProgress2, unmaskedContext) : emptyContextObject;
|
||
}
|
||
var instance = new ctor(props, context);
|
||
{
|
||
if (workInProgress2.mode & StrictLegacyMode) {
|
||
setIsStrictModeForDevtools(true);
|
||
try {
|
||
instance = new ctor(props, context);
|
||
} finally {
|
||
setIsStrictModeForDevtools(false);
|
||
}
|
||
}
|
||
}
|
||
var state = workInProgress2.memoizedState = instance.state !== null && instance.state !== void 0 ? instance.state : null;
|
||
adoptClassInstance(workInProgress2, instance);
|
||
{
|
||
if (typeof ctor.getDerivedStateFromProps === "function" && state === null) {
|
||
var componentName = getComponentNameFromType(ctor) || "Component";
|
||
if (!didWarnAboutUninitializedState.has(componentName)) {
|
||
didWarnAboutUninitializedState.add(componentName);
|
||
error("`%s` uses `getDerivedStateFromProps` but its initial state is %s. This is not recommended. Instead, define the initial state by assigning an object to `this.state` in the constructor of `%s`. This ensures that `getDerivedStateFromProps` arguments have a consistent shape.", componentName, instance.state === null ? "null" : "undefined", componentName);
|
||
}
|
||
}
|
||
if (typeof ctor.getDerivedStateFromProps === "function" || typeof instance.getSnapshotBeforeUpdate === "function") {
|
||
var foundWillMountName = null;
|
||
var foundWillReceivePropsName = null;
|
||
var foundWillUpdateName = null;
|
||
if (typeof instance.componentWillMount === "function" && instance.componentWillMount.__suppressDeprecationWarning !== true) {
|
||
foundWillMountName = "componentWillMount";
|
||
} else if (typeof instance.UNSAFE_componentWillMount === "function") {
|
||
foundWillMountName = "UNSAFE_componentWillMount";
|
||
}
|
||
if (typeof instance.componentWillReceiveProps === "function" && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
|
||
foundWillReceivePropsName = "componentWillReceiveProps";
|
||
} else if (typeof instance.UNSAFE_componentWillReceiveProps === "function") {
|
||
foundWillReceivePropsName = "UNSAFE_componentWillReceiveProps";
|
||
}
|
||
if (typeof instance.componentWillUpdate === "function" && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
|
||
foundWillUpdateName = "componentWillUpdate";
|
||
} else if (typeof instance.UNSAFE_componentWillUpdate === "function") {
|
||
foundWillUpdateName = "UNSAFE_componentWillUpdate";
|
||
}
|
||
if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
|
||
var _componentName = getComponentNameFromType(ctor) || "Component";
|
||
var newApiName = typeof ctor.getDerivedStateFromProps === "function" ? "getDerivedStateFromProps()" : "getSnapshotBeforeUpdate()";
|
||
if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
|
||
didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
|
||
error("Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\nThe above lifecycles should be removed. Learn more about this warning here:\nhttps://reactjs.org/link/unsafe-component-lifecycles", _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : "", foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : "", foundWillUpdateName !== null ? "\n " + foundWillUpdateName : "");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (isLegacyContextConsumer) {
|
||
cacheContext(workInProgress2, unmaskedContext, context);
|
||
}
|
||
return instance;
|
||
}
|
||
function callComponentWillMount(workInProgress2, instance) {
|
||
var oldState = instance.state;
|
||
if (typeof instance.componentWillMount === "function") {
|
||
instance.componentWillMount();
|
||
}
|
||
if (typeof instance.UNSAFE_componentWillMount === "function") {
|
||
instance.UNSAFE_componentWillMount();
|
||
}
|
||
if (oldState !== instance.state) {
|
||
{
|
||
error("%s.componentWillMount(): Assigning directly to this.state is deprecated (except inside a component's constructor). Use setState instead.", getComponentNameFromFiber(workInProgress2) || "Component");
|
||
}
|
||
classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
|
||
}
|
||
}
|
||
function callComponentWillReceiveProps(workInProgress2, instance, newProps, nextContext) {
|
||
var oldState = instance.state;
|
||
if (typeof instance.componentWillReceiveProps === "function") {
|
||
instance.componentWillReceiveProps(newProps, nextContext);
|
||
}
|
||
if (typeof instance.UNSAFE_componentWillReceiveProps === "function") {
|
||
instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
|
||
}
|
||
if (instance.state !== oldState) {
|
||
{
|
||
var componentName = getComponentNameFromFiber(workInProgress2) || "Component";
|
||
if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
|
||
didWarnAboutStateAssignmentForComponent.add(componentName);
|
||
error("%s.componentWillReceiveProps(): Assigning directly to this.state is deprecated (except inside a component's constructor). Use setState instead.", componentName);
|
||
}
|
||
}
|
||
classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
|
||
}
|
||
}
|
||
function mountClassInstance(workInProgress2, ctor, newProps, renderLanes2) {
|
||
{
|
||
checkClassInstance(workInProgress2, ctor, newProps);
|
||
}
|
||
var instance = workInProgress2.stateNode;
|
||
instance.props = newProps;
|
||
instance.state = workInProgress2.memoizedState;
|
||
instance.refs = emptyRefsObject;
|
||
initializeUpdateQueue(workInProgress2);
|
||
var contextType = ctor.contextType;
|
||
if (typeof contextType === "object" && contextType !== null) {
|
||
instance.context = readContext(contextType);
|
||
} else {
|
||
var unmaskedContext = getUnmaskedContext(workInProgress2, ctor, true);
|
||
instance.context = getMaskedContext(workInProgress2, unmaskedContext);
|
||
}
|
||
{
|
||
if (instance.state === newProps) {
|
||
var componentName = getComponentNameFromType(ctor) || "Component";
|
||
if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
|
||
didWarnAboutDirectlyAssigningPropsToState.add(componentName);
|
||
error("%s: It is not recommended to assign props directly to state because updates to props won't be reflected in state. In most cases, it is better to use props directly.", componentName);
|
||
}
|
||
}
|
||
if (workInProgress2.mode & StrictLegacyMode) {
|
||
ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress2, instance);
|
||
}
|
||
{
|
||
ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress2, instance);
|
||
}
|
||
}
|
||
instance.state = workInProgress2.memoizedState;
|
||
var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
||
if (typeof getDerivedStateFromProps === "function") {
|
||
applyDerivedStateFromProps(workInProgress2, ctor, getDerivedStateFromProps, newProps);
|
||
instance.state = workInProgress2.memoizedState;
|
||
}
|
||
if (typeof ctor.getDerivedStateFromProps !== "function" && typeof instance.getSnapshotBeforeUpdate !== "function" && (typeof instance.UNSAFE_componentWillMount === "function" || typeof instance.componentWillMount === "function")) {
|
||
callComponentWillMount(workInProgress2, instance);
|
||
processUpdateQueue(workInProgress2, newProps, instance, renderLanes2);
|
||
instance.state = workInProgress2.memoizedState;
|
||
}
|
||
if (typeof instance.componentDidMount === "function") {
|
||
var fiberFlags = Update;
|
||
{
|
||
fiberFlags |= LayoutStatic;
|
||
}
|
||
if ((workInProgress2.mode & StrictEffectsMode) !== NoMode) {
|
||
fiberFlags |= MountLayoutDev;
|
||
}
|
||
workInProgress2.flags |= fiberFlags;
|
||
}
|
||
}
|
||
function resumeMountClassInstance(workInProgress2, ctor, newProps, renderLanes2) {
|
||
var instance = workInProgress2.stateNode;
|
||
var oldProps = workInProgress2.memoizedProps;
|
||
instance.props = oldProps;
|
||
var oldContext = instance.context;
|
||
var contextType = ctor.contextType;
|
||
var nextContext = emptyContextObject;
|
||
if (typeof contextType === "object" && contextType !== null) {
|
||
nextContext = readContext(contextType);
|
||
} else {
|
||
var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress2, ctor, true);
|
||
nextContext = getMaskedContext(workInProgress2, nextLegacyUnmaskedContext);
|
||
}
|
||
var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
||
var hasNewLifecycles = typeof getDerivedStateFromProps === "function" || typeof instance.getSnapshotBeforeUpdate === "function";
|
||
if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === "function" || typeof instance.componentWillReceiveProps === "function")) {
|
||
if (oldProps !== newProps || oldContext !== nextContext) {
|
||
callComponentWillReceiveProps(workInProgress2, instance, newProps, nextContext);
|
||
}
|
||
}
|
||
resetHasForceUpdateBeforeProcessing();
|
||
var oldState = workInProgress2.memoizedState;
|
||
var newState = instance.state = oldState;
|
||
processUpdateQueue(workInProgress2, newProps, instance, renderLanes2);
|
||
newState = workInProgress2.memoizedState;
|
||
if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
|
||
if (typeof instance.componentDidMount === "function") {
|
||
var fiberFlags = Update;
|
||
{
|
||
fiberFlags |= LayoutStatic;
|
||
}
|
||
if ((workInProgress2.mode & StrictEffectsMode) !== NoMode) {
|
||
fiberFlags |= MountLayoutDev;
|
||
}
|
||
workInProgress2.flags |= fiberFlags;
|
||
}
|
||
return false;
|
||
}
|
||
if (typeof getDerivedStateFromProps === "function") {
|
||
applyDerivedStateFromProps(workInProgress2, ctor, getDerivedStateFromProps, newProps);
|
||
newState = workInProgress2.memoizedState;
|
||
}
|
||
var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress2, ctor, oldProps, newProps, oldState, newState, nextContext);
|
||
if (shouldUpdate) {
|
||
if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === "function" || typeof instance.componentWillMount === "function")) {
|
||
if (typeof instance.componentWillMount === "function") {
|
||
instance.componentWillMount();
|
||
}
|
||
if (typeof instance.UNSAFE_componentWillMount === "function") {
|
||
instance.UNSAFE_componentWillMount();
|
||
}
|
||
}
|
||
if (typeof instance.componentDidMount === "function") {
|
||
var _fiberFlags = Update;
|
||
{
|
||
_fiberFlags |= LayoutStatic;
|
||
}
|
||
if ((workInProgress2.mode & StrictEffectsMode) !== NoMode) {
|
||
_fiberFlags |= MountLayoutDev;
|
||
}
|
||
workInProgress2.flags |= _fiberFlags;
|
||
}
|
||
} else {
|
||
if (typeof instance.componentDidMount === "function") {
|
||
var _fiberFlags2 = Update;
|
||
{
|
||
_fiberFlags2 |= LayoutStatic;
|
||
}
|
||
if ((workInProgress2.mode & StrictEffectsMode) !== NoMode) {
|
||
_fiberFlags2 |= MountLayoutDev;
|
||
}
|
||
workInProgress2.flags |= _fiberFlags2;
|
||
}
|
||
workInProgress2.memoizedProps = newProps;
|
||
workInProgress2.memoizedState = newState;
|
||
}
|
||
instance.props = newProps;
|
||
instance.state = newState;
|
||
instance.context = nextContext;
|
||
return shouldUpdate;
|
||
}
|
||
function updateClassInstance(current2, workInProgress2, ctor, newProps, renderLanes2) {
|
||
var instance = workInProgress2.stateNode;
|
||
cloneUpdateQueue(current2, workInProgress2);
|
||
var unresolvedOldProps = workInProgress2.memoizedProps;
|
||
var oldProps = workInProgress2.type === workInProgress2.elementType ? unresolvedOldProps : resolveDefaultProps(workInProgress2.type, unresolvedOldProps);
|
||
instance.props = oldProps;
|
||
var unresolvedNewProps = workInProgress2.pendingProps;
|
||
var oldContext = instance.context;
|
||
var contextType = ctor.contextType;
|
||
var nextContext = emptyContextObject;
|
||
if (typeof contextType === "object" && contextType !== null) {
|
||
nextContext = readContext(contextType);
|
||
} else {
|
||
var nextUnmaskedContext = getUnmaskedContext(workInProgress2, ctor, true);
|
||
nextContext = getMaskedContext(workInProgress2, nextUnmaskedContext);
|
||
}
|
||
var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
||
var hasNewLifecycles = typeof getDerivedStateFromProps === "function" || typeof instance.getSnapshotBeforeUpdate === "function";
|
||
if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === "function" || typeof instance.componentWillReceiveProps === "function")) {
|
||
if (unresolvedOldProps !== unresolvedNewProps || oldContext !== nextContext) {
|
||
callComponentWillReceiveProps(workInProgress2, instance, newProps, nextContext);
|
||
}
|
||
}
|
||
resetHasForceUpdateBeforeProcessing();
|
||
var oldState = workInProgress2.memoizedState;
|
||
var newState = instance.state = oldState;
|
||
processUpdateQueue(workInProgress2, newProps, instance, renderLanes2);
|
||
newState = workInProgress2.memoizedState;
|
||
if (unresolvedOldProps === unresolvedNewProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing() && !enableLazyContextPropagation) {
|
||
if (typeof instance.componentDidUpdate === "function") {
|
||
if (unresolvedOldProps !== current2.memoizedProps || oldState !== current2.memoizedState) {
|
||
workInProgress2.flags |= Update;
|
||
}
|
||
}
|
||
if (typeof instance.getSnapshotBeforeUpdate === "function") {
|
||
if (unresolvedOldProps !== current2.memoizedProps || oldState !== current2.memoizedState) {
|
||
workInProgress2.flags |= Snapshot;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
if (typeof getDerivedStateFromProps === "function") {
|
||
applyDerivedStateFromProps(workInProgress2, ctor, getDerivedStateFromProps, newProps);
|
||
newState = workInProgress2.memoizedState;
|
||
}
|
||
var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress2, ctor, oldProps, newProps, oldState, newState, nextContext) || enableLazyContextPropagation;
|
||
if (shouldUpdate) {
|
||
if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === "function" || typeof instance.componentWillUpdate === "function")) {
|
||
if (typeof instance.componentWillUpdate === "function") {
|
||
instance.componentWillUpdate(newProps, newState, nextContext);
|
||
}
|
||
if (typeof instance.UNSAFE_componentWillUpdate === "function") {
|
||
instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
|
||
}
|
||
}
|
||
if (typeof instance.componentDidUpdate === "function") {
|
||
workInProgress2.flags |= Update;
|
||
}
|
||
if (typeof instance.getSnapshotBeforeUpdate === "function") {
|
||
workInProgress2.flags |= Snapshot;
|
||
}
|
||
} else {
|
||
if (typeof instance.componentDidUpdate === "function") {
|
||
if (unresolvedOldProps !== current2.memoizedProps || oldState !== current2.memoizedState) {
|
||
workInProgress2.flags |= Update;
|
||
}
|
||
}
|
||
if (typeof instance.getSnapshotBeforeUpdate === "function") {
|
||
if (unresolvedOldProps !== current2.memoizedProps || oldState !== current2.memoizedState) {
|
||
workInProgress2.flags |= Snapshot;
|
||
}
|
||
}
|
||
workInProgress2.memoizedProps = newProps;
|
||
workInProgress2.memoizedState = newState;
|
||
}
|
||
instance.props = newProps;
|
||
instance.state = newState;
|
||
instance.context = nextContext;
|
||
return shouldUpdate;
|
||
}
|
||
var didWarnAboutMaps;
|
||
var didWarnAboutGenerators;
|
||
var didWarnAboutStringRefs;
|
||
var ownerHasKeyUseWarning;
|
||
var ownerHasFunctionTypeWarning;
|
||
var warnForMissingKey = function(child, returnFiber) {
|
||
};
|
||
{
|
||
didWarnAboutMaps = false;
|
||
didWarnAboutGenerators = false;
|
||
didWarnAboutStringRefs = {};
|
||
ownerHasKeyUseWarning = {};
|
||
ownerHasFunctionTypeWarning = {};
|
||
warnForMissingKey = function(child, returnFiber) {
|
||
if (child === null || typeof child !== "object") {
|
||
return;
|
||
}
|
||
if (!child._store || child._store.validated || child.key != null) {
|
||
return;
|
||
}
|
||
if (typeof child._store !== "object") {
|
||
throw new Error("React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
child._store.validated = true;
|
||
var componentName = getComponentNameFromFiber(returnFiber) || "Component";
|
||
if (ownerHasKeyUseWarning[componentName]) {
|
||
return;
|
||
}
|
||
ownerHasKeyUseWarning[componentName] = true;
|
||
error('Each child in a list should have a unique "key" prop. See https://reactjs.org/link/warning-keys for more information.');
|
||
};
|
||
}
|
||
function coerceRef(returnFiber, current2, element) {
|
||
var mixedRef = element.ref;
|
||
if (mixedRef !== null && typeof mixedRef !== "function" && typeof mixedRef !== "object") {
|
||
{
|
||
if ((returnFiber.mode & StrictLegacyMode || warnAboutStringRefs) && !(element._owner && element._self && element._owner.stateNode !== element._self)) {
|
||
var componentName = getComponentNameFromFiber(returnFiber) || "Component";
|
||
if (!didWarnAboutStringRefs[componentName]) {
|
||
{
|
||
error('A string ref, "%s", has been found within a strict mode tree. String refs are a source of potential bugs and should be avoided. We recommend using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', mixedRef);
|
||
}
|
||
didWarnAboutStringRefs[componentName] = true;
|
||
}
|
||
}
|
||
}
|
||
if (element._owner) {
|
||
var owner = element._owner;
|
||
var inst;
|
||
if (owner) {
|
||
var ownerFiber = owner;
|
||
if (ownerFiber.tag !== ClassComponent) {
|
||
throw new Error("Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref");
|
||
}
|
||
inst = ownerFiber.stateNode;
|
||
}
|
||
if (!inst) {
|
||
throw new Error("Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
var resolvedInst = inst;
|
||
{
|
||
checkPropStringCoercion(mixedRef, "ref");
|
||
}
|
||
var stringRef = "" + mixedRef;
|
||
if (current2 !== null && current2.ref !== null && typeof current2.ref === "function" && current2.ref._stringRef === stringRef) {
|
||
return current2.ref;
|
||
}
|
||
var ref = function(value) {
|
||
var refs = resolvedInst.refs;
|
||
if (refs === emptyRefsObject) {
|
||
refs = resolvedInst.refs = {};
|
||
}
|
||
if (value === null) {
|
||
delete refs[stringRef];
|
||
} else {
|
||
refs[stringRef] = value;
|
||
}
|
||
};
|
||
ref._stringRef = stringRef;
|
||
return ref;
|
||
} else {
|
||
if (typeof mixedRef !== "string") {
|
||
throw new Error("Expected ref to be a function, a string, an object returned by React.createRef(), or null.");
|
||
}
|
||
if (!element._owner) {
|
||
throw new Error("Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information.");
|
||
}
|
||
}
|
||
}
|
||
return mixedRef;
|
||
}
|
||
function throwOnInvalidObjectType(returnFiber, newChild) {
|
||
var childString = Object.prototype.toString.call(newChild);
|
||
throw new Error("Objects are not valid as a React child (found: " + (childString === "[object Object]" ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : childString) + "). If you meant to render a collection of children, use an array instead.");
|
||
}
|
||
function warnOnFunctionType(returnFiber) {
|
||
{
|
||
var componentName = getComponentNameFromFiber(returnFiber) || "Component";
|
||
if (ownerHasFunctionTypeWarning[componentName]) {
|
||
return;
|
||
}
|
||
ownerHasFunctionTypeWarning[componentName] = true;
|
||
error("Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.");
|
||
}
|
||
}
|
||
function resolveLazy(lazyType) {
|
||
var payload = lazyType._payload;
|
||
var init = lazyType._init;
|
||
return init(payload);
|
||
}
|
||
function ChildReconciler(shouldTrackSideEffects) {
|
||
function deleteChild(returnFiber, childToDelete) {
|
||
if (!shouldTrackSideEffects) {
|
||
return;
|
||
}
|
||
var deletions = returnFiber.deletions;
|
||
if (deletions === null) {
|
||
returnFiber.deletions = [childToDelete];
|
||
returnFiber.flags |= ChildDeletion;
|
||
} else {
|
||
deletions.push(childToDelete);
|
||
}
|
||
}
|
||
function deleteRemainingChildren(returnFiber, currentFirstChild) {
|
||
if (!shouldTrackSideEffects) {
|
||
return null;
|
||
}
|
||
var childToDelete = currentFirstChild;
|
||
while (childToDelete !== null) {
|
||
deleteChild(returnFiber, childToDelete);
|
||
childToDelete = childToDelete.sibling;
|
||
}
|
||
return null;
|
||
}
|
||
function mapRemainingChildren(returnFiber, currentFirstChild) {
|
||
var existingChildren = /* @__PURE__ */ new Map();
|
||
var existingChild = currentFirstChild;
|
||
while (existingChild !== null) {
|
||
if (existingChild.key !== null) {
|
||
existingChildren.set(existingChild.key, existingChild);
|
||
} else {
|
||
existingChildren.set(existingChild.index, existingChild);
|
||
}
|
||
existingChild = existingChild.sibling;
|
||
}
|
||
return existingChildren;
|
||
}
|
||
function useFiber(fiber, pendingProps) {
|
||
var clone = createWorkInProgress(fiber, pendingProps);
|
||
clone.index = 0;
|
||
clone.sibling = null;
|
||
return clone;
|
||
}
|
||
function placeChild(newFiber, lastPlacedIndex, newIndex) {
|
||
newFiber.index = newIndex;
|
||
if (!shouldTrackSideEffects) {
|
||
newFiber.flags |= Forked;
|
||
return lastPlacedIndex;
|
||
}
|
||
var current2 = newFiber.alternate;
|
||
if (current2 !== null) {
|
||
var oldIndex = current2.index;
|
||
if (oldIndex < lastPlacedIndex) {
|
||
newFiber.flags |= Placement;
|
||
return lastPlacedIndex;
|
||
} else {
|
||
return oldIndex;
|
||
}
|
||
} else {
|
||
newFiber.flags |= Placement;
|
||
return lastPlacedIndex;
|
||
}
|
||
}
|
||
function placeSingleChild(newFiber) {
|
||
if (shouldTrackSideEffects && newFiber.alternate === null) {
|
||
newFiber.flags |= Placement;
|
||
}
|
||
return newFiber;
|
||
}
|
||
function updateTextNode(returnFiber, current2, textContent, lanes) {
|
||
if (current2 === null || current2.tag !== HostText) {
|
||
var created = createFiberFromText(textContent, returnFiber.mode, lanes);
|
||
created.return = returnFiber;
|
||
return created;
|
||
} else {
|
||
var existing = useFiber(current2, textContent);
|
||
existing.return = returnFiber;
|
||
return existing;
|
||
}
|
||
}
|
||
function updateElement(returnFiber, current2, element, lanes) {
|
||
var elementType = element.type;
|
||
if (elementType === REACT_FRAGMENT_TYPE) {
|
||
return updateFragment2(returnFiber, current2, element.props.children, lanes, element.key);
|
||
}
|
||
if (current2 !== null) {
|
||
if (current2.elementType === elementType || isCompatibleFamilyForHotReloading(current2, element) || typeof elementType === "object" && elementType !== null && elementType.$$typeof === REACT_LAZY_TYPE && resolveLazy(elementType) === current2.type) {
|
||
var existing = useFiber(current2, element.props);
|
||
existing.ref = coerceRef(returnFiber, current2, element);
|
||
existing.return = returnFiber;
|
||
{
|
||
existing._debugSource = element._source;
|
||
existing._debugOwner = element._owner;
|
||
}
|
||
return existing;
|
||
}
|
||
}
|
||
var created = createFiberFromElement(element, returnFiber.mode, lanes);
|
||
created.ref = coerceRef(returnFiber, current2, element);
|
||
created.return = returnFiber;
|
||
return created;
|
||
}
|
||
function updatePortal(returnFiber, current2, portal, lanes) {
|
||
if (current2 === null || current2.tag !== HostPortal || current2.stateNode.containerInfo !== portal.containerInfo || current2.stateNode.implementation !== portal.implementation) {
|
||
var created = createFiberFromPortal(portal, returnFiber.mode, lanes);
|
||
created.return = returnFiber;
|
||
return created;
|
||
} else {
|
||
var existing = useFiber(current2, portal.children || []);
|
||
existing.return = returnFiber;
|
||
return existing;
|
||
}
|
||
}
|
||
function updateFragment2(returnFiber, current2, fragment, lanes, key) {
|
||
if (current2 === null || current2.tag !== Fragment) {
|
||
var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);
|
||
created.return = returnFiber;
|
||
return created;
|
||
} else {
|
||
var existing = useFiber(current2, fragment);
|
||
existing.return = returnFiber;
|
||
return existing;
|
||
}
|
||
}
|
||
function createChild(returnFiber, newChild, lanes) {
|
||
if (typeof newChild === "string" && newChild !== "" || typeof newChild === "number") {
|
||
var created = createFiberFromText("" + newChild, returnFiber.mode, lanes);
|
||
created.return = returnFiber;
|
||
return created;
|
||
}
|
||
if (typeof newChild === "object" && newChild !== null) {
|
||
switch (newChild.$$typeof) {
|
||
case REACT_ELEMENT_TYPE: {
|
||
var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);
|
||
_created.ref = coerceRef(returnFiber, null, newChild);
|
||
_created.return = returnFiber;
|
||
return _created;
|
||
}
|
||
case REACT_PORTAL_TYPE: {
|
||
var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);
|
||
_created2.return = returnFiber;
|
||
return _created2;
|
||
}
|
||
case REACT_LAZY_TYPE: {
|
||
var payload = newChild._payload;
|
||
var init = newChild._init;
|
||
return createChild(returnFiber, init(payload), lanes);
|
||
}
|
||
}
|
||
if (isArray(newChild) || getIteratorFn(newChild)) {
|
||
var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);
|
||
_created3.return = returnFiber;
|
||
return _created3;
|
||
}
|
||
throwOnInvalidObjectType(returnFiber, newChild);
|
||
}
|
||
{
|
||
if (typeof newChild === "function") {
|
||
warnOnFunctionType(returnFiber);
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
function updateSlot(returnFiber, oldFiber, newChild, lanes) {
|
||
var key = oldFiber !== null ? oldFiber.key : null;
|
||
if (typeof newChild === "string" && newChild !== "" || typeof newChild === "number") {
|
||
if (key !== null) {
|
||
return null;
|
||
}
|
||
return updateTextNode(returnFiber, oldFiber, "" + newChild, lanes);
|
||
}
|
||
if (typeof newChild === "object" && newChild !== null) {
|
||
switch (newChild.$$typeof) {
|
||
case REACT_ELEMENT_TYPE: {
|
||
if (newChild.key === key) {
|
||
return updateElement(returnFiber, oldFiber, newChild, lanes);
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
case REACT_PORTAL_TYPE: {
|
||
if (newChild.key === key) {
|
||
return updatePortal(returnFiber, oldFiber, newChild, lanes);
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
case REACT_LAZY_TYPE: {
|
||
var payload = newChild._payload;
|
||
var init = newChild._init;
|
||
return updateSlot(returnFiber, oldFiber, init(payload), lanes);
|
||
}
|
||
}
|
||
if (isArray(newChild) || getIteratorFn(newChild)) {
|
||
if (key !== null) {
|
||
return null;
|
||
}
|
||
return updateFragment2(returnFiber, oldFiber, newChild, lanes, null);
|
||
}
|
||
throwOnInvalidObjectType(returnFiber, newChild);
|
||
}
|
||
{
|
||
if (typeof newChild === "function") {
|
||
warnOnFunctionType(returnFiber);
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {
|
||
if (typeof newChild === "string" && newChild !== "" || typeof newChild === "number") {
|
||
var matchedFiber = existingChildren.get(newIdx) || null;
|
||
return updateTextNode(returnFiber, matchedFiber, "" + newChild, lanes);
|
||
}
|
||
if (typeof newChild === "object" && newChild !== null) {
|
||
switch (newChild.$$typeof) {
|
||
case REACT_ELEMENT_TYPE: {
|
||
var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
|
||
return updateElement(returnFiber, _matchedFiber, newChild, lanes);
|
||
}
|
||
case REACT_PORTAL_TYPE: {
|
||
var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
|
||
return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);
|
||
}
|
||
case REACT_LAZY_TYPE:
|
||
var payload = newChild._payload;
|
||
var init = newChild._init;
|
||
return updateFromMap(existingChildren, returnFiber, newIdx, init(payload), lanes);
|
||
}
|
||
if (isArray(newChild) || getIteratorFn(newChild)) {
|
||
var _matchedFiber3 = existingChildren.get(newIdx) || null;
|
||
return updateFragment2(returnFiber, _matchedFiber3, newChild, lanes, null);
|
||
}
|
||
throwOnInvalidObjectType(returnFiber, newChild);
|
||
}
|
||
{
|
||
if (typeof newChild === "function") {
|
||
warnOnFunctionType(returnFiber);
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
function warnOnInvalidKey(child, knownKeys, returnFiber) {
|
||
{
|
||
if (typeof child !== "object" || child === null) {
|
||
return knownKeys;
|
||
}
|
||
switch (child.$$typeof) {
|
||
case REACT_ELEMENT_TYPE:
|
||
case REACT_PORTAL_TYPE:
|
||
warnForMissingKey(child, returnFiber);
|
||
var key = child.key;
|
||
if (typeof key !== "string") {
|
||
break;
|
||
}
|
||
if (knownKeys === null) {
|
||
knownKeys = /* @__PURE__ */ new Set();
|
||
knownKeys.add(key);
|
||
break;
|
||
}
|
||
if (!knownKeys.has(key)) {
|
||
knownKeys.add(key);
|
||
break;
|
||
}
|
||
error("Encountered two children with the same key, `%s`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted \u2014 the behavior is unsupported and could change in a future version.", key);
|
||
break;
|
||
case REACT_LAZY_TYPE:
|
||
var payload = child._payload;
|
||
var init = child._init;
|
||
warnOnInvalidKey(init(payload), knownKeys, returnFiber);
|
||
break;
|
||
}
|
||
}
|
||
return knownKeys;
|
||
}
|
||
function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {
|
||
{
|
||
var knownKeys = null;
|
||
for (var i = 0; i < newChildren.length; i++) {
|
||
var child = newChildren[i];
|
||
knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);
|
||
}
|
||
}
|
||
var resultingFirstChild = null;
|
||
var previousNewFiber = null;
|
||
var oldFiber = currentFirstChild;
|
||
var lastPlacedIndex = 0;
|
||
var newIdx = 0;
|
||
var nextOldFiber = null;
|
||
for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
|
||
if (oldFiber.index > newIdx) {
|
||
nextOldFiber = oldFiber;
|
||
oldFiber = null;
|
||
} else {
|
||
nextOldFiber = oldFiber.sibling;
|
||
}
|
||
var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);
|
||
if (newFiber === null) {
|
||
if (oldFiber === null) {
|
||
oldFiber = nextOldFiber;
|
||
}
|
||
break;
|
||
}
|
||
if (shouldTrackSideEffects) {
|
||
if (oldFiber && newFiber.alternate === null) {
|
||
deleteChild(returnFiber, oldFiber);
|
||
}
|
||
}
|
||
lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
|
||
if (previousNewFiber === null) {
|
||
resultingFirstChild = newFiber;
|
||
} else {
|
||
previousNewFiber.sibling = newFiber;
|
||
}
|
||
previousNewFiber = newFiber;
|
||
oldFiber = nextOldFiber;
|
||
}
|
||
if (newIdx === newChildren.length) {
|
||
deleteRemainingChildren(returnFiber, oldFiber);
|
||
if (getIsHydrating()) {
|
||
var numberOfForks = newIdx;
|
||
pushTreeFork(returnFiber, numberOfForks);
|
||
}
|
||
return resultingFirstChild;
|
||
}
|
||
if (oldFiber === null) {
|
||
for (; newIdx < newChildren.length; newIdx++) {
|
||
var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);
|
||
if (_newFiber === null) {
|
||
continue;
|
||
}
|
||
lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
|
||
if (previousNewFiber === null) {
|
||
resultingFirstChild = _newFiber;
|
||
} else {
|
||
previousNewFiber.sibling = _newFiber;
|
||
}
|
||
previousNewFiber = _newFiber;
|
||
}
|
||
if (getIsHydrating()) {
|
||
var _numberOfForks = newIdx;
|
||
pushTreeFork(returnFiber, _numberOfForks);
|
||
}
|
||
return resultingFirstChild;
|
||
}
|
||
var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
|
||
for (; newIdx < newChildren.length; newIdx++) {
|
||
var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);
|
||
if (_newFiber2 !== null) {
|
||
if (shouldTrackSideEffects) {
|
||
if (_newFiber2.alternate !== null) {
|
||
existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
|
||
}
|
||
}
|
||
lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
|
||
if (previousNewFiber === null) {
|
||
resultingFirstChild = _newFiber2;
|
||
} else {
|
||
previousNewFiber.sibling = _newFiber2;
|
||
}
|
||
previousNewFiber = _newFiber2;
|
||
}
|
||
}
|
||
if (shouldTrackSideEffects) {
|
||
existingChildren.forEach(function(child2) {
|
||
return deleteChild(returnFiber, child2);
|
||
});
|
||
}
|
||
if (getIsHydrating()) {
|
||
var _numberOfForks2 = newIdx;
|
||
pushTreeFork(returnFiber, _numberOfForks2);
|
||
}
|
||
return resultingFirstChild;
|
||
}
|
||
function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {
|
||
var iteratorFn = getIteratorFn(newChildrenIterable);
|
||
if (typeof iteratorFn !== "function") {
|
||
throw new Error("An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
{
|
||
if (typeof Symbol === "function" && newChildrenIterable[Symbol.toStringTag] === "Generator") {
|
||
if (!didWarnAboutGenerators) {
|
||
error("Using Generators as children is unsupported and will likely yield unexpected results because enumerating a generator mutates it. You may convert it to an array with `Array.from()` or the `[...spread]` operator before rendering. Keep in mind you might need to polyfill these features for older browsers.");
|
||
}
|
||
didWarnAboutGenerators = true;
|
||
}
|
||
if (newChildrenIterable.entries === iteratorFn) {
|
||
if (!didWarnAboutMaps) {
|
||
error("Using Maps as children is not supported. Use an array of keyed ReactElements instead.");
|
||
}
|
||
didWarnAboutMaps = true;
|
||
}
|
||
var _newChildren = iteratorFn.call(newChildrenIterable);
|
||
if (_newChildren) {
|
||
var knownKeys = null;
|
||
var _step = _newChildren.next();
|
||
for (; !_step.done; _step = _newChildren.next()) {
|
||
var child = _step.value;
|
||
knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);
|
||
}
|
||
}
|
||
}
|
||
var newChildren = iteratorFn.call(newChildrenIterable);
|
||
if (newChildren == null) {
|
||
throw new Error("An iterable object provided no iterator.");
|
||
}
|
||
var resultingFirstChild = null;
|
||
var previousNewFiber = null;
|
||
var oldFiber = currentFirstChild;
|
||
var lastPlacedIndex = 0;
|
||
var newIdx = 0;
|
||
var nextOldFiber = null;
|
||
var step = newChildren.next();
|
||
for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
|
||
if (oldFiber.index > newIdx) {
|
||
nextOldFiber = oldFiber;
|
||
oldFiber = null;
|
||
} else {
|
||
nextOldFiber = oldFiber.sibling;
|
||
}
|
||
var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);
|
||
if (newFiber === null) {
|
||
if (oldFiber === null) {
|
||
oldFiber = nextOldFiber;
|
||
}
|
||
break;
|
||
}
|
||
if (shouldTrackSideEffects) {
|
||
if (oldFiber && newFiber.alternate === null) {
|
||
deleteChild(returnFiber, oldFiber);
|
||
}
|
||
}
|
||
lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
|
||
if (previousNewFiber === null) {
|
||
resultingFirstChild = newFiber;
|
||
} else {
|
||
previousNewFiber.sibling = newFiber;
|
||
}
|
||
previousNewFiber = newFiber;
|
||
oldFiber = nextOldFiber;
|
||
}
|
||
if (step.done) {
|
||
deleteRemainingChildren(returnFiber, oldFiber);
|
||
if (getIsHydrating()) {
|
||
var numberOfForks = newIdx;
|
||
pushTreeFork(returnFiber, numberOfForks);
|
||
}
|
||
return resultingFirstChild;
|
||
}
|
||
if (oldFiber === null) {
|
||
for (; !step.done; newIdx++, step = newChildren.next()) {
|
||
var _newFiber3 = createChild(returnFiber, step.value, lanes);
|
||
if (_newFiber3 === null) {
|
||
continue;
|
||
}
|
||
lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
|
||
if (previousNewFiber === null) {
|
||
resultingFirstChild = _newFiber3;
|
||
} else {
|
||
previousNewFiber.sibling = _newFiber3;
|
||
}
|
||
previousNewFiber = _newFiber3;
|
||
}
|
||
if (getIsHydrating()) {
|
||
var _numberOfForks3 = newIdx;
|
||
pushTreeFork(returnFiber, _numberOfForks3);
|
||
}
|
||
return resultingFirstChild;
|
||
}
|
||
var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
|
||
for (; !step.done; newIdx++, step = newChildren.next()) {
|
||
var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);
|
||
if (_newFiber4 !== null) {
|
||
if (shouldTrackSideEffects) {
|
||
if (_newFiber4.alternate !== null) {
|
||
existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
|
||
}
|
||
}
|
||
lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
|
||
if (previousNewFiber === null) {
|
||
resultingFirstChild = _newFiber4;
|
||
} else {
|
||
previousNewFiber.sibling = _newFiber4;
|
||
}
|
||
previousNewFiber = _newFiber4;
|
||
}
|
||
}
|
||
if (shouldTrackSideEffects) {
|
||
existingChildren.forEach(function(child2) {
|
||
return deleteChild(returnFiber, child2);
|
||
});
|
||
}
|
||
if (getIsHydrating()) {
|
||
var _numberOfForks4 = newIdx;
|
||
pushTreeFork(returnFiber, _numberOfForks4);
|
||
}
|
||
return resultingFirstChild;
|
||
}
|
||
function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {
|
||
if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
|
||
deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
|
||
var existing = useFiber(currentFirstChild, textContent);
|
||
existing.return = returnFiber;
|
||
return existing;
|
||
}
|
||
deleteRemainingChildren(returnFiber, currentFirstChild);
|
||
var created = createFiberFromText(textContent, returnFiber.mode, lanes);
|
||
created.return = returnFiber;
|
||
return created;
|
||
}
|
||
function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {
|
||
var key = element.key;
|
||
var child = currentFirstChild;
|
||
while (child !== null) {
|
||
if (child.key === key) {
|
||
var elementType = element.type;
|
||
if (elementType === REACT_FRAGMENT_TYPE) {
|
||
if (child.tag === Fragment) {
|
||
deleteRemainingChildren(returnFiber, child.sibling);
|
||
var existing = useFiber(child, element.props.children);
|
||
existing.return = returnFiber;
|
||
{
|
||
existing._debugSource = element._source;
|
||
existing._debugOwner = element._owner;
|
||
}
|
||
return existing;
|
||
}
|
||
} else {
|
||
if (child.elementType === elementType || isCompatibleFamilyForHotReloading(child, element) || typeof elementType === "object" && elementType !== null && elementType.$$typeof === REACT_LAZY_TYPE && resolveLazy(elementType) === child.type) {
|
||
deleteRemainingChildren(returnFiber, child.sibling);
|
||
var _existing = useFiber(child, element.props);
|
||
_existing.ref = coerceRef(returnFiber, child, element);
|
||
_existing.return = returnFiber;
|
||
{
|
||
_existing._debugSource = element._source;
|
||
_existing._debugOwner = element._owner;
|
||
}
|
||
return _existing;
|
||
}
|
||
}
|
||
deleteRemainingChildren(returnFiber, child);
|
||
break;
|
||
} else {
|
||
deleteChild(returnFiber, child);
|
||
}
|
||
child = child.sibling;
|
||
}
|
||
if (element.type === REACT_FRAGMENT_TYPE) {
|
||
var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);
|
||
created.return = returnFiber;
|
||
return created;
|
||
} else {
|
||
var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);
|
||
_created4.ref = coerceRef(returnFiber, currentFirstChild, element);
|
||
_created4.return = returnFiber;
|
||
return _created4;
|
||
}
|
||
}
|
||
function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {
|
||
var key = portal.key;
|
||
var child = currentFirstChild;
|
||
while (child !== null) {
|
||
if (child.key === key) {
|
||
if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
|
||
deleteRemainingChildren(returnFiber, child.sibling);
|
||
var existing = useFiber(child, portal.children || []);
|
||
existing.return = returnFiber;
|
||
return existing;
|
||
} else {
|
||
deleteRemainingChildren(returnFiber, child);
|
||
break;
|
||
}
|
||
} else {
|
||
deleteChild(returnFiber, child);
|
||
}
|
||
child = child.sibling;
|
||
}
|
||
var created = createFiberFromPortal(portal, returnFiber.mode, lanes);
|
||
created.return = returnFiber;
|
||
return created;
|
||
}
|
||
function reconcileChildFibers2(returnFiber, currentFirstChild, newChild, lanes) {
|
||
var isUnkeyedTopLevelFragment = typeof newChild === "object" && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
|
||
if (isUnkeyedTopLevelFragment) {
|
||
newChild = newChild.props.children;
|
||
}
|
||
if (typeof newChild === "object" && newChild !== null) {
|
||
switch (newChild.$$typeof) {
|
||
case REACT_ELEMENT_TYPE:
|
||
return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));
|
||
case REACT_PORTAL_TYPE:
|
||
return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));
|
||
case REACT_LAZY_TYPE:
|
||
var payload = newChild._payload;
|
||
var init = newChild._init;
|
||
return reconcileChildFibers2(returnFiber, currentFirstChild, init(payload), lanes);
|
||
}
|
||
if (isArray(newChild)) {
|
||
return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);
|
||
}
|
||
if (getIteratorFn(newChild)) {
|
||
return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);
|
||
}
|
||
throwOnInvalidObjectType(returnFiber, newChild);
|
||
}
|
||
if (typeof newChild === "string" && newChild !== "" || typeof newChild === "number") {
|
||
return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, "" + newChild, lanes));
|
||
}
|
||
{
|
||
if (typeof newChild === "function") {
|
||
warnOnFunctionType(returnFiber);
|
||
}
|
||
}
|
||
return deleteRemainingChildren(returnFiber, currentFirstChild);
|
||
}
|
||
return reconcileChildFibers2;
|
||
}
|
||
var reconcileChildFibers = ChildReconciler(true);
|
||
var mountChildFibers = ChildReconciler(false);
|
||
function cloneChildFibers(current2, workInProgress2) {
|
||
if (current2 !== null && workInProgress2.child !== current2.child) {
|
||
throw new Error("Resuming work not yet implemented.");
|
||
}
|
||
if (workInProgress2.child === null) {
|
||
return;
|
||
}
|
||
var currentChild = workInProgress2.child;
|
||
var newChild = createWorkInProgress(currentChild, currentChild.pendingProps);
|
||
workInProgress2.child = newChild;
|
||
newChild.return = workInProgress2;
|
||
while (currentChild.sibling !== null) {
|
||
currentChild = currentChild.sibling;
|
||
newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps);
|
||
newChild.return = workInProgress2;
|
||
}
|
||
newChild.sibling = null;
|
||
}
|
||
function resetChildFibers(workInProgress2, lanes) {
|
||
var child = workInProgress2.child;
|
||
while (child !== null) {
|
||
resetWorkInProgress(child, lanes);
|
||
child = child.sibling;
|
||
}
|
||
}
|
||
var NO_CONTEXT = {};
|
||
var contextStackCursor$1 = createCursor(NO_CONTEXT);
|
||
var contextFiberStackCursor = createCursor(NO_CONTEXT);
|
||
var rootInstanceStackCursor = createCursor(NO_CONTEXT);
|
||
function requiredContext(c) {
|
||
if (c === NO_CONTEXT) {
|
||
throw new Error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
return c;
|
||
}
|
||
function getRootHostContainer() {
|
||
var rootInstance = requiredContext(rootInstanceStackCursor.current);
|
||
return rootInstance;
|
||
}
|
||
function pushHostContainer(fiber, nextRootInstance) {
|
||
push(rootInstanceStackCursor, nextRootInstance, fiber);
|
||
push(contextFiberStackCursor, fiber, fiber);
|
||
push(contextStackCursor$1, NO_CONTEXT, fiber);
|
||
var nextRootContext = getRootHostContext(nextRootInstance);
|
||
pop(contextStackCursor$1, fiber);
|
||
push(contextStackCursor$1, nextRootContext, fiber);
|
||
}
|
||
function popHostContainer(fiber) {
|
||
pop(contextStackCursor$1, fiber);
|
||
pop(contextFiberStackCursor, fiber);
|
||
pop(rootInstanceStackCursor, fiber);
|
||
}
|
||
function getHostContext() {
|
||
var context = requiredContext(contextStackCursor$1.current);
|
||
return context;
|
||
}
|
||
function pushHostContext(fiber) {
|
||
var rootInstance = requiredContext(rootInstanceStackCursor.current);
|
||
var context = requiredContext(contextStackCursor$1.current);
|
||
var nextContext = getChildHostContext(context, fiber.type);
|
||
if (context === nextContext) {
|
||
return;
|
||
}
|
||
push(contextFiberStackCursor, fiber, fiber);
|
||
push(contextStackCursor$1, nextContext, fiber);
|
||
}
|
||
function popHostContext(fiber) {
|
||
if (contextFiberStackCursor.current !== fiber) {
|
||
return;
|
||
}
|
||
pop(contextStackCursor$1, fiber);
|
||
pop(contextFiberStackCursor, fiber);
|
||
}
|
||
var DefaultSuspenseContext = 0;
|
||
var SubtreeSuspenseContextMask = 1;
|
||
var InvisibleParentSuspenseContext = 1;
|
||
var ForceSuspenseFallback = 2;
|
||
var suspenseStackCursor = createCursor(DefaultSuspenseContext);
|
||
function hasSuspenseContext(parentContext, flag) {
|
||
return (parentContext & flag) !== 0;
|
||
}
|
||
function setDefaultShallowSuspenseContext(parentContext) {
|
||
return parentContext & SubtreeSuspenseContextMask;
|
||
}
|
||
function setShallowSuspenseContext(parentContext, shallowContext) {
|
||
return parentContext & SubtreeSuspenseContextMask | shallowContext;
|
||
}
|
||
function addSubtreeSuspenseContext(parentContext, subtreeContext) {
|
||
return parentContext | subtreeContext;
|
||
}
|
||
function pushSuspenseContext(fiber, newContext) {
|
||
push(suspenseStackCursor, newContext, fiber);
|
||
}
|
||
function popSuspenseContext(fiber) {
|
||
pop(suspenseStackCursor, fiber);
|
||
}
|
||
function shouldCaptureSuspense(workInProgress2, hasInvisibleParent) {
|
||
var nextState = workInProgress2.memoizedState;
|
||
if (nextState !== null) {
|
||
if (nextState.dehydrated !== null) {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
var props = workInProgress2.memoizedProps;
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
function findFirstSuspended(row) {
|
||
var node = row;
|
||
while (node !== null) {
|
||
if (node.tag === SuspenseComponent) {
|
||
var state = node.memoizedState;
|
||
if (state !== null) {
|
||
var dehydrated = state.dehydrated;
|
||
if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) {
|
||
return node;
|
||
}
|
||
}
|
||
} else if (node.tag === SuspenseListComponent && node.memoizedProps.revealOrder !== void 0) {
|
||
var didSuspend = (node.flags & DidCapture) !== NoFlags;
|
||
if (didSuspend) {
|
||
return node;
|
||
}
|
||
} else if (node.child !== null) {
|
||
node.child.return = node;
|
||
node = node.child;
|
||
continue;
|
||
}
|
||
if (node === row) {
|
||
return null;
|
||
}
|
||
while (node.sibling === null) {
|
||
if (node.return === null || node.return === row) {
|
||
return null;
|
||
}
|
||
node = node.return;
|
||
}
|
||
node.sibling.return = node.return;
|
||
node = node.sibling;
|
||
}
|
||
return null;
|
||
}
|
||
var NoFlags$1 = 0;
|
||
var HasEffect = 1;
|
||
var Insertion = 2;
|
||
var Layout = 4;
|
||
var Passive$1 = 8;
|
||
var workInProgressSources = [];
|
||
function resetWorkInProgressVersions() {
|
||
for (var i = 0; i < workInProgressSources.length; i++) {
|
||
var mutableSource = workInProgressSources[i];
|
||
{
|
||
mutableSource._workInProgressVersionPrimary = null;
|
||
}
|
||
}
|
||
workInProgressSources.length = 0;
|
||
}
|
||
function registerMutableSourceForHydration(root2, mutableSource) {
|
||
var getVersion = mutableSource._getVersion;
|
||
var version = getVersion(mutableSource._source);
|
||
if (root2.mutableSourceEagerHydrationData == null) {
|
||
root2.mutableSourceEagerHydrationData = [mutableSource, version];
|
||
} else {
|
||
root2.mutableSourceEagerHydrationData.push(mutableSource, version);
|
||
}
|
||
}
|
||
var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$2 = ReactSharedInternals.ReactCurrentBatchConfig;
|
||
var didWarnAboutMismatchedHooksForComponent;
|
||
var didWarnUncachedGetSnapshot;
|
||
{
|
||
didWarnAboutMismatchedHooksForComponent = /* @__PURE__ */ new Set();
|
||
}
|
||
var renderLanes = NoLanes;
|
||
var currentlyRenderingFiber$1 = null;
|
||
var currentHook = null;
|
||
var workInProgressHook = null;
|
||
var didScheduleRenderPhaseUpdate = false;
|
||
var didScheduleRenderPhaseUpdateDuringThisPass = false;
|
||
var localIdCounter = 0;
|
||
var globalClientIdCounter = 0;
|
||
var RE_RENDER_LIMIT = 25;
|
||
var currentHookNameInDev = null;
|
||
var hookTypesDev = null;
|
||
var hookTypesUpdateIndexDev = -1;
|
||
var ignorePreviousDependencies = false;
|
||
function mountHookTypesDev() {
|
||
{
|
||
var hookName = currentHookNameInDev;
|
||
if (hookTypesDev === null) {
|
||
hookTypesDev = [hookName];
|
||
} else {
|
||
hookTypesDev.push(hookName);
|
||
}
|
||
}
|
||
}
|
||
function updateHookTypesDev() {
|
||
{
|
||
var hookName = currentHookNameInDev;
|
||
if (hookTypesDev !== null) {
|
||
hookTypesUpdateIndexDev++;
|
||
if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
|
||
warnOnHookMismatchInDev(hookName);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function checkDepsAreArrayDev(deps) {
|
||
{
|
||
if (deps !== void 0 && deps !== null && !isArray(deps)) {
|
||
error("%s received a final argument that is not an array (instead, received `%s`). When specified, the final argument must be an array.", currentHookNameInDev, typeof deps);
|
||
}
|
||
}
|
||
}
|
||
function warnOnHookMismatchInDev(currentHookName) {
|
||
{
|
||
var componentName = getComponentNameFromFiber(currentlyRenderingFiber$1);
|
||
if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
|
||
didWarnAboutMismatchedHooksForComponent.add(componentName);
|
||
if (hookTypesDev !== null) {
|
||
var table = "";
|
||
var secondColumnStart = 30;
|
||
for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
|
||
var oldHookName = hookTypesDev[i];
|
||
var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
|
||
var row = i + 1 + ". " + oldHookName;
|
||
while (row.length < secondColumnStart) {
|
||
row += " ";
|
||
}
|
||
row += newHookName + "\n";
|
||
table += row;
|
||
}
|
||
error("React has detected a change in the order of Hooks called by %s. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks\n\n Previous render Next render\n ------------------------------------------------------\n%s ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", componentName, table);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function throwInvalidHookError() {
|
||
throw new Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.");
|
||
}
|
||
function areHookInputsEqual(nextDeps, prevDeps) {
|
||
{
|
||
if (ignorePreviousDependencies) {
|
||
return false;
|
||
}
|
||
}
|
||
if (prevDeps === null) {
|
||
{
|
||
error("%s received a final argument during this render, but not during the previous render. Even though the final argument is optional, its type cannot change between renders.", currentHookNameInDev);
|
||
}
|
||
return false;
|
||
}
|
||
{
|
||
if (nextDeps.length !== prevDeps.length) {
|
||
error("The final argument passed to %s changed size between renders. The order and size of this array must remain constant.\n\nPrevious: %s\nIncoming: %s", currentHookNameInDev, "[" + prevDeps.join(", ") + "]", "[" + nextDeps.join(", ") + "]");
|
||
}
|
||
}
|
||
for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
|
||
if (objectIs(nextDeps[i], prevDeps[i])) {
|
||
continue;
|
||
}
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
function renderWithHooks(current2, workInProgress2, Component, props, secondArg, nextRenderLanes) {
|
||
renderLanes = nextRenderLanes;
|
||
currentlyRenderingFiber$1 = workInProgress2;
|
||
{
|
||
hookTypesDev = current2 !== null ? current2._debugHookTypes : null;
|
||
hookTypesUpdateIndexDev = -1;
|
||
ignorePreviousDependencies = current2 !== null && current2.type !== workInProgress2.type;
|
||
}
|
||
workInProgress2.memoizedState = null;
|
||
workInProgress2.updateQueue = null;
|
||
workInProgress2.lanes = NoLanes;
|
||
{
|
||
if (current2 !== null && current2.memoizedState !== null) {
|
||
ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
|
||
} else if (hookTypesDev !== null) {
|
||
ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
|
||
} else {
|
||
ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
|
||
}
|
||
}
|
||
var children = Component(props, secondArg);
|
||
if (didScheduleRenderPhaseUpdateDuringThisPass) {
|
||
var numberOfReRenders = 0;
|
||
do {
|
||
didScheduleRenderPhaseUpdateDuringThisPass = false;
|
||
localIdCounter = 0;
|
||
if (numberOfReRenders >= RE_RENDER_LIMIT) {
|
||
throw new Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");
|
||
}
|
||
numberOfReRenders += 1;
|
||
{
|
||
ignorePreviousDependencies = false;
|
||
}
|
||
currentHook = null;
|
||
workInProgressHook = null;
|
||
workInProgress2.updateQueue = null;
|
||
{
|
||
hookTypesUpdateIndexDev = -1;
|
||
}
|
||
ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV;
|
||
children = Component(props, secondArg);
|
||
} while (didScheduleRenderPhaseUpdateDuringThisPass);
|
||
}
|
||
ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
|
||
{
|
||
workInProgress2._debugHookTypes = hookTypesDev;
|
||
}
|
||
var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
|
||
renderLanes = NoLanes;
|
||
currentlyRenderingFiber$1 = null;
|
||
currentHook = null;
|
||
workInProgressHook = null;
|
||
{
|
||
currentHookNameInDev = null;
|
||
hookTypesDev = null;
|
||
hookTypesUpdateIndexDev = -1;
|
||
if (current2 !== null && (current2.flags & StaticMask) !== (workInProgress2.flags & StaticMask) && (current2.mode & ConcurrentMode) !== NoMode) {
|
||
error("Internal React error: Expected static flag was missing. Please notify the React team.");
|
||
}
|
||
}
|
||
didScheduleRenderPhaseUpdate = false;
|
||
if (didRenderTooFewHooks) {
|
||
throw new Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement.");
|
||
}
|
||
return children;
|
||
}
|
||
function checkDidRenderIdHook() {
|
||
var didRenderIdHook = localIdCounter !== 0;
|
||
localIdCounter = 0;
|
||
return didRenderIdHook;
|
||
}
|
||
function bailoutHooks(current2, workInProgress2, lanes) {
|
||
workInProgress2.updateQueue = current2.updateQueue;
|
||
if ((workInProgress2.mode & StrictEffectsMode) !== NoMode) {
|
||
workInProgress2.flags &= ~(MountPassiveDev | MountLayoutDev | Passive | Update);
|
||
} else {
|
||
workInProgress2.flags &= ~(Passive | Update);
|
||
}
|
||
current2.lanes = removeLanes(current2.lanes, lanes);
|
||
}
|
||
function resetHooksAfterThrow() {
|
||
ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
|
||
if (didScheduleRenderPhaseUpdate) {
|
||
var hook = currentlyRenderingFiber$1.memoizedState;
|
||
while (hook !== null) {
|
||
var queue = hook.queue;
|
||
if (queue !== null) {
|
||
queue.pending = null;
|
||
}
|
||
hook = hook.next;
|
||
}
|
||
didScheduleRenderPhaseUpdate = false;
|
||
}
|
||
renderLanes = NoLanes;
|
||
currentlyRenderingFiber$1 = null;
|
||
currentHook = null;
|
||
workInProgressHook = null;
|
||
{
|
||
hookTypesDev = null;
|
||
hookTypesUpdateIndexDev = -1;
|
||
currentHookNameInDev = null;
|
||
isUpdatingOpaqueValueInRenderPhase = false;
|
||
}
|
||
didScheduleRenderPhaseUpdateDuringThisPass = false;
|
||
localIdCounter = 0;
|
||
}
|
||
function mountWorkInProgressHook() {
|
||
var hook = {
|
||
memoizedState: null,
|
||
baseState: null,
|
||
baseQueue: null,
|
||
queue: null,
|
||
next: null
|
||
};
|
||
if (workInProgressHook === null) {
|
||
currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook;
|
||
} else {
|
||
workInProgressHook = workInProgressHook.next = hook;
|
||
}
|
||
return workInProgressHook;
|
||
}
|
||
function updateWorkInProgressHook() {
|
||
var nextCurrentHook;
|
||
if (currentHook === null) {
|
||
var current2 = currentlyRenderingFiber$1.alternate;
|
||
if (current2 !== null) {
|
||
nextCurrentHook = current2.memoizedState;
|
||
} else {
|
||
nextCurrentHook = null;
|
||
}
|
||
} else {
|
||
nextCurrentHook = currentHook.next;
|
||
}
|
||
var nextWorkInProgressHook;
|
||
if (workInProgressHook === null) {
|
||
nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState;
|
||
} else {
|
||
nextWorkInProgressHook = workInProgressHook.next;
|
||
}
|
||
if (nextWorkInProgressHook !== null) {
|
||
workInProgressHook = nextWorkInProgressHook;
|
||
nextWorkInProgressHook = workInProgressHook.next;
|
||
currentHook = nextCurrentHook;
|
||
} else {
|
||
if (nextCurrentHook === null) {
|
||
throw new Error("Rendered more hooks than during the previous render.");
|
||
}
|
||
currentHook = nextCurrentHook;
|
||
var newHook = {
|
||
memoizedState: currentHook.memoizedState,
|
||
baseState: currentHook.baseState,
|
||
baseQueue: currentHook.baseQueue,
|
||
queue: currentHook.queue,
|
||
next: null
|
||
};
|
||
if (workInProgressHook === null) {
|
||
currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook;
|
||
} else {
|
||
workInProgressHook = workInProgressHook.next = newHook;
|
||
}
|
||
}
|
||
return workInProgressHook;
|
||
}
|
||
function createFunctionComponentUpdateQueue() {
|
||
return {
|
||
lastEffect: null,
|
||
stores: null
|
||
};
|
||
}
|
||
function basicStateReducer(state, action) {
|
||
return typeof action === "function" ? action(state) : action;
|
||
}
|
||
function mountReducer(reducer, initialArg, init) {
|
||
var hook = mountWorkInProgressHook();
|
||
var initialState;
|
||
if (init !== void 0) {
|
||
initialState = init(initialArg);
|
||
} else {
|
||
initialState = initialArg;
|
||
}
|
||
hook.memoizedState = hook.baseState = initialState;
|
||
var queue = {
|
||
pending: null,
|
||
interleaved: null,
|
||
lanes: NoLanes,
|
||
dispatch: null,
|
||
lastRenderedReducer: reducer,
|
||
lastRenderedState: initialState
|
||
};
|
||
hook.queue = queue;
|
||
var dispatch = queue.dispatch = dispatchReducerAction.bind(null, currentlyRenderingFiber$1, queue);
|
||
return [hook.memoizedState, dispatch];
|
||
}
|
||
function updateReducer(reducer, initialArg, init) {
|
||
var hook = updateWorkInProgressHook();
|
||
var queue = hook.queue;
|
||
if (queue === null) {
|
||
throw new Error("Should have a queue. This is likely a bug in React. Please file an issue.");
|
||
}
|
||
queue.lastRenderedReducer = reducer;
|
||
var current2 = currentHook;
|
||
var baseQueue = current2.baseQueue;
|
||
var pendingQueue = queue.pending;
|
||
if (pendingQueue !== null) {
|
||
if (baseQueue !== null) {
|
||
var baseFirst = baseQueue.next;
|
||
var pendingFirst = pendingQueue.next;
|
||
baseQueue.next = pendingFirst;
|
||
pendingQueue.next = baseFirst;
|
||
}
|
||
{
|
||
if (current2.baseQueue !== baseQueue) {
|
||
error("Internal error: Expected work-in-progress queue to be a clone. This is a bug in React.");
|
||
}
|
||
}
|
||
current2.baseQueue = baseQueue = pendingQueue;
|
||
queue.pending = null;
|
||
}
|
||
if (baseQueue !== null) {
|
||
var first = baseQueue.next;
|
||
var newState = current2.baseState;
|
||
var newBaseState = null;
|
||
var newBaseQueueFirst = null;
|
||
var newBaseQueueLast = null;
|
||
var update = first;
|
||
do {
|
||
var updateLane = update.lane;
|
||
if (!isSubsetOfLanes(renderLanes, updateLane)) {
|
||
var clone = {
|
||
lane: updateLane,
|
||
action: update.action,
|
||
hasEagerState: update.hasEagerState,
|
||
eagerState: update.eagerState,
|
||
next: null
|
||
};
|
||
if (newBaseQueueLast === null) {
|
||
newBaseQueueFirst = newBaseQueueLast = clone;
|
||
newBaseState = newState;
|
||
} else {
|
||
newBaseQueueLast = newBaseQueueLast.next = clone;
|
||
}
|
||
currentlyRenderingFiber$1.lanes = mergeLanes(currentlyRenderingFiber$1.lanes, updateLane);
|
||
markSkippedUpdateLanes(updateLane);
|
||
} else {
|
||
if (newBaseQueueLast !== null) {
|
||
var _clone = {
|
||
lane: NoLane,
|
||
action: update.action,
|
||
hasEagerState: update.hasEagerState,
|
||
eagerState: update.eagerState,
|
||
next: null
|
||
};
|
||
newBaseQueueLast = newBaseQueueLast.next = _clone;
|
||
}
|
||
if (update.hasEagerState) {
|
||
newState = update.eagerState;
|
||
} else {
|
||
var action = update.action;
|
||
newState = reducer(newState, action);
|
||
}
|
||
}
|
||
update = update.next;
|
||
} while (update !== null && update !== first);
|
||
if (newBaseQueueLast === null) {
|
||
newBaseState = newState;
|
||
} else {
|
||
newBaseQueueLast.next = newBaseQueueFirst;
|
||
}
|
||
if (!objectIs(newState, hook.memoizedState)) {
|
||
markWorkInProgressReceivedUpdate();
|
||
}
|
||
hook.memoizedState = newState;
|
||
hook.baseState = newBaseState;
|
||
hook.baseQueue = newBaseQueueLast;
|
||
queue.lastRenderedState = newState;
|
||
}
|
||
var lastInterleaved = queue.interleaved;
|
||
if (lastInterleaved !== null) {
|
||
var interleaved = lastInterleaved;
|
||
do {
|
||
var interleavedLane = interleaved.lane;
|
||
currentlyRenderingFiber$1.lanes = mergeLanes(currentlyRenderingFiber$1.lanes, interleavedLane);
|
||
markSkippedUpdateLanes(interleavedLane);
|
||
interleaved = interleaved.next;
|
||
} while (interleaved !== lastInterleaved);
|
||
} else if (baseQueue === null) {
|
||
queue.lanes = NoLanes;
|
||
}
|
||
var dispatch = queue.dispatch;
|
||
return [hook.memoizedState, dispatch];
|
||
}
|
||
function rerenderReducer(reducer, initialArg, init) {
|
||
var hook = updateWorkInProgressHook();
|
||
var queue = hook.queue;
|
||
if (queue === null) {
|
||
throw new Error("Should have a queue. This is likely a bug in React. Please file an issue.");
|
||
}
|
||
queue.lastRenderedReducer = reducer;
|
||
var dispatch = queue.dispatch;
|
||
var lastRenderPhaseUpdate = queue.pending;
|
||
var newState = hook.memoizedState;
|
||
if (lastRenderPhaseUpdate !== null) {
|
||
queue.pending = null;
|
||
var firstRenderPhaseUpdate = lastRenderPhaseUpdate.next;
|
||
var update = firstRenderPhaseUpdate;
|
||
do {
|
||
var action = update.action;
|
||
newState = reducer(newState, action);
|
||
update = update.next;
|
||
} while (update !== firstRenderPhaseUpdate);
|
||
if (!objectIs(newState, hook.memoizedState)) {
|
||
markWorkInProgressReceivedUpdate();
|
||
}
|
||
hook.memoizedState = newState;
|
||
if (hook.baseQueue === null) {
|
||
hook.baseState = newState;
|
||
}
|
||
queue.lastRenderedState = newState;
|
||
}
|
||
return [newState, dispatch];
|
||
}
|
||
function mountMutableSource(source, getSnapshot, subscribe) {
|
||
{
|
||
return void 0;
|
||
}
|
||
}
|
||
function updateMutableSource(source, getSnapshot, subscribe) {
|
||
{
|
||
return void 0;
|
||
}
|
||
}
|
||
function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
|
||
var fiber = currentlyRenderingFiber$1;
|
||
var hook = mountWorkInProgressHook();
|
||
var nextSnapshot;
|
||
var isHydrating2 = getIsHydrating();
|
||
if (isHydrating2) {
|
||
if (getServerSnapshot === void 0) {
|
||
throw new Error("Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering.");
|
||
}
|
||
nextSnapshot = getServerSnapshot();
|
||
{
|
||
if (!didWarnUncachedGetSnapshot) {
|
||
if (nextSnapshot !== getServerSnapshot()) {
|
||
error("The result of getServerSnapshot should be cached to avoid an infinite loop");
|
||
didWarnUncachedGetSnapshot = true;
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
nextSnapshot = getSnapshot();
|
||
{
|
||
if (!didWarnUncachedGetSnapshot) {
|
||
var cachedSnapshot = getSnapshot();
|
||
if (!objectIs(nextSnapshot, cachedSnapshot)) {
|
||
error("The result of getSnapshot should be cached to avoid an infinite loop");
|
||
didWarnUncachedGetSnapshot = true;
|
||
}
|
||
}
|
||
}
|
||
var root2 = getWorkInProgressRoot();
|
||
if (root2 === null) {
|
||
throw new Error("Expected a work-in-progress root. This is a bug in React. Please file an issue.");
|
||
}
|
||
if (!includesBlockingLane(root2, renderLanes)) {
|
||
pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
|
||
}
|
||
}
|
||
hook.memoizedState = nextSnapshot;
|
||
var inst = {
|
||
value: nextSnapshot,
|
||
getSnapshot
|
||
};
|
||
hook.queue = inst;
|
||
mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]);
|
||
fiber.flags |= Passive;
|
||
pushEffect(HasEffect | Passive$1, updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot), void 0, null);
|
||
return nextSnapshot;
|
||
}
|
||
function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
|
||
var fiber = currentlyRenderingFiber$1;
|
||
var hook = updateWorkInProgressHook();
|
||
var nextSnapshot = getSnapshot();
|
||
{
|
||
if (!didWarnUncachedGetSnapshot) {
|
||
var cachedSnapshot = getSnapshot();
|
||
if (!objectIs(nextSnapshot, cachedSnapshot)) {
|
||
error("The result of getSnapshot should be cached to avoid an infinite loop");
|
||
didWarnUncachedGetSnapshot = true;
|
||
}
|
||
}
|
||
}
|
||
var prevSnapshot = hook.memoizedState;
|
||
var snapshotChanged = !objectIs(prevSnapshot, nextSnapshot);
|
||
if (snapshotChanged) {
|
||
hook.memoizedState = nextSnapshot;
|
||
markWorkInProgressReceivedUpdate();
|
||
}
|
||
var inst = hook.queue;
|
||
updateEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]);
|
||
if (inst.getSnapshot !== getSnapshot || snapshotChanged || workInProgressHook !== null && workInProgressHook.memoizedState.tag & HasEffect) {
|
||
fiber.flags |= Passive;
|
||
pushEffect(HasEffect | Passive$1, updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot), void 0, null);
|
||
var root2 = getWorkInProgressRoot();
|
||
if (root2 === null) {
|
||
throw new Error("Expected a work-in-progress root. This is a bug in React. Please file an issue.");
|
||
}
|
||
if (!includesBlockingLane(root2, renderLanes)) {
|
||
pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot);
|
||
}
|
||
}
|
||
return nextSnapshot;
|
||
}
|
||
function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) {
|
||
fiber.flags |= StoreConsistency;
|
||
var check = {
|
||
getSnapshot,
|
||
value: renderedSnapshot
|
||
};
|
||
var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue;
|
||
if (componentUpdateQueue === null) {
|
||
componentUpdateQueue = createFunctionComponentUpdateQueue();
|
||
currentlyRenderingFiber$1.updateQueue = componentUpdateQueue;
|
||
componentUpdateQueue.stores = [check];
|
||
} else {
|
||
var stores = componentUpdateQueue.stores;
|
||
if (stores === null) {
|
||
componentUpdateQueue.stores = [check];
|
||
} else {
|
||
stores.push(check);
|
||
}
|
||
}
|
||
}
|
||
function updateStoreInstance(fiber, inst, nextSnapshot, getSnapshot) {
|
||
inst.value = nextSnapshot;
|
||
inst.getSnapshot = getSnapshot;
|
||
if (checkIfSnapshotChanged(inst)) {
|
||
forceStoreRerender(fiber);
|
||
}
|
||
}
|
||
function subscribeToStore(fiber, inst, subscribe) {
|
||
var handleStoreChange = function() {
|
||
if (checkIfSnapshotChanged(inst)) {
|
||
forceStoreRerender(fiber);
|
||
}
|
||
};
|
||
return subscribe(handleStoreChange);
|
||
}
|
||
function checkIfSnapshotChanged(inst) {
|
||
var latestGetSnapshot = inst.getSnapshot;
|
||
var prevValue = inst.value;
|
||
try {
|
||
var nextValue = latestGetSnapshot();
|
||
return !objectIs(prevValue, nextValue);
|
||
} catch (error2) {
|
||
return true;
|
||
}
|
||
}
|
||
function forceStoreRerender(fiber) {
|
||
var root2 = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||
if (root2 !== null) {
|
||
scheduleUpdateOnFiber(root2, fiber, SyncLane, NoTimestamp);
|
||
}
|
||
}
|
||
function mountState(initialState) {
|
||
var hook = mountWorkInProgressHook();
|
||
if (typeof initialState === "function") {
|
||
initialState = initialState();
|
||
}
|
||
hook.memoizedState = hook.baseState = initialState;
|
||
var queue = {
|
||
pending: null,
|
||
interleaved: null,
|
||
lanes: NoLanes,
|
||
dispatch: null,
|
||
lastRenderedReducer: basicStateReducer,
|
||
lastRenderedState: initialState
|
||
};
|
||
hook.queue = queue;
|
||
var dispatch = queue.dispatch = dispatchSetState.bind(null, currentlyRenderingFiber$1, queue);
|
||
return [hook.memoizedState, dispatch];
|
||
}
|
||
function updateState(initialState) {
|
||
return updateReducer(basicStateReducer);
|
||
}
|
||
function rerenderState(initialState) {
|
||
return rerenderReducer(basicStateReducer);
|
||
}
|
||
function pushEffect(tag, create, destroy, deps) {
|
||
var effect = {
|
||
tag,
|
||
create,
|
||
destroy,
|
||
deps,
|
||
next: null
|
||
};
|
||
var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue;
|
||
if (componentUpdateQueue === null) {
|
||
componentUpdateQueue = createFunctionComponentUpdateQueue();
|
||
currentlyRenderingFiber$1.updateQueue = componentUpdateQueue;
|
||
componentUpdateQueue.lastEffect = effect.next = effect;
|
||
} else {
|
||
var lastEffect = componentUpdateQueue.lastEffect;
|
||
if (lastEffect === null) {
|
||
componentUpdateQueue.lastEffect = effect.next = effect;
|
||
} else {
|
||
var firstEffect = lastEffect.next;
|
||
lastEffect.next = effect;
|
||
effect.next = firstEffect;
|
||
componentUpdateQueue.lastEffect = effect;
|
||
}
|
||
}
|
||
return effect;
|
||
}
|
||
function mountRef(initialValue) {
|
||
var hook = mountWorkInProgressHook();
|
||
{
|
||
var _ref2 = {
|
||
current: initialValue
|
||
};
|
||
hook.memoizedState = _ref2;
|
||
return _ref2;
|
||
}
|
||
}
|
||
function updateRef(initialValue) {
|
||
var hook = updateWorkInProgressHook();
|
||
return hook.memoizedState;
|
||
}
|
||
function mountEffectImpl(fiberFlags, hookFlags, create, deps) {
|
||
var hook = mountWorkInProgressHook();
|
||
var nextDeps = deps === void 0 ? null : deps;
|
||
currentlyRenderingFiber$1.flags |= fiberFlags;
|
||
hook.memoizedState = pushEffect(HasEffect | hookFlags, create, void 0, nextDeps);
|
||
}
|
||
function updateEffectImpl(fiberFlags, hookFlags, create, deps) {
|
||
var hook = updateWorkInProgressHook();
|
||
var nextDeps = deps === void 0 ? null : deps;
|
||
var destroy = void 0;
|
||
if (currentHook !== null) {
|
||
var prevEffect = currentHook.memoizedState;
|
||
destroy = prevEffect.destroy;
|
||
if (nextDeps !== null) {
|
||
var prevDeps = prevEffect.deps;
|
||
if (areHookInputsEqual(nextDeps, prevDeps)) {
|
||
hook.memoizedState = pushEffect(hookFlags, create, destroy, nextDeps);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
currentlyRenderingFiber$1.flags |= fiberFlags;
|
||
hook.memoizedState = pushEffect(HasEffect | hookFlags, create, destroy, nextDeps);
|
||
}
|
||
function mountEffect(create, deps) {
|
||
if ((currentlyRenderingFiber$1.mode & StrictEffectsMode) !== NoMode) {
|
||
return mountEffectImpl(MountPassiveDev | Passive | PassiveStatic, Passive$1, create, deps);
|
||
} else {
|
||
return mountEffectImpl(Passive | PassiveStatic, Passive$1, create, deps);
|
||
}
|
||
}
|
||
function updateEffect(create, deps) {
|
||
return updateEffectImpl(Passive, Passive$1, create, deps);
|
||
}
|
||
function mountInsertionEffect(create, deps) {
|
||
return mountEffectImpl(Update, Insertion, create, deps);
|
||
}
|
||
function updateInsertionEffect(create, deps) {
|
||
return updateEffectImpl(Update, Insertion, create, deps);
|
||
}
|
||
function mountLayoutEffect(create, deps) {
|
||
var fiberFlags = Update;
|
||
{
|
||
fiberFlags |= LayoutStatic;
|
||
}
|
||
if ((currentlyRenderingFiber$1.mode & StrictEffectsMode) !== NoMode) {
|
||
fiberFlags |= MountLayoutDev;
|
||
}
|
||
return mountEffectImpl(fiberFlags, Layout, create, deps);
|
||
}
|
||
function updateLayoutEffect(create, deps) {
|
||
return updateEffectImpl(Update, Layout, create, deps);
|
||
}
|
||
function imperativeHandleEffect(create, ref) {
|
||
if (typeof ref === "function") {
|
||
var refCallback = ref;
|
||
var _inst = create();
|
||
refCallback(_inst);
|
||
return function() {
|
||
refCallback(null);
|
||
};
|
||
} else if (ref !== null && ref !== void 0) {
|
||
var refObject = ref;
|
||
{
|
||
if (!refObject.hasOwnProperty("current")) {
|
||
error("Expected useImperativeHandle() first argument to either be a ref callback or React.createRef() object. Instead received: %s.", "an object with keys {" + Object.keys(refObject).join(", ") + "}");
|
||
}
|
||
}
|
||
var _inst2 = create();
|
||
refObject.current = _inst2;
|
||
return function() {
|
||
refObject.current = null;
|
||
};
|
||
}
|
||
}
|
||
function mountImperativeHandle(ref, create, deps) {
|
||
{
|
||
if (typeof create !== "function") {
|
||
error("Expected useImperativeHandle() second argument to be a function that creates a handle. Instead received: %s.", create !== null ? typeof create : "null");
|
||
}
|
||
}
|
||
var effectDeps = deps !== null && deps !== void 0 ? deps.concat([ref]) : null;
|
||
var fiberFlags = Update;
|
||
{
|
||
fiberFlags |= LayoutStatic;
|
||
}
|
||
if ((currentlyRenderingFiber$1.mode & StrictEffectsMode) !== NoMode) {
|
||
fiberFlags |= MountLayoutDev;
|
||
}
|
||
return mountEffectImpl(fiberFlags, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
||
}
|
||
function updateImperativeHandle(ref, create, deps) {
|
||
{
|
||
if (typeof create !== "function") {
|
||
error("Expected useImperativeHandle() second argument to be a function that creates a handle. Instead received: %s.", create !== null ? typeof create : "null");
|
||
}
|
||
}
|
||
var effectDeps = deps !== null && deps !== void 0 ? deps.concat([ref]) : null;
|
||
return updateEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
||
}
|
||
function mountDebugValue(value, formatterFn) {
|
||
}
|
||
var updateDebugValue = mountDebugValue;
|
||
function mountCallback(callback, deps) {
|
||
var hook = mountWorkInProgressHook();
|
||
var nextDeps = deps === void 0 ? null : deps;
|
||
hook.memoizedState = [callback, nextDeps];
|
||
return callback;
|
||
}
|
||
function updateCallback(callback, deps) {
|
||
var hook = updateWorkInProgressHook();
|
||
var nextDeps = deps === void 0 ? null : deps;
|
||
var prevState = hook.memoizedState;
|
||
if (prevState !== null) {
|
||
if (nextDeps !== null) {
|
||
var prevDeps = prevState[1];
|
||
if (areHookInputsEqual(nextDeps, prevDeps)) {
|
||
return prevState[0];
|
||
}
|
||
}
|
||
}
|
||
hook.memoizedState = [callback, nextDeps];
|
||
return callback;
|
||
}
|
||
function mountMemo(nextCreate, deps) {
|
||
var hook = mountWorkInProgressHook();
|
||
var nextDeps = deps === void 0 ? null : deps;
|
||
var nextValue = nextCreate();
|
||
hook.memoizedState = [nextValue, nextDeps];
|
||
return nextValue;
|
||
}
|
||
function updateMemo(nextCreate, deps) {
|
||
var hook = updateWorkInProgressHook();
|
||
var nextDeps = deps === void 0 ? null : deps;
|
||
var prevState = hook.memoizedState;
|
||
if (prevState !== null) {
|
||
if (nextDeps !== null) {
|
||
var prevDeps = prevState[1];
|
||
if (areHookInputsEqual(nextDeps, prevDeps)) {
|
||
return prevState[0];
|
||
}
|
||
}
|
||
}
|
||
var nextValue = nextCreate();
|
||
hook.memoizedState = [nextValue, nextDeps];
|
||
return nextValue;
|
||
}
|
||
function mountDeferredValue(value) {
|
||
var hook = mountWorkInProgressHook();
|
||
hook.memoizedState = value;
|
||
return value;
|
||
}
|
||
function updateDeferredValue(value) {
|
||
var hook = updateWorkInProgressHook();
|
||
var resolvedCurrentHook = currentHook;
|
||
var prevValue = resolvedCurrentHook.memoizedState;
|
||
return updateDeferredValueImpl(hook, prevValue, value);
|
||
}
|
||
function rerenderDeferredValue(value) {
|
||
var hook = updateWorkInProgressHook();
|
||
if (currentHook === null) {
|
||
hook.memoizedState = value;
|
||
return value;
|
||
} else {
|
||
var prevValue = currentHook.memoizedState;
|
||
return updateDeferredValueImpl(hook, prevValue, value);
|
||
}
|
||
}
|
||
function updateDeferredValueImpl(hook, prevValue, value) {
|
||
var shouldDeferValue = !includesOnlyNonUrgentLanes(renderLanes);
|
||
if (shouldDeferValue) {
|
||
if (!objectIs(value, prevValue)) {
|
||
var deferredLane = claimNextTransitionLane();
|
||
currentlyRenderingFiber$1.lanes = mergeLanes(currentlyRenderingFiber$1.lanes, deferredLane);
|
||
markSkippedUpdateLanes(deferredLane);
|
||
hook.baseState = true;
|
||
}
|
||
return prevValue;
|
||
} else {
|
||
if (hook.baseState) {
|
||
hook.baseState = false;
|
||
markWorkInProgressReceivedUpdate();
|
||
}
|
||
hook.memoizedState = value;
|
||
return value;
|
||
}
|
||
}
|
||
function startTransition(setPending, callback, options2) {
|
||
var previousPriority = getCurrentUpdatePriority();
|
||
setCurrentUpdatePriority(higherEventPriority(previousPriority, ContinuousEventPriority));
|
||
setPending(true);
|
||
var prevTransition = ReactCurrentBatchConfig$2.transition;
|
||
ReactCurrentBatchConfig$2.transition = {};
|
||
var currentTransition = ReactCurrentBatchConfig$2.transition;
|
||
{
|
||
ReactCurrentBatchConfig$2.transition._updatedFibers = /* @__PURE__ */ new Set();
|
||
}
|
||
try {
|
||
setPending(false);
|
||
callback();
|
||
} finally {
|
||
setCurrentUpdatePriority(previousPriority);
|
||
ReactCurrentBatchConfig$2.transition = prevTransition;
|
||
{
|
||
if (prevTransition === null && currentTransition._updatedFibers) {
|
||
var updatedFibersCount = currentTransition._updatedFibers.size;
|
||
if (updatedFibersCount > 10) {
|
||
warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.");
|
||
}
|
||
currentTransition._updatedFibers.clear();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function mountTransition() {
|
||
var _mountState = mountState(false), isPending = _mountState[0], setPending = _mountState[1];
|
||
var start = startTransition.bind(null, setPending);
|
||
var hook = mountWorkInProgressHook();
|
||
hook.memoizedState = start;
|
||
return [isPending, start];
|
||
}
|
||
function updateTransition() {
|
||
var _updateState = updateState(), isPending = _updateState[0];
|
||
var hook = updateWorkInProgressHook();
|
||
var start = hook.memoizedState;
|
||
return [isPending, start];
|
||
}
|
||
function rerenderTransition() {
|
||
var _rerenderState = rerenderState(), isPending = _rerenderState[0];
|
||
var hook = updateWorkInProgressHook();
|
||
var start = hook.memoizedState;
|
||
return [isPending, start];
|
||
}
|
||
var isUpdatingOpaqueValueInRenderPhase = false;
|
||
function getIsUpdatingOpaqueValueInRenderPhaseInDEV() {
|
||
{
|
||
return isUpdatingOpaqueValueInRenderPhase;
|
||
}
|
||
}
|
||
function mountId() {
|
||
var hook = mountWorkInProgressHook();
|
||
var root2 = getWorkInProgressRoot();
|
||
var identifierPrefix = root2.identifierPrefix;
|
||
var id;
|
||
if (getIsHydrating()) {
|
||
var treeId = getTreeId();
|
||
id = ":" + identifierPrefix + "R" + treeId;
|
||
var localId = localIdCounter++;
|
||
if (localId > 0) {
|
||
id += "H" + localId.toString(32);
|
||
}
|
||
id += ":";
|
||
} else {
|
||
var globalClientId = globalClientIdCounter++;
|
||
id = ":" + identifierPrefix + "r" + globalClientId.toString(32) + ":";
|
||
}
|
||
hook.memoizedState = id;
|
||
return id;
|
||
}
|
||
function updateId() {
|
||
var hook = updateWorkInProgressHook();
|
||
var id = hook.memoizedState;
|
||
return id;
|
||
}
|
||
function dispatchReducerAction(fiber, queue, action) {
|
||
{
|
||
if (typeof arguments[3] === "function") {
|
||
error("State updates from the useState() and useReducer() Hooks don't support the second callback argument. To execute a side effect after rendering, declare it in the component body with useEffect().");
|
||
}
|
||
}
|
||
var lane = requestUpdateLane(fiber);
|
||
var update = {
|
||
lane,
|
||
action,
|
||
hasEagerState: false,
|
||
eagerState: null,
|
||
next: null
|
||
};
|
||
if (isRenderPhaseUpdate(fiber)) {
|
||
enqueueRenderPhaseUpdate(queue, update);
|
||
} else {
|
||
var root2 = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
|
||
if (root2 !== null) {
|
||
var eventTime = requestEventTime();
|
||
scheduleUpdateOnFiber(root2, fiber, lane, eventTime);
|
||
entangleTransitionUpdate(root2, queue, lane);
|
||
}
|
||
}
|
||
markUpdateInDevTools(fiber, lane);
|
||
}
|
||
function dispatchSetState(fiber, queue, action) {
|
||
{
|
||
if (typeof arguments[3] === "function") {
|
||
error("State updates from the useState() and useReducer() Hooks don't support the second callback argument. To execute a side effect after rendering, declare it in the component body with useEffect().");
|
||
}
|
||
}
|
||
var lane = requestUpdateLane(fiber);
|
||
var update = {
|
||
lane,
|
||
action,
|
||
hasEagerState: false,
|
||
eagerState: null,
|
||
next: null
|
||
};
|
||
if (isRenderPhaseUpdate(fiber)) {
|
||
enqueueRenderPhaseUpdate(queue, update);
|
||
} else {
|
||
var alternate = fiber.alternate;
|
||
if (fiber.lanes === NoLanes && (alternate === null || alternate.lanes === NoLanes)) {
|
||
var lastRenderedReducer = queue.lastRenderedReducer;
|
||
if (lastRenderedReducer !== null) {
|
||
var prevDispatcher;
|
||
{
|
||
prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
||
}
|
||
try {
|
||
var currentState = queue.lastRenderedState;
|
||
var eagerState = lastRenderedReducer(currentState, action);
|
||
update.hasEagerState = true;
|
||
update.eagerState = eagerState;
|
||
if (objectIs(eagerState, currentState)) {
|
||
enqueueConcurrentHookUpdateAndEagerlyBailout(fiber, queue, update, lane);
|
||
return;
|
||
}
|
||
} catch (error2) {
|
||
} finally {
|
||
{
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var root2 = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
|
||
if (root2 !== null) {
|
||
var eventTime = requestEventTime();
|
||
scheduleUpdateOnFiber(root2, fiber, lane, eventTime);
|
||
entangleTransitionUpdate(root2, queue, lane);
|
||
}
|
||
}
|
||
markUpdateInDevTools(fiber, lane);
|
||
}
|
||
function isRenderPhaseUpdate(fiber) {
|
||
var alternate = fiber.alternate;
|
||
return fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1;
|
||
}
|
||
function enqueueRenderPhaseUpdate(queue, update) {
|
||
didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
|
||
var pending = queue.pending;
|
||
if (pending === null) {
|
||
update.next = update;
|
||
} else {
|
||
update.next = pending.next;
|
||
pending.next = update;
|
||
}
|
||
queue.pending = update;
|
||
}
|
||
function entangleTransitionUpdate(root2, queue, lane) {
|
||
if (isTransitionLane(lane)) {
|
||
var queueLanes = queue.lanes;
|
||
queueLanes = intersectLanes(queueLanes, root2.pendingLanes);
|
||
var newQueueLanes = mergeLanes(queueLanes, lane);
|
||
queue.lanes = newQueueLanes;
|
||
markRootEntangled(root2, newQueueLanes);
|
||
}
|
||
}
|
||
function markUpdateInDevTools(fiber, lane, action) {
|
||
{
|
||
markStateUpdateScheduled(fiber, lane);
|
||
}
|
||
}
|
||
var ContextOnlyDispatcher = {
|
||
readContext,
|
||
useCallback: throwInvalidHookError,
|
||
useContext: throwInvalidHookError,
|
||
useEffect: throwInvalidHookError,
|
||
useImperativeHandle: throwInvalidHookError,
|
||
useInsertionEffect: throwInvalidHookError,
|
||
useLayoutEffect: throwInvalidHookError,
|
||
useMemo: throwInvalidHookError,
|
||
useReducer: throwInvalidHookError,
|
||
useRef: throwInvalidHookError,
|
||
useState: throwInvalidHookError,
|
||
useDebugValue: throwInvalidHookError,
|
||
useDeferredValue: throwInvalidHookError,
|
||
useTransition: throwInvalidHookError,
|
||
useMutableSource: throwInvalidHookError,
|
||
useSyncExternalStore: throwInvalidHookError,
|
||
useId: throwInvalidHookError,
|
||
unstable_isNewReconciler: enableNewReconciler
|
||
};
|
||
var HooksDispatcherOnMountInDEV = null;
|
||
var HooksDispatcherOnMountWithHookTypesInDEV = null;
|
||
var HooksDispatcherOnUpdateInDEV = null;
|
||
var HooksDispatcherOnRerenderInDEV = null;
|
||
var InvalidNestedHooksDispatcherOnMountInDEV = null;
|
||
var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
||
var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
|
||
{
|
||
var warnInvalidContextAccess = function() {
|
||
error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");
|
||
};
|
||
var warnInvalidHookAccess = function() {
|
||
error("Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://reactjs.org/link/rules-of-hooks");
|
||
};
|
||
HooksDispatcherOnMountInDEV = {
|
||
readContext: function(context) {
|
||
return readContext(context);
|
||
},
|
||
useCallback: function(callback, deps) {
|
||
currentHookNameInDev = "useCallback";
|
||
mountHookTypesDev();
|
||
checkDepsAreArrayDev(deps);
|
||
return mountCallback(callback, deps);
|
||
},
|
||
useContext: function(context) {
|
||
currentHookNameInDev = "useContext";
|
||
mountHookTypesDev();
|
||
return readContext(context);
|
||
},
|
||
useEffect: function(create, deps) {
|
||
currentHookNameInDev = "useEffect";
|
||
mountHookTypesDev();
|
||
checkDepsAreArrayDev(deps);
|
||
return mountEffect(create, deps);
|
||
},
|
||
useImperativeHandle: function(ref, create, deps) {
|
||
currentHookNameInDev = "useImperativeHandle";
|
||
mountHookTypesDev();
|
||
checkDepsAreArrayDev(deps);
|
||
return mountImperativeHandle(ref, create, deps);
|
||
},
|
||
useInsertionEffect: function(create, deps) {
|
||
currentHookNameInDev = "useInsertionEffect";
|
||
mountHookTypesDev();
|
||
checkDepsAreArrayDev(deps);
|
||
return mountInsertionEffect(create, deps);
|
||
},
|
||
useLayoutEffect: function(create, deps) {
|
||
currentHookNameInDev = "useLayoutEffect";
|
||
mountHookTypesDev();
|
||
checkDepsAreArrayDev(deps);
|
||
return mountLayoutEffect(create, deps);
|
||
},
|
||
useMemo: function(create, deps) {
|
||
currentHookNameInDev = "useMemo";
|
||
mountHookTypesDev();
|
||
checkDepsAreArrayDev(deps);
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
||
try {
|
||
return mountMemo(create, deps);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useReducer: function(reducer, initialArg, init) {
|
||
currentHookNameInDev = "useReducer";
|
||
mountHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
||
try {
|
||
return mountReducer(reducer, initialArg, init);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useRef: function(initialValue) {
|
||
currentHookNameInDev = "useRef";
|
||
mountHookTypesDev();
|
||
return mountRef(initialValue);
|
||
},
|
||
useState: function(initialState) {
|
||
currentHookNameInDev = "useState";
|
||
mountHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
||
try {
|
||
return mountState(initialState);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useDebugValue: function(value, formatterFn) {
|
||
currentHookNameInDev = "useDebugValue";
|
||
mountHookTypesDev();
|
||
return mountDebugValue();
|
||
},
|
||
useDeferredValue: function(value) {
|
||
currentHookNameInDev = "useDeferredValue";
|
||
mountHookTypesDev();
|
||
return mountDeferredValue(value);
|
||
},
|
||
useTransition: function() {
|
||
currentHookNameInDev = "useTransition";
|
||
mountHookTypesDev();
|
||
return mountTransition();
|
||
},
|
||
useMutableSource: function(source, getSnapshot, subscribe) {
|
||
currentHookNameInDev = "useMutableSource";
|
||
mountHookTypesDev();
|
||
return mountMutableSource();
|
||
},
|
||
useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
|
||
currentHookNameInDev = "useSyncExternalStore";
|
||
mountHookTypesDev();
|
||
return mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
||
},
|
||
useId: function() {
|
||
currentHookNameInDev = "useId";
|
||
mountHookTypesDev();
|
||
return mountId();
|
||
},
|
||
unstable_isNewReconciler: enableNewReconciler
|
||
};
|
||
HooksDispatcherOnMountWithHookTypesInDEV = {
|
||
readContext: function(context) {
|
||
return readContext(context);
|
||
},
|
||
useCallback: function(callback, deps) {
|
||
currentHookNameInDev = "useCallback";
|
||
updateHookTypesDev();
|
||
return mountCallback(callback, deps);
|
||
},
|
||
useContext: function(context) {
|
||
currentHookNameInDev = "useContext";
|
||
updateHookTypesDev();
|
||
return readContext(context);
|
||
},
|
||
useEffect: function(create, deps) {
|
||
currentHookNameInDev = "useEffect";
|
||
updateHookTypesDev();
|
||
return mountEffect(create, deps);
|
||
},
|
||
useImperativeHandle: function(ref, create, deps) {
|
||
currentHookNameInDev = "useImperativeHandle";
|
||
updateHookTypesDev();
|
||
return mountImperativeHandle(ref, create, deps);
|
||
},
|
||
useInsertionEffect: function(create, deps) {
|
||
currentHookNameInDev = "useInsertionEffect";
|
||
updateHookTypesDev();
|
||
return mountInsertionEffect(create, deps);
|
||
},
|
||
useLayoutEffect: function(create, deps) {
|
||
currentHookNameInDev = "useLayoutEffect";
|
||
updateHookTypesDev();
|
||
return mountLayoutEffect(create, deps);
|
||
},
|
||
useMemo: function(create, deps) {
|
||
currentHookNameInDev = "useMemo";
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
||
try {
|
||
return mountMemo(create, deps);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useReducer: function(reducer, initialArg, init) {
|
||
currentHookNameInDev = "useReducer";
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
||
try {
|
||
return mountReducer(reducer, initialArg, init);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useRef: function(initialValue) {
|
||
currentHookNameInDev = "useRef";
|
||
updateHookTypesDev();
|
||
return mountRef(initialValue);
|
||
},
|
||
useState: function(initialState) {
|
||
currentHookNameInDev = "useState";
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
||
try {
|
||
return mountState(initialState);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useDebugValue: function(value, formatterFn) {
|
||
currentHookNameInDev = "useDebugValue";
|
||
updateHookTypesDev();
|
||
return mountDebugValue();
|
||
},
|
||
useDeferredValue: function(value) {
|
||
currentHookNameInDev = "useDeferredValue";
|
||
updateHookTypesDev();
|
||
return mountDeferredValue(value);
|
||
},
|
||
useTransition: function() {
|
||
currentHookNameInDev = "useTransition";
|
||
updateHookTypesDev();
|
||
return mountTransition();
|
||
},
|
||
useMutableSource: function(source, getSnapshot, subscribe) {
|
||
currentHookNameInDev = "useMutableSource";
|
||
updateHookTypesDev();
|
||
return mountMutableSource();
|
||
},
|
||
useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
|
||
currentHookNameInDev = "useSyncExternalStore";
|
||
updateHookTypesDev();
|
||
return mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
||
},
|
||
useId: function() {
|
||
currentHookNameInDev = "useId";
|
||
updateHookTypesDev();
|
||
return mountId();
|
||
},
|
||
unstable_isNewReconciler: enableNewReconciler
|
||
};
|
||
HooksDispatcherOnUpdateInDEV = {
|
||
readContext: function(context) {
|
||
return readContext(context);
|
||
},
|
||
useCallback: function(callback, deps) {
|
||
currentHookNameInDev = "useCallback";
|
||
updateHookTypesDev();
|
||
return updateCallback(callback, deps);
|
||
},
|
||
useContext: function(context) {
|
||
currentHookNameInDev = "useContext";
|
||
updateHookTypesDev();
|
||
return readContext(context);
|
||
},
|
||
useEffect: function(create, deps) {
|
||
currentHookNameInDev = "useEffect";
|
||
updateHookTypesDev();
|
||
return updateEffect(create, deps);
|
||
},
|
||
useImperativeHandle: function(ref, create, deps) {
|
||
currentHookNameInDev = "useImperativeHandle";
|
||
updateHookTypesDev();
|
||
return updateImperativeHandle(ref, create, deps);
|
||
},
|
||
useInsertionEffect: function(create, deps) {
|
||
currentHookNameInDev = "useInsertionEffect";
|
||
updateHookTypesDev();
|
||
return updateInsertionEffect(create, deps);
|
||
},
|
||
useLayoutEffect: function(create, deps) {
|
||
currentHookNameInDev = "useLayoutEffect";
|
||
updateHookTypesDev();
|
||
return updateLayoutEffect(create, deps);
|
||
},
|
||
useMemo: function(create, deps) {
|
||
currentHookNameInDev = "useMemo";
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
||
try {
|
||
return updateMemo(create, deps);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useReducer: function(reducer, initialArg, init) {
|
||
currentHookNameInDev = "useReducer";
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
||
try {
|
||
return updateReducer(reducer, initialArg, init);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useRef: function(initialValue) {
|
||
currentHookNameInDev = "useRef";
|
||
updateHookTypesDev();
|
||
return updateRef();
|
||
},
|
||
useState: function(initialState) {
|
||
currentHookNameInDev = "useState";
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
||
try {
|
||
return updateState(initialState);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useDebugValue: function(value, formatterFn) {
|
||
currentHookNameInDev = "useDebugValue";
|
||
updateHookTypesDev();
|
||
return updateDebugValue();
|
||
},
|
||
useDeferredValue: function(value) {
|
||
currentHookNameInDev = "useDeferredValue";
|
||
updateHookTypesDev();
|
||
return updateDeferredValue(value);
|
||
},
|
||
useTransition: function() {
|
||
currentHookNameInDev = "useTransition";
|
||
updateHookTypesDev();
|
||
return updateTransition();
|
||
},
|
||
useMutableSource: function(source, getSnapshot, subscribe) {
|
||
currentHookNameInDev = "useMutableSource";
|
||
updateHookTypesDev();
|
||
return updateMutableSource();
|
||
},
|
||
useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
|
||
currentHookNameInDev = "useSyncExternalStore";
|
||
updateHookTypesDev();
|
||
return updateSyncExternalStore(subscribe, getSnapshot);
|
||
},
|
||
useId: function() {
|
||
currentHookNameInDev = "useId";
|
||
updateHookTypesDev();
|
||
return updateId();
|
||
},
|
||
unstable_isNewReconciler: enableNewReconciler
|
||
};
|
||
HooksDispatcherOnRerenderInDEV = {
|
||
readContext: function(context) {
|
||
return readContext(context);
|
||
},
|
||
useCallback: function(callback, deps) {
|
||
currentHookNameInDev = "useCallback";
|
||
updateHookTypesDev();
|
||
return updateCallback(callback, deps);
|
||
},
|
||
useContext: function(context) {
|
||
currentHookNameInDev = "useContext";
|
||
updateHookTypesDev();
|
||
return readContext(context);
|
||
},
|
||
useEffect: function(create, deps) {
|
||
currentHookNameInDev = "useEffect";
|
||
updateHookTypesDev();
|
||
return updateEffect(create, deps);
|
||
},
|
||
useImperativeHandle: function(ref, create, deps) {
|
||
currentHookNameInDev = "useImperativeHandle";
|
||
updateHookTypesDev();
|
||
return updateImperativeHandle(ref, create, deps);
|
||
},
|
||
useInsertionEffect: function(create, deps) {
|
||
currentHookNameInDev = "useInsertionEffect";
|
||
updateHookTypesDev();
|
||
return updateInsertionEffect(create, deps);
|
||
},
|
||
useLayoutEffect: function(create, deps) {
|
||
currentHookNameInDev = "useLayoutEffect";
|
||
updateHookTypesDev();
|
||
return updateLayoutEffect(create, deps);
|
||
},
|
||
useMemo: function(create, deps) {
|
||
currentHookNameInDev = "useMemo";
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
|
||
try {
|
||
return updateMemo(create, deps);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useReducer: function(reducer, initialArg, init) {
|
||
currentHookNameInDev = "useReducer";
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
|
||
try {
|
||
return rerenderReducer(reducer, initialArg, init);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useRef: function(initialValue) {
|
||
currentHookNameInDev = "useRef";
|
||
updateHookTypesDev();
|
||
return updateRef();
|
||
},
|
||
useState: function(initialState) {
|
||
currentHookNameInDev = "useState";
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
|
||
try {
|
||
return rerenderState(initialState);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useDebugValue: function(value, formatterFn) {
|
||
currentHookNameInDev = "useDebugValue";
|
||
updateHookTypesDev();
|
||
return updateDebugValue();
|
||
},
|
||
useDeferredValue: function(value) {
|
||
currentHookNameInDev = "useDeferredValue";
|
||
updateHookTypesDev();
|
||
return rerenderDeferredValue(value);
|
||
},
|
||
useTransition: function() {
|
||
currentHookNameInDev = "useTransition";
|
||
updateHookTypesDev();
|
||
return rerenderTransition();
|
||
},
|
||
useMutableSource: function(source, getSnapshot, subscribe) {
|
||
currentHookNameInDev = "useMutableSource";
|
||
updateHookTypesDev();
|
||
return updateMutableSource();
|
||
},
|
||
useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
|
||
currentHookNameInDev = "useSyncExternalStore";
|
||
updateHookTypesDev();
|
||
return updateSyncExternalStore(subscribe, getSnapshot);
|
||
},
|
||
useId: function() {
|
||
currentHookNameInDev = "useId";
|
||
updateHookTypesDev();
|
||
return updateId();
|
||
},
|
||
unstable_isNewReconciler: enableNewReconciler
|
||
};
|
||
InvalidNestedHooksDispatcherOnMountInDEV = {
|
||
readContext: function(context) {
|
||
warnInvalidContextAccess();
|
||
return readContext(context);
|
||
},
|
||
useCallback: function(callback, deps) {
|
||
currentHookNameInDev = "useCallback";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
return mountCallback(callback, deps);
|
||
},
|
||
useContext: function(context) {
|
||
currentHookNameInDev = "useContext";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
return readContext(context);
|
||
},
|
||
useEffect: function(create, deps) {
|
||
currentHookNameInDev = "useEffect";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
return mountEffect(create, deps);
|
||
},
|
||
useImperativeHandle: function(ref, create, deps) {
|
||
currentHookNameInDev = "useImperativeHandle";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
return mountImperativeHandle(ref, create, deps);
|
||
},
|
||
useInsertionEffect: function(create, deps) {
|
||
currentHookNameInDev = "useInsertionEffect";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
return mountInsertionEffect(create, deps);
|
||
},
|
||
useLayoutEffect: function(create, deps) {
|
||
currentHookNameInDev = "useLayoutEffect";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
return mountLayoutEffect(create, deps);
|
||
},
|
||
useMemo: function(create, deps) {
|
||
currentHookNameInDev = "useMemo";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
||
try {
|
||
return mountMemo(create, deps);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useReducer: function(reducer, initialArg, init) {
|
||
currentHookNameInDev = "useReducer";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
||
try {
|
||
return mountReducer(reducer, initialArg, init);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useRef: function(initialValue) {
|
||
currentHookNameInDev = "useRef";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
return mountRef(initialValue);
|
||
},
|
||
useState: function(initialState) {
|
||
currentHookNameInDev = "useState";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
||
try {
|
||
return mountState(initialState);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useDebugValue: function(value, formatterFn) {
|
||
currentHookNameInDev = "useDebugValue";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
return mountDebugValue();
|
||
},
|
||
useDeferredValue: function(value) {
|
||
currentHookNameInDev = "useDeferredValue";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
return mountDeferredValue(value);
|
||
},
|
||
useTransition: function() {
|
||
currentHookNameInDev = "useTransition";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
return mountTransition();
|
||
},
|
||
useMutableSource: function(source, getSnapshot, subscribe) {
|
||
currentHookNameInDev = "useMutableSource";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
return mountMutableSource();
|
||
},
|
||
useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
|
||
currentHookNameInDev = "useSyncExternalStore";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
return mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
||
},
|
||
useId: function() {
|
||
currentHookNameInDev = "useId";
|
||
warnInvalidHookAccess();
|
||
mountHookTypesDev();
|
||
return mountId();
|
||
},
|
||
unstable_isNewReconciler: enableNewReconciler
|
||
};
|
||
InvalidNestedHooksDispatcherOnUpdateInDEV = {
|
||
readContext: function(context) {
|
||
warnInvalidContextAccess();
|
||
return readContext(context);
|
||
},
|
||
useCallback: function(callback, deps) {
|
||
currentHookNameInDev = "useCallback";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateCallback(callback, deps);
|
||
},
|
||
useContext: function(context) {
|
||
currentHookNameInDev = "useContext";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return readContext(context);
|
||
},
|
||
useEffect: function(create, deps) {
|
||
currentHookNameInDev = "useEffect";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateEffect(create, deps);
|
||
},
|
||
useImperativeHandle: function(ref, create, deps) {
|
||
currentHookNameInDev = "useImperativeHandle";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateImperativeHandle(ref, create, deps);
|
||
},
|
||
useInsertionEffect: function(create, deps) {
|
||
currentHookNameInDev = "useInsertionEffect";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateInsertionEffect(create, deps);
|
||
},
|
||
useLayoutEffect: function(create, deps) {
|
||
currentHookNameInDev = "useLayoutEffect";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateLayoutEffect(create, deps);
|
||
},
|
||
useMemo: function(create, deps) {
|
||
currentHookNameInDev = "useMemo";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
||
try {
|
||
return updateMemo(create, deps);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useReducer: function(reducer, initialArg, init) {
|
||
currentHookNameInDev = "useReducer";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
||
try {
|
||
return updateReducer(reducer, initialArg, init);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useRef: function(initialValue) {
|
||
currentHookNameInDev = "useRef";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateRef();
|
||
},
|
||
useState: function(initialState) {
|
||
currentHookNameInDev = "useState";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
||
try {
|
||
return updateState(initialState);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useDebugValue: function(value, formatterFn) {
|
||
currentHookNameInDev = "useDebugValue";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateDebugValue();
|
||
},
|
||
useDeferredValue: function(value) {
|
||
currentHookNameInDev = "useDeferredValue";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateDeferredValue(value);
|
||
},
|
||
useTransition: function() {
|
||
currentHookNameInDev = "useTransition";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateTransition();
|
||
},
|
||
useMutableSource: function(source, getSnapshot, subscribe) {
|
||
currentHookNameInDev = "useMutableSource";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateMutableSource();
|
||
},
|
||
useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
|
||
currentHookNameInDev = "useSyncExternalStore";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateSyncExternalStore(subscribe, getSnapshot);
|
||
},
|
||
useId: function() {
|
||
currentHookNameInDev = "useId";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateId();
|
||
},
|
||
unstable_isNewReconciler: enableNewReconciler
|
||
};
|
||
InvalidNestedHooksDispatcherOnRerenderInDEV = {
|
||
readContext: function(context) {
|
||
warnInvalidContextAccess();
|
||
return readContext(context);
|
||
},
|
||
useCallback: function(callback, deps) {
|
||
currentHookNameInDev = "useCallback";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateCallback(callback, deps);
|
||
},
|
||
useContext: function(context) {
|
||
currentHookNameInDev = "useContext";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return readContext(context);
|
||
},
|
||
useEffect: function(create, deps) {
|
||
currentHookNameInDev = "useEffect";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateEffect(create, deps);
|
||
},
|
||
useImperativeHandle: function(ref, create, deps) {
|
||
currentHookNameInDev = "useImperativeHandle";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateImperativeHandle(ref, create, deps);
|
||
},
|
||
useInsertionEffect: function(create, deps) {
|
||
currentHookNameInDev = "useInsertionEffect";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateInsertionEffect(create, deps);
|
||
},
|
||
useLayoutEffect: function(create, deps) {
|
||
currentHookNameInDev = "useLayoutEffect";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateLayoutEffect(create, deps);
|
||
},
|
||
useMemo: function(create, deps) {
|
||
currentHookNameInDev = "useMemo";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
||
try {
|
||
return updateMemo(create, deps);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useReducer: function(reducer, initialArg, init) {
|
||
currentHookNameInDev = "useReducer";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
||
try {
|
||
return rerenderReducer(reducer, initialArg, init);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useRef: function(initialValue) {
|
||
currentHookNameInDev = "useRef";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateRef();
|
||
},
|
||
useState: function(initialState) {
|
||
currentHookNameInDev = "useState";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
||
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
||
try {
|
||
return rerenderState(initialState);
|
||
} finally {
|
||
ReactCurrentDispatcher$1.current = prevDispatcher;
|
||
}
|
||
},
|
||
useDebugValue: function(value, formatterFn) {
|
||
currentHookNameInDev = "useDebugValue";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateDebugValue();
|
||
},
|
||
useDeferredValue: function(value) {
|
||
currentHookNameInDev = "useDeferredValue";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return rerenderDeferredValue(value);
|
||
},
|
||
useTransition: function() {
|
||
currentHookNameInDev = "useTransition";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return rerenderTransition();
|
||
},
|
||
useMutableSource: function(source, getSnapshot, subscribe) {
|
||
currentHookNameInDev = "useMutableSource";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateMutableSource();
|
||
},
|
||
useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) {
|
||
currentHookNameInDev = "useSyncExternalStore";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateSyncExternalStore(subscribe, getSnapshot);
|
||
},
|
||
useId: function() {
|
||
currentHookNameInDev = "useId";
|
||
warnInvalidHookAccess();
|
||
updateHookTypesDev();
|
||
return updateId();
|
||
},
|
||
unstable_isNewReconciler: enableNewReconciler
|
||
};
|
||
}
|
||
var now$1 = Scheduler.unstable_now;
|
||
var commitTime = 0;
|
||
var layoutEffectStartTime = -1;
|
||
var profilerStartTime = -1;
|
||
var passiveEffectStartTime = -1;
|
||
var currentUpdateIsNested = false;
|
||
var nestedUpdateScheduled = false;
|
||
function isCurrentUpdateNested() {
|
||
return currentUpdateIsNested;
|
||
}
|
||
function markNestedUpdateScheduled() {
|
||
{
|
||
nestedUpdateScheduled = true;
|
||
}
|
||
}
|
||
function resetNestedUpdateFlag() {
|
||
{
|
||
currentUpdateIsNested = false;
|
||
nestedUpdateScheduled = false;
|
||
}
|
||
}
|
||
function syncNestedUpdateFlag() {
|
||
{
|
||
currentUpdateIsNested = nestedUpdateScheduled;
|
||
nestedUpdateScheduled = false;
|
||
}
|
||
}
|
||
function getCommitTime() {
|
||
return commitTime;
|
||
}
|
||
function recordCommitTime() {
|
||
commitTime = now$1();
|
||
}
|
||
function startProfilerTimer(fiber) {
|
||
profilerStartTime = now$1();
|
||
if (fiber.actualStartTime < 0) {
|
||
fiber.actualStartTime = now$1();
|
||
}
|
||
}
|
||
function stopProfilerTimerIfRunning(fiber) {
|
||
profilerStartTime = -1;
|
||
}
|
||
function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
|
||
if (profilerStartTime >= 0) {
|
||
var elapsedTime = now$1() - profilerStartTime;
|
||
fiber.actualDuration += elapsedTime;
|
||
if (overrideBaseTime) {
|
||
fiber.selfBaseDuration = elapsedTime;
|
||
}
|
||
profilerStartTime = -1;
|
||
}
|
||
}
|
||
function recordLayoutEffectDuration(fiber) {
|
||
if (layoutEffectStartTime >= 0) {
|
||
var elapsedTime = now$1() - layoutEffectStartTime;
|
||
layoutEffectStartTime = -1;
|
||
var parentFiber = fiber.return;
|
||
while (parentFiber !== null) {
|
||
switch (parentFiber.tag) {
|
||
case HostRoot:
|
||
var root2 = parentFiber.stateNode;
|
||
root2.effectDuration += elapsedTime;
|
||
return;
|
||
case Profiler:
|
||
var parentStateNode = parentFiber.stateNode;
|
||
parentStateNode.effectDuration += elapsedTime;
|
||
return;
|
||
}
|
||
parentFiber = parentFiber.return;
|
||
}
|
||
}
|
||
}
|
||
function recordPassiveEffectDuration(fiber) {
|
||
if (passiveEffectStartTime >= 0) {
|
||
var elapsedTime = now$1() - passiveEffectStartTime;
|
||
passiveEffectStartTime = -1;
|
||
var parentFiber = fiber.return;
|
||
while (parentFiber !== null) {
|
||
switch (parentFiber.tag) {
|
||
case HostRoot:
|
||
var root2 = parentFiber.stateNode;
|
||
if (root2 !== null) {
|
||
root2.passiveEffectDuration += elapsedTime;
|
||
}
|
||
return;
|
||
case Profiler:
|
||
var parentStateNode = parentFiber.stateNode;
|
||
if (parentStateNode !== null) {
|
||
parentStateNode.passiveEffectDuration += elapsedTime;
|
||
}
|
||
return;
|
||
}
|
||
parentFiber = parentFiber.return;
|
||
}
|
||
}
|
||
}
|
||
function startLayoutEffectTimer() {
|
||
layoutEffectStartTime = now$1();
|
||
}
|
||
function startPassiveEffectTimer() {
|
||
passiveEffectStartTime = now$1();
|
||
}
|
||
function transferActualDuration(fiber) {
|
||
var child = fiber.child;
|
||
while (child) {
|
||
fiber.actualDuration += child.actualDuration;
|
||
child = child.sibling;
|
||
}
|
||
}
|
||
function createCapturedValueAtFiber(value, source) {
|
||
return {
|
||
value,
|
||
source,
|
||
stack: getStackByFiberInDevAndProd(source),
|
||
digest: null
|
||
};
|
||
}
|
||
function createCapturedValue(value, digest, stack) {
|
||
return {
|
||
value,
|
||
source: null,
|
||
stack: stack != null ? stack : null,
|
||
digest: digest != null ? digest : null
|
||
};
|
||
}
|
||
function showErrorDialog(boundary, errorInfo) {
|
||
return true;
|
||
}
|
||
function logCapturedError(boundary, errorInfo) {
|
||
try {
|
||
var logError = showErrorDialog(boundary, errorInfo);
|
||
if (logError === false) {
|
||
return;
|
||
}
|
||
var error2 = errorInfo.value;
|
||
if (true) {
|
||
var source = errorInfo.source;
|
||
var stack = errorInfo.stack;
|
||
var componentStack = stack !== null ? stack : "";
|
||
if (error2 != null && error2._suppressLogging) {
|
||
if (boundary.tag === ClassComponent) {
|
||
return;
|
||
}
|
||
console["error"](error2);
|
||
}
|
||
var componentName = source ? getComponentNameFromFiber(source) : null;
|
||
var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : "The above error occurred in one of your React components:";
|
||
var errorBoundaryMessage;
|
||
if (boundary.tag === HostRoot) {
|
||
errorBoundaryMessage = "Consider adding an error boundary to your tree to customize error handling behavior.\nVisit https://reactjs.org/link/error-boundaries to learn more about error boundaries.";
|
||
} else {
|
||
var errorBoundaryName = getComponentNameFromFiber(boundary) || "Anonymous";
|
||
errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + ".");
|
||
}
|
||
var combinedMessage = componentNameMessage + "\n" + componentStack + "\n\n" + ("" + errorBoundaryMessage);
|
||
console["error"](combinedMessage);
|
||
} else {
|
||
console["error"](error2);
|
||
}
|
||
} catch (e) {
|
||
setTimeout(function() {
|
||
throw e;
|
||
});
|
||
}
|
||
}
|
||
var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map;
|
||
function createRootErrorUpdate(fiber, errorInfo, lane) {
|
||
var update = createUpdate(NoTimestamp, lane);
|
||
update.tag = CaptureUpdate;
|
||
update.payload = {
|
||
element: null
|
||
};
|
||
var error2 = errorInfo.value;
|
||
update.callback = function() {
|
||
onUncaughtError(error2);
|
||
logCapturedError(fiber, errorInfo);
|
||
};
|
||
return update;
|
||
}
|
||
function createClassErrorUpdate(fiber, errorInfo, lane) {
|
||
var update = createUpdate(NoTimestamp, lane);
|
||
update.tag = CaptureUpdate;
|
||
var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
|
||
if (typeof getDerivedStateFromError === "function") {
|
||
var error$1 = errorInfo.value;
|
||
update.payload = function() {
|
||
return getDerivedStateFromError(error$1);
|
||
};
|
||
update.callback = function() {
|
||
{
|
||
markFailedErrorBoundaryForHotReloading(fiber);
|
||
}
|
||
logCapturedError(fiber, errorInfo);
|
||
};
|
||
}
|
||
var inst = fiber.stateNode;
|
||
if (inst !== null && typeof inst.componentDidCatch === "function") {
|
||
update.callback = function callback() {
|
||
{
|
||
markFailedErrorBoundaryForHotReloading(fiber);
|
||
}
|
||
logCapturedError(fiber, errorInfo);
|
||
if (typeof getDerivedStateFromError !== "function") {
|
||
markLegacyErrorBoundaryAsFailed(this);
|
||
}
|
||
var error$12 = errorInfo.value;
|
||
var stack = errorInfo.stack;
|
||
this.componentDidCatch(error$12, {
|
||
componentStack: stack !== null ? stack : ""
|
||
});
|
||
{
|
||
if (typeof getDerivedStateFromError !== "function") {
|
||
if (!includesSomeLane(fiber.lanes, SyncLane)) {
|
||
error("%s: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.", getComponentNameFromFiber(fiber) || "Unknown");
|
||
}
|
||
}
|
||
}
|
||
};
|
||
}
|
||
return update;
|
||
}
|
||
function attachPingListener(root2, wakeable, lanes) {
|
||
var pingCache = root2.pingCache;
|
||
var threadIDs;
|
||
if (pingCache === null) {
|
||
pingCache = root2.pingCache = new PossiblyWeakMap$1();
|
||
threadIDs = /* @__PURE__ */ new Set();
|
||
pingCache.set(wakeable, threadIDs);
|
||
} else {
|
||
threadIDs = pingCache.get(wakeable);
|
||
if (threadIDs === void 0) {
|
||
threadIDs = /* @__PURE__ */ new Set();
|
||
pingCache.set(wakeable, threadIDs);
|
||
}
|
||
}
|
||
if (!threadIDs.has(lanes)) {
|
||
threadIDs.add(lanes);
|
||
var ping = pingSuspendedRoot.bind(null, root2, wakeable, lanes);
|
||
{
|
||
if (isDevToolsPresent) {
|
||
restorePendingUpdaters(root2, lanes);
|
||
}
|
||
}
|
||
wakeable.then(ping, ping);
|
||
}
|
||
}
|
||
function attachRetryListener(suspenseBoundary, root2, wakeable, lanes) {
|
||
var wakeables = suspenseBoundary.updateQueue;
|
||
if (wakeables === null) {
|
||
var updateQueue = /* @__PURE__ */ new Set();
|
||
updateQueue.add(wakeable);
|
||
suspenseBoundary.updateQueue = updateQueue;
|
||
} else {
|
||
wakeables.add(wakeable);
|
||
}
|
||
}
|
||
function resetSuspendedComponent(sourceFiber, rootRenderLanes) {
|
||
var tag = sourceFiber.tag;
|
||
if ((sourceFiber.mode & ConcurrentMode) === NoMode && (tag === FunctionComponent || tag === ForwardRef || tag === SimpleMemoComponent)) {
|
||
var currentSource = sourceFiber.alternate;
|
||
if (currentSource) {
|
||
sourceFiber.updateQueue = currentSource.updateQueue;
|
||
sourceFiber.memoizedState = currentSource.memoizedState;
|
||
sourceFiber.lanes = currentSource.lanes;
|
||
} else {
|
||
sourceFiber.updateQueue = null;
|
||
sourceFiber.memoizedState = null;
|
||
}
|
||
}
|
||
}
|
||
function getNearestSuspenseBoundaryToCapture(returnFiber) {
|
||
var node = returnFiber;
|
||
do {
|
||
if (node.tag === SuspenseComponent && shouldCaptureSuspense(node)) {
|
||
return node;
|
||
}
|
||
node = node.return;
|
||
} while (node !== null);
|
||
return null;
|
||
}
|
||
function markSuspenseBoundaryShouldCapture(suspenseBoundary, returnFiber, sourceFiber, root2, rootRenderLanes) {
|
||
if ((suspenseBoundary.mode & ConcurrentMode) === NoMode) {
|
||
if (suspenseBoundary === returnFiber) {
|
||
suspenseBoundary.flags |= ShouldCapture;
|
||
} else {
|
||
suspenseBoundary.flags |= DidCapture;
|
||
sourceFiber.flags |= ForceUpdateForLegacySuspense;
|
||
sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete);
|
||
if (sourceFiber.tag === ClassComponent) {
|
||
var currentSourceFiber = sourceFiber.alternate;
|
||
if (currentSourceFiber === null) {
|
||
sourceFiber.tag = IncompleteClassComponent;
|
||
} else {
|
||
var update = createUpdate(NoTimestamp, SyncLane);
|
||
update.tag = ForceUpdate;
|
||
enqueueUpdate(sourceFiber, update, SyncLane);
|
||
}
|
||
}
|
||
sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane);
|
||
}
|
||
return suspenseBoundary;
|
||
}
|
||
suspenseBoundary.flags |= ShouldCapture;
|
||
suspenseBoundary.lanes = rootRenderLanes;
|
||
return suspenseBoundary;
|
||
}
|
||
function throwException(root2, returnFiber, sourceFiber, value, rootRenderLanes) {
|
||
sourceFiber.flags |= Incomplete;
|
||
{
|
||
if (isDevToolsPresent) {
|
||
restorePendingUpdaters(root2, rootRenderLanes);
|
||
}
|
||
}
|
||
if (value !== null && typeof value === "object" && typeof value.then === "function") {
|
||
var wakeable = value;
|
||
resetSuspendedComponent(sourceFiber);
|
||
{
|
||
if (getIsHydrating() && sourceFiber.mode & ConcurrentMode) {
|
||
markDidThrowWhileHydratingDEV();
|
||
}
|
||
}
|
||
var suspenseBoundary = getNearestSuspenseBoundaryToCapture(returnFiber);
|
||
if (suspenseBoundary !== null) {
|
||
suspenseBoundary.flags &= ~ForceClientRender;
|
||
markSuspenseBoundaryShouldCapture(suspenseBoundary, returnFiber, sourceFiber, root2, rootRenderLanes);
|
||
if (suspenseBoundary.mode & ConcurrentMode) {
|
||
attachPingListener(root2, wakeable, rootRenderLanes);
|
||
}
|
||
attachRetryListener(suspenseBoundary, root2, wakeable);
|
||
return;
|
||
} else {
|
||
if (!includesSyncLane(rootRenderLanes)) {
|
||
attachPingListener(root2, wakeable, rootRenderLanes);
|
||
renderDidSuspendDelayIfPossible();
|
||
return;
|
||
}
|
||
var uncaughtSuspenseError = new Error("A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition.");
|
||
value = uncaughtSuspenseError;
|
||
}
|
||
} else {
|
||
if (getIsHydrating() && sourceFiber.mode & ConcurrentMode) {
|
||
markDidThrowWhileHydratingDEV();
|
||
var _suspenseBoundary = getNearestSuspenseBoundaryToCapture(returnFiber);
|
||
if (_suspenseBoundary !== null) {
|
||
if ((_suspenseBoundary.flags & ShouldCapture) === NoFlags) {
|
||
_suspenseBoundary.flags |= ForceClientRender;
|
||
}
|
||
markSuspenseBoundaryShouldCapture(_suspenseBoundary, returnFiber, sourceFiber, root2, rootRenderLanes);
|
||
queueHydrationError(createCapturedValueAtFiber(value, sourceFiber));
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
value = createCapturedValueAtFiber(value, sourceFiber);
|
||
renderDidError(value);
|
||
var workInProgress2 = returnFiber;
|
||
do {
|
||
switch (workInProgress2.tag) {
|
||
case HostRoot: {
|
||
var _errorInfo = value;
|
||
workInProgress2.flags |= ShouldCapture;
|
||
var lane = pickArbitraryLane(rootRenderLanes);
|
||
workInProgress2.lanes = mergeLanes(workInProgress2.lanes, lane);
|
||
var update = createRootErrorUpdate(workInProgress2, _errorInfo, lane);
|
||
enqueueCapturedUpdate(workInProgress2, update);
|
||
return;
|
||
}
|
||
case ClassComponent:
|
||
var errorInfo = value;
|
||
var ctor = workInProgress2.type;
|
||
var instance = workInProgress2.stateNode;
|
||
if ((workInProgress2.flags & DidCapture) === NoFlags && (typeof ctor.getDerivedStateFromError === "function" || instance !== null && typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance))) {
|
||
workInProgress2.flags |= ShouldCapture;
|
||
var _lane = pickArbitraryLane(rootRenderLanes);
|
||
workInProgress2.lanes = mergeLanes(workInProgress2.lanes, _lane);
|
||
var _update = createClassErrorUpdate(workInProgress2, errorInfo, _lane);
|
||
enqueueCapturedUpdate(workInProgress2, _update);
|
||
return;
|
||
}
|
||
break;
|
||
}
|
||
workInProgress2 = workInProgress2.return;
|
||
} while (workInProgress2 !== null);
|
||
}
|
||
function getSuspendedCache() {
|
||
{
|
||
return null;
|
||
}
|
||
}
|
||
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
||
var didReceiveUpdate = false;
|
||
var didWarnAboutBadClass;
|
||
var didWarnAboutModulePatternComponent;
|
||
var didWarnAboutContextTypeOnFunctionComponent;
|
||
var didWarnAboutGetDerivedStateOnFunctionComponent;
|
||
var didWarnAboutFunctionRefs;
|
||
var didWarnAboutReassigningProps;
|
||
var didWarnAboutRevealOrder;
|
||
var didWarnAboutTailOptions;
|
||
{
|
||
didWarnAboutBadClass = {};
|
||
didWarnAboutModulePatternComponent = {};
|
||
didWarnAboutContextTypeOnFunctionComponent = {};
|
||
didWarnAboutGetDerivedStateOnFunctionComponent = {};
|
||
didWarnAboutFunctionRefs = {};
|
||
didWarnAboutReassigningProps = false;
|
||
didWarnAboutRevealOrder = {};
|
||
didWarnAboutTailOptions = {};
|
||
}
|
||
function reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2) {
|
||
if (current2 === null) {
|
||
workInProgress2.child = mountChildFibers(workInProgress2, null, nextChildren, renderLanes2);
|
||
} else {
|
||
workInProgress2.child = reconcileChildFibers(workInProgress2, current2.child, nextChildren, renderLanes2);
|
||
}
|
||
}
|
||
function forceUnmountCurrentAndReconcile(current2, workInProgress2, nextChildren, renderLanes2) {
|
||
workInProgress2.child = reconcileChildFibers(workInProgress2, current2.child, null, renderLanes2);
|
||
workInProgress2.child = reconcileChildFibers(workInProgress2, null, nextChildren, renderLanes2);
|
||
}
|
||
function updateForwardRef(current2, workInProgress2, Component, nextProps, renderLanes2) {
|
||
{
|
||
if (workInProgress2.type !== workInProgress2.elementType) {
|
||
var innerPropTypes = Component.propTypes;
|
||
if (innerPropTypes) {
|
||
checkPropTypes(innerPropTypes, nextProps, "prop", getComponentNameFromType(Component));
|
||
}
|
||
}
|
||
}
|
||
var render3 = Component.render;
|
||
var ref = workInProgress2.ref;
|
||
var nextChildren;
|
||
var hasId;
|
||
prepareToReadContext(workInProgress2, renderLanes2);
|
||
{
|
||
markComponentRenderStarted(workInProgress2);
|
||
}
|
||
{
|
||
ReactCurrentOwner$1.current = workInProgress2;
|
||
setIsRendering(true);
|
||
nextChildren = renderWithHooks(current2, workInProgress2, render3, nextProps, ref, renderLanes2);
|
||
hasId = checkDidRenderIdHook();
|
||
if (workInProgress2.mode & StrictLegacyMode) {
|
||
setIsStrictModeForDevtools(true);
|
||
try {
|
||
nextChildren = renderWithHooks(current2, workInProgress2, render3, nextProps, ref, renderLanes2);
|
||
hasId = checkDidRenderIdHook();
|
||
} finally {
|
||
setIsStrictModeForDevtools(false);
|
||
}
|
||
}
|
||
setIsRendering(false);
|
||
}
|
||
{
|
||
markComponentRenderStopped();
|
||
}
|
||
if (current2 !== null && !didReceiveUpdate) {
|
||
bailoutHooks(current2, workInProgress2, renderLanes2);
|
||
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
||
}
|
||
if (getIsHydrating() && hasId) {
|
||
pushMaterializedTreeId(workInProgress2);
|
||
}
|
||
workInProgress2.flags |= PerformedWork;
|
||
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
||
return workInProgress2.child;
|
||
}
|
||
function updateMemoComponent(current2, workInProgress2, Component, nextProps, renderLanes2) {
|
||
if (current2 === null) {
|
||
var type = Component.type;
|
||
if (isSimpleFunctionComponent(type) && Component.compare === null && Component.defaultProps === void 0) {
|
||
var resolvedType = type;
|
||
{
|
||
resolvedType = resolveFunctionForHotReloading(type);
|
||
}
|
||
workInProgress2.tag = SimpleMemoComponent;
|
||
workInProgress2.type = resolvedType;
|
||
{
|
||
validateFunctionComponentInDev(workInProgress2, type);
|
||
}
|
||
return updateSimpleMemoComponent(current2, workInProgress2, resolvedType, nextProps, renderLanes2);
|
||
}
|
||
{
|
||
var innerPropTypes = type.propTypes;
|
||
if (innerPropTypes) {
|
||
checkPropTypes(innerPropTypes, nextProps, "prop", getComponentNameFromType(type));
|
||
}
|
||
}
|
||
var child = createFiberFromTypeAndProps(Component.type, null, nextProps, workInProgress2, workInProgress2.mode, renderLanes2);
|
||
child.ref = workInProgress2.ref;
|
||
child.return = workInProgress2;
|
||
workInProgress2.child = child;
|
||
return child;
|
||
}
|
||
{
|
||
var _type = Component.type;
|
||
var _innerPropTypes = _type.propTypes;
|
||
if (_innerPropTypes) {
|
||
checkPropTypes(_innerPropTypes, nextProps, "prop", getComponentNameFromType(_type));
|
||
}
|
||
}
|
||
var currentChild = current2.child;
|
||
var hasScheduledUpdateOrContext = checkScheduledUpdateOrContext(current2, renderLanes2);
|
||
if (!hasScheduledUpdateOrContext) {
|
||
var prevProps = currentChild.memoizedProps;
|
||
var compare = Component.compare;
|
||
compare = compare !== null ? compare : shallowEqual;
|
||
if (compare(prevProps, nextProps) && current2.ref === workInProgress2.ref) {
|
||
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
||
}
|
||
}
|
||
workInProgress2.flags |= PerformedWork;
|
||
var newChild = createWorkInProgress(currentChild, nextProps);
|
||
newChild.ref = workInProgress2.ref;
|
||
newChild.return = workInProgress2;
|
||
workInProgress2.child = newChild;
|
||
return newChild;
|
||
}
|
||
function updateSimpleMemoComponent(current2, workInProgress2, Component, nextProps, renderLanes2) {
|
||
{
|
||
if (workInProgress2.type !== workInProgress2.elementType) {
|
||
var outerMemoType = workInProgress2.elementType;
|
||
if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
|
||
var lazyComponent = outerMemoType;
|
||
var payload = lazyComponent._payload;
|
||
var init = lazyComponent._init;
|
||
try {
|
||
outerMemoType = init(payload);
|
||
} catch (x) {
|
||
outerMemoType = null;
|
||
}
|
||
var outerPropTypes = outerMemoType && outerMemoType.propTypes;
|
||
if (outerPropTypes) {
|
||
checkPropTypes(outerPropTypes, nextProps, "prop", getComponentNameFromType(outerMemoType));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (current2 !== null) {
|
||
var prevProps = current2.memoizedProps;
|
||
if (shallowEqual(prevProps, nextProps) && current2.ref === workInProgress2.ref && workInProgress2.type === current2.type) {
|
||
didReceiveUpdate = false;
|
||
workInProgress2.pendingProps = nextProps = prevProps;
|
||
if (!checkScheduledUpdateOrContext(current2, renderLanes2)) {
|
||
workInProgress2.lanes = current2.lanes;
|
||
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
||
} else if ((current2.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
|
||
didReceiveUpdate = true;
|
||
}
|
||
}
|
||
}
|
||
return updateFunctionComponent(current2, workInProgress2, Component, nextProps, renderLanes2);
|
||
}
|
||
function updateOffscreenComponent(current2, workInProgress2, renderLanes2) {
|
||
var nextProps = workInProgress2.pendingProps;
|
||
var nextChildren = nextProps.children;
|
||
var prevState = current2 !== null ? current2.memoizedState : null;
|
||
if (nextProps.mode === "hidden" || enableLegacyHidden) {
|
||
if ((workInProgress2.mode & ConcurrentMode) === NoMode) {
|
||
var nextState = {
|
||
baseLanes: NoLanes,
|
||
cachePool: null,
|
||
transitions: null
|
||
};
|
||
workInProgress2.memoizedState = nextState;
|
||
pushRenderLanes(workInProgress2, renderLanes2);
|
||
} else if (!includesSomeLane(renderLanes2, OffscreenLane)) {
|
||
var spawnedCachePool = null;
|
||
var nextBaseLanes;
|
||
if (prevState !== null) {
|
||
var prevBaseLanes = prevState.baseLanes;
|
||
nextBaseLanes = mergeLanes(prevBaseLanes, renderLanes2);
|
||
} else {
|
||
nextBaseLanes = renderLanes2;
|
||
}
|
||
workInProgress2.lanes = workInProgress2.childLanes = laneToLanes(OffscreenLane);
|
||
var _nextState = {
|
||
baseLanes: nextBaseLanes,
|
||
cachePool: spawnedCachePool,
|
||
transitions: null
|
||
};
|
||
workInProgress2.memoizedState = _nextState;
|
||
workInProgress2.updateQueue = null;
|
||
pushRenderLanes(workInProgress2, nextBaseLanes);
|
||
return null;
|
||
} else {
|
||
var _nextState2 = {
|
||
baseLanes: NoLanes,
|
||
cachePool: null,
|
||
transitions: null
|
||
};
|
||
workInProgress2.memoizedState = _nextState2;
|
||
var subtreeRenderLanes2 = prevState !== null ? prevState.baseLanes : renderLanes2;
|
||
pushRenderLanes(workInProgress2, subtreeRenderLanes2);
|
||
}
|
||
} else {
|
||
var _subtreeRenderLanes;
|
||
if (prevState !== null) {
|
||
_subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes2);
|
||
workInProgress2.memoizedState = null;
|
||
} else {
|
||
_subtreeRenderLanes = renderLanes2;
|
||
}
|
||
pushRenderLanes(workInProgress2, _subtreeRenderLanes);
|
||
}
|
||
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
||
return workInProgress2.child;
|
||
}
|
||
function updateFragment(current2, workInProgress2, renderLanes2) {
|
||
var nextChildren = workInProgress2.pendingProps;
|
||
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
||
return workInProgress2.child;
|
||
}
|
||
function updateMode(current2, workInProgress2, renderLanes2) {
|
||
var nextChildren = workInProgress2.pendingProps.children;
|
||
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
||
return workInProgress2.child;
|
||
}
|
||
function updateProfiler(current2, workInProgress2, renderLanes2) {
|
||
{
|
||
workInProgress2.flags |= Update;
|
||
{
|
||
var stateNode = workInProgress2.stateNode;
|
||
stateNode.effectDuration = 0;
|
||
stateNode.passiveEffectDuration = 0;
|
||
}
|
||
}
|
||
var nextProps = workInProgress2.pendingProps;
|
||
var nextChildren = nextProps.children;
|
||
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
||
return workInProgress2.child;
|
||
}
|
||
function markRef(current2, workInProgress2) {
|
||
var ref = workInProgress2.ref;
|
||
if (current2 === null && ref !== null || current2 !== null && current2.ref !== ref) {
|
||
workInProgress2.flags |= Ref;
|
||
{
|
||
workInProgress2.flags |= RefStatic;
|
||
}
|
||
}
|
||
}
|
||
function updateFunctionComponent(current2, workInProgress2, Component, nextProps, renderLanes2) {
|
||
{
|
||
if (workInProgress2.type !== workInProgress2.elementType) {
|
||
var innerPropTypes = Component.propTypes;
|
||
if (innerPropTypes) {
|
||
checkPropTypes(innerPropTypes, nextProps, "prop", getComponentNameFromType(Component));
|
||
}
|
||
}
|
||
}
|
||
var context;
|
||
{
|
||
var unmaskedContext = getUnmaskedContext(workInProgress2, Component, true);
|
||
context = getMaskedContext(workInProgress2, unmaskedContext);
|
||
}
|
||
var nextChildren;
|
||
var hasId;
|
||
prepareToReadContext(workInProgress2, renderLanes2);
|
||
{
|
||
markComponentRenderStarted(workInProgress2);
|
||
}
|
||
{
|
||
ReactCurrentOwner$1.current = workInProgress2;
|
||
setIsRendering(true);
|
||
nextChildren = renderWithHooks(current2, workInProgress2, Component, nextProps, context, renderLanes2);
|
||
hasId = checkDidRenderIdHook();
|
||
if (workInProgress2.mode & StrictLegacyMode) {
|
||
setIsStrictModeForDevtools(true);
|
||
try {
|
||
nextChildren = renderWithHooks(current2, workInProgress2, Component, nextProps, context, renderLanes2);
|
||
hasId = checkDidRenderIdHook();
|
||
} finally {
|
||
setIsStrictModeForDevtools(false);
|
||
}
|
||
}
|
||
setIsRendering(false);
|
||
}
|
||
{
|
||
markComponentRenderStopped();
|
||
}
|
||
if (current2 !== null && !didReceiveUpdate) {
|
||
bailoutHooks(current2, workInProgress2, renderLanes2);
|
||
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
||
}
|
||
if (getIsHydrating() && hasId) {
|
||
pushMaterializedTreeId(workInProgress2);
|
||
}
|
||
workInProgress2.flags |= PerformedWork;
|
||
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
||
return workInProgress2.child;
|
||
}
|
||
function updateClassComponent(current2, workInProgress2, Component, nextProps, renderLanes2) {
|
||
{
|
||
switch (shouldError(workInProgress2)) {
|
||
case false: {
|
||
var _instance = workInProgress2.stateNode;
|
||
var ctor = workInProgress2.type;
|
||
var tempInstance = new ctor(workInProgress2.memoizedProps, _instance.context);
|
||
var state = tempInstance.state;
|
||
_instance.updater.enqueueSetState(_instance, state, null);
|
||
break;
|
||
}
|
||
case true: {
|
||
workInProgress2.flags |= DidCapture;
|
||
workInProgress2.flags |= ShouldCapture;
|
||
var error$1 = new Error("Simulated error coming from DevTools");
|
||
var lane = pickArbitraryLane(renderLanes2);
|
||
workInProgress2.lanes = mergeLanes(workInProgress2.lanes, lane);
|
||
var update = createClassErrorUpdate(workInProgress2, createCapturedValueAtFiber(error$1, workInProgress2), lane);
|
||
enqueueCapturedUpdate(workInProgress2, update);
|
||
break;
|
||
}
|
||
}
|
||
if (workInProgress2.type !== workInProgress2.elementType) {
|
||
var innerPropTypes = Component.propTypes;
|
||
if (innerPropTypes) {
|
||
checkPropTypes(innerPropTypes, nextProps, "prop", getComponentNameFromType(Component));
|
||
}
|
||
}
|
||
}
|
||
var hasContext;
|
||
if (isContextProvider(Component)) {
|
||
hasContext = true;
|
||
pushContextProvider(workInProgress2);
|
||
} else {
|
||
hasContext = false;
|
||
}
|
||
prepareToReadContext(workInProgress2, renderLanes2);
|
||
var instance = workInProgress2.stateNode;
|
||
var shouldUpdate;
|
||
if (instance === null) {
|
||
resetSuspendedCurrentOnMountInLegacyMode(current2, workInProgress2);
|
||
constructClassInstance(workInProgress2, Component, nextProps);
|
||
mountClassInstance(workInProgress2, Component, nextProps, renderLanes2);
|
||
shouldUpdate = true;
|
||
} else if (current2 === null) {
|
||
shouldUpdate = resumeMountClassInstance(workInProgress2, Component, nextProps, renderLanes2);
|
||
} else {
|
||
shouldUpdate = updateClassInstance(current2, workInProgress2, Component, nextProps, renderLanes2);
|
||
}
|
||
var nextUnitOfWork = finishClassComponent(current2, workInProgress2, Component, shouldUpdate, hasContext, renderLanes2);
|
||
{
|
||
var inst = workInProgress2.stateNode;
|
||
if (shouldUpdate && inst.props !== nextProps) {
|
||
if (!didWarnAboutReassigningProps) {
|
||
error("It looks like %s is reassigning its own `this.props` while rendering. This is not supported and can lead to confusing bugs.", getComponentNameFromFiber(workInProgress2) || "a component");
|
||
}
|
||
didWarnAboutReassigningProps = true;
|
||
}
|
||
}
|
||
return nextUnitOfWork;
|
||
}
|
||
function finishClassComponent(current2, workInProgress2, Component, shouldUpdate, hasContext, renderLanes2) {
|
||
markRef(current2, workInProgress2);
|
||
var didCaptureError = (workInProgress2.flags & DidCapture) !== NoFlags;
|
||
if (!shouldUpdate && !didCaptureError) {
|
||
if (hasContext) {
|
||
invalidateContextProvider(workInProgress2, Component, false);
|
||
}
|
||
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
||
}
|
||
var instance = workInProgress2.stateNode;
|
||
ReactCurrentOwner$1.current = workInProgress2;
|
||
var nextChildren;
|
||
if (didCaptureError && typeof Component.getDerivedStateFromError !== "function") {
|
||
nextChildren = null;
|
||
{
|
||
stopProfilerTimerIfRunning();
|
||
}
|
||
} else {
|
||
{
|
||
markComponentRenderStarted(workInProgress2);
|
||
}
|
||
{
|
||
setIsRendering(true);
|
||
nextChildren = instance.render();
|
||
if (workInProgress2.mode & StrictLegacyMode) {
|
||
setIsStrictModeForDevtools(true);
|
||
try {
|
||
instance.render();
|
||
} finally {
|
||
setIsStrictModeForDevtools(false);
|
||
}
|
||
}
|
||
setIsRendering(false);
|
||
}
|
||
{
|
||
markComponentRenderStopped();
|
||
}
|
||
}
|
||
workInProgress2.flags |= PerformedWork;
|
||
if (current2 !== null && didCaptureError) {
|
||
forceUnmountCurrentAndReconcile(current2, workInProgress2, nextChildren, renderLanes2);
|
||
} else {
|
||
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
||
}
|
||
workInProgress2.memoizedState = instance.state;
|
||
if (hasContext) {
|
||
invalidateContextProvider(workInProgress2, Component, true);
|
||
}
|
||
return workInProgress2.child;
|
||
}
|
||
function pushHostRootContext(workInProgress2) {
|
||
var root2 = workInProgress2.stateNode;
|
||
if (root2.pendingContext) {
|
||
pushTopLevelContextObject(workInProgress2, root2.pendingContext, root2.pendingContext !== root2.context);
|
||
} else if (root2.context) {
|
||
pushTopLevelContextObject(workInProgress2, root2.context, false);
|
||
}
|
||
pushHostContainer(workInProgress2, root2.containerInfo);
|
||
}
|
||
function updateHostRoot(current2, workInProgress2, renderLanes2) {
|
||
pushHostRootContext(workInProgress2);
|
||
if (current2 === null) {
|
||
throw new Error("Should have a current fiber. This is a bug in React.");
|
||
}
|
||
var nextProps = workInProgress2.pendingProps;
|
||
var prevState = workInProgress2.memoizedState;
|
||
var prevChildren = prevState.element;
|
||
cloneUpdateQueue(current2, workInProgress2);
|
||
processUpdateQueue(workInProgress2, nextProps, null, renderLanes2);
|
||
var nextState = workInProgress2.memoizedState;
|
||
var root2 = workInProgress2.stateNode;
|
||
var nextChildren = nextState.element;
|
||
if (prevState.isDehydrated) {
|
||
var overrideState = {
|
||
element: nextChildren,
|
||
isDehydrated: false,
|
||
cache: nextState.cache,
|
||
pendingSuspenseBoundaries: nextState.pendingSuspenseBoundaries,
|
||
transitions: nextState.transitions
|
||
};
|
||
var updateQueue = workInProgress2.updateQueue;
|
||
updateQueue.baseState = overrideState;
|
||
workInProgress2.memoizedState = overrideState;
|
||
if (workInProgress2.flags & ForceClientRender) {
|
||
var recoverableError = createCapturedValueAtFiber(new Error("There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering."), workInProgress2);
|
||
return mountHostRootWithoutHydrating(current2, workInProgress2, nextChildren, renderLanes2, recoverableError);
|
||
} else if (nextChildren !== prevChildren) {
|
||
var _recoverableError = createCapturedValueAtFiber(new Error("This root received an early update, before anything was able hydrate. Switched the entire root to client rendering."), workInProgress2);
|
||
return mountHostRootWithoutHydrating(current2, workInProgress2, nextChildren, renderLanes2, _recoverableError);
|
||
} else {
|
||
enterHydrationState(workInProgress2);
|
||
var child = mountChildFibers(workInProgress2, null, nextChildren, renderLanes2);
|
||
workInProgress2.child = child;
|
||
var node = child;
|
||
while (node) {
|
||
node.flags = node.flags & ~Placement | Hydrating;
|
||
node = node.sibling;
|
||
}
|
||
}
|
||
} else {
|
||
resetHydrationState();
|
||
if (nextChildren === prevChildren) {
|
||
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
||
}
|
||
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
||
}
|
||
return workInProgress2.child;
|
||
}
|
||
function mountHostRootWithoutHydrating(current2, workInProgress2, nextChildren, renderLanes2, recoverableError) {
|
||
resetHydrationState();
|
||
queueHydrationError(recoverableError);
|
||
workInProgress2.flags |= ForceClientRender;
|
||
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
||
return workInProgress2.child;
|
||
}
|
||
function updateHostComponent(current2, workInProgress2, renderLanes2) {
|
||
pushHostContext(workInProgress2);
|
||
if (current2 === null) {
|
||
tryToClaimNextHydratableInstance(workInProgress2);
|
||
}
|
||
var type = workInProgress2.type;
|
||
var nextProps = workInProgress2.pendingProps;
|
||
var prevProps = current2 !== null ? current2.memoizedProps : null;
|
||
var nextChildren = nextProps.children;
|
||
var isDirectTextChild = shouldSetTextContent(type, nextProps);
|
||
if (isDirectTextChild) {
|
||
nextChildren = null;
|
||
} else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
|
||
workInProgress2.flags |= ContentReset;
|
||
}
|
||
markRef(current2, workInProgress2);
|
||
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
||
return workInProgress2.child;
|
||
}
|
||
function updateHostText(current2, workInProgress2) {
|
||
if (current2 === null) {
|
||
tryToClaimNextHydratableInstance(workInProgress2);
|
||
}
|
||
return null;
|
||
}
|
||
function mountLazyComponent(_current, workInProgress2, elementType, renderLanes2) {
|
||
resetSuspendedCurrentOnMountInLegacyMode(_current, workInProgress2);
|
||
var props = workInProgress2.pendingProps;
|
||
var lazyComponent = elementType;
|
||
var payload = lazyComponent._payload;
|
||
var init = lazyComponent._init;
|
||
var Component = init(payload);
|
||
workInProgress2.type = Component;
|
||
var resolvedTag = workInProgress2.tag = resolveLazyComponentTag(Component);
|
||
var resolvedProps = resolveDefaultProps(Component, props);
|
||
var child;
|
||
switch (resolvedTag) {
|
||
case FunctionComponent: {
|
||
{
|
||
validateFunctionComponentInDev(workInProgress2, Component);
|
||
workInProgress2.type = Component = resolveFunctionForHotReloading(Component);
|
||
}
|
||
child = updateFunctionComponent(null, workInProgress2, Component, resolvedProps, renderLanes2);
|
||
return child;
|
||
}
|
||
case ClassComponent: {
|
||
{
|
||
workInProgress2.type = Component = resolveClassForHotReloading(Component);
|
||
}
|
||
child = updateClassComponent(null, workInProgress2, Component, resolvedProps, renderLanes2);
|
||
return child;
|
||
}
|
||
case ForwardRef: {
|
||
{
|
||
workInProgress2.type = Component = resolveForwardRefForHotReloading(Component);
|
||
}
|
||
child = updateForwardRef(null, workInProgress2, Component, resolvedProps, renderLanes2);
|
||
return child;
|
||
}
|
||
case MemoComponent: {
|
||
{
|
||
if (workInProgress2.type !== workInProgress2.elementType) {
|
||
var outerPropTypes = Component.propTypes;
|
||
if (outerPropTypes) {
|
||
checkPropTypes(outerPropTypes, resolvedProps, "prop", getComponentNameFromType(Component));
|
||
}
|
||
}
|
||
}
|
||
child = updateMemoComponent(null, workInProgress2, Component, resolveDefaultProps(Component.type, resolvedProps), renderLanes2);
|
||
return child;
|
||
}
|
||
}
|
||
var hint = "";
|
||
{
|
||
if (Component !== null && typeof Component === "object" && Component.$$typeof === REACT_LAZY_TYPE) {
|
||
hint = " Did you wrap a component in React.lazy() more than once?";
|
||
}
|
||
}
|
||
throw new Error("Element type is invalid. Received a promise that resolves to: " + Component + ". " + ("Lazy element type must resolve to a class or function." + hint));
|
||
}
|
||
function mountIncompleteClassComponent(_current, workInProgress2, Component, nextProps, renderLanes2) {
|
||
resetSuspendedCurrentOnMountInLegacyMode(_current, workInProgress2);
|
||
workInProgress2.tag = ClassComponent;
|
||
var hasContext;
|
||
if (isContextProvider(Component)) {
|
||
hasContext = true;
|
||
pushContextProvider(workInProgress2);
|
||
} else {
|
||
hasContext = false;
|
||
}
|
||
prepareToReadContext(workInProgress2, renderLanes2);
|
||
constructClassInstance(workInProgress2, Component, nextProps);
|
||
mountClassInstance(workInProgress2, Component, nextProps, renderLanes2);
|
||
return finishClassComponent(null, workInProgress2, Component, true, hasContext, renderLanes2);
|
||
}
|
||
function mountIndeterminateComponent(_current, workInProgress2, Component, renderLanes2) {
|
||
resetSuspendedCurrentOnMountInLegacyMode(_current, workInProgress2);
|
||
var props = workInProgress2.pendingProps;
|
||
var context;
|
||
{
|
||
var unmaskedContext = getUnmaskedContext(workInProgress2, Component, false);
|
||
context = getMaskedContext(workInProgress2, unmaskedContext);
|
||
}
|
||
prepareToReadContext(workInProgress2, renderLanes2);
|
||
var value;
|
||
var hasId;
|
||
{
|
||
markComponentRenderStarted(workInProgress2);
|
||
}
|
||
{
|
||
if (Component.prototype && typeof Component.prototype.render === "function") {
|
||
var componentName = getComponentNameFromType(Component) || "Unknown";
|
||
if (!didWarnAboutBadClass[componentName]) {
|
||
error("The <%s /> component appears to have a render method, but doesn't extend React.Component. This is likely to cause errors. Change %s to extend React.Component instead.", componentName, componentName);
|
||
didWarnAboutBadClass[componentName] = true;
|
||
}
|
||
}
|
||
if (workInProgress2.mode & StrictLegacyMode) {
|
||
ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress2, null);
|
||
}
|
||
setIsRendering(true);
|
||
ReactCurrentOwner$1.current = workInProgress2;
|
||
value = renderWithHooks(null, workInProgress2, Component, props, context, renderLanes2);
|
||
hasId = checkDidRenderIdHook();
|
||
setIsRendering(false);
|
||
}
|
||
{
|
||
markComponentRenderStopped();
|
||
}
|
||
workInProgress2.flags |= PerformedWork;
|
||
{
|
||
if (typeof value === "object" && value !== null && typeof value.render === "function" && value.$$typeof === void 0) {
|
||
var _componentName = getComponentNameFromType(Component) || "Unknown";
|
||
if (!didWarnAboutModulePatternComponent[_componentName]) {
|
||
error("The <%s /> component appears to be a function component that returns a class instance. Change %s to a class that extends React.Component instead. If you can't use a class try assigning the prototype on the function as a workaround. `%s.prototype = React.Component.prototype`. Don't use an arrow function since it cannot be called with `new` by React.", _componentName, _componentName, _componentName);
|
||
didWarnAboutModulePatternComponent[_componentName] = true;
|
||
}
|
||
}
|
||
}
|
||
if (typeof value === "object" && value !== null && typeof value.render === "function" && value.$$typeof === void 0) {
|
||
{
|
||
var _componentName2 = getComponentNameFromType(Component) || "Unknown";
|
||
if (!didWarnAboutModulePatternComponent[_componentName2]) {
|
||
error("The <%s /> component appears to be a function component that returns a class instance. Change %s to a class that extends React.Component instead. If you can't use a class try assigning the prototype on the function as a workaround. `%s.prototype = React.Component.prototype`. Don't use an arrow function since it cannot be called with `new` by React.", _componentName2, _componentName2, _componentName2);
|
||
didWarnAboutModulePatternComponent[_componentName2] = true;
|
||
}
|
||
}
|
||
workInProgress2.tag = ClassComponent;
|
||
workInProgress2.memoizedState = null;
|
||
workInProgress2.updateQueue = null;
|
||
var hasContext = false;
|
||
if (isContextProvider(Component)) {
|
||
hasContext = true;
|
||
pushContextProvider(workInProgress2);
|
||
} else {
|
||
hasContext = false;
|
||
}
|
||
workInProgress2.memoizedState = value.state !== null && value.state !== void 0 ? value.state : null;
|
||
initializeUpdateQueue(workInProgress2);
|
||
adoptClassInstance(workInProgress2, value);
|
||
mountClassInstance(workInProgress2, Component, props, renderLanes2);
|
||
return finishClassComponent(null, workInProgress2, Component, true, hasContext, renderLanes2);
|
||
} else {
|
||
workInProgress2.tag = FunctionComponent;
|
||
{
|
||
if (workInProgress2.mode & StrictLegacyMode) {
|
||
setIsStrictModeForDevtools(true);
|
||
try {
|
||
value = renderWithHooks(null, workInProgress2, Component, props, context, renderLanes2);
|
||
hasId = checkDidRenderIdHook();
|
||
} finally {
|
||
setIsStrictModeForDevtools(false);
|
||
}
|
||
}
|
||
}
|
||
if (getIsHydrating() && hasId) {
|
||
pushMaterializedTreeId(workInProgress2);
|
||
}
|
||
reconcileChildren(null, workInProgress2, value, renderLanes2);
|
||
{
|
||
validateFunctionComponentInDev(workInProgress2, Component);
|
||
}
|
||
return workInProgress2.child;
|
||
}
|
||
}
|
||
function validateFunctionComponentInDev(workInProgress2, Component) {
|
||
{
|
||
if (Component) {
|
||
if (Component.childContextTypes) {
|
||
error("%s(...): childContextTypes cannot be defined on a function component.", Component.displayName || Component.name || "Component");
|
||
}
|
||
}
|
||
if (workInProgress2.ref !== null) {
|
||
var info = "";
|
||
var ownerName = getCurrentFiberOwnerNameInDevOrNull();
|
||
if (ownerName) {
|
||
info += "\n\nCheck the render method of `" + ownerName + "`.";
|
||
}
|
||
var warningKey = ownerName || "";
|
||
var debugSource = workInProgress2._debugSource;
|
||
if (debugSource) {
|
||
warningKey = debugSource.fileName + ":" + debugSource.lineNumber;
|
||
}
|
||
if (!didWarnAboutFunctionRefs[warningKey]) {
|
||
didWarnAboutFunctionRefs[warningKey] = true;
|
||
error("Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?%s", info);
|
||
}
|
||
}
|
||
if (typeof Component.getDerivedStateFromProps === "function") {
|
||
var _componentName3 = getComponentNameFromType(Component) || "Unknown";
|
||
if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) {
|
||
error("%s: Function components do not support getDerivedStateFromProps.", _componentName3);
|
||
didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true;
|
||
}
|
||
}
|
||
if (typeof Component.contextType === "object" && Component.contextType !== null) {
|
||
var _componentName4 = getComponentNameFromType(Component) || "Unknown";
|
||
if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
|
||
error("%s: Function components do not support contextType.", _componentName4);
|
||
didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var SUSPENDED_MARKER = {
|
||
dehydrated: null,
|
||
treeContext: null,
|
||
retryLane: NoLane
|
||
};
|
||
function mountSuspenseOffscreenState(renderLanes2) {
|
||
return {
|
||
baseLanes: renderLanes2,
|
||
cachePool: getSuspendedCache(),
|
||
transitions: null
|
||
};
|
||
}
|
||
function updateSuspenseOffscreenState(prevOffscreenState, renderLanes2) {
|
||
var cachePool = null;
|
||
return {
|
||
baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes2),
|
||
cachePool,
|
||
transitions: prevOffscreenState.transitions
|
||
};
|
||
}
|
||
function shouldRemainOnFallback(suspenseContext, current2, workInProgress2, renderLanes2) {
|
||
if (current2 !== null) {
|
||
var suspenseState = current2.memoizedState;
|
||
if (suspenseState === null) {
|
||
return false;
|
||
}
|
||
}
|
||
return hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
||
}
|
||
function getRemainingWorkInPrimaryTree(current2, renderLanes2) {
|
||
return removeLanes(current2.childLanes, renderLanes2);
|
||
}
|
||
function updateSuspenseComponent(current2, workInProgress2, renderLanes2) {
|
||
var nextProps = workInProgress2.pendingProps;
|
||
{
|
||
if (shouldSuspend(workInProgress2)) {
|
||
workInProgress2.flags |= DidCapture;
|
||
}
|
||
}
|
||
var suspenseContext = suspenseStackCursor.current;
|
||
var showFallback = false;
|
||
var didSuspend = (workInProgress2.flags & DidCapture) !== NoFlags;
|
||
if (didSuspend || shouldRemainOnFallback(suspenseContext, current2)) {
|
||
showFallback = true;
|
||
workInProgress2.flags &= ~DidCapture;
|
||
} else {
|
||
if (current2 === null || current2.memoizedState !== null) {
|
||
{
|
||
suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext);
|
||
}
|
||
}
|
||
}
|
||
suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
||
pushSuspenseContext(workInProgress2, suspenseContext);
|
||
if (current2 === null) {
|
||
tryToClaimNextHydratableInstance(workInProgress2);
|
||
var suspenseState = workInProgress2.memoizedState;
|
||
if (suspenseState !== null) {
|
||
var dehydrated = suspenseState.dehydrated;
|
||
if (dehydrated !== null) {
|
||
return mountDehydratedSuspenseComponent(workInProgress2, dehydrated);
|
||
}
|
||
}
|
||
var nextPrimaryChildren = nextProps.children;
|
||
var nextFallbackChildren = nextProps.fallback;
|
||
if (showFallback) {
|
||
var fallbackFragment = mountSuspenseFallbackChildren(workInProgress2, nextPrimaryChildren, nextFallbackChildren, renderLanes2);
|
||
var primaryChildFragment = workInProgress2.child;
|
||
primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes2);
|
||
workInProgress2.memoizedState = SUSPENDED_MARKER;
|
||
return fallbackFragment;
|
||
} else {
|
||
return mountSuspensePrimaryChildren(workInProgress2, nextPrimaryChildren);
|
||
}
|
||
} else {
|
||
var prevState = current2.memoizedState;
|
||
if (prevState !== null) {
|
||
var _dehydrated = prevState.dehydrated;
|
||
if (_dehydrated !== null) {
|
||
return updateDehydratedSuspenseComponent(current2, workInProgress2, didSuspend, nextProps, _dehydrated, prevState, renderLanes2);
|
||
}
|
||
}
|
||
if (showFallback) {
|
||
var _nextFallbackChildren = nextProps.fallback;
|
||
var _nextPrimaryChildren = nextProps.children;
|
||
var fallbackChildFragment = updateSuspenseFallbackChildren(current2, workInProgress2, _nextPrimaryChildren, _nextFallbackChildren, renderLanes2);
|
||
var _primaryChildFragment2 = workInProgress2.child;
|
||
var prevOffscreenState = current2.child.memoizedState;
|
||
_primaryChildFragment2.memoizedState = prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes2) : updateSuspenseOffscreenState(prevOffscreenState, renderLanes2);
|
||
_primaryChildFragment2.childLanes = getRemainingWorkInPrimaryTree(current2, renderLanes2);
|
||
workInProgress2.memoizedState = SUSPENDED_MARKER;
|
||
return fallbackChildFragment;
|
||
} else {
|
||
var _nextPrimaryChildren2 = nextProps.children;
|
||
var _primaryChildFragment3 = updateSuspensePrimaryChildren(current2, workInProgress2, _nextPrimaryChildren2, renderLanes2);
|
||
workInProgress2.memoizedState = null;
|
||
return _primaryChildFragment3;
|
||
}
|
||
}
|
||
}
|
||
function mountSuspensePrimaryChildren(workInProgress2, primaryChildren, renderLanes2) {
|
||
var mode = workInProgress2.mode;
|
||
var primaryChildProps = {
|
||
mode: "visible",
|
||
children: primaryChildren
|
||
};
|
||
var primaryChildFragment = mountWorkInProgressOffscreenFiber(primaryChildProps, mode);
|
||
primaryChildFragment.return = workInProgress2;
|
||
workInProgress2.child = primaryChildFragment;
|
||
return primaryChildFragment;
|
||
}
|
||
function mountSuspenseFallbackChildren(workInProgress2, primaryChildren, fallbackChildren, renderLanes2) {
|
||
var mode = workInProgress2.mode;
|
||
var progressedPrimaryFragment = workInProgress2.child;
|
||
var primaryChildProps = {
|
||
mode: "hidden",
|
||
children: primaryChildren
|
||
};
|
||
var primaryChildFragment;
|
||
var fallbackChildFragment;
|
||
if ((mode & ConcurrentMode) === NoMode && progressedPrimaryFragment !== null) {
|
||
primaryChildFragment = progressedPrimaryFragment;
|
||
primaryChildFragment.childLanes = NoLanes;
|
||
primaryChildFragment.pendingProps = primaryChildProps;
|
||
if (workInProgress2.mode & ProfileMode) {
|
||
primaryChildFragment.actualDuration = 0;
|
||
primaryChildFragment.actualStartTime = -1;
|
||
primaryChildFragment.selfBaseDuration = 0;
|
||
primaryChildFragment.treeBaseDuration = 0;
|
||
}
|
||
fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes2, null);
|
||
} else {
|
||
primaryChildFragment = mountWorkInProgressOffscreenFiber(primaryChildProps, mode);
|
||
fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes2, null);
|
||
}
|
||
primaryChildFragment.return = workInProgress2;
|
||
fallbackChildFragment.return = workInProgress2;
|
||
primaryChildFragment.sibling = fallbackChildFragment;
|
||
workInProgress2.child = primaryChildFragment;
|
||
return fallbackChildFragment;
|
||
}
|
||
function mountWorkInProgressOffscreenFiber(offscreenProps, mode, renderLanes2) {
|
||
return createFiberFromOffscreen(offscreenProps, mode, NoLanes, null);
|
||
}
|
||
function updateWorkInProgressOffscreenFiber(current2, offscreenProps) {
|
||
return createWorkInProgress(current2, offscreenProps);
|
||
}
|
||
function updateSuspensePrimaryChildren(current2, workInProgress2, primaryChildren, renderLanes2) {
|
||
var currentPrimaryChildFragment = current2.child;
|
||
var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
|
||
var primaryChildFragment = updateWorkInProgressOffscreenFiber(currentPrimaryChildFragment, {
|
||
mode: "visible",
|
||
children: primaryChildren
|
||
});
|
||
if ((workInProgress2.mode & ConcurrentMode) === NoMode) {
|
||
primaryChildFragment.lanes = renderLanes2;
|
||
}
|
||
primaryChildFragment.return = workInProgress2;
|
||
primaryChildFragment.sibling = null;
|
||
if (currentFallbackChildFragment !== null) {
|
||
var deletions = workInProgress2.deletions;
|
||
if (deletions === null) {
|
||
workInProgress2.deletions = [currentFallbackChildFragment];
|
||
workInProgress2.flags |= ChildDeletion;
|
||
} else {
|
||
deletions.push(currentFallbackChildFragment);
|
||
}
|
||
}
|
||
workInProgress2.child = primaryChildFragment;
|
||
return primaryChildFragment;
|
||
}
|
||
function updateSuspenseFallbackChildren(current2, workInProgress2, primaryChildren, fallbackChildren, renderLanes2) {
|
||
var mode = workInProgress2.mode;
|
||
var currentPrimaryChildFragment = current2.child;
|
||
var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
|
||
var primaryChildProps = {
|
||
mode: "hidden",
|
||
children: primaryChildren
|
||
};
|
||
var primaryChildFragment;
|
||
if ((mode & ConcurrentMode) === NoMode && workInProgress2.child !== currentPrimaryChildFragment) {
|
||
var progressedPrimaryFragment = workInProgress2.child;
|
||
primaryChildFragment = progressedPrimaryFragment;
|
||
primaryChildFragment.childLanes = NoLanes;
|
||
primaryChildFragment.pendingProps = primaryChildProps;
|
||
if (workInProgress2.mode & ProfileMode) {
|
||
primaryChildFragment.actualDuration = 0;
|
||
primaryChildFragment.actualStartTime = -1;
|
||
primaryChildFragment.selfBaseDuration = currentPrimaryChildFragment.selfBaseDuration;
|
||
primaryChildFragment.treeBaseDuration = currentPrimaryChildFragment.treeBaseDuration;
|
||
}
|
||
workInProgress2.deletions = null;
|
||
} else {
|
||
primaryChildFragment = updateWorkInProgressOffscreenFiber(currentPrimaryChildFragment, primaryChildProps);
|
||
primaryChildFragment.subtreeFlags = currentPrimaryChildFragment.subtreeFlags & StaticMask;
|
||
}
|
||
var fallbackChildFragment;
|
||
if (currentFallbackChildFragment !== null) {
|
||
fallbackChildFragment = createWorkInProgress(currentFallbackChildFragment, fallbackChildren);
|
||
} else {
|
||
fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes2, null);
|
||
fallbackChildFragment.flags |= Placement;
|
||
}
|
||
fallbackChildFragment.return = workInProgress2;
|
||
primaryChildFragment.return = workInProgress2;
|
||
primaryChildFragment.sibling = fallbackChildFragment;
|
||
workInProgress2.child = primaryChildFragment;
|
||
return fallbackChildFragment;
|
||
}
|
||
function retrySuspenseComponentWithoutHydrating(current2, workInProgress2, renderLanes2, recoverableError) {
|
||
if (recoverableError !== null) {
|
||
queueHydrationError(recoverableError);
|
||
}
|
||
reconcileChildFibers(workInProgress2, current2.child, null, renderLanes2);
|
||
var nextProps = workInProgress2.pendingProps;
|
||
var primaryChildren = nextProps.children;
|
||
var primaryChildFragment = mountSuspensePrimaryChildren(workInProgress2, primaryChildren);
|
||
primaryChildFragment.flags |= Placement;
|
||
workInProgress2.memoizedState = null;
|
||
return primaryChildFragment;
|
||
}
|
||
function mountSuspenseFallbackAfterRetryWithoutHydrating(current2, workInProgress2, primaryChildren, fallbackChildren, renderLanes2) {
|
||
var fiberMode = workInProgress2.mode;
|
||
var primaryChildProps = {
|
||
mode: "visible",
|
||
children: primaryChildren
|
||
};
|
||
var primaryChildFragment = mountWorkInProgressOffscreenFiber(primaryChildProps, fiberMode);
|
||
var fallbackChildFragment = createFiberFromFragment(fallbackChildren, fiberMode, renderLanes2, null);
|
||
fallbackChildFragment.flags |= Placement;
|
||
primaryChildFragment.return = workInProgress2;
|
||
fallbackChildFragment.return = workInProgress2;
|
||
primaryChildFragment.sibling = fallbackChildFragment;
|
||
workInProgress2.child = primaryChildFragment;
|
||
if ((workInProgress2.mode & ConcurrentMode) !== NoMode) {
|
||
reconcileChildFibers(workInProgress2, current2.child, null, renderLanes2);
|
||
}
|
||
return fallbackChildFragment;
|
||
}
|
||
function mountDehydratedSuspenseComponent(workInProgress2, suspenseInstance, renderLanes2) {
|
||
if ((workInProgress2.mode & ConcurrentMode) === NoMode) {
|
||
{
|
||
error("Cannot hydrate Suspense in legacy mode. Switch from ReactDOM.hydrate(element, container) to ReactDOMClient.hydrateRoot(container, <App />).render(element) or remove the Suspense components from the server rendered components.");
|
||
}
|
||
workInProgress2.lanes = laneToLanes(SyncLane);
|
||
} else if (isSuspenseInstanceFallback(suspenseInstance)) {
|
||
workInProgress2.lanes = laneToLanes(DefaultHydrationLane);
|
||
} else {
|
||
workInProgress2.lanes = laneToLanes(OffscreenLane);
|
||
}
|
||
return null;
|
||
}
|
||
function updateDehydratedSuspenseComponent(current2, workInProgress2, didSuspend, nextProps, suspenseInstance, suspenseState, renderLanes2) {
|
||
if (!didSuspend) {
|
||
warnIfHydrating();
|
||
if ((workInProgress2.mode & ConcurrentMode) === NoMode) {
|
||
return retrySuspenseComponentWithoutHydrating(current2, workInProgress2, renderLanes2, null);
|
||
}
|
||
if (isSuspenseInstanceFallback(suspenseInstance)) {
|
||
var digest, message, stack;
|
||
{
|
||
var _getSuspenseInstanceF = getSuspenseInstanceFallbackErrorDetails(suspenseInstance);
|
||
digest = _getSuspenseInstanceF.digest;
|
||
message = _getSuspenseInstanceF.message;
|
||
stack = _getSuspenseInstanceF.stack;
|
||
}
|
||
var error2;
|
||
if (message) {
|
||
error2 = new Error(message);
|
||
} else {
|
||
error2 = new Error("The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.");
|
||
}
|
||
var capturedValue = createCapturedValue(error2, digest, stack);
|
||
return retrySuspenseComponentWithoutHydrating(current2, workInProgress2, renderLanes2, capturedValue);
|
||
}
|
||
var hasContextChanged2 = includesSomeLane(renderLanes2, current2.childLanes);
|
||
if (didReceiveUpdate || hasContextChanged2) {
|
||
var root2 = getWorkInProgressRoot();
|
||
if (root2 !== null) {
|
||
var attemptHydrationAtLane = getBumpedLaneForHydration(root2, renderLanes2);
|
||
if (attemptHydrationAtLane !== NoLane && attemptHydrationAtLane !== suspenseState.retryLane) {
|
||
suspenseState.retryLane = attemptHydrationAtLane;
|
||
var eventTime = NoTimestamp;
|
||
enqueueConcurrentRenderForLane(current2, attemptHydrationAtLane);
|
||
scheduleUpdateOnFiber(root2, current2, attemptHydrationAtLane, eventTime);
|
||
}
|
||
}
|
||
renderDidSuspendDelayIfPossible();
|
||
var _capturedValue = createCapturedValue(new Error("This Suspense boundary received an update before it finished hydrating. This caused the boundary to switch to client rendering. The usual way to fix this is to wrap the original update in startTransition."));
|
||
return retrySuspenseComponentWithoutHydrating(current2, workInProgress2, renderLanes2, _capturedValue);
|
||
} else if (isSuspenseInstancePending(suspenseInstance)) {
|
||
workInProgress2.flags |= DidCapture;
|
||
workInProgress2.child = current2.child;
|
||
var retry = retryDehydratedSuspenseBoundary.bind(null, current2);
|
||
registerSuspenseInstanceRetry(suspenseInstance, retry);
|
||
return null;
|
||
} else {
|
||
reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress2, suspenseInstance, suspenseState.treeContext);
|
||
var primaryChildren = nextProps.children;
|
||
var primaryChildFragment = mountSuspensePrimaryChildren(workInProgress2, primaryChildren);
|
||
primaryChildFragment.flags |= Hydrating;
|
||
return primaryChildFragment;
|
||
}
|
||
} else {
|
||
if (workInProgress2.flags & ForceClientRender) {
|
||
workInProgress2.flags &= ~ForceClientRender;
|
||
var _capturedValue2 = createCapturedValue(new Error("There was an error while hydrating this Suspense boundary. Switched to client rendering."));
|
||
return retrySuspenseComponentWithoutHydrating(current2, workInProgress2, renderLanes2, _capturedValue2);
|
||
} else if (workInProgress2.memoizedState !== null) {
|
||
workInProgress2.child = current2.child;
|
||
workInProgress2.flags |= DidCapture;
|
||
return null;
|
||
} else {
|
||
var nextPrimaryChildren = nextProps.children;
|
||
var nextFallbackChildren = nextProps.fallback;
|
||
var fallbackChildFragment = mountSuspenseFallbackAfterRetryWithoutHydrating(current2, workInProgress2, nextPrimaryChildren, nextFallbackChildren, renderLanes2);
|
||
var _primaryChildFragment4 = workInProgress2.child;
|
||
_primaryChildFragment4.memoizedState = mountSuspenseOffscreenState(renderLanes2);
|
||
workInProgress2.memoizedState = SUSPENDED_MARKER;
|
||
return fallbackChildFragment;
|
||
}
|
||
}
|
||
}
|
||
function scheduleSuspenseWorkOnFiber(fiber, renderLanes2, propagationRoot) {
|
||
fiber.lanes = mergeLanes(fiber.lanes, renderLanes2);
|
||
var alternate = fiber.alternate;
|
||
if (alternate !== null) {
|
||
alternate.lanes = mergeLanes(alternate.lanes, renderLanes2);
|
||
}
|
||
scheduleContextWorkOnParentPath(fiber.return, renderLanes2, propagationRoot);
|
||
}
|
||
function propagateSuspenseContextChange(workInProgress2, firstChild, renderLanes2) {
|
||
var node = firstChild;
|
||
while (node !== null) {
|
||
if (node.tag === SuspenseComponent) {
|
||
var state = node.memoizedState;
|
||
if (state !== null) {
|
||
scheduleSuspenseWorkOnFiber(node, renderLanes2, workInProgress2);
|
||
}
|
||
} else if (node.tag === SuspenseListComponent) {
|
||
scheduleSuspenseWorkOnFiber(node, renderLanes2, workInProgress2);
|
||
} else if (node.child !== null) {
|
||
node.child.return = node;
|
||
node = node.child;
|
||
continue;
|
||
}
|
||
if (node === workInProgress2) {
|
||
return;
|
||
}
|
||
while (node.sibling === null) {
|
||
if (node.return === null || node.return === workInProgress2) {
|
||
return;
|
||
}
|
||
node = node.return;
|
||
}
|
||
node.sibling.return = node.return;
|
||
node = node.sibling;
|
||
}
|
||
}
|
||
function findLastContentRow(firstChild) {
|
||
var row = firstChild;
|
||
var lastContentRow = null;
|
||
while (row !== null) {
|
||
var currentRow = row.alternate;
|
||
if (currentRow !== null && findFirstSuspended(currentRow) === null) {
|
||
lastContentRow = row;
|
||
}
|
||
row = row.sibling;
|
||
}
|
||
return lastContentRow;
|
||
}
|
||
function validateRevealOrder(revealOrder) {
|
||
{
|
||
if (revealOrder !== void 0 && revealOrder !== "forwards" && revealOrder !== "backwards" && revealOrder !== "together" && !didWarnAboutRevealOrder[revealOrder]) {
|
||
didWarnAboutRevealOrder[revealOrder] = true;
|
||
if (typeof revealOrder === "string") {
|
||
switch (revealOrder.toLowerCase()) {
|
||
case "together":
|
||
case "forwards":
|
||
case "backwards": {
|
||
error('"%s" is not a valid value for revealOrder on <SuspenseList />. Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase());
|
||
break;
|
||
}
|
||
case "forward":
|
||
case "backward": {
|
||
error('"%s" is not a valid value for revealOrder on <SuspenseList />. React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase());
|
||
break;
|
||
}
|
||
default:
|
||
error('"%s" is not a supported revealOrder on <SuspenseList />. Did you mean "together", "forwards" or "backwards"?', revealOrder);
|
||
break;
|
||
}
|
||
} else {
|
||
error('%s is not a supported value for revealOrder on <SuspenseList />. Did you mean "together", "forwards" or "backwards"?', revealOrder);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function validateTailOptions(tailMode, revealOrder) {
|
||
{
|
||
if (tailMode !== void 0 && !didWarnAboutTailOptions[tailMode]) {
|
||
if (tailMode !== "collapsed" && tailMode !== "hidden") {
|
||
didWarnAboutTailOptions[tailMode] = true;
|
||
error('"%s" is not a supported value for tail on <SuspenseList />. Did you mean "collapsed" or "hidden"?', tailMode);
|
||
} else if (revealOrder !== "forwards" && revealOrder !== "backwards") {
|
||
didWarnAboutTailOptions[tailMode] = true;
|
||
error('<SuspenseList tail="%s" /> is only valid if revealOrder is "forwards" or "backwards". Did you mean to specify revealOrder="forwards"?', tailMode);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function validateSuspenseListNestedChild(childSlot, index2) {
|
||
{
|
||
var isAnArray = isArray(childSlot);
|
||
var isIterable = !isAnArray && typeof getIteratorFn(childSlot) === "function";
|
||
if (isAnArray || isIterable) {
|
||
var type = isAnArray ? "array" : "iterable";
|
||
error("A nested %s was passed to row #%s in <SuspenseList />. Wrap it in an additional SuspenseList to configure its revealOrder: <SuspenseList revealOrder=...> ... <SuspenseList revealOrder=...>{%s}</SuspenseList> ... </SuspenseList>", type, index2, type);
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
function validateSuspenseListChildren(children, revealOrder) {
|
||
{
|
||
if ((revealOrder === "forwards" || revealOrder === "backwards") && children !== void 0 && children !== null && children !== false) {
|
||
if (isArray(children)) {
|
||
for (var i = 0; i < children.length; i++) {
|
||
if (!validateSuspenseListNestedChild(children[i], i)) {
|
||
return;
|
||
}
|
||
}
|
||
} else {
|
||
var iteratorFn = getIteratorFn(children);
|
||
if (typeof iteratorFn === "function") {
|
||
var childrenIterator = iteratorFn.call(children);
|
||
if (childrenIterator) {
|
||
var step = childrenIterator.next();
|
||
var _i = 0;
|
||
for (; !step.done; step = childrenIterator.next()) {
|
||
if (!validateSuspenseListNestedChild(step.value, _i)) {
|
||
return;
|
||
}
|
||
_i++;
|
||
}
|
||
}
|
||
} else {
|
||
error('A single row was passed to a <SuspenseList revealOrder="%s" />. This is not useful since it needs multiple rows. Did you mean to pass multiple children or an array?', revealOrder);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function initSuspenseListRenderState(workInProgress2, isBackwards, tail, lastContentRow, tailMode) {
|
||
var renderState = workInProgress2.memoizedState;
|
||
if (renderState === null) {
|
||
workInProgress2.memoizedState = {
|
||
isBackwards,
|
||
rendering: null,
|
||
renderingStartTime: 0,
|
||
last: lastContentRow,
|
||
tail,
|
||
tailMode
|
||
};
|
||
} else {
|
||
renderState.isBackwards = isBackwards;
|
||
renderState.rendering = null;
|
||
renderState.renderingStartTime = 0;
|
||
renderState.last = lastContentRow;
|
||
renderState.tail = tail;
|
||
renderState.tailMode = tailMode;
|
||
}
|
||
}
|
||
function updateSuspenseListComponent(current2, workInProgress2, renderLanes2) {
|
||
var nextProps = workInProgress2.pendingProps;
|
||
var revealOrder = nextProps.revealOrder;
|
||
var tailMode = nextProps.tail;
|
||
var newChildren = nextProps.children;
|
||
validateRevealOrder(revealOrder);
|
||
validateTailOptions(tailMode, revealOrder);
|
||
validateSuspenseListChildren(newChildren, revealOrder);
|
||
reconcileChildren(current2, workInProgress2, newChildren, renderLanes2);
|
||
var suspenseContext = suspenseStackCursor.current;
|
||
var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
||
if (shouldForceFallback) {
|
||
suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
||
workInProgress2.flags |= DidCapture;
|
||
} else {
|
||
var didSuspendBefore = current2 !== null && (current2.flags & DidCapture) !== NoFlags;
|
||
if (didSuspendBefore) {
|
||
propagateSuspenseContextChange(workInProgress2, workInProgress2.child, renderLanes2);
|
||
}
|
||
suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
||
}
|
||
pushSuspenseContext(workInProgress2, suspenseContext);
|
||
if ((workInProgress2.mode & ConcurrentMode) === NoMode) {
|
||
workInProgress2.memoizedState = null;
|
||
} else {
|
||
switch (revealOrder) {
|
||
case "forwards": {
|
||
var lastContentRow = findLastContentRow(workInProgress2.child);
|
||
var tail;
|
||
if (lastContentRow === null) {
|
||
tail = workInProgress2.child;
|
||
workInProgress2.child = null;
|
||
} else {
|
||
tail = lastContentRow.sibling;
|
||
lastContentRow.sibling = null;
|
||
}
|
||
initSuspenseListRenderState(workInProgress2, false, tail, lastContentRow, tailMode);
|
||
break;
|
||
}
|
||
case "backwards": {
|
||
var _tail = null;
|
||
var row = workInProgress2.child;
|
||
workInProgress2.child = null;
|
||
while (row !== null) {
|
||
var currentRow = row.alternate;
|
||
if (currentRow !== null && findFirstSuspended(currentRow) === null) {
|
||
workInProgress2.child = row;
|
||
break;
|
||
}
|
||
var nextRow = row.sibling;
|
||
row.sibling = _tail;
|
||
_tail = row;
|
||
row = nextRow;
|
||
}
|
||
initSuspenseListRenderState(workInProgress2, true, _tail, null, tailMode);
|
||
break;
|
||
}
|
||
case "together": {
|
||
initSuspenseListRenderState(workInProgress2, false, null, null, void 0);
|
||
break;
|
||
}
|
||
default: {
|
||
workInProgress2.memoizedState = null;
|
||
}
|
||
}
|
||
}
|
||
return workInProgress2.child;
|
||
}
|
||
function updatePortalComponent(current2, workInProgress2, renderLanes2) {
|
||
pushHostContainer(workInProgress2, workInProgress2.stateNode.containerInfo);
|
||
var nextChildren = workInProgress2.pendingProps;
|
||
if (current2 === null) {
|
||
workInProgress2.child = reconcileChildFibers(workInProgress2, null, nextChildren, renderLanes2);
|
||
} else {
|
||
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
||
}
|
||
return workInProgress2.child;
|
||
}
|
||
var hasWarnedAboutUsingNoValuePropOnContextProvider = false;
|
||
function updateContextProvider(current2, workInProgress2, renderLanes2) {
|
||
var providerType = workInProgress2.type;
|
||
var context = providerType._context;
|
||
var newProps = workInProgress2.pendingProps;
|
||
var oldProps = workInProgress2.memoizedProps;
|
||
var newValue = newProps.value;
|
||
{
|
||
if (!("value" in newProps)) {
|
||
if (!hasWarnedAboutUsingNoValuePropOnContextProvider) {
|
||
hasWarnedAboutUsingNoValuePropOnContextProvider = true;
|
||
error("The `value` prop is required for the `<Context.Provider>`. Did you misspell it or forget to pass it?");
|
||
}
|
||
}
|
||
var providerPropTypes = workInProgress2.type.propTypes;
|
||
if (providerPropTypes) {
|
||
checkPropTypes(providerPropTypes, newProps, "prop", "Context.Provider");
|
||
}
|
||
}
|
||
pushProvider(workInProgress2, context, newValue);
|
||
{
|
||
if (oldProps !== null) {
|
||
var oldValue = oldProps.value;
|
||
if (objectIs(oldValue, newValue)) {
|
||
if (oldProps.children === newProps.children && !hasContextChanged()) {
|
||
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
||
}
|
||
} else {
|
||
propagateContextChange(workInProgress2, context, renderLanes2);
|
||
}
|
||
}
|
||
}
|
||
var newChildren = newProps.children;
|
||
reconcileChildren(current2, workInProgress2, newChildren, renderLanes2);
|
||
return workInProgress2.child;
|
||
}
|
||
var hasWarnedAboutUsingContextAsConsumer = false;
|
||
function updateContextConsumer(current2, workInProgress2, renderLanes2) {
|
||
var context = workInProgress2.type;
|
||
{
|
||
if (context._context === void 0) {
|
||
if (context !== context.Consumer) {
|
||
if (!hasWarnedAboutUsingContextAsConsumer) {
|
||
hasWarnedAboutUsingContextAsConsumer = true;
|
||
error("Rendering <Context> directly is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?");
|
||
}
|
||
}
|
||
} else {
|
||
context = context._context;
|
||
}
|
||
}
|
||
var newProps = workInProgress2.pendingProps;
|
||
var render3 = newProps.children;
|
||
{
|
||
if (typeof render3 !== "function") {
|
||
error("A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it.");
|
||
}
|
||
}
|
||
prepareToReadContext(workInProgress2, renderLanes2);
|
||
var newValue = readContext(context);
|
||
{
|
||
markComponentRenderStarted(workInProgress2);
|
||
}
|
||
var newChildren;
|
||
{
|
||
ReactCurrentOwner$1.current = workInProgress2;
|
||
setIsRendering(true);
|
||
newChildren = render3(newValue);
|
||
setIsRendering(false);
|
||
}
|
||
{
|
||
markComponentRenderStopped();
|
||
}
|
||
workInProgress2.flags |= PerformedWork;
|
||
reconcileChildren(current2, workInProgress2, newChildren, renderLanes2);
|
||
return workInProgress2.child;
|
||
}
|
||
function markWorkInProgressReceivedUpdate() {
|
||
didReceiveUpdate = true;
|
||
}
|
||
function resetSuspendedCurrentOnMountInLegacyMode(current2, workInProgress2) {
|
||
if ((workInProgress2.mode & ConcurrentMode) === NoMode) {
|
||
if (current2 !== null) {
|
||
current2.alternate = null;
|
||
workInProgress2.alternate = null;
|
||
workInProgress2.flags |= Placement;
|
||
}
|
||
}
|
||
}
|
||
function bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2) {
|
||
if (current2 !== null) {
|
||
workInProgress2.dependencies = current2.dependencies;
|
||
}
|
||
{
|
||
stopProfilerTimerIfRunning();
|
||
}
|
||
markSkippedUpdateLanes(workInProgress2.lanes);
|
||
if (!includesSomeLane(renderLanes2, workInProgress2.childLanes)) {
|
||
{
|
||
return null;
|
||
}
|
||
}
|
||
cloneChildFibers(current2, workInProgress2);
|
||
return workInProgress2.child;
|
||
}
|
||
function remountFiber(current2, oldWorkInProgress, newWorkInProgress) {
|
||
{
|
||
var returnFiber = oldWorkInProgress.return;
|
||
if (returnFiber === null) {
|
||
throw new Error("Cannot swap the root fiber.");
|
||
}
|
||
current2.alternate = null;
|
||
oldWorkInProgress.alternate = null;
|
||
newWorkInProgress.index = oldWorkInProgress.index;
|
||
newWorkInProgress.sibling = oldWorkInProgress.sibling;
|
||
newWorkInProgress.return = oldWorkInProgress.return;
|
||
newWorkInProgress.ref = oldWorkInProgress.ref;
|
||
if (oldWorkInProgress === returnFiber.child) {
|
||
returnFiber.child = newWorkInProgress;
|
||
} else {
|
||
var prevSibling = returnFiber.child;
|
||
if (prevSibling === null) {
|
||
throw new Error("Expected parent to have a child.");
|
||
}
|
||
while (prevSibling.sibling !== oldWorkInProgress) {
|
||
prevSibling = prevSibling.sibling;
|
||
if (prevSibling === null) {
|
||
throw new Error("Expected to find the previous sibling.");
|
||
}
|
||
}
|
||
prevSibling.sibling = newWorkInProgress;
|
||
}
|
||
var deletions = returnFiber.deletions;
|
||
if (deletions === null) {
|
||
returnFiber.deletions = [current2];
|
||
returnFiber.flags |= ChildDeletion;
|
||
} else {
|
||
deletions.push(current2);
|
||
}
|
||
newWorkInProgress.flags |= Placement;
|
||
return newWorkInProgress;
|
||
}
|
||
}
|
||
function checkScheduledUpdateOrContext(current2, renderLanes2) {
|
||
var updateLanes = current2.lanes;
|
||
if (includesSomeLane(updateLanes, renderLanes2)) {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
function attemptEarlyBailoutIfNoScheduledUpdate(current2, workInProgress2, renderLanes2) {
|
||
switch (workInProgress2.tag) {
|
||
case HostRoot:
|
||
pushHostRootContext(workInProgress2);
|
||
var root2 = workInProgress2.stateNode;
|
||
resetHydrationState();
|
||
break;
|
||
case HostComponent:
|
||
pushHostContext(workInProgress2);
|
||
break;
|
||
case ClassComponent: {
|
||
var Component = workInProgress2.type;
|
||
if (isContextProvider(Component)) {
|
||
pushContextProvider(workInProgress2);
|
||
}
|
||
break;
|
||
}
|
||
case HostPortal:
|
||
pushHostContainer(workInProgress2, workInProgress2.stateNode.containerInfo);
|
||
break;
|
||
case ContextProvider: {
|
||
var newValue = workInProgress2.memoizedProps.value;
|
||
var context = workInProgress2.type._context;
|
||
pushProvider(workInProgress2, context, newValue);
|
||
break;
|
||
}
|
||
case Profiler:
|
||
{
|
||
var hasChildWork = includesSomeLane(renderLanes2, workInProgress2.childLanes);
|
||
if (hasChildWork) {
|
||
workInProgress2.flags |= Update;
|
||
}
|
||
{
|
||
var stateNode = workInProgress2.stateNode;
|
||
stateNode.effectDuration = 0;
|
||
stateNode.passiveEffectDuration = 0;
|
||
}
|
||
}
|
||
break;
|
||
case SuspenseComponent: {
|
||
var state = workInProgress2.memoizedState;
|
||
if (state !== null) {
|
||
if (state.dehydrated !== null) {
|
||
pushSuspenseContext(workInProgress2, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
|
||
workInProgress2.flags |= DidCapture;
|
||
return null;
|
||
}
|
||
var primaryChildFragment = workInProgress2.child;
|
||
var primaryChildLanes = primaryChildFragment.childLanes;
|
||
if (includesSomeLane(renderLanes2, primaryChildLanes)) {
|
||
return updateSuspenseComponent(current2, workInProgress2, renderLanes2);
|
||
} else {
|
||
pushSuspenseContext(workInProgress2, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
|
||
var child = bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
||
if (child !== null) {
|
||
return child.sibling;
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
} else {
|
||
pushSuspenseContext(workInProgress2, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
|
||
}
|
||
break;
|
||
}
|
||
case SuspenseListComponent: {
|
||
var didSuspendBefore = (current2.flags & DidCapture) !== NoFlags;
|
||
var _hasChildWork = includesSomeLane(renderLanes2, workInProgress2.childLanes);
|
||
if (didSuspendBefore) {
|
||
if (_hasChildWork) {
|
||
return updateSuspenseListComponent(current2, workInProgress2, renderLanes2);
|
||
}
|
||
workInProgress2.flags |= DidCapture;
|
||
}
|
||
var renderState = workInProgress2.memoizedState;
|
||
if (renderState !== null) {
|
||
renderState.rendering = null;
|
||
renderState.tail = null;
|
||
renderState.lastEffect = null;
|
||
}
|
||
pushSuspenseContext(workInProgress2, suspenseStackCursor.current);
|
||
if (_hasChildWork) {
|
||
break;
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
case OffscreenComponent:
|
||
case LegacyHiddenComponent: {
|
||
workInProgress2.lanes = NoLanes;
|
||
return updateOffscreenComponent(current2, workInProgress2, renderLanes2);
|
||
}
|
||
}
|
||
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
||
}
|
||
function beginWork(current2, workInProgress2, renderLanes2) {
|
||
{
|
||
if (workInProgress2._debugNeedsRemount && current2 !== null) {
|
||
return remountFiber(current2, workInProgress2, createFiberFromTypeAndProps(workInProgress2.type, workInProgress2.key, workInProgress2.pendingProps, workInProgress2._debugOwner || null, workInProgress2.mode, workInProgress2.lanes));
|
||
}
|
||
}
|
||
if (current2 !== null) {
|
||
var oldProps = current2.memoizedProps;
|
||
var newProps = workInProgress2.pendingProps;
|
||
if (oldProps !== newProps || hasContextChanged() || workInProgress2.type !== current2.type) {
|
||
didReceiveUpdate = true;
|
||
} else {
|
||
var hasScheduledUpdateOrContext = checkScheduledUpdateOrContext(current2, renderLanes2);
|
||
if (!hasScheduledUpdateOrContext && (workInProgress2.flags & DidCapture) === NoFlags) {
|
||
didReceiveUpdate = false;
|
||
return attemptEarlyBailoutIfNoScheduledUpdate(current2, workInProgress2, renderLanes2);
|
||
}
|
||
if ((current2.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
|
||
didReceiveUpdate = true;
|
||
} else {
|
||
didReceiveUpdate = false;
|
||
}
|
||
}
|
||
} else {
|
||
didReceiveUpdate = false;
|
||
if (getIsHydrating() && isForkedChild(workInProgress2)) {
|
||
var slotIndex = workInProgress2.index;
|
||
var numberOfForks = getForksAtLevel();
|
||
pushTreeId(workInProgress2, numberOfForks, slotIndex);
|
||
}
|
||
}
|
||
workInProgress2.lanes = NoLanes;
|
||
switch (workInProgress2.tag) {
|
||
case IndeterminateComponent: {
|
||
return mountIndeterminateComponent(current2, workInProgress2, workInProgress2.type, renderLanes2);
|
||
}
|
||
case LazyComponent: {
|
||
var elementType = workInProgress2.elementType;
|
||
return mountLazyComponent(current2, workInProgress2, elementType, renderLanes2);
|
||
}
|
||
case FunctionComponent: {
|
||
var Component = workInProgress2.type;
|
||
var unresolvedProps = workInProgress2.pendingProps;
|
||
var resolvedProps = workInProgress2.elementType === Component ? unresolvedProps : resolveDefaultProps(Component, unresolvedProps);
|
||
return updateFunctionComponent(current2, workInProgress2, Component, resolvedProps, renderLanes2);
|
||
}
|
||
case ClassComponent: {
|
||
var _Component = workInProgress2.type;
|
||
var _unresolvedProps = workInProgress2.pendingProps;
|
||
var _resolvedProps = workInProgress2.elementType === _Component ? _unresolvedProps : resolveDefaultProps(_Component, _unresolvedProps);
|
||
return updateClassComponent(current2, workInProgress2, _Component, _resolvedProps, renderLanes2);
|
||
}
|
||
case HostRoot:
|
||
return updateHostRoot(current2, workInProgress2, renderLanes2);
|
||
case HostComponent:
|
||
return updateHostComponent(current2, workInProgress2, renderLanes2);
|
||
case HostText:
|
||
return updateHostText(current2, workInProgress2);
|
||
case SuspenseComponent:
|
||
return updateSuspenseComponent(current2, workInProgress2, renderLanes2);
|
||
case HostPortal:
|
||
return updatePortalComponent(current2, workInProgress2, renderLanes2);
|
||
case ForwardRef: {
|
||
var type = workInProgress2.type;
|
||
var _unresolvedProps2 = workInProgress2.pendingProps;
|
||
var _resolvedProps2 = workInProgress2.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
|
||
return updateForwardRef(current2, workInProgress2, type, _resolvedProps2, renderLanes2);
|
||
}
|
||
case Fragment:
|
||
return updateFragment(current2, workInProgress2, renderLanes2);
|
||
case Mode:
|
||
return updateMode(current2, workInProgress2, renderLanes2);
|
||
case Profiler:
|
||
return updateProfiler(current2, workInProgress2, renderLanes2);
|
||
case ContextProvider:
|
||
return updateContextProvider(current2, workInProgress2, renderLanes2);
|
||
case ContextConsumer:
|
||
return updateContextConsumer(current2, workInProgress2, renderLanes2);
|
||
case MemoComponent: {
|
||
var _type2 = workInProgress2.type;
|
||
var _unresolvedProps3 = workInProgress2.pendingProps;
|
||
var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
|
||
{
|
||
if (workInProgress2.type !== workInProgress2.elementType) {
|
||
var outerPropTypes = _type2.propTypes;
|
||
if (outerPropTypes) {
|
||
checkPropTypes(outerPropTypes, _resolvedProps3, "prop", getComponentNameFromType(_type2));
|
||
}
|
||
}
|
||
}
|
||
_resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
|
||
return updateMemoComponent(current2, workInProgress2, _type2, _resolvedProps3, renderLanes2);
|
||
}
|
||
case SimpleMemoComponent: {
|
||
return updateSimpleMemoComponent(current2, workInProgress2, workInProgress2.type, workInProgress2.pendingProps, renderLanes2);
|
||
}
|
||
case IncompleteClassComponent: {
|
||
var _Component2 = workInProgress2.type;
|
||
var _unresolvedProps4 = workInProgress2.pendingProps;
|
||
var _resolvedProps4 = workInProgress2.elementType === _Component2 ? _unresolvedProps4 : resolveDefaultProps(_Component2, _unresolvedProps4);
|
||
return mountIncompleteClassComponent(current2, workInProgress2, _Component2, _resolvedProps4, renderLanes2);
|
||
}
|
||
case SuspenseListComponent: {
|
||
return updateSuspenseListComponent(current2, workInProgress2, renderLanes2);
|
||
}
|
||
case ScopeComponent: {
|
||
break;
|
||
}
|
||
case OffscreenComponent: {
|
||
return updateOffscreenComponent(current2, workInProgress2, renderLanes2);
|
||
}
|
||
}
|
||
throw new Error("Unknown unit of work tag (" + workInProgress2.tag + "). This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
function markUpdate(workInProgress2) {
|
||
workInProgress2.flags |= Update;
|
||
}
|
||
function markRef$1(workInProgress2) {
|
||
workInProgress2.flags |= Ref;
|
||
{
|
||
workInProgress2.flags |= RefStatic;
|
||
}
|
||
}
|
||
var appendAllChildren;
|
||
var updateHostContainer;
|
||
var updateHostComponent$1;
|
||
var updateHostText$1;
|
||
{
|
||
appendAllChildren = function(parent2, workInProgress2, needsVisibilityToggle, isHidden) {
|
||
var node = workInProgress2.child;
|
||
while (node !== null) {
|
||
if (node.tag === HostComponent || node.tag === HostText) {
|
||
appendInitialChild(parent2, node.stateNode);
|
||
} else if (node.tag === HostPortal)
|
||
;
|
||
else if (node.child !== null) {
|
||
node.child.return = node;
|
||
node = node.child;
|
||
continue;
|
||
}
|
||
if (node === workInProgress2) {
|
||
return;
|
||
}
|
||
while (node.sibling === null) {
|
||
if (node.return === null || node.return === workInProgress2) {
|
||
return;
|
||
}
|
||
node = node.return;
|
||
}
|
||
node.sibling.return = node.return;
|
||
node = node.sibling;
|
||
}
|
||
};
|
||
updateHostContainer = function(current2, workInProgress2) {
|
||
};
|
||
updateHostComponent$1 = function(current2, workInProgress2, type, newProps, rootContainerInstance) {
|
||
var oldProps = current2.memoizedProps;
|
||
if (oldProps === newProps) {
|
||
return;
|
||
}
|
||
var instance = workInProgress2.stateNode;
|
||
var currentHostContext = getHostContext();
|
||
var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
|
||
workInProgress2.updateQueue = updatePayload;
|
||
if (updatePayload) {
|
||
markUpdate(workInProgress2);
|
||
}
|
||
};
|
||
updateHostText$1 = function(current2, workInProgress2, oldText, newText) {
|
||
if (oldText !== newText) {
|
||
markUpdate(workInProgress2);
|
||
}
|
||
};
|
||
}
|
||
function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
|
||
if (getIsHydrating()) {
|
||
return;
|
||
}
|
||
switch (renderState.tailMode) {
|
||
case "hidden": {
|
||
var tailNode = renderState.tail;
|
||
var lastTailNode = null;
|
||
while (tailNode !== null) {
|
||
if (tailNode.alternate !== null) {
|
||
lastTailNode = tailNode;
|
||
}
|
||
tailNode = tailNode.sibling;
|
||
}
|
||
if (lastTailNode === null) {
|
||
renderState.tail = null;
|
||
} else {
|
||
lastTailNode.sibling = null;
|
||
}
|
||
break;
|
||
}
|
||
case "collapsed": {
|
||
var _tailNode = renderState.tail;
|
||
var _lastTailNode = null;
|
||
while (_tailNode !== null) {
|
||
if (_tailNode.alternate !== null) {
|
||
_lastTailNode = _tailNode;
|
||
}
|
||
_tailNode = _tailNode.sibling;
|
||
}
|
||
if (_lastTailNode === null) {
|
||
if (!hasRenderedATailFallback && renderState.tail !== null) {
|
||
renderState.tail.sibling = null;
|
||
} else {
|
||
renderState.tail = null;
|
||
}
|
||
} else {
|
||
_lastTailNode.sibling = null;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
function bubbleProperties(completedWork) {
|
||
var didBailout = completedWork.alternate !== null && completedWork.alternate.child === completedWork.child;
|
||
var newChildLanes = NoLanes;
|
||
var subtreeFlags = NoFlags;
|
||
if (!didBailout) {
|
||
if ((completedWork.mode & ProfileMode) !== NoMode) {
|
||
var actualDuration = completedWork.actualDuration;
|
||
var treeBaseDuration = completedWork.selfBaseDuration;
|
||
var child = completedWork.child;
|
||
while (child !== null) {
|
||
newChildLanes = mergeLanes(newChildLanes, mergeLanes(child.lanes, child.childLanes));
|
||
subtreeFlags |= child.subtreeFlags;
|
||
subtreeFlags |= child.flags;
|
||
actualDuration += child.actualDuration;
|
||
treeBaseDuration += child.treeBaseDuration;
|
||
child = child.sibling;
|
||
}
|
||
completedWork.actualDuration = actualDuration;
|
||
completedWork.treeBaseDuration = treeBaseDuration;
|
||
} else {
|
||
var _child = completedWork.child;
|
||
while (_child !== null) {
|
||
newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child.lanes, _child.childLanes));
|
||
subtreeFlags |= _child.subtreeFlags;
|
||
subtreeFlags |= _child.flags;
|
||
_child.return = completedWork;
|
||
_child = _child.sibling;
|
||
}
|
||
}
|
||
completedWork.subtreeFlags |= subtreeFlags;
|
||
} else {
|
||
if ((completedWork.mode & ProfileMode) !== NoMode) {
|
||
var _treeBaseDuration = completedWork.selfBaseDuration;
|
||
var _child2 = completedWork.child;
|
||
while (_child2 !== null) {
|
||
newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child2.lanes, _child2.childLanes));
|
||
subtreeFlags |= _child2.subtreeFlags & StaticMask;
|
||
subtreeFlags |= _child2.flags & StaticMask;
|
||
_treeBaseDuration += _child2.treeBaseDuration;
|
||
_child2 = _child2.sibling;
|
||
}
|
||
completedWork.treeBaseDuration = _treeBaseDuration;
|
||
} else {
|
||
var _child3 = completedWork.child;
|
||
while (_child3 !== null) {
|
||
newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child3.lanes, _child3.childLanes));
|
||
subtreeFlags |= _child3.subtreeFlags & StaticMask;
|
||
subtreeFlags |= _child3.flags & StaticMask;
|
||
_child3.return = completedWork;
|
||
_child3 = _child3.sibling;
|
||
}
|
||
}
|
||
completedWork.subtreeFlags |= subtreeFlags;
|
||
}
|
||
completedWork.childLanes = newChildLanes;
|
||
return didBailout;
|
||
}
|
||
function completeDehydratedSuspenseBoundary(current2, workInProgress2, nextState) {
|
||
if (hasUnhydratedTailNodes() && (workInProgress2.mode & ConcurrentMode) !== NoMode && (workInProgress2.flags & DidCapture) === NoFlags) {
|
||
warnIfUnhydratedTailNodes(workInProgress2);
|
||
resetHydrationState();
|
||
workInProgress2.flags |= ForceClientRender | Incomplete | ShouldCapture;
|
||
return false;
|
||
}
|
||
var wasHydrated = popHydrationState(workInProgress2);
|
||
if (nextState !== null && nextState.dehydrated !== null) {
|
||
if (current2 === null) {
|
||
if (!wasHydrated) {
|
||
throw new Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.");
|
||
}
|
||
prepareToHydrateHostSuspenseInstance(workInProgress2);
|
||
bubbleProperties(workInProgress2);
|
||
{
|
||
if ((workInProgress2.mode & ProfileMode) !== NoMode) {
|
||
var isTimedOutSuspense = nextState !== null;
|
||
if (isTimedOutSuspense) {
|
||
var primaryChildFragment = workInProgress2.child;
|
||
if (primaryChildFragment !== null) {
|
||
workInProgress2.treeBaseDuration -= primaryChildFragment.treeBaseDuration;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return false;
|
||
} else {
|
||
resetHydrationState();
|
||
if ((workInProgress2.flags & DidCapture) === NoFlags) {
|
||
workInProgress2.memoizedState = null;
|
||
}
|
||
workInProgress2.flags |= Update;
|
||
bubbleProperties(workInProgress2);
|
||
{
|
||
if ((workInProgress2.mode & ProfileMode) !== NoMode) {
|
||
var _isTimedOutSuspense = nextState !== null;
|
||
if (_isTimedOutSuspense) {
|
||
var _primaryChildFragment = workInProgress2.child;
|
||
if (_primaryChildFragment !== null) {
|
||
workInProgress2.treeBaseDuration -= _primaryChildFragment.treeBaseDuration;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
} else {
|
||
upgradeHydrationErrorsToRecoverable();
|
||
return true;
|
||
}
|
||
}
|
||
function completeWork(current2, workInProgress2, renderLanes2) {
|
||
var newProps = workInProgress2.pendingProps;
|
||
popTreeContext(workInProgress2);
|
||
switch (workInProgress2.tag) {
|
||
case IndeterminateComponent:
|
||
case LazyComponent:
|
||
case SimpleMemoComponent:
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case Fragment:
|
||
case Mode:
|
||
case Profiler:
|
||
case ContextConsumer:
|
||
case MemoComponent:
|
||
bubbleProperties(workInProgress2);
|
||
return null;
|
||
case ClassComponent: {
|
||
var Component = workInProgress2.type;
|
||
if (isContextProvider(Component)) {
|
||
popContext(workInProgress2);
|
||
}
|
||
bubbleProperties(workInProgress2);
|
||
return null;
|
||
}
|
||
case HostRoot: {
|
||
var fiberRoot = workInProgress2.stateNode;
|
||
popHostContainer(workInProgress2);
|
||
popTopLevelContextObject(workInProgress2);
|
||
resetWorkInProgressVersions();
|
||
if (fiberRoot.pendingContext) {
|
||
fiberRoot.context = fiberRoot.pendingContext;
|
||
fiberRoot.pendingContext = null;
|
||
}
|
||
if (current2 === null || current2.child === null) {
|
||
var wasHydrated = popHydrationState(workInProgress2);
|
||
if (wasHydrated) {
|
||
markUpdate(workInProgress2);
|
||
} else {
|
||
if (current2 !== null) {
|
||
var prevState = current2.memoizedState;
|
||
if (!prevState.isDehydrated || (workInProgress2.flags & ForceClientRender) !== NoFlags) {
|
||
workInProgress2.flags |= Snapshot;
|
||
upgradeHydrationErrorsToRecoverable();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
updateHostContainer(current2, workInProgress2);
|
||
bubbleProperties(workInProgress2);
|
||
return null;
|
||
}
|
||
case HostComponent: {
|
||
popHostContext(workInProgress2);
|
||
var rootContainerInstance = getRootHostContainer();
|
||
var type = workInProgress2.type;
|
||
if (current2 !== null && workInProgress2.stateNode != null) {
|
||
updateHostComponent$1(current2, workInProgress2, type, newProps, rootContainerInstance);
|
||
if (current2.ref !== workInProgress2.ref) {
|
||
markRef$1(workInProgress2);
|
||
}
|
||
} else {
|
||
if (!newProps) {
|
||
if (workInProgress2.stateNode === null) {
|
||
throw new Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
bubbleProperties(workInProgress2);
|
||
return null;
|
||
}
|
||
var currentHostContext = getHostContext();
|
||
var _wasHydrated = popHydrationState(workInProgress2);
|
||
if (_wasHydrated) {
|
||
if (prepareToHydrateHostInstance(workInProgress2, rootContainerInstance, currentHostContext)) {
|
||
markUpdate(workInProgress2);
|
||
}
|
||
} else {
|
||
var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress2);
|
||
appendAllChildren(instance, workInProgress2, false, false);
|
||
workInProgress2.stateNode = instance;
|
||
if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance)) {
|
||
markUpdate(workInProgress2);
|
||
}
|
||
}
|
||
if (workInProgress2.ref !== null) {
|
||
markRef$1(workInProgress2);
|
||
}
|
||
}
|
||
bubbleProperties(workInProgress2);
|
||
return null;
|
||
}
|
||
case HostText: {
|
||
var newText = newProps;
|
||
if (current2 && workInProgress2.stateNode != null) {
|
||
var oldText = current2.memoizedProps;
|
||
updateHostText$1(current2, workInProgress2, oldText, newText);
|
||
} else {
|
||
if (typeof newText !== "string") {
|
||
if (workInProgress2.stateNode === null) {
|
||
throw new Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
var _rootContainerInstance = getRootHostContainer();
|
||
var _currentHostContext = getHostContext();
|
||
var _wasHydrated2 = popHydrationState(workInProgress2);
|
||
if (_wasHydrated2) {
|
||
if (prepareToHydrateHostTextInstance(workInProgress2)) {
|
||
markUpdate(workInProgress2);
|
||
}
|
||
} else {
|
||
workInProgress2.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress2);
|
||
}
|
||
}
|
||
bubbleProperties(workInProgress2);
|
||
return null;
|
||
}
|
||
case SuspenseComponent: {
|
||
popSuspenseContext(workInProgress2);
|
||
var nextState = workInProgress2.memoizedState;
|
||
if (current2 === null || current2.memoizedState !== null && current2.memoizedState.dehydrated !== null) {
|
||
var fallthroughToNormalSuspensePath = completeDehydratedSuspenseBoundary(current2, workInProgress2, nextState);
|
||
if (!fallthroughToNormalSuspensePath) {
|
||
if (workInProgress2.flags & ShouldCapture) {
|
||
return workInProgress2;
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
}
|
||
if ((workInProgress2.flags & DidCapture) !== NoFlags) {
|
||
workInProgress2.lanes = renderLanes2;
|
||
if ((workInProgress2.mode & ProfileMode) !== NoMode) {
|
||
transferActualDuration(workInProgress2);
|
||
}
|
||
return workInProgress2;
|
||
}
|
||
var nextDidTimeout = nextState !== null;
|
||
var prevDidTimeout = current2 !== null && current2.memoizedState !== null;
|
||
if (nextDidTimeout !== prevDidTimeout) {
|
||
if (nextDidTimeout) {
|
||
var _offscreenFiber2 = workInProgress2.child;
|
||
_offscreenFiber2.flags |= Visibility;
|
||
if ((workInProgress2.mode & ConcurrentMode) !== NoMode) {
|
||
var hasInvisibleChildContext = current2 === null && (workInProgress2.memoizedProps.unstable_avoidThisFallback !== true || !enableSuspenseAvoidThisFallback);
|
||
if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) {
|
||
renderDidSuspend();
|
||
} else {
|
||
renderDidSuspendDelayIfPossible();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var wakeables = workInProgress2.updateQueue;
|
||
if (wakeables !== null) {
|
||
workInProgress2.flags |= Update;
|
||
}
|
||
bubbleProperties(workInProgress2);
|
||
{
|
||
if ((workInProgress2.mode & ProfileMode) !== NoMode) {
|
||
if (nextDidTimeout) {
|
||
var primaryChildFragment = workInProgress2.child;
|
||
if (primaryChildFragment !== null) {
|
||
workInProgress2.treeBaseDuration -= primaryChildFragment.treeBaseDuration;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
case HostPortal:
|
||
popHostContainer(workInProgress2);
|
||
updateHostContainer(current2, workInProgress2);
|
||
if (current2 === null) {
|
||
preparePortalMount(workInProgress2.stateNode.containerInfo);
|
||
}
|
||
bubbleProperties(workInProgress2);
|
||
return null;
|
||
case ContextProvider:
|
||
var context = workInProgress2.type._context;
|
||
popProvider(context, workInProgress2);
|
||
bubbleProperties(workInProgress2);
|
||
return null;
|
||
case IncompleteClassComponent: {
|
||
var _Component = workInProgress2.type;
|
||
if (isContextProvider(_Component)) {
|
||
popContext(workInProgress2);
|
||
}
|
||
bubbleProperties(workInProgress2);
|
||
return null;
|
||
}
|
||
case SuspenseListComponent: {
|
||
popSuspenseContext(workInProgress2);
|
||
var renderState = workInProgress2.memoizedState;
|
||
if (renderState === null) {
|
||
bubbleProperties(workInProgress2);
|
||
return null;
|
||
}
|
||
var didSuspendAlready = (workInProgress2.flags & DidCapture) !== NoFlags;
|
||
var renderedTail = renderState.rendering;
|
||
if (renderedTail === null) {
|
||
if (!didSuspendAlready) {
|
||
var cannotBeSuspended = renderHasNotSuspendedYet() && (current2 === null || (current2.flags & DidCapture) === NoFlags);
|
||
if (!cannotBeSuspended) {
|
||
var row = workInProgress2.child;
|
||
while (row !== null) {
|
||
var suspended = findFirstSuspended(row);
|
||
if (suspended !== null) {
|
||
didSuspendAlready = true;
|
||
workInProgress2.flags |= DidCapture;
|
||
cutOffTailIfNeeded(renderState, false);
|
||
var newThenables = suspended.updateQueue;
|
||
if (newThenables !== null) {
|
||
workInProgress2.updateQueue = newThenables;
|
||
workInProgress2.flags |= Update;
|
||
}
|
||
workInProgress2.subtreeFlags = NoFlags;
|
||
resetChildFibers(workInProgress2, renderLanes2);
|
||
pushSuspenseContext(workInProgress2, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
|
||
return workInProgress2.child;
|
||
}
|
||
row = row.sibling;
|
||
}
|
||
}
|
||
if (renderState.tail !== null && now() > getRenderTargetTime()) {
|
||
workInProgress2.flags |= DidCapture;
|
||
didSuspendAlready = true;
|
||
cutOffTailIfNeeded(renderState, false);
|
||
workInProgress2.lanes = SomeRetryLane;
|
||
}
|
||
} else {
|
||
cutOffTailIfNeeded(renderState, false);
|
||
}
|
||
} else {
|
||
if (!didSuspendAlready) {
|
||
var _suspended = findFirstSuspended(renderedTail);
|
||
if (_suspended !== null) {
|
||
workInProgress2.flags |= DidCapture;
|
||
didSuspendAlready = true;
|
||
var _newThenables = _suspended.updateQueue;
|
||
if (_newThenables !== null) {
|
||
workInProgress2.updateQueue = _newThenables;
|
||
workInProgress2.flags |= Update;
|
||
}
|
||
cutOffTailIfNeeded(renderState, true);
|
||
if (renderState.tail === null && renderState.tailMode === "hidden" && !renderedTail.alternate && !getIsHydrating()) {
|
||
bubbleProperties(workInProgress2);
|
||
return null;
|
||
}
|
||
} else if (now() * 2 - renderState.renderingStartTime > getRenderTargetTime() && renderLanes2 !== OffscreenLane) {
|
||
workInProgress2.flags |= DidCapture;
|
||
didSuspendAlready = true;
|
||
cutOffTailIfNeeded(renderState, false);
|
||
workInProgress2.lanes = SomeRetryLane;
|
||
}
|
||
}
|
||
if (renderState.isBackwards) {
|
||
renderedTail.sibling = workInProgress2.child;
|
||
workInProgress2.child = renderedTail;
|
||
} else {
|
||
var previousSibling = renderState.last;
|
||
if (previousSibling !== null) {
|
||
previousSibling.sibling = renderedTail;
|
||
} else {
|
||
workInProgress2.child = renderedTail;
|
||
}
|
||
renderState.last = renderedTail;
|
||
}
|
||
}
|
||
if (renderState.tail !== null) {
|
||
var next = renderState.tail;
|
||
renderState.rendering = next;
|
||
renderState.tail = next.sibling;
|
||
renderState.renderingStartTime = now();
|
||
next.sibling = null;
|
||
var suspenseContext = suspenseStackCursor.current;
|
||
if (didSuspendAlready) {
|
||
suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
||
} else {
|
||
suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
||
}
|
||
pushSuspenseContext(workInProgress2, suspenseContext);
|
||
return next;
|
||
}
|
||
bubbleProperties(workInProgress2);
|
||
return null;
|
||
}
|
||
case ScopeComponent: {
|
||
break;
|
||
}
|
||
case OffscreenComponent:
|
||
case LegacyHiddenComponent: {
|
||
popRenderLanes(workInProgress2);
|
||
var _nextState = workInProgress2.memoizedState;
|
||
var nextIsHidden = _nextState !== null;
|
||
if (current2 !== null) {
|
||
var _prevState = current2.memoizedState;
|
||
var prevIsHidden = _prevState !== null;
|
||
if (prevIsHidden !== nextIsHidden && !enableLegacyHidden) {
|
||
workInProgress2.flags |= Visibility;
|
||
}
|
||
}
|
||
if (!nextIsHidden || (workInProgress2.mode & ConcurrentMode) === NoMode) {
|
||
bubbleProperties(workInProgress2);
|
||
} else {
|
||
if (includesSomeLane(subtreeRenderLanes, OffscreenLane)) {
|
||
bubbleProperties(workInProgress2);
|
||
{
|
||
if (workInProgress2.subtreeFlags & (Placement | Update)) {
|
||
workInProgress2.flags |= Visibility;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
case CacheComponent: {
|
||
return null;
|
||
}
|
||
case TracingMarkerComponent: {
|
||
return null;
|
||
}
|
||
}
|
||
throw new Error("Unknown unit of work tag (" + workInProgress2.tag + "). This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
function unwindWork(current2, workInProgress2, renderLanes2) {
|
||
popTreeContext(workInProgress2);
|
||
switch (workInProgress2.tag) {
|
||
case ClassComponent: {
|
||
var Component = workInProgress2.type;
|
||
if (isContextProvider(Component)) {
|
||
popContext(workInProgress2);
|
||
}
|
||
var flags = workInProgress2.flags;
|
||
if (flags & ShouldCapture) {
|
||
workInProgress2.flags = flags & ~ShouldCapture | DidCapture;
|
||
if ((workInProgress2.mode & ProfileMode) !== NoMode) {
|
||
transferActualDuration(workInProgress2);
|
||
}
|
||
return workInProgress2;
|
||
}
|
||
return null;
|
||
}
|
||
case HostRoot: {
|
||
var root2 = workInProgress2.stateNode;
|
||
popHostContainer(workInProgress2);
|
||
popTopLevelContextObject(workInProgress2);
|
||
resetWorkInProgressVersions();
|
||
var _flags = workInProgress2.flags;
|
||
if ((_flags & ShouldCapture) !== NoFlags && (_flags & DidCapture) === NoFlags) {
|
||
workInProgress2.flags = _flags & ~ShouldCapture | DidCapture;
|
||
return workInProgress2;
|
||
}
|
||
return null;
|
||
}
|
||
case HostComponent: {
|
||
popHostContext(workInProgress2);
|
||
return null;
|
||
}
|
||
case SuspenseComponent: {
|
||
popSuspenseContext(workInProgress2);
|
||
var suspenseState = workInProgress2.memoizedState;
|
||
if (suspenseState !== null && suspenseState.dehydrated !== null) {
|
||
if (workInProgress2.alternate === null) {
|
||
throw new Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue.");
|
||
}
|
||
resetHydrationState();
|
||
}
|
||
var _flags2 = workInProgress2.flags;
|
||
if (_flags2 & ShouldCapture) {
|
||
workInProgress2.flags = _flags2 & ~ShouldCapture | DidCapture;
|
||
if ((workInProgress2.mode & ProfileMode) !== NoMode) {
|
||
transferActualDuration(workInProgress2);
|
||
}
|
||
return workInProgress2;
|
||
}
|
||
return null;
|
||
}
|
||
case SuspenseListComponent: {
|
||
popSuspenseContext(workInProgress2);
|
||
return null;
|
||
}
|
||
case HostPortal:
|
||
popHostContainer(workInProgress2);
|
||
return null;
|
||
case ContextProvider:
|
||
var context = workInProgress2.type._context;
|
||
popProvider(context, workInProgress2);
|
||
return null;
|
||
case OffscreenComponent:
|
||
case LegacyHiddenComponent:
|
||
popRenderLanes(workInProgress2);
|
||
return null;
|
||
case CacheComponent:
|
||
return null;
|
||
default:
|
||
return null;
|
||
}
|
||
}
|
||
function unwindInterruptedWork(current2, interruptedWork, renderLanes2) {
|
||
popTreeContext(interruptedWork);
|
||
switch (interruptedWork.tag) {
|
||
case ClassComponent: {
|
||
var childContextTypes = interruptedWork.type.childContextTypes;
|
||
if (childContextTypes !== null && childContextTypes !== void 0) {
|
||
popContext(interruptedWork);
|
||
}
|
||
break;
|
||
}
|
||
case HostRoot: {
|
||
var root2 = interruptedWork.stateNode;
|
||
popHostContainer(interruptedWork);
|
||
popTopLevelContextObject(interruptedWork);
|
||
resetWorkInProgressVersions();
|
||
break;
|
||
}
|
||
case HostComponent: {
|
||
popHostContext(interruptedWork);
|
||
break;
|
||
}
|
||
case HostPortal:
|
||
popHostContainer(interruptedWork);
|
||
break;
|
||
case SuspenseComponent:
|
||
popSuspenseContext(interruptedWork);
|
||
break;
|
||
case SuspenseListComponent:
|
||
popSuspenseContext(interruptedWork);
|
||
break;
|
||
case ContextProvider:
|
||
var context = interruptedWork.type._context;
|
||
popProvider(context, interruptedWork);
|
||
break;
|
||
case OffscreenComponent:
|
||
case LegacyHiddenComponent:
|
||
popRenderLanes(interruptedWork);
|
||
break;
|
||
}
|
||
}
|
||
var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
|
||
{
|
||
didWarnAboutUndefinedSnapshotBeforeUpdate = /* @__PURE__ */ new Set();
|
||
}
|
||
var offscreenSubtreeIsHidden = false;
|
||
var offscreenSubtreeWasHidden = false;
|
||
var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set;
|
||
var nextEffect = null;
|
||
var inProgressLanes = null;
|
||
var inProgressRoot = null;
|
||
function reportUncaughtErrorInDEV(error2) {
|
||
{
|
||
invokeGuardedCallback(null, function() {
|
||
throw error2;
|
||
});
|
||
clearCaughtError();
|
||
}
|
||
}
|
||
var callComponentWillUnmountWithTimer = function(current2, instance) {
|
||
instance.props = current2.memoizedProps;
|
||
instance.state = current2.memoizedState;
|
||
if (current2.mode & ProfileMode) {
|
||
try {
|
||
startLayoutEffectTimer();
|
||
instance.componentWillUnmount();
|
||
} finally {
|
||
recordLayoutEffectDuration(current2);
|
||
}
|
||
} else {
|
||
instance.componentWillUnmount();
|
||
}
|
||
};
|
||
function safelyCallCommitHookLayoutEffectListMount(current2, nearestMountedAncestor) {
|
||
try {
|
||
commitHookEffectListMount(Layout, current2);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(current2, nearestMountedAncestor, error2);
|
||
}
|
||
}
|
||
function safelyCallComponentWillUnmount(current2, nearestMountedAncestor, instance) {
|
||
try {
|
||
callComponentWillUnmountWithTimer(current2, instance);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(current2, nearestMountedAncestor, error2);
|
||
}
|
||
}
|
||
function safelyCallComponentDidMount(current2, nearestMountedAncestor, instance) {
|
||
try {
|
||
instance.componentDidMount();
|
||
} catch (error2) {
|
||
captureCommitPhaseError(current2, nearestMountedAncestor, error2);
|
||
}
|
||
}
|
||
function safelyAttachRef(current2, nearestMountedAncestor) {
|
||
try {
|
||
commitAttachRef(current2);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(current2, nearestMountedAncestor, error2);
|
||
}
|
||
}
|
||
function safelyDetachRef(current2, nearestMountedAncestor) {
|
||
var ref = current2.ref;
|
||
if (ref !== null) {
|
||
if (typeof ref === "function") {
|
||
var retVal;
|
||
try {
|
||
if (enableProfilerTimer && enableProfilerCommitHooks && current2.mode & ProfileMode) {
|
||
try {
|
||
startLayoutEffectTimer();
|
||
retVal = ref(null);
|
||
} finally {
|
||
recordLayoutEffectDuration(current2);
|
||
}
|
||
} else {
|
||
retVal = ref(null);
|
||
}
|
||
} catch (error2) {
|
||
captureCommitPhaseError(current2, nearestMountedAncestor, error2);
|
||
}
|
||
{
|
||
if (typeof retVal === "function") {
|
||
error("Unexpected return value from a callback ref in %s. A callback ref should not return a function.", getComponentNameFromFiber(current2));
|
||
}
|
||
}
|
||
} else {
|
||
ref.current = null;
|
||
}
|
||
}
|
||
}
|
||
function safelyCallDestroy(current2, nearestMountedAncestor, destroy) {
|
||
try {
|
||
destroy();
|
||
} catch (error2) {
|
||
captureCommitPhaseError(current2, nearestMountedAncestor, error2);
|
||
}
|
||
}
|
||
var focusedInstanceHandle = null;
|
||
var shouldFireAfterActiveInstanceBlur = false;
|
||
function commitBeforeMutationEffects(root2, firstChild) {
|
||
focusedInstanceHandle = prepareForCommit(root2.containerInfo);
|
||
nextEffect = firstChild;
|
||
commitBeforeMutationEffects_begin();
|
||
var shouldFire = shouldFireAfterActiveInstanceBlur;
|
||
shouldFireAfterActiveInstanceBlur = false;
|
||
focusedInstanceHandle = null;
|
||
return shouldFire;
|
||
}
|
||
function commitBeforeMutationEffects_begin() {
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
var child = fiber.child;
|
||
if ((fiber.subtreeFlags & BeforeMutationMask) !== NoFlags && child !== null) {
|
||
child.return = fiber;
|
||
nextEffect = child;
|
||
} else {
|
||
commitBeforeMutationEffects_complete();
|
||
}
|
||
}
|
||
}
|
||
function commitBeforeMutationEffects_complete() {
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
setCurrentFiber(fiber);
|
||
try {
|
||
commitBeforeMutationEffectsOnFiber(fiber);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(fiber, fiber.return, error2);
|
||
}
|
||
resetCurrentFiber();
|
||
var sibling = fiber.sibling;
|
||
if (sibling !== null) {
|
||
sibling.return = fiber.return;
|
||
nextEffect = sibling;
|
||
return;
|
||
}
|
||
nextEffect = fiber.return;
|
||
}
|
||
}
|
||
function commitBeforeMutationEffectsOnFiber(finishedWork) {
|
||
var current2 = finishedWork.alternate;
|
||
var flags = finishedWork.flags;
|
||
if ((flags & Snapshot) !== NoFlags) {
|
||
setCurrentFiber(finishedWork);
|
||
switch (finishedWork.tag) {
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case SimpleMemoComponent: {
|
||
break;
|
||
}
|
||
case ClassComponent: {
|
||
if (current2 !== null) {
|
||
var prevProps = current2.memoizedProps;
|
||
var prevState = current2.memoizedState;
|
||
var instance = finishedWork.stateNode;
|
||
{
|
||
if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
||
if (instance.props !== finishedWork.memoizedProps) {
|
||
error("Expected %s props to match memoized props before getSnapshotBeforeUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.", getComponentNameFromFiber(finishedWork) || "instance");
|
||
}
|
||
if (instance.state !== finishedWork.memoizedState) {
|
||
error("Expected %s state to match memoized state before getSnapshotBeforeUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.", getComponentNameFromFiber(finishedWork) || "instance");
|
||
}
|
||
}
|
||
}
|
||
var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
|
||
{
|
||
var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
|
||
if (snapshot === void 0 && !didWarnSet.has(finishedWork.type)) {
|
||
didWarnSet.add(finishedWork.type);
|
||
error("%s.getSnapshotBeforeUpdate(): A snapshot value (or null) must be returned. You have returned undefined.", getComponentNameFromFiber(finishedWork));
|
||
}
|
||
}
|
||
instance.__reactInternalSnapshotBeforeUpdate = snapshot;
|
||
}
|
||
break;
|
||
}
|
||
case HostRoot: {
|
||
{
|
||
var root2 = finishedWork.stateNode;
|
||
clearContainer(root2.containerInfo);
|
||
}
|
||
break;
|
||
}
|
||
case HostComponent:
|
||
case HostText:
|
||
case HostPortal:
|
||
case IncompleteClassComponent:
|
||
break;
|
||
default: {
|
||
throw new Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
resetCurrentFiber();
|
||
}
|
||
}
|
||
function commitHookEffectListUnmount(flags, finishedWork, nearestMountedAncestor) {
|
||
var updateQueue = finishedWork.updateQueue;
|
||
var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
|
||
if (lastEffect !== null) {
|
||
var firstEffect = lastEffect.next;
|
||
var effect = firstEffect;
|
||
do {
|
||
if ((effect.tag & flags) === flags) {
|
||
var destroy = effect.destroy;
|
||
effect.destroy = void 0;
|
||
if (destroy !== void 0) {
|
||
{
|
||
if ((flags & Passive$1) !== NoFlags$1) {
|
||
markComponentPassiveEffectUnmountStarted(finishedWork);
|
||
} else if ((flags & Layout) !== NoFlags$1) {
|
||
markComponentLayoutEffectUnmountStarted(finishedWork);
|
||
}
|
||
}
|
||
{
|
||
if ((flags & Insertion) !== NoFlags$1) {
|
||
setIsRunningInsertionEffect(true);
|
||
}
|
||
}
|
||
safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy);
|
||
{
|
||
if ((flags & Insertion) !== NoFlags$1) {
|
||
setIsRunningInsertionEffect(false);
|
||
}
|
||
}
|
||
{
|
||
if ((flags & Passive$1) !== NoFlags$1) {
|
||
markComponentPassiveEffectUnmountStopped();
|
||
} else if ((flags & Layout) !== NoFlags$1) {
|
||
markComponentLayoutEffectUnmountStopped();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
effect = effect.next;
|
||
} while (effect !== firstEffect);
|
||
}
|
||
}
|
||
function commitHookEffectListMount(flags, finishedWork) {
|
||
var updateQueue = finishedWork.updateQueue;
|
||
var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
|
||
if (lastEffect !== null) {
|
||
var firstEffect = lastEffect.next;
|
||
var effect = firstEffect;
|
||
do {
|
||
if ((effect.tag & flags) === flags) {
|
||
{
|
||
if ((flags & Passive$1) !== NoFlags$1) {
|
||
markComponentPassiveEffectMountStarted(finishedWork);
|
||
} else if ((flags & Layout) !== NoFlags$1) {
|
||
markComponentLayoutEffectMountStarted(finishedWork);
|
||
}
|
||
}
|
||
var create = effect.create;
|
||
{
|
||
if ((flags & Insertion) !== NoFlags$1) {
|
||
setIsRunningInsertionEffect(true);
|
||
}
|
||
}
|
||
effect.destroy = create();
|
||
{
|
||
if ((flags & Insertion) !== NoFlags$1) {
|
||
setIsRunningInsertionEffect(false);
|
||
}
|
||
}
|
||
{
|
||
if ((flags & Passive$1) !== NoFlags$1) {
|
||
markComponentPassiveEffectMountStopped();
|
||
} else if ((flags & Layout) !== NoFlags$1) {
|
||
markComponentLayoutEffectMountStopped();
|
||
}
|
||
}
|
||
{
|
||
var destroy = effect.destroy;
|
||
if (destroy !== void 0 && typeof destroy !== "function") {
|
||
var hookName = void 0;
|
||
if ((effect.tag & Layout) !== NoFlags) {
|
||
hookName = "useLayoutEffect";
|
||
} else if ((effect.tag & Insertion) !== NoFlags) {
|
||
hookName = "useInsertionEffect";
|
||
} else {
|
||
hookName = "useEffect";
|
||
}
|
||
var addendum = void 0;
|
||
if (destroy === null) {
|
||
addendum = " You returned null. If your effect does not require clean up, return undefined (or nothing).";
|
||
} else if (typeof destroy.then === "function") {
|
||
addendum = "\n\nIt looks like you wrote " + hookName + "(async () => ...) or returned a Promise. Instead, write the async function inside your effect and call it immediately:\n\n" + hookName + "(() => {\n async function fetchData() {\n // You can await here\n const response = await MyAPI.getData(someId);\n // ...\n }\n fetchData();\n}, [someId]); // Or [] if effect doesn't need props or state\n\nLearn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching";
|
||
} else {
|
||
addendum = " You returned: " + destroy;
|
||
}
|
||
error("%s must not return anything besides a function, which is used for clean-up.%s", hookName, addendum);
|
||
}
|
||
}
|
||
}
|
||
effect = effect.next;
|
||
} while (effect !== firstEffect);
|
||
}
|
||
}
|
||
function commitPassiveEffectDurations(finishedRoot, finishedWork) {
|
||
{
|
||
if ((finishedWork.flags & Update) !== NoFlags) {
|
||
switch (finishedWork.tag) {
|
||
case Profiler: {
|
||
var passiveEffectDuration = finishedWork.stateNode.passiveEffectDuration;
|
||
var _finishedWork$memoize = finishedWork.memoizedProps, id = _finishedWork$memoize.id, onPostCommit = _finishedWork$memoize.onPostCommit;
|
||
var commitTime2 = getCommitTime();
|
||
var phase = finishedWork.alternate === null ? "mount" : "update";
|
||
{
|
||
if (isCurrentUpdateNested()) {
|
||
phase = "nested-update";
|
||
}
|
||
}
|
||
if (typeof onPostCommit === "function") {
|
||
onPostCommit(id, phase, passiveEffectDuration, commitTime2);
|
||
}
|
||
var parentFiber = finishedWork.return;
|
||
outer:
|
||
while (parentFiber !== null) {
|
||
switch (parentFiber.tag) {
|
||
case HostRoot:
|
||
var root2 = parentFiber.stateNode;
|
||
root2.passiveEffectDuration += passiveEffectDuration;
|
||
break outer;
|
||
case Profiler:
|
||
var parentStateNode = parentFiber.stateNode;
|
||
parentStateNode.passiveEffectDuration += passiveEffectDuration;
|
||
break outer;
|
||
}
|
||
parentFiber = parentFiber.return;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function commitLayoutEffectOnFiber(finishedRoot, current2, finishedWork, committedLanes) {
|
||
if ((finishedWork.flags & LayoutMask) !== NoFlags) {
|
||
switch (finishedWork.tag) {
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case SimpleMemoComponent: {
|
||
if (!offscreenSubtreeWasHidden) {
|
||
if (finishedWork.mode & ProfileMode) {
|
||
try {
|
||
startLayoutEffectTimer();
|
||
commitHookEffectListMount(Layout | HasEffect, finishedWork);
|
||
} finally {
|
||
recordLayoutEffectDuration(finishedWork);
|
||
}
|
||
} else {
|
||
commitHookEffectListMount(Layout | HasEffect, finishedWork);
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
case ClassComponent: {
|
||
var instance = finishedWork.stateNode;
|
||
if (finishedWork.flags & Update) {
|
||
if (!offscreenSubtreeWasHidden) {
|
||
if (current2 === null) {
|
||
{
|
||
if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
||
if (instance.props !== finishedWork.memoizedProps) {
|
||
error("Expected %s props to match memoized props before componentDidMount. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.", getComponentNameFromFiber(finishedWork) || "instance");
|
||
}
|
||
if (instance.state !== finishedWork.memoizedState) {
|
||
error("Expected %s state to match memoized state before componentDidMount. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.", getComponentNameFromFiber(finishedWork) || "instance");
|
||
}
|
||
}
|
||
}
|
||
if (finishedWork.mode & ProfileMode) {
|
||
try {
|
||
startLayoutEffectTimer();
|
||
instance.componentDidMount();
|
||
} finally {
|
||
recordLayoutEffectDuration(finishedWork);
|
||
}
|
||
} else {
|
||
instance.componentDidMount();
|
||
}
|
||
} else {
|
||
var prevProps = finishedWork.elementType === finishedWork.type ? current2.memoizedProps : resolveDefaultProps(finishedWork.type, current2.memoizedProps);
|
||
var prevState = current2.memoizedState;
|
||
{
|
||
if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
||
if (instance.props !== finishedWork.memoizedProps) {
|
||
error("Expected %s props to match memoized props before componentDidUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.", getComponentNameFromFiber(finishedWork) || "instance");
|
||
}
|
||
if (instance.state !== finishedWork.memoizedState) {
|
||
error("Expected %s state to match memoized state before componentDidUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.", getComponentNameFromFiber(finishedWork) || "instance");
|
||
}
|
||
}
|
||
}
|
||
if (finishedWork.mode & ProfileMode) {
|
||
try {
|
||
startLayoutEffectTimer();
|
||
instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
|
||
} finally {
|
||
recordLayoutEffectDuration(finishedWork);
|
||
}
|
||
} else {
|
||
instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var updateQueue = finishedWork.updateQueue;
|
||
if (updateQueue !== null) {
|
||
{
|
||
if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
||
if (instance.props !== finishedWork.memoizedProps) {
|
||
error("Expected %s props to match memoized props before processing the update queue. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.", getComponentNameFromFiber(finishedWork) || "instance");
|
||
}
|
||
if (instance.state !== finishedWork.memoizedState) {
|
||
error("Expected %s state to match memoized state before processing the update queue. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.", getComponentNameFromFiber(finishedWork) || "instance");
|
||
}
|
||
}
|
||
}
|
||
commitUpdateQueue(finishedWork, updateQueue, instance);
|
||
}
|
||
break;
|
||
}
|
||
case HostRoot: {
|
||
var _updateQueue = finishedWork.updateQueue;
|
||
if (_updateQueue !== null) {
|
||
var _instance = null;
|
||
if (finishedWork.child !== null) {
|
||
switch (finishedWork.child.tag) {
|
||
case HostComponent:
|
||
_instance = getPublicInstance(finishedWork.child.stateNode);
|
||
break;
|
||
case ClassComponent:
|
||
_instance = finishedWork.child.stateNode;
|
||
break;
|
||
}
|
||
}
|
||
commitUpdateQueue(finishedWork, _updateQueue, _instance);
|
||
}
|
||
break;
|
||
}
|
||
case HostComponent: {
|
||
var _instance2 = finishedWork.stateNode;
|
||
if (current2 === null && finishedWork.flags & Update) {
|
||
var type = finishedWork.type;
|
||
var props = finishedWork.memoizedProps;
|
||
commitMount(_instance2, type, props);
|
||
}
|
||
break;
|
||
}
|
||
case HostText: {
|
||
break;
|
||
}
|
||
case HostPortal: {
|
||
break;
|
||
}
|
||
case Profiler: {
|
||
{
|
||
var _finishedWork$memoize2 = finishedWork.memoizedProps, onCommit = _finishedWork$memoize2.onCommit, onRender = _finishedWork$memoize2.onRender;
|
||
var effectDuration = finishedWork.stateNode.effectDuration;
|
||
var commitTime2 = getCommitTime();
|
||
var phase = current2 === null ? "mount" : "update";
|
||
{
|
||
if (isCurrentUpdateNested()) {
|
||
phase = "nested-update";
|
||
}
|
||
}
|
||
if (typeof onRender === "function") {
|
||
onRender(finishedWork.memoizedProps.id, phase, finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, commitTime2);
|
||
}
|
||
{
|
||
if (typeof onCommit === "function") {
|
||
onCommit(finishedWork.memoizedProps.id, phase, effectDuration, commitTime2);
|
||
}
|
||
enqueuePendingPassiveProfilerEffect(finishedWork);
|
||
var parentFiber = finishedWork.return;
|
||
outer:
|
||
while (parentFiber !== null) {
|
||
switch (parentFiber.tag) {
|
||
case HostRoot:
|
||
var root2 = parentFiber.stateNode;
|
||
root2.effectDuration += effectDuration;
|
||
break outer;
|
||
case Profiler:
|
||
var parentStateNode = parentFiber.stateNode;
|
||
parentStateNode.effectDuration += effectDuration;
|
||
break outer;
|
||
}
|
||
parentFiber = parentFiber.return;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
case SuspenseComponent: {
|
||
commitSuspenseHydrationCallbacks(finishedRoot, finishedWork);
|
||
break;
|
||
}
|
||
case SuspenseListComponent:
|
||
case IncompleteClassComponent:
|
||
case ScopeComponent:
|
||
case OffscreenComponent:
|
||
case LegacyHiddenComponent:
|
||
case TracingMarkerComponent: {
|
||
break;
|
||
}
|
||
default:
|
||
throw new Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
if (!offscreenSubtreeWasHidden) {
|
||
{
|
||
if (finishedWork.flags & Ref) {
|
||
commitAttachRef(finishedWork);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function reappearLayoutEffectsOnFiber(node) {
|
||
switch (node.tag) {
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case SimpleMemoComponent: {
|
||
if (node.mode & ProfileMode) {
|
||
try {
|
||
startLayoutEffectTimer();
|
||
safelyCallCommitHookLayoutEffectListMount(node, node.return);
|
||
} finally {
|
||
recordLayoutEffectDuration(node);
|
||
}
|
||
} else {
|
||
safelyCallCommitHookLayoutEffectListMount(node, node.return);
|
||
}
|
||
break;
|
||
}
|
||
case ClassComponent: {
|
||
var instance = node.stateNode;
|
||
if (typeof instance.componentDidMount === "function") {
|
||
safelyCallComponentDidMount(node, node.return, instance);
|
||
}
|
||
safelyAttachRef(node, node.return);
|
||
break;
|
||
}
|
||
case HostComponent: {
|
||
safelyAttachRef(node, node.return);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
function hideOrUnhideAllChildren(finishedWork, isHidden) {
|
||
var hostSubtreeRoot = null;
|
||
{
|
||
var node = finishedWork;
|
||
while (true) {
|
||
if (node.tag === HostComponent) {
|
||
if (hostSubtreeRoot === null) {
|
||
hostSubtreeRoot = node;
|
||
try {
|
||
var instance = node.stateNode;
|
||
if (isHidden) {
|
||
hideInstance(instance);
|
||
} else {
|
||
unhideInstance(node.stateNode, node.memoizedProps);
|
||
}
|
||
} catch (error2) {
|
||
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
||
}
|
||
}
|
||
} else if (node.tag === HostText) {
|
||
if (hostSubtreeRoot === null) {
|
||
try {
|
||
var _instance3 = node.stateNode;
|
||
if (isHidden) {
|
||
hideTextInstance(_instance3);
|
||
} else {
|
||
unhideTextInstance(_instance3, node.memoizedProps);
|
||
}
|
||
} catch (error2) {
|
||
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
||
}
|
||
}
|
||
} else if ((node.tag === OffscreenComponent || node.tag === LegacyHiddenComponent) && node.memoizedState !== null && node !== finishedWork)
|
||
;
|
||
else if (node.child !== null) {
|
||
node.child.return = node;
|
||
node = node.child;
|
||
continue;
|
||
}
|
||
if (node === finishedWork) {
|
||
return;
|
||
}
|
||
while (node.sibling === null) {
|
||
if (node.return === null || node.return === finishedWork) {
|
||
return;
|
||
}
|
||
if (hostSubtreeRoot === node) {
|
||
hostSubtreeRoot = null;
|
||
}
|
||
node = node.return;
|
||
}
|
||
if (hostSubtreeRoot === node) {
|
||
hostSubtreeRoot = null;
|
||
}
|
||
node.sibling.return = node.return;
|
||
node = node.sibling;
|
||
}
|
||
}
|
||
}
|
||
function commitAttachRef(finishedWork) {
|
||
var ref = finishedWork.ref;
|
||
if (ref !== null) {
|
||
var instance = finishedWork.stateNode;
|
||
var instanceToUse;
|
||
switch (finishedWork.tag) {
|
||
case HostComponent:
|
||
instanceToUse = getPublicInstance(instance);
|
||
break;
|
||
default:
|
||
instanceToUse = instance;
|
||
}
|
||
if (typeof ref === "function") {
|
||
var retVal;
|
||
if (finishedWork.mode & ProfileMode) {
|
||
try {
|
||
startLayoutEffectTimer();
|
||
retVal = ref(instanceToUse);
|
||
} finally {
|
||
recordLayoutEffectDuration(finishedWork);
|
||
}
|
||
} else {
|
||
retVal = ref(instanceToUse);
|
||
}
|
||
{
|
||
if (typeof retVal === "function") {
|
||
error("Unexpected return value from a callback ref in %s. A callback ref should not return a function.", getComponentNameFromFiber(finishedWork));
|
||
}
|
||
}
|
||
} else {
|
||
{
|
||
if (!ref.hasOwnProperty("current")) {
|
||
error("Unexpected ref object provided for %s. Use either a ref-setter function or React.createRef().", getComponentNameFromFiber(finishedWork));
|
||
}
|
||
}
|
||
ref.current = instanceToUse;
|
||
}
|
||
}
|
||
}
|
||
function detachFiberMutation(fiber) {
|
||
var alternate = fiber.alternate;
|
||
if (alternate !== null) {
|
||
alternate.return = null;
|
||
}
|
||
fiber.return = null;
|
||
}
|
||
function detachFiberAfterEffects(fiber) {
|
||
var alternate = fiber.alternate;
|
||
if (alternate !== null) {
|
||
fiber.alternate = null;
|
||
detachFiberAfterEffects(alternate);
|
||
}
|
||
{
|
||
fiber.child = null;
|
||
fiber.deletions = null;
|
||
fiber.sibling = null;
|
||
if (fiber.tag === HostComponent) {
|
||
var hostInstance = fiber.stateNode;
|
||
if (hostInstance !== null) {
|
||
detachDeletedInstance(hostInstance);
|
||
}
|
||
}
|
||
fiber.stateNode = null;
|
||
{
|
||
fiber._debugOwner = null;
|
||
}
|
||
{
|
||
fiber.return = null;
|
||
fiber.dependencies = null;
|
||
fiber.memoizedProps = null;
|
||
fiber.memoizedState = null;
|
||
fiber.pendingProps = null;
|
||
fiber.stateNode = null;
|
||
fiber.updateQueue = null;
|
||
}
|
||
}
|
||
}
|
||
function getHostParentFiber(fiber) {
|
||
var parent2 = fiber.return;
|
||
while (parent2 !== null) {
|
||
if (isHostParent(parent2)) {
|
||
return parent2;
|
||
}
|
||
parent2 = parent2.return;
|
||
}
|
||
throw new Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
function isHostParent(fiber) {
|
||
return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
|
||
}
|
||
function getHostSibling(fiber) {
|
||
var node = fiber;
|
||
siblings:
|
||
while (true) {
|
||
while (node.sibling === null) {
|
||
if (node.return === null || isHostParent(node.return)) {
|
||
return null;
|
||
}
|
||
node = node.return;
|
||
}
|
||
node.sibling.return = node.return;
|
||
node = node.sibling;
|
||
while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) {
|
||
if (node.flags & Placement) {
|
||
continue siblings;
|
||
}
|
||
if (node.child === null || node.tag === HostPortal) {
|
||
continue siblings;
|
||
} else {
|
||
node.child.return = node;
|
||
node = node.child;
|
||
}
|
||
}
|
||
if (!(node.flags & Placement)) {
|
||
return node.stateNode;
|
||
}
|
||
}
|
||
}
|
||
function commitPlacement(finishedWork) {
|
||
var parentFiber = getHostParentFiber(finishedWork);
|
||
switch (parentFiber.tag) {
|
||
case HostComponent: {
|
||
var parent2 = parentFiber.stateNode;
|
||
if (parentFiber.flags & ContentReset) {
|
||
resetTextContent(parent2);
|
||
parentFiber.flags &= ~ContentReset;
|
||
}
|
||
var before = getHostSibling(finishedWork);
|
||
insertOrAppendPlacementNode(finishedWork, before, parent2);
|
||
break;
|
||
}
|
||
case HostRoot:
|
||
case HostPortal: {
|
||
var _parent = parentFiber.stateNode.containerInfo;
|
||
var _before = getHostSibling(finishedWork);
|
||
insertOrAppendPlacementNodeIntoContainer(finishedWork, _before, _parent);
|
||
break;
|
||
}
|
||
default:
|
||
throw new Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
function insertOrAppendPlacementNodeIntoContainer(node, before, parent2) {
|
||
var tag = node.tag;
|
||
var isHost = tag === HostComponent || tag === HostText;
|
||
if (isHost) {
|
||
var stateNode = node.stateNode;
|
||
if (before) {
|
||
insertInContainerBefore(parent2, stateNode, before);
|
||
} else {
|
||
appendChildToContainer(parent2, stateNode);
|
||
}
|
||
} else if (tag === HostPortal)
|
||
;
|
||
else {
|
||
var child = node.child;
|
||
if (child !== null) {
|
||
insertOrAppendPlacementNodeIntoContainer(child, before, parent2);
|
||
var sibling = child.sibling;
|
||
while (sibling !== null) {
|
||
insertOrAppendPlacementNodeIntoContainer(sibling, before, parent2);
|
||
sibling = sibling.sibling;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function insertOrAppendPlacementNode(node, before, parent2) {
|
||
var tag = node.tag;
|
||
var isHost = tag === HostComponent || tag === HostText;
|
||
if (isHost) {
|
||
var stateNode = node.stateNode;
|
||
if (before) {
|
||
insertBefore(parent2, stateNode, before);
|
||
} else {
|
||
appendChild(parent2, stateNode);
|
||
}
|
||
} else if (tag === HostPortal)
|
||
;
|
||
else {
|
||
var child = node.child;
|
||
if (child !== null) {
|
||
insertOrAppendPlacementNode(child, before, parent2);
|
||
var sibling = child.sibling;
|
||
while (sibling !== null) {
|
||
insertOrAppendPlacementNode(sibling, before, parent2);
|
||
sibling = sibling.sibling;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var hostParent = null;
|
||
var hostParentIsContainer = false;
|
||
function commitDeletionEffects(root2, returnFiber, deletedFiber) {
|
||
{
|
||
var parent2 = returnFiber;
|
||
findParent:
|
||
while (parent2 !== null) {
|
||
switch (parent2.tag) {
|
||
case HostComponent: {
|
||
hostParent = parent2.stateNode;
|
||
hostParentIsContainer = false;
|
||
break findParent;
|
||
}
|
||
case HostRoot: {
|
||
hostParent = parent2.stateNode.containerInfo;
|
||
hostParentIsContainer = true;
|
||
break findParent;
|
||
}
|
||
case HostPortal: {
|
||
hostParent = parent2.stateNode.containerInfo;
|
||
hostParentIsContainer = true;
|
||
break findParent;
|
||
}
|
||
}
|
||
parent2 = parent2.return;
|
||
}
|
||
if (hostParent === null) {
|
||
throw new Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
commitDeletionEffectsOnFiber(root2, returnFiber, deletedFiber);
|
||
hostParent = null;
|
||
hostParentIsContainer = false;
|
||
}
|
||
detachFiberMutation(deletedFiber);
|
||
}
|
||
function recursivelyTraverseDeletionEffects(finishedRoot, nearestMountedAncestor, parent2) {
|
||
var child = parent2.child;
|
||
while (child !== null) {
|
||
commitDeletionEffectsOnFiber(finishedRoot, nearestMountedAncestor, child);
|
||
child = child.sibling;
|
||
}
|
||
}
|
||
function commitDeletionEffectsOnFiber(finishedRoot, nearestMountedAncestor, deletedFiber) {
|
||
onCommitUnmount(deletedFiber);
|
||
switch (deletedFiber.tag) {
|
||
case HostComponent: {
|
||
if (!offscreenSubtreeWasHidden) {
|
||
safelyDetachRef(deletedFiber, nearestMountedAncestor);
|
||
}
|
||
}
|
||
case HostText: {
|
||
{
|
||
var prevHostParent = hostParent;
|
||
var prevHostParentIsContainer = hostParentIsContainer;
|
||
hostParent = null;
|
||
recursivelyTraverseDeletionEffects(finishedRoot, nearestMountedAncestor, deletedFiber);
|
||
hostParent = prevHostParent;
|
||
hostParentIsContainer = prevHostParentIsContainer;
|
||
if (hostParent !== null) {
|
||
if (hostParentIsContainer) {
|
||
removeChildFromContainer(hostParent, deletedFiber.stateNode);
|
||
} else {
|
||
removeChild(hostParent, deletedFiber.stateNode);
|
||
}
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
case DehydratedFragment: {
|
||
{
|
||
if (hostParent !== null) {
|
||
if (hostParentIsContainer) {
|
||
clearSuspenseBoundaryFromContainer(hostParent, deletedFiber.stateNode);
|
||
} else {
|
||
clearSuspenseBoundary(hostParent, deletedFiber.stateNode);
|
||
}
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
case HostPortal: {
|
||
{
|
||
var _prevHostParent = hostParent;
|
||
var _prevHostParentIsContainer = hostParentIsContainer;
|
||
hostParent = deletedFiber.stateNode.containerInfo;
|
||
hostParentIsContainer = true;
|
||
recursivelyTraverseDeletionEffects(finishedRoot, nearestMountedAncestor, deletedFiber);
|
||
hostParent = _prevHostParent;
|
||
hostParentIsContainer = _prevHostParentIsContainer;
|
||
}
|
||
return;
|
||
}
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case MemoComponent:
|
||
case SimpleMemoComponent: {
|
||
if (!offscreenSubtreeWasHidden) {
|
||
var updateQueue = deletedFiber.updateQueue;
|
||
if (updateQueue !== null) {
|
||
var lastEffect = updateQueue.lastEffect;
|
||
if (lastEffect !== null) {
|
||
var firstEffect = lastEffect.next;
|
||
var effect = firstEffect;
|
||
do {
|
||
var _effect = effect, destroy = _effect.destroy, tag = _effect.tag;
|
||
if (destroy !== void 0) {
|
||
if ((tag & Insertion) !== NoFlags$1) {
|
||
safelyCallDestroy(deletedFiber, nearestMountedAncestor, destroy);
|
||
} else if ((tag & Layout) !== NoFlags$1) {
|
||
{
|
||
markComponentLayoutEffectUnmountStarted(deletedFiber);
|
||
}
|
||
if (deletedFiber.mode & ProfileMode) {
|
||
startLayoutEffectTimer();
|
||
safelyCallDestroy(deletedFiber, nearestMountedAncestor, destroy);
|
||
recordLayoutEffectDuration(deletedFiber);
|
||
} else {
|
||
safelyCallDestroy(deletedFiber, nearestMountedAncestor, destroy);
|
||
}
|
||
{
|
||
markComponentLayoutEffectUnmountStopped();
|
||
}
|
||
}
|
||
}
|
||
effect = effect.next;
|
||
} while (effect !== firstEffect);
|
||
}
|
||
}
|
||
}
|
||
recursivelyTraverseDeletionEffects(finishedRoot, nearestMountedAncestor, deletedFiber);
|
||
return;
|
||
}
|
||
case ClassComponent: {
|
||
if (!offscreenSubtreeWasHidden) {
|
||
safelyDetachRef(deletedFiber, nearestMountedAncestor);
|
||
var instance = deletedFiber.stateNode;
|
||
if (typeof instance.componentWillUnmount === "function") {
|
||
safelyCallComponentWillUnmount(deletedFiber, nearestMountedAncestor, instance);
|
||
}
|
||
}
|
||
recursivelyTraverseDeletionEffects(finishedRoot, nearestMountedAncestor, deletedFiber);
|
||
return;
|
||
}
|
||
case ScopeComponent: {
|
||
recursivelyTraverseDeletionEffects(finishedRoot, nearestMountedAncestor, deletedFiber);
|
||
return;
|
||
}
|
||
case OffscreenComponent: {
|
||
if (deletedFiber.mode & ConcurrentMode) {
|
||
var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden;
|
||
offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || deletedFiber.memoizedState !== null;
|
||
recursivelyTraverseDeletionEffects(finishedRoot, nearestMountedAncestor, deletedFiber);
|
||
offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden;
|
||
} else {
|
||
recursivelyTraverseDeletionEffects(finishedRoot, nearestMountedAncestor, deletedFiber);
|
||
}
|
||
break;
|
||
}
|
||
default: {
|
||
recursivelyTraverseDeletionEffects(finishedRoot, nearestMountedAncestor, deletedFiber);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
function commitSuspenseCallback(finishedWork) {
|
||
var newState = finishedWork.memoizedState;
|
||
}
|
||
function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) {
|
||
var newState = finishedWork.memoizedState;
|
||
if (newState === null) {
|
||
var current2 = finishedWork.alternate;
|
||
if (current2 !== null) {
|
||
var prevState = current2.memoizedState;
|
||
if (prevState !== null) {
|
||
var suspenseInstance = prevState.dehydrated;
|
||
if (suspenseInstance !== null) {
|
||
commitHydratedSuspenseInstance(suspenseInstance);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function attachSuspenseRetryListeners(finishedWork) {
|
||
var wakeables = finishedWork.updateQueue;
|
||
if (wakeables !== null) {
|
||
finishedWork.updateQueue = null;
|
||
var retryCache = finishedWork.stateNode;
|
||
if (retryCache === null) {
|
||
retryCache = finishedWork.stateNode = new PossiblyWeakSet();
|
||
}
|
||
wakeables.forEach(function(wakeable) {
|
||
var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable);
|
||
if (!retryCache.has(wakeable)) {
|
||
retryCache.add(wakeable);
|
||
{
|
||
if (isDevToolsPresent) {
|
||
if (inProgressLanes !== null && inProgressRoot !== null) {
|
||
restorePendingUpdaters(inProgressRoot, inProgressLanes);
|
||
} else {
|
||
throw Error("Expected finished root and lanes to be set. This is a bug in React.");
|
||
}
|
||
}
|
||
}
|
||
wakeable.then(retry, retry);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
function commitMutationEffects(root2, finishedWork, committedLanes) {
|
||
inProgressLanes = committedLanes;
|
||
inProgressRoot = root2;
|
||
setCurrentFiber(finishedWork);
|
||
commitMutationEffectsOnFiber(finishedWork, root2);
|
||
setCurrentFiber(finishedWork);
|
||
inProgressLanes = null;
|
||
inProgressRoot = null;
|
||
}
|
||
function recursivelyTraverseMutationEffects(root2, parentFiber, lanes) {
|
||
var deletions = parentFiber.deletions;
|
||
if (deletions !== null) {
|
||
for (var i = 0; i < deletions.length; i++) {
|
||
var childToDelete = deletions[i];
|
||
try {
|
||
commitDeletionEffects(root2, parentFiber, childToDelete);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(childToDelete, parentFiber, error2);
|
||
}
|
||
}
|
||
}
|
||
var prevDebugFiber = getCurrentFiber();
|
||
if (parentFiber.subtreeFlags & MutationMask) {
|
||
var child = parentFiber.child;
|
||
while (child !== null) {
|
||
setCurrentFiber(child);
|
||
commitMutationEffectsOnFiber(child, root2);
|
||
child = child.sibling;
|
||
}
|
||
}
|
||
setCurrentFiber(prevDebugFiber);
|
||
}
|
||
function commitMutationEffectsOnFiber(finishedWork, root2, lanes) {
|
||
var current2 = finishedWork.alternate;
|
||
var flags = finishedWork.flags;
|
||
switch (finishedWork.tag) {
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case MemoComponent:
|
||
case SimpleMemoComponent: {
|
||
recursivelyTraverseMutationEffects(root2, finishedWork);
|
||
commitReconciliationEffects(finishedWork);
|
||
if (flags & Update) {
|
||
try {
|
||
commitHookEffectListUnmount(Insertion | HasEffect, finishedWork, finishedWork.return);
|
||
commitHookEffectListMount(Insertion | HasEffect, finishedWork);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
||
}
|
||
if (finishedWork.mode & ProfileMode) {
|
||
try {
|
||
startLayoutEffectTimer();
|
||
commitHookEffectListUnmount(Layout | HasEffect, finishedWork, finishedWork.return);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
||
}
|
||
recordLayoutEffectDuration(finishedWork);
|
||
} else {
|
||
try {
|
||
commitHookEffectListUnmount(Layout | HasEffect, finishedWork, finishedWork.return);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
||
}
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
case ClassComponent: {
|
||
recursivelyTraverseMutationEffects(root2, finishedWork);
|
||
commitReconciliationEffects(finishedWork);
|
||
if (flags & Ref) {
|
||
if (current2 !== null) {
|
||
safelyDetachRef(current2, current2.return);
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
case HostComponent: {
|
||
recursivelyTraverseMutationEffects(root2, finishedWork);
|
||
commitReconciliationEffects(finishedWork);
|
||
if (flags & Ref) {
|
||
if (current2 !== null) {
|
||
safelyDetachRef(current2, current2.return);
|
||
}
|
||
}
|
||
{
|
||
if (finishedWork.flags & ContentReset) {
|
||
var instance = finishedWork.stateNode;
|
||
try {
|
||
resetTextContent(instance);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
||
}
|
||
}
|
||
if (flags & Update) {
|
||
var _instance4 = finishedWork.stateNode;
|
||
if (_instance4 != null) {
|
||
var newProps = finishedWork.memoizedProps;
|
||
var oldProps = current2 !== null ? current2.memoizedProps : newProps;
|
||
var type = finishedWork.type;
|
||
var updatePayload = finishedWork.updateQueue;
|
||
finishedWork.updateQueue = null;
|
||
if (updatePayload !== null) {
|
||
try {
|
||
commitUpdate(_instance4, updatePayload, type, oldProps, newProps, finishedWork);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
case HostText: {
|
||
recursivelyTraverseMutationEffects(root2, finishedWork);
|
||
commitReconciliationEffects(finishedWork);
|
||
if (flags & Update) {
|
||
{
|
||
if (finishedWork.stateNode === null) {
|
||
throw new Error("This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
var textInstance = finishedWork.stateNode;
|
||
var newText = finishedWork.memoizedProps;
|
||
var oldText = current2 !== null ? current2.memoizedProps : newText;
|
||
try {
|
||
commitTextUpdate(textInstance, oldText, newText);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
||
}
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
case HostRoot: {
|
||
recursivelyTraverseMutationEffects(root2, finishedWork);
|
||
commitReconciliationEffects(finishedWork);
|
||
if (flags & Update) {
|
||
{
|
||
if (current2 !== null) {
|
||
var prevRootState = current2.memoizedState;
|
||
if (prevRootState.isDehydrated) {
|
||
try {
|
||
commitHydratedContainer(root2.containerInfo);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
case HostPortal: {
|
||
recursivelyTraverseMutationEffects(root2, finishedWork);
|
||
commitReconciliationEffects(finishedWork);
|
||
return;
|
||
}
|
||
case SuspenseComponent: {
|
||
recursivelyTraverseMutationEffects(root2, finishedWork);
|
||
commitReconciliationEffects(finishedWork);
|
||
var offscreenFiber = finishedWork.child;
|
||
if (offscreenFiber.flags & Visibility) {
|
||
var offscreenInstance = offscreenFiber.stateNode;
|
||
var newState = offscreenFiber.memoizedState;
|
||
var isHidden = newState !== null;
|
||
offscreenInstance.isHidden = isHidden;
|
||
if (isHidden) {
|
||
var wasHidden = offscreenFiber.alternate !== null && offscreenFiber.alternate.memoizedState !== null;
|
||
if (!wasHidden) {
|
||
markCommitTimeOfFallback();
|
||
}
|
||
}
|
||
}
|
||
if (flags & Update) {
|
||
try {
|
||
commitSuspenseCallback(finishedWork);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
||
}
|
||
attachSuspenseRetryListeners(finishedWork);
|
||
}
|
||
return;
|
||
}
|
||
case OffscreenComponent: {
|
||
var _wasHidden = current2 !== null && current2.memoizedState !== null;
|
||
if (finishedWork.mode & ConcurrentMode) {
|
||
var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden;
|
||
offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || _wasHidden;
|
||
recursivelyTraverseMutationEffects(root2, finishedWork);
|
||
offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden;
|
||
} else {
|
||
recursivelyTraverseMutationEffects(root2, finishedWork);
|
||
}
|
||
commitReconciliationEffects(finishedWork);
|
||
if (flags & Visibility) {
|
||
var _offscreenInstance = finishedWork.stateNode;
|
||
var _newState = finishedWork.memoizedState;
|
||
var _isHidden = _newState !== null;
|
||
var offscreenBoundary = finishedWork;
|
||
_offscreenInstance.isHidden = _isHidden;
|
||
{
|
||
if (_isHidden) {
|
||
if (!_wasHidden) {
|
||
if ((offscreenBoundary.mode & ConcurrentMode) !== NoMode) {
|
||
nextEffect = offscreenBoundary;
|
||
var offscreenChild = offscreenBoundary.child;
|
||
while (offscreenChild !== null) {
|
||
nextEffect = offscreenChild;
|
||
disappearLayoutEffects_begin(offscreenChild);
|
||
offscreenChild = offscreenChild.sibling;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
{
|
||
hideOrUnhideAllChildren(offscreenBoundary, _isHidden);
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
case SuspenseListComponent: {
|
||
recursivelyTraverseMutationEffects(root2, finishedWork);
|
||
commitReconciliationEffects(finishedWork);
|
||
if (flags & Update) {
|
||
attachSuspenseRetryListeners(finishedWork);
|
||
}
|
||
return;
|
||
}
|
||
case ScopeComponent: {
|
||
return;
|
||
}
|
||
default: {
|
||
recursivelyTraverseMutationEffects(root2, finishedWork);
|
||
commitReconciliationEffects(finishedWork);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
function commitReconciliationEffects(finishedWork) {
|
||
var flags = finishedWork.flags;
|
||
if (flags & Placement) {
|
||
try {
|
||
commitPlacement(finishedWork);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
||
}
|
||
finishedWork.flags &= ~Placement;
|
||
}
|
||
if (flags & Hydrating) {
|
||
finishedWork.flags &= ~Hydrating;
|
||
}
|
||
}
|
||
function commitLayoutEffects(finishedWork, root2, committedLanes) {
|
||
inProgressLanes = committedLanes;
|
||
inProgressRoot = root2;
|
||
nextEffect = finishedWork;
|
||
commitLayoutEffects_begin(finishedWork, root2, committedLanes);
|
||
inProgressLanes = null;
|
||
inProgressRoot = null;
|
||
}
|
||
function commitLayoutEffects_begin(subtreeRoot, root2, committedLanes) {
|
||
var isModernRoot = (subtreeRoot.mode & ConcurrentMode) !== NoMode;
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
var firstChild = fiber.child;
|
||
if (fiber.tag === OffscreenComponent && isModernRoot) {
|
||
var isHidden = fiber.memoizedState !== null;
|
||
var newOffscreenSubtreeIsHidden = isHidden || offscreenSubtreeIsHidden;
|
||
if (newOffscreenSubtreeIsHidden) {
|
||
commitLayoutMountEffects_complete(subtreeRoot, root2, committedLanes);
|
||
continue;
|
||
} else {
|
||
var current2 = fiber.alternate;
|
||
var wasHidden = current2 !== null && current2.memoizedState !== null;
|
||
var newOffscreenSubtreeWasHidden = wasHidden || offscreenSubtreeWasHidden;
|
||
var prevOffscreenSubtreeIsHidden = offscreenSubtreeIsHidden;
|
||
var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden;
|
||
offscreenSubtreeIsHidden = newOffscreenSubtreeIsHidden;
|
||
offscreenSubtreeWasHidden = newOffscreenSubtreeWasHidden;
|
||
if (offscreenSubtreeWasHidden && !prevOffscreenSubtreeWasHidden) {
|
||
nextEffect = fiber;
|
||
reappearLayoutEffects_begin(fiber);
|
||
}
|
||
var child = firstChild;
|
||
while (child !== null) {
|
||
nextEffect = child;
|
||
commitLayoutEffects_begin(child, root2, committedLanes);
|
||
child = child.sibling;
|
||
}
|
||
nextEffect = fiber;
|
||
offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden;
|
||
offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden;
|
||
commitLayoutMountEffects_complete(subtreeRoot, root2, committedLanes);
|
||
continue;
|
||
}
|
||
}
|
||
if ((fiber.subtreeFlags & LayoutMask) !== NoFlags && firstChild !== null) {
|
||
firstChild.return = fiber;
|
||
nextEffect = firstChild;
|
||
} else {
|
||
commitLayoutMountEffects_complete(subtreeRoot, root2, committedLanes);
|
||
}
|
||
}
|
||
}
|
||
function commitLayoutMountEffects_complete(subtreeRoot, root2, committedLanes) {
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
if ((fiber.flags & LayoutMask) !== NoFlags) {
|
||
var current2 = fiber.alternate;
|
||
setCurrentFiber(fiber);
|
||
try {
|
||
commitLayoutEffectOnFiber(root2, current2, fiber, committedLanes);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(fiber, fiber.return, error2);
|
||
}
|
||
resetCurrentFiber();
|
||
}
|
||
if (fiber === subtreeRoot) {
|
||
nextEffect = null;
|
||
return;
|
||
}
|
||
var sibling = fiber.sibling;
|
||
if (sibling !== null) {
|
||
sibling.return = fiber.return;
|
||
nextEffect = sibling;
|
||
return;
|
||
}
|
||
nextEffect = fiber.return;
|
||
}
|
||
}
|
||
function disappearLayoutEffects_begin(subtreeRoot) {
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
var firstChild = fiber.child;
|
||
switch (fiber.tag) {
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case MemoComponent:
|
||
case SimpleMemoComponent: {
|
||
if (fiber.mode & ProfileMode) {
|
||
try {
|
||
startLayoutEffectTimer();
|
||
commitHookEffectListUnmount(Layout, fiber, fiber.return);
|
||
} finally {
|
||
recordLayoutEffectDuration(fiber);
|
||
}
|
||
} else {
|
||
commitHookEffectListUnmount(Layout, fiber, fiber.return);
|
||
}
|
||
break;
|
||
}
|
||
case ClassComponent: {
|
||
safelyDetachRef(fiber, fiber.return);
|
||
var instance = fiber.stateNode;
|
||
if (typeof instance.componentWillUnmount === "function") {
|
||
safelyCallComponentWillUnmount(fiber, fiber.return, instance);
|
||
}
|
||
break;
|
||
}
|
||
case HostComponent: {
|
||
safelyDetachRef(fiber, fiber.return);
|
||
break;
|
||
}
|
||
case OffscreenComponent: {
|
||
var isHidden = fiber.memoizedState !== null;
|
||
if (isHidden) {
|
||
disappearLayoutEffects_complete(subtreeRoot);
|
||
continue;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
if (firstChild !== null) {
|
||
firstChild.return = fiber;
|
||
nextEffect = firstChild;
|
||
} else {
|
||
disappearLayoutEffects_complete(subtreeRoot);
|
||
}
|
||
}
|
||
}
|
||
function disappearLayoutEffects_complete(subtreeRoot) {
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
if (fiber === subtreeRoot) {
|
||
nextEffect = null;
|
||
return;
|
||
}
|
||
var sibling = fiber.sibling;
|
||
if (sibling !== null) {
|
||
sibling.return = fiber.return;
|
||
nextEffect = sibling;
|
||
return;
|
||
}
|
||
nextEffect = fiber.return;
|
||
}
|
||
}
|
||
function reappearLayoutEffects_begin(subtreeRoot) {
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
var firstChild = fiber.child;
|
||
if (fiber.tag === OffscreenComponent) {
|
||
var isHidden = fiber.memoizedState !== null;
|
||
if (isHidden) {
|
||
reappearLayoutEffects_complete(subtreeRoot);
|
||
continue;
|
||
}
|
||
}
|
||
if (firstChild !== null) {
|
||
firstChild.return = fiber;
|
||
nextEffect = firstChild;
|
||
} else {
|
||
reappearLayoutEffects_complete(subtreeRoot);
|
||
}
|
||
}
|
||
}
|
||
function reappearLayoutEffects_complete(subtreeRoot) {
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
setCurrentFiber(fiber);
|
||
try {
|
||
reappearLayoutEffectsOnFiber(fiber);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(fiber, fiber.return, error2);
|
||
}
|
||
resetCurrentFiber();
|
||
if (fiber === subtreeRoot) {
|
||
nextEffect = null;
|
||
return;
|
||
}
|
||
var sibling = fiber.sibling;
|
||
if (sibling !== null) {
|
||
sibling.return = fiber.return;
|
||
nextEffect = sibling;
|
||
return;
|
||
}
|
||
nextEffect = fiber.return;
|
||
}
|
||
}
|
||
function commitPassiveMountEffects(root2, finishedWork, committedLanes, committedTransitions) {
|
||
nextEffect = finishedWork;
|
||
commitPassiveMountEffects_begin(finishedWork, root2, committedLanes, committedTransitions);
|
||
}
|
||
function commitPassiveMountEffects_begin(subtreeRoot, root2, committedLanes, committedTransitions) {
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
var firstChild = fiber.child;
|
||
if ((fiber.subtreeFlags & PassiveMask) !== NoFlags && firstChild !== null) {
|
||
firstChild.return = fiber;
|
||
nextEffect = firstChild;
|
||
} else {
|
||
commitPassiveMountEffects_complete(subtreeRoot, root2, committedLanes, committedTransitions);
|
||
}
|
||
}
|
||
}
|
||
function commitPassiveMountEffects_complete(subtreeRoot, root2, committedLanes, committedTransitions) {
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
if ((fiber.flags & Passive) !== NoFlags) {
|
||
setCurrentFiber(fiber);
|
||
try {
|
||
commitPassiveMountOnFiber(root2, fiber, committedLanes, committedTransitions);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(fiber, fiber.return, error2);
|
||
}
|
||
resetCurrentFiber();
|
||
}
|
||
if (fiber === subtreeRoot) {
|
||
nextEffect = null;
|
||
return;
|
||
}
|
||
var sibling = fiber.sibling;
|
||
if (sibling !== null) {
|
||
sibling.return = fiber.return;
|
||
nextEffect = sibling;
|
||
return;
|
||
}
|
||
nextEffect = fiber.return;
|
||
}
|
||
}
|
||
function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) {
|
||
switch (finishedWork.tag) {
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case SimpleMemoComponent: {
|
||
if (finishedWork.mode & ProfileMode) {
|
||
startPassiveEffectTimer();
|
||
try {
|
||
commitHookEffectListMount(Passive$1 | HasEffect, finishedWork);
|
||
} finally {
|
||
recordPassiveEffectDuration(finishedWork);
|
||
}
|
||
} else {
|
||
commitHookEffectListMount(Passive$1 | HasEffect, finishedWork);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
function commitPassiveUnmountEffects(firstChild) {
|
||
nextEffect = firstChild;
|
||
commitPassiveUnmountEffects_begin();
|
||
}
|
||
function commitPassiveUnmountEffects_begin() {
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
var child = fiber.child;
|
||
if ((nextEffect.flags & ChildDeletion) !== NoFlags) {
|
||
var deletions = fiber.deletions;
|
||
if (deletions !== null) {
|
||
for (var i = 0; i < deletions.length; i++) {
|
||
var fiberToDelete = deletions[i];
|
||
nextEffect = fiberToDelete;
|
||
commitPassiveUnmountEffectsInsideOfDeletedTree_begin(fiberToDelete, fiber);
|
||
}
|
||
{
|
||
var previousFiber = fiber.alternate;
|
||
if (previousFiber !== null) {
|
||
var detachedChild = previousFiber.child;
|
||
if (detachedChild !== null) {
|
||
previousFiber.child = null;
|
||
do {
|
||
var detachedSibling = detachedChild.sibling;
|
||
detachedChild.sibling = null;
|
||
detachedChild = detachedSibling;
|
||
} while (detachedChild !== null);
|
||
}
|
||
}
|
||
}
|
||
nextEffect = fiber;
|
||
}
|
||
}
|
||
if ((fiber.subtreeFlags & PassiveMask) !== NoFlags && child !== null) {
|
||
child.return = fiber;
|
||
nextEffect = child;
|
||
} else {
|
||
commitPassiveUnmountEffects_complete();
|
||
}
|
||
}
|
||
}
|
||
function commitPassiveUnmountEffects_complete() {
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
if ((fiber.flags & Passive) !== NoFlags) {
|
||
setCurrentFiber(fiber);
|
||
commitPassiveUnmountOnFiber(fiber);
|
||
resetCurrentFiber();
|
||
}
|
||
var sibling = fiber.sibling;
|
||
if (sibling !== null) {
|
||
sibling.return = fiber.return;
|
||
nextEffect = sibling;
|
||
return;
|
||
}
|
||
nextEffect = fiber.return;
|
||
}
|
||
}
|
||
function commitPassiveUnmountOnFiber(finishedWork) {
|
||
switch (finishedWork.tag) {
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case SimpleMemoComponent: {
|
||
if (finishedWork.mode & ProfileMode) {
|
||
startPassiveEffectTimer();
|
||
commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork, finishedWork.return);
|
||
recordPassiveEffectDuration(finishedWork);
|
||
} else {
|
||
commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork, finishedWork.return);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot, nearestMountedAncestor) {
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
setCurrentFiber(fiber);
|
||
commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor);
|
||
resetCurrentFiber();
|
||
var child = fiber.child;
|
||
if (child !== null) {
|
||
child.return = fiber;
|
||
nextEffect = child;
|
||
} else {
|
||
commitPassiveUnmountEffectsInsideOfDeletedTree_complete(deletedSubtreeRoot);
|
||
}
|
||
}
|
||
}
|
||
function commitPassiveUnmountEffectsInsideOfDeletedTree_complete(deletedSubtreeRoot) {
|
||
while (nextEffect !== null) {
|
||
var fiber = nextEffect;
|
||
var sibling = fiber.sibling;
|
||
var returnFiber = fiber.return;
|
||
{
|
||
detachFiberAfterEffects(fiber);
|
||
if (fiber === deletedSubtreeRoot) {
|
||
nextEffect = null;
|
||
return;
|
||
}
|
||
}
|
||
if (sibling !== null) {
|
||
sibling.return = returnFiber;
|
||
nextEffect = sibling;
|
||
return;
|
||
}
|
||
nextEffect = returnFiber;
|
||
}
|
||
}
|
||
function commitPassiveUnmountInsideDeletedTreeOnFiber(current2, nearestMountedAncestor) {
|
||
switch (current2.tag) {
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case SimpleMemoComponent: {
|
||
if (current2.mode & ProfileMode) {
|
||
startPassiveEffectTimer();
|
||
commitHookEffectListUnmount(Passive$1, current2, nearestMountedAncestor);
|
||
recordPassiveEffectDuration(current2);
|
||
} else {
|
||
commitHookEffectListUnmount(Passive$1, current2, nearestMountedAncestor);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
function invokeLayoutEffectMountInDEV(fiber) {
|
||
{
|
||
switch (fiber.tag) {
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case SimpleMemoComponent: {
|
||
try {
|
||
commitHookEffectListMount(Layout | HasEffect, fiber);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(fiber, fiber.return, error2);
|
||
}
|
||
break;
|
||
}
|
||
case ClassComponent: {
|
||
var instance = fiber.stateNode;
|
||
try {
|
||
instance.componentDidMount();
|
||
} catch (error2) {
|
||
captureCommitPhaseError(fiber, fiber.return, error2);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function invokePassiveEffectMountInDEV(fiber) {
|
||
{
|
||
switch (fiber.tag) {
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case SimpleMemoComponent: {
|
||
try {
|
||
commitHookEffectListMount(Passive$1 | HasEffect, fiber);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(fiber, fiber.return, error2);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function invokeLayoutEffectUnmountInDEV(fiber) {
|
||
{
|
||
switch (fiber.tag) {
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case SimpleMemoComponent: {
|
||
try {
|
||
commitHookEffectListUnmount(Layout | HasEffect, fiber, fiber.return);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(fiber, fiber.return, error2);
|
||
}
|
||
break;
|
||
}
|
||
case ClassComponent: {
|
||
var instance = fiber.stateNode;
|
||
if (typeof instance.componentWillUnmount === "function") {
|
||
safelyCallComponentWillUnmount(fiber, fiber.return, instance);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function invokePassiveEffectUnmountInDEV(fiber) {
|
||
{
|
||
switch (fiber.tag) {
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case SimpleMemoComponent: {
|
||
try {
|
||
commitHookEffectListUnmount(Passive$1 | HasEffect, fiber, fiber.return);
|
||
} catch (error2) {
|
||
captureCommitPhaseError(fiber, fiber.return, error2);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var COMPONENT_TYPE = 0;
|
||
var HAS_PSEUDO_CLASS_TYPE = 1;
|
||
var ROLE_TYPE = 2;
|
||
var TEST_NAME_TYPE = 3;
|
||
var TEXT_TYPE = 4;
|
||
if (typeof Symbol === "function" && Symbol.for) {
|
||
var symbolFor = Symbol.for;
|
||
COMPONENT_TYPE = symbolFor("selector.component");
|
||
HAS_PSEUDO_CLASS_TYPE = symbolFor("selector.has_pseudo_class");
|
||
ROLE_TYPE = symbolFor("selector.role");
|
||
TEST_NAME_TYPE = symbolFor("selector.test_id");
|
||
TEXT_TYPE = symbolFor("selector.text");
|
||
}
|
||
var commitHooks = [];
|
||
function onCommitRoot$1() {
|
||
{
|
||
commitHooks.forEach(function(commitHook) {
|
||
return commitHook();
|
||
});
|
||
}
|
||
}
|
||
var ReactCurrentActQueue = ReactSharedInternals.ReactCurrentActQueue;
|
||
function isLegacyActEnvironment(fiber) {
|
||
{
|
||
var isReactActEnvironmentGlobal = typeof IS_REACT_ACT_ENVIRONMENT !== "undefined" ? IS_REACT_ACT_ENVIRONMENT : void 0;
|
||
var jestIsDefined = typeof jest !== "undefined";
|
||
return jestIsDefined && isReactActEnvironmentGlobal !== false;
|
||
}
|
||
}
|
||
function isConcurrentActEnvironment() {
|
||
{
|
||
var isReactActEnvironmentGlobal = typeof IS_REACT_ACT_ENVIRONMENT !== "undefined" ? IS_REACT_ACT_ENVIRONMENT : void 0;
|
||
if (!isReactActEnvironmentGlobal && ReactCurrentActQueue.current !== null) {
|
||
error("The current testing environment is not configured to support act(...)");
|
||
}
|
||
return isReactActEnvironmentGlobal;
|
||
}
|
||
}
|
||
var ceil = Math.ceil;
|
||
var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, ReactCurrentBatchConfig$3 = ReactSharedInternals.ReactCurrentBatchConfig, ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue;
|
||
var NoContext = 0;
|
||
var BatchedContext = 1;
|
||
var RenderContext = 2;
|
||
var CommitContext = 4;
|
||
var RootInProgress = 0;
|
||
var RootFatalErrored = 1;
|
||
var RootErrored = 2;
|
||
var RootSuspended = 3;
|
||
var RootSuspendedWithDelay = 4;
|
||
var RootCompleted = 5;
|
||
var RootDidNotComplete = 6;
|
||
var executionContext = NoContext;
|
||
var workInProgressRoot = null;
|
||
var workInProgress = null;
|
||
var workInProgressRootRenderLanes = NoLanes;
|
||
var subtreeRenderLanes = NoLanes;
|
||
var subtreeRenderLanesCursor = createCursor(NoLanes);
|
||
var workInProgressRootExitStatus = RootInProgress;
|
||
var workInProgressRootFatalError = null;
|
||
var workInProgressRootIncludedLanes = NoLanes;
|
||
var workInProgressRootSkippedLanes = NoLanes;
|
||
var workInProgressRootInterleavedUpdatedLanes = NoLanes;
|
||
var workInProgressRootPingedLanes = NoLanes;
|
||
var workInProgressRootConcurrentErrors = null;
|
||
var workInProgressRootRecoverableErrors = null;
|
||
var globalMostRecentFallbackTime = 0;
|
||
var FALLBACK_THROTTLE_MS = 500;
|
||
var workInProgressRootRenderTargetTime = Infinity;
|
||
var RENDER_TIMEOUT_MS = 500;
|
||
var workInProgressTransitions = null;
|
||
function resetRenderTimer() {
|
||
workInProgressRootRenderTargetTime = now() + RENDER_TIMEOUT_MS;
|
||
}
|
||
function getRenderTargetTime() {
|
||
return workInProgressRootRenderTargetTime;
|
||
}
|
||
var hasUncaughtError = false;
|
||
var firstUncaughtError = null;
|
||
var legacyErrorBoundariesThatAlreadyFailed = null;
|
||
var rootDoesHavePassiveEffects = false;
|
||
var rootWithPendingPassiveEffects = null;
|
||
var pendingPassiveEffectsLanes = NoLanes;
|
||
var pendingPassiveProfilerEffects = [];
|
||
var pendingPassiveTransitions = null;
|
||
var NESTED_UPDATE_LIMIT = 50;
|
||
var nestedUpdateCount = 0;
|
||
var rootWithNestedUpdates = null;
|
||
var isFlushingPassiveEffects = false;
|
||
var didScheduleUpdateDuringPassiveEffects = false;
|
||
var NESTED_PASSIVE_UPDATE_LIMIT = 50;
|
||
var nestedPassiveUpdateCount = 0;
|
||
var rootWithPassiveNestedUpdates = null;
|
||
var currentEventTime = NoTimestamp;
|
||
var currentEventTransitionLane = NoLanes;
|
||
var isRunningInsertionEffect = false;
|
||
function getWorkInProgressRoot() {
|
||
return workInProgressRoot;
|
||
}
|
||
function requestEventTime() {
|
||
if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
||
return now();
|
||
}
|
||
if (currentEventTime !== NoTimestamp) {
|
||
return currentEventTime;
|
||
}
|
||
currentEventTime = now();
|
||
return currentEventTime;
|
||
}
|
||
function requestUpdateLane(fiber) {
|
||
var mode = fiber.mode;
|
||
if ((mode & ConcurrentMode) === NoMode) {
|
||
return SyncLane;
|
||
} else if ((executionContext & RenderContext) !== NoContext && workInProgressRootRenderLanes !== NoLanes) {
|
||
return pickArbitraryLane(workInProgressRootRenderLanes);
|
||
}
|
||
var isTransition = requestCurrentTransition() !== NoTransition;
|
||
if (isTransition) {
|
||
if (ReactCurrentBatchConfig$3.transition !== null) {
|
||
var transition = ReactCurrentBatchConfig$3.transition;
|
||
if (!transition._updatedFibers) {
|
||
transition._updatedFibers = /* @__PURE__ */ new Set();
|
||
}
|
||
transition._updatedFibers.add(fiber);
|
||
}
|
||
if (currentEventTransitionLane === NoLane) {
|
||
currentEventTransitionLane = claimNextTransitionLane();
|
||
}
|
||
return currentEventTransitionLane;
|
||
}
|
||
var updateLane = getCurrentUpdatePriority();
|
||
if (updateLane !== NoLane) {
|
||
return updateLane;
|
||
}
|
||
var eventLane = getCurrentEventPriority();
|
||
return eventLane;
|
||
}
|
||
function requestRetryLane(fiber) {
|
||
var mode = fiber.mode;
|
||
if ((mode & ConcurrentMode) === NoMode) {
|
||
return SyncLane;
|
||
}
|
||
return claimNextRetryLane();
|
||
}
|
||
function scheduleUpdateOnFiber(root2, fiber, lane, eventTime) {
|
||
checkForNestedUpdates();
|
||
{
|
||
if (isRunningInsertionEffect) {
|
||
error("useInsertionEffect must not schedule updates.");
|
||
}
|
||
}
|
||
{
|
||
if (isFlushingPassiveEffects) {
|
||
didScheduleUpdateDuringPassiveEffects = true;
|
||
}
|
||
}
|
||
markRootUpdated(root2, lane, eventTime);
|
||
if ((executionContext & RenderContext) !== NoLanes && root2 === workInProgressRoot) {
|
||
warnAboutRenderPhaseUpdatesInDEV(fiber);
|
||
} else {
|
||
{
|
||
if (isDevToolsPresent) {
|
||
addFiberToLanesMap(root2, fiber, lane);
|
||
}
|
||
}
|
||
warnIfUpdatesNotWrappedWithActDEV(fiber);
|
||
if (root2 === workInProgressRoot) {
|
||
if ((executionContext & RenderContext) === NoContext) {
|
||
workInProgressRootInterleavedUpdatedLanes = mergeLanes(workInProgressRootInterleavedUpdatedLanes, lane);
|
||
}
|
||
if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
|
||
markRootSuspended$1(root2, workInProgressRootRenderLanes);
|
||
}
|
||
}
|
||
ensureRootIsScheduled(root2, eventTime);
|
||
if (lane === SyncLane && executionContext === NoContext && (fiber.mode & ConcurrentMode) === NoMode && !ReactCurrentActQueue$1.isBatchingLegacy) {
|
||
resetRenderTimer();
|
||
flushSyncCallbacksOnlyInLegacyMode();
|
||
}
|
||
}
|
||
}
|
||
function scheduleInitialHydrationOnRoot(root2, lane, eventTime) {
|
||
var current2 = root2.current;
|
||
current2.lanes = lane;
|
||
markRootUpdated(root2, lane, eventTime);
|
||
ensureRootIsScheduled(root2, eventTime);
|
||
}
|
||
function isUnsafeClassRenderPhaseUpdate(fiber) {
|
||
return (executionContext & RenderContext) !== NoContext;
|
||
}
|
||
function ensureRootIsScheduled(root2, currentTime) {
|
||
var existingCallbackNode = root2.callbackNode;
|
||
markStarvedLanesAsExpired(root2, currentTime);
|
||
var nextLanes = getNextLanes(root2, root2 === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes);
|
||
if (nextLanes === NoLanes) {
|
||
if (existingCallbackNode !== null) {
|
||
cancelCallback$1(existingCallbackNode);
|
||
}
|
||
root2.callbackNode = null;
|
||
root2.callbackPriority = NoLane;
|
||
return;
|
||
}
|
||
var newCallbackPriority = getHighestPriorityLane(nextLanes);
|
||
var existingCallbackPriority = root2.callbackPriority;
|
||
if (existingCallbackPriority === newCallbackPriority && !(ReactCurrentActQueue$1.current !== null && existingCallbackNode !== fakeActCallbackNode)) {
|
||
{
|
||
if (existingCallbackNode == null && existingCallbackPriority !== SyncLane) {
|
||
error("Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
if (existingCallbackNode != null) {
|
||
cancelCallback$1(existingCallbackNode);
|
||
}
|
||
var newCallbackNode;
|
||
if (newCallbackPriority === SyncLane) {
|
||
if (root2.tag === LegacyRoot) {
|
||
if (ReactCurrentActQueue$1.isBatchingLegacy !== null) {
|
||
ReactCurrentActQueue$1.didScheduleLegacyUpdate = true;
|
||
}
|
||
scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root2));
|
||
} else {
|
||
scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root2));
|
||
}
|
||
{
|
||
if (ReactCurrentActQueue$1.current !== null) {
|
||
ReactCurrentActQueue$1.current.push(flushSyncCallbacks);
|
||
} else {
|
||
scheduleMicrotask(function() {
|
||
if ((executionContext & (RenderContext | CommitContext)) === NoContext) {
|
||
flushSyncCallbacks();
|
||
}
|
||
});
|
||
}
|
||
}
|
||
newCallbackNode = null;
|
||
} else {
|
||
var schedulerPriorityLevel;
|
||
switch (lanesToEventPriority(nextLanes)) {
|
||
case DiscreteEventPriority:
|
||
schedulerPriorityLevel = ImmediatePriority;
|
||
break;
|
||
case ContinuousEventPriority:
|
||
schedulerPriorityLevel = UserBlockingPriority;
|
||
break;
|
||
case DefaultEventPriority:
|
||
schedulerPriorityLevel = NormalPriority;
|
||
break;
|
||
case IdleEventPriority:
|
||
schedulerPriorityLevel = IdlePriority;
|
||
break;
|
||
default:
|
||
schedulerPriorityLevel = NormalPriority;
|
||
break;
|
||
}
|
||
newCallbackNode = scheduleCallback$1(schedulerPriorityLevel, performConcurrentWorkOnRoot.bind(null, root2));
|
||
}
|
||
root2.callbackPriority = newCallbackPriority;
|
||
root2.callbackNode = newCallbackNode;
|
||
}
|
||
function performConcurrentWorkOnRoot(root2, didTimeout) {
|
||
{
|
||
resetNestedUpdateFlag();
|
||
}
|
||
currentEventTime = NoTimestamp;
|
||
currentEventTransitionLane = NoLanes;
|
||
if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
||
throw new Error("Should not already be working.");
|
||
}
|
||
var originalCallbackNode = root2.callbackNode;
|
||
var didFlushPassiveEffects = flushPassiveEffects();
|
||
if (didFlushPassiveEffects) {
|
||
if (root2.callbackNode !== originalCallbackNode) {
|
||
return null;
|
||
}
|
||
}
|
||
var lanes = getNextLanes(root2, root2 === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes);
|
||
if (lanes === NoLanes) {
|
||
return null;
|
||
}
|
||
var shouldTimeSlice = !includesBlockingLane(root2, lanes) && !includesExpiredLane(root2, lanes) && !didTimeout;
|
||
var exitStatus = shouldTimeSlice ? renderRootConcurrent(root2, lanes) : renderRootSync(root2, lanes);
|
||
if (exitStatus !== RootInProgress) {
|
||
if (exitStatus === RootErrored) {
|
||
var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root2);
|
||
if (errorRetryLanes !== NoLanes) {
|
||
lanes = errorRetryLanes;
|
||
exitStatus = recoverFromConcurrentError(root2, errorRetryLanes);
|
||
}
|
||
}
|
||
if (exitStatus === RootFatalErrored) {
|
||
var fatalError = workInProgressRootFatalError;
|
||
prepareFreshStack(root2, NoLanes);
|
||
markRootSuspended$1(root2, lanes);
|
||
ensureRootIsScheduled(root2, now());
|
||
throw fatalError;
|
||
}
|
||
if (exitStatus === RootDidNotComplete) {
|
||
markRootSuspended$1(root2, lanes);
|
||
} else {
|
||
var renderWasConcurrent = !includesBlockingLane(root2, lanes);
|
||
var finishedWork = root2.current.alternate;
|
||
if (renderWasConcurrent && !isRenderConsistentWithExternalStores(finishedWork)) {
|
||
exitStatus = renderRootSync(root2, lanes);
|
||
if (exitStatus === RootErrored) {
|
||
var _errorRetryLanes = getLanesToRetrySynchronouslyOnError(root2);
|
||
if (_errorRetryLanes !== NoLanes) {
|
||
lanes = _errorRetryLanes;
|
||
exitStatus = recoverFromConcurrentError(root2, _errorRetryLanes);
|
||
}
|
||
}
|
||
if (exitStatus === RootFatalErrored) {
|
||
var _fatalError = workInProgressRootFatalError;
|
||
prepareFreshStack(root2, NoLanes);
|
||
markRootSuspended$1(root2, lanes);
|
||
ensureRootIsScheduled(root2, now());
|
||
throw _fatalError;
|
||
}
|
||
}
|
||
root2.finishedWork = finishedWork;
|
||
root2.finishedLanes = lanes;
|
||
finishConcurrentRender(root2, exitStatus, lanes);
|
||
}
|
||
}
|
||
ensureRootIsScheduled(root2, now());
|
||
if (root2.callbackNode === originalCallbackNode) {
|
||
return performConcurrentWorkOnRoot.bind(null, root2);
|
||
}
|
||
return null;
|
||
}
|
||
function recoverFromConcurrentError(root2, errorRetryLanes) {
|
||
var errorsFromFirstAttempt = workInProgressRootConcurrentErrors;
|
||
if (isRootDehydrated(root2)) {
|
||
var rootWorkInProgress = prepareFreshStack(root2, errorRetryLanes);
|
||
rootWorkInProgress.flags |= ForceClientRender;
|
||
{
|
||
errorHydratingContainer(root2.containerInfo);
|
||
}
|
||
}
|
||
var exitStatus = renderRootSync(root2, errorRetryLanes);
|
||
if (exitStatus !== RootErrored) {
|
||
var errorsFromSecondAttempt = workInProgressRootRecoverableErrors;
|
||
workInProgressRootRecoverableErrors = errorsFromFirstAttempt;
|
||
if (errorsFromSecondAttempt !== null) {
|
||
queueRecoverableErrors(errorsFromSecondAttempt);
|
||
}
|
||
}
|
||
return exitStatus;
|
||
}
|
||
function queueRecoverableErrors(errors) {
|
||
if (workInProgressRootRecoverableErrors === null) {
|
||
workInProgressRootRecoverableErrors = errors;
|
||
} else {
|
||
workInProgressRootRecoverableErrors.push.apply(workInProgressRootRecoverableErrors, errors);
|
||
}
|
||
}
|
||
function finishConcurrentRender(root2, exitStatus, lanes) {
|
||
switch (exitStatus) {
|
||
case RootInProgress:
|
||
case RootFatalErrored: {
|
||
throw new Error("Root did not complete. This is a bug in React.");
|
||
}
|
||
case RootErrored: {
|
||
commitRoot(root2, workInProgressRootRecoverableErrors, workInProgressTransitions);
|
||
break;
|
||
}
|
||
case RootSuspended: {
|
||
markRootSuspended$1(root2, lanes);
|
||
if (includesOnlyRetries(lanes) && !shouldForceFlushFallbacksInDEV()) {
|
||
var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now();
|
||
if (msUntilTimeout > 10) {
|
||
var nextLanes = getNextLanes(root2, NoLanes);
|
||
if (nextLanes !== NoLanes) {
|
||
break;
|
||
}
|
||
var suspendedLanes = root2.suspendedLanes;
|
||
if (!isSubsetOfLanes(suspendedLanes, lanes)) {
|
||
var eventTime = requestEventTime();
|
||
markRootPinged(root2, suspendedLanes);
|
||
break;
|
||
}
|
||
root2.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root2, workInProgressRootRecoverableErrors, workInProgressTransitions), msUntilTimeout);
|
||
break;
|
||
}
|
||
}
|
||
commitRoot(root2, workInProgressRootRecoverableErrors, workInProgressTransitions);
|
||
break;
|
||
}
|
||
case RootSuspendedWithDelay: {
|
||
markRootSuspended$1(root2, lanes);
|
||
if (includesOnlyTransitions(lanes)) {
|
||
break;
|
||
}
|
||
if (!shouldForceFlushFallbacksInDEV()) {
|
||
var mostRecentEventTime = getMostRecentEventTime(root2, lanes);
|
||
var eventTimeMs = mostRecentEventTime;
|
||
var timeElapsedMs = now() - eventTimeMs;
|
||
var _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs;
|
||
if (_msUntilTimeout > 10) {
|
||
root2.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root2, workInProgressRootRecoverableErrors, workInProgressTransitions), _msUntilTimeout);
|
||
break;
|
||
}
|
||
}
|
||
commitRoot(root2, workInProgressRootRecoverableErrors, workInProgressTransitions);
|
||
break;
|
||
}
|
||
case RootCompleted: {
|
||
commitRoot(root2, workInProgressRootRecoverableErrors, workInProgressTransitions);
|
||
break;
|
||
}
|
||
default: {
|
||
throw new Error("Unknown root exit status.");
|
||
}
|
||
}
|
||
}
|
||
function isRenderConsistentWithExternalStores(finishedWork) {
|
||
var node = finishedWork;
|
||
while (true) {
|
||
if (node.flags & StoreConsistency) {
|
||
var updateQueue = node.updateQueue;
|
||
if (updateQueue !== null) {
|
||
var checks = updateQueue.stores;
|
||
if (checks !== null) {
|
||
for (var i = 0; i < checks.length; i++) {
|
||
var check = checks[i];
|
||
var getSnapshot = check.getSnapshot;
|
||
var renderedValue = check.value;
|
||
try {
|
||
if (!objectIs(getSnapshot(), renderedValue)) {
|
||
return false;
|
||
}
|
||
} catch (error2) {
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var child = node.child;
|
||
if (node.subtreeFlags & StoreConsistency && child !== null) {
|
||
child.return = node;
|
||
node = child;
|
||
continue;
|
||
}
|
||
if (node === finishedWork) {
|
||
return true;
|
||
}
|
||
while (node.sibling === null) {
|
||
if (node.return === null || node.return === finishedWork) {
|
||
return true;
|
||
}
|
||
node = node.return;
|
||
}
|
||
node.sibling.return = node.return;
|
||
node = node.sibling;
|
||
}
|
||
return true;
|
||
}
|
||
function markRootSuspended$1(root2, suspendedLanes) {
|
||
suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes);
|
||
suspendedLanes = removeLanes(suspendedLanes, workInProgressRootInterleavedUpdatedLanes);
|
||
markRootSuspended(root2, suspendedLanes);
|
||
}
|
||
function performSyncWorkOnRoot(root2) {
|
||
{
|
||
syncNestedUpdateFlag();
|
||
}
|
||
if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
||
throw new Error("Should not already be working.");
|
||
}
|
||
flushPassiveEffects();
|
||
var lanes = getNextLanes(root2, NoLanes);
|
||
if (!includesSomeLane(lanes, SyncLane)) {
|
||
ensureRootIsScheduled(root2, now());
|
||
return null;
|
||
}
|
||
var exitStatus = renderRootSync(root2, lanes);
|
||
if (root2.tag !== LegacyRoot && exitStatus === RootErrored) {
|
||
var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root2);
|
||
if (errorRetryLanes !== NoLanes) {
|
||
lanes = errorRetryLanes;
|
||
exitStatus = recoverFromConcurrentError(root2, errorRetryLanes);
|
||
}
|
||
}
|
||
if (exitStatus === RootFatalErrored) {
|
||
var fatalError = workInProgressRootFatalError;
|
||
prepareFreshStack(root2, NoLanes);
|
||
markRootSuspended$1(root2, lanes);
|
||
ensureRootIsScheduled(root2, now());
|
||
throw fatalError;
|
||
}
|
||
if (exitStatus === RootDidNotComplete) {
|
||
throw new Error("Root did not complete. This is a bug in React.");
|
||
}
|
||
var finishedWork = root2.current.alternate;
|
||
root2.finishedWork = finishedWork;
|
||
root2.finishedLanes = lanes;
|
||
commitRoot(root2, workInProgressRootRecoverableErrors, workInProgressTransitions);
|
||
ensureRootIsScheduled(root2, now());
|
||
return null;
|
||
}
|
||
function flushRoot(root2, lanes) {
|
||
if (lanes !== NoLanes) {
|
||
markRootEntangled(root2, mergeLanes(lanes, SyncLane));
|
||
ensureRootIsScheduled(root2, now());
|
||
if ((executionContext & (RenderContext | CommitContext)) === NoContext) {
|
||
resetRenderTimer();
|
||
flushSyncCallbacks();
|
||
}
|
||
}
|
||
}
|
||
function batchedUpdates$1(fn, a) {
|
||
var prevExecutionContext = executionContext;
|
||
executionContext |= BatchedContext;
|
||
try {
|
||
return fn(a);
|
||
} finally {
|
||
executionContext = prevExecutionContext;
|
||
if (executionContext === NoContext && !ReactCurrentActQueue$1.isBatchingLegacy) {
|
||
resetRenderTimer();
|
||
flushSyncCallbacksOnlyInLegacyMode();
|
||
}
|
||
}
|
||
}
|
||
function discreteUpdates(fn, a, b, c, d) {
|
||
var previousPriority = getCurrentUpdatePriority();
|
||
var prevTransition = ReactCurrentBatchConfig$3.transition;
|
||
try {
|
||
ReactCurrentBatchConfig$3.transition = null;
|
||
setCurrentUpdatePriority(DiscreteEventPriority);
|
||
return fn(a, b, c, d);
|
||
} finally {
|
||
setCurrentUpdatePriority(previousPriority);
|
||
ReactCurrentBatchConfig$3.transition = prevTransition;
|
||
if (executionContext === NoContext) {
|
||
resetRenderTimer();
|
||
}
|
||
}
|
||
}
|
||
function flushSync(fn) {
|
||
if (rootWithPendingPassiveEffects !== null && rootWithPendingPassiveEffects.tag === LegacyRoot && (executionContext & (RenderContext | CommitContext)) === NoContext) {
|
||
flushPassiveEffects();
|
||
}
|
||
var prevExecutionContext = executionContext;
|
||
executionContext |= BatchedContext;
|
||
var prevTransition = ReactCurrentBatchConfig$3.transition;
|
||
var previousPriority = getCurrentUpdatePriority();
|
||
try {
|
||
ReactCurrentBatchConfig$3.transition = null;
|
||
setCurrentUpdatePriority(DiscreteEventPriority);
|
||
if (fn) {
|
||
return fn();
|
||
} else {
|
||
return void 0;
|
||
}
|
||
} finally {
|
||
setCurrentUpdatePriority(previousPriority);
|
||
ReactCurrentBatchConfig$3.transition = prevTransition;
|
||
executionContext = prevExecutionContext;
|
||
if ((executionContext & (RenderContext | CommitContext)) === NoContext) {
|
||
flushSyncCallbacks();
|
||
}
|
||
}
|
||
}
|
||
function isAlreadyRendering() {
|
||
return (executionContext & (RenderContext | CommitContext)) !== NoContext;
|
||
}
|
||
function pushRenderLanes(fiber, lanes) {
|
||
push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber);
|
||
subtreeRenderLanes = mergeLanes(subtreeRenderLanes, lanes);
|
||
workInProgressRootIncludedLanes = mergeLanes(workInProgressRootIncludedLanes, lanes);
|
||
}
|
||
function popRenderLanes(fiber) {
|
||
subtreeRenderLanes = subtreeRenderLanesCursor.current;
|
||
pop(subtreeRenderLanesCursor, fiber);
|
||
}
|
||
function prepareFreshStack(root2, lanes) {
|
||
root2.finishedWork = null;
|
||
root2.finishedLanes = NoLanes;
|
||
var timeoutHandle = root2.timeoutHandle;
|
||
if (timeoutHandle !== noTimeout) {
|
||
root2.timeoutHandle = noTimeout;
|
||
cancelTimeout(timeoutHandle);
|
||
}
|
||
if (workInProgress !== null) {
|
||
var interruptedWork = workInProgress.return;
|
||
while (interruptedWork !== null) {
|
||
var current2 = interruptedWork.alternate;
|
||
unwindInterruptedWork(current2, interruptedWork);
|
||
interruptedWork = interruptedWork.return;
|
||
}
|
||
}
|
||
workInProgressRoot = root2;
|
||
var rootWorkInProgress = createWorkInProgress(root2.current, null);
|
||
workInProgress = rootWorkInProgress;
|
||
workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
|
||
workInProgressRootExitStatus = RootInProgress;
|
||
workInProgressRootFatalError = null;
|
||
workInProgressRootSkippedLanes = NoLanes;
|
||
workInProgressRootInterleavedUpdatedLanes = NoLanes;
|
||
workInProgressRootPingedLanes = NoLanes;
|
||
workInProgressRootConcurrentErrors = null;
|
||
workInProgressRootRecoverableErrors = null;
|
||
finishQueueingConcurrentUpdates();
|
||
{
|
||
ReactStrictModeWarnings.discardPendingWarnings();
|
||
}
|
||
return rootWorkInProgress;
|
||
}
|
||
function handleError(root2, thrownValue) {
|
||
do {
|
||
var erroredWork = workInProgress;
|
||
try {
|
||
resetContextDependencies();
|
||
resetHooksAfterThrow();
|
||
resetCurrentFiber();
|
||
ReactCurrentOwner$2.current = null;
|
||
if (erroredWork === null || erroredWork.return === null) {
|
||
workInProgressRootExitStatus = RootFatalErrored;
|
||
workInProgressRootFatalError = thrownValue;
|
||
workInProgress = null;
|
||
return;
|
||
}
|
||
if (enableProfilerTimer && erroredWork.mode & ProfileMode) {
|
||
stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true);
|
||
}
|
||
if (enableSchedulingProfiler) {
|
||
markComponentRenderStopped();
|
||
if (thrownValue !== null && typeof thrownValue === "object" && typeof thrownValue.then === "function") {
|
||
var wakeable = thrownValue;
|
||
markComponentSuspended(erroredWork, wakeable, workInProgressRootRenderLanes);
|
||
} else {
|
||
markComponentErrored(erroredWork, thrownValue, workInProgressRootRenderLanes);
|
||
}
|
||
}
|
||
throwException(root2, erroredWork.return, erroredWork, thrownValue, workInProgressRootRenderLanes);
|
||
completeUnitOfWork(erroredWork);
|
||
} catch (yetAnotherThrownValue) {
|
||
thrownValue = yetAnotherThrownValue;
|
||
if (workInProgress === erroredWork && erroredWork !== null) {
|
||
erroredWork = erroredWork.return;
|
||
workInProgress = erroredWork;
|
||
} else {
|
||
erroredWork = workInProgress;
|
||
}
|
||
continue;
|
||
}
|
||
return;
|
||
} while (true);
|
||
}
|
||
function pushDispatcher() {
|
||
var prevDispatcher = ReactCurrentDispatcher$2.current;
|
||
ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
|
||
if (prevDispatcher === null) {
|
||
return ContextOnlyDispatcher;
|
||
} else {
|
||
return prevDispatcher;
|
||
}
|
||
}
|
||
function popDispatcher(prevDispatcher) {
|
||
ReactCurrentDispatcher$2.current = prevDispatcher;
|
||
}
|
||
function markCommitTimeOfFallback() {
|
||
globalMostRecentFallbackTime = now();
|
||
}
|
||
function markSkippedUpdateLanes(lane) {
|
||
workInProgressRootSkippedLanes = mergeLanes(lane, workInProgressRootSkippedLanes);
|
||
}
|
||
function renderDidSuspend() {
|
||
if (workInProgressRootExitStatus === RootInProgress) {
|
||
workInProgressRootExitStatus = RootSuspended;
|
||
}
|
||
}
|
||
function renderDidSuspendDelayIfPossible() {
|
||
if (workInProgressRootExitStatus === RootInProgress || workInProgressRootExitStatus === RootSuspended || workInProgressRootExitStatus === RootErrored) {
|
||
workInProgressRootExitStatus = RootSuspendedWithDelay;
|
||
}
|
||
if (workInProgressRoot !== null && (includesNonIdleWork(workInProgressRootSkippedLanes) || includesNonIdleWork(workInProgressRootInterleavedUpdatedLanes))) {
|
||
markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
|
||
}
|
||
}
|
||
function renderDidError(error2) {
|
||
if (workInProgressRootExitStatus !== RootSuspendedWithDelay) {
|
||
workInProgressRootExitStatus = RootErrored;
|
||
}
|
||
if (workInProgressRootConcurrentErrors === null) {
|
||
workInProgressRootConcurrentErrors = [error2];
|
||
} else {
|
||
workInProgressRootConcurrentErrors.push(error2);
|
||
}
|
||
}
|
||
function renderHasNotSuspendedYet() {
|
||
return workInProgressRootExitStatus === RootInProgress;
|
||
}
|
||
function renderRootSync(root2, lanes) {
|
||
var prevExecutionContext = executionContext;
|
||
executionContext |= RenderContext;
|
||
var prevDispatcher = pushDispatcher();
|
||
if (workInProgressRoot !== root2 || workInProgressRootRenderLanes !== lanes) {
|
||
{
|
||
if (isDevToolsPresent) {
|
||
var memoizedUpdaters = root2.memoizedUpdaters;
|
||
if (memoizedUpdaters.size > 0) {
|
||
restorePendingUpdaters(root2, workInProgressRootRenderLanes);
|
||
memoizedUpdaters.clear();
|
||
}
|
||
movePendingFibersToMemoized(root2, lanes);
|
||
}
|
||
}
|
||
workInProgressTransitions = getTransitionsForLanes();
|
||
prepareFreshStack(root2, lanes);
|
||
}
|
||
{
|
||
markRenderStarted(lanes);
|
||
}
|
||
do {
|
||
try {
|
||
workLoopSync();
|
||
break;
|
||
} catch (thrownValue) {
|
||
handleError(root2, thrownValue);
|
||
}
|
||
} while (true);
|
||
resetContextDependencies();
|
||
executionContext = prevExecutionContext;
|
||
popDispatcher(prevDispatcher);
|
||
if (workInProgress !== null) {
|
||
throw new Error("Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
{
|
||
markRenderStopped();
|
||
}
|
||
workInProgressRoot = null;
|
||
workInProgressRootRenderLanes = NoLanes;
|
||
return workInProgressRootExitStatus;
|
||
}
|
||
function workLoopSync() {
|
||
while (workInProgress !== null) {
|
||
performUnitOfWork(workInProgress);
|
||
}
|
||
}
|
||
function renderRootConcurrent(root2, lanes) {
|
||
var prevExecutionContext = executionContext;
|
||
executionContext |= RenderContext;
|
||
var prevDispatcher = pushDispatcher();
|
||
if (workInProgressRoot !== root2 || workInProgressRootRenderLanes !== lanes) {
|
||
{
|
||
if (isDevToolsPresent) {
|
||
var memoizedUpdaters = root2.memoizedUpdaters;
|
||
if (memoizedUpdaters.size > 0) {
|
||
restorePendingUpdaters(root2, workInProgressRootRenderLanes);
|
||
memoizedUpdaters.clear();
|
||
}
|
||
movePendingFibersToMemoized(root2, lanes);
|
||
}
|
||
}
|
||
workInProgressTransitions = getTransitionsForLanes();
|
||
resetRenderTimer();
|
||
prepareFreshStack(root2, lanes);
|
||
}
|
||
{
|
||
markRenderStarted(lanes);
|
||
}
|
||
do {
|
||
try {
|
||
workLoopConcurrent();
|
||
break;
|
||
} catch (thrownValue) {
|
||
handleError(root2, thrownValue);
|
||
}
|
||
} while (true);
|
||
resetContextDependencies();
|
||
popDispatcher(prevDispatcher);
|
||
executionContext = prevExecutionContext;
|
||
if (workInProgress !== null) {
|
||
{
|
||
markRenderYielded();
|
||
}
|
||
return RootInProgress;
|
||
} else {
|
||
{
|
||
markRenderStopped();
|
||
}
|
||
workInProgressRoot = null;
|
||
workInProgressRootRenderLanes = NoLanes;
|
||
return workInProgressRootExitStatus;
|
||
}
|
||
}
|
||
function workLoopConcurrent() {
|
||
while (workInProgress !== null && !shouldYield()) {
|
||
performUnitOfWork(workInProgress);
|
||
}
|
||
}
|
||
function performUnitOfWork(unitOfWork) {
|
||
var current2 = unitOfWork.alternate;
|
||
setCurrentFiber(unitOfWork);
|
||
var next;
|
||
if ((unitOfWork.mode & ProfileMode) !== NoMode) {
|
||
startProfilerTimer(unitOfWork);
|
||
next = beginWork$1(current2, unitOfWork, subtreeRenderLanes);
|
||
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
|
||
} else {
|
||
next = beginWork$1(current2, unitOfWork, subtreeRenderLanes);
|
||
}
|
||
resetCurrentFiber();
|
||
unitOfWork.memoizedProps = unitOfWork.pendingProps;
|
||
if (next === null) {
|
||
completeUnitOfWork(unitOfWork);
|
||
} else {
|
||
workInProgress = next;
|
||
}
|
||
ReactCurrentOwner$2.current = null;
|
||
}
|
||
function completeUnitOfWork(unitOfWork) {
|
||
var completedWork = unitOfWork;
|
||
do {
|
||
var current2 = completedWork.alternate;
|
||
var returnFiber = completedWork.return;
|
||
if ((completedWork.flags & Incomplete) === NoFlags) {
|
||
setCurrentFiber(completedWork);
|
||
var next = void 0;
|
||
if ((completedWork.mode & ProfileMode) === NoMode) {
|
||
next = completeWork(current2, completedWork, subtreeRenderLanes);
|
||
} else {
|
||
startProfilerTimer(completedWork);
|
||
next = completeWork(current2, completedWork, subtreeRenderLanes);
|
||
stopProfilerTimerIfRunningAndRecordDelta(completedWork, false);
|
||
}
|
||
resetCurrentFiber();
|
||
if (next !== null) {
|
||
workInProgress = next;
|
||
return;
|
||
}
|
||
} else {
|
||
var _next = unwindWork(current2, completedWork);
|
||
if (_next !== null) {
|
||
_next.flags &= HostEffectMask;
|
||
workInProgress = _next;
|
||
return;
|
||
}
|
||
if ((completedWork.mode & ProfileMode) !== NoMode) {
|
||
stopProfilerTimerIfRunningAndRecordDelta(completedWork, false);
|
||
var actualDuration = completedWork.actualDuration;
|
||
var child = completedWork.child;
|
||
while (child !== null) {
|
||
actualDuration += child.actualDuration;
|
||
child = child.sibling;
|
||
}
|
||
completedWork.actualDuration = actualDuration;
|
||
}
|
||
if (returnFiber !== null) {
|
||
returnFiber.flags |= Incomplete;
|
||
returnFiber.subtreeFlags = NoFlags;
|
||
returnFiber.deletions = null;
|
||
} else {
|
||
workInProgressRootExitStatus = RootDidNotComplete;
|
||
workInProgress = null;
|
||
return;
|
||
}
|
||
}
|
||
var siblingFiber = completedWork.sibling;
|
||
if (siblingFiber !== null) {
|
||
workInProgress = siblingFiber;
|
||
return;
|
||
}
|
||
completedWork = returnFiber;
|
||
workInProgress = completedWork;
|
||
} while (completedWork !== null);
|
||
if (workInProgressRootExitStatus === RootInProgress) {
|
||
workInProgressRootExitStatus = RootCompleted;
|
||
}
|
||
}
|
||
function commitRoot(root2, recoverableErrors, transitions) {
|
||
var previousUpdateLanePriority = getCurrentUpdatePriority();
|
||
var prevTransition = ReactCurrentBatchConfig$3.transition;
|
||
try {
|
||
ReactCurrentBatchConfig$3.transition = null;
|
||
setCurrentUpdatePriority(DiscreteEventPriority);
|
||
commitRootImpl(root2, recoverableErrors, transitions, previousUpdateLanePriority);
|
||
} finally {
|
||
ReactCurrentBatchConfig$3.transition = prevTransition;
|
||
setCurrentUpdatePriority(previousUpdateLanePriority);
|
||
}
|
||
return null;
|
||
}
|
||
function commitRootImpl(root2, recoverableErrors, transitions, renderPriorityLevel) {
|
||
do {
|
||
flushPassiveEffects();
|
||
} while (rootWithPendingPassiveEffects !== null);
|
||
flushRenderPhaseStrictModeWarningsInDEV();
|
||
if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
||
throw new Error("Should not already be working.");
|
||
}
|
||
var finishedWork = root2.finishedWork;
|
||
var lanes = root2.finishedLanes;
|
||
{
|
||
markCommitStarted(lanes);
|
||
}
|
||
if (finishedWork === null) {
|
||
{
|
||
markCommitStopped();
|
||
}
|
||
return null;
|
||
} else {
|
||
{
|
||
if (lanes === NoLanes) {
|
||
error("root.finishedLanes should not be empty during a commit. This is a bug in React.");
|
||
}
|
||
}
|
||
}
|
||
root2.finishedWork = null;
|
||
root2.finishedLanes = NoLanes;
|
||
if (finishedWork === root2.current) {
|
||
throw new Error("Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue.");
|
||
}
|
||
root2.callbackNode = null;
|
||
root2.callbackPriority = NoLane;
|
||
var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes);
|
||
markRootFinished(root2, remainingLanes);
|
||
if (root2 === workInProgressRoot) {
|
||
workInProgressRoot = null;
|
||
workInProgress = null;
|
||
workInProgressRootRenderLanes = NoLanes;
|
||
}
|
||
if ((finishedWork.subtreeFlags & PassiveMask) !== NoFlags || (finishedWork.flags & PassiveMask) !== NoFlags) {
|
||
if (!rootDoesHavePassiveEffects) {
|
||
rootDoesHavePassiveEffects = true;
|
||
pendingPassiveTransitions = transitions;
|
||
scheduleCallback$1(NormalPriority, function() {
|
||
flushPassiveEffects();
|
||
return null;
|
||
});
|
||
}
|
||
}
|
||
var subtreeHasEffects = (finishedWork.subtreeFlags & (BeforeMutationMask | MutationMask | LayoutMask | PassiveMask)) !== NoFlags;
|
||
var rootHasEffect = (finishedWork.flags & (BeforeMutationMask | MutationMask | LayoutMask | PassiveMask)) !== NoFlags;
|
||
if (subtreeHasEffects || rootHasEffect) {
|
||
var prevTransition = ReactCurrentBatchConfig$3.transition;
|
||
ReactCurrentBatchConfig$3.transition = null;
|
||
var previousPriority = getCurrentUpdatePriority();
|
||
setCurrentUpdatePriority(DiscreteEventPriority);
|
||
var prevExecutionContext = executionContext;
|
||
executionContext |= CommitContext;
|
||
ReactCurrentOwner$2.current = null;
|
||
var shouldFireAfterActiveInstanceBlur2 = commitBeforeMutationEffects(root2, finishedWork);
|
||
{
|
||
recordCommitTime();
|
||
}
|
||
commitMutationEffects(root2, finishedWork, lanes);
|
||
resetAfterCommit(root2.containerInfo);
|
||
root2.current = finishedWork;
|
||
{
|
||
markLayoutEffectsStarted(lanes);
|
||
}
|
||
commitLayoutEffects(finishedWork, root2, lanes);
|
||
{
|
||
markLayoutEffectsStopped();
|
||
}
|
||
requestPaint();
|
||
executionContext = prevExecutionContext;
|
||
setCurrentUpdatePriority(previousPriority);
|
||
ReactCurrentBatchConfig$3.transition = prevTransition;
|
||
} else {
|
||
root2.current = finishedWork;
|
||
{
|
||
recordCommitTime();
|
||
}
|
||
}
|
||
var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
|
||
if (rootDoesHavePassiveEffects) {
|
||
rootDoesHavePassiveEffects = false;
|
||
rootWithPendingPassiveEffects = root2;
|
||
pendingPassiveEffectsLanes = lanes;
|
||
} else {
|
||
{
|
||
nestedPassiveUpdateCount = 0;
|
||
rootWithPassiveNestedUpdates = null;
|
||
}
|
||
}
|
||
remainingLanes = root2.pendingLanes;
|
||
if (remainingLanes === NoLanes) {
|
||
legacyErrorBoundariesThatAlreadyFailed = null;
|
||
}
|
||
{
|
||
if (!rootDidHavePassiveEffects) {
|
||
commitDoubleInvokeEffectsInDEV(root2.current, false);
|
||
}
|
||
}
|
||
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
|
||
{
|
||
if (isDevToolsPresent) {
|
||
root2.memoizedUpdaters.clear();
|
||
}
|
||
}
|
||
{
|
||
onCommitRoot$1();
|
||
}
|
||
ensureRootIsScheduled(root2, now());
|
||
if (recoverableErrors !== null) {
|
||
var onRecoverableError = root2.onRecoverableError;
|
||
for (var i = 0; i < recoverableErrors.length; i++) {
|
||
var recoverableError = recoverableErrors[i];
|
||
var componentStack = recoverableError.stack;
|
||
var digest = recoverableError.digest;
|
||
onRecoverableError(recoverableError.value, {
|
||
componentStack,
|
||
digest
|
||
});
|
||
}
|
||
}
|
||
if (hasUncaughtError) {
|
||
hasUncaughtError = false;
|
||
var error$1 = firstUncaughtError;
|
||
firstUncaughtError = null;
|
||
throw error$1;
|
||
}
|
||
if (includesSomeLane(pendingPassiveEffectsLanes, SyncLane) && root2.tag !== LegacyRoot) {
|
||
flushPassiveEffects();
|
||
}
|
||
remainingLanes = root2.pendingLanes;
|
||
if (includesSomeLane(remainingLanes, SyncLane)) {
|
||
{
|
||
markNestedUpdateScheduled();
|
||
}
|
||
if (root2 === rootWithNestedUpdates) {
|
||
nestedUpdateCount++;
|
||
} else {
|
||
nestedUpdateCount = 0;
|
||
rootWithNestedUpdates = root2;
|
||
}
|
||
} else {
|
||
nestedUpdateCount = 0;
|
||
}
|
||
flushSyncCallbacks();
|
||
{
|
||
markCommitStopped();
|
||
}
|
||
return null;
|
||
}
|
||
function flushPassiveEffects() {
|
||
if (rootWithPendingPassiveEffects !== null) {
|
||
var renderPriority = lanesToEventPriority(pendingPassiveEffectsLanes);
|
||
var priority = lowerEventPriority(DefaultEventPriority, renderPriority);
|
||
var prevTransition = ReactCurrentBatchConfig$3.transition;
|
||
var previousPriority = getCurrentUpdatePriority();
|
||
try {
|
||
ReactCurrentBatchConfig$3.transition = null;
|
||
setCurrentUpdatePriority(priority);
|
||
return flushPassiveEffectsImpl();
|
||
} finally {
|
||
setCurrentUpdatePriority(previousPriority);
|
||
ReactCurrentBatchConfig$3.transition = prevTransition;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
function enqueuePendingPassiveProfilerEffect(fiber) {
|
||
{
|
||
pendingPassiveProfilerEffects.push(fiber);
|
||
if (!rootDoesHavePassiveEffects) {
|
||
rootDoesHavePassiveEffects = true;
|
||
scheduleCallback$1(NormalPriority, function() {
|
||
flushPassiveEffects();
|
||
return null;
|
||
});
|
||
}
|
||
}
|
||
}
|
||
function flushPassiveEffectsImpl() {
|
||
if (rootWithPendingPassiveEffects === null) {
|
||
return false;
|
||
}
|
||
var transitions = pendingPassiveTransitions;
|
||
pendingPassiveTransitions = null;
|
||
var root2 = rootWithPendingPassiveEffects;
|
||
var lanes = pendingPassiveEffectsLanes;
|
||
rootWithPendingPassiveEffects = null;
|
||
pendingPassiveEffectsLanes = NoLanes;
|
||
if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
||
throw new Error("Cannot flush passive effects while already rendering.");
|
||
}
|
||
{
|
||
isFlushingPassiveEffects = true;
|
||
didScheduleUpdateDuringPassiveEffects = false;
|
||
}
|
||
{
|
||
markPassiveEffectsStarted(lanes);
|
||
}
|
||
var prevExecutionContext = executionContext;
|
||
executionContext |= CommitContext;
|
||
commitPassiveUnmountEffects(root2.current);
|
||
commitPassiveMountEffects(root2, root2.current, lanes, transitions);
|
||
{
|
||
var profilerEffects = pendingPassiveProfilerEffects;
|
||
pendingPassiveProfilerEffects = [];
|
||
for (var i = 0; i < profilerEffects.length; i++) {
|
||
var _fiber = profilerEffects[i];
|
||
commitPassiveEffectDurations(root2, _fiber);
|
||
}
|
||
}
|
||
{
|
||
markPassiveEffectsStopped();
|
||
}
|
||
{
|
||
commitDoubleInvokeEffectsInDEV(root2.current, true);
|
||
}
|
||
executionContext = prevExecutionContext;
|
||
flushSyncCallbacks();
|
||
{
|
||
if (didScheduleUpdateDuringPassiveEffects) {
|
||
if (root2 === rootWithPassiveNestedUpdates) {
|
||
nestedPassiveUpdateCount++;
|
||
} else {
|
||
nestedPassiveUpdateCount = 0;
|
||
rootWithPassiveNestedUpdates = root2;
|
||
}
|
||
} else {
|
||
nestedPassiveUpdateCount = 0;
|
||
}
|
||
isFlushingPassiveEffects = false;
|
||
didScheduleUpdateDuringPassiveEffects = false;
|
||
}
|
||
onPostCommitRoot(root2);
|
||
{
|
||
var stateNode = root2.current.stateNode;
|
||
stateNode.effectDuration = 0;
|
||
stateNode.passiveEffectDuration = 0;
|
||
}
|
||
return true;
|
||
}
|
||
function isAlreadyFailedLegacyErrorBoundary(instance) {
|
||
return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
|
||
}
|
||
function markLegacyErrorBoundaryAsFailed(instance) {
|
||
if (legacyErrorBoundariesThatAlreadyFailed === null) {
|
||
legacyErrorBoundariesThatAlreadyFailed = /* @__PURE__ */ new Set([instance]);
|
||
} else {
|
||
legacyErrorBoundariesThatAlreadyFailed.add(instance);
|
||
}
|
||
}
|
||
function prepareToThrowUncaughtError(error2) {
|
||
if (!hasUncaughtError) {
|
||
hasUncaughtError = true;
|
||
firstUncaughtError = error2;
|
||
}
|
||
}
|
||
var onUncaughtError = prepareToThrowUncaughtError;
|
||
function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error2) {
|
||
var errorInfo = createCapturedValueAtFiber(error2, sourceFiber);
|
||
var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane);
|
||
var root2 = enqueueUpdate(rootFiber, update, SyncLane);
|
||
var eventTime = requestEventTime();
|
||
if (root2 !== null) {
|
||
markRootUpdated(root2, SyncLane, eventTime);
|
||
ensureRootIsScheduled(root2, eventTime);
|
||
}
|
||
}
|
||
function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) {
|
||
{
|
||
reportUncaughtErrorInDEV(error$1);
|
||
setIsRunningInsertionEffect(false);
|
||
}
|
||
if (sourceFiber.tag === HostRoot) {
|
||
captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error$1);
|
||
return;
|
||
}
|
||
var fiber = null;
|
||
{
|
||
fiber = nearestMountedAncestor;
|
||
}
|
||
while (fiber !== null) {
|
||
if (fiber.tag === HostRoot) {
|
||
captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error$1);
|
||
return;
|
||
} else if (fiber.tag === ClassComponent) {
|
||
var ctor = fiber.type;
|
||
var instance = fiber.stateNode;
|
||
if (typeof ctor.getDerivedStateFromError === "function" || typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance)) {
|
||
var errorInfo = createCapturedValueAtFiber(error$1, sourceFiber);
|
||
var update = createClassErrorUpdate(fiber, errorInfo, SyncLane);
|
||
var root2 = enqueueUpdate(fiber, update, SyncLane);
|
||
var eventTime = requestEventTime();
|
||
if (root2 !== null) {
|
||
markRootUpdated(root2, SyncLane, eventTime);
|
||
ensureRootIsScheduled(root2, eventTime);
|
||
}
|
||
return;
|
||
}
|
||
}
|
||
fiber = fiber.return;
|
||
}
|
||
{
|
||
error("Internal React error: Attempted to capture a commit phase error inside a detached tree. This indicates a bug in React. Likely causes include deleting the same fiber more than once, committing an already-finished tree, or an inconsistent return pointer.\n\nError message:\n\n%s", error$1);
|
||
}
|
||
}
|
||
function pingSuspendedRoot(root2, wakeable, pingedLanes) {
|
||
var pingCache = root2.pingCache;
|
||
if (pingCache !== null) {
|
||
pingCache.delete(wakeable);
|
||
}
|
||
var eventTime = requestEventTime();
|
||
markRootPinged(root2, pingedLanes);
|
||
warnIfSuspenseResolutionNotWrappedWithActDEV(root2);
|
||
if (workInProgressRoot === root2 && isSubsetOfLanes(workInProgressRootRenderLanes, pingedLanes)) {
|
||
if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && includesOnlyRetries(workInProgressRootRenderLanes) && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
|
||
prepareFreshStack(root2, NoLanes);
|
||
} else {
|
||
workInProgressRootPingedLanes = mergeLanes(workInProgressRootPingedLanes, pingedLanes);
|
||
}
|
||
}
|
||
ensureRootIsScheduled(root2, eventTime);
|
||
}
|
||
function retryTimedOutBoundary(boundaryFiber, retryLane) {
|
||
if (retryLane === NoLane) {
|
||
retryLane = requestRetryLane(boundaryFiber);
|
||
}
|
||
var eventTime = requestEventTime();
|
||
var root2 = enqueueConcurrentRenderForLane(boundaryFiber, retryLane);
|
||
if (root2 !== null) {
|
||
markRootUpdated(root2, retryLane, eventTime);
|
||
ensureRootIsScheduled(root2, eventTime);
|
||
}
|
||
}
|
||
function retryDehydratedSuspenseBoundary(boundaryFiber) {
|
||
var suspenseState = boundaryFiber.memoizedState;
|
||
var retryLane = NoLane;
|
||
if (suspenseState !== null) {
|
||
retryLane = suspenseState.retryLane;
|
||
}
|
||
retryTimedOutBoundary(boundaryFiber, retryLane);
|
||
}
|
||
function resolveRetryWakeable(boundaryFiber, wakeable) {
|
||
var retryLane = NoLane;
|
||
var retryCache;
|
||
switch (boundaryFiber.tag) {
|
||
case SuspenseComponent:
|
||
retryCache = boundaryFiber.stateNode;
|
||
var suspenseState = boundaryFiber.memoizedState;
|
||
if (suspenseState !== null) {
|
||
retryLane = suspenseState.retryLane;
|
||
}
|
||
break;
|
||
case SuspenseListComponent:
|
||
retryCache = boundaryFiber.stateNode;
|
||
break;
|
||
default:
|
||
throw new Error("Pinged unknown suspense boundary type. This is probably a bug in React.");
|
||
}
|
||
if (retryCache !== null) {
|
||
retryCache.delete(wakeable);
|
||
}
|
||
retryTimedOutBoundary(boundaryFiber, retryLane);
|
||
}
|
||
function jnd(timeElapsed) {
|
||
return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3e3 ? 3e3 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960;
|
||
}
|
||
function checkForNestedUpdates() {
|
||
if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
|
||
nestedUpdateCount = 0;
|
||
rootWithNestedUpdates = null;
|
||
throw new Error("Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.");
|
||
}
|
||
{
|
||
if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
|
||
nestedPassiveUpdateCount = 0;
|
||
rootWithPassiveNestedUpdates = null;
|
||
error("Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.");
|
||
}
|
||
}
|
||
}
|
||
function flushRenderPhaseStrictModeWarningsInDEV() {
|
||
{
|
||
ReactStrictModeWarnings.flushLegacyContextWarning();
|
||
{
|
||
ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
|
||
}
|
||
}
|
||
}
|
||
function commitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) {
|
||
{
|
||
setCurrentFiber(fiber);
|
||
invokeEffectsInDev(fiber, MountLayoutDev, invokeLayoutEffectUnmountInDEV);
|
||
if (hasPassiveEffects) {
|
||
invokeEffectsInDev(fiber, MountPassiveDev, invokePassiveEffectUnmountInDEV);
|
||
}
|
||
invokeEffectsInDev(fiber, MountLayoutDev, invokeLayoutEffectMountInDEV);
|
||
if (hasPassiveEffects) {
|
||
invokeEffectsInDev(fiber, MountPassiveDev, invokePassiveEffectMountInDEV);
|
||
}
|
||
resetCurrentFiber();
|
||
}
|
||
}
|
||
function invokeEffectsInDev(firstChild, fiberFlags, invokeEffectFn) {
|
||
{
|
||
var current2 = firstChild;
|
||
var subtreeRoot = null;
|
||
while (current2 !== null) {
|
||
var primarySubtreeFlag = current2.subtreeFlags & fiberFlags;
|
||
if (current2 !== subtreeRoot && current2.child !== null && primarySubtreeFlag !== NoFlags) {
|
||
current2 = current2.child;
|
||
} else {
|
||
if ((current2.flags & fiberFlags) !== NoFlags) {
|
||
invokeEffectFn(current2);
|
||
}
|
||
if (current2.sibling !== null) {
|
||
current2 = current2.sibling;
|
||
} else {
|
||
current2 = subtreeRoot = current2.return;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var didWarnStateUpdateForNotYetMountedComponent = null;
|
||
function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) {
|
||
{
|
||
if ((executionContext & RenderContext) !== NoContext) {
|
||
return;
|
||
}
|
||
if (!(fiber.mode & ConcurrentMode)) {
|
||
return;
|
||
}
|
||
var tag = fiber.tag;
|
||
if (tag !== IndeterminateComponent && tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent) {
|
||
return;
|
||
}
|
||
var componentName = getComponentNameFromFiber(fiber) || "ReactComponent";
|
||
if (didWarnStateUpdateForNotYetMountedComponent !== null) {
|
||
if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) {
|
||
return;
|
||
}
|
||
didWarnStateUpdateForNotYetMountedComponent.add(componentName);
|
||
} else {
|
||
didWarnStateUpdateForNotYetMountedComponent = /* @__PURE__ */ new Set([componentName]);
|
||
}
|
||
var previousFiber = current;
|
||
try {
|
||
setCurrentFiber(fiber);
|
||
error("Can't perform a React state update on a component that hasn't mounted yet. This indicates that you have a side-effect in your render function that asynchronously later calls tries to update the component. Move this work to useEffect instead.");
|
||
} finally {
|
||
if (previousFiber) {
|
||
setCurrentFiber(fiber);
|
||
} else {
|
||
resetCurrentFiber();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var beginWork$1;
|
||
{
|
||
var dummyFiber = null;
|
||
beginWork$1 = function(current2, unitOfWork, lanes) {
|
||
var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork);
|
||
try {
|
||
return beginWork(current2, unitOfWork, lanes);
|
||
} catch (originalError) {
|
||
if (didSuspendOrErrorWhileHydratingDEV() || originalError !== null && typeof originalError === "object" && typeof originalError.then === "function") {
|
||
throw originalError;
|
||
}
|
||
resetContextDependencies();
|
||
resetHooksAfterThrow();
|
||
unwindInterruptedWork(current2, unitOfWork);
|
||
assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
|
||
if (unitOfWork.mode & ProfileMode) {
|
||
startProfilerTimer(unitOfWork);
|
||
}
|
||
invokeGuardedCallback(null, beginWork, null, current2, unitOfWork, lanes);
|
||
if (hasCaughtError()) {
|
||
var replayError = clearCaughtError();
|
||
if (typeof replayError === "object" && replayError !== null && replayError._suppressLogging && typeof originalError === "object" && originalError !== null && !originalError._suppressLogging) {
|
||
originalError._suppressLogging = true;
|
||
}
|
||
}
|
||
throw originalError;
|
||
}
|
||
};
|
||
}
|
||
var didWarnAboutUpdateInRender = false;
|
||
var didWarnAboutUpdateInRenderForAnotherComponent;
|
||
{
|
||
didWarnAboutUpdateInRenderForAnotherComponent = /* @__PURE__ */ new Set();
|
||
}
|
||
function warnAboutRenderPhaseUpdatesInDEV(fiber) {
|
||
{
|
||
if (isRendering && !getIsUpdatingOpaqueValueInRenderPhaseInDEV()) {
|
||
switch (fiber.tag) {
|
||
case FunctionComponent:
|
||
case ForwardRef:
|
||
case SimpleMemoComponent: {
|
||
var renderingComponentName = workInProgress && getComponentNameFromFiber(workInProgress) || "Unknown";
|
||
var dedupeKey = renderingComponentName;
|
||
if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) {
|
||
didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey);
|
||
var setStateComponentName = getComponentNameFromFiber(fiber) || "Unknown";
|
||
error("Cannot update a component (`%s`) while rendering a different component (`%s`). To locate the bad setState() call inside `%s`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render", setStateComponentName, renderingComponentName, renderingComponentName);
|
||
}
|
||
break;
|
||
}
|
||
case ClassComponent: {
|
||
if (!didWarnAboutUpdateInRender) {
|
||
error("Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state.");
|
||
didWarnAboutUpdateInRender = true;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function restorePendingUpdaters(root2, lanes) {
|
||
{
|
||
if (isDevToolsPresent) {
|
||
var memoizedUpdaters = root2.memoizedUpdaters;
|
||
memoizedUpdaters.forEach(function(schedulingFiber) {
|
||
addFiberToLanesMap(root2, schedulingFiber, lanes);
|
||
});
|
||
}
|
||
}
|
||
}
|
||
var fakeActCallbackNode = {};
|
||
function scheduleCallback$1(priorityLevel, callback) {
|
||
{
|
||
var actQueue = ReactCurrentActQueue$1.current;
|
||
if (actQueue !== null) {
|
||
actQueue.push(callback);
|
||
return fakeActCallbackNode;
|
||
} else {
|
||
return scheduleCallback(priorityLevel, callback);
|
||
}
|
||
}
|
||
}
|
||
function cancelCallback$1(callbackNode) {
|
||
if (callbackNode === fakeActCallbackNode) {
|
||
return;
|
||
}
|
||
return cancelCallback(callbackNode);
|
||
}
|
||
function shouldForceFlushFallbacksInDEV() {
|
||
return ReactCurrentActQueue$1.current !== null;
|
||
}
|
||
function warnIfUpdatesNotWrappedWithActDEV(fiber) {
|
||
{
|
||
if (fiber.mode & ConcurrentMode) {
|
||
if (!isConcurrentActEnvironment()) {
|
||
return;
|
||
}
|
||
} else {
|
||
if (!isLegacyActEnvironment()) {
|
||
return;
|
||
}
|
||
if (executionContext !== NoContext) {
|
||
return;
|
||
}
|
||
if (fiber.tag !== FunctionComponent && fiber.tag !== ForwardRef && fiber.tag !== SimpleMemoComponent) {
|
||
return;
|
||
}
|
||
}
|
||
if (ReactCurrentActQueue$1.current === null) {
|
||
var previousFiber = current;
|
||
try {
|
||
setCurrentFiber(fiber);
|
||
error("An update to %s inside a test was not wrapped in act(...).\n\nWhen testing, code that causes React state updates should be wrapped into act(...):\n\nact(() => {\n /* fire events that update state */\n});\n/* assert on the output */\n\nThis ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act", getComponentNameFromFiber(fiber));
|
||
} finally {
|
||
if (previousFiber) {
|
||
setCurrentFiber(fiber);
|
||
} else {
|
||
resetCurrentFiber();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function warnIfSuspenseResolutionNotWrappedWithActDEV(root2) {
|
||
{
|
||
if (root2.tag !== LegacyRoot && isConcurrentActEnvironment() && ReactCurrentActQueue$1.current === null) {
|
||
error("A suspended resource finished loading inside a test, but the event was not wrapped in act(...).\n\nWhen testing, code that resolves suspended data should be wrapped into act(...):\n\nact(() => {\n /* finish loading suspended data */\n});\n/* assert on the output */\n\nThis ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act");
|
||
}
|
||
}
|
||
}
|
||
function setIsRunningInsertionEffect(isRunning) {
|
||
{
|
||
isRunningInsertionEffect = isRunning;
|
||
}
|
||
}
|
||
var resolveFamily = null;
|
||
var failedBoundaries = null;
|
||
var setRefreshHandler = function(handler) {
|
||
{
|
||
resolveFamily = handler;
|
||
}
|
||
};
|
||
function resolveFunctionForHotReloading(type) {
|
||
{
|
||
if (resolveFamily === null) {
|
||
return type;
|
||
}
|
||
var family = resolveFamily(type);
|
||
if (family === void 0) {
|
||
return type;
|
||
}
|
||
return family.current;
|
||
}
|
||
}
|
||
function resolveClassForHotReloading(type) {
|
||
return resolveFunctionForHotReloading(type);
|
||
}
|
||
function resolveForwardRefForHotReloading(type) {
|
||
{
|
||
if (resolveFamily === null) {
|
||
return type;
|
||
}
|
||
var family = resolveFamily(type);
|
||
if (family === void 0) {
|
||
if (type !== null && type !== void 0 && typeof type.render === "function") {
|
||
var currentRender = resolveFunctionForHotReloading(type.render);
|
||
if (type.render !== currentRender) {
|
||
var syntheticType = {
|
||
$$typeof: REACT_FORWARD_REF_TYPE,
|
||
render: currentRender
|
||
};
|
||
if (type.displayName !== void 0) {
|
||
syntheticType.displayName = type.displayName;
|
||
}
|
||
return syntheticType;
|
||
}
|
||
}
|
||
return type;
|
||
}
|
||
return family.current;
|
||
}
|
||
}
|
||
function isCompatibleFamilyForHotReloading(fiber, element) {
|
||
{
|
||
if (resolveFamily === null) {
|
||
return false;
|
||
}
|
||
var prevType = fiber.elementType;
|
||
var nextType = element.type;
|
||
var needsCompareFamilies = false;
|
||
var $$typeofNextType = typeof nextType === "object" && nextType !== null ? nextType.$$typeof : null;
|
||
switch (fiber.tag) {
|
||
case ClassComponent: {
|
||
if (typeof nextType === "function") {
|
||
needsCompareFamilies = true;
|
||
}
|
||
break;
|
||
}
|
||
case FunctionComponent: {
|
||
if (typeof nextType === "function") {
|
||
needsCompareFamilies = true;
|
||
} else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
||
needsCompareFamilies = true;
|
||
}
|
||
break;
|
||
}
|
||
case ForwardRef: {
|
||
if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
|
||
needsCompareFamilies = true;
|
||
} else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
||
needsCompareFamilies = true;
|
||
}
|
||
break;
|
||
}
|
||
case MemoComponent:
|
||
case SimpleMemoComponent: {
|
||
if ($$typeofNextType === REACT_MEMO_TYPE) {
|
||
needsCompareFamilies = true;
|
||
} else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
||
needsCompareFamilies = true;
|
||
}
|
||
break;
|
||
}
|
||
default:
|
||
return false;
|
||
}
|
||
if (needsCompareFamilies) {
|
||
var prevFamily = resolveFamily(prevType);
|
||
if (prevFamily !== void 0 && prevFamily === resolveFamily(nextType)) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
function markFailedErrorBoundaryForHotReloading(fiber) {
|
||
{
|
||
if (resolveFamily === null) {
|
||
return;
|
||
}
|
||
if (typeof WeakSet !== "function") {
|
||
return;
|
||
}
|
||
if (failedBoundaries === null) {
|
||
failedBoundaries = /* @__PURE__ */ new WeakSet();
|
||
}
|
||
failedBoundaries.add(fiber);
|
||
}
|
||
}
|
||
var scheduleRefresh = function(root2, update) {
|
||
{
|
||
if (resolveFamily === null) {
|
||
return;
|
||
}
|
||
var staleFamilies = update.staleFamilies, updatedFamilies = update.updatedFamilies;
|
||
flushPassiveEffects();
|
||
flushSync(function() {
|
||
scheduleFibersWithFamiliesRecursively(root2.current, updatedFamilies, staleFamilies);
|
||
});
|
||
}
|
||
};
|
||
var scheduleRoot = function(root2, element) {
|
||
{
|
||
if (root2.context !== emptyContextObject) {
|
||
return;
|
||
}
|
||
flushPassiveEffects();
|
||
flushSync(function() {
|
||
updateContainer(element, root2, null, null);
|
||
});
|
||
}
|
||
};
|
||
function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) {
|
||
{
|
||
var alternate = fiber.alternate, child = fiber.child, sibling = fiber.sibling, tag = fiber.tag, type = fiber.type;
|
||
var candidateType = null;
|
||
switch (tag) {
|
||
case FunctionComponent:
|
||
case SimpleMemoComponent:
|
||
case ClassComponent:
|
||
candidateType = type;
|
||
break;
|
||
case ForwardRef:
|
||
candidateType = type.render;
|
||
break;
|
||
}
|
||
if (resolveFamily === null) {
|
||
throw new Error("Expected resolveFamily to be set during hot reload.");
|
||
}
|
||
var needsRender = false;
|
||
var needsRemount = false;
|
||
if (candidateType !== null) {
|
||
var family = resolveFamily(candidateType);
|
||
if (family !== void 0) {
|
||
if (staleFamilies.has(family)) {
|
||
needsRemount = true;
|
||
} else if (updatedFamilies.has(family)) {
|
||
if (tag === ClassComponent) {
|
||
needsRemount = true;
|
||
} else {
|
||
needsRender = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (failedBoundaries !== null) {
|
||
if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) {
|
||
needsRemount = true;
|
||
}
|
||
}
|
||
if (needsRemount) {
|
||
fiber._debugNeedsRemount = true;
|
||
}
|
||
if (needsRemount || needsRender) {
|
||
var _root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||
if (_root !== null) {
|
||
scheduleUpdateOnFiber(_root, fiber, SyncLane, NoTimestamp);
|
||
}
|
||
}
|
||
if (child !== null && !needsRemount) {
|
||
scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies);
|
||
}
|
||
if (sibling !== null) {
|
||
scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies);
|
||
}
|
||
}
|
||
}
|
||
var findHostInstancesForRefresh = function(root2, families) {
|
||
{
|
||
var hostInstances = /* @__PURE__ */ new Set();
|
||
var types = new Set(families.map(function(family) {
|
||
return family.current;
|
||
}));
|
||
findHostInstancesForMatchingFibersRecursively(root2.current, types, hostInstances);
|
||
return hostInstances;
|
||
}
|
||
};
|
||
function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) {
|
||
{
|
||
var child = fiber.child, sibling = fiber.sibling, tag = fiber.tag, type = fiber.type;
|
||
var candidateType = null;
|
||
switch (tag) {
|
||
case FunctionComponent:
|
||
case SimpleMemoComponent:
|
||
case ClassComponent:
|
||
candidateType = type;
|
||
break;
|
||
case ForwardRef:
|
||
candidateType = type.render;
|
||
break;
|
||
}
|
||
var didMatch = false;
|
||
if (candidateType !== null) {
|
||
if (types.has(candidateType)) {
|
||
didMatch = true;
|
||
}
|
||
}
|
||
if (didMatch) {
|
||
findHostInstancesForFiberShallowly(fiber, hostInstances);
|
||
} else {
|
||
if (child !== null) {
|
||
findHostInstancesForMatchingFibersRecursively(child, types, hostInstances);
|
||
}
|
||
}
|
||
if (sibling !== null) {
|
||
findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances);
|
||
}
|
||
}
|
||
}
|
||
function findHostInstancesForFiberShallowly(fiber, hostInstances) {
|
||
{
|
||
var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances);
|
||
if (foundHostInstances) {
|
||
return;
|
||
}
|
||
var node = fiber;
|
||
while (true) {
|
||
switch (node.tag) {
|
||
case HostComponent:
|
||
hostInstances.add(node.stateNode);
|
||
return;
|
||
case HostPortal:
|
||
hostInstances.add(node.stateNode.containerInfo);
|
||
return;
|
||
case HostRoot:
|
||
hostInstances.add(node.stateNode.containerInfo);
|
||
return;
|
||
}
|
||
if (node.return === null) {
|
||
throw new Error("Expected to reach root first.");
|
||
}
|
||
node = node.return;
|
||
}
|
||
}
|
||
}
|
||
function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
|
||
{
|
||
var node = fiber;
|
||
var foundHostInstances = false;
|
||
while (true) {
|
||
if (node.tag === HostComponent) {
|
||
foundHostInstances = true;
|
||
hostInstances.add(node.stateNode);
|
||
} else if (node.child !== null) {
|
||
node.child.return = node;
|
||
node = node.child;
|
||
continue;
|
||
}
|
||
if (node === fiber) {
|
||
return foundHostInstances;
|
||
}
|
||
while (node.sibling === null) {
|
||
if (node.return === null || node.return === fiber) {
|
||
return foundHostInstances;
|
||
}
|
||
node = node.return;
|
||
}
|
||
node.sibling.return = node.return;
|
||
node = node.sibling;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
var hasBadMapPolyfill;
|
||
{
|
||
hasBadMapPolyfill = false;
|
||
try {
|
||
var nonExtensibleObject = Object.preventExtensions({});
|
||
/* @__PURE__ */ new Map([[nonExtensibleObject, null]]);
|
||
/* @__PURE__ */ new Set([nonExtensibleObject]);
|
||
} catch (e) {
|
||
hasBadMapPolyfill = true;
|
||
}
|
||
}
|
||
function FiberNode(tag, pendingProps, key, mode) {
|
||
this.tag = tag;
|
||
this.key = key;
|
||
this.elementType = null;
|
||
this.type = null;
|
||
this.stateNode = null;
|
||
this.return = null;
|
||
this.child = null;
|
||
this.sibling = null;
|
||
this.index = 0;
|
||
this.ref = null;
|
||
this.pendingProps = pendingProps;
|
||
this.memoizedProps = null;
|
||
this.updateQueue = null;
|
||
this.memoizedState = null;
|
||
this.dependencies = null;
|
||
this.mode = mode;
|
||
this.flags = NoFlags;
|
||
this.subtreeFlags = NoFlags;
|
||
this.deletions = null;
|
||
this.lanes = NoLanes;
|
||
this.childLanes = NoLanes;
|
||
this.alternate = null;
|
||
{
|
||
this.actualDuration = Number.NaN;
|
||
this.actualStartTime = Number.NaN;
|
||
this.selfBaseDuration = Number.NaN;
|
||
this.treeBaseDuration = Number.NaN;
|
||
this.actualDuration = 0;
|
||
this.actualStartTime = -1;
|
||
this.selfBaseDuration = 0;
|
||
this.treeBaseDuration = 0;
|
||
}
|
||
{
|
||
this._debugSource = null;
|
||
this._debugOwner = null;
|
||
this._debugNeedsRemount = false;
|
||
this._debugHookTypes = null;
|
||
if (!hasBadMapPolyfill && typeof Object.preventExtensions === "function") {
|
||
Object.preventExtensions(this);
|
||
}
|
||
}
|
||
}
|
||
var createFiber = function(tag, pendingProps, key, mode) {
|
||
return new FiberNode(tag, pendingProps, key, mode);
|
||
};
|
||
function shouldConstruct$1(Component) {
|
||
var prototype = Component.prototype;
|
||
return !!(prototype && prototype.isReactComponent);
|
||
}
|
||
function isSimpleFunctionComponent(type) {
|
||
return typeof type === "function" && !shouldConstruct$1(type) && type.defaultProps === void 0;
|
||
}
|
||
function resolveLazyComponentTag(Component) {
|
||
if (typeof Component === "function") {
|
||
return shouldConstruct$1(Component) ? ClassComponent : FunctionComponent;
|
||
} else if (Component !== void 0 && Component !== null) {
|
||
var $$typeof = Component.$$typeof;
|
||
if ($$typeof === REACT_FORWARD_REF_TYPE) {
|
||
return ForwardRef;
|
||
}
|
||
if ($$typeof === REACT_MEMO_TYPE) {
|
||
return MemoComponent;
|
||
}
|
||
}
|
||
return IndeterminateComponent;
|
||
}
|
||
function createWorkInProgress(current2, pendingProps) {
|
||
var workInProgress2 = current2.alternate;
|
||
if (workInProgress2 === null) {
|
||
workInProgress2 = createFiber(current2.tag, pendingProps, current2.key, current2.mode);
|
||
workInProgress2.elementType = current2.elementType;
|
||
workInProgress2.type = current2.type;
|
||
workInProgress2.stateNode = current2.stateNode;
|
||
{
|
||
workInProgress2._debugSource = current2._debugSource;
|
||
workInProgress2._debugOwner = current2._debugOwner;
|
||
workInProgress2._debugHookTypes = current2._debugHookTypes;
|
||
}
|
||
workInProgress2.alternate = current2;
|
||
current2.alternate = workInProgress2;
|
||
} else {
|
||
workInProgress2.pendingProps = pendingProps;
|
||
workInProgress2.type = current2.type;
|
||
workInProgress2.flags = NoFlags;
|
||
workInProgress2.subtreeFlags = NoFlags;
|
||
workInProgress2.deletions = null;
|
||
{
|
||
workInProgress2.actualDuration = 0;
|
||
workInProgress2.actualStartTime = -1;
|
||
}
|
||
}
|
||
workInProgress2.flags = current2.flags & StaticMask;
|
||
workInProgress2.childLanes = current2.childLanes;
|
||
workInProgress2.lanes = current2.lanes;
|
||
workInProgress2.child = current2.child;
|
||
workInProgress2.memoizedProps = current2.memoizedProps;
|
||
workInProgress2.memoizedState = current2.memoizedState;
|
||
workInProgress2.updateQueue = current2.updateQueue;
|
||
var currentDependencies = current2.dependencies;
|
||
workInProgress2.dependencies = currentDependencies === null ? null : {
|
||
lanes: currentDependencies.lanes,
|
||
firstContext: currentDependencies.firstContext
|
||
};
|
||
workInProgress2.sibling = current2.sibling;
|
||
workInProgress2.index = current2.index;
|
||
workInProgress2.ref = current2.ref;
|
||
{
|
||
workInProgress2.selfBaseDuration = current2.selfBaseDuration;
|
||
workInProgress2.treeBaseDuration = current2.treeBaseDuration;
|
||
}
|
||
{
|
||
workInProgress2._debugNeedsRemount = current2._debugNeedsRemount;
|
||
switch (workInProgress2.tag) {
|
||
case IndeterminateComponent:
|
||
case FunctionComponent:
|
||
case SimpleMemoComponent:
|
||
workInProgress2.type = resolveFunctionForHotReloading(current2.type);
|
||
break;
|
||
case ClassComponent:
|
||
workInProgress2.type = resolveClassForHotReloading(current2.type);
|
||
break;
|
||
case ForwardRef:
|
||
workInProgress2.type = resolveForwardRefForHotReloading(current2.type);
|
||
break;
|
||
}
|
||
}
|
||
return workInProgress2;
|
||
}
|
||
function resetWorkInProgress(workInProgress2, renderLanes2) {
|
||
workInProgress2.flags &= StaticMask | Placement;
|
||
var current2 = workInProgress2.alternate;
|
||
if (current2 === null) {
|
||
workInProgress2.childLanes = NoLanes;
|
||
workInProgress2.lanes = renderLanes2;
|
||
workInProgress2.child = null;
|
||
workInProgress2.subtreeFlags = NoFlags;
|
||
workInProgress2.memoizedProps = null;
|
||
workInProgress2.memoizedState = null;
|
||
workInProgress2.updateQueue = null;
|
||
workInProgress2.dependencies = null;
|
||
workInProgress2.stateNode = null;
|
||
{
|
||
workInProgress2.selfBaseDuration = 0;
|
||
workInProgress2.treeBaseDuration = 0;
|
||
}
|
||
} else {
|
||
workInProgress2.childLanes = current2.childLanes;
|
||
workInProgress2.lanes = current2.lanes;
|
||
workInProgress2.child = current2.child;
|
||
workInProgress2.subtreeFlags = NoFlags;
|
||
workInProgress2.deletions = null;
|
||
workInProgress2.memoizedProps = current2.memoizedProps;
|
||
workInProgress2.memoizedState = current2.memoizedState;
|
||
workInProgress2.updateQueue = current2.updateQueue;
|
||
workInProgress2.type = current2.type;
|
||
var currentDependencies = current2.dependencies;
|
||
workInProgress2.dependencies = currentDependencies === null ? null : {
|
||
lanes: currentDependencies.lanes,
|
||
firstContext: currentDependencies.firstContext
|
||
};
|
||
{
|
||
workInProgress2.selfBaseDuration = current2.selfBaseDuration;
|
||
workInProgress2.treeBaseDuration = current2.treeBaseDuration;
|
||
}
|
||
}
|
||
return workInProgress2;
|
||
}
|
||
function createHostRootFiber(tag, isStrictMode, concurrentUpdatesByDefaultOverride) {
|
||
var mode;
|
||
if (tag === ConcurrentRoot) {
|
||
mode = ConcurrentMode;
|
||
if (isStrictMode === true) {
|
||
mode |= StrictLegacyMode;
|
||
{
|
||
mode |= StrictEffectsMode;
|
||
}
|
||
}
|
||
} else {
|
||
mode = NoMode;
|
||
}
|
||
if (isDevToolsPresent) {
|
||
mode |= ProfileMode;
|
||
}
|
||
return createFiber(HostRoot, null, null, mode);
|
||
}
|
||
function createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, lanes) {
|
||
var fiberTag = IndeterminateComponent;
|
||
var resolvedType = type;
|
||
if (typeof type === "function") {
|
||
if (shouldConstruct$1(type)) {
|
||
fiberTag = ClassComponent;
|
||
{
|
||
resolvedType = resolveClassForHotReloading(resolvedType);
|
||
}
|
||
} else {
|
||
{
|
||
resolvedType = resolveFunctionForHotReloading(resolvedType);
|
||
}
|
||
}
|
||
} else if (typeof type === "string") {
|
||
fiberTag = HostComponent;
|
||
} else {
|
||
getTag:
|
||
switch (type) {
|
||
case REACT_FRAGMENT_TYPE:
|
||
return createFiberFromFragment(pendingProps.children, mode, lanes, key);
|
||
case REACT_STRICT_MODE_TYPE:
|
||
fiberTag = Mode;
|
||
mode |= StrictLegacyMode;
|
||
if ((mode & ConcurrentMode) !== NoMode) {
|
||
mode |= StrictEffectsMode;
|
||
}
|
||
break;
|
||
case REACT_PROFILER_TYPE:
|
||
return createFiberFromProfiler(pendingProps, mode, lanes, key);
|
||
case REACT_SUSPENSE_TYPE:
|
||
return createFiberFromSuspense(pendingProps, mode, lanes, key);
|
||
case REACT_SUSPENSE_LIST_TYPE:
|
||
return createFiberFromSuspenseList(pendingProps, mode, lanes, key);
|
||
case REACT_OFFSCREEN_TYPE:
|
||
return createFiberFromOffscreen(pendingProps, mode, lanes, key);
|
||
case REACT_LEGACY_HIDDEN_TYPE:
|
||
case REACT_SCOPE_TYPE:
|
||
case REACT_CACHE_TYPE:
|
||
case REACT_TRACING_MARKER_TYPE:
|
||
case REACT_DEBUG_TRACING_MODE_TYPE:
|
||
default: {
|
||
if (typeof type === "object" && type !== null) {
|
||
switch (type.$$typeof) {
|
||
case REACT_PROVIDER_TYPE:
|
||
fiberTag = ContextProvider;
|
||
break getTag;
|
||
case REACT_CONTEXT_TYPE:
|
||
fiberTag = ContextConsumer;
|
||
break getTag;
|
||
case REACT_FORWARD_REF_TYPE:
|
||
fiberTag = ForwardRef;
|
||
{
|
||
resolvedType = resolveForwardRefForHotReloading(resolvedType);
|
||
}
|
||
break getTag;
|
||
case REACT_MEMO_TYPE:
|
||
fiberTag = MemoComponent;
|
||
break getTag;
|
||
case REACT_LAZY_TYPE:
|
||
fiberTag = LazyComponent;
|
||
resolvedType = null;
|
||
break getTag;
|
||
}
|
||
}
|
||
var info = "";
|
||
{
|
||
if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
|
||
info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
|
||
}
|
||
var ownerName = owner ? getComponentNameFromFiber(owner) : null;
|
||
if (ownerName) {
|
||
info += "\n\nCheck the render method of `" + ownerName + "`.";
|
||
}
|
||
}
|
||
throw new Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) " + ("but got: " + (type == null ? type : typeof type) + "." + info));
|
||
}
|
||
}
|
||
}
|
||
var fiber = createFiber(fiberTag, pendingProps, key, mode);
|
||
fiber.elementType = type;
|
||
fiber.type = resolvedType;
|
||
fiber.lanes = lanes;
|
||
{
|
||
fiber._debugOwner = owner;
|
||
}
|
||
return fiber;
|
||
}
|
||
function createFiberFromElement(element, mode, lanes) {
|
||
var owner = null;
|
||
{
|
||
owner = element._owner;
|
||
}
|
||
var type = element.type;
|
||
var key = element.key;
|
||
var pendingProps = element.props;
|
||
var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, lanes);
|
||
{
|
||
fiber._debugSource = element._source;
|
||
fiber._debugOwner = element._owner;
|
||
}
|
||
return fiber;
|
||
}
|
||
function createFiberFromFragment(elements, mode, lanes, key) {
|
||
var fiber = createFiber(Fragment, elements, key, mode);
|
||
fiber.lanes = lanes;
|
||
return fiber;
|
||
}
|
||
function createFiberFromProfiler(pendingProps, mode, lanes, key) {
|
||
{
|
||
if (typeof pendingProps.id !== "string") {
|
||
error('Profiler must specify an "id" of type `string` as a prop. Received the type `%s` instead.', typeof pendingProps.id);
|
||
}
|
||
}
|
||
var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
|
||
fiber.elementType = REACT_PROFILER_TYPE;
|
||
fiber.lanes = lanes;
|
||
{
|
||
fiber.stateNode = {
|
||
effectDuration: 0,
|
||
passiveEffectDuration: 0
|
||
};
|
||
}
|
||
return fiber;
|
||
}
|
||
function createFiberFromSuspense(pendingProps, mode, lanes, key) {
|
||
var fiber = createFiber(SuspenseComponent, pendingProps, key, mode);
|
||
fiber.elementType = REACT_SUSPENSE_TYPE;
|
||
fiber.lanes = lanes;
|
||
return fiber;
|
||
}
|
||
function createFiberFromSuspenseList(pendingProps, mode, lanes, key) {
|
||
var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
|
||
fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
|
||
fiber.lanes = lanes;
|
||
return fiber;
|
||
}
|
||
function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
|
||
var fiber = createFiber(OffscreenComponent, pendingProps, key, mode);
|
||
fiber.elementType = REACT_OFFSCREEN_TYPE;
|
||
fiber.lanes = lanes;
|
||
var primaryChildInstance = {
|
||
isHidden: false
|
||
};
|
||
fiber.stateNode = primaryChildInstance;
|
||
return fiber;
|
||
}
|
||
function createFiberFromText(content, mode, lanes) {
|
||
var fiber = createFiber(HostText, content, null, mode);
|
||
fiber.lanes = lanes;
|
||
return fiber;
|
||
}
|
||
function createFiberFromHostInstanceForDeletion() {
|
||
var fiber = createFiber(HostComponent, null, null, NoMode);
|
||
fiber.elementType = "DELETED";
|
||
return fiber;
|
||
}
|
||
function createFiberFromDehydratedFragment(dehydratedNode) {
|
||
var fiber = createFiber(DehydratedFragment, null, null, NoMode);
|
||
fiber.stateNode = dehydratedNode;
|
||
return fiber;
|
||
}
|
||
function createFiberFromPortal(portal, mode, lanes) {
|
||
var pendingProps = portal.children !== null ? portal.children : [];
|
||
var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
|
||
fiber.lanes = lanes;
|
||
fiber.stateNode = {
|
||
containerInfo: portal.containerInfo,
|
||
pendingChildren: null,
|
||
implementation: portal.implementation
|
||
};
|
||
return fiber;
|
||
}
|
||
function assignFiberPropertiesInDEV(target, source) {
|
||
if (target === null) {
|
||
target = createFiber(IndeterminateComponent, null, null, NoMode);
|
||
}
|
||
target.tag = source.tag;
|
||
target.key = source.key;
|
||
target.elementType = source.elementType;
|
||
target.type = source.type;
|
||
target.stateNode = source.stateNode;
|
||
target.return = source.return;
|
||
target.child = source.child;
|
||
target.sibling = source.sibling;
|
||
target.index = source.index;
|
||
target.ref = source.ref;
|
||
target.pendingProps = source.pendingProps;
|
||
target.memoizedProps = source.memoizedProps;
|
||
target.updateQueue = source.updateQueue;
|
||
target.memoizedState = source.memoizedState;
|
||
target.dependencies = source.dependencies;
|
||
target.mode = source.mode;
|
||
target.flags = source.flags;
|
||
target.subtreeFlags = source.subtreeFlags;
|
||
target.deletions = source.deletions;
|
||
target.lanes = source.lanes;
|
||
target.childLanes = source.childLanes;
|
||
target.alternate = source.alternate;
|
||
{
|
||
target.actualDuration = source.actualDuration;
|
||
target.actualStartTime = source.actualStartTime;
|
||
target.selfBaseDuration = source.selfBaseDuration;
|
||
target.treeBaseDuration = source.treeBaseDuration;
|
||
}
|
||
target._debugSource = source._debugSource;
|
||
target._debugOwner = source._debugOwner;
|
||
target._debugNeedsRemount = source._debugNeedsRemount;
|
||
target._debugHookTypes = source._debugHookTypes;
|
||
return target;
|
||
}
|
||
function FiberRootNode(containerInfo, tag, hydrate2, identifierPrefix, onRecoverableError) {
|
||
this.tag = tag;
|
||
this.containerInfo = containerInfo;
|
||
this.pendingChildren = null;
|
||
this.current = null;
|
||
this.pingCache = null;
|
||
this.finishedWork = null;
|
||
this.timeoutHandle = noTimeout;
|
||
this.context = null;
|
||
this.pendingContext = null;
|
||
this.callbackNode = null;
|
||
this.callbackPriority = NoLane;
|
||
this.eventTimes = createLaneMap(NoLanes);
|
||
this.expirationTimes = createLaneMap(NoTimestamp);
|
||
this.pendingLanes = NoLanes;
|
||
this.suspendedLanes = NoLanes;
|
||
this.pingedLanes = NoLanes;
|
||
this.expiredLanes = NoLanes;
|
||
this.mutableReadLanes = NoLanes;
|
||
this.finishedLanes = NoLanes;
|
||
this.entangledLanes = NoLanes;
|
||
this.entanglements = createLaneMap(NoLanes);
|
||
this.identifierPrefix = identifierPrefix;
|
||
this.onRecoverableError = onRecoverableError;
|
||
{
|
||
this.mutableSourceEagerHydrationData = null;
|
||
}
|
||
{
|
||
this.effectDuration = 0;
|
||
this.passiveEffectDuration = 0;
|
||
}
|
||
{
|
||
this.memoizedUpdaters = /* @__PURE__ */ new Set();
|
||
var pendingUpdatersLaneMap = this.pendingUpdatersLaneMap = [];
|
||
for (var _i = 0; _i < TotalLanes; _i++) {
|
||
pendingUpdatersLaneMap.push(/* @__PURE__ */ new Set());
|
||
}
|
||
}
|
||
{
|
||
switch (tag) {
|
||
case ConcurrentRoot:
|
||
this._debugRootType = hydrate2 ? "hydrateRoot()" : "createRoot()";
|
||
break;
|
||
case LegacyRoot:
|
||
this._debugRootType = hydrate2 ? "hydrate()" : "render()";
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
function createFiberRoot(containerInfo, tag, hydrate2, initialChildren, hydrationCallbacks, isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, onRecoverableError, transitionCallbacks) {
|
||
var root2 = new FiberRootNode(containerInfo, tag, hydrate2, identifierPrefix, onRecoverableError);
|
||
var uninitializedFiber = createHostRootFiber(tag, isStrictMode);
|
||
root2.current = uninitializedFiber;
|
||
uninitializedFiber.stateNode = root2;
|
||
{
|
||
var _initialState = {
|
||
element: initialChildren,
|
||
isDehydrated: hydrate2,
|
||
cache: null,
|
||
transitions: null,
|
||
pendingSuspenseBoundaries: null
|
||
};
|
||
uninitializedFiber.memoizedState = _initialState;
|
||
}
|
||
initializeUpdateQueue(uninitializedFiber);
|
||
return root2;
|
||
}
|
||
var ReactVersion = "18.2.0";
|
||
function createPortal(children, containerInfo, implementation) {
|
||
var key = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;
|
||
{
|
||
checkKeyStringCoercion(key);
|
||
}
|
||
return {
|
||
$$typeof: REACT_PORTAL_TYPE,
|
||
key: key == null ? null : "" + key,
|
||
children,
|
||
containerInfo,
|
||
implementation
|
||
};
|
||
}
|
||
var didWarnAboutNestedUpdates;
|
||
var didWarnAboutFindNodeInStrictMode;
|
||
{
|
||
didWarnAboutNestedUpdates = false;
|
||
didWarnAboutFindNodeInStrictMode = {};
|
||
}
|
||
function getContextForSubtree(parentComponent) {
|
||
if (!parentComponent) {
|
||
return emptyContextObject;
|
||
}
|
||
var fiber = get(parentComponent);
|
||
var parentContext = findCurrentUnmaskedContext(fiber);
|
||
if (fiber.tag === ClassComponent) {
|
||
var Component = fiber.type;
|
||
if (isContextProvider(Component)) {
|
||
return processChildContext(fiber, Component, parentContext);
|
||
}
|
||
}
|
||
return parentContext;
|
||
}
|
||
function findHostInstanceWithWarning(component, methodName) {
|
||
{
|
||
var fiber = get(component);
|
||
if (fiber === void 0) {
|
||
if (typeof component.render === "function") {
|
||
throw new Error("Unable to find node on an unmounted component.");
|
||
} else {
|
||
var keys = Object.keys(component).join(",");
|
||
throw new Error("Argument appears to not be a ReactComponent. Keys: " + keys);
|
||
}
|
||
}
|
||
var hostFiber = findCurrentHostFiber(fiber);
|
||
if (hostFiber === null) {
|
||
return null;
|
||
}
|
||
if (hostFiber.mode & StrictLegacyMode) {
|
||
var componentName = getComponentNameFromFiber(fiber) || "Component";
|
||
if (!didWarnAboutFindNodeInStrictMode[componentName]) {
|
||
didWarnAboutFindNodeInStrictMode[componentName] = true;
|
||
var previousFiber = current;
|
||
try {
|
||
setCurrentFiber(hostFiber);
|
||
if (fiber.mode & StrictLegacyMode) {
|
||
error("%s is deprecated in StrictMode. %s was passed an instance of %s which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-node", methodName, methodName, componentName);
|
||
} else {
|
||
error("%s is deprecated in StrictMode. %s was passed an instance of %s which renders StrictMode children. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-node", methodName, methodName, componentName);
|
||
}
|
||
} finally {
|
||
if (previousFiber) {
|
||
setCurrentFiber(previousFiber);
|
||
} else {
|
||
resetCurrentFiber();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return hostFiber.stateNode;
|
||
}
|
||
}
|
||
function createContainer(containerInfo, tag, hydrationCallbacks, isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, onRecoverableError, transitionCallbacks) {
|
||
var hydrate2 = false;
|
||
var initialChildren = null;
|
||
return createFiberRoot(containerInfo, tag, hydrate2, initialChildren, hydrationCallbacks, isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, onRecoverableError);
|
||
}
|
||
function createHydrationContainer(initialChildren, callback, containerInfo, tag, hydrationCallbacks, isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, onRecoverableError, transitionCallbacks) {
|
||
var hydrate2 = true;
|
||
var root2 = createFiberRoot(containerInfo, tag, hydrate2, initialChildren, hydrationCallbacks, isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, onRecoverableError);
|
||
root2.context = getContextForSubtree(null);
|
||
var current2 = root2.current;
|
||
var eventTime = requestEventTime();
|
||
var lane = requestUpdateLane(current2);
|
||
var update = createUpdate(eventTime, lane);
|
||
update.callback = callback !== void 0 && callback !== null ? callback : null;
|
||
enqueueUpdate(current2, update, lane);
|
||
scheduleInitialHydrationOnRoot(root2, lane, eventTime);
|
||
return root2;
|
||
}
|
||
function updateContainer(element, container, parentComponent, callback) {
|
||
{
|
||
onScheduleRoot(container, element);
|
||
}
|
||
var current$1 = container.current;
|
||
var eventTime = requestEventTime();
|
||
var lane = requestUpdateLane(current$1);
|
||
{
|
||
markRenderScheduled(lane);
|
||
}
|
||
var context = getContextForSubtree(parentComponent);
|
||
if (container.context === null) {
|
||
container.context = context;
|
||
} else {
|
||
container.pendingContext = context;
|
||
}
|
||
{
|
||
if (isRendering && current !== null && !didWarnAboutNestedUpdates) {
|
||
didWarnAboutNestedUpdates = true;
|
||
error("Render methods should be a pure function of props and state; triggering nested component updates from render is not allowed. If necessary, trigger nested updates in componentDidUpdate.\n\nCheck the render method of %s.", getComponentNameFromFiber(current) || "Unknown");
|
||
}
|
||
}
|
||
var update = createUpdate(eventTime, lane);
|
||
update.payload = {
|
||
element
|
||
};
|
||
callback = callback === void 0 ? null : callback;
|
||
if (callback !== null) {
|
||
{
|
||
if (typeof callback !== "function") {
|
||
error("render(...): Expected the last optional `callback` argument to be a function. Instead received: %s.", callback);
|
||
}
|
||
}
|
||
update.callback = callback;
|
||
}
|
||
var root2 = enqueueUpdate(current$1, update, lane);
|
||
if (root2 !== null) {
|
||
scheduleUpdateOnFiber(root2, current$1, lane, eventTime);
|
||
entangleTransitions(root2, current$1, lane);
|
||
}
|
||
return lane;
|
||
}
|
||
function getPublicRootInstance(container) {
|
||
var containerFiber = container.current;
|
||
if (!containerFiber.child) {
|
||
return null;
|
||
}
|
||
switch (containerFiber.child.tag) {
|
||
case HostComponent:
|
||
return getPublicInstance(containerFiber.child.stateNode);
|
||
default:
|
||
return containerFiber.child.stateNode;
|
||
}
|
||
}
|
||
function attemptSynchronousHydration$1(fiber) {
|
||
switch (fiber.tag) {
|
||
case HostRoot: {
|
||
var root2 = fiber.stateNode;
|
||
if (isRootDehydrated(root2)) {
|
||
var lanes = getHighestPriorityPendingLanes(root2);
|
||
flushRoot(root2, lanes);
|
||
}
|
||
break;
|
||
}
|
||
case SuspenseComponent: {
|
||
flushSync(function() {
|
||
var root3 = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||
if (root3 !== null) {
|
||
var eventTime = requestEventTime();
|
||
scheduleUpdateOnFiber(root3, fiber, SyncLane, eventTime);
|
||
}
|
||
});
|
||
var retryLane = SyncLane;
|
||
markRetryLaneIfNotHydrated(fiber, retryLane);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
function markRetryLaneImpl(fiber, retryLane) {
|
||
var suspenseState = fiber.memoizedState;
|
||
if (suspenseState !== null && suspenseState.dehydrated !== null) {
|
||
suspenseState.retryLane = higherPriorityLane(suspenseState.retryLane, retryLane);
|
||
}
|
||
}
|
||
function markRetryLaneIfNotHydrated(fiber, retryLane) {
|
||
markRetryLaneImpl(fiber, retryLane);
|
||
var alternate = fiber.alternate;
|
||
if (alternate) {
|
||
markRetryLaneImpl(alternate, retryLane);
|
||
}
|
||
}
|
||
function attemptContinuousHydration$1(fiber) {
|
||
if (fiber.tag !== SuspenseComponent) {
|
||
return;
|
||
}
|
||
var lane = SelectiveHydrationLane;
|
||
var root2 = enqueueConcurrentRenderForLane(fiber, lane);
|
||
if (root2 !== null) {
|
||
var eventTime = requestEventTime();
|
||
scheduleUpdateOnFiber(root2, fiber, lane, eventTime);
|
||
}
|
||
markRetryLaneIfNotHydrated(fiber, lane);
|
||
}
|
||
function attemptHydrationAtCurrentPriority$1(fiber) {
|
||
if (fiber.tag !== SuspenseComponent) {
|
||
return;
|
||
}
|
||
var lane = requestUpdateLane(fiber);
|
||
var root2 = enqueueConcurrentRenderForLane(fiber, lane);
|
||
if (root2 !== null) {
|
||
var eventTime = requestEventTime();
|
||
scheduleUpdateOnFiber(root2, fiber, lane, eventTime);
|
||
}
|
||
markRetryLaneIfNotHydrated(fiber, lane);
|
||
}
|
||
function findHostInstanceWithNoPortals(fiber) {
|
||
var hostFiber = findCurrentHostFiberWithNoPortals(fiber);
|
||
if (hostFiber === null) {
|
||
return null;
|
||
}
|
||
return hostFiber.stateNode;
|
||
}
|
||
var shouldErrorImpl = function(fiber) {
|
||
return null;
|
||
};
|
||
function shouldError(fiber) {
|
||
return shouldErrorImpl(fiber);
|
||
}
|
||
var shouldSuspendImpl = function(fiber) {
|
||
return false;
|
||
};
|
||
function shouldSuspend(fiber) {
|
||
return shouldSuspendImpl(fiber);
|
||
}
|
||
var overrideHookState = null;
|
||
var overrideHookStateDeletePath = null;
|
||
var overrideHookStateRenamePath = null;
|
||
var overrideProps = null;
|
||
var overridePropsDeletePath = null;
|
||
var overridePropsRenamePath = null;
|
||
var scheduleUpdate = null;
|
||
var setErrorHandler = null;
|
||
var setSuspenseHandler = null;
|
||
{
|
||
var copyWithDeleteImpl = function(obj, path, index2) {
|
||
var key = path[index2];
|
||
var updated = isArray(obj) ? obj.slice() : assign({}, obj);
|
||
if (index2 + 1 === path.length) {
|
||
if (isArray(updated)) {
|
||
updated.splice(key, 1);
|
||
} else {
|
||
delete updated[key];
|
||
}
|
||
return updated;
|
||
}
|
||
updated[key] = copyWithDeleteImpl(obj[key], path, index2 + 1);
|
||
return updated;
|
||
};
|
||
var copyWithDelete = function(obj, path) {
|
||
return copyWithDeleteImpl(obj, path, 0);
|
||
};
|
||
var copyWithRenameImpl = function(obj, oldPath, newPath, index2) {
|
||
var oldKey = oldPath[index2];
|
||
var updated = isArray(obj) ? obj.slice() : assign({}, obj);
|
||
if (index2 + 1 === oldPath.length) {
|
||
var newKey = newPath[index2];
|
||
updated[newKey] = updated[oldKey];
|
||
if (isArray(updated)) {
|
||
updated.splice(oldKey, 1);
|
||
} else {
|
||
delete updated[oldKey];
|
||
}
|
||
} else {
|
||
updated[oldKey] = copyWithRenameImpl(obj[oldKey], oldPath, newPath, index2 + 1);
|
||
}
|
||
return updated;
|
||
};
|
||
var copyWithRename = function(obj, oldPath, newPath) {
|
||
if (oldPath.length !== newPath.length) {
|
||
warn("copyWithRename() expects paths of the same length");
|
||
return;
|
||
} else {
|
||
for (var i = 0; i < newPath.length - 1; i++) {
|
||
if (oldPath[i] !== newPath[i]) {
|
||
warn("copyWithRename() expects paths to be the same except for the deepest key");
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
return copyWithRenameImpl(obj, oldPath, newPath, 0);
|
||
};
|
||
var copyWithSetImpl = function(obj, path, index2, value) {
|
||
if (index2 >= path.length) {
|
||
return value;
|
||
}
|
||
var key = path[index2];
|
||
var updated = isArray(obj) ? obj.slice() : assign({}, obj);
|
||
updated[key] = copyWithSetImpl(obj[key], path, index2 + 1, value);
|
||
return updated;
|
||
};
|
||
var copyWithSet = function(obj, path, value) {
|
||
return copyWithSetImpl(obj, path, 0, value);
|
||
};
|
||
var findHook = function(fiber, id) {
|
||
var currentHook2 = fiber.memoizedState;
|
||
while (currentHook2 !== null && id > 0) {
|
||
currentHook2 = currentHook2.next;
|
||
id--;
|
||
}
|
||
return currentHook2;
|
||
};
|
||
overrideHookState = function(fiber, id, path, value) {
|
||
var hook = findHook(fiber, id);
|
||
if (hook !== null) {
|
||
var newState = copyWithSet(hook.memoizedState, path, value);
|
||
hook.memoizedState = newState;
|
||
hook.baseState = newState;
|
||
fiber.memoizedProps = assign({}, fiber.memoizedProps);
|
||
var root2 = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||
if (root2 !== null) {
|
||
scheduleUpdateOnFiber(root2, fiber, SyncLane, NoTimestamp);
|
||
}
|
||
}
|
||
};
|
||
overrideHookStateDeletePath = function(fiber, id, path) {
|
||
var hook = findHook(fiber, id);
|
||
if (hook !== null) {
|
||
var newState = copyWithDelete(hook.memoizedState, path);
|
||
hook.memoizedState = newState;
|
||
hook.baseState = newState;
|
||
fiber.memoizedProps = assign({}, fiber.memoizedProps);
|
||
var root2 = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||
if (root2 !== null) {
|
||
scheduleUpdateOnFiber(root2, fiber, SyncLane, NoTimestamp);
|
||
}
|
||
}
|
||
};
|
||
overrideHookStateRenamePath = function(fiber, id, oldPath, newPath) {
|
||
var hook = findHook(fiber, id);
|
||
if (hook !== null) {
|
||
var newState = copyWithRename(hook.memoizedState, oldPath, newPath);
|
||
hook.memoizedState = newState;
|
||
hook.baseState = newState;
|
||
fiber.memoizedProps = assign({}, fiber.memoizedProps);
|
||
var root2 = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||
if (root2 !== null) {
|
||
scheduleUpdateOnFiber(root2, fiber, SyncLane, NoTimestamp);
|
||
}
|
||
}
|
||
};
|
||
overrideProps = function(fiber, path, value) {
|
||
fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
|
||
if (fiber.alternate) {
|
||
fiber.alternate.pendingProps = fiber.pendingProps;
|
||
}
|
||
var root2 = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||
if (root2 !== null) {
|
||
scheduleUpdateOnFiber(root2, fiber, SyncLane, NoTimestamp);
|
||
}
|
||
};
|
||
overridePropsDeletePath = function(fiber, path) {
|
||
fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path);
|
||
if (fiber.alternate) {
|
||
fiber.alternate.pendingProps = fiber.pendingProps;
|
||
}
|
||
var root2 = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||
if (root2 !== null) {
|
||
scheduleUpdateOnFiber(root2, fiber, SyncLane, NoTimestamp);
|
||
}
|
||
};
|
||
overridePropsRenamePath = function(fiber, oldPath, newPath) {
|
||
fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
|
||
if (fiber.alternate) {
|
||
fiber.alternate.pendingProps = fiber.pendingProps;
|
||
}
|
||
var root2 = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||
if (root2 !== null) {
|
||
scheduleUpdateOnFiber(root2, fiber, SyncLane, NoTimestamp);
|
||
}
|
||
};
|
||
scheduleUpdate = function(fiber) {
|
||
var root2 = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||
if (root2 !== null) {
|
||
scheduleUpdateOnFiber(root2, fiber, SyncLane, NoTimestamp);
|
||
}
|
||
};
|
||
setErrorHandler = function(newShouldErrorImpl) {
|
||
shouldErrorImpl = newShouldErrorImpl;
|
||
};
|
||
setSuspenseHandler = function(newShouldSuspendImpl) {
|
||
shouldSuspendImpl = newShouldSuspendImpl;
|
||
};
|
||
}
|
||
function findHostInstanceByFiber(fiber) {
|
||
var hostFiber = findCurrentHostFiber(fiber);
|
||
if (hostFiber === null) {
|
||
return null;
|
||
}
|
||
return hostFiber.stateNode;
|
||
}
|
||
function emptyFindFiberByHostInstance(instance) {
|
||
return null;
|
||
}
|
||
function getCurrentFiberForDevTools() {
|
||
return current;
|
||
}
|
||
function injectIntoDevTools(devToolsConfig) {
|
||
var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
|
||
var ReactCurrentDispatcher2 = ReactSharedInternals.ReactCurrentDispatcher;
|
||
return injectInternals({
|
||
bundleType: devToolsConfig.bundleType,
|
||
version: devToolsConfig.version,
|
||
rendererPackageName: devToolsConfig.rendererPackageName,
|
||
rendererConfig: devToolsConfig.rendererConfig,
|
||
overrideHookState,
|
||
overrideHookStateDeletePath,
|
||
overrideHookStateRenamePath,
|
||
overrideProps,
|
||
overridePropsDeletePath,
|
||
overridePropsRenamePath,
|
||
setErrorHandler,
|
||
setSuspenseHandler,
|
||
scheduleUpdate,
|
||
currentDispatcherRef: ReactCurrentDispatcher2,
|
||
findHostInstanceByFiber,
|
||
findFiberByHostInstance: findFiberByHostInstance || emptyFindFiberByHostInstance,
|
||
findHostInstancesForRefresh,
|
||
scheduleRefresh,
|
||
scheduleRoot,
|
||
setRefreshHandler,
|
||
getCurrentFiber: getCurrentFiberForDevTools,
|
||
reconcilerVersion: ReactVersion
|
||
});
|
||
}
|
||
var defaultOnRecoverableError = typeof reportError === "function" ? reportError : function(error2) {
|
||
console["error"](error2);
|
||
};
|
||
function ReactDOMRoot(internalRoot) {
|
||
this._internalRoot = internalRoot;
|
||
}
|
||
ReactDOMHydrationRoot.prototype.render = ReactDOMRoot.prototype.render = function(children) {
|
||
var root2 = this._internalRoot;
|
||
if (root2 === null) {
|
||
throw new Error("Cannot update an unmounted root.");
|
||
}
|
||
{
|
||
if (typeof arguments[1] === "function") {
|
||
error("render(...): does not support the second callback argument. To execute a side effect after rendering, declare it in a component body with useEffect().");
|
||
} else if (isValidContainer(arguments[1])) {
|
||
error("You passed a container to the second argument of root.render(...). You don't need to pass it again since you already passed it to create the root.");
|
||
} else if (typeof arguments[1] !== "undefined") {
|
||
error("You passed a second argument to root.render(...) but it only accepts one argument.");
|
||
}
|
||
var container = root2.containerInfo;
|
||
if (container.nodeType !== COMMENT_NODE) {
|
||
var hostInstance = findHostInstanceWithNoPortals(root2.current);
|
||
if (hostInstance) {
|
||
if (hostInstance.parentNode !== container) {
|
||
error("render(...): It looks like the React-rendered content of the root container was removed without using React. This is not supported and will cause errors. Instead, call root.unmount() to empty a root's container.");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
updateContainer(children, root2, null, null);
|
||
};
|
||
ReactDOMHydrationRoot.prototype.unmount = ReactDOMRoot.prototype.unmount = function() {
|
||
{
|
||
if (typeof arguments[0] === "function") {
|
||
error("unmount(...): does not support a callback argument. To execute a side effect after rendering, declare it in a component body with useEffect().");
|
||
}
|
||
}
|
||
var root2 = this._internalRoot;
|
||
if (root2 !== null) {
|
||
this._internalRoot = null;
|
||
var container = root2.containerInfo;
|
||
{
|
||
if (isAlreadyRendering()) {
|
||
error("Attempted to synchronously unmount a root while React was already rendering. React cannot finish unmounting the root until the current render has completed, which may lead to a race condition.");
|
||
}
|
||
}
|
||
flushSync(function() {
|
||
updateContainer(null, root2, null, null);
|
||
});
|
||
unmarkContainerAsRoot(container);
|
||
}
|
||
};
|
||
function createRoot(container, options2) {
|
||
if (!isValidContainer(container)) {
|
||
throw new Error("createRoot(...): Target container is not a DOM element.");
|
||
}
|
||
warnIfReactDOMContainerInDEV(container);
|
||
var isStrictMode = false;
|
||
var concurrentUpdatesByDefaultOverride = false;
|
||
var identifierPrefix = "";
|
||
var onRecoverableError = defaultOnRecoverableError;
|
||
var transitionCallbacks = null;
|
||
if (options2 !== null && options2 !== void 0) {
|
||
{
|
||
if (options2.hydrate) {
|
||
warn("hydrate through createRoot is deprecated. Use ReactDOMClient.hydrateRoot(container, <App />) instead.");
|
||
} else {
|
||
if (typeof options2 === "object" && options2 !== null && options2.$$typeof === REACT_ELEMENT_TYPE) {
|
||
error("You passed a JSX element to createRoot. You probably meant to call root.render instead. Example usage:\n\n let root = createRoot(domContainer);\n root.render(<App />);");
|
||
}
|
||
}
|
||
}
|
||
if (options2.unstable_strictMode === true) {
|
||
isStrictMode = true;
|
||
}
|
||
if (options2.identifierPrefix !== void 0) {
|
||
identifierPrefix = options2.identifierPrefix;
|
||
}
|
||
if (options2.onRecoverableError !== void 0) {
|
||
onRecoverableError = options2.onRecoverableError;
|
||
}
|
||
if (options2.transitionCallbacks !== void 0) {
|
||
transitionCallbacks = options2.transitionCallbacks;
|
||
}
|
||
}
|
||
var root2 = createContainer(container, ConcurrentRoot, null, isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, onRecoverableError);
|
||
markContainerAsRoot(root2.current, container);
|
||
var rootContainerElement = container.nodeType === COMMENT_NODE ? container.parentNode : container;
|
||
listenToAllSupportedEvents(rootContainerElement);
|
||
return new ReactDOMRoot(root2);
|
||
}
|
||
function ReactDOMHydrationRoot(internalRoot) {
|
||
this._internalRoot = internalRoot;
|
||
}
|
||
function scheduleHydration(target) {
|
||
if (target) {
|
||
queueExplicitHydrationTarget(target);
|
||
}
|
||
}
|
||
ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = scheduleHydration;
|
||
function hydrateRoot(container, initialChildren, options2) {
|
||
if (!isValidContainer(container)) {
|
||
throw new Error("hydrateRoot(...): Target container is not a DOM element.");
|
||
}
|
||
warnIfReactDOMContainerInDEV(container);
|
||
{
|
||
if (initialChildren === void 0) {
|
||
error("Must provide initial children as second argument to hydrateRoot. Example usage: hydrateRoot(domContainer, <App />)");
|
||
}
|
||
}
|
||
var hydrationCallbacks = options2 != null ? options2 : null;
|
||
var mutableSources = options2 != null && options2.hydratedSources || null;
|
||
var isStrictMode = false;
|
||
var concurrentUpdatesByDefaultOverride = false;
|
||
var identifierPrefix = "";
|
||
var onRecoverableError = defaultOnRecoverableError;
|
||
if (options2 !== null && options2 !== void 0) {
|
||
if (options2.unstable_strictMode === true) {
|
||
isStrictMode = true;
|
||
}
|
||
if (options2.identifierPrefix !== void 0) {
|
||
identifierPrefix = options2.identifierPrefix;
|
||
}
|
||
if (options2.onRecoverableError !== void 0) {
|
||
onRecoverableError = options2.onRecoverableError;
|
||
}
|
||
}
|
||
var root2 = createHydrationContainer(initialChildren, null, container, ConcurrentRoot, hydrationCallbacks, isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, onRecoverableError);
|
||
markContainerAsRoot(root2.current, container);
|
||
listenToAllSupportedEvents(container);
|
||
if (mutableSources) {
|
||
for (var i = 0; i < mutableSources.length; i++) {
|
||
var mutableSource = mutableSources[i];
|
||
registerMutableSourceForHydration(root2, mutableSource);
|
||
}
|
||
}
|
||
return new ReactDOMHydrationRoot(root2);
|
||
}
|
||
function isValidContainer(node) {
|
||
return !!(node && (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE || !disableCommentsAsDOMContainers));
|
||
}
|
||
function isValidContainerLegacy(node) {
|
||
return !!(node && (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE || node.nodeType === COMMENT_NODE && node.nodeValue === " react-mount-point-unstable "));
|
||
}
|
||
function warnIfReactDOMContainerInDEV(container) {
|
||
{
|
||
if (container.nodeType === ELEMENT_NODE && container.tagName && container.tagName.toUpperCase() === "BODY") {
|
||
error("createRoot(): Creating roots directly with document.body is discouraged, since its children are often manipulated by third-party scripts and browser extensions. This may lead to subtle reconciliation issues. Try using a container element created for your app.");
|
||
}
|
||
if (isContainerMarkedAsRoot(container)) {
|
||
if (container._reactRootContainer) {
|
||
error("You are calling ReactDOMClient.createRoot() on a container that was previously passed to ReactDOM.render(). This is not supported.");
|
||
} else {
|
||
error("You are calling ReactDOMClient.createRoot() on a container that has already been passed to createRoot() before. Instead, call root.render() on the existing root instead if you want to update it.");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner;
|
||
var topLevelUpdateWarnings;
|
||
{
|
||
topLevelUpdateWarnings = function(container) {
|
||
if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) {
|
||
var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer.current);
|
||
if (hostInstance) {
|
||
if (hostInstance.parentNode !== container) {
|
||
error("render(...): It looks like the React-rendered content of this container was removed without using React. This is not supported and will cause errors. Instead, call ReactDOM.unmountComponentAtNode to empty a container.");
|
||
}
|
||
}
|
||
}
|
||
var isRootRenderedBySomeReact = !!container._reactRootContainer;
|
||
var rootEl = getReactRootElementInContainer(container);
|
||
var hasNonRootReactChild = !!(rootEl && getInstanceFromNode(rootEl));
|
||
if (hasNonRootReactChild && !isRootRenderedBySomeReact) {
|
||
error("render(...): Replacing React-rendered children with a new root component. If you intended to update the children of this node, you should instead have the existing children update their state and render the new components instead of calling ReactDOM.render.");
|
||
}
|
||
if (container.nodeType === ELEMENT_NODE && container.tagName && container.tagName.toUpperCase() === "BODY") {
|
||
error("render(): Rendering components directly into document.body is discouraged, since its children are often manipulated by third-party scripts and browser extensions. This may lead to subtle reconciliation issues. Try rendering into a container element created for your app.");
|
||
}
|
||
};
|
||
}
|
||
function getReactRootElementInContainer(container) {
|
||
if (!container) {
|
||
return null;
|
||
}
|
||
if (container.nodeType === DOCUMENT_NODE) {
|
||
return container.documentElement;
|
||
} else {
|
||
return container.firstChild;
|
||
}
|
||
}
|
||
function noopOnRecoverableError() {
|
||
}
|
||
function legacyCreateRootFromDOMContainer(container, initialChildren, parentComponent, callback, isHydrationContainer) {
|
||
if (isHydrationContainer) {
|
||
if (typeof callback === "function") {
|
||
var originalCallback = callback;
|
||
callback = function() {
|
||
var instance = getPublicRootInstance(root2);
|
||
originalCallback.call(instance);
|
||
};
|
||
}
|
||
var root2 = createHydrationContainer(initialChildren, callback, container, LegacyRoot, null, false, false, "", noopOnRecoverableError);
|
||
container._reactRootContainer = root2;
|
||
markContainerAsRoot(root2.current, container);
|
||
var rootContainerElement = container.nodeType === COMMENT_NODE ? container.parentNode : container;
|
||
listenToAllSupportedEvents(rootContainerElement);
|
||
flushSync();
|
||
return root2;
|
||
} else {
|
||
var rootSibling;
|
||
while (rootSibling = container.lastChild) {
|
||
container.removeChild(rootSibling);
|
||
}
|
||
if (typeof callback === "function") {
|
||
var _originalCallback = callback;
|
||
callback = function() {
|
||
var instance = getPublicRootInstance(_root);
|
||
_originalCallback.call(instance);
|
||
};
|
||
}
|
||
var _root = createContainer(container, LegacyRoot, null, false, false, "", noopOnRecoverableError);
|
||
container._reactRootContainer = _root;
|
||
markContainerAsRoot(_root.current, container);
|
||
var _rootContainerElement = container.nodeType === COMMENT_NODE ? container.parentNode : container;
|
||
listenToAllSupportedEvents(_rootContainerElement);
|
||
flushSync(function() {
|
||
updateContainer(initialChildren, _root, parentComponent, callback);
|
||
});
|
||
return _root;
|
||
}
|
||
}
|
||
function warnOnInvalidCallback$1(callback, callerName) {
|
||
{
|
||
if (callback !== null && typeof callback !== "function") {
|
||
error("%s(...): Expected the last optional `callback` argument to be a function. Instead received: %s.", callerName, callback);
|
||
}
|
||
}
|
||
}
|
||
function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) {
|
||
{
|
||
topLevelUpdateWarnings(container);
|
||
warnOnInvalidCallback$1(callback === void 0 ? null : callback, "render");
|
||
}
|
||
var maybeRoot = container._reactRootContainer;
|
||
var root2;
|
||
if (!maybeRoot) {
|
||
root2 = legacyCreateRootFromDOMContainer(container, children, parentComponent, callback, forceHydrate);
|
||
} else {
|
||
root2 = maybeRoot;
|
||
if (typeof callback === "function") {
|
||
var originalCallback = callback;
|
||
callback = function() {
|
||
var instance = getPublicRootInstance(root2);
|
||
originalCallback.call(instance);
|
||
};
|
||
}
|
||
updateContainer(children, root2, parentComponent, callback);
|
||
}
|
||
return getPublicRootInstance(root2);
|
||
}
|
||
function findDOMNode(componentOrElement) {
|
||
{
|
||
var owner = ReactCurrentOwner$3.current;
|
||
if (owner !== null && owner.stateNode !== null) {
|
||
var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender;
|
||
if (!warnedAboutRefsInRender) {
|
||
error("%s is accessing findDOMNode inside its render(). render() should be a pure function of props and state. It should never access something that requires stale data from the previous render, such as refs. Move this logic to componentDidMount and componentDidUpdate instead.", getComponentNameFromType(owner.type) || "A component");
|
||
}
|
||
owner.stateNode._warnedAboutRefsInRender = true;
|
||
}
|
||
}
|
||
if (componentOrElement == null) {
|
||
return null;
|
||
}
|
||
if (componentOrElement.nodeType === ELEMENT_NODE) {
|
||
return componentOrElement;
|
||
}
|
||
{
|
||
return findHostInstanceWithWarning(componentOrElement, "findDOMNode");
|
||
}
|
||
}
|
||
function hydrate(element, container, callback) {
|
||
{
|
||
error("ReactDOM.hydrate is no longer supported in React 18. Use hydrateRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot");
|
||
}
|
||
if (!isValidContainerLegacy(container)) {
|
||
throw new Error("Target container is not a DOM element.");
|
||
}
|
||
{
|
||
var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === void 0;
|
||
if (isModernRoot) {
|
||
error("You are calling ReactDOM.hydrate() on a container that was previously passed to ReactDOMClient.createRoot(). This is not supported. Did you mean to call hydrateRoot(container, element)?");
|
||
}
|
||
}
|
||
return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);
|
||
}
|
||
function render2(element, container, callback) {
|
||
{
|
||
error("ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot");
|
||
}
|
||
if (!isValidContainerLegacy(container)) {
|
||
throw new Error("Target container is not a DOM element.");
|
||
}
|
||
{
|
||
var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === void 0;
|
||
if (isModernRoot) {
|
||
error("You are calling ReactDOM.render() on a container that was previously passed to ReactDOMClient.createRoot(). This is not supported. Did you mean to call root.render(element)?");
|
||
}
|
||
}
|
||
return legacyRenderSubtreeIntoContainer(null, element, container, false, callback);
|
||
}
|
||
function unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) {
|
||
{
|
||
error("ReactDOM.unstable_renderSubtreeIntoContainer() is no longer supported in React 18. Consider using a portal instead. Until you switch to the createRoot API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot");
|
||
}
|
||
if (!isValidContainerLegacy(containerNode)) {
|
||
throw new Error("Target container is not a DOM element.");
|
||
}
|
||
if (parentComponent == null || !has(parentComponent)) {
|
||
throw new Error("parentComponent must be a valid React Component");
|
||
}
|
||
return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback);
|
||
}
|
||
function unmountComponentAtNode2(container) {
|
||
if (!isValidContainerLegacy(container)) {
|
||
throw new Error("unmountComponentAtNode(...): Target container is not a DOM element.");
|
||
}
|
||
{
|
||
var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === void 0;
|
||
if (isModernRoot) {
|
||
error("You are calling ReactDOM.unmountComponentAtNode() on a container that was previously passed to ReactDOMClient.createRoot(). This is not supported. Did you mean to call root.unmount()?");
|
||
}
|
||
}
|
||
if (container._reactRootContainer) {
|
||
{
|
||
var rootEl = getReactRootElementInContainer(container);
|
||
var renderedByDifferentReact = rootEl && !getInstanceFromNode(rootEl);
|
||
if (renderedByDifferentReact) {
|
||
error("unmountComponentAtNode(): The node you're attempting to unmount was rendered by another copy of React.");
|
||
}
|
||
}
|
||
flushSync(function() {
|
||
legacyRenderSubtreeIntoContainer(null, null, container, false, function() {
|
||
container._reactRootContainer = null;
|
||
unmarkContainerAsRoot(container);
|
||
});
|
||
});
|
||
return true;
|
||
} else {
|
||
{
|
||
var _rootEl = getReactRootElementInContainer(container);
|
||
var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode(_rootEl));
|
||
var isContainerReactRoot = container.nodeType === ELEMENT_NODE && isValidContainerLegacy(container.parentNode) && !!container.parentNode._reactRootContainer;
|
||
if (hasNonRootReactChild) {
|
||
error("unmountComponentAtNode(): The node you're attempting to unmount was rendered by React and is not a top-level container. %s", isContainerReactRoot ? "You may have accidentally passed in a React root node instead of its container." : "Instead, have the parent component update its state and rerender in order to remove this component.");
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
setAttemptSynchronousHydration(attemptSynchronousHydration$1);
|
||
setAttemptContinuousHydration(attemptContinuousHydration$1);
|
||
setAttemptHydrationAtCurrentPriority(attemptHydrationAtCurrentPriority$1);
|
||
setGetCurrentUpdatePriority(getCurrentUpdatePriority);
|
||
setAttemptHydrationAtPriority(runWithPriority);
|
||
{
|
||
if (typeof Map !== "function" || Map.prototype == null || typeof Map.prototype.forEach !== "function" || typeof Set !== "function" || Set.prototype == null || typeof Set.prototype.clear !== "function" || typeof Set.prototype.forEach !== "function") {
|
||
error("React depends on Map and Set built-in types. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills");
|
||
}
|
||
}
|
||
setRestoreImplementation(restoreControlledState$3);
|
||
setBatchingImplementation(batchedUpdates$1, discreteUpdates, flushSync);
|
||
function createPortal$1(children, container) {
|
||
var key = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
|
||
if (!isValidContainer(container)) {
|
||
throw new Error("Target container is not a DOM element.");
|
||
}
|
||
return createPortal(children, container, null, key);
|
||
}
|
||
function renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) {
|
||
return unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback);
|
||
}
|
||
var Internals = {
|
||
usingClientEntryPoint: false,
|
||
Events: [getInstanceFromNode, getNodeFromInstance, getFiberCurrentPropsFromNode, enqueueStateRestore, restoreStateIfNeeded, batchedUpdates$1]
|
||
};
|
||
function createRoot$1(container, options2) {
|
||
{
|
||
if (!Internals.usingClientEntryPoint && true) {
|
||
error('You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".');
|
||
}
|
||
}
|
||
return createRoot(container, options2);
|
||
}
|
||
function hydrateRoot$1(container, initialChildren, options2) {
|
||
{
|
||
if (!Internals.usingClientEntryPoint && true) {
|
||
error('You are importing hydrateRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".');
|
||
}
|
||
}
|
||
return hydrateRoot(container, initialChildren, options2);
|
||
}
|
||
function flushSync$1(fn) {
|
||
{
|
||
if (isAlreadyRendering()) {
|
||
error("flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task.");
|
||
}
|
||
}
|
||
return flushSync(fn);
|
||
}
|
||
var foundDevTools = injectIntoDevTools({
|
||
findFiberByHostInstance: getClosestInstanceFromNode,
|
||
bundleType: 1,
|
||
version: ReactVersion,
|
||
rendererPackageName: "react-dom"
|
||
});
|
||
{
|
||
if (!foundDevTools && canUseDOM && window.top === window.self) {
|
||
if (navigator.userAgent.indexOf("Chrome") > -1 && navigator.userAgent.indexOf("Edge") === -1 || navigator.userAgent.indexOf("Firefox") > -1) {
|
||
var protocol = window.location.protocol;
|
||
if (/^(https?|file):$/.test(protocol)) {
|
||
console.info("%cDownload the React DevTools for a better development experience: https://reactjs.org/link/react-devtools" + (protocol === "file:" ? "\nYou might need to use a local HTTP server (instead of file://): https://reactjs.org/link/react-devtools-faq" : ""), "font-weight:bold");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
|
||
exports.createPortal = createPortal$1;
|
||
exports.createRoot = createRoot$1;
|
||
exports.findDOMNode = findDOMNode;
|
||
exports.flushSync = flushSync$1;
|
||
exports.hydrate = hydrate;
|
||
exports.hydrateRoot = hydrateRoot$1;
|
||
exports.render = render2;
|
||
exports.unmountComponentAtNode = unmountComponentAtNode2;
|
||
exports.unstable_batchedUpdates = batchedUpdates$1;
|
||
exports.unstable_renderSubtreeIntoContainer = renderSubtreeIntoContainer;
|
||
exports.version = ReactVersion;
|
||
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
|
||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
||
}
|
||
})();
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/react-dom/index.js
|
||
var require_react_dom = __commonJS({
|
||
"node_modules/react-dom/index.js"(exports, module2) {
|
||
"use strict";
|
||
if (false) {
|
||
checkDCE();
|
||
module2.exports = null;
|
||
} else {
|
||
module2.exports = require_react_dom_development();
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/react-is/cjs/react-is.development.js
|
||
var require_react_is_development = __commonJS({
|
||
"node_modules/react-is/cjs/react-is.development.js"(exports) {
|
||
"use strict";
|
||
if (true) {
|
||
(function() {
|
||
"use strict";
|
||
var hasSymbol = typeof Symbol === "function" && Symbol.for;
|
||
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103;
|
||
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106;
|
||
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107;
|
||
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108;
|
||
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114;
|
||
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109;
|
||
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110;
|
||
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 60111;
|
||
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for("react.concurrent_mode") : 60111;
|
||
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112;
|
||
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113;
|
||
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for("react.suspense_list") : 60120;
|
||
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115;
|
||
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116;
|
||
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121;
|
||
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for("react.fundamental") : 60117;
|
||
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for("react.responder") : 60118;
|
||
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for("react.scope") : 60119;
|
||
function isValidElementType(type) {
|
||
return typeof type === "string" || typeof type === "function" || type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === "object" && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
||
}
|
||
function typeOf(object) {
|
||
if (typeof object === "object" && object !== null) {
|
||
var $$typeof = object.$$typeof;
|
||
switch ($$typeof) {
|
||
case REACT_ELEMENT_TYPE:
|
||
var type = object.type;
|
||
switch (type) {
|
||
case REACT_ASYNC_MODE_TYPE:
|
||
case REACT_CONCURRENT_MODE_TYPE:
|
||
case REACT_FRAGMENT_TYPE:
|
||
case REACT_PROFILER_TYPE:
|
||
case REACT_STRICT_MODE_TYPE:
|
||
case REACT_SUSPENSE_TYPE:
|
||
return type;
|
||
default:
|
||
var $$typeofType = type && type.$$typeof;
|
||
switch ($$typeofType) {
|
||
case REACT_CONTEXT_TYPE:
|
||
case REACT_FORWARD_REF_TYPE:
|
||
case REACT_LAZY_TYPE:
|
||
case REACT_MEMO_TYPE:
|
||
case REACT_PROVIDER_TYPE:
|
||
return $$typeofType;
|
||
default:
|
||
return $$typeof;
|
||
}
|
||
}
|
||
case REACT_PORTAL_TYPE:
|
||
return $$typeof;
|
||
}
|
||
}
|
||
return void 0;
|
||
}
|
||
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
||
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
||
var ContextConsumer = REACT_CONTEXT_TYPE;
|
||
var ContextProvider = REACT_PROVIDER_TYPE;
|
||
var Element2 = REACT_ELEMENT_TYPE;
|
||
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
||
var Fragment = REACT_FRAGMENT_TYPE;
|
||
var Lazy = REACT_LAZY_TYPE;
|
||
var Memo = REACT_MEMO_TYPE;
|
||
var Portal = REACT_PORTAL_TYPE;
|
||
var Profiler = REACT_PROFILER_TYPE;
|
||
var StrictMode = REACT_STRICT_MODE_TYPE;
|
||
var Suspense = REACT_SUSPENSE_TYPE;
|
||
var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
||
function isAsyncMode(object) {
|
||
{
|
||
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
||
hasWarnedAboutDeprecatedIsAsyncMode = true;
|
||
console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.");
|
||
}
|
||
}
|
||
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
||
}
|
||
function isConcurrentMode(object) {
|
||
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
||
}
|
||
function isContextConsumer(object) {
|
||
return typeOf(object) === REACT_CONTEXT_TYPE;
|
||
}
|
||
function isContextProvider(object) {
|
||
return typeOf(object) === REACT_PROVIDER_TYPE;
|
||
}
|
||
function isElement(object) {
|
||
return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
||
}
|
||
function isForwardRef(object) {
|
||
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
||
}
|
||
function isFragment(object) {
|
||
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
||
}
|
||
function isLazy(object) {
|
||
return typeOf(object) === REACT_LAZY_TYPE;
|
||
}
|
||
function isMemo(object) {
|
||
return typeOf(object) === REACT_MEMO_TYPE;
|
||
}
|
||
function isPortal(object) {
|
||
return typeOf(object) === REACT_PORTAL_TYPE;
|
||
}
|
||
function isProfiler(object) {
|
||
return typeOf(object) === REACT_PROFILER_TYPE;
|
||
}
|
||
function isStrictMode(object) {
|
||
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
||
}
|
||
function isSuspense(object) {
|
||
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
||
}
|
||
exports.AsyncMode = AsyncMode;
|
||
exports.ConcurrentMode = ConcurrentMode;
|
||
exports.ContextConsumer = ContextConsumer;
|
||
exports.ContextProvider = ContextProvider;
|
||
exports.Element = Element2;
|
||
exports.ForwardRef = ForwardRef;
|
||
exports.Fragment = Fragment;
|
||
exports.Lazy = Lazy;
|
||
exports.Memo = Memo;
|
||
exports.Portal = Portal;
|
||
exports.Profiler = Profiler;
|
||
exports.StrictMode = StrictMode;
|
||
exports.Suspense = Suspense;
|
||
exports.isAsyncMode = isAsyncMode;
|
||
exports.isConcurrentMode = isConcurrentMode;
|
||
exports.isContextConsumer = isContextConsumer;
|
||
exports.isContextProvider = isContextProvider;
|
||
exports.isElement = isElement;
|
||
exports.isForwardRef = isForwardRef;
|
||
exports.isFragment = isFragment;
|
||
exports.isLazy = isLazy;
|
||
exports.isMemo = isMemo;
|
||
exports.isPortal = isPortal;
|
||
exports.isProfiler = isProfiler;
|
||
exports.isStrictMode = isStrictMode;
|
||
exports.isSuspense = isSuspense;
|
||
exports.isValidElementType = isValidElementType;
|
||
exports.typeOf = typeOf;
|
||
})();
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/react-is/index.js
|
||
var require_react_is = __commonJS({
|
||
"node_modules/react-is/index.js"(exports, module2) {
|
||
"use strict";
|
||
if (false) {
|
||
module2.exports = null;
|
||
} else {
|
||
module2.exports = require_react_is_development();
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/object-assign/index.js
|
||
var require_object_assign = __commonJS({
|
||
"node_modules/object-assign/index.js"(exports, module2) {
|
||
"use strict";
|
||
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
||
var hasOwnProperty2 = Object.prototype.hasOwnProperty;
|
||
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
||
function toObject(val) {
|
||
if (val === null || val === void 0) {
|
||
throw new TypeError("Object.assign cannot be called with null or undefined");
|
||
}
|
||
return Object(val);
|
||
}
|
||
function shouldUseNative() {
|
||
try {
|
||
if (!Object.assign) {
|
||
return false;
|
||
}
|
||
var test1 = new String("abc");
|
||
test1[5] = "de";
|
||
if (Object.getOwnPropertyNames(test1)[0] === "5") {
|
||
return false;
|
||
}
|
||
var test2 = {};
|
||
for (var i = 0; i < 10; i++) {
|
||
test2["_" + String.fromCharCode(i)] = i;
|
||
}
|
||
var order2 = Object.getOwnPropertyNames(test2).map(function(n) {
|
||
return test2[n];
|
||
});
|
||
if (order2.join("") !== "0123456789") {
|
||
return false;
|
||
}
|
||
var test3 = {};
|
||
"abcdefghijklmnopqrst".split("").forEach(function(letter) {
|
||
test3[letter] = letter;
|
||
});
|
||
if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") {
|
||
return false;
|
||
}
|
||
return true;
|
||
} catch (err) {
|
||
return false;
|
||
}
|
||
}
|
||
module2.exports = shouldUseNative() ? Object.assign : function(target, source) {
|
||
var from;
|
||
var to = toObject(target);
|
||
var symbols;
|
||
for (var s = 1; s < arguments.length; s++) {
|
||
from = Object(arguments[s]);
|
||
for (var key in from) {
|
||
if (hasOwnProperty2.call(from, key)) {
|
||
to[key] = from[key];
|
||
}
|
||
}
|
||
if (getOwnPropertySymbols) {
|
||
symbols = getOwnPropertySymbols(from);
|
||
for (var i = 0; i < symbols.length; i++) {
|
||
if (propIsEnumerable.call(from, symbols[i])) {
|
||
to[symbols[i]] = from[symbols[i]];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return to;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/prop-types/lib/ReactPropTypesSecret.js
|
||
var require_ReactPropTypesSecret = __commonJS({
|
||
"node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module2) {
|
||
"use strict";
|
||
var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
|
||
module2.exports = ReactPropTypesSecret;
|
||
}
|
||
});
|
||
|
||
// node_modules/prop-types/lib/has.js
|
||
var require_has = __commonJS({
|
||
"node_modules/prop-types/lib/has.js"(exports, module2) {
|
||
module2.exports = Function.call.bind(Object.prototype.hasOwnProperty);
|
||
}
|
||
});
|
||
|
||
// node_modules/prop-types/checkPropTypes.js
|
||
var require_checkPropTypes = __commonJS({
|
||
"node_modules/prop-types/checkPropTypes.js"(exports, module2) {
|
||
"use strict";
|
||
var printWarning = function() {
|
||
};
|
||
if (true) {
|
||
ReactPropTypesSecret = require_ReactPropTypesSecret();
|
||
loggedTypeFailures = {};
|
||
has = require_has();
|
||
printWarning = function(text) {
|
||
var message = "Warning: " + text;
|
||
if (typeof console !== "undefined") {
|
||
console.error(message);
|
||
}
|
||
try {
|
||
throw new Error(message);
|
||
} catch (x) {
|
||
}
|
||
};
|
||
}
|
||
var ReactPropTypesSecret;
|
||
var loggedTypeFailures;
|
||
var has;
|
||
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
||
if (true) {
|
||
for (var typeSpecName in typeSpecs) {
|
||
if (has(typeSpecs, typeSpecName)) {
|
||
var error;
|
||
try {
|
||
if (typeof typeSpecs[typeSpecName] !== "function") {
|
||
var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
||
err.name = "Invariant Violation";
|
||
throw err;
|
||
}
|
||
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
||
} catch (ex) {
|
||
error = ex;
|
||
}
|
||
if (error && !(error instanceof Error)) {
|
||
printWarning((componentName || "React class") + ": type specification of " + location + " `" + typeSpecName + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + typeof error + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).");
|
||
}
|
||
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
||
loggedTypeFailures[error.message] = true;
|
||
var stack = getStack ? getStack() : "";
|
||
printWarning("Failed " + location + " type: " + error.message + (stack != null ? stack : ""));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
checkPropTypes.resetWarningCache = function() {
|
||
if (true) {
|
||
loggedTypeFailures = {};
|
||
}
|
||
};
|
||
module2.exports = checkPropTypes;
|
||
}
|
||
});
|
||
|
||
// node_modules/prop-types/factoryWithTypeCheckers.js
|
||
var require_factoryWithTypeCheckers = __commonJS({
|
||
"node_modules/prop-types/factoryWithTypeCheckers.js"(exports, module2) {
|
||
"use strict";
|
||
var ReactIs = require_react_is();
|
||
var assign = require_object_assign();
|
||
var ReactPropTypesSecret = require_ReactPropTypesSecret();
|
||
var has = require_has();
|
||
var checkPropTypes = require_checkPropTypes();
|
||
var printWarning = function() {
|
||
};
|
||
if (true) {
|
||
printWarning = function(text) {
|
||
var message = "Warning: " + text;
|
||
if (typeof console !== "undefined") {
|
||
console.error(message);
|
||
}
|
||
try {
|
||
throw new Error(message);
|
||
} catch (x) {
|
||
}
|
||
};
|
||
}
|
||
function emptyFunctionThatReturnsNull() {
|
||
return null;
|
||
}
|
||
module2.exports = function(isValidElement, throwOnDirectAccess) {
|
||
var ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
|
||
var FAUX_ITERATOR_SYMBOL = "@@iterator";
|
||
function getIteratorFn(maybeIterable) {
|
||
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
||
if (typeof iteratorFn === "function") {
|
||
return iteratorFn;
|
||
}
|
||
}
|
||
var ANONYMOUS = "<<anonymous>>";
|
||
var ReactPropTypes = {
|
||
array: createPrimitiveTypeChecker("array"),
|
||
bigint: createPrimitiveTypeChecker("bigint"),
|
||
bool: createPrimitiveTypeChecker("boolean"),
|
||
func: createPrimitiveTypeChecker("function"),
|
||
number: createPrimitiveTypeChecker("number"),
|
||
object: createPrimitiveTypeChecker("object"),
|
||
string: createPrimitiveTypeChecker("string"),
|
||
symbol: createPrimitiveTypeChecker("symbol"),
|
||
any: createAnyTypeChecker(),
|
||
arrayOf: createArrayOfTypeChecker,
|
||
element: createElementTypeChecker(),
|
||
elementType: createElementTypeTypeChecker(),
|
||
instanceOf: createInstanceTypeChecker,
|
||
node: createNodeChecker(),
|
||
objectOf: createObjectOfTypeChecker,
|
||
oneOf: createEnumTypeChecker,
|
||
oneOfType: createUnionTypeChecker,
|
||
shape: createShapeTypeChecker,
|
||
exact: createStrictShapeTypeChecker
|
||
};
|
||
function is(x, y) {
|
||
if (x === y) {
|
||
return x !== 0 || 1 / x === 1 / y;
|
||
} else {
|
||
return x !== x && y !== y;
|
||
}
|
||
}
|
||
function PropTypeError(message, data) {
|
||
this.message = message;
|
||
this.data = data && typeof data === "object" ? data : {};
|
||
this.stack = "";
|
||
}
|
||
PropTypeError.prototype = Error.prototype;
|
||
function createChainableTypeChecker(validate) {
|
||
if (true) {
|
||
var manualPropTypeCallCache = {};
|
||
var manualPropTypeWarningCount = 0;
|
||
}
|
||
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
||
componentName = componentName || ANONYMOUS;
|
||
propFullName = propFullName || propName;
|
||
if (secret !== ReactPropTypesSecret) {
|
||
if (throwOnDirectAccess) {
|
||
var err = new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");
|
||
err.name = "Invariant Violation";
|
||
throw err;
|
||
} else if (typeof console !== "undefined") {
|
||
var cacheKey = componentName + ":" + propName;
|
||
if (!manualPropTypeCallCache[cacheKey] && manualPropTypeWarningCount < 3) {
|
||
printWarning("You are manually calling a React.PropTypes validation function for the `" + propFullName + "` prop on `" + componentName + "`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.");
|
||
manualPropTypeCallCache[cacheKey] = true;
|
||
manualPropTypeWarningCount++;
|
||
}
|
||
}
|
||
}
|
||
if (props[propName] == null) {
|
||
if (isRequired) {
|
||
if (props[propName] === null) {
|
||
return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required " + ("in `" + componentName + "`, but its value is `null`."));
|
||
}
|
||
return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required in " + ("`" + componentName + "`, but its value is `undefined`."));
|
||
}
|
||
return null;
|
||
} else {
|
||
return validate(props, propName, componentName, location, propFullName);
|
||
}
|
||
}
|
||
var chainedCheckType = checkType.bind(null, false);
|
||
chainedCheckType.isRequired = checkType.bind(null, true);
|
||
return chainedCheckType;
|
||
}
|
||
function createPrimitiveTypeChecker(expectedType) {
|
||
function validate(props, propName, componentName, location, propFullName, secret) {
|
||
var propValue = props[propName];
|
||
var propType = getPropType(propValue);
|
||
if (propType !== expectedType) {
|
||
var preciseType = getPreciseType(propValue);
|
||
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + preciseType + "` supplied to `" + componentName + "`, expected ") + ("`" + expectedType + "`."), { expectedType });
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
function createAnyTypeChecker() {
|
||
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
||
}
|
||
function createArrayOfTypeChecker(typeChecker) {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
if (typeof typeChecker !== "function") {
|
||
return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside arrayOf.");
|
||
}
|
||
var propValue = props[propName];
|
||
if (!Array.isArray(propValue)) {
|
||
var propType = getPropType(propValue);
|
||
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an array."));
|
||
}
|
||
for (var i = 0; i < propValue.length; i++) {
|
||
var error = typeChecker(propValue, i, componentName, location, propFullName + "[" + i + "]", ReactPropTypesSecret);
|
||
if (error instanceof Error) {
|
||
return error;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
function createElementTypeChecker() {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
var propValue = props[propName];
|
||
if (!isValidElement(propValue)) {
|
||
var propType = getPropType(propValue);
|
||
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement."));
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
function createElementTypeTypeChecker() {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
var propValue = props[propName];
|
||
if (!ReactIs.isValidElementType(propValue)) {
|
||
var propType = getPropType(propValue);
|
||
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement type."));
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
function createInstanceTypeChecker(expectedClass) {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
if (!(props[propName] instanceof expectedClass)) {
|
||
var expectedClassName = expectedClass.name || ANONYMOUS;
|
||
var actualClassName = getClassName(props[propName]);
|
||
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + actualClassName + "` supplied to `" + componentName + "`, expected ") + ("instance of `" + expectedClassName + "`."));
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
function createEnumTypeChecker(expectedValues) {
|
||
if (!Array.isArray(expectedValues)) {
|
||
if (true) {
|
||
if (arguments.length > 1) {
|
||
printWarning("Invalid arguments supplied to oneOf, expected an array, got " + arguments.length + " arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).");
|
||
} else {
|
||
printWarning("Invalid argument supplied to oneOf, expected an array.");
|
||
}
|
||
}
|
||
return emptyFunctionThatReturnsNull;
|
||
}
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
var propValue = props[propName];
|
||
for (var i = 0; i < expectedValues.length; i++) {
|
||
if (is(propValue, expectedValues[i])) {
|
||
return null;
|
||
}
|
||
}
|
||
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
||
var type = getPreciseType(value);
|
||
if (type === "symbol") {
|
||
return String(value);
|
||
}
|
||
return value;
|
||
});
|
||
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of value `" + String(propValue) + "` " + ("supplied to `" + componentName + "`, expected one of " + valuesString + "."));
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
function createObjectOfTypeChecker(typeChecker) {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
if (typeof typeChecker !== "function") {
|
||
return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside objectOf.");
|
||
}
|
||
var propValue = props[propName];
|
||
var propType = getPropType(propValue);
|
||
if (propType !== "object") {
|
||
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an object."));
|
||
}
|
||
for (var key in propValue) {
|
||
if (has(propValue, key)) {
|
||
var error = typeChecker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
|
||
if (error instanceof Error) {
|
||
return error;
|
||
}
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
||
if (!Array.isArray(arrayOfTypeCheckers)) {
|
||
true ? printWarning("Invalid argument supplied to oneOfType, expected an instance of array.") : void 0;
|
||
return emptyFunctionThatReturnsNull;
|
||
}
|
||
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
||
var checker = arrayOfTypeCheckers[i];
|
||
if (typeof checker !== "function") {
|
||
printWarning("Invalid argument supplied to oneOfType. Expected an array of check functions, but received " + getPostfixForTypeWarning(checker) + " at index " + i + ".");
|
||
return emptyFunctionThatReturnsNull;
|
||
}
|
||
}
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
var expectedTypes = [];
|
||
for (var i2 = 0; i2 < arrayOfTypeCheckers.length; i2++) {
|
||
var checker2 = arrayOfTypeCheckers[i2];
|
||
var checkerResult = checker2(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
|
||
if (checkerResult == null) {
|
||
return null;
|
||
}
|
||
if (checkerResult.data && has(checkerResult.data, "expectedType")) {
|
||
expectedTypes.push(checkerResult.data.expectedType);
|
||
}
|
||
}
|
||
var expectedTypesMessage = expectedTypes.length > 0 ? ", expected one of type [" + expectedTypes.join(", ") + "]" : "";
|
||
return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`" + expectedTypesMessage + "."));
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
function createNodeChecker() {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
if (!isNode(props[propName])) {
|
||
return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`, expected a ReactNode."));
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
function invalidValidatorError(componentName, location, propFullName, key, type) {
|
||
return new PropTypeError((componentName || "React class") + ": " + location + " type `" + propFullName + "." + key + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + type + "`.");
|
||
}
|
||
function createShapeTypeChecker(shapeTypes) {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
var propValue = props[propName];
|
||
var propType = getPropType(propValue);
|
||
if (propType !== "object") {
|
||
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
|
||
}
|
||
for (var key in shapeTypes) {
|
||
var checker = shapeTypes[key];
|
||
if (typeof checker !== "function") {
|
||
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
||
}
|
||
var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
|
||
if (error) {
|
||
return error;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
function createStrictShapeTypeChecker(shapeTypes) {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
var propValue = props[propName];
|
||
var propType = getPropType(propValue);
|
||
if (propType !== "object") {
|
||
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
|
||
}
|
||
var allKeys = assign({}, props[propName], shapeTypes);
|
||
for (var key in allKeys) {
|
||
var checker = shapeTypes[key];
|
||
if (has(shapeTypes, key) && typeof checker !== "function") {
|
||
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
||
}
|
||
if (!checker) {
|
||
return new PropTypeError("Invalid " + location + " `" + propFullName + "` key `" + key + "` supplied to `" + componentName + "`.\nBad object: " + JSON.stringify(props[propName], null, " ") + "\nValid keys: " + JSON.stringify(Object.keys(shapeTypes), null, " "));
|
||
}
|
||
var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
|
||
if (error) {
|
||
return error;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
function isNode(propValue) {
|
||
switch (typeof propValue) {
|
||
case "number":
|
||
case "string":
|
||
case "undefined":
|
||
return true;
|
||
case "boolean":
|
||
return !propValue;
|
||
case "object":
|
||
if (Array.isArray(propValue)) {
|
||
return propValue.every(isNode);
|
||
}
|
||
if (propValue === null || isValidElement(propValue)) {
|
||
return true;
|
||
}
|
||
var iteratorFn = getIteratorFn(propValue);
|
||
if (iteratorFn) {
|
||
var iterator = iteratorFn.call(propValue);
|
||
var step;
|
||
if (iteratorFn !== propValue.entries) {
|
||
while (!(step = iterator.next()).done) {
|
||
if (!isNode(step.value)) {
|
||
return false;
|
||
}
|
||
}
|
||
} else {
|
||
while (!(step = iterator.next()).done) {
|
||
var entry = step.value;
|
||
if (entry) {
|
||
if (!isNode(entry[1])) {
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
return false;
|
||
}
|
||
return true;
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
function isSymbol(propType, propValue) {
|
||
if (propType === "symbol") {
|
||
return true;
|
||
}
|
||
if (!propValue) {
|
||
return false;
|
||
}
|
||
if (propValue["@@toStringTag"] === "Symbol") {
|
||
return true;
|
||
}
|
||
if (typeof Symbol === "function" && propValue instanceof Symbol) {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
function getPropType(propValue) {
|
||
var propType = typeof propValue;
|
||
if (Array.isArray(propValue)) {
|
||
return "array";
|
||
}
|
||
if (propValue instanceof RegExp) {
|
||
return "object";
|
||
}
|
||
if (isSymbol(propType, propValue)) {
|
||
return "symbol";
|
||
}
|
||
return propType;
|
||
}
|
||
function getPreciseType(propValue) {
|
||
if (typeof propValue === "undefined" || propValue === null) {
|
||
return "" + propValue;
|
||
}
|
||
var propType = getPropType(propValue);
|
||
if (propType === "object") {
|
||
if (propValue instanceof Date) {
|
||
return "date";
|
||
} else if (propValue instanceof RegExp) {
|
||
return "regexp";
|
||
}
|
||
}
|
||
return propType;
|
||
}
|
||
function getPostfixForTypeWarning(value) {
|
||
var type = getPreciseType(value);
|
||
switch (type) {
|
||
case "array":
|
||
case "object":
|
||
return "an " + type;
|
||
case "boolean":
|
||
case "date":
|
||
case "regexp":
|
||
return "a " + type;
|
||
default:
|
||
return type;
|
||
}
|
||
}
|
||
function getClassName(propValue) {
|
||
if (!propValue.constructor || !propValue.constructor.name) {
|
||
return ANONYMOUS;
|
||
}
|
||
return propValue.constructor.name;
|
||
}
|
||
ReactPropTypes.checkPropTypes = checkPropTypes;
|
||
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
|
||
ReactPropTypes.PropTypes = ReactPropTypes;
|
||
return ReactPropTypes;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/prop-types/index.js
|
||
var require_prop_types = __commonJS({
|
||
"node_modules/prop-types/index.js"(exports, module2) {
|
||
if (true) {
|
||
ReactIs = require_react_is();
|
||
throwOnDirectAccess = true;
|
||
module2.exports = require_factoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
|
||
} else {
|
||
module2.exports = null();
|
||
}
|
||
var ReactIs;
|
||
var throwOnDirectAccess;
|
||
}
|
||
});
|
||
|
||
// node_modules/type/value/is.js
|
||
var require_is = __commonJS({
|
||
"node_modules/type/value/is.js"(exports, module2) {
|
||
"use strict";
|
||
var _undefined = void 0;
|
||
module2.exports = function(value) {
|
||
return value !== _undefined && value !== null;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/type/object/is.js
|
||
var require_is2 = __commonJS({
|
||
"node_modules/type/object/is.js"(exports, module2) {
|
||
"use strict";
|
||
var isValue = require_is();
|
||
var possibleTypes = { "object": true, "function": true, "undefined": true };
|
||
module2.exports = function(value) {
|
||
if (!isValue(value))
|
||
return false;
|
||
return hasOwnProperty.call(possibleTypes, typeof value);
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/type/prototype/is.js
|
||
var require_is3 = __commonJS({
|
||
"node_modules/type/prototype/is.js"(exports, module2) {
|
||
"use strict";
|
||
var isObject = require_is2();
|
||
module2.exports = function(value) {
|
||
if (!isObject(value))
|
||
return false;
|
||
try {
|
||
if (!value.constructor)
|
||
return false;
|
||
return value.constructor.prototype === value;
|
||
} catch (error) {
|
||
return false;
|
||
}
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/type/function/is.js
|
||
var require_is4 = __commonJS({
|
||
"node_modules/type/function/is.js"(exports, module2) {
|
||
"use strict";
|
||
var isPrototype = require_is3();
|
||
module2.exports = function(value) {
|
||
if (typeof value !== "function")
|
||
return false;
|
||
if (!hasOwnProperty.call(value, "length"))
|
||
return false;
|
||
try {
|
||
if (typeof value.length !== "number")
|
||
return false;
|
||
if (typeof value.call !== "function")
|
||
return false;
|
||
if (typeof value.apply !== "function")
|
||
return false;
|
||
} catch (error) {
|
||
return false;
|
||
}
|
||
return !isPrototype(value);
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/type/plain-function/is.js
|
||
var require_is5 = __commonJS({
|
||
"node_modules/type/plain-function/is.js"(exports, module2) {
|
||
"use strict";
|
||
var isFunction = require_is4();
|
||
var classRe = /^\s*class[\s{/}]/;
|
||
var functionToString = Function.prototype.toString;
|
||
module2.exports = function(value) {
|
||
if (!isFunction(value))
|
||
return false;
|
||
if (classRe.test(functionToString.call(value)))
|
||
return false;
|
||
return true;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/object/assign/is-implemented.js
|
||
var require_is_implemented = __commonJS({
|
||
"node_modules/es5-ext/object/assign/is-implemented.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = function() {
|
||
var assign = Object.assign, obj;
|
||
if (typeof assign !== "function")
|
||
return false;
|
||
obj = { foo: "raz" };
|
||
assign(obj, { bar: "dwa" }, { trzy: "trzy" });
|
||
return obj.foo + obj.bar + obj.trzy === "razdwatrzy";
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/object/keys/is-implemented.js
|
||
var require_is_implemented2 = __commonJS({
|
||
"node_modules/es5-ext/object/keys/is-implemented.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = function() {
|
||
try {
|
||
Object.keys("primitive");
|
||
return true;
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/function/noop.js
|
||
var require_noop = __commonJS({
|
||
"node_modules/es5-ext/function/noop.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = function() {
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/object/is-value.js
|
||
var require_is_value = __commonJS({
|
||
"node_modules/es5-ext/object/is-value.js"(exports, module2) {
|
||
"use strict";
|
||
var _undefined = require_noop()();
|
||
module2.exports = function(val) {
|
||
return val !== _undefined && val !== null;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/object/keys/shim.js
|
||
var require_shim = __commonJS({
|
||
"node_modules/es5-ext/object/keys/shim.js"(exports, module2) {
|
||
"use strict";
|
||
var isValue = require_is_value();
|
||
var keys = Object.keys;
|
||
module2.exports = function(object) {
|
||
return keys(isValue(object) ? Object(object) : object);
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/object/keys/index.js
|
||
var require_keys = __commonJS({
|
||
"node_modules/es5-ext/object/keys/index.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = require_is_implemented2()() ? Object.keys : require_shim();
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/object/valid-value.js
|
||
var require_valid_value = __commonJS({
|
||
"node_modules/es5-ext/object/valid-value.js"(exports, module2) {
|
||
"use strict";
|
||
var isValue = require_is_value();
|
||
module2.exports = function(value) {
|
||
if (!isValue(value))
|
||
throw new TypeError("Cannot use null or undefined");
|
||
return value;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/object/assign/shim.js
|
||
var require_shim2 = __commonJS({
|
||
"node_modules/es5-ext/object/assign/shim.js"(exports, module2) {
|
||
"use strict";
|
||
var keys = require_keys();
|
||
var value = require_valid_value();
|
||
var max = Math.max;
|
||
module2.exports = function(dest, src) {
|
||
var error, i, length = max(arguments.length, 2), assign;
|
||
dest = Object(value(dest));
|
||
assign = function(key) {
|
||
try {
|
||
dest[key] = src[key];
|
||
} catch (e) {
|
||
if (!error)
|
||
error = e;
|
||
}
|
||
};
|
||
for (i = 1; i < length; ++i) {
|
||
src = arguments[i];
|
||
keys(src).forEach(assign);
|
||
}
|
||
if (error !== void 0)
|
||
throw error;
|
||
return dest;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/object/assign/index.js
|
||
var require_assign = __commonJS({
|
||
"node_modules/es5-ext/object/assign/index.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = require_is_implemented()() ? Object.assign : require_shim2();
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/object/normalize-options.js
|
||
var require_normalize_options = __commonJS({
|
||
"node_modules/es5-ext/object/normalize-options.js"(exports, module2) {
|
||
"use strict";
|
||
var isValue = require_is_value();
|
||
var forEach = Array.prototype.forEach;
|
||
var create = Object.create;
|
||
var process2 = function(src, obj) {
|
||
var key;
|
||
for (key in src)
|
||
obj[key] = src[key];
|
||
};
|
||
module2.exports = function(opts1) {
|
||
var result = create(null);
|
||
forEach.call(arguments, function(options) {
|
||
if (!isValue(options))
|
||
return;
|
||
process2(Object(options), result);
|
||
});
|
||
return result;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/string/#/contains/is-implemented.js
|
||
var require_is_implemented3 = __commonJS({
|
||
"node_modules/es5-ext/string/#/contains/is-implemented.js"(exports, module2) {
|
||
"use strict";
|
||
var str = "razdwatrzy";
|
||
module2.exports = function() {
|
||
if (typeof str.contains !== "function")
|
||
return false;
|
||
return str.contains("dwa") === true && str.contains("foo") === false;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/string/#/contains/shim.js
|
||
var require_shim3 = __commonJS({
|
||
"node_modules/es5-ext/string/#/contains/shim.js"(exports, module2) {
|
||
"use strict";
|
||
var indexOf = String.prototype.indexOf;
|
||
module2.exports = function(searchString) {
|
||
return indexOf.call(this, searchString, arguments[1]) > -1;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/string/#/contains/index.js
|
||
var require_contains = __commonJS({
|
||
"node_modules/es5-ext/string/#/contains/index.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = require_is_implemented3()() ? String.prototype.contains : require_shim3();
|
||
}
|
||
});
|
||
|
||
// node_modules/d/index.js
|
||
var require_d = __commonJS({
|
||
"node_modules/d/index.js"(exports, module2) {
|
||
"use strict";
|
||
var isValue = require_is();
|
||
var isPlainFunction = require_is5();
|
||
var assign = require_assign();
|
||
var normalizeOpts = require_normalize_options();
|
||
var contains = require_contains();
|
||
var d = module2.exports = function(dscr, value) {
|
||
var c, e, w, options, desc;
|
||
if (arguments.length < 2 || typeof dscr !== "string") {
|
||
options = value;
|
||
value = dscr;
|
||
dscr = null;
|
||
} else {
|
||
options = arguments[2];
|
||
}
|
||
if (isValue(dscr)) {
|
||
c = contains.call(dscr, "c");
|
||
e = contains.call(dscr, "e");
|
||
w = contains.call(dscr, "w");
|
||
} else {
|
||
c = w = true;
|
||
e = false;
|
||
}
|
||
desc = { value, configurable: c, enumerable: e, writable: w };
|
||
return !options ? desc : assign(normalizeOpts(options), desc);
|
||
};
|
||
d.gs = function(dscr, get, set) {
|
||
var c, e, options, desc;
|
||
if (typeof dscr !== "string") {
|
||
options = set;
|
||
set = get;
|
||
get = dscr;
|
||
dscr = null;
|
||
} else {
|
||
options = arguments[3];
|
||
}
|
||
if (!isValue(get)) {
|
||
get = void 0;
|
||
} else if (!isPlainFunction(get)) {
|
||
options = get;
|
||
get = set = void 0;
|
||
} else if (!isValue(set)) {
|
||
set = void 0;
|
||
} else if (!isPlainFunction(set)) {
|
||
options = set;
|
||
set = void 0;
|
||
}
|
||
if (isValue(dscr)) {
|
||
c = contains.call(dscr, "c");
|
||
e = contains.call(dscr, "e");
|
||
} else {
|
||
c = true;
|
||
e = false;
|
||
}
|
||
desc = { get, set, configurable: c, enumerable: e };
|
||
return !options ? desc : assign(normalizeOpts(options), desc);
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/es5-ext/object/valid-callable.js
|
||
var require_valid_callable = __commonJS({
|
||
"node_modules/es5-ext/object/valid-callable.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = function(fn) {
|
||
if (typeof fn !== "function")
|
||
throw new TypeError(fn + " is not a function");
|
||
return fn;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/event-emitter/index.js
|
||
var require_event_emitter = __commonJS({
|
||
"node_modules/event-emitter/index.js"(exports, module2) {
|
||
"use strict";
|
||
var d = require_d();
|
||
var callable = require_valid_callable();
|
||
var apply = Function.prototype.apply;
|
||
var call = Function.prototype.call;
|
||
var create = Object.create;
|
||
var defineProperty = Object.defineProperty;
|
||
var defineProperties = Object.defineProperties;
|
||
var hasOwnProperty2 = Object.prototype.hasOwnProperty;
|
||
var descriptor = { configurable: true, enumerable: false, writable: true };
|
||
var on;
|
||
var once;
|
||
var off;
|
||
var emit;
|
||
var methods;
|
||
var descriptors;
|
||
var base;
|
||
on = function(type, listener) {
|
||
var data;
|
||
callable(listener);
|
||
if (!hasOwnProperty2.call(this, "__ee__")) {
|
||
data = descriptor.value = create(null);
|
||
defineProperty(this, "__ee__", descriptor);
|
||
descriptor.value = null;
|
||
} else {
|
||
data = this.__ee__;
|
||
}
|
||
if (!data[type])
|
||
data[type] = listener;
|
||
else if (typeof data[type] === "object")
|
||
data[type].push(listener);
|
||
else
|
||
data[type] = [data[type], listener];
|
||
return this;
|
||
};
|
||
once = function(type, listener) {
|
||
var once2, self2;
|
||
callable(listener);
|
||
self2 = this;
|
||
on.call(this, type, once2 = function() {
|
||
off.call(self2, type, once2);
|
||
apply.call(listener, this, arguments);
|
||
});
|
||
once2.__eeOnceListener__ = listener;
|
||
return this;
|
||
};
|
||
off = function(type, listener) {
|
||
var data, listeners, candidate, i;
|
||
callable(listener);
|
||
if (!hasOwnProperty2.call(this, "__ee__"))
|
||
return this;
|
||
data = this.__ee__;
|
||
if (!data[type])
|
||
return this;
|
||
listeners = data[type];
|
||
if (typeof listeners === "object") {
|
||
for (i = 0; candidate = listeners[i]; ++i) {
|
||
if (candidate === listener || candidate.__eeOnceListener__ === listener) {
|
||
if (listeners.length === 2)
|
||
data[type] = listeners[i ? 0 : 1];
|
||
else
|
||
listeners.splice(i, 1);
|
||
}
|
||
}
|
||
} else {
|
||
if (listeners === listener || listeners.__eeOnceListener__ === listener) {
|
||
delete data[type];
|
||
}
|
||
}
|
||
return this;
|
||
};
|
||
emit = function(type) {
|
||
var i, l, listener, listeners, args;
|
||
if (!hasOwnProperty2.call(this, "__ee__"))
|
||
return;
|
||
listeners = this.__ee__[type];
|
||
if (!listeners)
|
||
return;
|
||
if (typeof listeners === "object") {
|
||
l = arguments.length;
|
||
args = new Array(l - 1);
|
||
for (i = 1; i < l; ++i)
|
||
args[i - 1] = arguments[i];
|
||
listeners = listeners.slice();
|
||
for (i = 0; listener = listeners[i]; ++i) {
|
||
apply.call(listener, this, args);
|
||
}
|
||
} else {
|
||
switch (arguments.length) {
|
||
case 1:
|
||
call.call(listeners, this);
|
||
break;
|
||
case 2:
|
||
call.call(listeners, this, arguments[1]);
|
||
break;
|
||
case 3:
|
||
call.call(listeners, this, arguments[1], arguments[2]);
|
||
break;
|
||
default:
|
||
l = arguments.length;
|
||
args = new Array(l - 1);
|
||
for (i = 1; i < l; ++i) {
|
||
args[i - 1] = arguments[i];
|
||
}
|
||
apply.call(listeners, this, args);
|
||
}
|
||
}
|
||
};
|
||
methods = {
|
||
on,
|
||
once,
|
||
off,
|
||
emit
|
||
};
|
||
descriptors = {
|
||
on: d(on),
|
||
once: d(once),
|
||
off: d(off),
|
||
emit: d(emit)
|
||
};
|
||
base = defineProperties({}, descriptors);
|
||
module2.exports = exports = function(o) {
|
||
return o == null ? create(base) : defineProperties(Object(o), descriptors);
|
||
};
|
||
exports.methods = methods;
|
||
}
|
||
});
|
||
|
||
// node_modules/@xmldom/xmldom/lib/conventions.js
|
||
var require_conventions = __commonJS({
|
||
"node_modules/@xmldom/xmldom/lib/conventions.js"(exports) {
|
||
"use strict";
|
||
function find(list, predicate, ac) {
|
||
if (ac === void 0) {
|
||
ac = Array.prototype;
|
||
}
|
||
if (list && typeof ac.find === "function") {
|
||
return ac.find.call(list, predicate);
|
||
}
|
||
for (var i = 0; i < list.length; i++) {
|
||
if (Object.prototype.hasOwnProperty.call(list, i)) {
|
||
var item = list[i];
|
||
if (predicate.call(void 0, item, i, list)) {
|
||
return item;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function freeze(object, oc) {
|
||
if (oc === void 0) {
|
||
oc = Object;
|
||
}
|
||
return oc && typeof oc.freeze === "function" ? oc.freeze(object) : object;
|
||
}
|
||
var MIME_TYPE = freeze({
|
||
HTML: "text/html",
|
||
isHTML: function(value) {
|
||
return value === MIME_TYPE.HTML;
|
||
},
|
||
XML_APPLICATION: "application/xml",
|
||
XML_TEXT: "text/xml",
|
||
XML_XHTML_APPLICATION: "application/xhtml+xml",
|
||
XML_SVG_IMAGE: "image/svg+xml"
|
||
});
|
||
var NAMESPACE = freeze({
|
||
HTML: "http://www.w3.org/1999/xhtml",
|
||
isHTML: function(uri) {
|
||
return uri === NAMESPACE.HTML;
|
||
},
|
||
SVG: "http://www.w3.org/2000/svg",
|
||
XML: "http://www.w3.org/XML/1998/namespace",
|
||
XMLNS: "http://www.w3.org/2000/xmlns/"
|
||
});
|
||
exports.find = find;
|
||
exports.freeze = freeze;
|
||
exports.MIME_TYPE = MIME_TYPE;
|
||
exports.NAMESPACE = NAMESPACE;
|
||
}
|
||
});
|
||
|
||
// node_modules/@xmldom/xmldom/lib/dom.js
|
||
var require_dom = __commonJS({
|
||
"node_modules/@xmldom/xmldom/lib/dom.js"(exports) {
|
||
var conventions = require_conventions();
|
||
var find = conventions.find;
|
||
var NAMESPACE = conventions.NAMESPACE;
|
||
function notEmptyString(input) {
|
||
return input !== "";
|
||
}
|
||
function splitOnASCIIWhitespace(input) {
|
||
return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : [];
|
||
}
|
||
function orderedSetReducer(current, element) {
|
||
if (!current.hasOwnProperty(element)) {
|
||
current[element] = true;
|
||
}
|
||
return current;
|
||
}
|
||
function toOrderedSet(input) {
|
||
if (!input)
|
||
return [];
|
||
var list = splitOnASCIIWhitespace(input);
|
||
return Object.keys(list.reduce(orderedSetReducer, {}));
|
||
}
|
||
function arrayIncludes(list) {
|
||
return function(element) {
|
||
return list && list.indexOf(element) !== -1;
|
||
};
|
||
}
|
||
function copy(src, dest) {
|
||
for (var p in src) {
|
||
if (Object.prototype.hasOwnProperty.call(src, p)) {
|
||
dest[p] = src[p];
|
||
}
|
||
}
|
||
}
|
||
function _extends(Class, Super) {
|
||
var pt = Class.prototype;
|
||
if (!(pt instanceof Super)) {
|
||
let t2 = function() {
|
||
};
|
||
var t = t2;
|
||
;
|
||
t2.prototype = Super.prototype;
|
||
t2 = new t2();
|
||
copy(pt, t2);
|
||
Class.prototype = pt = t2;
|
||
}
|
||
if (pt.constructor != Class) {
|
||
if (typeof Class != "function") {
|
||
console.error("unknown Class:" + Class);
|
||
}
|
||
pt.constructor = Class;
|
||
}
|
||
}
|
||
var NodeType = {};
|
||
var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
|
||
var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
|
||
var TEXT_NODE = NodeType.TEXT_NODE = 3;
|
||
var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
|
||
var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
|
||
var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
|
||
var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
|
||
var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
|
||
var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
|
||
var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
|
||
var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
|
||
var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
|
||
var ExceptionCode = {};
|
||
var ExceptionMessage = {};
|
||
var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = (ExceptionMessage[1] = "Index size error", 1);
|
||
var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = (ExceptionMessage[2] = "DOMString size error", 2);
|
||
var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = (ExceptionMessage[3] = "Hierarchy request error", 3);
|
||
var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = (ExceptionMessage[4] = "Wrong document", 4);
|
||
var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = (ExceptionMessage[5] = "Invalid character", 5);
|
||
var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = (ExceptionMessage[6] = "No data allowed", 6);
|
||
var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = (ExceptionMessage[7] = "No modification allowed", 7);
|
||
var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = (ExceptionMessage[8] = "Not found", 8);
|
||
var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = (ExceptionMessage[9] = "Not supported", 9);
|
||
var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = (ExceptionMessage[10] = "Attribute in use", 10);
|
||
var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = (ExceptionMessage[11] = "Invalid state", 11);
|
||
var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = (ExceptionMessage[12] = "Syntax error", 12);
|
||
var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = (ExceptionMessage[13] = "Invalid modification", 13);
|
||
var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = (ExceptionMessage[14] = "Invalid namespace", 14);
|
||
var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = (ExceptionMessage[15] = "Invalid access", 15);
|
||
function DOMException(code, message) {
|
||
if (message instanceof Error) {
|
||
var error = message;
|
||
} else {
|
||
error = this;
|
||
Error.call(this, ExceptionMessage[code]);
|
||
this.message = ExceptionMessage[code];
|
||
if (Error.captureStackTrace)
|
||
Error.captureStackTrace(this, DOMException);
|
||
}
|
||
error.code = code;
|
||
if (message)
|
||
this.message = this.message + ": " + message;
|
||
return error;
|
||
}
|
||
DOMException.prototype = Error.prototype;
|
||
copy(ExceptionCode, DOMException);
|
||
function NodeList() {
|
||
}
|
||
NodeList.prototype = {
|
||
length: 0,
|
||
item: function(index) {
|
||
return this[index] || null;
|
||
},
|
||
toString: function(isHTML, nodeFilter) {
|
||
for (var buf = [], i = 0; i < this.length; i++) {
|
||
serializeToString(this[i], buf, isHTML, nodeFilter);
|
||
}
|
||
return buf.join("");
|
||
},
|
||
filter: function(predicate) {
|
||
return Array.prototype.filter.call(this, predicate);
|
||
},
|
||
indexOf: function(item) {
|
||
return Array.prototype.indexOf.call(this, item);
|
||
}
|
||
};
|
||
function LiveNodeList(node, refresh) {
|
||
this._node = node;
|
||
this._refresh = refresh;
|
||
_updateLiveList(this);
|
||
}
|
||
function _updateLiveList(list) {
|
||
var inc = list._node._inc || list._node.ownerDocument._inc;
|
||
if (list._inc != inc) {
|
||
var ls = list._refresh(list._node);
|
||
__set__(list, "length", ls.length);
|
||
copy(ls, list);
|
||
list._inc = inc;
|
||
}
|
||
}
|
||
LiveNodeList.prototype.item = function(i) {
|
||
_updateLiveList(this);
|
||
return this[i];
|
||
};
|
||
_extends(LiveNodeList, NodeList);
|
||
function NamedNodeMap() {
|
||
}
|
||
function _findNodeIndex(list, node) {
|
||
var i = list.length;
|
||
while (i--) {
|
||
if (list[i] === node) {
|
||
return i;
|
||
}
|
||
}
|
||
}
|
||
function _addNamedNode(el, list, newAttr, oldAttr) {
|
||
if (oldAttr) {
|
||
list[_findNodeIndex(list, oldAttr)] = newAttr;
|
||
} else {
|
||
list[list.length++] = newAttr;
|
||
}
|
||
if (el) {
|
||
newAttr.ownerElement = el;
|
||
var doc = el.ownerDocument;
|
||
if (doc) {
|
||
oldAttr && _onRemoveAttribute(doc, el, oldAttr);
|
||
_onAddAttribute(doc, el, newAttr);
|
||
}
|
||
}
|
||
}
|
||
function _removeNamedNode(el, list, attr) {
|
||
var i = _findNodeIndex(list, attr);
|
||
if (i >= 0) {
|
||
var lastIndex = list.length - 1;
|
||
while (i < lastIndex) {
|
||
list[i] = list[++i];
|
||
}
|
||
list.length = lastIndex;
|
||
if (el) {
|
||
var doc = el.ownerDocument;
|
||
if (doc) {
|
||
_onRemoveAttribute(doc, el, attr);
|
||
attr.ownerElement = null;
|
||
}
|
||
}
|
||
} else {
|
||
throw new DOMException(NOT_FOUND_ERR, new Error(el.tagName + "@" + attr));
|
||
}
|
||
}
|
||
NamedNodeMap.prototype = {
|
||
length: 0,
|
||
item: NodeList.prototype.item,
|
||
getNamedItem: function(key) {
|
||
var i = this.length;
|
||
while (i--) {
|
||
var attr = this[i];
|
||
if (attr.nodeName == key) {
|
||
return attr;
|
||
}
|
||
}
|
||
},
|
||
setNamedItem: function(attr) {
|
||
var el = attr.ownerElement;
|
||
if (el && el != this._ownerElement) {
|
||
throw new DOMException(INUSE_ATTRIBUTE_ERR);
|
||
}
|
||
var oldAttr = this.getNamedItem(attr.nodeName);
|
||
_addNamedNode(this._ownerElement, this, attr, oldAttr);
|
||
return oldAttr;
|
||
},
|
||
setNamedItemNS: function(attr) {
|
||
var el = attr.ownerElement, oldAttr;
|
||
if (el && el != this._ownerElement) {
|
||
throw new DOMException(INUSE_ATTRIBUTE_ERR);
|
||
}
|
||
oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);
|
||
_addNamedNode(this._ownerElement, this, attr, oldAttr);
|
||
return oldAttr;
|
||
},
|
||
removeNamedItem: function(key) {
|
||
var attr = this.getNamedItem(key);
|
||
_removeNamedNode(this._ownerElement, this, attr);
|
||
return attr;
|
||
},
|
||
removeNamedItemNS: function(namespaceURI, localName) {
|
||
var attr = this.getNamedItemNS(namespaceURI, localName);
|
||
_removeNamedNode(this._ownerElement, this, attr);
|
||
return attr;
|
||
},
|
||
getNamedItemNS: function(namespaceURI, localName) {
|
||
var i = this.length;
|
||
while (i--) {
|
||
var node = this[i];
|
||
if (node.localName == localName && node.namespaceURI == namespaceURI) {
|
||
return node;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
};
|
||
function DOMImplementation() {
|
||
}
|
||
DOMImplementation.prototype = {
|
||
hasFeature: function(feature, version) {
|
||
return true;
|
||
},
|
||
createDocument: function(namespaceURI, qualifiedName, doctype) {
|
||
var doc = new Document();
|
||
doc.implementation = this;
|
||
doc.childNodes = new NodeList();
|
||
doc.doctype = doctype || null;
|
||
if (doctype) {
|
||
doc.appendChild(doctype);
|
||
}
|
||
if (qualifiedName) {
|
||
var root = doc.createElementNS(namespaceURI, qualifiedName);
|
||
doc.appendChild(root);
|
||
}
|
||
return doc;
|
||
},
|
||
createDocumentType: function(qualifiedName, publicId, systemId) {
|
||
var node = new DocumentType();
|
||
node.name = qualifiedName;
|
||
node.nodeName = qualifiedName;
|
||
node.publicId = publicId || "";
|
||
node.systemId = systemId || "";
|
||
return node;
|
||
}
|
||
};
|
||
function Node2() {
|
||
}
|
||
Node2.prototype = {
|
||
firstChild: null,
|
||
lastChild: null,
|
||
previousSibling: null,
|
||
nextSibling: null,
|
||
attributes: null,
|
||
parentNode: null,
|
||
childNodes: null,
|
||
ownerDocument: null,
|
||
nodeValue: null,
|
||
namespaceURI: null,
|
||
prefix: null,
|
||
localName: null,
|
||
insertBefore: function(newChild, refChild) {
|
||
return _insertBefore(this, newChild, refChild);
|
||
},
|
||
replaceChild: function(newChild, oldChild) {
|
||
_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
|
||
if (oldChild) {
|
||
this.removeChild(oldChild);
|
||
}
|
||
},
|
||
removeChild: function(oldChild) {
|
||
return _removeChild(this, oldChild);
|
||
},
|
||
appendChild: function(newChild) {
|
||
return this.insertBefore(newChild, null);
|
||
},
|
||
hasChildNodes: function() {
|
||
return this.firstChild != null;
|
||
},
|
||
cloneNode: function(deep) {
|
||
return cloneNode(this.ownerDocument || this, this, deep);
|
||
},
|
||
normalize: function() {
|
||
var child = this.firstChild;
|
||
while (child) {
|
||
var next = child.nextSibling;
|
||
if (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {
|
||
this.removeChild(next);
|
||
child.appendData(next.data);
|
||
} else {
|
||
child.normalize();
|
||
child = next;
|
||
}
|
||
}
|
||
},
|
||
isSupported: function(feature, version) {
|
||
return this.ownerDocument.implementation.hasFeature(feature, version);
|
||
},
|
||
hasAttributes: function() {
|
||
return this.attributes.length > 0;
|
||
},
|
||
lookupPrefix: function(namespaceURI) {
|
||
var el = this;
|
||
while (el) {
|
||
var map = el._nsMap;
|
||
if (map) {
|
||
for (var n in map) {
|
||
if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
|
||
return n;
|
||
}
|
||
}
|
||
}
|
||
el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
|
||
}
|
||
return null;
|
||
},
|
||
lookupNamespaceURI: function(prefix) {
|
||
var el = this;
|
||
while (el) {
|
||
var map = el._nsMap;
|
||
if (map) {
|
||
if (prefix in map) {
|
||
if (Object.prototype.hasOwnProperty.call(map, prefix)) {
|
||
return map[prefix];
|
||
}
|
||
}
|
||
}
|
||
el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
|
||
}
|
||
return null;
|
||
},
|
||
isDefaultNamespace: function(namespaceURI) {
|
||
var prefix = this.lookupPrefix(namespaceURI);
|
||
return prefix == null;
|
||
}
|
||
};
|
||
function _xmlEncoder(c) {
|
||
return c == "<" && "<" || c == ">" && ">" || c == "&" && "&" || c == '"' && """ || "&#" + c.charCodeAt() + ";";
|
||
}
|
||
copy(NodeType, Node2);
|
||
copy(NodeType, Node2.prototype);
|
||
function _visitNode(node, callback) {
|
||
if (callback(node)) {
|
||
return true;
|
||
}
|
||
if (node = node.firstChild) {
|
||
do {
|
||
if (_visitNode(node, callback)) {
|
||
return true;
|
||
}
|
||
} while (node = node.nextSibling);
|
||
}
|
||
}
|
||
function Document() {
|
||
this.ownerDocument = this;
|
||
}
|
||
function _onAddAttribute(doc, el, newAttr) {
|
||
doc && doc._inc++;
|
||
var ns = newAttr.namespaceURI;
|
||
if (ns === NAMESPACE.XMLNS) {
|
||
el._nsMap[newAttr.prefix ? newAttr.localName : ""] = newAttr.value;
|
||
}
|
||
}
|
||
function _onRemoveAttribute(doc, el, newAttr, remove) {
|
||
doc && doc._inc++;
|
||
var ns = newAttr.namespaceURI;
|
||
if (ns === NAMESPACE.XMLNS) {
|
||
delete el._nsMap[newAttr.prefix ? newAttr.localName : ""];
|
||
}
|
||
}
|
||
function _onUpdateChild(doc, el, newChild) {
|
||
if (doc && doc._inc) {
|
||
doc._inc++;
|
||
var cs = el.childNodes;
|
||
if (newChild) {
|
||
cs[cs.length++] = newChild;
|
||
} else {
|
||
var child = el.firstChild;
|
||
var i = 0;
|
||
while (child) {
|
||
cs[i++] = child;
|
||
child = child.nextSibling;
|
||
}
|
||
cs.length = i;
|
||
delete cs[cs.length];
|
||
}
|
||
}
|
||
}
|
||
function _removeChild(parentNode, child) {
|
||
var previous = child.previousSibling;
|
||
var next = child.nextSibling;
|
||
if (previous) {
|
||
previous.nextSibling = next;
|
||
} else {
|
||
parentNode.firstChild = next;
|
||
}
|
||
if (next) {
|
||
next.previousSibling = previous;
|
||
} else {
|
||
parentNode.lastChild = previous;
|
||
}
|
||
child.parentNode = null;
|
||
child.previousSibling = null;
|
||
child.nextSibling = null;
|
||
_onUpdateChild(parentNode.ownerDocument, parentNode);
|
||
return child;
|
||
}
|
||
function hasValidParentNodeType(node) {
|
||
return node && (node.nodeType === Node2.DOCUMENT_NODE || node.nodeType === Node2.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node2.ELEMENT_NODE);
|
||
}
|
||
function hasInsertableNodeType(node) {
|
||
return node && (isElementNode(node) || isTextNode(node) || isDocTypeNode(node) || node.nodeType === Node2.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node2.COMMENT_NODE || node.nodeType === Node2.PROCESSING_INSTRUCTION_NODE);
|
||
}
|
||
function isDocTypeNode(node) {
|
||
return node && node.nodeType === Node2.DOCUMENT_TYPE_NODE;
|
||
}
|
||
function isElementNode(node) {
|
||
return node && node.nodeType === Node2.ELEMENT_NODE;
|
||
}
|
||
function isTextNode(node) {
|
||
return node && node.nodeType === Node2.TEXT_NODE;
|
||
}
|
||
function isElementInsertionPossible(doc, child) {
|
||
var parentChildNodes = doc.childNodes || [];
|
||
if (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {
|
||
return false;
|
||
}
|
||
var docTypeNode = find(parentChildNodes, isDocTypeNode);
|
||
return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
|
||
}
|
||
function isElementReplacementPossible(doc, child) {
|
||
var parentChildNodes = doc.childNodes || [];
|
||
function hasElementChildThatIsNotChild(node) {
|
||
return isElementNode(node) && node !== child;
|
||
}
|
||
if (find(parentChildNodes, hasElementChildThatIsNotChild)) {
|
||
return false;
|
||
}
|
||
var docTypeNode = find(parentChildNodes, isDocTypeNode);
|
||
return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
|
||
}
|
||
function assertPreInsertionValidity1to5(parent2, node, child) {
|
||
if (!hasValidParentNodeType(parent2)) {
|
||
throw new DOMException(HIERARCHY_REQUEST_ERR, "Unexpected parent node type " + parent2.nodeType);
|
||
}
|
||
if (child && child.parentNode !== parent2) {
|
||
throw new DOMException(NOT_FOUND_ERR, "child not in parent");
|
||
}
|
||
if (!hasInsertableNodeType(node) || isDocTypeNode(node) && parent2.nodeType !== Node2.DOCUMENT_NODE) {
|
||
throw new DOMException(HIERARCHY_REQUEST_ERR, "Unexpected node type " + node.nodeType + " for parent node type " + parent2.nodeType);
|
||
}
|
||
}
|
||
function assertPreInsertionValidityInDocument(parent2, node, child) {
|
||
var parentChildNodes = parent2.childNodes || [];
|
||
var nodeChildNodes = node.childNodes || [];
|
||
if (node.nodeType === Node2.DOCUMENT_FRAGMENT_NODE) {
|
||
var nodeChildElements = nodeChildNodes.filter(isElementNode);
|
||
if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
|
||
throw new DOMException(HIERARCHY_REQUEST_ERR, "More than one element or text in fragment");
|
||
}
|
||
if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent2, child)) {
|
||
throw new DOMException(HIERARCHY_REQUEST_ERR, "Element in fragment can not be inserted before doctype");
|
||
}
|
||
}
|
||
if (isElementNode(node)) {
|
||
if (!isElementInsertionPossible(parent2, child)) {
|
||
throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one element can be added and only after doctype");
|
||
}
|
||
}
|
||
if (isDocTypeNode(node)) {
|
||
if (find(parentChildNodes, isDocTypeNode)) {
|
||
throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one doctype is allowed");
|
||
}
|
||
var parentElementChild = find(parentChildNodes, isElementNode);
|
||
if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
|
||
throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can only be inserted before an element");
|
||
}
|
||
if (!child && parentElementChild) {
|
||
throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can not be appended since element is present");
|
||
}
|
||
}
|
||
}
|
||
function assertPreReplacementValidityInDocument(parent2, node, child) {
|
||
var parentChildNodes = parent2.childNodes || [];
|
||
var nodeChildNodes = node.childNodes || [];
|
||
if (node.nodeType === Node2.DOCUMENT_FRAGMENT_NODE) {
|
||
var nodeChildElements = nodeChildNodes.filter(isElementNode);
|
||
if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
|
||
throw new DOMException(HIERARCHY_REQUEST_ERR, "More than one element or text in fragment");
|
||
}
|
||
if (nodeChildElements.length === 1 && !isElementReplacementPossible(parent2, child)) {
|
||
throw new DOMException(HIERARCHY_REQUEST_ERR, "Element in fragment can not be inserted before doctype");
|
||
}
|
||
}
|
||
if (isElementNode(node)) {
|
||
if (!isElementReplacementPossible(parent2, child)) {
|
||
throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one element can be added and only after doctype");
|
||
}
|
||
}
|
||
if (isDocTypeNode(node)) {
|
||
let hasDoctypeChildThatIsNotChild2 = function(node2) {
|
||
return isDocTypeNode(node2) && node2 !== child;
|
||
};
|
||
var hasDoctypeChildThatIsNotChild = hasDoctypeChildThatIsNotChild2;
|
||
if (find(parentChildNodes, hasDoctypeChildThatIsNotChild2)) {
|
||
throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one doctype is allowed");
|
||
}
|
||
var parentElementChild = find(parentChildNodes, isElementNode);
|
||
if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
|
||
throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can only be inserted before an element");
|
||
}
|
||
}
|
||
}
|
||
function _insertBefore(parent2, node, child, _inDocumentAssertion) {
|
||
assertPreInsertionValidity1to5(parent2, node, child);
|
||
if (parent2.nodeType === Node2.DOCUMENT_NODE) {
|
||
(_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent2, node, child);
|
||
}
|
||
var cp = node.parentNode;
|
||
if (cp) {
|
||
cp.removeChild(node);
|
||
}
|
||
if (node.nodeType === DOCUMENT_FRAGMENT_NODE) {
|
||
var newFirst = node.firstChild;
|
||
if (newFirst == null) {
|
||
return node;
|
||
}
|
||
var newLast = node.lastChild;
|
||
} else {
|
||
newFirst = newLast = node;
|
||
}
|
||
var pre = child ? child.previousSibling : parent2.lastChild;
|
||
newFirst.previousSibling = pre;
|
||
newLast.nextSibling = child;
|
||
if (pre) {
|
||
pre.nextSibling = newFirst;
|
||
} else {
|
||
parent2.firstChild = newFirst;
|
||
}
|
||
if (child == null) {
|
||
parent2.lastChild = newLast;
|
||
} else {
|
||
child.previousSibling = newLast;
|
||
}
|
||
do {
|
||
newFirst.parentNode = parent2;
|
||
} while (newFirst !== newLast && (newFirst = newFirst.nextSibling));
|
||
_onUpdateChild(parent2.ownerDocument || parent2, parent2);
|
||
if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
|
||
node.firstChild = node.lastChild = null;
|
||
}
|
||
return node;
|
||
}
|
||
function _appendSingleChild(parentNode, newChild) {
|
||
if (newChild.parentNode) {
|
||
newChild.parentNode.removeChild(newChild);
|
||
}
|
||
newChild.parentNode = parentNode;
|
||
newChild.previousSibling = parentNode.lastChild;
|
||
newChild.nextSibling = null;
|
||
if (newChild.previousSibling) {
|
||
newChild.previousSibling.nextSibling = newChild;
|
||
} else {
|
||
parentNode.firstChild = newChild;
|
||
}
|
||
parentNode.lastChild = newChild;
|
||
_onUpdateChild(parentNode.ownerDocument, parentNode, newChild);
|
||
return newChild;
|
||
}
|
||
Document.prototype = {
|
||
nodeName: "#document",
|
||
nodeType: DOCUMENT_NODE,
|
||
doctype: null,
|
||
documentElement: null,
|
||
_inc: 1,
|
||
insertBefore: function(newChild, refChild) {
|
||
if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
|
||
var child = newChild.firstChild;
|
||
while (child) {
|
||
var next = child.nextSibling;
|
||
this.insertBefore(child, refChild);
|
||
child = next;
|
||
}
|
||
return newChild;
|
||
}
|
||
_insertBefore(this, newChild, refChild);
|
||
newChild.ownerDocument = this;
|
||
if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {
|
||
this.documentElement = newChild;
|
||
}
|
||
return newChild;
|
||
},
|
||
removeChild: function(oldChild) {
|
||
if (this.documentElement == oldChild) {
|
||
this.documentElement = null;
|
||
}
|
||
return _removeChild(this, oldChild);
|
||
},
|
||
replaceChild: function(newChild, oldChild) {
|
||
_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
|
||
newChild.ownerDocument = this;
|
||
if (oldChild) {
|
||
this.removeChild(oldChild);
|
||
}
|
||
if (isElementNode(newChild)) {
|
||
this.documentElement = newChild;
|
||
}
|
||
},
|
||
importNode: function(importedNode, deep) {
|
||
return importNode(this, importedNode, deep);
|
||
},
|
||
getElementById: function(id) {
|
||
var rtv = null;
|
||
_visitNode(this.documentElement, function(node) {
|
||
if (node.nodeType == ELEMENT_NODE) {
|
||
if (node.getAttribute("id") == id) {
|
||
rtv = node;
|
||
return true;
|
||
}
|
||
}
|
||
});
|
||
return rtv;
|
||
},
|
||
getElementsByClassName: function(classNames) {
|
||
var classNamesSet = toOrderedSet(classNames);
|
||
return new LiveNodeList(this, function(base) {
|
||
var ls = [];
|
||
if (classNamesSet.length > 0) {
|
||
_visitNode(base.documentElement, function(node) {
|
||
if (node !== base && node.nodeType === ELEMENT_NODE) {
|
||
var nodeClassNames = node.getAttribute("class");
|
||
if (nodeClassNames) {
|
||
var matches = classNames === nodeClassNames;
|
||
if (!matches) {
|
||
var nodeClassNamesSet = toOrderedSet(nodeClassNames);
|
||
matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
|
||
}
|
||
if (matches) {
|
||
ls.push(node);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
return ls;
|
||
});
|
||
},
|
||
createElement: function(tagName) {
|
||
var node = new Element2();
|
||
node.ownerDocument = this;
|
||
node.nodeName = tagName;
|
||
node.tagName = tagName;
|
||
node.localName = tagName;
|
||
node.childNodes = new NodeList();
|
||
var attrs = node.attributes = new NamedNodeMap();
|
||
attrs._ownerElement = node;
|
||
return node;
|
||
},
|
||
createDocumentFragment: function() {
|
||
var node = new DocumentFragment();
|
||
node.ownerDocument = this;
|
||
node.childNodes = new NodeList();
|
||
return node;
|
||
},
|
||
createTextNode: function(data) {
|
||
var node = new Text();
|
||
node.ownerDocument = this;
|
||
node.appendData(data);
|
||
return node;
|
||
},
|
||
createComment: function(data) {
|
||
var node = new Comment();
|
||
node.ownerDocument = this;
|
||
node.appendData(data);
|
||
return node;
|
||
},
|
||
createCDATASection: function(data) {
|
||
var node = new CDATASection();
|
||
node.ownerDocument = this;
|
||
node.appendData(data);
|
||
return node;
|
||
},
|
||
createProcessingInstruction: function(target, data) {
|
||
var node = new ProcessingInstruction();
|
||
node.ownerDocument = this;
|
||
node.tagName = node.target = target;
|
||
node.nodeValue = node.data = data;
|
||
return node;
|
||
},
|
||
createAttribute: function(name) {
|
||
var node = new Attr();
|
||
node.ownerDocument = this;
|
||
node.name = name;
|
||
node.nodeName = name;
|
||
node.localName = name;
|
||
node.specified = true;
|
||
return node;
|
||
},
|
||
createEntityReference: function(name) {
|
||
var node = new EntityReference();
|
||
node.ownerDocument = this;
|
||
node.nodeName = name;
|
||
return node;
|
||
},
|
||
createElementNS: function(namespaceURI, qualifiedName) {
|
||
var node = new Element2();
|
||
var pl = qualifiedName.split(":");
|
||
var attrs = node.attributes = new NamedNodeMap();
|
||
node.childNodes = new NodeList();
|
||
node.ownerDocument = this;
|
||
node.nodeName = qualifiedName;
|
||
node.tagName = qualifiedName;
|
||
node.namespaceURI = namespaceURI;
|
||
if (pl.length == 2) {
|
||
node.prefix = pl[0];
|
||
node.localName = pl[1];
|
||
} else {
|
||
node.localName = qualifiedName;
|
||
}
|
||
attrs._ownerElement = node;
|
||
return node;
|
||
},
|
||
createAttributeNS: function(namespaceURI, qualifiedName) {
|
||
var node = new Attr();
|
||
var pl = qualifiedName.split(":");
|
||
node.ownerDocument = this;
|
||
node.nodeName = qualifiedName;
|
||
node.name = qualifiedName;
|
||
node.namespaceURI = namespaceURI;
|
||
node.specified = true;
|
||
if (pl.length == 2) {
|
||
node.prefix = pl[0];
|
||
node.localName = pl[1];
|
||
} else {
|
||
node.localName = qualifiedName;
|
||
}
|
||
return node;
|
||
}
|
||
};
|
||
_extends(Document, Node2);
|
||
function Element2() {
|
||
this._nsMap = {};
|
||
}
|
||
Element2.prototype = {
|
||
nodeType: ELEMENT_NODE,
|
||
hasAttribute: function(name) {
|
||
return this.getAttributeNode(name) != null;
|
||
},
|
||
getAttribute: function(name) {
|
||
var attr = this.getAttributeNode(name);
|
||
return attr && attr.value || "";
|
||
},
|
||
getAttributeNode: function(name) {
|
||
return this.attributes.getNamedItem(name);
|
||
},
|
||
setAttribute: function(name, value) {
|
||
var attr = this.ownerDocument.createAttribute(name);
|
||
attr.value = attr.nodeValue = "" + value;
|
||
this.setAttributeNode(attr);
|
||
},
|
||
removeAttribute: function(name) {
|
||
var attr = this.getAttributeNode(name);
|
||
attr && this.removeAttributeNode(attr);
|
||
},
|
||
appendChild: function(newChild) {
|
||
if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
|
||
return this.insertBefore(newChild, null);
|
||
} else {
|
||
return _appendSingleChild(this, newChild);
|
||
}
|
||
},
|
||
setAttributeNode: function(newAttr) {
|
||
return this.attributes.setNamedItem(newAttr);
|
||
},
|
||
setAttributeNodeNS: function(newAttr) {
|
||
return this.attributes.setNamedItemNS(newAttr);
|
||
},
|
||
removeAttributeNode: function(oldAttr) {
|
||
return this.attributes.removeNamedItem(oldAttr.nodeName);
|
||
},
|
||
removeAttributeNS: function(namespaceURI, localName) {
|
||
var old = this.getAttributeNodeNS(namespaceURI, localName);
|
||
old && this.removeAttributeNode(old);
|
||
},
|
||
hasAttributeNS: function(namespaceURI, localName) {
|
||
return this.getAttributeNodeNS(namespaceURI, localName) != null;
|
||
},
|
||
getAttributeNS: function(namespaceURI, localName) {
|
||
var attr = this.getAttributeNodeNS(namespaceURI, localName);
|
||
return attr && attr.value || "";
|
||
},
|
||
setAttributeNS: function(namespaceURI, qualifiedName, value) {
|
||
var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
|
||
attr.value = attr.nodeValue = "" + value;
|
||
this.setAttributeNode(attr);
|
||
},
|
||
getAttributeNodeNS: function(namespaceURI, localName) {
|
||
return this.attributes.getNamedItemNS(namespaceURI, localName);
|
||
},
|
||
getElementsByTagName: function(tagName) {
|
||
return new LiveNodeList(this, function(base) {
|
||
var ls = [];
|
||
_visitNode(base, function(node) {
|
||
if (node !== base && node.nodeType == ELEMENT_NODE && (tagName === "*" || node.tagName == tagName)) {
|
||
ls.push(node);
|
||
}
|
||
});
|
||
return ls;
|
||
});
|
||
},
|
||
getElementsByTagNameNS: function(namespaceURI, localName) {
|
||
return new LiveNodeList(this, function(base) {
|
||
var ls = [];
|
||
_visitNode(base, function(node) {
|
||
if (node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === "*" || node.namespaceURI === namespaceURI) && (localName === "*" || node.localName == localName)) {
|
||
ls.push(node);
|
||
}
|
||
});
|
||
return ls;
|
||
});
|
||
}
|
||
};
|
||
Document.prototype.getElementsByTagName = Element2.prototype.getElementsByTagName;
|
||
Document.prototype.getElementsByTagNameNS = Element2.prototype.getElementsByTagNameNS;
|
||
_extends(Element2, Node2);
|
||
function Attr() {
|
||
}
|
||
Attr.prototype.nodeType = ATTRIBUTE_NODE;
|
||
_extends(Attr, Node2);
|
||
function CharacterData() {
|
||
}
|
||
CharacterData.prototype = {
|
||
data: "",
|
||
substringData: function(offset, count) {
|
||
return this.data.substring(offset, offset + count);
|
||
},
|
||
appendData: function(text) {
|
||
text = this.data + text;
|
||
this.nodeValue = this.data = text;
|
||
this.length = text.length;
|
||
},
|
||
insertData: function(offset, text) {
|
||
this.replaceData(offset, 0, text);
|
||
},
|
||
appendChild: function(newChild) {
|
||
throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]);
|
||
},
|
||
deleteData: function(offset, count) {
|
||
this.replaceData(offset, count, "");
|
||
},
|
||
replaceData: function(offset, count, text) {
|
||
var start = this.data.substring(0, offset);
|
||
var end = this.data.substring(offset + count);
|
||
text = start + text + end;
|
||
this.nodeValue = this.data = text;
|
||
this.length = text.length;
|
||
}
|
||
};
|
||
_extends(CharacterData, Node2);
|
||
function Text() {
|
||
}
|
||
Text.prototype = {
|
||
nodeName: "#text",
|
||
nodeType: TEXT_NODE,
|
||
splitText: function(offset) {
|
||
var text = this.data;
|
||
var newText = text.substring(offset);
|
||
text = text.substring(0, offset);
|
||
this.data = this.nodeValue = text;
|
||
this.length = text.length;
|
||
var newNode = this.ownerDocument.createTextNode(newText);
|
||
if (this.parentNode) {
|
||
this.parentNode.insertBefore(newNode, this.nextSibling);
|
||
}
|
||
return newNode;
|
||
}
|
||
};
|
||
_extends(Text, CharacterData);
|
||
function Comment() {
|
||
}
|
||
Comment.prototype = {
|
||
nodeName: "#comment",
|
||
nodeType: COMMENT_NODE
|
||
};
|
||
_extends(Comment, CharacterData);
|
||
function CDATASection() {
|
||
}
|
||
CDATASection.prototype = {
|
||
nodeName: "#cdata-section",
|
||
nodeType: CDATA_SECTION_NODE
|
||
};
|
||
_extends(CDATASection, CharacterData);
|
||
function DocumentType() {
|
||
}
|
||
DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
|
||
_extends(DocumentType, Node2);
|
||
function Notation() {
|
||
}
|
||
Notation.prototype.nodeType = NOTATION_NODE;
|
||
_extends(Notation, Node2);
|
||
function Entity() {
|
||
}
|
||
Entity.prototype.nodeType = ENTITY_NODE;
|
||
_extends(Entity, Node2);
|
||
function EntityReference() {
|
||
}
|
||
EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
|
||
_extends(EntityReference, Node2);
|
||
function DocumentFragment() {
|
||
}
|
||
DocumentFragment.prototype.nodeName = "#document-fragment";
|
||
DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
|
||
_extends(DocumentFragment, Node2);
|
||
function ProcessingInstruction() {
|
||
}
|
||
ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
|
||
_extends(ProcessingInstruction, Node2);
|
||
function XMLSerializer2() {
|
||
}
|
||
XMLSerializer2.prototype.serializeToString = function(node, isHtml, nodeFilter) {
|
||
return nodeSerializeToString.call(node, isHtml, nodeFilter);
|
||
};
|
||
Node2.prototype.toString = nodeSerializeToString;
|
||
function nodeSerializeToString(isHtml, nodeFilter) {
|
||
var buf = [];
|
||
var refNode = this.nodeType == 9 && this.documentElement || this;
|
||
var prefix = refNode.prefix;
|
||
var uri = refNode.namespaceURI;
|
||
if (uri && prefix == null) {
|
||
var prefix = refNode.lookupPrefix(uri);
|
||
if (prefix == null) {
|
||
var visibleNamespaces = [
|
||
{ namespace: uri, prefix: null }
|
||
];
|
||
}
|
||
}
|
||
serializeToString(this, buf, isHtml, nodeFilter, visibleNamespaces);
|
||
return buf.join("");
|
||
}
|
||
function needNamespaceDefine(node, isHTML, visibleNamespaces) {
|
||
var prefix = node.prefix || "";
|
||
var uri = node.namespaceURI;
|
||
if (!uri) {
|
||
return false;
|
||
}
|
||
if (prefix === "xml" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) {
|
||
return false;
|
||
}
|
||
var i = visibleNamespaces.length;
|
||
while (i--) {
|
||
var ns = visibleNamespaces[i];
|
||
if (ns.prefix === prefix) {
|
||
return ns.namespace !== uri;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
function addSerializedAttribute(buf, qualifiedName, value) {
|
||
buf.push(" ", qualifiedName, '="', value.replace(/[<&"]/g, _xmlEncoder), '"');
|
||
}
|
||
function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces) {
|
||
if (!visibleNamespaces) {
|
||
visibleNamespaces = [];
|
||
}
|
||
if (nodeFilter) {
|
||
node = nodeFilter(node);
|
||
if (node) {
|
||
if (typeof node == "string") {
|
||
buf.push(node);
|
||
return;
|
||
}
|
||
} else {
|
||
return;
|
||
}
|
||
}
|
||
switch (node.nodeType) {
|
||
case ELEMENT_NODE:
|
||
var attrs = node.attributes;
|
||
var len = attrs.length;
|
||
var child = node.firstChild;
|
||
var nodeName = node.tagName;
|
||
isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML;
|
||
var prefixedNodeName = nodeName;
|
||
if (!isHTML && !node.prefix && node.namespaceURI) {
|
||
var defaultNS;
|
||
for (var ai = 0; ai < attrs.length; ai++) {
|
||
if (attrs.item(ai).name === "xmlns") {
|
||
defaultNS = attrs.item(ai).value;
|
||
break;
|
||
}
|
||
}
|
||
if (!defaultNS) {
|
||
for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
|
||
var namespace = visibleNamespaces[nsi];
|
||
if (namespace.prefix === "" && namespace.namespace === node.namespaceURI) {
|
||
defaultNS = namespace.namespace;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if (defaultNS !== node.namespaceURI) {
|
||
for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
|
||
var namespace = visibleNamespaces[nsi];
|
||
if (namespace.namespace === node.namespaceURI) {
|
||
if (namespace.prefix) {
|
||
prefixedNodeName = namespace.prefix + ":" + nodeName;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
buf.push("<", prefixedNodeName);
|
||
for (var i = 0; i < len; i++) {
|
||
var attr = attrs.item(i);
|
||
if (attr.prefix == "xmlns") {
|
||
visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
|
||
} else if (attr.nodeName == "xmlns") {
|
||
visibleNamespaces.push({ prefix: "", namespace: attr.value });
|
||
}
|
||
}
|
||
for (var i = 0; i < len; i++) {
|
||
var attr = attrs.item(i);
|
||
if (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {
|
||
var prefix = attr.prefix || "";
|
||
var uri = attr.namespaceURI;
|
||
addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
|
||
visibleNamespaces.push({ prefix, namespace: uri });
|
||
}
|
||
serializeToString(attr, buf, isHTML, nodeFilter, visibleNamespaces);
|
||
}
|
||
if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
|
||
var prefix = node.prefix || "";
|
||
var uri = node.namespaceURI;
|
||
addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
|
||
visibleNamespaces.push({ prefix, namespace: uri });
|
||
}
|
||
if (child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
|
||
buf.push(">");
|
||
if (isHTML && /^script$/i.test(nodeName)) {
|
||
while (child) {
|
||
if (child.data) {
|
||
buf.push(child.data);
|
||
} else {
|
||
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
||
}
|
||
child = child.nextSibling;
|
||
}
|
||
} else {
|
||
while (child) {
|
||
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
||
child = child.nextSibling;
|
||
}
|
||
}
|
||
buf.push("</", prefixedNodeName, ">");
|
||
} else {
|
||
buf.push("/>");
|
||
}
|
||
return;
|
||
case DOCUMENT_NODE:
|
||
case DOCUMENT_FRAGMENT_NODE:
|
||
var child = node.firstChild;
|
||
while (child) {
|
||
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
||
child = child.nextSibling;
|
||
}
|
||
return;
|
||
case ATTRIBUTE_NODE:
|
||
return addSerializedAttribute(buf, node.name, node.value);
|
||
case TEXT_NODE:
|
||
return buf.push(node.data.replace(/[<&]/g, _xmlEncoder).replace(/]]>/g, "]]>"));
|
||
case CDATA_SECTION_NODE:
|
||
return buf.push("<![CDATA[", node.data, "]]>");
|
||
case COMMENT_NODE:
|
||
return buf.push("<!--", node.data, "-->");
|
||
case DOCUMENT_TYPE_NODE:
|
||
var pubid = node.publicId;
|
||
var sysid = node.systemId;
|
||
buf.push("<!DOCTYPE ", node.name);
|
||
if (pubid) {
|
||
buf.push(" PUBLIC ", pubid);
|
||
if (sysid && sysid != ".") {
|
||
buf.push(" ", sysid);
|
||
}
|
||
buf.push(">");
|
||
} else if (sysid && sysid != ".") {
|
||
buf.push(" SYSTEM ", sysid, ">");
|
||
} else {
|
||
var sub = node.internalSubset;
|
||
if (sub) {
|
||
buf.push(" [", sub, "]");
|
||
}
|
||
buf.push(">");
|
||
}
|
||
return;
|
||
case PROCESSING_INSTRUCTION_NODE:
|
||
return buf.push("<?", node.target, " ", node.data, "?>");
|
||
case ENTITY_REFERENCE_NODE:
|
||
return buf.push("&", node.nodeName, ";");
|
||
default:
|
||
buf.push("??", node.nodeName);
|
||
}
|
||
}
|
||
function importNode(doc, node, deep) {
|
||
var node2;
|
||
switch (node.nodeType) {
|
||
case ELEMENT_NODE:
|
||
node2 = node.cloneNode(false);
|
||
node2.ownerDocument = doc;
|
||
case DOCUMENT_FRAGMENT_NODE:
|
||
break;
|
||
case ATTRIBUTE_NODE:
|
||
deep = true;
|
||
break;
|
||
}
|
||
if (!node2) {
|
||
node2 = node.cloneNode(false);
|
||
}
|
||
node2.ownerDocument = doc;
|
||
node2.parentNode = null;
|
||
if (deep) {
|
||
var child = node.firstChild;
|
||
while (child) {
|
||
node2.appendChild(importNode(doc, child, deep));
|
||
child = child.nextSibling;
|
||
}
|
||
}
|
||
return node2;
|
||
}
|
||
function cloneNode(doc, node, deep) {
|
||
var node2 = new node.constructor();
|
||
for (var n in node) {
|
||
if (Object.prototype.hasOwnProperty.call(node, n)) {
|
||
var v = node[n];
|
||
if (typeof v != "object") {
|
||
if (v != node2[n]) {
|
||
node2[n] = v;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (node.childNodes) {
|
||
node2.childNodes = new NodeList();
|
||
}
|
||
node2.ownerDocument = doc;
|
||
switch (node2.nodeType) {
|
||
case ELEMENT_NODE:
|
||
var attrs = node.attributes;
|
||
var attrs2 = node2.attributes = new NamedNodeMap();
|
||
var len = attrs.length;
|
||
attrs2._ownerElement = node2;
|
||
for (var i = 0; i < len; i++) {
|
||
node2.setAttributeNode(cloneNode(doc, attrs.item(i), true));
|
||
}
|
||
break;
|
||
;
|
||
case ATTRIBUTE_NODE:
|
||
deep = true;
|
||
}
|
||
if (deep) {
|
||
var child = node.firstChild;
|
||
while (child) {
|
||
node2.appendChild(cloneNode(doc, child, deep));
|
||
child = child.nextSibling;
|
||
}
|
||
}
|
||
return node2;
|
||
}
|
||
function __set__(object, key, value) {
|
||
object[key] = value;
|
||
}
|
||
try {
|
||
if (Object.defineProperty) {
|
||
let getTextContent2 = function(node) {
|
||
switch (node.nodeType) {
|
||
case ELEMENT_NODE:
|
||
case DOCUMENT_FRAGMENT_NODE:
|
||
var buf = [];
|
||
node = node.firstChild;
|
||
while (node) {
|
||
if (node.nodeType !== 7 && node.nodeType !== 8) {
|
||
buf.push(getTextContent2(node));
|
||
}
|
||
node = node.nextSibling;
|
||
}
|
||
return buf.join("");
|
||
default:
|
||
return node.nodeValue;
|
||
}
|
||
};
|
||
getTextContent = getTextContent2;
|
||
Object.defineProperty(LiveNodeList.prototype, "length", {
|
||
get: function() {
|
||
_updateLiveList(this);
|
||
return this.$$length;
|
||
}
|
||
});
|
||
Object.defineProperty(Node2.prototype, "textContent", {
|
||
get: function() {
|
||
return getTextContent2(this);
|
||
},
|
||
set: function(data) {
|
||
switch (this.nodeType) {
|
||
case ELEMENT_NODE:
|
||
case DOCUMENT_FRAGMENT_NODE:
|
||
while (this.firstChild) {
|
||
this.removeChild(this.firstChild);
|
||
}
|
||
if (data || String(data)) {
|
||
this.appendChild(this.ownerDocument.createTextNode(data));
|
||
}
|
||
break;
|
||
default:
|
||
this.data = data;
|
||
this.value = data;
|
||
this.nodeValue = data;
|
||
}
|
||
}
|
||
});
|
||
__set__ = function(object, key, value) {
|
||
object["$$" + key] = value;
|
||
};
|
||
}
|
||
} catch (e) {
|
||
}
|
||
var getTextContent;
|
||
exports.DocumentType = DocumentType;
|
||
exports.DOMException = DOMException;
|
||
exports.DOMImplementation = DOMImplementation;
|
||
exports.Element = Element2;
|
||
exports.Node = Node2;
|
||
exports.NodeList = NodeList;
|
||
exports.XMLSerializer = XMLSerializer2;
|
||
}
|
||
});
|
||
|
||
// node_modules/@xmldom/xmldom/lib/entities.js
|
||
var require_entities = __commonJS({
|
||
"node_modules/@xmldom/xmldom/lib/entities.js"(exports) {
|
||
var freeze = require_conventions().freeze;
|
||
exports.XML_ENTITIES = freeze({ amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' });
|
||
exports.HTML_ENTITIES = freeze({
|
||
lt: "<",
|
||
gt: ">",
|
||
amp: "&",
|
||
quot: '"',
|
||
apos: "'",
|
||
Agrave: "\xC0",
|
||
Aacute: "\xC1",
|
||
Acirc: "\xC2",
|
||
Atilde: "\xC3",
|
||
Auml: "\xC4",
|
||
Aring: "\xC5",
|
||
AElig: "\xC6",
|
||
Ccedil: "\xC7",
|
||
Egrave: "\xC8",
|
||
Eacute: "\xC9",
|
||
Ecirc: "\xCA",
|
||
Euml: "\xCB",
|
||
Igrave: "\xCC",
|
||
Iacute: "\xCD",
|
||
Icirc: "\xCE",
|
||
Iuml: "\xCF",
|
||
ETH: "\xD0",
|
||
Ntilde: "\xD1",
|
||
Ograve: "\xD2",
|
||
Oacute: "\xD3",
|
||
Ocirc: "\xD4",
|
||
Otilde: "\xD5",
|
||
Ouml: "\xD6",
|
||
Oslash: "\xD8",
|
||
Ugrave: "\xD9",
|
||
Uacute: "\xDA",
|
||
Ucirc: "\xDB",
|
||
Uuml: "\xDC",
|
||
Yacute: "\xDD",
|
||
THORN: "\xDE",
|
||
szlig: "\xDF",
|
||
agrave: "\xE0",
|
||
aacute: "\xE1",
|
||
acirc: "\xE2",
|
||
atilde: "\xE3",
|
||
auml: "\xE4",
|
||
aring: "\xE5",
|
||
aelig: "\xE6",
|
||
ccedil: "\xE7",
|
||
egrave: "\xE8",
|
||
eacute: "\xE9",
|
||
ecirc: "\xEA",
|
||
euml: "\xEB",
|
||
igrave: "\xEC",
|
||
iacute: "\xED",
|
||
icirc: "\xEE",
|
||
iuml: "\xEF",
|
||
eth: "\xF0",
|
||
ntilde: "\xF1",
|
||
ograve: "\xF2",
|
||
oacute: "\xF3",
|
||
ocirc: "\xF4",
|
||
otilde: "\xF5",
|
||
ouml: "\xF6",
|
||
oslash: "\xF8",
|
||
ugrave: "\xF9",
|
||
uacute: "\xFA",
|
||
ucirc: "\xFB",
|
||
uuml: "\xFC",
|
||
yacute: "\xFD",
|
||
thorn: "\xFE",
|
||
yuml: "\xFF",
|
||
nbsp: "\xA0",
|
||
iexcl: "\xA1",
|
||
cent: "\xA2",
|
||
pound: "\xA3",
|
||
curren: "\xA4",
|
||
yen: "\xA5",
|
||
brvbar: "\xA6",
|
||
sect: "\xA7",
|
||
uml: "\xA8",
|
||
copy: "\xA9",
|
||
ordf: "\xAA",
|
||
laquo: "\xAB",
|
||
not: "\xAC",
|
||
shy: "\xAD\xAD",
|
||
reg: "\xAE",
|
||
macr: "\xAF",
|
||
deg: "\xB0",
|
||
plusmn: "\xB1",
|
||
sup2: "\xB2",
|
||
sup3: "\xB3",
|
||
acute: "\xB4",
|
||
micro: "\xB5",
|
||
para: "\xB6",
|
||
middot: "\xB7",
|
||
cedil: "\xB8",
|
||
sup1: "\xB9",
|
||
ordm: "\xBA",
|
||
raquo: "\xBB",
|
||
frac14: "\xBC",
|
||
frac12: "\xBD",
|
||
frac34: "\xBE",
|
||
iquest: "\xBF",
|
||
times: "\xD7",
|
||
divide: "\xF7",
|
||
forall: "\u2200",
|
||
part: "\u2202",
|
||
exist: "\u2203",
|
||
empty: "\u2205",
|
||
nabla: "\u2207",
|
||
isin: "\u2208",
|
||
notin: "\u2209",
|
||
ni: "\u220B",
|
||
prod: "\u220F",
|
||
sum: "\u2211",
|
||
minus: "\u2212",
|
||
lowast: "\u2217",
|
||
radic: "\u221A",
|
||
prop: "\u221D",
|
||
infin: "\u221E",
|
||
ang: "\u2220",
|
||
and: "\u2227",
|
||
or: "\u2228",
|
||
cap: "\u2229",
|
||
cup: "\u222A",
|
||
"int": "\u222B",
|
||
there4: "\u2234",
|
||
sim: "\u223C",
|
||
cong: "\u2245",
|
||
asymp: "\u2248",
|
||
ne: "\u2260",
|
||
equiv: "\u2261",
|
||
le: "\u2264",
|
||
ge: "\u2265",
|
||
sub: "\u2282",
|
||
sup: "\u2283",
|
||
nsub: "\u2284",
|
||
sube: "\u2286",
|
||
supe: "\u2287",
|
||
oplus: "\u2295",
|
||
otimes: "\u2297",
|
||
perp: "\u22A5",
|
||
sdot: "\u22C5",
|
||
Alpha: "\u0391",
|
||
Beta: "\u0392",
|
||
Gamma: "\u0393",
|
||
Delta: "\u0394",
|
||
Epsilon: "\u0395",
|
||
Zeta: "\u0396",
|
||
Eta: "\u0397",
|
||
Theta: "\u0398",
|
||
Iota: "\u0399",
|
||
Kappa: "\u039A",
|
||
Lambda: "\u039B",
|
||
Mu: "\u039C",
|
||
Nu: "\u039D",
|
||
Xi: "\u039E",
|
||
Omicron: "\u039F",
|
||
Pi: "\u03A0",
|
||
Rho: "\u03A1",
|
||
Sigma: "\u03A3",
|
||
Tau: "\u03A4",
|
||
Upsilon: "\u03A5",
|
||
Phi: "\u03A6",
|
||
Chi: "\u03A7",
|
||
Psi: "\u03A8",
|
||
Omega: "\u03A9",
|
||
alpha: "\u03B1",
|
||
beta: "\u03B2",
|
||
gamma: "\u03B3",
|
||
delta: "\u03B4",
|
||
epsilon: "\u03B5",
|
||
zeta: "\u03B6",
|
||
eta: "\u03B7",
|
||
theta: "\u03B8",
|
||
iota: "\u03B9",
|
||
kappa: "\u03BA",
|
||
lambda: "\u03BB",
|
||
mu: "\u03BC",
|
||
nu: "\u03BD",
|
||
xi: "\u03BE",
|
||
omicron: "\u03BF",
|
||
pi: "\u03C0",
|
||
rho: "\u03C1",
|
||
sigmaf: "\u03C2",
|
||
sigma: "\u03C3",
|
||
tau: "\u03C4",
|
||
upsilon: "\u03C5",
|
||
phi: "\u03C6",
|
||
chi: "\u03C7",
|
||
psi: "\u03C8",
|
||
omega: "\u03C9",
|
||
thetasym: "\u03D1",
|
||
upsih: "\u03D2",
|
||
piv: "\u03D6",
|
||
OElig: "\u0152",
|
||
oelig: "\u0153",
|
||
Scaron: "\u0160",
|
||
scaron: "\u0161",
|
||
Yuml: "\u0178",
|
||
fnof: "\u0192",
|
||
circ: "\u02C6",
|
||
tilde: "\u02DC",
|
||
ensp: "\u2002",
|
||
emsp: "\u2003",
|
||
thinsp: "\u2009",
|
||
zwnj: "\u200C",
|
||
zwj: "\u200D",
|
||
lrm: "\u200E",
|
||
rlm: "\u200F",
|
||
ndash: "\u2013",
|
||
mdash: "\u2014",
|
||
lsquo: "\u2018",
|
||
rsquo: "\u2019",
|
||
sbquo: "\u201A",
|
||
ldquo: "\u201C",
|
||
rdquo: "\u201D",
|
||
bdquo: "\u201E",
|
||
dagger: "\u2020",
|
||
Dagger: "\u2021",
|
||
bull: "\u2022",
|
||
hellip: "\u2026",
|
||
permil: "\u2030",
|
||
prime: "\u2032",
|
||
Prime: "\u2033",
|
||
lsaquo: "\u2039",
|
||
rsaquo: "\u203A",
|
||
oline: "\u203E",
|
||
euro: "\u20AC",
|
||
trade: "\u2122",
|
||
larr: "\u2190",
|
||
uarr: "\u2191",
|
||
rarr: "\u2192",
|
||
darr: "\u2193",
|
||
harr: "\u2194",
|
||
crarr: "\u21B5",
|
||
lceil: "\u2308",
|
||
rceil: "\u2309",
|
||
lfloor: "\u230A",
|
||
rfloor: "\u230B",
|
||
loz: "\u25CA",
|
||
spades: "\u2660",
|
||
clubs: "\u2663",
|
||
hearts: "\u2665",
|
||
diams: "\u2666"
|
||
});
|
||
exports.entityMap = exports.HTML_ENTITIES;
|
||
}
|
||
});
|
||
|
||
// node_modules/@xmldom/xmldom/lib/sax.js
|
||
var require_sax = __commonJS({
|
||
"node_modules/@xmldom/xmldom/lib/sax.js"(exports) {
|
||
var NAMESPACE = require_conventions().NAMESPACE;
|
||
var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
|
||
var nameChar = new RegExp("[\\-\\.0-9" + nameStartChar.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
|
||
var tagNamePattern = new RegExp("^" + nameStartChar.source + nameChar.source + "*(?::" + nameStartChar.source + nameChar.source + "*)?$");
|
||
var S_TAG = 0;
|
||
var S_ATTR = 1;
|
||
var S_ATTR_SPACE = 2;
|
||
var S_EQ = 3;
|
||
var S_ATTR_NOQUOT_VALUE = 4;
|
||
var S_ATTR_END = 5;
|
||
var S_TAG_SPACE = 6;
|
||
var S_TAG_CLOSE = 7;
|
||
function ParseError(message, locator) {
|
||
this.message = message;
|
||
this.locator = locator;
|
||
if (Error.captureStackTrace)
|
||
Error.captureStackTrace(this, ParseError);
|
||
}
|
||
ParseError.prototype = new Error();
|
||
ParseError.prototype.name = ParseError.name;
|
||
function XMLReader() {
|
||
}
|
||
XMLReader.prototype = {
|
||
parse: function(source, defaultNSMap, entityMap) {
|
||
var domBuilder = this.domBuilder;
|
||
domBuilder.startDocument();
|
||
_copy(defaultNSMap, defaultNSMap = {});
|
||
parse(source, defaultNSMap, entityMap, domBuilder, this.errorHandler);
|
||
domBuilder.endDocument();
|
||
}
|
||
};
|
||
function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
|
||
function fixedFromCharCode(code) {
|
||
if (code > 65535) {
|
||
code -= 65536;
|
||
var surrogate1 = 55296 + (code >> 10), surrogate2 = 56320 + (code & 1023);
|
||
return String.fromCharCode(surrogate1, surrogate2);
|
||
} else {
|
||
return String.fromCharCode(code);
|
||
}
|
||
}
|
||
function entityReplacer(a2) {
|
||
var k = a2.slice(1, -1);
|
||
if (k in entityMap) {
|
||
return entityMap[k];
|
||
} else if (k.charAt(0) === "#") {
|
||
return fixedFromCharCode(parseInt(k.substr(1).replace("x", "0x")));
|
||
} else {
|
||
errorHandler.error("entity not found:" + a2);
|
||
return a2;
|
||
}
|
||
}
|
||
function appendText(end2) {
|
||
if (end2 > start) {
|
||
var xt = source.substring(start, end2).replace(/&#?\w+;/g, entityReplacer);
|
||
locator && position(start);
|
||
domBuilder.characters(xt, 0, end2 - start);
|
||
start = end2;
|
||
}
|
||
}
|
||
function position(p, m) {
|
||
while (p >= lineEnd && (m = linePattern.exec(source))) {
|
||
lineStart = m.index;
|
||
lineEnd = lineStart + m[0].length;
|
||
locator.lineNumber++;
|
||
}
|
||
locator.columnNumber = p - lineStart + 1;
|
||
}
|
||
var lineStart = 0;
|
||
var lineEnd = 0;
|
||
var linePattern = /.*(?:\r\n?|\n)|.*$/g;
|
||
var locator = domBuilder.locator;
|
||
var parseStack = [{ currentNSMap: defaultNSMapCopy }];
|
||
var closeMap = {};
|
||
var start = 0;
|
||
while (true) {
|
||
try {
|
||
var tagStart = source.indexOf("<", start);
|
||
if (tagStart < 0) {
|
||
if (!source.substr(start).match(/^\s*$/)) {
|
||
var doc = domBuilder.doc;
|
||
var text = doc.createTextNode(source.substr(start));
|
||
doc.appendChild(text);
|
||
domBuilder.currentElement = text;
|
||
}
|
||
return;
|
||
}
|
||
if (tagStart > start) {
|
||
appendText(tagStart);
|
||
}
|
||
switch (source.charAt(tagStart + 1)) {
|
||
case "/":
|
||
var end = source.indexOf(">", tagStart + 3);
|
||
var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, "");
|
||
var config = parseStack.pop();
|
||
if (end < 0) {
|
||
tagName = source.substring(tagStart + 2).replace(/[\s<].*/, "");
|
||
errorHandler.error("end tag name: " + tagName + " is not complete:" + config.tagName);
|
||
end = tagStart + 1 + tagName.length;
|
||
} else if (tagName.match(/\s</)) {
|
||
tagName = tagName.replace(/[\s<].*/, "");
|
||
errorHandler.error("end tag name: " + tagName + " maybe not complete");
|
||
end = tagStart + 1 + tagName.length;
|
||
}
|
||
var localNSMap = config.localNSMap;
|
||
var endMatch = config.tagName == tagName;
|
||
var endIgnoreCaseMach = endMatch || config.tagName && config.tagName.toLowerCase() == tagName.toLowerCase();
|
||
if (endIgnoreCaseMach) {
|
||
domBuilder.endElement(config.uri, config.localName, tagName);
|
||
if (localNSMap) {
|
||
for (var prefix in localNSMap) {
|
||
if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
|
||
domBuilder.endPrefixMapping(prefix);
|
||
}
|
||
}
|
||
}
|
||
if (!endMatch) {
|
||
errorHandler.fatalError("end tag name: " + tagName + " is not match the current start tagName:" + config.tagName);
|
||
}
|
||
} else {
|
||
parseStack.push(config);
|
||
}
|
||
end++;
|
||
break;
|
||
case "?":
|
||
locator && position(tagStart);
|
||
end = parseInstruction(source, tagStart, domBuilder);
|
||
break;
|
||
case "!":
|
||
locator && position(tagStart);
|
||
end = parseDCC(source, tagStart, domBuilder, errorHandler);
|
||
break;
|
||
default:
|
||
locator && position(tagStart);
|
||
var el = new ElementAttributes();
|
||
var currentNSMap = parseStack[parseStack.length - 1].currentNSMap;
|
||
var end = parseElementStartPart(source, tagStart, el, currentNSMap, entityReplacer, errorHandler);
|
||
var len = el.length;
|
||
if (!el.closed && fixSelfClosed(source, end, el.tagName, closeMap)) {
|
||
el.closed = true;
|
||
if (!entityMap.nbsp) {
|
||
errorHandler.warning("unclosed xml attribute");
|
||
}
|
||
}
|
||
if (locator && len) {
|
||
var locator2 = copyLocator(locator, {});
|
||
for (var i = 0; i < len; i++) {
|
||
var a = el[i];
|
||
position(a.offset);
|
||
a.locator = copyLocator(locator, {});
|
||
}
|
||
domBuilder.locator = locator2;
|
||
if (appendElement(el, domBuilder, currentNSMap)) {
|
||
parseStack.push(el);
|
||
}
|
||
domBuilder.locator = locator;
|
||
} else {
|
||
if (appendElement(el, domBuilder, currentNSMap)) {
|
||
parseStack.push(el);
|
||
}
|
||
}
|
||
if (NAMESPACE.isHTML(el.uri) && !el.closed) {
|
||
end = parseHtmlSpecialContent(source, end, el.tagName, entityReplacer, domBuilder);
|
||
} else {
|
||
end++;
|
||
}
|
||
}
|
||
} catch (e) {
|
||
if (e instanceof ParseError) {
|
||
throw e;
|
||
}
|
||
errorHandler.error("element parse error: " + e);
|
||
end = -1;
|
||
}
|
||
if (end > start) {
|
||
start = end;
|
||
} else {
|
||
appendText(Math.max(tagStart, start) + 1);
|
||
}
|
||
}
|
||
}
|
||
function copyLocator(f, t) {
|
||
t.lineNumber = f.lineNumber;
|
||
t.columnNumber = f.columnNumber;
|
||
return t;
|
||
}
|
||
function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler) {
|
||
function addAttribute(qname, value2, startIndex) {
|
||
if (el.attributeNames.hasOwnProperty(qname)) {
|
||
errorHandler.fatalError("Attribute " + qname + " redefined");
|
||
}
|
||
el.addValue(qname, value2, startIndex);
|
||
}
|
||
var attrName;
|
||
var value;
|
||
var p = ++start;
|
||
var s = S_TAG;
|
||
while (true) {
|
||
var c = source.charAt(p);
|
||
switch (c) {
|
||
case "=":
|
||
if (s === S_ATTR) {
|
||
attrName = source.slice(start, p);
|
||
s = S_EQ;
|
||
} else if (s === S_ATTR_SPACE) {
|
||
s = S_EQ;
|
||
} else {
|
||
throw new Error("attribute equal must after attrName");
|
||
}
|
||
break;
|
||
case "'":
|
||
case '"':
|
||
if (s === S_EQ || s === S_ATTR) {
|
||
if (s === S_ATTR) {
|
||
errorHandler.warning('attribute value must after "="');
|
||
attrName = source.slice(start, p);
|
||
}
|
||
start = p + 1;
|
||
p = source.indexOf(c, start);
|
||
if (p > 0) {
|
||
value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
|
||
addAttribute(attrName, value, start - 1);
|
||
s = S_ATTR_END;
|
||
} else {
|
||
throw new Error("attribute value no end '" + c + "' match");
|
||
}
|
||
} else if (s == S_ATTR_NOQUOT_VALUE) {
|
||
value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
|
||
addAttribute(attrName, value, start);
|
||
errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c + ")!!");
|
||
start = p + 1;
|
||
s = S_ATTR_END;
|
||
} else {
|
||
throw new Error('attribute value must after "="');
|
||
}
|
||
break;
|
||
case "/":
|
||
switch (s) {
|
||
case S_TAG:
|
||
el.setTagName(source.slice(start, p));
|
||
case S_ATTR_END:
|
||
case S_TAG_SPACE:
|
||
case S_TAG_CLOSE:
|
||
s = S_TAG_CLOSE;
|
||
el.closed = true;
|
||
case S_ATTR_NOQUOT_VALUE:
|
||
case S_ATTR:
|
||
case S_ATTR_SPACE:
|
||
break;
|
||
default:
|
||
throw new Error("attribute invalid close char('/')");
|
||
}
|
||
break;
|
||
case "":
|
||
errorHandler.error("unexpected end of input");
|
||
if (s == S_TAG) {
|
||
el.setTagName(source.slice(start, p));
|
||
}
|
||
return p;
|
||
case ">":
|
||
switch (s) {
|
||
case S_TAG:
|
||
el.setTagName(source.slice(start, p));
|
||
case S_ATTR_END:
|
||
case S_TAG_SPACE:
|
||
case S_TAG_CLOSE:
|
||
break;
|
||
case S_ATTR_NOQUOT_VALUE:
|
||
case S_ATTR:
|
||
value = source.slice(start, p);
|
||
if (value.slice(-1) === "/") {
|
||
el.closed = true;
|
||
value = value.slice(0, -1);
|
||
}
|
||
case S_ATTR_SPACE:
|
||
if (s === S_ATTR_SPACE) {
|
||
value = attrName;
|
||
}
|
||
if (s == S_ATTR_NOQUOT_VALUE) {
|
||
errorHandler.warning('attribute "' + value + '" missed quot(")!');
|
||
addAttribute(attrName, value.replace(/&#?\w+;/g, entityReplacer), start);
|
||
} else {
|
||
if (!NAMESPACE.isHTML(currentNSMap[""]) || !value.match(/^(?:disabled|checked|selected)$/i)) {
|
||
errorHandler.warning('attribute "' + value + '" missed value!! "' + value + '" instead!!');
|
||
}
|
||
addAttribute(value, value, start);
|
||
}
|
||
break;
|
||
case S_EQ:
|
||
throw new Error("attribute value missed!!");
|
||
}
|
||
return p;
|
||
case "\x80":
|
||
c = " ";
|
||
default:
|
||
if (c <= " ") {
|
||
switch (s) {
|
||
case S_TAG:
|
||
el.setTagName(source.slice(start, p));
|
||
s = S_TAG_SPACE;
|
||
break;
|
||
case S_ATTR:
|
||
attrName = source.slice(start, p);
|
||
s = S_ATTR_SPACE;
|
||
break;
|
||
case S_ATTR_NOQUOT_VALUE:
|
||
var value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
|
||
errorHandler.warning('attribute "' + value + '" missed quot(")!!');
|
||
addAttribute(attrName, value, start);
|
||
case S_ATTR_END:
|
||
s = S_TAG_SPACE;
|
||
break;
|
||
}
|
||
} else {
|
||
switch (s) {
|
||
case S_ATTR_SPACE:
|
||
var tagName = el.tagName;
|
||
if (!NAMESPACE.isHTML(currentNSMap[""]) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
|
||
errorHandler.warning('attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!');
|
||
}
|
||
addAttribute(attrName, attrName, start);
|
||
start = p;
|
||
s = S_ATTR;
|
||
break;
|
||
case S_ATTR_END:
|
||
errorHandler.warning('attribute space is required"' + attrName + '"!!');
|
||
case S_TAG_SPACE:
|
||
s = S_ATTR;
|
||
start = p;
|
||
break;
|
||
case S_EQ:
|
||
s = S_ATTR_NOQUOT_VALUE;
|
||
start = p;
|
||
break;
|
||
case S_TAG_CLOSE:
|
||
throw new Error("elements closed character '/' and '>' must be connected to");
|
||
}
|
||
}
|
||
}
|
||
p++;
|
||
}
|
||
}
|
||
function appendElement(el, domBuilder, currentNSMap) {
|
||
var tagName = el.tagName;
|
||
var localNSMap = null;
|
||
var i = el.length;
|
||
while (i--) {
|
||
var a = el[i];
|
||
var qName = a.qName;
|
||
var value = a.value;
|
||
var nsp = qName.indexOf(":");
|
||
if (nsp > 0) {
|
||
var prefix = a.prefix = qName.slice(0, nsp);
|
||
var localName = qName.slice(nsp + 1);
|
||
var nsPrefix = prefix === "xmlns" && localName;
|
||
} else {
|
||
localName = qName;
|
||
prefix = null;
|
||
nsPrefix = qName === "xmlns" && "";
|
||
}
|
||
a.localName = localName;
|
||
if (nsPrefix !== false) {
|
||
if (localNSMap == null) {
|
||
localNSMap = {};
|
||
_copy(currentNSMap, currentNSMap = {});
|
||
}
|
||
currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
|
||
a.uri = NAMESPACE.XMLNS;
|
||
domBuilder.startPrefixMapping(nsPrefix, value);
|
||
}
|
||
}
|
||
var i = el.length;
|
||
while (i--) {
|
||
a = el[i];
|
||
var prefix = a.prefix;
|
||
if (prefix) {
|
||
if (prefix === "xml") {
|
||
a.uri = NAMESPACE.XML;
|
||
}
|
||
if (prefix !== "xmlns") {
|
||
a.uri = currentNSMap[prefix || ""];
|
||
}
|
||
}
|
||
}
|
||
var nsp = tagName.indexOf(":");
|
||
if (nsp > 0) {
|
||
prefix = el.prefix = tagName.slice(0, nsp);
|
||
localName = el.localName = tagName.slice(nsp + 1);
|
||
} else {
|
||
prefix = null;
|
||
localName = el.localName = tagName;
|
||
}
|
||
var ns = el.uri = currentNSMap[prefix || ""];
|
||
domBuilder.startElement(ns, localName, tagName, el);
|
||
if (el.closed) {
|
||
domBuilder.endElement(ns, localName, tagName);
|
||
if (localNSMap) {
|
||
for (prefix in localNSMap) {
|
||
if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
|
||
domBuilder.endPrefixMapping(prefix);
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
el.currentNSMap = currentNSMap;
|
||
el.localNSMap = localNSMap;
|
||
return true;
|
||
}
|
||
}
|
||
function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
|
||
if (/^(?:script|textarea)$/i.test(tagName)) {
|
||
var elEndStart = source.indexOf("</" + tagName + ">", elStartEnd);
|
||
var text = source.substring(elStartEnd + 1, elEndStart);
|
||
if (/[&<]/.test(text)) {
|
||
if (/^script$/i.test(tagName)) {
|
||
domBuilder.characters(text, 0, text.length);
|
||
return elEndStart;
|
||
}
|
||
text = text.replace(/&#?\w+;/g, entityReplacer);
|
||
domBuilder.characters(text, 0, text.length);
|
||
return elEndStart;
|
||
}
|
||
}
|
||
return elStartEnd + 1;
|
||
}
|
||
function fixSelfClosed(source, elStartEnd, tagName, closeMap) {
|
||
var pos = closeMap[tagName];
|
||
if (pos == null) {
|
||
pos = source.lastIndexOf("</" + tagName + ">");
|
||
if (pos < elStartEnd) {
|
||
pos = source.lastIndexOf("</" + tagName);
|
||
}
|
||
closeMap[tagName] = pos;
|
||
}
|
||
return pos < elStartEnd;
|
||
}
|
||
function _copy(source, target) {
|
||
for (var n in source) {
|
||
if (Object.prototype.hasOwnProperty.call(source, n)) {
|
||
target[n] = source[n];
|
||
}
|
||
}
|
||
}
|
||
function parseDCC(source, start, domBuilder, errorHandler) {
|
||
var next = source.charAt(start + 2);
|
||
switch (next) {
|
||
case "-":
|
||
if (source.charAt(start + 3) === "-") {
|
||
var end = source.indexOf("-->", start + 4);
|
||
if (end > start) {
|
||
domBuilder.comment(source, start + 4, end - start - 4);
|
||
return end + 3;
|
||
} else {
|
||
errorHandler.error("Unclosed comment");
|
||
return -1;
|
||
}
|
||
} else {
|
||
return -1;
|
||
}
|
||
default:
|
||
if (source.substr(start + 3, 6) == "CDATA[") {
|
||
var end = source.indexOf("]]>", start + 9);
|
||
domBuilder.startCDATA();
|
||
domBuilder.characters(source, start + 9, end - start - 9);
|
||
domBuilder.endCDATA();
|
||
return end + 3;
|
||
}
|
||
var matchs = split(source, start);
|
||
var len = matchs.length;
|
||
if (len > 1 && /!doctype/i.test(matchs[0][0])) {
|
||
var name = matchs[1][0];
|
||
var pubid = false;
|
||
var sysid = false;
|
||
if (len > 3) {
|
||
if (/^public$/i.test(matchs[2][0])) {
|
||
pubid = matchs[3][0];
|
||
sysid = len > 4 && matchs[4][0];
|
||
} else if (/^system$/i.test(matchs[2][0])) {
|
||
sysid = matchs[3][0];
|
||
}
|
||
}
|
||
var lastMatch = matchs[len - 1];
|
||
domBuilder.startDTD(name, pubid, sysid);
|
||
domBuilder.endDTD();
|
||
return lastMatch.index + lastMatch[0].length;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
function parseInstruction(source, start, domBuilder) {
|
||
var end = source.indexOf("?>", start);
|
||
if (end) {
|
||
var match = source.substring(start, end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
|
||
if (match) {
|
||
var len = match[0].length;
|
||
domBuilder.processingInstruction(match[1], match[2]);
|
||
return end + 2;
|
||
} else {
|
||
return -1;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
function ElementAttributes() {
|
||
this.attributeNames = {};
|
||
}
|
||
ElementAttributes.prototype = {
|
||
setTagName: function(tagName) {
|
||
if (!tagNamePattern.test(tagName)) {
|
||
throw new Error("invalid tagName:" + tagName);
|
||
}
|
||
this.tagName = tagName;
|
||
},
|
||
addValue: function(qName, value, offset) {
|
||
if (!tagNamePattern.test(qName)) {
|
||
throw new Error("invalid attribute:" + qName);
|
||
}
|
||
this.attributeNames[qName] = this.length;
|
||
this[this.length++] = { qName, value, offset };
|
||
},
|
||
length: 0,
|
||
getLocalName: function(i) {
|
||
return this[i].localName;
|
||
},
|
||
getLocator: function(i) {
|
||
return this[i].locator;
|
||
},
|
||
getQName: function(i) {
|
||
return this[i].qName;
|
||
},
|
||
getURI: function(i) {
|
||
return this[i].uri;
|
||
},
|
||
getValue: function(i) {
|
||
return this[i].value;
|
||
}
|
||
};
|
||
function split(source, start) {
|
||
var match;
|
||
var buf = [];
|
||
var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
|
||
reg.lastIndex = start;
|
||
reg.exec(source);
|
||
while (match = reg.exec(source)) {
|
||
buf.push(match);
|
||
if (match[1])
|
||
return buf;
|
||
}
|
||
}
|
||
exports.XMLReader = XMLReader;
|
||
exports.ParseError = ParseError;
|
||
}
|
||
});
|
||
|
||
// node_modules/@xmldom/xmldom/lib/dom-parser.js
|
||
var require_dom_parser = __commonJS({
|
||
"node_modules/@xmldom/xmldom/lib/dom-parser.js"(exports) {
|
||
var conventions = require_conventions();
|
||
var dom = require_dom();
|
||
var entities = require_entities();
|
||
var sax = require_sax();
|
||
var DOMImplementation = dom.DOMImplementation;
|
||
var NAMESPACE = conventions.NAMESPACE;
|
||
var ParseError = sax.ParseError;
|
||
var XMLReader = sax.XMLReader;
|
||
function DOMParser2(options) {
|
||
this.options = options || { locator: {} };
|
||
}
|
||
DOMParser2.prototype.parseFromString = function(source, mimeType) {
|
||
var options = this.options;
|
||
var sax2 = new XMLReader();
|
||
var domBuilder = options.domBuilder || new DOMHandler();
|
||
var errorHandler = options.errorHandler;
|
||
var locator = options.locator;
|
||
var defaultNSMap = options.xmlns || {};
|
||
var isHTML = /\/x?html?$/.test(mimeType);
|
||
var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES;
|
||
if (locator) {
|
||
domBuilder.setDocumentLocator(locator);
|
||
}
|
||
sax2.errorHandler = buildErrorHandler(errorHandler, domBuilder, locator);
|
||
sax2.domBuilder = options.domBuilder || domBuilder;
|
||
if (isHTML) {
|
||
defaultNSMap[""] = NAMESPACE.HTML;
|
||
}
|
||
defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
|
||
if (source && typeof source === "string") {
|
||
sax2.parse(source, defaultNSMap, entityMap);
|
||
} else {
|
||
sax2.errorHandler.error("invalid doc source");
|
||
}
|
||
return domBuilder.doc;
|
||
};
|
||
function buildErrorHandler(errorImpl, domBuilder, locator) {
|
||
if (!errorImpl) {
|
||
if (domBuilder instanceof DOMHandler) {
|
||
return domBuilder;
|
||
}
|
||
errorImpl = domBuilder;
|
||
}
|
||
var errorHandler = {};
|
||
var isCallback = errorImpl instanceof Function;
|
||
locator = locator || {};
|
||
function build(key) {
|
||
var fn = errorImpl[key];
|
||
if (!fn && isCallback) {
|
||
fn = errorImpl.length == 2 ? function(msg) {
|
||
errorImpl(key, msg);
|
||
} : errorImpl;
|
||
}
|
||
errorHandler[key] = fn && function(msg) {
|
||
fn("[xmldom " + key + "] " + msg + _locator(locator));
|
||
} || function() {
|
||
};
|
||
}
|
||
build("warning");
|
||
build("error");
|
||
build("fatalError");
|
||
return errorHandler;
|
||
}
|
||
function DOMHandler() {
|
||
this.cdata = false;
|
||
}
|
||
function position(locator, node) {
|
||
node.lineNumber = locator.lineNumber;
|
||
node.columnNumber = locator.columnNumber;
|
||
}
|
||
DOMHandler.prototype = {
|
||
startDocument: function() {
|
||
this.doc = new DOMImplementation().createDocument(null, null, null);
|
||
if (this.locator) {
|
||
this.doc.documentURI = this.locator.systemId;
|
||
}
|
||
},
|
||
startElement: function(namespaceURI, localName, qName, attrs) {
|
||
var doc = this.doc;
|
||
var el = doc.createElementNS(namespaceURI, qName || localName);
|
||
var len = attrs.length;
|
||
appendElement(this, el);
|
||
this.currentElement = el;
|
||
this.locator && position(this.locator, el);
|
||
for (var i = 0; i < len; i++) {
|
||
var namespaceURI = attrs.getURI(i);
|
||
var value = attrs.getValue(i);
|
||
var qName = attrs.getQName(i);
|
||
var attr = doc.createAttributeNS(namespaceURI, qName);
|
||
this.locator && position(attrs.getLocator(i), attr);
|
||
attr.value = attr.nodeValue = value;
|
||
el.setAttributeNode(attr);
|
||
}
|
||
},
|
||
endElement: function(namespaceURI, localName, qName) {
|
||
var current = this.currentElement;
|
||
var tagName = current.tagName;
|
||
this.currentElement = current.parentNode;
|
||
},
|
||
startPrefixMapping: function(prefix, uri) {
|
||
},
|
||
endPrefixMapping: function(prefix) {
|
||
},
|
||
processingInstruction: function(target, data) {
|
||
var ins = this.doc.createProcessingInstruction(target, data);
|
||
this.locator && position(this.locator, ins);
|
||
appendElement(this, ins);
|
||
},
|
||
ignorableWhitespace: function(ch, start, length) {
|
||
},
|
||
characters: function(chars, start, length) {
|
||
chars = _toString.apply(this, arguments);
|
||
if (chars) {
|
||
if (this.cdata) {
|
||
var charNode = this.doc.createCDATASection(chars);
|
||
} else {
|
||
var charNode = this.doc.createTextNode(chars);
|
||
}
|
||
if (this.currentElement) {
|
||
this.currentElement.appendChild(charNode);
|
||
} else if (/^\s*$/.test(chars)) {
|
||
this.doc.appendChild(charNode);
|
||
}
|
||
this.locator && position(this.locator, charNode);
|
||
}
|
||
},
|
||
skippedEntity: function(name) {
|
||
},
|
||
endDocument: function() {
|
||
this.doc.normalize();
|
||
},
|
||
setDocumentLocator: function(locator) {
|
||
if (this.locator = locator) {
|
||
locator.lineNumber = 0;
|
||
}
|
||
},
|
||
comment: function(chars, start, length) {
|
||
chars = _toString.apply(this, arguments);
|
||
var comm = this.doc.createComment(chars);
|
||
this.locator && position(this.locator, comm);
|
||
appendElement(this, comm);
|
||
},
|
||
startCDATA: function() {
|
||
this.cdata = true;
|
||
},
|
||
endCDATA: function() {
|
||
this.cdata = false;
|
||
},
|
||
startDTD: function(name, publicId, systemId) {
|
||
var impl = this.doc.implementation;
|
||
if (impl && impl.createDocumentType) {
|
||
var dt = impl.createDocumentType(name, publicId, systemId);
|
||
this.locator && position(this.locator, dt);
|
||
appendElement(this, dt);
|
||
this.doc.doctype = dt;
|
||
}
|
||
},
|
||
warning: function(error) {
|
||
console.warn("[xmldom warning] " + error, _locator(this.locator));
|
||
},
|
||
error: function(error) {
|
||
console.error("[xmldom error] " + error, _locator(this.locator));
|
||
},
|
||
fatalError: function(error) {
|
||
throw new ParseError(error, this.locator);
|
||
}
|
||
};
|
||
function _locator(l) {
|
||
if (l) {
|
||
return "\n@" + (l.systemId || "") + "#[line:" + l.lineNumber + ",col:" + l.columnNumber + "]";
|
||
}
|
||
}
|
||
function _toString(chars, start, length) {
|
||
if (typeof chars == "string") {
|
||
return chars.substr(start, length);
|
||
} else {
|
||
if (chars.length >= start + length || start) {
|
||
return new java.lang.String(chars, start, length) + "";
|
||
}
|
||
return chars;
|
||
}
|
||
}
|
||
"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, function(key) {
|
||
DOMHandler.prototype[key] = function() {
|
||
return null;
|
||
};
|
||
});
|
||
function appendElement(hander, node) {
|
||
if (!hander.currentElement) {
|
||
hander.doc.appendChild(node);
|
||
} else {
|
||
hander.currentElement.appendChild(node);
|
||
}
|
||
}
|
||
exports.__DOMHandler = DOMHandler;
|
||
exports.DOMParser = DOMParser2;
|
||
exports.DOMImplementation = dom.DOMImplementation;
|
||
exports.XMLSerializer = dom.XMLSerializer;
|
||
}
|
||
});
|
||
|
||
// node_modules/@xmldom/xmldom/lib/index.js
|
||
var require_lib = __commonJS({
|
||
"node_modules/@xmldom/xmldom/lib/index.js"(exports) {
|
||
var dom = require_dom();
|
||
exports.DOMImplementation = dom.DOMImplementation;
|
||
exports.XMLSerializer = dom.XMLSerializer;
|
||
exports.DOMParser = require_dom_parser().DOMParser;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/utils/core.js
|
||
var require_core = __commonJS({
|
||
"node_modules/epubjs/lib/utils/core.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.RangeObject = void 0;
|
||
exports.blob2base64 = blob2base64;
|
||
exports.borders = borders;
|
||
exports.bounds = bounds;
|
||
exports.createBase64Url = createBase64Url;
|
||
exports.createBlob = createBlob;
|
||
exports.createBlobUrl = createBlobUrl;
|
||
exports.defaults = defaults;
|
||
exports.defer = defer;
|
||
exports.documentHeight = documentHeight;
|
||
exports.extend = extend;
|
||
exports.filterChildren = filterChildren;
|
||
exports.findChildren = findChildren;
|
||
exports.getParentByTagName = getParentByTagName;
|
||
exports.indexOfElementNode = indexOfElementNode;
|
||
exports.indexOfNode = indexOfNode;
|
||
exports.indexOfSorted = indexOfSorted;
|
||
exports.indexOfTextNode = indexOfTextNode;
|
||
exports.insert = insert;
|
||
exports.isElement = isElement;
|
||
exports.isFloat = isFloat;
|
||
exports.isNumber = isNumber;
|
||
exports.isXml = isXml;
|
||
exports.locationOf = locationOf;
|
||
exports.nodeBounds = nodeBounds;
|
||
exports.parents = parents;
|
||
exports.parse = parse;
|
||
exports.prefixed = prefixed;
|
||
exports.qs = qs;
|
||
exports.qsa = qsa;
|
||
exports.qsp = qsp;
|
||
exports.querySelectorByType = querySelectorByType;
|
||
exports.requestAnimationFrame = void 0;
|
||
exports.revokeBlobUrl = revokeBlobUrl;
|
||
exports.sprint = sprint;
|
||
exports.treeWalker = treeWalker;
|
||
exports.type = type;
|
||
exports.uuid = uuid;
|
||
exports.walk = walk;
|
||
exports.windowBounds = windowBounds;
|
||
var _xmldom = require_lib();
|
||
var requestAnimationFrame2 = typeof window != "undefined" ? window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame : false;
|
||
exports.requestAnimationFrame = requestAnimationFrame2;
|
||
var ELEMENT_NODE = 1;
|
||
var TEXT_NODE = 3;
|
||
var _URL = typeof URL != "undefined" ? URL : typeof window != "undefined" ? window.URL || window.webkitURL || window.mozURL : void 0;
|
||
function uuid() {
|
||
var d = new Date().getTime();
|
||
var uuid2 = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
||
var r = (d + Math.random() * 16) % 16 | 0;
|
||
d = Math.floor(d / 16);
|
||
return (c == "x" ? r : r & 7 | 8).toString(16);
|
||
});
|
||
return uuid2;
|
||
}
|
||
function documentHeight() {
|
||
return Math.max(document.documentElement.clientHeight, document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight);
|
||
}
|
||
function isElement(obj) {
|
||
return !!(obj && obj.nodeType == 1);
|
||
}
|
||
function isNumber(n) {
|
||
return !isNaN(parseFloat(n)) && isFinite(n);
|
||
}
|
||
function isFloat(n) {
|
||
let f = parseFloat(n);
|
||
if (isNumber(n) === false) {
|
||
return false;
|
||
}
|
||
if (typeof n === "string" && n.indexOf(".") > -1) {
|
||
return true;
|
||
}
|
||
return Math.floor(f) !== f;
|
||
}
|
||
function prefixed(unprefixed) {
|
||
var vendors = ["Webkit", "webkit", "Moz", "O", "ms"];
|
||
var prefixes = ["-webkit-", "-webkit-", "-moz-", "-o-", "-ms-"];
|
||
var lower = unprefixed.toLowerCase();
|
||
var length = vendors.length;
|
||
if (typeof document === "undefined" || typeof document.body.style[lower] != "undefined") {
|
||
return unprefixed;
|
||
}
|
||
for (var i = 0; i < length; i++) {
|
||
if (typeof document.body.style[prefixes[i] + lower] != "undefined") {
|
||
return prefixes[i] + lower;
|
||
}
|
||
}
|
||
return unprefixed;
|
||
}
|
||
function defaults(obj) {
|
||
for (var i = 1, length = arguments.length; i < length; i++) {
|
||
var source = arguments[i];
|
||
for (var prop in source) {
|
||
if (obj[prop] === void 0)
|
||
obj[prop] = source[prop];
|
||
}
|
||
}
|
||
return obj;
|
||
}
|
||
function extend(target) {
|
||
var sources = [].slice.call(arguments, 1);
|
||
sources.forEach(function(source) {
|
||
if (!source)
|
||
return;
|
||
Object.getOwnPropertyNames(source).forEach(function(propName) {
|
||
Object.defineProperty(target, propName, Object.getOwnPropertyDescriptor(source, propName));
|
||
});
|
||
});
|
||
return target;
|
||
}
|
||
function insert(item, array, compareFunction) {
|
||
var location = locationOf(item, array, compareFunction);
|
||
array.splice(location, 0, item);
|
||
return location;
|
||
}
|
||
function locationOf(item, array, compareFunction, _start, _end) {
|
||
var start = _start || 0;
|
||
var end = _end || array.length;
|
||
var pivot = parseInt(start + (end - start) / 2);
|
||
var compared;
|
||
if (!compareFunction) {
|
||
compareFunction = function(a, b) {
|
||
if (a > b)
|
||
return 1;
|
||
if (a < b)
|
||
return -1;
|
||
if (a == b)
|
||
return 0;
|
||
};
|
||
}
|
||
if (end - start <= 0) {
|
||
return pivot;
|
||
}
|
||
compared = compareFunction(array[pivot], item);
|
||
if (end - start === 1) {
|
||
return compared >= 0 ? pivot : pivot + 1;
|
||
}
|
||
if (compared === 0) {
|
||
return pivot;
|
||
}
|
||
if (compared === -1) {
|
||
return locationOf(item, array, compareFunction, pivot, end);
|
||
} else {
|
||
return locationOf(item, array, compareFunction, start, pivot);
|
||
}
|
||
}
|
||
function indexOfSorted(item, array, compareFunction, _start, _end) {
|
||
var start = _start || 0;
|
||
var end = _end || array.length;
|
||
var pivot = parseInt(start + (end - start) / 2);
|
||
var compared;
|
||
if (!compareFunction) {
|
||
compareFunction = function(a, b) {
|
||
if (a > b)
|
||
return 1;
|
||
if (a < b)
|
||
return -1;
|
||
if (a == b)
|
||
return 0;
|
||
};
|
||
}
|
||
if (end - start <= 0) {
|
||
return -1;
|
||
}
|
||
compared = compareFunction(array[pivot], item);
|
||
if (end - start === 1) {
|
||
return compared === 0 ? pivot : -1;
|
||
}
|
||
if (compared === 0) {
|
||
return pivot;
|
||
}
|
||
if (compared === -1) {
|
||
return indexOfSorted(item, array, compareFunction, pivot, end);
|
||
} else {
|
||
return indexOfSorted(item, array, compareFunction, start, pivot);
|
||
}
|
||
}
|
||
function bounds(el) {
|
||
var style = window.getComputedStyle(el);
|
||
var widthProps = ["width", "paddingRight", "paddingLeft", "marginRight", "marginLeft", "borderRightWidth", "borderLeftWidth"];
|
||
var heightProps = ["height", "paddingTop", "paddingBottom", "marginTop", "marginBottom", "borderTopWidth", "borderBottomWidth"];
|
||
var width = 0;
|
||
var height = 0;
|
||
widthProps.forEach(function(prop) {
|
||
width += parseFloat(style[prop]) || 0;
|
||
});
|
||
heightProps.forEach(function(prop) {
|
||
height += parseFloat(style[prop]) || 0;
|
||
});
|
||
return {
|
||
height,
|
||
width
|
||
};
|
||
}
|
||
function borders(el) {
|
||
var style = window.getComputedStyle(el);
|
||
var widthProps = ["paddingRight", "paddingLeft", "marginRight", "marginLeft", "borderRightWidth", "borderLeftWidth"];
|
||
var heightProps = ["paddingTop", "paddingBottom", "marginTop", "marginBottom", "borderTopWidth", "borderBottomWidth"];
|
||
var width = 0;
|
||
var height = 0;
|
||
widthProps.forEach(function(prop) {
|
||
width += parseFloat(style[prop]) || 0;
|
||
});
|
||
heightProps.forEach(function(prop) {
|
||
height += parseFloat(style[prop]) || 0;
|
||
});
|
||
return {
|
||
height,
|
||
width
|
||
};
|
||
}
|
||
function nodeBounds(node) {
|
||
let elPos;
|
||
let doc = node.ownerDocument;
|
||
if (node.nodeType == Node.TEXT_NODE) {
|
||
let elRange = doc.createRange();
|
||
elRange.selectNodeContents(node);
|
||
elPos = elRange.getBoundingClientRect();
|
||
} else {
|
||
elPos = node.getBoundingClientRect();
|
||
}
|
||
return elPos;
|
||
}
|
||
function windowBounds() {
|
||
var width = window.innerWidth;
|
||
var height = window.innerHeight;
|
||
return {
|
||
top: 0,
|
||
left: 0,
|
||
right: width,
|
||
bottom: height,
|
||
width,
|
||
height
|
||
};
|
||
}
|
||
function indexOfNode(node, typeId) {
|
||
var parent2 = node.parentNode;
|
||
var children = parent2.childNodes;
|
||
var sib;
|
||
var index = -1;
|
||
for (var i = 0; i < children.length; i++) {
|
||
sib = children[i];
|
||
if (sib.nodeType === typeId) {
|
||
index++;
|
||
}
|
||
if (sib == node)
|
||
break;
|
||
}
|
||
return index;
|
||
}
|
||
function indexOfTextNode(textNode) {
|
||
return indexOfNode(textNode, TEXT_NODE);
|
||
}
|
||
function indexOfElementNode(elementNode) {
|
||
return indexOfNode(elementNode, ELEMENT_NODE);
|
||
}
|
||
function isXml(ext) {
|
||
return ["xml", "opf", "ncx"].indexOf(ext) > -1;
|
||
}
|
||
function createBlob(content, mime) {
|
||
return new Blob([content], {
|
||
type: mime
|
||
});
|
||
}
|
||
function createBlobUrl(content, mime) {
|
||
var tempUrl;
|
||
var blob = createBlob(content, mime);
|
||
tempUrl = _URL.createObjectURL(blob);
|
||
return tempUrl;
|
||
}
|
||
function revokeBlobUrl(url) {
|
||
return _URL.revokeObjectURL(url);
|
||
}
|
||
function createBase64Url(content, mime) {
|
||
var data;
|
||
var datauri;
|
||
if (typeof content !== "string") {
|
||
return;
|
||
}
|
||
data = btoa(content);
|
||
datauri = "data:" + mime + ";base64," + data;
|
||
return datauri;
|
||
}
|
||
function type(obj) {
|
||
return Object.prototype.toString.call(obj).slice(8, -1);
|
||
}
|
||
function parse(markup, mime, forceXMLDom) {
|
||
var doc;
|
||
var Parser;
|
||
if (typeof DOMParser === "undefined" || forceXMLDom) {
|
||
Parser = _xmldom.DOMParser;
|
||
} else {
|
||
Parser = DOMParser;
|
||
}
|
||
if (markup.charCodeAt(0) === 65279) {
|
||
markup = markup.slice(1);
|
||
}
|
||
doc = new Parser().parseFromString(markup, mime);
|
||
return doc;
|
||
}
|
||
function qs(el, sel) {
|
||
var elements;
|
||
if (!el) {
|
||
throw new Error("No Element Provided");
|
||
}
|
||
if (typeof el.querySelector != "undefined") {
|
||
return el.querySelector(sel);
|
||
} else {
|
||
elements = el.getElementsByTagName(sel);
|
||
if (elements.length) {
|
||
return elements[0];
|
||
}
|
||
}
|
||
}
|
||
function qsa(el, sel) {
|
||
if (typeof el.querySelector != "undefined") {
|
||
return el.querySelectorAll(sel);
|
||
} else {
|
||
return el.getElementsByTagName(sel);
|
||
}
|
||
}
|
||
function qsp(el, sel, props) {
|
||
var q, filtered;
|
||
if (typeof el.querySelector != "undefined") {
|
||
sel += "[";
|
||
for (var prop in props) {
|
||
sel += prop + "~='" + props[prop] + "'";
|
||
}
|
||
sel += "]";
|
||
return el.querySelector(sel);
|
||
} else {
|
||
q = el.getElementsByTagName(sel);
|
||
filtered = Array.prototype.slice.call(q, 0).filter(function(el2) {
|
||
for (var prop2 in props) {
|
||
if (el2.getAttribute(prop2) === props[prop2]) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
});
|
||
if (filtered) {
|
||
return filtered[0];
|
||
}
|
||
}
|
||
}
|
||
function sprint(root, func) {
|
||
var doc = root.ownerDocument || root;
|
||
if (typeof doc.createTreeWalker !== "undefined") {
|
||
treeWalker(root, func, NodeFilter.SHOW_TEXT);
|
||
} else {
|
||
walk(root, function(node) {
|
||
if (node && node.nodeType === 3) {
|
||
func(node);
|
||
}
|
||
}, true);
|
||
}
|
||
}
|
||
function treeWalker(root, func, filter) {
|
||
var treeWalker2 = document.createTreeWalker(root, filter, null, false);
|
||
let node;
|
||
while (node = treeWalker2.nextNode()) {
|
||
func(node);
|
||
}
|
||
}
|
||
function walk(node, callback) {
|
||
if (callback(node)) {
|
||
return true;
|
||
}
|
||
node = node.firstChild;
|
||
if (node) {
|
||
do {
|
||
let walked = walk(node, callback);
|
||
if (walked) {
|
||
return true;
|
||
}
|
||
node = node.nextSibling;
|
||
} while (node);
|
||
}
|
||
}
|
||
function blob2base64(blob) {
|
||
return new Promise(function(resolve, reject) {
|
||
var reader = new FileReader();
|
||
reader.readAsDataURL(blob);
|
||
reader.onloadend = function() {
|
||
resolve(reader.result);
|
||
};
|
||
});
|
||
}
|
||
function defer() {
|
||
this.resolve = null;
|
||
this.reject = null;
|
||
this.id = uuid();
|
||
this.promise = new Promise((resolve, reject) => {
|
||
this.resolve = resolve;
|
||
this.reject = reject;
|
||
});
|
||
Object.freeze(this);
|
||
}
|
||
function querySelectorByType(html, element, type2) {
|
||
var query;
|
||
if (typeof html.querySelector != "undefined") {
|
||
query = html.querySelector(`${element}[*|type="${type2}"]`);
|
||
}
|
||
if (!query || query.length === 0) {
|
||
query = qsa(html, element);
|
||
for (var i = 0; i < query.length; i++) {
|
||
if (query[i].getAttributeNS("http://www.idpf.org/2007/ops", "type") === type2 || query[i].getAttribute("epub:type") === type2) {
|
||
return query[i];
|
||
}
|
||
}
|
||
} else {
|
||
return query;
|
||
}
|
||
}
|
||
function findChildren(el) {
|
||
var result = [];
|
||
var childNodes = el.childNodes;
|
||
for (var i = 0; i < childNodes.length; i++) {
|
||
let node = childNodes[i];
|
||
if (node.nodeType === 1) {
|
||
result.push(node);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
function parents(node) {
|
||
var nodes = [node];
|
||
for (; node; node = node.parentNode) {
|
||
nodes.unshift(node);
|
||
}
|
||
return nodes;
|
||
}
|
||
function filterChildren(el, nodeName, single) {
|
||
var result = [];
|
||
var childNodes = el.childNodes;
|
||
for (var i = 0; i < childNodes.length; i++) {
|
||
let node = childNodes[i];
|
||
if (node.nodeType === 1 && node.nodeName.toLowerCase() === nodeName) {
|
||
if (single) {
|
||
return node;
|
||
} else {
|
||
result.push(node);
|
||
}
|
||
}
|
||
}
|
||
if (!single) {
|
||
return result;
|
||
}
|
||
}
|
||
function getParentByTagName(node, tagname) {
|
||
let parent2;
|
||
if (node === null || tagname === "")
|
||
return;
|
||
parent2 = node.parentNode;
|
||
while (parent2.nodeType === 1) {
|
||
if (parent2.tagName.toLowerCase() === tagname) {
|
||
return parent2;
|
||
}
|
||
parent2 = parent2.parentNode;
|
||
}
|
||
}
|
||
var RangeObject = class {
|
||
constructor() {
|
||
this.collapsed = false;
|
||
this.commonAncestorContainer = void 0;
|
||
this.endContainer = void 0;
|
||
this.endOffset = void 0;
|
||
this.startContainer = void 0;
|
||
this.startOffset = void 0;
|
||
}
|
||
setStart(startNode, startOffset) {
|
||
this.startContainer = startNode;
|
||
this.startOffset = startOffset;
|
||
if (!this.endContainer) {
|
||
this.collapse(true);
|
||
} else {
|
||
this.commonAncestorContainer = this._commonAncestorContainer();
|
||
}
|
||
this._checkCollapsed();
|
||
}
|
||
setEnd(endNode, endOffset) {
|
||
this.endContainer = endNode;
|
||
this.endOffset = endOffset;
|
||
if (!this.startContainer) {
|
||
this.collapse(false);
|
||
} else {
|
||
this.collapsed = false;
|
||
this.commonAncestorContainer = this._commonAncestorContainer();
|
||
}
|
||
this._checkCollapsed();
|
||
}
|
||
collapse(toStart) {
|
||
this.collapsed = true;
|
||
if (toStart) {
|
||
this.endContainer = this.startContainer;
|
||
this.endOffset = this.startOffset;
|
||
this.commonAncestorContainer = this.startContainer.parentNode;
|
||
} else {
|
||
this.startContainer = this.endContainer;
|
||
this.startOffset = this.endOffset;
|
||
this.commonAncestorContainer = this.endOffset.parentNode;
|
||
}
|
||
}
|
||
selectNode(referenceNode) {
|
||
let parent2 = referenceNode.parentNode;
|
||
let index = Array.prototype.indexOf.call(parent2.childNodes, referenceNode);
|
||
this.setStart(parent2, index);
|
||
this.setEnd(parent2, index + 1);
|
||
}
|
||
selectNodeContents(referenceNode) {
|
||
let end = referenceNode.childNodes[referenceNode.childNodes - 1];
|
||
let endIndex = referenceNode.nodeType === 3 ? referenceNode.textContent.length : parent.childNodes.length;
|
||
this.setStart(referenceNode, 0);
|
||
this.setEnd(referenceNode, endIndex);
|
||
}
|
||
_commonAncestorContainer(startContainer, endContainer) {
|
||
var startParents = parents(startContainer || this.startContainer);
|
||
var endParents = parents(endContainer || this.endContainer);
|
||
if (startParents[0] != endParents[0])
|
||
return void 0;
|
||
for (var i = 0; i < startParents.length; i++) {
|
||
if (startParents[i] != endParents[i]) {
|
||
return startParents[i - 1];
|
||
}
|
||
}
|
||
}
|
||
_checkCollapsed() {
|
||
if (this.startContainer === this.endContainer && this.startOffset === this.endOffset) {
|
||
this.collapsed = true;
|
||
} else {
|
||
this.collapsed = false;
|
||
}
|
||
}
|
||
toString() {
|
||
}
|
||
};
|
||
exports.RangeObject = RangeObject;
|
||
}
|
||
});
|
||
|
||
// node_modules/path-webpack/path.js
|
||
var require_path = __commonJS({
|
||
"node_modules/path-webpack/path.js"(exports, module2) {
|
||
"use strict";
|
||
if (!process2) {
|
||
process2 = {
|
||
"cwd": function() {
|
||
return "/";
|
||
}
|
||
};
|
||
}
|
||
var process2;
|
||
function assertPath(path) {
|
||
if (typeof path !== "string") {
|
||
throw new TypeError("Path must be a string. Received " + path);
|
||
}
|
||
}
|
||
function normalizeStringPosix(path, allowAboveRoot) {
|
||
var res = "";
|
||
var lastSlash = -1;
|
||
var dots = 0;
|
||
var code;
|
||
for (var i = 0; i <= path.length; ++i) {
|
||
if (i < path.length)
|
||
code = path.charCodeAt(i);
|
||
else if (code === 47)
|
||
break;
|
||
else
|
||
code = 47;
|
||
if (code === 47) {
|
||
if (lastSlash === i - 1 || dots === 1) {
|
||
} else if (lastSlash !== i - 1 && dots === 2) {
|
||
if (res.length < 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
|
||
if (res.length > 2) {
|
||
var start = res.length - 1;
|
||
var j = start;
|
||
for (; j >= 0; --j) {
|
||
if (res.charCodeAt(j) === 47)
|
||
break;
|
||
}
|
||
if (j !== start) {
|
||
if (j === -1)
|
||
res = "";
|
||
else
|
||
res = res.slice(0, j);
|
||
lastSlash = i;
|
||
dots = 0;
|
||
continue;
|
||
}
|
||
} else if (res.length === 2 || res.length === 1) {
|
||
res = "";
|
||
lastSlash = i;
|
||
dots = 0;
|
||
continue;
|
||
}
|
||
}
|
||
if (allowAboveRoot) {
|
||
if (res.length > 0)
|
||
res += "/..";
|
||
else
|
||
res = "..";
|
||
}
|
||
} else {
|
||
if (res.length > 0)
|
||
res += "/" + path.slice(lastSlash + 1, i);
|
||
else
|
||
res = path.slice(lastSlash + 1, i);
|
||
}
|
||
lastSlash = i;
|
||
dots = 0;
|
||
} else if (code === 46 && dots !== -1) {
|
||
++dots;
|
||
} else {
|
||
dots = -1;
|
||
}
|
||
}
|
||
return res;
|
||
}
|
||
function _format(sep, pathObject) {
|
||
var dir = pathObject.dir || pathObject.root;
|
||
var base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
|
||
if (!dir) {
|
||
return base;
|
||
}
|
||
if (dir === pathObject.root) {
|
||
return dir + base;
|
||
}
|
||
return dir + sep + base;
|
||
}
|
||
var posix = {
|
||
resolve: function resolve() {
|
||
var resolvedPath = "";
|
||
var resolvedAbsolute = false;
|
||
var cwd;
|
||
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
||
var path;
|
||
if (i >= 0)
|
||
path = arguments[i];
|
||
else {
|
||
if (cwd === void 0)
|
||
cwd = process2.cwd();
|
||
path = cwd;
|
||
}
|
||
assertPath(path);
|
||
if (path.length === 0) {
|
||
continue;
|
||
}
|
||
resolvedPath = path + "/" + resolvedPath;
|
||
resolvedAbsolute = path.charCodeAt(0) === 47;
|
||
}
|
||
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
||
if (resolvedAbsolute) {
|
||
if (resolvedPath.length > 0)
|
||
return "/" + resolvedPath;
|
||
else
|
||
return "/";
|
||
} else if (resolvedPath.length > 0) {
|
||
return resolvedPath;
|
||
} else {
|
||
return ".";
|
||
}
|
||
},
|
||
normalize: function normalize(path) {
|
||
assertPath(path);
|
||
if (path.length === 0)
|
||
return ".";
|
||
var isAbsolute = path.charCodeAt(0) === 47;
|
||
var trailingSeparator = path.charCodeAt(path.length - 1) === 47;
|
||
path = normalizeStringPosix(path, !isAbsolute);
|
||
if (path.length === 0 && !isAbsolute)
|
||
path = ".";
|
||
if (path.length > 0 && trailingSeparator)
|
||
path += "/";
|
||
if (isAbsolute)
|
||
return "/" + path;
|
||
return path;
|
||
},
|
||
isAbsolute: function isAbsolute(path) {
|
||
assertPath(path);
|
||
return path.length > 0 && path.charCodeAt(0) === 47;
|
||
},
|
||
join: function join() {
|
||
if (arguments.length === 0)
|
||
return ".";
|
||
var joined;
|
||
for (var i = 0; i < arguments.length; ++i) {
|
||
var arg = arguments[i];
|
||
assertPath(arg);
|
||
if (arg.length > 0) {
|
||
if (joined === void 0)
|
||
joined = arg;
|
||
else
|
||
joined += "/" + arg;
|
||
}
|
||
}
|
||
if (joined === void 0)
|
||
return ".";
|
||
return posix.normalize(joined);
|
||
},
|
||
relative: function relative(from, to) {
|
||
assertPath(from);
|
||
assertPath(to);
|
||
if (from === to)
|
||
return "";
|
||
from = posix.resolve(from);
|
||
to = posix.resolve(to);
|
||
if (from === to)
|
||
return "";
|
||
var fromStart = 1;
|
||
for (; fromStart < from.length; ++fromStart) {
|
||
if (from.charCodeAt(fromStart) !== 47)
|
||
break;
|
||
}
|
||
var fromEnd = from.length;
|
||
var fromLen = fromEnd - fromStart;
|
||
var toStart = 1;
|
||
for (; toStart < to.length; ++toStart) {
|
||
if (to.charCodeAt(toStart) !== 47)
|
||
break;
|
||
}
|
||
var toEnd = to.length;
|
||
var toLen = toEnd - toStart;
|
||
var length = fromLen < toLen ? fromLen : toLen;
|
||
var lastCommonSep = -1;
|
||
var i = 0;
|
||
for (; i <= length; ++i) {
|
||
if (i === length) {
|
||
if (toLen > length) {
|
||
if (to.charCodeAt(toStart + i) === 47) {
|
||
return to.slice(toStart + i + 1);
|
||
} else if (i === 0) {
|
||
return to.slice(toStart + i);
|
||
}
|
||
} else if (fromLen > length) {
|
||
if (from.charCodeAt(fromStart + i) === 47) {
|
||
lastCommonSep = i;
|
||
} else if (i === 0) {
|
||
lastCommonSep = 0;
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
var fromCode = from.charCodeAt(fromStart + i);
|
||
var toCode = to.charCodeAt(toStart + i);
|
||
if (fromCode !== toCode)
|
||
break;
|
||
else if (fromCode === 47)
|
||
lastCommonSep = i;
|
||
}
|
||
var out = "";
|
||
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
||
if (i === fromEnd || from.charCodeAt(i) === 47) {
|
||
if (out.length === 0)
|
||
out += "..";
|
||
else
|
||
out += "/..";
|
||
}
|
||
}
|
||
if (out.length > 0)
|
||
return out + to.slice(toStart + lastCommonSep);
|
||
else {
|
||
toStart += lastCommonSep;
|
||
if (to.charCodeAt(toStart) === 47)
|
||
++toStart;
|
||
return to.slice(toStart);
|
||
}
|
||
},
|
||
_makeLong: function _makeLong(path) {
|
||
return path;
|
||
},
|
||
dirname: function dirname(path) {
|
||
assertPath(path);
|
||
if (path.length === 0)
|
||
return ".";
|
||
var code = path.charCodeAt(0);
|
||
var hasRoot = code === 47;
|
||
var end = -1;
|
||
var matchedSlash = true;
|
||
for (var i = path.length - 1; i >= 1; --i) {
|
||
code = path.charCodeAt(i);
|
||
if (code === 47) {
|
||
if (!matchedSlash) {
|
||
end = i;
|
||
break;
|
||
}
|
||
} else {
|
||
matchedSlash = false;
|
||
}
|
||
}
|
||
if (end === -1)
|
||
return hasRoot ? "/" : ".";
|
||
if (hasRoot && end === 1)
|
||
return "//";
|
||
return path.slice(0, end);
|
||
},
|
||
basename: function basename(path, ext) {
|
||
if (ext !== void 0 && typeof ext !== "string")
|
||
throw new TypeError('"ext" argument must be a string');
|
||
assertPath(path);
|
||
var start = 0;
|
||
var end = -1;
|
||
var matchedSlash = true;
|
||
var i;
|
||
if (ext !== void 0 && ext.length > 0 && ext.length <= path.length) {
|
||
if (ext.length === path.length && ext === path)
|
||
return "";
|
||
var extIdx = ext.length - 1;
|
||
var firstNonSlashEnd = -1;
|
||
for (i = path.length - 1; i >= 0; --i) {
|
||
var code = path.charCodeAt(i);
|
||
if (code === 47) {
|
||
if (!matchedSlash) {
|
||
start = i + 1;
|
||
break;
|
||
}
|
||
} else {
|
||
if (firstNonSlashEnd === -1) {
|
||
matchedSlash = false;
|
||
firstNonSlashEnd = i + 1;
|
||
}
|
||
if (extIdx >= 0) {
|
||
if (code === ext.charCodeAt(extIdx)) {
|
||
if (--extIdx === -1) {
|
||
end = i;
|
||
}
|
||
} else {
|
||
extIdx = -1;
|
||
end = firstNonSlashEnd;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (start === end)
|
||
end = firstNonSlashEnd;
|
||
else if (end === -1)
|
||
end = path.length;
|
||
return path.slice(start, end);
|
||
} else {
|
||
for (i = path.length - 1; i >= 0; --i) {
|
||
if (path.charCodeAt(i) === 47) {
|
||
if (!matchedSlash) {
|
||
start = i + 1;
|
||
break;
|
||
}
|
||
} else if (end === -1) {
|
||
matchedSlash = false;
|
||
end = i + 1;
|
||
}
|
||
}
|
||
if (end === -1)
|
||
return "";
|
||
return path.slice(start, end);
|
||
}
|
||
},
|
||
extname: function extname(path) {
|
||
assertPath(path);
|
||
var startDot = -1;
|
||
var startPart = 0;
|
||
var end = -1;
|
||
var matchedSlash = true;
|
||
var preDotState = 0;
|
||
for (var i = path.length - 1; i >= 0; --i) {
|
||
var code = path.charCodeAt(i);
|
||
if (code === 47) {
|
||
if (!matchedSlash) {
|
||
startPart = i + 1;
|
||
break;
|
||
}
|
||
continue;
|
||
}
|
||
if (end === -1) {
|
||
matchedSlash = false;
|
||
end = i + 1;
|
||
}
|
||
if (code === 46) {
|
||
if (startDot === -1)
|
||
startDot = i;
|
||
else if (preDotState !== 1)
|
||
preDotState = 1;
|
||
} else if (startDot !== -1) {
|
||
preDotState = -1;
|
||
}
|
||
}
|
||
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
||
return "";
|
||
}
|
||
return path.slice(startDot, end);
|
||
},
|
||
format: function format(pathObject) {
|
||
if (pathObject === null || typeof pathObject !== "object") {
|
||
throw new TypeError('Parameter "pathObject" must be an object, not ' + typeof pathObject);
|
||
}
|
||
return _format("/", pathObject);
|
||
},
|
||
parse: function parse(path) {
|
||
assertPath(path);
|
||
var ret = { root: "", dir: "", base: "", ext: "", name: "" };
|
||
if (path.length === 0)
|
||
return ret;
|
||
var code = path.charCodeAt(0);
|
||
var isAbsolute = code === 47;
|
||
var start;
|
||
if (isAbsolute) {
|
||
ret.root = "/";
|
||
start = 1;
|
||
} else {
|
||
start = 0;
|
||
}
|
||
var startDot = -1;
|
||
var startPart = 0;
|
||
var end = -1;
|
||
var matchedSlash = true;
|
||
var i = path.length - 1;
|
||
var preDotState = 0;
|
||
for (; i >= start; --i) {
|
||
code = path.charCodeAt(i);
|
||
if (code === 47) {
|
||
if (!matchedSlash) {
|
||
startPart = i + 1;
|
||
break;
|
||
}
|
||
continue;
|
||
}
|
||
if (end === -1) {
|
||
matchedSlash = false;
|
||
end = i + 1;
|
||
}
|
||
if (code === 46) {
|
||
if (startDot === -1)
|
||
startDot = i;
|
||
else if (preDotState !== 1)
|
||
preDotState = 1;
|
||
} else if (startDot !== -1) {
|
||
preDotState = -1;
|
||
}
|
||
}
|
||
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
||
if (end !== -1) {
|
||
if (startPart === 0 && isAbsolute)
|
||
ret.base = ret.name = path.slice(1, end);
|
||
else
|
||
ret.base = ret.name = path.slice(startPart, end);
|
||
}
|
||
} else {
|
||
if (startPart === 0 && isAbsolute) {
|
||
ret.name = path.slice(1, startDot);
|
||
ret.base = path.slice(1, end);
|
||
} else {
|
||
ret.name = path.slice(startPart, startDot);
|
||
ret.base = path.slice(startPart, end);
|
||
}
|
||
ret.ext = path.slice(startDot, end);
|
||
}
|
||
if (startPart > 0)
|
||
ret.dir = path.slice(0, startPart - 1);
|
||
else if (isAbsolute)
|
||
ret.dir = "/";
|
||
return ret;
|
||
},
|
||
sep: "/",
|
||
delimiter: ":",
|
||
posix: null
|
||
};
|
||
module2.exports = posix;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/utils/path.js
|
||
var require_path2 = __commonJS({
|
||
"node_modules/epubjs/lib/utils/path.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _pathWebpack = _interopRequireDefault(require_path());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Path = class {
|
||
constructor(pathString) {
|
||
var protocol;
|
||
var parsed;
|
||
protocol = pathString.indexOf("://");
|
||
if (protocol > -1) {
|
||
pathString = new URL(pathString).pathname;
|
||
}
|
||
parsed = this.parse(pathString);
|
||
this.path = pathString;
|
||
if (this.isDirectory(pathString)) {
|
||
this.directory = pathString;
|
||
} else {
|
||
this.directory = parsed.dir + "/";
|
||
}
|
||
this.filename = parsed.base;
|
||
this.extension = parsed.ext.slice(1);
|
||
}
|
||
parse(what) {
|
||
return _pathWebpack.default.parse(what);
|
||
}
|
||
isAbsolute(what) {
|
||
return _pathWebpack.default.isAbsolute(what || this.path);
|
||
}
|
||
isDirectory(what) {
|
||
return what.charAt(what.length - 1) === "/";
|
||
}
|
||
resolve(what) {
|
||
return _pathWebpack.default.resolve(this.directory, what);
|
||
}
|
||
relative(what) {
|
||
var isAbsolute = what && what.indexOf("://") > -1;
|
||
if (isAbsolute) {
|
||
return what;
|
||
}
|
||
return _pathWebpack.default.relative(this.directory, what);
|
||
}
|
||
splitPath(filename) {
|
||
return this.splitPathRe.exec(filename).slice(1);
|
||
}
|
||
toString() {
|
||
return this.path;
|
||
}
|
||
};
|
||
var _default = Path;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/utils/url.js
|
||
var require_url = __commonJS({
|
||
"node_modules/epubjs/lib/utils/url.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _path = _interopRequireDefault(require_path2());
|
||
var _pathWebpack = _interopRequireDefault(require_path());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Url = class {
|
||
constructor(urlString, baseString) {
|
||
var absolute = urlString.indexOf("://") > -1;
|
||
var pathname = urlString;
|
||
var basePath;
|
||
this.Url = void 0;
|
||
this.href = urlString;
|
||
this.protocol = "";
|
||
this.origin = "";
|
||
this.hash = "";
|
||
this.hash = "";
|
||
this.search = "";
|
||
this.base = baseString;
|
||
if (!absolute && baseString !== false && typeof baseString !== "string" && window && window.location) {
|
||
this.base = window.location.href;
|
||
}
|
||
if (absolute || this.base) {
|
||
try {
|
||
if (this.base) {
|
||
this.Url = new URL(urlString, this.base);
|
||
} else {
|
||
this.Url = new URL(urlString);
|
||
}
|
||
this.href = this.Url.href;
|
||
this.protocol = this.Url.protocol;
|
||
this.origin = this.Url.origin;
|
||
this.hash = this.Url.hash;
|
||
this.search = this.Url.search;
|
||
pathname = this.Url.pathname + (this.Url.search ? this.Url.search : "");
|
||
} catch (e) {
|
||
this.Url = void 0;
|
||
if (this.base) {
|
||
basePath = new _path.default(this.base);
|
||
pathname = basePath.resolve(pathname);
|
||
}
|
||
}
|
||
}
|
||
this.Path = new _path.default(pathname);
|
||
this.directory = this.Path.directory;
|
||
this.filename = this.Path.filename;
|
||
this.extension = this.Path.extension;
|
||
}
|
||
path() {
|
||
return this.Path;
|
||
}
|
||
resolve(what) {
|
||
var isAbsolute = what.indexOf("://") > -1;
|
||
var fullpath;
|
||
if (isAbsolute) {
|
||
return what;
|
||
}
|
||
fullpath = _pathWebpack.default.resolve(this.directory, what);
|
||
return this.origin + fullpath;
|
||
}
|
||
relative(what) {
|
||
return _pathWebpack.default.relative(what, this.directory);
|
||
}
|
||
toString() {
|
||
return this.href;
|
||
}
|
||
};
|
||
var _default = Url;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/epubcfi.js
|
||
var require_epubcfi = __commonJS({
|
||
"node_modules/epubjs/lib/epubcfi.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _core = require_core();
|
||
var ELEMENT_NODE = 1;
|
||
var TEXT_NODE = 3;
|
||
var DOCUMENT_NODE = 9;
|
||
var EpubCFI = class {
|
||
constructor(cfiFrom, base, ignoreClass) {
|
||
var type;
|
||
this.str = "";
|
||
this.base = {};
|
||
this.spinePos = 0;
|
||
this.range = false;
|
||
this.path = {};
|
||
this.start = null;
|
||
this.end = null;
|
||
if (!(this instanceof EpubCFI)) {
|
||
return new EpubCFI(cfiFrom, base, ignoreClass);
|
||
}
|
||
if (typeof base === "string") {
|
||
this.base = this.parseComponent(base);
|
||
} else if (typeof base === "object" && base.steps) {
|
||
this.base = base;
|
||
}
|
||
type = this.checkType(cfiFrom);
|
||
if (type === "string") {
|
||
this.str = cfiFrom;
|
||
return (0, _core.extend)(this, this.parse(cfiFrom));
|
||
} else if (type === "range") {
|
||
return (0, _core.extend)(this, this.fromRange(cfiFrom, this.base, ignoreClass));
|
||
} else if (type === "node") {
|
||
return (0, _core.extend)(this, this.fromNode(cfiFrom, this.base, ignoreClass));
|
||
} else if (type === "EpubCFI" && cfiFrom.path) {
|
||
return cfiFrom;
|
||
} else if (!cfiFrom) {
|
||
return this;
|
||
} else {
|
||
throw new TypeError("not a valid argument for EpubCFI");
|
||
}
|
||
}
|
||
checkType(cfi) {
|
||
if (this.isCfiString(cfi)) {
|
||
return "string";
|
||
} else if (cfi && typeof cfi === "object" && ((0, _core.type)(cfi) === "Range" || typeof cfi.startContainer != "undefined")) {
|
||
return "range";
|
||
} else if (cfi && typeof cfi === "object" && typeof cfi.nodeType != "undefined") {
|
||
return "node";
|
||
} else if (cfi && typeof cfi === "object" && cfi instanceof EpubCFI) {
|
||
return "EpubCFI";
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
parse(cfiStr) {
|
||
var cfi = {
|
||
spinePos: -1,
|
||
range: false,
|
||
base: {},
|
||
path: {},
|
||
start: null,
|
||
end: null
|
||
};
|
||
var baseComponent, pathComponent, range;
|
||
if (typeof cfiStr !== "string") {
|
||
return {
|
||
spinePos: -1
|
||
};
|
||
}
|
||
if (cfiStr.indexOf("epubcfi(") === 0 && cfiStr[cfiStr.length - 1] === ")") {
|
||
cfiStr = cfiStr.slice(8, cfiStr.length - 1);
|
||
}
|
||
baseComponent = this.getChapterComponent(cfiStr);
|
||
if (!baseComponent) {
|
||
return {
|
||
spinePos: -1
|
||
};
|
||
}
|
||
cfi.base = this.parseComponent(baseComponent);
|
||
pathComponent = this.getPathComponent(cfiStr);
|
||
cfi.path = this.parseComponent(pathComponent);
|
||
range = this.getRange(cfiStr);
|
||
if (range) {
|
||
cfi.range = true;
|
||
cfi.start = this.parseComponent(range[0]);
|
||
cfi.end = this.parseComponent(range[1]);
|
||
}
|
||
cfi.spinePos = cfi.base.steps[1].index;
|
||
return cfi;
|
||
}
|
||
parseComponent(componentStr) {
|
||
var component = {
|
||
steps: [],
|
||
terminal: {
|
||
offset: null,
|
||
assertion: null
|
||
}
|
||
};
|
||
var parts = componentStr.split(":");
|
||
var steps = parts[0].split("/");
|
||
var terminal;
|
||
if (parts.length > 1) {
|
||
terminal = parts[1];
|
||
component.terminal = this.parseTerminal(terminal);
|
||
}
|
||
if (steps[0] === "") {
|
||
steps.shift();
|
||
}
|
||
component.steps = steps.map(function(step) {
|
||
return this.parseStep(step);
|
||
}.bind(this));
|
||
return component;
|
||
}
|
||
parseStep(stepStr) {
|
||
var type, num, index, has_brackets, id;
|
||
has_brackets = stepStr.match(/\[(.*)\]/);
|
||
if (has_brackets && has_brackets[1]) {
|
||
id = has_brackets[1];
|
||
}
|
||
num = parseInt(stepStr);
|
||
if (isNaN(num)) {
|
||
return;
|
||
}
|
||
if (num % 2 === 0) {
|
||
type = "element";
|
||
index = num / 2 - 1;
|
||
} else {
|
||
type = "text";
|
||
index = (num - 1) / 2;
|
||
}
|
||
return {
|
||
"type": type,
|
||
"index": index,
|
||
"id": id || null
|
||
};
|
||
}
|
||
parseTerminal(termialStr) {
|
||
var characterOffset, textLocationAssertion;
|
||
var assertion = termialStr.match(/\[(.*)\]/);
|
||
if (assertion && assertion[1]) {
|
||
characterOffset = parseInt(termialStr.split("[")[0]);
|
||
textLocationAssertion = assertion[1];
|
||
} else {
|
||
characterOffset = parseInt(termialStr);
|
||
}
|
||
if (!(0, _core.isNumber)(characterOffset)) {
|
||
characterOffset = null;
|
||
}
|
||
return {
|
||
"offset": characterOffset,
|
||
"assertion": textLocationAssertion
|
||
};
|
||
}
|
||
getChapterComponent(cfiStr) {
|
||
var indirection = cfiStr.split("!");
|
||
return indirection[0];
|
||
}
|
||
getPathComponent(cfiStr) {
|
||
var indirection = cfiStr.split("!");
|
||
if (indirection[1]) {
|
||
let ranges = indirection[1].split(",");
|
||
return ranges[0];
|
||
}
|
||
}
|
||
getRange(cfiStr) {
|
||
var ranges = cfiStr.split(",");
|
||
if (ranges.length === 3) {
|
||
return [ranges[1], ranges[2]];
|
||
}
|
||
return false;
|
||
}
|
||
getCharecterOffsetComponent(cfiStr) {
|
||
var splitStr = cfiStr.split(":");
|
||
return splitStr[1] || "";
|
||
}
|
||
joinSteps(steps) {
|
||
if (!steps) {
|
||
return "";
|
||
}
|
||
return steps.map(function(part) {
|
||
var segment = "";
|
||
if (part.type === "element") {
|
||
segment += (part.index + 1) * 2;
|
||
}
|
||
if (part.type === "text") {
|
||
segment += 1 + 2 * part.index;
|
||
}
|
||
if (part.id) {
|
||
segment += "[" + part.id + "]";
|
||
}
|
||
return segment;
|
||
}).join("/");
|
||
}
|
||
segmentString(segment) {
|
||
var segmentString = "/";
|
||
segmentString += this.joinSteps(segment.steps);
|
||
if (segment.terminal && segment.terminal.offset != null) {
|
||
segmentString += ":" + segment.terminal.offset;
|
||
}
|
||
if (segment.terminal && segment.terminal.assertion != null) {
|
||
segmentString += "[" + segment.terminal.assertion + "]";
|
||
}
|
||
return segmentString;
|
||
}
|
||
toString() {
|
||
var cfiString = "epubcfi(";
|
||
cfiString += this.segmentString(this.base);
|
||
cfiString += "!";
|
||
cfiString += this.segmentString(this.path);
|
||
if (this.range && this.start) {
|
||
cfiString += ",";
|
||
cfiString += this.segmentString(this.start);
|
||
}
|
||
if (this.range && this.end) {
|
||
cfiString += ",";
|
||
cfiString += this.segmentString(this.end);
|
||
}
|
||
cfiString += ")";
|
||
return cfiString;
|
||
}
|
||
compare(cfiOne, cfiTwo) {
|
||
var stepsA, stepsB;
|
||
var terminalA, terminalB;
|
||
var rangeAStartSteps, rangeAEndSteps;
|
||
var rangeBEndSteps, rangeBEndSteps;
|
||
var rangeAStartTerminal, rangeAEndTerminal;
|
||
var rangeBStartTerminal, rangeBEndTerminal;
|
||
if (typeof cfiOne === "string") {
|
||
cfiOne = new EpubCFI(cfiOne);
|
||
}
|
||
if (typeof cfiTwo === "string") {
|
||
cfiTwo = new EpubCFI(cfiTwo);
|
||
}
|
||
if (cfiOne.spinePos > cfiTwo.spinePos) {
|
||
return 1;
|
||
}
|
||
if (cfiOne.spinePos < cfiTwo.spinePos) {
|
||
return -1;
|
||
}
|
||
if (cfiOne.range) {
|
||
stepsA = cfiOne.path.steps.concat(cfiOne.start.steps);
|
||
terminalA = cfiOne.start.terminal;
|
||
} else {
|
||
stepsA = cfiOne.path.steps;
|
||
terminalA = cfiOne.path.terminal;
|
||
}
|
||
if (cfiTwo.range) {
|
||
stepsB = cfiTwo.path.steps.concat(cfiTwo.start.steps);
|
||
terminalB = cfiTwo.start.terminal;
|
||
} else {
|
||
stepsB = cfiTwo.path.steps;
|
||
terminalB = cfiTwo.path.terminal;
|
||
}
|
||
for (var i = 0; i < stepsA.length; i++) {
|
||
if (!stepsA[i]) {
|
||
return -1;
|
||
}
|
||
if (!stepsB[i]) {
|
||
return 1;
|
||
}
|
||
if (stepsA[i].index > stepsB[i].index) {
|
||
return 1;
|
||
}
|
||
if (stepsA[i].index < stepsB[i].index) {
|
||
return -1;
|
||
}
|
||
}
|
||
if (stepsA.length < stepsB.length) {
|
||
return -1;
|
||
}
|
||
if (terminalA.offset > terminalB.offset) {
|
||
return 1;
|
||
}
|
||
if (terminalA.offset < terminalB.offset) {
|
||
return -1;
|
||
}
|
||
return 0;
|
||
}
|
||
step(node) {
|
||
var nodeType = node.nodeType === TEXT_NODE ? "text" : "element";
|
||
return {
|
||
"id": node.id,
|
||
"tagName": node.tagName,
|
||
"type": nodeType,
|
||
"index": this.position(node)
|
||
};
|
||
}
|
||
filteredStep(node, ignoreClass) {
|
||
var filteredNode = this.filter(node, ignoreClass);
|
||
var nodeType;
|
||
if (!filteredNode) {
|
||
return;
|
||
}
|
||
nodeType = filteredNode.nodeType === TEXT_NODE ? "text" : "element";
|
||
return {
|
||
"id": filteredNode.id,
|
||
"tagName": filteredNode.tagName,
|
||
"type": nodeType,
|
||
"index": this.filteredPosition(filteredNode, ignoreClass)
|
||
};
|
||
}
|
||
pathTo(node, offset, ignoreClass) {
|
||
var segment = {
|
||
steps: [],
|
||
terminal: {
|
||
offset: null,
|
||
assertion: null
|
||
}
|
||
};
|
||
var currentNode = node;
|
||
var step;
|
||
while (currentNode && currentNode.parentNode && currentNode.parentNode.nodeType != DOCUMENT_NODE) {
|
||
if (ignoreClass) {
|
||
step = this.filteredStep(currentNode, ignoreClass);
|
||
} else {
|
||
step = this.step(currentNode);
|
||
}
|
||
if (step) {
|
||
segment.steps.unshift(step);
|
||
}
|
||
currentNode = currentNode.parentNode;
|
||
}
|
||
if (offset != null && offset >= 0) {
|
||
segment.terminal.offset = offset;
|
||
if (segment.steps[segment.steps.length - 1].type != "text") {
|
||
segment.steps.push({
|
||
"type": "text",
|
||
"index": 0
|
||
});
|
||
}
|
||
}
|
||
return segment;
|
||
}
|
||
equalStep(stepA, stepB) {
|
||
if (!stepA || !stepB) {
|
||
return false;
|
||
}
|
||
if (stepA.index === stepB.index && stepA.id === stepB.id && stepA.type === stepB.type) {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
fromRange(range, base, ignoreClass) {
|
||
var cfi = {
|
||
range: false,
|
||
base: {},
|
||
path: {},
|
||
start: null,
|
||
end: null
|
||
};
|
||
var start = range.startContainer;
|
||
var end = range.endContainer;
|
||
var startOffset = range.startOffset;
|
||
var endOffset = range.endOffset;
|
||
var needsIgnoring = false;
|
||
if (ignoreClass) {
|
||
needsIgnoring = start.ownerDocument.querySelector("." + ignoreClass) != null;
|
||
}
|
||
if (typeof base === "string") {
|
||
cfi.base = this.parseComponent(base);
|
||
cfi.spinePos = cfi.base.steps[1].index;
|
||
} else if (typeof base === "object") {
|
||
cfi.base = base;
|
||
}
|
||
if (range.collapsed) {
|
||
if (needsIgnoring) {
|
||
startOffset = this.patchOffset(start, startOffset, ignoreClass);
|
||
}
|
||
cfi.path = this.pathTo(start, startOffset, ignoreClass);
|
||
} else {
|
||
cfi.range = true;
|
||
if (needsIgnoring) {
|
||
startOffset = this.patchOffset(start, startOffset, ignoreClass);
|
||
}
|
||
cfi.start = this.pathTo(start, startOffset, ignoreClass);
|
||
if (needsIgnoring) {
|
||
endOffset = this.patchOffset(end, endOffset, ignoreClass);
|
||
}
|
||
cfi.end = this.pathTo(end, endOffset, ignoreClass);
|
||
cfi.path = {
|
||
steps: [],
|
||
terminal: null
|
||
};
|
||
var len = cfi.start.steps.length;
|
||
var i;
|
||
for (i = 0; i < len; i++) {
|
||
if (this.equalStep(cfi.start.steps[i], cfi.end.steps[i])) {
|
||
if (i === len - 1) {
|
||
if (cfi.start.terminal === cfi.end.terminal) {
|
||
cfi.path.steps.push(cfi.start.steps[i]);
|
||
cfi.range = false;
|
||
}
|
||
} else {
|
||
cfi.path.steps.push(cfi.start.steps[i]);
|
||
}
|
||
} else {
|
||
break;
|
||
}
|
||
}
|
||
cfi.start.steps = cfi.start.steps.slice(cfi.path.steps.length);
|
||
cfi.end.steps = cfi.end.steps.slice(cfi.path.steps.length);
|
||
}
|
||
return cfi;
|
||
}
|
||
fromNode(anchor, base, ignoreClass) {
|
||
var cfi = {
|
||
range: false,
|
||
base: {},
|
||
path: {},
|
||
start: null,
|
||
end: null
|
||
};
|
||
if (typeof base === "string") {
|
||
cfi.base = this.parseComponent(base);
|
||
cfi.spinePos = cfi.base.steps[1].index;
|
||
} else if (typeof base === "object") {
|
||
cfi.base = base;
|
||
}
|
||
cfi.path = this.pathTo(anchor, null, ignoreClass);
|
||
return cfi;
|
||
}
|
||
filter(anchor, ignoreClass) {
|
||
var needsIgnoring;
|
||
var sibling;
|
||
var parent2, previousSibling, nextSibling;
|
||
var isText = false;
|
||
if (anchor.nodeType === TEXT_NODE) {
|
||
isText = true;
|
||
parent2 = anchor.parentNode;
|
||
needsIgnoring = anchor.parentNode.classList.contains(ignoreClass);
|
||
} else {
|
||
isText = false;
|
||
needsIgnoring = anchor.classList.contains(ignoreClass);
|
||
}
|
||
if (needsIgnoring && isText) {
|
||
previousSibling = parent2.previousSibling;
|
||
nextSibling = parent2.nextSibling;
|
||
if (previousSibling && previousSibling.nodeType === TEXT_NODE) {
|
||
sibling = previousSibling;
|
||
} else if (nextSibling && nextSibling.nodeType === TEXT_NODE) {
|
||
sibling = nextSibling;
|
||
}
|
||
if (sibling) {
|
||
return sibling;
|
||
} else {
|
||
return anchor;
|
||
}
|
||
} else if (needsIgnoring && !isText) {
|
||
return false;
|
||
} else {
|
||
return anchor;
|
||
}
|
||
}
|
||
patchOffset(anchor, offset, ignoreClass) {
|
||
if (anchor.nodeType != TEXT_NODE) {
|
||
throw new Error("Anchor must be a text node");
|
||
}
|
||
var curr = anchor;
|
||
var totalOffset = offset;
|
||
if (anchor.parentNode.classList.contains(ignoreClass)) {
|
||
curr = anchor.parentNode;
|
||
}
|
||
while (curr.previousSibling) {
|
||
if (curr.previousSibling.nodeType === ELEMENT_NODE) {
|
||
if (curr.previousSibling.classList.contains(ignoreClass)) {
|
||
totalOffset += curr.previousSibling.textContent.length;
|
||
} else {
|
||
break;
|
||
}
|
||
} else {
|
||
totalOffset += curr.previousSibling.textContent.length;
|
||
}
|
||
curr = curr.previousSibling;
|
||
}
|
||
return totalOffset;
|
||
}
|
||
normalizedMap(children, nodeType, ignoreClass) {
|
||
var output = {};
|
||
var prevIndex = -1;
|
||
var i, len = children.length;
|
||
var currNodeType;
|
||
var prevNodeType;
|
||
for (i = 0; i < len; i++) {
|
||
currNodeType = children[i].nodeType;
|
||
if (currNodeType === ELEMENT_NODE && children[i].classList.contains(ignoreClass)) {
|
||
currNodeType = TEXT_NODE;
|
||
}
|
||
if (i > 0 && currNodeType === TEXT_NODE && prevNodeType === TEXT_NODE) {
|
||
output[i] = prevIndex;
|
||
} else if (nodeType === currNodeType) {
|
||
prevIndex = prevIndex + 1;
|
||
output[i] = prevIndex;
|
||
}
|
||
prevNodeType = currNodeType;
|
||
}
|
||
return output;
|
||
}
|
||
position(anchor) {
|
||
var children, index;
|
||
if (anchor.nodeType === ELEMENT_NODE) {
|
||
children = anchor.parentNode.children;
|
||
if (!children) {
|
||
children = (0, _core.findChildren)(anchor.parentNode);
|
||
}
|
||
index = Array.prototype.indexOf.call(children, anchor);
|
||
} else {
|
||
children = this.textNodes(anchor.parentNode);
|
||
index = children.indexOf(anchor);
|
||
}
|
||
return index;
|
||
}
|
||
filteredPosition(anchor, ignoreClass) {
|
||
var children, index, map;
|
||
if (anchor.nodeType === ELEMENT_NODE) {
|
||
children = anchor.parentNode.children;
|
||
map = this.normalizedMap(children, ELEMENT_NODE, ignoreClass);
|
||
} else {
|
||
children = anchor.parentNode.childNodes;
|
||
if (anchor.parentNode.classList.contains(ignoreClass)) {
|
||
anchor = anchor.parentNode;
|
||
children = anchor.parentNode.childNodes;
|
||
}
|
||
map = this.normalizedMap(children, TEXT_NODE, ignoreClass);
|
||
}
|
||
index = Array.prototype.indexOf.call(children, anchor);
|
||
return map[index];
|
||
}
|
||
stepsToXpath(steps) {
|
||
var xpath = [".", "*"];
|
||
steps.forEach(function(step) {
|
||
var position = step.index + 1;
|
||
if (step.id) {
|
||
xpath.push("*[position()=" + position + " and @id='" + step.id + "']");
|
||
} else if (step.type === "text") {
|
||
xpath.push("text()[" + position + "]");
|
||
} else {
|
||
xpath.push("*[" + position + "]");
|
||
}
|
||
});
|
||
return xpath.join("/");
|
||
}
|
||
stepsToQuerySelector(steps) {
|
||
var query = ["html"];
|
||
steps.forEach(function(step) {
|
||
var position = step.index + 1;
|
||
if (step.id) {
|
||
query.push("#" + step.id);
|
||
} else if (step.type === "text") {
|
||
} else {
|
||
query.push("*:nth-child(" + position + ")");
|
||
}
|
||
});
|
||
return query.join(">");
|
||
}
|
||
textNodes(container, ignoreClass) {
|
||
return Array.prototype.slice.call(container.childNodes).filter(function(node) {
|
||
if (node.nodeType === TEXT_NODE) {
|
||
return true;
|
||
} else if (ignoreClass && node.classList.contains(ignoreClass)) {
|
||
return true;
|
||
}
|
||
return false;
|
||
});
|
||
}
|
||
walkToNode(steps, _doc, ignoreClass) {
|
||
var doc = _doc || document;
|
||
var container = doc.documentElement;
|
||
var children;
|
||
var step;
|
||
var len = steps.length;
|
||
var i;
|
||
for (i = 0; i < len; i++) {
|
||
step = steps[i];
|
||
if (step.type === "element") {
|
||
if (step.id) {
|
||
container = doc.getElementById(step.id);
|
||
} else {
|
||
children = container.children || (0, _core.findChildren)(container);
|
||
container = children[step.index];
|
||
}
|
||
} else if (step.type === "text") {
|
||
container = this.textNodes(container, ignoreClass)[step.index];
|
||
}
|
||
if (!container) {
|
||
break;
|
||
}
|
||
}
|
||
return container;
|
||
}
|
||
findNode(steps, _doc, ignoreClass) {
|
||
var doc = _doc || document;
|
||
var container;
|
||
var xpath;
|
||
if (!ignoreClass && typeof doc.evaluate != "undefined") {
|
||
xpath = this.stepsToXpath(steps);
|
||
container = doc.evaluate(xpath, doc, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
||
} else if (ignoreClass) {
|
||
container = this.walkToNode(steps, doc, ignoreClass);
|
||
} else {
|
||
container = this.walkToNode(steps, doc);
|
||
}
|
||
return container;
|
||
}
|
||
fixMiss(steps, offset, _doc, ignoreClass) {
|
||
var container = this.findNode(steps.slice(0, -1), _doc, ignoreClass);
|
||
var children = container.childNodes;
|
||
var map = this.normalizedMap(children, TEXT_NODE, ignoreClass);
|
||
var child;
|
||
var len;
|
||
var lastStepIndex = steps[steps.length - 1].index;
|
||
for (let childIndex in map) {
|
||
if (!map.hasOwnProperty(childIndex))
|
||
return;
|
||
if (map[childIndex] === lastStepIndex) {
|
||
child = children[childIndex];
|
||
len = child.textContent.length;
|
||
if (offset > len) {
|
||
offset = offset - len;
|
||
} else {
|
||
if (child.nodeType === ELEMENT_NODE) {
|
||
container = child.childNodes[0];
|
||
} else {
|
||
container = child;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
return {
|
||
container,
|
||
offset
|
||
};
|
||
}
|
||
toRange(_doc, ignoreClass) {
|
||
var doc = _doc || document;
|
||
var range;
|
||
var start, end, startContainer, endContainer;
|
||
var cfi = this;
|
||
var startSteps, endSteps;
|
||
var needsIgnoring = ignoreClass ? doc.querySelector("." + ignoreClass) != null : false;
|
||
var missed;
|
||
if (typeof doc.createRange !== "undefined") {
|
||
range = doc.createRange();
|
||
} else {
|
||
range = new _core.RangeObject();
|
||
}
|
||
if (cfi.range) {
|
||
start = cfi.start;
|
||
startSteps = cfi.path.steps.concat(start.steps);
|
||
startContainer = this.findNode(startSteps, doc, needsIgnoring ? ignoreClass : null);
|
||
end = cfi.end;
|
||
endSteps = cfi.path.steps.concat(end.steps);
|
||
endContainer = this.findNode(endSteps, doc, needsIgnoring ? ignoreClass : null);
|
||
} else {
|
||
start = cfi.path;
|
||
startSteps = cfi.path.steps;
|
||
startContainer = this.findNode(cfi.path.steps, doc, needsIgnoring ? ignoreClass : null);
|
||
}
|
||
if (startContainer) {
|
||
try {
|
||
if (start.terminal.offset != null) {
|
||
range.setStart(startContainer, start.terminal.offset);
|
||
} else {
|
||
range.setStart(startContainer, 0);
|
||
}
|
||
} catch (e) {
|
||
missed = this.fixMiss(startSteps, start.terminal.offset, doc, needsIgnoring ? ignoreClass : null);
|
||
range.setStart(missed.container, missed.offset);
|
||
}
|
||
} else {
|
||
console.log("No startContainer found for", this.toString());
|
||
return null;
|
||
}
|
||
if (endContainer) {
|
||
try {
|
||
if (end.terminal.offset != null) {
|
||
range.setEnd(endContainer, end.terminal.offset);
|
||
} else {
|
||
range.setEnd(endContainer, 0);
|
||
}
|
||
} catch (e) {
|
||
missed = this.fixMiss(endSteps, cfi.end.terminal.offset, doc, needsIgnoring ? ignoreClass : null);
|
||
range.setEnd(missed.container, missed.offset);
|
||
}
|
||
}
|
||
return range;
|
||
}
|
||
isCfiString(str) {
|
||
if (typeof str === "string" && str.indexOf("epubcfi(") === 0 && str[str.length - 1] === ")") {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
generateChapterComponent(_spineNodeIndex, _pos, id) {
|
||
var pos = parseInt(_pos), spineNodeIndex = (_spineNodeIndex + 1) * 2, cfi = "/" + spineNodeIndex + "/";
|
||
cfi += (pos + 1) * 2;
|
||
if (id) {
|
||
cfi += "[" + id + "]";
|
||
}
|
||
return cfi;
|
||
}
|
||
collapse(toStart) {
|
||
if (!this.range) {
|
||
return;
|
||
}
|
||
this.range = false;
|
||
if (toStart) {
|
||
this.path.steps = this.path.steps.concat(this.start.steps);
|
||
this.path.terminal = this.start.terminal;
|
||
} else {
|
||
this.path.steps = this.path.steps.concat(this.end.steps);
|
||
this.path.terminal = this.end.terminal;
|
||
}
|
||
}
|
||
};
|
||
var _default = EpubCFI;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/utils/hook.js
|
||
var require_hook = __commonJS({
|
||
"node_modules/epubjs/lib/utils/hook.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var Hook = class {
|
||
constructor(context) {
|
||
this.context = context || this;
|
||
this.hooks = [];
|
||
}
|
||
register() {
|
||
for (var i = 0; i < arguments.length; ++i) {
|
||
if (typeof arguments[i] === "function") {
|
||
this.hooks.push(arguments[i]);
|
||
} else {
|
||
for (var j = 0; j < arguments[i].length; ++j) {
|
||
this.hooks.push(arguments[i][j]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
deregister(func) {
|
||
let hook;
|
||
for (let i = 0; i < this.hooks.length; i++) {
|
||
hook = this.hooks[i];
|
||
if (hook === func) {
|
||
this.hooks.splice(i, 1);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
trigger() {
|
||
var args = arguments;
|
||
var context = this.context;
|
||
var promises = [];
|
||
this.hooks.forEach(function(task) {
|
||
try {
|
||
var executing = task.apply(context, args);
|
||
} catch (err) {
|
||
console.log(err);
|
||
}
|
||
if (executing && typeof executing["then"] === "function") {
|
||
promises.push(executing);
|
||
}
|
||
});
|
||
return Promise.all(promises);
|
||
}
|
||
list() {
|
||
return this.hooks;
|
||
}
|
||
clear() {
|
||
return this.hooks = [];
|
||
}
|
||
};
|
||
var _default = Hook;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/utils/replacements.js
|
||
var require_replacements = __commonJS({
|
||
"node_modules/epubjs/lib/utils/replacements.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.replaceBase = replaceBase;
|
||
exports.replaceCanonical = replaceCanonical;
|
||
exports.replaceLinks = replaceLinks;
|
||
exports.replaceMeta = replaceMeta;
|
||
exports.substitute = substitute;
|
||
var _core = require_core();
|
||
var _url = _interopRequireDefault(require_url());
|
||
var _path = _interopRequireDefault(require_path2());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
function replaceBase(doc, section) {
|
||
var base;
|
||
var head;
|
||
var url = section.url;
|
||
var absolute = url.indexOf("://") > -1;
|
||
if (!doc) {
|
||
return;
|
||
}
|
||
head = (0, _core.qs)(doc, "head");
|
||
base = (0, _core.qs)(head, "base");
|
||
if (!base) {
|
||
base = doc.createElement("base");
|
||
head.insertBefore(base, head.firstChild);
|
||
}
|
||
if (!absolute && window && window.location) {
|
||
url = window.location.origin + url;
|
||
}
|
||
base.setAttribute("href", url);
|
||
}
|
||
function replaceCanonical(doc, section) {
|
||
var head;
|
||
var link;
|
||
var url = section.canonical;
|
||
if (!doc) {
|
||
return;
|
||
}
|
||
head = (0, _core.qs)(doc, "head");
|
||
link = (0, _core.qs)(head, "link[rel='canonical']");
|
||
if (link) {
|
||
link.setAttribute("href", url);
|
||
} else {
|
||
link = doc.createElement("link");
|
||
link.setAttribute("rel", "canonical");
|
||
link.setAttribute("href", url);
|
||
head.appendChild(link);
|
||
}
|
||
}
|
||
function replaceMeta(doc, section) {
|
||
var head;
|
||
var meta;
|
||
var id = section.idref;
|
||
if (!doc) {
|
||
return;
|
||
}
|
||
head = (0, _core.qs)(doc, "head");
|
||
meta = (0, _core.qs)(head, "link[property='dc.identifier']");
|
||
if (meta) {
|
||
meta.setAttribute("content", id);
|
||
} else {
|
||
meta = doc.createElement("meta");
|
||
meta.setAttribute("name", "dc.identifier");
|
||
meta.setAttribute("content", id);
|
||
head.appendChild(meta);
|
||
}
|
||
}
|
||
function replaceLinks(contents, fn) {
|
||
var links = contents.querySelectorAll("a[href]");
|
||
if (!links.length) {
|
||
return;
|
||
}
|
||
var base = (0, _core.qs)(contents.ownerDocument, "base");
|
||
var location = base ? base.getAttribute("href") : void 0;
|
||
var replaceLink = function(link) {
|
||
var href = link.getAttribute("href");
|
||
if (href.indexOf("mailto:") === 0) {
|
||
return;
|
||
}
|
||
var absolute = href.indexOf("://") > -1;
|
||
if (absolute) {
|
||
link.setAttribute("target", "_blank");
|
||
} else {
|
||
var linkUrl;
|
||
try {
|
||
linkUrl = new _url.default(href, location);
|
||
} catch (error) {
|
||
}
|
||
link.onclick = function() {
|
||
if (linkUrl && linkUrl.hash) {
|
||
fn(linkUrl.Path.path + linkUrl.hash);
|
||
} else if (linkUrl) {
|
||
fn(linkUrl.Path.path);
|
||
} else {
|
||
fn(href);
|
||
}
|
||
return false;
|
||
};
|
||
}
|
||
}.bind(this);
|
||
for (var i = 0; i < links.length; i++) {
|
||
replaceLink(links[i]);
|
||
}
|
||
}
|
||
function substitute(content, urls, replacements) {
|
||
urls.forEach(function(url, i) {
|
||
if (url && replacements[i]) {
|
||
url = url.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
||
content = content.replace(new RegExp(url, "g"), replacements[i]);
|
||
}
|
||
});
|
||
return content;
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/utils/request.js
|
||
var require_request = __commonJS({
|
||
"node_modules/epubjs/lib/utils/request.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _core = require_core();
|
||
var _path = _interopRequireDefault(require_path2());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
function request(url, type, withCredentials, headers) {
|
||
var supportsURL = typeof window != "undefined" ? window.URL : false;
|
||
var BLOB_RESPONSE = supportsURL ? "blob" : "arraybuffer";
|
||
var deferred = new _core.defer();
|
||
var xhr = new XMLHttpRequest();
|
||
var xhrPrototype = XMLHttpRequest.prototype;
|
||
var header;
|
||
if (!("overrideMimeType" in xhrPrototype)) {
|
||
Object.defineProperty(xhrPrototype, "overrideMimeType", {
|
||
value: function xmlHttpRequestOverrideMimeType() {
|
||
}
|
||
});
|
||
}
|
||
if (withCredentials) {
|
||
xhr.withCredentials = true;
|
||
}
|
||
xhr.onreadystatechange = handler;
|
||
xhr.onerror = err;
|
||
xhr.open("GET", url, true);
|
||
for (header in headers) {
|
||
xhr.setRequestHeader(header, headers[header]);
|
||
}
|
||
if (type == "json") {
|
||
xhr.setRequestHeader("Accept", "application/json");
|
||
}
|
||
if (!type) {
|
||
type = new _path.default(url).extension;
|
||
}
|
||
if (type == "blob") {
|
||
xhr.responseType = BLOB_RESPONSE;
|
||
}
|
||
if ((0, _core.isXml)(type)) {
|
||
xhr.overrideMimeType("text/xml");
|
||
}
|
||
if (type == "xhtml") {
|
||
}
|
||
if (type == "html" || type == "htm") {
|
||
}
|
||
if (type == "binary") {
|
||
xhr.responseType = "arraybuffer";
|
||
}
|
||
xhr.send();
|
||
function err(e) {
|
||
deferred.reject(e);
|
||
}
|
||
function handler() {
|
||
if (this.readyState === XMLHttpRequest.DONE) {
|
||
var responseXML = false;
|
||
if (this.responseType === "" || this.responseType === "document") {
|
||
responseXML = this.responseXML;
|
||
}
|
||
if (this.status === 200 || this.status === 0 || responseXML) {
|
||
var r;
|
||
if (!this.response && !responseXML) {
|
||
deferred.reject({
|
||
status: this.status,
|
||
message: "Empty Response",
|
||
stack: new Error().stack
|
||
});
|
||
return deferred.promise;
|
||
}
|
||
if (this.status === 403) {
|
||
deferred.reject({
|
||
status: this.status,
|
||
response: this.response,
|
||
message: "Forbidden",
|
||
stack: new Error().stack
|
||
});
|
||
return deferred.promise;
|
||
}
|
||
if (responseXML) {
|
||
r = this.responseXML;
|
||
} else if ((0, _core.isXml)(type)) {
|
||
r = (0, _core.parse)(this.response, "text/xml");
|
||
} else if (type == "xhtml") {
|
||
r = (0, _core.parse)(this.response, "application/xhtml+xml");
|
||
} else if (type == "html" || type == "htm") {
|
||
r = (0, _core.parse)(this.response, "text/html");
|
||
} else if (type == "json") {
|
||
r = JSON.parse(this.response);
|
||
} else if (type == "blob") {
|
||
if (supportsURL) {
|
||
r = this.response;
|
||
} else {
|
||
r = new Blob([this.response]);
|
||
}
|
||
} else {
|
||
r = this.response;
|
||
}
|
||
deferred.resolve(r);
|
||
} else {
|
||
deferred.reject({
|
||
status: this.status,
|
||
message: this.response,
|
||
stack: new Error().stack
|
||
});
|
||
}
|
||
}
|
||
}
|
||
return deferred.promise;
|
||
}
|
||
var _default = request;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/section.js
|
||
var require_section = __commonJS({
|
||
"node_modules/epubjs/lib/section.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _core = require_core();
|
||
var _epubcfi = _interopRequireDefault(require_epubcfi());
|
||
var _hook = _interopRequireDefault(require_hook());
|
||
var _replacements = require_replacements();
|
||
var _request2 = _interopRequireDefault(require_request());
|
||
var _xmldom = require_lib();
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Section = class {
|
||
constructor(item, hooks) {
|
||
this.idref = item.idref;
|
||
this.linear = item.linear === "yes";
|
||
this.properties = item.properties;
|
||
this.index = item.index;
|
||
this.href = item.href;
|
||
this.url = item.url;
|
||
this.canonical = item.canonical;
|
||
this.next = item.next;
|
||
this.prev = item.prev;
|
||
this.cfiBase = item.cfiBase;
|
||
if (hooks) {
|
||
this.hooks = hooks;
|
||
} else {
|
||
this.hooks = {};
|
||
this.hooks.serialize = new _hook.default(this);
|
||
this.hooks.content = new _hook.default(this);
|
||
}
|
||
this.document = void 0;
|
||
this.contents = void 0;
|
||
this.output = void 0;
|
||
}
|
||
load(_request) {
|
||
var request = _request || this.request || _request2.default;
|
||
var loading = new _core.defer();
|
||
var loaded = loading.promise;
|
||
if (this.contents) {
|
||
loading.resolve(this.contents);
|
||
} else {
|
||
request(this.url).then(function(xml) {
|
||
this.document = xml;
|
||
this.contents = xml.documentElement;
|
||
return this.hooks.content.trigger(this.document, this);
|
||
}.bind(this)).then(function() {
|
||
loading.resolve(this.contents);
|
||
}.bind(this)).catch(function(error) {
|
||
loading.reject(error);
|
||
});
|
||
}
|
||
return loaded;
|
||
}
|
||
base() {
|
||
return (0, _replacements.replaceBase)(this.document, this);
|
||
}
|
||
render(_request) {
|
||
var rendering = new _core.defer();
|
||
var rendered = rendering.promise;
|
||
this.output;
|
||
this.load(_request).then(function(contents) {
|
||
var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
|
||
var isIE = userAgent.indexOf("Trident") >= 0;
|
||
var Serializer;
|
||
if (typeof XMLSerializer === "undefined" || isIE) {
|
||
Serializer = _xmldom.DOMParser;
|
||
} else {
|
||
Serializer = XMLSerializer;
|
||
}
|
||
var serializer = new Serializer();
|
||
this.output = serializer.serializeToString(contents);
|
||
return this.output;
|
||
}.bind(this)).then(function() {
|
||
return this.hooks.serialize.trigger(this.output, this);
|
||
}.bind(this)).then(function() {
|
||
rendering.resolve(this.output);
|
||
}.bind(this)).catch(function(error) {
|
||
rendering.reject(error);
|
||
});
|
||
return rendered;
|
||
}
|
||
find(_query) {
|
||
var section = this;
|
||
var matches = [];
|
||
var query = _query.toLowerCase();
|
||
var find = function(node) {
|
||
var text = node.textContent.toLowerCase();
|
||
var range = section.document.createRange();
|
||
var cfi;
|
||
var pos;
|
||
var last = -1;
|
||
var excerpt;
|
||
var limit = 150;
|
||
while (pos != -1) {
|
||
pos = text.indexOf(query, last + 1);
|
||
if (pos != -1) {
|
||
range = section.document.createRange();
|
||
range.setStart(node, pos);
|
||
range.setEnd(node, pos + query.length);
|
||
cfi = section.cfiFromRange(range);
|
||
if (node.textContent.length < limit) {
|
||
excerpt = node.textContent;
|
||
} else {
|
||
excerpt = node.textContent.substring(pos - limit / 2, pos + limit / 2);
|
||
excerpt = "..." + excerpt + "...";
|
||
}
|
||
matches.push({
|
||
cfi,
|
||
excerpt
|
||
});
|
||
}
|
||
last = pos;
|
||
}
|
||
};
|
||
(0, _core.sprint)(section.document, function(node) {
|
||
find(node);
|
||
});
|
||
return matches;
|
||
}
|
||
search(_query, maxSeqEle = 5) {
|
||
if (typeof document.createTreeWalker == "undefined") {
|
||
return this.find(_query);
|
||
}
|
||
let matches = [];
|
||
const excerptLimit = 150;
|
||
const section = this;
|
||
const query = _query.toLowerCase();
|
||
const search = function(nodeList2) {
|
||
const textWithCase = nodeList2.reduce((acc, current) => {
|
||
return acc + current.textContent;
|
||
}, "");
|
||
const text = textWithCase.toLowerCase();
|
||
const pos = text.indexOf(query);
|
||
if (pos != -1) {
|
||
const startNodeIndex = 0, endPos = pos + query.length;
|
||
let endNodeIndex = 0, l = 0;
|
||
if (pos < nodeList2[startNodeIndex].length) {
|
||
let cfi;
|
||
while (endNodeIndex < nodeList2.length - 1) {
|
||
l += nodeList2[endNodeIndex].length;
|
||
if (endPos <= l) {
|
||
break;
|
||
}
|
||
endNodeIndex += 1;
|
||
}
|
||
let startNode = nodeList2[startNodeIndex], endNode = nodeList2[endNodeIndex];
|
||
let range = section.document.createRange();
|
||
range.setStart(startNode, pos);
|
||
let beforeEndLengthCount = nodeList2.slice(0, endNodeIndex).reduce((acc, current) => {
|
||
return acc + current.textContent.length;
|
||
}, 0);
|
||
range.setEnd(endNode, beforeEndLengthCount > endPos ? endPos : endPos - beforeEndLengthCount);
|
||
cfi = section.cfiFromRange(range);
|
||
let excerpt = nodeList2.slice(0, endNodeIndex + 1).reduce((acc, current) => {
|
||
return acc + current.textContent;
|
||
}, "");
|
||
if (excerpt.length > excerptLimit) {
|
||
excerpt = excerpt.substring(pos - excerptLimit / 2, pos + excerptLimit / 2);
|
||
excerpt = "..." + excerpt + "...";
|
||
}
|
||
matches.push({
|
||
cfi,
|
||
excerpt
|
||
});
|
||
}
|
||
}
|
||
};
|
||
const treeWalker = document.createTreeWalker(section.document, NodeFilter.SHOW_TEXT, null, false);
|
||
let node, nodeList = [];
|
||
while (node = treeWalker.nextNode()) {
|
||
nodeList.push(node);
|
||
if (nodeList.length == maxSeqEle) {
|
||
search(nodeList.slice(0, maxSeqEle));
|
||
nodeList = nodeList.slice(1, maxSeqEle);
|
||
}
|
||
}
|
||
if (nodeList.length > 0) {
|
||
search(nodeList);
|
||
}
|
||
return matches;
|
||
}
|
||
reconcileLayoutSettings(globalLayout) {
|
||
var settings = {
|
||
layout: globalLayout.layout,
|
||
spread: globalLayout.spread,
|
||
orientation: globalLayout.orientation
|
||
};
|
||
this.properties.forEach(function(prop) {
|
||
var rendition = prop.replace("rendition:", "");
|
||
var split = rendition.indexOf("-");
|
||
var property, value;
|
||
if (split != -1) {
|
||
property = rendition.slice(0, split);
|
||
value = rendition.slice(split + 1);
|
||
settings[property] = value;
|
||
}
|
||
});
|
||
return settings;
|
||
}
|
||
cfiFromRange(_range) {
|
||
return new _epubcfi.default(_range, this.cfiBase).toString();
|
||
}
|
||
cfiFromElement(el) {
|
||
return new _epubcfi.default(el, this.cfiBase).toString();
|
||
}
|
||
unload() {
|
||
this.document = void 0;
|
||
this.contents = void 0;
|
||
this.output = void 0;
|
||
}
|
||
destroy() {
|
||
this.unload();
|
||
this.hooks.serialize.clear();
|
||
this.hooks.content.clear();
|
||
this.hooks = void 0;
|
||
this.idref = void 0;
|
||
this.linear = void 0;
|
||
this.properties = void 0;
|
||
this.index = void 0;
|
||
this.href = void 0;
|
||
this.url = void 0;
|
||
this.next = void 0;
|
||
this.prev = void 0;
|
||
this.cfiBase = void 0;
|
||
}
|
||
};
|
||
var _default = Section;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/spine.js
|
||
var require_spine = __commonJS({
|
||
"node_modules/epubjs/lib/spine.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _epubcfi = _interopRequireDefault(require_epubcfi());
|
||
var _hook = _interopRequireDefault(require_hook());
|
||
var _section = _interopRequireDefault(require_section());
|
||
var _replacements = require_replacements();
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Spine = class {
|
||
constructor() {
|
||
this.spineItems = [];
|
||
this.spineByHref = {};
|
||
this.spineById = {};
|
||
this.hooks = {};
|
||
this.hooks.serialize = new _hook.default();
|
||
this.hooks.content = new _hook.default();
|
||
this.hooks.content.register(_replacements.replaceBase);
|
||
this.hooks.content.register(_replacements.replaceCanonical);
|
||
this.hooks.content.register(_replacements.replaceMeta);
|
||
this.epubcfi = new _epubcfi.default();
|
||
this.loaded = false;
|
||
this.items = void 0;
|
||
this.manifest = void 0;
|
||
this.spineNodeIndex = void 0;
|
||
this.baseUrl = void 0;
|
||
this.length = void 0;
|
||
}
|
||
unpack(_package, resolver, canonical) {
|
||
this.items = _package.spine;
|
||
this.manifest = _package.manifest;
|
||
this.spineNodeIndex = _package.spineNodeIndex;
|
||
this.baseUrl = _package.baseUrl || _package.basePath || "";
|
||
this.length = this.items.length;
|
||
this.items.forEach((item, index) => {
|
||
var manifestItem = this.manifest[item.idref];
|
||
var spineItem;
|
||
item.index = index;
|
||
item.cfiBase = this.epubcfi.generateChapterComponent(this.spineNodeIndex, item.index, item.id);
|
||
if (item.href) {
|
||
item.url = resolver(item.href, true);
|
||
item.canonical = canonical(item.href);
|
||
}
|
||
if (manifestItem) {
|
||
item.href = manifestItem.href;
|
||
item.url = resolver(item.href, true);
|
||
item.canonical = canonical(item.href);
|
||
if (manifestItem.properties.length) {
|
||
item.properties.push.apply(item.properties, manifestItem.properties);
|
||
}
|
||
}
|
||
if (item.linear === "yes") {
|
||
item.prev = function() {
|
||
let prevIndex = item.index;
|
||
while (prevIndex > 0) {
|
||
let prev = this.get(prevIndex - 1);
|
||
if (prev && prev.linear) {
|
||
return prev;
|
||
}
|
||
prevIndex -= 1;
|
||
}
|
||
return;
|
||
}.bind(this);
|
||
item.next = function() {
|
||
let nextIndex = item.index;
|
||
while (nextIndex < this.spineItems.length - 1) {
|
||
let next = this.get(nextIndex + 1);
|
||
if (next && next.linear) {
|
||
return next;
|
||
}
|
||
nextIndex += 1;
|
||
}
|
||
return;
|
||
}.bind(this);
|
||
} else {
|
||
item.prev = function() {
|
||
return;
|
||
};
|
||
item.next = function() {
|
||
return;
|
||
};
|
||
}
|
||
spineItem = new _section.default(item, this.hooks);
|
||
this.append(spineItem);
|
||
});
|
||
this.loaded = true;
|
||
}
|
||
get(target) {
|
||
var index = 0;
|
||
if (typeof target === "undefined") {
|
||
while (index < this.spineItems.length) {
|
||
let next = this.spineItems[index];
|
||
if (next && next.linear) {
|
||
break;
|
||
}
|
||
index += 1;
|
||
}
|
||
} else if (this.epubcfi.isCfiString(target)) {
|
||
let cfi = new _epubcfi.default(target);
|
||
index = cfi.spinePos;
|
||
} else if (typeof target === "number" || isNaN(target) === false) {
|
||
index = target;
|
||
} else if (typeof target === "string" && target.indexOf("#") === 0) {
|
||
index = this.spineById[target.substring(1)];
|
||
} else if (typeof target === "string") {
|
||
target = target.split("#")[0];
|
||
index = this.spineByHref[target] || this.spineByHref[encodeURI(target)];
|
||
}
|
||
return this.spineItems[index] || null;
|
||
}
|
||
append(section) {
|
||
var index = this.spineItems.length;
|
||
section.index = index;
|
||
this.spineItems.push(section);
|
||
this.spineByHref[decodeURI(section.href)] = index;
|
||
this.spineByHref[encodeURI(section.href)] = index;
|
||
this.spineByHref[section.href] = index;
|
||
this.spineById[section.idref] = index;
|
||
return index;
|
||
}
|
||
prepend(section) {
|
||
this.spineByHref[section.href] = 0;
|
||
this.spineById[section.idref] = 0;
|
||
this.spineItems.forEach(function(item, index) {
|
||
item.index = index;
|
||
});
|
||
return 0;
|
||
}
|
||
remove(section) {
|
||
var index = this.spineItems.indexOf(section);
|
||
if (index > -1) {
|
||
delete this.spineByHref[section.href];
|
||
delete this.spineById[section.idref];
|
||
return this.spineItems.splice(index, 1);
|
||
}
|
||
}
|
||
each() {
|
||
return this.spineItems.forEach.apply(this.spineItems, arguments);
|
||
}
|
||
first() {
|
||
let index = 0;
|
||
do {
|
||
let next = this.get(index);
|
||
if (next && next.linear) {
|
||
return next;
|
||
}
|
||
index += 1;
|
||
} while (index < this.spineItems.length);
|
||
}
|
||
last() {
|
||
let index = this.spineItems.length - 1;
|
||
do {
|
||
let prev = this.get(index);
|
||
if (prev && prev.linear) {
|
||
return prev;
|
||
}
|
||
index -= 1;
|
||
} while (index >= 0);
|
||
}
|
||
destroy() {
|
||
this.each((section) => section.destroy());
|
||
this.spineItems = void 0;
|
||
this.spineByHref = void 0;
|
||
this.spineById = void 0;
|
||
this.hooks.serialize.clear();
|
||
this.hooks.content.clear();
|
||
this.hooks = void 0;
|
||
this.epubcfi = void 0;
|
||
this.loaded = false;
|
||
this.items = void 0;
|
||
this.manifest = void 0;
|
||
this.spineNodeIndex = void 0;
|
||
this.baseUrl = void 0;
|
||
this.length = void 0;
|
||
}
|
||
};
|
||
var _default = Spine;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/utils/queue.js
|
||
var require_queue = __commonJS({
|
||
"node_modules/epubjs/lib/utils/queue.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = exports.Task = void 0;
|
||
var _core = require_core();
|
||
var Queue = class {
|
||
constructor(context) {
|
||
this._q = [];
|
||
this.context = context;
|
||
this.tick = _core.requestAnimationFrame;
|
||
this.running = false;
|
||
this.paused = false;
|
||
}
|
||
enqueue() {
|
||
var deferred, promise;
|
||
var queued;
|
||
var task = [].shift.call(arguments);
|
||
var args = arguments;
|
||
if (!task) {
|
||
throw new Error("No Task Provided");
|
||
}
|
||
if (typeof task === "function") {
|
||
deferred = new _core.defer();
|
||
promise = deferred.promise;
|
||
queued = {
|
||
"task": task,
|
||
"args": args,
|
||
"deferred": deferred,
|
||
"promise": promise
|
||
};
|
||
} else {
|
||
queued = {
|
||
"promise": task
|
||
};
|
||
}
|
||
this._q.push(queued);
|
||
if (this.paused == false && !this.running) {
|
||
this.run();
|
||
}
|
||
return queued.promise;
|
||
}
|
||
dequeue() {
|
||
var inwait, task, result;
|
||
if (this._q.length && !this.paused) {
|
||
inwait = this._q.shift();
|
||
task = inwait.task;
|
||
if (task) {
|
||
result = task.apply(this.context, inwait.args);
|
||
if (result && typeof result["then"] === "function") {
|
||
return result.then(function() {
|
||
inwait.deferred.resolve.apply(this.context, arguments);
|
||
}.bind(this), function() {
|
||
inwait.deferred.reject.apply(this.context, arguments);
|
||
}.bind(this));
|
||
} else {
|
||
inwait.deferred.resolve.apply(this.context, result);
|
||
return inwait.promise;
|
||
}
|
||
} else if (inwait.promise) {
|
||
return inwait.promise;
|
||
}
|
||
} else {
|
||
inwait = new _core.defer();
|
||
inwait.deferred.resolve();
|
||
return inwait.promise;
|
||
}
|
||
}
|
||
dump() {
|
||
while (this._q.length) {
|
||
this.dequeue();
|
||
}
|
||
}
|
||
run() {
|
||
if (!this.running) {
|
||
this.running = true;
|
||
this.defered = new _core.defer();
|
||
}
|
||
this.tick.call(window, () => {
|
||
if (this._q.length) {
|
||
this.dequeue().then(function() {
|
||
this.run();
|
||
}.bind(this));
|
||
} else {
|
||
this.defered.resolve();
|
||
this.running = void 0;
|
||
}
|
||
});
|
||
if (this.paused == true) {
|
||
this.paused = false;
|
||
}
|
||
return this.defered.promise;
|
||
}
|
||
flush() {
|
||
if (this.running) {
|
||
return this.running;
|
||
}
|
||
if (this._q.length) {
|
||
this.running = this.dequeue().then(function() {
|
||
this.running = void 0;
|
||
return this.flush();
|
||
}.bind(this));
|
||
return this.running;
|
||
}
|
||
}
|
||
clear() {
|
||
this._q = [];
|
||
}
|
||
length() {
|
||
return this._q.length;
|
||
}
|
||
pause() {
|
||
this.paused = true;
|
||
}
|
||
stop() {
|
||
this._q = [];
|
||
this.running = false;
|
||
this.paused = true;
|
||
}
|
||
};
|
||
var Task = class {
|
||
constructor(task, args, context) {
|
||
return function() {
|
||
var toApply = arguments || [];
|
||
return new Promise((resolve, reject) => {
|
||
var callback = function(value, err) {
|
||
if (!value && err) {
|
||
reject(err);
|
||
} else {
|
||
resolve(value);
|
||
}
|
||
};
|
||
toApply.push(callback);
|
||
task.apply(context || this, toApply);
|
||
});
|
||
};
|
||
}
|
||
};
|
||
exports.Task = Task;
|
||
var _default = Queue;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/utils/constants.js
|
||
var require_constants = __commonJS({
|
||
"node_modules/epubjs/lib/utils/constants.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.EVENTS = exports.EPUBJS_VERSION = exports.DOM_EVENTS = void 0;
|
||
var EPUBJS_VERSION = "0.3";
|
||
exports.EPUBJS_VERSION = EPUBJS_VERSION;
|
||
var DOM_EVENTS = ["keydown", "keyup", "keypressed", "mouseup", "mousedown", "mousemove", "click", "touchend", "touchstart", "touchmove"];
|
||
exports.DOM_EVENTS = DOM_EVENTS;
|
||
var EVENTS = {
|
||
BOOK: {
|
||
OPEN_FAILED: "openFailed"
|
||
},
|
||
CONTENTS: {
|
||
EXPAND: "expand",
|
||
RESIZE: "resize",
|
||
SELECTED: "selected",
|
||
SELECTED_RANGE: "selectedRange",
|
||
LINK_CLICKED: "linkClicked"
|
||
},
|
||
LOCATIONS: {
|
||
CHANGED: "changed"
|
||
},
|
||
MANAGERS: {
|
||
RESIZE: "resize",
|
||
RESIZED: "resized",
|
||
ORIENTATION_CHANGE: "orientationchange",
|
||
ADDED: "added",
|
||
SCROLL: "scroll",
|
||
SCROLLED: "scrolled",
|
||
REMOVED: "removed"
|
||
},
|
||
VIEWS: {
|
||
AXIS: "axis",
|
||
WRITING_MODE: "writingMode",
|
||
LOAD_ERROR: "loaderror",
|
||
RENDERED: "rendered",
|
||
RESIZED: "resized",
|
||
DISPLAYED: "displayed",
|
||
SHOWN: "shown",
|
||
HIDDEN: "hidden",
|
||
MARK_CLICKED: "markClicked"
|
||
},
|
||
RENDITION: {
|
||
STARTED: "started",
|
||
ATTACHED: "attached",
|
||
DISPLAYED: "displayed",
|
||
DISPLAY_ERROR: "displayerror",
|
||
RENDERED: "rendered",
|
||
REMOVED: "removed",
|
||
RESIZED: "resized",
|
||
ORIENTATION_CHANGE: "orientationchange",
|
||
LOCATION_CHANGED: "locationChanged",
|
||
RELOCATED: "relocated",
|
||
MARK_CLICKED: "markClicked",
|
||
SELECTED: "selected",
|
||
LAYOUT: "layout"
|
||
},
|
||
LAYOUT: {
|
||
UPDATED: "updated"
|
||
},
|
||
ANNOTATION: {
|
||
ATTACH: "attach",
|
||
DETACH: "detach"
|
||
}
|
||
};
|
||
exports.EVENTS = EVENTS;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/locations.js
|
||
var require_locations = __commonJS({
|
||
"node_modules/epubjs/lib/locations.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _core = require_core();
|
||
var _queue = _interopRequireDefault(require_queue());
|
||
var _epubcfi = _interopRequireDefault(require_epubcfi());
|
||
var _constants = require_constants();
|
||
var _eventEmitter = _interopRequireDefault(require_event_emitter());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Locations = class {
|
||
constructor(spine, request, pause) {
|
||
this.spine = spine;
|
||
this.request = request;
|
||
this.pause = pause || 100;
|
||
this.q = new _queue.default(this);
|
||
this.epubcfi = new _epubcfi.default();
|
||
this._locations = [];
|
||
this._locationsWords = [];
|
||
this.total = 0;
|
||
this.break = 150;
|
||
this._current = 0;
|
||
this._wordCounter = 0;
|
||
this.currentLocation = "";
|
||
this._currentCfi = "";
|
||
this.processingTimeout = void 0;
|
||
}
|
||
generate(chars) {
|
||
if (chars) {
|
||
this.break = chars;
|
||
}
|
||
this.q.pause();
|
||
this.spine.each(function(section) {
|
||
if (section.linear) {
|
||
this.q.enqueue(this.process.bind(this), section);
|
||
}
|
||
}.bind(this));
|
||
return this.q.run().then(function() {
|
||
this.total = this._locations.length - 1;
|
||
if (this._currentCfi) {
|
||
this.currentLocation = this._currentCfi;
|
||
}
|
||
return this._locations;
|
||
}.bind(this));
|
||
}
|
||
createRange() {
|
||
return {
|
||
startContainer: void 0,
|
||
startOffset: void 0,
|
||
endContainer: void 0,
|
||
endOffset: void 0
|
||
};
|
||
}
|
||
process(section) {
|
||
return section.load(this.request).then(function(contents) {
|
||
var completed = new _core.defer();
|
||
var locations = this.parse(contents, section.cfiBase);
|
||
this._locations = this._locations.concat(locations);
|
||
section.unload();
|
||
this.processingTimeout = setTimeout(() => completed.resolve(locations), this.pause);
|
||
return completed.promise;
|
||
}.bind(this));
|
||
}
|
||
parse(contents, cfiBase, chars) {
|
||
var locations = [];
|
||
var range;
|
||
var doc = contents.ownerDocument;
|
||
var body = (0, _core.qs)(doc, "body");
|
||
var counter = 0;
|
||
var prev;
|
||
var _break = chars || this.break;
|
||
var parser = function(node) {
|
||
var len = node.length;
|
||
var dist;
|
||
var pos = 0;
|
||
if (node.textContent.trim().length === 0) {
|
||
return false;
|
||
}
|
||
if (counter == 0) {
|
||
range = this.createRange();
|
||
range.startContainer = node;
|
||
range.startOffset = 0;
|
||
}
|
||
dist = _break - counter;
|
||
if (dist > len) {
|
||
counter += len;
|
||
pos = len;
|
||
}
|
||
while (pos < len) {
|
||
dist = _break - counter;
|
||
if (counter === 0) {
|
||
pos += 1;
|
||
range = this.createRange();
|
||
range.startContainer = node;
|
||
range.startOffset = pos;
|
||
}
|
||
if (pos + dist >= len) {
|
||
counter += len - pos;
|
||
pos = len;
|
||
} else {
|
||
pos += dist;
|
||
range.endContainer = node;
|
||
range.endOffset = pos;
|
||
let cfi = new _epubcfi.default(range, cfiBase).toString();
|
||
locations.push(cfi);
|
||
counter = 0;
|
||
}
|
||
}
|
||
prev = node;
|
||
};
|
||
(0, _core.sprint)(body, parser.bind(this));
|
||
if (range && range.startContainer && prev) {
|
||
range.endContainer = prev;
|
||
range.endOffset = prev.length;
|
||
let cfi = new _epubcfi.default(range, cfiBase).toString();
|
||
locations.push(cfi);
|
||
counter = 0;
|
||
}
|
||
return locations;
|
||
}
|
||
generateFromWords(startCfi, wordCount, count) {
|
||
var start = startCfi ? new _epubcfi.default(startCfi) : void 0;
|
||
this.q.pause();
|
||
this._locationsWords = [];
|
||
this._wordCounter = 0;
|
||
this.spine.each(function(section) {
|
||
if (section.linear) {
|
||
if (start) {
|
||
if (section.index >= start.spinePos) {
|
||
this.q.enqueue(this.processWords.bind(this), section, wordCount, start, count);
|
||
}
|
||
} else {
|
||
this.q.enqueue(this.processWords.bind(this), section, wordCount, start, count);
|
||
}
|
||
}
|
||
}.bind(this));
|
||
return this.q.run().then(function() {
|
||
if (this._currentCfi) {
|
||
this.currentLocation = this._currentCfi;
|
||
}
|
||
return this._locationsWords;
|
||
}.bind(this));
|
||
}
|
||
processWords(section, wordCount, startCfi, count) {
|
||
if (count && this._locationsWords.length >= count) {
|
||
return Promise.resolve();
|
||
}
|
||
return section.load(this.request).then(function(contents) {
|
||
var completed = new _core.defer();
|
||
var locations = this.parseWords(contents, section, wordCount, startCfi);
|
||
var remainingCount = count - this._locationsWords.length;
|
||
this._locationsWords = this._locationsWords.concat(locations.length >= count ? locations.slice(0, remainingCount) : locations);
|
||
section.unload();
|
||
this.processingTimeout = setTimeout(() => completed.resolve(locations), this.pause);
|
||
return completed.promise;
|
||
}.bind(this));
|
||
}
|
||
countWords(s) {
|
||
s = s.replace(/(^\s*)|(\s*$)/gi, "");
|
||
s = s.replace(/[ ]{2,}/gi, " ");
|
||
s = s.replace(/\n /, "\n");
|
||
return s.split(" ").length;
|
||
}
|
||
parseWords(contents, section, wordCount, startCfi) {
|
||
var cfiBase = section.cfiBase;
|
||
var locations = [];
|
||
var doc = contents.ownerDocument;
|
||
var body = (0, _core.qs)(doc, "body");
|
||
var prev;
|
||
var _break = wordCount;
|
||
var foundStartNode = startCfi ? startCfi.spinePos !== section.index : true;
|
||
var startNode;
|
||
if (startCfi && section.index === startCfi.spinePos) {
|
||
startNode = startCfi.findNode(startCfi.range ? startCfi.path.steps.concat(startCfi.start.steps) : startCfi.path.steps, contents.ownerDocument);
|
||
}
|
||
var parser = function(node) {
|
||
if (!foundStartNode) {
|
||
if (node === startNode) {
|
||
foundStartNode = true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
if (node.textContent.length < 10) {
|
||
if (node.textContent.trim().length === 0) {
|
||
return false;
|
||
}
|
||
}
|
||
var len = this.countWords(node.textContent);
|
||
var dist;
|
||
var pos = 0;
|
||
if (len === 0) {
|
||
return false;
|
||
}
|
||
dist = _break - this._wordCounter;
|
||
if (dist > len) {
|
||
this._wordCounter += len;
|
||
pos = len;
|
||
}
|
||
while (pos < len) {
|
||
dist = _break - this._wordCounter;
|
||
if (pos + dist >= len) {
|
||
this._wordCounter += len - pos;
|
||
pos = len;
|
||
} else {
|
||
pos += dist;
|
||
let cfi = new _epubcfi.default(node, cfiBase);
|
||
locations.push({
|
||
cfi: cfi.toString(),
|
||
wordCount: this._wordCounter
|
||
});
|
||
this._wordCounter = 0;
|
||
}
|
||
}
|
||
prev = node;
|
||
};
|
||
(0, _core.sprint)(body, parser.bind(this));
|
||
return locations;
|
||
}
|
||
locationFromCfi(cfi) {
|
||
let loc;
|
||
if (_epubcfi.default.prototype.isCfiString(cfi)) {
|
||
cfi = new _epubcfi.default(cfi);
|
||
}
|
||
if (this._locations.length === 0) {
|
||
return -1;
|
||
}
|
||
loc = (0, _core.locationOf)(cfi, this._locations, this.epubcfi.compare);
|
||
if (loc > this.total) {
|
||
return this.total;
|
||
}
|
||
return loc;
|
||
}
|
||
percentageFromCfi(cfi) {
|
||
if (this._locations.length === 0) {
|
||
return null;
|
||
}
|
||
var loc = this.locationFromCfi(cfi);
|
||
return this.percentageFromLocation(loc);
|
||
}
|
||
percentageFromLocation(loc) {
|
||
if (!loc || !this.total) {
|
||
return 0;
|
||
}
|
||
return loc / this.total;
|
||
}
|
||
cfiFromLocation(loc) {
|
||
var cfi = -1;
|
||
if (typeof loc != "number") {
|
||
loc = parseInt(loc);
|
||
}
|
||
if (loc >= 0 && loc < this._locations.length) {
|
||
cfi = this._locations[loc];
|
||
}
|
||
return cfi;
|
||
}
|
||
cfiFromPercentage(percentage) {
|
||
let loc;
|
||
if (percentage > 1) {
|
||
console.warn("Normalize cfiFromPercentage value to between 0 - 1");
|
||
}
|
||
if (percentage >= 1) {
|
||
let cfi = new _epubcfi.default(this._locations[this.total]);
|
||
cfi.collapse();
|
||
return cfi.toString();
|
||
}
|
||
loc = Math.ceil(this.total * percentage);
|
||
return this.cfiFromLocation(loc);
|
||
}
|
||
load(locations) {
|
||
if (typeof locations === "string") {
|
||
this._locations = JSON.parse(locations);
|
||
} else {
|
||
this._locations = locations;
|
||
}
|
||
this.total = this._locations.length - 1;
|
||
return this._locations;
|
||
}
|
||
save() {
|
||
return JSON.stringify(this._locations);
|
||
}
|
||
getCurrent() {
|
||
return this._current;
|
||
}
|
||
setCurrent(curr) {
|
||
var loc;
|
||
if (typeof curr == "string") {
|
||
this._currentCfi = curr;
|
||
} else if (typeof curr == "number") {
|
||
this._current = curr;
|
||
} else {
|
||
return;
|
||
}
|
||
if (this._locations.length === 0) {
|
||
return;
|
||
}
|
||
if (typeof curr == "string") {
|
||
loc = this.locationFromCfi(curr);
|
||
this._current = loc;
|
||
} else {
|
||
loc = curr;
|
||
}
|
||
this.emit(_constants.EVENTS.LOCATIONS.CHANGED, {
|
||
percentage: this.percentageFromLocation(loc)
|
||
});
|
||
}
|
||
get currentLocation() {
|
||
return this._current;
|
||
}
|
||
set currentLocation(curr) {
|
||
this.setCurrent(curr);
|
||
}
|
||
length() {
|
||
return this._locations.length;
|
||
}
|
||
destroy() {
|
||
this.spine = void 0;
|
||
this.request = void 0;
|
||
this.pause = void 0;
|
||
this.q.stop();
|
||
this.q = void 0;
|
||
this.epubcfi = void 0;
|
||
this._locations = void 0;
|
||
this.total = void 0;
|
||
this.break = void 0;
|
||
this._current = void 0;
|
||
this.currentLocation = void 0;
|
||
this._currentCfi = void 0;
|
||
clearTimeout(this.processingTimeout);
|
||
}
|
||
};
|
||
(0, _eventEmitter.default)(Locations.prototype);
|
||
var _default = Locations;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/container.js
|
||
var require_container = __commonJS({
|
||
"node_modules/epubjs/lib/container.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _pathWebpack = _interopRequireDefault(require_path());
|
||
var _core = require_core();
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Container = class {
|
||
constructor(containerDocument) {
|
||
this.packagePath = "";
|
||
this.directory = "";
|
||
this.encoding = "";
|
||
if (containerDocument) {
|
||
this.parse(containerDocument);
|
||
}
|
||
}
|
||
parse(containerDocument) {
|
||
var rootfile;
|
||
if (!containerDocument) {
|
||
throw new Error("Container File Not Found");
|
||
}
|
||
rootfile = (0, _core.qs)(containerDocument, "rootfile");
|
||
if (!rootfile) {
|
||
throw new Error("No RootFile Found");
|
||
}
|
||
this.packagePath = rootfile.getAttribute("full-path");
|
||
this.directory = _pathWebpack.default.dirname(this.packagePath);
|
||
this.encoding = containerDocument.xmlEncoding;
|
||
}
|
||
destroy() {
|
||
this.packagePath = void 0;
|
||
this.directory = void 0;
|
||
this.encoding = void 0;
|
||
}
|
||
};
|
||
var _default = Container;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/packaging.js
|
||
var require_packaging = __commonJS({
|
||
"node_modules/epubjs/lib/packaging.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _core = require_core();
|
||
var Packaging = class {
|
||
constructor(packageDocument) {
|
||
this.manifest = {};
|
||
this.navPath = "";
|
||
this.ncxPath = "";
|
||
this.coverPath = "";
|
||
this.spineNodeIndex = 0;
|
||
this.spine = [];
|
||
this.metadata = {};
|
||
if (packageDocument) {
|
||
this.parse(packageDocument);
|
||
}
|
||
}
|
||
parse(packageDocument) {
|
||
var metadataNode, manifestNode, spineNode;
|
||
if (!packageDocument) {
|
||
throw new Error("Package File Not Found");
|
||
}
|
||
metadataNode = (0, _core.qs)(packageDocument, "metadata");
|
||
if (!metadataNode) {
|
||
throw new Error("No Metadata Found");
|
||
}
|
||
manifestNode = (0, _core.qs)(packageDocument, "manifest");
|
||
if (!manifestNode) {
|
||
throw new Error("No Manifest Found");
|
||
}
|
||
spineNode = (0, _core.qs)(packageDocument, "spine");
|
||
if (!spineNode) {
|
||
throw new Error("No Spine Found");
|
||
}
|
||
this.manifest = this.parseManifest(manifestNode);
|
||
this.navPath = this.findNavPath(manifestNode);
|
||
this.ncxPath = this.findNcxPath(manifestNode, spineNode);
|
||
this.coverPath = this.findCoverPath(packageDocument);
|
||
this.spineNodeIndex = (0, _core.indexOfElementNode)(spineNode);
|
||
this.spine = this.parseSpine(spineNode, this.manifest);
|
||
this.uniqueIdentifier = this.findUniqueIdentifier(packageDocument);
|
||
this.metadata = this.parseMetadata(metadataNode);
|
||
this.metadata.direction = spineNode.getAttribute("page-progression-direction");
|
||
return {
|
||
"metadata": this.metadata,
|
||
"spine": this.spine,
|
||
"manifest": this.manifest,
|
||
"navPath": this.navPath,
|
||
"ncxPath": this.ncxPath,
|
||
"coverPath": this.coverPath,
|
||
"spineNodeIndex": this.spineNodeIndex
|
||
};
|
||
}
|
||
parseMetadata(xml) {
|
||
var metadata = {};
|
||
metadata.title = this.getElementText(xml, "title");
|
||
metadata.creator = this.getElementText(xml, "creator");
|
||
metadata.description = this.getElementText(xml, "description");
|
||
metadata.pubdate = this.getElementText(xml, "date");
|
||
metadata.publisher = this.getElementText(xml, "publisher");
|
||
metadata.identifier = this.getElementText(xml, "identifier");
|
||
metadata.language = this.getElementText(xml, "language");
|
||
metadata.rights = this.getElementText(xml, "rights");
|
||
metadata.modified_date = this.getPropertyText(xml, "dcterms:modified");
|
||
metadata.layout = this.getPropertyText(xml, "rendition:layout");
|
||
metadata.orientation = this.getPropertyText(xml, "rendition:orientation");
|
||
metadata.flow = this.getPropertyText(xml, "rendition:flow");
|
||
metadata.viewport = this.getPropertyText(xml, "rendition:viewport");
|
||
metadata.media_active_class = this.getPropertyText(xml, "media:active-class");
|
||
metadata.spread = this.getPropertyText(xml, "rendition:spread");
|
||
return metadata;
|
||
}
|
||
parseManifest(manifestXml) {
|
||
var manifest = {};
|
||
var selected = (0, _core.qsa)(manifestXml, "item");
|
||
var items = Array.prototype.slice.call(selected);
|
||
items.forEach(function(item) {
|
||
var id = item.getAttribute("id"), href = item.getAttribute("href") || "", type = item.getAttribute("media-type") || "", overlay = item.getAttribute("media-overlay") || "", properties = item.getAttribute("properties") || "";
|
||
manifest[id] = {
|
||
"href": href,
|
||
"type": type,
|
||
"overlay": overlay,
|
||
"properties": properties.length ? properties.split(" ") : []
|
||
};
|
||
});
|
||
return manifest;
|
||
}
|
||
parseSpine(spineXml, manifest) {
|
||
var spine = [];
|
||
var selected = (0, _core.qsa)(spineXml, "itemref");
|
||
var items = Array.prototype.slice.call(selected);
|
||
items.forEach(function(item, index) {
|
||
var idref = item.getAttribute("idref");
|
||
var props = item.getAttribute("properties") || "";
|
||
var propArray = props.length ? props.split(" ") : [];
|
||
var itemref = {
|
||
"id": item.getAttribute("id"),
|
||
"idref": idref,
|
||
"linear": item.getAttribute("linear") || "yes",
|
||
"properties": propArray,
|
||
"index": index
|
||
};
|
||
spine.push(itemref);
|
||
});
|
||
return spine;
|
||
}
|
||
findUniqueIdentifier(packageXml) {
|
||
var uniqueIdentifierId = packageXml.documentElement.getAttribute("unique-identifier");
|
||
if (!uniqueIdentifierId) {
|
||
return "";
|
||
}
|
||
var identifier = packageXml.getElementById(uniqueIdentifierId);
|
||
if (!identifier) {
|
||
return "";
|
||
}
|
||
if (identifier.localName === "identifier" && identifier.namespaceURI === "http://purl.org/dc/elements/1.1/") {
|
||
return identifier.childNodes.length > 0 ? identifier.childNodes[0].nodeValue.trim() : "";
|
||
}
|
||
return "";
|
||
}
|
||
findNavPath(manifestNode) {
|
||
var node = (0, _core.qsp)(manifestNode, "item", {
|
||
"properties": "nav"
|
||
});
|
||
return node ? node.getAttribute("href") : false;
|
||
}
|
||
findNcxPath(manifestNode, spineNode) {
|
||
var node = (0, _core.qsp)(manifestNode, "item", {
|
||
"media-type": "application/x-dtbncx+xml"
|
||
});
|
||
var tocId;
|
||
if (!node) {
|
||
tocId = spineNode.getAttribute("toc");
|
||
if (tocId) {
|
||
node = manifestNode.querySelector(`#${tocId}`);
|
||
}
|
||
}
|
||
return node ? node.getAttribute("href") : false;
|
||
}
|
||
findCoverPath(packageXml) {
|
||
var pkg = (0, _core.qs)(packageXml, "package");
|
||
var epubVersion = pkg.getAttribute("version");
|
||
var node = (0, _core.qsp)(packageXml, "item", {
|
||
"properties": "cover-image"
|
||
});
|
||
if (node)
|
||
return node.getAttribute("href");
|
||
var metaCover = (0, _core.qsp)(packageXml, "meta", {
|
||
"name": "cover"
|
||
});
|
||
if (metaCover) {
|
||
var coverId = metaCover.getAttribute("content");
|
||
var cover = packageXml.getElementById(coverId);
|
||
return cover ? cover.getAttribute("href") : "";
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
getElementText(xml, tag) {
|
||
var found = xml.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/", tag);
|
||
var el;
|
||
if (!found || found.length === 0)
|
||
return "";
|
||
el = found[0];
|
||
if (el.childNodes.length) {
|
||
return el.childNodes[0].nodeValue;
|
||
}
|
||
return "";
|
||
}
|
||
getPropertyText(xml, property) {
|
||
var el = (0, _core.qsp)(xml, "meta", {
|
||
"property": property
|
||
});
|
||
if (el && el.childNodes.length) {
|
||
return el.childNodes[0].nodeValue;
|
||
}
|
||
return "";
|
||
}
|
||
load(json) {
|
||
this.metadata = json.metadata;
|
||
let spine = json.readingOrder || json.spine;
|
||
this.spine = spine.map((item, index) => {
|
||
item.index = index;
|
||
item.linear = item.linear || "yes";
|
||
return item;
|
||
});
|
||
json.resources.forEach((item, index) => {
|
||
this.manifest[index] = item;
|
||
if (item.rel && item.rel[0] === "cover") {
|
||
this.coverPath = item.href;
|
||
}
|
||
});
|
||
this.spineNodeIndex = 0;
|
||
this.toc = json.toc.map((item, index) => {
|
||
item.label = item.title;
|
||
return item;
|
||
});
|
||
return {
|
||
"metadata": this.metadata,
|
||
"spine": this.spine,
|
||
"manifest": this.manifest,
|
||
"navPath": this.navPath,
|
||
"ncxPath": this.ncxPath,
|
||
"coverPath": this.coverPath,
|
||
"spineNodeIndex": this.spineNodeIndex,
|
||
"toc": this.toc
|
||
};
|
||
}
|
||
destroy() {
|
||
this.manifest = void 0;
|
||
this.navPath = void 0;
|
||
this.ncxPath = void 0;
|
||
this.coverPath = void 0;
|
||
this.spineNodeIndex = void 0;
|
||
this.spine = void 0;
|
||
this.metadata = void 0;
|
||
}
|
||
};
|
||
var _default = Packaging;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/navigation.js
|
||
var require_navigation = __commonJS({
|
||
"node_modules/epubjs/lib/navigation.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _core = require_core();
|
||
var Navigation = class {
|
||
constructor(xml) {
|
||
this.toc = [];
|
||
this.tocByHref = {};
|
||
this.tocById = {};
|
||
this.landmarks = [];
|
||
this.landmarksByType = {};
|
||
this.length = 0;
|
||
if (xml) {
|
||
this.parse(xml);
|
||
}
|
||
}
|
||
parse(xml) {
|
||
let isXml = xml.nodeType;
|
||
let html;
|
||
let ncx;
|
||
if (isXml) {
|
||
html = (0, _core.qs)(xml, "html");
|
||
ncx = (0, _core.qs)(xml, "ncx");
|
||
}
|
||
if (!isXml) {
|
||
this.toc = this.load(xml);
|
||
} else if (html) {
|
||
this.toc = this.parseNav(xml);
|
||
this.landmarks = this.parseLandmarks(xml);
|
||
} else if (ncx) {
|
||
this.toc = this.parseNcx(xml);
|
||
}
|
||
this.length = 0;
|
||
this.unpack(this.toc);
|
||
}
|
||
unpack(toc) {
|
||
var item;
|
||
for (var i = 0; i < toc.length; i++) {
|
||
item = toc[i];
|
||
if (item.href) {
|
||
this.tocByHref[item.href] = i;
|
||
}
|
||
if (item.id) {
|
||
this.tocById[item.id] = i;
|
||
}
|
||
this.length++;
|
||
if (item.subitems.length) {
|
||
this.unpack(item.subitems);
|
||
}
|
||
}
|
||
}
|
||
get(target) {
|
||
var index;
|
||
if (!target) {
|
||
return this.toc;
|
||
}
|
||
if (target.indexOf("#") === 0) {
|
||
index = this.tocById[target.substring(1)];
|
||
} else if (target in this.tocByHref) {
|
||
index = this.tocByHref[target];
|
||
}
|
||
return this.getByIndex(target, index, this.toc);
|
||
}
|
||
getByIndex(target, index, navItems) {
|
||
if (navItems.length === 0) {
|
||
return;
|
||
}
|
||
const item = navItems[index];
|
||
if (item && (target === item.id || target === item.href)) {
|
||
return item;
|
||
} else {
|
||
let result;
|
||
for (let i = 0; i < navItems.length; ++i) {
|
||
result = this.getByIndex(target, index, navItems[i].subitems);
|
||
if (result) {
|
||
break;
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
}
|
||
landmark(type) {
|
||
var index;
|
||
if (!type) {
|
||
return this.landmarks;
|
||
}
|
||
index = this.landmarksByType[type];
|
||
return this.landmarks[index];
|
||
}
|
||
parseNav(navHtml) {
|
||
var navElement = (0, _core.querySelectorByType)(navHtml, "nav", "toc");
|
||
var list = [];
|
||
if (!navElement)
|
||
return list;
|
||
let navList = (0, _core.filterChildren)(navElement, "ol", true);
|
||
if (!navList)
|
||
return list;
|
||
list = this.parseNavList(navList);
|
||
return list;
|
||
}
|
||
parseNavList(navListHtml, parent2) {
|
||
const result = [];
|
||
if (!navListHtml)
|
||
return result;
|
||
if (!navListHtml.children)
|
||
return result;
|
||
for (let i = 0; i < navListHtml.children.length; i++) {
|
||
const item = this.navItem(navListHtml.children[i], parent2);
|
||
if (item) {
|
||
result.push(item);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
navItem(item, parent2) {
|
||
let id = item.getAttribute("id") || void 0;
|
||
let content = (0, _core.filterChildren)(item, "a", true) || (0, _core.filterChildren)(item, "span", true);
|
||
if (!content) {
|
||
return;
|
||
}
|
||
let src = content.getAttribute("href") || "";
|
||
if (!id) {
|
||
id = src;
|
||
}
|
||
let text = content.textContent || "";
|
||
let subitems = [];
|
||
let nested = (0, _core.filterChildren)(item, "ol", true);
|
||
if (nested) {
|
||
subitems = this.parseNavList(nested, id);
|
||
}
|
||
return {
|
||
"id": id,
|
||
"href": src,
|
||
"label": text,
|
||
"subitems": subitems,
|
||
"parent": parent2
|
||
};
|
||
}
|
||
parseLandmarks(navHtml) {
|
||
var navElement = (0, _core.querySelectorByType)(navHtml, "nav", "landmarks");
|
||
var navItems = navElement ? (0, _core.qsa)(navElement, "li") : [];
|
||
var length = navItems.length;
|
||
var i;
|
||
var list = [];
|
||
var item;
|
||
if (!navItems || length === 0)
|
||
return list;
|
||
for (i = 0; i < length; ++i) {
|
||
item = this.landmarkItem(navItems[i]);
|
||
if (item) {
|
||
list.push(item);
|
||
this.landmarksByType[item.type] = i;
|
||
}
|
||
}
|
||
return list;
|
||
}
|
||
landmarkItem(item) {
|
||
let content = (0, _core.filterChildren)(item, "a", true);
|
||
if (!content) {
|
||
return;
|
||
}
|
||
let type = content.getAttributeNS("http://www.idpf.org/2007/ops", "type") || void 0;
|
||
let href = content.getAttribute("href") || "";
|
||
let text = content.textContent || "";
|
||
return {
|
||
"href": href,
|
||
"label": text,
|
||
"type": type
|
||
};
|
||
}
|
||
parseNcx(tocXml) {
|
||
var navPoints = (0, _core.qsa)(tocXml, "navPoint");
|
||
var length = navPoints.length;
|
||
var i;
|
||
var toc = {};
|
||
var list = [];
|
||
var item, parent2;
|
||
if (!navPoints || length === 0)
|
||
return list;
|
||
for (i = 0; i < length; ++i) {
|
||
item = this.ncxItem(navPoints[i]);
|
||
toc[item.id] = item;
|
||
if (!item.parent) {
|
||
list.push(item);
|
||
} else {
|
||
parent2 = toc[item.parent];
|
||
parent2.subitems.push(item);
|
||
}
|
||
}
|
||
return list;
|
||
}
|
||
ncxItem(item) {
|
||
var id = item.getAttribute("id") || false, content = (0, _core.qs)(item, "content"), src = content.getAttribute("src"), navLabel = (0, _core.qs)(item, "navLabel"), text = navLabel.textContent ? navLabel.textContent : "", subitems = [], parentNode = item.parentNode, parent2;
|
||
if (parentNode && (parentNode.nodeName === "navPoint" || parentNode.nodeName.split(":").slice(-1)[0] === "navPoint")) {
|
||
parent2 = parentNode.getAttribute("id");
|
||
}
|
||
return {
|
||
"id": id,
|
||
"href": src,
|
||
"label": text,
|
||
"subitems": subitems,
|
||
"parent": parent2
|
||
};
|
||
}
|
||
load(json) {
|
||
return json.map((item) => {
|
||
item.label = item.title;
|
||
item.subitems = item.children ? this.load(item.children) : [];
|
||
return item;
|
||
});
|
||
}
|
||
forEach(fn) {
|
||
return this.toc.forEach(fn);
|
||
}
|
||
};
|
||
var _default = Navigation;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/utils/mime.js
|
||
var require_mime = __commonJS({
|
||
"node_modules/epubjs/lib/utils/mime.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var table = {
|
||
"application": {
|
||
"ecmascript": ["es", "ecma"],
|
||
"javascript": "js",
|
||
"ogg": "ogx",
|
||
"pdf": "pdf",
|
||
"postscript": ["ps", "ai", "eps", "epsi", "epsf", "eps2", "eps3"],
|
||
"rdf+xml": "rdf",
|
||
"smil": ["smi", "smil"],
|
||
"xhtml+xml": ["xhtml", "xht"],
|
||
"xml": ["xml", "xsl", "xsd", "opf", "ncx"],
|
||
"zip": "zip",
|
||
"x-httpd-eruby": "rhtml",
|
||
"x-latex": "latex",
|
||
"x-maker": ["frm", "maker", "frame", "fm", "fb", "book", "fbdoc"],
|
||
"x-object": "o",
|
||
"x-shockwave-flash": ["swf", "swfl"],
|
||
"x-silverlight": "scr",
|
||
"epub+zip": "epub",
|
||
"font-tdpfr": "pfr",
|
||
"inkml+xml": ["ink", "inkml"],
|
||
"json": "json",
|
||
"jsonml+json": "jsonml",
|
||
"mathml+xml": "mathml",
|
||
"metalink+xml": "metalink",
|
||
"mp4": "mp4s",
|
||
"omdoc+xml": "omdoc",
|
||
"oxps": "oxps",
|
||
"vnd.amazon.ebook": "azw",
|
||
"widget": "wgt",
|
||
"x-dtbook+xml": "dtb",
|
||
"x-dtbresource+xml": "res",
|
||
"x-font-bdf": "bdf",
|
||
"x-font-ghostscript": "gsf",
|
||
"x-font-linux-psf": "psf",
|
||
"x-font-otf": "otf",
|
||
"x-font-pcf": "pcf",
|
||
"x-font-snf": "snf",
|
||
"x-font-ttf": ["ttf", "ttc"],
|
||
"x-font-type1": ["pfa", "pfb", "pfm", "afm"],
|
||
"x-font-woff": "woff",
|
||
"x-mobipocket-ebook": ["prc", "mobi"],
|
||
"x-mspublisher": "pub",
|
||
"x-nzb": "nzb",
|
||
"x-tgif": "obj",
|
||
"xaml+xml": "xaml",
|
||
"xml-dtd": "dtd",
|
||
"xproc+xml": "xpl",
|
||
"xslt+xml": "xslt",
|
||
"internet-property-stream": "acx",
|
||
"x-compress": "z",
|
||
"x-compressed": "tgz",
|
||
"x-gzip": "gz"
|
||
},
|
||
"audio": {
|
||
"flac": "flac",
|
||
"midi": ["mid", "midi", "kar", "rmi"],
|
||
"mpeg": ["mpga", "mpega", "mp2", "mp3", "m4a", "mp2a", "m2a", "m3a"],
|
||
"mpegurl": "m3u",
|
||
"ogg": ["oga", "ogg", "spx"],
|
||
"x-aiff": ["aif", "aiff", "aifc"],
|
||
"x-ms-wma": "wma",
|
||
"x-wav": "wav",
|
||
"adpcm": "adp",
|
||
"mp4": "mp4a",
|
||
"webm": "weba",
|
||
"x-aac": "aac",
|
||
"x-caf": "caf",
|
||
"x-matroska": "mka",
|
||
"x-pn-realaudio-plugin": "rmp",
|
||
"xm": "xm",
|
||
"mid": ["mid", "rmi"]
|
||
},
|
||
"image": {
|
||
"gif": "gif",
|
||
"ief": "ief",
|
||
"jpeg": ["jpeg", "jpg", "jpe"],
|
||
"pcx": "pcx",
|
||
"png": "png",
|
||
"svg+xml": ["svg", "svgz"],
|
||
"tiff": ["tiff", "tif"],
|
||
"x-icon": "ico",
|
||
"bmp": "bmp",
|
||
"webp": "webp",
|
||
"x-pict": ["pic", "pct"],
|
||
"x-tga": "tga",
|
||
"cis-cod": "cod"
|
||
},
|
||
"text": {
|
||
"cache-manifest": ["manifest", "appcache"],
|
||
"css": "css",
|
||
"csv": "csv",
|
||
"html": ["html", "htm", "shtml", "stm"],
|
||
"mathml": "mml",
|
||
"plain": ["txt", "text", "brf", "conf", "def", "list", "log", "in", "bas"],
|
||
"richtext": "rtx",
|
||
"tab-separated-values": "tsv",
|
||
"x-bibtex": "bib"
|
||
},
|
||
"video": {
|
||
"mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v", "mp2", "mpa", "mpv2"],
|
||
"mp4": ["mp4", "mp4v", "mpg4"],
|
||
"quicktime": ["qt", "mov"],
|
||
"ogg": "ogv",
|
||
"vnd.mpegurl": ["mxu", "m4u"],
|
||
"x-flv": "flv",
|
||
"x-la-asf": ["lsf", "lsx"],
|
||
"x-mng": "mng",
|
||
"x-ms-asf": ["asf", "asx", "asr"],
|
||
"x-ms-wm": "wm",
|
||
"x-ms-wmv": "wmv",
|
||
"x-ms-wmx": "wmx",
|
||
"x-ms-wvx": "wvx",
|
||
"x-msvideo": "avi",
|
||
"x-sgi-movie": "movie",
|
||
"x-matroska": ["mpv", "mkv", "mk3d", "mks"],
|
||
"3gpp2": "3g2",
|
||
"h261": "h261",
|
||
"h263": "h263",
|
||
"h264": "h264",
|
||
"jpeg": "jpgv",
|
||
"jpm": ["jpm", "jpgm"],
|
||
"mj2": ["mj2", "mjp2"],
|
||
"vnd.ms-playready.media.pyv": "pyv",
|
||
"vnd.uvvu.mp4": ["uvu", "uvvu"],
|
||
"vnd.vivo": "viv",
|
||
"webm": "webm",
|
||
"x-f4v": "f4v",
|
||
"x-m4v": "m4v",
|
||
"x-ms-vob": "vob",
|
||
"x-smv": "smv"
|
||
}
|
||
};
|
||
var mimeTypes = function() {
|
||
var type, subtype, val, index, mimeTypes2 = {};
|
||
for (type in table) {
|
||
if (table.hasOwnProperty(type)) {
|
||
for (subtype in table[type]) {
|
||
if (table[type].hasOwnProperty(subtype)) {
|
||
val = table[type][subtype];
|
||
if (typeof val == "string") {
|
||
mimeTypes2[val] = type + "/" + subtype;
|
||
} else {
|
||
for (index = 0; index < val.length; index++) {
|
||
mimeTypes2[val[index]] = type + "/" + subtype;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return mimeTypes2;
|
||
}();
|
||
var defaultValue = "text/plain";
|
||
function lookup(filename) {
|
||
return filename && mimeTypes[filename.split(".").pop().toLowerCase()] || defaultValue;
|
||
}
|
||
var _default = {
|
||
lookup
|
||
};
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/resources.js
|
||
var require_resources = __commonJS({
|
||
"node_modules/epubjs/lib/resources.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _replacements = require_replacements();
|
||
var _core = require_core();
|
||
var _url = _interopRequireDefault(require_url());
|
||
var _mime = _interopRequireDefault(require_mime());
|
||
var _path = _interopRequireDefault(require_path2());
|
||
var _pathWebpack = _interopRequireDefault(require_path());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Resources = class {
|
||
constructor(manifest, options) {
|
||
this.settings = {
|
||
replacements: options && options.replacements || "base64",
|
||
archive: options && options.archive,
|
||
resolver: options && options.resolver,
|
||
request: options && options.request
|
||
};
|
||
this.process(manifest);
|
||
}
|
||
process(manifest) {
|
||
this.manifest = manifest;
|
||
this.resources = Object.keys(manifest).map(function(key) {
|
||
return manifest[key];
|
||
});
|
||
this.replacementUrls = [];
|
||
this.html = [];
|
||
this.assets = [];
|
||
this.css = [];
|
||
this.urls = [];
|
||
this.cssUrls = [];
|
||
this.split();
|
||
this.splitUrls();
|
||
}
|
||
split() {
|
||
this.html = this.resources.filter(function(item) {
|
||
if (item.type === "application/xhtml+xml" || item.type === "text/html") {
|
||
return true;
|
||
}
|
||
});
|
||
this.assets = this.resources.filter(function(item) {
|
||
if (item.type !== "application/xhtml+xml" && item.type !== "text/html") {
|
||
return true;
|
||
}
|
||
});
|
||
this.css = this.resources.filter(function(item) {
|
||
if (item.type === "text/css") {
|
||
return true;
|
||
}
|
||
});
|
||
}
|
||
splitUrls() {
|
||
this.urls = this.assets.map(function(item) {
|
||
return item.href;
|
||
}.bind(this));
|
||
this.cssUrls = this.css.map(function(item) {
|
||
return item.href;
|
||
});
|
||
}
|
||
createUrl(url) {
|
||
var parsedUrl = new _url.default(url);
|
||
var mimeType = _mime.default.lookup(parsedUrl.filename);
|
||
if (this.settings.archive) {
|
||
return this.settings.archive.createUrl(url, {
|
||
"base64": this.settings.replacements === "base64"
|
||
});
|
||
} else {
|
||
if (this.settings.replacements === "base64") {
|
||
return this.settings.request(url, "blob").then((blob) => {
|
||
return (0, _core.blob2base64)(blob);
|
||
}).then((blob) => {
|
||
return (0, _core.createBase64Url)(blob, mimeType);
|
||
});
|
||
} else {
|
||
return this.settings.request(url, "blob").then((blob) => {
|
||
return (0, _core.createBlobUrl)(blob, mimeType);
|
||
});
|
||
}
|
||
}
|
||
}
|
||
replacements() {
|
||
if (this.settings.replacements === "none") {
|
||
return new Promise(function(resolve) {
|
||
resolve(this.urls);
|
||
}.bind(this));
|
||
}
|
||
var replacements = this.urls.map((url) => {
|
||
var absolute = this.settings.resolver(url);
|
||
return this.createUrl(absolute).catch((err) => {
|
||
console.error(err);
|
||
return null;
|
||
});
|
||
});
|
||
return Promise.all(replacements).then((replacementUrls) => {
|
||
this.replacementUrls = replacementUrls.filter((url) => {
|
||
return typeof url === "string";
|
||
});
|
||
return replacementUrls;
|
||
});
|
||
}
|
||
replaceCss(archive, resolver) {
|
||
var replaced = [];
|
||
archive = archive || this.settings.archive;
|
||
resolver = resolver || this.settings.resolver;
|
||
this.cssUrls.forEach(function(href) {
|
||
var replacement = this.createCssFile(href, archive, resolver).then(function(replacementUrl) {
|
||
var indexInUrls = this.urls.indexOf(href);
|
||
if (indexInUrls > -1) {
|
||
this.replacementUrls[indexInUrls] = replacementUrl;
|
||
}
|
||
}.bind(this));
|
||
replaced.push(replacement);
|
||
}.bind(this));
|
||
return Promise.all(replaced);
|
||
}
|
||
createCssFile(href) {
|
||
var newUrl;
|
||
if (_pathWebpack.default.isAbsolute(href)) {
|
||
return new Promise(function(resolve) {
|
||
resolve();
|
||
});
|
||
}
|
||
var absolute = this.settings.resolver(href);
|
||
var textResponse;
|
||
if (this.settings.archive) {
|
||
textResponse = this.settings.archive.getText(absolute);
|
||
} else {
|
||
textResponse = this.settings.request(absolute, "text");
|
||
}
|
||
var relUrls = this.urls.map((assetHref) => {
|
||
var resolved = this.settings.resolver(assetHref);
|
||
var relative = new _path.default(absolute).relative(resolved);
|
||
return relative;
|
||
});
|
||
if (!textResponse) {
|
||
return new Promise(function(resolve) {
|
||
resolve();
|
||
});
|
||
}
|
||
return textResponse.then((text) => {
|
||
text = (0, _replacements.substitute)(text, relUrls, this.replacementUrls);
|
||
if (this.settings.replacements === "base64") {
|
||
newUrl = (0, _core.createBase64Url)(text, "text/css");
|
||
} else {
|
||
newUrl = (0, _core.createBlobUrl)(text, "text/css");
|
||
}
|
||
return newUrl;
|
||
}, (err) => {
|
||
return new Promise(function(resolve) {
|
||
resolve();
|
||
});
|
||
});
|
||
}
|
||
relativeTo(absolute, resolver) {
|
||
resolver = resolver || this.settings.resolver;
|
||
return this.urls.map(function(href) {
|
||
var resolved = resolver(href);
|
||
var relative = new _path.default(absolute).relative(resolved);
|
||
return relative;
|
||
}.bind(this));
|
||
}
|
||
get(path) {
|
||
var indexInUrls = this.urls.indexOf(path);
|
||
if (indexInUrls === -1) {
|
||
return;
|
||
}
|
||
if (this.replacementUrls.length) {
|
||
return new Promise(function(resolve, reject) {
|
||
resolve(this.replacementUrls[indexInUrls]);
|
||
}.bind(this));
|
||
} else {
|
||
return this.createUrl(path);
|
||
}
|
||
}
|
||
substitute(content, url) {
|
||
var relUrls;
|
||
if (url) {
|
||
relUrls = this.relativeTo(url);
|
||
} else {
|
||
relUrls = this.urls;
|
||
}
|
||
return (0, _replacements.substitute)(content, relUrls, this.replacementUrls);
|
||
}
|
||
destroy() {
|
||
this.settings = void 0;
|
||
this.manifest = void 0;
|
||
this.resources = void 0;
|
||
this.replacementUrls = void 0;
|
||
this.html = void 0;
|
||
this.assets = void 0;
|
||
this.css = void 0;
|
||
this.urls = void 0;
|
||
this.cssUrls = void 0;
|
||
}
|
||
};
|
||
var _default = Resources;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/pagelist.js
|
||
var require_pagelist = __commonJS({
|
||
"node_modules/epubjs/lib/pagelist.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _epubcfi = _interopRequireDefault(require_epubcfi());
|
||
var _core = require_core();
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var PageList = class {
|
||
constructor(xml) {
|
||
this.pages = [];
|
||
this.locations = [];
|
||
this.epubcfi = new _epubcfi.default();
|
||
this.firstPage = 0;
|
||
this.lastPage = 0;
|
||
this.totalPages = 0;
|
||
this.toc = void 0;
|
||
this.ncx = void 0;
|
||
if (xml) {
|
||
this.pageList = this.parse(xml);
|
||
}
|
||
if (this.pageList && this.pageList.length) {
|
||
this.process(this.pageList);
|
||
}
|
||
}
|
||
parse(xml) {
|
||
var html = (0, _core.qs)(xml, "html");
|
||
var ncx = (0, _core.qs)(xml, "ncx");
|
||
if (html) {
|
||
return this.parseNav(xml);
|
||
} else if (ncx) {
|
||
return this.parseNcx(xml);
|
||
}
|
||
}
|
||
parseNav(navHtml) {
|
||
var navElement = (0, _core.querySelectorByType)(navHtml, "nav", "page-list");
|
||
var navItems = navElement ? (0, _core.qsa)(navElement, "li") : [];
|
||
var length = navItems.length;
|
||
var i;
|
||
var list = [];
|
||
var item;
|
||
if (!navItems || length === 0)
|
||
return list;
|
||
for (i = 0; i < length; ++i) {
|
||
item = this.item(navItems[i]);
|
||
list.push(item);
|
||
}
|
||
return list;
|
||
}
|
||
parseNcx(navXml) {
|
||
var list = [];
|
||
var i = 0;
|
||
var item;
|
||
var pageList;
|
||
var pageTargets;
|
||
var length = 0;
|
||
pageList = (0, _core.qs)(navXml, "pageList");
|
||
if (!pageList)
|
||
return list;
|
||
pageTargets = (0, _core.qsa)(pageList, "pageTarget");
|
||
length = pageTargets.length;
|
||
if (!pageTargets || pageTargets.length === 0) {
|
||
return list;
|
||
}
|
||
for (i = 0; i < length; ++i) {
|
||
item = this.ncxItem(pageTargets[i]);
|
||
list.push(item);
|
||
}
|
||
return list;
|
||
}
|
||
ncxItem(item) {
|
||
var navLabel = (0, _core.qs)(item, "navLabel");
|
||
var navLabelText = (0, _core.qs)(navLabel, "text");
|
||
var pageText = navLabelText.textContent;
|
||
var content = (0, _core.qs)(item, "content");
|
||
var href = content.getAttribute("src");
|
||
var page = parseInt(pageText, 10);
|
||
return {
|
||
"href": href,
|
||
"page": page
|
||
};
|
||
}
|
||
item(item) {
|
||
var content = (0, _core.qs)(item, "a"), href = content.getAttribute("href") || "", text = content.textContent || "", page = parseInt(text), isCfi = href.indexOf("epubcfi"), split, packageUrl, cfi;
|
||
if (isCfi != -1) {
|
||
split = href.split("#");
|
||
packageUrl = split[0];
|
||
cfi = split.length > 1 ? split[1] : false;
|
||
return {
|
||
"cfi": cfi,
|
||
"href": href,
|
||
"packageUrl": packageUrl,
|
||
"page": page
|
||
};
|
||
} else {
|
||
return {
|
||
"href": href,
|
||
"page": page
|
||
};
|
||
}
|
||
}
|
||
process(pageList) {
|
||
pageList.forEach(function(item) {
|
||
this.pages.push(item.page);
|
||
if (item.cfi) {
|
||
this.locations.push(item.cfi);
|
||
}
|
||
}, this);
|
||
this.firstPage = parseInt(this.pages[0]);
|
||
this.lastPage = parseInt(this.pages[this.pages.length - 1]);
|
||
this.totalPages = this.lastPage - this.firstPage;
|
||
}
|
||
pageFromCfi(cfi) {
|
||
var pg = -1;
|
||
if (this.locations.length === 0) {
|
||
return -1;
|
||
}
|
||
var index = (0, _core.indexOfSorted)(cfi, this.locations, this.epubcfi.compare);
|
||
if (index != -1) {
|
||
pg = this.pages[index];
|
||
} else {
|
||
index = (0, _core.locationOf)(cfi, this.locations, this.epubcfi.compare);
|
||
pg = index - 1 >= 0 ? this.pages[index - 1] : this.pages[0];
|
||
if (pg !== void 0) {
|
||
} else {
|
||
pg = -1;
|
||
}
|
||
}
|
||
return pg;
|
||
}
|
||
cfiFromPage(pg) {
|
||
var cfi = -1;
|
||
if (typeof pg != "number") {
|
||
pg = parseInt(pg);
|
||
}
|
||
var index = this.pages.indexOf(pg);
|
||
if (index != -1) {
|
||
cfi = this.locations[index];
|
||
}
|
||
return cfi;
|
||
}
|
||
pageFromPercentage(percent) {
|
||
var pg = Math.round(this.totalPages * percent);
|
||
return pg;
|
||
}
|
||
percentageFromPage(pg) {
|
||
var percentage = (pg - this.firstPage) / this.totalPages;
|
||
return Math.round(percentage * 1e3) / 1e3;
|
||
}
|
||
percentageFromCfi(cfi) {
|
||
var pg = this.pageFromCfi(cfi);
|
||
var percentage = this.percentageFromPage(pg);
|
||
return percentage;
|
||
}
|
||
destroy() {
|
||
this.pages = void 0;
|
||
this.locations = void 0;
|
||
this.epubcfi = void 0;
|
||
this.pageList = void 0;
|
||
this.toc = void 0;
|
||
this.ncx = void 0;
|
||
}
|
||
};
|
||
var _default = PageList;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/layout.js
|
||
var require_layout = __commonJS({
|
||
"node_modules/epubjs/lib/layout.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _core = require_core();
|
||
var _constants = require_constants();
|
||
var _eventEmitter = _interopRequireDefault(require_event_emitter());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Layout = class {
|
||
constructor(settings) {
|
||
this.settings = settings;
|
||
this.name = settings.layout || "reflowable";
|
||
this._spread = settings.spread === "none" ? false : true;
|
||
this._minSpreadWidth = settings.minSpreadWidth || 800;
|
||
this._evenSpreads = settings.evenSpreads || false;
|
||
if (settings.flow === "scrolled" || settings.flow === "scrolled-continuous" || settings.flow === "scrolled-doc") {
|
||
this._flow = "scrolled";
|
||
} else {
|
||
this._flow = "paginated";
|
||
}
|
||
this.width = 0;
|
||
this.height = 0;
|
||
this.spreadWidth = 0;
|
||
this.delta = 0;
|
||
this.columnWidth = 0;
|
||
this.gap = 0;
|
||
this.divisor = 1;
|
||
this.props = {
|
||
name: this.name,
|
||
spread: this._spread,
|
||
flow: this._flow,
|
||
width: 0,
|
||
height: 0,
|
||
spreadWidth: 0,
|
||
delta: 0,
|
||
columnWidth: 0,
|
||
gap: 0,
|
||
divisor: 1
|
||
};
|
||
}
|
||
flow(flow) {
|
||
if (typeof flow != "undefined") {
|
||
if (flow === "scrolled" || flow === "scrolled-continuous" || flow === "scrolled-doc") {
|
||
this._flow = "scrolled";
|
||
} else {
|
||
this._flow = "paginated";
|
||
}
|
||
this.update({
|
||
flow: this._flow
|
||
});
|
||
}
|
||
return this._flow;
|
||
}
|
||
spread(spread, min) {
|
||
if (spread) {
|
||
this._spread = spread === "none" ? false : true;
|
||
this.update({
|
||
spread: this._spread
|
||
});
|
||
}
|
||
if (min >= 0) {
|
||
this._minSpreadWidth = min;
|
||
}
|
||
return this._spread;
|
||
}
|
||
calculate(_width, _height, _gap) {
|
||
var divisor = 1;
|
||
var gap = _gap || 0;
|
||
var width = _width;
|
||
var height = _height;
|
||
var section = Math.floor(width / 12);
|
||
var columnWidth;
|
||
var spreadWidth;
|
||
var pageWidth;
|
||
var delta;
|
||
if (this._spread && width >= this._minSpreadWidth) {
|
||
divisor = 2;
|
||
} else {
|
||
divisor = 1;
|
||
}
|
||
if (this.name === "reflowable" && this._flow === "paginated" && !(_gap >= 0)) {
|
||
gap = section % 2 === 0 ? section : section - 1;
|
||
}
|
||
if (this.name === "pre-paginated") {
|
||
gap = 0;
|
||
}
|
||
if (divisor > 1) {
|
||
columnWidth = width / divisor - gap;
|
||
pageWidth = columnWidth + gap;
|
||
} else {
|
||
columnWidth = width;
|
||
pageWidth = width;
|
||
}
|
||
if (this.name === "pre-paginated" && divisor > 1) {
|
||
width = columnWidth;
|
||
}
|
||
spreadWidth = columnWidth * divisor + gap;
|
||
delta = width;
|
||
this.width = width;
|
||
this.height = height;
|
||
this.spreadWidth = spreadWidth;
|
||
this.pageWidth = pageWidth;
|
||
this.delta = delta;
|
||
this.columnWidth = columnWidth;
|
||
this.gap = gap;
|
||
this.divisor = divisor;
|
||
this.update({
|
||
width,
|
||
height,
|
||
spreadWidth,
|
||
pageWidth,
|
||
delta,
|
||
columnWidth,
|
||
gap,
|
||
divisor
|
||
});
|
||
}
|
||
format(contents, section, axis) {
|
||
var formating;
|
||
if (this.name === "pre-paginated") {
|
||
formating = contents.fit(this.columnWidth, this.height, section);
|
||
} else if (this._flow === "paginated") {
|
||
formating = contents.columns(this.width, this.height, this.columnWidth, this.gap, this.settings.direction);
|
||
} else if (axis && axis === "horizontal") {
|
||
formating = contents.size(null, this.height);
|
||
} else {
|
||
formating = contents.size(this.width, null);
|
||
}
|
||
return formating;
|
||
}
|
||
count(totalLength, pageLength) {
|
||
let spreads, pages;
|
||
if (this.name === "pre-paginated") {
|
||
spreads = 1;
|
||
pages = 1;
|
||
} else if (this._flow === "paginated") {
|
||
pageLength = pageLength || this.delta;
|
||
spreads = Math.ceil(totalLength / pageLength);
|
||
pages = spreads * this.divisor;
|
||
} else {
|
||
pageLength = pageLength || this.height;
|
||
spreads = Math.ceil(totalLength / pageLength);
|
||
pages = spreads;
|
||
}
|
||
return {
|
||
spreads,
|
||
pages
|
||
};
|
||
}
|
||
update(props) {
|
||
Object.keys(props).forEach((propName) => {
|
||
if (this.props[propName] === props[propName]) {
|
||
delete props[propName];
|
||
}
|
||
});
|
||
if (Object.keys(props).length > 0) {
|
||
let newProps = (0, _core.extend)(this.props, props);
|
||
this.emit(_constants.EVENTS.LAYOUT.UPDATED, newProps, props);
|
||
}
|
||
}
|
||
};
|
||
(0, _eventEmitter.default)(Layout.prototype);
|
||
var _default = Layout;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/themes.js
|
||
var require_themes = __commonJS({
|
||
"node_modules/epubjs/lib/themes.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _url = _interopRequireDefault(require_url());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Themes = class {
|
||
constructor(rendition) {
|
||
this.rendition = rendition;
|
||
this._themes = {
|
||
"default": {
|
||
"rules": {},
|
||
"url": "",
|
||
"serialized": ""
|
||
}
|
||
};
|
||
this._overrides = {};
|
||
this._current = "default";
|
||
this._injected = [];
|
||
this.rendition.hooks.content.register(this.inject.bind(this));
|
||
this.rendition.hooks.content.register(this.overrides.bind(this));
|
||
}
|
||
register() {
|
||
if (arguments.length === 0) {
|
||
return;
|
||
}
|
||
if (arguments.length === 1 && typeof arguments[0] === "object") {
|
||
return this.registerThemes(arguments[0]);
|
||
}
|
||
if (arguments.length === 1 && typeof arguments[0] === "string") {
|
||
return this.default(arguments[0]);
|
||
}
|
||
if (arguments.length === 2 && typeof arguments[1] === "string") {
|
||
return this.registerUrl(arguments[0], arguments[1]);
|
||
}
|
||
if (arguments.length === 2 && typeof arguments[1] === "object") {
|
||
return this.registerRules(arguments[0], arguments[1]);
|
||
}
|
||
}
|
||
default(theme) {
|
||
if (!theme) {
|
||
return;
|
||
}
|
||
if (typeof theme === "string") {
|
||
return this.registerUrl("default", theme);
|
||
}
|
||
if (typeof theme === "object") {
|
||
return this.registerRules("default", theme);
|
||
}
|
||
}
|
||
registerThemes(themes) {
|
||
for (var theme in themes) {
|
||
if (themes.hasOwnProperty(theme)) {
|
||
if (typeof themes[theme] === "string") {
|
||
this.registerUrl(theme, themes[theme]);
|
||
} else {
|
||
this.registerRules(theme, themes[theme]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
registerCss(name, css) {
|
||
this._themes[name] = {
|
||
"serialized": css
|
||
};
|
||
if (this._injected[name] || name == "default") {
|
||
this.update(name);
|
||
}
|
||
}
|
||
registerUrl(name, input) {
|
||
var url = new _url.default(input);
|
||
this._themes[name] = {
|
||
"url": url.toString()
|
||
};
|
||
if (this._injected[name] || name == "default") {
|
||
this.update(name);
|
||
}
|
||
}
|
||
registerRules(name, rules) {
|
||
this._themes[name] = {
|
||
"rules": rules
|
||
};
|
||
if (this._injected[name] || name == "default") {
|
||
this.update(name);
|
||
}
|
||
}
|
||
select(name) {
|
||
var prev = this._current;
|
||
var contents;
|
||
this._current = name;
|
||
this.update(name);
|
||
contents = this.rendition.getContents();
|
||
contents.forEach((content) => {
|
||
content.removeClass(prev);
|
||
content.addClass(name);
|
||
});
|
||
}
|
||
update(name) {
|
||
var contents = this.rendition.getContents();
|
||
contents.forEach((content) => {
|
||
this.add(name, content);
|
||
});
|
||
}
|
||
inject(contents) {
|
||
var links = [];
|
||
var themes = this._themes;
|
||
var theme;
|
||
for (var name in themes) {
|
||
if (themes.hasOwnProperty(name) && (name === this._current || name === "default")) {
|
||
theme = themes[name];
|
||
if (theme.rules && Object.keys(theme.rules).length > 0 || theme.url && links.indexOf(theme.url) === -1) {
|
||
this.add(name, contents);
|
||
}
|
||
this._injected.push(name);
|
||
}
|
||
}
|
||
if (this._current != "default") {
|
||
contents.addClass(this._current);
|
||
}
|
||
}
|
||
add(name, contents) {
|
||
var theme = this._themes[name];
|
||
if (!theme || !contents) {
|
||
return;
|
||
}
|
||
if (theme.url) {
|
||
contents.addStylesheet(theme.url);
|
||
} else if (theme.serialized) {
|
||
contents.addStylesheetCss(theme.serialized, name);
|
||
theme.injected = true;
|
||
} else if (theme.rules) {
|
||
contents.addStylesheetRules(theme.rules, name);
|
||
theme.injected = true;
|
||
}
|
||
}
|
||
override(name, value, priority) {
|
||
var contents = this.rendition.getContents();
|
||
this._overrides[name] = {
|
||
value,
|
||
priority: priority === true
|
||
};
|
||
contents.forEach((content) => {
|
||
content.css(name, this._overrides[name].value, this._overrides[name].priority);
|
||
});
|
||
}
|
||
removeOverride(name) {
|
||
var contents = this.rendition.getContents();
|
||
delete this._overrides[name];
|
||
contents.forEach((content) => {
|
||
content.css(name);
|
||
});
|
||
}
|
||
overrides(contents) {
|
||
var overrides = this._overrides;
|
||
for (var rule in overrides) {
|
||
if (overrides.hasOwnProperty(rule)) {
|
||
contents.css(rule, overrides[rule].value, overrides[rule].priority);
|
||
}
|
||
}
|
||
}
|
||
fontSize(size) {
|
||
this.override("font-size", size);
|
||
}
|
||
font(f) {
|
||
this.override("font-family", f, true);
|
||
}
|
||
destroy() {
|
||
this.rendition = void 0;
|
||
this._themes = void 0;
|
||
this._overrides = void 0;
|
||
this._current = void 0;
|
||
this._injected = void 0;
|
||
}
|
||
};
|
||
var _default = Themes;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/mapping.js
|
||
var require_mapping = __commonJS({
|
||
"node_modules/epubjs/lib/mapping.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _epubcfi = _interopRequireDefault(require_epubcfi());
|
||
var _core = require_core();
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Mapping = class {
|
||
constructor(layout, direction, axis, dev = false) {
|
||
this.layout = layout;
|
||
this.horizontal = axis === "horizontal" ? true : false;
|
||
this.direction = direction || "ltr";
|
||
this._dev = dev;
|
||
}
|
||
section(view) {
|
||
var ranges = this.findRanges(view);
|
||
var map = this.rangeListToCfiList(view.section.cfiBase, ranges);
|
||
return map;
|
||
}
|
||
page(contents, cfiBase, start, end) {
|
||
var root = contents && contents.document ? contents.document.body : false;
|
||
var result;
|
||
if (!root) {
|
||
return;
|
||
}
|
||
result = this.rangePairToCfiPair(cfiBase, {
|
||
start: this.findStart(root, start, end),
|
||
end: this.findEnd(root, start, end)
|
||
});
|
||
if (this._dev === true) {
|
||
let doc = contents.document;
|
||
let startRange = new _epubcfi.default(result.start).toRange(doc);
|
||
let endRange = new _epubcfi.default(result.end).toRange(doc);
|
||
let selection = doc.defaultView.getSelection();
|
||
let r = doc.createRange();
|
||
selection.removeAllRanges();
|
||
r.setStart(startRange.startContainer, startRange.startOffset);
|
||
r.setEnd(endRange.endContainer, endRange.endOffset);
|
||
selection.addRange(r);
|
||
}
|
||
return result;
|
||
}
|
||
walk(root, func) {
|
||
if (root && root.nodeType === Node.TEXT_NODE) {
|
||
return;
|
||
}
|
||
var filter = {
|
||
acceptNode: function(node2) {
|
||
if (node2.data.trim().length > 0) {
|
||
return NodeFilter.FILTER_ACCEPT;
|
||
} else {
|
||
return NodeFilter.FILTER_REJECT;
|
||
}
|
||
}
|
||
};
|
||
var safeFilter = filter.acceptNode;
|
||
safeFilter.acceptNode = filter.acceptNode;
|
||
var treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, safeFilter, false);
|
||
var node;
|
||
var result;
|
||
while (node = treeWalker.nextNode()) {
|
||
result = func(node);
|
||
if (result)
|
||
break;
|
||
}
|
||
return result;
|
||
}
|
||
findRanges(view) {
|
||
var columns = [];
|
||
var scrollWidth = view.contents.scrollWidth();
|
||
var spreads = Math.ceil(scrollWidth / this.layout.spreadWidth);
|
||
var count = spreads * this.layout.divisor;
|
||
var columnWidth = this.layout.columnWidth;
|
||
var gap = this.layout.gap;
|
||
var start, end;
|
||
for (var i = 0; i < count.pages; i++) {
|
||
start = (columnWidth + gap) * i;
|
||
end = columnWidth * (i + 1) + gap * i;
|
||
columns.push({
|
||
start: this.findStart(view.document.body, start, end),
|
||
end: this.findEnd(view.document.body, start, end)
|
||
});
|
||
}
|
||
return columns;
|
||
}
|
||
findStart(root, start, end) {
|
||
var stack = [root];
|
||
var $el;
|
||
var found;
|
||
var $prev = root;
|
||
while (stack.length) {
|
||
$el = stack.shift();
|
||
found = this.walk($el, (node) => {
|
||
var left, right, top, bottom;
|
||
var elPos;
|
||
var elRange;
|
||
elPos = (0, _core.nodeBounds)(node);
|
||
if (this.horizontal && this.direction === "ltr") {
|
||
left = this.horizontal ? elPos.left : elPos.top;
|
||
right = this.horizontal ? elPos.right : elPos.bottom;
|
||
if (left >= start && left <= end) {
|
||
return node;
|
||
} else if (right > start) {
|
||
return node;
|
||
} else {
|
||
$prev = node;
|
||
stack.push(node);
|
||
}
|
||
} else if (this.horizontal && this.direction === "rtl") {
|
||
left = elPos.left;
|
||
right = elPos.right;
|
||
if (right <= end && right >= start) {
|
||
return node;
|
||
} else if (left < end) {
|
||
return node;
|
||
} else {
|
||
$prev = node;
|
||
stack.push(node);
|
||
}
|
||
} else {
|
||
top = elPos.top;
|
||
bottom = elPos.bottom;
|
||
if (top >= start && top <= end) {
|
||
return node;
|
||
} else if (bottom > start) {
|
||
return node;
|
||
} else {
|
||
$prev = node;
|
||
stack.push(node);
|
||
}
|
||
}
|
||
});
|
||
if (found) {
|
||
return this.findTextStartRange(found, start, end);
|
||
}
|
||
}
|
||
return this.findTextStartRange($prev, start, end);
|
||
}
|
||
findEnd(root, start, end) {
|
||
var stack = [root];
|
||
var $el;
|
||
var $prev = root;
|
||
var found;
|
||
while (stack.length) {
|
||
$el = stack.shift();
|
||
found = this.walk($el, (node) => {
|
||
var left, right, top, bottom;
|
||
var elPos;
|
||
var elRange;
|
||
elPos = (0, _core.nodeBounds)(node);
|
||
if (this.horizontal && this.direction === "ltr") {
|
||
left = Math.round(elPos.left);
|
||
right = Math.round(elPos.right);
|
||
if (left > end && $prev) {
|
||
return $prev;
|
||
} else if (right > end) {
|
||
return node;
|
||
} else {
|
||
$prev = node;
|
||
stack.push(node);
|
||
}
|
||
} else if (this.horizontal && this.direction === "rtl") {
|
||
left = Math.round(this.horizontal ? elPos.left : elPos.top);
|
||
right = Math.round(this.horizontal ? elPos.right : elPos.bottom);
|
||
if (right < start && $prev) {
|
||
return $prev;
|
||
} else if (left < start) {
|
||
return node;
|
||
} else {
|
||
$prev = node;
|
||
stack.push(node);
|
||
}
|
||
} else {
|
||
top = Math.round(elPos.top);
|
||
bottom = Math.round(elPos.bottom);
|
||
if (top > end && $prev) {
|
||
return $prev;
|
||
} else if (bottom > end) {
|
||
return node;
|
||
} else {
|
||
$prev = node;
|
||
stack.push(node);
|
||
}
|
||
}
|
||
});
|
||
if (found) {
|
||
return this.findTextEndRange(found, start, end);
|
||
}
|
||
}
|
||
return this.findTextEndRange($prev, start, end);
|
||
}
|
||
findTextStartRange(node, start, end) {
|
||
var ranges = this.splitTextNodeIntoRanges(node);
|
||
var range;
|
||
var pos;
|
||
var left, top, right;
|
||
for (var i = 0; i < ranges.length; i++) {
|
||
range = ranges[i];
|
||
pos = range.getBoundingClientRect();
|
||
if (this.horizontal && this.direction === "ltr") {
|
||
left = pos.left;
|
||
if (left >= start) {
|
||
return range;
|
||
}
|
||
} else if (this.horizontal && this.direction === "rtl") {
|
||
right = pos.right;
|
||
if (right <= end) {
|
||
return range;
|
||
}
|
||
} else {
|
||
top = pos.top;
|
||
if (top >= start) {
|
||
return range;
|
||
}
|
||
}
|
||
}
|
||
return ranges[0];
|
||
}
|
||
findTextEndRange(node, start, end) {
|
||
var ranges = this.splitTextNodeIntoRanges(node);
|
||
var prev;
|
||
var range;
|
||
var pos;
|
||
var left, right, top, bottom;
|
||
for (var i = 0; i < ranges.length; i++) {
|
||
range = ranges[i];
|
||
pos = range.getBoundingClientRect();
|
||
if (this.horizontal && this.direction === "ltr") {
|
||
left = pos.left;
|
||
right = pos.right;
|
||
if (left > end && prev) {
|
||
return prev;
|
||
} else if (right > end) {
|
||
return range;
|
||
}
|
||
} else if (this.horizontal && this.direction === "rtl") {
|
||
left = pos.left;
|
||
right = pos.right;
|
||
if (right < start && prev) {
|
||
return prev;
|
||
} else if (left < start) {
|
||
return range;
|
||
}
|
||
} else {
|
||
top = pos.top;
|
||
bottom = pos.bottom;
|
||
if (top > end && prev) {
|
||
return prev;
|
||
} else if (bottom > end) {
|
||
return range;
|
||
}
|
||
}
|
||
prev = range;
|
||
}
|
||
return ranges[ranges.length - 1];
|
||
}
|
||
splitTextNodeIntoRanges(node, _splitter) {
|
||
var ranges = [];
|
||
var textContent = node.textContent || "";
|
||
var text = textContent.trim();
|
||
var range;
|
||
var doc = node.ownerDocument;
|
||
var splitter = _splitter || " ";
|
||
var pos = text.indexOf(splitter);
|
||
if (pos === -1 || node.nodeType != Node.TEXT_NODE) {
|
||
range = doc.createRange();
|
||
range.selectNodeContents(node);
|
||
return [range];
|
||
}
|
||
range = doc.createRange();
|
||
range.setStart(node, 0);
|
||
range.setEnd(node, pos);
|
||
ranges.push(range);
|
||
range = false;
|
||
while (pos != -1) {
|
||
pos = text.indexOf(splitter, pos + 1);
|
||
if (pos > 0) {
|
||
if (range) {
|
||
range.setEnd(node, pos);
|
||
ranges.push(range);
|
||
}
|
||
range = doc.createRange();
|
||
range.setStart(node, pos + 1);
|
||
}
|
||
}
|
||
if (range) {
|
||
range.setEnd(node, text.length);
|
||
ranges.push(range);
|
||
}
|
||
return ranges;
|
||
}
|
||
rangePairToCfiPair(cfiBase, rangePair) {
|
||
var startRange = rangePair.start;
|
||
var endRange = rangePair.end;
|
||
startRange.collapse(true);
|
||
endRange.collapse(false);
|
||
let startCfi = new _epubcfi.default(startRange, cfiBase).toString();
|
||
let endCfi = new _epubcfi.default(endRange, cfiBase).toString();
|
||
return {
|
||
start: startCfi,
|
||
end: endCfi
|
||
};
|
||
}
|
||
rangeListToCfiList(cfiBase, columns) {
|
||
var map = [];
|
||
var cifPair;
|
||
for (var i = 0; i < columns.length; i++) {
|
||
cifPair = this.rangePairToCfiPair(cfiBase, columns[i]);
|
||
map.push(cifPair);
|
||
}
|
||
return map;
|
||
}
|
||
axis(axis) {
|
||
if (axis) {
|
||
this.horizontal = axis === "horizontal" ? true : false;
|
||
}
|
||
return this.horizontal;
|
||
}
|
||
};
|
||
var _default = Mapping;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/contents.js
|
||
var require_contents = __commonJS({
|
||
"node_modules/epubjs/lib/contents.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _eventEmitter = _interopRequireDefault(require_event_emitter());
|
||
var _core = require_core();
|
||
var _epubcfi = _interopRequireDefault(require_epubcfi());
|
||
var _mapping = _interopRequireDefault(require_mapping());
|
||
var _replacements = require_replacements();
|
||
var _constants = require_constants();
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var hasNavigator = typeof navigator !== "undefined";
|
||
var isChrome = hasNavigator && /Chrome/.test(navigator.userAgent);
|
||
var isWebkit = hasNavigator && !isChrome && /AppleWebKit/.test(navigator.userAgent);
|
||
var ELEMENT_NODE = 1;
|
||
var Contents = class {
|
||
constructor(doc, content, cfiBase, sectionIndex) {
|
||
this.epubcfi = new _epubcfi.default();
|
||
this.document = doc;
|
||
this.documentElement = this.document.documentElement;
|
||
this.content = content || this.document.body;
|
||
this.window = this.document.defaultView;
|
||
this._size = {
|
||
width: 0,
|
||
height: 0
|
||
};
|
||
this.sectionIndex = sectionIndex || 0;
|
||
this.cfiBase = cfiBase || "";
|
||
this.epubReadingSystem("epub.js", _constants.EPUBJS_VERSION);
|
||
this.called = 0;
|
||
this.active = true;
|
||
this.listeners();
|
||
}
|
||
static get listenedEvents() {
|
||
return _constants.DOM_EVENTS;
|
||
}
|
||
width(w) {
|
||
var frame = this.content;
|
||
if (w && (0, _core.isNumber)(w)) {
|
||
w = w + "px";
|
||
}
|
||
if (w) {
|
||
frame.style.width = w;
|
||
}
|
||
return parseInt(this.window.getComputedStyle(frame)["width"]);
|
||
}
|
||
height(h) {
|
||
var frame = this.content;
|
||
if (h && (0, _core.isNumber)(h)) {
|
||
h = h + "px";
|
||
}
|
||
if (h) {
|
||
frame.style.height = h;
|
||
}
|
||
return parseInt(this.window.getComputedStyle(frame)["height"]);
|
||
}
|
||
contentWidth(w) {
|
||
var content = this.content || this.document.body;
|
||
if (w && (0, _core.isNumber)(w)) {
|
||
w = w + "px";
|
||
}
|
||
if (w) {
|
||
content.style.width = w;
|
||
}
|
||
return parseInt(this.window.getComputedStyle(content)["width"]);
|
||
}
|
||
contentHeight(h) {
|
||
var content = this.content || this.document.body;
|
||
if (h && (0, _core.isNumber)(h)) {
|
||
h = h + "px";
|
||
}
|
||
if (h) {
|
||
content.style.height = h;
|
||
}
|
||
return parseInt(this.window.getComputedStyle(content)["height"]);
|
||
}
|
||
textWidth() {
|
||
let rect;
|
||
let width;
|
||
let range = this.document.createRange();
|
||
let content = this.content || this.document.body;
|
||
let border = (0, _core.borders)(content);
|
||
range.selectNodeContents(content);
|
||
rect = range.getBoundingClientRect();
|
||
width = rect.width;
|
||
if (border && border.width) {
|
||
width += border.width;
|
||
}
|
||
return Math.round(width);
|
||
}
|
||
textHeight() {
|
||
let rect;
|
||
let height;
|
||
let range = this.document.createRange();
|
||
let content = this.content || this.document.body;
|
||
range.selectNodeContents(content);
|
||
rect = range.getBoundingClientRect();
|
||
height = rect.bottom;
|
||
return Math.round(height);
|
||
}
|
||
scrollWidth() {
|
||
var width = this.documentElement.scrollWidth;
|
||
return width;
|
||
}
|
||
scrollHeight() {
|
||
var height = this.documentElement.scrollHeight;
|
||
return height;
|
||
}
|
||
overflow(overflow) {
|
||
if (overflow) {
|
||
this.documentElement.style.overflow = overflow;
|
||
}
|
||
return this.window.getComputedStyle(this.documentElement)["overflow"];
|
||
}
|
||
overflowX(overflow) {
|
||
if (overflow) {
|
||
this.documentElement.style.overflowX = overflow;
|
||
}
|
||
return this.window.getComputedStyle(this.documentElement)["overflowX"];
|
||
}
|
||
overflowY(overflow) {
|
||
if (overflow) {
|
||
this.documentElement.style.overflowY = overflow;
|
||
}
|
||
return this.window.getComputedStyle(this.documentElement)["overflowY"];
|
||
}
|
||
css(property, value, priority) {
|
||
var content = this.content || this.document.body;
|
||
if (value) {
|
||
content.style.setProperty(property, value, priority ? "important" : "");
|
||
} else {
|
||
content.style.removeProperty(property);
|
||
}
|
||
return this.window.getComputedStyle(content)[property];
|
||
}
|
||
viewport(options) {
|
||
var _width, _height, _scale, _minimum, _maximum, _scalable;
|
||
var $viewport = this.document.querySelector("meta[name='viewport']");
|
||
var parsed = {
|
||
"width": void 0,
|
||
"height": void 0,
|
||
"scale": void 0,
|
||
"minimum": void 0,
|
||
"maximum": void 0,
|
||
"scalable": void 0
|
||
};
|
||
var newContent = [];
|
||
var settings = {};
|
||
if ($viewport && $viewport.hasAttribute("content")) {
|
||
let content = $viewport.getAttribute("content");
|
||
let _width2 = content.match(/width\s*=\s*([^,]*)/);
|
||
let _height2 = content.match(/height\s*=\s*([^,]*)/);
|
||
let _scale2 = content.match(/initial-scale\s*=\s*([^,]*)/);
|
||
let _minimum2 = content.match(/minimum-scale\s*=\s*([^,]*)/);
|
||
let _maximum2 = content.match(/maximum-scale\s*=\s*([^,]*)/);
|
||
let _scalable2 = content.match(/user-scalable\s*=\s*([^,]*)/);
|
||
if (_width2 && _width2.length && typeof _width2[1] !== "undefined") {
|
||
parsed.width = _width2[1];
|
||
}
|
||
if (_height2 && _height2.length && typeof _height2[1] !== "undefined") {
|
||
parsed.height = _height2[1];
|
||
}
|
||
if (_scale2 && _scale2.length && typeof _scale2[1] !== "undefined") {
|
||
parsed.scale = _scale2[1];
|
||
}
|
||
if (_minimum2 && _minimum2.length && typeof _minimum2[1] !== "undefined") {
|
||
parsed.minimum = _minimum2[1];
|
||
}
|
||
if (_maximum2 && _maximum2.length && typeof _maximum2[1] !== "undefined") {
|
||
parsed.maximum = _maximum2[1];
|
||
}
|
||
if (_scalable2 && _scalable2.length && typeof _scalable2[1] !== "undefined") {
|
||
parsed.scalable = _scalable2[1];
|
||
}
|
||
}
|
||
settings = (0, _core.defaults)(options || {}, parsed);
|
||
if (options) {
|
||
if (settings.width) {
|
||
newContent.push("width=" + settings.width);
|
||
}
|
||
if (settings.height) {
|
||
newContent.push("height=" + settings.height);
|
||
}
|
||
if (settings.scale) {
|
||
newContent.push("initial-scale=" + settings.scale);
|
||
}
|
||
if (settings.scalable === "no") {
|
||
newContent.push("minimum-scale=" + settings.scale);
|
||
newContent.push("maximum-scale=" + settings.scale);
|
||
newContent.push("user-scalable=" + settings.scalable);
|
||
} else {
|
||
if (settings.scalable) {
|
||
newContent.push("user-scalable=" + settings.scalable);
|
||
}
|
||
if (settings.minimum) {
|
||
newContent.push("minimum-scale=" + settings.minimum);
|
||
}
|
||
if (settings.maximum) {
|
||
newContent.push("minimum-scale=" + settings.maximum);
|
||
}
|
||
}
|
||
if (!$viewport) {
|
||
$viewport = this.document.createElement("meta");
|
||
$viewport.setAttribute("name", "viewport");
|
||
this.document.querySelector("head").appendChild($viewport);
|
||
}
|
||
$viewport.setAttribute("content", newContent.join(", "));
|
||
this.window.scrollTo(0, 0);
|
||
}
|
||
return settings;
|
||
}
|
||
expand() {
|
||
this.emit(_constants.EVENTS.CONTENTS.EXPAND);
|
||
}
|
||
listeners() {
|
||
this.imageLoadListeners();
|
||
this.mediaQueryListeners();
|
||
this.addEventListeners();
|
||
this.addSelectionListeners();
|
||
if (typeof ResizeObserver === "undefined") {
|
||
this.resizeListeners();
|
||
this.visibilityListeners();
|
||
} else {
|
||
this.resizeObservers();
|
||
}
|
||
this.linksHandler();
|
||
}
|
||
removeListeners() {
|
||
this.removeEventListeners();
|
||
this.removeSelectionListeners();
|
||
if (this.observer) {
|
||
this.observer.disconnect();
|
||
}
|
||
clearTimeout(this.expanding);
|
||
}
|
||
resizeCheck() {
|
||
let width = this.textWidth();
|
||
let height = this.textHeight();
|
||
if (width != this._size.width || height != this._size.height) {
|
||
this._size = {
|
||
width,
|
||
height
|
||
};
|
||
this.onResize && this.onResize(this._size);
|
||
this.emit(_constants.EVENTS.CONTENTS.RESIZE, this._size);
|
||
}
|
||
}
|
||
resizeListeners() {
|
||
var width, height;
|
||
clearTimeout(this.expanding);
|
||
requestAnimationFrame(this.resizeCheck.bind(this));
|
||
this.expanding = setTimeout(this.resizeListeners.bind(this), 350);
|
||
}
|
||
visibilityListeners() {
|
||
document.addEventListener("visibilitychange", () => {
|
||
if (document.visibilityState === "visible" && this.active === false) {
|
||
this.active = true;
|
||
this.resizeListeners();
|
||
} else {
|
||
this.active = false;
|
||
clearTimeout(this.expanding);
|
||
}
|
||
});
|
||
}
|
||
transitionListeners() {
|
||
let body = this.content;
|
||
body.style["transitionProperty"] = "font, font-size, font-size-adjust, font-stretch, font-variation-settings, font-weight, width, height";
|
||
body.style["transitionDuration"] = "0.001ms";
|
||
body.style["transitionTimingFunction"] = "linear";
|
||
body.style["transitionDelay"] = "0";
|
||
this._resizeCheck = this.resizeCheck.bind(this);
|
||
this.document.addEventListener("transitionend", this._resizeCheck);
|
||
}
|
||
mediaQueryListeners() {
|
||
var sheets = this.document.styleSheets;
|
||
var mediaChangeHandler = function(m) {
|
||
if (m.matches && !this._expanding) {
|
||
setTimeout(this.expand.bind(this), 1);
|
||
}
|
||
}.bind(this);
|
||
for (var i = 0; i < sheets.length; i += 1) {
|
||
var rules;
|
||
try {
|
||
rules = sheets[i].cssRules;
|
||
} catch (e) {
|
||
return;
|
||
}
|
||
if (!rules)
|
||
return;
|
||
for (var j = 0; j < rules.length; j += 1) {
|
||
if (rules[j].media) {
|
||
var mql = this.window.matchMedia(rules[j].media.mediaText);
|
||
mql.addListener(mediaChangeHandler);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
resizeObservers() {
|
||
this.observer = new ResizeObserver((e) => {
|
||
requestAnimationFrame(this.resizeCheck.bind(this));
|
||
});
|
||
this.observer.observe(this.document.documentElement);
|
||
}
|
||
mutationObservers() {
|
||
this.observer = new MutationObserver((mutations) => {
|
||
this.resizeCheck();
|
||
});
|
||
let config = {
|
||
attributes: true,
|
||
childList: true,
|
||
characterData: true,
|
||
subtree: true
|
||
};
|
||
this.observer.observe(this.document, config);
|
||
}
|
||
imageLoadListeners() {
|
||
var images = this.document.querySelectorAll("img");
|
||
var img;
|
||
for (var i = 0; i < images.length; i++) {
|
||
img = images[i];
|
||
if (typeof img.naturalWidth !== "undefined" && img.naturalWidth === 0) {
|
||
img.onload = this.expand.bind(this);
|
||
}
|
||
}
|
||
}
|
||
fontLoadListeners() {
|
||
if (!this.document || !this.document.fonts) {
|
||
return;
|
||
}
|
||
this.document.fonts.ready.then(function() {
|
||
this.resizeCheck();
|
||
}.bind(this));
|
||
}
|
||
root() {
|
||
if (!this.document)
|
||
return null;
|
||
return this.document.documentElement;
|
||
}
|
||
locationOf(target, ignoreClass) {
|
||
var position;
|
||
var targetPos = {
|
||
"left": 0,
|
||
"top": 0
|
||
};
|
||
if (!this.document)
|
||
return targetPos;
|
||
if (this.epubcfi.isCfiString(target)) {
|
||
let range = new _epubcfi.default(target).toRange(this.document, ignoreClass);
|
||
if (range) {
|
||
try {
|
||
if (!range.endContainer || range.startContainer == range.endContainer && range.startOffset == range.endOffset) {
|
||
let pos = range.startContainer.textContent.indexOf(" ", range.startOffset);
|
||
if (pos == -1) {
|
||
pos = range.startContainer.textContent.length;
|
||
}
|
||
range.setEnd(range.startContainer, pos);
|
||
}
|
||
} catch (e) {
|
||
console.error("setting end offset to start container length failed", e);
|
||
}
|
||
if (range.startContainer.nodeType === Node.ELEMENT_NODE) {
|
||
position = range.startContainer.getBoundingClientRect();
|
||
targetPos.left = position.left;
|
||
targetPos.top = position.top;
|
||
} else {
|
||
if (isWebkit) {
|
||
let container = range.startContainer;
|
||
let newRange = new Range();
|
||
try {
|
||
if (container.nodeType === ELEMENT_NODE) {
|
||
position = container.getBoundingClientRect();
|
||
} else if (range.startOffset + 2 < container.length) {
|
||
newRange.setStart(container, range.startOffset);
|
||
newRange.setEnd(container, range.startOffset + 2);
|
||
position = newRange.getBoundingClientRect();
|
||
} else if (range.startOffset - 2 > 0) {
|
||
newRange.setStart(container, range.startOffset - 2);
|
||
newRange.setEnd(container, range.startOffset);
|
||
position = newRange.getBoundingClientRect();
|
||
} else {
|
||
position = container.parentNode.getBoundingClientRect();
|
||
}
|
||
} catch (e) {
|
||
console.error(e, e.stack);
|
||
}
|
||
} else {
|
||
position = range.getBoundingClientRect();
|
||
}
|
||
}
|
||
}
|
||
} else if (typeof target === "string" && target.indexOf("#") > -1) {
|
||
let id = target.substring(target.indexOf("#") + 1);
|
||
let el = this.document.getElementById(id);
|
||
if (el) {
|
||
if (isWebkit) {
|
||
let newRange = new Range();
|
||
newRange.selectNode(el);
|
||
position = newRange.getBoundingClientRect();
|
||
} else {
|
||
position = el.getBoundingClientRect();
|
||
}
|
||
}
|
||
}
|
||
if (position) {
|
||
targetPos.left = position.left;
|
||
targetPos.top = position.top;
|
||
}
|
||
return targetPos;
|
||
}
|
||
addStylesheet(src) {
|
||
return new Promise(function(resolve, reject) {
|
||
var $stylesheet;
|
||
var ready = false;
|
||
if (!this.document) {
|
||
resolve(false);
|
||
return;
|
||
}
|
||
$stylesheet = this.document.querySelector("link[href='" + src + "']");
|
||
if ($stylesheet) {
|
||
resolve(true);
|
||
return;
|
||
}
|
||
$stylesheet = this.document.createElement("link");
|
||
$stylesheet.type = "text/css";
|
||
$stylesheet.rel = "stylesheet";
|
||
$stylesheet.href = src;
|
||
$stylesheet.onload = $stylesheet.onreadystatechange = function() {
|
||
if (!ready && (!this.readyState || this.readyState == "complete")) {
|
||
ready = true;
|
||
setTimeout(() => {
|
||
resolve(true);
|
||
}, 1);
|
||
}
|
||
};
|
||
this.document.head.appendChild($stylesheet);
|
||
}.bind(this));
|
||
}
|
||
_getStylesheetNode(key) {
|
||
var styleEl;
|
||
key = "epubjs-inserted-css-" + (key || "");
|
||
if (!this.document)
|
||
return false;
|
||
styleEl = this.document.getElementById(key);
|
||
if (!styleEl) {
|
||
styleEl = this.document.createElement("style");
|
||
styleEl.id = key;
|
||
this.document.head.appendChild(styleEl);
|
||
}
|
||
return styleEl;
|
||
}
|
||
addStylesheetCss(serializedCss, key) {
|
||
if (!this.document || !serializedCss)
|
||
return false;
|
||
var styleEl;
|
||
styleEl = this._getStylesheetNode(key);
|
||
styleEl.innerHTML = serializedCss;
|
||
return true;
|
||
}
|
||
addStylesheetRules(rules, key) {
|
||
var styleSheet;
|
||
if (!this.document || !rules || rules.length === 0)
|
||
return;
|
||
styleSheet = this._getStylesheetNode(key).sheet;
|
||
if (Object.prototype.toString.call(rules) === "[object Array]") {
|
||
for (var i = 0, rl = rules.length; i < rl; i++) {
|
||
var j = 1, rule = rules[i], selector = rules[i][0], propStr = "";
|
||
if (Object.prototype.toString.call(rule[1][0]) === "[object Array]") {
|
||
rule = rule[1];
|
||
j = 0;
|
||
}
|
||
for (var pl = rule.length; j < pl; j++) {
|
||
var prop = rule[j];
|
||
propStr += prop[0] + ":" + prop[1] + (prop[2] ? " !important" : "") + ";\n";
|
||
}
|
||
styleSheet.insertRule(selector + "{" + propStr + "}", styleSheet.cssRules.length);
|
||
}
|
||
} else {
|
||
const selectors = Object.keys(rules);
|
||
selectors.forEach((selector2) => {
|
||
const definition = rules[selector2];
|
||
if (Array.isArray(definition)) {
|
||
definition.forEach((item) => {
|
||
const _rules = Object.keys(item);
|
||
const result = _rules.map((rule2) => {
|
||
return `${rule2}:${item[rule2]}`;
|
||
}).join(";");
|
||
styleSheet.insertRule(`${selector2}{${result}}`, styleSheet.cssRules.length);
|
||
});
|
||
} else {
|
||
const _rules = Object.keys(definition);
|
||
const result = _rules.map((rule2) => {
|
||
return `${rule2}:${definition[rule2]}`;
|
||
}).join(";");
|
||
styleSheet.insertRule(`${selector2}{${result}}`, styleSheet.cssRules.length);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
addScript(src) {
|
||
return new Promise(function(resolve, reject) {
|
||
var $script;
|
||
var ready = false;
|
||
if (!this.document) {
|
||
resolve(false);
|
||
return;
|
||
}
|
||
$script = this.document.createElement("script");
|
||
$script.type = "text/javascript";
|
||
$script.async = true;
|
||
$script.src = src;
|
||
$script.onload = $script.onreadystatechange = function() {
|
||
if (!ready && (!this.readyState || this.readyState == "complete")) {
|
||
ready = true;
|
||
setTimeout(function() {
|
||
resolve(true);
|
||
}, 1);
|
||
}
|
||
};
|
||
this.document.head.appendChild($script);
|
||
}.bind(this));
|
||
}
|
||
addClass(className) {
|
||
var content;
|
||
if (!this.document)
|
||
return;
|
||
content = this.content || this.document.body;
|
||
if (content) {
|
||
content.classList.add(className);
|
||
}
|
||
}
|
||
removeClass(className) {
|
||
var content;
|
||
if (!this.document)
|
||
return;
|
||
content = this.content || this.document.body;
|
||
if (content) {
|
||
content.classList.remove(className);
|
||
}
|
||
}
|
||
addEventListeners() {
|
||
if (!this.document) {
|
||
return;
|
||
}
|
||
this._triggerEvent = this.triggerEvent.bind(this);
|
||
_constants.DOM_EVENTS.forEach(function(eventName) {
|
||
this.document.addEventListener(eventName, this._triggerEvent, {
|
||
passive: true
|
||
});
|
||
}, this);
|
||
}
|
||
removeEventListeners() {
|
||
if (!this.document) {
|
||
return;
|
||
}
|
||
_constants.DOM_EVENTS.forEach(function(eventName) {
|
||
this.document.removeEventListener(eventName, this._triggerEvent, {
|
||
passive: true
|
||
});
|
||
}, this);
|
||
this._triggerEvent = void 0;
|
||
}
|
||
triggerEvent(e) {
|
||
this.emit(e.type, e);
|
||
}
|
||
addSelectionListeners() {
|
||
if (!this.document) {
|
||
return;
|
||
}
|
||
this._onSelectionChange = this.onSelectionChange.bind(this);
|
||
this.document.addEventListener("selectionchange", this._onSelectionChange, {
|
||
passive: true
|
||
});
|
||
}
|
||
removeSelectionListeners() {
|
||
if (!this.document) {
|
||
return;
|
||
}
|
||
this.document.removeEventListener("selectionchange", this._onSelectionChange, {
|
||
passive: true
|
||
});
|
||
this._onSelectionChange = void 0;
|
||
}
|
||
onSelectionChange(e) {
|
||
if (this.selectionEndTimeout) {
|
||
clearTimeout(this.selectionEndTimeout);
|
||
}
|
||
this.selectionEndTimeout = setTimeout(function() {
|
||
var selection = this.window.getSelection();
|
||
this.triggerSelectedEvent(selection);
|
||
}.bind(this), 250);
|
||
}
|
||
triggerSelectedEvent(selection) {
|
||
var range, cfirange;
|
||
if (selection && selection.rangeCount > 0) {
|
||
range = selection.getRangeAt(0);
|
||
if (!range.collapsed) {
|
||
cfirange = new _epubcfi.default(range, this.cfiBase).toString();
|
||
this.emit(_constants.EVENTS.CONTENTS.SELECTED, cfirange);
|
||
this.emit(_constants.EVENTS.CONTENTS.SELECTED_RANGE, range);
|
||
}
|
||
}
|
||
}
|
||
range(_cfi, ignoreClass) {
|
||
var cfi = new _epubcfi.default(_cfi);
|
||
return cfi.toRange(this.document, ignoreClass);
|
||
}
|
||
cfiFromRange(range, ignoreClass) {
|
||
return new _epubcfi.default(range, this.cfiBase, ignoreClass).toString();
|
||
}
|
||
cfiFromNode(node, ignoreClass) {
|
||
return new _epubcfi.default(node, this.cfiBase, ignoreClass).toString();
|
||
}
|
||
map(layout) {
|
||
var map = new _mapping.default(layout);
|
||
return map.section();
|
||
}
|
||
size(width, height) {
|
||
var viewport = {
|
||
scale: 1,
|
||
scalable: "no"
|
||
};
|
||
this.layoutStyle("scrolling");
|
||
if (width >= 0) {
|
||
this.width(width);
|
||
viewport.width = width;
|
||
this.css("padding", "0 " + width / 12 + "px");
|
||
}
|
||
if (height >= 0) {
|
||
this.height(height);
|
||
viewport.height = height;
|
||
}
|
||
this.css("margin", "0");
|
||
this.css("box-sizing", "border-box");
|
||
this.viewport(viewport);
|
||
}
|
||
columns(width, height, columnWidth, gap, dir) {
|
||
let COLUMN_AXIS = (0, _core.prefixed)("column-axis");
|
||
let COLUMN_GAP = (0, _core.prefixed)("column-gap");
|
||
let COLUMN_WIDTH = (0, _core.prefixed)("column-width");
|
||
let COLUMN_FILL = (0, _core.prefixed)("column-fill");
|
||
let writingMode = this.writingMode();
|
||
let axis = writingMode.indexOf("vertical") === 0 ? "vertical" : "horizontal";
|
||
this.layoutStyle("paginated");
|
||
if (dir === "rtl" && axis === "horizontal") {
|
||
this.direction(dir);
|
||
}
|
||
this.width(width);
|
||
this.height(height);
|
||
this.viewport({
|
||
width,
|
||
height,
|
||
scale: 1,
|
||
scalable: "no"
|
||
});
|
||
this.css("overflow-y", "hidden");
|
||
this.css("margin", "0", true);
|
||
if (axis === "vertical") {
|
||
this.css("padding-top", gap / 2 + "px", true);
|
||
this.css("padding-bottom", gap / 2 + "px", true);
|
||
this.css("padding-left", "20px");
|
||
this.css("padding-right", "20px");
|
||
this.css(COLUMN_AXIS, "vertical");
|
||
} else {
|
||
this.css("padding-top", "20px");
|
||
this.css("padding-bottom", "20px");
|
||
this.css("padding-left", gap / 2 + "px", true);
|
||
this.css("padding-right", gap / 2 + "px", true);
|
||
this.css(COLUMN_AXIS, "horizontal");
|
||
}
|
||
this.css("box-sizing", "border-box");
|
||
this.css("max-width", "inherit");
|
||
this.css(COLUMN_FILL, "auto");
|
||
this.css(COLUMN_GAP, gap + "px");
|
||
this.css(COLUMN_WIDTH, columnWidth + "px");
|
||
this.css("-webkit-line-box-contain", "block glyphs replaced");
|
||
}
|
||
scaler(scale, offsetX, offsetY) {
|
||
var scaleStr = "scale(" + scale + ")";
|
||
var translateStr = "";
|
||
this.css("transform-origin", "top left");
|
||
if (offsetX >= 0 || offsetY >= 0) {
|
||
translateStr = " translate(" + (offsetX || 0) + "px, " + (offsetY || 0) + "px )";
|
||
}
|
||
this.css("transform", scaleStr + translateStr);
|
||
}
|
||
fit(width, height, section) {
|
||
var viewport = this.viewport();
|
||
var viewportWidth = parseInt(viewport.width);
|
||
var viewportHeight = parseInt(viewport.height);
|
||
var widthScale = width / viewportWidth;
|
||
var heightScale = height / viewportHeight;
|
||
var scale = widthScale < heightScale ? widthScale : heightScale;
|
||
this.layoutStyle("paginated");
|
||
this.width(viewportWidth);
|
||
this.height(viewportHeight);
|
||
this.overflow("hidden");
|
||
this.scaler(scale, 0, 0);
|
||
this.css("background-size", viewportWidth * scale + "px " + viewportHeight * scale + "px");
|
||
this.css("background-color", "transparent");
|
||
if (section && section.properties.includes("page-spread-left")) {
|
||
var marginLeft = width - viewportWidth * scale;
|
||
this.css("margin-left", marginLeft + "px");
|
||
}
|
||
}
|
||
direction(dir) {
|
||
if (this.documentElement) {
|
||
this.documentElement.style["direction"] = dir;
|
||
}
|
||
}
|
||
mapPage(cfiBase, layout, start, end, dev) {
|
||
var mapping = new _mapping.default(layout, dev);
|
||
return mapping.page(this, cfiBase, start, end);
|
||
}
|
||
linksHandler() {
|
||
(0, _replacements.replaceLinks)(this.content, (href) => {
|
||
this.emit(_constants.EVENTS.CONTENTS.LINK_CLICKED, href);
|
||
});
|
||
}
|
||
writingMode(mode) {
|
||
let WRITING_MODE = (0, _core.prefixed)("writing-mode");
|
||
if (mode && this.documentElement) {
|
||
this.documentElement.style[WRITING_MODE] = mode;
|
||
}
|
||
return this.window.getComputedStyle(this.documentElement)[WRITING_MODE] || "";
|
||
}
|
||
layoutStyle(style) {
|
||
if (style) {
|
||
this._layoutStyle = style;
|
||
navigator.epubReadingSystem.layoutStyle = this._layoutStyle;
|
||
}
|
||
return this._layoutStyle || "paginated";
|
||
}
|
||
epubReadingSystem(name, version) {
|
||
navigator.epubReadingSystem = {
|
||
name,
|
||
version,
|
||
layoutStyle: this.layoutStyle(),
|
||
hasFeature: function(feature) {
|
||
switch (feature) {
|
||
case "dom-manipulation":
|
||
return true;
|
||
case "layout-changes":
|
||
return true;
|
||
case "touch-events":
|
||
return true;
|
||
case "mouse-events":
|
||
return true;
|
||
case "keyboard-events":
|
||
return true;
|
||
case "spine-scripting":
|
||
return false;
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
};
|
||
return navigator.epubReadingSystem;
|
||
}
|
||
destroy() {
|
||
this.removeListeners();
|
||
}
|
||
};
|
||
(0, _eventEmitter.default)(Contents.prototype);
|
||
var _default = Contents;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/annotations.js
|
||
var require_annotations = __commonJS({
|
||
"node_modules/epubjs/lib/annotations.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _eventEmitter = _interopRequireDefault(require_event_emitter());
|
||
var _epubcfi = _interopRequireDefault(require_epubcfi());
|
||
var _constants = require_constants();
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Annotations = class {
|
||
constructor(rendition) {
|
||
this.rendition = rendition;
|
||
this.highlights = [];
|
||
this.underlines = [];
|
||
this.marks = [];
|
||
this._annotations = {};
|
||
this._annotationsBySectionIndex = {};
|
||
this.rendition.hooks.render.register(this.inject.bind(this));
|
||
this.rendition.hooks.unloaded.register(this.clear.bind(this));
|
||
}
|
||
add(type, cfiRange, data, cb, className, styles) {
|
||
let hash = encodeURI(cfiRange + type);
|
||
let cfi = new _epubcfi.default(cfiRange);
|
||
let sectionIndex = cfi.spinePos;
|
||
let annotation = new Annotation({
|
||
type,
|
||
cfiRange,
|
||
data,
|
||
sectionIndex,
|
||
cb,
|
||
className,
|
||
styles
|
||
});
|
||
this._annotations[hash] = annotation;
|
||
if (sectionIndex in this._annotationsBySectionIndex) {
|
||
this._annotationsBySectionIndex[sectionIndex].push(hash);
|
||
} else {
|
||
this._annotationsBySectionIndex[sectionIndex] = [hash];
|
||
}
|
||
let views = this.rendition.views();
|
||
views.forEach((view) => {
|
||
if (annotation.sectionIndex === view.index) {
|
||
annotation.attach(view);
|
||
}
|
||
});
|
||
return annotation;
|
||
}
|
||
remove(cfiRange, type) {
|
||
let hash = encodeURI(cfiRange + type);
|
||
if (hash in this._annotations) {
|
||
let annotation = this._annotations[hash];
|
||
if (type && annotation.type !== type) {
|
||
return;
|
||
}
|
||
let views = this.rendition.views();
|
||
views.forEach((view) => {
|
||
this._removeFromAnnotationBySectionIndex(annotation.sectionIndex, hash);
|
||
if (annotation.sectionIndex === view.index) {
|
||
annotation.detach(view);
|
||
}
|
||
});
|
||
delete this._annotations[hash];
|
||
}
|
||
}
|
||
_removeFromAnnotationBySectionIndex(sectionIndex, hash) {
|
||
this._annotationsBySectionIndex[sectionIndex] = this._annotationsAt(sectionIndex).filter((h) => h !== hash);
|
||
}
|
||
_annotationsAt(index) {
|
||
return this._annotationsBySectionIndex[index];
|
||
}
|
||
highlight(cfiRange, data, cb, className, styles) {
|
||
return this.add("highlight", cfiRange, data, cb, className, styles);
|
||
}
|
||
underline(cfiRange, data, cb, className, styles) {
|
||
return this.add("underline", cfiRange, data, cb, className, styles);
|
||
}
|
||
mark(cfiRange, data, cb) {
|
||
return this.add("mark", cfiRange, data, cb);
|
||
}
|
||
each() {
|
||
return this._annotations.forEach.apply(this._annotations, arguments);
|
||
}
|
||
inject(view) {
|
||
let sectionIndex = view.index;
|
||
if (sectionIndex in this._annotationsBySectionIndex) {
|
||
let annotations = this._annotationsBySectionIndex[sectionIndex];
|
||
annotations.forEach((hash) => {
|
||
let annotation = this._annotations[hash];
|
||
annotation.attach(view);
|
||
});
|
||
}
|
||
}
|
||
clear(view) {
|
||
let sectionIndex = view.index;
|
||
if (sectionIndex in this._annotationsBySectionIndex) {
|
||
let annotations = this._annotationsBySectionIndex[sectionIndex];
|
||
annotations.forEach((hash) => {
|
||
let annotation = this._annotations[hash];
|
||
annotation.detach(view);
|
||
});
|
||
}
|
||
}
|
||
show() {
|
||
}
|
||
hide() {
|
||
}
|
||
};
|
||
var Annotation = class {
|
||
constructor({
|
||
type,
|
||
cfiRange,
|
||
data,
|
||
sectionIndex,
|
||
cb,
|
||
className,
|
||
styles
|
||
}) {
|
||
this.type = type;
|
||
this.cfiRange = cfiRange;
|
||
this.data = data;
|
||
this.sectionIndex = sectionIndex;
|
||
this.mark = void 0;
|
||
this.cb = cb;
|
||
this.className = className;
|
||
this.styles = styles;
|
||
}
|
||
update(data) {
|
||
this.data = data;
|
||
}
|
||
attach(view) {
|
||
let {
|
||
cfiRange,
|
||
data,
|
||
type,
|
||
mark,
|
||
cb,
|
||
className,
|
||
styles
|
||
} = this;
|
||
let result;
|
||
if (type === "highlight") {
|
||
result = view.highlight(cfiRange, data, cb, className, styles);
|
||
} else if (type === "underline") {
|
||
result = view.underline(cfiRange, data, cb, className, styles);
|
||
} else if (type === "mark") {
|
||
result = view.mark(cfiRange, data, cb);
|
||
}
|
||
this.mark = result;
|
||
this.emit(_constants.EVENTS.ANNOTATION.ATTACH, result);
|
||
return result;
|
||
}
|
||
detach(view) {
|
||
let {
|
||
cfiRange,
|
||
type
|
||
} = this;
|
||
let result;
|
||
if (view) {
|
||
if (type === "highlight") {
|
||
result = view.unhighlight(cfiRange);
|
||
} else if (type === "underline") {
|
||
result = view.ununderline(cfiRange);
|
||
} else if (type === "mark") {
|
||
result = view.unmark(cfiRange);
|
||
}
|
||
}
|
||
this.mark = void 0;
|
||
this.emit(_constants.EVENTS.ANNOTATION.DETACH, result);
|
||
return result;
|
||
}
|
||
text() {
|
||
}
|
||
};
|
||
(0, _eventEmitter.default)(Annotation.prototype);
|
||
var _default = Annotations;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/marks-pane/lib/svg.js
|
||
var require_svg = __commonJS({
|
||
"node_modules/marks-pane/lib/svg.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.createElement = createElement2;
|
||
function createElement2(name) {
|
||
return document.createElementNS("http://www.w3.org/2000/svg", name);
|
||
}
|
||
exports.default = {
|
||
createElement: createElement2
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/marks-pane/lib/events.js
|
||
var require_events = __commonJS({
|
||
"node_modules/marks-pane/lib/events.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.proxyMouse = proxyMouse;
|
||
exports.clone = clone;
|
||
exports.default = {
|
||
proxyMouse
|
||
};
|
||
function proxyMouse(target, tracked) {
|
||
function dispatch(e) {
|
||
for (var i = tracked.length - 1; i >= 0; i--) {
|
||
var t = tracked[i];
|
||
var x = e.clientX;
|
||
var y = e.clientY;
|
||
if (e.touches && e.touches.length) {
|
||
x = e.touches[0].clientX;
|
||
y = e.touches[0].clientY;
|
||
}
|
||
if (!contains(t, target, x, y)) {
|
||
continue;
|
||
}
|
||
t.dispatchEvent(clone(e));
|
||
break;
|
||
}
|
||
}
|
||
if (target.nodeName === "iframe" || target.nodeName === "IFRAME") {
|
||
try {
|
||
this.target = target.contentDocument;
|
||
} catch (err) {
|
||
this.target = target;
|
||
}
|
||
} else {
|
||
this.target = target;
|
||
}
|
||
var _arr = ["mouseup", "mousedown", "click", "touchstart"];
|
||
for (var _i = 0; _i < _arr.length; _i++) {
|
||
var ev = _arr[_i];
|
||
this.target.addEventListener(ev, function(e) {
|
||
return dispatch(e);
|
||
}, false);
|
||
}
|
||
}
|
||
function clone(e) {
|
||
var opts = Object.assign({}, e, { bubbles: false });
|
||
try {
|
||
return new MouseEvent(e.type, opts);
|
||
} catch (err) {
|
||
var copy = document.createEvent("MouseEvents");
|
||
copy.initMouseEvent(e.type, false, opts.cancelable, opts.view, opts.detail, opts.screenX, opts.screenY, opts.clientX, opts.clientY, opts.ctrlKey, opts.altKey, opts.shiftKey, opts.metaKey, opts.button, opts.relatedTarget);
|
||
return copy;
|
||
}
|
||
}
|
||
function contains(item, target, x, y) {
|
||
var offset = target.getBoundingClientRect();
|
||
function rectContains(r, x2, y2) {
|
||
var top = r.top - offset.top;
|
||
var left = r.left - offset.left;
|
||
var bottom = top + r.height;
|
||
var right = left + r.width;
|
||
return top <= y2 && left <= x2 && bottom > y2 && right > x2;
|
||
}
|
||
var rect = item.getBoundingClientRect();
|
||
if (!rectContains(rect, x, y)) {
|
||
return false;
|
||
}
|
||
var rects = item.getClientRects();
|
||
for (var i = 0, len = rects.length; i < len; i++) {
|
||
if (rectContains(rects[i], x, y)) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/marks-pane/lib/marks.js
|
||
var require_marks = __commonJS({
|
||
"node_modules/marks-pane/lib/marks.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.Underline = exports.Highlight = exports.Mark = exports.Pane = void 0;
|
||
var _get = function get(object, property, receiver) {
|
||
if (object === null)
|
||
object = Function.prototype;
|
||
var desc = Object.getOwnPropertyDescriptor(object, property);
|
||
if (desc === void 0) {
|
||
var parent2 = Object.getPrototypeOf(object);
|
||
if (parent2 === null) {
|
||
return void 0;
|
||
} else {
|
||
return get(parent2, property, receiver);
|
||
}
|
||
} else if ("value" in desc) {
|
||
return desc.value;
|
||
} else {
|
||
var getter = desc.get;
|
||
if (getter === void 0) {
|
||
return void 0;
|
||
}
|
||
return getter.call(receiver);
|
||
}
|
||
};
|
||
var _createClass = function() {
|
||
function defineProperties(target, props) {
|
||
for (var i = 0; i < props.length; i++) {
|
||
var descriptor = props[i];
|
||
descriptor.enumerable = descriptor.enumerable || false;
|
||
descriptor.configurable = true;
|
||
if ("value" in descriptor)
|
||
descriptor.writable = true;
|
||
Object.defineProperty(target, descriptor.key, descriptor);
|
||
}
|
||
}
|
||
return function(Constructor, protoProps, staticProps) {
|
||
if (protoProps)
|
||
defineProperties(Constructor.prototype, protoProps);
|
||
if (staticProps)
|
||
defineProperties(Constructor, staticProps);
|
||
return Constructor;
|
||
};
|
||
}();
|
||
var _svg = require_svg();
|
||
var _svg2 = _interopRequireDefault(_svg);
|
||
var _events = require_events();
|
||
var _events2 = _interopRequireDefault(_events);
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
function _possibleConstructorReturn(self2, call) {
|
||
if (!self2) {
|
||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||
}
|
||
return call && (typeof call === "object" || typeof call === "function") ? call : self2;
|
||
}
|
||
function _inherits(subClass, superClass) {
|
||
if (typeof superClass !== "function" && superClass !== null) {
|
||
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
||
}
|
||
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });
|
||
if (superClass)
|
||
Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
||
}
|
||
function _classCallCheck(instance, Constructor) {
|
||
if (!(instance instanceof Constructor)) {
|
||
throw new TypeError("Cannot call a class as a function");
|
||
}
|
||
}
|
||
var Pane = exports.Pane = function() {
|
||
function Pane2(target) {
|
||
var container = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : document.body;
|
||
_classCallCheck(this, Pane2);
|
||
this.target = target;
|
||
this.element = _svg2.default.createElement("svg");
|
||
this.marks = [];
|
||
this.element.style.position = "absolute";
|
||
this.element.setAttribute("pointer-events", "none");
|
||
_events2.default.proxyMouse(this.target, this.marks);
|
||
this.container = container;
|
||
this.container.appendChild(this.element);
|
||
this.render();
|
||
}
|
||
_createClass(Pane2, [{
|
||
key: "addMark",
|
||
value: function addMark(mark) {
|
||
var g = _svg2.default.createElement("g");
|
||
this.element.appendChild(g);
|
||
mark.bind(g, this.container);
|
||
this.marks.push(mark);
|
||
mark.render();
|
||
return mark;
|
||
}
|
||
}, {
|
||
key: "removeMark",
|
||
value: function removeMark(mark) {
|
||
var idx = this.marks.indexOf(mark);
|
||
if (idx === -1) {
|
||
return;
|
||
}
|
||
var el = mark.unbind();
|
||
this.element.removeChild(el);
|
||
this.marks.splice(idx, 1);
|
||
}
|
||
}, {
|
||
key: "render",
|
||
value: function render2() {
|
||
setCoords(this.element, coords(this.target, this.container));
|
||
var _iteratorNormalCompletion = true;
|
||
var _didIteratorError = false;
|
||
var _iteratorError = void 0;
|
||
try {
|
||
for (var _iterator = this.marks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||
var m = _step.value;
|
||
m.render();
|
||
}
|
||
} catch (err) {
|
||
_didIteratorError = true;
|
||
_iteratorError = err;
|
||
} finally {
|
||
try {
|
||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||
_iterator.return();
|
||
}
|
||
} finally {
|
||
if (_didIteratorError) {
|
||
throw _iteratorError;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}]);
|
||
return Pane2;
|
||
}();
|
||
var Mark = exports.Mark = function() {
|
||
function Mark2() {
|
||
_classCallCheck(this, Mark2);
|
||
this.element = null;
|
||
}
|
||
_createClass(Mark2, [{
|
||
key: "bind",
|
||
value: function bind(element, container) {
|
||
this.element = element;
|
||
this.container = container;
|
||
}
|
||
}, {
|
||
key: "unbind",
|
||
value: function unbind() {
|
||
var el = this.element;
|
||
this.element = null;
|
||
return el;
|
||
}
|
||
}, {
|
||
key: "render",
|
||
value: function render2() {
|
||
}
|
||
}, {
|
||
key: "dispatchEvent",
|
||
value: function dispatchEvent(e) {
|
||
if (!this.element)
|
||
return;
|
||
this.element.dispatchEvent(e);
|
||
}
|
||
}, {
|
||
key: "getBoundingClientRect",
|
||
value: function getBoundingClientRect() {
|
||
return this.element.getBoundingClientRect();
|
||
}
|
||
}, {
|
||
key: "getClientRects",
|
||
value: function getClientRects() {
|
||
var rects = [];
|
||
var el = this.element.firstChild;
|
||
while (el) {
|
||
rects.push(el.getBoundingClientRect());
|
||
el = el.nextSibling;
|
||
}
|
||
return rects;
|
||
}
|
||
}, {
|
||
key: "filteredRanges",
|
||
value: function filteredRanges() {
|
||
var rects = Array.from(this.range.getClientRects());
|
||
return rects.filter(function(box) {
|
||
for (var i = 0; i < rects.length; i++) {
|
||
if (rects[i] === box) {
|
||
return true;
|
||
}
|
||
var contained = contains(rects[i], box);
|
||
if (contained) {
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
});
|
||
}
|
||
}]);
|
||
return Mark2;
|
||
}();
|
||
var Highlight = exports.Highlight = function(_Mark) {
|
||
_inherits(Highlight2, _Mark);
|
||
function Highlight2(range, className, data, attributes) {
|
||
_classCallCheck(this, Highlight2);
|
||
var _this = _possibleConstructorReturn(this, (Highlight2.__proto__ || Object.getPrototypeOf(Highlight2)).call(this));
|
||
_this.range = range;
|
||
_this.className = className;
|
||
_this.data = data || {};
|
||
_this.attributes = attributes || {};
|
||
return _this;
|
||
}
|
||
_createClass(Highlight2, [{
|
||
key: "bind",
|
||
value: function bind(element, container) {
|
||
_get(Highlight2.prototype.__proto__ || Object.getPrototypeOf(Highlight2.prototype), "bind", this).call(this, element, container);
|
||
for (var attr in this.data) {
|
||
if (this.data.hasOwnProperty(attr)) {
|
||
this.element.dataset[attr] = this.data[attr];
|
||
}
|
||
}
|
||
for (var attr in this.attributes) {
|
||
if (this.attributes.hasOwnProperty(attr)) {
|
||
this.element.setAttribute(attr, this.attributes[attr]);
|
||
}
|
||
}
|
||
if (this.className) {
|
||
this.element.classList.add(this.className);
|
||
}
|
||
}
|
||
}, {
|
||
key: "render",
|
||
value: function render2() {
|
||
while (this.element.firstChild) {
|
||
this.element.removeChild(this.element.firstChild);
|
||
}
|
||
var docFrag = this.element.ownerDocument.createDocumentFragment();
|
||
var filtered = this.filteredRanges();
|
||
var offset = this.element.getBoundingClientRect();
|
||
var container = this.container.getBoundingClientRect();
|
||
for (var i = 0, len = filtered.length; i < len; i++) {
|
||
var r = filtered[i];
|
||
var el = _svg2.default.createElement("rect");
|
||
el.setAttribute("x", r.left - offset.left + container.left);
|
||
el.setAttribute("y", r.top - offset.top + container.top);
|
||
el.setAttribute("height", r.height);
|
||
el.setAttribute("width", r.width);
|
||
docFrag.appendChild(el);
|
||
}
|
||
this.element.appendChild(docFrag);
|
||
}
|
||
}]);
|
||
return Highlight2;
|
||
}(Mark);
|
||
var Underline = exports.Underline = function(_Highlight) {
|
||
_inherits(Underline2, _Highlight);
|
||
function Underline2(range, className, data, attributes) {
|
||
_classCallCheck(this, Underline2);
|
||
return _possibleConstructorReturn(this, (Underline2.__proto__ || Object.getPrototypeOf(Underline2)).call(this, range, className, data, attributes));
|
||
}
|
||
_createClass(Underline2, [{
|
||
key: "render",
|
||
value: function render2() {
|
||
while (this.element.firstChild) {
|
||
this.element.removeChild(this.element.firstChild);
|
||
}
|
||
var docFrag = this.element.ownerDocument.createDocumentFragment();
|
||
var filtered = this.filteredRanges();
|
||
var offset = this.element.getBoundingClientRect();
|
||
var container = this.container.getBoundingClientRect();
|
||
for (var i = 0, len = filtered.length; i < len; i++) {
|
||
var r = filtered[i];
|
||
var rect = _svg2.default.createElement("rect");
|
||
rect.setAttribute("x", r.left - offset.left + container.left);
|
||
rect.setAttribute("y", r.top - offset.top + container.top);
|
||
rect.setAttribute("height", r.height);
|
||
rect.setAttribute("width", r.width);
|
||
rect.setAttribute("fill", "none");
|
||
var line = _svg2.default.createElement("line");
|
||
line.setAttribute("x1", r.left - offset.left + container.left);
|
||
line.setAttribute("x2", r.left - offset.left + container.left + r.width);
|
||
line.setAttribute("y1", r.top - offset.top + container.top + r.height - 1);
|
||
line.setAttribute("y2", r.top - offset.top + container.top + r.height - 1);
|
||
line.setAttribute("stroke-width", 1);
|
||
line.setAttribute("stroke", "black");
|
||
line.setAttribute("stroke-linecap", "square");
|
||
docFrag.appendChild(rect);
|
||
docFrag.appendChild(line);
|
||
}
|
||
this.element.appendChild(docFrag);
|
||
}
|
||
}]);
|
||
return Underline2;
|
||
}(Highlight);
|
||
function coords(el, container) {
|
||
var offset = container.getBoundingClientRect();
|
||
var rect = el.getBoundingClientRect();
|
||
return {
|
||
top: rect.top - offset.top,
|
||
left: rect.left - offset.left,
|
||
height: el.scrollHeight,
|
||
width: el.scrollWidth
|
||
};
|
||
}
|
||
function setCoords(el, coords2) {
|
||
el.style.setProperty("top", coords2.top + "px", "important");
|
||
el.style.setProperty("left", coords2.left + "px", "important");
|
||
el.style.setProperty("height", coords2.height + "px", "important");
|
||
el.style.setProperty("width", coords2.width + "px", "important");
|
||
}
|
||
function contains(rect1, rect2) {
|
||
return rect2.right <= rect1.right && rect2.left >= rect1.left && rect2.top >= rect1.top && rect2.bottom <= rect1.bottom;
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/managers/views/iframe.js
|
||
var require_iframe = __commonJS({
|
||
"node_modules/epubjs/lib/managers/views/iframe.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _eventEmitter = _interopRequireDefault(require_event_emitter());
|
||
var _core = require_core();
|
||
var _epubcfi = _interopRequireDefault(require_epubcfi());
|
||
var _contents = _interopRequireDefault(require_contents());
|
||
var _constants = require_constants();
|
||
var _marksPane = require_marks();
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var IframeView = class {
|
||
constructor(section, options) {
|
||
this.settings = (0, _core.extend)({
|
||
ignoreClass: "",
|
||
axis: void 0,
|
||
direction: void 0,
|
||
width: 0,
|
||
height: 0,
|
||
layout: void 0,
|
||
globalLayoutProperties: {},
|
||
method: void 0,
|
||
forceRight: false,
|
||
allowScriptedContent: false,
|
||
allowPopups: false
|
||
}, options || {});
|
||
this.id = "epubjs-view-" + (0, _core.uuid)();
|
||
this.section = section;
|
||
this.index = section.index;
|
||
this.element = this.container(this.settings.axis);
|
||
this.added = false;
|
||
this.displayed = false;
|
||
this.rendered = false;
|
||
this.fixedWidth = 0;
|
||
this.fixedHeight = 0;
|
||
this.epubcfi = new _epubcfi.default();
|
||
this.layout = this.settings.layout;
|
||
this.pane = void 0;
|
||
this.highlights = {};
|
||
this.underlines = {};
|
||
this.marks = {};
|
||
}
|
||
container(axis) {
|
||
var element = document.createElement("div");
|
||
element.classList.add("epub-view");
|
||
element.style.height = "0px";
|
||
element.style.width = "0px";
|
||
element.style.overflow = "hidden";
|
||
element.style.position = "relative";
|
||
element.style.display = "block";
|
||
if (axis && axis == "horizontal") {
|
||
element.style.flex = "none";
|
||
} else {
|
||
element.style.flex = "initial";
|
||
}
|
||
return element;
|
||
}
|
||
create() {
|
||
if (this.iframe) {
|
||
return this.iframe;
|
||
}
|
||
if (!this.element) {
|
||
this.element = this.createContainer();
|
||
}
|
||
this.iframe = document.createElement("iframe");
|
||
this.iframe.id = this.id;
|
||
this.iframe.scrolling = "no";
|
||
this.iframe.style.overflow = "hidden";
|
||
this.iframe.seamless = "seamless";
|
||
this.iframe.style.border = "none";
|
||
this.iframe.sandbox = "allow-same-origin";
|
||
if (this.settings.allowScriptedContent) {
|
||
this.iframe.sandbox += " allow-scripts";
|
||
}
|
||
if (this.settings.allowPopups) {
|
||
this.iframe.sandbox += " allow-popups";
|
||
}
|
||
this.iframe.setAttribute("enable-annotation", "true");
|
||
this.resizing = true;
|
||
this.element.style.visibility = "hidden";
|
||
this.iframe.style.visibility = "hidden";
|
||
this.iframe.style.width = "0";
|
||
this.iframe.style.height = "0";
|
||
this._width = 0;
|
||
this._height = 0;
|
||
this.element.setAttribute("ref", this.index);
|
||
this.added = true;
|
||
this.elementBounds = (0, _core.bounds)(this.element);
|
||
if ("srcdoc" in this.iframe) {
|
||
this.supportsSrcdoc = true;
|
||
} else {
|
||
this.supportsSrcdoc = false;
|
||
}
|
||
if (!this.settings.method) {
|
||
this.settings.method = this.supportsSrcdoc ? "srcdoc" : "write";
|
||
}
|
||
return this.iframe;
|
||
}
|
||
render(request, show) {
|
||
this.create();
|
||
this.size();
|
||
if (!this.sectionRender) {
|
||
this.sectionRender = this.section.render(request);
|
||
}
|
||
return this.sectionRender.then(function(contents) {
|
||
return this.load(contents);
|
||
}.bind(this)).then(function() {
|
||
let writingMode = this.contents.writingMode();
|
||
let axis;
|
||
if (this.settings.flow === "scrolled") {
|
||
axis = writingMode.indexOf("vertical") === 0 ? "horizontal" : "vertical";
|
||
} else {
|
||
axis = writingMode.indexOf("vertical") === 0 ? "vertical" : "horizontal";
|
||
}
|
||
if (writingMode.indexOf("vertical") === 0 && this.settings.flow === "paginated") {
|
||
this.layout.delta = this.layout.height;
|
||
}
|
||
this.setAxis(axis);
|
||
this.emit(_constants.EVENTS.VIEWS.AXIS, axis);
|
||
this.setWritingMode(writingMode);
|
||
this.emit(_constants.EVENTS.VIEWS.WRITING_MODE, writingMode);
|
||
this.layout.format(this.contents, this.section, this.axis);
|
||
this.addListeners();
|
||
return new Promise((resolve, reject) => {
|
||
this.expand();
|
||
if (this.settings.forceRight) {
|
||
this.element.style.marginLeft = this.width() + "px";
|
||
}
|
||
resolve();
|
||
});
|
||
}.bind(this), function(e) {
|
||
this.emit(_constants.EVENTS.VIEWS.LOAD_ERROR, e);
|
||
return new Promise((resolve, reject) => {
|
||
reject(e);
|
||
});
|
||
}.bind(this)).then(function() {
|
||
this.emit(_constants.EVENTS.VIEWS.RENDERED, this.section);
|
||
}.bind(this));
|
||
}
|
||
reset() {
|
||
if (this.iframe) {
|
||
this.iframe.style.width = "0";
|
||
this.iframe.style.height = "0";
|
||
this._width = 0;
|
||
this._height = 0;
|
||
this._textWidth = void 0;
|
||
this._contentWidth = void 0;
|
||
this._textHeight = void 0;
|
||
this._contentHeight = void 0;
|
||
}
|
||
this._needsReframe = true;
|
||
}
|
||
size(_width, _height) {
|
||
var width = _width || this.settings.width;
|
||
var height = _height || this.settings.height;
|
||
if (this.layout.name === "pre-paginated") {
|
||
this.lock("both", width, height);
|
||
} else if (this.settings.axis === "horizontal") {
|
||
this.lock("height", width, height);
|
||
} else {
|
||
this.lock("width", width, height);
|
||
}
|
||
this.settings.width = width;
|
||
this.settings.height = height;
|
||
}
|
||
lock(what, width, height) {
|
||
var elBorders = (0, _core.borders)(this.element);
|
||
var iframeBorders;
|
||
if (this.iframe) {
|
||
iframeBorders = (0, _core.borders)(this.iframe);
|
||
} else {
|
||
iframeBorders = {
|
||
width: 0,
|
||
height: 0
|
||
};
|
||
}
|
||
if (what == "width" && (0, _core.isNumber)(width)) {
|
||
this.lockedWidth = width - elBorders.width - iframeBorders.width;
|
||
}
|
||
if (what == "height" && (0, _core.isNumber)(height)) {
|
||
this.lockedHeight = height - elBorders.height - iframeBorders.height;
|
||
}
|
||
if (what === "both" && (0, _core.isNumber)(width) && (0, _core.isNumber)(height)) {
|
||
this.lockedWidth = width - elBorders.width - iframeBorders.width;
|
||
this.lockedHeight = height - elBorders.height - iframeBorders.height;
|
||
}
|
||
if (this.displayed && this.iframe) {
|
||
this.expand();
|
||
}
|
||
}
|
||
expand(force) {
|
||
var width = this.lockedWidth;
|
||
var height = this.lockedHeight;
|
||
var columns;
|
||
var textWidth, textHeight;
|
||
if (!this.iframe || this._expanding)
|
||
return;
|
||
this._expanding = true;
|
||
if (this.layout.name === "pre-paginated") {
|
||
width = this.layout.columnWidth;
|
||
height = this.layout.height;
|
||
} else if (this.settings.axis === "horizontal") {
|
||
width = this.contents.textWidth();
|
||
if (width % this.layout.pageWidth > 0) {
|
||
width = Math.ceil(width / this.layout.pageWidth) * this.layout.pageWidth;
|
||
}
|
||
if (this.settings.forceEvenPages) {
|
||
columns = width / this.layout.pageWidth;
|
||
if (this.layout.divisor > 1 && this.layout.name === "reflowable" && columns % 2 > 0) {
|
||
width += this.layout.pageWidth;
|
||
}
|
||
}
|
||
} else if (this.settings.axis === "vertical") {
|
||
height = this.contents.textHeight();
|
||
if (this.settings.flow === "paginated" && height % this.layout.height > 0) {
|
||
height = Math.ceil(height / this.layout.height) * this.layout.height;
|
||
}
|
||
}
|
||
if (this._needsReframe || width != this._width || height != this._height) {
|
||
this.reframe(width, height);
|
||
}
|
||
this._expanding = false;
|
||
}
|
||
reframe(width, height) {
|
||
var size;
|
||
if ((0, _core.isNumber)(width)) {
|
||
this.element.style.width = width + "px";
|
||
this.iframe.style.width = width + "px";
|
||
this._width = width;
|
||
}
|
||
if ((0, _core.isNumber)(height)) {
|
||
this.element.style.height = height + "px";
|
||
this.iframe.style.height = height + "px";
|
||
this._height = height;
|
||
}
|
||
let widthDelta = this.prevBounds ? width - this.prevBounds.width : width;
|
||
let heightDelta = this.prevBounds ? height - this.prevBounds.height : height;
|
||
size = {
|
||
width,
|
||
height,
|
||
widthDelta,
|
||
heightDelta
|
||
};
|
||
this.pane && this.pane.render();
|
||
requestAnimationFrame(() => {
|
||
let mark;
|
||
for (let m in this.marks) {
|
||
if (this.marks.hasOwnProperty(m)) {
|
||
mark = this.marks[m];
|
||
this.placeMark(mark.element, mark.range);
|
||
}
|
||
}
|
||
});
|
||
this.onResize(this, size);
|
||
this.emit(_constants.EVENTS.VIEWS.RESIZED, size);
|
||
this.prevBounds = size;
|
||
this.elementBounds = (0, _core.bounds)(this.element);
|
||
}
|
||
load(contents) {
|
||
var loading = new _core.defer();
|
||
var loaded = loading.promise;
|
||
if (!this.iframe) {
|
||
loading.reject(new Error("No Iframe Available"));
|
||
return loaded;
|
||
}
|
||
this.iframe.onload = function(event) {
|
||
this.onLoad(event, loading);
|
||
}.bind(this);
|
||
if (this.settings.method === "blobUrl") {
|
||
this.blobUrl = (0, _core.createBlobUrl)(contents, "application/xhtml+xml");
|
||
this.iframe.src = this.blobUrl;
|
||
this.element.appendChild(this.iframe);
|
||
} else if (this.settings.method === "srcdoc") {
|
||
this.iframe.srcdoc = contents;
|
||
this.element.appendChild(this.iframe);
|
||
} else {
|
||
this.element.appendChild(this.iframe);
|
||
this.document = this.iframe.contentDocument;
|
||
if (!this.document) {
|
||
loading.reject(new Error("No Document Available"));
|
||
return loaded;
|
||
}
|
||
this.iframe.contentDocument.open();
|
||
if (window.MSApp && MSApp.execUnsafeLocalFunction) {
|
||
var outerThis = this;
|
||
MSApp.execUnsafeLocalFunction(function() {
|
||
outerThis.iframe.contentDocument.write(contents);
|
||
});
|
||
} else {
|
||
this.iframe.contentDocument.write(contents);
|
||
}
|
||
this.iframe.contentDocument.close();
|
||
}
|
||
return loaded;
|
||
}
|
||
onLoad(event, promise) {
|
||
this.window = this.iframe.contentWindow;
|
||
this.document = this.iframe.contentDocument;
|
||
this.contents = new _contents.default(this.document, this.document.body, this.section.cfiBase, this.section.index);
|
||
this.rendering = false;
|
||
var link = this.document.querySelector("link[rel='canonical']");
|
||
if (link) {
|
||
link.setAttribute("href", this.section.canonical);
|
||
} else {
|
||
link = this.document.createElement("link");
|
||
link.setAttribute("rel", "canonical");
|
||
link.setAttribute("href", this.section.canonical);
|
||
this.document.querySelector("head").appendChild(link);
|
||
}
|
||
this.contents.on(_constants.EVENTS.CONTENTS.EXPAND, () => {
|
||
if (this.displayed && this.iframe) {
|
||
this.expand();
|
||
if (this.contents) {
|
||
this.layout.format(this.contents);
|
||
}
|
||
}
|
||
});
|
||
this.contents.on(_constants.EVENTS.CONTENTS.RESIZE, (e) => {
|
||
if (this.displayed && this.iframe) {
|
||
this.expand();
|
||
if (this.contents) {
|
||
this.layout.format(this.contents);
|
||
}
|
||
}
|
||
});
|
||
promise.resolve(this.contents);
|
||
}
|
||
setLayout(layout) {
|
||
this.layout = layout;
|
||
if (this.contents) {
|
||
this.layout.format(this.contents);
|
||
this.expand();
|
||
}
|
||
}
|
||
setAxis(axis) {
|
||
this.settings.axis = axis;
|
||
if (axis == "horizontal") {
|
||
this.element.style.flex = "none";
|
||
} else {
|
||
this.element.style.flex = "initial";
|
||
}
|
||
this.size();
|
||
}
|
||
setWritingMode(mode) {
|
||
this.writingMode = mode;
|
||
}
|
||
addListeners() {
|
||
}
|
||
removeListeners(layoutFunc) {
|
||
}
|
||
display(request) {
|
||
var displayed = new _core.defer();
|
||
if (!this.displayed) {
|
||
this.render(request).then(function() {
|
||
this.emit(_constants.EVENTS.VIEWS.DISPLAYED, this);
|
||
this.onDisplayed(this);
|
||
this.displayed = true;
|
||
displayed.resolve(this);
|
||
}.bind(this), function(err) {
|
||
displayed.reject(err, this);
|
||
});
|
||
} else {
|
||
displayed.resolve(this);
|
||
}
|
||
return displayed.promise;
|
||
}
|
||
show() {
|
||
this.element.style.visibility = "visible";
|
||
if (this.iframe) {
|
||
this.iframe.style.visibility = "visible";
|
||
this.iframe.style.transform = "translateZ(0)";
|
||
this.iframe.offsetWidth;
|
||
this.iframe.style.transform = null;
|
||
}
|
||
this.emit(_constants.EVENTS.VIEWS.SHOWN, this);
|
||
}
|
||
hide() {
|
||
this.element.style.visibility = "hidden";
|
||
this.iframe.style.visibility = "hidden";
|
||
this.stopExpanding = true;
|
||
this.emit(_constants.EVENTS.VIEWS.HIDDEN, this);
|
||
}
|
||
offset() {
|
||
return {
|
||
top: this.element.offsetTop,
|
||
left: this.element.offsetLeft
|
||
};
|
||
}
|
||
width() {
|
||
return this._width;
|
||
}
|
||
height() {
|
||
return this._height;
|
||
}
|
||
position() {
|
||
return this.element.getBoundingClientRect();
|
||
}
|
||
locationOf(target) {
|
||
var parentPos = this.iframe.getBoundingClientRect();
|
||
var targetPos = this.contents.locationOf(target, this.settings.ignoreClass);
|
||
return {
|
||
"left": targetPos.left,
|
||
"top": targetPos.top
|
||
};
|
||
}
|
||
onDisplayed(view) {
|
||
}
|
||
onResize(view, e) {
|
||
}
|
||
bounds(force) {
|
||
if (force || !this.elementBounds) {
|
||
this.elementBounds = (0, _core.bounds)(this.element);
|
||
}
|
||
return this.elementBounds;
|
||
}
|
||
highlight(cfiRange, data = {}, cb, className = "epubjs-hl", styles = {}) {
|
||
if (!this.contents) {
|
||
return;
|
||
}
|
||
const attributes = Object.assign({
|
||
"fill": "yellow",
|
||
"fill-opacity": "0.3",
|
||
"mix-blend-mode": "multiply"
|
||
}, styles);
|
||
let range = this.contents.range(cfiRange);
|
||
let emitter = () => {
|
||
this.emit(_constants.EVENTS.VIEWS.MARK_CLICKED, cfiRange, data);
|
||
};
|
||
data["epubcfi"] = cfiRange;
|
||
if (!this.pane) {
|
||
this.pane = new _marksPane.Pane(this.iframe, this.element);
|
||
}
|
||
let m = new _marksPane.Highlight(range, className, data, attributes);
|
||
let h = this.pane.addMark(m);
|
||
this.highlights[cfiRange] = {
|
||
"mark": h,
|
||
"element": h.element,
|
||
"listeners": [emitter, cb]
|
||
};
|
||
h.element.setAttribute("ref", className);
|
||
h.element.addEventListener("click", emitter);
|
||
h.element.addEventListener("touchstart", emitter);
|
||
if (cb) {
|
||
h.element.addEventListener("click", cb);
|
||
h.element.addEventListener("touchstart", cb);
|
||
}
|
||
return h;
|
||
}
|
||
underline(cfiRange, data = {}, cb, className = "epubjs-ul", styles = {}) {
|
||
if (!this.contents) {
|
||
return;
|
||
}
|
||
const attributes = Object.assign({
|
||
"stroke": "black",
|
||
"stroke-opacity": "0.3",
|
||
"mix-blend-mode": "multiply"
|
||
}, styles);
|
||
let range = this.contents.range(cfiRange);
|
||
let emitter = () => {
|
||
this.emit(_constants.EVENTS.VIEWS.MARK_CLICKED, cfiRange, data);
|
||
};
|
||
data["epubcfi"] = cfiRange;
|
||
if (!this.pane) {
|
||
this.pane = new _marksPane.Pane(this.iframe, this.element);
|
||
}
|
||
let m = new _marksPane.Underline(range, className, data, attributes);
|
||
let h = this.pane.addMark(m);
|
||
this.underlines[cfiRange] = {
|
||
"mark": h,
|
||
"element": h.element,
|
||
"listeners": [emitter, cb]
|
||
};
|
||
h.element.setAttribute("ref", className);
|
||
h.element.addEventListener("click", emitter);
|
||
h.element.addEventListener("touchstart", emitter);
|
||
if (cb) {
|
||
h.element.addEventListener("click", cb);
|
||
h.element.addEventListener("touchstart", cb);
|
||
}
|
||
return h;
|
||
}
|
||
mark(cfiRange, data = {}, cb) {
|
||
if (!this.contents) {
|
||
return;
|
||
}
|
||
if (cfiRange in this.marks) {
|
||
let item = this.marks[cfiRange];
|
||
return item;
|
||
}
|
||
let range = this.contents.range(cfiRange);
|
||
if (!range) {
|
||
return;
|
||
}
|
||
let container = range.commonAncestorContainer;
|
||
let parent2 = container.nodeType === 1 ? container : container.parentNode;
|
||
let emitter = (e) => {
|
||
this.emit(_constants.EVENTS.VIEWS.MARK_CLICKED, cfiRange, data);
|
||
};
|
||
if (range.collapsed && container.nodeType === 1) {
|
||
range = new Range();
|
||
range.selectNodeContents(container);
|
||
} else if (range.collapsed) {
|
||
range = new Range();
|
||
range.selectNodeContents(parent2);
|
||
}
|
||
let mark = this.document.createElement("a");
|
||
mark.setAttribute("ref", "epubjs-mk");
|
||
mark.style.position = "absolute";
|
||
mark.dataset["epubcfi"] = cfiRange;
|
||
if (data) {
|
||
Object.keys(data).forEach((key) => {
|
||
mark.dataset[key] = data[key];
|
||
});
|
||
}
|
||
if (cb) {
|
||
mark.addEventListener("click", cb);
|
||
mark.addEventListener("touchstart", cb);
|
||
}
|
||
mark.addEventListener("click", emitter);
|
||
mark.addEventListener("touchstart", emitter);
|
||
this.placeMark(mark, range);
|
||
this.element.appendChild(mark);
|
||
this.marks[cfiRange] = {
|
||
"element": mark,
|
||
"range": range,
|
||
"listeners": [emitter, cb]
|
||
};
|
||
return parent2;
|
||
}
|
||
placeMark(element, range) {
|
||
let top, right, left;
|
||
if (this.layout.name === "pre-paginated" || this.settings.axis !== "horizontal") {
|
||
let pos = range.getBoundingClientRect();
|
||
top = pos.top;
|
||
right = pos.right;
|
||
} else {
|
||
let rects = range.getClientRects();
|
||
let rect;
|
||
for (var i = 0; i != rects.length; i++) {
|
||
rect = rects[i];
|
||
if (!left || rect.left < left) {
|
||
left = rect.left;
|
||
right = Math.ceil(left / this.layout.props.pageWidth) * this.layout.props.pageWidth - this.layout.gap / 2;
|
||
top = rect.top;
|
||
}
|
||
}
|
||
}
|
||
element.style.top = `${top}px`;
|
||
element.style.left = `${right}px`;
|
||
}
|
||
unhighlight(cfiRange) {
|
||
let item;
|
||
if (cfiRange in this.highlights) {
|
||
item = this.highlights[cfiRange];
|
||
this.pane.removeMark(item.mark);
|
||
item.listeners.forEach((l) => {
|
||
if (l) {
|
||
item.element.removeEventListener("click", l);
|
||
item.element.removeEventListener("touchstart", l);
|
||
}
|
||
;
|
||
});
|
||
delete this.highlights[cfiRange];
|
||
}
|
||
}
|
||
ununderline(cfiRange) {
|
||
let item;
|
||
if (cfiRange in this.underlines) {
|
||
item = this.underlines[cfiRange];
|
||
this.pane.removeMark(item.mark);
|
||
item.listeners.forEach((l) => {
|
||
if (l) {
|
||
item.element.removeEventListener("click", l);
|
||
item.element.removeEventListener("touchstart", l);
|
||
}
|
||
;
|
||
});
|
||
delete this.underlines[cfiRange];
|
||
}
|
||
}
|
||
unmark(cfiRange) {
|
||
let item;
|
||
if (cfiRange in this.marks) {
|
||
item = this.marks[cfiRange];
|
||
this.element.removeChild(item.element);
|
||
item.listeners.forEach((l) => {
|
||
if (l) {
|
||
item.element.removeEventListener("click", l);
|
||
item.element.removeEventListener("touchstart", l);
|
||
}
|
||
;
|
||
});
|
||
delete this.marks[cfiRange];
|
||
}
|
||
}
|
||
destroy() {
|
||
for (let cfiRange in this.highlights) {
|
||
this.unhighlight(cfiRange);
|
||
}
|
||
for (let cfiRange in this.underlines) {
|
||
this.ununderline(cfiRange);
|
||
}
|
||
for (let cfiRange in this.marks) {
|
||
this.unmark(cfiRange);
|
||
}
|
||
if (this.blobUrl) {
|
||
(0, _core.revokeBlobUrl)(this.blobUrl);
|
||
}
|
||
if (this.displayed) {
|
||
this.displayed = false;
|
||
this.removeListeners();
|
||
this.contents.destroy();
|
||
this.stopExpanding = true;
|
||
this.element.removeChild(this.iframe);
|
||
if (this.pane) {
|
||
this.pane.element.remove();
|
||
this.pane = void 0;
|
||
}
|
||
this.iframe = void 0;
|
||
this.contents = void 0;
|
||
this._textWidth = null;
|
||
this._textHeight = null;
|
||
this._width = null;
|
||
this._height = null;
|
||
}
|
||
}
|
||
};
|
||
(0, _eventEmitter.default)(IframeView.prototype);
|
||
var _default = IframeView;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/utils/scrolltype.js
|
||
var require_scrolltype = __commonJS({
|
||
"node_modules/epubjs/lib/utils/scrolltype.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.createDefiner = createDefiner;
|
||
exports.default = scrollType;
|
||
function scrollType() {
|
||
var type = "reverse";
|
||
var definer = createDefiner();
|
||
document.body.appendChild(definer);
|
||
if (definer.scrollLeft > 0) {
|
||
type = "default";
|
||
} else {
|
||
if (typeof Element !== "undefined" && Element.prototype.scrollIntoView) {
|
||
definer.children[0].children[1].scrollIntoView();
|
||
if (definer.scrollLeft < 0) {
|
||
type = "negative";
|
||
}
|
||
} else {
|
||
definer.scrollLeft = 1;
|
||
if (definer.scrollLeft === 0) {
|
||
type = "negative";
|
||
}
|
||
}
|
||
}
|
||
document.body.removeChild(definer);
|
||
return type;
|
||
}
|
||
function createDefiner() {
|
||
var definer = document.createElement("div");
|
||
definer.dir = "rtl";
|
||
definer.style.position = "fixed";
|
||
definer.style.width = "1px";
|
||
definer.style.height = "1px";
|
||
definer.style.top = "0px";
|
||
definer.style.left = "0px";
|
||
definer.style.overflow = "hidden";
|
||
var innerDiv = document.createElement("div");
|
||
innerDiv.style.width = "2px";
|
||
var spanA = document.createElement("span");
|
||
spanA.style.width = "1px";
|
||
spanA.style.display = "inline-block";
|
||
var spanB = document.createElement("span");
|
||
spanB.style.width = "1px";
|
||
spanB.style.display = "inline-block";
|
||
innerDiv.appendChild(spanA);
|
||
innerDiv.appendChild(spanB);
|
||
definer.appendChild(innerDiv);
|
||
return definer;
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/isObject.js
|
||
var require_isObject = __commonJS({
|
||
"node_modules/lodash/isObject.js"(exports, module2) {
|
||
function isObject(value) {
|
||
var type = typeof value;
|
||
return value != null && (type == "object" || type == "function");
|
||
}
|
||
module2.exports = isObject;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/_freeGlobal.js
|
||
var require_freeGlobal = __commonJS({
|
||
"node_modules/lodash/_freeGlobal.js"(exports, module2) {
|
||
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
||
module2.exports = freeGlobal;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/_root.js
|
||
var require_root = __commonJS({
|
||
"node_modules/lodash/_root.js"(exports, module2) {
|
||
var freeGlobal = require_freeGlobal();
|
||
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
||
var root = freeGlobal || freeSelf || Function("return this")();
|
||
module2.exports = root;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/now.js
|
||
var require_now = __commonJS({
|
||
"node_modules/lodash/now.js"(exports, module2) {
|
||
var root = require_root();
|
||
var now = function() {
|
||
return root.Date.now();
|
||
};
|
||
module2.exports = now;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/_trimmedEndIndex.js
|
||
var require_trimmedEndIndex = __commonJS({
|
||
"node_modules/lodash/_trimmedEndIndex.js"(exports, module2) {
|
||
var reWhitespace = /\s/;
|
||
function trimmedEndIndex(string) {
|
||
var index = string.length;
|
||
while (index-- && reWhitespace.test(string.charAt(index))) {
|
||
}
|
||
return index;
|
||
}
|
||
module2.exports = trimmedEndIndex;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/_baseTrim.js
|
||
var require_baseTrim = __commonJS({
|
||
"node_modules/lodash/_baseTrim.js"(exports, module2) {
|
||
var trimmedEndIndex = require_trimmedEndIndex();
|
||
var reTrimStart = /^\s+/;
|
||
function baseTrim(string) {
|
||
return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
|
||
}
|
||
module2.exports = baseTrim;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/_Symbol.js
|
||
var require_Symbol = __commonJS({
|
||
"node_modules/lodash/_Symbol.js"(exports, module2) {
|
||
var root = require_root();
|
||
var Symbol2 = root.Symbol;
|
||
module2.exports = Symbol2;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/_getRawTag.js
|
||
var require_getRawTag = __commonJS({
|
||
"node_modules/lodash/_getRawTag.js"(exports, module2) {
|
||
var Symbol2 = require_Symbol();
|
||
var objectProto = Object.prototype;
|
||
var hasOwnProperty2 = objectProto.hasOwnProperty;
|
||
var nativeObjectToString = objectProto.toString;
|
||
var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
|
||
function getRawTag(value) {
|
||
var isOwn = hasOwnProperty2.call(value, symToStringTag), tag = value[symToStringTag];
|
||
try {
|
||
value[symToStringTag] = void 0;
|
||
var unmasked = true;
|
||
} catch (e) {
|
||
}
|
||
var result = nativeObjectToString.call(value);
|
||
if (unmasked) {
|
||
if (isOwn) {
|
||
value[symToStringTag] = tag;
|
||
} else {
|
||
delete value[symToStringTag];
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
module2.exports = getRawTag;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/_objectToString.js
|
||
var require_objectToString = __commonJS({
|
||
"node_modules/lodash/_objectToString.js"(exports, module2) {
|
||
var objectProto = Object.prototype;
|
||
var nativeObjectToString = objectProto.toString;
|
||
function objectToString(value) {
|
||
return nativeObjectToString.call(value);
|
||
}
|
||
module2.exports = objectToString;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/_baseGetTag.js
|
||
var require_baseGetTag = __commonJS({
|
||
"node_modules/lodash/_baseGetTag.js"(exports, module2) {
|
||
var Symbol2 = require_Symbol();
|
||
var getRawTag = require_getRawTag();
|
||
var objectToString = require_objectToString();
|
||
var nullTag = "[object Null]";
|
||
var undefinedTag = "[object Undefined]";
|
||
var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
|
||
function baseGetTag(value) {
|
||
if (value == null) {
|
||
return value === void 0 ? undefinedTag : nullTag;
|
||
}
|
||
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
||
}
|
||
module2.exports = baseGetTag;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/isObjectLike.js
|
||
var require_isObjectLike = __commonJS({
|
||
"node_modules/lodash/isObjectLike.js"(exports, module2) {
|
||
function isObjectLike(value) {
|
||
return value != null && typeof value == "object";
|
||
}
|
||
module2.exports = isObjectLike;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/isSymbol.js
|
||
var require_isSymbol = __commonJS({
|
||
"node_modules/lodash/isSymbol.js"(exports, module2) {
|
||
var baseGetTag = require_baseGetTag();
|
||
var isObjectLike = require_isObjectLike();
|
||
var symbolTag = "[object Symbol]";
|
||
function isSymbol(value) {
|
||
return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
|
||
}
|
||
module2.exports = isSymbol;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/toNumber.js
|
||
var require_toNumber = __commonJS({
|
||
"node_modules/lodash/toNumber.js"(exports, module2) {
|
||
var baseTrim = require_baseTrim();
|
||
var isObject = require_isObject();
|
||
var isSymbol = require_isSymbol();
|
||
var NAN = 0 / 0;
|
||
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
||
var reIsBinary = /^0b[01]+$/i;
|
||
var reIsOctal = /^0o[0-7]+$/i;
|
||
var freeParseInt = parseInt;
|
||
function toNumber(value) {
|
||
if (typeof value == "number") {
|
||
return value;
|
||
}
|
||
if (isSymbol(value)) {
|
||
return NAN;
|
||
}
|
||
if (isObject(value)) {
|
||
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
||
value = isObject(other) ? other + "" : other;
|
||
}
|
||
if (typeof value != "string") {
|
||
return value === 0 ? value : +value;
|
||
}
|
||
value = baseTrim(value);
|
||
var isBinary = reIsBinary.test(value);
|
||
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
||
}
|
||
module2.exports = toNumber;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/debounce.js
|
||
var require_debounce = __commonJS({
|
||
"node_modules/lodash/debounce.js"(exports, module2) {
|
||
var isObject = require_isObject();
|
||
var now = require_now();
|
||
var toNumber = require_toNumber();
|
||
var FUNC_ERROR_TEXT = "Expected a function";
|
||
var nativeMax = Math.max;
|
||
var nativeMin = Math.min;
|
||
function debounce(func, wait, options) {
|
||
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
||
if (typeof func != "function") {
|
||
throw new TypeError(FUNC_ERROR_TEXT);
|
||
}
|
||
wait = toNumber(wait) || 0;
|
||
if (isObject(options)) {
|
||
leading = !!options.leading;
|
||
maxing = "maxWait" in options;
|
||
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
||
trailing = "trailing" in options ? !!options.trailing : trailing;
|
||
}
|
||
function invokeFunc(time) {
|
||
var args = lastArgs, thisArg = lastThis;
|
||
lastArgs = lastThis = void 0;
|
||
lastInvokeTime = time;
|
||
result = func.apply(thisArg, args);
|
||
return result;
|
||
}
|
||
function leadingEdge(time) {
|
||
lastInvokeTime = time;
|
||
timerId = setTimeout(timerExpired, wait);
|
||
return leading ? invokeFunc(time) : result;
|
||
}
|
||
function remainingWait(time) {
|
||
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
|
||
return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
|
||
}
|
||
function shouldInvoke(time) {
|
||
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
|
||
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
||
}
|
||
function timerExpired() {
|
||
var time = now();
|
||
if (shouldInvoke(time)) {
|
||
return trailingEdge(time);
|
||
}
|
||
timerId = setTimeout(timerExpired, remainingWait(time));
|
||
}
|
||
function trailingEdge(time) {
|
||
timerId = void 0;
|
||
if (trailing && lastArgs) {
|
||
return invokeFunc(time);
|
||
}
|
||
lastArgs = lastThis = void 0;
|
||
return result;
|
||
}
|
||
function cancel() {
|
||
if (timerId !== void 0) {
|
||
clearTimeout(timerId);
|
||
}
|
||
lastInvokeTime = 0;
|
||
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
||
}
|
||
function flush() {
|
||
return timerId === void 0 ? result : trailingEdge(now());
|
||
}
|
||
function debounced() {
|
||
var time = now(), isInvoking = shouldInvoke(time);
|
||
lastArgs = arguments;
|
||
lastThis = this;
|
||
lastCallTime = time;
|
||
if (isInvoking) {
|
||
if (timerId === void 0) {
|
||
return leadingEdge(lastCallTime);
|
||
}
|
||
if (maxing) {
|
||
clearTimeout(timerId);
|
||
timerId = setTimeout(timerExpired, wait);
|
||
return invokeFunc(lastCallTime);
|
||
}
|
||
}
|
||
if (timerId === void 0) {
|
||
timerId = setTimeout(timerExpired, wait);
|
||
}
|
||
return result;
|
||
}
|
||
debounced.cancel = cancel;
|
||
debounced.flush = flush;
|
||
return debounced;
|
||
}
|
||
module2.exports = debounce;
|
||
}
|
||
});
|
||
|
||
// node_modules/lodash/throttle.js
|
||
var require_throttle = __commonJS({
|
||
"node_modules/lodash/throttle.js"(exports, module2) {
|
||
var debounce = require_debounce();
|
||
var isObject = require_isObject();
|
||
var FUNC_ERROR_TEXT = "Expected a function";
|
||
function throttle(func, wait, options) {
|
||
var leading = true, trailing = true;
|
||
if (typeof func != "function") {
|
||
throw new TypeError(FUNC_ERROR_TEXT);
|
||
}
|
||
if (isObject(options)) {
|
||
leading = "leading" in options ? !!options.leading : leading;
|
||
trailing = "trailing" in options ? !!options.trailing : trailing;
|
||
}
|
||
return debounce(func, wait, {
|
||
"leading": leading,
|
||
"maxWait": wait,
|
||
"trailing": trailing
|
||
});
|
||
}
|
||
module2.exports = throttle;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/managers/helpers/stage.js
|
||
var require_stage = __commonJS({
|
||
"node_modules/epubjs/lib/managers/helpers/stage.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _core = require_core();
|
||
var _throttle = _interopRequireDefault(require_throttle());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Stage = class {
|
||
constructor(_options) {
|
||
this.settings = _options || {};
|
||
this.id = "epubjs-container-" + (0, _core.uuid)();
|
||
this.container = this.create(this.settings);
|
||
if (this.settings.hidden) {
|
||
this.wrapper = this.wrap(this.container);
|
||
}
|
||
}
|
||
create(options) {
|
||
let height = options.height;
|
||
let width = options.width;
|
||
let overflow = options.overflow || false;
|
||
let axis = options.axis || "vertical";
|
||
let direction = options.direction;
|
||
(0, _core.extend)(this.settings, options);
|
||
if (options.height && (0, _core.isNumber)(options.height)) {
|
||
height = options.height + "px";
|
||
}
|
||
if (options.width && (0, _core.isNumber)(options.width)) {
|
||
width = options.width + "px";
|
||
}
|
||
let container = document.createElement("div");
|
||
container.id = this.id;
|
||
container.classList.add("epub-container");
|
||
container.style.wordSpacing = "0";
|
||
container.style.lineHeight = "0";
|
||
container.style.verticalAlign = "top";
|
||
container.style.position = "relative";
|
||
if (axis === "horizontal") {
|
||
container.style.display = "flex";
|
||
container.style.flexDirection = "row";
|
||
container.style.flexWrap = "nowrap";
|
||
}
|
||
if (width) {
|
||
container.style.width = width;
|
||
}
|
||
if (height) {
|
||
container.style.height = height;
|
||
}
|
||
if (overflow) {
|
||
if (overflow === "scroll" && axis === "vertical") {
|
||
container.style["overflow-y"] = overflow;
|
||
container.style["overflow-x"] = "hidden";
|
||
} else if (overflow === "scroll" && axis === "horizontal") {
|
||
container.style["overflow-y"] = "hidden";
|
||
container.style["overflow-x"] = overflow;
|
||
} else {
|
||
container.style["overflow"] = overflow;
|
||
}
|
||
}
|
||
if (direction) {
|
||
container.dir = direction;
|
||
container.style["direction"] = direction;
|
||
}
|
||
if (direction && this.settings.fullsize) {
|
||
document.body.style["direction"] = direction;
|
||
}
|
||
return container;
|
||
}
|
||
wrap(container) {
|
||
var wrapper = document.createElement("div");
|
||
wrapper.style.visibility = "hidden";
|
||
wrapper.style.overflow = "hidden";
|
||
wrapper.style.width = "0";
|
||
wrapper.style.height = "0";
|
||
wrapper.appendChild(container);
|
||
return wrapper;
|
||
}
|
||
getElement(_element) {
|
||
var element;
|
||
if ((0, _core.isElement)(_element)) {
|
||
element = _element;
|
||
} else if (typeof _element === "string") {
|
||
element = document.getElementById(_element);
|
||
}
|
||
if (!element) {
|
||
throw new Error("Not an Element");
|
||
}
|
||
return element;
|
||
}
|
||
attachTo(what) {
|
||
var element = this.getElement(what);
|
||
var base;
|
||
if (!element) {
|
||
return;
|
||
}
|
||
if (this.settings.hidden) {
|
||
base = this.wrapper;
|
||
} else {
|
||
base = this.container;
|
||
}
|
||
element.appendChild(base);
|
||
this.element = element;
|
||
return element;
|
||
}
|
||
getContainer() {
|
||
return this.container;
|
||
}
|
||
onResize(func) {
|
||
if (!(0, _core.isNumber)(this.settings.width) || !(0, _core.isNumber)(this.settings.height)) {
|
||
this.resizeFunc = (0, _throttle.default)(func, 50);
|
||
window.addEventListener("resize", this.resizeFunc, false);
|
||
}
|
||
}
|
||
onOrientationChange(func) {
|
||
this.orientationChangeFunc = func;
|
||
window.addEventListener("orientationchange", this.orientationChangeFunc, false);
|
||
}
|
||
size(width, height) {
|
||
var bounds;
|
||
let _width = width || this.settings.width;
|
||
let _height = height || this.settings.height;
|
||
if (width === null) {
|
||
bounds = this.element.getBoundingClientRect();
|
||
if (bounds.width) {
|
||
width = Math.floor(bounds.width);
|
||
this.container.style.width = width + "px";
|
||
}
|
||
} else {
|
||
if ((0, _core.isNumber)(width)) {
|
||
this.container.style.width = width + "px";
|
||
} else {
|
||
this.container.style.width = width;
|
||
}
|
||
}
|
||
if (height === null) {
|
||
bounds = bounds || this.element.getBoundingClientRect();
|
||
if (bounds.height) {
|
||
height = bounds.height;
|
||
this.container.style.height = height + "px";
|
||
}
|
||
} else {
|
||
if ((0, _core.isNumber)(height)) {
|
||
this.container.style.height = height + "px";
|
||
} else {
|
||
this.container.style.height = height;
|
||
}
|
||
}
|
||
if (!(0, _core.isNumber)(width)) {
|
||
width = this.container.clientWidth;
|
||
}
|
||
if (!(0, _core.isNumber)(height)) {
|
||
height = this.container.clientHeight;
|
||
}
|
||
this.containerStyles = window.getComputedStyle(this.container);
|
||
this.containerPadding = {
|
||
left: parseFloat(this.containerStyles["padding-left"]) || 0,
|
||
right: parseFloat(this.containerStyles["padding-right"]) || 0,
|
||
top: parseFloat(this.containerStyles["padding-top"]) || 0,
|
||
bottom: parseFloat(this.containerStyles["padding-bottom"]) || 0
|
||
};
|
||
let _windowBounds = (0, _core.windowBounds)();
|
||
let bodyStyles = window.getComputedStyle(document.body);
|
||
let bodyPadding = {
|
||
left: parseFloat(bodyStyles["padding-left"]) || 0,
|
||
right: parseFloat(bodyStyles["padding-right"]) || 0,
|
||
top: parseFloat(bodyStyles["padding-top"]) || 0,
|
||
bottom: parseFloat(bodyStyles["padding-bottom"]) || 0
|
||
};
|
||
if (!_width) {
|
||
width = _windowBounds.width - bodyPadding.left - bodyPadding.right;
|
||
}
|
||
if (this.settings.fullsize && !_height || !_height) {
|
||
height = _windowBounds.height - bodyPadding.top - bodyPadding.bottom;
|
||
}
|
||
return {
|
||
width: width - this.containerPadding.left - this.containerPadding.right,
|
||
height: height - this.containerPadding.top - this.containerPadding.bottom
|
||
};
|
||
}
|
||
bounds() {
|
||
let box;
|
||
if (this.container.style.overflow !== "visible") {
|
||
box = this.container && this.container.getBoundingClientRect();
|
||
}
|
||
if (!box || !box.width || !box.height) {
|
||
return (0, _core.windowBounds)();
|
||
} else {
|
||
return box;
|
||
}
|
||
}
|
||
getSheet() {
|
||
var style = document.createElement("style");
|
||
style.appendChild(document.createTextNode(""));
|
||
document.head.appendChild(style);
|
||
return style.sheet;
|
||
}
|
||
addStyleRules(selector, rulesArray) {
|
||
var scope = "#" + this.id + " ";
|
||
var rules = "";
|
||
if (!this.sheet) {
|
||
this.sheet = this.getSheet();
|
||
}
|
||
rulesArray.forEach(function(set) {
|
||
for (var prop in set) {
|
||
if (set.hasOwnProperty(prop)) {
|
||
rules += prop + ":" + set[prop] + ";";
|
||
}
|
||
}
|
||
});
|
||
this.sheet.insertRule(scope + selector + " {" + rules + "}", 0);
|
||
}
|
||
axis(axis) {
|
||
if (axis === "horizontal") {
|
||
this.container.style.display = "flex";
|
||
this.container.style.flexDirection = "row";
|
||
this.container.style.flexWrap = "nowrap";
|
||
} else {
|
||
this.container.style.display = "block";
|
||
}
|
||
this.settings.axis = axis;
|
||
}
|
||
direction(dir) {
|
||
if (this.container) {
|
||
this.container.dir = dir;
|
||
this.container.style["direction"] = dir;
|
||
}
|
||
if (this.settings.fullsize) {
|
||
document.body.style["direction"] = dir;
|
||
}
|
||
this.settings.dir = dir;
|
||
}
|
||
overflow(overflow) {
|
||
if (this.container) {
|
||
if (overflow === "scroll" && this.settings.axis === "vertical") {
|
||
this.container.style["overflow-y"] = overflow;
|
||
this.container.style["overflow-x"] = "hidden";
|
||
} else if (overflow === "scroll" && this.settings.axis === "horizontal") {
|
||
this.container.style["overflow-y"] = "hidden";
|
||
this.container.style["overflow-x"] = overflow;
|
||
} else {
|
||
this.container.style["overflow"] = overflow;
|
||
}
|
||
}
|
||
this.settings.overflow = overflow;
|
||
}
|
||
destroy() {
|
||
var base;
|
||
if (this.element) {
|
||
if (this.settings.hidden) {
|
||
base = this.wrapper;
|
||
} else {
|
||
base = this.container;
|
||
}
|
||
if (this.element.contains(this.container)) {
|
||
this.element.removeChild(this.container);
|
||
}
|
||
window.removeEventListener("resize", this.resizeFunc);
|
||
window.removeEventListener("orientationChange", this.orientationChangeFunc);
|
||
}
|
||
}
|
||
};
|
||
var _default = Stage;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/managers/helpers/views.js
|
||
var require_views = __commonJS({
|
||
"node_modules/epubjs/lib/managers/helpers/views.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var Views = class {
|
||
constructor(container) {
|
||
this.container = container;
|
||
this._views = [];
|
||
this.length = 0;
|
||
this.hidden = false;
|
||
}
|
||
all() {
|
||
return this._views;
|
||
}
|
||
first() {
|
||
return this._views[0];
|
||
}
|
||
last() {
|
||
return this._views[this._views.length - 1];
|
||
}
|
||
indexOf(view) {
|
||
return this._views.indexOf(view);
|
||
}
|
||
slice() {
|
||
return this._views.slice.apply(this._views, arguments);
|
||
}
|
||
get(i) {
|
||
return this._views[i];
|
||
}
|
||
append(view) {
|
||
this._views.push(view);
|
||
if (this.container) {
|
||
this.container.appendChild(view.element);
|
||
}
|
||
this.length++;
|
||
return view;
|
||
}
|
||
prepend(view) {
|
||
this._views.unshift(view);
|
||
if (this.container) {
|
||
this.container.insertBefore(view.element, this.container.firstChild);
|
||
}
|
||
this.length++;
|
||
return view;
|
||
}
|
||
insert(view, index) {
|
||
this._views.splice(index, 0, view);
|
||
if (this.container) {
|
||
if (index < this.container.children.length) {
|
||
this.container.insertBefore(view.element, this.container.children[index]);
|
||
} else {
|
||
this.container.appendChild(view.element);
|
||
}
|
||
}
|
||
this.length++;
|
||
return view;
|
||
}
|
||
remove(view) {
|
||
var index = this._views.indexOf(view);
|
||
if (index > -1) {
|
||
this._views.splice(index, 1);
|
||
}
|
||
this.destroy(view);
|
||
this.length--;
|
||
}
|
||
destroy(view) {
|
||
if (view.displayed) {
|
||
view.destroy();
|
||
}
|
||
if (this.container) {
|
||
this.container.removeChild(view.element);
|
||
}
|
||
view = null;
|
||
}
|
||
forEach() {
|
||
return this._views.forEach.apply(this._views, arguments);
|
||
}
|
||
clear() {
|
||
var view;
|
||
var len = this.length;
|
||
if (!this.length)
|
||
return;
|
||
for (var i = 0; i < len; i++) {
|
||
view = this._views[i];
|
||
this.destroy(view);
|
||
}
|
||
this._views = [];
|
||
this.length = 0;
|
||
}
|
||
find(section) {
|
||
var view;
|
||
var len = this.length;
|
||
for (var i = 0; i < len; i++) {
|
||
view = this._views[i];
|
||
if (view.displayed && view.section.index == section.index) {
|
||
return view;
|
||
}
|
||
}
|
||
}
|
||
displayed() {
|
||
var displayed = [];
|
||
var view;
|
||
var len = this.length;
|
||
for (var i = 0; i < len; i++) {
|
||
view = this._views[i];
|
||
if (view.displayed) {
|
||
displayed.push(view);
|
||
}
|
||
}
|
||
return displayed;
|
||
}
|
||
show() {
|
||
var view;
|
||
var len = this.length;
|
||
for (var i = 0; i < len; i++) {
|
||
view = this._views[i];
|
||
if (view.displayed) {
|
||
view.show();
|
||
}
|
||
}
|
||
this.hidden = false;
|
||
}
|
||
hide() {
|
||
var view;
|
||
var len = this.length;
|
||
for (var i = 0; i < len; i++) {
|
||
view = this._views[i];
|
||
if (view.displayed) {
|
||
view.hide();
|
||
}
|
||
}
|
||
this.hidden = true;
|
||
}
|
||
};
|
||
var _default = Views;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/managers/default/index.js
|
||
var require_default = __commonJS({
|
||
"node_modules/epubjs/lib/managers/default/index.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _eventEmitter = _interopRequireDefault(require_event_emitter());
|
||
var _core = require_core();
|
||
var _scrolltype = _interopRequireDefault(require_scrolltype());
|
||
var _mapping = _interopRequireDefault(require_mapping());
|
||
var _queue = _interopRequireDefault(require_queue());
|
||
var _stage = _interopRequireDefault(require_stage());
|
||
var _views = _interopRequireDefault(require_views());
|
||
var _constants = require_constants();
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var DefaultViewManager = class {
|
||
constructor(options) {
|
||
this.name = "default";
|
||
this.optsSettings = options.settings;
|
||
this.View = options.view;
|
||
this.request = options.request;
|
||
this.renditionQueue = options.queue;
|
||
this.q = new _queue.default(this);
|
||
this.settings = (0, _core.extend)(this.settings || {}, {
|
||
infinite: true,
|
||
hidden: false,
|
||
width: void 0,
|
||
height: void 0,
|
||
axis: void 0,
|
||
writingMode: void 0,
|
||
flow: "scrolled",
|
||
ignoreClass: "",
|
||
fullsize: void 0,
|
||
allowScriptedContent: false,
|
||
allowPopups: false
|
||
});
|
||
(0, _core.extend)(this.settings, options.settings || {});
|
||
this.viewSettings = {
|
||
ignoreClass: this.settings.ignoreClass,
|
||
axis: this.settings.axis,
|
||
flow: this.settings.flow,
|
||
layout: this.layout,
|
||
method: this.settings.method,
|
||
width: 0,
|
||
height: 0,
|
||
forceEvenPages: true,
|
||
allowScriptedContent: this.settings.allowScriptedContent,
|
||
allowPopups: this.settings.allowPopups
|
||
};
|
||
this.rendered = false;
|
||
}
|
||
render(element, size) {
|
||
let tag = element.tagName;
|
||
if (typeof this.settings.fullsize === "undefined" && tag && (tag.toLowerCase() == "body" || tag.toLowerCase() == "html")) {
|
||
this.settings.fullsize = true;
|
||
}
|
||
if (this.settings.fullsize) {
|
||
this.settings.overflow = "visible";
|
||
this.overflow = this.settings.overflow;
|
||
}
|
||
this.settings.size = size;
|
||
this.settings.rtlScrollType = (0, _scrolltype.default)();
|
||
this.stage = new _stage.default({
|
||
width: size.width,
|
||
height: size.height,
|
||
overflow: this.overflow,
|
||
hidden: this.settings.hidden,
|
||
axis: this.settings.axis,
|
||
fullsize: this.settings.fullsize,
|
||
direction: this.settings.direction
|
||
});
|
||
this.stage.attachTo(element);
|
||
this.container = this.stage.getContainer();
|
||
this.views = new _views.default(this.container);
|
||
this._bounds = this.bounds();
|
||
this._stageSize = this.stage.size();
|
||
this.viewSettings.width = this._stageSize.width;
|
||
this.viewSettings.height = this._stageSize.height;
|
||
this.stage.onResize(this.onResized.bind(this));
|
||
this.stage.onOrientationChange(this.onOrientationChange.bind(this));
|
||
this.addEventListeners();
|
||
if (this.layout) {
|
||
this.updateLayout();
|
||
}
|
||
this.rendered = true;
|
||
}
|
||
addEventListeners() {
|
||
var scroller;
|
||
window.addEventListener("unload", function(e) {
|
||
this.destroy();
|
||
}.bind(this));
|
||
if (!this.settings.fullsize) {
|
||
scroller = this.container;
|
||
} else {
|
||
scroller = window;
|
||
}
|
||
this._onScroll = this.onScroll.bind(this);
|
||
scroller.addEventListener("scroll", this._onScroll);
|
||
}
|
||
removeEventListeners() {
|
||
var scroller;
|
||
if (!this.settings.fullsize) {
|
||
scroller = this.container;
|
||
} else {
|
||
scroller = window;
|
||
}
|
||
scroller.removeEventListener("scroll", this._onScroll);
|
||
this._onScroll = void 0;
|
||
}
|
||
destroy() {
|
||
clearTimeout(this.orientationTimeout);
|
||
clearTimeout(this.resizeTimeout);
|
||
clearTimeout(this.afterScrolled);
|
||
this.clear();
|
||
this.removeEventListeners();
|
||
this.stage.destroy();
|
||
this.rendered = false;
|
||
}
|
||
onOrientationChange(e) {
|
||
let {
|
||
orientation
|
||
} = window;
|
||
if (this.optsSettings.resizeOnOrientationChange) {
|
||
this.resize();
|
||
}
|
||
clearTimeout(this.orientationTimeout);
|
||
this.orientationTimeout = setTimeout(function() {
|
||
this.orientationTimeout = void 0;
|
||
if (this.optsSettings.resizeOnOrientationChange) {
|
||
this.resize();
|
||
}
|
||
this.emit(_constants.EVENTS.MANAGERS.ORIENTATION_CHANGE, orientation);
|
||
}.bind(this), 500);
|
||
}
|
||
onResized(e) {
|
||
this.resize();
|
||
}
|
||
resize(width, height, epubcfi) {
|
||
let stageSize = this.stage.size(width, height);
|
||
this.winBounds = (0, _core.windowBounds)();
|
||
if (this.orientationTimeout && this.winBounds.width === this.winBounds.height) {
|
||
this._stageSize = void 0;
|
||
return;
|
||
}
|
||
if (this._stageSize && this._stageSize.width === stageSize.width && this._stageSize.height === stageSize.height) {
|
||
return;
|
||
}
|
||
this._stageSize = stageSize;
|
||
this._bounds = this.bounds();
|
||
this.clear();
|
||
this.viewSettings.width = this._stageSize.width;
|
||
this.viewSettings.height = this._stageSize.height;
|
||
this.updateLayout();
|
||
this.emit(_constants.EVENTS.MANAGERS.RESIZED, {
|
||
width: this._stageSize.width,
|
||
height: this._stageSize.height
|
||
}, epubcfi);
|
||
}
|
||
createView(section, forceRight) {
|
||
return new this.View(section, (0, _core.extend)(this.viewSettings, {
|
||
forceRight
|
||
}));
|
||
}
|
||
handleNextPrePaginated(forceRight, section, action) {
|
||
let next;
|
||
if (this.layout.name === "pre-paginated" && this.layout.divisor > 1) {
|
||
if (forceRight || section.index === 0) {
|
||
return;
|
||
}
|
||
next = section.next();
|
||
if (next && !next.properties.includes("page-spread-left")) {
|
||
return action.call(this, next);
|
||
}
|
||
}
|
||
}
|
||
display(section, target) {
|
||
var displaying = new _core.defer();
|
||
var displayed = displaying.promise;
|
||
if (target === section.href || (0, _core.isNumber)(target)) {
|
||
target = void 0;
|
||
}
|
||
var visible = this.views.find(section);
|
||
if (visible && section && this.layout.name !== "pre-paginated") {
|
||
let offset = visible.offset();
|
||
if (this.settings.direction === "ltr") {
|
||
this.scrollTo(offset.left, offset.top, true);
|
||
} else {
|
||
let width = visible.width();
|
||
this.scrollTo(offset.left + width, offset.top, true);
|
||
}
|
||
if (target) {
|
||
let offset2 = visible.locationOf(target);
|
||
let width = visible.width();
|
||
this.moveTo(offset2, width);
|
||
}
|
||
displaying.resolve();
|
||
return displayed;
|
||
}
|
||
this.clear();
|
||
let forceRight = false;
|
||
if (this.layout.name === "pre-paginated" && this.layout.divisor === 2 && section.properties.includes("page-spread-right")) {
|
||
forceRight = true;
|
||
}
|
||
this.add(section, forceRight).then(function(view) {
|
||
if (target) {
|
||
let offset = view.locationOf(target);
|
||
let width = view.width();
|
||
this.moveTo(offset, width);
|
||
}
|
||
}.bind(this), (err) => {
|
||
displaying.reject(err);
|
||
}).then(function() {
|
||
return this.handleNextPrePaginated(forceRight, section, this.add);
|
||
}.bind(this)).then(function() {
|
||
this.views.show();
|
||
displaying.resolve();
|
||
}.bind(this));
|
||
return displayed;
|
||
}
|
||
afterDisplayed(view) {
|
||
this.emit(_constants.EVENTS.MANAGERS.ADDED, view);
|
||
}
|
||
afterResized(view) {
|
||
this.emit(_constants.EVENTS.MANAGERS.RESIZE, view.section);
|
||
}
|
||
moveTo(offset, width) {
|
||
var distX = 0, distY = 0;
|
||
if (!this.isPaginated) {
|
||
distY = offset.top;
|
||
} else {
|
||
distX = Math.floor(offset.left / this.layout.delta) * this.layout.delta;
|
||
if (distX + this.layout.delta > this.container.scrollWidth) {
|
||
distX = this.container.scrollWidth - this.layout.delta;
|
||
}
|
||
distY = Math.floor(offset.top / this.layout.delta) * this.layout.delta;
|
||
if (distY + this.layout.delta > this.container.scrollHeight) {
|
||
distY = this.container.scrollHeight - this.layout.delta;
|
||
}
|
||
}
|
||
if (this.settings.direction === "rtl") {
|
||
distX = distX + this.layout.delta;
|
||
distX = distX - width;
|
||
}
|
||
this.scrollTo(distX, distY, true);
|
||
}
|
||
add(section, forceRight) {
|
||
var view = this.createView(section, forceRight);
|
||
this.views.append(view);
|
||
view.onDisplayed = this.afterDisplayed.bind(this);
|
||
view.onResize = this.afterResized.bind(this);
|
||
view.on(_constants.EVENTS.VIEWS.AXIS, (axis) => {
|
||
this.updateAxis(axis);
|
||
});
|
||
view.on(_constants.EVENTS.VIEWS.WRITING_MODE, (mode) => {
|
||
this.updateWritingMode(mode);
|
||
});
|
||
return view.display(this.request);
|
||
}
|
||
append(section, forceRight) {
|
||
var view = this.createView(section, forceRight);
|
||
this.views.append(view);
|
||
view.onDisplayed = this.afterDisplayed.bind(this);
|
||
view.onResize = this.afterResized.bind(this);
|
||
view.on(_constants.EVENTS.VIEWS.AXIS, (axis) => {
|
||
this.updateAxis(axis);
|
||
});
|
||
view.on(_constants.EVENTS.VIEWS.WRITING_MODE, (mode) => {
|
||
this.updateWritingMode(mode);
|
||
});
|
||
return view.display(this.request);
|
||
}
|
||
prepend(section, forceRight) {
|
||
var view = this.createView(section, forceRight);
|
||
view.on(_constants.EVENTS.VIEWS.RESIZED, (bounds) => {
|
||
this.counter(bounds);
|
||
});
|
||
this.views.prepend(view);
|
||
view.onDisplayed = this.afterDisplayed.bind(this);
|
||
view.onResize = this.afterResized.bind(this);
|
||
view.on(_constants.EVENTS.VIEWS.AXIS, (axis) => {
|
||
this.updateAxis(axis);
|
||
});
|
||
view.on(_constants.EVENTS.VIEWS.WRITING_MODE, (mode) => {
|
||
this.updateWritingMode(mode);
|
||
});
|
||
return view.display(this.request);
|
||
}
|
||
counter(bounds) {
|
||
if (this.settings.axis === "vertical") {
|
||
this.scrollBy(0, bounds.heightDelta, true);
|
||
} else {
|
||
this.scrollBy(bounds.widthDelta, 0, true);
|
||
}
|
||
}
|
||
next() {
|
||
var next;
|
||
var left;
|
||
let dir = this.settings.direction;
|
||
if (!this.views.length)
|
||
return;
|
||
if (this.isPaginated && this.settings.axis === "horizontal" && (!dir || dir === "ltr")) {
|
||
this.scrollLeft = this.container.scrollLeft;
|
||
left = this.container.scrollLeft + this.container.offsetWidth + this.layout.delta;
|
||
if (left <= this.container.scrollWidth) {
|
||
this.scrollBy(this.layout.delta, 0, true);
|
||
} else {
|
||
next = this.views.last().section.next();
|
||
}
|
||
} else if (this.isPaginated && this.settings.axis === "horizontal" && dir === "rtl") {
|
||
this.scrollLeft = this.container.scrollLeft;
|
||
if (this.settings.rtlScrollType === "default") {
|
||
left = this.container.scrollLeft;
|
||
if (left > 0) {
|
||
this.scrollBy(this.layout.delta, 0, true);
|
||
} else {
|
||
next = this.views.last().section.next();
|
||
}
|
||
} else {
|
||
left = this.container.scrollLeft + this.layout.delta * -1;
|
||
if (left > this.container.scrollWidth * -1) {
|
||
this.scrollBy(this.layout.delta, 0, true);
|
||
} else {
|
||
next = this.views.last().section.next();
|
||
}
|
||
}
|
||
} else if (this.isPaginated && this.settings.axis === "vertical") {
|
||
this.scrollTop = this.container.scrollTop;
|
||
let top = this.container.scrollTop + this.container.offsetHeight;
|
||
if (top < this.container.scrollHeight) {
|
||
this.scrollBy(0, this.layout.height, true);
|
||
} else {
|
||
next = this.views.last().section.next();
|
||
}
|
||
} else {
|
||
next = this.views.last().section.next();
|
||
}
|
||
if (next) {
|
||
this.clear();
|
||
this.updateLayout();
|
||
let forceRight = false;
|
||
if (this.layout.name === "pre-paginated" && this.layout.divisor === 2 && next.properties.includes("page-spread-right")) {
|
||
forceRight = true;
|
||
}
|
||
return this.append(next, forceRight).then(function() {
|
||
return this.handleNextPrePaginated(forceRight, next, this.append);
|
||
}.bind(this), (err) => {
|
||
return err;
|
||
}).then(function() {
|
||
if (!this.isPaginated && this.settings.axis === "horizontal" && this.settings.direction === "rtl" && this.settings.rtlScrollType === "default") {
|
||
this.scrollTo(this.container.scrollWidth, 0, true);
|
||
}
|
||
this.views.show();
|
||
}.bind(this));
|
||
}
|
||
}
|
||
prev() {
|
||
var prev;
|
||
var left;
|
||
let dir = this.settings.direction;
|
||
if (!this.views.length)
|
||
return;
|
||
if (this.isPaginated && this.settings.axis === "horizontal" && (!dir || dir === "ltr")) {
|
||
this.scrollLeft = this.container.scrollLeft;
|
||
left = this.container.scrollLeft;
|
||
if (left > 0) {
|
||
this.scrollBy(-this.layout.delta, 0, true);
|
||
} else {
|
||
prev = this.views.first().section.prev();
|
||
}
|
||
} else if (this.isPaginated && this.settings.axis === "horizontal" && dir === "rtl") {
|
||
this.scrollLeft = this.container.scrollLeft;
|
||
if (this.settings.rtlScrollType === "default") {
|
||
left = this.container.scrollLeft + this.container.offsetWidth;
|
||
if (left < this.container.scrollWidth) {
|
||
this.scrollBy(-this.layout.delta, 0, true);
|
||
} else {
|
||
prev = this.views.first().section.prev();
|
||
}
|
||
} else {
|
||
left = this.container.scrollLeft;
|
||
if (left < 0) {
|
||
this.scrollBy(-this.layout.delta, 0, true);
|
||
} else {
|
||
prev = this.views.first().section.prev();
|
||
}
|
||
}
|
||
} else if (this.isPaginated && this.settings.axis === "vertical") {
|
||
this.scrollTop = this.container.scrollTop;
|
||
let top = this.container.scrollTop;
|
||
if (top > 0) {
|
||
this.scrollBy(0, -this.layout.height, true);
|
||
} else {
|
||
prev = this.views.first().section.prev();
|
||
}
|
||
} else {
|
||
prev = this.views.first().section.prev();
|
||
}
|
||
if (prev) {
|
||
this.clear();
|
||
this.updateLayout();
|
||
let forceRight = false;
|
||
if (this.layout.name === "pre-paginated" && this.layout.divisor === 2 && typeof prev.prev() !== "object") {
|
||
forceRight = true;
|
||
}
|
||
return this.prepend(prev, forceRight).then(function() {
|
||
var left2;
|
||
if (this.layout.name === "pre-paginated" && this.layout.divisor > 1) {
|
||
left2 = prev.prev();
|
||
if (left2) {
|
||
return this.prepend(left2);
|
||
}
|
||
}
|
||
}.bind(this), (err) => {
|
||
return err;
|
||
}).then(function() {
|
||
if (this.isPaginated && this.settings.axis === "horizontal") {
|
||
if (this.settings.direction === "rtl") {
|
||
if (this.settings.rtlScrollType === "default") {
|
||
this.scrollTo(0, 0, true);
|
||
} else {
|
||
this.scrollTo(this.container.scrollWidth * -1 + this.layout.delta, 0, true);
|
||
}
|
||
} else {
|
||
this.scrollTo(this.container.scrollWidth - this.layout.delta, 0, true);
|
||
}
|
||
}
|
||
this.views.show();
|
||
}.bind(this));
|
||
}
|
||
}
|
||
current() {
|
||
var visible = this.visible();
|
||
if (visible.length) {
|
||
return visible[visible.length - 1];
|
||
}
|
||
return null;
|
||
}
|
||
clear() {
|
||
if (this.views) {
|
||
this.views.hide();
|
||
this.scrollTo(0, 0, true);
|
||
this.views.clear();
|
||
}
|
||
}
|
||
currentLocation() {
|
||
this.updateLayout();
|
||
if (this.isPaginated && this.settings.axis === "horizontal") {
|
||
this.location = this.paginatedLocation();
|
||
} else {
|
||
this.location = this.scrolledLocation();
|
||
}
|
||
return this.location;
|
||
}
|
||
scrolledLocation() {
|
||
let visible = this.visible();
|
||
let container = this.container.getBoundingClientRect();
|
||
let pageHeight = container.height < window.innerHeight ? container.height : window.innerHeight;
|
||
let pageWidth = container.width < window.innerWidth ? container.width : window.innerWidth;
|
||
let vertical = this.settings.axis === "vertical";
|
||
let rtl = this.settings.direction === "rtl";
|
||
let offset = 0;
|
||
let used = 0;
|
||
if (this.settings.fullsize) {
|
||
offset = vertical ? window.scrollY : window.scrollX;
|
||
}
|
||
let sections = visible.map((view) => {
|
||
let {
|
||
index,
|
||
href
|
||
} = view.section;
|
||
let position = view.position();
|
||
let width = view.width();
|
||
let height = view.height();
|
||
let startPos;
|
||
let endPos;
|
||
let stopPos;
|
||
let totalPages;
|
||
if (vertical) {
|
||
startPos = offset + container.top - position.top + used;
|
||
endPos = startPos + pageHeight - used;
|
||
totalPages = this.layout.count(height, pageHeight).pages;
|
||
stopPos = pageHeight;
|
||
} else {
|
||
startPos = offset + container.left - position.left + used;
|
||
endPos = startPos + pageWidth - used;
|
||
totalPages = this.layout.count(width, pageWidth).pages;
|
||
stopPos = pageWidth;
|
||
}
|
||
let currPage = Math.ceil(startPos / stopPos);
|
||
let pages = [];
|
||
let endPage = Math.ceil(endPos / stopPos);
|
||
if (this.settings.direction === "rtl" && !vertical) {
|
||
let tempStartPage = currPage;
|
||
currPage = totalPages - endPage;
|
||
endPage = totalPages - tempStartPage;
|
||
}
|
||
pages = [];
|
||
for (var i = currPage; i <= endPage; i++) {
|
||
let pg = i + 1;
|
||
pages.push(pg);
|
||
}
|
||
let mapping = this.mapping.page(view.contents, view.section.cfiBase, startPos, endPos);
|
||
return {
|
||
index,
|
||
href,
|
||
pages,
|
||
totalPages,
|
||
mapping
|
||
};
|
||
});
|
||
return sections;
|
||
}
|
||
paginatedLocation() {
|
||
let visible = this.visible();
|
||
let container = this.container.getBoundingClientRect();
|
||
let left = 0;
|
||
let used = 0;
|
||
if (this.settings.fullsize) {
|
||
left = window.scrollX;
|
||
}
|
||
let sections = visible.map((view) => {
|
||
let {
|
||
index,
|
||
href
|
||
} = view.section;
|
||
let offset;
|
||
let position = view.position();
|
||
let width = view.width();
|
||
let start;
|
||
let end;
|
||
let pageWidth;
|
||
if (this.settings.direction === "rtl") {
|
||
offset = container.right - left;
|
||
pageWidth = Math.min(Math.abs(offset - position.left), this.layout.width) - used;
|
||
end = position.width - (position.right - offset) - used;
|
||
start = end - pageWidth;
|
||
} else {
|
||
offset = container.left + left;
|
||
pageWidth = Math.min(position.right - offset, this.layout.width) - used;
|
||
start = offset - position.left + used;
|
||
end = start + pageWidth;
|
||
}
|
||
used += pageWidth;
|
||
let mapping = this.mapping.page(view.contents, view.section.cfiBase, start, end);
|
||
let totalPages = this.layout.count(width).pages;
|
||
let startPage = Math.floor(start / this.layout.pageWidth);
|
||
let pages = [];
|
||
let endPage = Math.floor(end / this.layout.pageWidth);
|
||
if (startPage < 0) {
|
||
startPage = 0;
|
||
endPage = endPage + 1;
|
||
}
|
||
if (this.settings.direction === "rtl") {
|
||
let tempStartPage = startPage;
|
||
startPage = totalPages - endPage;
|
||
endPage = totalPages - tempStartPage;
|
||
}
|
||
for (var i = startPage + 1; i <= endPage; i++) {
|
||
let pg = i;
|
||
pages.push(pg);
|
||
}
|
||
return {
|
||
index,
|
||
href,
|
||
pages,
|
||
totalPages,
|
||
mapping
|
||
};
|
||
});
|
||
return sections;
|
||
}
|
||
isVisible(view, offsetPrev, offsetNext, _container) {
|
||
var position = view.position();
|
||
var container = _container || this.bounds();
|
||
if (this.settings.axis === "horizontal" && position.right > container.left - offsetPrev && position.left < container.right + offsetNext) {
|
||
return true;
|
||
} else if (this.settings.axis === "vertical" && position.bottom > container.top - offsetPrev && position.top < container.bottom + offsetNext) {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
visible() {
|
||
var container = this.bounds();
|
||
var views = this.views.displayed();
|
||
var viewsLength = views.length;
|
||
var visible = [];
|
||
var isVisible;
|
||
var view;
|
||
for (var i = 0; i < viewsLength; i++) {
|
||
view = views[i];
|
||
isVisible = this.isVisible(view, 0, 0, container);
|
||
if (isVisible === true) {
|
||
visible.push(view);
|
||
}
|
||
}
|
||
return visible;
|
||
}
|
||
scrollBy(x, y, silent) {
|
||
let dir = this.settings.direction === "rtl" ? -1 : 1;
|
||
if (silent) {
|
||
this.ignore = true;
|
||
}
|
||
if (!this.settings.fullsize) {
|
||
if (x)
|
||
this.container.scrollLeft += x * dir;
|
||
if (y)
|
||
this.container.scrollTop += y;
|
||
} else {
|
||
window.scrollBy(x * dir, y * dir);
|
||
}
|
||
this.scrolled = true;
|
||
}
|
||
scrollTo(x, y, silent) {
|
||
if (silent) {
|
||
this.ignore = true;
|
||
}
|
||
if (!this.settings.fullsize) {
|
||
this.container.scrollLeft = x;
|
||
this.container.scrollTop = y;
|
||
} else {
|
||
window.scrollTo(x, y);
|
||
}
|
||
this.scrolled = true;
|
||
}
|
||
onScroll() {
|
||
let scrollTop;
|
||
let scrollLeft;
|
||
if (!this.settings.fullsize) {
|
||
scrollTop = this.container.scrollTop;
|
||
scrollLeft = this.container.scrollLeft;
|
||
} else {
|
||
scrollTop = window.scrollY;
|
||
scrollLeft = window.scrollX;
|
||
}
|
||
this.scrollTop = scrollTop;
|
||
this.scrollLeft = scrollLeft;
|
||
if (!this.ignore) {
|
||
this.emit(_constants.EVENTS.MANAGERS.SCROLL, {
|
||
top: scrollTop,
|
||
left: scrollLeft
|
||
});
|
||
clearTimeout(this.afterScrolled);
|
||
this.afterScrolled = setTimeout(function() {
|
||
this.emit(_constants.EVENTS.MANAGERS.SCROLLED, {
|
||
top: this.scrollTop,
|
||
left: this.scrollLeft
|
||
});
|
||
}.bind(this), 20);
|
||
} else {
|
||
this.ignore = false;
|
||
}
|
||
}
|
||
bounds() {
|
||
var bounds;
|
||
bounds = this.stage.bounds();
|
||
return bounds;
|
||
}
|
||
applyLayout(layout) {
|
||
this.layout = layout;
|
||
this.updateLayout();
|
||
if (this.views && this.views.length > 0 && this.layout.name === "pre-paginated") {
|
||
this.display(this.views.first().section);
|
||
}
|
||
}
|
||
updateLayout() {
|
||
if (!this.stage) {
|
||
return;
|
||
}
|
||
this._stageSize = this.stage.size();
|
||
if (!this.isPaginated) {
|
||
this.layout.calculate(this._stageSize.width, this._stageSize.height);
|
||
} else {
|
||
this.layout.calculate(this._stageSize.width, this._stageSize.height, this.settings.gap);
|
||
this.settings.offset = this.layout.delta / this.layout.divisor;
|
||
}
|
||
this.viewSettings.width = this.layout.width;
|
||
this.viewSettings.height = this.layout.height;
|
||
this.setLayout(this.layout);
|
||
}
|
||
setLayout(layout) {
|
||
this.viewSettings.layout = layout;
|
||
this.mapping = new _mapping.default(layout.props, this.settings.direction, this.settings.axis);
|
||
if (this.views) {
|
||
this.views.forEach(function(view) {
|
||
if (view) {
|
||
view.setLayout(layout);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
updateWritingMode(mode) {
|
||
this.writingMode = mode;
|
||
}
|
||
updateAxis(axis, forceUpdate) {
|
||
if (!forceUpdate && axis === this.settings.axis) {
|
||
return;
|
||
}
|
||
this.settings.axis = axis;
|
||
this.stage && this.stage.axis(axis);
|
||
this.viewSettings.axis = axis;
|
||
if (this.mapping) {
|
||
this.mapping = new _mapping.default(this.layout.props, this.settings.direction, this.settings.axis);
|
||
}
|
||
if (this.layout) {
|
||
if (axis === "vertical") {
|
||
this.layout.spread("none");
|
||
} else {
|
||
this.layout.spread(this.layout.settings.spread);
|
||
}
|
||
}
|
||
}
|
||
updateFlow(flow, defaultScrolledOverflow = "auto") {
|
||
let isPaginated = flow === "paginated" || flow === "auto";
|
||
this.isPaginated = isPaginated;
|
||
if (flow === "scrolled-doc" || flow === "scrolled-continuous" || flow === "scrolled") {
|
||
this.updateAxis("vertical");
|
||
} else {
|
||
this.updateAxis("horizontal");
|
||
}
|
||
this.viewSettings.flow = flow;
|
||
if (!this.settings.overflow) {
|
||
this.overflow = isPaginated ? "hidden" : defaultScrolledOverflow;
|
||
} else {
|
||
this.overflow = this.settings.overflow;
|
||
}
|
||
this.stage && this.stage.overflow(this.overflow);
|
||
this.updateLayout();
|
||
}
|
||
getContents() {
|
||
var contents = [];
|
||
if (!this.views) {
|
||
return contents;
|
||
}
|
||
this.views.forEach(function(view) {
|
||
const viewContents = view && view.contents;
|
||
if (viewContents) {
|
||
contents.push(viewContents);
|
||
}
|
||
});
|
||
return contents;
|
||
}
|
||
direction(dir = "ltr") {
|
||
this.settings.direction = dir;
|
||
this.stage && this.stage.direction(dir);
|
||
this.viewSettings.direction = dir;
|
||
this.updateLayout();
|
||
}
|
||
isRendered() {
|
||
return this.rendered;
|
||
}
|
||
};
|
||
(0, _eventEmitter.default)(DefaultViewManager.prototype);
|
||
var _default = DefaultViewManager;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/managers/helpers/snap.js
|
||
var require_snap = __commonJS({
|
||
"node_modules/epubjs/lib/managers/helpers/snap.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _core = require_core();
|
||
var _constants = require_constants();
|
||
var _eventEmitter = _interopRequireDefault(require_event_emitter());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var PI_D2 = Math.PI / 2;
|
||
var EASING_EQUATIONS = {
|
||
easeOutSine: function(pos) {
|
||
return Math.sin(pos * PI_D2);
|
||
},
|
||
easeInOutSine: function(pos) {
|
||
return -0.5 * (Math.cos(Math.PI * pos) - 1);
|
||
},
|
||
easeInOutQuint: function(pos) {
|
||
if ((pos /= 0.5) < 1) {
|
||
return 0.5 * Math.pow(pos, 5);
|
||
}
|
||
return 0.5 * (Math.pow(pos - 2, 5) + 2);
|
||
},
|
||
easeInCubic: function(pos) {
|
||
return Math.pow(pos, 3);
|
||
}
|
||
};
|
||
var Snap = class {
|
||
constructor(manager, options) {
|
||
this.settings = (0, _core.extend)({
|
||
duration: 80,
|
||
minVelocity: 0.2,
|
||
minDistance: 10,
|
||
easing: EASING_EQUATIONS["easeInCubic"]
|
||
}, options || {});
|
||
this.supportsTouch = this.supportsTouch();
|
||
if (this.supportsTouch) {
|
||
this.setup(manager);
|
||
}
|
||
}
|
||
setup(manager) {
|
||
this.manager = manager;
|
||
this.layout = this.manager.layout;
|
||
this.fullsize = this.manager.settings.fullsize;
|
||
if (this.fullsize) {
|
||
this.element = this.manager.stage.element;
|
||
this.scroller = window;
|
||
this.disableScroll();
|
||
} else {
|
||
this.element = this.manager.stage.container;
|
||
this.scroller = this.element;
|
||
this.element.style["WebkitOverflowScrolling"] = "touch";
|
||
}
|
||
this.manager.settings.offset = this.layout.width;
|
||
this.manager.settings.afterScrolledTimeout = this.settings.duration * 2;
|
||
this.isVertical = this.manager.settings.axis === "vertical";
|
||
if (!this.manager.isPaginated || this.isVertical) {
|
||
return;
|
||
}
|
||
this.touchCanceler = false;
|
||
this.resizeCanceler = false;
|
||
this.snapping = false;
|
||
this.scrollLeft;
|
||
this.scrollTop;
|
||
this.startTouchX = void 0;
|
||
this.startTouchY = void 0;
|
||
this.startTime = void 0;
|
||
this.endTouchX = void 0;
|
||
this.endTouchY = void 0;
|
||
this.endTime = void 0;
|
||
this.addListeners();
|
||
}
|
||
supportsTouch() {
|
||
if ("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch) {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
disableScroll() {
|
||
this.element.style.overflow = "hidden";
|
||
}
|
||
enableScroll() {
|
||
this.element.style.overflow = "";
|
||
}
|
||
addListeners() {
|
||
this._onResize = this.onResize.bind(this);
|
||
window.addEventListener("resize", this._onResize);
|
||
this._onScroll = this.onScroll.bind(this);
|
||
this.scroller.addEventListener("scroll", this._onScroll);
|
||
this._onTouchStart = this.onTouchStart.bind(this);
|
||
this.scroller.addEventListener("touchstart", this._onTouchStart, {
|
||
passive: true
|
||
});
|
||
this.on("touchstart", this._onTouchStart);
|
||
this._onTouchMove = this.onTouchMove.bind(this);
|
||
this.scroller.addEventListener("touchmove", this._onTouchMove, {
|
||
passive: true
|
||
});
|
||
this.on("touchmove", this._onTouchMove);
|
||
this._onTouchEnd = this.onTouchEnd.bind(this);
|
||
this.scroller.addEventListener("touchend", this._onTouchEnd, {
|
||
passive: true
|
||
});
|
||
this.on("touchend", this._onTouchEnd);
|
||
this._afterDisplayed = this.afterDisplayed.bind(this);
|
||
this.manager.on(_constants.EVENTS.MANAGERS.ADDED, this._afterDisplayed);
|
||
}
|
||
removeListeners() {
|
||
window.removeEventListener("resize", this._onResize);
|
||
this._onResize = void 0;
|
||
this.scroller.removeEventListener("scroll", this._onScroll);
|
||
this._onScroll = void 0;
|
||
this.scroller.removeEventListener("touchstart", this._onTouchStart, {
|
||
passive: true
|
||
});
|
||
this.off("touchstart", this._onTouchStart);
|
||
this._onTouchStart = void 0;
|
||
this.scroller.removeEventListener("touchmove", this._onTouchMove, {
|
||
passive: true
|
||
});
|
||
this.off("touchmove", this._onTouchMove);
|
||
this._onTouchMove = void 0;
|
||
this.scroller.removeEventListener("touchend", this._onTouchEnd, {
|
||
passive: true
|
||
});
|
||
this.off("touchend", this._onTouchEnd);
|
||
this._onTouchEnd = void 0;
|
||
this.manager.off(_constants.EVENTS.MANAGERS.ADDED, this._afterDisplayed);
|
||
this._afterDisplayed = void 0;
|
||
}
|
||
afterDisplayed(view) {
|
||
let contents = view.contents;
|
||
["touchstart", "touchmove", "touchend"].forEach((e) => {
|
||
contents.on(e, (ev) => this.triggerViewEvent(ev, contents));
|
||
});
|
||
}
|
||
triggerViewEvent(e, contents) {
|
||
this.emit(e.type, e, contents);
|
||
}
|
||
onScroll(e) {
|
||
this.scrollLeft = this.fullsize ? window.scrollX : this.scroller.scrollLeft;
|
||
this.scrollTop = this.fullsize ? window.scrollY : this.scroller.scrollTop;
|
||
}
|
||
onResize(e) {
|
||
this.resizeCanceler = true;
|
||
}
|
||
onTouchStart(e) {
|
||
let {
|
||
screenX,
|
||
screenY
|
||
} = e.touches[0];
|
||
if (this.fullsize) {
|
||
this.enableScroll();
|
||
}
|
||
this.touchCanceler = true;
|
||
if (!this.startTouchX) {
|
||
this.startTouchX = screenX;
|
||
this.startTouchY = screenY;
|
||
this.startTime = this.now();
|
||
}
|
||
this.endTouchX = screenX;
|
||
this.endTouchY = screenY;
|
||
this.endTime = this.now();
|
||
}
|
||
onTouchMove(e) {
|
||
let {
|
||
screenX,
|
||
screenY
|
||
} = e.touches[0];
|
||
let deltaY = Math.abs(screenY - this.endTouchY);
|
||
this.touchCanceler = true;
|
||
if (!this.fullsize && deltaY < 10) {
|
||
this.element.scrollLeft -= screenX - this.endTouchX;
|
||
}
|
||
this.endTouchX = screenX;
|
||
this.endTouchY = screenY;
|
||
this.endTime = this.now();
|
||
}
|
||
onTouchEnd(e) {
|
||
if (this.fullsize) {
|
||
this.disableScroll();
|
||
}
|
||
this.touchCanceler = false;
|
||
let swipped = this.wasSwiped();
|
||
if (swipped !== 0) {
|
||
this.snap(swipped);
|
||
} else {
|
||
this.snap();
|
||
}
|
||
this.startTouchX = void 0;
|
||
this.startTouchY = void 0;
|
||
this.startTime = void 0;
|
||
this.endTouchX = void 0;
|
||
this.endTouchY = void 0;
|
||
this.endTime = void 0;
|
||
}
|
||
wasSwiped() {
|
||
let snapWidth = this.layout.pageWidth * this.layout.divisor;
|
||
let distance = this.endTouchX - this.startTouchX;
|
||
let absolute = Math.abs(distance);
|
||
let time = this.endTime - this.startTime;
|
||
let velocity = distance / time;
|
||
let minVelocity = this.settings.minVelocity;
|
||
if (absolute <= this.settings.minDistance || absolute >= snapWidth) {
|
||
return 0;
|
||
}
|
||
if (velocity > minVelocity) {
|
||
return -1;
|
||
} else if (velocity < -minVelocity) {
|
||
return 1;
|
||
}
|
||
}
|
||
needsSnap() {
|
||
let left = this.scrollLeft;
|
||
let snapWidth = this.layout.pageWidth * this.layout.divisor;
|
||
return left % snapWidth !== 0;
|
||
}
|
||
snap(howMany = 0) {
|
||
let left = this.scrollLeft;
|
||
let snapWidth = this.layout.pageWidth * this.layout.divisor;
|
||
let snapTo = Math.round(left / snapWidth) * snapWidth;
|
||
if (howMany) {
|
||
snapTo += howMany * snapWidth;
|
||
}
|
||
return this.smoothScrollTo(snapTo);
|
||
}
|
||
smoothScrollTo(destination) {
|
||
const deferred = new _core.defer();
|
||
const start = this.scrollLeft;
|
||
const startTime = this.now();
|
||
const duration = this.settings.duration;
|
||
const easing = this.settings.easing;
|
||
this.snapping = true;
|
||
function tick() {
|
||
const now = this.now();
|
||
const time = Math.min(1, (now - startTime) / duration);
|
||
const timeFunction = easing(time);
|
||
if (this.touchCanceler || this.resizeCanceler) {
|
||
this.resizeCanceler = false;
|
||
this.snapping = false;
|
||
deferred.resolve();
|
||
return;
|
||
}
|
||
if (time < 1) {
|
||
window.requestAnimationFrame(tick.bind(this));
|
||
this.scrollTo(start + (destination - start) * time, 0);
|
||
} else {
|
||
this.scrollTo(destination, 0);
|
||
this.snapping = false;
|
||
deferred.resolve();
|
||
}
|
||
}
|
||
tick.call(this);
|
||
return deferred.promise;
|
||
}
|
||
scrollTo(left = 0, top = 0) {
|
||
if (this.fullsize) {
|
||
window.scroll(left, top);
|
||
} else {
|
||
this.scroller.scrollLeft = left;
|
||
this.scroller.scrollTop = top;
|
||
}
|
||
}
|
||
now() {
|
||
return "now" in window.performance ? performance.now() : new Date().getTime();
|
||
}
|
||
destroy() {
|
||
if (!this.scroller) {
|
||
return;
|
||
}
|
||
if (this.fullsize) {
|
||
this.enableScroll();
|
||
}
|
||
this.removeListeners();
|
||
this.scroller = void 0;
|
||
}
|
||
};
|
||
(0, _eventEmitter.default)(Snap.prototype);
|
||
var _default = Snap;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/managers/continuous/index.js
|
||
var require_continuous = __commonJS({
|
||
"node_modules/epubjs/lib/managers/continuous/index.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _core = require_core();
|
||
var _default2 = _interopRequireDefault(require_default());
|
||
var _snap = _interopRequireDefault(require_snap());
|
||
var _constants = require_constants();
|
||
var _debounce = _interopRequireDefault(require_debounce());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var ContinuousViewManager = class extends _default2.default {
|
||
constructor(options) {
|
||
super(options);
|
||
this.name = "continuous";
|
||
this.settings = (0, _core.extend)(this.settings || {}, {
|
||
infinite: true,
|
||
overflow: void 0,
|
||
axis: void 0,
|
||
writingMode: void 0,
|
||
flow: "scrolled",
|
||
offset: 500,
|
||
offsetDelta: 250,
|
||
width: void 0,
|
||
height: void 0,
|
||
snap: false,
|
||
afterScrolledTimeout: 10,
|
||
allowScriptedContent: false,
|
||
allowPopups: false
|
||
});
|
||
(0, _core.extend)(this.settings, options.settings || {});
|
||
if (options.settings.gap != "undefined" && options.settings.gap === 0) {
|
||
this.settings.gap = options.settings.gap;
|
||
}
|
||
this.viewSettings = {
|
||
ignoreClass: this.settings.ignoreClass,
|
||
axis: this.settings.axis,
|
||
flow: this.settings.flow,
|
||
layout: this.layout,
|
||
width: 0,
|
||
height: 0,
|
||
forceEvenPages: false,
|
||
allowScriptedContent: this.settings.allowScriptedContent,
|
||
allowPopups: this.settings.allowPopups
|
||
};
|
||
this.scrollTop = 0;
|
||
this.scrollLeft = 0;
|
||
}
|
||
display(section, target) {
|
||
return _default2.default.prototype.display.call(this, section, target).then(function() {
|
||
return this.fill();
|
||
}.bind(this));
|
||
}
|
||
fill(_full) {
|
||
var full = _full || new _core.defer();
|
||
this.q.enqueue(() => {
|
||
return this.check();
|
||
}).then((result) => {
|
||
if (result) {
|
||
this.fill(full);
|
||
} else {
|
||
full.resolve();
|
||
}
|
||
});
|
||
return full.promise;
|
||
}
|
||
moveTo(offset) {
|
||
var distX = 0, distY = 0;
|
||
var offsetX = 0, offsetY = 0;
|
||
if (!this.isPaginated) {
|
||
distY = offset.top;
|
||
offsetY = offset.top + this.settings.offsetDelta;
|
||
} else {
|
||
distX = Math.floor(offset.left / this.layout.delta) * this.layout.delta;
|
||
offsetX = distX + this.settings.offsetDelta;
|
||
}
|
||
if (distX > 0 || distY > 0) {
|
||
this.scrollBy(distX, distY, true);
|
||
}
|
||
}
|
||
afterResized(view) {
|
||
this.emit(_constants.EVENTS.MANAGERS.RESIZE, view.section);
|
||
}
|
||
removeShownListeners(view) {
|
||
view.onDisplayed = function() {
|
||
};
|
||
}
|
||
add(section) {
|
||
var view = this.createView(section);
|
||
this.views.append(view);
|
||
view.on(_constants.EVENTS.VIEWS.RESIZED, (bounds) => {
|
||
view.expanded = true;
|
||
});
|
||
view.on(_constants.EVENTS.VIEWS.AXIS, (axis) => {
|
||
this.updateAxis(axis);
|
||
});
|
||
view.on(_constants.EVENTS.VIEWS.WRITING_MODE, (mode) => {
|
||
this.updateWritingMode(mode);
|
||
});
|
||
view.onDisplayed = this.afterDisplayed.bind(this);
|
||
view.onResize = this.afterResized.bind(this);
|
||
return view.display(this.request);
|
||
}
|
||
append(section) {
|
||
var view = this.createView(section);
|
||
view.on(_constants.EVENTS.VIEWS.RESIZED, (bounds) => {
|
||
view.expanded = true;
|
||
});
|
||
view.on(_constants.EVENTS.VIEWS.AXIS, (axis) => {
|
||
this.updateAxis(axis);
|
||
});
|
||
view.on(_constants.EVENTS.VIEWS.WRITING_MODE, (mode) => {
|
||
this.updateWritingMode(mode);
|
||
});
|
||
this.views.append(view);
|
||
view.onDisplayed = this.afterDisplayed.bind(this);
|
||
return view;
|
||
}
|
||
prepend(section) {
|
||
var view = this.createView(section);
|
||
view.on(_constants.EVENTS.VIEWS.RESIZED, (bounds) => {
|
||
this.counter(bounds);
|
||
view.expanded = true;
|
||
});
|
||
view.on(_constants.EVENTS.VIEWS.AXIS, (axis) => {
|
||
this.updateAxis(axis);
|
||
});
|
||
view.on(_constants.EVENTS.VIEWS.WRITING_MODE, (mode) => {
|
||
this.updateWritingMode(mode);
|
||
});
|
||
this.views.prepend(view);
|
||
view.onDisplayed = this.afterDisplayed.bind(this);
|
||
return view;
|
||
}
|
||
counter(bounds) {
|
||
if (this.settings.axis === "vertical") {
|
||
this.scrollBy(0, bounds.heightDelta, true);
|
||
} else {
|
||
this.scrollBy(bounds.widthDelta, 0, true);
|
||
}
|
||
}
|
||
update(_offset) {
|
||
var container = this.bounds();
|
||
var views = this.views.all();
|
||
var viewsLength = views.length;
|
||
var visible = [];
|
||
var offset = typeof _offset != "undefined" ? _offset : this.settings.offset || 0;
|
||
var isVisible;
|
||
var view;
|
||
var updating = new _core.defer();
|
||
var promises = [];
|
||
for (var i = 0; i < viewsLength; i++) {
|
||
view = views[i];
|
||
isVisible = this.isVisible(view, offset, offset, container);
|
||
if (isVisible === true) {
|
||
if (!view.displayed) {
|
||
let displayed = view.display(this.request).then(function(view2) {
|
||
view2.show();
|
||
}, (err) => {
|
||
view.hide();
|
||
});
|
||
promises.push(displayed);
|
||
} else {
|
||
view.show();
|
||
}
|
||
visible.push(view);
|
||
} else {
|
||
this.q.enqueue(view.destroy.bind(view));
|
||
clearTimeout(this.trimTimeout);
|
||
this.trimTimeout = setTimeout(function() {
|
||
this.q.enqueue(this.trim.bind(this));
|
||
}.bind(this), 250);
|
||
}
|
||
}
|
||
if (promises.length) {
|
||
return Promise.all(promises).catch((err) => {
|
||
updating.reject(err);
|
||
});
|
||
} else {
|
||
updating.resolve();
|
||
return updating.promise;
|
||
}
|
||
}
|
||
check(_offsetLeft, _offsetTop) {
|
||
var checking = new _core.defer();
|
||
var newViews = [];
|
||
var horizontal = this.settings.axis === "horizontal";
|
||
var delta = this.settings.offset || 0;
|
||
if (_offsetLeft && horizontal) {
|
||
delta = _offsetLeft;
|
||
}
|
||
if (_offsetTop && !horizontal) {
|
||
delta = _offsetTop;
|
||
}
|
||
var bounds = this._bounds;
|
||
let offset = horizontal ? this.scrollLeft : this.scrollTop;
|
||
let visibleLength = horizontal ? Math.floor(bounds.width) : bounds.height;
|
||
let contentLength = horizontal ? this.container.scrollWidth : this.container.scrollHeight;
|
||
let writingMode = this.writingMode && this.writingMode.indexOf("vertical") === 0 ? "vertical" : "horizontal";
|
||
let rtlScrollType = this.settings.rtlScrollType;
|
||
let rtl = this.settings.direction === "rtl";
|
||
if (!this.settings.fullsize) {
|
||
if (rtl && rtlScrollType === "default" && writingMode === "horizontal") {
|
||
offset = contentLength - visibleLength - offset;
|
||
}
|
||
if (rtl && rtlScrollType === "negative" && writingMode === "horizontal") {
|
||
offset = offset * -1;
|
||
}
|
||
} else {
|
||
if (horizontal && rtl && rtlScrollType === "negative" || !horizontal && rtl && rtlScrollType === "default") {
|
||
offset = offset * -1;
|
||
}
|
||
}
|
||
let prepend = () => {
|
||
let first = this.views.first();
|
||
let prev = first && first.section.prev();
|
||
if (prev) {
|
||
newViews.push(this.prepend(prev));
|
||
}
|
||
};
|
||
let append = () => {
|
||
let last = this.views.last();
|
||
let next = last && last.section.next();
|
||
if (next) {
|
||
newViews.push(this.append(next));
|
||
}
|
||
};
|
||
let end = offset + visibleLength + delta;
|
||
let start = offset - delta;
|
||
if (end >= contentLength) {
|
||
append();
|
||
}
|
||
if (start < 0) {
|
||
prepend();
|
||
}
|
||
let promises = newViews.map((view) => {
|
||
return view.display(this.request);
|
||
});
|
||
if (newViews.length) {
|
||
return Promise.all(promises).then(() => {
|
||
return this.check();
|
||
}).then(() => {
|
||
return this.update(delta);
|
||
}, (err) => {
|
||
return err;
|
||
});
|
||
} else {
|
||
this.q.enqueue(function() {
|
||
this.update();
|
||
}.bind(this));
|
||
checking.resolve(false);
|
||
return checking.promise;
|
||
}
|
||
}
|
||
trim() {
|
||
var task = new _core.defer();
|
||
var displayed = this.views.displayed();
|
||
var first = displayed[0];
|
||
var last = displayed[displayed.length - 1];
|
||
var firstIndex = this.views.indexOf(first);
|
||
var lastIndex = this.views.indexOf(last);
|
||
var above = this.views.slice(0, firstIndex);
|
||
var below = this.views.slice(lastIndex + 1);
|
||
for (var i = 0; i < above.length - 1; i++) {
|
||
this.erase(above[i], above);
|
||
}
|
||
for (var j = 1; j < below.length; j++) {
|
||
this.erase(below[j]);
|
||
}
|
||
task.resolve();
|
||
return task.promise;
|
||
}
|
||
erase(view, above) {
|
||
var prevTop;
|
||
var prevLeft;
|
||
if (!this.settings.fullsize) {
|
||
prevTop = this.container.scrollTop;
|
||
prevLeft = this.container.scrollLeft;
|
||
} else {
|
||
prevTop = window.scrollY;
|
||
prevLeft = window.scrollX;
|
||
}
|
||
var bounds = view.bounds();
|
||
this.views.remove(view);
|
||
if (above) {
|
||
if (this.settings.axis === "vertical") {
|
||
this.scrollTo(0, prevTop - bounds.height, true);
|
||
} else {
|
||
if (this.settings.direction === "rtl") {
|
||
if (!this.settings.fullsize) {
|
||
this.scrollTo(prevLeft, 0, true);
|
||
} else {
|
||
this.scrollTo(prevLeft + Math.floor(bounds.width), 0, true);
|
||
}
|
||
} else {
|
||
this.scrollTo(prevLeft - Math.floor(bounds.width), 0, true);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
addEventListeners(stage) {
|
||
window.addEventListener("unload", function(e) {
|
||
this.ignore = true;
|
||
this.destroy();
|
||
}.bind(this));
|
||
this.addScrollListeners();
|
||
if (this.isPaginated && this.settings.snap) {
|
||
this.snapper = new _snap.default(this, this.settings.snap && typeof this.settings.snap === "object" && this.settings.snap);
|
||
}
|
||
}
|
||
addScrollListeners() {
|
||
var scroller;
|
||
this.tick = _core.requestAnimationFrame;
|
||
let dir = this.settings.direction === "rtl" && this.settings.rtlScrollType === "default" ? -1 : 1;
|
||
this.scrollDeltaVert = 0;
|
||
this.scrollDeltaHorz = 0;
|
||
if (!this.settings.fullsize) {
|
||
scroller = this.container;
|
||
this.scrollTop = this.container.scrollTop;
|
||
this.scrollLeft = this.container.scrollLeft;
|
||
} else {
|
||
scroller = window;
|
||
this.scrollTop = window.scrollY * dir;
|
||
this.scrollLeft = window.scrollX * dir;
|
||
}
|
||
this._onScroll = this.onScroll.bind(this);
|
||
scroller.addEventListener("scroll", this._onScroll);
|
||
this._scrolled = (0, _debounce.default)(this.scrolled.bind(this), 30);
|
||
this.didScroll = false;
|
||
}
|
||
removeEventListeners() {
|
||
var scroller;
|
||
if (!this.settings.fullsize) {
|
||
scroller = this.container;
|
||
} else {
|
||
scroller = window;
|
||
}
|
||
scroller.removeEventListener("scroll", this._onScroll);
|
||
this._onScroll = void 0;
|
||
}
|
||
onScroll() {
|
||
let scrollTop;
|
||
let scrollLeft;
|
||
let dir = this.settings.direction === "rtl" && this.settings.rtlScrollType === "default" ? -1 : 1;
|
||
if (!this.settings.fullsize) {
|
||
scrollTop = this.container.scrollTop;
|
||
scrollLeft = this.container.scrollLeft;
|
||
} else {
|
||
scrollTop = window.scrollY * dir;
|
||
scrollLeft = window.scrollX * dir;
|
||
}
|
||
this.scrollTop = scrollTop;
|
||
this.scrollLeft = scrollLeft;
|
||
if (!this.ignore) {
|
||
this._scrolled();
|
||
} else {
|
||
this.ignore = false;
|
||
}
|
||
this.scrollDeltaVert += Math.abs(scrollTop - this.prevScrollTop);
|
||
this.scrollDeltaHorz += Math.abs(scrollLeft - this.prevScrollLeft);
|
||
this.prevScrollTop = scrollTop;
|
||
this.prevScrollLeft = scrollLeft;
|
||
clearTimeout(this.scrollTimeout);
|
||
this.scrollTimeout = setTimeout(function() {
|
||
this.scrollDeltaVert = 0;
|
||
this.scrollDeltaHorz = 0;
|
||
}.bind(this), 150);
|
||
clearTimeout(this.afterScrolled);
|
||
this.didScroll = false;
|
||
}
|
||
scrolled() {
|
||
this.q.enqueue(function() {
|
||
return this.check();
|
||
}.bind(this));
|
||
this.emit(_constants.EVENTS.MANAGERS.SCROLL, {
|
||
top: this.scrollTop,
|
||
left: this.scrollLeft
|
||
});
|
||
clearTimeout(this.afterScrolled);
|
||
this.afterScrolled = setTimeout(function() {
|
||
if (this.snapper && this.snapper.supportsTouch && this.snapper.needsSnap()) {
|
||
return;
|
||
}
|
||
this.emit(_constants.EVENTS.MANAGERS.SCROLLED, {
|
||
top: this.scrollTop,
|
||
left: this.scrollLeft
|
||
});
|
||
}.bind(this), this.settings.afterScrolledTimeout);
|
||
}
|
||
next() {
|
||
let delta = this.layout.props.name === "pre-paginated" && this.layout.props.spread ? this.layout.props.delta * 2 : this.layout.props.delta;
|
||
if (!this.views.length)
|
||
return;
|
||
if (this.isPaginated && this.settings.axis === "horizontal") {
|
||
this.scrollBy(delta, 0, true);
|
||
} else {
|
||
this.scrollBy(0, this.layout.height, true);
|
||
}
|
||
this.q.enqueue(function() {
|
||
return this.check();
|
||
}.bind(this));
|
||
}
|
||
prev() {
|
||
let delta = this.layout.props.name === "pre-paginated" && this.layout.props.spread ? this.layout.props.delta * 2 : this.layout.props.delta;
|
||
if (!this.views.length)
|
||
return;
|
||
if (this.isPaginated && this.settings.axis === "horizontal") {
|
||
this.scrollBy(-delta, 0, true);
|
||
} else {
|
||
this.scrollBy(0, -this.layout.height, true);
|
||
}
|
||
this.q.enqueue(function() {
|
||
return this.check();
|
||
}.bind(this));
|
||
}
|
||
updateFlow(flow) {
|
||
if (this.rendered && this.snapper) {
|
||
this.snapper.destroy();
|
||
this.snapper = void 0;
|
||
}
|
||
super.updateFlow(flow, "scroll");
|
||
if (this.rendered && this.isPaginated && this.settings.snap) {
|
||
this.snapper = new _snap.default(this, this.settings.snap && typeof this.settings.snap === "object" && this.settings.snap);
|
||
}
|
||
}
|
||
destroy() {
|
||
super.destroy();
|
||
if (this.snapper) {
|
||
this.snapper.destroy();
|
||
}
|
||
}
|
||
};
|
||
var _default = ContinuousViewManager;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/rendition.js
|
||
var require_rendition = __commonJS({
|
||
"node_modules/epubjs/lib/rendition.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _eventEmitter = _interopRequireDefault(require_event_emitter());
|
||
var _core = require_core();
|
||
var _hook = _interopRequireDefault(require_hook());
|
||
var _epubcfi = _interopRequireDefault(require_epubcfi());
|
||
var _queue = _interopRequireDefault(require_queue());
|
||
var _layout = _interopRequireDefault(require_layout());
|
||
var _themes = _interopRequireDefault(require_themes());
|
||
var _contents = _interopRequireDefault(require_contents());
|
||
var _annotations = _interopRequireDefault(require_annotations());
|
||
var _constants = require_constants();
|
||
var _iframe = _interopRequireDefault(require_iframe());
|
||
var _index = _interopRequireDefault(require_default());
|
||
var _index2 = _interopRequireDefault(require_continuous());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Rendition = class {
|
||
constructor(book, options) {
|
||
this.settings = (0, _core.extend)(this.settings || {}, {
|
||
width: null,
|
||
height: null,
|
||
ignoreClass: "",
|
||
manager: "default",
|
||
view: "iframe",
|
||
flow: null,
|
||
layout: null,
|
||
spread: null,
|
||
minSpreadWidth: 800,
|
||
stylesheet: null,
|
||
resizeOnOrientationChange: true,
|
||
script: null,
|
||
snap: false,
|
||
defaultDirection: "ltr",
|
||
allowScriptedContent: false,
|
||
allowPopups: false
|
||
});
|
||
(0, _core.extend)(this.settings, options);
|
||
if (typeof this.settings.manager === "object") {
|
||
this.manager = this.settings.manager;
|
||
}
|
||
this.book = book;
|
||
this.hooks = {};
|
||
this.hooks.display = new _hook.default(this);
|
||
this.hooks.serialize = new _hook.default(this);
|
||
this.hooks.content = new _hook.default(this);
|
||
this.hooks.unloaded = new _hook.default(this);
|
||
this.hooks.layout = new _hook.default(this);
|
||
this.hooks.render = new _hook.default(this);
|
||
this.hooks.show = new _hook.default(this);
|
||
this.hooks.content.register(this.handleLinks.bind(this));
|
||
this.hooks.content.register(this.passEvents.bind(this));
|
||
this.hooks.content.register(this.adjustImages.bind(this));
|
||
this.book.spine.hooks.content.register(this.injectIdentifier.bind(this));
|
||
if (this.settings.stylesheet) {
|
||
this.book.spine.hooks.content.register(this.injectStylesheet.bind(this));
|
||
}
|
||
if (this.settings.script) {
|
||
this.book.spine.hooks.content.register(this.injectScript.bind(this));
|
||
}
|
||
this.themes = new _themes.default(this);
|
||
this.annotations = new _annotations.default(this);
|
||
this.epubcfi = new _epubcfi.default();
|
||
this.q = new _queue.default(this);
|
||
this.location = void 0;
|
||
this.q.enqueue(this.book.opened);
|
||
this.starting = new _core.defer();
|
||
this.started = this.starting.promise;
|
||
this.q.enqueue(this.start);
|
||
}
|
||
setManager(manager) {
|
||
this.manager = manager;
|
||
}
|
||
requireManager(manager) {
|
||
var viewManager;
|
||
if (typeof manager === "string" && manager === "default") {
|
||
viewManager = _index.default;
|
||
} else if (typeof manager === "string" && manager === "continuous") {
|
||
viewManager = _index2.default;
|
||
} else {
|
||
viewManager = manager;
|
||
}
|
||
return viewManager;
|
||
}
|
||
requireView(view) {
|
||
var View;
|
||
if (typeof view == "string" && view === "iframe") {
|
||
View = _iframe.default;
|
||
} else {
|
||
View = view;
|
||
}
|
||
return View;
|
||
}
|
||
start() {
|
||
if (!this.settings.layout && (this.book.package.metadata.layout === "pre-paginated" || this.book.displayOptions.fixedLayout === "true")) {
|
||
this.settings.layout = "pre-paginated";
|
||
}
|
||
switch (this.book.package.metadata.spread) {
|
||
case "none":
|
||
this.settings.spread = "none";
|
||
break;
|
||
case "both":
|
||
this.settings.spread = true;
|
||
break;
|
||
}
|
||
if (!this.manager) {
|
||
this.ViewManager = this.requireManager(this.settings.manager);
|
||
this.View = this.requireView(this.settings.view);
|
||
this.manager = new this.ViewManager({
|
||
view: this.View,
|
||
queue: this.q,
|
||
request: this.book.load.bind(this.book),
|
||
settings: this.settings
|
||
});
|
||
}
|
||
this.direction(this.book.package.metadata.direction || this.settings.defaultDirection);
|
||
this.settings.globalLayoutProperties = this.determineLayoutProperties(this.book.package.metadata);
|
||
this.flow(this.settings.globalLayoutProperties.flow);
|
||
this.layout(this.settings.globalLayoutProperties);
|
||
this.manager.on(_constants.EVENTS.MANAGERS.ADDED, this.afterDisplayed.bind(this));
|
||
this.manager.on(_constants.EVENTS.MANAGERS.REMOVED, this.afterRemoved.bind(this));
|
||
this.manager.on(_constants.EVENTS.MANAGERS.RESIZED, this.onResized.bind(this));
|
||
this.manager.on(_constants.EVENTS.MANAGERS.ORIENTATION_CHANGE, this.onOrientationChange.bind(this));
|
||
this.manager.on(_constants.EVENTS.MANAGERS.SCROLLED, this.reportLocation.bind(this));
|
||
this.emit(_constants.EVENTS.RENDITION.STARTED);
|
||
this.starting.resolve();
|
||
}
|
||
attachTo(element) {
|
||
return this.q.enqueue(function() {
|
||
this.manager.render(element, {
|
||
"width": this.settings.width,
|
||
"height": this.settings.height
|
||
});
|
||
this.emit(_constants.EVENTS.RENDITION.ATTACHED);
|
||
}.bind(this));
|
||
}
|
||
display(target) {
|
||
if (this.displaying) {
|
||
this.displaying.resolve();
|
||
}
|
||
return this.q.enqueue(this._display, target);
|
||
}
|
||
_display(target) {
|
||
if (!this.book) {
|
||
return;
|
||
}
|
||
var isCfiString = this.epubcfi.isCfiString(target);
|
||
var displaying = new _core.defer();
|
||
var displayed = displaying.promise;
|
||
var section;
|
||
var moveTo;
|
||
this.displaying = displaying;
|
||
if (this.book.locations.length() && (0, _core.isFloat)(target)) {
|
||
target = this.book.locations.cfiFromPercentage(parseFloat(target));
|
||
}
|
||
section = this.book.spine.get(target);
|
||
if (!section) {
|
||
displaying.reject(new Error("No Section Found"));
|
||
return displayed;
|
||
}
|
||
this.manager.display(section, target).then(() => {
|
||
displaying.resolve(section);
|
||
this.displaying = void 0;
|
||
this.emit(_constants.EVENTS.RENDITION.DISPLAYED, section);
|
||
this.reportLocation();
|
||
}, (err) => {
|
||
this.emit(_constants.EVENTS.RENDITION.DISPLAY_ERROR, err);
|
||
});
|
||
return displayed;
|
||
}
|
||
afterDisplayed(view) {
|
||
view.on(_constants.EVENTS.VIEWS.MARK_CLICKED, (cfiRange, data) => this.triggerMarkEvent(cfiRange, data, view.contents));
|
||
this.hooks.render.trigger(view, this).then(() => {
|
||
if (view.contents) {
|
||
this.hooks.content.trigger(view.contents, this).then(() => {
|
||
this.emit(_constants.EVENTS.RENDITION.RENDERED, view.section, view);
|
||
});
|
||
} else {
|
||
this.emit(_constants.EVENTS.RENDITION.RENDERED, view.section, view);
|
||
}
|
||
});
|
||
}
|
||
afterRemoved(view) {
|
||
this.hooks.unloaded.trigger(view, this).then(() => {
|
||
this.emit(_constants.EVENTS.RENDITION.REMOVED, view.section, view);
|
||
});
|
||
}
|
||
onResized(size, epubcfi) {
|
||
this.emit(_constants.EVENTS.RENDITION.RESIZED, {
|
||
width: size.width,
|
||
height: size.height
|
||
}, epubcfi);
|
||
if (this.location && this.location.start) {
|
||
this.display(epubcfi || this.location.start.cfi);
|
||
}
|
||
}
|
||
onOrientationChange(orientation) {
|
||
this.emit(_constants.EVENTS.RENDITION.ORIENTATION_CHANGE, orientation);
|
||
}
|
||
moveTo(offset) {
|
||
this.manager.moveTo(offset);
|
||
}
|
||
resize(width, height, epubcfi) {
|
||
if (width) {
|
||
this.settings.width = width;
|
||
}
|
||
if (height) {
|
||
this.settings.height = height;
|
||
}
|
||
this.manager.resize(width, height, epubcfi);
|
||
}
|
||
clear() {
|
||
this.manager.clear();
|
||
}
|
||
next() {
|
||
return this.q.enqueue(this.manager.next.bind(this.manager)).then(this.reportLocation.bind(this));
|
||
}
|
||
prev() {
|
||
return this.q.enqueue(this.manager.prev.bind(this.manager)).then(this.reportLocation.bind(this));
|
||
}
|
||
determineLayoutProperties(metadata) {
|
||
var properties;
|
||
var layout = this.settings.layout || metadata.layout || "reflowable";
|
||
var spread = this.settings.spread || metadata.spread || "auto";
|
||
var orientation = this.settings.orientation || metadata.orientation || "auto";
|
||
var flow = this.settings.flow || metadata.flow || "auto";
|
||
var viewport = metadata.viewport || "";
|
||
var minSpreadWidth = this.settings.minSpreadWidth || metadata.minSpreadWidth || 800;
|
||
var direction = this.settings.direction || metadata.direction || "ltr";
|
||
if ((this.settings.width === 0 || this.settings.width > 0) && (this.settings.height === 0 || this.settings.height > 0)) {
|
||
}
|
||
properties = {
|
||
layout,
|
||
spread,
|
||
orientation,
|
||
flow,
|
||
viewport,
|
||
minSpreadWidth,
|
||
direction
|
||
};
|
||
return properties;
|
||
}
|
||
flow(flow) {
|
||
var _flow = flow;
|
||
if (flow === "scrolled" || flow === "scrolled-doc" || flow === "scrolled-continuous") {
|
||
_flow = "scrolled";
|
||
}
|
||
if (flow === "auto" || flow === "paginated") {
|
||
_flow = "paginated";
|
||
}
|
||
this.settings.flow = flow;
|
||
if (this._layout) {
|
||
this._layout.flow(_flow);
|
||
}
|
||
if (this.manager && this._layout) {
|
||
this.manager.applyLayout(this._layout);
|
||
}
|
||
if (this.manager) {
|
||
this.manager.updateFlow(_flow);
|
||
}
|
||
if (this.manager && this.manager.isRendered() && this.location) {
|
||
this.manager.clear();
|
||
this.display(this.location.start.cfi);
|
||
}
|
||
}
|
||
layout(settings) {
|
||
if (settings) {
|
||
this._layout = new _layout.default(settings);
|
||
this._layout.spread(settings.spread, this.settings.minSpreadWidth);
|
||
this._layout.on(_constants.EVENTS.LAYOUT.UPDATED, (props, changed) => {
|
||
this.emit(_constants.EVENTS.RENDITION.LAYOUT, props, changed);
|
||
});
|
||
}
|
||
if (this.manager && this._layout) {
|
||
this.manager.applyLayout(this._layout);
|
||
}
|
||
return this._layout;
|
||
}
|
||
spread(spread, min) {
|
||
this.settings.spread = spread;
|
||
if (min) {
|
||
this.settings.minSpreadWidth = min;
|
||
}
|
||
if (this._layout) {
|
||
this._layout.spread(spread, min);
|
||
}
|
||
if (this.manager && this.manager.isRendered()) {
|
||
this.manager.updateLayout();
|
||
}
|
||
}
|
||
direction(dir) {
|
||
this.settings.direction = dir || "ltr";
|
||
if (this.manager) {
|
||
this.manager.direction(this.settings.direction);
|
||
}
|
||
if (this.manager && this.manager.isRendered() && this.location) {
|
||
this.manager.clear();
|
||
this.display(this.location.start.cfi);
|
||
}
|
||
}
|
||
reportLocation() {
|
||
return this.q.enqueue(function reportedLocation() {
|
||
requestAnimationFrame(function reportedLocationAfterRAF() {
|
||
var location = this.manager.currentLocation();
|
||
if (location && location.then && typeof location.then === "function") {
|
||
location.then(function(result) {
|
||
let located = this.located(result);
|
||
if (!located || !located.start || !located.end) {
|
||
return;
|
||
}
|
||
this.location = located;
|
||
this.emit(_constants.EVENTS.RENDITION.LOCATION_CHANGED, {
|
||
index: this.location.start.index,
|
||
href: this.location.start.href,
|
||
start: this.location.start.cfi,
|
||
end: this.location.end.cfi,
|
||
percentage: this.location.start.percentage
|
||
});
|
||
this.emit(_constants.EVENTS.RENDITION.RELOCATED, this.location);
|
||
}.bind(this));
|
||
} else if (location) {
|
||
let located = this.located(location);
|
||
if (!located || !located.start || !located.end) {
|
||
return;
|
||
}
|
||
this.location = located;
|
||
this.emit(_constants.EVENTS.RENDITION.LOCATION_CHANGED, {
|
||
index: this.location.start.index,
|
||
href: this.location.start.href,
|
||
start: this.location.start.cfi,
|
||
end: this.location.end.cfi,
|
||
percentage: this.location.start.percentage
|
||
});
|
||
this.emit(_constants.EVENTS.RENDITION.RELOCATED, this.location);
|
||
}
|
||
}.bind(this));
|
||
}.bind(this));
|
||
}
|
||
currentLocation() {
|
||
var location = this.manager.currentLocation();
|
||
if (location && location.then && typeof location.then === "function") {
|
||
location.then(function(result) {
|
||
let located = this.located(result);
|
||
return located;
|
||
}.bind(this));
|
||
} else if (location) {
|
||
let located = this.located(location);
|
||
return located;
|
||
}
|
||
}
|
||
located(location) {
|
||
if (!location.length) {
|
||
return {};
|
||
}
|
||
let start = location[0];
|
||
let end = location[location.length - 1];
|
||
let located = {
|
||
start: {
|
||
index: start.index,
|
||
href: start.href,
|
||
cfi: start.mapping.start,
|
||
displayed: {
|
||
page: start.pages[0] || 1,
|
||
total: start.totalPages
|
||
}
|
||
},
|
||
end: {
|
||
index: end.index,
|
||
href: end.href,
|
||
cfi: end.mapping.end,
|
||
displayed: {
|
||
page: end.pages[end.pages.length - 1] || 1,
|
||
total: end.totalPages
|
||
}
|
||
}
|
||
};
|
||
let locationStart = this.book.locations.locationFromCfi(start.mapping.start);
|
||
let locationEnd = this.book.locations.locationFromCfi(end.mapping.end);
|
||
if (locationStart != null) {
|
||
located.start.location = locationStart;
|
||
located.start.percentage = this.book.locations.percentageFromLocation(locationStart);
|
||
}
|
||
if (locationEnd != null) {
|
||
located.end.location = locationEnd;
|
||
located.end.percentage = this.book.locations.percentageFromLocation(locationEnd);
|
||
}
|
||
let pageStart = this.book.pageList.pageFromCfi(start.mapping.start);
|
||
let pageEnd = this.book.pageList.pageFromCfi(end.mapping.end);
|
||
if (pageStart != -1) {
|
||
located.start.page = pageStart;
|
||
}
|
||
if (pageEnd != -1) {
|
||
located.end.page = pageEnd;
|
||
}
|
||
if (end.index === this.book.spine.last().index && located.end.displayed.page >= located.end.displayed.total) {
|
||
located.atEnd = true;
|
||
}
|
||
if (start.index === this.book.spine.first().index && located.start.displayed.page === 1) {
|
||
located.atStart = true;
|
||
}
|
||
return located;
|
||
}
|
||
destroy() {
|
||
this.manager && this.manager.destroy();
|
||
this.book = void 0;
|
||
}
|
||
passEvents(contents) {
|
||
_constants.DOM_EVENTS.forEach((e) => {
|
||
contents.on(e, (ev) => this.triggerViewEvent(ev, contents));
|
||
});
|
||
contents.on(_constants.EVENTS.CONTENTS.SELECTED, (e) => this.triggerSelectedEvent(e, contents));
|
||
}
|
||
triggerViewEvent(e, contents) {
|
||
this.emit(e.type, e, contents);
|
||
}
|
||
triggerSelectedEvent(cfirange, contents) {
|
||
this.emit(_constants.EVENTS.RENDITION.SELECTED, cfirange, contents);
|
||
}
|
||
triggerMarkEvent(cfiRange, data, contents) {
|
||
this.emit(_constants.EVENTS.RENDITION.MARK_CLICKED, cfiRange, data, contents);
|
||
}
|
||
getRange(cfi, ignoreClass) {
|
||
var _cfi = new _epubcfi.default(cfi);
|
||
var found = this.manager.visible().filter(function(view) {
|
||
if (_cfi.spinePos === view.index)
|
||
return true;
|
||
});
|
||
if (found.length) {
|
||
return found[0].contents.range(_cfi, ignoreClass);
|
||
}
|
||
}
|
||
adjustImages(contents) {
|
||
if (this._layout.name === "pre-paginated") {
|
||
return new Promise(function(resolve) {
|
||
resolve();
|
||
});
|
||
}
|
||
let computed = contents.window.getComputedStyle(contents.content, null);
|
||
let height = (contents.content.offsetHeight - (parseFloat(computed.paddingTop) + parseFloat(computed.paddingBottom))) * 0.95;
|
||
let horizontalPadding = parseFloat(computed.paddingLeft) + parseFloat(computed.paddingRight);
|
||
contents.addStylesheetRules({
|
||
"img": {
|
||
"max-width": (this._layout.columnWidth ? this._layout.columnWidth - horizontalPadding + "px" : "100%") + "!important",
|
||
"max-height": height + "px!important",
|
||
"object-fit": "contain",
|
||
"page-break-inside": "avoid",
|
||
"break-inside": "avoid",
|
||
"box-sizing": "border-box"
|
||
},
|
||
"svg": {
|
||
"max-width": (this._layout.columnWidth ? this._layout.columnWidth - horizontalPadding + "px" : "100%") + "!important",
|
||
"max-height": height + "px!important",
|
||
"page-break-inside": "avoid",
|
||
"break-inside": "avoid"
|
||
}
|
||
});
|
||
return new Promise(function(resolve, reject) {
|
||
setTimeout(function() {
|
||
resolve();
|
||
}, 1);
|
||
});
|
||
}
|
||
getContents() {
|
||
return this.manager ? this.manager.getContents() : [];
|
||
}
|
||
views() {
|
||
let views = this.manager ? this.manager.views : void 0;
|
||
return views || [];
|
||
}
|
||
handleLinks(contents) {
|
||
if (contents) {
|
||
contents.on(_constants.EVENTS.CONTENTS.LINK_CLICKED, (href) => {
|
||
let relative = this.book.path.relative(href);
|
||
this.display(relative);
|
||
});
|
||
}
|
||
}
|
||
injectStylesheet(doc, section) {
|
||
let style = doc.createElement("link");
|
||
style.setAttribute("type", "text/css");
|
||
style.setAttribute("rel", "stylesheet");
|
||
style.setAttribute("href", this.settings.stylesheet);
|
||
doc.getElementsByTagName("head")[0].appendChild(style);
|
||
}
|
||
injectScript(doc, section) {
|
||
let script = doc.createElement("script");
|
||
script.setAttribute("type", "text/javascript");
|
||
script.setAttribute("src", this.settings.script);
|
||
script.textContent = " ";
|
||
doc.getElementsByTagName("head")[0].appendChild(script);
|
||
}
|
||
injectIdentifier(doc, section) {
|
||
let ident = this.book.packaging.metadata.identifier;
|
||
let meta = doc.createElement("meta");
|
||
meta.setAttribute("name", "dc.relation.ispartof");
|
||
if (ident) {
|
||
meta.setAttribute("content", ident);
|
||
}
|
||
doc.getElementsByTagName("head")[0].appendChild(meta);
|
||
}
|
||
};
|
||
(0, _eventEmitter.default)(Rendition.prototype);
|
||
var _default = Rendition;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/jszip/dist/jszip.js
|
||
var require_jszip = __commonJS({
|
||
"node_modules/jszip/dist/jszip.js"(exports, module2) {
|
||
(function(f) {
|
||
if (typeof exports === "object" && typeof module2 !== "undefined") {
|
||
module2.exports = f();
|
||
} else if (typeof define === "function" && define.amd) {
|
||
define([], f);
|
||
} else {
|
||
var g;
|
||
if (typeof window !== "undefined") {
|
||
g = window;
|
||
} else if (typeof global !== "undefined") {
|
||
g = global;
|
||
} else if (typeof self !== "undefined") {
|
||
g = self;
|
||
} else {
|
||
g = this;
|
||
}
|
||
g.JSZip = f();
|
||
}
|
||
})(function() {
|
||
var define2, module3, exports2;
|
||
return function e(t, n, r) {
|
||
function s(o2, u) {
|
||
if (!n[o2]) {
|
||
if (!t[o2]) {
|
||
var a = typeof require == "function" && require;
|
||
if (!u && a)
|
||
return a(o2, true);
|
||
if (i)
|
||
return i(o2, true);
|
||
var f = new Error("Cannot find module '" + o2 + "'");
|
||
throw f.code = "MODULE_NOT_FOUND", f;
|
||
}
|
||
var l = n[o2] = { exports: {} };
|
||
t[o2][0].call(l.exports, function(e2) {
|
||
var n2 = t[o2][1][e2];
|
||
return s(n2 ? n2 : e2);
|
||
}, l, l.exports, e, t, n, r);
|
||
}
|
||
return n[o2].exports;
|
||
}
|
||
var i = typeof require == "function" && require;
|
||
for (var o = 0; o < r.length; o++)
|
||
s(r[o]);
|
||
return s;
|
||
}({ 1: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("./utils");
|
||
var support = require2("./support");
|
||
var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||
exports3.encode = function(input) {
|
||
var output = [];
|
||
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
||
var i = 0, len = input.length, remainingBytes = len;
|
||
var isArray = utils.getTypeOf(input) !== "string";
|
||
while (i < input.length) {
|
||
remainingBytes = len - i;
|
||
if (!isArray) {
|
||
chr1 = input.charCodeAt(i++);
|
||
chr2 = i < len ? input.charCodeAt(i++) : 0;
|
||
chr3 = i < len ? input.charCodeAt(i++) : 0;
|
||
} else {
|
||
chr1 = input[i++];
|
||
chr2 = i < len ? input[i++] : 0;
|
||
chr3 = i < len ? input[i++] : 0;
|
||
}
|
||
enc1 = chr1 >> 2;
|
||
enc2 = (chr1 & 3) << 4 | chr2 >> 4;
|
||
enc3 = remainingBytes > 1 ? (chr2 & 15) << 2 | chr3 >> 6 : 64;
|
||
enc4 = remainingBytes > 2 ? chr3 & 63 : 64;
|
||
output.push(_keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4));
|
||
}
|
||
return output.join("");
|
||
};
|
||
exports3.decode = function(input) {
|
||
var chr1, chr2, chr3;
|
||
var enc1, enc2, enc3, enc4;
|
||
var i = 0, resultIndex = 0;
|
||
var dataUrlPrefix = "data:";
|
||
if (input.substr(0, dataUrlPrefix.length) === dataUrlPrefix) {
|
||
throw new Error("Invalid base64 input, it looks like a data url.");
|
||
}
|
||
input = input.replace(/[^A-Za-z0-9+/=]/g, "");
|
||
var totalLength = input.length * 3 / 4;
|
||
if (input.charAt(input.length - 1) === _keyStr.charAt(64)) {
|
||
totalLength--;
|
||
}
|
||
if (input.charAt(input.length - 2) === _keyStr.charAt(64)) {
|
||
totalLength--;
|
||
}
|
||
if (totalLength % 1 !== 0) {
|
||
throw new Error("Invalid base64 input, bad content length.");
|
||
}
|
||
var output;
|
||
if (support.uint8array) {
|
||
output = new Uint8Array(totalLength | 0);
|
||
} else {
|
||
output = new Array(totalLength | 0);
|
||
}
|
||
while (i < input.length) {
|
||
enc1 = _keyStr.indexOf(input.charAt(i++));
|
||
enc2 = _keyStr.indexOf(input.charAt(i++));
|
||
enc3 = _keyStr.indexOf(input.charAt(i++));
|
||
enc4 = _keyStr.indexOf(input.charAt(i++));
|
||
chr1 = enc1 << 2 | enc2 >> 4;
|
||
chr2 = (enc2 & 15) << 4 | enc3 >> 2;
|
||
chr3 = (enc3 & 3) << 6 | enc4;
|
||
output[resultIndex++] = chr1;
|
||
if (enc3 !== 64) {
|
||
output[resultIndex++] = chr2;
|
||
}
|
||
if (enc4 !== 64) {
|
||
output[resultIndex++] = chr3;
|
||
}
|
||
}
|
||
return output;
|
||
};
|
||
}, { "./support": 30, "./utils": 32 }], 2: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var external = require2("./external");
|
||
var DataWorker = require2("./stream/DataWorker");
|
||
var Crc32Probe = require2("./stream/Crc32Probe");
|
||
var DataLengthProbe = require2("./stream/DataLengthProbe");
|
||
function CompressedObject(compressedSize, uncompressedSize, crc32, compression, data) {
|
||
this.compressedSize = compressedSize;
|
||
this.uncompressedSize = uncompressedSize;
|
||
this.crc32 = crc32;
|
||
this.compression = compression;
|
||
this.compressedContent = data;
|
||
}
|
||
CompressedObject.prototype = {
|
||
getContentWorker: function() {
|
||
var worker = new DataWorker(external.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new DataLengthProbe("data_length"));
|
||
var that = this;
|
||
worker.on("end", function() {
|
||
if (this.streamInfo["data_length"] !== that.uncompressedSize) {
|
||
throw new Error("Bug : uncompressed data size mismatch");
|
||
}
|
||
});
|
||
return worker;
|
||
},
|
||
getCompressedWorker: function() {
|
||
return new DataWorker(external.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize", this.compressedSize).withStreamInfo("uncompressedSize", this.uncompressedSize).withStreamInfo("crc32", this.crc32).withStreamInfo("compression", this.compression);
|
||
}
|
||
};
|
||
CompressedObject.createWorkerFrom = function(uncompressedWorker, compression, compressionOptions) {
|
||
return uncompressedWorker.pipe(new Crc32Probe()).pipe(new DataLengthProbe("uncompressedSize")).pipe(compression.compressWorker(compressionOptions)).pipe(new DataLengthProbe("compressedSize")).withStreamInfo("compression", compression);
|
||
};
|
||
module4.exports = CompressedObject;
|
||
}, { "./external": 6, "./stream/Crc32Probe": 25, "./stream/DataLengthProbe": 26, "./stream/DataWorker": 27 }], 3: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var GenericWorker = require2("./stream/GenericWorker");
|
||
exports3.STORE = {
|
||
magic: "\0\0",
|
||
compressWorker: function() {
|
||
return new GenericWorker("STORE compression");
|
||
},
|
||
uncompressWorker: function() {
|
||
return new GenericWorker("STORE decompression");
|
||
}
|
||
};
|
||
exports3.DEFLATE = require2("./flate");
|
||
}, { "./flate": 7, "./stream/GenericWorker": 28 }], 4: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("./utils");
|
||
function makeTable() {
|
||
var c, table = [];
|
||
for (var n = 0; n < 256; n++) {
|
||
c = n;
|
||
for (var k = 0; k < 8; k++) {
|
||
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
||
}
|
||
table[n] = c;
|
||
}
|
||
return table;
|
||
}
|
||
var crcTable = makeTable();
|
||
function crc32(crc, buf, len, pos) {
|
||
var t = crcTable, end = pos + len;
|
||
crc = crc ^ -1;
|
||
for (var i = pos; i < end; i++) {
|
||
crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];
|
||
}
|
||
return crc ^ -1;
|
||
}
|
||
function crc32str(crc, str, len, pos) {
|
||
var t = crcTable, end = pos + len;
|
||
crc = crc ^ -1;
|
||
for (var i = pos; i < end; i++) {
|
||
crc = crc >>> 8 ^ t[(crc ^ str.charCodeAt(i)) & 255];
|
||
}
|
||
return crc ^ -1;
|
||
}
|
||
module4.exports = function crc32wrapper(input, crc) {
|
||
if (typeof input === "undefined" || !input.length) {
|
||
return 0;
|
||
}
|
||
var isArray = utils.getTypeOf(input) !== "string";
|
||
if (isArray) {
|
||
return crc32(crc | 0, input, input.length, 0);
|
||
} else {
|
||
return crc32str(crc | 0, input, input.length, 0);
|
||
}
|
||
};
|
||
}, { "./utils": 32 }], 5: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
exports3.base64 = false;
|
||
exports3.binary = false;
|
||
exports3.dir = false;
|
||
exports3.createFolders = true;
|
||
exports3.date = null;
|
||
exports3.compression = null;
|
||
exports3.compressionOptions = null;
|
||
exports3.comment = null;
|
||
exports3.unixPermissions = null;
|
||
exports3.dosPermissions = null;
|
||
}, {}], 6: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var ES6Promise = null;
|
||
if (typeof Promise !== "undefined") {
|
||
ES6Promise = Promise;
|
||
} else {
|
||
ES6Promise = require2("lie");
|
||
}
|
||
module4.exports = {
|
||
Promise: ES6Promise
|
||
};
|
||
}, { "lie": 37 }], 7: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var USE_TYPEDARRAY = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Uint32Array !== "undefined";
|
||
var pako = require2("pako");
|
||
var utils = require2("./utils");
|
||
var GenericWorker = require2("./stream/GenericWorker");
|
||
var ARRAY_TYPE = USE_TYPEDARRAY ? "uint8array" : "array";
|
||
exports3.magic = "\b\0";
|
||
function FlateWorker(action, options) {
|
||
GenericWorker.call(this, "FlateWorker/" + action);
|
||
this._pako = null;
|
||
this._pakoAction = action;
|
||
this._pakoOptions = options;
|
||
this.meta = {};
|
||
}
|
||
utils.inherits(FlateWorker, GenericWorker);
|
||
FlateWorker.prototype.processChunk = function(chunk) {
|
||
this.meta = chunk.meta;
|
||
if (this._pako === null) {
|
||
this._createPako();
|
||
}
|
||
this._pako.push(utils.transformTo(ARRAY_TYPE, chunk.data), false);
|
||
};
|
||
FlateWorker.prototype.flush = function() {
|
||
GenericWorker.prototype.flush.call(this);
|
||
if (this._pako === null) {
|
||
this._createPako();
|
||
}
|
||
this._pako.push([], true);
|
||
};
|
||
FlateWorker.prototype.cleanUp = function() {
|
||
GenericWorker.prototype.cleanUp.call(this);
|
||
this._pako = null;
|
||
};
|
||
FlateWorker.prototype._createPako = function() {
|
||
this._pako = new pako[this._pakoAction]({
|
||
raw: true,
|
||
level: this._pakoOptions.level || -1
|
||
});
|
||
var self2 = this;
|
||
this._pako.onData = function(data) {
|
||
self2.push({
|
||
data,
|
||
meta: self2.meta
|
||
});
|
||
};
|
||
};
|
||
exports3.compressWorker = function(compressionOptions) {
|
||
return new FlateWorker("Deflate", compressionOptions);
|
||
};
|
||
exports3.uncompressWorker = function() {
|
||
return new FlateWorker("Inflate", {});
|
||
};
|
||
}, { "./stream/GenericWorker": 28, "./utils": 32, "pako": 38 }], 8: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("../utils");
|
||
var GenericWorker = require2("../stream/GenericWorker");
|
||
var utf8 = require2("../utf8");
|
||
var crc32 = require2("../crc32");
|
||
var signature = require2("../signature");
|
||
var decToHex = function(dec, bytes) {
|
||
var hex = "", i;
|
||
for (i = 0; i < bytes; i++) {
|
||
hex += String.fromCharCode(dec & 255);
|
||
dec = dec >>> 8;
|
||
}
|
||
return hex;
|
||
};
|
||
var generateUnixExternalFileAttr = function(unixPermissions, isDir) {
|
||
var result = unixPermissions;
|
||
if (!unixPermissions) {
|
||
result = isDir ? 16893 : 33204;
|
||
}
|
||
return (result & 65535) << 16;
|
||
};
|
||
var generateDosExternalFileAttr = function(dosPermissions) {
|
||
return (dosPermissions || 0) & 63;
|
||
};
|
||
var generateZipParts = function(streamInfo, streamedContent, streamingEnded, offset, platform, encodeFileName) {
|
||
var file = streamInfo["file"], compression = streamInfo["compression"], useCustomEncoding = encodeFileName !== utf8.utf8encode, encodedFileName = utils.transformTo("string", encodeFileName(file.name)), utfEncodedFileName = utils.transformTo("string", utf8.utf8encode(file.name)), comment = file.comment, encodedComment = utils.transformTo("string", encodeFileName(comment)), utfEncodedComment = utils.transformTo("string", utf8.utf8encode(comment)), useUTF8ForFileName = utfEncodedFileName.length !== file.name.length, useUTF8ForComment = utfEncodedComment.length !== comment.length, dosTime, dosDate, extraFields = "", unicodePathExtraField = "", unicodeCommentExtraField = "", dir = file.dir, date = file.date;
|
||
var dataInfo = {
|
||
crc32: 0,
|
||
compressedSize: 0,
|
||
uncompressedSize: 0
|
||
};
|
||
if (!streamedContent || streamingEnded) {
|
||
dataInfo.crc32 = streamInfo["crc32"];
|
||
dataInfo.compressedSize = streamInfo["compressedSize"];
|
||
dataInfo.uncompressedSize = streamInfo["uncompressedSize"];
|
||
}
|
||
var bitflag = 0;
|
||
if (streamedContent) {
|
||
bitflag |= 8;
|
||
}
|
||
if (!useCustomEncoding && (useUTF8ForFileName || useUTF8ForComment)) {
|
||
bitflag |= 2048;
|
||
}
|
||
var extFileAttr = 0;
|
||
var versionMadeBy = 0;
|
||
if (dir) {
|
||
extFileAttr |= 16;
|
||
}
|
||
if (platform === "UNIX") {
|
||
versionMadeBy = 798;
|
||
extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir);
|
||
} else {
|
||
versionMadeBy = 20;
|
||
extFileAttr |= generateDosExternalFileAttr(file.dosPermissions, dir);
|
||
}
|
||
dosTime = date.getUTCHours();
|
||
dosTime = dosTime << 6;
|
||
dosTime = dosTime | date.getUTCMinutes();
|
||
dosTime = dosTime << 5;
|
||
dosTime = dosTime | date.getUTCSeconds() / 2;
|
||
dosDate = date.getUTCFullYear() - 1980;
|
||
dosDate = dosDate << 4;
|
||
dosDate = dosDate | date.getUTCMonth() + 1;
|
||
dosDate = dosDate << 5;
|
||
dosDate = dosDate | date.getUTCDate();
|
||
if (useUTF8ForFileName) {
|
||
unicodePathExtraField = decToHex(1, 1) + decToHex(crc32(encodedFileName), 4) + utfEncodedFileName;
|
||
extraFields += "up" + decToHex(unicodePathExtraField.length, 2) + unicodePathExtraField;
|
||
}
|
||
if (useUTF8ForComment) {
|
||
unicodeCommentExtraField = decToHex(1, 1) + decToHex(crc32(encodedComment), 4) + utfEncodedComment;
|
||
extraFields += "uc" + decToHex(unicodeCommentExtraField.length, 2) + unicodeCommentExtraField;
|
||
}
|
||
var header = "";
|
||
header += "\n\0";
|
||
header += decToHex(bitflag, 2);
|
||
header += compression.magic;
|
||
header += decToHex(dosTime, 2);
|
||
header += decToHex(dosDate, 2);
|
||
header += decToHex(dataInfo.crc32, 4);
|
||
header += decToHex(dataInfo.compressedSize, 4);
|
||
header += decToHex(dataInfo.uncompressedSize, 4);
|
||
header += decToHex(encodedFileName.length, 2);
|
||
header += decToHex(extraFields.length, 2);
|
||
var fileRecord = signature.LOCAL_FILE_HEADER + header + encodedFileName + extraFields;
|
||
var dirRecord = signature.CENTRAL_FILE_HEADER + decToHex(versionMadeBy, 2) + header + decToHex(encodedComment.length, 2) + "\0\0\0\0" + decToHex(extFileAttr, 4) + decToHex(offset, 4) + encodedFileName + extraFields + encodedComment;
|
||
return {
|
||
fileRecord,
|
||
dirRecord
|
||
};
|
||
};
|
||
var generateCentralDirectoryEnd = function(entriesCount, centralDirLength, localDirLength, comment, encodeFileName) {
|
||
var dirEnd = "";
|
||
var encodedComment = utils.transformTo("string", encodeFileName(comment));
|
||
dirEnd = signature.CENTRAL_DIRECTORY_END + "\0\0\0\0" + decToHex(entriesCount, 2) + decToHex(entriesCount, 2) + decToHex(centralDirLength, 4) + decToHex(localDirLength, 4) + decToHex(encodedComment.length, 2) + encodedComment;
|
||
return dirEnd;
|
||
};
|
||
var generateDataDescriptors = function(streamInfo) {
|
||
var descriptor = "";
|
||
descriptor = signature.DATA_DESCRIPTOR + decToHex(streamInfo["crc32"], 4) + decToHex(streamInfo["compressedSize"], 4) + decToHex(streamInfo["uncompressedSize"], 4);
|
||
return descriptor;
|
||
};
|
||
function ZipFileWorker(streamFiles, comment, platform, encodeFileName) {
|
||
GenericWorker.call(this, "ZipFileWorker");
|
||
this.bytesWritten = 0;
|
||
this.zipComment = comment;
|
||
this.zipPlatform = platform;
|
||
this.encodeFileName = encodeFileName;
|
||
this.streamFiles = streamFiles;
|
||
this.accumulate = false;
|
||
this.contentBuffer = [];
|
||
this.dirRecords = [];
|
||
this.currentSourceOffset = 0;
|
||
this.entriesCount = 0;
|
||
this.currentFile = null;
|
||
this._sources = [];
|
||
}
|
||
utils.inherits(ZipFileWorker, GenericWorker);
|
||
ZipFileWorker.prototype.push = function(chunk) {
|
||
var currentFilePercent = chunk.meta.percent || 0;
|
||
var entriesCount = this.entriesCount;
|
||
var remainingFiles = this._sources.length;
|
||
if (this.accumulate) {
|
||
this.contentBuffer.push(chunk);
|
||
} else {
|
||
this.bytesWritten += chunk.data.length;
|
||
GenericWorker.prototype.push.call(this, {
|
||
data: chunk.data,
|
||
meta: {
|
||
currentFile: this.currentFile,
|
||
percent: entriesCount ? (currentFilePercent + 100 * (entriesCount - remainingFiles - 1)) / entriesCount : 100
|
||
}
|
||
});
|
||
}
|
||
};
|
||
ZipFileWorker.prototype.openedSource = function(streamInfo) {
|
||
this.currentSourceOffset = this.bytesWritten;
|
||
this.currentFile = streamInfo["file"].name;
|
||
var streamedContent = this.streamFiles && !streamInfo["file"].dir;
|
||
if (streamedContent) {
|
||
var record = generateZipParts(streamInfo, streamedContent, false, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
|
||
this.push({
|
||
data: record.fileRecord,
|
||
meta: { percent: 0 }
|
||
});
|
||
} else {
|
||
this.accumulate = true;
|
||
}
|
||
};
|
||
ZipFileWorker.prototype.closedSource = function(streamInfo) {
|
||
this.accumulate = false;
|
||
var streamedContent = this.streamFiles && !streamInfo["file"].dir;
|
||
var record = generateZipParts(streamInfo, streamedContent, true, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
|
||
this.dirRecords.push(record.dirRecord);
|
||
if (streamedContent) {
|
||
this.push({
|
||
data: generateDataDescriptors(streamInfo),
|
||
meta: { percent: 100 }
|
||
});
|
||
} else {
|
||
this.push({
|
||
data: record.fileRecord,
|
||
meta: { percent: 0 }
|
||
});
|
||
while (this.contentBuffer.length) {
|
||
this.push(this.contentBuffer.shift());
|
||
}
|
||
}
|
||
this.currentFile = null;
|
||
};
|
||
ZipFileWorker.prototype.flush = function() {
|
||
var localDirLength = this.bytesWritten;
|
||
for (var i = 0; i < this.dirRecords.length; i++) {
|
||
this.push({
|
||
data: this.dirRecords[i],
|
||
meta: { percent: 100 }
|
||
});
|
||
}
|
||
var centralDirLength = this.bytesWritten - localDirLength;
|
||
var dirEnd = generateCentralDirectoryEnd(this.dirRecords.length, centralDirLength, localDirLength, this.zipComment, this.encodeFileName);
|
||
this.push({
|
||
data: dirEnd,
|
||
meta: { percent: 100 }
|
||
});
|
||
};
|
||
ZipFileWorker.prototype.prepareNextSource = function() {
|
||
this.previous = this._sources.shift();
|
||
this.openedSource(this.previous.streamInfo);
|
||
if (this.isPaused) {
|
||
this.previous.pause();
|
||
} else {
|
||
this.previous.resume();
|
||
}
|
||
};
|
||
ZipFileWorker.prototype.registerPrevious = function(previous) {
|
||
this._sources.push(previous);
|
||
var self2 = this;
|
||
previous.on("data", function(chunk) {
|
||
self2.processChunk(chunk);
|
||
});
|
||
previous.on("end", function() {
|
||
self2.closedSource(self2.previous.streamInfo);
|
||
if (self2._sources.length) {
|
||
self2.prepareNextSource();
|
||
} else {
|
||
self2.end();
|
||
}
|
||
});
|
||
previous.on("error", function(e) {
|
||
self2.error(e);
|
||
});
|
||
return this;
|
||
};
|
||
ZipFileWorker.prototype.resume = function() {
|
||
if (!GenericWorker.prototype.resume.call(this)) {
|
||
return false;
|
||
}
|
||
if (!this.previous && this._sources.length) {
|
||
this.prepareNextSource();
|
||
return true;
|
||
}
|
||
if (!this.previous && !this._sources.length && !this.generatedError) {
|
||
this.end();
|
||
return true;
|
||
}
|
||
};
|
||
ZipFileWorker.prototype.error = function(e) {
|
||
var sources = this._sources;
|
||
if (!GenericWorker.prototype.error.call(this, e)) {
|
||
return false;
|
||
}
|
||
for (var i = 0; i < sources.length; i++) {
|
||
try {
|
||
sources[i].error(e);
|
||
} catch (e2) {
|
||
}
|
||
}
|
||
return true;
|
||
};
|
||
ZipFileWorker.prototype.lock = function() {
|
||
GenericWorker.prototype.lock.call(this);
|
||
var sources = this._sources;
|
||
for (var i = 0; i < sources.length; i++) {
|
||
sources[i].lock();
|
||
}
|
||
};
|
||
module4.exports = ZipFileWorker;
|
||
}, { "../crc32": 4, "../signature": 23, "../stream/GenericWorker": 28, "../utf8": 31, "../utils": 32 }], 9: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var compressions = require2("../compressions");
|
||
var ZipFileWorker = require2("./ZipFileWorker");
|
||
var getCompression = function(fileCompression, zipCompression) {
|
||
var compressionName = fileCompression || zipCompression;
|
||
var compression = compressions[compressionName];
|
||
if (!compression) {
|
||
throw new Error(compressionName + " is not a valid compression method !");
|
||
}
|
||
return compression;
|
||
};
|
||
exports3.generateWorker = function(zip, options, comment) {
|
||
var zipFileWorker = new ZipFileWorker(options.streamFiles, comment, options.platform, options.encodeFileName);
|
||
var entriesCount = 0;
|
||
try {
|
||
zip.forEach(function(relativePath, file) {
|
||
entriesCount++;
|
||
var compression = getCompression(file.options.compression, options.compression);
|
||
var compressionOptions = file.options.compressionOptions || options.compressionOptions || {};
|
||
var dir = file.dir, date = file.date;
|
||
file._compressWorker(compression, compressionOptions).withStreamInfo("file", {
|
||
name: relativePath,
|
||
dir,
|
||
date,
|
||
comment: file.comment || "",
|
||
unixPermissions: file.unixPermissions,
|
||
dosPermissions: file.dosPermissions
|
||
}).pipe(zipFileWorker);
|
||
});
|
||
zipFileWorker.entriesCount = entriesCount;
|
||
} catch (e) {
|
||
zipFileWorker.error(e);
|
||
}
|
||
return zipFileWorker;
|
||
};
|
||
}, { "../compressions": 3, "./ZipFileWorker": 8 }], 10: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
function JSZip() {
|
||
if (!(this instanceof JSZip)) {
|
||
return new JSZip();
|
||
}
|
||
if (arguments.length) {
|
||
throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
|
||
}
|
||
this.files = /* @__PURE__ */ Object.create(null);
|
||
this.comment = null;
|
||
this.root = "";
|
||
this.clone = function() {
|
||
var newObj = new JSZip();
|
||
for (var i in this) {
|
||
if (typeof this[i] !== "function") {
|
||
newObj[i] = this[i];
|
||
}
|
||
}
|
||
return newObj;
|
||
};
|
||
}
|
||
JSZip.prototype = require2("./object");
|
||
JSZip.prototype.loadAsync = require2("./load");
|
||
JSZip.support = require2("./support");
|
||
JSZip.defaults = require2("./defaults");
|
||
JSZip.version = "3.10.1";
|
||
JSZip.loadAsync = function(content, options) {
|
||
return new JSZip().loadAsync(content, options);
|
||
};
|
||
JSZip.external = require2("./external");
|
||
module4.exports = JSZip;
|
||
}, { "./defaults": 5, "./external": 6, "./load": 11, "./object": 15, "./support": 30 }], 11: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("./utils");
|
||
var external = require2("./external");
|
||
var utf8 = require2("./utf8");
|
||
var ZipEntries = require2("./zipEntries");
|
||
var Crc32Probe = require2("./stream/Crc32Probe");
|
||
var nodejsUtils = require2("./nodejsUtils");
|
||
function checkEntryCRC32(zipEntry) {
|
||
return new external.Promise(function(resolve, reject) {
|
||
var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe());
|
||
worker.on("error", function(e) {
|
||
reject(e);
|
||
}).on("end", function() {
|
||
if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) {
|
||
reject(new Error("Corrupted zip : CRC32 mismatch"));
|
||
} else {
|
||
resolve();
|
||
}
|
||
}).resume();
|
||
});
|
||
}
|
||
module4.exports = function(data, options) {
|
||
var zip = this;
|
||
options = utils.extend(options || {}, {
|
||
base64: false,
|
||
checkCRC32: false,
|
||
optimizedBinaryString: false,
|
||
createFolders: false,
|
||
decodeFileName: utf8.utf8decode
|
||
});
|
||
if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {
|
||
return external.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file."));
|
||
}
|
||
return utils.prepareContent("the loaded zip file", data, true, options.optimizedBinaryString, options.base64).then(function(data2) {
|
||
var zipEntries = new ZipEntries(options);
|
||
zipEntries.load(data2);
|
||
return zipEntries;
|
||
}).then(function checkCRC32(zipEntries) {
|
||
var promises = [external.Promise.resolve(zipEntries)];
|
||
var files = zipEntries.files;
|
||
if (options.checkCRC32) {
|
||
for (var i = 0; i < files.length; i++) {
|
||
promises.push(checkEntryCRC32(files[i]));
|
||
}
|
||
}
|
||
return external.Promise.all(promises);
|
||
}).then(function addFiles(results) {
|
||
var zipEntries = results.shift();
|
||
var files = zipEntries.files;
|
||
for (var i = 0; i < files.length; i++) {
|
||
var input = files[i];
|
||
var unsafeName = input.fileNameStr;
|
||
var safeName = utils.resolve(input.fileNameStr);
|
||
zip.file(safeName, input.decompressed, {
|
||
binary: true,
|
||
optimizedBinaryString: true,
|
||
date: input.date,
|
||
dir: input.dir,
|
||
comment: input.fileCommentStr.length ? input.fileCommentStr : null,
|
||
unixPermissions: input.unixPermissions,
|
||
dosPermissions: input.dosPermissions,
|
||
createFolders: options.createFolders
|
||
});
|
||
if (!input.dir) {
|
||
zip.file(safeName).unsafeOriginalName = unsafeName;
|
||
}
|
||
}
|
||
if (zipEntries.zipComment.length) {
|
||
zip.comment = zipEntries.zipComment;
|
||
}
|
||
return zip;
|
||
});
|
||
};
|
||
}, { "./external": 6, "./nodejsUtils": 14, "./stream/Crc32Probe": 25, "./utf8": 31, "./utils": 32, "./zipEntries": 33 }], 12: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("../utils");
|
||
var GenericWorker = require2("../stream/GenericWorker");
|
||
function NodejsStreamInputAdapter(filename, stream) {
|
||
GenericWorker.call(this, "Nodejs stream input adapter for " + filename);
|
||
this._upstreamEnded = false;
|
||
this._bindStream(stream);
|
||
}
|
||
utils.inherits(NodejsStreamInputAdapter, GenericWorker);
|
||
NodejsStreamInputAdapter.prototype._bindStream = function(stream) {
|
||
var self2 = this;
|
||
this._stream = stream;
|
||
stream.pause();
|
||
stream.on("data", function(chunk) {
|
||
self2.push({
|
||
data: chunk,
|
||
meta: {
|
||
percent: 0
|
||
}
|
||
});
|
||
}).on("error", function(e) {
|
||
if (self2.isPaused) {
|
||
this.generatedError = e;
|
||
} else {
|
||
self2.error(e);
|
||
}
|
||
}).on("end", function() {
|
||
if (self2.isPaused) {
|
||
self2._upstreamEnded = true;
|
||
} else {
|
||
self2.end();
|
||
}
|
||
});
|
||
};
|
||
NodejsStreamInputAdapter.prototype.pause = function() {
|
||
if (!GenericWorker.prototype.pause.call(this)) {
|
||
return false;
|
||
}
|
||
this._stream.pause();
|
||
return true;
|
||
};
|
||
NodejsStreamInputAdapter.prototype.resume = function() {
|
||
if (!GenericWorker.prototype.resume.call(this)) {
|
||
return false;
|
||
}
|
||
if (this._upstreamEnded) {
|
||
this.end();
|
||
} else {
|
||
this._stream.resume();
|
||
}
|
||
return true;
|
||
};
|
||
module4.exports = NodejsStreamInputAdapter;
|
||
}, { "../stream/GenericWorker": 28, "../utils": 32 }], 13: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var Readable = require2("readable-stream").Readable;
|
||
var utils = require2("../utils");
|
||
utils.inherits(NodejsStreamOutputAdapter, Readable);
|
||
function NodejsStreamOutputAdapter(helper, options, updateCb) {
|
||
Readable.call(this, options);
|
||
this._helper = helper;
|
||
var self2 = this;
|
||
helper.on("data", function(data, meta) {
|
||
if (!self2.push(data)) {
|
||
self2._helper.pause();
|
||
}
|
||
if (updateCb) {
|
||
updateCb(meta);
|
||
}
|
||
}).on("error", function(e) {
|
||
self2.emit("error", e);
|
||
}).on("end", function() {
|
||
self2.push(null);
|
||
});
|
||
}
|
||
NodejsStreamOutputAdapter.prototype._read = function() {
|
||
this._helper.resume();
|
||
};
|
||
module4.exports = NodejsStreamOutputAdapter;
|
||
}, { "../utils": 32, "readable-stream": 16 }], 14: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
module4.exports = {
|
||
isNode: typeof Buffer !== "undefined",
|
||
newBufferFrom: function(data, encoding) {
|
||
if (Buffer.from && Buffer.from !== Uint8Array.from) {
|
||
return Buffer.from(data, encoding);
|
||
} else {
|
||
if (typeof data === "number") {
|
||
throw new Error('The "data" argument must not be a number');
|
||
}
|
||
return new Buffer(data, encoding);
|
||
}
|
||
},
|
||
allocBuffer: function(size) {
|
||
if (Buffer.alloc) {
|
||
return Buffer.alloc(size);
|
||
} else {
|
||
var buf = new Buffer(size);
|
||
buf.fill(0);
|
||
return buf;
|
||
}
|
||
},
|
||
isBuffer: function(b) {
|
||
return Buffer.isBuffer(b);
|
||
},
|
||
isStream: function(obj) {
|
||
return obj && typeof obj.on === "function" && typeof obj.pause === "function" && typeof obj.resume === "function";
|
||
}
|
||
};
|
||
}, {}], 15: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utf8 = require2("./utf8");
|
||
var utils = require2("./utils");
|
||
var GenericWorker = require2("./stream/GenericWorker");
|
||
var StreamHelper = require2("./stream/StreamHelper");
|
||
var defaults = require2("./defaults");
|
||
var CompressedObject = require2("./compressedObject");
|
||
var ZipObject = require2("./zipObject");
|
||
var generate = require2("./generate");
|
||
var nodejsUtils = require2("./nodejsUtils");
|
||
var NodejsStreamInputAdapter = require2("./nodejs/NodejsStreamInputAdapter");
|
||
var fileAdd = function(name, data, originalOptions) {
|
||
var dataType = utils.getTypeOf(data), parent2;
|
||
var o = utils.extend(originalOptions || {}, defaults);
|
||
o.date = o.date || new Date();
|
||
if (o.compression !== null) {
|
||
o.compression = o.compression.toUpperCase();
|
||
}
|
||
if (typeof o.unixPermissions === "string") {
|
||
o.unixPermissions = parseInt(o.unixPermissions, 8);
|
||
}
|
||
if (o.unixPermissions && o.unixPermissions & 16384) {
|
||
o.dir = true;
|
||
}
|
||
if (o.dosPermissions && o.dosPermissions & 16) {
|
||
o.dir = true;
|
||
}
|
||
if (o.dir) {
|
||
name = forceTrailingSlash(name);
|
||
}
|
||
if (o.createFolders && (parent2 = parentFolder(name))) {
|
||
folderAdd.call(this, parent2, true);
|
||
}
|
||
var isUnicodeString = dataType === "string" && o.binary === false && o.base64 === false;
|
||
if (!originalOptions || typeof originalOptions.binary === "undefined") {
|
||
o.binary = !isUnicodeString;
|
||
}
|
||
var isCompressedEmpty = data instanceof CompressedObject && data.uncompressedSize === 0;
|
||
if (isCompressedEmpty || o.dir || !data || data.length === 0) {
|
||
o.base64 = false;
|
||
o.binary = true;
|
||
data = "";
|
||
o.compression = "STORE";
|
||
dataType = "string";
|
||
}
|
||
var zipObjectContent = null;
|
||
if (data instanceof CompressedObject || data instanceof GenericWorker) {
|
||
zipObjectContent = data;
|
||
} else if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {
|
||
zipObjectContent = new NodejsStreamInputAdapter(name, data);
|
||
} else {
|
||
zipObjectContent = utils.prepareContent(name, data, o.binary, o.optimizedBinaryString, o.base64);
|
||
}
|
||
var object = new ZipObject(name, zipObjectContent, o);
|
||
this.files[name] = object;
|
||
};
|
||
var parentFolder = function(path) {
|
||
if (path.slice(-1) === "/") {
|
||
path = path.substring(0, path.length - 1);
|
||
}
|
||
var lastSlash = path.lastIndexOf("/");
|
||
return lastSlash > 0 ? path.substring(0, lastSlash) : "";
|
||
};
|
||
var forceTrailingSlash = function(path) {
|
||
if (path.slice(-1) !== "/") {
|
||
path += "/";
|
||
}
|
||
return path;
|
||
};
|
||
var folderAdd = function(name, createFolders) {
|
||
createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders;
|
||
name = forceTrailingSlash(name);
|
||
if (!this.files[name]) {
|
||
fileAdd.call(this, name, null, {
|
||
dir: true,
|
||
createFolders
|
||
});
|
||
}
|
||
return this.files[name];
|
||
};
|
||
function isRegExp(object) {
|
||
return Object.prototype.toString.call(object) === "[object RegExp]";
|
||
}
|
||
var out = {
|
||
load: function() {
|
||
throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
|
||
},
|
||
forEach: function(cb) {
|
||
var filename, relativePath, file;
|
||
for (filename in this.files) {
|
||
file = this.files[filename];
|
||
relativePath = filename.slice(this.root.length, filename.length);
|
||
if (relativePath && filename.slice(0, this.root.length) === this.root) {
|
||
cb(relativePath, file);
|
||
}
|
||
}
|
||
},
|
||
filter: function(search) {
|
||
var result = [];
|
||
this.forEach(function(relativePath, entry) {
|
||
if (search(relativePath, entry)) {
|
||
result.push(entry);
|
||
}
|
||
});
|
||
return result;
|
||
},
|
||
file: function(name, data, o) {
|
||
if (arguments.length === 1) {
|
||
if (isRegExp(name)) {
|
||
var regexp = name;
|
||
return this.filter(function(relativePath, file) {
|
||
return !file.dir && regexp.test(relativePath);
|
||
});
|
||
} else {
|
||
var obj = this.files[this.root + name];
|
||
if (obj && !obj.dir) {
|
||
return obj;
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
} else {
|
||
name = this.root + name;
|
||
fileAdd.call(this, name, data, o);
|
||
}
|
||
return this;
|
||
},
|
||
folder: function(arg) {
|
||
if (!arg) {
|
||
return this;
|
||
}
|
||
if (isRegExp(arg)) {
|
||
return this.filter(function(relativePath, file) {
|
||
return file.dir && arg.test(relativePath);
|
||
});
|
||
}
|
||
var name = this.root + arg;
|
||
var newFolder = folderAdd.call(this, name);
|
||
var ret = this.clone();
|
||
ret.root = newFolder.name;
|
||
return ret;
|
||
},
|
||
remove: function(name) {
|
||
name = this.root + name;
|
||
var file = this.files[name];
|
||
if (!file) {
|
||
if (name.slice(-1) !== "/") {
|
||
name += "/";
|
||
}
|
||
file = this.files[name];
|
||
}
|
||
if (file && !file.dir) {
|
||
delete this.files[name];
|
||
} else {
|
||
var kids = this.filter(function(relativePath, file2) {
|
||
return file2.name.slice(0, name.length) === name;
|
||
});
|
||
for (var i = 0; i < kids.length; i++) {
|
||
delete this.files[kids[i].name];
|
||
}
|
||
}
|
||
return this;
|
||
},
|
||
generate: function() {
|
||
throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
|
||
},
|
||
generateInternalStream: function(options) {
|
||
var worker, opts = {};
|
||
try {
|
||
opts = utils.extend(options || {}, {
|
||
streamFiles: false,
|
||
compression: "STORE",
|
||
compressionOptions: null,
|
||
type: "",
|
||
platform: "DOS",
|
||
comment: null,
|
||
mimeType: "application/zip",
|
||
encodeFileName: utf8.utf8encode
|
||
});
|
||
opts.type = opts.type.toLowerCase();
|
||
opts.compression = opts.compression.toUpperCase();
|
||
if (opts.type === "binarystring") {
|
||
opts.type = "string";
|
||
}
|
||
if (!opts.type) {
|
||
throw new Error("No output type specified.");
|
||
}
|
||
utils.checkSupport(opts.type);
|
||
if (opts.platform === "darwin" || opts.platform === "freebsd" || opts.platform === "linux" || opts.platform === "sunos") {
|
||
opts.platform = "UNIX";
|
||
}
|
||
if (opts.platform === "win32") {
|
||
opts.platform = "DOS";
|
||
}
|
||
var comment = opts.comment || this.comment || "";
|
||
worker = generate.generateWorker(this, opts, comment);
|
||
} catch (e) {
|
||
worker = new GenericWorker("error");
|
||
worker.error(e);
|
||
}
|
||
return new StreamHelper(worker, opts.type || "string", opts.mimeType);
|
||
},
|
||
generateAsync: function(options, onUpdate) {
|
||
return this.generateInternalStream(options).accumulate(onUpdate);
|
||
},
|
||
generateNodeStream: function(options, onUpdate) {
|
||
options = options || {};
|
||
if (!options.type) {
|
||
options.type = "nodebuffer";
|
||
}
|
||
return this.generateInternalStream(options).toNodejsStream(onUpdate);
|
||
}
|
||
};
|
||
module4.exports = out;
|
||
}, { "./compressedObject": 2, "./defaults": 5, "./generate": 9, "./nodejs/NodejsStreamInputAdapter": 12, "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./stream/StreamHelper": 29, "./utf8": 31, "./utils": 32, "./zipObject": 35 }], 16: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
module4.exports = require2("stream");
|
||
}, { "stream": void 0 }], 17: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var DataReader = require2("./DataReader");
|
||
var utils = require2("../utils");
|
||
function ArrayReader(data) {
|
||
DataReader.call(this, data);
|
||
for (var i = 0; i < this.data.length; i++) {
|
||
data[i] = data[i] & 255;
|
||
}
|
||
}
|
||
utils.inherits(ArrayReader, DataReader);
|
||
ArrayReader.prototype.byteAt = function(i) {
|
||
return this.data[this.zero + i];
|
||
};
|
||
ArrayReader.prototype.lastIndexOfSignature = function(sig) {
|
||
var sig0 = sig.charCodeAt(0), sig1 = sig.charCodeAt(1), sig2 = sig.charCodeAt(2), sig3 = sig.charCodeAt(3);
|
||
for (var i = this.length - 4; i >= 0; --i) {
|
||
if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) {
|
||
return i - this.zero;
|
||
}
|
||
}
|
||
return -1;
|
||
};
|
||
ArrayReader.prototype.readAndCheckSignature = function(sig) {
|
||
var sig0 = sig.charCodeAt(0), sig1 = sig.charCodeAt(1), sig2 = sig.charCodeAt(2), sig3 = sig.charCodeAt(3), data = this.readData(4);
|
||
return sig0 === data[0] && sig1 === data[1] && sig2 === data[2] && sig3 === data[3];
|
||
};
|
||
ArrayReader.prototype.readData = function(size) {
|
||
this.checkOffset(size);
|
||
if (size === 0) {
|
||
return [];
|
||
}
|
||
var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
|
||
this.index += size;
|
||
return result;
|
||
};
|
||
module4.exports = ArrayReader;
|
||
}, { "../utils": 32, "./DataReader": 18 }], 18: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("../utils");
|
||
function DataReader(data) {
|
||
this.data = data;
|
||
this.length = data.length;
|
||
this.index = 0;
|
||
this.zero = 0;
|
||
}
|
||
DataReader.prototype = {
|
||
checkOffset: function(offset) {
|
||
this.checkIndex(this.index + offset);
|
||
},
|
||
checkIndex: function(newIndex) {
|
||
if (this.length < this.zero + newIndex || newIndex < 0) {
|
||
throw new Error("End of data reached (data length = " + this.length + ", asked index = " + newIndex + "). Corrupted zip ?");
|
||
}
|
||
},
|
||
setIndex: function(newIndex) {
|
||
this.checkIndex(newIndex);
|
||
this.index = newIndex;
|
||
},
|
||
skip: function(n) {
|
||
this.setIndex(this.index + n);
|
||
},
|
||
byteAt: function() {
|
||
},
|
||
readInt: function(size) {
|
||
var result = 0, i;
|
||
this.checkOffset(size);
|
||
for (i = this.index + size - 1; i >= this.index; i--) {
|
||
result = (result << 8) + this.byteAt(i);
|
||
}
|
||
this.index += size;
|
||
return result;
|
||
},
|
||
readString: function(size) {
|
||
return utils.transformTo("string", this.readData(size));
|
||
},
|
||
readData: function() {
|
||
},
|
||
lastIndexOfSignature: function() {
|
||
},
|
||
readAndCheckSignature: function() {
|
||
},
|
||
readDate: function() {
|
||
var dostime = this.readInt(4);
|
||
return new Date(Date.UTC((dostime >> 25 & 127) + 1980, (dostime >> 21 & 15) - 1, dostime >> 16 & 31, dostime >> 11 & 31, dostime >> 5 & 63, (dostime & 31) << 1));
|
||
}
|
||
};
|
||
module4.exports = DataReader;
|
||
}, { "../utils": 32 }], 19: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var Uint8ArrayReader = require2("./Uint8ArrayReader");
|
||
var utils = require2("../utils");
|
||
function NodeBufferReader(data) {
|
||
Uint8ArrayReader.call(this, data);
|
||
}
|
||
utils.inherits(NodeBufferReader, Uint8ArrayReader);
|
||
NodeBufferReader.prototype.readData = function(size) {
|
||
this.checkOffset(size);
|
||
var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
|
||
this.index += size;
|
||
return result;
|
||
};
|
||
module4.exports = NodeBufferReader;
|
||
}, { "../utils": 32, "./Uint8ArrayReader": 21 }], 20: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var DataReader = require2("./DataReader");
|
||
var utils = require2("../utils");
|
||
function StringReader(data) {
|
||
DataReader.call(this, data);
|
||
}
|
||
utils.inherits(StringReader, DataReader);
|
||
StringReader.prototype.byteAt = function(i) {
|
||
return this.data.charCodeAt(this.zero + i);
|
||
};
|
||
StringReader.prototype.lastIndexOfSignature = function(sig) {
|
||
return this.data.lastIndexOf(sig) - this.zero;
|
||
};
|
||
StringReader.prototype.readAndCheckSignature = function(sig) {
|
||
var data = this.readData(4);
|
||
return sig === data;
|
||
};
|
||
StringReader.prototype.readData = function(size) {
|
||
this.checkOffset(size);
|
||
var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
|
||
this.index += size;
|
||
return result;
|
||
};
|
||
module4.exports = StringReader;
|
||
}, { "../utils": 32, "./DataReader": 18 }], 21: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var ArrayReader = require2("./ArrayReader");
|
||
var utils = require2("../utils");
|
||
function Uint8ArrayReader(data) {
|
||
ArrayReader.call(this, data);
|
||
}
|
||
utils.inherits(Uint8ArrayReader, ArrayReader);
|
||
Uint8ArrayReader.prototype.readData = function(size) {
|
||
this.checkOffset(size);
|
||
if (size === 0) {
|
||
return new Uint8Array(0);
|
||
}
|
||
var result = this.data.subarray(this.zero + this.index, this.zero + this.index + size);
|
||
this.index += size;
|
||
return result;
|
||
};
|
||
module4.exports = Uint8ArrayReader;
|
||
}, { "../utils": 32, "./ArrayReader": 17 }], 22: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("../utils");
|
||
var support = require2("../support");
|
||
var ArrayReader = require2("./ArrayReader");
|
||
var StringReader = require2("./StringReader");
|
||
var NodeBufferReader = require2("./NodeBufferReader");
|
||
var Uint8ArrayReader = require2("./Uint8ArrayReader");
|
||
module4.exports = function(data) {
|
||
var type = utils.getTypeOf(data);
|
||
utils.checkSupport(type);
|
||
if (type === "string" && !support.uint8array) {
|
||
return new StringReader(data);
|
||
}
|
||
if (type === "nodebuffer") {
|
||
return new NodeBufferReader(data);
|
||
}
|
||
if (support.uint8array) {
|
||
return new Uint8ArrayReader(utils.transformTo("uint8array", data));
|
||
}
|
||
return new ArrayReader(utils.transformTo("array", data));
|
||
};
|
||
}, { "../support": 30, "../utils": 32, "./ArrayReader": 17, "./NodeBufferReader": 19, "./StringReader": 20, "./Uint8ArrayReader": 21 }], 23: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
exports3.LOCAL_FILE_HEADER = "PK";
|
||
exports3.CENTRAL_FILE_HEADER = "PK";
|
||
exports3.CENTRAL_DIRECTORY_END = "PK";
|
||
exports3.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x07";
|
||
exports3.ZIP64_CENTRAL_DIRECTORY_END = "PK";
|
||
exports3.DATA_DESCRIPTOR = "PK\x07\b";
|
||
}, {}], 24: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var GenericWorker = require2("./GenericWorker");
|
||
var utils = require2("../utils");
|
||
function ConvertWorker(destType) {
|
||
GenericWorker.call(this, "ConvertWorker to " + destType);
|
||
this.destType = destType;
|
||
}
|
||
utils.inherits(ConvertWorker, GenericWorker);
|
||
ConvertWorker.prototype.processChunk = function(chunk) {
|
||
this.push({
|
||
data: utils.transformTo(this.destType, chunk.data),
|
||
meta: chunk.meta
|
||
});
|
||
};
|
||
module4.exports = ConvertWorker;
|
||
}, { "../utils": 32, "./GenericWorker": 28 }], 25: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var GenericWorker = require2("./GenericWorker");
|
||
var crc32 = require2("../crc32");
|
||
var utils = require2("../utils");
|
||
function Crc32Probe() {
|
||
GenericWorker.call(this, "Crc32Probe");
|
||
this.withStreamInfo("crc32", 0);
|
||
}
|
||
utils.inherits(Crc32Probe, GenericWorker);
|
||
Crc32Probe.prototype.processChunk = function(chunk) {
|
||
this.streamInfo.crc32 = crc32(chunk.data, this.streamInfo.crc32 || 0);
|
||
this.push(chunk);
|
||
};
|
||
module4.exports = Crc32Probe;
|
||
}, { "../crc32": 4, "../utils": 32, "./GenericWorker": 28 }], 26: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("../utils");
|
||
var GenericWorker = require2("./GenericWorker");
|
||
function DataLengthProbe(propName) {
|
||
GenericWorker.call(this, "DataLengthProbe for " + propName);
|
||
this.propName = propName;
|
||
this.withStreamInfo(propName, 0);
|
||
}
|
||
utils.inherits(DataLengthProbe, GenericWorker);
|
||
DataLengthProbe.prototype.processChunk = function(chunk) {
|
||
if (chunk) {
|
||
var length = this.streamInfo[this.propName] || 0;
|
||
this.streamInfo[this.propName] = length + chunk.data.length;
|
||
}
|
||
GenericWorker.prototype.processChunk.call(this, chunk);
|
||
};
|
||
module4.exports = DataLengthProbe;
|
||
}, { "../utils": 32, "./GenericWorker": 28 }], 27: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("../utils");
|
||
var GenericWorker = require2("./GenericWorker");
|
||
var DEFAULT_BLOCK_SIZE = 16 * 1024;
|
||
function DataWorker(dataP) {
|
||
GenericWorker.call(this, "DataWorker");
|
||
var self2 = this;
|
||
this.dataIsReady = false;
|
||
this.index = 0;
|
||
this.max = 0;
|
||
this.data = null;
|
||
this.type = "";
|
||
this._tickScheduled = false;
|
||
dataP.then(function(data) {
|
||
self2.dataIsReady = true;
|
||
self2.data = data;
|
||
self2.max = data && data.length || 0;
|
||
self2.type = utils.getTypeOf(data);
|
||
if (!self2.isPaused) {
|
||
self2._tickAndRepeat();
|
||
}
|
||
}, function(e) {
|
||
self2.error(e);
|
||
});
|
||
}
|
||
utils.inherits(DataWorker, GenericWorker);
|
||
DataWorker.prototype.cleanUp = function() {
|
||
GenericWorker.prototype.cleanUp.call(this);
|
||
this.data = null;
|
||
};
|
||
DataWorker.prototype.resume = function() {
|
||
if (!GenericWorker.prototype.resume.call(this)) {
|
||
return false;
|
||
}
|
||
if (!this._tickScheduled && this.dataIsReady) {
|
||
this._tickScheduled = true;
|
||
utils.delay(this._tickAndRepeat, [], this);
|
||
}
|
||
return true;
|
||
};
|
||
DataWorker.prototype._tickAndRepeat = function() {
|
||
this._tickScheduled = false;
|
||
if (this.isPaused || this.isFinished) {
|
||
return;
|
||
}
|
||
this._tick();
|
||
if (!this.isFinished) {
|
||
utils.delay(this._tickAndRepeat, [], this);
|
||
this._tickScheduled = true;
|
||
}
|
||
};
|
||
DataWorker.prototype._tick = function() {
|
||
if (this.isPaused || this.isFinished) {
|
||
return false;
|
||
}
|
||
var size = DEFAULT_BLOCK_SIZE;
|
||
var data = null, nextIndex = Math.min(this.max, this.index + size);
|
||
if (this.index >= this.max) {
|
||
return this.end();
|
||
} else {
|
||
switch (this.type) {
|
||
case "string":
|
||
data = this.data.substring(this.index, nextIndex);
|
||
break;
|
||
case "uint8array":
|
||
data = this.data.subarray(this.index, nextIndex);
|
||
break;
|
||
case "array":
|
||
case "nodebuffer":
|
||
data = this.data.slice(this.index, nextIndex);
|
||
break;
|
||
}
|
||
this.index = nextIndex;
|
||
return this.push({
|
||
data,
|
||
meta: {
|
||
percent: this.max ? this.index / this.max * 100 : 0
|
||
}
|
||
});
|
||
}
|
||
};
|
||
module4.exports = DataWorker;
|
||
}, { "../utils": 32, "./GenericWorker": 28 }], 28: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
function GenericWorker(name) {
|
||
this.name = name || "default";
|
||
this.streamInfo = {};
|
||
this.generatedError = null;
|
||
this.extraStreamInfo = {};
|
||
this.isPaused = true;
|
||
this.isFinished = false;
|
||
this.isLocked = false;
|
||
this._listeners = {
|
||
"data": [],
|
||
"end": [],
|
||
"error": []
|
||
};
|
||
this.previous = null;
|
||
}
|
||
GenericWorker.prototype = {
|
||
push: function(chunk) {
|
||
this.emit("data", chunk);
|
||
},
|
||
end: function() {
|
||
if (this.isFinished) {
|
||
return false;
|
||
}
|
||
this.flush();
|
||
try {
|
||
this.emit("end");
|
||
this.cleanUp();
|
||
this.isFinished = true;
|
||
} catch (e) {
|
||
this.emit("error", e);
|
||
}
|
||
return true;
|
||
},
|
||
error: function(e) {
|
||
if (this.isFinished) {
|
||
return false;
|
||
}
|
||
if (this.isPaused) {
|
||
this.generatedError = e;
|
||
} else {
|
||
this.isFinished = true;
|
||
this.emit("error", e);
|
||
if (this.previous) {
|
||
this.previous.error(e);
|
||
}
|
||
this.cleanUp();
|
||
}
|
||
return true;
|
||
},
|
||
on: function(name, listener) {
|
||
this._listeners[name].push(listener);
|
||
return this;
|
||
},
|
||
cleanUp: function() {
|
||
this.streamInfo = this.generatedError = this.extraStreamInfo = null;
|
||
this._listeners = [];
|
||
},
|
||
emit: function(name, arg) {
|
||
if (this._listeners[name]) {
|
||
for (var i = 0; i < this._listeners[name].length; i++) {
|
||
this._listeners[name][i].call(this, arg);
|
||
}
|
||
}
|
||
},
|
||
pipe: function(next) {
|
||
return next.registerPrevious(this);
|
||
},
|
||
registerPrevious: function(previous) {
|
||
if (this.isLocked) {
|
||
throw new Error("The stream '" + this + "' has already been used.");
|
||
}
|
||
this.streamInfo = previous.streamInfo;
|
||
this.mergeStreamInfo();
|
||
this.previous = previous;
|
||
var self2 = this;
|
||
previous.on("data", function(chunk) {
|
||
self2.processChunk(chunk);
|
||
});
|
||
previous.on("end", function() {
|
||
self2.end();
|
||
});
|
||
previous.on("error", function(e) {
|
||
self2.error(e);
|
||
});
|
||
return this;
|
||
},
|
||
pause: function() {
|
||
if (this.isPaused || this.isFinished) {
|
||
return false;
|
||
}
|
||
this.isPaused = true;
|
||
if (this.previous) {
|
||
this.previous.pause();
|
||
}
|
||
return true;
|
||
},
|
||
resume: function() {
|
||
if (!this.isPaused || this.isFinished) {
|
||
return false;
|
||
}
|
||
this.isPaused = false;
|
||
var withError = false;
|
||
if (this.generatedError) {
|
||
this.error(this.generatedError);
|
||
withError = true;
|
||
}
|
||
if (this.previous) {
|
||
this.previous.resume();
|
||
}
|
||
return !withError;
|
||
},
|
||
flush: function() {
|
||
},
|
||
processChunk: function(chunk) {
|
||
this.push(chunk);
|
||
},
|
||
withStreamInfo: function(key, value) {
|
||
this.extraStreamInfo[key] = value;
|
||
this.mergeStreamInfo();
|
||
return this;
|
||
},
|
||
mergeStreamInfo: function() {
|
||
for (var key in this.extraStreamInfo) {
|
||
if (!Object.prototype.hasOwnProperty.call(this.extraStreamInfo, key)) {
|
||
continue;
|
||
}
|
||
this.streamInfo[key] = this.extraStreamInfo[key];
|
||
}
|
||
},
|
||
lock: function() {
|
||
if (this.isLocked) {
|
||
throw new Error("The stream '" + this + "' has already been used.");
|
||
}
|
||
this.isLocked = true;
|
||
if (this.previous) {
|
||
this.previous.lock();
|
||
}
|
||
},
|
||
toString: function() {
|
||
var me = "Worker " + this.name;
|
||
if (this.previous) {
|
||
return this.previous + " -> " + me;
|
||
} else {
|
||
return me;
|
||
}
|
||
}
|
||
};
|
||
module4.exports = GenericWorker;
|
||
}, {}], 29: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("../utils");
|
||
var ConvertWorker = require2("./ConvertWorker");
|
||
var GenericWorker = require2("./GenericWorker");
|
||
var base64 = require2("../base64");
|
||
var support = require2("../support");
|
||
var external = require2("../external");
|
||
var NodejsStreamOutputAdapter = null;
|
||
if (support.nodestream) {
|
||
try {
|
||
NodejsStreamOutputAdapter = require2("../nodejs/NodejsStreamOutputAdapter");
|
||
} catch (e) {
|
||
}
|
||
}
|
||
function transformZipOutput(type, content, mimeType) {
|
||
switch (type) {
|
||
case "blob":
|
||
return utils.newBlob(utils.transformTo("arraybuffer", content), mimeType);
|
||
case "base64":
|
||
return base64.encode(content);
|
||
default:
|
||
return utils.transformTo(type, content);
|
||
}
|
||
}
|
||
function concat(type, dataArray) {
|
||
var i, index = 0, res = null, totalLength = 0;
|
||
for (i = 0; i < dataArray.length; i++) {
|
||
totalLength += dataArray[i].length;
|
||
}
|
||
switch (type) {
|
||
case "string":
|
||
return dataArray.join("");
|
||
case "array":
|
||
return Array.prototype.concat.apply([], dataArray);
|
||
case "uint8array":
|
||
res = new Uint8Array(totalLength);
|
||
for (i = 0; i < dataArray.length; i++) {
|
||
res.set(dataArray[i], index);
|
||
index += dataArray[i].length;
|
||
}
|
||
return res;
|
||
case "nodebuffer":
|
||
return Buffer.concat(dataArray);
|
||
default:
|
||
throw new Error("concat : unsupported type '" + type + "'");
|
||
}
|
||
}
|
||
function accumulate(helper, updateCallback) {
|
||
return new external.Promise(function(resolve, reject) {
|
||
var dataArray = [];
|
||
var chunkType = helper._internalType, resultType = helper._outputType, mimeType = helper._mimeType;
|
||
helper.on("data", function(data, meta) {
|
||
dataArray.push(data);
|
||
if (updateCallback) {
|
||
updateCallback(meta);
|
||
}
|
||
}).on("error", function(err) {
|
||
dataArray = [];
|
||
reject(err);
|
||
}).on("end", function() {
|
||
try {
|
||
var result = transformZipOutput(resultType, concat(chunkType, dataArray), mimeType);
|
||
resolve(result);
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
dataArray = [];
|
||
}).resume();
|
||
});
|
||
}
|
||
function StreamHelper(worker, outputType, mimeType) {
|
||
var internalType = outputType;
|
||
switch (outputType) {
|
||
case "blob":
|
||
case "arraybuffer":
|
||
internalType = "uint8array";
|
||
break;
|
||
case "base64":
|
||
internalType = "string";
|
||
break;
|
||
}
|
||
try {
|
||
this._internalType = internalType;
|
||
this._outputType = outputType;
|
||
this._mimeType = mimeType;
|
||
utils.checkSupport(internalType);
|
||
this._worker = worker.pipe(new ConvertWorker(internalType));
|
||
worker.lock();
|
||
} catch (e) {
|
||
this._worker = new GenericWorker("error");
|
||
this._worker.error(e);
|
||
}
|
||
}
|
||
StreamHelper.prototype = {
|
||
accumulate: function(updateCb) {
|
||
return accumulate(this, updateCb);
|
||
},
|
||
on: function(evt, fn) {
|
||
var self2 = this;
|
||
if (evt === "data") {
|
||
this._worker.on(evt, function(chunk) {
|
||
fn.call(self2, chunk.data, chunk.meta);
|
||
});
|
||
} else {
|
||
this._worker.on(evt, function() {
|
||
utils.delay(fn, arguments, self2);
|
||
});
|
||
}
|
||
return this;
|
||
},
|
||
resume: function() {
|
||
utils.delay(this._worker.resume, [], this._worker);
|
||
return this;
|
||
},
|
||
pause: function() {
|
||
this._worker.pause();
|
||
return this;
|
||
},
|
||
toNodejsStream: function(updateCb) {
|
||
utils.checkSupport("nodestream");
|
||
if (this._outputType !== "nodebuffer") {
|
||
throw new Error(this._outputType + " is not supported by this method");
|
||
}
|
||
return new NodejsStreamOutputAdapter(this, {
|
||
objectMode: this._outputType !== "nodebuffer"
|
||
}, updateCb);
|
||
}
|
||
};
|
||
module4.exports = StreamHelper;
|
||
}, { "../base64": 1, "../external": 6, "../nodejs/NodejsStreamOutputAdapter": 13, "../support": 30, "../utils": 32, "./ConvertWorker": 24, "./GenericWorker": 28 }], 30: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
exports3.base64 = true;
|
||
exports3.array = true;
|
||
exports3.string = true;
|
||
exports3.arraybuffer = typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined";
|
||
exports3.nodebuffer = typeof Buffer !== "undefined";
|
||
exports3.uint8array = typeof Uint8Array !== "undefined";
|
||
if (typeof ArrayBuffer === "undefined") {
|
||
exports3.blob = false;
|
||
} else {
|
||
var buffer = new ArrayBuffer(0);
|
||
try {
|
||
exports3.blob = new Blob([buffer], {
|
||
type: "application/zip"
|
||
}).size === 0;
|
||
} catch (e) {
|
||
try {
|
||
var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;
|
||
var builder = new Builder();
|
||
builder.append(buffer);
|
||
exports3.blob = builder.getBlob("application/zip").size === 0;
|
||
} catch (e2) {
|
||
exports3.blob = false;
|
||
}
|
||
}
|
||
}
|
||
try {
|
||
exports3.nodestream = !!require2("readable-stream").Readable;
|
||
} catch (e) {
|
||
exports3.nodestream = false;
|
||
}
|
||
}, { "readable-stream": 16 }], 31: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("./utils");
|
||
var support = require2("./support");
|
||
var nodejsUtils = require2("./nodejsUtils");
|
||
var GenericWorker = require2("./stream/GenericWorker");
|
||
var _utf8len = new Array(256);
|
||
for (var i = 0; i < 256; i++) {
|
||
_utf8len[i] = i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1;
|
||
}
|
||
_utf8len[254] = _utf8len[254] = 1;
|
||
var string2buf = function(str) {
|
||
var buf, c, c2, m_pos, i2, str_len = str.length, buf_len = 0;
|
||
for (m_pos = 0; m_pos < str_len; m_pos++) {
|
||
c = str.charCodeAt(m_pos);
|
||
if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
|
||
c2 = str.charCodeAt(m_pos + 1);
|
||
if ((c2 & 64512) === 56320) {
|
||
c = 65536 + (c - 55296 << 10) + (c2 - 56320);
|
||
m_pos++;
|
||
}
|
||
}
|
||
buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;
|
||
}
|
||
if (support.uint8array) {
|
||
buf = new Uint8Array(buf_len);
|
||
} else {
|
||
buf = new Array(buf_len);
|
||
}
|
||
for (i2 = 0, m_pos = 0; i2 < buf_len; m_pos++) {
|
||
c = str.charCodeAt(m_pos);
|
||
if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
|
||
c2 = str.charCodeAt(m_pos + 1);
|
||
if ((c2 & 64512) === 56320) {
|
||
c = 65536 + (c - 55296 << 10) + (c2 - 56320);
|
||
m_pos++;
|
||
}
|
||
}
|
||
if (c < 128) {
|
||
buf[i2++] = c;
|
||
} else if (c < 2048) {
|
||
buf[i2++] = 192 | c >>> 6;
|
||
buf[i2++] = 128 | c & 63;
|
||
} else if (c < 65536) {
|
||
buf[i2++] = 224 | c >>> 12;
|
||
buf[i2++] = 128 | c >>> 6 & 63;
|
||
buf[i2++] = 128 | c & 63;
|
||
} else {
|
||
buf[i2++] = 240 | c >>> 18;
|
||
buf[i2++] = 128 | c >>> 12 & 63;
|
||
buf[i2++] = 128 | c >>> 6 & 63;
|
||
buf[i2++] = 128 | c & 63;
|
||
}
|
||
}
|
||
return buf;
|
||
};
|
||
var utf8border = function(buf, max) {
|
||
var pos;
|
||
max = max || buf.length;
|
||
if (max > buf.length) {
|
||
max = buf.length;
|
||
}
|
||
pos = max - 1;
|
||
while (pos >= 0 && (buf[pos] & 192) === 128) {
|
||
pos--;
|
||
}
|
||
if (pos < 0) {
|
||
return max;
|
||
}
|
||
if (pos === 0) {
|
||
return max;
|
||
}
|
||
return pos + _utf8len[buf[pos]] > max ? pos : max;
|
||
};
|
||
var buf2string = function(buf) {
|
||
var i2, out, c, c_len;
|
||
var len = buf.length;
|
||
var utf16buf = new Array(len * 2);
|
||
for (out = 0, i2 = 0; i2 < len; ) {
|
||
c = buf[i2++];
|
||
if (c < 128) {
|
||
utf16buf[out++] = c;
|
||
continue;
|
||
}
|
||
c_len = _utf8len[c];
|
||
if (c_len > 4) {
|
||
utf16buf[out++] = 65533;
|
||
i2 += c_len - 1;
|
||
continue;
|
||
}
|
||
c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;
|
||
while (c_len > 1 && i2 < len) {
|
||
c = c << 6 | buf[i2++] & 63;
|
||
c_len--;
|
||
}
|
||
if (c_len > 1) {
|
||
utf16buf[out++] = 65533;
|
||
continue;
|
||
}
|
||
if (c < 65536) {
|
||
utf16buf[out++] = c;
|
||
} else {
|
||
c -= 65536;
|
||
utf16buf[out++] = 55296 | c >> 10 & 1023;
|
||
utf16buf[out++] = 56320 | c & 1023;
|
||
}
|
||
}
|
||
if (utf16buf.length !== out) {
|
||
if (utf16buf.subarray) {
|
||
utf16buf = utf16buf.subarray(0, out);
|
||
} else {
|
||
utf16buf.length = out;
|
||
}
|
||
}
|
||
return utils.applyFromCharCode(utf16buf);
|
||
};
|
||
exports3.utf8encode = function utf8encode(str) {
|
||
if (support.nodebuffer) {
|
||
return nodejsUtils.newBufferFrom(str, "utf-8");
|
||
}
|
||
return string2buf(str);
|
||
};
|
||
exports3.utf8decode = function utf8decode(buf) {
|
||
if (support.nodebuffer) {
|
||
return utils.transformTo("nodebuffer", buf).toString("utf-8");
|
||
}
|
||
buf = utils.transformTo(support.uint8array ? "uint8array" : "array", buf);
|
||
return buf2string(buf);
|
||
};
|
||
function Utf8DecodeWorker() {
|
||
GenericWorker.call(this, "utf-8 decode");
|
||
this.leftOver = null;
|
||
}
|
||
utils.inherits(Utf8DecodeWorker, GenericWorker);
|
||
Utf8DecodeWorker.prototype.processChunk = function(chunk) {
|
||
var data = utils.transformTo(support.uint8array ? "uint8array" : "array", chunk.data);
|
||
if (this.leftOver && this.leftOver.length) {
|
||
if (support.uint8array) {
|
||
var previousData = data;
|
||
data = new Uint8Array(previousData.length + this.leftOver.length);
|
||
data.set(this.leftOver, 0);
|
||
data.set(previousData, this.leftOver.length);
|
||
} else {
|
||
data = this.leftOver.concat(data);
|
||
}
|
||
this.leftOver = null;
|
||
}
|
||
var nextBoundary = utf8border(data);
|
||
var usableData = data;
|
||
if (nextBoundary !== data.length) {
|
||
if (support.uint8array) {
|
||
usableData = data.subarray(0, nextBoundary);
|
||
this.leftOver = data.subarray(nextBoundary, data.length);
|
||
} else {
|
||
usableData = data.slice(0, nextBoundary);
|
||
this.leftOver = data.slice(nextBoundary, data.length);
|
||
}
|
||
}
|
||
this.push({
|
||
data: exports3.utf8decode(usableData),
|
||
meta: chunk.meta
|
||
});
|
||
};
|
||
Utf8DecodeWorker.prototype.flush = function() {
|
||
if (this.leftOver && this.leftOver.length) {
|
||
this.push({
|
||
data: exports3.utf8decode(this.leftOver),
|
||
meta: {}
|
||
});
|
||
this.leftOver = null;
|
||
}
|
||
};
|
||
exports3.Utf8DecodeWorker = Utf8DecodeWorker;
|
||
function Utf8EncodeWorker() {
|
||
GenericWorker.call(this, "utf-8 encode");
|
||
}
|
||
utils.inherits(Utf8EncodeWorker, GenericWorker);
|
||
Utf8EncodeWorker.prototype.processChunk = function(chunk) {
|
||
this.push({
|
||
data: exports3.utf8encode(chunk.data),
|
||
meta: chunk.meta
|
||
});
|
||
};
|
||
exports3.Utf8EncodeWorker = Utf8EncodeWorker;
|
||
}, { "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./support": 30, "./utils": 32 }], 32: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var support = require2("./support");
|
||
var base64 = require2("./base64");
|
||
var nodejsUtils = require2("./nodejsUtils");
|
||
var external = require2("./external");
|
||
require2("setimmediate");
|
||
function string2binary(str) {
|
||
var result = null;
|
||
if (support.uint8array) {
|
||
result = new Uint8Array(str.length);
|
||
} else {
|
||
result = new Array(str.length);
|
||
}
|
||
return stringToArrayLike(str, result);
|
||
}
|
||
exports3.newBlob = function(part, type) {
|
||
exports3.checkSupport("blob");
|
||
try {
|
||
return new Blob([part], {
|
||
type
|
||
});
|
||
} catch (e) {
|
||
try {
|
||
var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;
|
||
var builder = new Builder();
|
||
builder.append(part);
|
||
return builder.getBlob(type);
|
||
} catch (e2) {
|
||
throw new Error("Bug : can't construct the Blob.");
|
||
}
|
||
}
|
||
};
|
||
function identity(input) {
|
||
return input;
|
||
}
|
||
function stringToArrayLike(str, array) {
|
||
for (var i = 0; i < str.length; ++i) {
|
||
array[i] = str.charCodeAt(i) & 255;
|
||
}
|
||
return array;
|
||
}
|
||
var arrayToStringHelper = {
|
||
stringifyByChunk: function(array, type, chunk) {
|
||
var result = [], k = 0, len = array.length;
|
||
if (len <= chunk) {
|
||
return String.fromCharCode.apply(null, array);
|
||
}
|
||
while (k < len) {
|
||
if (type === "array" || type === "nodebuffer") {
|
||
result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));
|
||
} else {
|
||
result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));
|
||
}
|
||
k += chunk;
|
||
}
|
||
return result.join("");
|
||
},
|
||
stringifyByChar: function(array) {
|
||
var resultStr = "";
|
||
for (var i = 0; i < array.length; i++) {
|
||
resultStr += String.fromCharCode(array[i]);
|
||
}
|
||
return resultStr;
|
||
},
|
||
applyCanBeUsed: {
|
||
uint8array: function() {
|
||
try {
|
||
return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1;
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
}(),
|
||
nodebuffer: function() {
|
||
try {
|
||
return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1;
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
}()
|
||
}
|
||
};
|
||
function arrayLikeToString(array) {
|
||
var chunk = 65536, type = exports3.getTypeOf(array), canUseApply = true;
|
||
if (type === "uint8array") {
|
||
canUseApply = arrayToStringHelper.applyCanBeUsed.uint8array;
|
||
} else if (type === "nodebuffer") {
|
||
canUseApply = arrayToStringHelper.applyCanBeUsed.nodebuffer;
|
||
}
|
||
if (canUseApply) {
|
||
while (chunk > 1) {
|
||
try {
|
||
return arrayToStringHelper.stringifyByChunk(array, type, chunk);
|
||
} catch (e) {
|
||
chunk = Math.floor(chunk / 2);
|
||
}
|
||
}
|
||
}
|
||
return arrayToStringHelper.stringifyByChar(array);
|
||
}
|
||
exports3.applyFromCharCode = arrayLikeToString;
|
||
function arrayLikeToArrayLike(arrayFrom, arrayTo) {
|
||
for (var i = 0; i < arrayFrom.length; i++) {
|
||
arrayTo[i] = arrayFrom[i];
|
||
}
|
||
return arrayTo;
|
||
}
|
||
var transform = {};
|
||
transform["string"] = {
|
||
"string": identity,
|
||
"array": function(input) {
|
||
return stringToArrayLike(input, new Array(input.length));
|
||
},
|
||
"arraybuffer": function(input) {
|
||
return transform["string"]["uint8array"](input).buffer;
|
||
},
|
||
"uint8array": function(input) {
|
||
return stringToArrayLike(input, new Uint8Array(input.length));
|
||
},
|
||
"nodebuffer": function(input) {
|
||
return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length));
|
||
}
|
||
};
|
||
transform["array"] = {
|
||
"string": arrayLikeToString,
|
||
"array": identity,
|
||
"arraybuffer": function(input) {
|
||
return new Uint8Array(input).buffer;
|
||
},
|
||
"uint8array": function(input) {
|
||
return new Uint8Array(input);
|
||
},
|
||
"nodebuffer": function(input) {
|
||
return nodejsUtils.newBufferFrom(input);
|
||
}
|
||
};
|
||
transform["arraybuffer"] = {
|
||
"string": function(input) {
|
||
return arrayLikeToString(new Uint8Array(input));
|
||
},
|
||
"array": function(input) {
|
||
return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));
|
||
},
|
||
"arraybuffer": identity,
|
||
"uint8array": function(input) {
|
||
return new Uint8Array(input);
|
||
},
|
||
"nodebuffer": function(input) {
|
||
return nodejsUtils.newBufferFrom(new Uint8Array(input));
|
||
}
|
||
};
|
||
transform["uint8array"] = {
|
||
"string": arrayLikeToString,
|
||
"array": function(input) {
|
||
return arrayLikeToArrayLike(input, new Array(input.length));
|
||
},
|
||
"arraybuffer": function(input) {
|
||
return input.buffer;
|
||
},
|
||
"uint8array": identity,
|
||
"nodebuffer": function(input) {
|
||
return nodejsUtils.newBufferFrom(input);
|
||
}
|
||
};
|
||
transform["nodebuffer"] = {
|
||
"string": arrayLikeToString,
|
||
"array": function(input) {
|
||
return arrayLikeToArrayLike(input, new Array(input.length));
|
||
},
|
||
"arraybuffer": function(input) {
|
||
return transform["nodebuffer"]["uint8array"](input).buffer;
|
||
},
|
||
"uint8array": function(input) {
|
||
return arrayLikeToArrayLike(input, new Uint8Array(input.length));
|
||
},
|
||
"nodebuffer": identity
|
||
};
|
||
exports3.transformTo = function(outputType, input) {
|
||
if (!input) {
|
||
input = "";
|
||
}
|
||
if (!outputType) {
|
||
return input;
|
||
}
|
||
exports3.checkSupport(outputType);
|
||
var inputType = exports3.getTypeOf(input);
|
||
var result = transform[inputType][outputType](input);
|
||
return result;
|
||
};
|
||
exports3.resolve = function(path) {
|
||
var parts = path.split("/");
|
||
var result = [];
|
||
for (var index = 0; index < parts.length; index++) {
|
||
var part = parts[index];
|
||
if (part === "." || part === "" && index !== 0 && index !== parts.length - 1) {
|
||
continue;
|
||
} else if (part === "..") {
|
||
result.pop();
|
||
} else {
|
||
result.push(part);
|
||
}
|
||
}
|
||
return result.join("/");
|
||
};
|
||
exports3.getTypeOf = function(input) {
|
||
if (typeof input === "string") {
|
||
return "string";
|
||
}
|
||
if (Object.prototype.toString.call(input) === "[object Array]") {
|
||
return "array";
|
||
}
|
||
if (support.nodebuffer && nodejsUtils.isBuffer(input)) {
|
||
return "nodebuffer";
|
||
}
|
||
if (support.uint8array && input instanceof Uint8Array) {
|
||
return "uint8array";
|
||
}
|
||
if (support.arraybuffer && input instanceof ArrayBuffer) {
|
||
return "arraybuffer";
|
||
}
|
||
};
|
||
exports3.checkSupport = function(type) {
|
||
var supported = support[type.toLowerCase()];
|
||
if (!supported) {
|
||
throw new Error(type + " is not supported by this platform");
|
||
}
|
||
};
|
||
exports3.MAX_VALUE_16BITS = 65535;
|
||
exports3.MAX_VALUE_32BITS = -1;
|
||
exports3.pretty = function(str) {
|
||
var res = "", code, i;
|
||
for (i = 0; i < (str || "").length; i++) {
|
||
code = str.charCodeAt(i);
|
||
res += "\\x" + (code < 16 ? "0" : "") + code.toString(16).toUpperCase();
|
||
}
|
||
return res;
|
||
};
|
||
exports3.delay = function(callback, args, self2) {
|
||
setImmediate(function() {
|
||
callback.apply(self2 || null, args || []);
|
||
});
|
||
};
|
||
exports3.inherits = function(ctor, superCtor) {
|
||
var Obj = function() {
|
||
};
|
||
Obj.prototype = superCtor.prototype;
|
||
ctor.prototype = new Obj();
|
||
};
|
||
exports3.extend = function() {
|
||
var result = {}, i, attr;
|
||
for (i = 0; i < arguments.length; i++) {
|
||
for (attr in arguments[i]) {
|
||
if (Object.prototype.hasOwnProperty.call(arguments[i], attr) && typeof result[attr] === "undefined") {
|
||
result[attr] = arguments[i][attr];
|
||
}
|
||
}
|
||
}
|
||
return result;
|
||
};
|
||
exports3.prepareContent = function(name, inputData, isBinary, isOptimizedBinaryString, isBase64) {
|
||
var promise = external.Promise.resolve(inputData).then(function(data) {
|
||
var isBlob = support.blob && (data instanceof Blob || ["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(data)) !== -1);
|
||
if (isBlob && typeof FileReader !== "undefined") {
|
||
return new external.Promise(function(resolve, reject) {
|
||
var reader = new FileReader();
|
||
reader.onload = function(e) {
|
||
resolve(e.target.result);
|
||
};
|
||
reader.onerror = function(e) {
|
||
reject(e.target.error);
|
||
};
|
||
reader.readAsArrayBuffer(data);
|
||
});
|
||
} else {
|
||
return data;
|
||
}
|
||
});
|
||
return promise.then(function(data) {
|
||
var dataType = exports3.getTypeOf(data);
|
||
if (!dataType) {
|
||
return external.Promise.reject(new Error("Can't read the data of '" + name + "'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"));
|
||
}
|
||
if (dataType === "arraybuffer") {
|
||
data = exports3.transformTo("uint8array", data);
|
||
} else if (dataType === "string") {
|
||
if (isBase64) {
|
||
data = base64.decode(data);
|
||
} else if (isBinary) {
|
||
if (isOptimizedBinaryString !== true) {
|
||
data = string2binary(data);
|
||
}
|
||
}
|
||
}
|
||
return data;
|
||
});
|
||
};
|
||
}, { "./base64": 1, "./external": 6, "./nodejsUtils": 14, "./support": 30, "setimmediate": 54 }], 33: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var readerFor = require2("./reader/readerFor");
|
||
var utils = require2("./utils");
|
||
var sig = require2("./signature");
|
||
var ZipEntry = require2("./zipEntry");
|
||
var support = require2("./support");
|
||
function ZipEntries(loadOptions) {
|
||
this.files = [];
|
||
this.loadOptions = loadOptions;
|
||
}
|
||
ZipEntries.prototype = {
|
||
checkSignature: function(expectedSignature) {
|
||
if (!this.reader.readAndCheckSignature(expectedSignature)) {
|
||
this.reader.index -= 4;
|
||
var signature = this.reader.readString(4);
|
||
throw new Error("Corrupted zip or bug: unexpected signature (" + utils.pretty(signature) + ", expected " + utils.pretty(expectedSignature) + ")");
|
||
}
|
||
},
|
||
isSignature: function(askedIndex, expectedSignature) {
|
||
var currentIndex = this.reader.index;
|
||
this.reader.setIndex(askedIndex);
|
||
var signature = this.reader.readString(4);
|
||
var result = signature === expectedSignature;
|
||
this.reader.setIndex(currentIndex);
|
||
return result;
|
||
},
|
||
readBlockEndOfCentral: function() {
|
||
this.diskNumber = this.reader.readInt(2);
|
||
this.diskWithCentralDirStart = this.reader.readInt(2);
|
||
this.centralDirRecordsOnThisDisk = this.reader.readInt(2);
|
||
this.centralDirRecords = this.reader.readInt(2);
|
||
this.centralDirSize = this.reader.readInt(4);
|
||
this.centralDirOffset = this.reader.readInt(4);
|
||
this.zipCommentLength = this.reader.readInt(2);
|
||
var zipComment = this.reader.readData(this.zipCommentLength);
|
||
var decodeParamType = support.uint8array ? "uint8array" : "array";
|
||
var decodeContent = utils.transformTo(decodeParamType, zipComment);
|
||
this.zipComment = this.loadOptions.decodeFileName(decodeContent);
|
||
},
|
||
readBlockZip64EndOfCentral: function() {
|
||
this.zip64EndOfCentralSize = this.reader.readInt(8);
|
||
this.reader.skip(4);
|
||
this.diskNumber = this.reader.readInt(4);
|
||
this.diskWithCentralDirStart = this.reader.readInt(4);
|
||
this.centralDirRecordsOnThisDisk = this.reader.readInt(8);
|
||
this.centralDirRecords = this.reader.readInt(8);
|
||
this.centralDirSize = this.reader.readInt(8);
|
||
this.centralDirOffset = this.reader.readInt(8);
|
||
this.zip64ExtensibleData = {};
|
||
var extraDataSize = this.zip64EndOfCentralSize - 44, index = 0, extraFieldId, extraFieldLength, extraFieldValue;
|
||
while (index < extraDataSize) {
|
||
extraFieldId = this.reader.readInt(2);
|
||
extraFieldLength = this.reader.readInt(4);
|
||
extraFieldValue = this.reader.readData(extraFieldLength);
|
||
this.zip64ExtensibleData[extraFieldId] = {
|
||
id: extraFieldId,
|
||
length: extraFieldLength,
|
||
value: extraFieldValue
|
||
};
|
||
}
|
||
},
|
||
readBlockZip64EndOfCentralLocator: function() {
|
||
this.diskWithZip64CentralDirStart = this.reader.readInt(4);
|
||
this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8);
|
||
this.disksCount = this.reader.readInt(4);
|
||
if (this.disksCount > 1) {
|
||
throw new Error("Multi-volumes zip are not supported");
|
||
}
|
||
},
|
||
readLocalFiles: function() {
|
||
var i, file;
|
||
for (i = 0; i < this.files.length; i++) {
|
||
file = this.files[i];
|
||
this.reader.setIndex(file.localHeaderOffset);
|
||
this.checkSignature(sig.LOCAL_FILE_HEADER);
|
||
file.readLocalPart(this.reader);
|
||
file.handleUTF8();
|
||
file.processAttributes();
|
||
}
|
||
},
|
||
readCentralDir: function() {
|
||
var file;
|
||
this.reader.setIndex(this.centralDirOffset);
|
||
while (this.reader.readAndCheckSignature(sig.CENTRAL_FILE_HEADER)) {
|
||
file = new ZipEntry({
|
||
zip64: this.zip64
|
||
}, this.loadOptions);
|
||
file.readCentralPart(this.reader);
|
||
this.files.push(file);
|
||
}
|
||
if (this.centralDirRecords !== this.files.length) {
|
||
if (this.centralDirRecords !== 0 && this.files.length === 0) {
|
||
throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length);
|
||
} else {
|
||
}
|
||
}
|
||
},
|
||
readEndOfCentral: function() {
|
||
var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);
|
||
if (offset < 0) {
|
||
var isGarbage = !this.isSignature(0, sig.LOCAL_FILE_HEADER);
|
||
if (isGarbage) {
|
||
throw new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");
|
||
} else {
|
||
throw new Error("Corrupted zip: can't find end of central directory");
|
||
}
|
||
}
|
||
this.reader.setIndex(offset);
|
||
var endOfCentralDirOffset = offset;
|
||
this.checkSignature(sig.CENTRAL_DIRECTORY_END);
|
||
this.readBlockEndOfCentral();
|
||
if (this.diskNumber === utils.MAX_VALUE_16BITS || this.diskWithCentralDirStart === utils.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === utils.MAX_VALUE_16BITS || this.centralDirRecords === utils.MAX_VALUE_16BITS || this.centralDirSize === utils.MAX_VALUE_32BITS || this.centralDirOffset === utils.MAX_VALUE_32BITS) {
|
||
this.zip64 = true;
|
||
offset = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
|
||
if (offset < 0) {
|
||
throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");
|
||
}
|
||
this.reader.setIndex(offset);
|
||
this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
|
||
this.readBlockZip64EndOfCentralLocator();
|
||
if (!this.isSignature(this.relativeOffsetEndOfZip64CentralDir, sig.ZIP64_CENTRAL_DIRECTORY_END)) {
|
||
this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);
|
||
if (this.relativeOffsetEndOfZip64CentralDir < 0) {
|
||
throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");
|
||
}
|
||
}
|
||
this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir);
|
||
this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);
|
||
this.readBlockZip64EndOfCentral();
|
||
}
|
||
var expectedEndOfCentralDirOffset = this.centralDirOffset + this.centralDirSize;
|
||
if (this.zip64) {
|
||
expectedEndOfCentralDirOffset += 20;
|
||
expectedEndOfCentralDirOffset += 12 + this.zip64EndOfCentralSize;
|
||
}
|
||
var extraBytes = endOfCentralDirOffset - expectedEndOfCentralDirOffset;
|
||
if (extraBytes > 0) {
|
||
if (this.isSignature(endOfCentralDirOffset, sig.CENTRAL_FILE_HEADER)) {
|
||
} else {
|
||
this.reader.zero = extraBytes;
|
||
}
|
||
} else if (extraBytes < 0) {
|
||
throw new Error("Corrupted zip: missing " + Math.abs(extraBytes) + " bytes.");
|
||
}
|
||
},
|
||
prepareReader: function(data) {
|
||
this.reader = readerFor(data);
|
||
},
|
||
load: function(data) {
|
||
this.prepareReader(data);
|
||
this.readEndOfCentral();
|
||
this.readCentralDir();
|
||
this.readLocalFiles();
|
||
}
|
||
};
|
||
module4.exports = ZipEntries;
|
||
}, { "./reader/readerFor": 22, "./signature": 23, "./support": 30, "./utils": 32, "./zipEntry": 34 }], 34: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var readerFor = require2("./reader/readerFor");
|
||
var utils = require2("./utils");
|
||
var CompressedObject = require2("./compressedObject");
|
||
var crc32fn = require2("./crc32");
|
||
var utf8 = require2("./utf8");
|
||
var compressions = require2("./compressions");
|
||
var support = require2("./support");
|
||
var MADE_BY_DOS = 0;
|
||
var MADE_BY_UNIX = 3;
|
||
var findCompression = function(compressionMethod) {
|
||
for (var method in compressions) {
|
||
if (!Object.prototype.hasOwnProperty.call(compressions, method)) {
|
||
continue;
|
||
}
|
||
if (compressions[method].magic === compressionMethod) {
|
||
return compressions[method];
|
||
}
|
||
}
|
||
return null;
|
||
};
|
||
function ZipEntry(options, loadOptions) {
|
||
this.options = options;
|
||
this.loadOptions = loadOptions;
|
||
}
|
||
ZipEntry.prototype = {
|
||
isEncrypted: function() {
|
||
return (this.bitFlag & 1) === 1;
|
||
},
|
||
useUTF8: function() {
|
||
return (this.bitFlag & 2048) === 2048;
|
||
},
|
||
readLocalPart: function(reader) {
|
||
var compression, localExtraFieldsLength;
|
||
reader.skip(22);
|
||
this.fileNameLength = reader.readInt(2);
|
||
localExtraFieldsLength = reader.readInt(2);
|
||
this.fileName = reader.readData(this.fileNameLength);
|
||
reader.skip(localExtraFieldsLength);
|
||
if (this.compressedSize === -1 || this.uncompressedSize === -1) {
|
||
throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");
|
||
}
|
||
compression = findCompression(this.compressionMethod);
|
||
if (compression === null) {
|
||
throw new Error("Corrupted zip : compression " + utils.pretty(this.compressionMethod) + " unknown (inner file : " + utils.transformTo("string", this.fileName) + ")");
|
||
}
|
||
this.decompressed = new CompressedObject(this.compressedSize, this.uncompressedSize, this.crc32, compression, reader.readData(this.compressedSize));
|
||
},
|
||
readCentralPart: function(reader) {
|
||
this.versionMadeBy = reader.readInt(2);
|
||
reader.skip(2);
|
||
this.bitFlag = reader.readInt(2);
|
||
this.compressionMethod = reader.readString(2);
|
||
this.date = reader.readDate();
|
||
this.crc32 = reader.readInt(4);
|
||
this.compressedSize = reader.readInt(4);
|
||
this.uncompressedSize = reader.readInt(4);
|
||
var fileNameLength = reader.readInt(2);
|
||
this.extraFieldsLength = reader.readInt(2);
|
||
this.fileCommentLength = reader.readInt(2);
|
||
this.diskNumberStart = reader.readInt(2);
|
||
this.internalFileAttributes = reader.readInt(2);
|
||
this.externalFileAttributes = reader.readInt(4);
|
||
this.localHeaderOffset = reader.readInt(4);
|
||
if (this.isEncrypted()) {
|
||
throw new Error("Encrypted zip are not supported");
|
||
}
|
||
reader.skip(fileNameLength);
|
||
this.readExtraFields(reader);
|
||
this.parseZIP64ExtraField(reader);
|
||
this.fileComment = reader.readData(this.fileCommentLength);
|
||
},
|
||
processAttributes: function() {
|
||
this.unixPermissions = null;
|
||
this.dosPermissions = null;
|
||
var madeBy = this.versionMadeBy >> 8;
|
||
this.dir = this.externalFileAttributes & 16 ? true : false;
|
||
if (madeBy === MADE_BY_DOS) {
|
||
this.dosPermissions = this.externalFileAttributes & 63;
|
||
}
|
||
if (madeBy === MADE_BY_UNIX) {
|
||
this.unixPermissions = this.externalFileAttributes >> 16 & 65535;
|
||
}
|
||
if (!this.dir && this.fileNameStr.slice(-1) === "/") {
|
||
this.dir = true;
|
||
}
|
||
},
|
||
parseZIP64ExtraField: function() {
|
||
if (!this.extraFields[1]) {
|
||
return;
|
||
}
|
||
var extraReader = readerFor(this.extraFields[1].value);
|
||
if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {
|
||
this.uncompressedSize = extraReader.readInt(8);
|
||
}
|
||
if (this.compressedSize === utils.MAX_VALUE_32BITS) {
|
||
this.compressedSize = extraReader.readInt(8);
|
||
}
|
||
if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {
|
||
this.localHeaderOffset = extraReader.readInt(8);
|
||
}
|
||
if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {
|
||
this.diskNumberStart = extraReader.readInt(4);
|
||
}
|
||
},
|
||
readExtraFields: function(reader) {
|
||
var end = reader.index + this.extraFieldsLength, extraFieldId, extraFieldLength, extraFieldValue;
|
||
if (!this.extraFields) {
|
||
this.extraFields = {};
|
||
}
|
||
while (reader.index + 4 < end) {
|
||
extraFieldId = reader.readInt(2);
|
||
extraFieldLength = reader.readInt(2);
|
||
extraFieldValue = reader.readData(extraFieldLength);
|
||
this.extraFields[extraFieldId] = {
|
||
id: extraFieldId,
|
||
length: extraFieldLength,
|
||
value: extraFieldValue
|
||
};
|
||
}
|
||
reader.setIndex(end);
|
||
},
|
||
handleUTF8: function() {
|
||
var decodeParamType = support.uint8array ? "uint8array" : "array";
|
||
if (this.useUTF8()) {
|
||
this.fileNameStr = utf8.utf8decode(this.fileName);
|
||
this.fileCommentStr = utf8.utf8decode(this.fileComment);
|
||
} else {
|
||
var upath = this.findExtraFieldUnicodePath();
|
||
if (upath !== null) {
|
||
this.fileNameStr = upath;
|
||
} else {
|
||
var fileNameByteArray = utils.transformTo(decodeParamType, this.fileName);
|
||
this.fileNameStr = this.loadOptions.decodeFileName(fileNameByteArray);
|
||
}
|
||
var ucomment = this.findExtraFieldUnicodeComment();
|
||
if (ucomment !== null) {
|
||
this.fileCommentStr = ucomment;
|
||
} else {
|
||
var commentByteArray = utils.transformTo(decodeParamType, this.fileComment);
|
||
this.fileCommentStr = this.loadOptions.decodeFileName(commentByteArray);
|
||
}
|
||
}
|
||
},
|
||
findExtraFieldUnicodePath: function() {
|
||
var upathField = this.extraFields[28789];
|
||
if (upathField) {
|
||
var extraReader = readerFor(upathField.value);
|
||
if (extraReader.readInt(1) !== 1) {
|
||
return null;
|
||
}
|
||
if (crc32fn(this.fileName) !== extraReader.readInt(4)) {
|
||
return null;
|
||
}
|
||
return utf8.utf8decode(extraReader.readData(upathField.length - 5));
|
||
}
|
||
return null;
|
||
},
|
||
findExtraFieldUnicodeComment: function() {
|
||
var ucommentField = this.extraFields[25461];
|
||
if (ucommentField) {
|
||
var extraReader = readerFor(ucommentField.value);
|
||
if (extraReader.readInt(1) !== 1) {
|
||
return null;
|
||
}
|
||
if (crc32fn(this.fileComment) !== extraReader.readInt(4)) {
|
||
return null;
|
||
}
|
||
return utf8.utf8decode(extraReader.readData(ucommentField.length - 5));
|
||
}
|
||
return null;
|
||
}
|
||
};
|
||
module4.exports = ZipEntry;
|
||
}, { "./compressedObject": 2, "./compressions": 3, "./crc32": 4, "./reader/readerFor": 22, "./support": 30, "./utf8": 31, "./utils": 32 }], 35: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var StreamHelper = require2("./stream/StreamHelper");
|
||
var DataWorker = require2("./stream/DataWorker");
|
||
var utf8 = require2("./utf8");
|
||
var CompressedObject = require2("./compressedObject");
|
||
var GenericWorker = require2("./stream/GenericWorker");
|
||
var ZipObject = function(name, data, options) {
|
||
this.name = name;
|
||
this.dir = options.dir;
|
||
this.date = options.date;
|
||
this.comment = options.comment;
|
||
this.unixPermissions = options.unixPermissions;
|
||
this.dosPermissions = options.dosPermissions;
|
||
this._data = data;
|
||
this._dataBinary = options.binary;
|
||
this.options = {
|
||
compression: options.compression,
|
||
compressionOptions: options.compressionOptions
|
||
};
|
||
};
|
||
ZipObject.prototype = {
|
||
internalStream: function(type) {
|
||
var result = null, outputType = "string";
|
||
try {
|
||
if (!type) {
|
||
throw new Error("No output type specified.");
|
||
}
|
||
outputType = type.toLowerCase();
|
||
var askUnicodeString = outputType === "string" || outputType === "text";
|
||
if (outputType === "binarystring" || outputType === "text") {
|
||
outputType = "string";
|
||
}
|
||
result = this._decompressWorker();
|
||
var isUnicodeString = !this._dataBinary;
|
||
if (isUnicodeString && !askUnicodeString) {
|
||
result = result.pipe(new utf8.Utf8EncodeWorker());
|
||
}
|
||
if (!isUnicodeString && askUnicodeString) {
|
||
result = result.pipe(new utf8.Utf8DecodeWorker());
|
||
}
|
||
} catch (e) {
|
||
result = new GenericWorker("error");
|
||
result.error(e);
|
||
}
|
||
return new StreamHelper(result, outputType, "");
|
||
},
|
||
async: function(type, onUpdate) {
|
||
return this.internalStream(type).accumulate(onUpdate);
|
||
},
|
||
nodeStream: function(type, onUpdate) {
|
||
return this.internalStream(type || "nodebuffer").toNodejsStream(onUpdate);
|
||
},
|
||
_compressWorker: function(compression, compressionOptions) {
|
||
if (this._data instanceof CompressedObject && this._data.compression.magic === compression.magic) {
|
||
return this._data.getCompressedWorker();
|
||
} else {
|
||
var result = this._decompressWorker();
|
||
if (!this._dataBinary) {
|
||
result = result.pipe(new utf8.Utf8EncodeWorker());
|
||
}
|
||
return CompressedObject.createWorkerFrom(result, compression, compressionOptions);
|
||
}
|
||
},
|
||
_decompressWorker: function() {
|
||
if (this._data instanceof CompressedObject) {
|
||
return this._data.getContentWorker();
|
||
} else if (this._data instanceof GenericWorker) {
|
||
return this._data;
|
||
} else {
|
||
return new DataWorker(this._data);
|
||
}
|
||
}
|
||
};
|
||
var removedMethods = ["asText", "asBinary", "asNodeBuffer", "asUint8Array", "asArrayBuffer"];
|
||
var removedFn = function() {
|
||
throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
|
||
};
|
||
for (var i = 0; i < removedMethods.length; i++) {
|
||
ZipObject.prototype[removedMethods[i]] = removedFn;
|
||
}
|
||
module4.exports = ZipObject;
|
||
}, { "./compressedObject": 2, "./stream/DataWorker": 27, "./stream/GenericWorker": 28, "./stream/StreamHelper": 29, "./utf8": 31 }], 36: [function(require2, module4, exports3) {
|
||
(function(global2) {
|
||
"use strict";
|
||
var Mutation = global2.MutationObserver || global2.WebKitMutationObserver;
|
||
var scheduleDrain;
|
||
{
|
||
if (Mutation) {
|
||
var called = 0;
|
||
var observer = new Mutation(nextTick);
|
||
var element = global2.document.createTextNode("");
|
||
observer.observe(element, {
|
||
characterData: true
|
||
});
|
||
scheduleDrain = function() {
|
||
element.data = called = ++called % 2;
|
||
};
|
||
} else if (!global2.setImmediate && typeof global2.MessageChannel !== "undefined") {
|
||
var channel = new global2.MessageChannel();
|
||
channel.port1.onmessage = nextTick;
|
||
scheduleDrain = function() {
|
||
channel.port2.postMessage(0);
|
||
};
|
||
} else if ("document" in global2 && "onreadystatechange" in global2.document.createElement("script")) {
|
||
scheduleDrain = function() {
|
||
var scriptEl = global2.document.createElement("script");
|
||
scriptEl.onreadystatechange = function() {
|
||
nextTick();
|
||
scriptEl.onreadystatechange = null;
|
||
scriptEl.parentNode.removeChild(scriptEl);
|
||
scriptEl = null;
|
||
};
|
||
global2.document.documentElement.appendChild(scriptEl);
|
||
};
|
||
} else {
|
||
scheduleDrain = function() {
|
||
setTimeout(nextTick, 0);
|
||
};
|
||
}
|
||
}
|
||
var draining;
|
||
var queue = [];
|
||
function nextTick() {
|
||
draining = true;
|
||
var i, oldQueue;
|
||
var len = queue.length;
|
||
while (len) {
|
||
oldQueue = queue;
|
||
queue = [];
|
||
i = -1;
|
||
while (++i < len) {
|
||
oldQueue[i]();
|
||
}
|
||
len = queue.length;
|
||
}
|
||
draining = false;
|
||
}
|
||
module4.exports = immediate;
|
||
function immediate(task) {
|
||
if (queue.push(task) === 1 && !draining) {
|
||
scheduleDrain();
|
||
}
|
||
}
|
||
}).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {});
|
||
}, {}], 37: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var immediate = require2("immediate");
|
||
function INTERNAL() {
|
||
}
|
||
var handlers = {};
|
||
var REJECTED = ["REJECTED"];
|
||
var FULFILLED = ["FULFILLED"];
|
||
var PENDING = ["PENDING"];
|
||
module4.exports = Promise2;
|
||
function Promise2(resolver) {
|
||
if (typeof resolver !== "function") {
|
||
throw new TypeError("resolver must be a function");
|
||
}
|
||
this.state = PENDING;
|
||
this.queue = [];
|
||
this.outcome = void 0;
|
||
if (resolver !== INTERNAL) {
|
||
safelyResolveThenable(this, resolver);
|
||
}
|
||
}
|
||
Promise2.prototype["finally"] = function(callback) {
|
||
if (typeof callback !== "function") {
|
||
return this;
|
||
}
|
||
var p = this.constructor;
|
||
return this.then(resolve2, reject2);
|
||
function resolve2(value) {
|
||
function yes() {
|
||
return value;
|
||
}
|
||
return p.resolve(callback()).then(yes);
|
||
}
|
||
function reject2(reason) {
|
||
function no() {
|
||
throw reason;
|
||
}
|
||
return p.resolve(callback()).then(no);
|
||
}
|
||
};
|
||
Promise2.prototype["catch"] = function(onRejected) {
|
||
return this.then(null, onRejected);
|
||
};
|
||
Promise2.prototype.then = function(onFulfilled, onRejected) {
|
||
if (typeof onFulfilled !== "function" && this.state === FULFILLED || typeof onRejected !== "function" && this.state === REJECTED) {
|
||
return this;
|
||
}
|
||
var promise = new this.constructor(INTERNAL);
|
||
if (this.state !== PENDING) {
|
||
var resolver = this.state === FULFILLED ? onFulfilled : onRejected;
|
||
unwrap(promise, resolver, this.outcome);
|
||
} else {
|
||
this.queue.push(new QueueItem(promise, onFulfilled, onRejected));
|
||
}
|
||
return promise;
|
||
};
|
||
function QueueItem(promise, onFulfilled, onRejected) {
|
||
this.promise = promise;
|
||
if (typeof onFulfilled === "function") {
|
||
this.onFulfilled = onFulfilled;
|
||
this.callFulfilled = this.otherCallFulfilled;
|
||
}
|
||
if (typeof onRejected === "function") {
|
||
this.onRejected = onRejected;
|
||
this.callRejected = this.otherCallRejected;
|
||
}
|
||
}
|
||
QueueItem.prototype.callFulfilled = function(value) {
|
||
handlers.resolve(this.promise, value);
|
||
};
|
||
QueueItem.prototype.otherCallFulfilled = function(value) {
|
||
unwrap(this.promise, this.onFulfilled, value);
|
||
};
|
||
QueueItem.prototype.callRejected = function(value) {
|
||
handlers.reject(this.promise, value);
|
||
};
|
||
QueueItem.prototype.otherCallRejected = function(value) {
|
||
unwrap(this.promise, this.onRejected, value);
|
||
};
|
||
function unwrap(promise, func, value) {
|
||
immediate(function() {
|
||
var returnValue;
|
||
try {
|
||
returnValue = func(value);
|
||
} catch (e) {
|
||
return handlers.reject(promise, e);
|
||
}
|
||
if (returnValue === promise) {
|
||
handlers.reject(promise, new TypeError("Cannot resolve promise with itself"));
|
||
} else {
|
||
handlers.resolve(promise, returnValue);
|
||
}
|
||
});
|
||
}
|
||
handlers.resolve = function(self2, value) {
|
||
var result = tryCatch(getThen, value);
|
||
if (result.status === "error") {
|
||
return handlers.reject(self2, result.value);
|
||
}
|
||
var thenable = result.value;
|
||
if (thenable) {
|
||
safelyResolveThenable(self2, thenable);
|
||
} else {
|
||
self2.state = FULFILLED;
|
||
self2.outcome = value;
|
||
var i = -1;
|
||
var len = self2.queue.length;
|
||
while (++i < len) {
|
||
self2.queue[i].callFulfilled(value);
|
||
}
|
||
}
|
||
return self2;
|
||
};
|
||
handlers.reject = function(self2, error) {
|
||
self2.state = REJECTED;
|
||
self2.outcome = error;
|
||
var i = -1;
|
||
var len = self2.queue.length;
|
||
while (++i < len) {
|
||
self2.queue[i].callRejected(error);
|
||
}
|
||
return self2;
|
||
};
|
||
function getThen(obj) {
|
||
var then = obj && obj.then;
|
||
if (obj && (typeof obj === "object" || typeof obj === "function") && typeof then === "function") {
|
||
return function appyThen() {
|
||
then.apply(obj, arguments);
|
||
};
|
||
}
|
||
}
|
||
function safelyResolveThenable(self2, thenable) {
|
||
var called = false;
|
||
function onError(value) {
|
||
if (called) {
|
||
return;
|
||
}
|
||
called = true;
|
||
handlers.reject(self2, value);
|
||
}
|
||
function onSuccess(value) {
|
||
if (called) {
|
||
return;
|
||
}
|
||
called = true;
|
||
handlers.resolve(self2, value);
|
||
}
|
||
function tryToUnwrap() {
|
||
thenable(onSuccess, onError);
|
||
}
|
||
var result = tryCatch(tryToUnwrap);
|
||
if (result.status === "error") {
|
||
onError(result.value);
|
||
}
|
||
}
|
||
function tryCatch(func, value) {
|
||
var out = {};
|
||
try {
|
||
out.value = func(value);
|
||
out.status = "success";
|
||
} catch (e) {
|
||
out.status = "error";
|
||
out.value = e;
|
||
}
|
||
return out;
|
||
}
|
||
Promise2.resolve = resolve;
|
||
function resolve(value) {
|
||
if (value instanceof this) {
|
||
return value;
|
||
}
|
||
return handlers.resolve(new this(INTERNAL), value);
|
||
}
|
||
Promise2.reject = reject;
|
||
function reject(reason) {
|
||
var promise = new this(INTERNAL);
|
||
return handlers.reject(promise, reason);
|
||
}
|
||
Promise2.all = all;
|
||
function all(iterable) {
|
||
var self2 = this;
|
||
if (Object.prototype.toString.call(iterable) !== "[object Array]") {
|
||
return this.reject(new TypeError("must be an array"));
|
||
}
|
||
var len = iterable.length;
|
||
var called = false;
|
||
if (!len) {
|
||
return this.resolve([]);
|
||
}
|
||
var values = new Array(len);
|
||
var resolved = 0;
|
||
var i = -1;
|
||
var promise = new this(INTERNAL);
|
||
while (++i < len) {
|
||
allResolver(iterable[i], i);
|
||
}
|
||
return promise;
|
||
function allResolver(value, i2) {
|
||
self2.resolve(value).then(resolveFromAll, function(error) {
|
||
if (!called) {
|
||
called = true;
|
||
handlers.reject(promise, error);
|
||
}
|
||
});
|
||
function resolveFromAll(outValue) {
|
||
values[i2] = outValue;
|
||
if (++resolved === len && !called) {
|
||
called = true;
|
||
handlers.resolve(promise, values);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
Promise2.race = race;
|
||
function race(iterable) {
|
||
var self2 = this;
|
||
if (Object.prototype.toString.call(iterable) !== "[object Array]") {
|
||
return this.reject(new TypeError("must be an array"));
|
||
}
|
||
var len = iterable.length;
|
||
var called = false;
|
||
if (!len) {
|
||
return this.resolve([]);
|
||
}
|
||
var i = -1;
|
||
var promise = new this(INTERNAL);
|
||
while (++i < len) {
|
||
resolver(iterable[i]);
|
||
}
|
||
return promise;
|
||
function resolver(value) {
|
||
self2.resolve(value).then(function(response) {
|
||
if (!called) {
|
||
called = true;
|
||
handlers.resolve(promise, response);
|
||
}
|
||
}, function(error) {
|
||
if (!called) {
|
||
called = true;
|
||
handlers.reject(promise, error);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
}, { "immediate": 36 }], 38: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var assign = require2("./lib/utils/common").assign;
|
||
var deflate = require2("./lib/deflate");
|
||
var inflate = require2("./lib/inflate");
|
||
var constants = require2("./lib/zlib/constants");
|
||
var pako = {};
|
||
assign(pako, deflate, inflate, constants);
|
||
module4.exports = pako;
|
||
}, { "./lib/deflate": 39, "./lib/inflate": 40, "./lib/utils/common": 41, "./lib/zlib/constants": 44 }], 39: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var zlib_deflate = require2("./zlib/deflate");
|
||
var utils = require2("./utils/common");
|
||
var strings = require2("./utils/strings");
|
||
var msg = require2("./zlib/messages");
|
||
var ZStream = require2("./zlib/zstream");
|
||
var toString = Object.prototype.toString;
|
||
var Z_NO_FLUSH = 0;
|
||
var Z_FINISH = 4;
|
||
var Z_OK = 0;
|
||
var Z_STREAM_END = 1;
|
||
var Z_SYNC_FLUSH = 2;
|
||
var Z_DEFAULT_COMPRESSION = -1;
|
||
var Z_DEFAULT_STRATEGY = 0;
|
||
var Z_DEFLATED = 8;
|
||
function Deflate(options) {
|
||
if (!(this instanceof Deflate))
|
||
return new Deflate(options);
|
||
this.options = utils.assign({
|
||
level: Z_DEFAULT_COMPRESSION,
|
||
method: Z_DEFLATED,
|
||
chunkSize: 16384,
|
||
windowBits: 15,
|
||
memLevel: 8,
|
||
strategy: Z_DEFAULT_STRATEGY,
|
||
to: ""
|
||
}, options || {});
|
||
var opt = this.options;
|
||
if (opt.raw && opt.windowBits > 0) {
|
||
opt.windowBits = -opt.windowBits;
|
||
} else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) {
|
||
opt.windowBits += 16;
|
||
}
|
||
this.err = 0;
|
||
this.msg = "";
|
||
this.ended = false;
|
||
this.chunks = [];
|
||
this.strm = new ZStream();
|
||
this.strm.avail_out = 0;
|
||
var status = zlib_deflate.deflateInit2(this.strm, opt.level, opt.method, opt.windowBits, opt.memLevel, opt.strategy);
|
||
if (status !== Z_OK) {
|
||
throw new Error(msg[status]);
|
||
}
|
||
if (opt.header) {
|
||
zlib_deflate.deflateSetHeader(this.strm, opt.header);
|
||
}
|
||
if (opt.dictionary) {
|
||
var dict;
|
||
if (typeof opt.dictionary === "string") {
|
||
dict = strings.string2buf(opt.dictionary);
|
||
} else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {
|
||
dict = new Uint8Array(opt.dictionary);
|
||
} else {
|
||
dict = opt.dictionary;
|
||
}
|
||
status = zlib_deflate.deflateSetDictionary(this.strm, dict);
|
||
if (status !== Z_OK) {
|
||
throw new Error(msg[status]);
|
||
}
|
||
this._dict_set = true;
|
||
}
|
||
}
|
||
Deflate.prototype.push = function(data, mode) {
|
||
var strm = this.strm;
|
||
var chunkSize = this.options.chunkSize;
|
||
var status, _mode;
|
||
if (this.ended) {
|
||
return false;
|
||
}
|
||
_mode = mode === ~~mode ? mode : mode === true ? Z_FINISH : Z_NO_FLUSH;
|
||
if (typeof data === "string") {
|
||
strm.input = strings.string2buf(data);
|
||
} else if (toString.call(data) === "[object ArrayBuffer]") {
|
||
strm.input = new Uint8Array(data);
|
||
} else {
|
||
strm.input = data;
|
||
}
|
||
strm.next_in = 0;
|
||
strm.avail_in = strm.input.length;
|
||
do {
|
||
if (strm.avail_out === 0) {
|
||
strm.output = new utils.Buf8(chunkSize);
|
||
strm.next_out = 0;
|
||
strm.avail_out = chunkSize;
|
||
}
|
||
status = zlib_deflate.deflate(strm, _mode);
|
||
if (status !== Z_STREAM_END && status !== Z_OK) {
|
||
this.onEnd(status);
|
||
this.ended = true;
|
||
return false;
|
||
}
|
||
if (strm.avail_out === 0 || strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH)) {
|
||
if (this.options.to === "string") {
|
||
this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));
|
||
} else {
|
||
this.onData(utils.shrinkBuf(strm.output, strm.next_out));
|
||
}
|
||
}
|
||
} while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END);
|
||
if (_mode === Z_FINISH) {
|
||
status = zlib_deflate.deflateEnd(this.strm);
|
||
this.onEnd(status);
|
||
this.ended = true;
|
||
return status === Z_OK;
|
||
}
|
||
if (_mode === Z_SYNC_FLUSH) {
|
||
this.onEnd(Z_OK);
|
||
strm.avail_out = 0;
|
||
return true;
|
||
}
|
||
return true;
|
||
};
|
||
Deflate.prototype.onData = function(chunk) {
|
||
this.chunks.push(chunk);
|
||
};
|
||
Deflate.prototype.onEnd = function(status) {
|
||
if (status === Z_OK) {
|
||
if (this.options.to === "string") {
|
||
this.result = this.chunks.join("");
|
||
} else {
|
||
this.result = utils.flattenChunks(this.chunks);
|
||
}
|
||
}
|
||
this.chunks = [];
|
||
this.err = status;
|
||
this.msg = this.strm.msg;
|
||
};
|
||
function deflate(input, options) {
|
||
var deflator = new Deflate(options);
|
||
deflator.push(input, true);
|
||
if (deflator.err) {
|
||
throw deflator.msg || msg[deflator.err];
|
||
}
|
||
return deflator.result;
|
||
}
|
||
function deflateRaw(input, options) {
|
||
options = options || {};
|
||
options.raw = true;
|
||
return deflate(input, options);
|
||
}
|
||
function gzip(input, options) {
|
||
options = options || {};
|
||
options.gzip = true;
|
||
return deflate(input, options);
|
||
}
|
||
exports3.Deflate = Deflate;
|
||
exports3.deflate = deflate;
|
||
exports3.deflateRaw = deflateRaw;
|
||
exports3.gzip = gzip;
|
||
}, { "./utils/common": 41, "./utils/strings": 42, "./zlib/deflate": 46, "./zlib/messages": 51, "./zlib/zstream": 53 }], 40: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var zlib_inflate = require2("./zlib/inflate");
|
||
var utils = require2("./utils/common");
|
||
var strings = require2("./utils/strings");
|
||
var c = require2("./zlib/constants");
|
||
var msg = require2("./zlib/messages");
|
||
var ZStream = require2("./zlib/zstream");
|
||
var GZheader = require2("./zlib/gzheader");
|
||
var toString = Object.prototype.toString;
|
||
function Inflate(options) {
|
||
if (!(this instanceof Inflate))
|
||
return new Inflate(options);
|
||
this.options = utils.assign({
|
||
chunkSize: 16384,
|
||
windowBits: 0,
|
||
to: ""
|
||
}, options || {});
|
||
var opt = this.options;
|
||
if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {
|
||
opt.windowBits = -opt.windowBits;
|
||
if (opt.windowBits === 0) {
|
||
opt.windowBits = -15;
|
||
}
|
||
}
|
||
if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {
|
||
opt.windowBits += 32;
|
||
}
|
||
if (opt.windowBits > 15 && opt.windowBits < 48) {
|
||
if ((opt.windowBits & 15) === 0) {
|
||
opt.windowBits |= 15;
|
||
}
|
||
}
|
||
this.err = 0;
|
||
this.msg = "";
|
||
this.ended = false;
|
||
this.chunks = [];
|
||
this.strm = new ZStream();
|
||
this.strm.avail_out = 0;
|
||
var status = zlib_inflate.inflateInit2(this.strm, opt.windowBits);
|
||
if (status !== c.Z_OK) {
|
||
throw new Error(msg[status]);
|
||
}
|
||
this.header = new GZheader();
|
||
zlib_inflate.inflateGetHeader(this.strm, this.header);
|
||
}
|
||
Inflate.prototype.push = function(data, mode) {
|
||
var strm = this.strm;
|
||
var chunkSize = this.options.chunkSize;
|
||
var dictionary = this.options.dictionary;
|
||
var status, _mode;
|
||
var next_out_utf8, tail, utf8str;
|
||
var dict;
|
||
var allowBufError = false;
|
||
if (this.ended) {
|
||
return false;
|
||
}
|
||
_mode = mode === ~~mode ? mode : mode === true ? c.Z_FINISH : c.Z_NO_FLUSH;
|
||
if (typeof data === "string") {
|
||
strm.input = strings.binstring2buf(data);
|
||
} else if (toString.call(data) === "[object ArrayBuffer]") {
|
||
strm.input = new Uint8Array(data);
|
||
} else {
|
||
strm.input = data;
|
||
}
|
||
strm.next_in = 0;
|
||
strm.avail_in = strm.input.length;
|
||
do {
|
||
if (strm.avail_out === 0) {
|
||
strm.output = new utils.Buf8(chunkSize);
|
||
strm.next_out = 0;
|
||
strm.avail_out = chunkSize;
|
||
}
|
||
status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH);
|
||
if (status === c.Z_NEED_DICT && dictionary) {
|
||
if (typeof dictionary === "string") {
|
||
dict = strings.string2buf(dictionary);
|
||
} else if (toString.call(dictionary) === "[object ArrayBuffer]") {
|
||
dict = new Uint8Array(dictionary);
|
||
} else {
|
||
dict = dictionary;
|
||
}
|
||
status = zlib_inflate.inflateSetDictionary(this.strm, dict);
|
||
}
|
||
if (status === c.Z_BUF_ERROR && allowBufError === true) {
|
||
status = c.Z_OK;
|
||
allowBufError = false;
|
||
}
|
||
if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
|
||
this.onEnd(status);
|
||
this.ended = true;
|
||
return false;
|
||
}
|
||
if (strm.next_out) {
|
||
if (strm.avail_out === 0 || status === c.Z_STREAM_END || strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH)) {
|
||
if (this.options.to === "string") {
|
||
next_out_utf8 = strings.utf8border(strm.output, strm.next_out);
|
||
tail = strm.next_out - next_out_utf8;
|
||
utf8str = strings.buf2string(strm.output, next_out_utf8);
|
||
strm.next_out = tail;
|
||
strm.avail_out = chunkSize - tail;
|
||
if (tail) {
|
||
utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0);
|
||
}
|
||
this.onData(utf8str);
|
||
} else {
|
||
this.onData(utils.shrinkBuf(strm.output, strm.next_out));
|
||
}
|
||
}
|
||
}
|
||
if (strm.avail_in === 0 && strm.avail_out === 0) {
|
||
allowBufError = true;
|
||
}
|
||
} while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);
|
||
if (status === c.Z_STREAM_END) {
|
||
_mode = c.Z_FINISH;
|
||
}
|
||
if (_mode === c.Z_FINISH) {
|
||
status = zlib_inflate.inflateEnd(this.strm);
|
||
this.onEnd(status);
|
||
this.ended = true;
|
||
return status === c.Z_OK;
|
||
}
|
||
if (_mode === c.Z_SYNC_FLUSH) {
|
||
this.onEnd(c.Z_OK);
|
||
strm.avail_out = 0;
|
||
return true;
|
||
}
|
||
return true;
|
||
};
|
||
Inflate.prototype.onData = function(chunk) {
|
||
this.chunks.push(chunk);
|
||
};
|
||
Inflate.prototype.onEnd = function(status) {
|
||
if (status === c.Z_OK) {
|
||
if (this.options.to === "string") {
|
||
this.result = this.chunks.join("");
|
||
} else {
|
||
this.result = utils.flattenChunks(this.chunks);
|
||
}
|
||
}
|
||
this.chunks = [];
|
||
this.err = status;
|
||
this.msg = this.strm.msg;
|
||
};
|
||
function inflate(input, options) {
|
||
var inflator = new Inflate(options);
|
||
inflator.push(input, true);
|
||
if (inflator.err) {
|
||
throw inflator.msg || msg[inflator.err];
|
||
}
|
||
return inflator.result;
|
||
}
|
||
function inflateRaw(input, options) {
|
||
options = options || {};
|
||
options.raw = true;
|
||
return inflate(input, options);
|
||
}
|
||
exports3.Inflate = Inflate;
|
||
exports3.inflate = inflate;
|
||
exports3.inflateRaw = inflateRaw;
|
||
exports3.ungzip = inflate;
|
||
}, { "./utils/common": 41, "./utils/strings": 42, "./zlib/constants": 44, "./zlib/gzheader": 47, "./zlib/inflate": 49, "./zlib/messages": 51, "./zlib/zstream": 53 }], 41: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined";
|
||
exports3.assign = function(obj) {
|
||
var sources = Array.prototype.slice.call(arguments, 1);
|
||
while (sources.length) {
|
||
var source = sources.shift();
|
||
if (!source) {
|
||
continue;
|
||
}
|
||
if (typeof source !== "object") {
|
||
throw new TypeError(source + "must be non-object");
|
||
}
|
||
for (var p in source) {
|
||
if (source.hasOwnProperty(p)) {
|
||
obj[p] = source[p];
|
||
}
|
||
}
|
||
}
|
||
return obj;
|
||
};
|
||
exports3.shrinkBuf = function(buf, size) {
|
||
if (buf.length === size) {
|
||
return buf;
|
||
}
|
||
if (buf.subarray) {
|
||
return buf.subarray(0, size);
|
||
}
|
||
buf.length = size;
|
||
return buf;
|
||
};
|
||
var fnTyped = {
|
||
arraySet: function(dest, src, src_offs, len, dest_offs) {
|
||
if (src.subarray && dest.subarray) {
|
||
dest.set(src.subarray(src_offs, src_offs + len), dest_offs);
|
||
return;
|
||
}
|
||
for (var i = 0; i < len; i++) {
|
||
dest[dest_offs + i] = src[src_offs + i];
|
||
}
|
||
},
|
||
flattenChunks: function(chunks) {
|
||
var i, l, len, pos, chunk, result;
|
||
len = 0;
|
||
for (i = 0, l = chunks.length; i < l; i++) {
|
||
len += chunks[i].length;
|
||
}
|
||
result = new Uint8Array(len);
|
||
pos = 0;
|
||
for (i = 0, l = chunks.length; i < l; i++) {
|
||
chunk = chunks[i];
|
||
result.set(chunk, pos);
|
||
pos += chunk.length;
|
||
}
|
||
return result;
|
||
}
|
||
};
|
||
var fnUntyped = {
|
||
arraySet: function(dest, src, src_offs, len, dest_offs) {
|
||
for (var i = 0; i < len; i++) {
|
||
dest[dest_offs + i] = src[src_offs + i];
|
||
}
|
||
},
|
||
flattenChunks: function(chunks) {
|
||
return [].concat.apply([], chunks);
|
||
}
|
||
};
|
||
exports3.setTyped = function(on) {
|
||
if (on) {
|
||
exports3.Buf8 = Uint8Array;
|
||
exports3.Buf16 = Uint16Array;
|
||
exports3.Buf32 = Int32Array;
|
||
exports3.assign(exports3, fnTyped);
|
||
} else {
|
||
exports3.Buf8 = Array;
|
||
exports3.Buf16 = Array;
|
||
exports3.Buf32 = Array;
|
||
exports3.assign(exports3, fnUntyped);
|
||
}
|
||
};
|
||
exports3.setTyped(TYPED_OK);
|
||
}, {}], 42: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("./common");
|
||
var STR_APPLY_OK = true;
|
||
var STR_APPLY_UIA_OK = true;
|
||
try {
|
||
String.fromCharCode.apply(null, [0]);
|
||
} catch (__) {
|
||
STR_APPLY_OK = false;
|
||
}
|
||
try {
|
||
String.fromCharCode.apply(null, new Uint8Array(1));
|
||
} catch (__) {
|
||
STR_APPLY_UIA_OK = false;
|
||
}
|
||
var _utf8len = new utils.Buf8(256);
|
||
for (var q = 0; q < 256; q++) {
|
||
_utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;
|
||
}
|
||
_utf8len[254] = _utf8len[254] = 1;
|
||
exports3.string2buf = function(str) {
|
||
var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;
|
||
for (m_pos = 0; m_pos < str_len; m_pos++) {
|
||
c = str.charCodeAt(m_pos);
|
||
if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
|
||
c2 = str.charCodeAt(m_pos + 1);
|
||
if ((c2 & 64512) === 56320) {
|
||
c = 65536 + (c - 55296 << 10) + (c2 - 56320);
|
||
m_pos++;
|
||
}
|
||
}
|
||
buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;
|
||
}
|
||
buf = new utils.Buf8(buf_len);
|
||
for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
|
||
c = str.charCodeAt(m_pos);
|
||
if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
|
||
c2 = str.charCodeAt(m_pos + 1);
|
||
if ((c2 & 64512) === 56320) {
|
||
c = 65536 + (c - 55296 << 10) + (c2 - 56320);
|
||
m_pos++;
|
||
}
|
||
}
|
||
if (c < 128) {
|
||
buf[i++] = c;
|
||
} else if (c < 2048) {
|
||
buf[i++] = 192 | c >>> 6;
|
||
buf[i++] = 128 | c & 63;
|
||
} else if (c < 65536) {
|
||
buf[i++] = 224 | c >>> 12;
|
||
buf[i++] = 128 | c >>> 6 & 63;
|
||
buf[i++] = 128 | c & 63;
|
||
} else {
|
||
buf[i++] = 240 | c >>> 18;
|
||
buf[i++] = 128 | c >>> 12 & 63;
|
||
buf[i++] = 128 | c >>> 6 & 63;
|
||
buf[i++] = 128 | c & 63;
|
||
}
|
||
}
|
||
return buf;
|
||
};
|
||
function buf2binstring(buf, len) {
|
||
if (len < 65537) {
|
||
if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) {
|
||
return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));
|
||
}
|
||
}
|
||
var result = "";
|
||
for (var i = 0; i < len; i++) {
|
||
result += String.fromCharCode(buf[i]);
|
||
}
|
||
return result;
|
||
}
|
||
exports3.buf2binstring = function(buf) {
|
||
return buf2binstring(buf, buf.length);
|
||
};
|
||
exports3.binstring2buf = function(str) {
|
||
var buf = new utils.Buf8(str.length);
|
||
for (var i = 0, len = buf.length; i < len; i++) {
|
||
buf[i] = str.charCodeAt(i);
|
||
}
|
||
return buf;
|
||
};
|
||
exports3.buf2string = function(buf, max) {
|
||
var i, out, c, c_len;
|
||
var len = max || buf.length;
|
||
var utf16buf = new Array(len * 2);
|
||
for (out = 0, i = 0; i < len; ) {
|
||
c = buf[i++];
|
||
if (c < 128) {
|
||
utf16buf[out++] = c;
|
||
continue;
|
||
}
|
||
c_len = _utf8len[c];
|
||
if (c_len > 4) {
|
||
utf16buf[out++] = 65533;
|
||
i += c_len - 1;
|
||
continue;
|
||
}
|
||
c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;
|
||
while (c_len > 1 && i < len) {
|
||
c = c << 6 | buf[i++] & 63;
|
||
c_len--;
|
||
}
|
||
if (c_len > 1) {
|
||
utf16buf[out++] = 65533;
|
||
continue;
|
||
}
|
||
if (c < 65536) {
|
||
utf16buf[out++] = c;
|
||
} else {
|
||
c -= 65536;
|
||
utf16buf[out++] = 55296 | c >> 10 & 1023;
|
||
utf16buf[out++] = 56320 | c & 1023;
|
||
}
|
||
}
|
||
return buf2binstring(utf16buf, out);
|
||
};
|
||
exports3.utf8border = function(buf, max) {
|
||
var pos;
|
||
max = max || buf.length;
|
||
if (max > buf.length) {
|
||
max = buf.length;
|
||
}
|
||
pos = max - 1;
|
||
while (pos >= 0 && (buf[pos] & 192) === 128) {
|
||
pos--;
|
||
}
|
||
if (pos < 0) {
|
||
return max;
|
||
}
|
||
if (pos === 0) {
|
||
return max;
|
||
}
|
||
return pos + _utf8len[buf[pos]] > max ? pos : max;
|
||
};
|
||
}, { "./common": 41 }], 43: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
function adler32(adler, buf, len, pos) {
|
||
var s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;
|
||
while (len !== 0) {
|
||
n = len > 2e3 ? 2e3 : len;
|
||
len -= n;
|
||
do {
|
||
s1 = s1 + buf[pos++] | 0;
|
||
s2 = s2 + s1 | 0;
|
||
} while (--n);
|
||
s1 %= 65521;
|
||
s2 %= 65521;
|
||
}
|
||
return s1 | s2 << 16 | 0;
|
||
}
|
||
module4.exports = adler32;
|
||
}, {}], 44: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
module4.exports = {
|
||
Z_NO_FLUSH: 0,
|
||
Z_PARTIAL_FLUSH: 1,
|
||
Z_SYNC_FLUSH: 2,
|
||
Z_FULL_FLUSH: 3,
|
||
Z_FINISH: 4,
|
||
Z_BLOCK: 5,
|
||
Z_TREES: 6,
|
||
Z_OK: 0,
|
||
Z_STREAM_END: 1,
|
||
Z_NEED_DICT: 2,
|
||
Z_ERRNO: -1,
|
||
Z_STREAM_ERROR: -2,
|
||
Z_DATA_ERROR: -3,
|
||
Z_BUF_ERROR: -5,
|
||
Z_NO_COMPRESSION: 0,
|
||
Z_BEST_SPEED: 1,
|
||
Z_BEST_COMPRESSION: 9,
|
||
Z_DEFAULT_COMPRESSION: -1,
|
||
Z_FILTERED: 1,
|
||
Z_HUFFMAN_ONLY: 2,
|
||
Z_RLE: 3,
|
||
Z_FIXED: 4,
|
||
Z_DEFAULT_STRATEGY: 0,
|
||
Z_BINARY: 0,
|
||
Z_TEXT: 1,
|
||
Z_UNKNOWN: 2,
|
||
Z_DEFLATED: 8
|
||
};
|
||
}, {}], 45: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
function makeTable() {
|
||
var c, table = [];
|
||
for (var n = 0; n < 256; n++) {
|
||
c = n;
|
||
for (var k = 0; k < 8; k++) {
|
||
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
||
}
|
||
table[n] = c;
|
||
}
|
||
return table;
|
||
}
|
||
var crcTable = makeTable();
|
||
function crc32(crc, buf, len, pos) {
|
||
var t = crcTable, end = pos + len;
|
||
crc ^= -1;
|
||
for (var i = pos; i < end; i++) {
|
||
crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];
|
||
}
|
||
return crc ^ -1;
|
||
}
|
||
module4.exports = crc32;
|
||
}, {}], 46: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("../utils/common");
|
||
var trees = require2("./trees");
|
||
var adler32 = require2("./adler32");
|
||
var crc32 = require2("./crc32");
|
||
var msg = require2("./messages");
|
||
var Z_NO_FLUSH = 0;
|
||
var Z_PARTIAL_FLUSH = 1;
|
||
var Z_FULL_FLUSH = 3;
|
||
var Z_FINISH = 4;
|
||
var Z_BLOCK = 5;
|
||
var Z_OK = 0;
|
||
var Z_STREAM_END = 1;
|
||
var Z_STREAM_ERROR = -2;
|
||
var Z_DATA_ERROR = -3;
|
||
var Z_BUF_ERROR = -5;
|
||
var Z_DEFAULT_COMPRESSION = -1;
|
||
var Z_FILTERED = 1;
|
||
var Z_HUFFMAN_ONLY = 2;
|
||
var Z_RLE = 3;
|
||
var Z_FIXED = 4;
|
||
var Z_DEFAULT_STRATEGY = 0;
|
||
var Z_UNKNOWN = 2;
|
||
var Z_DEFLATED = 8;
|
||
var MAX_MEM_LEVEL = 9;
|
||
var MAX_WBITS = 15;
|
||
var DEF_MEM_LEVEL = 8;
|
||
var LENGTH_CODES = 29;
|
||
var LITERALS = 256;
|
||
var L_CODES = LITERALS + 1 + LENGTH_CODES;
|
||
var D_CODES = 30;
|
||
var BL_CODES = 19;
|
||
var HEAP_SIZE = 2 * L_CODES + 1;
|
||
var MAX_BITS = 15;
|
||
var MIN_MATCH = 3;
|
||
var MAX_MATCH = 258;
|
||
var MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;
|
||
var PRESET_DICT = 32;
|
||
var INIT_STATE = 42;
|
||
var EXTRA_STATE = 69;
|
||
var NAME_STATE = 73;
|
||
var COMMENT_STATE = 91;
|
||
var HCRC_STATE = 103;
|
||
var BUSY_STATE = 113;
|
||
var FINISH_STATE = 666;
|
||
var BS_NEED_MORE = 1;
|
||
var BS_BLOCK_DONE = 2;
|
||
var BS_FINISH_STARTED = 3;
|
||
var BS_FINISH_DONE = 4;
|
||
var OS_CODE = 3;
|
||
function err(strm, errorCode) {
|
||
strm.msg = msg[errorCode];
|
||
return errorCode;
|
||
}
|
||
function rank(f) {
|
||
return (f << 1) - (f > 4 ? 9 : 0);
|
||
}
|
||
function zero(buf) {
|
||
var len = buf.length;
|
||
while (--len >= 0) {
|
||
buf[len] = 0;
|
||
}
|
||
}
|
||
function flush_pending(strm) {
|
||
var s = strm.state;
|
||
var len = s.pending;
|
||
if (len > strm.avail_out) {
|
||
len = strm.avail_out;
|
||
}
|
||
if (len === 0) {
|
||
return;
|
||
}
|
||
utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);
|
||
strm.next_out += len;
|
||
s.pending_out += len;
|
||
strm.total_out += len;
|
||
strm.avail_out -= len;
|
||
s.pending -= len;
|
||
if (s.pending === 0) {
|
||
s.pending_out = 0;
|
||
}
|
||
}
|
||
function flush_block_only(s, last) {
|
||
trees._tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last);
|
||
s.block_start = s.strstart;
|
||
flush_pending(s.strm);
|
||
}
|
||
function put_byte(s, b) {
|
||
s.pending_buf[s.pending++] = b;
|
||
}
|
||
function putShortMSB(s, b) {
|
||
s.pending_buf[s.pending++] = b >>> 8 & 255;
|
||
s.pending_buf[s.pending++] = b & 255;
|
||
}
|
||
function read_buf(strm, buf, start, size) {
|
||
var len = strm.avail_in;
|
||
if (len > size) {
|
||
len = size;
|
||
}
|
||
if (len === 0) {
|
||
return 0;
|
||
}
|
||
strm.avail_in -= len;
|
||
utils.arraySet(buf, strm.input, strm.next_in, len, start);
|
||
if (strm.state.wrap === 1) {
|
||
strm.adler = adler32(strm.adler, buf, len, start);
|
||
} else if (strm.state.wrap === 2) {
|
||
strm.adler = crc32(strm.adler, buf, len, start);
|
||
}
|
||
strm.next_in += len;
|
||
strm.total_in += len;
|
||
return len;
|
||
}
|
||
function longest_match(s, cur_match) {
|
||
var chain_length = s.max_chain_length;
|
||
var scan = s.strstart;
|
||
var match;
|
||
var len;
|
||
var best_len = s.prev_length;
|
||
var nice_match = s.nice_match;
|
||
var limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0;
|
||
var _win = s.window;
|
||
var wmask = s.w_mask;
|
||
var prev = s.prev;
|
||
var strend = s.strstart + MAX_MATCH;
|
||
var scan_end1 = _win[scan + best_len - 1];
|
||
var scan_end = _win[scan + best_len];
|
||
if (s.prev_length >= s.good_match) {
|
||
chain_length >>= 2;
|
||
}
|
||
if (nice_match > s.lookahead) {
|
||
nice_match = s.lookahead;
|
||
}
|
||
do {
|
||
match = cur_match;
|
||
if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) {
|
||
continue;
|
||
}
|
||
scan += 2;
|
||
match++;
|
||
do {
|
||
} while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend);
|
||
len = MAX_MATCH - (strend - scan);
|
||
scan = strend - MAX_MATCH;
|
||
if (len > best_len) {
|
||
s.match_start = cur_match;
|
||
best_len = len;
|
||
if (len >= nice_match) {
|
||
break;
|
||
}
|
||
scan_end1 = _win[scan + best_len - 1];
|
||
scan_end = _win[scan + best_len];
|
||
}
|
||
} while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);
|
||
if (best_len <= s.lookahead) {
|
||
return best_len;
|
||
}
|
||
return s.lookahead;
|
||
}
|
||
function fill_window(s) {
|
||
var _w_size = s.w_size;
|
||
var p, n, m, more, str;
|
||
do {
|
||
more = s.window_size - s.lookahead - s.strstart;
|
||
if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
|
||
utils.arraySet(s.window, s.window, _w_size, _w_size, 0);
|
||
s.match_start -= _w_size;
|
||
s.strstart -= _w_size;
|
||
s.block_start -= _w_size;
|
||
n = s.hash_size;
|
||
p = n;
|
||
do {
|
||
m = s.head[--p];
|
||
s.head[p] = m >= _w_size ? m - _w_size : 0;
|
||
} while (--n);
|
||
n = _w_size;
|
||
p = n;
|
||
do {
|
||
m = s.prev[--p];
|
||
s.prev[p] = m >= _w_size ? m - _w_size : 0;
|
||
} while (--n);
|
||
more += _w_size;
|
||
}
|
||
if (s.strm.avail_in === 0) {
|
||
break;
|
||
}
|
||
n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);
|
||
s.lookahead += n;
|
||
if (s.lookahead + s.insert >= MIN_MATCH) {
|
||
str = s.strstart - s.insert;
|
||
s.ins_h = s.window[str];
|
||
s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + 1]) & s.hash_mask;
|
||
while (s.insert) {
|
||
s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;
|
||
s.prev[str & s.w_mask] = s.head[s.ins_h];
|
||
s.head[s.ins_h] = str;
|
||
str++;
|
||
s.insert--;
|
||
if (s.lookahead + s.insert < MIN_MATCH) {
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
} while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);
|
||
}
|
||
function deflate_stored(s, flush) {
|
||
var max_block_size = 65535;
|
||
if (max_block_size > s.pending_buf_size - 5) {
|
||
max_block_size = s.pending_buf_size - 5;
|
||
}
|
||
for (; ; ) {
|
||
if (s.lookahead <= 1) {
|
||
fill_window(s);
|
||
if (s.lookahead === 0 && flush === Z_NO_FLUSH) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
if (s.lookahead === 0) {
|
||
break;
|
||
}
|
||
}
|
||
s.strstart += s.lookahead;
|
||
s.lookahead = 0;
|
||
var max_start = s.block_start + max_block_size;
|
||
if (s.strstart === 0 || s.strstart >= max_start) {
|
||
s.lookahead = s.strstart - max_start;
|
||
s.strstart = max_start;
|
||
flush_block_only(s, false);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
}
|
||
if (s.strstart - s.block_start >= s.w_size - MIN_LOOKAHEAD) {
|
||
flush_block_only(s, false);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
}
|
||
}
|
||
s.insert = 0;
|
||
if (flush === Z_FINISH) {
|
||
flush_block_only(s, true);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_FINISH_STARTED;
|
||
}
|
||
return BS_FINISH_DONE;
|
||
}
|
||
if (s.strstart > s.block_start) {
|
||
flush_block_only(s, false);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
}
|
||
return BS_NEED_MORE;
|
||
}
|
||
function deflate_fast(s, flush) {
|
||
var hash_head;
|
||
var bflush;
|
||
for (; ; ) {
|
||
if (s.lookahead < MIN_LOOKAHEAD) {
|
||
fill_window(s);
|
||
if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
if (s.lookahead === 0) {
|
||
break;
|
||
}
|
||
}
|
||
hash_head = 0;
|
||
if (s.lookahead >= MIN_MATCH) {
|
||
s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
|
||
hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
|
||
s.head[s.ins_h] = s.strstart;
|
||
}
|
||
if (hash_head !== 0 && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {
|
||
s.match_length = longest_match(s, hash_head);
|
||
}
|
||
if (s.match_length >= MIN_MATCH) {
|
||
bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);
|
||
s.lookahead -= s.match_length;
|
||
if (s.match_length <= s.max_lazy_match && s.lookahead >= MIN_MATCH) {
|
||
s.match_length--;
|
||
do {
|
||
s.strstart++;
|
||
s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
|
||
hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
|
||
s.head[s.ins_h] = s.strstart;
|
||
} while (--s.match_length !== 0);
|
||
s.strstart++;
|
||
} else {
|
||
s.strstart += s.match_length;
|
||
s.match_length = 0;
|
||
s.ins_h = s.window[s.strstart];
|
||
s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + 1]) & s.hash_mask;
|
||
}
|
||
} else {
|
||
bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
|
||
s.lookahead--;
|
||
s.strstart++;
|
||
}
|
||
if (bflush) {
|
||
flush_block_only(s, false);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
}
|
||
}
|
||
s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;
|
||
if (flush === Z_FINISH) {
|
||
flush_block_only(s, true);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_FINISH_STARTED;
|
||
}
|
||
return BS_FINISH_DONE;
|
||
}
|
||
if (s.last_lit) {
|
||
flush_block_only(s, false);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
}
|
||
return BS_BLOCK_DONE;
|
||
}
|
||
function deflate_slow(s, flush) {
|
||
var hash_head;
|
||
var bflush;
|
||
var max_insert;
|
||
for (; ; ) {
|
||
if (s.lookahead < MIN_LOOKAHEAD) {
|
||
fill_window(s);
|
||
if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
if (s.lookahead === 0) {
|
||
break;
|
||
}
|
||
}
|
||
hash_head = 0;
|
||
if (s.lookahead >= MIN_MATCH) {
|
||
s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
|
||
hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
|
||
s.head[s.ins_h] = s.strstart;
|
||
}
|
||
s.prev_length = s.match_length;
|
||
s.prev_match = s.match_start;
|
||
s.match_length = MIN_MATCH - 1;
|
||
if (hash_head !== 0 && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {
|
||
s.match_length = longest_match(s, hash_head);
|
||
if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096)) {
|
||
s.match_length = MIN_MATCH - 1;
|
||
}
|
||
}
|
||
if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {
|
||
max_insert = s.strstart + s.lookahead - MIN_MATCH;
|
||
bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);
|
||
s.lookahead -= s.prev_length - 1;
|
||
s.prev_length -= 2;
|
||
do {
|
||
if (++s.strstart <= max_insert) {
|
||
s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
|
||
hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
|
||
s.head[s.ins_h] = s.strstart;
|
||
}
|
||
} while (--s.prev_length !== 0);
|
||
s.match_available = 0;
|
||
s.match_length = MIN_MATCH - 1;
|
||
s.strstart++;
|
||
if (bflush) {
|
||
flush_block_only(s, false);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
}
|
||
} else if (s.match_available) {
|
||
bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
|
||
if (bflush) {
|
||
flush_block_only(s, false);
|
||
}
|
||
s.strstart++;
|
||
s.lookahead--;
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
} else {
|
||
s.match_available = 1;
|
||
s.strstart++;
|
||
s.lookahead--;
|
||
}
|
||
}
|
||
if (s.match_available) {
|
||
bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
|
||
s.match_available = 0;
|
||
}
|
||
s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;
|
||
if (flush === Z_FINISH) {
|
||
flush_block_only(s, true);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_FINISH_STARTED;
|
||
}
|
||
return BS_FINISH_DONE;
|
||
}
|
||
if (s.last_lit) {
|
||
flush_block_only(s, false);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
}
|
||
return BS_BLOCK_DONE;
|
||
}
|
||
function deflate_rle(s, flush) {
|
||
var bflush;
|
||
var prev;
|
||
var scan, strend;
|
||
var _win = s.window;
|
||
for (; ; ) {
|
||
if (s.lookahead <= MAX_MATCH) {
|
||
fill_window(s);
|
||
if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
if (s.lookahead === 0) {
|
||
break;
|
||
}
|
||
}
|
||
s.match_length = 0;
|
||
if (s.lookahead >= MIN_MATCH && s.strstart > 0) {
|
||
scan = s.strstart - 1;
|
||
prev = _win[scan];
|
||
if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {
|
||
strend = s.strstart + MAX_MATCH;
|
||
do {
|
||
} while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend);
|
||
s.match_length = MAX_MATCH - (strend - scan);
|
||
if (s.match_length > s.lookahead) {
|
||
s.match_length = s.lookahead;
|
||
}
|
||
}
|
||
}
|
||
if (s.match_length >= MIN_MATCH) {
|
||
bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);
|
||
s.lookahead -= s.match_length;
|
||
s.strstart += s.match_length;
|
||
s.match_length = 0;
|
||
} else {
|
||
bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
|
||
s.lookahead--;
|
||
s.strstart++;
|
||
}
|
||
if (bflush) {
|
||
flush_block_only(s, false);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
}
|
||
}
|
||
s.insert = 0;
|
||
if (flush === Z_FINISH) {
|
||
flush_block_only(s, true);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_FINISH_STARTED;
|
||
}
|
||
return BS_FINISH_DONE;
|
||
}
|
||
if (s.last_lit) {
|
||
flush_block_only(s, false);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
}
|
||
return BS_BLOCK_DONE;
|
||
}
|
||
function deflate_huff(s, flush) {
|
||
var bflush;
|
||
for (; ; ) {
|
||
if (s.lookahead === 0) {
|
||
fill_window(s);
|
||
if (s.lookahead === 0) {
|
||
if (flush === Z_NO_FLUSH) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
s.match_length = 0;
|
||
bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
|
||
s.lookahead--;
|
||
s.strstart++;
|
||
if (bflush) {
|
||
flush_block_only(s, false);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
}
|
||
}
|
||
s.insert = 0;
|
||
if (flush === Z_FINISH) {
|
||
flush_block_only(s, true);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_FINISH_STARTED;
|
||
}
|
||
return BS_FINISH_DONE;
|
||
}
|
||
if (s.last_lit) {
|
||
flush_block_only(s, false);
|
||
if (s.strm.avail_out === 0) {
|
||
return BS_NEED_MORE;
|
||
}
|
||
}
|
||
return BS_BLOCK_DONE;
|
||
}
|
||
function Config(good_length, max_lazy, nice_length, max_chain, func) {
|
||
this.good_length = good_length;
|
||
this.max_lazy = max_lazy;
|
||
this.nice_length = nice_length;
|
||
this.max_chain = max_chain;
|
||
this.func = func;
|
||
}
|
||
var configuration_table;
|
||
configuration_table = [
|
||
new Config(0, 0, 0, 0, deflate_stored),
|
||
new Config(4, 4, 8, 4, deflate_fast),
|
||
new Config(4, 5, 16, 8, deflate_fast),
|
||
new Config(4, 6, 32, 32, deflate_fast),
|
||
new Config(4, 4, 16, 16, deflate_slow),
|
||
new Config(8, 16, 32, 32, deflate_slow),
|
||
new Config(8, 16, 128, 128, deflate_slow),
|
||
new Config(8, 32, 128, 256, deflate_slow),
|
||
new Config(32, 128, 258, 1024, deflate_slow),
|
||
new Config(32, 258, 258, 4096, deflate_slow)
|
||
];
|
||
function lm_init(s) {
|
||
s.window_size = 2 * s.w_size;
|
||
zero(s.head);
|
||
s.max_lazy_match = configuration_table[s.level].max_lazy;
|
||
s.good_match = configuration_table[s.level].good_length;
|
||
s.nice_match = configuration_table[s.level].nice_length;
|
||
s.max_chain_length = configuration_table[s.level].max_chain;
|
||
s.strstart = 0;
|
||
s.block_start = 0;
|
||
s.lookahead = 0;
|
||
s.insert = 0;
|
||
s.match_length = s.prev_length = MIN_MATCH - 1;
|
||
s.match_available = 0;
|
||
s.ins_h = 0;
|
||
}
|
||
function DeflateState() {
|
||
this.strm = null;
|
||
this.status = 0;
|
||
this.pending_buf = null;
|
||
this.pending_buf_size = 0;
|
||
this.pending_out = 0;
|
||
this.pending = 0;
|
||
this.wrap = 0;
|
||
this.gzhead = null;
|
||
this.gzindex = 0;
|
||
this.method = Z_DEFLATED;
|
||
this.last_flush = -1;
|
||
this.w_size = 0;
|
||
this.w_bits = 0;
|
||
this.w_mask = 0;
|
||
this.window = null;
|
||
this.window_size = 0;
|
||
this.prev = null;
|
||
this.head = null;
|
||
this.ins_h = 0;
|
||
this.hash_size = 0;
|
||
this.hash_bits = 0;
|
||
this.hash_mask = 0;
|
||
this.hash_shift = 0;
|
||
this.block_start = 0;
|
||
this.match_length = 0;
|
||
this.prev_match = 0;
|
||
this.match_available = 0;
|
||
this.strstart = 0;
|
||
this.match_start = 0;
|
||
this.lookahead = 0;
|
||
this.prev_length = 0;
|
||
this.max_chain_length = 0;
|
||
this.max_lazy_match = 0;
|
||
this.level = 0;
|
||
this.strategy = 0;
|
||
this.good_match = 0;
|
||
this.nice_match = 0;
|
||
this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);
|
||
this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);
|
||
this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);
|
||
zero(this.dyn_ltree);
|
||
zero(this.dyn_dtree);
|
||
zero(this.bl_tree);
|
||
this.l_desc = null;
|
||
this.d_desc = null;
|
||
this.bl_desc = null;
|
||
this.bl_count = new utils.Buf16(MAX_BITS + 1);
|
||
this.heap = new utils.Buf16(2 * L_CODES + 1);
|
||
zero(this.heap);
|
||
this.heap_len = 0;
|
||
this.heap_max = 0;
|
||
this.depth = new utils.Buf16(2 * L_CODES + 1);
|
||
zero(this.depth);
|
||
this.l_buf = 0;
|
||
this.lit_bufsize = 0;
|
||
this.last_lit = 0;
|
||
this.d_buf = 0;
|
||
this.opt_len = 0;
|
||
this.static_len = 0;
|
||
this.matches = 0;
|
||
this.insert = 0;
|
||
this.bi_buf = 0;
|
||
this.bi_valid = 0;
|
||
}
|
||
function deflateResetKeep(strm) {
|
||
var s;
|
||
if (!strm || !strm.state) {
|
||
return err(strm, Z_STREAM_ERROR);
|
||
}
|
||
strm.total_in = strm.total_out = 0;
|
||
strm.data_type = Z_UNKNOWN;
|
||
s = strm.state;
|
||
s.pending = 0;
|
||
s.pending_out = 0;
|
||
if (s.wrap < 0) {
|
||
s.wrap = -s.wrap;
|
||
}
|
||
s.status = s.wrap ? INIT_STATE : BUSY_STATE;
|
||
strm.adler = s.wrap === 2 ? 0 : 1;
|
||
s.last_flush = Z_NO_FLUSH;
|
||
trees._tr_init(s);
|
||
return Z_OK;
|
||
}
|
||
function deflateReset(strm) {
|
||
var ret = deflateResetKeep(strm);
|
||
if (ret === Z_OK) {
|
||
lm_init(strm.state);
|
||
}
|
||
return ret;
|
||
}
|
||
function deflateSetHeader(strm, head) {
|
||
if (!strm || !strm.state) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
if (strm.state.wrap !== 2) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
strm.state.gzhead = head;
|
||
return Z_OK;
|
||
}
|
||
function deflateInit2(strm, level, method, windowBits, memLevel, strategy) {
|
||
if (!strm) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
var wrap = 1;
|
||
if (level === Z_DEFAULT_COMPRESSION) {
|
||
level = 6;
|
||
}
|
||
if (windowBits < 0) {
|
||
wrap = 0;
|
||
windowBits = -windowBits;
|
||
} else if (windowBits > 15) {
|
||
wrap = 2;
|
||
windowBits -= 16;
|
||
}
|
||
if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
|
||
return err(strm, Z_STREAM_ERROR);
|
||
}
|
||
if (windowBits === 8) {
|
||
windowBits = 9;
|
||
}
|
||
var s = new DeflateState();
|
||
strm.state = s;
|
||
s.strm = strm;
|
||
s.wrap = wrap;
|
||
s.gzhead = null;
|
||
s.w_bits = windowBits;
|
||
s.w_size = 1 << s.w_bits;
|
||
s.w_mask = s.w_size - 1;
|
||
s.hash_bits = memLevel + 7;
|
||
s.hash_size = 1 << s.hash_bits;
|
||
s.hash_mask = s.hash_size - 1;
|
||
s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);
|
||
s.window = new utils.Buf8(s.w_size * 2);
|
||
s.head = new utils.Buf16(s.hash_size);
|
||
s.prev = new utils.Buf16(s.w_size);
|
||
s.lit_bufsize = 1 << memLevel + 6;
|
||
s.pending_buf_size = s.lit_bufsize * 4;
|
||
s.pending_buf = new utils.Buf8(s.pending_buf_size);
|
||
s.d_buf = 1 * s.lit_bufsize;
|
||
s.l_buf = (1 + 2) * s.lit_bufsize;
|
||
s.level = level;
|
||
s.strategy = strategy;
|
||
s.method = method;
|
||
return deflateReset(strm);
|
||
}
|
||
function deflateInit(strm, level) {
|
||
return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
|
||
}
|
||
function deflate(strm, flush) {
|
||
var old_flush, s;
|
||
var beg, val;
|
||
if (!strm || !strm.state || flush > Z_BLOCK || flush < 0) {
|
||
return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;
|
||
}
|
||
s = strm.state;
|
||
if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE && flush !== Z_FINISH) {
|
||
return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR : Z_STREAM_ERROR);
|
||
}
|
||
s.strm = strm;
|
||
old_flush = s.last_flush;
|
||
s.last_flush = flush;
|
||
if (s.status === INIT_STATE) {
|
||
if (s.wrap === 2) {
|
||
strm.adler = 0;
|
||
put_byte(s, 31);
|
||
put_byte(s, 139);
|
||
put_byte(s, 8);
|
||
if (!s.gzhead) {
|
||
put_byte(s, 0);
|
||
put_byte(s, 0);
|
||
put_byte(s, 0);
|
||
put_byte(s, 0);
|
||
put_byte(s, 0);
|
||
put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);
|
||
put_byte(s, OS_CODE);
|
||
s.status = BUSY_STATE;
|
||
} else {
|
||
put_byte(s, (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16));
|
||
put_byte(s, s.gzhead.time & 255);
|
||
put_byte(s, s.gzhead.time >> 8 & 255);
|
||
put_byte(s, s.gzhead.time >> 16 & 255);
|
||
put_byte(s, s.gzhead.time >> 24 & 255);
|
||
put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);
|
||
put_byte(s, s.gzhead.os & 255);
|
||
if (s.gzhead.extra && s.gzhead.extra.length) {
|
||
put_byte(s, s.gzhead.extra.length & 255);
|
||
put_byte(s, s.gzhead.extra.length >> 8 & 255);
|
||
}
|
||
if (s.gzhead.hcrc) {
|
||
strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);
|
||
}
|
||
s.gzindex = 0;
|
||
s.status = EXTRA_STATE;
|
||
}
|
||
} else {
|
||
var header = Z_DEFLATED + (s.w_bits - 8 << 4) << 8;
|
||
var level_flags = -1;
|
||
if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {
|
||
level_flags = 0;
|
||
} else if (s.level < 6) {
|
||
level_flags = 1;
|
||
} else if (s.level === 6) {
|
||
level_flags = 2;
|
||
} else {
|
||
level_flags = 3;
|
||
}
|
||
header |= level_flags << 6;
|
||
if (s.strstart !== 0) {
|
||
header |= PRESET_DICT;
|
||
}
|
||
header += 31 - header % 31;
|
||
s.status = BUSY_STATE;
|
||
putShortMSB(s, header);
|
||
if (s.strstart !== 0) {
|
||
putShortMSB(s, strm.adler >>> 16);
|
||
putShortMSB(s, strm.adler & 65535);
|
||
}
|
||
strm.adler = 1;
|
||
}
|
||
}
|
||
if (s.status === EXTRA_STATE) {
|
||
if (s.gzhead.extra) {
|
||
beg = s.pending;
|
||
while (s.gzindex < (s.gzhead.extra.length & 65535)) {
|
||
if (s.pending === s.pending_buf_size) {
|
||
if (s.gzhead.hcrc && s.pending > beg) {
|
||
strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
|
||
}
|
||
flush_pending(strm);
|
||
beg = s.pending;
|
||
if (s.pending === s.pending_buf_size) {
|
||
break;
|
||
}
|
||
}
|
||
put_byte(s, s.gzhead.extra[s.gzindex] & 255);
|
||
s.gzindex++;
|
||
}
|
||
if (s.gzhead.hcrc && s.pending > beg) {
|
||
strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
|
||
}
|
||
if (s.gzindex === s.gzhead.extra.length) {
|
||
s.gzindex = 0;
|
||
s.status = NAME_STATE;
|
||
}
|
||
} else {
|
||
s.status = NAME_STATE;
|
||
}
|
||
}
|
||
if (s.status === NAME_STATE) {
|
||
if (s.gzhead.name) {
|
||
beg = s.pending;
|
||
do {
|
||
if (s.pending === s.pending_buf_size) {
|
||
if (s.gzhead.hcrc && s.pending > beg) {
|
||
strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
|
||
}
|
||
flush_pending(strm);
|
||
beg = s.pending;
|
||
if (s.pending === s.pending_buf_size) {
|
||
val = 1;
|
||
break;
|
||
}
|
||
}
|
||
if (s.gzindex < s.gzhead.name.length) {
|
||
val = s.gzhead.name.charCodeAt(s.gzindex++) & 255;
|
||
} else {
|
||
val = 0;
|
||
}
|
||
put_byte(s, val);
|
||
} while (val !== 0);
|
||
if (s.gzhead.hcrc && s.pending > beg) {
|
||
strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
|
||
}
|
||
if (val === 0) {
|
||
s.gzindex = 0;
|
||
s.status = COMMENT_STATE;
|
||
}
|
||
} else {
|
||
s.status = COMMENT_STATE;
|
||
}
|
||
}
|
||
if (s.status === COMMENT_STATE) {
|
||
if (s.gzhead.comment) {
|
||
beg = s.pending;
|
||
do {
|
||
if (s.pending === s.pending_buf_size) {
|
||
if (s.gzhead.hcrc && s.pending > beg) {
|
||
strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
|
||
}
|
||
flush_pending(strm);
|
||
beg = s.pending;
|
||
if (s.pending === s.pending_buf_size) {
|
||
val = 1;
|
||
break;
|
||
}
|
||
}
|
||
if (s.gzindex < s.gzhead.comment.length) {
|
||
val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255;
|
||
} else {
|
||
val = 0;
|
||
}
|
||
put_byte(s, val);
|
||
} while (val !== 0);
|
||
if (s.gzhead.hcrc && s.pending > beg) {
|
||
strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
|
||
}
|
||
if (val === 0) {
|
||
s.status = HCRC_STATE;
|
||
}
|
||
} else {
|
||
s.status = HCRC_STATE;
|
||
}
|
||
}
|
||
if (s.status === HCRC_STATE) {
|
||
if (s.gzhead.hcrc) {
|
||
if (s.pending + 2 > s.pending_buf_size) {
|
||
flush_pending(strm);
|
||
}
|
||
if (s.pending + 2 <= s.pending_buf_size) {
|
||
put_byte(s, strm.adler & 255);
|
||
put_byte(s, strm.adler >> 8 & 255);
|
||
strm.adler = 0;
|
||
s.status = BUSY_STATE;
|
||
}
|
||
} else {
|
||
s.status = BUSY_STATE;
|
||
}
|
||
}
|
||
if (s.pending !== 0) {
|
||
flush_pending(strm);
|
||
if (strm.avail_out === 0) {
|
||
s.last_flush = -1;
|
||
return Z_OK;
|
||
}
|
||
} else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH) {
|
||
return err(strm, Z_BUF_ERROR);
|
||
}
|
||
if (s.status === FINISH_STATE && strm.avail_in !== 0) {
|
||
return err(strm, Z_BUF_ERROR);
|
||
}
|
||
if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH && s.status !== FINISH_STATE) {
|
||
var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush);
|
||
if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {
|
||
s.status = FINISH_STATE;
|
||
}
|
||
if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {
|
||
if (strm.avail_out === 0) {
|
||
s.last_flush = -1;
|
||
}
|
||
return Z_OK;
|
||
}
|
||
if (bstate === BS_BLOCK_DONE) {
|
||
if (flush === Z_PARTIAL_FLUSH) {
|
||
trees._tr_align(s);
|
||
} else if (flush !== Z_BLOCK) {
|
||
trees._tr_stored_block(s, 0, 0, false);
|
||
if (flush === Z_FULL_FLUSH) {
|
||
zero(s.head);
|
||
if (s.lookahead === 0) {
|
||
s.strstart = 0;
|
||
s.block_start = 0;
|
||
s.insert = 0;
|
||
}
|
||
}
|
||
}
|
||
flush_pending(strm);
|
||
if (strm.avail_out === 0) {
|
||
s.last_flush = -1;
|
||
return Z_OK;
|
||
}
|
||
}
|
||
}
|
||
if (flush !== Z_FINISH) {
|
||
return Z_OK;
|
||
}
|
||
if (s.wrap <= 0) {
|
||
return Z_STREAM_END;
|
||
}
|
||
if (s.wrap === 2) {
|
||
put_byte(s, strm.adler & 255);
|
||
put_byte(s, strm.adler >> 8 & 255);
|
||
put_byte(s, strm.adler >> 16 & 255);
|
||
put_byte(s, strm.adler >> 24 & 255);
|
||
put_byte(s, strm.total_in & 255);
|
||
put_byte(s, strm.total_in >> 8 & 255);
|
||
put_byte(s, strm.total_in >> 16 & 255);
|
||
put_byte(s, strm.total_in >> 24 & 255);
|
||
} else {
|
||
putShortMSB(s, strm.adler >>> 16);
|
||
putShortMSB(s, strm.adler & 65535);
|
||
}
|
||
flush_pending(strm);
|
||
if (s.wrap > 0) {
|
||
s.wrap = -s.wrap;
|
||
}
|
||
return s.pending !== 0 ? Z_OK : Z_STREAM_END;
|
||
}
|
||
function deflateEnd(strm) {
|
||
var status;
|
||
if (!strm || !strm.state) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
status = strm.state.status;
|
||
if (status !== INIT_STATE && status !== EXTRA_STATE && status !== NAME_STATE && status !== COMMENT_STATE && status !== HCRC_STATE && status !== BUSY_STATE && status !== FINISH_STATE) {
|
||
return err(strm, Z_STREAM_ERROR);
|
||
}
|
||
strm.state = null;
|
||
return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;
|
||
}
|
||
function deflateSetDictionary(strm, dictionary) {
|
||
var dictLength = dictionary.length;
|
||
var s;
|
||
var str, n;
|
||
var wrap;
|
||
var avail;
|
||
var next;
|
||
var input;
|
||
var tmpDict;
|
||
if (!strm || !strm.state) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
s = strm.state;
|
||
wrap = s.wrap;
|
||
if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
if (wrap === 1) {
|
||
strm.adler = adler32(strm.adler, dictionary, dictLength, 0);
|
||
}
|
||
s.wrap = 0;
|
||
if (dictLength >= s.w_size) {
|
||
if (wrap === 0) {
|
||
zero(s.head);
|
||
s.strstart = 0;
|
||
s.block_start = 0;
|
||
s.insert = 0;
|
||
}
|
||
tmpDict = new utils.Buf8(s.w_size);
|
||
utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);
|
||
dictionary = tmpDict;
|
||
dictLength = s.w_size;
|
||
}
|
||
avail = strm.avail_in;
|
||
next = strm.next_in;
|
||
input = strm.input;
|
||
strm.avail_in = dictLength;
|
||
strm.next_in = 0;
|
||
strm.input = dictionary;
|
||
fill_window(s);
|
||
while (s.lookahead >= MIN_MATCH) {
|
||
str = s.strstart;
|
||
n = s.lookahead - (MIN_MATCH - 1);
|
||
do {
|
||
s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;
|
||
s.prev[str & s.w_mask] = s.head[s.ins_h];
|
||
s.head[s.ins_h] = str;
|
||
str++;
|
||
} while (--n);
|
||
s.strstart = str;
|
||
s.lookahead = MIN_MATCH - 1;
|
||
fill_window(s);
|
||
}
|
||
s.strstart += s.lookahead;
|
||
s.block_start = s.strstart;
|
||
s.insert = s.lookahead;
|
||
s.lookahead = 0;
|
||
s.match_length = s.prev_length = MIN_MATCH - 1;
|
||
s.match_available = 0;
|
||
strm.next_in = next;
|
||
strm.input = input;
|
||
strm.avail_in = avail;
|
||
s.wrap = wrap;
|
||
return Z_OK;
|
||
}
|
||
exports3.deflateInit = deflateInit;
|
||
exports3.deflateInit2 = deflateInit2;
|
||
exports3.deflateReset = deflateReset;
|
||
exports3.deflateResetKeep = deflateResetKeep;
|
||
exports3.deflateSetHeader = deflateSetHeader;
|
||
exports3.deflate = deflate;
|
||
exports3.deflateEnd = deflateEnd;
|
||
exports3.deflateSetDictionary = deflateSetDictionary;
|
||
exports3.deflateInfo = "pako deflate (from Nodeca project)";
|
||
}, { "../utils/common": 41, "./adler32": 43, "./crc32": 45, "./messages": 51, "./trees": 52 }], 47: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
function GZheader() {
|
||
this.text = 0;
|
||
this.time = 0;
|
||
this.xflags = 0;
|
||
this.os = 0;
|
||
this.extra = null;
|
||
this.extra_len = 0;
|
||
this.name = "";
|
||
this.comment = "";
|
||
this.hcrc = 0;
|
||
this.done = false;
|
||
}
|
||
module4.exports = GZheader;
|
||
}, {}], 48: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var BAD = 30;
|
||
var TYPE = 12;
|
||
module4.exports = function inflate_fast(strm, start) {
|
||
var state;
|
||
var _in;
|
||
var last;
|
||
var _out;
|
||
var beg;
|
||
var end;
|
||
var dmax;
|
||
var wsize;
|
||
var whave;
|
||
var wnext;
|
||
var s_window;
|
||
var hold;
|
||
var bits;
|
||
var lcode;
|
||
var dcode;
|
||
var lmask;
|
||
var dmask;
|
||
var here;
|
||
var op;
|
||
var len;
|
||
var dist;
|
||
var from;
|
||
var from_source;
|
||
var input, output;
|
||
state = strm.state;
|
||
_in = strm.next_in;
|
||
input = strm.input;
|
||
last = _in + (strm.avail_in - 5);
|
||
_out = strm.next_out;
|
||
output = strm.output;
|
||
beg = _out - (start - strm.avail_out);
|
||
end = _out + (strm.avail_out - 257);
|
||
dmax = state.dmax;
|
||
wsize = state.wsize;
|
||
whave = state.whave;
|
||
wnext = state.wnext;
|
||
s_window = state.window;
|
||
hold = state.hold;
|
||
bits = state.bits;
|
||
lcode = state.lencode;
|
||
dcode = state.distcode;
|
||
lmask = (1 << state.lenbits) - 1;
|
||
dmask = (1 << state.distbits) - 1;
|
||
top:
|
||
do {
|
||
if (bits < 15) {
|
||
hold += input[_in++] << bits;
|
||
bits += 8;
|
||
hold += input[_in++] << bits;
|
||
bits += 8;
|
||
}
|
||
here = lcode[hold & lmask];
|
||
dolen:
|
||
for (; ; ) {
|
||
op = here >>> 24;
|
||
hold >>>= op;
|
||
bits -= op;
|
||
op = here >>> 16 & 255;
|
||
if (op === 0) {
|
||
output[_out++] = here & 65535;
|
||
} else if (op & 16) {
|
||
len = here & 65535;
|
||
op &= 15;
|
||
if (op) {
|
||
if (bits < op) {
|
||
hold += input[_in++] << bits;
|
||
bits += 8;
|
||
}
|
||
len += hold & (1 << op) - 1;
|
||
hold >>>= op;
|
||
bits -= op;
|
||
}
|
||
if (bits < 15) {
|
||
hold += input[_in++] << bits;
|
||
bits += 8;
|
||
hold += input[_in++] << bits;
|
||
bits += 8;
|
||
}
|
||
here = dcode[hold & dmask];
|
||
dodist:
|
||
for (; ; ) {
|
||
op = here >>> 24;
|
||
hold >>>= op;
|
||
bits -= op;
|
||
op = here >>> 16 & 255;
|
||
if (op & 16) {
|
||
dist = here & 65535;
|
||
op &= 15;
|
||
if (bits < op) {
|
||
hold += input[_in++] << bits;
|
||
bits += 8;
|
||
if (bits < op) {
|
||
hold += input[_in++] << bits;
|
||
bits += 8;
|
||
}
|
||
}
|
||
dist += hold & (1 << op) - 1;
|
||
if (dist > dmax) {
|
||
strm.msg = "invalid distance too far back";
|
||
state.mode = BAD;
|
||
break top;
|
||
}
|
||
hold >>>= op;
|
||
bits -= op;
|
||
op = _out - beg;
|
||
if (dist > op) {
|
||
op = dist - op;
|
||
if (op > whave) {
|
||
if (state.sane) {
|
||
strm.msg = "invalid distance too far back";
|
||
state.mode = BAD;
|
||
break top;
|
||
}
|
||
}
|
||
from = 0;
|
||
from_source = s_window;
|
||
if (wnext === 0) {
|
||
from += wsize - op;
|
||
if (op < len) {
|
||
len -= op;
|
||
do {
|
||
output[_out++] = s_window[from++];
|
||
} while (--op);
|
||
from = _out - dist;
|
||
from_source = output;
|
||
}
|
||
} else if (wnext < op) {
|
||
from += wsize + wnext - op;
|
||
op -= wnext;
|
||
if (op < len) {
|
||
len -= op;
|
||
do {
|
||
output[_out++] = s_window[from++];
|
||
} while (--op);
|
||
from = 0;
|
||
if (wnext < len) {
|
||
op = wnext;
|
||
len -= op;
|
||
do {
|
||
output[_out++] = s_window[from++];
|
||
} while (--op);
|
||
from = _out - dist;
|
||
from_source = output;
|
||
}
|
||
}
|
||
} else {
|
||
from += wnext - op;
|
||
if (op < len) {
|
||
len -= op;
|
||
do {
|
||
output[_out++] = s_window[from++];
|
||
} while (--op);
|
||
from = _out - dist;
|
||
from_source = output;
|
||
}
|
||
}
|
||
while (len > 2) {
|
||
output[_out++] = from_source[from++];
|
||
output[_out++] = from_source[from++];
|
||
output[_out++] = from_source[from++];
|
||
len -= 3;
|
||
}
|
||
if (len) {
|
||
output[_out++] = from_source[from++];
|
||
if (len > 1) {
|
||
output[_out++] = from_source[from++];
|
||
}
|
||
}
|
||
} else {
|
||
from = _out - dist;
|
||
do {
|
||
output[_out++] = output[from++];
|
||
output[_out++] = output[from++];
|
||
output[_out++] = output[from++];
|
||
len -= 3;
|
||
} while (len > 2);
|
||
if (len) {
|
||
output[_out++] = output[from++];
|
||
if (len > 1) {
|
||
output[_out++] = output[from++];
|
||
}
|
||
}
|
||
}
|
||
} else if ((op & 64) === 0) {
|
||
here = dcode[(here & 65535) + (hold & (1 << op) - 1)];
|
||
continue dodist;
|
||
} else {
|
||
strm.msg = "invalid distance code";
|
||
state.mode = BAD;
|
||
break top;
|
||
}
|
||
break;
|
||
}
|
||
} else if ((op & 64) === 0) {
|
||
here = lcode[(here & 65535) + (hold & (1 << op) - 1)];
|
||
continue dolen;
|
||
} else if (op & 32) {
|
||
state.mode = TYPE;
|
||
break top;
|
||
} else {
|
||
strm.msg = "invalid literal/length code";
|
||
state.mode = BAD;
|
||
break top;
|
||
}
|
||
break;
|
||
}
|
||
} while (_in < last && _out < end);
|
||
len = bits >> 3;
|
||
_in -= len;
|
||
bits -= len << 3;
|
||
hold &= (1 << bits) - 1;
|
||
strm.next_in = _in;
|
||
strm.next_out = _out;
|
||
strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);
|
||
strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);
|
||
state.hold = hold;
|
||
state.bits = bits;
|
||
return;
|
||
};
|
||
}, {}], 49: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("../utils/common");
|
||
var adler32 = require2("./adler32");
|
||
var crc32 = require2("./crc32");
|
||
var inflate_fast = require2("./inffast");
|
||
var inflate_table = require2("./inftrees");
|
||
var CODES = 0;
|
||
var LENS = 1;
|
||
var DISTS = 2;
|
||
var Z_FINISH = 4;
|
||
var Z_BLOCK = 5;
|
||
var Z_TREES = 6;
|
||
var Z_OK = 0;
|
||
var Z_STREAM_END = 1;
|
||
var Z_NEED_DICT = 2;
|
||
var Z_STREAM_ERROR = -2;
|
||
var Z_DATA_ERROR = -3;
|
||
var Z_MEM_ERROR = -4;
|
||
var Z_BUF_ERROR = -5;
|
||
var Z_DEFLATED = 8;
|
||
var HEAD = 1;
|
||
var FLAGS = 2;
|
||
var TIME = 3;
|
||
var OS = 4;
|
||
var EXLEN = 5;
|
||
var EXTRA = 6;
|
||
var NAME = 7;
|
||
var COMMENT = 8;
|
||
var HCRC = 9;
|
||
var DICTID = 10;
|
||
var DICT = 11;
|
||
var TYPE = 12;
|
||
var TYPEDO = 13;
|
||
var STORED = 14;
|
||
var COPY_ = 15;
|
||
var COPY = 16;
|
||
var TABLE = 17;
|
||
var LENLENS = 18;
|
||
var CODELENS = 19;
|
||
var LEN_ = 20;
|
||
var LEN = 21;
|
||
var LENEXT = 22;
|
||
var DIST = 23;
|
||
var DISTEXT = 24;
|
||
var MATCH = 25;
|
||
var LIT = 26;
|
||
var CHECK = 27;
|
||
var LENGTH = 28;
|
||
var DONE = 29;
|
||
var BAD = 30;
|
||
var MEM = 31;
|
||
var SYNC = 32;
|
||
var ENOUGH_LENS = 852;
|
||
var ENOUGH_DISTS = 592;
|
||
var MAX_WBITS = 15;
|
||
var DEF_WBITS = MAX_WBITS;
|
||
function zswap32(q) {
|
||
return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);
|
||
}
|
||
function InflateState() {
|
||
this.mode = 0;
|
||
this.last = false;
|
||
this.wrap = 0;
|
||
this.havedict = false;
|
||
this.flags = 0;
|
||
this.dmax = 0;
|
||
this.check = 0;
|
||
this.total = 0;
|
||
this.head = null;
|
||
this.wbits = 0;
|
||
this.wsize = 0;
|
||
this.whave = 0;
|
||
this.wnext = 0;
|
||
this.window = null;
|
||
this.hold = 0;
|
||
this.bits = 0;
|
||
this.length = 0;
|
||
this.offset = 0;
|
||
this.extra = 0;
|
||
this.lencode = null;
|
||
this.distcode = null;
|
||
this.lenbits = 0;
|
||
this.distbits = 0;
|
||
this.ncode = 0;
|
||
this.nlen = 0;
|
||
this.ndist = 0;
|
||
this.have = 0;
|
||
this.next = null;
|
||
this.lens = new utils.Buf16(320);
|
||
this.work = new utils.Buf16(288);
|
||
this.lendyn = null;
|
||
this.distdyn = null;
|
||
this.sane = 0;
|
||
this.back = 0;
|
||
this.was = 0;
|
||
}
|
||
function inflateResetKeep(strm) {
|
||
var state;
|
||
if (!strm || !strm.state) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
state = strm.state;
|
||
strm.total_in = strm.total_out = state.total = 0;
|
||
strm.msg = "";
|
||
if (state.wrap) {
|
||
strm.adler = state.wrap & 1;
|
||
}
|
||
state.mode = HEAD;
|
||
state.last = 0;
|
||
state.havedict = 0;
|
||
state.dmax = 32768;
|
||
state.head = null;
|
||
state.hold = 0;
|
||
state.bits = 0;
|
||
state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);
|
||
state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);
|
||
state.sane = 1;
|
||
state.back = -1;
|
||
return Z_OK;
|
||
}
|
||
function inflateReset(strm) {
|
||
var state;
|
||
if (!strm || !strm.state) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
state = strm.state;
|
||
state.wsize = 0;
|
||
state.whave = 0;
|
||
state.wnext = 0;
|
||
return inflateResetKeep(strm);
|
||
}
|
||
function inflateReset2(strm, windowBits) {
|
||
var wrap;
|
||
var state;
|
||
if (!strm || !strm.state) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
state = strm.state;
|
||
if (windowBits < 0) {
|
||
wrap = 0;
|
||
windowBits = -windowBits;
|
||
} else {
|
||
wrap = (windowBits >> 4) + 1;
|
||
if (windowBits < 48) {
|
||
windowBits &= 15;
|
||
}
|
||
}
|
||
if (windowBits && (windowBits < 8 || windowBits > 15)) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
if (state.window !== null && state.wbits !== windowBits) {
|
||
state.window = null;
|
||
}
|
||
state.wrap = wrap;
|
||
state.wbits = windowBits;
|
||
return inflateReset(strm);
|
||
}
|
||
function inflateInit2(strm, windowBits) {
|
||
var ret;
|
||
var state;
|
||
if (!strm) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
state = new InflateState();
|
||
strm.state = state;
|
||
state.window = null;
|
||
ret = inflateReset2(strm, windowBits);
|
||
if (ret !== Z_OK) {
|
||
strm.state = null;
|
||
}
|
||
return ret;
|
||
}
|
||
function inflateInit(strm) {
|
||
return inflateInit2(strm, DEF_WBITS);
|
||
}
|
||
var virgin = true;
|
||
var lenfix, distfix;
|
||
function fixedtables(state) {
|
||
if (virgin) {
|
||
var sym;
|
||
lenfix = new utils.Buf32(512);
|
||
distfix = new utils.Buf32(32);
|
||
sym = 0;
|
||
while (sym < 144) {
|
||
state.lens[sym++] = 8;
|
||
}
|
||
while (sym < 256) {
|
||
state.lens[sym++] = 9;
|
||
}
|
||
while (sym < 280) {
|
||
state.lens[sym++] = 7;
|
||
}
|
||
while (sym < 288) {
|
||
state.lens[sym++] = 8;
|
||
}
|
||
inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });
|
||
sym = 0;
|
||
while (sym < 32) {
|
||
state.lens[sym++] = 5;
|
||
}
|
||
inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });
|
||
virgin = false;
|
||
}
|
||
state.lencode = lenfix;
|
||
state.lenbits = 9;
|
||
state.distcode = distfix;
|
||
state.distbits = 5;
|
||
}
|
||
function updatewindow(strm, src, end, copy) {
|
||
var dist;
|
||
var state = strm.state;
|
||
if (state.window === null) {
|
||
state.wsize = 1 << state.wbits;
|
||
state.wnext = 0;
|
||
state.whave = 0;
|
||
state.window = new utils.Buf8(state.wsize);
|
||
}
|
||
if (copy >= state.wsize) {
|
||
utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);
|
||
state.wnext = 0;
|
||
state.whave = state.wsize;
|
||
} else {
|
||
dist = state.wsize - state.wnext;
|
||
if (dist > copy) {
|
||
dist = copy;
|
||
}
|
||
utils.arraySet(state.window, src, end - copy, dist, state.wnext);
|
||
copy -= dist;
|
||
if (copy) {
|
||
utils.arraySet(state.window, src, end - copy, copy, 0);
|
||
state.wnext = copy;
|
||
state.whave = state.wsize;
|
||
} else {
|
||
state.wnext += dist;
|
||
if (state.wnext === state.wsize) {
|
||
state.wnext = 0;
|
||
}
|
||
if (state.whave < state.wsize) {
|
||
state.whave += dist;
|
||
}
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
function inflate(strm, flush) {
|
||
var state;
|
||
var input, output;
|
||
var next;
|
||
var put;
|
||
var have, left;
|
||
var hold;
|
||
var bits;
|
||
var _in, _out;
|
||
var copy;
|
||
var from;
|
||
var from_source;
|
||
var here = 0;
|
||
var here_bits, here_op, here_val;
|
||
var last_bits, last_op, last_val;
|
||
var len;
|
||
var ret;
|
||
var hbuf = new utils.Buf8(4);
|
||
var opts;
|
||
var n;
|
||
var order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
|
||
if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
state = strm.state;
|
||
if (state.mode === TYPE) {
|
||
state.mode = TYPEDO;
|
||
}
|
||
put = strm.next_out;
|
||
output = strm.output;
|
||
left = strm.avail_out;
|
||
next = strm.next_in;
|
||
input = strm.input;
|
||
have = strm.avail_in;
|
||
hold = state.hold;
|
||
bits = state.bits;
|
||
_in = have;
|
||
_out = left;
|
||
ret = Z_OK;
|
||
inf_leave:
|
||
for (; ; ) {
|
||
switch (state.mode) {
|
||
case HEAD:
|
||
if (state.wrap === 0) {
|
||
state.mode = TYPEDO;
|
||
break;
|
||
}
|
||
while (bits < 16) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
if (state.wrap & 2 && hold === 35615) {
|
||
state.check = 0;
|
||
hbuf[0] = hold & 255;
|
||
hbuf[1] = hold >>> 8 & 255;
|
||
state.check = crc32(state.check, hbuf, 2, 0);
|
||
hold = 0;
|
||
bits = 0;
|
||
state.mode = FLAGS;
|
||
break;
|
||
}
|
||
state.flags = 0;
|
||
if (state.head) {
|
||
state.head.done = false;
|
||
}
|
||
if (!(state.wrap & 1) || (((hold & 255) << 8) + (hold >> 8)) % 31) {
|
||
strm.msg = "incorrect header check";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
if ((hold & 15) !== Z_DEFLATED) {
|
||
strm.msg = "unknown compression method";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
hold >>>= 4;
|
||
bits -= 4;
|
||
len = (hold & 15) + 8;
|
||
if (state.wbits === 0) {
|
||
state.wbits = len;
|
||
} else if (len > state.wbits) {
|
||
strm.msg = "invalid window size";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
state.dmax = 1 << len;
|
||
strm.adler = state.check = 1;
|
||
state.mode = hold & 512 ? DICTID : TYPE;
|
||
hold = 0;
|
||
bits = 0;
|
||
break;
|
||
case FLAGS:
|
||
while (bits < 16) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
state.flags = hold;
|
||
if ((state.flags & 255) !== Z_DEFLATED) {
|
||
strm.msg = "unknown compression method";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
if (state.flags & 57344) {
|
||
strm.msg = "unknown header flags set";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
if (state.head) {
|
||
state.head.text = hold >> 8 & 1;
|
||
}
|
||
if (state.flags & 512) {
|
||
hbuf[0] = hold & 255;
|
||
hbuf[1] = hold >>> 8 & 255;
|
||
state.check = crc32(state.check, hbuf, 2, 0);
|
||
}
|
||
hold = 0;
|
||
bits = 0;
|
||
state.mode = TIME;
|
||
case TIME:
|
||
while (bits < 32) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
if (state.head) {
|
||
state.head.time = hold;
|
||
}
|
||
if (state.flags & 512) {
|
||
hbuf[0] = hold & 255;
|
||
hbuf[1] = hold >>> 8 & 255;
|
||
hbuf[2] = hold >>> 16 & 255;
|
||
hbuf[3] = hold >>> 24 & 255;
|
||
state.check = crc32(state.check, hbuf, 4, 0);
|
||
}
|
||
hold = 0;
|
||
bits = 0;
|
||
state.mode = OS;
|
||
case OS:
|
||
while (bits < 16) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
if (state.head) {
|
||
state.head.xflags = hold & 255;
|
||
state.head.os = hold >> 8;
|
||
}
|
||
if (state.flags & 512) {
|
||
hbuf[0] = hold & 255;
|
||
hbuf[1] = hold >>> 8 & 255;
|
||
state.check = crc32(state.check, hbuf, 2, 0);
|
||
}
|
||
hold = 0;
|
||
bits = 0;
|
||
state.mode = EXLEN;
|
||
case EXLEN:
|
||
if (state.flags & 1024) {
|
||
while (bits < 16) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
state.length = hold;
|
||
if (state.head) {
|
||
state.head.extra_len = hold;
|
||
}
|
||
if (state.flags & 512) {
|
||
hbuf[0] = hold & 255;
|
||
hbuf[1] = hold >>> 8 & 255;
|
||
state.check = crc32(state.check, hbuf, 2, 0);
|
||
}
|
||
hold = 0;
|
||
bits = 0;
|
||
} else if (state.head) {
|
||
state.head.extra = null;
|
||
}
|
||
state.mode = EXTRA;
|
||
case EXTRA:
|
||
if (state.flags & 1024) {
|
||
copy = state.length;
|
||
if (copy > have) {
|
||
copy = have;
|
||
}
|
||
if (copy) {
|
||
if (state.head) {
|
||
len = state.head.extra_len - state.length;
|
||
if (!state.head.extra) {
|
||
state.head.extra = new Array(state.head.extra_len);
|
||
}
|
||
utils.arraySet(state.head.extra, input, next, copy, len);
|
||
}
|
||
if (state.flags & 512) {
|
||
state.check = crc32(state.check, input, copy, next);
|
||
}
|
||
have -= copy;
|
||
next += copy;
|
||
state.length -= copy;
|
||
}
|
||
if (state.length) {
|
||
break inf_leave;
|
||
}
|
||
}
|
||
state.length = 0;
|
||
state.mode = NAME;
|
||
case NAME:
|
||
if (state.flags & 2048) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
copy = 0;
|
||
do {
|
||
len = input[next + copy++];
|
||
if (state.head && len && state.length < 65536) {
|
||
state.head.name += String.fromCharCode(len);
|
||
}
|
||
} while (len && copy < have);
|
||
if (state.flags & 512) {
|
||
state.check = crc32(state.check, input, copy, next);
|
||
}
|
||
have -= copy;
|
||
next += copy;
|
||
if (len) {
|
||
break inf_leave;
|
||
}
|
||
} else if (state.head) {
|
||
state.head.name = null;
|
||
}
|
||
state.length = 0;
|
||
state.mode = COMMENT;
|
||
case COMMENT:
|
||
if (state.flags & 4096) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
copy = 0;
|
||
do {
|
||
len = input[next + copy++];
|
||
if (state.head && len && state.length < 65536) {
|
||
state.head.comment += String.fromCharCode(len);
|
||
}
|
||
} while (len && copy < have);
|
||
if (state.flags & 512) {
|
||
state.check = crc32(state.check, input, copy, next);
|
||
}
|
||
have -= copy;
|
||
next += copy;
|
||
if (len) {
|
||
break inf_leave;
|
||
}
|
||
} else if (state.head) {
|
||
state.head.comment = null;
|
||
}
|
||
state.mode = HCRC;
|
||
case HCRC:
|
||
if (state.flags & 512) {
|
||
while (bits < 16) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
if (hold !== (state.check & 65535)) {
|
||
strm.msg = "header crc mismatch";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
hold = 0;
|
||
bits = 0;
|
||
}
|
||
if (state.head) {
|
||
state.head.hcrc = state.flags >> 9 & 1;
|
||
state.head.done = true;
|
||
}
|
||
strm.adler = state.check = 0;
|
||
state.mode = TYPE;
|
||
break;
|
||
case DICTID:
|
||
while (bits < 32) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
strm.adler = state.check = zswap32(hold);
|
||
hold = 0;
|
||
bits = 0;
|
||
state.mode = DICT;
|
||
case DICT:
|
||
if (state.havedict === 0) {
|
||
strm.next_out = put;
|
||
strm.avail_out = left;
|
||
strm.next_in = next;
|
||
strm.avail_in = have;
|
||
state.hold = hold;
|
||
state.bits = bits;
|
||
return Z_NEED_DICT;
|
||
}
|
||
strm.adler = state.check = 1;
|
||
state.mode = TYPE;
|
||
case TYPE:
|
||
if (flush === Z_BLOCK || flush === Z_TREES) {
|
||
break inf_leave;
|
||
}
|
||
case TYPEDO:
|
||
if (state.last) {
|
||
hold >>>= bits & 7;
|
||
bits -= bits & 7;
|
||
state.mode = CHECK;
|
||
break;
|
||
}
|
||
while (bits < 3) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
state.last = hold & 1;
|
||
hold >>>= 1;
|
||
bits -= 1;
|
||
switch (hold & 3) {
|
||
case 0:
|
||
state.mode = STORED;
|
||
break;
|
||
case 1:
|
||
fixedtables(state);
|
||
state.mode = LEN_;
|
||
if (flush === Z_TREES) {
|
||
hold >>>= 2;
|
||
bits -= 2;
|
||
break inf_leave;
|
||
}
|
||
break;
|
||
case 2:
|
||
state.mode = TABLE;
|
||
break;
|
||
case 3:
|
||
strm.msg = "invalid block type";
|
||
state.mode = BAD;
|
||
}
|
||
hold >>>= 2;
|
||
bits -= 2;
|
||
break;
|
||
case STORED:
|
||
hold >>>= bits & 7;
|
||
bits -= bits & 7;
|
||
while (bits < 32) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {
|
||
strm.msg = "invalid stored block lengths";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
state.length = hold & 65535;
|
||
hold = 0;
|
||
bits = 0;
|
||
state.mode = COPY_;
|
||
if (flush === Z_TREES) {
|
||
break inf_leave;
|
||
}
|
||
case COPY_:
|
||
state.mode = COPY;
|
||
case COPY:
|
||
copy = state.length;
|
||
if (copy) {
|
||
if (copy > have) {
|
||
copy = have;
|
||
}
|
||
if (copy > left) {
|
||
copy = left;
|
||
}
|
||
if (copy === 0) {
|
||
break inf_leave;
|
||
}
|
||
utils.arraySet(output, input, next, copy, put);
|
||
have -= copy;
|
||
next += copy;
|
||
left -= copy;
|
||
put += copy;
|
||
state.length -= copy;
|
||
break;
|
||
}
|
||
state.mode = TYPE;
|
||
break;
|
||
case TABLE:
|
||
while (bits < 14) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
state.nlen = (hold & 31) + 257;
|
||
hold >>>= 5;
|
||
bits -= 5;
|
||
state.ndist = (hold & 31) + 1;
|
||
hold >>>= 5;
|
||
bits -= 5;
|
||
state.ncode = (hold & 15) + 4;
|
||
hold >>>= 4;
|
||
bits -= 4;
|
||
if (state.nlen > 286 || state.ndist > 30) {
|
||
strm.msg = "too many length or distance symbols";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
state.have = 0;
|
||
state.mode = LENLENS;
|
||
case LENLENS:
|
||
while (state.have < state.ncode) {
|
||
while (bits < 3) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
state.lens[order[state.have++]] = hold & 7;
|
||
hold >>>= 3;
|
||
bits -= 3;
|
||
}
|
||
while (state.have < 19) {
|
||
state.lens[order[state.have++]] = 0;
|
||
}
|
||
state.lencode = state.lendyn;
|
||
state.lenbits = 7;
|
||
opts = { bits: state.lenbits };
|
||
ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);
|
||
state.lenbits = opts.bits;
|
||
if (ret) {
|
||
strm.msg = "invalid code lengths set";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
state.have = 0;
|
||
state.mode = CODELENS;
|
||
case CODELENS:
|
||
while (state.have < state.nlen + state.ndist) {
|
||
for (; ; ) {
|
||
here = state.lencode[hold & (1 << state.lenbits) - 1];
|
||
here_bits = here >>> 24;
|
||
here_op = here >>> 16 & 255;
|
||
here_val = here & 65535;
|
||
if (here_bits <= bits) {
|
||
break;
|
||
}
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
if (here_val < 16) {
|
||
hold >>>= here_bits;
|
||
bits -= here_bits;
|
||
state.lens[state.have++] = here_val;
|
||
} else {
|
||
if (here_val === 16) {
|
||
n = here_bits + 2;
|
||
while (bits < n) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
hold >>>= here_bits;
|
||
bits -= here_bits;
|
||
if (state.have === 0) {
|
||
strm.msg = "invalid bit length repeat";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
len = state.lens[state.have - 1];
|
||
copy = 3 + (hold & 3);
|
||
hold >>>= 2;
|
||
bits -= 2;
|
||
} else if (here_val === 17) {
|
||
n = here_bits + 3;
|
||
while (bits < n) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
hold >>>= here_bits;
|
||
bits -= here_bits;
|
||
len = 0;
|
||
copy = 3 + (hold & 7);
|
||
hold >>>= 3;
|
||
bits -= 3;
|
||
} else {
|
||
n = here_bits + 7;
|
||
while (bits < n) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
hold >>>= here_bits;
|
||
bits -= here_bits;
|
||
len = 0;
|
||
copy = 11 + (hold & 127);
|
||
hold >>>= 7;
|
||
bits -= 7;
|
||
}
|
||
if (state.have + copy > state.nlen + state.ndist) {
|
||
strm.msg = "invalid bit length repeat";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
while (copy--) {
|
||
state.lens[state.have++] = len;
|
||
}
|
||
}
|
||
}
|
||
if (state.mode === BAD) {
|
||
break;
|
||
}
|
||
if (state.lens[256] === 0) {
|
||
strm.msg = "invalid code -- missing end-of-block";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
state.lenbits = 9;
|
||
opts = { bits: state.lenbits };
|
||
ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);
|
||
state.lenbits = opts.bits;
|
||
if (ret) {
|
||
strm.msg = "invalid literal/lengths set";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
state.distbits = 6;
|
||
state.distcode = state.distdyn;
|
||
opts = { bits: state.distbits };
|
||
ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);
|
||
state.distbits = opts.bits;
|
||
if (ret) {
|
||
strm.msg = "invalid distances set";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
state.mode = LEN_;
|
||
if (flush === Z_TREES) {
|
||
break inf_leave;
|
||
}
|
||
case LEN_:
|
||
state.mode = LEN;
|
||
case LEN:
|
||
if (have >= 6 && left >= 258) {
|
||
strm.next_out = put;
|
||
strm.avail_out = left;
|
||
strm.next_in = next;
|
||
strm.avail_in = have;
|
||
state.hold = hold;
|
||
state.bits = bits;
|
||
inflate_fast(strm, _out);
|
||
put = strm.next_out;
|
||
output = strm.output;
|
||
left = strm.avail_out;
|
||
next = strm.next_in;
|
||
input = strm.input;
|
||
have = strm.avail_in;
|
||
hold = state.hold;
|
||
bits = state.bits;
|
||
if (state.mode === TYPE) {
|
||
state.back = -1;
|
||
}
|
||
break;
|
||
}
|
||
state.back = 0;
|
||
for (; ; ) {
|
||
here = state.lencode[hold & (1 << state.lenbits) - 1];
|
||
here_bits = here >>> 24;
|
||
here_op = here >>> 16 & 255;
|
||
here_val = here & 65535;
|
||
if (here_bits <= bits) {
|
||
break;
|
||
}
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
if (here_op && (here_op & 240) === 0) {
|
||
last_bits = here_bits;
|
||
last_op = here_op;
|
||
last_val = here_val;
|
||
for (; ; ) {
|
||
here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
|
||
here_bits = here >>> 24;
|
||
here_op = here >>> 16 & 255;
|
||
here_val = here & 65535;
|
||
if (last_bits + here_bits <= bits) {
|
||
break;
|
||
}
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
hold >>>= last_bits;
|
||
bits -= last_bits;
|
||
state.back += last_bits;
|
||
}
|
||
hold >>>= here_bits;
|
||
bits -= here_bits;
|
||
state.back += here_bits;
|
||
state.length = here_val;
|
||
if (here_op === 0) {
|
||
state.mode = LIT;
|
||
break;
|
||
}
|
||
if (here_op & 32) {
|
||
state.back = -1;
|
||
state.mode = TYPE;
|
||
break;
|
||
}
|
||
if (here_op & 64) {
|
||
strm.msg = "invalid literal/length code";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
state.extra = here_op & 15;
|
||
state.mode = LENEXT;
|
||
case LENEXT:
|
||
if (state.extra) {
|
||
n = state.extra;
|
||
while (bits < n) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
state.length += hold & (1 << state.extra) - 1;
|
||
hold >>>= state.extra;
|
||
bits -= state.extra;
|
||
state.back += state.extra;
|
||
}
|
||
state.was = state.length;
|
||
state.mode = DIST;
|
||
case DIST:
|
||
for (; ; ) {
|
||
here = state.distcode[hold & (1 << state.distbits) - 1];
|
||
here_bits = here >>> 24;
|
||
here_op = here >>> 16 & 255;
|
||
here_val = here & 65535;
|
||
if (here_bits <= bits) {
|
||
break;
|
||
}
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
if ((here_op & 240) === 0) {
|
||
last_bits = here_bits;
|
||
last_op = here_op;
|
||
last_val = here_val;
|
||
for (; ; ) {
|
||
here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
|
||
here_bits = here >>> 24;
|
||
here_op = here >>> 16 & 255;
|
||
here_val = here & 65535;
|
||
if (last_bits + here_bits <= bits) {
|
||
break;
|
||
}
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
hold >>>= last_bits;
|
||
bits -= last_bits;
|
||
state.back += last_bits;
|
||
}
|
||
hold >>>= here_bits;
|
||
bits -= here_bits;
|
||
state.back += here_bits;
|
||
if (here_op & 64) {
|
||
strm.msg = "invalid distance code";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
state.offset = here_val;
|
||
state.extra = here_op & 15;
|
||
state.mode = DISTEXT;
|
||
case DISTEXT:
|
||
if (state.extra) {
|
||
n = state.extra;
|
||
while (bits < n) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
state.offset += hold & (1 << state.extra) - 1;
|
||
hold >>>= state.extra;
|
||
bits -= state.extra;
|
||
state.back += state.extra;
|
||
}
|
||
if (state.offset > state.dmax) {
|
||
strm.msg = "invalid distance too far back";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
state.mode = MATCH;
|
||
case MATCH:
|
||
if (left === 0) {
|
||
break inf_leave;
|
||
}
|
||
copy = _out - left;
|
||
if (state.offset > copy) {
|
||
copy = state.offset - copy;
|
||
if (copy > state.whave) {
|
||
if (state.sane) {
|
||
strm.msg = "invalid distance too far back";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
}
|
||
if (copy > state.wnext) {
|
||
copy -= state.wnext;
|
||
from = state.wsize - copy;
|
||
} else {
|
||
from = state.wnext - copy;
|
||
}
|
||
if (copy > state.length) {
|
||
copy = state.length;
|
||
}
|
||
from_source = state.window;
|
||
} else {
|
||
from_source = output;
|
||
from = put - state.offset;
|
||
copy = state.length;
|
||
}
|
||
if (copy > left) {
|
||
copy = left;
|
||
}
|
||
left -= copy;
|
||
state.length -= copy;
|
||
do {
|
||
output[put++] = from_source[from++];
|
||
} while (--copy);
|
||
if (state.length === 0) {
|
||
state.mode = LEN;
|
||
}
|
||
break;
|
||
case LIT:
|
||
if (left === 0) {
|
||
break inf_leave;
|
||
}
|
||
output[put++] = state.length;
|
||
left--;
|
||
state.mode = LEN;
|
||
break;
|
||
case CHECK:
|
||
if (state.wrap) {
|
||
while (bits < 32) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold |= input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
_out -= left;
|
||
strm.total_out += _out;
|
||
state.total += _out;
|
||
if (_out) {
|
||
strm.adler = state.check = state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out);
|
||
}
|
||
_out = left;
|
||
if ((state.flags ? hold : zswap32(hold)) !== state.check) {
|
||
strm.msg = "incorrect data check";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
hold = 0;
|
||
bits = 0;
|
||
}
|
||
state.mode = LENGTH;
|
||
case LENGTH:
|
||
if (state.wrap && state.flags) {
|
||
while (bits < 32) {
|
||
if (have === 0) {
|
||
break inf_leave;
|
||
}
|
||
have--;
|
||
hold += input[next++] << bits;
|
||
bits += 8;
|
||
}
|
||
if (hold !== (state.total & 4294967295)) {
|
||
strm.msg = "incorrect length check";
|
||
state.mode = BAD;
|
||
break;
|
||
}
|
||
hold = 0;
|
||
bits = 0;
|
||
}
|
||
state.mode = DONE;
|
||
case DONE:
|
||
ret = Z_STREAM_END;
|
||
break inf_leave;
|
||
case BAD:
|
||
ret = Z_DATA_ERROR;
|
||
break inf_leave;
|
||
case MEM:
|
||
return Z_MEM_ERROR;
|
||
case SYNC:
|
||
default:
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
}
|
||
strm.next_out = put;
|
||
strm.avail_out = left;
|
||
strm.next_in = next;
|
||
strm.avail_in = have;
|
||
state.hold = hold;
|
||
state.bits = bits;
|
||
if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH)) {
|
||
if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {
|
||
state.mode = MEM;
|
||
return Z_MEM_ERROR;
|
||
}
|
||
}
|
||
_in -= strm.avail_in;
|
||
_out -= strm.avail_out;
|
||
strm.total_in += _in;
|
||
strm.total_out += _out;
|
||
state.total += _out;
|
||
if (state.wrap && _out) {
|
||
strm.adler = state.check = state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out);
|
||
}
|
||
strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
|
||
if ((_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) {
|
||
ret = Z_BUF_ERROR;
|
||
}
|
||
return ret;
|
||
}
|
||
function inflateEnd(strm) {
|
||
if (!strm || !strm.state) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
var state = strm.state;
|
||
if (state.window) {
|
||
state.window = null;
|
||
}
|
||
strm.state = null;
|
||
return Z_OK;
|
||
}
|
||
function inflateGetHeader(strm, head) {
|
||
var state;
|
||
if (!strm || !strm.state) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
state = strm.state;
|
||
if ((state.wrap & 2) === 0) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
state.head = head;
|
||
head.done = false;
|
||
return Z_OK;
|
||
}
|
||
function inflateSetDictionary(strm, dictionary) {
|
||
var dictLength = dictionary.length;
|
||
var state;
|
||
var dictid;
|
||
var ret;
|
||
if (!strm || !strm.state) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
state = strm.state;
|
||
if (state.wrap !== 0 && state.mode !== DICT) {
|
||
return Z_STREAM_ERROR;
|
||
}
|
||
if (state.mode === DICT) {
|
||
dictid = 1;
|
||
dictid = adler32(dictid, dictionary, dictLength, 0);
|
||
if (dictid !== state.check) {
|
||
return Z_DATA_ERROR;
|
||
}
|
||
}
|
||
ret = updatewindow(strm, dictionary, dictLength, dictLength);
|
||
if (ret) {
|
||
state.mode = MEM;
|
||
return Z_MEM_ERROR;
|
||
}
|
||
state.havedict = 1;
|
||
return Z_OK;
|
||
}
|
||
exports3.inflateReset = inflateReset;
|
||
exports3.inflateReset2 = inflateReset2;
|
||
exports3.inflateResetKeep = inflateResetKeep;
|
||
exports3.inflateInit = inflateInit;
|
||
exports3.inflateInit2 = inflateInit2;
|
||
exports3.inflate = inflate;
|
||
exports3.inflateEnd = inflateEnd;
|
||
exports3.inflateGetHeader = inflateGetHeader;
|
||
exports3.inflateSetDictionary = inflateSetDictionary;
|
||
exports3.inflateInfo = "pako inflate (from Nodeca project)";
|
||
}, { "../utils/common": 41, "./adler32": 43, "./crc32": 45, "./inffast": 48, "./inftrees": 50 }], 50: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("../utils/common");
|
||
var MAXBITS = 15;
|
||
var ENOUGH_LENS = 852;
|
||
var ENOUGH_DISTS = 592;
|
||
var CODES = 0;
|
||
var LENS = 1;
|
||
var DISTS = 2;
|
||
var lbase = [
|
||
3,
|
||
4,
|
||
5,
|
||
6,
|
||
7,
|
||
8,
|
||
9,
|
||
10,
|
||
11,
|
||
13,
|
||
15,
|
||
17,
|
||
19,
|
||
23,
|
||
27,
|
||
31,
|
||
35,
|
||
43,
|
||
51,
|
||
59,
|
||
67,
|
||
83,
|
||
99,
|
||
115,
|
||
131,
|
||
163,
|
||
195,
|
||
227,
|
||
258,
|
||
0,
|
||
0
|
||
];
|
||
var lext = [
|
||
16,
|
||
16,
|
||
16,
|
||
16,
|
||
16,
|
||
16,
|
||
16,
|
||
16,
|
||
17,
|
||
17,
|
||
17,
|
||
17,
|
||
18,
|
||
18,
|
||
18,
|
||
18,
|
||
19,
|
||
19,
|
||
19,
|
||
19,
|
||
20,
|
||
20,
|
||
20,
|
||
20,
|
||
21,
|
||
21,
|
||
21,
|
||
21,
|
||
16,
|
||
72,
|
||
78
|
||
];
|
||
var dbase = [
|
||
1,
|
||
2,
|
||
3,
|
||
4,
|
||
5,
|
||
7,
|
||
9,
|
||
13,
|
||
17,
|
||
25,
|
||
33,
|
||
49,
|
||
65,
|
||
97,
|
||
129,
|
||
193,
|
||
257,
|
||
385,
|
||
513,
|
||
769,
|
||
1025,
|
||
1537,
|
||
2049,
|
||
3073,
|
||
4097,
|
||
6145,
|
||
8193,
|
||
12289,
|
||
16385,
|
||
24577,
|
||
0,
|
||
0
|
||
];
|
||
var dext = [
|
||
16,
|
||
16,
|
||
16,
|
||
16,
|
||
17,
|
||
17,
|
||
18,
|
||
18,
|
||
19,
|
||
19,
|
||
20,
|
||
20,
|
||
21,
|
||
21,
|
||
22,
|
||
22,
|
||
23,
|
||
23,
|
||
24,
|
||
24,
|
||
25,
|
||
25,
|
||
26,
|
||
26,
|
||
27,
|
||
27,
|
||
28,
|
||
28,
|
||
29,
|
||
29,
|
||
64,
|
||
64
|
||
];
|
||
module4.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) {
|
||
var bits = opts.bits;
|
||
var len = 0;
|
||
var sym = 0;
|
||
var min = 0, max = 0;
|
||
var root = 0;
|
||
var curr = 0;
|
||
var drop = 0;
|
||
var left = 0;
|
||
var used = 0;
|
||
var huff = 0;
|
||
var incr;
|
||
var fill;
|
||
var low;
|
||
var mask;
|
||
var next;
|
||
var base = null;
|
||
var base_index = 0;
|
||
var end;
|
||
var count = new utils.Buf16(MAXBITS + 1);
|
||
var offs = new utils.Buf16(MAXBITS + 1);
|
||
var extra = null;
|
||
var extra_index = 0;
|
||
var here_bits, here_op, here_val;
|
||
for (len = 0; len <= MAXBITS; len++) {
|
||
count[len] = 0;
|
||
}
|
||
for (sym = 0; sym < codes; sym++) {
|
||
count[lens[lens_index + sym]]++;
|
||
}
|
||
root = bits;
|
||
for (max = MAXBITS; max >= 1; max--) {
|
||
if (count[max] !== 0) {
|
||
break;
|
||
}
|
||
}
|
||
if (root > max) {
|
||
root = max;
|
||
}
|
||
if (max === 0) {
|
||
table[table_index++] = 1 << 24 | 64 << 16 | 0;
|
||
table[table_index++] = 1 << 24 | 64 << 16 | 0;
|
||
opts.bits = 1;
|
||
return 0;
|
||
}
|
||
for (min = 1; min < max; min++) {
|
||
if (count[min] !== 0) {
|
||
break;
|
||
}
|
||
}
|
||
if (root < min) {
|
||
root = min;
|
||
}
|
||
left = 1;
|
||
for (len = 1; len <= MAXBITS; len++) {
|
||
left <<= 1;
|
||
left -= count[len];
|
||
if (left < 0) {
|
||
return -1;
|
||
}
|
||
}
|
||
if (left > 0 && (type === CODES || max !== 1)) {
|
||
return -1;
|
||
}
|
||
offs[1] = 0;
|
||
for (len = 1; len < MAXBITS; len++) {
|
||
offs[len + 1] = offs[len] + count[len];
|
||
}
|
||
for (sym = 0; sym < codes; sym++) {
|
||
if (lens[lens_index + sym] !== 0) {
|
||
work[offs[lens[lens_index + sym]]++] = sym;
|
||
}
|
||
}
|
||
if (type === CODES) {
|
||
base = extra = work;
|
||
end = 19;
|
||
} else if (type === LENS) {
|
||
base = lbase;
|
||
base_index -= 257;
|
||
extra = lext;
|
||
extra_index -= 257;
|
||
end = 256;
|
||
} else {
|
||
base = dbase;
|
||
extra = dext;
|
||
end = -1;
|
||
}
|
||
huff = 0;
|
||
sym = 0;
|
||
len = min;
|
||
next = table_index;
|
||
curr = root;
|
||
drop = 0;
|
||
low = -1;
|
||
used = 1 << root;
|
||
mask = used - 1;
|
||
if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
|
||
return 1;
|
||
}
|
||
for (; ; ) {
|
||
here_bits = len - drop;
|
||
if (work[sym] < end) {
|
||
here_op = 0;
|
||
here_val = work[sym];
|
||
} else if (work[sym] > end) {
|
||
here_op = extra[extra_index + work[sym]];
|
||
here_val = base[base_index + work[sym]];
|
||
} else {
|
||
here_op = 32 + 64;
|
||
here_val = 0;
|
||
}
|
||
incr = 1 << len - drop;
|
||
fill = 1 << curr;
|
||
min = fill;
|
||
do {
|
||
fill -= incr;
|
||
table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
|
||
} while (fill !== 0);
|
||
incr = 1 << len - 1;
|
||
while (huff & incr) {
|
||
incr >>= 1;
|
||
}
|
||
if (incr !== 0) {
|
||
huff &= incr - 1;
|
||
huff += incr;
|
||
} else {
|
||
huff = 0;
|
||
}
|
||
sym++;
|
||
if (--count[len] === 0) {
|
||
if (len === max) {
|
||
break;
|
||
}
|
||
len = lens[lens_index + work[sym]];
|
||
}
|
||
if (len > root && (huff & mask) !== low) {
|
||
if (drop === 0) {
|
||
drop = root;
|
||
}
|
||
next += min;
|
||
curr = len - drop;
|
||
left = 1 << curr;
|
||
while (curr + drop < max) {
|
||
left -= count[curr + drop];
|
||
if (left <= 0) {
|
||
break;
|
||
}
|
||
curr++;
|
||
left <<= 1;
|
||
}
|
||
used += 1 << curr;
|
||
if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
|
||
return 1;
|
||
}
|
||
low = huff & mask;
|
||
table[low] = root << 24 | curr << 16 | next - table_index | 0;
|
||
}
|
||
}
|
||
if (huff !== 0) {
|
||
table[next + huff] = len - drop << 24 | 64 << 16 | 0;
|
||
}
|
||
opts.bits = root;
|
||
return 0;
|
||
};
|
||
}, { "../utils/common": 41 }], 51: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
module4.exports = {
|
||
2: "need dictionary",
|
||
1: "stream end",
|
||
0: "",
|
||
"-1": "file error",
|
||
"-2": "stream error",
|
||
"-3": "data error",
|
||
"-4": "insufficient memory",
|
||
"-5": "buffer error",
|
||
"-6": "incompatible version"
|
||
};
|
||
}, {}], 52: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
var utils = require2("../utils/common");
|
||
var Z_FIXED = 4;
|
||
var Z_BINARY = 0;
|
||
var Z_TEXT = 1;
|
||
var Z_UNKNOWN = 2;
|
||
function zero(buf) {
|
||
var len = buf.length;
|
||
while (--len >= 0) {
|
||
buf[len] = 0;
|
||
}
|
||
}
|
||
var STORED_BLOCK = 0;
|
||
var STATIC_TREES = 1;
|
||
var DYN_TREES = 2;
|
||
var MIN_MATCH = 3;
|
||
var MAX_MATCH = 258;
|
||
var LENGTH_CODES = 29;
|
||
var LITERALS = 256;
|
||
var L_CODES = LITERALS + 1 + LENGTH_CODES;
|
||
var D_CODES = 30;
|
||
var BL_CODES = 19;
|
||
var HEAP_SIZE = 2 * L_CODES + 1;
|
||
var MAX_BITS = 15;
|
||
var Buf_size = 16;
|
||
var MAX_BL_BITS = 7;
|
||
var END_BLOCK = 256;
|
||
var REP_3_6 = 16;
|
||
var REPZ_3_10 = 17;
|
||
var REPZ_11_138 = 18;
|
||
var extra_lbits = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0];
|
||
var extra_dbits = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13];
|
||
var extra_blbits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7];
|
||
var bl_order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
|
||
var DIST_CODE_LEN = 512;
|
||
var static_ltree = new Array((L_CODES + 2) * 2);
|
||
zero(static_ltree);
|
||
var static_dtree = new Array(D_CODES * 2);
|
||
zero(static_dtree);
|
||
var _dist_code = new Array(DIST_CODE_LEN);
|
||
zero(_dist_code);
|
||
var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);
|
||
zero(_length_code);
|
||
var base_length = new Array(LENGTH_CODES);
|
||
zero(base_length);
|
||
var base_dist = new Array(D_CODES);
|
||
zero(base_dist);
|
||
function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {
|
||
this.static_tree = static_tree;
|
||
this.extra_bits = extra_bits;
|
||
this.extra_base = extra_base;
|
||
this.elems = elems;
|
||
this.max_length = max_length;
|
||
this.has_stree = static_tree && static_tree.length;
|
||
}
|
||
var static_l_desc;
|
||
var static_d_desc;
|
||
var static_bl_desc;
|
||
function TreeDesc(dyn_tree, stat_desc) {
|
||
this.dyn_tree = dyn_tree;
|
||
this.max_code = 0;
|
||
this.stat_desc = stat_desc;
|
||
}
|
||
function d_code(dist) {
|
||
return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];
|
||
}
|
||
function put_short(s, w) {
|
||
s.pending_buf[s.pending++] = w & 255;
|
||
s.pending_buf[s.pending++] = w >>> 8 & 255;
|
||
}
|
||
function send_bits(s, value, length) {
|
||
if (s.bi_valid > Buf_size - length) {
|
||
s.bi_buf |= value << s.bi_valid & 65535;
|
||
put_short(s, s.bi_buf);
|
||
s.bi_buf = value >> Buf_size - s.bi_valid;
|
||
s.bi_valid += length - Buf_size;
|
||
} else {
|
||
s.bi_buf |= value << s.bi_valid & 65535;
|
||
s.bi_valid += length;
|
||
}
|
||
}
|
||
function send_code(s, c, tree) {
|
||
send_bits(s, tree[c * 2], tree[c * 2 + 1]);
|
||
}
|
||
function bi_reverse(code, len) {
|
||
var res = 0;
|
||
do {
|
||
res |= code & 1;
|
||
code >>>= 1;
|
||
res <<= 1;
|
||
} while (--len > 0);
|
||
return res >>> 1;
|
||
}
|
||
function bi_flush(s) {
|
||
if (s.bi_valid === 16) {
|
||
put_short(s, s.bi_buf);
|
||
s.bi_buf = 0;
|
||
s.bi_valid = 0;
|
||
} else if (s.bi_valid >= 8) {
|
||
s.pending_buf[s.pending++] = s.bi_buf & 255;
|
||
s.bi_buf >>= 8;
|
||
s.bi_valid -= 8;
|
||
}
|
||
}
|
||
function gen_bitlen(s, desc) {
|
||
var tree = desc.dyn_tree;
|
||
var max_code = desc.max_code;
|
||
var stree = desc.stat_desc.static_tree;
|
||
var has_stree = desc.stat_desc.has_stree;
|
||
var extra = desc.stat_desc.extra_bits;
|
||
var base = desc.stat_desc.extra_base;
|
||
var max_length = desc.stat_desc.max_length;
|
||
var h;
|
||
var n, m;
|
||
var bits;
|
||
var xbits;
|
||
var f;
|
||
var overflow = 0;
|
||
for (bits = 0; bits <= MAX_BITS; bits++) {
|
||
s.bl_count[bits] = 0;
|
||
}
|
||
tree[s.heap[s.heap_max] * 2 + 1] = 0;
|
||
for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {
|
||
n = s.heap[h];
|
||
bits = tree[tree[n * 2 + 1] * 2 + 1] + 1;
|
||
if (bits > max_length) {
|
||
bits = max_length;
|
||
overflow++;
|
||
}
|
||
tree[n * 2 + 1] = bits;
|
||
if (n > max_code) {
|
||
continue;
|
||
}
|
||
s.bl_count[bits]++;
|
||
xbits = 0;
|
||
if (n >= base) {
|
||
xbits = extra[n - base];
|
||
}
|
||
f = tree[n * 2];
|
||
s.opt_len += f * (bits + xbits);
|
||
if (has_stree) {
|
||
s.static_len += f * (stree[n * 2 + 1] + xbits);
|
||
}
|
||
}
|
||
if (overflow === 0) {
|
||
return;
|
||
}
|
||
do {
|
||
bits = max_length - 1;
|
||
while (s.bl_count[bits] === 0) {
|
||
bits--;
|
||
}
|
||
s.bl_count[bits]--;
|
||
s.bl_count[bits + 1] += 2;
|
||
s.bl_count[max_length]--;
|
||
overflow -= 2;
|
||
} while (overflow > 0);
|
||
for (bits = max_length; bits !== 0; bits--) {
|
||
n = s.bl_count[bits];
|
||
while (n !== 0) {
|
||
m = s.heap[--h];
|
||
if (m > max_code) {
|
||
continue;
|
||
}
|
||
if (tree[m * 2 + 1] !== bits) {
|
||
s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2];
|
||
tree[m * 2 + 1] = bits;
|
||
}
|
||
n--;
|
||
}
|
||
}
|
||
}
|
||
function gen_codes(tree, max_code, bl_count) {
|
||
var next_code = new Array(MAX_BITS + 1);
|
||
var code = 0;
|
||
var bits;
|
||
var n;
|
||
for (bits = 1; bits <= MAX_BITS; bits++) {
|
||
next_code[bits] = code = code + bl_count[bits - 1] << 1;
|
||
}
|
||
for (n = 0; n <= max_code; n++) {
|
||
var len = tree[n * 2 + 1];
|
||
if (len === 0) {
|
||
continue;
|
||
}
|
||
tree[n * 2] = bi_reverse(next_code[len]++, len);
|
||
}
|
||
}
|
||
function tr_static_init() {
|
||
var n;
|
||
var bits;
|
||
var length;
|
||
var code;
|
||
var dist;
|
||
var bl_count = new Array(MAX_BITS + 1);
|
||
length = 0;
|
||
for (code = 0; code < LENGTH_CODES - 1; code++) {
|
||
base_length[code] = length;
|
||
for (n = 0; n < 1 << extra_lbits[code]; n++) {
|
||
_length_code[length++] = code;
|
||
}
|
||
}
|
||
_length_code[length - 1] = code;
|
||
dist = 0;
|
||
for (code = 0; code < 16; code++) {
|
||
base_dist[code] = dist;
|
||
for (n = 0; n < 1 << extra_dbits[code]; n++) {
|
||
_dist_code[dist++] = code;
|
||
}
|
||
}
|
||
dist >>= 7;
|
||
for (; code < D_CODES; code++) {
|
||
base_dist[code] = dist << 7;
|
||
for (n = 0; n < 1 << extra_dbits[code] - 7; n++) {
|
||
_dist_code[256 + dist++] = code;
|
||
}
|
||
}
|
||
for (bits = 0; bits <= MAX_BITS; bits++) {
|
||
bl_count[bits] = 0;
|
||
}
|
||
n = 0;
|
||
while (n <= 143) {
|
||
static_ltree[n * 2 + 1] = 8;
|
||
n++;
|
||
bl_count[8]++;
|
||
}
|
||
while (n <= 255) {
|
||
static_ltree[n * 2 + 1] = 9;
|
||
n++;
|
||
bl_count[9]++;
|
||
}
|
||
while (n <= 279) {
|
||
static_ltree[n * 2 + 1] = 7;
|
||
n++;
|
||
bl_count[7]++;
|
||
}
|
||
while (n <= 287) {
|
||
static_ltree[n * 2 + 1] = 8;
|
||
n++;
|
||
bl_count[8]++;
|
||
}
|
||
gen_codes(static_ltree, L_CODES + 1, bl_count);
|
||
for (n = 0; n < D_CODES; n++) {
|
||
static_dtree[n * 2 + 1] = 5;
|
||
static_dtree[n * 2] = bi_reverse(n, 5);
|
||
}
|
||
static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);
|
||
static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);
|
||
static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);
|
||
}
|
||
function init_block(s) {
|
||
var n;
|
||
for (n = 0; n < L_CODES; n++) {
|
||
s.dyn_ltree[n * 2] = 0;
|
||
}
|
||
for (n = 0; n < D_CODES; n++) {
|
||
s.dyn_dtree[n * 2] = 0;
|
||
}
|
||
for (n = 0; n < BL_CODES; n++) {
|
||
s.bl_tree[n * 2] = 0;
|
||
}
|
||
s.dyn_ltree[END_BLOCK * 2] = 1;
|
||
s.opt_len = s.static_len = 0;
|
||
s.last_lit = s.matches = 0;
|
||
}
|
||
function bi_windup(s) {
|
||
if (s.bi_valid > 8) {
|
||
put_short(s, s.bi_buf);
|
||
} else if (s.bi_valid > 0) {
|
||
s.pending_buf[s.pending++] = s.bi_buf;
|
||
}
|
||
s.bi_buf = 0;
|
||
s.bi_valid = 0;
|
||
}
|
||
function copy_block(s, buf, len, header) {
|
||
bi_windup(s);
|
||
if (header) {
|
||
put_short(s, len);
|
||
put_short(s, ~len);
|
||
}
|
||
utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);
|
||
s.pending += len;
|
||
}
|
||
function smaller(tree, n, m, depth) {
|
||
var _n2 = n * 2;
|
||
var _m2 = m * 2;
|
||
return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[m];
|
||
}
|
||
function pqdownheap(s, tree, k) {
|
||
var v = s.heap[k];
|
||
var j = k << 1;
|
||
while (j <= s.heap_len) {
|
||
if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {
|
||
j++;
|
||
}
|
||
if (smaller(tree, v, s.heap[j], s.depth)) {
|
||
break;
|
||
}
|
||
s.heap[k] = s.heap[j];
|
||
k = j;
|
||
j <<= 1;
|
||
}
|
||
s.heap[k] = v;
|
||
}
|
||
function compress_block(s, ltree, dtree) {
|
||
var dist;
|
||
var lc;
|
||
var lx = 0;
|
||
var code;
|
||
var extra;
|
||
if (s.last_lit !== 0) {
|
||
do {
|
||
dist = s.pending_buf[s.d_buf + lx * 2] << 8 | s.pending_buf[s.d_buf + lx * 2 + 1];
|
||
lc = s.pending_buf[s.l_buf + lx];
|
||
lx++;
|
||
if (dist === 0) {
|
||
send_code(s, lc, ltree);
|
||
} else {
|
||
code = _length_code[lc];
|
||
send_code(s, code + LITERALS + 1, ltree);
|
||
extra = extra_lbits[code];
|
||
if (extra !== 0) {
|
||
lc -= base_length[code];
|
||
send_bits(s, lc, extra);
|
||
}
|
||
dist--;
|
||
code = d_code(dist);
|
||
send_code(s, code, dtree);
|
||
extra = extra_dbits[code];
|
||
if (extra !== 0) {
|
||
dist -= base_dist[code];
|
||
send_bits(s, dist, extra);
|
||
}
|
||
}
|
||
} while (lx < s.last_lit);
|
||
}
|
||
send_code(s, END_BLOCK, ltree);
|
||
}
|
||
function build_tree(s, desc) {
|
||
var tree = desc.dyn_tree;
|
||
var stree = desc.stat_desc.static_tree;
|
||
var has_stree = desc.stat_desc.has_stree;
|
||
var elems = desc.stat_desc.elems;
|
||
var n, m;
|
||
var max_code = -1;
|
||
var node;
|
||
s.heap_len = 0;
|
||
s.heap_max = HEAP_SIZE;
|
||
for (n = 0; n < elems; n++) {
|
||
if (tree[n * 2] !== 0) {
|
||
s.heap[++s.heap_len] = max_code = n;
|
||
s.depth[n] = 0;
|
||
} else {
|
||
tree[n * 2 + 1] = 0;
|
||
}
|
||
}
|
||
while (s.heap_len < 2) {
|
||
node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0;
|
||
tree[node * 2] = 1;
|
||
s.depth[node] = 0;
|
||
s.opt_len--;
|
||
if (has_stree) {
|
||
s.static_len -= stree[node * 2 + 1];
|
||
}
|
||
}
|
||
desc.max_code = max_code;
|
||
for (n = s.heap_len >> 1; n >= 1; n--) {
|
||
pqdownheap(s, tree, n);
|
||
}
|
||
node = elems;
|
||
do {
|
||
n = s.heap[1];
|
||
s.heap[1] = s.heap[s.heap_len--];
|
||
pqdownheap(s, tree, 1);
|
||
m = s.heap[1];
|
||
s.heap[--s.heap_max] = n;
|
||
s.heap[--s.heap_max] = m;
|
||
tree[node * 2] = tree[n * 2] + tree[m * 2];
|
||
s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;
|
||
tree[n * 2 + 1] = tree[m * 2 + 1] = node;
|
||
s.heap[1] = node++;
|
||
pqdownheap(s, tree, 1);
|
||
} while (s.heap_len >= 2);
|
||
s.heap[--s.heap_max] = s.heap[1];
|
||
gen_bitlen(s, desc);
|
||
gen_codes(tree, max_code, s.bl_count);
|
||
}
|
||
function scan_tree(s, tree, max_code) {
|
||
var n;
|
||
var prevlen = -1;
|
||
var curlen;
|
||
var nextlen = tree[0 * 2 + 1];
|
||
var count = 0;
|
||
var max_count = 7;
|
||
var min_count = 4;
|
||
if (nextlen === 0) {
|
||
max_count = 138;
|
||
min_count = 3;
|
||
}
|
||
tree[(max_code + 1) * 2 + 1] = 65535;
|
||
for (n = 0; n <= max_code; n++) {
|
||
curlen = nextlen;
|
||
nextlen = tree[(n + 1) * 2 + 1];
|
||
if (++count < max_count && curlen === nextlen) {
|
||
continue;
|
||
} else if (count < min_count) {
|
||
s.bl_tree[curlen * 2] += count;
|
||
} else if (curlen !== 0) {
|
||
if (curlen !== prevlen) {
|
||
s.bl_tree[curlen * 2]++;
|
||
}
|
||
s.bl_tree[REP_3_6 * 2]++;
|
||
} else if (count <= 10) {
|
||
s.bl_tree[REPZ_3_10 * 2]++;
|
||
} else {
|
||
s.bl_tree[REPZ_11_138 * 2]++;
|
||
}
|
||
count = 0;
|
||
prevlen = curlen;
|
||
if (nextlen === 0) {
|
||
max_count = 138;
|
||
min_count = 3;
|
||
} else if (curlen === nextlen) {
|
||
max_count = 6;
|
||
min_count = 3;
|
||
} else {
|
||
max_count = 7;
|
||
min_count = 4;
|
||
}
|
||
}
|
||
}
|
||
function send_tree(s, tree, max_code) {
|
||
var n;
|
||
var prevlen = -1;
|
||
var curlen;
|
||
var nextlen = tree[0 * 2 + 1];
|
||
var count = 0;
|
||
var max_count = 7;
|
||
var min_count = 4;
|
||
if (nextlen === 0) {
|
||
max_count = 138;
|
||
min_count = 3;
|
||
}
|
||
for (n = 0; n <= max_code; n++) {
|
||
curlen = nextlen;
|
||
nextlen = tree[(n + 1) * 2 + 1];
|
||
if (++count < max_count && curlen === nextlen) {
|
||
continue;
|
||
} else if (count < min_count) {
|
||
do {
|
||
send_code(s, curlen, s.bl_tree);
|
||
} while (--count !== 0);
|
||
} else if (curlen !== 0) {
|
||
if (curlen !== prevlen) {
|
||
send_code(s, curlen, s.bl_tree);
|
||
count--;
|
||
}
|
||
send_code(s, REP_3_6, s.bl_tree);
|
||
send_bits(s, count - 3, 2);
|
||
} else if (count <= 10) {
|
||
send_code(s, REPZ_3_10, s.bl_tree);
|
||
send_bits(s, count - 3, 3);
|
||
} else {
|
||
send_code(s, REPZ_11_138, s.bl_tree);
|
||
send_bits(s, count - 11, 7);
|
||
}
|
||
count = 0;
|
||
prevlen = curlen;
|
||
if (nextlen === 0) {
|
||
max_count = 138;
|
||
min_count = 3;
|
||
} else if (curlen === nextlen) {
|
||
max_count = 6;
|
||
min_count = 3;
|
||
} else {
|
||
max_count = 7;
|
||
min_count = 4;
|
||
}
|
||
}
|
||
}
|
||
function build_bl_tree(s) {
|
||
var max_blindex;
|
||
scan_tree(s, s.dyn_ltree, s.l_desc.max_code);
|
||
scan_tree(s, s.dyn_dtree, s.d_desc.max_code);
|
||
build_tree(s, s.bl_desc);
|
||
for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {
|
||
if (s.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) {
|
||
break;
|
||
}
|
||
}
|
||
s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;
|
||
return max_blindex;
|
||
}
|
||
function send_all_trees(s, lcodes, dcodes, blcodes) {
|
||
var rank;
|
||
send_bits(s, lcodes - 257, 5);
|
||
send_bits(s, dcodes - 1, 5);
|
||
send_bits(s, blcodes - 4, 4);
|
||
for (rank = 0; rank < blcodes; rank++) {
|
||
send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1], 3);
|
||
}
|
||
send_tree(s, s.dyn_ltree, lcodes - 1);
|
||
send_tree(s, s.dyn_dtree, dcodes - 1);
|
||
}
|
||
function detect_data_type(s) {
|
||
var black_mask = 4093624447;
|
||
var n;
|
||
for (n = 0; n <= 31; n++, black_mask >>>= 1) {
|
||
if (black_mask & 1 && s.dyn_ltree[n * 2] !== 0) {
|
||
return Z_BINARY;
|
||
}
|
||
}
|
||
if (s.dyn_ltree[9 * 2] !== 0 || s.dyn_ltree[10 * 2] !== 0 || s.dyn_ltree[13 * 2] !== 0) {
|
||
return Z_TEXT;
|
||
}
|
||
for (n = 32; n < LITERALS; n++) {
|
||
if (s.dyn_ltree[n * 2] !== 0) {
|
||
return Z_TEXT;
|
||
}
|
||
}
|
||
return Z_BINARY;
|
||
}
|
||
var static_init_done = false;
|
||
function _tr_init(s) {
|
||
if (!static_init_done) {
|
||
tr_static_init();
|
||
static_init_done = true;
|
||
}
|
||
s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);
|
||
s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);
|
||
s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);
|
||
s.bi_buf = 0;
|
||
s.bi_valid = 0;
|
||
init_block(s);
|
||
}
|
||
function _tr_stored_block(s, buf, stored_len, last) {
|
||
send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3);
|
||
copy_block(s, buf, stored_len, true);
|
||
}
|
||
function _tr_align(s) {
|
||
send_bits(s, STATIC_TREES << 1, 3);
|
||
send_code(s, END_BLOCK, static_ltree);
|
||
bi_flush(s);
|
||
}
|
||
function _tr_flush_block(s, buf, stored_len, last) {
|
||
var opt_lenb, static_lenb;
|
||
var max_blindex = 0;
|
||
if (s.level > 0) {
|
||
if (s.strm.data_type === Z_UNKNOWN) {
|
||
s.strm.data_type = detect_data_type(s);
|
||
}
|
||
build_tree(s, s.l_desc);
|
||
build_tree(s, s.d_desc);
|
||
max_blindex = build_bl_tree(s);
|
||
opt_lenb = s.opt_len + 3 + 7 >>> 3;
|
||
static_lenb = s.static_len + 3 + 7 >>> 3;
|
||
if (static_lenb <= opt_lenb) {
|
||
opt_lenb = static_lenb;
|
||
}
|
||
} else {
|
||
opt_lenb = static_lenb = stored_len + 5;
|
||
}
|
||
if (stored_len + 4 <= opt_lenb && buf !== -1) {
|
||
_tr_stored_block(s, buf, stored_len, last);
|
||
} else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {
|
||
send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);
|
||
compress_block(s, static_ltree, static_dtree);
|
||
} else {
|
||
send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);
|
||
send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);
|
||
compress_block(s, s.dyn_ltree, s.dyn_dtree);
|
||
}
|
||
init_block(s);
|
||
if (last) {
|
||
bi_windup(s);
|
||
}
|
||
}
|
||
function _tr_tally(s, dist, lc) {
|
||
s.pending_buf[s.d_buf + s.last_lit * 2] = dist >>> 8 & 255;
|
||
s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 255;
|
||
s.pending_buf[s.l_buf + s.last_lit] = lc & 255;
|
||
s.last_lit++;
|
||
if (dist === 0) {
|
||
s.dyn_ltree[lc * 2]++;
|
||
} else {
|
||
s.matches++;
|
||
dist--;
|
||
s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]++;
|
||
s.dyn_dtree[d_code(dist) * 2]++;
|
||
}
|
||
return s.last_lit === s.lit_bufsize - 1;
|
||
}
|
||
exports3._tr_init = _tr_init;
|
||
exports3._tr_stored_block = _tr_stored_block;
|
||
exports3._tr_flush_block = _tr_flush_block;
|
||
exports3._tr_tally = _tr_tally;
|
||
exports3._tr_align = _tr_align;
|
||
}, { "../utils/common": 41 }], 53: [function(require2, module4, exports3) {
|
||
"use strict";
|
||
function ZStream() {
|
||
this.input = null;
|
||
this.next_in = 0;
|
||
this.avail_in = 0;
|
||
this.total_in = 0;
|
||
this.output = null;
|
||
this.next_out = 0;
|
||
this.avail_out = 0;
|
||
this.total_out = 0;
|
||
this.msg = "";
|
||
this.state = null;
|
||
this.data_type = 2;
|
||
this.adler = 0;
|
||
}
|
||
module4.exports = ZStream;
|
||
}, {}], 54: [function(require2, module4, exports3) {
|
||
(function(global2) {
|
||
(function(global3, undefined2) {
|
||
"use strict";
|
||
if (global3.setImmediate) {
|
||
return;
|
||
}
|
||
var nextHandle = 1;
|
||
var tasksByHandle = {};
|
||
var currentlyRunningATask = false;
|
||
var doc = global3.document;
|
||
var registerImmediate;
|
||
function setImmediate2(callback) {
|
||
if (typeof callback !== "function") {
|
||
callback = new Function("" + callback);
|
||
}
|
||
var args = new Array(arguments.length - 1);
|
||
for (var i = 0; i < args.length; i++) {
|
||
args[i] = arguments[i + 1];
|
||
}
|
||
var task = { callback, args };
|
||
tasksByHandle[nextHandle] = task;
|
||
registerImmediate(nextHandle);
|
||
return nextHandle++;
|
||
}
|
||
function clearImmediate(handle) {
|
||
delete tasksByHandle[handle];
|
||
}
|
||
function run(task) {
|
||
var callback = task.callback;
|
||
var args = task.args;
|
||
switch (args.length) {
|
||
case 0:
|
||
callback();
|
||
break;
|
||
case 1:
|
||
callback(args[0]);
|
||
break;
|
||
case 2:
|
||
callback(args[0], args[1]);
|
||
break;
|
||
case 3:
|
||
callback(args[0], args[1], args[2]);
|
||
break;
|
||
default:
|
||
callback.apply(undefined2, args);
|
||
break;
|
||
}
|
||
}
|
||
function runIfPresent(handle) {
|
||
if (currentlyRunningATask) {
|
||
setTimeout(runIfPresent, 0, handle);
|
||
} else {
|
||
var task = tasksByHandle[handle];
|
||
if (task) {
|
||
currentlyRunningATask = true;
|
||
try {
|
||
run(task);
|
||
} finally {
|
||
clearImmediate(handle);
|
||
currentlyRunningATask = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
function installNextTickImplementation() {
|
||
registerImmediate = function(handle) {
|
||
process.nextTick(function() {
|
||
runIfPresent(handle);
|
||
});
|
||
};
|
||
}
|
||
function canUsePostMessage() {
|
||
if (global3.postMessage && !global3.importScripts) {
|
||
var postMessageIsAsynchronous = true;
|
||
var oldOnMessage = global3.onmessage;
|
||
global3.onmessage = function() {
|
||
postMessageIsAsynchronous = false;
|
||
};
|
||
global3.postMessage("", "*");
|
||
global3.onmessage = oldOnMessage;
|
||
return postMessageIsAsynchronous;
|
||
}
|
||
}
|
||
function installPostMessageImplementation() {
|
||
var messagePrefix = "setImmediate$" + Math.random() + "$";
|
||
var onGlobalMessage = function(event) {
|
||
if (event.source === global3 && typeof event.data === "string" && event.data.indexOf(messagePrefix) === 0) {
|
||
runIfPresent(+event.data.slice(messagePrefix.length));
|
||
}
|
||
};
|
||
if (global3.addEventListener) {
|
||
global3.addEventListener("message", onGlobalMessage, false);
|
||
} else {
|
||
global3.attachEvent("onmessage", onGlobalMessage);
|
||
}
|
||
registerImmediate = function(handle) {
|
||
global3.postMessage(messagePrefix + handle, "*");
|
||
};
|
||
}
|
||
function installMessageChannelImplementation() {
|
||
var channel = new MessageChannel();
|
||
channel.port1.onmessage = function(event) {
|
||
var handle = event.data;
|
||
runIfPresent(handle);
|
||
};
|
||
registerImmediate = function(handle) {
|
||
channel.port2.postMessage(handle);
|
||
};
|
||
}
|
||
function installReadyStateChangeImplementation() {
|
||
var html = doc.documentElement;
|
||
registerImmediate = function(handle) {
|
||
var script = doc.createElement("script");
|
||
script.onreadystatechange = function() {
|
||
runIfPresent(handle);
|
||
script.onreadystatechange = null;
|
||
html.removeChild(script);
|
||
script = null;
|
||
};
|
||
html.appendChild(script);
|
||
};
|
||
}
|
||
function installSetTimeoutImplementation() {
|
||
registerImmediate = function(handle) {
|
||
setTimeout(runIfPresent, 0, handle);
|
||
};
|
||
}
|
||
var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global3);
|
||
attachTo = attachTo && attachTo.setTimeout ? attachTo : global3;
|
||
if ({}.toString.call(global3.process) === "[object process]") {
|
||
installNextTickImplementation();
|
||
} else if (canUsePostMessage()) {
|
||
installPostMessageImplementation();
|
||
} else if (global3.MessageChannel) {
|
||
installMessageChannelImplementation();
|
||
} else if (doc && "onreadystatechange" in doc.createElement("script")) {
|
||
installReadyStateChangeImplementation();
|
||
} else {
|
||
installSetTimeoutImplementation();
|
||
}
|
||
attachTo.setImmediate = setImmediate2;
|
||
attachTo.clearImmediate = clearImmediate;
|
||
})(typeof self === "undefined" ? typeof global2 === "undefined" ? this : global2 : self);
|
||
}).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {});
|
||
}, {}] }, {}, [10])(10);
|
||
});
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/archive.js
|
||
var require_archive = __commonJS({
|
||
"node_modules/epubjs/lib/archive.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _core = require_core();
|
||
var _request = _interopRequireDefault(require_request());
|
||
var _mime = _interopRequireDefault(require_mime());
|
||
var _path = _interopRequireDefault(require_path2());
|
||
var _jszip = _interopRequireDefault(require_jszip());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Archive = class {
|
||
constructor() {
|
||
this.zip = void 0;
|
||
this.urlCache = {};
|
||
this.checkRequirements();
|
||
}
|
||
checkRequirements() {
|
||
try {
|
||
this.zip = new _jszip.default();
|
||
} catch (e) {
|
||
throw new Error("JSZip lib not loaded");
|
||
}
|
||
}
|
||
open(input, isBase64) {
|
||
return this.zip.loadAsync(input, {
|
||
"base64": isBase64
|
||
});
|
||
}
|
||
openUrl(zipUrl, isBase64) {
|
||
return (0, _request.default)(zipUrl, "binary").then(function(data) {
|
||
return this.zip.loadAsync(data, {
|
||
"base64": isBase64
|
||
});
|
||
}.bind(this));
|
||
}
|
||
request(url, type) {
|
||
var deferred = new _core.defer();
|
||
var response;
|
||
var path = new _path.default(url);
|
||
if (!type) {
|
||
type = path.extension;
|
||
}
|
||
if (type == "blob") {
|
||
response = this.getBlob(url);
|
||
} else {
|
||
response = this.getText(url);
|
||
}
|
||
if (response) {
|
||
response.then(function(r) {
|
||
let result = this.handleResponse(r, type);
|
||
deferred.resolve(result);
|
||
}.bind(this));
|
||
} else {
|
||
deferred.reject({
|
||
message: "File not found in the epub: " + url,
|
||
stack: new Error().stack
|
||
});
|
||
}
|
||
return deferred.promise;
|
||
}
|
||
handleResponse(response, type) {
|
||
var r;
|
||
if (type == "json") {
|
||
r = JSON.parse(response);
|
||
} else if ((0, _core.isXml)(type)) {
|
||
r = (0, _core.parse)(response, "text/xml");
|
||
} else if (type == "xhtml") {
|
||
r = (0, _core.parse)(response, "application/xhtml+xml");
|
||
} else if (type == "html" || type == "htm") {
|
||
r = (0, _core.parse)(response, "text/html");
|
||
} else {
|
||
r = response;
|
||
}
|
||
return r;
|
||
}
|
||
getBlob(url, mimeType) {
|
||
var decodededUrl = window.decodeURIComponent(url.substr(1));
|
||
var entry = this.zip.file(decodededUrl);
|
||
if (entry) {
|
||
mimeType = mimeType || _mime.default.lookup(entry.name);
|
||
return entry.async("uint8array").then(function(uint8array) {
|
||
return new Blob([uint8array], {
|
||
type: mimeType
|
||
});
|
||
});
|
||
}
|
||
}
|
||
getText(url, encoding) {
|
||
var decodededUrl = window.decodeURIComponent(url.substr(1));
|
||
var entry = this.zip.file(decodededUrl);
|
||
if (entry) {
|
||
return entry.async("string").then(function(text) {
|
||
return text;
|
||
});
|
||
}
|
||
}
|
||
getBase64(url, mimeType) {
|
||
var decodededUrl = window.decodeURIComponent(url.substr(1));
|
||
var entry = this.zip.file(decodededUrl);
|
||
if (entry) {
|
||
mimeType = mimeType || _mime.default.lookup(entry.name);
|
||
return entry.async("base64").then(function(data) {
|
||
return "data:" + mimeType + ";base64," + data;
|
||
});
|
||
}
|
||
}
|
||
createUrl(url, options) {
|
||
var deferred = new _core.defer();
|
||
var _URL = window.URL || window.webkitURL || window.mozURL;
|
||
var tempUrl;
|
||
var response;
|
||
var useBase64 = options && options.base64;
|
||
if (url in this.urlCache) {
|
||
deferred.resolve(this.urlCache[url]);
|
||
return deferred.promise;
|
||
}
|
||
if (useBase64) {
|
||
response = this.getBase64(url);
|
||
if (response) {
|
||
response.then(function(tempUrl2) {
|
||
this.urlCache[url] = tempUrl2;
|
||
deferred.resolve(tempUrl2);
|
||
}.bind(this));
|
||
}
|
||
} else {
|
||
response = this.getBlob(url);
|
||
if (response) {
|
||
response.then(function(blob) {
|
||
tempUrl = _URL.createObjectURL(blob);
|
||
this.urlCache[url] = tempUrl;
|
||
deferred.resolve(tempUrl);
|
||
}.bind(this));
|
||
}
|
||
}
|
||
if (!response) {
|
||
deferred.reject({
|
||
message: "File not found in the epub: " + url,
|
||
stack: new Error().stack
|
||
});
|
||
}
|
||
return deferred.promise;
|
||
}
|
||
revokeUrl(url) {
|
||
var _URL = window.URL || window.webkitURL || window.mozURL;
|
||
var fromCache = this.urlCache[url];
|
||
if (fromCache)
|
||
_URL.revokeObjectURL(fromCache);
|
||
}
|
||
destroy() {
|
||
var _URL = window.URL || window.webkitURL || window.mozURL;
|
||
for (let fromCache in this.urlCache) {
|
||
_URL.revokeObjectURL(fromCache);
|
||
}
|
||
this.zip = void 0;
|
||
this.urlCache = {};
|
||
}
|
||
};
|
||
var _default = Archive;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/localforage/dist/localforage.js
|
||
var require_localforage = __commonJS({
|
||
"node_modules/localforage/dist/localforage.js"(exports, module2) {
|
||
(function(f) {
|
||
if (typeof exports === "object" && typeof module2 !== "undefined") {
|
||
module2.exports = f();
|
||
} else if (typeof define === "function" && define.amd) {
|
||
define([], f);
|
||
} else {
|
||
var g;
|
||
if (typeof window !== "undefined") {
|
||
g = window;
|
||
} else if (typeof global !== "undefined") {
|
||
g = global;
|
||
} else if (typeof self !== "undefined") {
|
||
g = self;
|
||
} else {
|
||
g = this;
|
||
}
|
||
g.localforage = f();
|
||
}
|
||
})(function() {
|
||
var define2, module3, exports2;
|
||
return function e(t, n, r) {
|
||
function s(o2, u) {
|
||
if (!n[o2]) {
|
||
if (!t[o2]) {
|
||
var a = typeof require == "function" && require;
|
||
if (!u && a)
|
||
return a(o2, true);
|
||
if (i)
|
||
return i(o2, true);
|
||
var f = new Error("Cannot find module '" + o2 + "'");
|
||
throw f.code = "MODULE_NOT_FOUND", f;
|
||
}
|
||
var l = n[o2] = { exports: {} };
|
||
t[o2][0].call(l.exports, function(e2) {
|
||
var n2 = t[o2][1][e2];
|
||
return s(n2 ? n2 : e2);
|
||
}, l, l.exports, e, t, n, r);
|
||
}
|
||
return n[o2].exports;
|
||
}
|
||
var i = typeof require == "function" && require;
|
||
for (var o = 0; o < r.length; o++)
|
||
s(r[o]);
|
||
return s;
|
||
}({ 1: [function(_dereq_, module4, exports3) {
|
||
(function(global2) {
|
||
"use strict";
|
||
var Mutation = global2.MutationObserver || global2.WebKitMutationObserver;
|
||
var scheduleDrain;
|
||
{
|
||
if (Mutation) {
|
||
var called = 0;
|
||
var observer = new Mutation(nextTick);
|
||
var element = global2.document.createTextNode("");
|
||
observer.observe(element, {
|
||
characterData: true
|
||
});
|
||
scheduleDrain = function() {
|
||
element.data = called = ++called % 2;
|
||
};
|
||
} else if (!global2.setImmediate && typeof global2.MessageChannel !== "undefined") {
|
||
var channel = new global2.MessageChannel();
|
||
channel.port1.onmessage = nextTick;
|
||
scheduleDrain = function() {
|
||
channel.port2.postMessage(0);
|
||
};
|
||
} else if ("document" in global2 && "onreadystatechange" in global2.document.createElement("script")) {
|
||
scheduleDrain = function() {
|
||
var scriptEl = global2.document.createElement("script");
|
||
scriptEl.onreadystatechange = function() {
|
||
nextTick();
|
||
scriptEl.onreadystatechange = null;
|
||
scriptEl.parentNode.removeChild(scriptEl);
|
||
scriptEl = null;
|
||
};
|
||
global2.document.documentElement.appendChild(scriptEl);
|
||
};
|
||
} else {
|
||
scheduleDrain = function() {
|
||
setTimeout(nextTick, 0);
|
||
};
|
||
}
|
||
}
|
||
var draining;
|
||
var queue = [];
|
||
function nextTick() {
|
||
draining = true;
|
||
var i, oldQueue;
|
||
var len = queue.length;
|
||
while (len) {
|
||
oldQueue = queue;
|
||
queue = [];
|
||
i = -1;
|
||
while (++i < len) {
|
||
oldQueue[i]();
|
||
}
|
||
len = queue.length;
|
||
}
|
||
draining = false;
|
||
}
|
||
module4.exports = immediate;
|
||
function immediate(task) {
|
||
if (queue.push(task) === 1 && !draining) {
|
||
scheduleDrain();
|
||
}
|
||
}
|
||
}).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {});
|
||
}, {}], 2: [function(_dereq_, module4, exports3) {
|
||
"use strict";
|
||
var immediate = _dereq_(1);
|
||
function INTERNAL() {
|
||
}
|
||
var handlers = {};
|
||
var REJECTED = ["REJECTED"];
|
||
var FULFILLED = ["FULFILLED"];
|
||
var PENDING = ["PENDING"];
|
||
module4.exports = Promise2;
|
||
function Promise2(resolver) {
|
||
if (typeof resolver !== "function") {
|
||
throw new TypeError("resolver must be a function");
|
||
}
|
||
this.state = PENDING;
|
||
this.queue = [];
|
||
this.outcome = void 0;
|
||
if (resolver !== INTERNAL) {
|
||
safelyResolveThenable(this, resolver);
|
||
}
|
||
}
|
||
Promise2.prototype["catch"] = function(onRejected) {
|
||
return this.then(null, onRejected);
|
||
};
|
||
Promise2.prototype.then = function(onFulfilled, onRejected) {
|
||
if (typeof onFulfilled !== "function" && this.state === FULFILLED || typeof onRejected !== "function" && this.state === REJECTED) {
|
||
return this;
|
||
}
|
||
var promise = new this.constructor(INTERNAL);
|
||
if (this.state !== PENDING) {
|
||
var resolver = this.state === FULFILLED ? onFulfilled : onRejected;
|
||
unwrap(promise, resolver, this.outcome);
|
||
} else {
|
||
this.queue.push(new QueueItem(promise, onFulfilled, onRejected));
|
||
}
|
||
return promise;
|
||
};
|
||
function QueueItem(promise, onFulfilled, onRejected) {
|
||
this.promise = promise;
|
||
if (typeof onFulfilled === "function") {
|
||
this.onFulfilled = onFulfilled;
|
||
this.callFulfilled = this.otherCallFulfilled;
|
||
}
|
||
if (typeof onRejected === "function") {
|
||
this.onRejected = onRejected;
|
||
this.callRejected = this.otherCallRejected;
|
||
}
|
||
}
|
||
QueueItem.prototype.callFulfilled = function(value) {
|
||
handlers.resolve(this.promise, value);
|
||
};
|
||
QueueItem.prototype.otherCallFulfilled = function(value) {
|
||
unwrap(this.promise, this.onFulfilled, value);
|
||
};
|
||
QueueItem.prototype.callRejected = function(value) {
|
||
handlers.reject(this.promise, value);
|
||
};
|
||
QueueItem.prototype.otherCallRejected = function(value) {
|
||
unwrap(this.promise, this.onRejected, value);
|
||
};
|
||
function unwrap(promise, func, value) {
|
||
immediate(function() {
|
||
var returnValue;
|
||
try {
|
||
returnValue = func(value);
|
||
} catch (e) {
|
||
return handlers.reject(promise, e);
|
||
}
|
||
if (returnValue === promise) {
|
||
handlers.reject(promise, new TypeError("Cannot resolve promise with itself"));
|
||
} else {
|
||
handlers.resolve(promise, returnValue);
|
||
}
|
||
});
|
||
}
|
||
handlers.resolve = function(self2, value) {
|
||
var result = tryCatch(getThen, value);
|
||
if (result.status === "error") {
|
||
return handlers.reject(self2, result.value);
|
||
}
|
||
var thenable = result.value;
|
||
if (thenable) {
|
||
safelyResolveThenable(self2, thenable);
|
||
} else {
|
||
self2.state = FULFILLED;
|
||
self2.outcome = value;
|
||
var i = -1;
|
||
var len = self2.queue.length;
|
||
while (++i < len) {
|
||
self2.queue[i].callFulfilled(value);
|
||
}
|
||
}
|
||
return self2;
|
||
};
|
||
handlers.reject = function(self2, error) {
|
||
self2.state = REJECTED;
|
||
self2.outcome = error;
|
||
var i = -1;
|
||
var len = self2.queue.length;
|
||
while (++i < len) {
|
||
self2.queue[i].callRejected(error);
|
||
}
|
||
return self2;
|
||
};
|
||
function getThen(obj) {
|
||
var then = obj && obj.then;
|
||
if (obj && (typeof obj === "object" || typeof obj === "function") && typeof then === "function") {
|
||
return function appyThen() {
|
||
then.apply(obj, arguments);
|
||
};
|
||
}
|
||
}
|
||
function safelyResolveThenable(self2, thenable) {
|
||
var called = false;
|
||
function onError(value) {
|
||
if (called) {
|
||
return;
|
||
}
|
||
called = true;
|
||
handlers.reject(self2, value);
|
||
}
|
||
function onSuccess(value) {
|
||
if (called) {
|
||
return;
|
||
}
|
||
called = true;
|
||
handlers.resolve(self2, value);
|
||
}
|
||
function tryToUnwrap() {
|
||
thenable(onSuccess, onError);
|
||
}
|
||
var result = tryCatch(tryToUnwrap);
|
||
if (result.status === "error") {
|
||
onError(result.value);
|
||
}
|
||
}
|
||
function tryCatch(func, value) {
|
||
var out = {};
|
||
try {
|
||
out.value = func(value);
|
||
out.status = "success";
|
||
} catch (e) {
|
||
out.status = "error";
|
||
out.value = e;
|
||
}
|
||
return out;
|
||
}
|
||
Promise2.resolve = resolve;
|
||
function resolve(value) {
|
||
if (value instanceof this) {
|
||
return value;
|
||
}
|
||
return handlers.resolve(new this(INTERNAL), value);
|
||
}
|
||
Promise2.reject = reject;
|
||
function reject(reason) {
|
||
var promise = new this(INTERNAL);
|
||
return handlers.reject(promise, reason);
|
||
}
|
||
Promise2.all = all;
|
||
function all(iterable) {
|
||
var self2 = this;
|
||
if (Object.prototype.toString.call(iterable) !== "[object Array]") {
|
||
return this.reject(new TypeError("must be an array"));
|
||
}
|
||
var len = iterable.length;
|
||
var called = false;
|
||
if (!len) {
|
||
return this.resolve([]);
|
||
}
|
||
var values = new Array(len);
|
||
var resolved = 0;
|
||
var i = -1;
|
||
var promise = new this(INTERNAL);
|
||
while (++i < len) {
|
||
allResolver(iterable[i], i);
|
||
}
|
||
return promise;
|
||
function allResolver(value, i2) {
|
||
self2.resolve(value).then(resolveFromAll, function(error) {
|
||
if (!called) {
|
||
called = true;
|
||
handlers.reject(promise, error);
|
||
}
|
||
});
|
||
function resolveFromAll(outValue) {
|
||
values[i2] = outValue;
|
||
if (++resolved === len && !called) {
|
||
called = true;
|
||
handlers.resolve(promise, values);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
Promise2.race = race;
|
||
function race(iterable) {
|
||
var self2 = this;
|
||
if (Object.prototype.toString.call(iterable) !== "[object Array]") {
|
||
return this.reject(new TypeError("must be an array"));
|
||
}
|
||
var len = iterable.length;
|
||
var called = false;
|
||
if (!len) {
|
||
return this.resolve([]);
|
||
}
|
||
var i = -1;
|
||
var promise = new this(INTERNAL);
|
||
while (++i < len) {
|
||
resolver(iterable[i]);
|
||
}
|
||
return promise;
|
||
function resolver(value) {
|
||
self2.resolve(value).then(function(response) {
|
||
if (!called) {
|
||
called = true;
|
||
handlers.resolve(promise, response);
|
||
}
|
||
}, function(error) {
|
||
if (!called) {
|
||
called = true;
|
||
handlers.reject(promise, error);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
}, { "1": 1 }], 3: [function(_dereq_, module4, exports3) {
|
||
(function(global2) {
|
||
"use strict";
|
||
if (typeof global2.Promise !== "function") {
|
||
global2.Promise = _dereq_(2);
|
||
}
|
||
}).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {});
|
||
}, { "2": 2 }], 4: [function(_dereq_, module4, exports3) {
|
||
"use strict";
|
||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
|
||
return typeof obj;
|
||
} : function(obj) {
|
||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
||
};
|
||
function _classCallCheck(instance, Constructor) {
|
||
if (!(instance instanceof Constructor)) {
|
||
throw new TypeError("Cannot call a class as a function");
|
||
}
|
||
}
|
||
function getIDB() {
|
||
try {
|
||
if (typeof indexedDB !== "undefined") {
|
||
return indexedDB;
|
||
}
|
||
if (typeof webkitIndexedDB !== "undefined") {
|
||
return webkitIndexedDB;
|
||
}
|
||
if (typeof mozIndexedDB !== "undefined") {
|
||
return mozIndexedDB;
|
||
}
|
||
if (typeof OIndexedDB !== "undefined") {
|
||
return OIndexedDB;
|
||
}
|
||
if (typeof msIndexedDB !== "undefined") {
|
||
return msIndexedDB;
|
||
}
|
||
} catch (e) {
|
||
return;
|
||
}
|
||
}
|
||
var idb = getIDB();
|
||
function isIndexedDBValid() {
|
||
try {
|
||
if (!idb || !idb.open) {
|
||
return false;
|
||
}
|
||
var isSafari = typeof openDatabase !== "undefined" && /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/BlackBerry/.test(navigator.platform);
|
||
var hasFetch = typeof fetch === "function" && fetch.toString().indexOf("[native code") !== -1;
|
||
return (!isSafari || hasFetch) && typeof indexedDB !== "undefined" && typeof IDBKeyRange !== "undefined";
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
}
|
||
function createBlob(parts, properties) {
|
||
parts = parts || [];
|
||
properties = properties || {};
|
||
try {
|
||
return new Blob(parts, properties);
|
||
} catch (e) {
|
||
if (e.name !== "TypeError") {
|
||
throw e;
|
||
}
|
||
var Builder = typeof BlobBuilder !== "undefined" ? BlobBuilder : typeof MSBlobBuilder !== "undefined" ? MSBlobBuilder : typeof MozBlobBuilder !== "undefined" ? MozBlobBuilder : WebKitBlobBuilder;
|
||
var builder = new Builder();
|
||
for (var i = 0; i < parts.length; i += 1) {
|
||
builder.append(parts[i]);
|
||
}
|
||
return builder.getBlob(properties.type);
|
||
}
|
||
}
|
||
if (typeof Promise === "undefined") {
|
||
_dereq_(3);
|
||
}
|
||
var Promise$1 = Promise;
|
||
function executeCallback(promise, callback) {
|
||
if (callback) {
|
||
promise.then(function(result) {
|
||
callback(null, result);
|
||
}, function(error) {
|
||
callback(error);
|
||
});
|
||
}
|
||
}
|
||
function executeTwoCallbacks(promise, callback, errorCallback) {
|
||
if (typeof callback === "function") {
|
||
promise.then(callback);
|
||
}
|
||
if (typeof errorCallback === "function") {
|
||
promise["catch"](errorCallback);
|
||
}
|
||
}
|
||
function normalizeKey(key2) {
|
||
if (typeof key2 !== "string") {
|
||
console.warn(key2 + " used as a key, but it is not a string.");
|
||
key2 = String(key2);
|
||
}
|
||
return key2;
|
||
}
|
||
function getCallback() {
|
||
if (arguments.length && typeof arguments[arguments.length - 1] === "function") {
|
||
return arguments[arguments.length - 1];
|
||
}
|
||
}
|
||
var DETECT_BLOB_SUPPORT_STORE = "local-forage-detect-blob-support";
|
||
var supportsBlobs = void 0;
|
||
var dbContexts = {};
|
||
var toString = Object.prototype.toString;
|
||
var READ_ONLY = "readonly";
|
||
var READ_WRITE = "readwrite";
|
||
function _binStringToArrayBuffer(bin) {
|
||
var length2 = bin.length;
|
||
var buf = new ArrayBuffer(length2);
|
||
var arr = new Uint8Array(buf);
|
||
for (var i = 0; i < length2; i++) {
|
||
arr[i] = bin.charCodeAt(i);
|
||
}
|
||
return buf;
|
||
}
|
||
function _checkBlobSupportWithoutCaching(idb2) {
|
||
return new Promise$1(function(resolve) {
|
||
var txn = idb2.transaction(DETECT_BLOB_SUPPORT_STORE, READ_WRITE);
|
||
var blob = createBlob([""]);
|
||
txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, "key");
|
||
txn.onabort = function(e) {
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
resolve(false);
|
||
};
|
||
txn.oncomplete = function() {
|
||
var matchedChrome = navigator.userAgent.match(/Chrome\/(\d+)/);
|
||
var matchedEdge = navigator.userAgent.match(/Edge\//);
|
||
resolve(matchedEdge || !matchedChrome || parseInt(matchedChrome[1], 10) >= 43);
|
||
};
|
||
})["catch"](function() {
|
||
return false;
|
||
});
|
||
}
|
||
function _checkBlobSupport(idb2) {
|
||
if (typeof supportsBlobs === "boolean") {
|
||
return Promise$1.resolve(supportsBlobs);
|
||
}
|
||
return _checkBlobSupportWithoutCaching(idb2).then(function(value) {
|
||
supportsBlobs = value;
|
||
return supportsBlobs;
|
||
});
|
||
}
|
||
function _deferReadiness(dbInfo) {
|
||
var dbContext = dbContexts[dbInfo.name];
|
||
var deferredOperation = {};
|
||
deferredOperation.promise = new Promise$1(function(resolve, reject) {
|
||
deferredOperation.resolve = resolve;
|
||
deferredOperation.reject = reject;
|
||
});
|
||
dbContext.deferredOperations.push(deferredOperation);
|
||
if (!dbContext.dbReady) {
|
||
dbContext.dbReady = deferredOperation.promise;
|
||
} else {
|
||
dbContext.dbReady = dbContext.dbReady.then(function() {
|
||
return deferredOperation.promise;
|
||
});
|
||
}
|
||
}
|
||
function _advanceReadiness(dbInfo) {
|
||
var dbContext = dbContexts[dbInfo.name];
|
||
var deferredOperation = dbContext.deferredOperations.pop();
|
||
if (deferredOperation) {
|
||
deferredOperation.resolve();
|
||
return deferredOperation.promise;
|
||
}
|
||
}
|
||
function _rejectReadiness(dbInfo, err) {
|
||
var dbContext = dbContexts[dbInfo.name];
|
||
var deferredOperation = dbContext.deferredOperations.pop();
|
||
if (deferredOperation) {
|
||
deferredOperation.reject(err);
|
||
return deferredOperation.promise;
|
||
}
|
||
}
|
||
function _getConnection(dbInfo, upgradeNeeded) {
|
||
return new Promise$1(function(resolve, reject) {
|
||
dbContexts[dbInfo.name] = dbContexts[dbInfo.name] || createDbContext();
|
||
if (dbInfo.db) {
|
||
if (upgradeNeeded) {
|
||
_deferReadiness(dbInfo);
|
||
dbInfo.db.close();
|
||
} else {
|
||
return resolve(dbInfo.db);
|
||
}
|
||
}
|
||
var dbArgs = [dbInfo.name];
|
||
if (upgradeNeeded) {
|
||
dbArgs.push(dbInfo.version);
|
||
}
|
||
var openreq = idb.open.apply(idb, dbArgs);
|
||
if (upgradeNeeded) {
|
||
openreq.onupgradeneeded = function(e) {
|
||
var db = openreq.result;
|
||
try {
|
||
db.createObjectStore(dbInfo.storeName);
|
||
if (e.oldVersion <= 1) {
|
||
db.createObjectStore(DETECT_BLOB_SUPPORT_STORE);
|
||
}
|
||
} catch (ex) {
|
||
if (ex.name === "ConstraintError") {
|
||
console.warn('The database "' + dbInfo.name + '" has been upgraded from version ' + e.oldVersion + " to version " + e.newVersion + ', but the storage "' + dbInfo.storeName + '" already exists.');
|
||
} else {
|
||
throw ex;
|
||
}
|
||
}
|
||
};
|
||
}
|
||
openreq.onerror = function(e) {
|
||
e.preventDefault();
|
||
reject(openreq.error);
|
||
};
|
||
openreq.onsuccess = function() {
|
||
var db = openreq.result;
|
||
db.onversionchange = function(e) {
|
||
e.target.close();
|
||
};
|
||
resolve(db);
|
||
_advanceReadiness(dbInfo);
|
||
};
|
||
});
|
||
}
|
||
function _getOriginalConnection(dbInfo) {
|
||
return _getConnection(dbInfo, false);
|
||
}
|
||
function _getUpgradedConnection(dbInfo) {
|
||
return _getConnection(dbInfo, true);
|
||
}
|
||
function _isUpgradeNeeded(dbInfo, defaultVersion) {
|
||
if (!dbInfo.db) {
|
||
return true;
|
||
}
|
||
var isNewStore = !dbInfo.db.objectStoreNames.contains(dbInfo.storeName);
|
||
var isDowngrade = dbInfo.version < dbInfo.db.version;
|
||
var isUpgrade = dbInfo.version > dbInfo.db.version;
|
||
if (isDowngrade) {
|
||
if (dbInfo.version !== defaultVersion) {
|
||
console.warn('The database "' + dbInfo.name + `" can't be downgraded from version ` + dbInfo.db.version + " to version " + dbInfo.version + ".");
|
||
}
|
||
dbInfo.version = dbInfo.db.version;
|
||
}
|
||
if (isUpgrade || isNewStore) {
|
||
if (isNewStore) {
|
||
var incVersion = dbInfo.db.version + 1;
|
||
if (incVersion > dbInfo.version) {
|
||
dbInfo.version = incVersion;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
function _encodeBlob(blob) {
|
||
return new Promise$1(function(resolve, reject) {
|
||
var reader = new FileReader();
|
||
reader.onerror = reject;
|
||
reader.onloadend = function(e) {
|
||
var base64 = btoa(e.target.result || "");
|
||
resolve({
|
||
__local_forage_encoded_blob: true,
|
||
data: base64,
|
||
type: blob.type
|
||
});
|
||
};
|
||
reader.readAsBinaryString(blob);
|
||
});
|
||
}
|
||
function _decodeBlob(encodedBlob) {
|
||
var arrayBuff = _binStringToArrayBuffer(atob(encodedBlob.data));
|
||
return createBlob([arrayBuff], { type: encodedBlob.type });
|
||
}
|
||
function _isEncodedBlob(value) {
|
||
return value && value.__local_forage_encoded_blob;
|
||
}
|
||
function _fullyReady(callback) {
|
||
var self2 = this;
|
||
var promise = self2._initReady().then(function() {
|
||
var dbContext = dbContexts[self2._dbInfo.name];
|
||
if (dbContext && dbContext.dbReady) {
|
||
return dbContext.dbReady;
|
||
}
|
||
});
|
||
executeTwoCallbacks(promise, callback, callback);
|
||
return promise;
|
||
}
|
||
function _tryReconnect(dbInfo) {
|
||
_deferReadiness(dbInfo);
|
||
var dbContext = dbContexts[dbInfo.name];
|
||
var forages = dbContext.forages;
|
||
for (var i = 0; i < forages.length; i++) {
|
||
var forage = forages[i];
|
||
if (forage._dbInfo.db) {
|
||
forage._dbInfo.db.close();
|
||
forage._dbInfo.db = null;
|
||
}
|
||
}
|
||
dbInfo.db = null;
|
||
return _getOriginalConnection(dbInfo).then(function(db) {
|
||
dbInfo.db = db;
|
||
if (_isUpgradeNeeded(dbInfo)) {
|
||
return _getUpgradedConnection(dbInfo);
|
||
}
|
||
return db;
|
||
}).then(function(db) {
|
||
dbInfo.db = dbContext.db = db;
|
||
for (var i2 = 0; i2 < forages.length; i2++) {
|
||
forages[i2]._dbInfo.db = db;
|
||
}
|
||
})["catch"](function(err) {
|
||
_rejectReadiness(dbInfo, err);
|
||
throw err;
|
||
});
|
||
}
|
||
function createTransaction(dbInfo, mode, callback, retries) {
|
||
if (retries === void 0) {
|
||
retries = 1;
|
||
}
|
||
try {
|
||
var tx = dbInfo.db.transaction(dbInfo.storeName, mode);
|
||
callback(null, tx);
|
||
} catch (err) {
|
||
if (retries > 0 && (!dbInfo.db || err.name === "InvalidStateError" || err.name === "NotFoundError")) {
|
||
return Promise$1.resolve().then(function() {
|
||
if (!dbInfo.db || err.name === "NotFoundError" && !dbInfo.db.objectStoreNames.contains(dbInfo.storeName) && dbInfo.version <= dbInfo.db.version) {
|
||
if (dbInfo.db) {
|
||
dbInfo.version = dbInfo.db.version + 1;
|
||
}
|
||
return _getUpgradedConnection(dbInfo);
|
||
}
|
||
}).then(function() {
|
||
return _tryReconnect(dbInfo).then(function() {
|
||
createTransaction(dbInfo, mode, callback, retries - 1);
|
||
});
|
||
})["catch"](callback);
|
||
}
|
||
callback(err);
|
||
}
|
||
}
|
||
function createDbContext() {
|
||
return {
|
||
forages: [],
|
||
db: null,
|
||
dbReady: null,
|
||
deferredOperations: []
|
||
};
|
||
}
|
||
function _initStorage(options) {
|
||
var self2 = this;
|
||
var dbInfo = {
|
||
db: null
|
||
};
|
||
if (options) {
|
||
for (var i in options) {
|
||
dbInfo[i] = options[i];
|
||
}
|
||
}
|
||
var dbContext = dbContexts[dbInfo.name];
|
||
if (!dbContext) {
|
||
dbContext = createDbContext();
|
||
dbContexts[dbInfo.name] = dbContext;
|
||
}
|
||
dbContext.forages.push(self2);
|
||
if (!self2._initReady) {
|
||
self2._initReady = self2.ready;
|
||
self2.ready = _fullyReady;
|
||
}
|
||
var initPromises = [];
|
||
function ignoreErrors() {
|
||
return Promise$1.resolve();
|
||
}
|
||
for (var j = 0; j < dbContext.forages.length; j++) {
|
||
var forage = dbContext.forages[j];
|
||
if (forage !== self2) {
|
||
initPromises.push(forage._initReady()["catch"](ignoreErrors));
|
||
}
|
||
}
|
||
var forages = dbContext.forages.slice(0);
|
||
return Promise$1.all(initPromises).then(function() {
|
||
dbInfo.db = dbContext.db;
|
||
return _getOriginalConnection(dbInfo);
|
||
}).then(function(db) {
|
||
dbInfo.db = db;
|
||
if (_isUpgradeNeeded(dbInfo, self2._defaultConfig.version)) {
|
||
return _getUpgradedConnection(dbInfo);
|
||
}
|
||
return db;
|
||
}).then(function(db) {
|
||
dbInfo.db = dbContext.db = db;
|
||
self2._dbInfo = dbInfo;
|
||
for (var k = 0; k < forages.length; k++) {
|
||
var forage2 = forages[k];
|
||
if (forage2 !== self2) {
|
||
forage2._dbInfo.db = dbInfo.db;
|
||
forage2._dbInfo.version = dbInfo.version;
|
||
}
|
||
}
|
||
});
|
||
}
|
||
function getItem(key2, callback) {
|
||
var self2 = this;
|
||
key2 = normalizeKey(key2);
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
createTransaction(self2._dbInfo, READ_ONLY, function(err, transaction) {
|
||
if (err) {
|
||
return reject(err);
|
||
}
|
||
try {
|
||
var store = transaction.objectStore(self2._dbInfo.storeName);
|
||
var req = store.get(key2);
|
||
req.onsuccess = function() {
|
||
var value = req.result;
|
||
if (value === void 0) {
|
||
value = null;
|
||
}
|
||
if (_isEncodedBlob(value)) {
|
||
value = _decodeBlob(value);
|
||
}
|
||
resolve(value);
|
||
};
|
||
req.onerror = function() {
|
||
reject(req.error);
|
||
};
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function iterate(iterator, callback) {
|
||
var self2 = this;
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
createTransaction(self2._dbInfo, READ_ONLY, function(err, transaction) {
|
||
if (err) {
|
||
return reject(err);
|
||
}
|
||
try {
|
||
var store = transaction.objectStore(self2._dbInfo.storeName);
|
||
var req = store.openCursor();
|
||
var iterationNumber = 1;
|
||
req.onsuccess = function() {
|
||
var cursor = req.result;
|
||
if (cursor) {
|
||
var value = cursor.value;
|
||
if (_isEncodedBlob(value)) {
|
||
value = _decodeBlob(value);
|
||
}
|
||
var result = iterator(value, cursor.key, iterationNumber++);
|
||
if (result !== void 0) {
|
||
resolve(result);
|
||
} else {
|
||
cursor["continue"]();
|
||
}
|
||
} else {
|
||
resolve();
|
||
}
|
||
};
|
||
req.onerror = function() {
|
||
reject(req.error);
|
||
};
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function setItem(key2, value, callback) {
|
||
var self2 = this;
|
||
key2 = normalizeKey(key2);
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
var dbInfo;
|
||
self2.ready().then(function() {
|
||
dbInfo = self2._dbInfo;
|
||
if (toString.call(value) === "[object Blob]") {
|
||
return _checkBlobSupport(dbInfo.db).then(function(blobSupport) {
|
||
if (blobSupport) {
|
||
return value;
|
||
}
|
||
return _encodeBlob(value);
|
||
});
|
||
}
|
||
return value;
|
||
}).then(function(value2) {
|
||
createTransaction(self2._dbInfo, READ_WRITE, function(err, transaction) {
|
||
if (err) {
|
||
return reject(err);
|
||
}
|
||
try {
|
||
var store = transaction.objectStore(self2._dbInfo.storeName);
|
||
if (value2 === null) {
|
||
value2 = void 0;
|
||
}
|
||
var req = store.put(value2, key2);
|
||
transaction.oncomplete = function() {
|
||
if (value2 === void 0) {
|
||
value2 = null;
|
||
}
|
||
resolve(value2);
|
||
};
|
||
transaction.onabort = transaction.onerror = function() {
|
||
var err2 = req.error ? req.error : req.transaction.error;
|
||
reject(err2);
|
||
};
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function removeItem(key2, callback) {
|
||
var self2 = this;
|
||
key2 = normalizeKey(key2);
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
createTransaction(self2._dbInfo, READ_WRITE, function(err, transaction) {
|
||
if (err) {
|
||
return reject(err);
|
||
}
|
||
try {
|
||
var store = transaction.objectStore(self2._dbInfo.storeName);
|
||
var req = store["delete"](key2);
|
||
transaction.oncomplete = function() {
|
||
resolve();
|
||
};
|
||
transaction.onerror = function() {
|
||
reject(req.error);
|
||
};
|
||
transaction.onabort = function() {
|
||
var err2 = req.error ? req.error : req.transaction.error;
|
||
reject(err2);
|
||
};
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function clear(callback) {
|
||
var self2 = this;
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
createTransaction(self2._dbInfo, READ_WRITE, function(err, transaction) {
|
||
if (err) {
|
||
return reject(err);
|
||
}
|
||
try {
|
||
var store = transaction.objectStore(self2._dbInfo.storeName);
|
||
var req = store.clear();
|
||
transaction.oncomplete = function() {
|
||
resolve();
|
||
};
|
||
transaction.onabort = transaction.onerror = function() {
|
||
var err2 = req.error ? req.error : req.transaction.error;
|
||
reject(err2);
|
||
};
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function length(callback) {
|
||
var self2 = this;
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
createTransaction(self2._dbInfo, READ_ONLY, function(err, transaction) {
|
||
if (err) {
|
||
return reject(err);
|
||
}
|
||
try {
|
||
var store = transaction.objectStore(self2._dbInfo.storeName);
|
||
var req = store.count();
|
||
req.onsuccess = function() {
|
||
resolve(req.result);
|
||
};
|
||
req.onerror = function() {
|
||
reject(req.error);
|
||
};
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function key(n, callback) {
|
||
var self2 = this;
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
if (n < 0) {
|
||
resolve(null);
|
||
return;
|
||
}
|
||
self2.ready().then(function() {
|
||
createTransaction(self2._dbInfo, READ_ONLY, function(err, transaction) {
|
||
if (err) {
|
||
return reject(err);
|
||
}
|
||
try {
|
||
var store = transaction.objectStore(self2._dbInfo.storeName);
|
||
var advanced = false;
|
||
var req = store.openKeyCursor();
|
||
req.onsuccess = function() {
|
||
var cursor = req.result;
|
||
if (!cursor) {
|
||
resolve(null);
|
||
return;
|
||
}
|
||
if (n === 0) {
|
||
resolve(cursor.key);
|
||
} else {
|
||
if (!advanced) {
|
||
advanced = true;
|
||
cursor.advance(n);
|
||
} else {
|
||
resolve(cursor.key);
|
||
}
|
||
}
|
||
};
|
||
req.onerror = function() {
|
||
reject(req.error);
|
||
};
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function keys(callback) {
|
||
var self2 = this;
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
createTransaction(self2._dbInfo, READ_ONLY, function(err, transaction) {
|
||
if (err) {
|
||
return reject(err);
|
||
}
|
||
try {
|
||
var store = transaction.objectStore(self2._dbInfo.storeName);
|
||
var req = store.openKeyCursor();
|
||
var keys2 = [];
|
||
req.onsuccess = function() {
|
||
var cursor = req.result;
|
||
if (!cursor) {
|
||
resolve(keys2);
|
||
return;
|
||
}
|
||
keys2.push(cursor.key);
|
||
cursor["continue"]();
|
||
};
|
||
req.onerror = function() {
|
||
reject(req.error);
|
||
};
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function dropInstance(options, callback) {
|
||
callback = getCallback.apply(this, arguments);
|
||
var currentConfig = this.config();
|
||
options = typeof options !== "function" && options || {};
|
||
if (!options.name) {
|
||
options.name = options.name || currentConfig.name;
|
||
options.storeName = options.storeName || currentConfig.storeName;
|
||
}
|
||
var self2 = this;
|
||
var promise;
|
||
if (!options.name) {
|
||
promise = Promise$1.reject("Invalid arguments");
|
||
} else {
|
||
var isCurrentDb = options.name === currentConfig.name && self2._dbInfo.db;
|
||
var dbPromise = isCurrentDb ? Promise$1.resolve(self2._dbInfo.db) : _getOriginalConnection(options).then(function(db) {
|
||
var dbContext = dbContexts[options.name];
|
||
var forages = dbContext.forages;
|
||
dbContext.db = db;
|
||
for (var i = 0; i < forages.length; i++) {
|
||
forages[i]._dbInfo.db = db;
|
||
}
|
||
return db;
|
||
});
|
||
if (!options.storeName) {
|
||
promise = dbPromise.then(function(db) {
|
||
_deferReadiness(options);
|
||
var dbContext = dbContexts[options.name];
|
||
var forages = dbContext.forages;
|
||
db.close();
|
||
for (var i = 0; i < forages.length; i++) {
|
||
var forage = forages[i];
|
||
forage._dbInfo.db = null;
|
||
}
|
||
var dropDBPromise = new Promise$1(function(resolve, reject) {
|
||
var req = idb.deleteDatabase(options.name);
|
||
req.onerror = function() {
|
||
var db2 = req.result;
|
||
if (db2) {
|
||
db2.close();
|
||
}
|
||
reject(req.error);
|
||
};
|
||
req.onblocked = function() {
|
||
console.warn('dropInstance blocked for database "' + options.name + '" until all open connections are closed');
|
||
};
|
||
req.onsuccess = function() {
|
||
var db2 = req.result;
|
||
if (db2) {
|
||
db2.close();
|
||
}
|
||
resolve(db2);
|
||
};
|
||
});
|
||
return dropDBPromise.then(function(db2) {
|
||
dbContext.db = db2;
|
||
for (var i2 = 0; i2 < forages.length; i2++) {
|
||
var _forage = forages[i2];
|
||
_advanceReadiness(_forage._dbInfo);
|
||
}
|
||
})["catch"](function(err) {
|
||
(_rejectReadiness(options, err) || Promise$1.resolve())["catch"](function() {
|
||
});
|
||
throw err;
|
||
});
|
||
});
|
||
} else {
|
||
promise = dbPromise.then(function(db) {
|
||
if (!db.objectStoreNames.contains(options.storeName)) {
|
||
return;
|
||
}
|
||
var newVersion = db.version + 1;
|
||
_deferReadiness(options);
|
||
var dbContext = dbContexts[options.name];
|
||
var forages = dbContext.forages;
|
||
db.close();
|
||
for (var i = 0; i < forages.length; i++) {
|
||
var forage = forages[i];
|
||
forage._dbInfo.db = null;
|
||
forage._dbInfo.version = newVersion;
|
||
}
|
||
var dropObjectPromise = new Promise$1(function(resolve, reject) {
|
||
var req = idb.open(options.name, newVersion);
|
||
req.onerror = function(err) {
|
||
var db2 = req.result;
|
||
db2.close();
|
||
reject(err);
|
||
};
|
||
req.onupgradeneeded = function() {
|
||
var db2 = req.result;
|
||
db2.deleteObjectStore(options.storeName);
|
||
};
|
||
req.onsuccess = function() {
|
||
var db2 = req.result;
|
||
db2.close();
|
||
resolve(db2);
|
||
};
|
||
});
|
||
return dropObjectPromise.then(function(db2) {
|
||
dbContext.db = db2;
|
||
for (var j = 0; j < forages.length; j++) {
|
||
var _forage2 = forages[j];
|
||
_forage2._dbInfo.db = db2;
|
||
_advanceReadiness(_forage2._dbInfo);
|
||
}
|
||
})["catch"](function(err) {
|
||
(_rejectReadiness(options, err) || Promise$1.resolve())["catch"](function() {
|
||
});
|
||
throw err;
|
||
});
|
||
});
|
||
}
|
||
}
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
var asyncStorage = {
|
||
_driver: "asyncStorage",
|
||
_initStorage,
|
||
_support: isIndexedDBValid(),
|
||
iterate,
|
||
getItem,
|
||
setItem,
|
||
removeItem,
|
||
clear,
|
||
length,
|
||
key,
|
||
keys,
|
||
dropInstance
|
||
};
|
||
function isWebSQLValid() {
|
||
return typeof openDatabase === "function";
|
||
}
|
||
var BASE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||
var BLOB_TYPE_PREFIX = "~~local_forage_type~";
|
||
var BLOB_TYPE_PREFIX_REGEX = /^~~local_forage_type~([^~]+)~/;
|
||
var SERIALIZED_MARKER = "__lfsc__:";
|
||
var SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER.length;
|
||
var TYPE_ARRAYBUFFER = "arbf";
|
||
var TYPE_BLOB = "blob";
|
||
var TYPE_INT8ARRAY = "si08";
|
||
var TYPE_UINT8ARRAY = "ui08";
|
||
var TYPE_UINT8CLAMPEDARRAY = "uic8";
|
||
var TYPE_INT16ARRAY = "si16";
|
||
var TYPE_INT32ARRAY = "si32";
|
||
var TYPE_UINT16ARRAY = "ur16";
|
||
var TYPE_UINT32ARRAY = "ui32";
|
||
var TYPE_FLOAT32ARRAY = "fl32";
|
||
var TYPE_FLOAT64ARRAY = "fl64";
|
||
var TYPE_SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER_LENGTH + TYPE_ARRAYBUFFER.length;
|
||
var toString$1 = Object.prototype.toString;
|
||
function stringToBuffer(serializedString) {
|
||
var bufferLength = serializedString.length * 0.75;
|
||
var len = serializedString.length;
|
||
var i;
|
||
var p = 0;
|
||
var encoded1, encoded2, encoded3, encoded4;
|
||
if (serializedString[serializedString.length - 1] === "=") {
|
||
bufferLength--;
|
||
if (serializedString[serializedString.length - 2] === "=") {
|
||
bufferLength--;
|
||
}
|
||
}
|
||
var buffer = new ArrayBuffer(bufferLength);
|
||
var bytes = new Uint8Array(buffer);
|
||
for (i = 0; i < len; i += 4) {
|
||
encoded1 = BASE_CHARS.indexOf(serializedString[i]);
|
||
encoded2 = BASE_CHARS.indexOf(serializedString[i + 1]);
|
||
encoded3 = BASE_CHARS.indexOf(serializedString[i + 2]);
|
||
encoded4 = BASE_CHARS.indexOf(serializedString[i + 3]);
|
||
bytes[p++] = encoded1 << 2 | encoded2 >> 4;
|
||
bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
|
||
bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
|
||
}
|
||
return buffer;
|
||
}
|
||
function bufferToString(buffer) {
|
||
var bytes = new Uint8Array(buffer);
|
||
var base64String = "";
|
||
var i;
|
||
for (i = 0; i < bytes.length; i += 3) {
|
||
base64String += BASE_CHARS[bytes[i] >> 2];
|
||
base64String += BASE_CHARS[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
|
||
base64String += BASE_CHARS[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
|
||
base64String += BASE_CHARS[bytes[i + 2] & 63];
|
||
}
|
||
if (bytes.length % 3 === 2) {
|
||
base64String = base64String.substring(0, base64String.length - 1) + "=";
|
||
} else if (bytes.length % 3 === 1) {
|
||
base64String = base64String.substring(0, base64String.length - 2) + "==";
|
||
}
|
||
return base64String;
|
||
}
|
||
function serialize(value, callback) {
|
||
var valueType = "";
|
||
if (value) {
|
||
valueType = toString$1.call(value);
|
||
}
|
||
if (value && (valueType === "[object ArrayBuffer]" || value.buffer && toString$1.call(value.buffer) === "[object ArrayBuffer]")) {
|
||
var buffer;
|
||
var marker = SERIALIZED_MARKER;
|
||
if (value instanceof ArrayBuffer) {
|
||
buffer = value;
|
||
marker += TYPE_ARRAYBUFFER;
|
||
} else {
|
||
buffer = value.buffer;
|
||
if (valueType === "[object Int8Array]") {
|
||
marker += TYPE_INT8ARRAY;
|
||
} else if (valueType === "[object Uint8Array]") {
|
||
marker += TYPE_UINT8ARRAY;
|
||
} else if (valueType === "[object Uint8ClampedArray]") {
|
||
marker += TYPE_UINT8CLAMPEDARRAY;
|
||
} else if (valueType === "[object Int16Array]") {
|
||
marker += TYPE_INT16ARRAY;
|
||
} else if (valueType === "[object Uint16Array]") {
|
||
marker += TYPE_UINT16ARRAY;
|
||
} else if (valueType === "[object Int32Array]") {
|
||
marker += TYPE_INT32ARRAY;
|
||
} else if (valueType === "[object Uint32Array]") {
|
||
marker += TYPE_UINT32ARRAY;
|
||
} else if (valueType === "[object Float32Array]") {
|
||
marker += TYPE_FLOAT32ARRAY;
|
||
} else if (valueType === "[object Float64Array]") {
|
||
marker += TYPE_FLOAT64ARRAY;
|
||
} else {
|
||
callback(new Error("Failed to get type for BinaryArray"));
|
||
}
|
||
}
|
||
callback(marker + bufferToString(buffer));
|
||
} else if (valueType === "[object Blob]") {
|
||
var fileReader = new FileReader();
|
||
fileReader.onload = function() {
|
||
var str = BLOB_TYPE_PREFIX + value.type + "~" + bufferToString(this.result);
|
||
callback(SERIALIZED_MARKER + TYPE_BLOB + str);
|
||
};
|
||
fileReader.readAsArrayBuffer(value);
|
||
} else {
|
||
try {
|
||
callback(JSON.stringify(value));
|
||
} catch (e) {
|
||
console.error("Couldn't convert value into a JSON string: ", value);
|
||
callback(null, e);
|
||
}
|
||
}
|
||
}
|
||
function deserialize(value) {
|
||
if (value.substring(0, SERIALIZED_MARKER_LENGTH) !== SERIALIZED_MARKER) {
|
||
return JSON.parse(value);
|
||
}
|
||
var serializedString = value.substring(TYPE_SERIALIZED_MARKER_LENGTH);
|
||
var type = value.substring(SERIALIZED_MARKER_LENGTH, TYPE_SERIALIZED_MARKER_LENGTH);
|
||
var blobType;
|
||
if (type === TYPE_BLOB && BLOB_TYPE_PREFIX_REGEX.test(serializedString)) {
|
||
var matcher = serializedString.match(BLOB_TYPE_PREFIX_REGEX);
|
||
blobType = matcher[1];
|
||
serializedString = serializedString.substring(matcher[0].length);
|
||
}
|
||
var buffer = stringToBuffer(serializedString);
|
||
switch (type) {
|
||
case TYPE_ARRAYBUFFER:
|
||
return buffer;
|
||
case TYPE_BLOB:
|
||
return createBlob([buffer], { type: blobType });
|
||
case TYPE_INT8ARRAY:
|
||
return new Int8Array(buffer);
|
||
case TYPE_UINT8ARRAY:
|
||
return new Uint8Array(buffer);
|
||
case TYPE_UINT8CLAMPEDARRAY:
|
||
return new Uint8ClampedArray(buffer);
|
||
case TYPE_INT16ARRAY:
|
||
return new Int16Array(buffer);
|
||
case TYPE_UINT16ARRAY:
|
||
return new Uint16Array(buffer);
|
||
case TYPE_INT32ARRAY:
|
||
return new Int32Array(buffer);
|
||
case TYPE_UINT32ARRAY:
|
||
return new Uint32Array(buffer);
|
||
case TYPE_FLOAT32ARRAY:
|
||
return new Float32Array(buffer);
|
||
case TYPE_FLOAT64ARRAY:
|
||
return new Float64Array(buffer);
|
||
default:
|
||
throw new Error("Unkown type: " + type);
|
||
}
|
||
}
|
||
var localforageSerializer = {
|
||
serialize,
|
||
deserialize,
|
||
stringToBuffer,
|
||
bufferToString
|
||
};
|
||
function createDbTable(t, dbInfo, callback, errorCallback) {
|
||
t.executeSql("CREATE TABLE IF NOT EXISTS " + dbInfo.storeName + " (id INTEGER PRIMARY KEY, key unique, value)", [], callback, errorCallback);
|
||
}
|
||
function _initStorage$1(options) {
|
||
var self2 = this;
|
||
var dbInfo = {
|
||
db: null
|
||
};
|
||
if (options) {
|
||
for (var i in options) {
|
||
dbInfo[i] = typeof options[i] !== "string" ? options[i].toString() : options[i];
|
||
}
|
||
}
|
||
var dbInfoPromise = new Promise$1(function(resolve, reject) {
|
||
try {
|
||
dbInfo.db = openDatabase(dbInfo.name, String(dbInfo.version), dbInfo.description, dbInfo.size);
|
||
} catch (e) {
|
||
return reject(e);
|
||
}
|
||
dbInfo.db.transaction(function(t) {
|
||
createDbTable(t, dbInfo, function() {
|
||
self2._dbInfo = dbInfo;
|
||
resolve();
|
||
}, function(t2, error) {
|
||
reject(error);
|
||
});
|
||
}, reject);
|
||
});
|
||
dbInfo.serializer = localforageSerializer;
|
||
return dbInfoPromise;
|
||
}
|
||
function tryExecuteSql(t, dbInfo, sqlStatement, args, callback, errorCallback) {
|
||
t.executeSql(sqlStatement, args, callback, function(t2, error) {
|
||
if (error.code === error.SYNTAX_ERR) {
|
||
t2.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?", [dbInfo.storeName], function(t3, results) {
|
||
if (!results.rows.length) {
|
||
createDbTable(t3, dbInfo, function() {
|
||
t3.executeSql(sqlStatement, args, callback, errorCallback);
|
||
}, errorCallback);
|
||
} else {
|
||
errorCallback(t3, error);
|
||
}
|
||
}, errorCallback);
|
||
} else {
|
||
errorCallback(t2, error);
|
||
}
|
||
}, errorCallback);
|
||
}
|
||
function getItem$1(key2, callback) {
|
||
var self2 = this;
|
||
key2 = normalizeKey(key2);
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
var dbInfo = self2._dbInfo;
|
||
dbInfo.db.transaction(function(t) {
|
||
tryExecuteSql(t, dbInfo, "SELECT * FROM " + dbInfo.storeName + " WHERE key = ? LIMIT 1", [key2], function(t2, results) {
|
||
var result = results.rows.length ? results.rows.item(0).value : null;
|
||
if (result) {
|
||
result = dbInfo.serializer.deserialize(result);
|
||
}
|
||
resolve(result);
|
||
}, function(t2, error) {
|
||
reject(error);
|
||
});
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function iterate$1(iterator, callback) {
|
||
var self2 = this;
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
var dbInfo = self2._dbInfo;
|
||
dbInfo.db.transaction(function(t) {
|
||
tryExecuteSql(t, dbInfo, "SELECT * FROM " + dbInfo.storeName, [], function(t2, results) {
|
||
var rows = results.rows;
|
||
var length2 = rows.length;
|
||
for (var i = 0; i < length2; i++) {
|
||
var item = rows.item(i);
|
||
var result = item.value;
|
||
if (result) {
|
||
result = dbInfo.serializer.deserialize(result);
|
||
}
|
||
result = iterator(result, item.key, i + 1);
|
||
if (result !== void 0) {
|
||
resolve(result);
|
||
return;
|
||
}
|
||
}
|
||
resolve();
|
||
}, function(t2, error) {
|
||
reject(error);
|
||
});
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function _setItem(key2, value, callback, retriesLeft) {
|
||
var self2 = this;
|
||
key2 = normalizeKey(key2);
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
if (value === void 0) {
|
||
value = null;
|
||
}
|
||
var originalValue = value;
|
||
var dbInfo = self2._dbInfo;
|
||
dbInfo.serializer.serialize(value, function(value2, error) {
|
||
if (error) {
|
||
reject(error);
|
||
} else {
|
||
dbInfo.db.transaction(function(t) {
|
||
tryExecuteSql(t, dbInfo, "INSERT OR REPLACE INTO " + dbInfo.storeName + " (key, value) VALUES (?, ?)", [key2, value2], function() {
|
||
resolve(originalValue);
|
||
}, function(t2, error2) {
|
||
reject(error2);
|
||
});
|
||
}, function(sqlError) {
|
||
if (sqlError.code === sqlError.QUOTA_ERR) {
|
||
if (retriesLeft > 0) {
|
||
resolve(_setItem.apply(self2, [key2, originalValue, callback, retriesLeft - 1]));
|
||
return;
|
||
}
|
||
reject(sqlError);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function setItem$1(key2, value, callback) {
|
||
return _setItem.apply(this, [key2, value, callback, 1]);
|
||
}
|
||
function removeItem$1(key2, callback) {
|
||
var self2 = this;
|
||
key2 = normalizeKey(key2);
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
var dbInfo = self2._dbInfo;
|
||
dbInfo.db.transaction(function(t) {
|
||
tryExecuteSql(t, dbInfo, "DELETE FROM " + dbInfo.storeName + " WHERE key = ?", [key2], function() {
|
||
resolve();
|
||
}, function(t2, error) {
|
||
reject(error);
|
||
});
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function clear$1(callback) {
|
||
var self2 = this;
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
var dbInfo = self2._dbInfo;
|
||
dbInfo.db.transaction(function(t) {
|
||
tryExecuteSql(t, dbInfo, "DELETE FROM " + dbInfo.storeName, [], function() {
|
||
resolve();
|
||
}, function(t2, error) {
|
||
reject(error);
|
||
});
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function length$1(callback) {
|
||
var self2 = this;
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
var dbInfo = self2._dbInfo;
|
||
dbInfo.db.transaction(function(t) {
|
||
tryExecuteSql(t, dbInfo, "SELECT COUNT(key) as c FROM " + dbInfo.storeName, [], function(t2, results) {
|
||
var result = results.rows.item(0).c;
|
||
resolve(result);
|
||
}, function(t2, error) {
|
||
reject(error);
|
||
});
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function key$1(n, callback) {
|
||
var self2 = this;
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
var dbInfo = self2._dbInfo;
|
||
dbInfo.db.transaction(function(t) {
|
||
tryExecuteSql(t, dbInfo, "SELECT key FROM " + dbInfo.storeName + " WHERE id = ? LIMIT 1", [n + 1], function(t2, results) {
|
||
var result = results.rows.length ? results.rows.item(0).key : null;
|
||
resolve(result);
|
||
}, function(t2, error) {
|
||
reject(error);
|
||
});
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function keys$1(callback) {
|
||
var self2 = this;
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
self2.ready().then(function() {
|
||
var dbInfo = self2._dbInfo;
|
||
dbInfo.db.transaction(function(t) {
|
||
tryExecuteSql(t, dbInfo, "SELECT key FROM " + dbInfo.storeName, [], function(t2, results) {
|
||
var keys2 = [];
|
||
for (var i = 0; i < results.rows.length; i++) {
|
||
keys2.push(results.rows.item(i).key);
|
||
}
|
||
resolve(keys2);
|
||
}, function(t2, error) {
|
||
reject(error);
|
||
});
|
||
});
|
||
})["catch"](reject);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function getAllStoreNames(db) {
|
||
return new Promise$1(function(resolve, reject) {
|
||
db.transaction(function(t) {
|
||
t.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'", [], function(t2, results) {
|
||
var storeNames = [];
|
||
for (var i = 0; i < results.rows.length; i++) {
|
||
storeNames.push(results.rows.item(i).name);
|
||
}
|
||
resolve({
|
||
db,
|
||
storeNames
|
||
});
|
||
}, function(t2, error) {
|
||
reject(error);
|
||
});
|
||
}, function(sqlError) {
|
||
reject(sqlError);
|
||
});
|
||
});
|
||
}
|
||
function dropInstance$1(options, callback) {
|
||
callback = getCallback.apply(this, arguments);
|
||
var currentConfig = this.config();
|
||
options = typeof options !== "function" && options || {};
|
||
if (!options.name) {
|
||
options.name = options.name || currentConfig.name;
|
||
options.storeName = options.storeName || currentConfig.storeName;
|
||
}
|
||
var self2 = this;
|
||
var promise;
|
||
if (!options.name) {
|
||
promise = Promise$1.reject("Invalid arguments");
|
||
} else {
|
||
promise = new Promise$1(function(resolve) {
|
||
var db;
|
||
if (options.name === currentConfig.name) {
|
||
db = self2._dbInfo.db;
|
||
} else {
|
||
db = openDatabase(options.name, "", "", 0);
|
||
}
|
||
if (!options.storeName) {
|
||
resolve(getAllStoreNames(db));
|
||
} else {
|
||
resolve({
|
||
db,
|
||
storeNames: [options.storeName]
|
||
});
|
||
}
|
||
}).then(function(operationInfo) {
|
||
return new Promise$1(function(resolve, reject) {
|
||
operationInfo.db.transaction(function(t) {
|
||
function dropTable(storeName) {
|
||
return new Promise$1(function(resolve2, reject2) {
|
||
t.executeSql("DROP TABLE IF EXISTS " + storeName, [], function() {
|
||
resolve2();
|
||
}, function(t2, error) {
|
||
reject2(error);
|
||
});
|
||
});
|
||
}
|
||
var operations = [];
|
||
for (var i = 0, len = operationInfo.storeNames.length; i < len; i++) {
|
||
operations.push(dropTable(operationInfo.storeNames[i]));
|
||
}
|
||
Promise$1.all(operations).then(function() {
|
||
resolve();
|
||
})["catch"](function(e) {
|
||
reject(e);
|
||
});
|
||
}, function(sqlError) {
|
||
reject(sqlError);
|
||
});
|
||
});
|
||
});
|
||
}
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
var webSQLStorage = {
|
||
_driver: "webSQLStorage",
|
||
_initStorage: _initStorage$1,
|
||
_support: isWebSQLValid(),
|
||
iterate: iterate$1,
|
||
getItem: getItem$1,
|
||
setItem: setItem$1,
|
||
removeItem: removeItem$1,
|
||
clear: clear$1,
|
||
length: length$1,
|
||
key: key$1,
|
||
keys: keys$1,
|
||
dropInstance: dropInstance$1
|
||
};
|
||
function isLocalStorageValid() {
|
||
try {
|
||
return typeof localStorage !== "undefined" && "setItem" in localStorage && !!localStorage.setItem;
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
}
|
||
function _getKeyPrefix(options, defaultConfig) {
|
||
var keyPrefix = options.name + "/";
|
||
if (options.storeName !== defaultConfig.storeName) {
|
||
keyPrefix += options.storeName + "/";
|
||
}
|
||
return keyPrefix;
|
||
}
|
||
function checkIfLocalStorageThrows() {
|
||
var localStorageTestKey = "_localforage_support_test";
|
||
try {
|
||
localStorage.setItem(localStorageTestKey, true);
|
||
localStorage.removeItem(localStorageTestKey);
|
||
return false;
|
||
} catch (e) {
|
||
return true;
|
||
}
|
||
}
|
||
function _isLocalStorageUsable() {
|
||
return !checkIfLocalStorageThrows() || localStorage.length > 0;
|
||
}
|
||
function _initStorage$2(options) {
|
||
var self2 = this;
|
||
var dbInfo = {};
|
||
if (options) {
|
||
for (var i in options) {
|
||
dbInfo[i] = options[i];
|
||
}
|
||
}
|
||
dbInfo.keyPrefix = _getKeyPrefix(options, self2._defaultConfig);
|
||
if (!_isLocalStorageUsable()) {
|
||
return Promise$1.reject();
|
||
}
|
||
self2._dbInfo = dbInfo;
|
||
dbInfo.serializer = localforageSerializer;
|
||
return Promise$1.resolve();
|
||
}
|
||
function clear$2(callback) {
|
||
var self2 = this;
|
||
var promise = self2.ready().then(function() {
|
||
var keyPrefix = self2._dbInfo.keyPrefix;
|
||
for (var i = localStorage.length - 1; i >= 0; i--) {
|
||
var key2 = localStorage.key(i);
|
||
if (key2.indexOf(keyPrefix) === 0) {
|
||
localStorage.removeItem(key2);
|
||
}
|
||
}
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function getItem$2(key2, callback) {
|
||
var self2 = this;
|
||
key2 = normalizeKey(key2);
|
||
var promise = self2.ready().then(function() {
|
||
var dbInfo = self2._dbInfo;
|
||
var result = localStorage.getItem(dbInfo.keyPrefix + key2);
|
||
if (result) {
|
||
result = dbInfo.serializer.deserialize(result);
|
||
}
|
||
return result;
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function iterate$2(iterator, callback) {
|
||
var self2 = this;
|
||
var promise = self2.ready().then(function() {
|
||
var dbInfo = self2._dbInfo;
|
||
var keyPrefix = dbInfo.keyPrefix;
|
||
var keyPrefixLength = keyPrefix.length;
|
||
var length2 = localStorage.length;
|
||
var iterationNumber = 1;
|
||
for (var i = 0; i < length2; i++) {
|
||
var key2 = localStorage.key(i);
|
||
if (key2.indexOf(keyPrefix) !== 0) {
|
||
continue;
|
||
}
|
||
var value = localStorage.getItem(key2);
|
||
if (value) {
|
||
value = dbInfo.serializer.deserialize(value);
|
||
}
|
||
value = iterator(value, key2.substring(keyPrefixLength), iterationNumber++);
|
||
if (value !== void 0) {
|
||
return value;
|
||
}
|
||
}
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function key$2(n, callback) {
|
||
var self2 = this;
|
||
var promise = self2.ready().then(function() {
|
||
var dbInfo = self2._dbInfo;
|
||
var result;
|
||
try {
|
||
result = localStorage.key(n);
|
||
} catch (error) {
|
||
result = null;
|
||
}
|
||
if (result) {
|
||
result = result.substring(dbInfo.keyPrefix.length);
|
||
}
|
||
return result;
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function keys$2(callback) {
|
||
var self2 = this;
|
||
var promise = self2.ready().then(function() {
|
||
var dbInfo = self2._dbInfo;
|
||
var length2 = localStorage.length;
|
||
var keys2 = [];
|
||
for (var i = 0; i < length2; i++) {
|
||
var itemKey = localStorage.key(i);
|
||
if (itemKey.indexOf(dbInfo.keyPrefix) === 0) {
|
||
keys2.push(itemKey.substring(dbInfo.keyPrefix.length));
|
||
}
|
||
}
|
||
return keys2;
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function length$2(callback) {
|
||
var self2 = this;
|
||
var promise = self2.keys().then(function(keys2) {
|
||
return keys2.length;
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function removeItem$2(key2, callback) {
|
||
var self2 = this;
|
||
key2 = normalizeKey(key2);
|
||
var promise = self2.ready().then(function() {
|
||
var dbInfo = self2._dbInfo;
|
||
localStorage.removeItem(dbInfo.keyPrefix + key2);
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function setItem$2(key2, value, callback) {
|
||
var self2 = this;
|
||
key2 = normalizeKey(key2);
|
||
var promise = self2.ready().then(function() {
|
||
if (value === void 0) {
|
||
value = null;
|
||
}
|
||
var originalValue = value;
|
||
return new Promise$1(function(resolve, reject) {
|
||
var dbInfo = self2._dbInfo;
|
||
dbInfo.serializer.serialize(value, function(value2, error) {
|
||
if (error) {
|
||
reject(error);
|
||
} else {
|
||
try {
|
||
localStorage.setItem(dbInfo.keyPrefix + key2, value2);
|
||
resolve(originalValue);
|
||
} catch (e) {
|
||
if (e.name === "QuotaExceededError" || e.name === "NS_ERROR_DOM_QUOTA_REACHED") {
|
||
reject(e);
|
||
}
|
||
reject(e);
|
||
}
|
||
}
|
||
});
|
||
});
|
||
});
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
function dropInstance$2(options, callback) {
|
||
callback = getCallback.apply(this, arguments);
|
||
options = typeof options !== "function" && options || {};
|
||
if (!options.name) {
|
||
var currentConfig = this.config();
|
||
options.name = options.name || currentConfig.name;
|
||
options.storeName = options.storeName || currentConfig.storeName;
|
||
}
|
||
var self2 = this;
|
||
var promise;
|
||
if (!options.name) {
|
||
promise = Promise$1.reject("Invalid arguments");
|
||
} else {
|
||
promise = new Promise$1(function(resolve) {
|
||
if (!options.storeName) {
|
||
resolve(options.name + "/");
|
||
} else {
|
||
resolve(_getKeyPrefix(options, self2._defaultConfig));
|
||
}
|
||
}).then(function(keyPrefix) {
|
||
for (var i = localStorage.length - 1; i >= 0; i--) {
|
||
var key2 = localStorage.key(i);
|
||
if (key2.indexOf(keyPrefix) === 0) {
|
||
localStorage.removeItem(key2);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
executeCallback(promise, callback);
|
||
return promise;
|
||
}
|
||
var localStorageWrapper = {
|
||
_driver: "localStorageWrapper",
|
||
_initStorage: _initStorage$2,
|
||
_support: isLocalStorageValid(),
|
||
iterate: iterate$2,
|
||
getItem: getItem$2,
|
||
setItem: setItem$2,
|
||
removeItem: removeItem$2,
|
||
clear: clear$2,
|
||
length: length$2,
|
||
key: key$2,
|
||
keys: keys$2,
|
||
dropInstance: dropInstance$2
|
||
};
|
||
var sameValue = function sameValue2(x, y) {
|
||
return x === y || typeof x === "number" && typeof y === "number" && isNaN(x) && isNaN(y);
|
||
};
|
||
var includes = function includes2(array, searchElement) {
|
||
var len = array.length;
|
||
var i = 0;
|
||
while (i < len) {
|
||
if (sameValue(array[i], searchElement)) {
|
||
return true;
|
||
}
|
||
i++;
|
||
}
|
||
return false;
|
||
};
|
||
var isArray = Array.isArray || function(arg) {
|
||
return Object.prototype.toString.call(arg) === "[object Array]";
|
||
};
|
||
var DefinedDrivers = {};
|
||
var DriverSupport = {};
|
||
var DefaultDrivers = {
|
||
INDEXEDDB: asyncStorage,
|
||
WEBSQL: webSQLStorage,
|
||
LOCALSTORAGE: localStorageWrapper
|
||
};
|
||
var DefaultDriverOrder = [DefaultDrivers.INDEXEDDB._driver, DefaultDrivers.WEBSQL._driver, DefaultDrivers.LOCALSTORAGE._driver];
|
||
var OptionalDriverMethods = ["dropInstance"];
|
||
var LibraryMethods = ["clear", "getItem", "iterate", "key", "keys", "length", "removeItem", "setItem"].concat(OptionalDriverMethods);
|
||
var DefaultConfig = {
|
||
description: "",
|
||
driver: DefaultDriverOrder.slice(),
|
||
name: "localforage",
|
||
size: 4980736,
|
||
storeName: "keyvaluepairs",
|
||
version: 1
|
||
};
|
||
function callWhenReady(localForageInstance, libraryMethod) {
|
||
localForageInstance[libraryMethod] = function() {
|
||
var _args = arguments;
|
||
return localForageInstance.ready().then(function() {
|
||
return localForageInstance[libraryMethod].apply(localForageInstance, _args);
|
||
});
|
||
};
|
||
}
|
||
function extend() {
|
||
for (var i = 1; i < arguments.length; i++) {
|
||
var arg = arguments[i];
|
||
if (arg) {
|
||
for (var _key in arg) {
|
||
if (arg.hasOwnProperty(_key)) {
|
||
if (isArray(arg[_key])) {
|
||
arguments[0][_key] = arg[_key].slice();
|
||
} else {
|
||
arguments[0][_key] = arg[_key];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return arguments[0];
|
||
}
|
||
var LocalForage = function() {
|
||
function LocalForage2(options) {
|
||
_classCallCheck(this, LocalForage2);
|
||
for (var driverTypeKey in DefaultDrivers) {
|
||
if (DefaultDrivers.hasOwnProperty(driverTypeKey)) {
|
||
var driver = DefaultDrivers[driverTypeKey];
|
||
var driverName = driver._driver;
|
||
this[driverTypeKey] = driverName;
|
||
if (!DefinedDrivers[driverName]) {
|
||
this.defineDriver(driver);
|
||
}
|
||
}
|
||
}
|
||
this._defaultConfig = extend({}, DefaultConfig);
|
||
this._config = extend({}, this._defaultConfig, options);
|
||
this._driverSet = null;
|
||
this._initDriver = null;
|
||
this._ready = false;
|
||
this._dbInfo = null;
|
||
this._wrapLibraryMethodsWithReady();
|
||
this.setDriver(this._config.driver)["catch"](function() {
|
||
});
|
||
}
|
||
LocalForage2.prototype.config = function config(options) {
|
||
if ((typeof options === "undefined" ? "undefined" : _typeof(options)) === "object") {
|
||
if (this._ready) {
|
||
return new Error("Can't call config() after localforage has been used.");
|
||
}
|
||
for (var i in options) {
|
||
if (i === "storeName") {
|
||
options[i] = options[i].replace(/\W/g, "_");
|
||
}
|
||
if (i === "version" && typeof options[i] !== "number") {
|
||
return new Error("Database version must be a number.");
|
||
}
|
||
this._config[i] = options[i];
|
||
}
|
||
if ("driver" in options && options.driver) {
|
||
return this.setDriver(this._config.driver);
|
||
}
|
||
return true;
|
||
} else if (typeof options === "string") {
|
||
return this._config[options];
|
||
} else {
|
||
return this._config;
|
||
}
|
||
};
|
||
LocalForage2.prototype.defineDriver = function defineDriver(driverObject, callback, errorCallback) {
|
||
var promise = new Promise$1(function(resolve, reject) {
|
||
try {
|
||
var driverName = driverObject._driver;
|
||
var complianceError = new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");
|
||
if (!driverObject._driver) {
|
||
reject(complianceError);
|
||
return;
|
||
}
|
||
var driverMethods = LibraryMethods.concat("_initStorage");
|
||
for (var i = 0, len = driverMethods.length; i < len; i++) {
|
||
var driverMethodName = driverMethods[i];
|
||
var isRequired = !includes(OptionalDriverMethods, driverMethodName);
|
||
if ((isRequired || driverObject[driverMethodName]) && typeof driverObject[driverMethodName] !== "function") {
|
||
reject(complianceError);
|
||
return;
|
||
}
|
||
}
|
||
var configureMissingMethods = function configureMissingMethods2() {
|
||
var methodNotImplementedFactory = function methodNotImplementedFactory2(methodName) {
|
||
return function() {
|
||
var error = new Error("Method " + methodName + " is not implemented by the current driver");
|
||
var promise2 = Promise$1.reject(error);
|
||
executeCallback(promise2, arguments[arguments.length - 1]);
|
||
return promise2;
|
||
};
|
||
};
|
||
for (var _i = 0, _len = OptionalDriverMethods.length; _i < _len; _i++) {
|
||
var optionalDriverMethod = OptionalDriverMethods[_i];
|
||
if (!driverObject[optionalDriverMethod]) {
|
||
driverObject[optionalDriverMethod] = methodNotImplementedFactory(optionalDriverMethod);
|
||
}
|
||
}
|
||
};
|
||
configureMissingMethods();
|
||
var setDriverSupport = function setDriverSupport2(support) {
|
||
if (DefinedDrivers[driverName]) {
|
||
console.info("Redefining LocalForage driver: " + driverName);
|
||
}
|
||
DefinedDrivers[driverName] = driverObject;
|
||
DriverSupport[driverName] = support;
|
||
resolve();
|
||
};
|
||
if ("_support" in driverObject) {
|
||
if (driverObject._support && typeof driverObject._support === "function") {
|
||
driverObject._support().then(setDriverSupport, reject);
|
||
} else {
|
||
setDriverSupport(!!driverObject._support);
|
||
}
|
||
} else {
|
||
setDriverSupport(true);
|
||
}
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
});
|
||
executeTwoCallbacks(promise, callback, errorCallback);
|
||
return promise;
|
||
};
|
||
LocalForage2.prototype.driver = function driver() {
|
||
return this._driver || null;
|
||
};
|
||
LocalForage2.prototype.getDriver = function getDriver(driverName, callback, errorCallback) {
|
||
var getDriverPromise = DefinedDrivers[driverName] ? Promise$1.resolve(DefinedDrivers[driverName]) : Promise$1.reject(new Error("Driver not found."));
|
||
executeTwoCallbacks(getDriverPromise, callback, errorCallback);
|
||
return getDriverPromise;
|
||
};
|
||
LocalForage2.prototype.getSerializer = function getSerializer(callback) {
|
||
var serializerPromise = Promise$1.resolve(localforageSerializer);
|
||
executeTwoCallbacks(serializerPromise, callback);
|
||
return serializerPromise;
|
||
};
|
||
LocalForage2.prototype.ready = function ready(callback) {
|
||
var self2 = this;
|
||
var promise = self2._driverSet.then(function() {
|
||
if (self2._ready === null) {
|
||
self2._ready = self2._initDriver();
|
||
}
|
||
return self2._ready;
|
||
});
|
||
executeTwoCallbacks(promise, callback, callback);
|
||
return promise;
|
||
};
|
||
LocalForage2.prototype.setDriver = function setDriver(drivers, callback, errorCallback) {
|
||
var self2 = this;
|
||
if (!isArray(drivers)) {
|
||
drivers = [drivers];
|
||
}
|
||
var supportedDrivers = this._getSupportedDrivers(drivers);
|
||
function setDriverToConfig() {
|
||
self2._config.driver = self2.driver();
|
||
}
|
||
function extendSelfWithDriver(driver) {
|
||
self2._extend(driver);
|
||
setDriverToConfig();
|
||
self2._ready = self2._initStorage(self2._config);
|
||
return self2._ready;
|
||
}
|
||
function initDriver(supportedDrivers2) {
|
||
return function() {
|
||
var currentDriverIndex = 0;
|
||
function driverPromiseLoop() {
|
||
while (currentDriverIndex < supportedDrivers2.length) {
|
||
var driverName = supportedDrivers2[currentDriverIndex];
|
||
currentDriverIndex++;
|
||
self2._dbInfo = null;
|
||
self2._ready = null;
|
||
return self2.getDriver(driverName).then(extendSelfWithDriver)["catch"](driverPromiseLoop);
|
||
}
|
||
setDriverToConfig();
|
||
var error = new Error("No available storage method found.");
|
||
self2._driverSet = Promise$1.reject(error);
|
||
return self2._driverSet;
|
||
}
|
||
return driverPromiseLoop();
|
||
};
|
||
}
|
||
var oldDriverSetDone = this._driverSet !== null ? this._driverSet["catch"](function() {
|
||
return Promise$1.resolve();
|
||
}) : Promise$1.resolve();
|
||
this._driverSet = oldDriverSetDone.then(function() {
|
||
var driverName = supportedDrivers[0];
|
||
self2._dbInfo = null;
|
||
self2._ready = null;
|
||
return self2.getDriver(driverName).then(function(driver) {
|
||
self2._driver = driver._driver;
|
||
setDriverToConfig();
|
||
self2._wrapLibraryMethodsWithReady();
|
||
self2._initDriver = initDriver(supportedDrivers);
|
||
});
|
||
})["catch"](function() {
|
||
setDriverToConfig();
|
||
var error = new Error("No available storage method found.");
|
||
self2._driverSet = Promise$1.reject(error);
|
||
return self2._driverSet;
|
||
});
|
||
executeTwoCallbacks(this._driverSet, callback, errorCallback);
|
||
return this._driverSet;
|
||
};
|
||
LocalForage2.prototype.supports = function supports(driverName) {
|
||
return !!DriverSupport[driverName];
|
||
};
|
||
LocalForage2.prototype._extend = function _extend(libraryMethodsAndProperties) {
|
||
extend(this, libraryMethodsAndProperties);
|
||
};
|
||
LocalForage2.prototype._getSupportedDrivers = function _getSupportedDrivers(drivers) {
|
||
var supportedDrivers = [];
|
||
for (var i = 0, len = drivers.length; i < len; i++) {
|
||
var driverName = drivers[i];
|
||
if (this.supports(driverName)) {
|
||
supportedDrivers.push(driverName);
|
||
}
|
||
}
|
||
return supportedDrivers;
|
||
};
|
||
LocalForage2.prototype._wrapLibraryMethodsWithReady = function _wrapLibraryMethodsWithReady() {
|
||
for (var i = 0, len = LibraryMethods.length; i < len; i++) {
|
||
callWhenReady(this, LibraryMethods[i]);
|
||
}
|
||
};
|
||
LocalForage2.prototype.createInstance = function createInstance(options) {
|
||
return new LocalForage2(options);
|
||
};
|
||
return LocalForage2;
|
||
}();
|
||
var localforage_js = new LocalForage();
|
||
module4.exports = localforage_js;
|
||
}, { "3": 3 }] }, {}, [4])(4);
|
||
});
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/store.js
|
||
var require_store = __commonJS({
|
||
"node_modules/epubjs/lib/store.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _core = require_core();
|
||
var _request = _interopRequireDefault(require_request());
|
||
var _mime = _interopRequireDefault(require_mime());
|
||
var _path = _interopRequireDefault(require_path2());
|
||
var _eventEmitter = _interopRequireDefault(require_event_emitter());
|
||
var _localforage = _interopRequireDefault(require_localforage());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var Store = class {
|
||
constructor(name, requester, resolver) {
|
||
this.urlCache = {};
|
||
this.storage = void 0;
|
||
this.name = name;
|
||
this.requester = requester || _request.default;
|
||
this.resolver = resolver;
|
||
this.online = true;
|
||
this.checkRequirements();
|
||
this.addListeners();
|
||
}
|
||
checkRequirements() {
|
||
try {
|
||
let store;
|
||
if (typeof _localforage.default === "undefined") {
|
||
store = _localforage.default;
|
||
}
|
||
this.storage = store.createInstance({
|
||
name: this.name
|
||
});
|
||
} catch (e) {
|
||
throw new Error("localForage lib not loaded");
|
||
}
|
||
}
|
||
addListeners() {
|
||
this._status = this.status.bind(this);
|
||
window.addEventListener("online", this._status);
|
||
window.addEventListener("offline", this._status);
|
||
}
|
||
removeListeners() {
|
||
window.removeEventListener("online", this._status);
|
||
window.removeEventListener("offline", this._status);
|
||
this._status = void 0;
|
||
}
|
||
status(event) {
|
||
let online = navigator.onLine;
|
||
this.online = online;
|
||
if (online) {
|
||
this.emit("online", this);
|
||
} else {
|
||
this.emit("offline", this);
|
||
}
|
||
}
|
||
add(resources, force) {
|
||
let mapped = resources.resources.map((item) => {
|
||
let {
|
||
href
|
||
} = item;
|
||
let url = this.resolver(href);
|
||
let encodedUrl = window.encodeURIComponent(url);
|
||
return this.storage.getItem(encodedUrl).then((item2) => {
|
||
if (!item2 || force) {
|
||
return this.requester(url, "binary").then((data) => {
|
||
return this.storage.setItem(encodedUrl, data);
|
||
});
|
||
} else {
|
||
return item2;
|
||
}
|
||
});
|
||
});
|
||
return Promise.all(mapped);
|
||
}
|
||
put(url, withCredentials, headers) {
|
||
let encodedUrl = window.encodeURIComponent(url);
|
||
return this.storage.getItem(encodedUrl).then((result) => {
|
||
if (!result) {
|
||
return this.requester(url, "binary", withCredentials, headers).then((data) => {
|
||
return this.storage.setItem(encodedUrl, data);
|
||
});
|
||
}
|
||
return result;
|
||
});
|
||
}
|
||
request(url, type, withCredentials, headers) {
|
||
if (this.online) {
|
||
return this.requester(url, type, withCredentials, headers).then((data) => {
|
||
this.put(url);
|
||
return data;
|
||
});
|
||
} else {
|
||
return this.retrieve(url, type);
|
||
}
|
||
}
|
||
retrieve(url, type) {
|
||
var deferred = new _core.defer();
|
||
var response;
|
||
var path = new _path.default(url);
|
||
if (!type) {
|
||
type = path.extension;
|
||
}
|
||
if (type == "blob") {
|
||
response = this.getBlob(url);
|
||
} else {
|
||
response = this.getText(url);
|
||
}
|
||
return response.then((r) => {
|
||
var deferred2 = new _core.defer();
|
||
var result;
|
||
if (r) {
|
||
result = this.handleResponse(r, type);
|
||
deferred2.resolve(result);
|
||
} else {
|
||
deferred2.reject({
|
||
message: "File not found in storage: " + url,
|
||
stack: new Error().stack
|
||
});
|
||
}
|
||
return deferred2.promise;
|
||
});
|
||
}
|
||
handleResponse(response, type) {
|
||
var r;
|
||
if (type == "json") {
|
||
r = JSON.parse(response);
|
||
} else if ((0, _core.isXml)(type)) {
|
||
r = (0, _core.parse)(response, "text/xml");
|
||
} else if (type == "xhtml") {
|
||
r = (0, _core.parse)(response, "application/xhtml+xml");
|
||
} else if (type == "html" || type == "htm") {
|
||
r = (0, _core.parse)(response, "text/html");
|
||
} else {
|
||
r = response;
|
||
}
|
||
return r;
|
||
}
|
||
getBlob(url, mimeType) {
|
||
let encodedUrl = window.encodeURIComponent(url);
|
||
return this.storage.getItem(encodedUrl).then(function(uint8array) {
|
||
if (!uint8array)
|
||
return;
|
||
mimeType = mimeType || _mime.default.lookup(url);
|
||
return new Blob([uint8array], {
|
||
type: mimeType
|
||
});
|
||
});
|
||
}
|
||
getText(url, mimeType) {
|
||
let encodedUrl = window.encodeURIComponent(url);
|
||
mimeType = mimeType || _mime.default.lookup(url);
|
||
return this.storage.getItem(encodedUrl).then(function(uint8array) {
|
||
var deferred = new _core.defer();
|
||
var reader = new FileReader();
|
||
var blob;
|
||
if (!uint8array)
|
||
return;
|
||
blob = new Blob([uint8array], {
|
||
type: mimeType
|
||
});
|
||
reader.addEventListener("loadend", () => {
|
||
deferred.resolve(reader.result);
|
||
});
|
||
reader.readAsText(blob, mimeType);
|
||
return deferred.promise;
|
||
});
|
||
}
|
||
getBase64(url, mimeType) {
|
||
let encodedUrl = window.encodeURIComponent(url);
|
||
mimeType = mimeType || _mime.default.lookup(url);
|
||
return this.storage.getItem(encodedUrl).then((uint8array) => {
|
||
var deferred = new _core.defer();
|
||
var reader = new FileReader();
|
||
var blob;
|
||
if (!uint8array)
|
||
return;
|
||
blob = new Blob([uint8array], {
|
||
type: mimeType
|
||
});
|
||
reader.addEventListener("loadend", () => {
|
||
deferred.resolve(reader.result);
|
||
});
|
||
reader.readAsDataURL(blob, mimeType);
|
||
return deferred.promise;
|
||
});
|
||
}
|
||
createUrl(url, options) {
|
||
var deferred = new _core.defer();
|
||
var _URL = window.URL || window.webkitURL || window.mozURL;
|
||
var tempUrl;
|
||
var response;
|
||
var useBase64 = options && options.base64;
|
||
if (url in this.urlCache) {
|
||
deferred.resolve(this.urlCache[url]);
|
||
return deferred.promise;
|
||
}
|
||
if (useBase64) {
|
||
response = this.getBase64(url);
|
||
if (response) {
|
||
response.then(function(tempUrl2) {
|
||
this.urlCache[url] = tempUrl2;
|
||
deferred.resolve(tempUrl2);
|
||
}.bind(this));
|
||
}
|
||
} else {
|
||
response = this.getBlob(url);
|
||
if (response) {
|
||
response.then(function(blob) {
|
||
tempUrl = _URL.createObjectURL(blob);
|
||
this.urlCache[url] = tempUrl;
|
||
deferred.resolve(tempUrl);
|
||
}.bind(this));
|
||
}
|
||
}
|
||
if (!response) {
|
||
deferred.reject({
|
||
message: "File not found in storage: " + url,
|
||
stack: new Error().stack
|
||
});
|
||
}
|
||
return deferred.promise;
|
||
}
|
||
revokeUrl(url) {
|
||
var _URL = window.URL || window.webkitURL || window.mozURL;
|
||
var fromCache = this.urlCache[url];
|
||
if (fromCache)
|
||
_URL.revokeObjectURL(fromCache);
|
||
}
|
||
destroy() {
|
||
var _URL = window.URL || window.webkitURL || window.mozURL;
|
||
for (let fromCache in this.urlCache) {
|
||
_URL.revokeObjectURL(fromCache);
|
||
}
|
||
this.urlCache = {};
|
||
this.removeListeners();
|
||
}
|
||
};
|
||
(0, _eventEmitter.default)(Store.prototype);
|
||
var _default = Store;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/displayoptions.js
|
||
var require_displayoptions = __commonJS({
|
||
"node_modules/epubjs/lib/displayoptions.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _core = require_core();
|
||
var DisplayOptions = class {
|
||
constructor(displayOptionsDocument) {
|
||
this.interactive = "";
|
||
this.fixedLayout = "";
|
||
this.openToSpread = "";
|
||
this.orientationLock = "";
|
||
if (displayOptionsDocument) {
|
||
this.parse(displayOptionsDocument);
|
||
}
|
||
}
|
||
parse(displayOptionsDocument) {
|
||
if (!displayOptionsDocument) {
|
||
return this;
|
||
}
|
||
const displayOptionsNode = (0, _core.qs)(displayOptionsDocument, "display_options");
|
||
if (!displayOptionsNode) {
|
||
return this;
|
||
}
|
||
const options = (0, _core.qsa)(displayOptionsNode, "option");
|
||
options.forEach((el) => {
|
||
let value = "";
|
||
if (el.childNodes.length) {
|
||
value = el.childNodes[0].nodeValue;
|
||
}
|
||
switch (el.attributes.name.value) {
|
||
case "interactive":
|
||
this.interactive = value;
|
||
break;
|
||
case "fixed-layout":
|
||
this.fixedLayout = value;
|
||
break;
|
||
case "open-to-spread":
|
||
this.openToSpread = value;
|
||
break;
|
||
case "orientation-lock":
|
||
this.orientationLock = value;
|
||
break;
|
||
}
|
||
});
|
||
return this;
|
||
}
|
||
destroy() {
|
||
this.interactive = void 0;
|
||
this.fixedLayout = void 0;
|
||
this.openToSpread = void 0;
|
||
this.orientationLock = void 0;
|
||
}
|
||
};
|
||
var _default = DisplayOptions;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/book.js
|
||
var require_book = __commonJS({
|
||
"node_modules/epubjs/lib/book.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _eventEmitter = _interopRequireDefault(require_event_emitter());
|
||
var _core = require_core();
|
||
var _url = _interopRequireDefault(require_url());
|
||
var _path = _interopRequireDefault(require_path2());
|
||
var _spine = _interopRequireDefault(require_spine());
|
||
var _locations = _interopRequireDefault(require_locations());
|
||
var _container = _interopRequireDefault(require_container());
|
||
var _packaging = _interopRequireDefault(require_packaging());
|
||
var _navigation = _interopRequireDefault(require_navigation());
|
||
var _resources = _interopRequireDefault(require_resources());
|
||
var _pagelist = _interopRequireDefault(require_pagelist());
|
||
var _rendition = _interopRequireDefault(require_rendition());
|
||
var _archive = _interopRequireDefault(require_archive());
|
||
var _request2 = _interopRequireDefault(require_request());
|
||
var _epubcfi = _interopRequireDefault(require_epubcfi());
|
||
var _store = _interopRequireDefault(require_store());
|
||
var _displayoptions = _interopRequireDefault(require_displayoptions());
|
||
var _constants = require_constants();
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var CONTAINER_PATH = "META-INF/container.xml";
|
||
var IBOOKS_DISPLAY_OPTIONS_PATH = "META-INF/com.apple.ibooks.display-options.xml";
|
||
var INPUT_TYPE = {
|
||
BINARY: "binary",
|
||
BASE64: "base64",
|
||
EPUB: "epub",
|
||
OPF: "opf",
|
||
MANIFEST: "json",
|
||
DIRECTORY: "directory"
|
||
};
|
||
var Book = class {
|
||
constructor(url, options) {
|
||
if (typeof options === "undefined" && typeof url !== "string" && url instanceof Blob === false && url instanceof ArrayBuffer === false) {
|
||
options = url;
|
||
url = void 0;
|
||
}
|
||
this.settings = (0, _core.extend)(this.settings || {}, {
|
||
requestMethod: void 0,
|
||
requestCredentials: void 0,
|
||
requestHeaders: void 0,
|
||
encoding: void 0,
|
||
replacements: void 0,
|
||
canonical: void 0,
|
||
openAs: void 0,
|
||
store: void 0
|
||
});
|
||
(0, _core.extend)(this.settings, options);
|
||
this.opening = new _core.defer();
|
||
this.opened = this.opening.promise;
|
||
this.isOpen = false;
|
||
this.loading = {
|
||
manifest: new _core.defer(),
|
||
spine: new _core.defer(),
|
||
metadata: new _core.defer(),
|
||
cover: new _core.defer(),
|
||
navigation: new _core.defer(),
|
||
pageList: new _core.defer(),
|
||
resources: new _core.defer(),
|
||
displayOptions: new _core.defer()
|
||
};
|
||
this.loaded = {
|
||
manifest: this.loading.manifest.promise,
|
||
spine: this.loading.spine.promise,
|
||
metadata: this.loading.metadata.promise,
|
||
cover: this.loading.cover.promise,
|
||
navigation: this.loading.navigation.promise,
|
||
pageList: this.loading.pageList.promise,
|
||
resources: this.loading.resources.promise,
|
||
displayOptions: this.loading.displayOptions.promise
|
||
};
|
||
this.ready = Promise.all([this.loaded.manifest, this.loaded.spine, this.loaded.metadata, this.loaded.cover, this.loaded.navigation, this.loaded.resources, this.loaded.displayOptions]);
|
||
this.isRendered = false;
|
||
this.request = this.settings.requestMethod || _request2.default;
|
||
this.spine = new _spine.default();
|
||
this.locations = new _locations.default(this.spine, this.load.bind(this));
|
||
this.navigation = void 0;
|
||
this.pageList = void 0;
|
||
this.url = void 0;
|
||
this.path = void 0;
|
||
this.archived = false;
|
||
this.archive = void 0;
|
||
this.storage = void 0;
|
||
this.resources = void 0;
|
||
this.rendition = void 0;
|
||
this.container = void 0;
|
||
this.packaging = void 0;
|
||
this.displayOptions = void 0;
|
||
if (this.settings.store) {
|
||
this.store(this.settings.store);
|
||
}
|
||
if (url) {
|
||
this.open(url, this.settings.openAs).catch((error) => {
|
||
var err = new Error("Cannot load book at " + url);
|
||
this.emit(_constants.EVENTS.BOOK.OPEN_FAILED, err);
|
||
});
|
||
}
|
||
}
|
||
open(input, what) {
|
||
var opening;
|
||
var type = what || this.determineType(input);
|
||
if (type === INPUT_TYPE.BINARY) {
|
||
this.archived = true;
|
||
this.url = new _url.default("/", "");
|
||
opening = this.openEpub(input);
|
||
} else if (type === INPUT_TYPE.BASE64) {
|
||
this.archived = true;
|
||
this.url = new _url.default("/", "");
|
||
opening = this.openEpub(input, type);
|
||
} else if (type === INPUT_TYPE.EPUB) {
|
||
this.archived = true;
|
||
this.url = new _url.default("/", "");
|
||
opening = this.request(input, "binary", this.settings.requestCredentials, this.settings.requestHeaders).then(this.openEpub.bind(this));
|
||
} else if (type == INPUT_TYPE.OPF) {
|
||
this.url = new _url.default(input);
|
||
opening = this.openPackaging(this.url.Path.toString());
|
||
} else if (type == INPUT_TYPE.MANIFEST) {
|
||
this.url = new _url.default(input);
|
||
opening = this.openManifest(this.url.Path.toString());
|
||
} else {
|
||
this.url = new _url.default(input);
|
||
opening = this.openContainer(CONTAINER_PATH).then(this.openPackaging.bind(this));
|
||
}
|
||
return opening;
|
||
}
|
||
openEpub(data, encoding) {
|
||
return this.unarchive(data, encoding || this.settings.encoding).then(() => {
|
||
return this.openContainer(CONTAINER_PATH);
|
||
}).then((packagePath) => {
|
||
return this.openPackaging(packagePath);
|
||
});
|
||
}
|
||
openContainer(url) {
|
||
return this.load(url).then((xml) => {
|
||
this.container = new _container.default(xml);
|
||
return this.resolve(this.container.packagePath);
|
||
});
|
||
}
|
||
openPackaging(url) {
|
||
this.path = new _path.default(url);
|
||
return this.load(url).then((xml) => {
|
||
this.packaging = new _packaging.default(xml);
|
||
return this.unpack(this.packaging);
|
||
});
|
||
}
|
||
openManifest(url) {
|
||
this.path = new _path.default(url);
|
||
return this.load(url).then((json) => {
|
||
this.packaging = new _packaging.default();
|
||
this.packaging.load(json);
|
||
return this.unpack(this.packaging);
|
||
});
|
||
}
|
||
load(path) {
|
||
var resolved = this.resolve(path);
|
||
if (this.archived) {
|
||
return this.archive.request(resolved);
|
||
} else {
|
||
return this.request(resolved, null, this.settings.requestCredentials, this.settings.requestHeaders);
|
||
}
|
||
}
|
||
resolve(path, absolute) {
|
||
if (!path) {
|
||
return;
|
||
}
|
||
var resolved = path;
|
||
var isAbsolute = path.indexOf("://") > -1;
|
||
if (isAbsolute) {
|
||
return path;
|
||
}
|
||
if (this.path) {
|
||
resolved = this.path.resolve(path);
|
||
}
|
||
if (absolute != false && this.url) {
|
||
resolved = this.url.resolve(resolved);
|
||
}
|
||
return resolved;
|
||
}
|
||
canonical(path) {
|
||
var url = path;
|
||
if (!path) {
|
||
return "";
|
||
}
|
||
if (this.settings.canonical) {
|
||
url = this.settings.canonical(path);
|
||
} else {
|
||
url = this.resolve(path, true);
|
||
}
|
||
return url;
|
||
}
|
||
determineType(input) {
|
||
var url;
|
||
var path;
|
||
var extension;
|
||
if (this.settings.encoding === "base64") {
|
||
return INPUT_TYPE.BASE64;
|
||
}
|
||
if (typeof input != "string") {
|
||
return INPUT_TYPE.BINARY;
|
||
}
|
||
url = new _url.default(input);
|
||
path = url.path();
|
||
extension = path.extension;
|
||
if (extension) {
|
||
extension = extension.replace(/\?.*$/, "");
|
||
}
|
||
if (!extension) {
|
||
return INPUT_TYPE.DIRECTORY;
|
||
}
|
||
if (extension === "epub") {
|
||
return INPUT_TYPE.EPUB;
|
||
}
|
||
if (extension === "opf") {
|
||
return INPUT_TYPE.OPF;
|
||
}
|
||
if (extension === "json") {
|
||
return INPUT_TYPE.MANIFEST;
|
||
}
|
||
}
|
||
unpack(packaging) {
|
||
this.package = packaging;
|
||
if (this.packaging.metadata.layout === "") {
|
||
this.load(this.url.resolve(IBOOKS_DISPLAY_OPTIONS_PATH)).then((xml) => {
|
||
this.displayOptions = new _displayoptions.default(xml);
|
||
this.loading.displayOptions.resolve(this.displayOptions);
|
||
}).catch((err) => {
|
||
this.displayOptions = new _displayoptions.default();
|
||
this.loading.displayOptions.resolve(this.displayOptions);
|
||
});
|
||
} else {
|
||
this.displayOptions = new _displayoptions.default();
|
||
this.loading.displayOptions.resolve(this.displayOptions);
|
||
}
|
||
this.spine.unpack(this.packaging, this.resolve.bind(this), this.canonical.bind(this));
|
||
this.resources = new _resources.default(this.packaging.manifest, {
|
||
archive: this.archive,
|
||
resolver: this.resolve.bind(this),
|
||
request: this.request.bind(this),
|
||
replacements: this.settings.replacements || (this.archived ? "blobUrl" : "base64")
|
||
});
|
||
this.loadNavigation(this.packaging).then(() => {
|
||
this.loading.navigation.resolve(this.navigation);
|
||
});
|
||
if (this.packaging.coverPath) {
|
||
this.cover = this.resolve(this.packaging.coverPath);
|
||
}
|
||
this.loading.manifest.resolve(this.packaging.manifest);
|
||
this.loading.metadata.resolve(this.packaging.metadata);
|
||
this.loading.spine.resolve(this.spine);
|
||
this.loading.cover.resolve(this.cover);
|
||
this.loading.resources.resolve(this.resources);
|
||
this.loading.pageList.resolve(this.pageList);
|
||
this.isOpen = true;
|
||
if (this.archived || this.settings.replacements && this.settings.replacements != "none") {
|
||
this.replacements().then(() => {
|
||
this.loaded.displayOptions.then(() => {
|
||
this.opening.resolve(this);
|
||
});
|
||
}).catch((err) => {
|
||
console.error(err);
|
||
});
|
||
} else {
|
||
this.loaded.displayOptions.then(() => {
|
||
this.opening.resolve(this);
|
||
});
|
||
}
|
||
}
|
||
loadNavigation(packaging) {
|
||
let navPath = packaging.navPath || packaging.ncxPath;
|
||
let toc = packaging.toc;
|
||
if (toc) {
|
||
return new Promise((resolve, reject) => {
|
||
this.navigation = new _navigation.default(toc);
|
||
if (packaging.pageList) {
|
||
this.pageList = new _pagelist.default(packaging.pageList);
|
||
}
|
||
resolve(this.navigation);
|
||
});
|
||
}
|
||
if (!navPath) {
|
||
return new Promise((resolve, reject) => {
|
||
this.navigation = new _navigation.default();
|
||
this.pageList = new _pagelist.default();
|
||
resolve(this.navigation);
|
||
});
|
||
}
|
||
return this.load(navPath, "xml").then((xml) => {
|
||
this.navigation = new _navigation.default(xml);
|
||
this.pageList = new _pagelist.default(xml);
|
||
return this.navigation;
|
||
});
|
||
}
|
||
section(target) {
|
||
return this.spine.get(target);
|
||
}
|
||
renderTo(element, options) {
|
||
this.rendition = new _rendition.default(this, options);
|
||
this.rendition.attachTo(element);
|
||
return this.rendition;
|
||
}
|
||
setRequestCredentials(credentials) {
|
||
this.settings.requestCredentials = credentials;
|
||
}
|
||
setRequestHeaders(headers) {
|
||
this.settings.requestHeaders = headers;
|
||
}
|
||
unarchive(input, encoding) {
|
||
this.archive = new _archive.default();
|
||
return this.archive.open(input, encoding);
|
||
}
|
||
store(name) {
|
||
let replacementsSetting = this.settings.replacements && this.settings.replacements !== "none";
|
||
let originalUrl = this.url;
|
||
let requester = this.settings.requestMethod || _request2.default.bind(this);
|
||
this.storage = new _store.default(name, requester, this.resolve.bind(this));
|
||
this.request = this.storage.request.bind(this.storage);
|
||
this.opened.then(() => {
|
||
if (this.archived) {
|
||
this.storage.requester = this.archive.request.bind(this.archive);
|
||
}
|
||
let substituteResources = (output, section) => {
|
||
section.output = this.resources.substitute(output, section.url);
|
||
};
|
||
this.resources.settings.replacements = replacementsSetting || "blobUrl";
|
||
this.resources.replacements().then(() => {
|
||
return this.resources.replaceCss();
|
||
});
|
||
this.storage.on("offline", () => {
|
||
this.url = new _url.default("/", "");
|
||
this.spine.hooks.serialize.register(substituteResources);
|
||
});
|
||
this.storage.on("online", () => {
|
||
this.url = originalUrl;
|
||
this.spine.hooks.serialize.deregister(substituteResources);
|
||
});
|
||
});
|
||
return this.storage;
|
||
}
|
||
coverUrl() {
|
||
return this.loaded.cover.then(() => {
|
||
if (!this.cover) {
|
||
return null;
|
||
}
|
||
if (this.archived) {
|
||
return this.archive.createUrl(this.cover);
|
||
} else {
|
||
return this.cover;
|
||
}
|
||
});
|
||
}
|
||
replacements() {
|
||
this.spine.hooks.serialize.register((output, section) => {
|
||
section.output = this.resources.substitute(output, section.url);
|
||
});
|
||
return this.resources.replacements().then(() => {
|
||
return this.resources.replaceCss();
|
||
});
|
||
}
|
||
getRange(cfiRange) {
|
||
var cfi = new _epubcfi.default(cfiRange);
|
||
var item = this.spine.get(cfi.spinePos);
|
||
var _request = this.load.bind(this);
|
||
if (!item) {
|
||
return new Promise((resolve, reject) => {
|
||
reject("CFI could not be found");
|
||
});
|
||
}
|
||
return item.load(_request).then(function(contents) {
|
||
var range = cfi.toRange(item.document);
|
||
return range;
|
||
});
|
||
}
|
||
key(identifier) {
|
||
var ident = identifier || this.packaging.metadata.identifier || this.url.filename;
|
||
return `epubjs:${_constants.EPUBJS_VERSION}:${ident}`;
|
||
}
|
||
destroy() {
|
||
this.opened = void 0;
|
||
this.loading = void 0;
|
||
this.loaded = void 0;
|
||
this.ready = void 0;
|
||
this.isOpen = false;
|
||
this.isRendered = false;
|
||
this.spine && this.spine.destroy();
|
||
this.locations && this.locations.destroy();
|
||
this.pageList && this.pageList.destroy();
|
||
this.archive && this.archive.destroy();
|
||
this.resources && this.resources.destroy();
|
||
this.container && this.container.destroy();
|
||
this.packaging && this.packaging.destroy();
|
||
this.rendition && this.rendition.destroy();
|
||
this.displayOptions && this.displayOptions.destroy();
|
||
this.spine = void 0;
|
||
this.locations = void 0;
|
||
this.pageList = void 0;
|
||
this.archive = void 0;
|
||
this.resources = void 0;
|
||
this.container = void 0;
|
||
this.packaging = void 0;
|
||
this.rendition = void 0;
|
||
this.navigation = void 0;
|
||
this.url = void 0;
|
||
this.path = void 0;
|
||
this.archived = false;
|
||
}
|
||
};
|
||
(0, _eventEmitter.default)(Book.prototype);
|
||
var _default = Book;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/epub.js
|
||
var require_epub = __commonJS({
|
||
"node_modules/epubjs/lib/epub.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _book = _interopRequireDefault(require_book());
|
||
var _rendition = _interopRequireDefault(require_rendition());
|
||
var _epubcfi = _interopRequireDefault(require_epubcfi());
|
||
var _contents = _interopRequireDefault(require_contents());
|
||
var utils = _interopRequireWildcard(require_core());
|
||
var _constants = require_constants();
|
||
var _iframe = _interopRequireDefault(require_iframe());
|
||
var _default2 = _interopRequireDefault(require_default());
|
||
var _continuous = _interopRequireDefault(require_continuous());
|
||
function _getRequireWildcardCache(nodeInterop) {
|
||
if (typeof WeakMap !== "function")
|
||
return null;
|
||
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
||
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
||
return (_getRequireWildcardCache = function(nodeInterop2) {
|
||
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
||
})(nodeInterop);
|
||
}
|
||
function _interopRequireWildcard(obj, nodeInterop) {
|
||
if (!nodeInterop && obj && obj.__esModule) {
|
||
return obj;
|
||
}
|
||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
||
return { default: obj };
|
||
}
|
||
var cache = _getRequireWildcardCache(nodeInterop);
|
||
if (cache && cache.has(obj)) {
|
||
return cache.get(obj);
|
||
}
|
||
var newObj = {};
|
||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||
for (var key in obj) {
|
||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||
if (desc && (desc.get || desc.set)) {
|
||
Object.defineProperty(newObj, key, desc);
|
||
} else {
|
||
newObj[key] = obj[key];
|
||
}
|
||
}
|
||
}
|
||
newObj.default = obj;
|
||
if (cache) {
|
||
cache.set(obj, newObj);
|
||
}
|
||
return newObj;
|
||
}
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
function ePub(url, options) {
|
||
return new _book.default(url, options);
|
||
}
|
||
ePub.VERSION = _constants.EPUBJS_VERSION;
|
||
if (typeof global !== "undefined") {
|
||
global.EPUBJS_VERSION = _constants.EPUBJS_VERSION;
|
||
}
|
||
ePub.Book = _book.default;
|
||
ePub.Rendition = _rendition.default;
|
||
ePub.Contents = _contents.default;
|
||
ePub.CFI = _epubcfi.default;
|
||
ePub.utils = utils;
|
||
var _default = ePub;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/epubjs/lib/index.js
|
||
var require_lib2 = __commonJS({
|
||
"node_modules/epubjs/lib/index.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
Object.defineProperty(exports, "Book", {
|
||
enumerable: true,
|
||
get: function() {
|
||
return _book.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "Contents", {
|
||
enumerable: true,
|
||
get: function() {
|
||
return _contents.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "EpubCFI", {
|
||
enumerable: true,
|
||
get: function() {
|
||
return _epubcfi.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "Layout", {
|
||
enumerable: true,
|
||
get: function() {
|
||
return _layout.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "Rendition", {
|
||
enumerable: true,
|
||
get: function() {
|
||
return _rendition.default;
|
||
}
|
||
});
|
||
exports.default = void 0;
|
||
var _book = _interopRequireDefault(require_book());
|
||
var _epubcfi = _interopRequireDefault(require_epubcfi());
|
||
var _rendition = _interopRequireDefault(require_rendition());
|
||
var _contents = _interopRequireDefault(require_contents());
|
||
var _layout = _interopRequireDefault(require_layout());
|
||
var _epub = _interopRequireDefault(require_epub());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
var _default = _epub.default;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/react-reader/lib/EpubView/style.js
|
||
var require_style = __commonJS({
|
||
"node_modules/react-reader/lib/EpubView/style.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var epubViewStyles = {
|
||
viewHolder: {
|
||
position: "relative",
|
||
height: "100%",
|
||
width: "100%"
|
||
},
|
||
view: {
|
||
height: "100%"
|
||
}
|
||
};
|
||
var _default = epubViewStyles;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/react-reader/lib/EpubView/EpubView.js
|
||
var require_EpubView = __commonJS({
|
||
"node_modules/react-reader/lib/EpubView/EpubView.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _react = _interopRequireWildcard(require_react());
|
||
var _propTypes = _interopRequireDefault(require_prop_types());
|
||
var _index = _interopRequireDefault(require_lib2());
|
||
var _style = _interopRequireDefault(require_style());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
function _getRequireWildcardCache(nodeInterop) {
|
||
if (typeof WeakMap !== "function")
|
||
return null;
|
||
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
||
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
||
return (_getRequireWildcardCache = function _getRequireWildcardCache2(nodeInterop2) {
|
||
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
||
})(nodeInterop);
|
||
}
|
||
function _interopRequireWildcard(obj, nodeInterop) {
|
||
if (!nodeInterop && obj && obj.__esModule) {
|
||
return obj;
|
||
}
|
||
if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
|
||
return { default: obj };
|
||
}
|
||
var cache = _getRequireWildcardCache(nodeInterop);
|
||
if (cache && cache.has(obj)) {
|
||
return cache.get(obj);
|
||
}
|
||
var newObj = {};
|
||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||
for (var key in obj) {
|
||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||
if (desc && (desc.get || desc.set)) {
|
||
Object.defineProperty(newObj, key, desc);
|
||
} else {
|
||
newObj[key] = obj[key];
|
||
}
|
||
}
|
||
}
|
||
newObj.default = obj;
|
||
if (cache) {
|
||
cache.set(obj, newObj);
|
||
}
|
||
return newObj;
|
||
}
|
||
function _typeof(obj) {
|
||
"@babel/helpers - typeof";
|
||
return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(obj2) {
|
||
return typeof obj2;
|
||
} : function(obj2) {
|
||
return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
||
}, _typeof(obj);
|
||
}
|
||
function ownKeys(object, enumerableOnly) {
|
||
var keys = Object.keys(object);
|
||
if (Object.getOwnPropertySymbols) {
|
||
var symbols = Object.getOwnPropertySymbols(object);
|
||
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
||
})), keys.push.apply(keys, symbols);
|
||
}
|
||
return keys;
|
||
}
|
||
function _objectSpread(target) {
|
||
for (var i = 1; i < arguments.length; i++) {
|
||
var source = arguments[i] != null ? arguments[i] : {};
|
||
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
||
_defineProperty(target, key, source[key]);
|
||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
||
});
|
||
}
|
||
return target;
|
||
}
|
||
function _classCallCheck(instance, Constructor) {
|
||
if (!(instance instanceof Constructor)) {
|
||
throw new TypeError("Cannot call a class as a function");
|
||
}
|
||
}
|
||
function _defineProperties(target, props) {
|
||
for (var i = 0; i < props.length; i++) {
|
||
var descriptor = props[i];
|
||
descriptor.enumerable = descriptor.enumerable || false;
|
||
descriptor.configurable = true;
|
||
if ("value" in descriptor)
|
||
descriptor.writable = true;
|
||
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
||
}
|
||
}
|
||
function _createClass(Constructor, protoProps, staticProps) {
|
||
if (protoProps)
|
||
_defineProperties(Constructor.prototype, protoProps);
|
||
if (staticProps)
|
||
_defineProperties(Constructor, staticProps);
|
||
Object.defineProperty(Constructor, "prototype", { writable: false });
|
||
return Constructor;
|
||
}
|
||
function _inherits(subClass, superClass) {
|
||
if (typeof superClass !== "function" && superClass !== null) {
|
||
throw new TypeError("Super expression must either be null or a function");
|
||
}
|
||
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
||
Object.defineProperty(subClass, "prototype", { writable: false });
|
||
if (superClass)
|
||
_setPrototypeOf(subClass, superClass);
|
||
}
|
||
function _setPrototypeOf(o, p) {
|
||
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
|
||
o2.__proto__ = p2;
|
||
return o2;
|
||
};
|
||
return _setPrototypeOf(o, p);
|
||
}
|
||
function _createSuper(Derived) {
|
||
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
||
return function _createSuperInternal() {
|
||
var Super = _getPrototypeOf(Derived), result;
|
||
if (hasNativeReflectConstruct) {
|
||
var NewTarget = _getPrototypeOf(this).constructor;
|
||
result = Reflect.construct(Super, arguments, NewTarget);
|
||
} else {
|
||
result = Super.apply(this, arguments);
|
||
}
|
||
return _possibleConstructorReturn(this, result);
|
||
};
|
||
}
|
||
function _possibleConstructorReturn(self2, call) {
|
||
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
||
return call;
|
||
} else if (call !== void 0) {
|
||
throw new TypeError("Derived constructors may only return object or undefined");
|
||
}
|
||
return _assertThisInitialized(self2);
|
||
}
|
||
function _assertThisInitialized(self2) {
|
||
if (self2 === void 0) {
|
||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||
}
|
||
return self2;
|
||
}
|
||
function _isNativeReflectConstruct() {
|
||
if (typeof Reflect === "undefined" || !Reflect.construct)
|
||
return false;
|
||
if (Reflect.construct.sham)
|
||
return false;
|
||
if (typeof Proxy === "function")
|
||
return true;
|
||
try {
|
||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
||
}));
|
||
return true;
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
}
|
||
function _getPrototypeOf(o) {
|
||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
|
||
return o2.__proto__ || Object.getPrototypeOf(o2);
|
||
};
|
||
return _getPrototypeOf(o);
|
||
}
|
||
function _defineProperty(obj, key, value) {
|
||
key = _toPropertyKey(key);
|
||
if (key in obj) {
|
||
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
||
} else {
|
||
obj[key] = value;
|
||
}
|
||
return obj;
|
||
}
|
||
function _toPropertyKey(arg) {
|
||
var key = _toPrimitive(arg, "string");
|
||
return _typeof(key) === "symbol" ? key : String(key);
|
||
}
|
||
function _toPrimitive(input, hint) {
|
||
if (_typeof(input) !== "object" || input === null)
|
||
return input;
|
||
var prim = input[Symbol.toPrimitive];
|
||
if (prim !== void 0) {
|
||
var res = prim.call(input, hint || "default");
|
||
if (_typeof(res) !== "object")
|
||
return res;
|
||
throw new TypeError("@@toPrimitive must return a primitive value.");
|
||
}
|
||
return (hint === "string" ? String : Number)(input);
|
||
}
|
||
var EpubView2 = /* @__PURE__ */ function(_Component) {
|
||
_inherits(EpubView3, _Component);
|
||
var _super = _createSuper(EpubView3);
|
||
function EpubView3(props) {
|
||
var _this;
|
||
_classCallCheck(this, EpubView3);
|
||
_this = _super.call(this, props);
|
||
_defineProperty(_assertThisInitialized(_this), "onLocationChange", function(loc) {
|
||
var _this$props = _this.props, location = _this$props.location, locationChanged = _this$props.locationChanged;
|
||
var newLocation = loc && loc.start;
|
||
if (location !== newLocation) {
|
||
_this.location = newLocation;
|
||
locationChanged && locationChanged(newLocation);
|
||
}
|
||
});
|
||
_defineProperty(_assertThisInitialized(_this), "handleKeyPress", function(_ref) {
|
||
var key = _ref.key;
|
||
key && key === "ArrowRight" && _this.nextPage();
|
||
key && key === "ArrowLeft" && _this.prevPage();
|
||
});
|
||
_this.state = {
|
||
isLoaded: false,
|
||
toc: []
|
||
};
|
||
_this.viewerRef = /* @__PURE__ */ _react.default.createRef();
|
||
_this.location = props.location;
|
||
_this.book = _this.rendition = _this.prevPage = _this.nextPage = null;
|
||
return _this;
|
||
}
|
||
_createClass(EpubView3, [{
|
||
key: "componentDidMount",
|
||
value: function componentDidMount() {
|
||
this.initBook(true);
|
||
document.addEventListener("keyup", this.handleKeyPress, false);
|
||
}
|
||
}, {
|
||
key: "initBook",
|
||
value: function initBook() {
|
||
var _this2 = this;
|
||
var _this$props2 = this.props, url = _this$props2.url, tocChanged = _this$props2.tocChanged, epubInitOptions = _this$props2.epubInitOptions;
|
||
if (this.book) {
|
||
this.book.destroy();
|
||
}
|
||
this.book = new _index.default(url, epubInitOptions);
|
||
this.book.loaded.navigation.then(function(_ref2) {
|
||
var toc = _ref2.toc;
|
||
_this2.setState({
|
||
isLoaded: true,
|
||
toc
|
||
}, function() {
|
||
tocChanged && tocChanged(toc);
|
||
_this2.initReader();
|
||
});
|
||
});
|
||
}
|
||
}, {
|
||
key: "componentWillUnmount",
|
||
value: function componentWillUnmount() {
|
||
if (this.book) {
|
||
this.book.destroy();
|
||
}
|
||
this.book = this.rendition = this.prevPage = this.nextPage = null;
|
||
document.removeEventListener("keyup", this.handleKeyPress, false);
|
||
}
|
||
}, {
|
||
key: "shouldComponentUpdate",
|
||
value: function shouldComponentUpdate(nextProps) {
|
||
return !this.state.isLoaded || nextProps.location !== this.props.location || nextProps.location !== this.props.location;
|
||
}
|
||
}, {
|
||
key: "componentDidUpdate",
|
||
value: function componentDidUpdate(prevProps) {
|
||
if (prevProps.location !== this.props.location && this.location !== this.props.location) {
|
||
this.rendition.display(this.props.location);
|
||
}
|
||
if (prevProps.url !== this.props.url) {
|
||
this.initBook();
|
||
}
|
||
}
|
||
}, {
|
||
key: "initReader",
|
||
value: function initReader() {
|
||
var _this3 = this;
|
||
var toc = this.state.toc;
|
||
var _this$props3 = this.props, location = _this$props3.location, epubOptions = _this$props3.epubOptions, getRendition = _this$props3.getRendition;
|
||
var node = this.viewerRef.current;
|
||
this.rendition = this.book.renderTo(node, _objectSpread({
|
||
contained: true,
|
||
width: "100%",
|
||
height: "100%"
|
||
}, epubOptions));
|
||
this.prevPage = function() {
|
||
_this3.rendition.prev();
|
||
};
|
||
this.nextPage = function() {
|
||
_this3.rendition.next();
|
||
};
|
||
this.registerEvents();
|
||
getRendition && getRendition(this.rendition);
|
||
if (typeof location === "string" || typeof location === "number") {
|
||
this.rendition.display(location);
|
||
} else if (toc.length > 0 && toc[0].href) {
|
||
this.rendition.display(toc[0].href);
|
||
} else {
|
||
this.rendition.display();
|
||
}
|
||
}
|
||
}, {
|
||
key: "registerEvents",
|
||
value: function registerEvents() {
|
||
var _this$props4 = this.props, handleKeyPress = _this$props4.handleKeyPress, handleTextSelected = _this$props4.handleTextSelected;
|
||
this.rendition.on("locationChanged", this.onLocationChange);
|
||
this.rendition.on("keyup", handleKeyPress || this.handleKeyPress);
|
||
if (handleTextSelected) {
|
||
this.rendition.on("selected", handleTextSelected);
|
||
}
|
||
}
|
||
}, {
|
||
key: "renderBook",
|
||
value: function renderBook() {
|
||
var epubViewStyles = this.props.epubViewStyles;
|
||
return /* @__PURE__ */ _react.default.createElement("div", {
|
||
ref: this.viewerRef,
|
||
style: epubViewStyles.view
|
||
});
|
||
}
|
||
}, {
|
||
key: "render",
|
||
value: function render2() {
|
||
var isLoaded = this.state.isLoaded;
|
||
var _this$props5 = this.props, loadingView = _this$props5.loadingView, epubViewStyles = _this$props5.epubViewStyles;
|
||
return /* @__PURE__ */ _react.default.createElement("div", {
|
||
style: epubViewStyles.viewHolder
|
||
}, isLoaded && this.renderBook() || loadingView);
|
||
}
|
||
}]);
|
||
return EpubView3;
|
||
}(_react.Component);
|
||
EpubView2.defaultProps = {
|
||
loadingView: null,
|
||
locationChanged: null,
|
||
tocChanged: null,
|
||
epubViewStyles: _style.default,
|
||
epubOptions: {},
|
||
epubInitOptions: {}
|
||
};
|
||
EpubView2.propTypes = {
|
||
url: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.instanceOf(ArrayBuffer)]),
|
||
loadingView: _propTypes.default.element,
|
||
location: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
||
locationChanged: _propTypes.default.func,
|
||
tocChanged: _propTypes.default.func,
|
||
epubViewStyles: _propTypes.default.object,
|
||
epubInitOptions: _propTypes.default.object,
|
||
epubOptions: _propTypes.default.object,
|
||
getRendition: _propTypes.default.func,
|
||
handleKeyPress: _propTypes.default.func,
|
||
handleTextSelected: _propTypes.default.func
|
||
};
|
||
var _default = EpubView2;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/react-swipeable/lib/index.js
|
||
var require_lib3 = __commonJS({
|
||
"node_modules/react-swipeable/lib/index.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", { value: true });
|
||
var React2 = require_react();
|
||
var LEFT = "Left";
|
||
var RIGHT = "Right";
|
||
var UP = "Up";
|
||
var DOWN = "Down";
|
||
var defaultProps = {
|
||
delta: 10,
|
||
preventScrollOnSwipe: false,
|
||
rotationAngle: 0,
|
||
trackMouse: false,
|
||
trackTouch: true,
|
||
swipeDuration: Infinity,
|
||
touchEventOptions: { passive: true }
|
||
};
|
||
var initialState = {
|
||
first: true,
|
||
initial: [0, 0],
|
||
start: 0,
|
||
swiping: false,
|
||
xy: [0, 0]
|
||
};
|
||
var mouseMove = "mousemove";
|
||
var mouseUp = "mouseup";
|
||
var touchEnd = "touchend";
|
||
var touchMove = "touchmove";
|
||
var touchStart = "touchstart";
|
||
function getDirection(absX, absY, deltaX, deltaY) {
|
||
if (absX > absY) {
|
||
if (deltaX > 0) {
|
||
return RIGHT;
|
||
}
|
||
return LEFT;
|
||
} else if (deltaY > 0) {
|
||
return DOWN;
|
||
}
|
||
return UP;
|
||
}
|
||
function rotateXYByAngle(pos, angle) {
|
||
if (angle === 0)
|
||
return pos;
|
||
const angleInRadians = Math.PI / 180 * angle;
|
||
const x = pos[0] * Math.cos(angleInRadians) + pos[1] * Math.sin(angleInRadians);
|
||
const y = pos[1] * Math.cos(angleInRadians) - pos[0] * Math.sin(angleInRadians);
|
||
return [x, y];
|
||
}
|
||
function getHandlers(set, handlerProps) {
|
||
const onStart = (event) => {
|
||
const isTouch = "touches" in event;
|
||
if (isTouch && event.touches.length > 1)
|
||
return;
|
||
set((state, props) => {
|
||
if (props.trackMouse && !isTouch) {
|
||
document.addEventListener(mouseMove, onMove);
|
||
document.addEventListener(mouseUp, onUp);
|
||
}
|
||
const { clientX, clientY } = isTouch ? event.touches[0] : event;
|
||
const xy = rotateXYByAngle([clientX, clientY], props.rotationAngle);
|
||
props.onTouchStartOrOnMouseDown && props.onTouchStartOrOnMouseDown({ event });
|
||
return Object.assign(Object.assign(Object.assign({}, state), initialState), { initial: xy.slice(), xy, start: event.timeStamp || 0 });
|
||
});
|
||
};
|
||
const onMove = (event) => {
|
||
set((state, props) => {
|
||
const isTouch = "touches" in event;
|
||
if (isTouch && event.touches.length > 1) {
|
||
return state;
|
||
}
|
||
if (event.timeStamp - state.start > props.swipeDuration) {
|
||
return state.swiping ? Object.assign(Object.assign({}, state), { swiping: false }) : state;
|
||
}
|
||
const { clientX, clientY } = isTouch ? event.touches[0] : event;
|
||
const [x, y] = rotateXYByAngle([clientX, clientY], props.rotationAngle);
|
||
const deltaX = x - state.xy[0];
|
||
const deltaY = y - state.xy[1];
|
||
const absX = Math.abs(deltaX);
|
||
const absY = Math.abs(deltaY);
|
||
const time = (event.timeStamp || 0) - state.start;
|
||
const velocity = Math.sqrt(absX * absX + absY * absY) / (time || 1);
|
||
const vxvy = [deltaX / (time || 1), deltaY / (time || 1)];
|
||
const dir = getDirection(absX, absY, deltaX, deltaY);
|
||
const delta = typeof props.delta === "number" ? props.delta : props.delta[dir.toLowerCase()] || defaultProps.delta;
|
||
if (absX < delta && absY < delta && !state.swiping)
|
||
return state;
|
||
const eventData = {
|
||
absX,
|
||
absY,
|
||
deltaX,
|
||
deltaY,
|
||
dir,
|
||
event,
|
||
first: state.first,
|
||
initial: state.initial,
|
||
velocity,
|
||
vxvy
|
||
};
|
||
eventData.first && props.onSwipeStart && props.onSwipeStart(eventData);
|
||
props.onSwiping && props.onSwiping(eventData);
|
||
let cancelablePageSwipe = false;
|
||
if (props.onSwiping || props.onSwiped || props[`onSwiped${dir}`]) {
|
||
cancelablePageSwipe = true;
|
||
}
|
||
if (cancelablePageSwipe && props.preventScrollOnSwipe && props.trackTouch && event.cancelable) {
|
||
event.preventDefault();
|
||
}
|
||
return Object.assign(Object.assign({}, state), {
|
||
first: false,
|
||
eventData,
|
||
swiping: true
|
||
});
|
||
});
|
||
};
|
||
const onEnd = (event) => {
|
||
set((state, props) => {
|
||
let eventData;
|
||
if (state.swiping && state.eventData) {
|
||
if (event.timeStamp - state.start < props.swipeDuration) {
|
||
eventData = Object.assign(Object.assign({}, state.eventData), { event });
|
||
props.onSwiped && props.onSwiped(eventData);
|
||
const onSwipedDir = props[`onSwiped${eventData.dir}`];
|
||
onSwipedDir && onSwipedDir(eventData);
|
||
}
|
||
} else {
|
||
props.onTap && props.onTap({ event });
|
||
}
|
||
props.onTouchEndOrOnMouseUp && props.onTouchEndOrOnMouseUp({ event });
|
||
return Object.assign(Object.assign(Object.assign({}, state), initialState), { eventData });
|
||
});
|
||
};
|
||
const cleanUpMouse = () => {
|
||
document.removeEventListener(mouseMove, onMove);
|
||
document.removeEventListener(mouseUp, onUp);
|
||
};
|
||
const onUp = (e) => {
|
||
cleanUpMouse();
|
||
onEnd(e);
|
||
};
|
||
const attachTouch = (el, props) => {
|
||
let cleanup = () => {
|
||
};
|
||
if (el && el.addEventListener) {
|
||
const baseOptions = Object.assign(Object.assign({}, defaultProps.touchEventOptions), props.touchEventOptions);
|
||
const tls = [
|
||
[touchStart, onStart, baseOptions],
|
||
[
|
||
touchMove,
|
||
onMove,
|
||
Object.assign(Object.assign({}, baseOptions), props.preventScrollOnSwipe ? { passive: false } : {})
|
||
],
|
||
[touchEnd, onEnd, baseOptions]
|
||
];
|
||
tls.forEach(([e, h, o]) => el.addEventListener(e, h, o));
|
||
cleanup = () => tls.forEach(([e, h]) => el.removeEventListener(e, h));
|
||
}
|
||
return cleanup;
|
||
};
|
||
const onRef = (el) => {
|
||
if (el === null)
|
||
return;
|
||
set((state, props) => {
|
||
if (state.el === el)
|
||
return state;
|
||
const addState = {};
|
||
if (state.el && state.el !== el && state.cleanUpTouch) {
|
||
state.cleanUpTouch();
|
||
addState.cleanUpTouch = void 0;
|
||
}
|
||
if (props.trackTouch && el) {
|
||
addState.cleanUpTouch = attachTouch(el, props);
|
||
}
|
||
return Object.assign(Object.assign(Object.assign({}, state), { el }), addState);
|
||
});
|
||
};
|
||
const output = {
|
||
ref: onRef
|
||
};
|
||
if (handlerProps.trackMouse) {
|
||
output.onMouseDown = onStart;
|
||
}
|
||
return [output, attachTouch];
|
||
}
|
||
function updateTransientState(state, props, previousProps, attachTouch) {
|
||
if (!props.trackTouch || !state.el) {
|
||
if (state.cleanUpTouch) {
|
||
state.cleanUpTouch();
|
||
}
|
||
return Object.assign(Object.assign({}, state), { cleanUpTouch: void 0 });
|
||
}
|
||
if (!state.cleanUpTouch) {
|
||
return Object.assign(Object.assign({}, state), { cleanUpTouch: attachTouch(state.el, props) });
|
||
}
|
||
if (props.preventScrollOnSwipe !== previousProps.preventScrollOnSwipe || props.touchEventOptions.passive !== previousProps.touchEventOptions.passive) {
|
||
state.cleanUpTouch();
|
||
return Object.assign(Object.assign({}, state), { cleanUpTouch: attachTouch(state.el, props) });
|
||
}
|
||
return state;
|
||
}
|
||
function useSwipeable(options) {
|
||
const { trackMouse } = options;
|
||
const transientState = React2.useRef(Object.assign({}, initialState));
|
||
const transientProps = React2.useRef(Object.assign({}, defaultProps));
|
||
const previousProps = React2.useRef(Object.assign({}, transientProps.current));
|
||
previousProps.current = Object.assign({}, transientProps.current);
|
||
transientProps.current = Object.assign(Object.assign({}, defaultProps), options);
|
||
let defaultKey;
|
||
for (defaultKey in defaultProps) {
|
||
if (transientProps.current[defaultKey] === void 0) {
|
||
transientProps.current[defaultKey] = defaultProps[defaultKey];
|
||
}
|
||
}
|
||
const [handlers, attachTouch] = React2.useMemo(() => getHandlers((stateSetter) => transientState.current = stateSetter(transientState.current, transientProps.current), { trackMouse }), [trackMouse]);
|
||
transientState.current = updateTransientState(transientState.current, transientProps.current, previousProps.current, attachTouch);
|
||
return handlers;
|
||
}
|
||
exports.DOWN = DOWN;
|
||
exports.LEFT = LEFT;
|
||
exports.RIGHT = RIGHT;
|
||
exports.UP = UP;
|
||
exports.useSwipeable = useSwipeable;
|
||
}
|
||
});
|
||
|
||
// node_modules/react-reader/lib/ReactReader/style.js
|
||
var require_style2 = __commonJS({
|
||
"node_modules/react-reader/lib/ReactReader/style.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var reactReaderStyles = {
|
||
container: {
|
||
overflow: "hidden",
|
||
position: "relative",
|
||
height: "100%"
|
||
},
|
||
readerArea: {
|
||
position: "relative",
|
||
zIndex: 1,
|
||
height: "100%",
|
||
width: "100%",
|
||
backgroundColor: "#fff",
|
||
transition: "all .3s ease"
|
||
},
|
||
containerExpanded: {
|
||
transform: "translateX(256px)"
|
||
},
|
||
titleArea: {
|
||
position: "absolute",
|
||
top: 20,
|
||
left: 50,
|
||
right: 50,
|
||
textAlign: "center",
|
||
color: "#999"
|
||
},
|
||
reader: {
|
||
position: "absolute",
|
||
top: 50,
|
||
left: 50,
|
||
bottom: 20,
|
||
right: 50
|
||
},
|
||
swipeWrapper: {
|
||
position: "absolute",
|
||
top: 0,
|
||
left: 0,
|
||
bottom: 0,
|
||
right: 0,
|
||
zIndex: 200
|
||
},
|
||
prev: {
|
||
left: 1
|
||
},
|
||
next: {
|
||
right: 1
|
||
},
|
||
arrow: {
|
||
outline: "none",
|
||
border: "none",
|
||
background: "none",
|
||
position: "absolute",
|
||
top: "50%",
|
||
marginTop: -32,
|
||
fontSize: 64,
|
||
padding: "0 10px",
|
||
color: "#E2E2E2",
|
||
fontFamily: "arial, sans-serif",
|
||
cursor: "pointer",
|
||
userSelect: "none",
|
||
appearance: "none",
|
||
fontWeight: "normal"
|
||
},
|
||
arrowHover: {
|
||
color: "#777"
|
||
},
|
||
tocBackground: {
|
||
position: "absolute",
|
||
left: 256,
|
||
top: 0,
|
||
bottom: 0,
|
||
right: 0,
|
||
zIndex: 1
|
||
},
|
||
tocArea: {
|
||
position: "absolute",
|
||
left: 0,
|
||
top: 0,
|
||
bottom: 0,
|
||
zIndex: 0,
|
||
width: 256,
|
||
overflowY: "auto",
|
||
WebkitOverflowScrolling: "touch",
|
||
background: "#f2f2f2",
|
||
padding: "10px 0"
|
||
},
|
||
tocAreaButton: {
|
||
userSelect: "none",
|
||
appearance: "none",
|
||
background: "none",
|
||
border: "none",
|
||
display: "block",
|
||
fontFamily: "sans-serif",
|
||
width: "100%",
|
||
fontSize: ".9em",
|
||
textAlign: "left",
|
||
padding: ".9em 1em",
|
||
borderBottom: "1px solid #ddd",
|
||
color: "#aaa",
|
||
boxSizing: "border-box",
|
||
outline: "none",
|
||
cursor: "pointer"
|
||
},
|
||
tocButton: {
|
||
background: "none",
|
||
border: "none",
|
||
width: 32,
|
||
height: 32,
|
||
position: "absolute",
|
||
top: 10,
|
||
left: 10,
|
||
borderRadius: 2,
|
||
outline: "none",
|
||
cursor: "pointer"
|
||
},
|
||
tocButtonExpanded: {
|
||
background: "#f2f2f2"
|
||
},
|
||
tocButtonBar: {
|
||
position: "absolute",
|
||
width: "60%",
|
||
background: "#ccc",
|
||
height: 2,
|
||
left: "50%",
|
||
margin: "-1px -30%",
|
||
top: "50%",
|
||
transition: "all .5s ease"
|
||
},
|
||
tocButtonBarTop: {
|
||
top: "35%"
|
||
},
|
||
tocButtonBottom: {
|
||
top: "66%"
|
||
},
|
||
loadingView: {
|
||
position: "absolute",
|
||
top: "50%",
|
||
left: "10%",
|
||
right: "10%",
|
||
color: "#ccc",
|
||
textAlign: "center",
|
||
margintop: "-.5em"
|
||
}
|
||
};
|
||
var _default = reactReaderStyles;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/react-reader/lib/ReactReader/ReactReader.js
|
||
var require_ReactReader = __commonJS({
|
||
"node_modules/react-reader/lib/ReactReader/ReactReader.js"(exports) {
|
||
"use strict";
|
||
function _typeof(obj) {
|
||
"@babel/helpers - typeof";
|
||
return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(obj2) {
|
||
return typeof obj2;
|
||
} : function(obj2) {
|
||
return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
||
}, _typeof(obj);
|
||
}
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
var _react = _interopRequireWildcard(require_react());
|
||
var _propTypes = _interopRequireDefault(require_prop_types());
|
||
var _reactSwipeable = require_lib3();
|
||
var _ = require_lib4();
|
||
var _style = _interopRequireDefault(require_style2());
|
||
var _excluded = ["children"];
|
||
var _excluded2 = ["title", "showToc", "loadingView", "readerStyles", "locationChanged", "swipeable", "epubViewStyles"];
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
function _getRequireWildcardCache(nodeInterop) {
|
||
if (typeof WeakMap !== "function")
|
||
return null;
|
||
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
||
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
||
return (_getRequireWildcardCache = function _getRequireWildcardCache2(nodeInterop2) {
|
||
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
||
})(nodeInterop);
|
||
}
|
||
function _interopRequireWildcard(obj, nodeInterop) {
|
||
if (!nodeInterop && obj && obj.__esModule) {
|
||
return obj;
|
||
}
|
||
if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
|
||
return { default: obj };
|
||
}
|
||
var cache = _getRequireWildcardCache(nodeInterop);
|
||
if (cache && cache.has(obj)) {
|
||
return cache.get(obj);
|
||
}
|
||
var newObj = {};
|
||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||
for (var key in obj) {
|
||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||
if (desc && (desc.get || desc.set)) {
|
||
Object.defineProperty(newObj, key, desc);
|
||
} else {
|
||
newObj[key] = obj[key];
|
||
}
|
||
}
|
||
}
|
||
newObj.default = obj;
|
||
if (cache) {
|
||
cache.set(obj, newObj);
|
||
}
|
||
return newObj;
|
||
}
|
||
function _extends() {
|
||
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
||
for (var i = 1; i < arguments.length; i++) {
|
||
var source = arguments[i];
|
||
for (var key in source) {
|
||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||
target[key] = source[key];
|
||
}
|
||
}
|
||
}
|
||
return target;
|
||
};
|
||
return _extends.apply(this, arguments);
|
||
}
|
||
function _classCallCheck(instance, Constructor) {
|
||
if (!(instance instanceof Constructor)) {
|
||
throw new TypeError("Cannot call a class as a function");
|
||
}
|
||
}
|
||
function _defineProperties(target, props) {
|
||
for (var i = 0; i < props.length; i++) {
|
||
var descriptor = props[i];
|
||
descriptor.enumerable = descriptor.enumerable || false;
|
||
descriptor.configurable = true;
|
||
if ("value" in descriptor)
|
||
descriptor.writable = true;
|
||
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
||
}
|
||
}
|
||
function _createClass(Constructor, protoProps, staticProps) {
|
||
if (protoProps)
|
||
_defineProperties(Constructor.prototype, protoProps);
|
||
if (staticProps)
|
||
_defineProperties(Constructor, staticProps);
|
||
Object.defineProperty(Constructor, "prototype", { writable: false });
|
||
return Constructor;
|
||
}
|
||
function _inherits(subClass, superClass) {
|
||
if (typeof superClass !== "function" && superClass !== null) {
|
||
throw new TypeError("Super expression must either be null or a function");
|
||
}
|
||
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
||
Object.defineProperty(subClass, "prototype", { writable: false });
|
||
if (superClass)
|
||
_setPrototypeOf(subClass, superClass);
|
||
}
|
||
function _setPrototypeOf(o, p) {
|
||
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
|
||
o2.__proto__ = p2;
|
||
return o2;
|
||
};
|
||
return _setPrototypeOf(o, p);
|
||
}
|
||
function _createSuper(Derived) {
|
||
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
||
return function _createSuperInternal() {
|
||
var Super = _getPrototypeOf(Derived), result;
|
||
if (hasNativeReflectConstruct) {
|
||
var NewTarget = _getPrototypeOf(this).constructor;
|
||
result = Reflect.construct(Super, arguments, NewTarget);
|
||
} else {
|
||
result = Super.apply(this, arguments);
|
||
}
|
||
return _possibleConstructorReturn(this, result);
|
||
};
|
||
}
|
||
function _possibleConstructorReturn(self2, call) {
|
||
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
||
return call;
|
||
} else if (call !== void 0) {
|
||
throw new TypeError("Derived constructors may only return object or undefined");
|
||
}
|
||
return _assertThisInitialized(self2);
|
||
}
|
||
function _assertThisInitialized(self2) {
|
||
if (self2 === void 0) {
|
||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||
}
|
||
return self2;
|
||
}
|
||
function _isNativeReflectConstruct() {
|
||
if (typeof Reflect === "undefined" || !Reflect.construct)
|
||
return false;
|
||
if (Reflect.construct.sham)
|
||
return false;
|
||
if (typeof Proxy === "function")
|
||
return true;
|
||
try {
|
||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
||
}));
|
||
return true;
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
}
|
||
function _getPrototypeOf(o) {
|
||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
|
||
return o2.__proto__ || Object.getPrototypeOf(o2);
|
||
};
|
||
return _getPrototypeOf(o);
|
||
}
|
||
function _defineProperty(obj, key, value) {
|
||
key = _toPropertyKey(key);
|
||
if (key in obj) {
|
||
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
||
} else {
|
||
obj[key] = value;
|
||
}
|
||
return obj;
|
||
}
|
||
function _toPropertyKey(arg) {
|
||
var key = _toPrimitive(arg, "string");
|
||
return _typeof(key) === "symbol" ? key : String(key);
|
||
}
|
||
function _toPrimitive(input, hint) {
|
||
if (_typeof(input) !== "object" || input === null)
|
||
return input;
|
||
var prim = input[Symbol.toPrimitive];
|
||
if (prim !== void 0) {
|
||
var res = prim.call(input, hint || "default");
|
||
if (_typeof(res) !== "object")
|
||
return res;
|
||
throw new TypeError("@@toPrimitive must return a primitive value.");
|
||
}
|
||
return (hint === "string" ? String : Number)(input);
|
||
}
|
||
function _objectWithoutProperties(source, excluded) {
|
||
if (source == null)
|
||
return {};
|
||
var target = _objectWithoutPropertiesLoose(source, excluded);
|
||
var key, i;
|
||
if (Object.getOwnPropertySymbols) {
|
||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
||
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
||
key = sourceSymbolKeys[i];
|
||
if (excluded.indexOf(key) >= 0)
|
||
continue;
|
||
if (!Object.prototype.propertyIsEnumerable.call(source, key))
|
||
continue;
|
||
target[key] = source[key];
|
||
}
|
||
}
|
||
return target;
|
||
}
|
||
function _objectWithoutPropertiesLoose(source, excluded) {
|
||
if (source == null)
|
||
return {};
|
||
var target = {};
|
||
var sourceKeys = Object.keys(source);
|
||
var key, i;
|
||
for (i = 0; i < sourceKeys.length; i++) {
|
||
key = sourceKeys[i];
|
||
if (excluded.indexOf(key) >= 0)
|
||
continue;
|
||
target[key] = source[key];
|
||
}
|
||
return target;
|
||
}
|
||
var Swipeable = function Swipeable2(_ref) {
|
||
var children = _ref.children, props = _objectWithoutProperties(_ref, _excluded);
|
||
var handlers = (0, _reactSwipeable.useSwipeable)(props);
|
||
return /* @__PURE__ */ _react.default.createElement("div", handlers, children);
|
||
};
|
||
var TocItem = /* @__PURE__ */ function(_PureComponent) {
|
||
_inherits(TocItem2, _PureComponent);
|
||
var _super = _createSuper(TocItem2);
|
||
function TocItem2() {
|
||
var _this;
|
||
_classCallCheck(this, TocItem2);
|
||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||
args[_key] = arguments[_key];
|
||
}
|
||
_this = _super.call.apply(_super, [this].concat(args));
|
||
_defineProperty(_assertThisInitialized(_this), "setLocation", function() {
|
||
_this.props.setLocation(_this.props.href);
|
||
});
|
||
return _this;
|
||
}
|
||
_createClass(TocItem2, [{
|
||
key: "render",
|
||
value: function render2() {
|
||
var _this2 = this;
|
||
var _this$props = this.props, label = _this$props.label, styles = _this$props.styles, subitems = _this$props.subitems;
|
||
return /* @__PURE__ */ _react.default.createElement("div", null, /* @__PURE__ */ _react.default.createElement("button", {
|
||
onClick: this.setLocation,
|
||
style: styles
|
||
}, label), subitems && subitems.length > 0 && /* @__PURE__ */ _react.default.createElement("div", {
|
||
style: {
|
||
paddingLeft: 10
|
||
}
|
||
}, subitems.map(function(item, i) {
|
||
return /* @__PURE__ */ _react.default.createElement(TocItem2, _extends({
|
||
key: i
|
||
}, _this2.props, item));
|
||
})));
|
||
}
|
||
}]);
|
||
return TocItem2;
|
||
}(_react.PureComponent);
|
||
TocItem.propTypes = {
|
||
label: _propTypes.default.string,
|
||
href: _propTypes.default.string,
|
||
setLocation: _propTypes.default.func,
|
||
styles: _propTypes.default.object
|
||
};
|
||
var ReactReader2 = /* @__PURE__ */ function(_PureComponent2) {
|
||
_inherits(ReactReader3, _PureComponent2);
|
||
var _super2 = _createSuper(ReactReader3);
|
||
function ReactReader3(props) {
|
||
var _this3;
|
||
_classCallCheck(this, ReactReader3);
|
||
_this3 = _super2.call(this, props);
|
||
_defineProperty(_assertThisInitialized(_this3), "toggleToc", function() {
|
||
_this3.setState({
|
||
expandedToc: !_this3.state.expandedToc
|
||
});
|
||
});
|
||
_defineProperty(_assertThisInitialized(_this3), "next", function() {
|
||
var node = _this3.readerRef.current;
|
||
node.nextPage();
|
||
});
|
||
_defineProperty(_assertThisInitialized(_this3), "prev", function() {
|
||
var node = _this3.readerRef.current;
|
||
node.prevPage();
|
||
});
|
||
_defineProperty(_assertThisInitialized(_this3), "onTocChange", function(toc) {
|
||
var tocChanged = _this3.props.tocChanged;
|
||
_this3.setState({
|
||
toc
|
||
}, function() {
|
||
return tocChanged && tocChanged(toc);
|
||
});
|
||
});
|
||
_defineProperty(_assertThisInitialized(_this3), "setLocation", function(loc) {
|
||
var locationChanged = _this3.props.locationChanged;
|
||
_this3.setState({
|
||
expandedToc: false
|
||
}, function() {
|
||
return locationChanged && locationChanged(loc);
|
||
});
|
||
});
|
||
_this3.readerRef = /* @__PURE__ */ _react.default.createRef();
|
||
_this3.state = {
|
||
expandedToc: false,
|
||
toc: false
|
||
};
|
||
return _this3;
|
||
}
|
||
_createClass(ReactReader3, [{
|
||
key: "renderToc",
|
||
value: function renderToc() {
|
||
var _this4 = this;
|
||
var _this$state = this.state, toc = _this$state.toc, expandedToc = _this$state.expandedToc;
|
||
var readerStyles = this.props.readerStyles;
|
||
return /* @__PURE__ */ _react.default.createElement("div", null, /* @__PURE__ */ _react.default.createElement("div", {
|
||
style: readerStyles.tocArea
|
||
}, /* @__PURE__ */ _react.default.createElement("div", {
|
||
style: readerStyles.toc
|
||
}, toc.map(function(item, i) {
|
||
return /* @__PURE__ */ _react.default.createElement(TocItem, _extends({}, item, {
|
||
key: i,
|
||
setLocation: _this4.setLocation,
|
||
styles: readerStyles.tocAreaButton
|
||
}));
|
||
}))), expandedToc && /* @__PURE__ */ _react.default.createElement("div", {
|
||
style: readerStyles.tocBackground,
|
||
onClick: this.toggleToc
|
||
}));
|
||
}
|
||
}, {
|
||
key: "renderTocToggle",
|
||
value: function renderTocToggle() {
|
||
var expandedToc = this.state.expandedToc;
|
||
var readerStyles = this.props.readerStyles;
|
||
return /* @__PURE__ */ _react.default.createElement("button", {
|
||
style: Object.assign({}, readerStyles.tocButton, expandedToc ? readerStyles.tocButtonExpanded : {}),
|
||
onClick: this.toggleToc
|
||
}, /* @__PURE__ */ _react.default.createElement("span", {
|
||
style: Object.assign({}, readerStyles.tocButtonBar, readerStyles.tocButtonBarTop)
|
||
}), /* @__PURE__ */ _react.default.createElement("span", {
|
||
style: Object.assign({}, readerStyles.tocButtonBar, readerStyles.tocButtonBottom)
|
||
}));
|
||
}
|
||
}, {
|
||
key: "render",
|
||
value: function render2() {
|
||
var _this$props2 = this.props, title = _this$props2.title, showToc = _this$props2.showToc, loadingView = _this$props2.loadingView, readerStyles = _this$props2.readerStyles, locationChanged = _this$props2.locationChanged, swipeable = _this$props2.swipeable, epubViewStyles = _this$props2.epubViewStyles, props = _objectWithoutProperties(_this$props2, _excluded2);
|
||
var _this$state2 = this.state, toc = _this$state2.toc, expandedToc = _this$state2.expandedToc;
|
||
return /* @__PURE__ */ _react.default.createElement("div", {
|
||
style: readerStyles.container
|
||
}, /* @__PURE__ */ _react.default.createElement("div", {
|
||
style: Object.assign({}, readerStyles.readerArea, expandedToc ? readerStyles.containerExpanded : {})
|
||
}, showToc && this.renderTocToggle(), /* @__PURE__ */ _react.default.createElement("div", {
|
||
style: readerStyles.titleArea
|
||
}, title), /* @__PURE__ */ _react.default.createElement(Swipeable, {
|
||
onSwipedRight: this.prev,
|
||
onSwipedLeft: this.next,
|
||
trackMouse: true
|
||
}, /* @__PURE__ */ _react.default.createElement("div", {
|
||
style: readerStyles.reader
|
||
}, /* @__PURE__ */ _react.default.createElement(_.EpubView, _extends({
|
||
ref: this.readerRef,
|
||
loadingView,
|
||
epubViewStyles
|
||
}, props, {
|
||
tocChanged: this.onTocChange,
|
||
locationChanged
|
||
})), swipeable && /* @__PURE__ */ _react.default.createElement("div", {
|
||
style: readerStyles.swipeWrapper
|
||
}))), /* @__PURE__ */ _react.default.createElement("button", {
|
||
style: Object.assign({}, readerStyles.arrow, readerStyles.prev),
|
||
onClick: this.prev
|
||
}, "\u2039"), /* @__PURE__ */ _react.default.createElement("button", {
|
||
style: Object.assign({}, readerStyles.arrow, readerStyles.next),
|
||
onClick: this.next
|
||
}, "\u203A")), showToc && toc && this.renderToc());
|
||
}
|
||
}]);
|
||
return ReactReader3;
|
||
}(_react.PureComponent);
|
||
ReactReader2.defaultProps = {
|
||
loadingView: /* @__PURE__ */ _react.default.createElement("div", {
|
||
style: _style.default.loadingView
|
||
}, "Loading\u2026"),
|
||
locationChanged: null,
|
||
tocChanged: null,
|
||
showToc: true,
|
||
readerStyles: _style.default
|
||
};
|
||
ReactReader2.propTypes = {
|
||
title: _propTypes.default.string,
|
||
loadingView: _propTypes.default.element,
|
||
showToc: _propTypes.default.bool,
|
||
locationChanged: _propTypes.default.func,
|
||
tocChanged: _propTypes.default.func,
|
||
readerStyles: _propTypes.default.object,
|
||
epubViewStyles: _propTypes.default.object,
|
||
swipeable: _propTypes.default.bool
|
||
};
|
||
var _default = ReactReader2;
|
||
exports.default = _default;
|
||
}
|
||
});
|
||
|
||
// node_modules/react-reader/lib/index.js
|
||
var require_lib4 = __commonJS({
|
||
"node_modules/react-reader/lib/index.js"(exports) {
|
||
"use strict";
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
Object.defineProperty(exports, "EpubView", {
|
||
enumerable: true,
|
||
get: function get() {
|
||
return _EpubView.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "EpubViewStyle", {
|
||
enumerable: true,
|
||
get: function get() {
|
||
return _style.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "ReactReader", {
|
||
enumerable: true,
|
||
get: function get() {
|
||
return _ReactReader.default;
|
||
}
|
||
});
|
||
Object.defineProperty(exports, "ReactReaderStyle", {
|
||
enumerable: true,
|
||
get: function get() {
|
||
return _style2.default;
|
||
}
|
||
});
|
||
var _EpubView = _interopRequireDefault(require_EpubView());
|
||
var _style = _interopRequireDefault(require_style());
|
||
var _ReactReader = _interopRequireDefault(require_ReactReader());
|
||
var _style2 = _interopRequireDefault(require_style2());
|
||
function _interopRequireDefault(obj) {
|
||
return obj && obj.__esModule ? obj : { default: obj };
|
||
}
|
||
}
|
||
});
|
||
|
||
// src/main.ts
|
||
var main_exports = {};
|
||
__export(main_exports, {
|
||
default: () => AwesomeReaderPlugin
|
||
});
|
||
module.exports = __toCommonJS(main_exports);
|
||
var import_obsidian3 = require("obsidian");
|
||
|
||
// src/EpubView.tsx
|
||
var import_obsidian2 = require("obsidian");
|
||
var React = __toESM(require_react());
|
||
var import_react = __toESM(require_react());
|
||
var ReactDOM = __toESM(require_react_dom());
|
||
|
||
// src/utils.ts
|
||
var import_obsidian = require("obsidian");
|
||
async function openOrCreateNote(app, file, toc) {
|
||
const noteFilename = `${file.parent.path}/${file.basename}.md`;
|
||
let noteFile = app.vault.getAbstractFileByPath(noteFilename);
|
||
if (noteFile == null || !(noteFile instanceof import_obsidian.TFile)) {
|
||
noteFile = await app.vault.create(noteFilename, `---
|
||
bookname: "${file.basename}.${file.extension}"
|
||
---
|
||
|
||
` + toc);
|
||
}
|
||
const leaf = app.workspace.getMostRecentLeaf();
|
||
if (leaf instanceof import_obsidian.WorkspaceLeaf) {
|
||
const fileLeaf = app.workspace.createLeafBySplit(leaf);
|
||
await fileLeaf.openFile(noteFile, { active: true });
|
||
}
|
||
}
|
||
function getEpubTocMd(rawToc) {
|
||
function dfs(node, output2, depth) {
|
||
if (!node)
|
||
return;
|
||
const cleanedLabel = node.label.replace(/\u0000/g, "").trim();
|
||
output2.push("#".repeat(depth) + " " + cleanedLabel);
|
||
for (let sub of node.subitems) {
|
||
dfs(sub, output2, depth + 1);
|
||
}
|
||
}
|
||
if (!rawToc)
|
||
return "";
|
||
const output = [];
|
||
for (let sub of rawToc) {
|
||
dfs(sub, output, 1);
|
||
}
|
||
return output.join("\n\n");
|
||
}
|
||
async function getPdfTocMd(file) {
|
||
const pdfjsLib = await (0, import_obsidian.loadPdfJs)();
|
||
const content = await this.app.vault.readBinary(file.path);
|
||
const pdf = await pdfjsLib.getDocument(new Uint8Array(content)).promise;
|
||
const rawToc = await pdf.getOutline();
|
||
function dfs(node, output2, depth) {
|
||
if (!node)
|
||
return;
|
||
const cleanedLabel = node.title.replace(/\u0000/g, "").trim();
|
||
output2.push("#".repeat(depth) + " " + cleanedLabel);
|
||
for (let sub of node.items) {
|
||
dfs(sub, output2, depth + 1);
|
||
}
|
||
}
|
||
if (!rawToc)
|
||
return "";
|
||
const output = [];
|
||
for (let sub of rawToc) {
|
||
dfs(sub, output, 1);
|
||
}
|
||
return output.join("\n\n");
|
||
}
|
||
|
||
// src/EpubView.tsx
|
||
var import_react_reader = __toESM(require_lib4());
|
||
var EpubReader = ({ contents, title, scrolled, tocOffset, initLocation, saveLocation, tocMemo }) => {
|
||
const [location, setLocation] = (0, import_react.useState)(initLocation);
|
||
const locationChanged = (epubcifi) => {
|
||
setLocation(epubcifi);
|
||
saveLocation(epubcifi);
|
||
};
|
||
return /* @__PURE__ */ React.createElement("div", {
|
||
className: "awesome-reader-epub",
|
||
style: { border: "none", height: "100%", width: "100%", overflow: "hidden" }
|
||
}, /* @__PURE__ */ React.createElement(import_react_reader.ReactReader, {
|
||
title,
|
||
showToc: true,
|
||
location,
|
||
locationChanged,
|
||
swipeable: false,
|
||
url: contents,
|
||
tocChanged: (toc) => tocMemo(toc),
|
||
epubOptions: scrolled ? {
|
||
allowPopups: false,
|
||
flow: "scrolled",
|
||
manager: "continuous"
|
||
} : {
|
||
allowPopups: false
|
||
},
|
||
readerStyles: {
|
||
...import_react_reader.ReactReaderStyle,
|
||
tocArea: {
|
||
...import_react_reader.ReactReaderStyle.tocArea,
|
||
top: (tocOffset + 20).toString() + "px",
|
||
bottom: 0,
|
||
left: "auto",
|
||
backgroundColor: "currentColor"
|
||
},
|
||
tocButtonExpanded: {
|
||
...import_react_reader.ReactReaderStyle.tocButtonExpanded,
|
||
backgroundColor: "currentColor"
|
||
}
|
||
}
|
||
}));
|
||
};
|
||
var EpubView = class extends import_obsidian2.FileView {
|
||
constructor(leaf, settings, plugin) {
|
||
super(leaf);
|
||
this.settings = settings;
|
||
this.plugin = plugin;
|
||
}
|
||
onPaneMenu(menu) {
|
||
menu.addItem((item) => {
|
||
item.setTitle("Open/create book note").setIcon("document").onClick(async () => {
|
||
await openOrCreateNote(this.app, this.file, getEpubTocMd(this.fileToc));
|
||
});
|
||
});
|
||
}
|
||
async setInitLocation(initLocation) {
|
||
this.plugin.settings.bookInitLocations[this.file.path] = initLocation;
|
||
await this.plugin.saveSettings();
|
||
}
|
||
async getInitLocation() {
|
||
const location = this.plugin.settings.bookInitLocations[this.file.path];
|
||
return location ? location : null;
|
||
}
|
||
async onLoadFile(file) {
|
||
ReactDOM.unmountComponentAtNode(this.contentEl);
|
||
this.contentEl.empty();
|
||
const style = getComputedStyle(this.containerEl.parentElement.querySelector("div.view-header"));
|
||
const width = parseFloat(style.width);
|
||
const height = parseFloat(style.height);
|
||
const tocOffset = height < width ? height : 0;
|
||
const contents = await this.app.vault.adapter.readBinary(file.path);
|
||
ReactDOM.render(/* @__PURE__ */ React.createElement(EpubReader, {
|
||
contents,
|
||
title: file.basename,
|
||
scrolled: this.settings.scrolledView,
|
||
tocOffset,
|
||
initLocation: await this.getInitLocation(),
|
||
saveLocation: (location) => {
|
||
this.setInitLocation(location);
|
||
},
|
||
tocMemo: (toc) => {
|
||
this.fileToc = toc;
|
||
}
|
||
}), this.contentEl);
|
||
}
|
||
onunload() {
|
||
ReactDOM.unmountComponentAtNode(this.contentEl);
|
||
}
|
||
canAcceptExtension(extension) {
|
||
return extension == "epub";
|
||
}
|
||
getViewType() {
|
||
return "epub";
|
||
}
|
||
};
|
||
|
||
// src/main.ts
|
||
var DEFAULT_SETTINGS = {
|
||
scrolledView: false,
|
||
bookInitLocations: {}
|
||
};
|
||
var AwesomeReaderPlugin = class extends import_obsidian3.Plugin {
|
||
async onload() {
|
||
await this.loadSettings();
|
||
this.registerView("epub", (leaf) => {
|
||
return new EpubView(leaf, this.settings, this);
|
||
});
|
||
try {
|
||
this.registerExtensions(["epub"], "epub");
|
||
} catch (error) {
|
||
console.log(`registerExtensions epub failed.`);
|
||
}
|
||
this.registerEvent(this.app.workspace.on("file-menu", (menu, file) => {
|
||
if (file.extension.toLowerCase() === "pdf") {
|
||
menu.addItem((item) => {
|
||
item.setTitle("Open/create book note").setIcon("document").onClick(async () => {
|
||
await openOrCreateNote(this.app, file, await getPdfTocMd(file));
|
||
});
|
||
});
|
||
}
|
||
}));
|
||
this.addSettingTab(new AwesomeReaderSettingTab(this.app, this));
|
||
}
|
||
onunload() {
|
||
}
|
||
async loadSettings() {
|
||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||
}
|
||
async saveSettings() {
|
||
await this.saveData(this.settings);
|
||
}
|
||
};
|
||
var AwesomeReaderSettingTab = class extends import_obsidian3.PluginSettingTab {
|
||
constructor(app, plugin) {
|
||
super(app, plugin);
|
||
this.plugin = plugin;
|
||
}
|
||
display() {
|
||
const { containerEl } = this;
|
||
containerEl.empty();
|
||
containerEl.createEl("h2", { text: "Awesome Reader Settings" });
|
||
new import_obsidian3.Setting(containerEl).setName("Scrolled View").setDesc("This enables seamless scrolling between pages.").addToggle((toggle) => toggle.setValue(this.plugin.settings.scrolledView).onChange(async (value) => {
|
||
this.plugin.settings.scrolledView = value;
|
||
await this.plugin.saveSettings();
|
||
}));
|
||
}
|
||
};
|
||
/*
|
||
object-assign
|
||
(c) Sindre Sorhus
|
||
@license MIT
|
||
*/
|
||
/*!
|
||
|
||
JSZip v3.10.1 - A JavaScript class for generating and reading zip files
|
||
<http://stuartk.com/jszip>
|
||
|
||
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
|
||
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
|
||
|
||
JSZip uses the library pako released under the MIT license :
|
||
https://github.com/nodeca/pako/blob/main/LICENSE
|
||
*/
|
||
/*!
|
||
localForage -- Offline Storage, Improved
|
||
Version 1.10.0
|
||
https://localforage.github.io/localForage
|
||
(c) 2013-2017 Mozilla, Apache License 2.0
|
||
*/
|
||
/**
|
||
* @license React
|
||
* react-dom.development.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/
|
||
/**
|
||
* @license React
|
||
* react.development.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/
|
||
/**
|
||
* @license React
|
||
* scheduler.development.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/
|
||
/**
|
||
* Checks if an event is supported in the current execution environment.
|
||
*
|
||
* NOTE: This will not work correctly for non-generic events such as `change`,
|
||
* `reset`, `load`, `error`, and `select`.
|
||
*
|
||
* Borrows from Modernizr.
|
||
*
|
||
* @param {string} eventNameSuffix Event name, e.g. "click".
|
||
* @return {boolean} True if the event is supported.
|
||
* @internal
|
||
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
||
*/
|
||
/** @license React v16.13.1
|
||
* react-is.development.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/
|