@chhsiao1981/use-thunk 10.4.0 → 11.0.0

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.
Files changed (85) hide show
  1. package/dist/ThunkContext.d.ts +7 -0
  2. package/dist/createReducer.d.ts +4 -0
  3. package/dist/createThunk.d.ts +4 -0
  4. package/dist/dispatch.d.ts +4 -0
  5. package/dist/dispatchFuncMap.d.ts +18 -0
  6. package/dist/genUUID.d.ts +1 -0
  7. package/dist/index.d.ts +15 -0
  8. package/{types → dist}/init.d.ts +0 -3
  9. package/dist/reduceMap.d.ts +6 -0
  10. package/dist/reducer.d.ts +5 -0
  11. package/dist/remove.d.ts +5 -0
  12. package/dist/setDefaultID.d.ts +5 -0
  13. package/dist/stateTypes.d.ts +16 -0
  14. package/dist/states.d.ts +9 -0
  15. package/{types → dist}/thunk.d.ts +6 -3
  16. package/dist/thunkContextMap.d.ts +15 -0
  17. package/dist/thunkContextTypes.d.ts +8 -0
  18. package/{types → dist}/thunkModuleFuncMap.d.ts +1 -0
  19. package/dist/update.d.ts +6 -0
  20. package/dist/useThunk.d.ts +12 -0
  21. package/dist/useThunkReducer.d.ts +17 -0
  22. package/package.json +1 -1
  23. package/src/ThunkContext.tsx +17 -17
  24. package/src/action/ActionOrThunk.ts +5 -0
  25. package/src/action/baseAction.ts +6 -0
  26. package/src/action/index.ts +16 -0
  27. package/src/action/thunk.ts +5 -0
  28. package/src/createReducer.ts +7 -7
  29. package/src/createThunk.ts +31 -0
  30. package/src/index.ts +21 -27
  31. package/src/init/index.ts +26 -0
  32. package/src/init/initCore.ts +31 -0
  33. package/src/reduceMap.ts +3 -4
  34. package/src/reducer.ts +4 -4
  35. package/src/remove.ts +10 -25
  36. package/src/set.ts +7 -0
  37. package/src/setDefaultID.ts +5 -5
  38. package/src/setMap.ts +65 -0
  39. package/src/stateTypes.ts +4 -3
  40. package/src/states.ts +17 -17
  41. package/src/thunkContextMap.ts +4 -4
  42. package/src/thunkContextTypes.ts +4 -4
  43. package/src/thunkModule/defaultThunkModuleFuncMap.ts +16 -0
  44. package/src/thunkModule/index.ts +21 -0
  45. package/src/update.ts +31 -0
  46. package/src/useThunk.ts +24 -44
  47. package/src/useThunkReducer.ts +33 -44
  48. package/types/ThunkContext.d.ts +4 -4
  49. package/types/action/ActionOrThunk.d.ts +4 -0
  50. package/types/action/baseAction.d.ts +5 -0
  51. package/types/action/index.d.ts +8 -0
  52. package/types/action/thunk.d.ts +3 -0
  53. package/types/createThunk.d.ts +5 -0
  54. package/types/dispatch.d.ts +1 -1
  55. package/types/dispatchFuncMap.d.ts +4 -5
  56. package/types/index.d.ts +14 -8
  57. package/types/init/index.d.ts +7 -0
  58. package/types/init/initCore.d.ts +9 -0
  59. package/types/reducer.d.ts +4 -4
  60. package/types/remove.d.ts +4 -4
  61. package/types/set.d.ts +4 -0
  62. package/types/setDefaultID.d.ts +3 -3
  63. package/types/setMap.d.ts +17 -0
  64. package/types/stateTypes.d.ts +3 -2
  65. package/types/states.d.ts +8 -8
  66. package/types/thunkContextMap.d.ts +4 -4
  67. package/types/thunkContextTypes.d.ts +4 -4
  68. package/types/thunkModule/defaultThunkModuleFuncMap.d.ts +5 -0
  69. package/types/thunkModule/index.d.ts +16 -0
  70. package/types/update.d.ts +6 -0
  71. package/types/useThunk.d.ts +5 -8
  72. package/types/useThunkReducer.d.ts +5 -11
  73. package/dist/index.js +0 -1723
  74. package/dist/index.umd.cjs +0 -50
  75. package/src/action.ts +0 -20
  76. package/src/dispatch.ts +0 -6
  77. package/src/dispatchFuncMap.ts +0 -67
  78. package/src/init.ts +0 -64
  79. package/src/registerThunk.ts +0 -42
  80. package/src/setData.ts +0 -26
  81. package/src/thunk.ts +0 -20
  82. package/src/thunkModuleFuncMap.ts +0 -11
  83. package/types/registerThunk.d.ts +0 -4
  84. package/types/setData.d.ts +0 -5
  85. /package/{types → dist}/action.d.ts +0 -0
