feat(es/minifier): Drop more returns (#4471)

This commit is contained in:
Donny/강동윤 2022-04-28 22:28:33 +09:00 committed by GitHub
parent 0340c6889f
commit 273954640a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 2475 additions and 105851 deletions

View File

@ -1,7 +1,7 @@
use std::{fmt::Write, num::FpCategory};
use swc_atoms::{js_word, JsWord};
use swc_common::{iter::IdentifyLast, util::take::Take, Span, DUMMY_SP};
use swc_common::{iter::IdentifyLast, util::take::Take, EqIgnoreSpan, Span, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_utils::ident::IdentLike;
@ -212,6 +212,81 @@ impl Pure<'_> {
}
}
pub(super) fn remove_duplicate_returns(&mut self, stmts: &mut Vec<Stmt>) {
fn drop_if_identical(last: &Stmt, check: &mut Stmt) -> bool {
if check.eq_ignore_span(last) {
check.take();
return true;
}
match check {
Stmt::Try(TryStmt {
finalizer: Some(finalizer),
..
}) => {
if let Some(check) = finalizer.stmts.last_mut() {
if drop_if_identical(last, check) {
return true;
}
}
}
Stmt::Try(TryStmt {
handler: Some(CatchClause { body, .. }),
finalizer: None,
..
}) => {
if let Some(check) = body.stmts.last_mut() {
if drop_if_identical(last, check) {
return true;
}
}
}
Stmt::If(IfStmt { cons, alt, .. }) => {
let mut changed = drop_if_identical(last, cons);
if let Some(alt) = alt {
if drop_if_identical(last, alt) {
changed = true;
}
}
return changed;
}
Stmt::Switch(SwitchStmt { cases, .. }) => {
for case in cases {
if let Some(check) = case.cons.last_mut() {
if drop_if_identical(last, check) {
return true;
}
}
}
}
_ => {}
}
false
}
if stmts.is_empty() {
return;
}
let orig_len = stmts.len();
let (a, b) = stmts.split_at_mut(orig_len - 1);
if let Some(last @ Stmt::Return(..)) = b.last() {
if let Some(stmt_before_last) = a.last_mut() {
if drop_if_identical(last, stmt_before_last) {
self.changed = true;
report_change!("Dropped duplicate return");
}
}
}
}
pub(super) fn remove_useless_return(&mut self, stmts: &mut Vec<Stmt>) {
if !self.options.dead_code && !self.options.reduce_vars {
return;

View File

@ -136,6 +136,8 @@ impl Pure<'_> {
}
}
self.remove_duplicate_returns(stmts);
self.remove_useless_return(stmts);
self.negate_if_terminate(stmts, true, false);

View File

@ -343,12 +343,38 @@ fn projects(input: PathBuf) {
None => return Ok(()),
};
let output = print(cm, &[output_module], false, false);
let output = print(cm.clone(), &[output_module], false, false);
eprintln!("---- {} -----\n{}", Color::Green.paint("Output"), output);
println!("{}", input.display());
let minified = {
let output = run(
cm.clone(),
&handler,
&input,
r#"{ "defaults": true, "toplevel": true, "passes": 3 }"#,
Some(TestMangleOptions::Normal(MangleOptions {
top_level: true,
..Default::default()
})),
false,
);
let output_module = match output {
Some(v) => v,
None => return Ok(()),
};
print(cm, &[output_module], true, true)
};
eprintln!(
"---- {} -----\n{}",
Color::Green.paint("Size"),
minified.len()
);
NormalizedOutput::from(output)
.compare_to_file(
dir.parent()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2967,7 +2967,7 @@ Elements.prototype = {
case 'cancel':
return this.cancel(), !0;
case 'chain':
return this.chain(this.caller.pass(arguments, this)), !1;
this.chain(this.caller.pass(arguments, this));
}
return !1;
},
@ -3385,7 +3385,7 @@ Elements.prototype = {
case 'cancel':
return this.cancel(), !0;
case 'chain':
return this.chain(this.caller.pass(arguments, this)), !1;
this.chain(this.caller.pass(arguments, this));
}
return !1;
},

View File

