rtk-framework
Version:
a framework for RTK
26 lines (23 loc) • 26.5 kB
JavaScript
var St=Object.defineProperty;var Tt=(s,t,r)=>t in s?St(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r;var y=(s,t,r)=>Tt(s,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ue=require("@reduxjs/toolkit"),W=require("react"),Q=require("react-redux"),Ce=require("react-router-dom"),jt=require("antd"),C={Key:0,Name:1,Path:2,KeyOrName:3},k="",Lt=["src","routes","layout","page","model","service"],Mt=/(\w)+((.ts)|(.tsx)|(.js)|(.jsx))$/;function H(s,t=Lt){return Pt(s,t)}function Pt(s,t){const r=new RegExp(`\\b(${t.join("|")})\\b`,"g");return s.replace(r,"").replace(Mt,"").replace(/\/+/g,"/").replace(/^\//,"").replace(/\/$/,"")}function Ze(s){return!s&&s!==0&&s!==""?!0:RegExp.prototype.isPrototypeOf(s)?!1:Array.prototype.isPrototypeOf(s)?s.length===0:Map.prototype.isPrototypeOf(s)||Set.prototype.isPrototypeOf(s)?s.size===0:Object.prototype.isPrototypeOf(s)?Object.keys(s).length===0:!1}const z=(s,t)=>t.split(".").reduce((r,n)=>{if(r!=null)return r[n]},s),Qe=s=>{const t=s.includes(".");return r=>t?z(r,s):r[s]},Kt=s=>{const t=s.map(r=>({path:r,selector:Qe(r),hasNested:r.includes(".")}));return r=>{const n={};return t.forEach(({path:a,selector:u,hasNested:f})=>{const v=f?a.replace(/\./g,"_"):a;n[v]=u(r)}),n}};class fe{constructor(t,r,n,a,u){y(this,"type");y(this,"moduleLoaders",{});y(this,"configLoaders",{});y(this,"moduleAsyncLoaders",{});y(this,"configAsyncLoaders",{});y(this,"modules",{});y(this,"configs",{});y(this,"usedName",new Set);y(this,"nameToKeyManual",{});y(this,"nameToKeyAuto",{});this.nameToKeyManual=u,Object.entries(a).forEach(([f,v])=>{const l=H(f);this.configAsyncLoaders[l]=async()=>(await v()).default}),Object.entries(r).forEach(([f,v])=>{const l=H(f);this.configLoaders[l]=v.default}),Object.entries(n).forEach(([f,v])=>{const l=H(f);this.moduleAsyncLoaders[l]=async()=>(await v()).default,this.configAsyncLoaders[l]||(this.configAsyncLoaders[l]=async()=>await this.buildConfig({},l)),this.configLoaders[l]||(this.configLoaders[l]=this.buildConfig({},l))}),Object.entries(t).forEach(([f,v])=>{const l=H(f);this.moduleLoaders[l]=v.default,this.configAsyncLoaders[l]||(this.configAsyncLoaders[l]=async()=>await this.buildConfig({},l)),this.configLoaders[l]||(this.configLoaders[l]=this.buildConfig({},l))})}getKey(t,r){let n;switch(r){case C.Key:n=t;break;case C.Name:n=this.nameToKeyManual[t]??this.nameToKeyAuto[t];break;case C.Path:n=H(t);break;case C.KeyOrName:this.moduleLoaders[t]||this.moduleAsyncLoaders[t]||this.configLoaders[t]||this.configAsyncLoaders[t]?n=t:n=this.nameToKeyManual[t]??this.nameToKeyAuto[t];break;default:n=t;break}return Ze(n)&&console.warn(`${this.type}: GetKey may failed , param:${t} type:${r} result:${n}`),n}getType(){return this.type}getModuleLoadersKeys(){return Object.keys(this.moduleLoaders)}getConfigLoadersKeys(){return Object.keys(this.configLoaders)}getModuleAsyncLoadersKeys(){return Object.keys(this.moduleAsyncLoaders)}getgetConfigAsyncLoadersKeys(){return Object.keys(this.configAsyncLoaders)}getModuleLoader(t,r){const n=this.getKey(t,r);return this.moduleLoaders[n]}getConfigLoader(t,r){const n=this.getKey(t,r);return this.configLoaders[n]}getModuleAsyncLoader(t,r){const n=this.getKey(t,r);return this.moduleAsyncLoaders[n]}getConfigAsyncLoader(t,r){const n=this.getKey(t,r);return this.configAsyncLoaders[n]}getModule(t,r){const n=this.getKey(t,r);return this.modules[n]}getConfig(t,r){const n=this.getKey(t,r);return this.configs[n]}loadModule(t,r){const n=this.getKey(t,r);if(this.modules[n])return!0;if(!this.moduleLoaders[n])return console.warn(`${this.type}-loadModule:${n} is not exist in moduleLoaders...`),!1;this.modules[n]=this.moduleLoaders[n];const a=this.configs[n];return a&&a.name!==n&&(this.modules[a.name]=this.modules[n]),!0}loadConfig(t,r){const n=this.getKey(t,r);if(this.configs[n])return!0;if(!this.configLoaders[n])return console.warn(`${this.type}-loadConfig:${n} is not exist in configLoaders...`),!1;const a=this.configLoaders[n],u=this.buildConfig(a,n),f=u.name;return this.usedName.has(f)||this.usedName.has(n)?(console.error(`${this.type}-loadConfig:Duplicated name ${f}`),!1):(this.configs[n]=u,f!==n&&(this.nameToKeyAuto[f]=n,this.usedName.add(n)),this.usedName.add(f),!0)}async load(t,r){const n=this.getKey(t,r);return!!(this.loadConfig(n,C.Key)&&this.loadModule(n,C.Key))}async loadModuleAsync(t,r){const n=this.getKey(t,r);if(this.modules[n])return!0;if(!this.moduleAsyncLoaders[n])return console.warn(`${this.type}-loadModuleAsync:${n} is not exist in moduleAsyncLoaders...`),!1;this.modules[n]=await this.moduleAsyncLoaders[n]();const a=this.configs[n];return a&&a.name!==n&&(this.modules[a.name]=this.modules[n]),!0}async loadConfigAsync(t,r){const n=this.getKey(t,r);if(this.configs[n])return!0;if(!this.configAsyncLoaders[n])return console.warn(`${this.type}-loadConfigAsync:${n} is not exist in configAsyncLoaders...`),!1;const a=await this.configAsyncLoaders[n](),u=this.buildConfig(a,n),f=u.name;return this.usedName.has(f)||this.usedName.has(n)?(console.error(`${this.type}-loadConfigAsync:Duplicated name ${f}`),!1):(this.configs[n]=u,f!==n&&(this.nameToKeyAuto[f]=n,this.usedName.add(n)),this.usedName.add(f),!0)}async loadAsync(t,r){const n=this.getKey(t,r);return!!(await this.loadConfigAsync(n,C.Key)&&await this.loadModuleAsync(n,C.Key))}}class kt extends fe{constructor(t,r,n,a,u){super(t,r,n,a,u),this.type="MODEL"}buildConfig(t,r){return{...t,name:t.name??r,service:t.service??r,extraservice:t.extraservice??[]}}}class Dt extends fe{constructor(t,r,n,a,u){super(t,r,n,a,u),this.type="SERVICE"}buildConfig(t,r){return{...t,name:t.name??r}}}class $t extends fe{constructor(r,n,a,u,f,v){super(r,n,a,u,f);y(this,"defaultLayout",k);this.type="PAGE",this.defaultLayout=v}buildConfig(r,n){return{...r,name:r.name??n,path:r.path??n,ignore:r.ignore??!1,layout:r.layout??this.defaultLayout,model:r.model??n,extraModel:r.extraModel??[],action:r.action??n,extraAction:r.extraAction??[]}}}class Ft extends fe{constructor(t,r,n,a,u){t[k]||(t[k]={default:void 0}),n[k]||(n[k]=async()=>({default:void 0})),r[k]||(r[k]={default:{ignore:!1}}),a[k]||(a[k]=async()=>({default:{ignore:!1}})),super(t,r,n,a,u),this.type="LAYOUT"}buildConfig(t,r){return{...t,name:t.name??r,path:t.path??r,ignore:t.ignore??!1,model:t.model??r,extraModel:t.extraModel??[],action:t.action??r,extraAction:t.extraAction??[]}}}const Nt=(s={})=>s;class It{constructor(t,r){y(this,"type");y(this,"modelClient");y(this,"serviceClient");y(this,"used",new Set);y(this,"store");y(this,"asyncReducers",{});y(this,"actions",{});this.type="STORE",this.modelClient=t,this.serviceClient=r,this.store=ue.configureStore({reducer:this.createRootReducer(),middleware:n=>n({serializableCheck:!1,thunk:{extraArgument:{actions:this.actions}}})}),this.store.asyncReducers=this.asyncReducers,this.store.injectReducer=this.injectReducer.bind(this)}async loadAsync(t,r){if(this.used.has(t+r))return;if(this.used.add(t+r),!await this.modelClient.loadAsync(t,r)){console.error(`${this.type}:load ${t} failed...`);return}const n=this.modelClient.getModule(t,r),a=this.modelClient.getConfig(t,r),u=a.name,{state:f={},effects:v={},reducers:l={}}=n,{service:w,extraservice:R}=a;await this.serviceClient.loadAsync(w,C.KeyOrName);const x=this.serviceClient.getModule(w,C.KeyOrName),A={};for(const p of R){await this.serviceClient.loadAsync(p,C.KeyOrName);const T=this.serviceClient.getModule(p,C.KeyOrName);A[p]=T}const N={service:x,extraservice:A},K={...Object.keys(v).reduce((p,T)=>{const j=`${T}Data`;return{...p,[j]:{data:null,loading:!1}}},{}),...f},D={};Object.entries(v).forEach(([p,T])=>{const j=async(L,O)=>{try{return await T(L,N,O)}catch(M){const F=M;return O.rejectWithValue(F.message??"Unknown error")}};D[p]=ue.createAsyncThunk(`${u}/${p}`,j)});const $=ue.createSlice({name:u,initialState:K,reducers:l,extraReducers:p=>{Object.entries(D).forEach(([T,j])=>{const L=`${T}Data`;p.addCase(j.pending,O=>{const M=O[L];M.loading=!0}).addCase(j.fulfilled,(O,M)=>{const F=O[L];F.data=M.payload,F.loading=!1}).addCase(j.rejected,(O,M)=>{const F=O[L];F.data=M.payload,F.loading=!1})})}}),S={...$.actions,...D};this.actions[u]=S,this.injectReducer(u,$.reducer)}getStore(){return this.store}getActions(){return this.actions}createRootReducer(){return ue.combineReducers({base:Nt,...this.asyncReducers})}injectReducer(t,r){this.asyncReducers[t]||(this.asyncReducers[t]=r,this.store.replaceReducer(this.createRootReducer()))}}var ce={exports:{}},X={};/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var qe;function Wt(){if(qe)return X;qe=1;var s=W,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,a=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function f(v,l,w){var R,x={},A=null,N=null;w!==void 0&&(A=""+w),l.key!==void 0&&(A=""+l.key),l.ref!==void 0&&(N=l.ref);for(R in l)n.call(l,R)&&!u.hasOwnProperty(R)&&(x[R]=l[R]);if(v&&v.defaultProps)for(R in l=v.defaultProps,l)x[R]===void 0&&(x[R]=l[R]);return{$$typeof:t,type:v,key:A,ref:N,props:x,_owner:a.current}}return X.Fragment=r,X.jsx=f,X.jsxs=f,X}var Z={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ze;function Yt(){return ze||(ze=1,process.env.NODE_ENV!=="production"&&(function(){var s=W,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),f=Symbol.for("react.provider"),v=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),N=Symbol.for("react.offscreen"),K=Symbol.iterator,D="@@iterator";function $(e){if(e===null||typeof e!="object")return null;var o=K&&e[K]||e[D];return typeof o=="function"?o:null}var S=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function p(e){{for(var o=arguments.length,i=new Array(o>1?o-1:0),c=1;c<o;c++)i[c-1]=arguments[c];T("error",e,i)}}function T(e,o,i){{var c=S.ReactDebugCurrentFrame,g=c.getStackAddendum();g!==""&&(o+="%s",i=i.concat([g]));var m=i.map(function(h){return String(h)});m.unshift("Warning: "+o),Function.prototype.apply.call(console[e],console,m)}}var j=!1,L=!1,O=!1,M=!1,F=!1,re;re=Symbol.for("react.module.reference");function tt(e){return!!(typeof e=="string"||typeof e=="function"||e===n||e===u||F||e===a||e===w||e===R||M||e===N||j||L||O||typeof e=="object"&&e!==null&&(e.$$typeof===A||e.$$typeof===x||e.$$typeof===f||e.$$typeof===v||e.$$typeof===l||e.$$typeof===re||e.getModuleId!==void 0))}function rt(e,o,i){var c=e.displayName;if(c)return c;var g=o.displayName||o.name||"";return g!==""?i+"("+g+")":i}function be(e){return e.displayName||"Context"}function Y(e){if(e==null)return null;if(typeof e.tag=="number"&&p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case n:return"Fragment";case r:return"Portal";case u:return"Profiler";case a:return"StrictMode";case w:return"Suspense";case R:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case v:var o=e;return be(o)+".Consumer";case f:var i=e;return be(i._context)+".Provider";case l:return rt(e,e.render,"ForwardRef");case x:var c=e.displayName||null;return c!==null?c:Y(e.type)||"Memo";case A:{var g=e,m=g._payload,h=g._init;try{return Y(h(m))}catch{return null}}}return null}var U=Object.assign,G=0,Re,Ae,xe,_e,Oe,we,Se;function Te(){}Te.__reactDisabledLog=!0;function nt(){{if(G===0){Re=console.log,Ae=console.info,xe=console.warn,_e=console.error,Oe=console.group,we=console.groupCollapsed,Se=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Te,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}G++}}function ot(){{if(G--,G===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:U({},e,{value:Re}),info:U({},e,{value:Ae}),warn:U({},e,{value:xe}),error:U({},e,{value:_e}),group:U({},e,{value:Oe}),groupCollapsed:U({},e,{value:we}),groupEnd:U({},e,{value:Se})})}G<0&&p("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var de=S.ReactCurrentDispatcher,he;function ne(e,o,i){{if(he===void 0)try{throw Error()}catch(g){var c=g.stack.trim().match(/\n( *(at )?)/);he=c&&c[1]||""}return`
`+he+e}}var ye=!1,oe;{var st=typeof WeakMap=="function"?WeakMap:Map;oe=new st}function je(e,o){if(!e||ye)return"";{var i=oe.get(e);if(i!==void 0)return i}var c;ye=!0;var g=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var m;m=de.current,de.current=null,nt();try{if(o){var h=function(){throw Error()};if(Object.defineProperty(h.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(h,[])}catch(I){c=I}Reflect.construct(e,[],h)}else{try{h.call()}catch(I){c=I}e.call(h.prototype)}}else{try{throw Error()}catch(I){c=I}e()}}catch(I){if(I&&c&&typeof I.stack=="string"){for(var d=I.stack.split(`
`),_=c.stack.split(`
`),E=d.length-1,b=_.length-1;E>=1&&b>=0&&d[E]!==_[b];)b--;for(;E>=1&&b>=0;E--,b--)if(d[E]!==_[b]){if(E!==1||b!==1)do if(E--,b--,b<0||d[E]!==_[b]){var P=`
`+d[E].replace(" at new "," at ");return e.displayName&&P.includes("<anonymous>")&&(P=P.replace("<anonymous>",e.displayName)),typeof e=="function"&&oe.set(e,P),P}while(E>=1&&b>=0);break}}}finally{ye=!1,de.current=m,ot(),Error.prepareStackTrace=g}var J=e?e.displayName||e.name:"",Ve=J?ne(J):"";return typeof e=="function"&&oe.set(e,Ve),Ve}function it(e,o,i){return je(e,!1)}function at(e){var o=e.prototype;return!!(o&&o.isReactComponent)}function se(e,o,i){if(e==null)return"";if(typeof e=="function")return je(e,at(e));if(typeof e=="string")return ne(e);switch(e){case w:return ne("Suspense");case R:return ne("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case l:return it(e.render);case x:return se(e.type,o,i);case A:{var c=e,g=c._payload,m=c._init;try{return se(m(g),o,i)}catch{}}}return""}var ie=Object.prototype.hasOwnProperty,Le={},Me=S.ReactDebugCurrentFrame;function ae(e){if(e){var o=e._owner,i=se(e.type,e._source,o?o.type:null);Me.setExtraStackFrame(i)}else Me.setExtraStackFrame(null)}function ut(e,o,i,c,g){{var m=Function.call.bind(ie);for(var h in e)if(m(e,h)){var d=void 0;try{if(typeof e[h]!="function"){var _=Error((c||"React class")+": "+i+" type `"+h+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[h]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw _.name="Invariant Violation",_}d=e[h](o,h,c,i,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(E){d=E}d&&!(d instanceof Error)&&(ae(g),p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",c||"React class",i,h,typeof d),ae(null)),d instanceof Error&&!(d.message in Le)&&(Le[d.message]=!0,ae(g),p("Failed %s type: %s",i,d.message),ae(null))}}}var ct=Array.isArray;function pe(e){return ct(e)}function lt(e){{var o=typeof Symbol=="function"&&Symbol.toStringTag,i=o&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i}}function ft(e){try{return Pe(e),!1}catch{return!0}}function Pe(e){return""+e}function Ke(e){if(ft(e))return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",lt(e)),Pe(e)}var ke=S.ReactCurrentOwner,dt={key:!0,ref:!0,__self:!0,__source:!0},De,$e;function ht(e){if(ie.call(e,"ref")){var o=Object.getOwnPropertyDescriptor(e,"ref").get;if(o&&o.isReactWarning)return!1}return e.ref!==void 0}function yt(e){if(ie.call(e,"key")){var o=Object.getOwnPropertyDescriptor(e,"key").get;if(o&&o.isReactWarning)return!1}return e.key!==void 0}function pt(e,o){typeof e.ref=="string"&&ke.current}function gt(e,o){{var i=function(){De||(De=!0,p("%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://reactjs.org/link/special-props)",o))};i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}}function vt(e,o){{var i=function(){$e||($e=!0,p("%s: `ref` 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://reactjs.org/link/special-props)",o))};i.isReactWarning=!0,Object.defineProperty(e,"ref",{get:i,configurable:!0})}}var mt=function(e,o,i,c,g,m,h){var d={$$typeof:t,type:e,key:o,ref:i,props:h,_owner:m};return d._store={},Object.defineProperty(d._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(d,"_self",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.defineProperty(d,"_source",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.freeze&&(Object.freeze(d.props),Object.freeze(d)),d};function Ct(e,o,i,c,g){{var m,h={},d=null,_=null;i!==void 0&&(Ke(i),d=""+i),yt(o)&&(Ke(o.key),d=""+o.key),ht(o)&&(_=o.ref,pt(o,g));for(m in o)ie.call(o,m)&&!dt.hasOwnProperty(m)&&(h[m]=o[m]);if(e&&e.defaultProps){var E=e.defaultProps;for(m in E)h[m]===void 0&&(h[m]=E[m])}if(d||_){var b=typeof e=="function"?e.displayName||e.name||"Unknown":e;d&>(h,b),_&&vt(h,b)}return mt(e,d,_,g,c,ke.current,h)}}var ge=S.ReactCurrentOwner,Fe=S.ReactDebugCurrentFrame;function B(e){if(e){var o=e._owner,i=se(e.type,e._source,o?o.type:null);Fe.setExtraStackFrame(i)}else Fe.setExtraStackFrame(null)}var ve;ve=!1;function me(e){return typeof e=="object"&&e!==null&&e.$$typeof===t}function Ne(){{if(ge.current){var e=Y(ge.current.type);if(e)return`
Check the render method of \``+e+"`."}return""}}function Et(e){return""}var Ie={};function bt(e){{var o=Ne();if(!o){var i=typeof e=="string"?e:e.displayName||e.name;i&&(o=`
Check the top-level render call using <`+i+">.")}return o}}function We(e,o){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var i=bt(o);if(Ie[i])return;Ie[i]=!0;var c="";e&&e._owner&&e._owner!==ge.current&&(c=" It was passed a child from "+Y(e._owner.type)+"."),B(e),p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',i,c),B(null)}}function Ye(e,o){{if(typeof e!="object")return;if(pe(e))for(var i=0;i<e.length;i++){var c=e[i];me(c)&&We(c,o)}else if(me(e))e._store&&(e._store.validated=!0);else if(e){var g=$(e);if(typeof g=="function"&&g!==e.entries)for(var m=g.call(e),h;!(h=m.next()).done;)me(h.value)&&We(h.value,o)}}}function Rt(e){{var o=e.type;if(o==null||typeof o=="string")return;var i;if(typeof o=="function")i=o.propTypes;else if(typeof o=="object"&&(o.$$typeof===l||o.$$typeof===x))i=o.propTypes;else return;if(i){var c=Y(o);ut(i,e.props,"prop",c,e)}else if(o.PropTypes!==void 0&&!ve){ve=!0;var g=Y(o);p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",g||"Unknown")}typeof o.getDefaultProps=="function"&&!o.getDefaultProps.isReactClassApproved&&p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function At(e){{for(var o=Object.keys(e.props),i=0;i<o.length;i++){var c=o[i];if(c!=="children"&&c!=="key"){B(e),p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",c),B(null);break}}e.ref!==null&&(B(e),p("Invalid attribute `ref` supplied to `React.Fragment`."),B(null))}}function Ue(e,o,i,c,g,m){{var h=tt(e);if(!h){var d="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(d+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var _=Et();_?d+=_:d+=Ne();var E;e===null?E="null":pe(e)?E="array":e!==void 0&&e.$$typeof===t?(E="<"+(Y(e.type)||"Unknown")+" />",d=" Did you accidentally export a JSX literal instead of a component?"):E=typeof e,p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,d)}var b=Ct(e,o,i,g,m);if(b==null)return b;if(h){var P=o.children;if(P!==void 0)if(c)if(pe(P)){for(var J=0;J<P.length;J++)Ye(P[J],e);Object.freeze&&Object.freeze(P)}else p("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 Ye(P,e)}return e===n?At(b):Rt(b),b}}function xt(e,o,i){return Ue(e,o,i,!0)}function _t(e,o,i){return Ue(e,o,i,!1)}var Ot=_t,wt=xt;Z.Fragment=n,Z.jsx=Ot,Z.jsxs=wt})()),Z}var Be;function Ut(){return Be||(Be=1,process.env.NODE_ENV==="production"?ce.exports=Wt():ce.exports=Yt()),ce.exports}var q=Ut();const Je=(s,t)=>r=>(W.useEffect(()=>{t&&(window.document.title=t)},[t]),q.jsx(s,{...r})),Ge=(s,t)=>r=>{const{model:n,extraModel:a,action:u,extraAction:f}=t,v={dispatch:et(),model:n,extraModel:a??{},action:u,extraAction:f??{}};return q.jsx(s,{...v,...r})},He=q.jsx("div",{children:"error"}),Xe=q.jsx(jt.Spin,{});class Vt{constructor(t,r,n){y(this,"type");y(this,"layoutClient");y(this,"pageClient");y(this,"storeClient");y(this,"router");this.type="ROUTER",this.type,this.layoutClient=t,this.pageClient=r,this.storeClient=n}createRouter(){if(!Ze(this.router))return this.router;const t={},r=this.layoutClient.getModuleAsyncLoadersKeys();return r.forEach(a=>{if(!this.layoutClient.loadConfig(a,C.Key))return;const u=this.layoutClient.getConfig(a,C.Key);u.ignore||(t[a]={path:u.path,title:u.title,indexRoute:u.indexRoute,component:this.layoutClient.getModuleAsyncLoader(a,C.Key),children:[],model:u.model,extraModel:u.extraModel,action:u.action,extraAction:u.extraAction,isAnonymous:a===k})}),this.pageClient.getModuleAsyncLoadersKeys().forEach(a=>{if(!this.pageClient.loadConfig(a,C.Key))return;const u=this.pageClient.getConfig(a,C.Key);if(u.ignore)return;const f=u.layout;t[f].children.push({path:u.path,title:u.title,model:u.model,extraModel:u.extraModel,action:u.action,extraAction:u.extraAction,component:this.pageClient.getModuleAsyncLoader(a,C.Key)})}),this.router=[],r.forEach(a=>{this.router.push(this.createRouterHelper(t[a]))}),this.router}createRouterHelper(t){const{path:r,title:n,indexRoute:a,component:u,children:f,model:v,extraModel:l,action:w,extraAction:R,isAnonymous:x}=t,A=[];return a&&A.push({index:!0,element:q.jsx(Ce.Navigate,{to:a,replace:!0})}),f.forEach(K=>{const{path:D,title:$,model:S,extraModel:p,action:T,extraAction:j,component:L}=K,O=async()=>{if(!L)return{Component:()=>He};await this.storeClient.loadAsync(S,C.KeyOrName);for(const re of p)await this.storeClient.loadAsync(re,C.KeyOrName);const M=await L();return M?{Component:Ge(Je(M,$),{model:S,extraModel:p,action:T,extraAction:j})}:{Component:()=>He}};A.push({path:D,lazy:O,hydrateFallbackElement:Xe})}),{path:r,lazy:async()=>{if(!u)return{Component:()=>q.jsx(Ce.Outlet,{})};if(!x){await this.storeClient.loadAsync(v,C.KeyOrName);for(const $ of l)await this.storeClient.loadAsync($,C.KeyOrName)}const K=await u();return K?{Component:Ge(Je(K,n),{model:v,extraModel:l,action:w,extraAction:R})}:{Component:()=>q.jsx(Ce.Outlet,{})}},children:A,hydrateFallbackElement:Xe}}}let le,ee,te;exports.appDispatch=void 0;const V=class V{constructor(t){y(this,"serviceClient");y(this,"modelClient");y(this,"pageClient");y(this,"layoutClient");y(this,"storeClient");y(this,"routerClient");const{serviceModule:r={},serviceConfig:n={},serviceAsyncModule:a={},serviceAsyncConfig:u={},serviceNameToKey:f={},modelModule:v={},modelConfig:l={},modelAsyncModule:w={},modelAsyncConfig:R={},modelNameToKey:x={},pageModule:A={},pageConfig:N={},pageAsyncModule:K={},pageAsyncConfig:D={},pageNameToKey:$={},layoutModule:S={},layoutConfig:p={},layoutAsyncModule:T={},layoutAsyncConfig:j={},layoutNameToKey:L={},defaultLayout:O=k}=t;this.serviceClient=new Dt(r,n,a,u,f),this.modelClient=new kt(v,l,w,R,x),this.pageClient=new $t(A,N,K,D,$,O),this.layoutClient=new Ft(S,p,T,j,L),this.storeClient=new It(this.modelClient,this.serviceClient),this.routerClient=new Vt(this.layoutClient,this.pageClient,this.storeClient),le=this.storeClient.getStore(),ee=this.storeClient.getActions(),te=this.serviceClient,exports.appDispatch=le.dispatch}static getInstance(t){if(V.instance)t&&console.warn("RTKFrameWork already initialized. Config will be ignored.");else{if(!t)throw new Error("RTKFrameWork not initialized. Provide config in first call to getInstance().");V.instance=new V(t)}return V.instance}createRouter(){return this.routerClient.createRouter()}store(){return this.storeClient.getStore()}};y(V,"instance",null);let Ee=V;const qt=(s,t=C.KeyOrName)=>te.getModule(s,t),zt=(s,t=C.KeyOrName)=>s.reduce((r,n)=>(r[n]=te.getModule(n,t),r),{}),Bt=(s,t=C.KeyOrName)=>W.useMemo(()=>te.getModule(s,t),[s,t]),Jt=(s,t=C.KeyOrName)=>W.useMemo(()=>s.reduce((n,a)=>(n[a]=te.getModule(a,t),n),{}),[s,t]),Gt=s=>{const t=le.getState();return z(t,s)},Ht=s=>{const t=le.getState();return s.reduce((r,n)=>(r[n]=z(t,n),r),{})},Xt=s=>z(ee,s),Zt=s=>s.reduce((t,r)=>(t[r]=z(ee,r),t),{}),et=()=>Q.useDispatch(),Qt=s=>{const t=W.useMemo(()=>Qe(s),[s]);return Q.useSelector(t,Q.shallowEqual)},er=s=>{const t=W.useMemo(()=>Kt(s),[s]);return Q.useSelector(t,Q.shallowEqual)},tr=s=>W.useCallback((...t)=>{const r=z(ee,s);return typeof r=="function"?r(...t):r},[s]),rr=s=>W.useMemo(()=>s.reduce((r,n)=>{const a=z(ee,n);return r[n]=typeof a=="function"?(...u)=>a(...u):a,r},{}),[s]);exports.RTKFrameWork=Ee;exports.appAction=Xt;exports.appActions=Zt;exports.appService=qt;exports.appServices=zt;exports.appState=Gt;exports.appStates=Ht;exports.useAppAction=tr;exports.useAppActions=rr;exports.useAppDispatch=et;exports.useAppService=Bt;exports.useAppServices=Jt;exports.useAppState=Qt;exports.useAppStates=er;
;