usegamigameapi 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ Your code should look like:
|
|
|
10
10
|
1. You might have mismatching versions of React and the renderer (such as React DOM)
|
|
11
11
|
2. You might be breaking the Rules of Hooks
|
|
12
12
|
3. You might have more than one copy of React in the same app
|
|
13
|
-
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),e}function q(){d.asyncTransitions--}function H(e){if(Z===null)try{var n=("require"+Math.random()).slice(0,7);Z=(ne&&ne[n]).call(ne,"timers").setImmediate}catch(o){Z=function(u){qe===!1&&(qe=!0,typeof MessageChannel=="undefined"&&console.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 a=new MessageChannel;a.port1.onmessage=u,a.port2.postMessage(void 0)}}return Z(e)}function S(e){return 1<e.length&&typeof AggregateError=="function"?new AggregateError(e):e[0]}function L(e,n){n!==V-1&&console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),V=n}function ie(e,n,o){var u=d.actQueue;if(u!==null)if(u.length!==0)try{ae(u),H(function(){return ie(e,n,o)});return}catch(a){d.thrownErrors.push(a)}else d.actQueue=null;0<d.thrownErrors.length?(u=S(d.thrownErrors),d.thrownErrors.length=0,o(u)):n(e)}function ae(e){if(!ye){ye=!0;var n=0;try{for(;n<e.length;n++){var o=e[n];do{d.didUsePromise=!1;var u=o(!1);if(u!==null){if(d.didUsePromise){e[n]=o,e.splice(0,n);return}o=u}else break}while(!0)}e.length=0}catch(a){e.splice(0,n+1),d.thrownErrors.push(a)}finally{ye=!1}}}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var ce=Symbol.for("react.transitional.element"),Se=Symbol.for("react.portal"),fe=Symbol.for("react.fragment"),be=Symbol.for("react.strict_mode"),Ce=Symbol.for("react.profiler"),le=Symbol.for("react.consumer"),Ae=Symbol.for("react.context"),ke=Symbol.for("react.forward_ref"),Pe=Symbol.for("react.suspense"),st=Symbol.for("react.suspense_list"),pe=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),Ne=Symbol.for("react.activity"),je=Symbol.iterator,Le={},Me={isMounted:function(){return!1},enqueueForceUpdate:function(e){s(e,"forceUpdate")},enqueueReplaceState:function(e){s(e,"replaceState")},enqueueSetState:function(e){s(e,"setState")}},$e=Object.assign,de={};Object.freeze(de),i.prototype.isReactComponent={},i.prototype.setState=function(e,n){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,n,"setState")},i.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};var O={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)."]};for(G in O)O.hasOwnProperty(G)&&t(G,O[G]);c.prototype=i.prototype,O=y.prototype=new c,O.constructor=y,$e(O,i.prototype),O.isPureReactComponent=!0;var Ie=Array.isArray,it=Symbol.for("react.client.reference"),d={H:null,A:null,T:null,S:null,actQueue:null,asyncTransitions:0,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1,didUsePromise:!1,thrownErrors:[],getCurrentStack:null,recentlyCreatedOwnerStacks:0},F=Object.prototype.hasOwnProperty,De=console.createTask?console.createTask:function(){return null};O={react_stack_bottom_frame:function(e){return e()}};var He,Ue,Ye={},at=O.react_stack_bottom_frame.bind(O,W)(),ct=De(B(W)),xe=!1,We=/\/+/g,ze=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},qe=!1,Z=null,V=0,J=!1,ye=!1,Qe=typeof queueMicrotask=="function"?function(e){queueMicrotask(function(){return queueMicrotask(e)})}:H;O=Object.freeze({__proto__:null,c:function(e){return m().useMemoCache(e)}});var G={map:D,forEach:function(e,n,o){D(e,function(){n.apply(this,arguments)},o)},count:function(e){var n=0;return D(e,function(){n++}),n},toArray:function(e){return D(e,function(n){return n})||[]},only:function(e){if(!C(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};f.Activity=Ne,f.Children=G,f.Component=i,f.Fragment=fe,f.Profiler=Ce,f.PureComponent=y,f.StrictMode=be,f.Suspense=Pe,f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=d,f.__COMPILER_RUNTIME=O,f.act=function(e){var n=d.actQueue,o=V;V++;var u=d.actQueue=n!==null?n:[],a=!1;try{var _=e()}catch(E){d.thrownErrors.push(E)}if(0<d.thrownErrors.length)throw L(n,o),e=S(d.thrownErrors),d.thrownErrors.length=0,e;if(_!==null&&typeof _=="object"&&typeof _.then=="function"){var p=_;return Qe(function(){a||J||(J=!0,console.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 () => ...);"))}),{then:function(E,k){a=!0,p.then(function(U){if(L(n,o),o===0){try{ae(u),H(function(){return ie(U,E,k)})}catch(lt){d.thrownErrors.push(lt)}if(0<d.thrownErrors.length){var ft=S(d.thrownErrors);d.thrownErrors.length=0,k(ft)}}else E(U)},function(U){L(n,o),0<d.thrownErrors.length&&(U=S(d.thrownErrors),d.thrownErrors.length=0),k(U)})}}}var v=_;if(L(n,o),o===0&&(ae(u),u.length!==0&&Qe(function(){a||J||(J=!0,console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"))}),d.actQueue=null),0<d.thrownErrors.length)throw e=S(d.thrownErrors),d.thrownErrors.length=0,e;return{then:function(E,k){a=!0,o===0?(d.actQueue=u,H(function(){return ie(v,E,k)})):E(v)}}},f.cache=function(e){return function(){return e.apply(null,arguments)}},f.cacheSignal=function(){return null},f.captureOwnerStack=function(){var e=d.getCurrentStack;return e===null?null:e()},f.cloneElement=function(e,n,o){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var u=$e({},e.props),a=e.key,_=e._owner;if(n!=null){var p;e:{if(F.call(n,"ref")&&(p=Object.getOwnPropertyDescriptor(n,"ref").get)&&p.isReactWarning){p=!1;break e}p=n.ref!==void 0}p&&(_=K()),X(n)&&(R(n.key),a=""+n.key);for(v in n)!F.call(n,v)||v==="key"||v==="__self"||v==="__source"||v==="ref"&&n.ref===void 0||(u[v]=n[v])}var v=arguments.length-2;if(v===1)u.children=o;else if(1<v){p=Array(v);for(var E=0;E<v;E++)p[E]=arguments[E+2];u.children=p}for(u=N(e.type,a,u,_,e._debugStack,e._debugTask),a=2;a<arguments.length;a++)z(arguments[a]);return u},f.createContext=function(e){return e={$$typeof:Ae,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:le,_context:e},e._currentRenderer=null,e._currentRenderer2=null,e},f.createElement=function(e,n,o){for(var u=2;u<arguments.length;u++)z(arguments[u]);u={};var a=null;if(n!=null)for(E in Ue||!("__self"in n)||"key"in n||(Ue=!0,console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")),X(n)&&(R(n.key),a=""+n.key),n)F.call(n,E)&&E!=="key"&&E!=="__self"&&E!=="__source"&&(u[E]=n[E]);var _=arguments.length-2;if(_===1)u.children=o;else if(1<_){for(var p=Array(_),v=0;v<_;v++)p[v]=arguments[v+2];Object.freeze&&Object.freeze(p),u.children=p}if(e&&e.defaultProps)for(E in _=e.defaultProps,_)u[E]===void 0&&(u[E]=_[E]);a&&re(u,typeof e=="function"?e.displayName||e.name||"Unknown":e);var E=1e4>d.recentlyCreatedOwnerStacks++;return N(e,a,u,K(),E?Error("react-stack-top-frame"):at,E?De(B(e)):ct)},f.createRef=function(){var e={current:null};return Object.seal(e),e},f.forwardRef=function(e){e!=null&&e.$$typeof===pe?console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):typeof e!="function"?console.error("forwardRef requires a render function but was given %s.",e===null?"null":typeof e):e.length!==0&&e.length!==2&&console.error("forwardRef render functions accept exactly two parameters: props and ref. %s",e.length===1?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),e!=null&&e.defaultProps!=null&&console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");var n={$$typeof:ke,render:e},o;return Object.defineProperty(n,"displayName",{enumerable:!1,configurable:!0,get:function(){return o},set:function(u){o=u,e.name||e.displayName||(Object.defineProperty(e,"name",{value:u}),e.displayName=u)}}),n},f.isValidElement=C,f.lazy=function(e){e={_status:-1,_result:e};var n={$$typeof:Q,_payload:e,_init:se},o={name:"lazy",start:-1,end:-1,value:null,owner:null,debugStack:Error("react-stack-top-frame"),debugTask:console.createTask?console.createTask("lazy()"):null};return e._ioInfo=o,n._debugInfo=[{awaited:o}],n},f.memo=function(e,n){e==null&&console.error("memo: The first argument must be a component. Instead received: %s",e===null?"null":typeof e),n={$$typeof:pe,type:e,compare:n===void 0?null:n};var o;return Object.defineProperty(n,"displayName",{enumerable:!1,configurable:!0,get:function(){return o},set:function(u){o=u,e.name||e.displayName||(Object.defineProperty(e,"name",{value:u}),e.displayName=u)}}),n},f.startTransition=function(e){var n=d.T,o={};o._updatedFibers=new Set,d.T=o;try{var u=e(),a=d.S;a!==null&&a(o,u),typeof u=="object"&&u!==null&&typeof u.then=="function"&&(d.asyncTransitions++,u.then(q,q),u.then(h,ze))}catch(_){ze(_)}finally{n===null&&o._updatedFibers&&(e=o._updatedFibers.size,o._updatedFibers.clear(),10<e&&console.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.")),n!==null&&o.types!==null&&(n.types!==null&&n.types!==o.types&&console.error("We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."),n.types=o.types),d.T=n}},f.unstable_useCacheRefresh=function(){return m().useCacheRefresh()},f.use=function(e){return m().use(e)},f.useActionState=function(e,n,o){return m().useActionState(e,n,o)},f.useCallback=function(e,n){return m().useCallback(e,n)},f.useContext=function(e){var n=m();return e.$$typeof===le&&console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"),n.useContext(e)},f.useDebugValue=function(e,n){return m().useDebugValue(e,n)},f.useDeferredValue=function(e,n){return m().useDeferredValue(e,n)},f.useEffect=function(e,n){return e==null&&console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"),m().useEffect(e,n)},f.useEffectEvent=function(e){return m().useEffectEvent(e)},f.useId=function(){return m().useId()},f.useImperativeHandle=function(e,n,o){return m().useImperativeHandle(e,n,o)},f.useInsertionEffect=function(e,n){return e==null&&console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"),m().useInsertionEffect(e,n)},f.useLayoutEffect=function(e,n){return e==null&&console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"),m().useLayoutEffect(e,n)},f.useMemo=function(e,n){return m().useMemo(e,n)},f.useOptimistic=function(e,n){return m().useOptimistic(e,n)},f.useReducer=function(e,n,o){return m().useReducer(e,n,o)},f.useRef=function(e){return m().useRef(e)},f.useState=function(e){return m().useState(e)},f.useSyncExternalStore=function(e,n,o){return m().useSyncExternalStore(e,n,o)},f.useTransition=function(){return m().useTransition()},f.version="19.2.3",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var ut=_e((Yt,Te)=>{"use strict";process.env.NODE_ENV==="production"?Te.exports=rt():Te.exports=ot()});var Dt={};mt(Dt,{useGameAPI:()=>It});module.exports=vt(Dt);var w=ht(ut());var M={SHOW_LO5:"SHOW_LO5",RETURN_LO5:"RETURN_LO5",UPDATE_ANSWER:"UPDATE_ANSWER",RETURN_UPDATE_ANSWER:"RETURN_UPDATE_ANSWER",FINISH:"FINISH"},Oe=class{constructor(){this.handlers={};window.addEventListener("message",this.handleMessage.bind(this))}handleMessage(r){let{type:s,payload:i}=r.data;this.handlers[s]&&this.handlers[s](i)}on(r,s){this.handlers[r]=s}send(r,s={}){window.parent&&window.parent.postMessage({type:r,payload:s},"*")}},$=new Oe;console.log("useGameAPI-V1.0.6");function It({onAnswerCorrect:t,onAnswerIncorrect:r}){let[s,i]=(0,w.useState)(0),c=(0,w.useRef)(0),[y,h]=(0,w.useState)(null),[T,R]=(0,w.useState)([]),[b,B]=(0,w.useState)(null),[K,W]=(0,w.useState)(null),[X,re]=(0,w.useState)(0),[P,N]=(0,w.useState)(!1),[j,z]=(0,w.useState)(!1),[C,oe]=(0,w.useState)(!1),I=(0,w.useRef)(!1),ue=(0,w.useCallback)(()=>{$.send(M.FINISH)},[]),A=(0,w.useCallback)(async()=>{if(!(!y||P))return $.send(M.UPDATE_ANSWER,y.id),N(!0),z(!0),Promise.resolve()},[y,P]),D=(0,w.useCallback)(()=>{if(j)if(I.current)oe(!0);else{$.send(M.SHOW_LO5);let m=c.current+1;c.current=m,i(m),h(null),N(!1),z(!1),W(null)}},[j]),se=(0,w.useCallback)(m=>{!P&&!j&&h(m)},[P,j]);return(0,w.useEffect)(()=>{$.send(M.SHOW_LO5),$.on(M.RETURN_LO5,m=>{B(m)}),$.on(M.RETURN_UPDATE_ANSWER,m=>{let q=(m==null?void 0:m.isCorrect)===!0,H=(m==null?void 0:m.isLastQuestion)===!0;I.current=H,R(S=>{let L=[...S];return L[c.current]=q,L}),q?(re(S=>S+1),console.log({currentQuestionIndex:c.current}),t==null||t({currentQuestionIndex:c.current})):r==null||r(),N(!1),W(m)})},[]),{quiz:b,currentResult:K,answers:T,correctCount:X,currentQuestionIndex:s,selectedAnswer:y,isSubmitting:P,hasSubmitted:j,isCompleted:C,handleAnswerSelect:se,updateAnswer:A,handleContinue:D,finish:ue}}0&&(module.exports={useGameAPI});
|
|
13
|
+
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),e}function q(){d.asyncTransitions--}function H(e){if(Z===null)try{var n=("require"+Math.random()).slice(0,7);Z=(ne&&ne[n]).call(ne,"timers").setImmediate}catch(o){Z=function(u){qe===!1&&(qe=!0,typeof MessageChannel=="undefined"&&console.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 a=new MessageChannel;a.port1.onmessage=u,a.port2.postMessage(void 0)}}return Z(e)}function S(e){return 1<e.length&&typeof AggregateError=="function"?new AggregateError(e):e[0]}function L(e,n){n!==V-1&&console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),V=n}function ie(e,n,o){var u=d.actQueue;if(u!==null)if(u.length!==0)try{ae(u),H(function(){return ie(e,n,o)});return}catch(a){d.thrownErrors.push(a)}else d.actQueue=null;0<d.thrownErrors.length?(u=S(d.thrownErrors),d.thrownErrors.length=0,o(u)):n(e)}function ae(e){if(!ye){ye=!0;var n=0;try{for(;n<e.length;n++){var o=e[n];do{d.didUsePromise=!1;var u=o(!1);if(u!==null){if(d.didUsePromise){e[n]=o,e.splice(0,n);return}o=u}else break}while(!0)}e.length=0}catch(a){e.splice(0,n+1),d.thrownErrors.push(a)}finally{ye=!1}}}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var ce=Symbol.for("react.transitional.element"),Se=Symbol.for("react.portal"),fe=Symbol.for("react.fragment"),be=Symbol.for("react.strict_mode"),Ce=Symbol.for("react.profiler"),le=Symbol.for("react.consumer"),Ae=Symbol.for("react.context"),ke=Symbol.for("react.forward_ref"),Pe=Symbol.for("react.suspense"),st=Symbol.for("react.suspense_list"),pe=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),Ne=Symbol.for("react.activity"),je=Symbol.iterator,Le={},Me={isMounted:function(){return!1},enqueueForceUpdate:function(e){s(e,"forceUpdate")},enqueueReplaceState:function(e){s(e,"replaceState")},enqueueSetState:function(e){s(e,"setState")}},$e=Object.assign,de={};Object.freeze(de),i.prototype.isReactComponent={},i.prototype.setState=function(e,n){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,n,"setState")},i.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};var O={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)."]};for(G in O)O.hasOwnProperty(G)&&t(G,O[G]);c.prototype=i.prototype,O=y.prototype=new c,O.constructor=y,$e(O,i.prototype),O.isPureReactComponent=!0;var Ie=Array.isArray,it=Symbol.for("react.client.reference"),d={H:null,A:null,T:null,S:null,actQueue:null,asyncTransitions:0,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1,didUsePromise:!1,thrownErrors:[],getCurrentStack:null,recentlyCreatedOwnerStacks:0},F=Object.prototype.hasOwnProperty,De=console.createTask?console.createTask:function(){return null};O={react_stack_bottom_frame:function(e){return e()}};var He,Ue,Ye={},at=O.react_stack_bottom_frame.bind(O,W)(),ct=De(B(W)),xe=!1,We=/\/+/g,ze=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},qe=!1,Z=null,V=0,J=!1,ye=!1,Qe=typeof queueMicrotask=="function"?function(e){queueMicrotask(function(){return queueMicrotask(e)})}:H;O=Object.freeze({__proto__:null,c:function(e){return m().useMemoCache(e)}});var G={map:D,forEach:function(e,n,o){D(e,function(){n.apply(this,arguments)},o)},count:function(e){var n=0;return D(e,function(){n++}),n},toArray:function(e){return D(e,function(n){return n})||[]},only:function(e){if(!C(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};f.Activity=Ne,f.Children=G,f.Component=i,f.Fragment=fe,f.Profiler=Ce,f.PureComponent=y,f.StrictMode=be,f.Suspense=Pe,f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=d,f.__COMPILER_RUNTIME=O,f.act=function(e){var n=d.actQueue,o=V;V++;var u=d.actQueue=n!==null?n:[],a=!1;try{var _=e()}catch(E){d.thrownErrors.push(E)}if(0<d.thrownErrors.length)throw L(n,o),e=S(d.thrownErrors),d.thrownErrors.length=0,e;if(_!==null&&typeof _=="object"&&typeof _.then=="function"){var p=_;return Qe(function(){a||J||(J=!0,console.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 () => ...);"))}),{then:function(E,k){a=!0,p.then(function(U){if(L(n,o),o===0){try{ae(u),H(function(){return ie(U,E,k)})}catch(lt){d.thrownErrors.push(lt)}if(0<d.thrownErrors.length){var ft=S(d.thrownErrors);d.thrownErrors.length=0,k(ft)}}else E(U)},function(U){L(n,o),0<d.thrownErrors.length&&(U=S(d.thrownErrors),d.thrownErrors.length=0),k(U)})}}}var v=_;if(L(n,o),o===0&&(ae(u),u.length!==0&&Qe(function(){a||J||(J=!0,console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"))}),d.actQueue=null),0<d.thrownErrors.length)throw e=S(d.thrownErrors),d.thrownErrors.length=0,e;return{then:function(E,k){a=!0,o===0?(d.actQueue=u,H(function(){return ie(v,E,k)})):E(v)}}},f.cache=function(e){return function(){return e.apply(null,arguments)}},f.cacheSignal=function(){return null},f.captureOwnerStack=function(){var e=d.getCurrentStack;return e===null?null:e()},f.cloneElement=function(e,n,o){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var u=$e({},e.props),a=e.key,_=e._owner;if(n!=null){var p;e:{if(F.call(n,"ref")&&(p=Object.getOwnPropertyDescriptor(n,"ref").get)&&p.isReactWarning){p=!1;break e}p=n.ref!==void 0}p&&(_=K()),X(n)&&(R(n.key),a=""+n.key);for(v in n)!F.call(n,v)||v==="key"||v==="__self"||v==="__source"||v==="ref"&&n.ref===void 0||(u[v]=n[v])}var v=arguments.length-2;if(v===1)u.children=o;else if(1<v){p=Array(v);for(var E=0;E<v;E++)p[E]=arguments[E+2];u.children=p}for(u=N(e.type,a,u,_,e._debugStack,e._debugTask),a=2;a<arguments.length;a++)z(arguments[a]);return u},f.createContext=function(e){return e={$$typeof:Ae,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:le,_context:e},e._currentRenderer=null,e._currentRenderer2=null,e},f.createElement=function(e,n,o){for(var u=2;u<arguments.length;u++)z(arguments[u]);u={};var a=null;if(n!=null)for(E in Ue||!("__self"in n)||"key"in n||(Ue=!0,console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")),X(n)&&(R(n.key),a=""+n.key),n)F.call(n,E)&&E!=="key"&&E!=="__self"&&E!=="__source"&&(u[E]=n[E]);var _=arguments.length-2;if(_===1)u.children=o;else if(1<_){for(var p=Array(_),v=0;v<_;v++)p[v]=arguments[v+2];Object.freeze&&Object.freeze(p),u.children=p}if(e&&e.defaultProps)for(E in _=e.defaultProps,_)u[E]===void 0&&(u[E]=_[E]);a&&re(u,typeof e=="function"?e.displayName||e.name||"Unknown":e);var E=1e4>d.recentlyCreatedOwnerStacks++;return N(e,a,u,K(),E?Error("react-stack-top-frame"):at,E?De(B(e)):ct)},f.createRef=function(){var e={current:null};return Object.seal(e),e},f.forwardRef=function(e){e!=null&&e.$$typeof===pe?console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):typeof e!="function"?console.error("forwardRef requires a render function but was given %s.",e===null?"null":typeof e):e.length!==0&&e.length!==2&&console.error("forwardRef render functions accept exactly two parameters: props and ref. %s",e.length===1?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),e!=null&&e.defaultProps!=null&&console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");var n={$$typeof:ke,render:e},o;return Object.defineProperty(n,"displayName",{enumerable:!1,configurable:!0,get:function(){return o},set:function(u){o=u,e.name||e.displayName||(Object.defineProperty(e,"name",{value:u}),e.displayName=u)}}),n},f.isValidElement=C,f.lazy=function(e){e={_status:-1,_result:e};var n={$$typeof:Q,_payload:e,_init:se},o={name:"lazy",start:-1,end:-1,value:null,owner:null,debugStack:Error("react-stack-top-frame"),debugTask:console.createTask?console.createTask("lazy()"):null};return e._ioInfo=o,n._debugInfo=[{awaited:o}],n},f.memo=function(e,n){e==null&&console.error("memo: The first argument must be a component. Instead received: %s",e===null?"null":typeof e),n={$$typeof:pe,type:e,compare:n===void 0?null:n};var o;return Object.defineProperty(n,"displayName",{enumerable:!1,configurable:!0,get:function(){return o},set:function(u){o=u,e.name||e.displayName||(Object.defineProperty(e,"name",{value:u}),e.displayName=u)}}),n},f.startTransition=function(e){var n=d.T,o={};o._updatedFibers=new Set,d.T=o;try{var u=e(),a=d.S;a!==null&&a(o,u),typeof u=="object"&&u!==null&&typeof u.then=="function"&&(d.asyncTransitions++,u.then(q,q),u.then(h,ze))}catch(_){ze(_)}finally{n===null&&o._updatedFibers&&(e=o._updatedFibers.size,o._updatedFibers.clear(),10<e&&console.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.")),n!==null&&o.types!==null&&(n.types!==null&&n.types!==o.types&&console.error("We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."),n.types=o.types),d.T=n}},f.unstable_useCacheRefresh=function(){return m().useCacheRefresh()},f.use=function(e){return m().use(e)},f.useActionState=function(e,n,o){return m().useActionState(e,n,o)},f.useCallback=function(e,n){return m().useCallback(e,n)},f.useContext=function(e){var n=m();return e.$$typeof===le&&console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"),n.useContext(e)},f.useDebugValue=function(e,n){return m().useDebugValue(e,n)},f.useDeferredValue=function(e,n){return m().useDeferredValue(e,n)},f.useEffect=function(e,n){return e==null&&console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"),m().useEffect(e,n)},f.useEffectEvent=function(e){return m().useEffectEvent(e)},f.useId=function(){return m().useId()},f.useImperativeHandle=function(e,n,o){return m().useImperativeHandle(e,n,o)},f.useInsertionEffect=function(e,n){return e==null&&console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"),m().useInsertionEffect(e,n)},f.useLayoutEffect=function(e,n){return e==null&&console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"),m().useLayoutEffect(e,n)},f.useMemo=function(e,n){return m().useMemo(e,n)},f.useOptimistic=function(e,n){return m().useOptimistic(e,n)},f.useReducer=function(e,n,o){return m().useReducer(e,n,o)},f.useRef=function(e){return m().useRef(e)},f.useState=function(e){return m().useState(e)},f.useSyncExternalStore=function(e,n,o){return m().useSyncExternalStore(e,n,o)},f.useTransition=function(){return m().useTransition()},f.version="19.2.3",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var ut=_e((Yt,Te)=>{"use strict";process.env.NODE_ENV==="production"?Te.exports=rt():Te.exports=ot()});var Dt={};mt(Dt,{useGameAPI:()=>It});module.exports=vt(Dt);var w=ht(ut());var M={SHOW_LO5:"SHOW_LO5",RETURN_LO5:"RETURN_LO5",UPDATE_ANSWER:"UPDATE_ANSWER",RETURN_UPDATE_ANSWER:"RETURN_UPDATE_ANSWER",FINISH:"FINISH"},Oe=class{constructor(){this.handlers={};window.addEventListener("message",this.handleMessage.bind(this))}handleMessage(r){let{type:s,payload:i}=r.data;this.handlers[s]&&this.handlers[s](i)}on(r,s){this.handlers[r]=s}send(r,s={}){window.parent&&window.parent.postMessage({type:r,payload:s},"*")}},$=new Oe;console.log("useGameAPI-V1.0.10");function It({onAnswerCorrect:t,onAnswerIncorrect:r}){let[s,i]=(0,w.useState)(0),c=(0,w.useRef)(0),[y,h]=(0,w.useState)(null),[T,R]=(0,w.useState)([]),[b,B]=(0,w.useState)(null),[K,W]=(0,w.useState)(null),[X,re]=(0,w.useState)(0),[P,N]=(0,w.useState)(!1),[j,z]=(0,w.useState)(!1),[C,oe]=(0,w.useState)(!1),I=(0,w.useRef)(!1),ue=(0,w.useCallback)(()=>{$.send(M.FINISH)},[]),A=(0,w.useCallback)(async()=>{if(!(!y||P))return $.send(M.UPDATE_ANSWER,y.id),N(!0),z(!0),Promise.resolve()},[y,P]),D=(0,w.useCallback)(()=>{if(j)if(I.current)oe(!0);else{$.send(M.SHOW_LO5);let m=c.current+1;c.current=m,i(m),h(null),N(!1),z(!1),W(null)}},[j]),se=(0,w.useCallback)(m=>{!P&&!j&&h(m)},[P,j]);return(0,w.useEffect)(()=>{$.send(M.SHOW_LO5),$.on(M.RETURN_LO5,m=>{B(m)}),$.on(M.RETURN_UPDATE_ANSWER,m=>{let q=(m==null?void 0:m.isCorrect)===!0,H=(m==null?void 0:m.isLastQuestion)===!0;I.current=H,R(S=>{let L=[...S];return L[c.current]=q,L}),q?(re(S=>S+1),console.log({currentQuestionIndex:c.current}),t==null||t({currentQuestionIndex:c.current})):r==null||r(),N(!1),W(m)})},[]),{quiz:b,currentResult:K,answers:T,correctCount:X,currentQuestionIndex:s,selectedAnswer:y,isSubmitting:P,hasSubmitted:j,isCompleted:C,handleAnswerSelect:se,updateAnswer:A,handleContinue:D,finish:ue}}0&&(module.exports={useGameAPI});
|
|
14
14
|
/*! Bundled license information:
|
|
15
15
|
|
|
16
16
|
react/cjs/react.production.js:
|
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ Your code should look like:
|
|
|
10
10
|
1. You might have mismatching versions of React and the renderer (such as React DOM)
|
|
11
11
|
2. You might be breaking the Rules of Hooks
|
|
12
12
|
3. You might have more than one copy of React in the same app
|
|
13
|
-
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),e}function q(){d.asyncTransitions--}function H(e){if(Z===null)try{var n=("require"+Math.random()).slice(0,7);Z=(te&&te[n]).call(te,"timers").setImmediate}catch(o){Z=function(u){ze===!1&&(ze=!0,typeof MessageChannel=="undefined"&&console.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 a=new MessageChannel;a.port1.onmessage=u,a.port2.postMessage(void 0)}}return Z(e)}function S(e){return 1<e.length&&typeof AggregateError=="function"?new AggregateError(e):e[0]}function L(e,n){n!==V-1&&console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),V=n}function se(e,n,o){var u=d.actQueue;if(u!==null)if(u.length!==0)try{ie(u),H(function(){return se(e,n,o)});return}catch(a){d.thrownErrors.push(a)}else d.actQueue=null;0<d.thrownErrors.length?(u=S(d.thrownErrors),d.thrownErrors.length=0,o(u)):n(e)}function ie(e){if(!de){de=!0;var n=0;try{for(;n<e.length;n++){var o=e[n];do{d.didUsePromise=!1;var u=o(!1);if(u!==null){if(d.didUsePromise){e[n]=o,e.splice(0,n);return}o=u}else break}while(!0)}e.length=0}catch(a){e.splice(0,n+1),d.thrownErrors.push(a)}finally{de=!1}}}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var ae=Symbol.for("react.transitional.element"),Oe=Symbol.for("react.portal"),ce=Symbol.for("react.fragment"),Se=Symbol.for("react.strict_mode"),be=Symbol.for("react.profiler"),fe=Symbol.for("react.consumer"),Ce=Symbol.for("react.context"),Ae=Symbol.for("react.forward_ref"),ke=Symbol.for("react.suspense"),ut=Symbol.for("react.suspense_list"),le=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),Pe=Symbol.for("react.activity"),Ne=Symbol.iterator,je={},Le={isMounted:function(){return!1},enqueueForceUpdate:function(e){s(e,"forceUpdate")},enqueueReplaceState:function(e){s(e,"replaceState")},enqueueSetState:function(e){s(e,"setState")}},Me=Object.assign,pe={};Object.freeze(pe),i.prototype.isReactComponent={},i.prototype.setState=function(e,n){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,n,"setState")},i.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};var O={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)."]};for(G in O)O.hasOwnProperty(G)&&t(G,O[G]);c.prototype=i.prototype,O=y.prototype=new c,O.constructor=y,Me(O,i.prototype),O.isPureReactComponent=!0;var $e=Array.isArray,st=Symbol.for("react.client.reference"),d={H:null,A:null,T:null,S:null,actQueue:null,asyncTransitions:0,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1,didUsePromise:!1,thrownErrors:[],getCurrentStack:null,recentlyCreatedOwnerStacks:0},F=Object.prototype.hasOwnProperty,Ie=console.createTask?console.createTask:function(){return null};O={react_stack_bottom_frame:function(e){return e()}};var De,He,Ue={},it=O.react_stack_bottom_frame.bind(O,W)(),at=Ie(B(W)),Ye=!1,xe=/\/+/g,We=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},ze=!1,Z=null,V=0,J=!1,de=!1,qe=typeof queueMicrotask=="function"?function(e){queueMicrotask(function(){return queueMicrotask(e)})}:H;O=Object.freeze({__proto__:null,c:function(e){return m().useMemoCache(e)}});var G={map:D,forEach:function(e,n,o){D(e,function(){n.apply(this,arguments)},o)},count:function(e){var n=0;return D(e,function(){n++}),n},toArray:function(e){return D(e,function(n){return n})||[]},only:function(e){if(!C(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};f.Activity=Pe,f.Children=G,f.Component=i,f.Fragment=ce,f.Profiler=be,f.PureComponent=y,f.StrictMode=Se,f.Suspense=ke,f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=d,f.__COMPILER_RUNTIME=O,f.act=function(e){var n=d.actQueue,o=V;V++;var u=d.actQueue=n!==null?n:[],a=!1;try{var _=e()}catch(E){d.thrownErrors.push(E)}if(0<d.thrownErrors.length)throw L(n,o),e=S(d.thrownErrors),d.thrownErrors.length=0,e;if(_!==null&&typeof _=="object"&&typeof _.then=="function"){var p=_;return qe(function(){a||J||(J=!0,console.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 () => ...);"))}),{then:function(E,k){a=!0,p.then(function(U){if(L(n,o),o===0){try{ie(u),H(function(){return se(U,E,k)})}catch(ft){d.thrownErrors.push(ft)}if(0<d.thrownErrors.length){var ct=S(d.thrownErrors);d.thrownErrors.length=0,k(ct)}}else E(U)},function(U){L(n,o),0<d.thrownErrors.length&&(U=S(d.thrownErrors),d.thrownErrors.length=0),k(U)})}}}var v=_;if(L(n,o),o===0&&(ie(u),u.length!==0&&qe(function(){a||J||(J=!0,console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"))}),d.actQueue=null),0<d.thrownErrors.length)throw e=S(d.thrownErrors),d.thrownErrors.length=0,e;return{then:function(E,k){a=!0,o===0?(d.actQueue=u,H(function(){return se(v,E,k)})):E(v)}}},f.cache=function(e){return function(){return e.apply(null,arguments)}},f.cacheSignal=function(){return null},f.captureOwnerStack=function(){var e=d.getCurrentStack;return e===null?null:e()},f.cloneElement=function(e,n,o){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var u=Me({},e.props),a=e.key,_=e._owner;if(n!=null){var p;e:{if(F.call(n,"ref")&&(p=Object.getOwnPropertyDescriptor(n,"ref").get)&&p.isReactWarning){p=!1;break e}p=n.ref!==void 0}p&&(_=K()),X(n)&&(R(n.key),a=""+n.key);for(v in n)!F.call(n,v)||v==="key"||v==="__self"||v==="__source"||v==="ref"&&n.ref===void 0||(u[v]=n[v])}var v=arguments.length-2;if(v===1)u.children=o;else if(1<v){p=Array(v);for(var E=0;E<v;E++)p[E]=arguments[E+2];u.children=p}for(u=N(e.type,a,u,_,e._debugStack,e._debugTask),a=2;a<arguments.length;a++)z(arguments[a]);return u},f.createContext=function(e){return e={$$typeof:Ce,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:fe,_context:e},e._currentRenderer=null,e._currentRenderer2=null,e},f.createElement=function(e,n,o){for(var u=2;u<arguments.length;u++)z(arguments[u]);u={};var a=null;if(n!=null)for(E in He||!("__self"in n)||"key"in n||(He=!0,console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")),X(n)&&(R(n.key),a=""+n.key),n)F.call(n,E)&&E!=="key"&&E!=="__self"&&E!=="__source"&&(u[E]=n[E]);var _=arguments.length-2;if(_===1)u.children=o;else if(1<_){for(var p=Array(_),v=0;v<_;v++)p[v]=arguments[v+2];Object.freeze&&Object.freeze(p),u.children=p}if(e&&e.defaultProps)for(E in _=e.defaultProps,_)u[E]===void 0&&(u[E]=_[E]);a&&ne(u,typeof e=="function"?e.displayName||e.name||"Unknown":e);var E=1e4>d.recentlyCreatedOwnerStacks++;return N(e,a,u,K(),E?Error("react-stack-top-frame"):it,E?Ie(B(e)):at)},f.createRef=function(){var e={current:null};return Object.seal(e),e},f.forwardRef=function(e){e!=null&&e.$$typeof===le?console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):typeof e!="function"?console.error("forwardRef requires a render function but was given %s.",e===null?"null":typeof e):e.length!==0&&e.length!==2&&console.error("forwardRef render functions accept exactly two parameters: props and ref. %s",e.length===1?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),e!=null&&e.defaultProps!=null&&console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");var n={$$typeof:Ae,render:e},o;return Object.defineProperty(n,"displayName",{enumerable:!1,configurable:!0,get:function(){return o},set:function(u){o=u,e.name||e.displayName||(Object.defineProperty(e,"name",{value:u}),e.displayName=u)}}),n},f.isValidElement=C,f.lazy=function(e){e={_status:-1,_result:e};var n={$$typeof:Q,_payload:e,_init:ue},o={name:"lazy",start:-1,end:-1,value:null,owner:null,debugStack:Error("react-stack-top-frame"),debugTask:console.createTask?console.createTask("lazy()"):null};return e._ioInfo=o,n._debugInfo=[{awaited:o}],n},f.memo=function(e,n){e==null&&console.error("memo: The first argument must be a component. Instead received: %s",e===null?"null":typeof e),n={$$typeof:le,type:e,compare:n===void 0?null:n};var o;return Object.defineProperty(n,"displayName",{enumerable:!1,configurable:!0,get:function(){return o},set:function(u){o=u,e.name||e.displayName||(Object.defineProperty(e,"name",{value:u}),e.displayName=u)}}),n},f.startTransition=function(e){var n=d.T,o={};o._updatedFibers=new Set,d.T=o;try{var u=e(),a=d.S;a!==null&&a(o,u),typeof u=="object"&&u!==null&&typeof u.then=="function"&&(d.asyncTransitions++,u.then(q,q),u.then(h,We))}catch(_){We(_)}finally{n===null&&o._updatedFibers&&(e=o._updatedFibers.size,o._updatedFibers.clear(),10<e&&console.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.")),n!==null&&o.types!==null&&(n.types!==null&&n.types!==o.types&&console.error("We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."),n.types=o.types),d.T=n}},f.unstable_useCacheRefresh=function(){return m().useCacheRefresh()},f.use=function(e){return m().use(e)},f.useActionState=function(e,n,o){return m().useActionState(e,n,o)},f.useCallback=function(e,n){return m().useCallback(e,n)},f.useContext=function(e){var n=m();return e.$$typeof===fe&&console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"),n.useContext(e)},f.useDebugValue=function(e,n){return m().useDebugValue(e,n)},f.useDeferredValue=function(e,n){return m().useDeferredValue(e,n)},f.useEffect=function(e,n){return e==null&&console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"),m().useEffect(e,n)},f.useEffectEvent=function(e){return m().useEffectEvent(e)},f.useId=function(){return m().useId()},f.useImperativeHandle=function(e,n,o){return m().useImperativeHandle(e,n,o)},f.useInsertionEffect=function(e,n){return e==null&&console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"),m().useInsertionEffect(e,n)},f.useLayoutEffect=function(e,n){return e==null&&console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"),m().useLayoutEffect(e,n)},f.useMemo=function(e,n){return m().useMemo(e,n)},f.useOptimistic=function(e,n){return m().useOptimistic(e,n)},f.useReducer=function(e,n,o){return m().useReducer(e,n,o)},f.useRef=function(e){return m().useRef(e)},f.useState=function(e){return m().useState(e)},f.useSyncExternalStore=function(e,n,o){return m().useSyncExternalStore(e,n,o)},f.useTransition=function(){return m().useTransition()},f.version="19.2.3",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var ot=ye((It,we)=>{"use strict";process.env.NODE_ENV==="production"?we.exports=nt():we.exports=rt()});var w=mt(ot());var M={SHOW_LO5:"SHOW_LO5",RETURN_LO5:"RETURN_LO5",UPDATE_ANSWER:"UPDATE_ANSWER",RETURN_UPDATE_ANSWER:"RETURN_UPDATE_ANSWER",FINISH:"FINISH"},Te=class{constructor(){this.handlers={};window.addEventListener("message",this.handleMessage.bind(this))}handleMessage(r){let{type:s,payload:i}=r.data;this.handlers[s]&&this.handlers[s](i)}on(r,s){this.handlers[r]=s}send(r,s={}){window.parent&&window.parent.postMessage({type:r,payload:s},"*")}},$=new Te;console.log("useGameAPI-V1.0.6");function Ut({onAnswerCorrect:t,onAnswerIncorrect:r}){let[s,i]=(0,w.useState)(0),c=(0,w.useRef)(0),[y,h]=(0,w.useState)(null),[T,R]=(0,w.useState)([]),[b,B]=(0,w.useState)(null),[K,W]=(0,w.useState)(null),[X,ne]=(0,w.useState)(0),[P,N]=(0,w.useState)(!1),[j,z]=(0,w.useState)(!1),[C,re]=(0,w.useState)(!1),I=(0,w.useRef)(!1),oe=(0,w.useCallback)(()=>{$.send(M.FINISH)},[]),A=(0,w.useCallback)(async()=>{if(!(!y||P))return $.send(M.UPDATE_ANSWER,y.id),N(!0),z(!0),Promise.resolve()},[y,P]),D=(0,w.useCallback)(()=>{if(j)if(I.current)re(!0);else{$.send(M.SHOW_LO5);let m=c.current+1;c.current=m,i(m),h(null),N(!1),z(!1),W(null)}},[j]),ue=(0,w.useCallback)(m=>{!P&&!j&&h(m)},[P,j]);return(0,w.useEffect)(()=>{$.send(M.SHOW_LO5),$.on(M.RETURN_LO5,m=>{B(m)}),$.on(M.RETURN_UPDATE_ANSWER,m=>{let q=(m==null?void 0:m.isCorrect)===!0,H=(m==null?void 0:m.isLastQuestion)===!0;I.current=H,R(S=>{let L=[...S];return L[c.current]=q,L}),q?(ne(S=>S+1),console.log({currentQuestionIndex:c.current}),t==null||t({currentQuestionIndex:c.current})):r==null||r(),N(!1),W(m)})},[]),{quiz:b,currentResult:K,answers:T,correctCount:X,currentQuestionIndex:s,selectedAnswer:y,isSubmitting:P,hasSubmitted:j,isCompleted:C,handleAnswerSelect:ue,updateAnswer:A,handleContinue:D,finish:oe}}export{Ut as useGameAPI};
|
|
13
|
+
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),e}function q(){d.asyncTransitions--}function H(e){if(Z===null)try{var n=("require"+Math.random()).slice(0,7);Z=(te&&te[n]).call(te,"timers").setImmediate}catch(o){Z=function(u){ze===!1&&(ze=!0,typeof MessageChannel=="undefined"&&console.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 a=new MessageChannel;a.port1.onmessage=u,a.port2.postMessage(void 0)}}return Z(e)}function S(e){return 1<e.length&&typeof AggregateError=="function"?new AggregateError(e):e[0]}function L(e,n){n!==V-1&&console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),V=n}function se(e,n,o){var u=d.actQueue;if(u!==null)if(u.length!==0)try{ie(u),H(function(){return se(e,n,o)});return}catch(a){d.thrownErrors.push(a)}else d.actQueue=null;0<d.thrownErrors.length?(u=S(d.thrownErrors),d.thrownErrors.length=0,o(u)):n(e)}function ie(e){if(!de){de=!0;var n=0;try{for(;n<e.length;n++){var o=e[n];do{d.didUsePromise=!1;var u=o(!1);if(u!==null){if(d.didUsePromise){e[n]=o,e.splice(0,n);return}o=u}else break}while(!0)}e.length=0}catch(a){e.splice(0,n+1),d.thrownErrors.push(a)}finally{de=!1}}}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var ae=Symbol.for("react.transitional.element"),Oe=Symbol.for("react.portal"),ce=Symbol.for("react.fragment"),Se=Symbol.for("react.strict_mode"),be=Symbol.for("react.profiler"),fe=Symbol.for("react.consumer"),Ce=Symbol.for("react.context"),Ae=Symbol.for("react.forward_ref"),ke=Symbol.for("react.suspense"),ut=Symbol.for("react.suspense_list"),le=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),Pe=Symbol.for("react.activity"),Ne=Symbol.iterator,je={},Le={isMounted:function(){return!1},enqueueForceUpdate:function(e){s(e,"forceUpdate")},enqueueReplaceState:function(e){s(e,"replaceState")},enqueueSetState:function(e){s(e,"setState")}},Me=Object.assign,pe={};Object.freeze(pe),i.prototype.isReactComponent={},i.prototype.setState=function(e,n){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,n,"setState")},i.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};var O={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)."]};for(G in O)O.hasOwnProperty(G)&&t(G,O[G]);c.prototype=i.prototype,O=y.prototype=new c,O.constructor=y,Me(O,i.prototype),O.isPureReactComponent=!0;var $e=Array.isArray,st=Symbol.for("react.client.reference"),d={H:null,A:null,T:null,S:null,actQueue:null,asyncTransitions:0,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1,didUsePromise:!1,thrownErrors:[],getCurrentStack:null,recentlyCreatedOwnerStacks:0},F=Object.prototype.hasOwnProperty,Ie=console.createTask?console.createTask:function(){return null};O={react_stack_bottom_frame:function(e){return e()}};var De,He,Ue={},it=O.react_stack_bottom_frame.bind(O,W)(),at=Ie(B(W)),Ye=!1,xe=/\/+/g,We=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},ze=!1,Z=null,V=0,J=!1,de=!1,qe=typeof queueMicrotask=="function"?function(e){queueMicrotask(function(){return queueMicrotask(e)})}:H;O=Object.freeze({__proto__:null,c:function(e){return m().useMemoCache(e)}});var G={map:D,forEach:function(e,n,o){D(e,function(){n.apply(this,arguments)},o)},count:function(e){var n=0;return D(e,function(){n++}),n},toArray:function(e){return D(e,function(n){return n})||[]},only:function(e){if(!C(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};f.Activity=Pe,f.Children=G,f.Component=i,f.Fragment=ce,f.Profiler=be,f.PureComponent=y,f.StrictMode=Se,f.Suspense=ke,f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=d,f.__COMPILER_RUNTIME=O,f.act=function(e){var n=d.actQueue,o=V;V++;var u=d.actQueue=n!==null?n:[],a=!1;try{var _=e()}catch(E){d.thrownErrors.push(E)}if(0<d.thrownErrors.length)throw L(n,o),e=S(d.thrownErrors),d.thrownErrors.length=0,e;if(_!==null&&typeof _=="object"&&typeof _.then=="function"){var p=_;return qe(function(){a||J||(J=!0,console.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 () => ...);"))}),{then:function(E,k){a=!0,p.then(function(U){if(L(n,o),o===0){try{ie(u),H(function(){return se(U,E,k)})}catch(ft){d.thrownErrors.push(ft)}if(0<d.thrownErrors.length){var ct=S(d.thrownErrors);d.thrownErrors.length=0,k(ct)}}else E(U)},function(U){L(n,o),0<d.thrownErrors.length&&(U=S(d.thrownErrors),d.thrownErrors.length=0),k(U)})}}}var v=_;if(L(n,o),o===0&&(ie(u),u.length!==0&&qe(function(){a||J||(J=!0,console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"))}),d.actQueue=null),0<d.thrownErrors.length)throw e=S(d.thrownErrors),d.thrownErrors.length=0,e;return{then:function(E,k){a=!0,o===0?(d.actQueue=u,H(function(){return se(v,E,k)})):E(v)}}},f.cache=function(e){return function(){return e.apply(null,arguments)}},f.cacheSignal=function(){return null},f.captureOwnerStack=function(){var e=d.getCurrentStack;return e===null?null:e()},f.cloneElement=function(e,n,o){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var u=Me({},e.props),a=e.key,_=e._owner;if(n!=null){var p;e:{if(F.call(n,"ref")&&(p=Object.getOwnPropertyDescriptor(n,"ref").get)&&p.isReactWarning){p=!1;break e}p=n.ref!==void 0}p&&(_=K()),X(n)&&(R(n.key),a=""+n.key);for(v in n)!F.call(n,v)||v==="key"||v==="__self"||v==="__source"||v==="ref"&&n.ref===void 0||(u[v]=n[v])}var v=arguments.length-2;if(v===1)u.children=o;else if(1<v){p=Array(v);for(var E=0;E<v;E++)p[E]=arguments[E+2];u.children=p}for(u=N(e.type,a,u,_,e._debugStack,e._debugTask),a=2;a<arguments.length;a++)z(arguments[a]);return u},f.createContext=function(e){return e={$$typeof:Ce,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:fe,_context:e},e._currentRenderer=null,e._currentRenderer2=null,e},f.createElement=function(e,n,o){for(var u=2;u<arguments.length;u++)z(arguments[u]);u={};var a=null;if(n!=null)for(E in He||!("__self"in n)||"key"in n||(He=!0,console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")),X(n)&&(R(n.key),a=""+n.key),n)F.call(n,E)&&E!=="key"&&E!=="__self"&&E!=="__source"&&(u[E]=n[E]);var _=arguments.length-2;if(_===1)u.children=o;else if(1<_){for(var p=Array(_),v=0;v<_;v++)p[v]=arguments[v+2];Object.freeze&&Object.freeze(p),u.children=p}if(e&&e.defaultProps)for(E in _=e.defaultProps,_)u[E]===void 0&&(u[E]=_[E]);a&&ne(u,typeof e=="function"?e.displayName||e.name||"Unknown":e);var E=1e4>d.recentlyCreatedOwnerStacks++;return N(e,a,u,K(),E?Error("react-stack-top-frame"):it,E?Ie(B(e)):at)},f.createRef=function(){var e={current:null};return Object.seal(e),e},f.forwardRef=function(e){e!=null&&e.$$typeof===le?console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):typeof e!="function"?console.error("forwardRef requires a render function but was given %s.",e===null?"null":typeof e):e.length!==0&&e.length!==2&&console.error("forwardRef render functions accept exactly two parameters: props and ref. %s",e.length===1?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),e!=null&&e.defaultProps!=null&&console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");var n={$$typeof:Ae,render:e},o;return Object.defineProperty(n,"displayName",{enumerable:!1,configurable:!0,get:function(){return o},set:function(u){o=u,e.name||e.displayName||(Object.defineProperty(e,"name",{value:u}),e.displayName=u)}}),n},f.isValidElement=C,f.lazy=function(e){e={_status:-1,_result:e};var n={$$typeof:Q,_payload:e,_init:ue},o={name:"lazy",start:-1,end:-1,value:null,owner:null,debugStack:Error("react-stack-top-frame"),debugTask:console.createTask?console.createTask("lazy()"):null};return e._ioInfo=o,n._debugInfo=[{awaited:o}],n},f.memo=function(e,n){e==null&&console.error("memo: The first argument must be a component. Instead received: %s",e===null?"null":typeof e),n={$$typeof:le,type:e,compare:n===void 0?null:n};var o;return Object.defineProperty(n,"displayName",{enumerable:!1,configurable:!0,get:function(){return o},set:function(u){o=u,e.name||e.displayName||(Object.defineProperty(e,"name",{value:u}),e.displayName=u)}}),n},f.startTransition=function(e){var n=d.T,o={};o._updatedFibers=new Set,d.T=o;try{var u=e(),a=d.S;a!==null&&a(o,u),typeof u=="object"&&u!==null&&typeof u.then=="function"&&(d.asyncTransitions++,u.then(q,q),u.then(h,We))}catch(_){We(_)}finally{n===null&&o._updatedFibers&&(e=o._updatedFibers.size,o._updatedFibers.clear(),10<e&&console.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.")),n!==null&&o.types!==null&&(n.types!==null&&n.types!==o.types&&console.error("We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."),n.types=o.types),d.T=n}},f.unstable_useCacheRefresh=function(){return m().useCacheRefresh()},f.use=function(e){return m().use(e)},f.useActionState=function(e,n,o){return m().useActionState(e,n,o)},f.useCallback=function(e,n){return m().useCallback(e,n)},f.useContext=function(e){var n=m();return e.$$typeof===fe&&console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"),n.useContext(e)},f.useDebugValue=function(e,n){return m().useDebugValue(e,n)},f.useDeferredValue=function(e,n){return m().useDeferredValue(e,n)},f.useEffect=function(e,n){return e==null&&console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"),m().useEffect(e,n)},f.useEffectEvent=function(e){return m().useEffectEvent(e)},f.useId=function(){return m().useId()},f.useImperativeHandle=function(e,n,o){return m().useImperativeHandle(e,n,o)},f.useInsertionEffect=function(e,n){return e==null&&console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"),m().useInsertionEffect(e,n)},f.useLayoutEffect=function(e,n){return e==null&&console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"),m().useLayoutEffect(e,n)},f.useMemo=function(e,n){return m().useMemo(e,n)},f.useOptimistic=function(e,n){return m().useOptimistic(e,n)},f.useReducer=function(e,n,o){return m().useReducer(e,n,o)},f.useRef=function(e){return m().useRef(e)},f.useState=function(e){return m().useState(e)},f.useSyncExternalStore=function(e,n,o){return m().useSyncExternalStore(e,n,o)},f.useTransition=function(){return m().useTransition()},f.version="19.2.3",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var ot=ye((It,we)=>{"use strict";process.env.NODE_ENV==="production"?we.exports=nt():we.exports=rt()});var w=mt(ot());var M={SHOW_LO5:"SHOW_LO5",RETURN_LO5:"RETURN_LO5",UPDATE_ANSWER:"UPDATE_ANSWER",RETURN_UPDATE_ANSWER:"RETURN_UPDATE_ANSWER",FINISH:"FINISH"},Te=class{constructor(){this.handlers={};window.addEventListener("message",this.handleMessage.bind(this))}handleMessage(r){let{type:s,payload:i}=r.data;this.handlers[s]&&this.handlers[s](i)}on(r,s){this.handlers[r]=s}send(r,s={}){window.parent&&window.parent.postMessage({type:r,payload:s},"*")}},$=new Te;console.log("useGameAPI-V1.0.10");function Ut({onAnswerCorrect:t,onAnswerIncorrect:r}){let[s,i]=(0,w.useState)(0),c=(0,w.useRef)(0),[y,h]=(0,w.useState)(null),[T,R]=(0,w.useState)([]),[b,B]=(0,w.useState)(null),[K,W]=(0,w.useState)(null),[X,ne]=(0,w.useState)(0),[P,N]=(0,w.useState)(!1),[j,z]=(0,w.useState)(!1),[C,re]=(0,w.useState)(!1),I=(0,w.useRef)(!1),oe=(0,w.useCallback)(()=>{$.send(M.FINISH)},[]),A=(0,w.useCallback)(async()=>{if(!(!y||P))return $.send(M.UPDATE_ANSWER,y.id),N(!0),z(!0),Promise.resolve()},[y,P]),D=(0,w.useCallback)(()=>{if(j)if(I.current)re(!0);else{$.send(M.SHOW_LO5);let m=c.current+1;c.current=m,i(m),h(null),N(!1),z(!1),W(null)}},[j]),ue=(0,w.useCallback)(m=>{!P&&!j&&h(m)},[P,j]);return(0,w.useEffect)(()=>{$.send(M.SHOW_LO5),$.on(M.RETURN_LO5,m=>{B(m)}),$.on(M.RETURN_UPDATE_ANSWER,m=>{let q=(m==null?void 0:m.isCorrect)===!0,H=(m==null?void 0:m.isLastQuestion)===!0;I.current=H,R(S=>{let L=[...S];return L[c.current]=q,L}),q?(ne(S=>S+1),console.log({currentQuestionIndex:c.current}),t==null||t({currentQuestionIndex:c.current})):r==null||r(),N(!1),W(m)})},[]),{quiz:b,currentResult:K,answers:T,correctCount:X,currentQuestionIndex:s,selectedAnswer:y,isSubmitting:P,hasSubmitted:j,isCompleted:C,handleAnswerSelect:ue,updateAnswer:A,handleContinue:D,finish:oe}}export{Ut as useGameAPI};
|
|
14
14
|
/*! Bundled license information:
|
|
15
15
|
|
|
16
16
|
react/cjs/react.production.js:
|