@ -1,10 +1,7 @@
!function(global, factory) {
'object' == typeof exports && 'undefined' != typeof module ? factory(exports) : 'function' == typeof define && define.amd ? define([
'exports'
], factory) : factory((global = global || self).React = {});
}(this, function(exports) {
'use strict';
"production" !== process.env.NODE_ENV && function() {
'use strict';
var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs, prevLog, prevInfo, prevWarn, prevError, prevGroup, prevGroupCollapsed, prevGroupEnd, prefix, componentFrameCache, propTypesMisspellWarningShown, requestHostCallback, requestHostTimeout, cancelHostTimeout, shouldYieldToHost, requestPaint, getCurrentTime, forceFrameRate, REACT_ELEMENT_TYPE = 0xeac7, REACT_PORTAL_TYPE = 0xeaca;
var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs, prevLog, prevInfo, prevWarn, prevError, prevGroup, prevGroupCollapsed, prevGroupEnd, prefix, componentFrameCache, propTypesMisspellWarningShown, _assign = require('object-assign'), REACT_ELEMENT_TYPE = 0xeac7, REACT_PORTAL_TYPE = 0xeaca;
exports.Fragment = 0xeacb, exports.StrictMode = 0xeacc, exports.Profiler = 0xead2;
var REACT_PROVIDER_TYPE = 0xeacd, REACT_CONTEXT_TYPE = 0xeace, REACT_FORWARD_REF_TYPE = 0xead0;
exports.Suspense = 0xead1;
@ -19,19 +16,8 @@
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable['@@iterator'];
return 'function' == typeof maybeIterator ? maybeIterator : null;
}
var hasOwnProperty = Object.prototype.hasOwnProperty, _assign = function(to, from) {
for(var key in from)hasOwnProperty.call(from, key) && (to[key] = from[key]);
}, assign = Object.assign || function(target, sources) {
if (null == target) throw new TypeError('Object.assign target cannot be null or undefined');
for(var to = Object(target), nextIndex = 1; nextIndex < arguments.length; nextIndex++){
var nextSource = arguments[nextIndex];
null != nextSource && _assign(to, Object(nextSource));
}
return to;
}, ReactCurrentDispatcher = {
var ReactCurrentDispatcher = {
current: null
}, ReactCurrentBatchConfig = {
transition: 0
}, ReactCurrentOwner = {
current: null
}, ReactDebugCurrentFrame = {}, currentExtraStackFrame = null;
@ -43,14 +29,16 @@
var impl = ReactDebugCurrentFrame.getCurrentStack;
return impl && (stack += impl() || ''), stack;
};
var IsSomeRendererActing = {
current: !1
}, ReactSharedInternals = {
var ReactSharedInternals = {
ReactCurrentDispatcher: ReactCurrentDispatcher,
ReactCurrentBatchConfig: ReactCurrentBatchConfig,
ReactCurrentBatchConfig: {
transition: 0
},
ReactCurrentOwner: ReactCurrentOwner,
IsSomeRendererActing: IsSomeRendererActing,
assign: assign
IsSomeRendererActing: {
current: !1
},
assign: _assign
};
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];
@ -158,28 +146,26 @@
var outerType, innerType, wrapperName, functionName, lazyComponent = type, payload = lazyComponent._payload, init = lazyComponent._init;
try {
return getComponentName(init(payload));
} catch (x) {
return null;
}
} catch (x) {}
}
return null;
}
pureComponentPrototype.constructor = PureComponent, assign(pureComponentPrototype, Component.prototype), pureComponentPrototype.isPureReactComponent = !0;
var hasOwnProperty$1 = Object.prototype.hasOwnProperty, RESERVED_PROPS = {
pureComponentPrototype.constructor = PureComponent, _assign(pureComponentPrototype, Component.prototype), pureComponentPrototype.isPureReactComponent = !0;
var hasOwnProperty = Object.prototype.hasOwnProperty, RESERVED_PROPS = {
key: !0,
ref: !0,
__self: !0,
__source: !0
};
function hasValidRef(config) {
if (hasOwnProperty$1.call(config, 'ref')) {
if (hasOwnProperty.call(config, 'ref')) {
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
if (getter && getter.isReactWarning) return !1;
}
return void 0 !== config.ref;
}
function hasValidKey(config) {
if (hasOwnProperty$1.call(config, 'key')) {
if (hasOwnProperty.call(config, 'key')) {
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
if (getter && getter.isReactWarning) return !1;
}
@ -219,7 +205,7 @@
var componentName = getComponentName(ReactCurrentOwner.current.type);
didWarnAboutStringRefs[componentName] || (error1('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] = !0);
}
}(config1)), hasValidKey(config1) && (key = '' + config1.key), self = void 0 === config1.__self ? null : config1.__self, source = void 0 === config1.__source ? null : config1.__source, config1)hasOwnProperty$1.call(config1, propName) && !RESERVED_PROPS.hasOwnProperty(propName) && (props[propName] = config1[propName]);
}(config1)), hasValidKey(config1) && (key = '' + config1.key), self = void 0 === config1.__self ? null : config1.__self, source = void 0 === config1.__source ? null : config1.__source, config1)hasOwnProperty.call(config1, propName) && !RESERVED_PROPS.hasOwnProperty(propName) && (props[propName] = config1[propName]);
var childrenLength = arguments.length - 2;
if (1 === childrenLength) props.children = children;
else if (childrenLength > 1) {
@ -248,8 +234,8 @@
}
function cloneElement(element, config, children) {
if (!(null != element)) throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");
var propName, defaultProps, props = assign({}, element.props), key = element.key, ref = element.ref, self = element._self, source = element._source, owner = element._owner;
if (null != config) for(propName in hasValidRef(config) && (ref = config.ref, owner = ReactCurrentOwner.current), hasValidKey(config) && (key = '' + config.key), element.type && element.type.defaultProps && (defaultProps = element.type.defaultProps), config)hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName) && (void 0 === config[propName] && void 0 !== defaultProps ? props[propName] = defaultProps[propName] : props[propName] = config[propName]);
var propName, defaultProps, props = _assign({}, element.props), key = element.key, ref = element.ref, self = element._self, source = element._source, owner = element._owner;
if (null != config) for(propName in hasValidRef(config) && (ref = config.ref, owner = ReactCurrentOwner.current), hasValidKey(config) && (key = '' + config.key), element.type && element.type.defaultProps && (defaultProps = element.type.defaultProps), config)hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName) && (void 0 === config[propName] && void 0 !== defaultProps ? props[propName] = defaultProps[propName] : props[propName] = config[propName]);
var childrenLength = arguments.length - 2;
if (1 === childrenLength) props.children = children;
else if (childrenLength > 1) {
@ -267,11 +253,11 @@
}
function getElementKey(element, index) {
if ('object' == typeof element && null !== element && null != element.key) {
var key, escaperLookup;
return key = '' + element.key, escaperLookup = {
var key, escapeRegex, escaperLookup;
return key = '' + element.key, escapeRegex = /[=:]/g, escaperLookup = {
'=': '=0',
':': '=2'
}, '$' + key.replace(/[=:]/g, function(match) {
}, '$' + key.replace(escapeRegex, function(match) {
return escaperLookup[match];
});
}
@ -448,25 +434,25 @@
writable: !0
};
Object.defineProperties(console, {
log: assign({}, props, {
log: _assign({}, props, {
value: prevLog
}),
info: assign({}, props, {
info: _assign({}, props, {
value: prevInfo
}),
warn: assign({}, props, {
warn: _assign({}, props, {
value: prevWarn
}),
error: assign({}, props, {
error: _assign({}, props, {
value: prevError
}),
group: assign({}, props, {
group: _assign({}, props, {
value: prevGroup
}),
groupCollapsed: assign({}, props, {
groupCollapsed: _assign({}, props, {
value: prevGroupCollapsed
}),
groupEnd: assign({}, props, {
groupEnd: _assign({}, props, {
value: prevGroupEnd
})
});
@ -621,446 +607,6 @@
}(element) : validatePropTypes(element), element;
}
var didWarnAboutDeprecatedCreateFactory = !1;
if ('object' == typeof performance && 'function' == typeof performance.now) {
var localPerformance = performance;
getCurrentTime = function() {
return localPerformance.now();
};
} else {
var localDate = Date, initialTime = localDate.now();
getCurrentTime = function() {
return localDate.now() - initialTime;
};
}
if ('undefined' == typeof window || 'function' != typeof MessageChannel) {
var _callback = null, _timeoutID = null, _flushCallback = function() {
if (null !== _callback) try {
var currentTime = getCurrentTime(), hasRemainingTime = !0;
_callback(hasRemainingTime, currentTime), _callback = null;
} catch (e) {
throw setTimeout(_flushCallback, 0), e;
}
};
requestHostCallback = function(cb) {
null !== _callback ? setTimeout(requestHostCallback, 0, cb) : (_callback = cb, setTimeout(_flushCallback, 0));
}, requestHostTimeout = function(cb, ms) {
_timeoutID = setTimeout(cb, ms);
}, cancelHostTimeout = function() {
clearTimeout(_timeoutID);
}, shouldYieldToHost = function() {
return !1;
}, requestPaint = forceFrameRate = function() {};
} else {
var _setTimeout = window.setTimeout, _clearTimeout = window.clearTimeout;
if ('undefined' != typeof console) {
var requestAnimationFrame = window.requestAnimationFrame, cancelAnimationFrame = window.cancelAnimationFrame;
'function' != typeof requestAnimationFrame && console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"), 'function' != typeof cancelAnimationFrame && console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills");
}
var isMessageLoopRunning = !1, scheduledHostCallback = null, taskTimeoutID = -1, yieldInterval = 5, deadline = 0;
shouldYieldToHost = function() {
return getCurrentTime() >= deadline;
}, requestPaint = function() {}, forceFrameRate = function(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;
}
yieldInterval = fps > 0 ? Math.floor(1000 / fps) : 5;
};
var performWorkUntilDeadline = function() {
if (null !== scheduledHostCallback) {
var currentTime = getCurrentTime();
deadline = currentTime + yieldInterval;
var hasTimeRemaining = !0;
try {
scheduledHostCallback(hasTimeRemaining, currentTime) ? port.postMessage(null) : (isMessageLoopRunning = !1, scheduledHostCallback = null);
} catch (error) {
throw port.postMessage(null), error;
}
} else isMessageLoopRunning = !1;
}, channel = new MessageChannel(), port = channel.port2;
channel.port1.onmessage = performWorkUntilDeadline, requestHostCallback = function(callback) {
scheduledHostCallback = callback, isMessageLoopRunning || (isMessageLoopRunning = !0, port.postMessage(null));
}, requestHostTimeout = function(callback, ms) {
taskTimeoutID = _setTimeout(function() {
callback(getCurrentTime());
}, ms);
}, cancelHostTimeout = function() {
_clearTimeout(taskTimeoutID), taskTimeoutID = -1;
};
}
function push(heap, node) {
var index = heap.length;
heap.push(node), siftUp(heap, node, index);
}
function peek(heap) {
var first = heap[0];
return void 0 === first ? null : first;
}
function pop(heap) {
var first = heap[0];
if (void 0 === first) return null;
var last = heap.pop();
return last !== first && (heap[0] = last, siftDown(heap, last, 0)), first;
}
function siftUp(heap, node, i) {
for(var index = i;;){
var parentIndex = index - 1 >>> 1, parent = heap[parentIndex];
if (!(void 0 !== parent && compare1(parent, node) > 0)) return;
heap[parentIndex] = node, heap[index] = parent, index = parentIndex;
}
}
function siftDown(heap, node, i) {
for(var index = i, length = heap.length; index < length;){
var leftIndex = (index + 1) * 2 - 1, left = heap[leftIndex], rightIndex = leftIndex + 1, right = heap[rightIndex];
if (void 0 !== left && 0 > compare1(left, node)) void 0 !== right && 0 > compare1(right, left) ? (heap[index] = right, heap[rightIndex] = node, index = rightIndex) : (heap[index] = left, heap[leftIndex] = node, index = leftIndex);
else {
if (!(void 0 !== right && 0 > compare1(right, node))) return;
heap[index] = right, heap[rightIndex] = node, index = rightIndex;
}
}
}
function compare1(a, b) {
var diff = a.sortIndex - b.sortIndex;
return 0 !== diff ? diff : a.id - b.id;
}
var taskQueue = [], timerQueue = [], taskIdCounter = 1, currentTask = null, currentPriorityLevel = 3, isPerformingWork = !1, isHostCallbackScheduled = !1, isHostTimeoutScheduled = !1;
function advanceTimers(currentTime) {
for(var timer = peek(timerQueue); null !== timer;){
if (null === timer.callback) pop(timerQueue);
else {
if (!(timer.startTime <= currentTime)) return;
pop(timerQueue), timer.sortIndex = timer.expirationTime, push(taskQueue, timer);
}
timer = peek(timerQueue);
}
}
function handleTimeout(currentTime) {
if (isHostTimeoutScheduled = !1, advanceTimers(currentTime), !isHostCallbackScheduled) {
if (null !== peek(taskQueue)) isHostCallbackScheduled = !0, requestHostCallback(flushWork);
else {
var firstTimer = peek(timerQueue);
null !== firstTimer && requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
}
}
}
function flushWork(hasTimeRemaining, initialTime) {
isHostCallbackScheduled = !1, isHostTimeoutScheduled && (isHostTimeoutScheduled = !1, cancelHostTimeout()), isPerformingWork = !0;
var previousPriorityLevel = currentPriorityLevel;
try {
return workLoop(hasTimeRemaining, initialTime);
} finally{
currentTask = null, currentPriorityLevel = previousPriorityLevel, isPerformingWork = !1;
}
}
function workLoop(hasTimeRemaining, initialTime) {
var currentTime = initialTime;
for(advanceTimers(currentTime), currentTask = peek(taskQueue); null !== currentTask && !(currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost()));){
var callback = currentTask.callback;
if ('function' == typeof callback) {
currentTask.callback = null, currentPriorityLevel = currentTask.priorityLevel;
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime, continuationCallback = callback(didUserCallbackTimeout);
currentTime = getCurrentTime(), 'function' == typeof continuationCallback ? currentTask.callback = continuationCallback : currentTask === peek(taskQueue) && pop(taskQueue), advanceTimers(currentTime);
} else pop(taskQueue);
currentTask = peek(taskQueue);
}
if (null !== currentTask) return !0;
var firstTimer = peek(timerQueue);
return null !== firstTimer && requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime), !1;
}
function unstable_getCurrentPriorityLevel() {
return currentPriorityLevel;
}
var unstable_requestPaint = requestPaint, Scheduler = Object.freeze({
__proto__: null,
unstable_ImmediatePriority: 1,
unstable_UserBlockingPriority: 2,
unstable_NormalPriority: 3,
unstable_IdlePriority: 5,
unstable_LowPriority: 4,
unstable_runWithPriority: function(priorityLevel, eventHandler) {
switch(priorityLevel){
case 1:
case 2:
case 3:
case 4:
case 5:
break;
default:
priorityLevel = 3;
}
var previousPriorityLevel = currentPriorityLevel;
currentPriorityLevel = priorityLevel;
try {
return eventHandler();
} finally{
currentPriorityLevel = previousPriorityLevel;
}
},
unstable_next: function(eventHandler) {
switch(currentPriorityLevel){
case 1:
case 2:
case 3:
priorityLevel = 3;
break;
default:
priorityLevel = currentPriorityLevel;
}
var priorityLevel, previousPriorityLevel = currentPriorityLevel;
currentPriorityLevel = priorityLevel;
try {
return eventHandler();
} finally{
currentPriorityLevel = previousPriorityLevel;
}
},
unstable_scheduleCallback: function(priorityLevel, callback, options) {
var startTime, timeout, currentTime = getCurrentTime();
if ('object' == typeof options && null !== options) {
var delay = options.delay;
startTime = 'number' == typeof delay && delay > 0 ? currentTime + delay : currentTime;
} else startTime = currentTime;
switch(priorityLevel){
case 1:
timeout = -1;
break;
case 2:
timeout = 250;
break;
case 5:
timeout = 1073741823;
break;
case 4:
timeout = 10000;
break;
default:
timeout = 5000;
}
var expirationTime = startTime + timeout, newTask = {
id: taskIdCounter++,
callback: callback,
priorityLevel: priorityLevel,
startTime: startTime,
expirationTime: expirationTime,
sortIndex: -1
};
return startTime > currentTime ? (newTask.sortIndex = startTime, push(timerQueue, newTask), null === peek(taskQueue) && newTask === peek(timerQueue) && (isHostTimeoutScheduled ? cancelHostTimeout() : isHostTimeoutScheduled = !0, requestHostTimeout(handleTimeout, startTime - currentTime))) : (newTask.sortIndex = expirationTime, push(taskQueue, newTask), isHostCallbackScheduled || isPerformingWork || (isHostCallbackScheduled = !0, requestHostCallback(flushWork))), newTask;
},
unstable_cancelCallback: function(task) {
task.callback = null;
},
unstable_wrapCallback: function(callback) {
var parentPriorityLevel = currentPriorityLevel;
return function() {
var previousPriorityLevel = currentPriorityLevel;
currentPriorityLevel = parentPriorityLevel;
try {
return callback.apply(this, arguments);
} finally{
currentPriorityLevel = previousPriorityLevel;
}
};
},
unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel,
get unstable_shouldYield () {
return shouldYieldToHost;
},
unstable_requestPaint: unstable_requestPaint,
unstable_continueExecution: function() {
isHostCallbackScheduled || isPerformingWork || (isHostCallbackScheduled = !0, requestHostCallback(flushWork));
},
unstable_pauseExecution: function() {},
unstable_getFirstCallbackNode: function() {
return peek(taskQueue);
},
get unstable_now () {
return getCurrentTime;
},
get unstable_forceFrameRate () {
return forceFrameRate;
},
unstable_Profiling: null
}), interactionIDCounter = 0, threadIDCounter = 0, interactionsRef = null, subscriberRef = null;
function unstable_getThreadID() {
return ++threadIDCounter;
}
interactionsRef = {
current: new Set()
}, subscriberRef = {
current: null
};
var subscribers = null;
function onInteractionTraced(interaction) {
var didCatchError = !1, caughtError = null;
if (subscribers.forEach(function(subscriber) {
try {
subscriber.onInteractionTraced(interaction);
} catch (error) {
didCatchError || (didCatchError = !0, caughtError = error);
}
}), didCatchError) throw caughtError;
}
function onInteractionScheduledWorkCompleted(interaction) {
var didCatchError = !1, caughtError = null;
if (subscribers.forEach(function(subscriber) {
try {
subscriber.onInteractionScheduledWorkCompleted(interaction);
} catch (error) {
didCatchError || (didCatchError = !0, caughtError = error);
}
}), didCatchError) throw caughtError;
}
function onWorkScheduled(interactions, threadID) {
var didCatchError = !1, caughtError = null;
if (subscribers.forEach(function(subscriber) {
try {
subscriber.onWorkScheduled(interactions, threadID);
} catch (error) {
didCatchError || (didCatchError = !0, caughtError = error);
}
}), didCatchError) throw caughtError;
}
function onWorkStarted(interactions, threadID) {
var didCatchError = !1, caughtError = null;
if (subscribers.forEach(function(subscriber) {
try {
subscriber.onWorkStarted(interactions, threadID);
} catch (error) {
didCatchError || (didCatchError = !0, caughtError = error);
}
}), didCatchError) throw caughtError;
}
function onWorkStopped(interactions, threadID) {
var didCatchError = !1, caughtError = null;
if (subscribers.forEach(function(subscriber) {
try {
subscriber.onWorkStopped(interactions, threadID);
} catch (error) {
didCatchError || (didCatchError = !0, caughtError = error);
}
}), didCatchError) throw caughtError;
}
function onWorkCanceled(interactions, threadID) {
var didCatchError = !1, caughtError = null;
if (subscribers.forEach(function(subscriber) {
try {
subscriber.onWorkCanceled(interactions, threadID);
} catch (error) {
didCatchError || (didCatchError = !0, caughtError = error);
}
}), didCatchError) throw caughtError;
}
subscribers = new Set();
var ReactSharedInternals$1 = {
ReactCurrentDispatcher: ReactCurrentDispatcher,
ReactCurrentOwner: ReactCurrentOwner,
IsSomeRendererActing: IsSomeRendererActing,
ReactCurrentBatchConfig: ReactCurrentBatchConfig,
assign: assign,
Scheduler: Scheduler,
SchedulerTracing: Object.freeze({
__proto__: null,
get __interactionsRef () {
return interactionsRef;
},
get __subscriberRef () {
return subscriberRef;
},
unstable_clear: function(callback) {
var prevInteractions = interactionsRef.current;
interactionsRef.current = new Set();
try {
return callback();
} finally{
interactionsRef.current = prevInteractions;
}
},
unstable_getCurrent: function() {
return interactionsRef.current;
},
unstable_getThreadID: unstable_getThreadID,
unstable_trace: function(name, timestamp, callback) {
var returnValue, threadID = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : 0, interaction = {
__count: 1,
id: interactionIDCounter++,
name: name,
timestamp: timestamp
}, prevInteractions = interactionsRef.current, interactions = new Set(prevInteractions);
interactions.add(interaction), interactionsRef.current = interactions;
var subscriber = subscriberRef.current;
try {
null !== subscriber && subscriber.onInteractionTraced(interaction);
} finally{
try {
null !== subscriber && subscriber.onWorkStarted(interactions, threadID);
} finally{
try {
returnValue = callback();
} finally{
interactionsRef.current = prevInteractions;
try {
null !== subscriber && subscriber.onWorkStopped(interactions, threadID);
} finally{
interaction.__count--, null !== subscriber && 0 === interaction.__count && subscriber.onInteractionScheduledWorkCompleted(interaction);
}
}
}
}
return returnValue;
},
unstable_wrap: function(callback) {
var threadID = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0, wrappedInteractions = interactionsRef.current, subscriber = subscriberRef.current;
null !== subscriber && subscriber.onWorkScheduled(wrappedInteractions, threadID), wrappedInteractions.forEach(function(interaction) {
interaction.__count++;
});
var hasRun = !1;
function wrapped() {
var returnValue, prevInteractions = interactionsRef.current;
interactionsRef.current = wrappedInteractions, subscriber = subscriberRef.current;
try {
try {
null !== subscriber && subscriber.onWorkStarted(wrappedInteractions, threadID);
} finally{
try {
returnValue = callback.apply(void 0, arguments);
} finally{
interactionsRef.current = prevInteractions, null !== subscriber && subscriber.onWorkStopped(wrappedInteractions, threadID);
}
}
return returnValue;
} finally{
hasRun || (hasRun = !0, wrappedInteractions.forEach(function(interaction) {
interaction.__count--, null !== subscriber && 0 === interaction.__count && subscriber.onInteractionScheduledWorkCompleted(interaction);
}));
}
}
return wrapped.cancel = function() {
subscriber = subscriberRef.current;
try {
null !== subscriber && subscriber.onWorkCanceled(wrappedInteractions, threadID);
} finally{
wrappedInteractions.forEach(function(interaction) {
interaction.__count--, subscriber && 0 === interaction.__count && subscriber.onInteractionScheduledWorkCompleted(interaction);
});
}
}, wrapped;
},
unstable_subscribe: function(subscriber) {
subscribers.add(subscriber), 1 === subscribers.size && (subscriberRef.current = {
onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
onInteractionTraced: onInteractionTraced,
onWorkCanceled: onWorkCanceled,
onWorkScheduled: onWorkScheduled,
onWorkStarted: onWorkStarted,
onWorkStopped: onWorkStopped
});
},
unstable_unsubscribe: function(subscriber) {
subscribers.delete(subscriber), 0 === subscribers.size && (subscriberRef.current = null);
}
})
};
ReactSharedInternals$1.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
try {
var frozenObject = Object.freeze({});
new Map([
@ -1094,7 +640,7 @@
if (!isValidElement(children)) throw Error("React.Children.only expected to receive a single React element child.");
return children;
}
}, exports.Component = Component, exports.PureComponent = PureComponent, exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals$1, exports.cloneElement = function(element, props, children) {
}, exports.Component = Component, exports.PureComponent = PureComponent, exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals, exports.cloneElement = function(element, props, children) {
for(var newElement = cloneElement.apply(this, arguments), i = 2; i < arguments.length; i++)validateChildKeys(arguments[i], newElement.type);
return validatePropTypes(newElement), newElement;
}, exports.createContext = function(defaultValue, calculateChangedBits) {
@ -1270,5 +816,5 @@
return resolveDispatcher().useRef(initialValue);
}, exports.useState = function(initialState) {
return resolveDispatcher().useState(initialState);
}, exports.version = '17.0.2';
});
}, exports.version = '17.0.1';
}();

View File

@ -575,9 +575,7 @@
var outerType, innerType, wrapperName, functionName, lazyComponent = type, payload = lazyComponent._payload, init = lazyComponent._init;
try {
return getComponentName(init(payload));
} catch (x) {
return null;
}
} catch (x) {}
}
return null;
}
@ -4493,7 +4491,7 @@
if (null == partialState) return prevState;
return _assign({}, prevState, partialState);
case 2:
return hasForceUpdate = !0, prevState;
hasForceUpdate = !0;
}
return prevState;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff