rsnext/packages/next/compiled/scheduler/index.js
Jiachi Liu b0f87fbc7c
Bundle ssr client layer excepts react externals (#41606)
Bundle the ssr client layer for RSC, this solves the problem when
there's an esm package is using on client components, but esm imports
the installed react instead of the built-in react version since esm
imports is not intercepted by require hook.

After bundling the ssr client layer and treating react as externals, now
react compiles as cjs externals and could be intercepted by require
hook, other code are bundled together which can also get optimized.

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

Co-authored-by: Shu Ding <g@shud.in>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-10-22 16:33:51 -07:00

21 lines
No EOL
11 KiB
JavaScript

(()=>{"use strict";var e={620:(e,n)=>{
/**
* @license React
* scheduler.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
if(process.env.NODE_ENV!=="production"){(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 e=false;var t=false;var r=5;function push(e,n){var t=e.length;e.push(n);siftUp(e,n,t)}function peek(e){return e.length===0?null:e[0]}function pop(e){if(e.length===0){return null}var n=e[0];var t=e.pop();if(t!==n){e[0]=t;siftDown(e,t,0)}return n}function siftUp(e,n,t){var r=t;while(r>0){var a=r-1>>>1;var l=e[a];if(compare(l,n)>0){e[a]=n;e[r]=l;r=a}else{return}}}function siftDown(e,n,t){var r=t;var a=e.length;var l=a>>>1;while(r<l){var i=(r+1)*2-1;var u=e[i];var o=i+1;var s=e[o];if(compare(u,n)<0){if(o<a&&compare(s,u)<0){e[r]=s;e[o]=n;r=o}else{e[r]=u;e[i]=n;r=i}}else if(o<a&&compare(s,n)<0){e[r]=s;e[o]=n;r=o}else{return}}}function compare(e,n){var t=e.sortIndex-n.sortIndex;return t!==0?t:e.id-n.id}var a=1;var l=2;var i=3;var u=4;var o=5;function markTaskErrored(e,n){}var s=typeof performance==="object"&&typeof performance.now==="function";if(s){var c=performance;n.unstable_now=function(){return c.now()}}else{var v=Date;var _=v.now();n.unstable_now=function(){return v.now()-_}}var p=1073741823;var b=-1;var d=250;var m=5e3;var y=1e4;var T=p;var w=[];var x=[];var C=1;var O=null;var L=i;var E=false;var P=false;var q=false;var A=typeof setTimeout==="function"?setTimeout:null;var D=typeof clearTimeout==="function"?clearTimeout:null;var F=typeof setImmediate!=="undefined"?setImmediate:null;var N=typeof navigator!=="undefined"&&navigator.scheduling!==undefined&&navigator.scheduling.isInputPending!==undefined?navigator.scheduling.isInputPending.bind(navigator.scheduling):null;function advanceTimers(e){var n=peek(x);while(n!==null){if(n.callback===null){pop(x)}else if(n.startTime<=e){pop(x);n.sortIndex=n.expirationTime;push(w,n)}else{return}n=peek(x)}}function handleTimeout(e){q=false;advanceTimers(e);if(!P){if(peek(w)!==null){P=true;requestHostCallback(flushWork)}else{var n=peek(x);if(n!==null){requestHostTimeout(handleTimeout,n.startTime-e)}}}}function flushWork(e,r){P=false;if(q){q=false;cancelHostTimeout()}E=true;var a=L;try{if(t){try{return workLoop(e,r)}catch(e){if(O!==null){var l=n.unstable_now();markTaskErrored(O,l);O.isQueued=false}throw e}}else{return workLoop(e,r)}}finally{O=null;L=a;E=false}}function workLoop(t,r){var a=r;advanceTimers(a);O=peek(w);while(O!==null&&!e){if(O.expirationTime>a&&(!t||shouldYieldToHost())){break}var l=O.callback;if(typeof l==="function"){O.callback=null;L=O.priorityLevel;var i=O.expirationTime<=a;var u=l(i);a=n.unstable_now();if(typeof u==="function"){O.callback=u;advanceTimers(a);return true}else{if(O===peek(w)){pop(w)}advanceTimers(a)}}else{pop(w)}O=peek(w)}if(O!==null){return true}else{var o=peek(x);if(o!==null){requestHostTimeout(handleTimeout,o.startTime-a)}return false}}function unstable_runWithPriority(e,n){switch(e){case a:case l:case i:case u:case o:break;default:e=i}var t=L;L=e;try{return n()}finally{L=t}}function unstable_next(e){var n;switch(L){case a:case l:case i:n=i;break;default:n=L;break}var t=L;L=n;try{return e()}finally{L=t}}function unstable_wrapCallback(e){var n=L;return function(){var t=L;L=n;try{return e.apply(this,arguments)}finally{L=t}}}function unstable_scheduleCallback(e,t,r){var s=n.unstable_now();var c;if(typeof r==="object"&&r!==null){var v=r.delay;if(typeof v==="number"&&v>0){c=s+v}else{c=s}}else{c=s}var _;switch(e){case a:_=b;break;case l:_=d;break;case o:_=T;break;case u:_=y;break;case i:default:_=m;break}var p=c+_;var O={id:C++,callback:t,priorityLevel:e,startTime:c,expirationTime:p,sortIndex:-1};if(c>s){O.sortIndex=c;push(x,O);if(peek(w)===null&&O===peek(x)){if(q){cancelHostTimeout()}else{q=true}requestHostTimeout(handleTimeout,c-s)}}else{O.sortIndex=p;push(w,O);if(!P&&!E){P=true;requestHostCallback(flushWork)}}return O}function unstable_pauseExecution(){}function unstable_continueExecution(){if(!P&&!E){P=true;requestHostCallback(flushWork)}}function unstable_getFirstCallbackNode(){return peek(w)}function unstable_cancelCallback(e){e.callback=null}function unstable_getCurrentPriorityLevel(){return L}var S=false;var B=null;var V=-1;var W=r;var Y=-1;function shouldYieldToHost(){var e=n.unstable_now()-Y;if(e<W){return false}return true}function requestPaint(){}function forceFrameRate(e){if(e<0||e>125){console["error"]("forceFrameRate takes a positive int between 0 and 125, "+"forcing frame rates higher than 125 fps is not supported");return}if(e>0){W=Math.floor(1e3/e)}else{W=r}}var performWorkUntilDeadline=function(){if(B!==null){var e=n.unstable_now();Y=e;var t=true;var r=true;try{r=B(t,e)}finally{if(r){j()}else{S=false;B=null}}}else{S=false}};var j;if(typeof F==="function"){j=function(){F(performWorkUntilDeadline)}}else if(typeof MessageChannel!=="undefined"){var U=new MessageChannel;var Q=U.port2;U.port1.onmessage=performWorkUntilDeadline;j=function(){Q.postMessage(null)}}else{j=function(){A(performWorkUntilDeadline,0)}}function requestHostCallback(e){B=e;if(!S){S=true;j()}}function requestHostTimeout(e,t){V=A((function(){e(n.unstable_now())}),t)}function cancelHostTimeout(){D(V);V=-1}var z=null;n.unstable_IdlePriority=o;n.unstable_ImmediatePriority=a;n.unstable_LowPriority=u;n.unstable_NormalPriority=i;n.unstable_Profiling=z;n.unstable_UserBlockingPriority=l;n.unstable_cancelCallback=unstable_cancelCallback;n.unstable_continueExecution=unstable_continueExecution;n.unstable_forceFrameRate=forceFrameRate;n.unstable_getCurrentPriorityLevel=unstable_getCurrentPriorityLevel;n.unstable_getFirstCallbackNode=unstable_getFirstCallbackNode;n.unstable_next=unstable_next;n.unstable_pauseExecution=unstable_pauseExecution;n.unstable_requestPaint=requestPaint;n.unstable_runWithPriority=unstable_runWithPriority;n.unstable_scheduleCallback=unstable_scheduleCallback;n.unstable_shouldYield=shouldYieldToHost;n.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)}})()}},360:(e,n)=>{
/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
function f(e,n){var t=e.length;e.push(n);e:for(;0<t;){var r=t-1>>>1,a=e[r];if(0<g(a,n))e[r]=n,e[t]=a,t=r;else break e}}function h(e){return 0===e.length?null:e[0]}function k(e){if(0===e.length)return null;var n=e[0],t=e.pop();if(t!==n){e[0]=t;e:for(var r=0,a=e.length,l=a>>>1;r<l;){var i=2*(r+1)-1,u=e[i],o=i+1,s=e[o];if(0>g(u,t))o<a&&0>g(s,u)?(e[r]=s,e[o]=t,r=o):(e[r]=u,e[i]=t,r=i);else if(o<a&&0>g(s,t))e[r]=s,e[o]=t,r=o;else break e}}return n}function g(e,n){var t=e.sortIndex-n.sortIndex;return 0!==t?t:e.id-n.id}if("object"===typeof performance&&"function"===typeof performance.now){var t=performance;n.unstable_now=function(){return t.now()}}else{var r=Date,a=r.now();n.unstable_now=function(){return r.now()-a}}var l=[],i=[],u=1,o=null,s=3,c=!1,v=!1,_=!1,p="function"===typeof setTimeout?setTimeout:null,b="function"===typeof clearTimeout?clearTimeout:null,d="undefined"!==typeof setImmediate?setImmediate:null;"undefined"!==typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function G(e){for(var n=h(i);null!==n;){if(null===n.callback)k(i);else if(n.startTime<=e)k(i),n.sortIndex=n.expirationTime,f(l,n);else break;n=h(i)}}function H(e){_=!1;G(e);if(!v)if(null!==h(l))v=!0,I(J);else{var n=h(i);null!==n&&K(H,n.startTime-e)}}function J(e,t){v=!1;_&&(_=!1,b(T),T=-1);c=!0;var r=s;try{e:{G(t);for(o=h(l);null!==o&&(!(o.expirationTime>t)||e&&!M());){var a=o.callback;if("function"===typeof a){o.callback=null;s=o.priorityLevel;var u=a(o.expirationTime<=t);t=n.unstable_now();if("function"===typeof u){o.callback=u;G(t);var p=!0;break e}o===h(l)&&k(l);G(t)}else k(l);o=h(l)}if(null!==o)p=!0;else{var d=h(i);null!==d&&K(H,d.startTime-t);p=!1}}return p}finally{o=null,s=r,c=!1}}var m=!1,y=null,T=-1,w=5,x=-1;function M(){return n.unstable_now()-x<w?!1:!0}function R(){if(null!==y){var e=n.unstable_now();x=e;var t=!0;try{t=y(!0,e)}finally{t?C():(m=!1,y=null)}}else m=!1}var C;if("function"===typeof d)C=function(){d(R)};else if("undefined"!==typeof MessageChannel){var O=new MessageChannel,L=O.port2;O.port1.onmessage=R;C=function(){L.postMessage(null)}}else C=function(){p(R,0)};function I(e){y=e;m||(m=!0,C())}function K(e,t){T=p((function(){e(n.unstable_now())}),t)}n.unstable_IdlePriority=5;n.unstable_ImmediatePriority=1;n.unstable_LowPriority=4;n.unstable_NormalPriority=3;n.unstable_Profiling=null;n.unstable_UserBlockingPriority=2;n.unstable_cancelCallback=function(e){e.callback=null};n.unstable_continueExecution=function(){v||c||(v=!0,I(J))};n.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):w=0<e?Math.floor(1e3/e):5};n.unstable_getCurrentPriorityLevel=function(){return s};n.unstable_getFirstCallbackNode=function(){return h(l)};n.unstable_next=function(e){switch(s){case 1:case 2:case 3:var n=3;break;default:n=s}var t=s;s=n;try{return e()}finally{s=t}};n.unstable_pauseExecution=function(){};n.unstable_requestPaint=function(){};n.unstable_runWithPriority=function(e,n){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var t=s;s=e;try{return n()}finally{s=t}};n.unstable_scheduleCallback=function(e,t,r){var a=n.unstable_now();"object"===typeof r&&null!==r?(r=r.delay,r="number"===typeof r&&0<r?a+r:a):r=a;switch(e){case 1:var o=-1;break;case 2:o=250;break;case 5:o=1073741823;break;case 4:o=1e4;break;default:o=5e3}o=r+o;e={id:u++,callback:t,priorityLevel:e,startTime:r,expirationTime:o,sortIndex:-1};r>a?(e.sortIndex=r,f(i,e),null===h(l)&&e===h(i)&&(_?(b(T),T=-1):_=!0,K(H,r-a))):(e.sortIndex=o,f(l,e),v||c||(v=!0,I(J)));return e};n.unstable_shouldYield=M;n.unstable_wrapCallback=function(e){var n=s;return function(){var t=s;s=n;try{return e.apply(this,arguments)}finally{s=t}}}},720:(e,n,t)=>{if(process.env.NODE_ENV==="production"){e.exports=t(360)}else{e.exports=t(620)}}};var n={};function __nccwpck_require__(t){var r=n[t];if(r!==undefined){return r.exports}var a=n[t]={exports:{}};var l=true;try{e[t](a,a.exports,__nccwpck_require__);l=false}finally{if(l)delete n[t]}return a.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(720);module.exports=t})();