@@ -1,50 +0,0 @@
1
- (function(P,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(P=typeof globalThis<"u"?globalThis:P||self,A((P["use-thunk"]=P["use-thunk"]||{},P["use-thunk"].js={})))})(this,(function(P){"use strict";const A=[];for(let u=0;u<256;++u)A.push((u+256).toString(16).slice(1));function st(u,n=0){return(A[u[n+0]]+A[u[n+1]]+A[u[n+2]]+A[u[n+3]]+"-"+A[u[n+4]]+A[u[n+5]]+"-"+A[u[n+6]]+A[u[n+7]]+"-"+A[u[n+8]]+A[u[n+9]]+"-"+A[u[n+10]]+A[u[n+11]]+A[u[n+12]]+A[u[n+13]]+A[u[n+14]]+A[u[n+15]]).toLowerCase()}let Re;const at=new Uint8Array(16);function ct(){if(!Re){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Re=crypto.getRandomValues.bind(crypto)}return Re(at)}const be={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function it(u,n,i){var p;if(be.randomUUID&&!n&&!u)return be.randomUUID();u=u||{};const l=u.random??((p=u.rng)==null?void 0:p.call(u))??ct();if(l.length<16)throw new Error("Random bytes length must be >= 16");if(l[6]=l[6]&15|64,l[8]=l[8]&63|128,n){if(i=i||0,i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let _=0;_<16;++_)n[i+_]=l[_];return n}return st(l)}const Oe=new Set,ft=3,Ce={iterate:1},ke=u=>{let n="",i=!1;for(let l=0;l<ft;l++)if(n=Se(u),!Oe.has(n)){Oe.add(n),i=!0;break}return i||(Ce.iterate+=1,n=Se(u)),n},Se=(u=it)=>{let n="";for(let i=0;i<Ce.iterate;i++)n+=u();return n},Ae="@chhsiao1981/use-thunk/SET_ROOT",lt=u=>({myID:u,type:Ae}),dt=(u,n)=>{const{myID:i}=n;return Object.assign({},u,{root:i})},je=(u,n)=>(i,l)=>{const p=u.myID??ke(n),{state:_}=u;i(pt(p,_));const{root:T}=l();T||i(lt(p))},Pe="@chhsiao1981/use-thunk/INIT",pt=(u,n)=>({myID:u,type:Pe,state:n}),_t=(u,n)=>{const{myID:i,state:l}=n,p={id:i,state:l},_=Object.assign({},u.nodes,{[i]:p});return Object.assign({},u,{nodes:_})};var me={exports:{}},y={};/**
2
- * @license React
3
- * react.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Ne;function mt(){if(Ne)return y;Ne=1;var u=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),T=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),N=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),q=Symbol.for("react.activity"),V=Symbol.iterator;function G(t){return t===null||typeof t!="object"?null:(t=V&&t[V]||t["@@iterator"],typeof t=="function"?t:null)}var Q={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},oe=Object.assign,X={};function W(t,o,c){this.props=t,this.context=o,this.refs=X,this.updater=c||Q}W.prototype.isReactComponent={},W.prototype.setState=function(t,o){if(typeof t!="object"&&typeof t!="function"&&t!=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,t,o,"setState")},W.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function K(){}K.prototype=W.prototype;function ue(t,o,c){this.props=t,this.context=o,this.refs=X,this.updater=c||Q}var Z=ue.prototype=new K;Z.constructor=ue,oe(Z,W.prototype),Z.isPureReactComponent=!0;var Y=Array.isArray;function se(){}var b={H:null,A:null,T:null,S:null},ie=Object.prototype.hasOwnProperty;function U(t,o,c){var f=c.ref;return{$$typeof:u,type:t,key:o,ref:f!==void 0?f:null,props:c}}function J(t,o){return U(t.type,o,t.props)}function ae(t){return typeof t=="object"&&t!==null&&t.$$typeof===u}function O(t){var o={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(c){return o[c]})}var ee=/\/+/g;function z(t,o){return typeof t=="object"&&t!==null&&t.key!=null?O(""+t.key):o.toString(36)}function H(t){switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:switch(typeof t.status=="string"?t.then(se,se):(t.status="pending",t.then(function(o){t.status==="pending"&&(t.status="fulfilled",t.value=o)},function(o){t.status==="pending"&&(t.status="rejected",t.reason=o)})),t.status){case"fulfilled":return t.value;case"rejected":throw t.reason}}throw t}function I(t,o,c,f,h){var w=typeof t;(w==="undefined"||w==="boolean")&&(t=null);var m=!1;if(t===null)m=!0;else switch(w){case"bigint":case"string":case"number":m=!0;break;case"object":switch(t.$$typeof){case u:case n:m=!0;break;case D:return m=t._init,I(m(t._payload),o,c,f,h)}}if(m)return h=h(t),m=f===""?"."+z(t,0):f,Y(h)?(c="",m!=null&&(c=m.replace(ee,"$&/")+"/"),I(h,o,c,"",function(B){return B})):h!=null&&(ae(h)&&(h=J(h,c+(h.key==null||t&&t.key===h.key?"":(""+h.key).replace(ee,"$&/")+"/")+m)),o.push(h)),1;m=0;var j=f===""?".":f+":";if(Y(t))for(var S=0;S<t.length;S++)f=t[S],w=j+z(f,S),m+=I(f,o,c,w,h);else if(S=G(t),typeof S=="function")for(t=S.call(t),S=0;!(f=t.next()).done;)f=f.value,w=j+z(f,S++),m+=I(f,o,c,w,h);else if(w==="object"){if(typeof t.then=="function")return I(H(t),o,c,f,h);throw o=String(t),Error("Objects are not valid as a React child (found: "+(o==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":o)+"). If you meant to render a collection of children, use an array instead.")}return m}function x(t,o,c){if(t==null)return t;var f=[],h=0;return I(t,f,"","",function(w){return o.call(c,w,h++)}),f}function te(t){if(t._status===-1){var o=t._result;o=o(),o.then(function(c){(t._status===0||t._status===-1)&&(t._status=1,t._result=c)},function(c){(t._status===0||t._status===-1)&&(t._status=2,t._result=c)}),t._status===-1&&(t._status=0,t._result=o)}if(t._status===1)return t._result.default;throw t._result}var F=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var o=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(o))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},ce={map:x,forEach:function(t,o,c){x(t,function(){o.apply(this,arguments)},c)},count:function(t){var o=0;return x(t,function(){o++}),o},toArray:function(t){return x(t,function(o){return o})||[]},only:function(t){if(!ae(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};return y.Activity=q,y.Children=ce,y.Component=W,y.Fragment=i,y.Profiler=p,y.PureComponent=ue,y.StrictMode=l,y.Suspense=M,y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=b,y.__COMPILER_RUNTIME={__proto__:null,c:function(t){return b.H.useMemoCache(t)}},y.cache=function(t){return function(){return t.apply(null,arguments)}},y.cacheSignal=function(){return null},y.cloneElement=function(t,o,c){if(t==null)throw Error("The argument must be a React element, but you passed "+t+".");var f=oe({},t.props),h=t.key;if(o!=null)for(w in o.key!==void 0&&(h=""+o.key),o)!ie.call(o,w)||w==="key"||w==="__self"||w==="__source"||w==="ref"&&o.ref===void 0||(f[w]=o[w]);var w=arguments.length-2;if(w===1)f.children=c;else if(1<w){for(var m=Array(w),j=0;j<w;j++)m[j]=arguments[j+2];f.children=m}return U(t.type,h,f)},y.createContext=function(t){return t={$$typeof:T,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null},t.Provider=t,t.Consumer={$$typeof:_,_context:t},t},y.createElement=function(t,o,c){var f,h={},w=null;if(o!=null)for(f in o.key!==void 0&&(w=""+o.key),o)ie.call(o,f)&&f!=="key"&&f!=="__self"&&f!=="__source"&&(h[f]=o[f]);var m=arguments.length-2;if(m===1)h.children=c;else if(1<m){for(var j=Array(m),S=0;S<m;S++)j[S]=arguments[S+2];h.children=j}if(t&&t.defaultProps)for(f in m=t.defaultProps,m)h[f]===void 0&&(h[f]=m[f]);return U(t,w,h)},y.createRef=function(){return{current:null}},y.forwardRef=function(t){return{$$typeof:k,render:t}},y.isValidElement=ae,y.lazy=function(t){return{$$typeof:D,_payload:{_status:-1,_result:t},_init:te}},y.memo=function(t,o){return{$$typeof:N,type:t,compare:o===void 0?null:o}},y.startTransition=function(t){var o=b.T,c={};b.T=c;try{var f=t(),h=b.S;h!==null&&h(c,f),typeof f=="object"&&f!==null&&typeof f.then=="function"&&f.then(se,F)}catch(w){F(w)}finally{o!==null&&c.types!==null&&(o.types=c.types),b.T=o}},y.unstable_useCacheRefresh=function(){return b.H.useCacheRefresh()},y.use=function(t){return b.H.use(t)},y.useActionState=function(t,o,c){return b.H.useActionState(t,o,c)},y.useCallback=function(t,o){return b.H.useCallback(t,o)},y.useContext=function(t){return b.H.useContext(t)},y.useDebugValue=function(){},y.useDeferredValue=function(t,o){return b.H.useDeferredValue(t,o)},y.useEffect=function(t,o){return b.H.useEffect(t,o)},y.useEffectEvent=function(t){return b.H.useEffectEvent(t)},y.useId=function(){return b.H.useId()},y.useImperativeHandle=function(t,o,c){return b.H.useImperativeHandle(t,o,c)},y.useInsertionEffect=function(t,o){return b.H.useInsertionEffect(t,o)},y.useLayoutEffect=function(t,o){return b.H.useLayoutEffect(t,o)},y.useMemo=function(t,o){return b.H.useMemo(t,o)},y.useOptimistic=function(t,o){return b.H.useOptimistic(t,o)},y.useReducer=function(t,o,c){return b.H.useReducer(t,o,c)},y.useRef=function(t){return b.H.useRef(t)},y.useState=function(t){return b.H.useState(t)},y.useSyncExternalStore=function(t,o,c){return b.H.useSyncExternalStore(t,o,c)},y.useTransition=function(){return b.H.useTransition()},y.version="19.2.0",y}var le={exports:{}};/**
10
- * @license React
11
- * react.development.js
12
- *
13
- * Copyright (c) Meta Platforms, Inc. and affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */le.exports;var Me;function yt(){return Me||(Me=1,(function(u,n){process.env.NODE_ENV!=="production"&&(function(){function i(e,r){Object.defineProperty(_.prototype,e,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",r[0],r[1])}})}function l(e){return e===null||typeof e!="object"?null:(e=Fe&&e[Fe]||e["@@iterator"],typeof e=="function"?e:null)}function p(e,r){e=(e=e.constructor)&&(e.displayName||e.name)||"ReactClass";var s=e+"."+r;Be[s]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",r,e),Be[s]=!0)}function _(e,r,s){this.props=e,this.context=r,this.refs=Te,this.updater=s||Ve}function T(){}function k(e,r,s){this.props=e,this.context=r,this.refs=Te,this.updater=s||Ve}function M(){}function N(e){return""+e}function D(e){try{N(e);var r=!1}catch{r=!0}if(r){r=console;var s=r.error,a=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return s.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",a),N(e)}}function q(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===It?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case t:return"Fragment";case c:return"Profiler";case o:return"StrictMode";case m:return"Suspense";case j:return"SuspenseList";case Ge:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case ce:return"Portal";case h:return e.displayName||"Context";case f:return(e._context.displayName||"Context")+".Consumer";case w:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case S:return r=e.displayName||null,r!==null?r:q(e.type)||"Memo";case B:r=e._payload,e=e._init;try{return q(e(r))}catch{}}return null}function V(e){if(e===t)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===B)return"<...>";try{var r=q(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function G(){var e=v.A;return e===null?null:e.getOwner()}function Q(){return Error("react-stack-top-frame")}function oe(e){if(Ee.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function X(e,r){function s(){Ze||(Ze=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}s.isReactWarning=!0,Object.defineProperty(e,"key",{get:s,configurable:!0})}function W(){var e=q(this.type);return et[e]||(et[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function K(e,r,s,a,d,g){var E=s.ref;return e={$$typeof:F,type:e,key:r,props:s,_owner:a},(E!==void 0?E:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:W}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:d}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:g}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function ue(e,r){return r=K(e.type,r,e.props,e._owner,e._debugStack,e._debugTask),e._store&&(r._store.validated=e._store.validated),r}function Z(e){Y(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===B&&(e._payload.status==="fulfilled"?Y(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function Y(e){return typeof e=="object"&&e!==null&&e.$$typeof===F}function se(e){var r={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return r[s]})}function b(e,r){return typeof e=="object"&&e!==null&&e.key!=null?(D(e.key),se(""+e.key)):r.toString(36)}function ie(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(M,M):(e.status="pending",e.then(function(r){e.status==="pending"&&(e.status="fulfilled",e.value=r)},function(r){e.status==="pending"&&(e.status="rejected",e.reason=r)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function U(e,r,s,a,d){var g=typeof e;(g==="undefined"||g==="boolean")&&(e=null);var E=!1;if(e===null)E=!0;else switch(g){case"bigint":case"string":case"number":E=!0;break;case"object":switch(e.$$typeof){case F:case ce:E=!0;break;case B:return E=e._init,U(E(e._payload),r,s,a,d)}}if(E){E=e,d=d(E);var C=a===""?"."+b(E,0):a;return Xe(d)?(s="",C!=null&&(s=C.replace(rt,"$&/")+"/"),U(d,r,s,"",function(re){return re})):d!=null&&(Y(d)&&(d.key!=null&&(E&&E.key===d.key||D(d.key)),s=ue(d,s+(d.key==null||E&&E.key===d.key?"":(""+d.key).replace(rt,"$&/")+"/")+C),a!==""&&E!=null&&Y(E)&&E.key==null&&E._store&&!E._store.validated&&(s._store.validated=2),d=s),r.push(d)),1}if(E=0,C=a===""?".":a+":",Xe(e))for(var R=0;R<e.length;R++)a=e[R],g=C+b(a,R),E+=U(a,r,s,g,d);else if(R=l(e),typeof R=="function")for(R===e.entries&&(tt||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),tt=!0),e=R.call(e),R=0;!(a=e.next()).done;)a=a.value,g=C+b(a,R++),E+=U(a,r,s,g,d);else if(g==="object"){if(typeof e.then=="function")return U(ie(e),r,s,a,d);throw r=String(e),Error("Objects are not valid as a React child (found: "+(r==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":r)+"). If you meant to render a collection of children, use an array instead.")}return E}function J(e,r,s){if(e==null)return e;var a=[],d=0;return U(e,a,"","",function(g){return r.call(s,g,d++)}),a}function ae(e){if(e._status===-1){var r=e._ioInfo;r!=null&&(r.start=r.end=performance.now()),r=e._result;var s=r();if(s.then(function(d){if(e._status===0||e._status===-1){e._status=1,e._result=d;var g=e._ioInfo;g!=null&&(g.end=performance.now()),s.status===void 0&&(s.status="fulfilled",s.value=d)}},function(d){if(e._status===0||e._status===-1){e._status=2,e._result=d;var g=e._ioInfo;g!=null&&(g.end=performance.now()),s.status===void 0&&(s.status="rejected",s.reason=d)}}),r=e._ioInfo,r!=null){r.value=s;var a=s.displayName;typeof a=="string"&&(r.name=a)}e._status===-1&&(e._status=0,e._result=s)}if(e._status===1)return r=e._result,r===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
18
-
19
- Your code should look like:
20
- const MyComponent = lazy(() => import('./MyComponent'))
21
-
22
- Did you accidentally put curly braces around the import?`,r),"default"in r||console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
23
-
24
- Your code should look like:
25
- const MyComponent = lazy(() => import('./MyComponent'))`,r),r.default;throw e._result}function O(){var e=v.H;return e===null&&console.error(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
26
- 1. You might have mismatching versions of React and the renderer (such as React DOM)
27
- 2. You might be breaking the Rules of Hooks
28
- 3. You might have more than one copy of React in the same app
29
- See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),e}function ee(){v.asyncTransitions--}function z(e){if(he===null)try{var r=("require"+Math.random()).slice(0,7);he=(u&&u[r]).call(u,"timers").setImmediate}catch{he=function(a){ot===!1&&(ot=!0,typeof MessageChannel>"u"&&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 d=new MessageChannel;d.port1.onmessage=a,d.port2.postMessage(void 0)}}return he(e)}function H(e){return 1<e.length&&typeof AggregateError=="function"?new AggregateError(e):e[0]}function I(e,r){r!==ve-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. "),ve=r}function x(e,r,s){var a=v.actQueue;if(a!==null)if(a.length!==0)try{te(a),z(function(){return x(e,r,s)});return}catch(d){v.thrownErrors.push(d)}else v.actQueue=null;0<v.thrownErrors.length?(a=H(v.thrownErrors),v.thrownErrors.length=0,s(a)):r(e)}function te(e){if(!we){we=!0;var r=0;try{for(;r<e.length;r++){var s=e[r];do{v.didUsePromise=!1;var a=s(!1);if(a!==null){if(v.didUsePromise){e[r]=s,e.splice(0,r);return}s=a}else break}while(!0)}e.length=0}catch(d){e.splice(0,r+1),v.thrownErrors.push(d)}finally{we=!1}}}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var F=Symbol.for("react.transitional.element"),ce=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),f=Symbol.for("react.consumer"),h=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),Ge=Symbol.for("react.activity"),Fe=Symbol.iterator,Be={},Ve={isMounted:function(){return!1},enqueueForceUpdate:function(e){p(e,"forceUpdate")},enqueueReplaceState:function(e){p(e,"replaceState")},enqueueSetState:function(e){p(e,"setState")}},Qe=Object.assign,Te={};Object.freeze(Te),_.prototype.isReactComponent={},_.prototype.setState=function(e,r){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,r,"setState")},_.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};var L={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(_e in L)L.hasOwnProperty(_e)&&i(_e,L[_e]);T.prototype=_.prototype,L=k.prototype=new T,L.constructor=k,Qe(L,_.prototype),L.isPureReactComponent=!0;var Xe=Array.isArray,It=Symbol.for("react.client.reference"),v={H:null,A:null,T:null,S:null,actQueue:null,asyncTransitions:0,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1,didUsePromise:!1,thrownErrors:[],getCurrentStack:null,recentlyCreatedOwnerStacks:0},Ee=Object.prototype.hasOwnProperty,Ke=console.createTask?console.createTask:function(){return null};L={react_stack_bottom_frame:function(e){return e()}};var Ze,Je,et={},Lt=L.react_stack_bottom_frame.bind(L,Q)(),Yt=Ke(V(Q)),tt=!1,rt=/\/+/g,nt=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=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(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},ot=!1,he=null,ve=0,ge=!1,we=!1,ut=typeof queueMicrotask=="function"?function(e){queueMicrotask(function(){return queueMicrotask(e)})}:z;L=Object.freeze({__proto__:null,c:function(e){return O().useMemoCache(e)}});var _e={map:J,forEach:function(e,r,s){J(e,function(){r.apply(this,arguments)},s)},count:function(e){var r=0;return J(e,function(){r++}),r},toArray:function(e){return J(e,function(r){return r})||[]},only:function(e){if(!Y(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};n.Activity=Ge,n.Children=_e,n.Component=_,n.Fragment=t,n.Profiler=c,n.PureComponent=k,n.StrictMode=o,n.Suspense=m,n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=v,n.__COMPILER_RUNTIME=L,n.act=function(e){var r=v.actQueue,s=ve;ve++;var a=v.actQueue=r!==null?r:[],d=!1;try{var g=e()}catch(R){v.thrownErrors.push(R)}if(0<v.thrownErrors.length)throw I(r,s),e=H(v.thrownErrors),v.thrownErrors.length=0,e;if(g!==null&&typeof g=="object"&&typeof g.then=="function"){var E=g;return ut(function(){d||ge||(ge=!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(R,re){d=!0,E.then(function(fe){if(I(r,s),s===0){try{te(a),z(function(){return x(fe,R,re)})}catch(xt){v.thrownErrors.push(xt)}if(0<v.thrownErrors.length){var Ht=H(v.thrownErrors);v.thrownErrors.length=0,re(Ht)}}else R(fe)},function(fe){I(r,s),0<v.thrownErrors.length&&(fe=H(v.thrownErrors),v.thrownErrors.length=0),re(fe)})}}}var C=g;if(I(r,s),s===0&&(te(a),a.length!==0&&ut(function(){d||ge||(ge=!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(() => ...)"))}),v.actQueue=null),0<v.thrownErrors.length)throw e=H(v.thrownErrors),v.thrownErrors.length=0,e;return{then:function(R,re){d=!0,s===0?(v.actQueue=a,z(function(){return x(C,R,re)})):R(C)}}},n.cache=function(e){return function(){return e.apply(null,arguments)}},n.cacheSignal=function(){return null},n.captureOwnerStack=function(){var e=v.getCurrentStack;return e===null?null:e()},n.cloneElement=function(e,r,s){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var a=Qe({},e.props),d=e.key,g=e._owner;if(r!=null){var E;e:{if(Ee.call(r,"ref")&&(E=Object.getOwnPropertyDescriptor(r,"ref").get)&&E.isReactWarning){E=!1;break e}E=r.ref!==void 0}E&&(g=G()),oe(r)&&(D(r.key),d=""+r.key);for(C in r)!Ee.call(r,C)||C==="key"||C==="__self"||C==="__source"||C==="ref"&&r.ref===void 0||(a[C]=r[C])}var C=arguments.length-2;if(C===1)a.children=s;else if(1<C){E=Array(C);for(var R=0;R<C;R++)E[R]=arguments[R+2];a.children=E}for(a=K(e.type,d,a,g,e._debugStack,e._debugTask),d=2;d<arguments.length;d++)Z(arguments[d]);return a},n.createContext=function(e){return e={$$typeof:h,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:f,_context:e},e._currentRenderer=null,e._currentRenderer2=null,e},n.createElement=function(e,r,s){for(var a=2;a<arguments.length;a++)Z(arguments[a]);a={};var d=null;if(r!=null)for(R in Je||!("__self"in r)||"key"in r||(Je=!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")),oe(r)&&(D(r.key),d=""+r.key),r)Ee.call(r,R)&&R!=="key"&&R!=="__self"&&R!=="__source"&&(a[R]=r[R]);var g=arguments.length-2;if(g===1)a.children=s;else if(1<g){for(var E=Array(g),C=0;C<g;C++)E[C]=arguments[C+2];Object.freeze&&Object.freeze(E),a.children=E}if(e&&e.defaultProps)for(R in g=e.defaultProps,g)a[R]===void 0&&(a[R]=g[R]);d&&X(a,typeof e=="function"?e.displayName||e.name||"Unknown":e);var R=1e4>v.recentlyCreatedOwnerStacks++;return K(e,d,a,G(),R?Error("react-stack-top-frame"):Lt,R?Ke(V(e)):Yt)},n.createRef=function(){var e={current:null};return Object.seal(e),e},n.forwardRef=function(e){e!=null&&e.$$typeof===S?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 r={$$typeof:w,render:e},s;return Object.defineProperty(r,"displayName",{enumerable:!1,configurable:!0,get:function(){return s},set:function(a){s=a,e.name||e.displayName||(Object.defineProperty(e,"name",{value:a}),e.displayName=a)}}),r},n.isValidElement=Y,n.lazy=function(e){e={_status:-1,_result:e};var r={$$typeof:B,_payload:e,_init:ae},s={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=s,r._debugInfo=[{awaited:s}],r},n.memo=function(e,r){e==null&&console.error("memo: The first argument must be a component. Instead received: %s",e===null?"null":typeof e),r={$$typeof:S,type:e,compare:r===void 0?null:r};var s;return Object.defineProperty(r,"displayName",{enumerable:!1,configurable:!0,get:function(){return s},set:function(a){s=a,e.name||e.displayName||(Object.defineProperty(e,"name",{value:a}),e.displayName=a)}}),r},n.startTransition=function(e){var r=v.T,s={};s._updatedFibers=new Set,v.T=s;try{var a=e(),d=v.S;d!==null&&d(s,a),typeof a=="object"&&a!==null&&typeof a.then=="function"&&(v.asyncTransitions++,a.then(ee,ee),a.then(M,nt))}catch(g){nt(g)}finally{r===null&&s._updatedFibers&&(e=s._updatedFibers.size,s._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.")),r!==null&&s.types!==null&&(r.types!==null&&r.types!==s.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."),r.types=s.types),v.T=r}},n.unstable_useCacheRefresh=function(){return O().useCacheRefresh()},n.use=function(e){return O().use(e)},n.useActionState=function(e,r,s){return O().useActionState(e,r,s)},n.useCallback=function(e,r){return O().useCallback(e,r)},n.useContext=function(e){var r=O();return e.$$typeof===f&&console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"),r.useContext(e)},n.useDebugValue=function(e,r){return O().useDebugValue(e,r)},n.useDeferredValue=function(e,r){return O().useDeferredValue(e,r)},n.useEffect=function(e,r){return e==null&&console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"),O().useEffect(e,r)},n.useEffectEvent=function(e){return O().useEffectEvent(e)},n.useId=function(){return O().useId()},n.useImperativeHandle=function(e,r,s){return O().useImperativeHandle(e,r,s)},n.useInsertionEffect=function(e,r){return e==null&&console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"),O().useInsertionEffect(e,r)},n.useLayoutEffect=function(e,r){return e==null&&console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"),O().useLayoutEffect(e,r)},n.useMemo=function(e,r){return O().useMemo(e,r)},n.useOptimistic=function(e,r){return O().useOptimistic(e,r)},n.useReducer=function(e,r,s){return O().useReducer(e,r,s)},n.useRef=function(e){return O().useRef(e)},n.useState=function(e){return O().useState(e)},n.useSyncExternalStore=function(e,r,s){return O().useSyncExternalStore(e,r,s)},n.useTransition=function(){return O().useTransition()},n.version="19.2.0",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()})(le,le.exports)),le.exports}var De;function Ue(){return De||(De=1,process.env.NODE_ENV==="production"?me.exports=mt():me.exports=yt()),me.exports}var $=Ue();const ne={theMap:{},theList:[]},Et=u=>{const{myClass:n}=u;if(ne.theMap[n]){console.info("regsterThunk: already init:",n);return}const i={myClass:n,nodes:{}},l=()=>{},p={current:i},_=$.createContext({refClassState:p,setClassState:l});ne.theMap[n]={context:_,refClassState:p};const T=Object.keys(ne.theMap);T.sort(),ne.theList=T,console.info("registerThunk: done:",n)},Ie=u=>(n,i)=>{const l=i(),{nodes:{[u]:p}}=l;p&&n(ht(u))},Le="@chhsiao1981/use-thunk/REMOVE",ht=u=>({myID:u,type:Le}),vt=(u,n)=>{const{myID:i}=n;if(!u.nodes[i])return u;const p=Object.keys(u.nodes).filter(T=>T!==i).reduce((T,k)=>(T[k]=u.nodes[k],T),{}),_=Object.assign({},u,{nodes:p});return _.root===i&&(_.root=null),_},Ye="@chhsiao1981/use-thunk/SET_DATA",He=(u,n)=>({myID:u,type:Ye,data:n}),gt=(u,n)=>{const{myID:i,data:l}=n,p=u.nodes[i];if(!p)return u;const _=Object.assign({},p.state,l),T=Object.assign({},p,{state:_}),k=Object.assign({},u.nodes,{[i]:T});return Object.assign({},u,{nodes:k})},Rt=u=>{const n=u.root;return n&&u.nodes[n]||null},Tt=u=>u.root??"",wt=u=>{const n=u.root;if(!n)return null;const i=u.nodes[n];return i?i.state:null},bt=(u,n)=>n?u.nodes[n]||null:Rt(u),Ot=(u,n)=>{if(!n)return wt(u);const i=u.nodes[n];return i?i.state:null};var ye={exports:{}},de={};/**
30
- * @license React
31
- * react-jsx-runtime.production.js
32
- *
33
- * Copyright (c) Meta Platforms, Inc. and affiliates.
34
- *
35
- * This source code is licensed under the MIT license found in the
36
- * LICENSE file in the root directory of this source tree.
37
- */var xe;function Ct(){if(xe)return de;xe=1;var u=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function i(l,p,_){var T=null;if(_!==void 0&&(T=""+_),p.key!==void 0&&(T=""+p.key),"key"in p){_={};for(var k in p)k!=="key"&&(_[k]=p[k])}else _=p;return p=_.ref,{$$typeof:u,type:l,key:T,ref:p!==void 0?p:null,props:_}}return de.Fragment=n,de.jsx=i,de.jsxs=i,de}var pe={};/**
38
- * @license React
39
- * react-jsx-runtime.development.js
40
- *
41
- * Copyright (c) Meta Platforms, Inc. and affiliates.
42
- *
43
- * This source code is licensed under the MIT license found in the
44
- * LICENSE file in the root directory of this source tree.
45
- */var qe;function kt(){return qe||(qe=1,process.env.NODE_ENV!=="production"&&(function(){function u(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===ae?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case X:return"Fragment";case K:return"Profiler";case W:return"StrictMode";case se:return"Suspense";case b:return"SuspenseList";case J:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case oe:return"Portal";case Z:return t.displayName||"Context";case ue:return(t._context.displayName||"Context")+".Consumer";case Y:var o=t.render;return t=t.displayName,t||(t=o.displayName||o.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ie:return o=t.displayName||null,o!==null?o:u(t.type)||"Memo";case U:o=t._payload,t=t._init;try{return u(t(o))}catch{}}return null}function n(t){return""+t}function i(t){try{n(t);var o=!1}catch{o=!0}if(o){o=console;var c=o.error,f=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return c.call(o,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",f),n(t)}}function l(t){if(t===X)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===U)return"<...>";try{var o=u(t);return o?"<"+o+">":"<...>"}catch{return"<...>"}}function p(){var t=O.A;return t===null?null:t.getOwner()}function _(){return Error("react-stack-top-frame")}function T(t){if(ee.call(t,"key")){var o=Object.getOwnPropertyDescriptor(t,"key").get;if(o&&o.isReactWarning)return!1}return t.key!==void 0}function k(t,o){function c(){I||(I=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",o))}c.isReactWarning=!0,Object.defineProperty(t,"key",{get:c,configurable:!0})}function M(){var t=u(this.type);return x[t]||(x[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function N(t,o,c,f,h,w){var m=c.ref;return t={$$typeof:Q,type:t,key:o,props:c,_owner:f},(m!==void 0?m:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:M}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:h}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:w}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function D(t,o,c,f,h,w){var m=o.children;if(m!==void 0)if(f)if(z(m)){for(f=0;f<m.length;f++)q(m[f]);Object.freeze&&Object.freeze(m)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else q(m);if(ee.call(o,"key")){m=u(t);var j=Object.keys(o).filter(function(B){return B!=="key"});f=0<j.length?"{key: someKey, "+j.join(": ..., ")+": ...}":"{key: someKey}",ce[m+f]||(j=0<j.length?"{"+j.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
46
- let props = %s;
47
- <%s {...props} />
48
- React keys must be passed directly to JSX without using spread:
49
- let props = %s;
50
- <%s key={someKey} {...props} />`,f,m,j,m),ce[m+f]=!0)}if(m=null,c!==void 0&&(i(c),m=""+c),T(o)&&(i(o.key),m=""+o.key),"key"in o){c={};for(var S in o)S!=="key"&&(c[S]=o[S])}else c=o;return m&&k(c,typeof t=="function"?t.displayName||t.name||"Unknown":t),N(t,m,c,p(),h,w)}function q(t){V(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===U&&(t._payload.status==="fulfilled"?V(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function V(t){return typeof t=="object"&&t!==null&&t.$$typeof===Q}var G=Ue(),Q=Symbol.for("react.transitional.element"),oe=Symbol.for("react.portal"),X=Symbol.for("react.fragment"),W=Symbol.for("react.strict_mode"),K=Symbol.for("react.profiler"),ue=Symbol.for("react.consumer"),Z=Symbol.for("react.context"),Y=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),ie=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),ae=Symbol.for("react.client.reference"),O=G.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=Object.prototype.hasOwnProperty,z=Array.isArray,H=console.createTask?console.createTask:function(){return null};G={react_stack_bottom_frame:function(t){return t()}};var I,x={},te=G.react_stack_bottom_frame.bind(G,_)(),F=H(l(_)),ce={};pe.Fragment=X,pe.jsx=function(t,o,c){var f=1e4>O.recentlyCreatedOwnerStacks++;return D(t,o,c,!1,f?Error("react-stack-top-frame"):te,f?H(l(t)):F)},pe.jsxs=function(t,o,c){var f=1e4>O.recentlyCreatedOwnerStacks++;return D(t,o,c,!0,f?Error("react-stack-top-frame"):te,f?H(l(t)):F)}})()),pe}var We;function St(){return We||(We=1,process.env.NODE_ENV==="production"?ye.exports=Ct():ye.exports=kt()),ye.exports}var At=St();const ze=u=>{let{classes:n,children:i}=u;if(n||(n=ne.theList),n.length===0)return i;const l=n[0],{context:p,refClassState:_}=ne.theMap[l],[T,k]=$.useState({myClass:l,nodes:{}});_.current=T;const M={refClassState:_,setClassState:k},N=n.length===1?i:ze({classes:n.slice(1),children:i});return At.jsx(p,{value:M,children:N})},jt=()=>({[Pe]:_t,[Ye]:gt,[Le]:vt,[Ae]:dt}),Pt=u=>(n,i)=>{if(!i)return n;const l=jt();return l!=null&&l[i.type]?l[i.type](n,i):n},$e={init:je,setData:He,remove:Ie},Nt=(u,n,i)=>(Object.keys(u).filter(l=>typeof u[l]=="function").reduce((l,p)=>{if(l[p])return l;const _=u[p];return l[p]=(...T)=>n(_(...T)),l},i),Object.keys($e).reduce((l,p)=>{if(l[p])return l;const _=$e[p];return l[p]=(...T)=>n(_(...T)),l},i),i),Mt=(u,n)=>{const{context:i}=ne.theMap[n],{refClassState:l,setClassState:p}=$.useContext(i),_=$.useCallback(()=>l.current,[l]),T=$.useCallback(N=>{l.current=N,p(N)},[l,p]),k=$.useCallback(N=>{const D=_();return u(D,N)},[u,_]),M=$.useCallback(N=>{if(typeof N=="function"){N(M,_);return}const D=k(N);T(D)},[_,T,k]);return[l.current,M]},Dt={},Ut=u=>{const{myClass:n}=u,i=Dt,l=!i[n];l&&(i[n]={});const p=i[n],_=$.useMemo(()=>u.default??Pt(),[]),[T,k]=Mt(_,n),M=$.useMemo(()=>[T,p],[T,p]);return l&&Nt(u,k,p),M};P.ThunkContext=ze,P.genUUID=ke,P.getNode=bt,P.getRootID=Tt,P.getState=Ot,P.init=je,P.registerThunk=Et,P.remove=Ie,P.setData=He,P.useThunk=Ut,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})}));
package/src/action.ts DELETED
@@ -1,20 +0,0 @@
1
- import type { ClassState, State } from './stateTypes'
2
- import type { ActionOrThunk as rActionOrThunk, Thunk as rThunk } from './useThunkReducer'
3
-
4
- // BaseAction contains only object-based actions, no thunk-based actions.
5
- export interface BaseAction {
6
- myID: string
7
- type: string
8
- [key: string]: unknown
9
- }
10
- // Thunk
11
- export type Thunk<S extends State> = rThunk<S, BaseAction>
12
-
13
- export type ActionOrThunk<S extends State> = rActionOrThunk<S, BaseAction>
14
-
15
- // ActionFunc
16
- // biome-ignore lint/suspicious/noExplicitAny: unknown requires same type in list. use any for possible different types.
17
- export type ActionFunc<S extends State> = (...params: any[]) => ActionOrThunk<S>
18
-
19
- // GetClassState
20
- export type GetClassState<S extends State> = () => ClassState<S>
package/src/dispatch.ts DELETED
@@ -1,6 +0,0 @@
1
- import type { Dispatch as rDispatch } from 'react'
2
- import type { ActionOrThunk } from './action'
3
- import type { State } from './stateTypes'
4
-
5
- // Dispatch
6
- export type Dispatch<S extends State> = rDispatch<ActionOrThunk<S>>
@@ -1,67 +0,0 @@
1
- import type { ActionFunc, BaseAction } from './action'
2
- import type { State } from './stateTypes'
3
- import type { ThunkModule, ThunkModuleFunc } from './thunk'
4
- import { DEFAULT_THUNK_MODULE_FUNC_MAP, type DefaultThunkModuleFuncMap } from './thunkModuleFuncMap'
5
- import type { Thunk as rThunk } from './useThunkReducer'
6
-
7
- // biome-ignore lint/suspicious/noExplicitAny: unknown requires same type in list, use any for possible different types.
8
- type VoidReturnType<T extends (...params: any[]) => unknown> = (...params: Parameters<T>) => void
9
-
10
- export type DispatchFuncMap<S extends State, T extends ThunkModuleFunc<S>> = {
11
- [action in keyof T]: VoidReturnType<T[action]>
12
- } & Omit<DefaultDispatchFuncMap, keyof T>
13
-
14
- export type DefaultDispatchFuncMap = {
15
- [action in keyof DefaultThunkModuleFuncMap]: VoidReturnType<DefaultThunkModuleFuncMap[action]>
16
- }
17
-
18
- export interface DispatchFuncMapByClassMap<S extends State, T extends ThunkModuleFunc<S>> {
19
- [className: string]: DispatchFuncMap<S, T>
20
- }
21
-
22
- // biome-ignore lint/suspicious/noExplicitAny: dispatch func map by class map can be any.
23
- export const DISPATCH_FUNC_MAP_BY_CLASS_MAP: DispatchFuncMapByClassMap<any, any> = {}
24
-
25
- export const constructDispatchMap = <
26
- S extends State,
27
- T extends ThunkModuleFunc<S>,
28
- A extends BaseAction,
29
- >(
30
- theDo: ThunkModule<S>,
31
- dispatch: (action: A | rThunk<S, A>) => void,
32
- dispatchMap: DispatchFuncMap<S, T>,
33
- ) => {
34
- Object.keys(theDo)
35
- // default and myClass are reserved words.
36
- // functions starting reduce are included in default and not exported.
37
- .filter((each) => typeof theDo[each] === 'function')
38
- .reduce((val, eachAction) => {
39
- if (val[eachAction]) {
40
- return val
41
- }
42
-
43
- // because action is a function.
44
- const action = theDo[eachAction] as ActionFunc<S>
45
-
46
- // @ts-expect-error eachAction is in DispatchFuncMap<S, R>
47
- // biome-ignore lint/suspicious/noExplicitAny: action parameters can be any types.
48
- val[eachAction] = (...params: any[]) => dispatch(action(...params))
49
- return val
50
- }, dispatchMap)
51
-
52
- Object.keys(DEFAULT_THUNK_MODULE_FUNC_MAP).reduce((val, eachAction) => {
53
- if (val[eachAction]) {
54
- return val
55
- }
56
-
57
- // @ts-expect-error DEFAULT_REDUCER_MODULE_FUNCS are all ActionFunc<S>
58
- const action: ActionFunc<S> = DEFAULT_THUNK_MODULE_FUNC_MAP[eachAction]
59
-
60
- // @ts-expect-error eachAction is in DispatchFuncMap<S, R>
61
- // biome-ignore lint/suspicious/noExplicitAny: action parameters can be any types.
62
- val[eachAction] = (...params: any[]) => dispatch(action(...params))
63
- return val
64
- }, dispatchMap)
65
-
66
- return dispatchMap
67
- }
package/src/init.ts DELETED
@@ -1,64 +0,0 @@
1
- import type { BaseAction, Thunk } from './action'
2
- import { genUUID } from './genUUID'
3
- import { setDefaultID } from './setDefaultID'
4
- import type { ClassState, NodeState, NodeStateMap, State } from './stateTypes'
5
-
6
- // InitParams
7
- export interface InitParams<S extends State> {
8
- myID?: string
9
- parentID?: string
10
- // @ts-expect-error doParent can be any type.
11
- doParent?: DispatchFuncMap
12
- parentClass?: string
13
-
14
- state: S
15
- }
16
-
17
- export const init = <S extends State>(params: InitParams<S>, myuuidv4?: () => string): Thunk<S> => {
18
- return (dispatch, getClassState) => {
19
- const myID = params.myID ?? genUUID(myuuidv4)
20
-
21
- const { state } = params
22
- dispatch(initCore(myID, state))
23
-
24
- const { defaultID } = getClassState()
25
-
26
- if (!defaultID) {
27
- dispatch(setDefaultID(myID))
28
- }
29
- }
30
- }
31
-
32
- interface InitAction<S extends State> extends BaseAction {
33
- parentID?: string
34
- // @ts-expect-error doParent can be any type
35
- doParent?: DispatchFuncMap
36
- parentClass?: string
37
-
38
- state: S
39
- }
40
-
41
- export const INIT = '@chhsiao1981/use-thunk/INIT'
42
- const initCore = <S extends State>(myID: string, state: S): InitAction<S> => {
43
- return {
44
- myID,
45
- type: INIT,
46
- state,
47
- }
48
- }
49
-
50
- export const reduceInit = <S extends State>(
51
- classState: ClassState<S>,
52
- action: InitAction<S>,
53
- ): ClassState<S> => {
54
- const { myID, state } = action
55
-
56
- const myNode: NodeState<S> = {
57
- id: myID,
58
- state: state,
59
- }
60
- const newNodes: NodeStateMap<S> = Object.assign({}, classState.nodes, { [myID]: myNode })
61
- const newClassState: ClassState<S> = Object.assign({}, classState, { nodes: newNodes })
62
-
63
- return newClassState
64
- }
@@ -1,42 +0,0 @@
1
- import { createContext, type Dispatch, type SetStateAction } from 'react'
2
- import type { ClassState, State } from './stateTypes'
3
- import type { ThunkModule } from './thunk'
4
- import { THUNK_CONTEXT_MAP } from './thunkContextMap'
5
-
6
- export default <S extends State>(theDo: ThunkModule<S>) => {
7
- const { myClass, defaultState } = theDo
8
-
9
- if (THUNK_CONTEXT_MAP.theMap[myClass]) {
10
- // 1. already init
11
- console.warn('regsterThunk: already init:', myClass)
12
- return
13
- }
14
-
15
- // 2. to initialize classState, setClassState, and refClassState.
16
- const classState: ClassState<S> = {
17
- myClass,
18
- nodes: {},
19
- defaultState,
20
- }
21
- const setClassState: Dispatch<SetStateAction<ClassState<S>>> = () => {}
22
- const refClassState = { current: classState }
23
-
24
- // 3. create context
25
- const context = createContext({
26
- refClassState,
27
- setClassState,
28
- })
29
-
30
- // 4. setup THUNK_CONTEXT_MAP.theMap.
31
- THUNK_CONTEXT_MAP.theMap[myClass] = {
32
- context,
33
- refClassState,
34
- }
35
-
36
- // 5. setup THUNK_CONTEXT_MAP.theList, to ensure the rendering order.
37
- const theList = Object.keys(THUNK_CONTEXT_MAP.theMap)
38
- theList.sort()
39
- THUNK_CONTEXT_MAP.theList = theList
40
-
41
- console.info('registerThunk: done:', myClass)
42
- }
package/src/setData.ts DELETED
@@ -1,26 +0,0 @@
1
- import type { BaseAction } from './action'
2
- import type { ClassState, State } from './stateTypes'
3
-
4
- export const SET_DATA = '@chhsiao1981/use-thunk/SET_DATA'
5
- export const setData = <S extends State>(myID: string, data: Partial<S>): BaseAction => ({
6
- myID,
7
- type: SET_DATA,
8
- data,
9
- })
10
-
11
- export const reduceSetData = <S extends State>(
12
- classState: ClassState<S>,
13
- action: BaseAction,
14
- ): ClassState<S> => {
15
- const { myID, data } = action
16
-
17
- const myNode = classState.nodes[myID]
18
- if (!myNode) return classState
19
-
20
- const newMyState = Object.assign({}, myNode.state, data)
21
- const newMyNode = Object.assign({}, myNode, { state: newMyState })
22
- const newNodes = Object.assign({}, classState.nodes, { [myID]: newMyNode })
23
- const newClassState = Object.assign({}, classState, { nodes: newNodes })
24
-
25
- return newClassState
26
- }
package/src/thunk.ts DELETED
@@ -1,20 +0,0 @@
1
- import type { ActionFunc } from './action'
2
- import type { Reducer } from './reducer'
3
- import type { State } from './stateTypes'
4
-
5
- export interface ThunkModuleBase<S extends State> {
6
- [idx: string]: ActionFunc<S> | string | Reducer<S> | S | undefined
7
- }
8
-
9
- export interface ThunkModuleFunc<S extends State> extends ThunkModuleBase<S> {
10
- [action: string]: ActionFunc<S>
11
- }
12
-
13
- // This is used as the parameter for useThunk.
14
- export type ThunkModule<S extends State> = {
15
- myClass: string
16
- default?: Reducer<S>
17
- defaultState: S
18
- } & ThunkModuleBase<S>
19
-
20
- export type ThunkModuleToFunc<T> = Omit<T, 'myClass' | 'default' | 'defaultState'>
@@ -1,11 +0,0 @@
1
- import { init } from './init'
2
- import { remove } from './remove'
3
- import { setData } from './setData'
4
-
5
- export const DEFAULT_THUNK_MODULE_FUNC_MAP = {
6
- init,
7
- setData,
8
- remove,
9
- }
10
-
11
- export type DefaultThunkModuleFuncMap = typeof DEFAULT_THUNK_MODULE_FUNC_MAP
@@ -1,4 +0,0 @@
1
- import type { State } from './stateTypes';
2
- import type { ThunkModule, ThunkModuleFunc } from './thunk';
3
- declare const _default: <S extends State, R extends ThunkModuleFunc<S>>(theDo: ThunkModule<S, R>) => void;
4
- export default _default;
@@ -1,5 +0,0 @@
1
- import type { BaseAction } from './action';
2
- import type { ClassState, State } from './stateTypes';
3
- export declare const SET_DATA = "@chhsiao1981/use-thunk/SET_DATA";
4
- export declare const setData: <S extends State>(myID: string, data: Partial<S>) => BaseAction;
5
- export declare const reduceSetData: <S extends State>(classState: ClassState<S>, action: BaseAction) => ClassState<S>;
File without changes