react-compiler-runtime
Advanced tools
Comparing version 0.0.0-experimental-605e95c-20241015 to 0.0.0-experimental-7929cc7-20241018
@@ -14,3 +14,3 @@ /** | ||
"use no memo";"use strict";function e(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var t,n,o=e(require("react"));const{useRef:r,useEffect:c,isValidElement:a}=o,i=null!==(t=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE)&&void 0!==t?t:o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,s=Symbol.for("react.memo_cache_sentinel"),u="function"==typeof(null===(n=o.__COMPILER_RUNTIME)||void 0===n?void 0:n.c)?o.__COMPILER_RUNTIME.c:function(e){return o.useMemo((()=>{const t=new Array(e);for(let n=0;n<e;n++)t[n]=s;return t[s]=!0,t}),[])},l={};["readContext","useCallback","useContext","useEffect","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useReducer","useRef","useState","useDebugValue","useDeferredValue","useTransition","useMutableSource","useSyncExternalStore","useId","unstable_isNewReconciler","getCacheSignal","getCacheForType","useCacheRefresh"].forEach((e=>{l[e]=()=>{throw new Error(`[React] Unexpected React hook call (${e}) from a React Forget compiled function. Check that all hooks are called directly and named according to convention ('use[A-Z]') `)}}));let f=null;var p;function h(e){return i.ReactCurrentDispatcher.current=e,i.ReactCurrentDispatcher.current}l.useMemoCache=e=>{if(null==f)throw new Error("React Forget internal invariant violation: unexpected null dispatcher");return f.useMemoCache(e)},function(e){e[e.PushGuardContext=0]="PushGuardContext",e[e.PopGuardContext=1]="PopGuardContext",e[e.PushExpectHook=2]="PushExpectHook",e[e.PopExpectHook=3]="PopExpectHook"}(p||(p={}));const d=[];const y=new Map;const R=new Set;exports.$dispatcherGuard=function(e){const t=i.ReactCurrentDispatcher.current;if(e===p.PushGuardContext){if(d.push(t),1===d.length&&(f=t),t===l)throw new Error("[React] Unexpected call to custom hook or component from a React Forget compiled function. Check that (1) all hooks are called directly and named according to convention ('use[A-Z]') and (2) components are returned as JSX instead of being directly invoked.");h(l)}else if(e===p.PopGuardContext){const e=d.pop();if(null==e)throw new Error("React Forget internal error: unexpected null in guard stack");0===d.length&&(f=null),h(e)}else if(e===p.PushExpectHook)d.push(t),h(f);else{if(e!==p.PopExpectHook)throw new Error("Forget internal error: unreachable block"+e);{const e=d.pop();if(null==e)throw new Error("React Forget internal error: unexpected null in guard stack");h(e)}}},exports.$makeReadOnly=function(){throw new Error("TODO: implement $makeReadOnly in react-compiler-runtime")},exports.$reset=function(e){for(let t=0;t<e.length;t++)e[t]=s},exports.$structuralCheck=function(e,t,n,o,r,c){function i(e,t,a,i){const s=`${o}:${c} [${r}] ${n}${a} changed from ${e} to ${t} at depth ${i}`;R.has(s)||(R.add(s),console.error(s))}!function e(t,n,o,r){if(!(r>2)&&t!==n)if(typeof t!=typeof n)i("type "+typeof t,"type "+typeof n,o,r);else if("object"==typeof t){const c=Array.isArray(t),s=Array.isArray(n);if(null===t&&null!==n)i("null","type "+typeof n,o,r);else if(null===n)i("type "+typeof t,"null",o,r);else if(t instanceof Map)if(n instanceof Map)if(t.size!==n.size)i(`Map instance with size ${t.size}`,`Map instance with size ${n.size}`,o,r);else for(const[c,a]of t)n.has(c)?e(a,n.get(c),`${o}.get(${c})`,r+1):i(`Map instance with key ${c}`,`Map instance without key ${c}`,o,r);else i("Map instance","other value",o,r);else if(n instanceof Map)i("other value","Map instance",o,r);else if(t instanceof Set)if(n instanceof Set)if(t.size!==n.size)i(`Set instance with size ${t.size}`,`Set instance with size ${n.size}`,o,r);else for(const e of n)t.has(e)||i(`Set instance without element ${e}`,`Set instance with element ${e}`,o,r);else i("Set instance","other value",o,r);else if(n instanceof Set)i("other value","Set instance",o,r);else if(c||s)if(c!==s)i("type "+(c?"array":"object"),"type "+(s?"array":"object"),o,r);else if(t.length!==n.length)i(`array with length ${t.length}`,`array with length ${n.length}`,o,r);else for(let c=0;c<t.length;c++)e(t[c],n[c],`${o}[${c}]`,r+1);else if(a(t)||a(n))a(t)!==a(n)?i("type "+(a(t)?"React element":"object"),"type "+(a(n)?"React element":"object"),o,r):t.type!==n.type?i(`React element of type ${t.type}`,`React element of type ${n.type}`,o,r):e(t.props,n.props,`[props of ${o}]`,r+1);else{for(const e in n)e in t||i(`object without key ${e}`,`object with key ${e}`,o,r);for(const c in t)c in n?e(t[c],n[c],`${o}.${c}`,r+1):i(`object with key ${c}`,`object without key ${c}`,o,r)}}else{if("function"==typeof t)return;isNaN(t)||isNaN(n)?isNaN(t)!==isNaN(n)&&i(""+(isNaN(t)?"NaN":"non-NaN value"),""+(isNaN(n)?"NaN":"non-NaN value"),o,r):t!==n&&i(t,n,o,r)}}(e,t,"",0)},exports.c=u,exports.clearRenderCounterRegistry=function(){for(const e of y.values())e.forEach((e=>{e.count=0}))},exports.renderCounterRegistry=y,exports.useRenderCounter=function(e){const t=r(null);null!=t.current&&(t.current.count+=1),c((()=>{if(null==t.current){const n={count:0};!function(e,t){let n=y.get(e);null==n&&(n=new Set,y.set(e,n)),n.add(t)}(e,n),t.current=n}return()=>{null!==t.current&&function(e,t){const n=y.get(e);null!=n&&n.delete(t)}(e,t.current)}}))}; | ||
"use no memo";"use strict";function e(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var t,n,o=e(require("react"));const{useRef:r,useEffect:c,isValidElement:a}=o,i=null!==(t=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE)&&void 0!==t?t:o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,s=Symbol.for("react.memo_cache_sentinel"),l="function"==typeof(null===(n=o.__COMPILER_RUNTIME)||void 0===n?void 0:n.c)?o.__COMPILER_RUNTIME.c:function(e){return o.useMemo((()=>{const t=new Array(e);for(let n=0;n<e;n++)t[n]=s;return t[s]=!0,t}),[])},u={};["readContext","useCallback","useContext","useEffect","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useReducer","useRef","useState","useDebugValue","useDeferredValue","useTransition","useMutableSource","useSyncExternalStore","useId","unstable_isNewReconciler","getCacheSignal","getCacheForType","useCacheRefresh"].forEach((e=>{u[e]=()=>{throw new Error(`[React] Unexpected React hook call (${e}) from a React compiled function. Check that all hooks are called directly and named according to convention ('use[A-Z]') `)}}));let f=null;var p;function h(e){return i.ReactCurrentDispatcher.current=e,i.ReactCurrentDispatcher.current}u.useMemoCache=e=>{if(null==f)throw new Error("React Compiler internal invariant violation: unexpected null dispatcher");return f.useMemoCache(e)},function(e){e[e.PushGuardContext=0]="PushGuardContext",e[e.PopGuardContext=1]="PopGuardContext",e[e.PushExpectHook=2]="PushExpectHook",e[e.PopExpectHook=3]="PopExpectHook"}(p||(p={}));const d=[];const y=new Map;const R=new Set;exports.$dispatcherGuard=function(e){const t=i.ReactCurrentDispatcher.current;if(e===p.PushGuardContext){if(d.push(t),1===d.length&&(f=t),t===u)throw new Error("[React] Unexpected call to custom hook or component from a React compiled function. Check that (1) all hooks are called directly and named according to convention ('use[A-Z]') and (2) components are returned as JSX instead of being directly invoked.");h(u)}else if(e===p.PopGuardContext){const e=d.pop();if(null==e)throw new Error("React Compiler internal error: unexpected null in guard stack");0===d.length&&(f=null),h(e)}else if(e===p.PushExpectHook)d.push(t),h(f);else{if(e!==p.PopExpectHook)throw new Error("React Compiler internal error: unreachable block"+e);{const e=d.pop();if(null==e)throw new Error("React Compiler internal error: unexpected null in guard stack");h(e)}}},exports.$makeReadOnly=function(){throw new Error("TODO: implement $makeReadOnly in react-compiler-runtime")},exports.$reset=function(e){for(let t=0;t<e.length;t++)e[t]=s},exports.$structuralCheck=function(e,t,n,o,r,c){function i(e,t,a,i){const s=`${o}:${c} [${r}] ${n}${a} changed from ${e} to ${t} at depth ${i}`;R.has(s)||(R.add(s),console.error(s))}!function e(t,n,o,r){if(!(r>2)&&t!==n)if(typeof t!=typeof n)i("type "+typeof t,"type "+typeof n,o,r);else if("object"==typeof t){const c=Array.isArray(t),s=Array.isArray(n);if(null===t&&null!==n)i("null","type "+typeof n,o,r);else if(null===n)i("type "+typeof t,"null",o,r);else if(t instanceof Map)if(n instanceof Map)if(t.size!==n.size)i(`Map instance with size ${t.size}`,`Map instance with size ${n.size}`,o,r);else for(const[c,a]of t)n.has(c)?e(a,n.get(c),`${o}.get(${c})`,r+1):i(`Map instance with key ${c}`,`Map instance without key ${c}`,o,r);else i("Map instance","other value",o,r);else if(n instanceof Map)i("other value","Map instance",o,r);else if(t instanceof Set)if(n instanceof Set)if(t.size!==n.size)i(`Set instance with size ${t.size}`,`Set instance with size ${n.size}`,o,r);else for(const e of n)t.has(e)||i(`Set instance without element ${e}`,`Set instance with element ${e}`,o,r);else i("Set instance","other value",o,r);else if(n instanceof Set)i("other value","Set instance",o,r);else if(c||s)if(c!==s)i("type "+(c?"array":"object"),"type "+(s?"array":"object"),o,r);else if(t.length!==n.length)i(`array with length ${t.length}`,`array with length ${n.length}`,o,r);else for(let c=0;c<t.length;c++)e(t[c],n[c],`${o}[${c}]`,r+1);else if(a(t)||a(n))a(t)!==a(n)?i("type "+(a(t)?"React element":"object"),"type "+(a(n)?"React element":"object"),o,r):t.type!==n.type?i(`React element of type ${t.type}`,`React element of type ${n.type}`,o,r):e(t.props,n.props,`[props of ${o}]`,r+1);else{for(const e in n)e in t||i(`object without key ${e}`,`object with key ${e}`,o,r);for(const c in t)c in n?e(t[c],n[c],`${o}.${c}`,r+1):i(`object with key ${c}`,`object without key ${c}`,o,r)}}else{if("function"==typeof t)return;isNaN(t)||isNaN(n)?isNaN(t)!==isNaN(n)&&i(""+(isNaN(t)?"NaN":"non-NaN value"),""+(isNaN(n)?"NaN":"non-NaN value"),o,r):t!==n&&i(t,n,o,r)}}(e,t,"",0)},exports.c=l,exports.clearRenderCounterRegistry=function(){for(const e of y.values())e.forEach((e=>{e.count=0}))},exports.renderCounterRegistry=y,exports.useRenderCounter=function(e){const t=r(null);null!=t.current&&(t.current.count+=1),c((()=>{if(null==t.current){const n={count:0};!function(e,t){let n=y.get(e);null==n&&(n=new Set,y.set(e,n)),n.add(t)}(e,n),t.current=n}return()=>{null!==t.current&&function(e,t){const n=y.get(e);null!=n&&n.delete(t)}(e,t.current)}}))}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-compiler-runtime", | ||
"version": "0.0.0-experimental-605e95c-20241015", | ||
"version": "0.0.0-experimental-7929cc7-20241018", | ||
"description": "Runtime for React Compiler", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -8,3 +8,3 @@ /** | ||
'use no forget'; | ||
'use no memo'; | ||
@@ -71,3 +71,3 @@ import * as React from 'react'; | ||
throw new Error( | ||
`[React] Unexpected React hook call (${name}) from a React Forget compiled function. ` + | ||
`[React] Unexpected React hook call (${name}) from a React compiled function. ` + | ||
"Check that all hooks are called directly and named according to convention ('use[A-Z]') ", | ||
@@ -84,3 +84,3 @@ ); | ||
throw new Error( | ||
'React Forget internal invariant violation: unexpected null dispatcher', | ||
'React Compiler internal invariant violation: unexpected null dispatcher', | ||
); | ||
@@ -109,8 +109,8 @@ } else { | ||
* of the no-conditional-hook-calls rule. | ||
* As Forget needs to statically understand which calls to move out of | ||
* conditional branches (i.e. Forget cannot memoize the results of hook | ||
* As React Compiler needs to statically understand which calls to move out of | ||
* conditional branches (i.e. React Compiler cannot memoize the results of hook | ||
* calls), its understanding of "the rules of React" are more restrictive. | ||
* This validation throws on unsound inputs at runtime. | ||
* | ||
* Components should only be invoked through React as Forget could memoize | ||
* Components should only be invoked through React as React Compiler could memoize | ||
* the call to AnotherComponent, introducing conditional hook calls in its | ||
@@ -155,3 +155,3 @@ * compiled output. | ||
throw new Error( | ||
`[React] Unexpected call to custom hook or component from a React Forget compiled function. ` + | ||
`[React] Unexpected call to custom hook or component from a React compiled function. ` + | ||
"Check that (1) all hooks are called directly and named according to convention ('use[A-Z]') " + | ||
@@ -168,3 +168,3 @@ 'and (2) components are returned as JSX instead of being directly invoked.', | ||
throw new Error( | ||
'React Forget internal error: unexpected null in guard stack', | ||
'React Compiler internal error: unexpected null in guard stack', | ||
); | ||
@@ -185,3 +185,3 @@ } | ||
throw new Error( | ||
'React Forget internal error: unexpected null in guard stack', | ||
'React Compiler internal error: unexpected null in guard stack', | ||
); | ||
@@ -191,3 +191,3 @@ } | ||
} else { | ||
throw new Error('Forget internal error: unreachable block' + kind); | ||
throw new Error('React Compiler internal error: unreachable block' + kind); | ||
} | ||
@@ -194,0 +194,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39791