@rallie/core
Advanced tools
Comparing version 0.14.1 to 0.14.2
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RallieCore={})}(this,(function(e){"use strict";function t(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function n(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function i(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}function r(e,t){const n=Object.create(null),i=e.split(",");for(let e=0;e<i.length;e++)n[i[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}"production"===process.env.NODE_ENV||Object.freeze({}),"production"===process.env.NODE_ENV||Object.freeze([]);const s=Object.assign,o=Object.prototype.hasOwnProperty,a=(e,t)=>o.call(e,t),c=Array.isArray,l=e=>"[object Map]"===f(e),h=e=>"symbol"==typeof e,d=e=>null!==e&&"object"==typeof e,u=Object.prototype.toString,f=e=>u.call(e),p=e=>f(e).slice(8,-1),v=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,w=(e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))})((e=>e.charAt(0).toUpperCase()+e.slice(1))),g=(e,t)=>!Object.is(e,t),y=e=>{const t=parseFloat(e);return isNaN(t)?e:t};function E(e,...t){console.warn(`[Vue warn] ${e}`,...t)}let m;function _(e,t=m){t&&t.active&&t.effects.push(e)}const b=e=>{const t=new Set(e);return t.w=0,t.n=0,t},S=e=>(e.w&x)>0,N=e=>(e.n&x)>0,O=new WeakMap;let k=0,x=1;const j=30;let A;const R=Symbol("production"!==process.env.NODE_ENV?"iterate":""),P=Symbol("production"!==process.env.NODE_ENV?"Map key iterate":"");class ${constructor(e,t=null,n){this.fn=e,this.scheduler=t,this.active=!0,this.deps=[],this.parent=void 0,_(this,n)}run(){if(!this.active)return this.fn();let e=A,t=L;for(;e;){if(e===this)return;e=e.parent}try{return this.parent=A,A=this,L=!0,x=1<<++k,k<=j?(({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=x})(this):B(this),this.fn()}finally{k<=j&&(e=>{const{deps:t}=e;if(t.length){let n=0;for(let i=0;i<t.length;i++){const r=t[i];S(r)&&!N(r)?r.delete(e):t[n++]=r,r.w&=~x,r.n&=~x}t.length=n}})(this),x=1<<--k,A=this.parent,L=t,this.parent=void 0,this.deferStop&&this.stop()}}stop(){A===this?this.deferStop=!0:this.active&&(B(this),this.onStop&&this.onStop(),this.active=!1)}}function B(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}let L=!0;const M=[];function T(e,t,n){if(L&&A){let i=O.get(e);i||O.set(e,i=new Map);let r=i.get(n);r||i.set(n,r=b());!function(e,t){let n=!1;k<=j?N(e)||(e.n|=x,n=!S(e)):n=!e.has(A);n&&(e.add(A),A.deps.push(e),"production"!==process.env.NODE_ENV&&A.onTrack&&A.onTrack(Object.assign({effect:A},t)))}(r,"production"!==process.env.NODE_ENV?{effect:A,target:e,type:t,key:n}:void 0)}}function U(e,t,n,i,r,s){const o=O.get(e);if(!o)return;let a=[];if("clear"===t)a=[...o.values()];else if("length"===n&&c(e)){const e=y(i);o.forEach(((t,n)=>{("length"===n||n>=e)&&a.push(t)}))}else switch(void 0!==n&&a.push(o.get(n)),t){case"add":c(e)?v(n)&&a.push(o.get("length")):(a.push(o.get(R)),l(e)&&a.push(o.get(P)));break;case"delete":c(e)||(a.push(o.get(R)),l(e)&&a.push(o.get(P)));break;case"set":l(e)&&a.push(o.get(R))}const h="production"!==process.env.NODE_ENV?{target:e,type:t,key:n,newValue:i,oldValue:r,oldTarget:s}:void 0;if(1===a.length)a[0]&&("production"!==process.env.NODE_ENV?W(a[0],h):W(a[0]));else{const e=[];for(const t of a)t&&e.push(...t);"production"!==process.env.NODE_ENV?W(b(e),h):W(b(e))}}function W(e,t){const n=c(e)?e:[...e];for(const e of n)e.computed&&D(e,t);for(const e of n)e.computed||D(e,t)}function D(e,t){(e!==A||e.allowRecurse)&&("production"!==process.env.NODE_ENV&&e.onTrigger&&e.onTrigger(s({effect:e},t)),e.scheduler?e.scheduler():e.run())}const V=r("__proto__,__v_isRef,__isVue"),z=new Set(Object.getOwnPropertyNames(Symbol).filter((e=>"arguments"!==e&&"caller"!==e)).map((e=>Symbol[e])).filter(h)),C=K(),I=K(!0),F=H();function H(){const e={};return["includes","indexOf","lastIndexOf"].forEach((t=>{e[t]=function(...e){const n=Oe(this);for(let e=0,t=this.length;e<t;e++)T(n,"get",e+"");const i=n[t](...e);return-1===i||!1===i?n[t](...e.map(Oe)):i}})),["push","pop","shift","unshift","splice"].forEach((t=>{e[t]=function(...e){M.push(L),L=!1;const n=Oe(this)[t].apply(this,e);return function(){const e=M.pop();L=void 0===e||e}(),n}})),e}function K(e=!1,t=!1){return function(n,i,r){if("__v_isReactive"===i)return!e;if("__v_isReadonly"===i)return e;if("__v_isShallow"===i)return t;if("__v_raw"===i&&r===(e?t?me:Ee:t?ye:ge).get(n))return n;const s=c(n);if(!e&&s&&a(F,i))return Reflect.get(F,i,r);const o=Reflect.get(n,i,r);return(h(i)?z.has(i):V(i))?o:(e||T(n,"get",i),t?o:je(o)?s&&v(i)?o:o.value:d(o)?e?be(o):_e(o):o)}}function q(e=!1){return function(t,n,i,r){let s=t[n];if(Ne(s)&&je(s)&&!je(i))return!1;if(!e&&(function(e){return!(!e||!e.__v_isShallow)}(i)||Ne(i)||(s=Oe(s),i=Oe(i)),!c(t)&&je(s)&&!je(i)))return s.value=i,!0;const o=c(t)&&v(n)?Number(n)<t.length:a(t,n),l=Reflect.set(t,n,i,r);return t===Oe(r)&&(o?g(i,s)&&U(t,"set",n,i,s):U(t,"add",n,i)),l}}const G={get:C,set:q(),deleteProperty:function(e,t){const n=a(e,t),i=e[t],r=Reflect.deleteProperty(e,t);return r&&n&&U(e,"delete",t,void 0,i),r},has:function(e,t){const n=Reflect.has(e,t);return h(t)&&z.has(t)||T(e,"has",t),n},ownKeys:function(e){return T(e,"iterate",c(e)?"length":R),Reflect.ownKeys(e)}},J={get:I,set:(e,t)=>("production"!==process.env.NODE_ENV&&E(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0),deleteProperty:(e,t)=>("production"!==process.env.NODE_ENV&&E(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0)},Q=e=>e,X=e=>Reflect.getPrototypeOf(e);function Y(e,t,n=!1,i=!1){const r=Oe(e=e.__v_raw),s=Oe(t);n||(t!==s&&T(r,"get",t),T(r,"get",s));const{has:o}=X(r),a=i?Q:n?xe:ke;return o.call(r,t)?a(e.get(t)):o.call(r,s)?a(e.get(s)):void(e!==r&&e.get(t))}function Z(e,t=!1){const n=this.__v_raw,i=Oe(n),r=Oe(e);return t||(e!==r&&T(i,"has",e),T(i,"has",r)),e===r?n.has(e):n.has(e)||n.has(r)}function ee(e,t=!1){return e=e.__v_raw,!t&&T(Oe(e),"iterate",R),Reflect.get(e,"size",e)}function te(e){e=Oe(e);const t=Oe(this);return X(t).has.call(t,e)||(t.add(e),U(t,"add",e,e)),this}function ne(e,t){t=Oe(t);const n=Oe(this),{has:i,get:r}=X(n);let s=i.call(n,e);s?"production"!==process.env.NODE_ENV&&we(n,i,e):(e=Oe(e),s=i.call(n,e));const o=r.call(n,e);return n.set(e,t),s?g(t,o)&&U(n,"set",e,t,o):U(n,"add",e,t),this}function ie(e){const t=Oe(this),{has:n,get:i}=X(t);let r=n.call(t,e);r?"production"!==process.env.NODE_ENV&&we(t,n,e):(e=Oe(e),r=n.call(t,e));const s=i?i.call(t,e):void 0,o=t.delete(e);return r&&U(t,"delete",e,void 0,s),o}function re(){const e=Oe(this),t=0!==e.size,n="production"!==process.env.NODE_ENV?l(e)?new Map(e):new Set(e):void 0,i=e.clear();return t&&U(e,"clear",void 0,void 0,n),i}function se(e,t){return function(n,i){const r=this,s=r.__v_raw,o=Oe(s),a=t?Q:e?xe:ke;return!e&&T(o,"iterate",R),s.forEach(((e,t)=>n.call(i,a(e),a(t),r)))}}function oe(e,t,n){return function(...i){const r=this.__v_raw,s=Oe(r),o=l(s),a="entries"===e||e===Symbol.iterator&&o,c="keys"===e&&o,h=r[e](...i),d=n?Q:t?xe:ke;return!t&&T(s,"iterate",c?P:R),{next(){const{value:e,done:t}=h.next();return t?{value:e,done:t}:{value:a?[d(e[0]),d(e[1])]:d(e),done:t}},[Symbol.iterator](){return this}}}}function ae(e){return function(...t){if("production"!==process.env.NODE_ENV){const n=t[0]?`on key "${t[0]}" `:"";console.warn(`${w(e)} operation ${n}failed: target is readonly.`,Oe(this))}return"delete"!==e&&this}}function ce(){const e={get(e){return Y(this,e)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:ie,clear:re,forEach:se(!1,!1)},t={get(e){return Y(this,e,!1,!0)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:ie,clear:re,forEach:se(!1,!0)},n={get(e){return Y(this,e,!0)},get size(){return ee(this,!0)},has(e){return Z.call(this,e,!0)},add:ae("add"),set:ae("set"),delete:ae("delete"),clear:ae("clear"),forEach:se(!0,!1)},i={get(e){return Y(this,e,!0,!0)},get size(){return ee(this,!0)},has(e){return Z.call(this,e,!0)},add:ae("add"),set:ae("set"),delete:ae("delete"),clear:ae("clear"),forEach:se(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((r=>{e[r]=oe(r,!1,!1),n[r]=oe(r,!0,!1),t[r]=oe(r,!1,!0),i[r]=oe(r,!0,!0)})),[e,n,t,i]}const[le,he,de,ue]=ce();function fe(e,t){const n=t?e?ue:de:e?he:le;return(t,i,r)=>"__v_isReactive"===i?!e:"__v_isReadonly"===i?e:"__v_raw"===i?t:Reflect.get(a(n,i)&&i in t?n:t,i,r)}const pe={get:fe(!1,!1)},ve={get:fe(!0,!1)};function we(e,t,n){const i=Oe(n);if(i!==n&&t.call(e,i)){const t=p(e);console.warn(`Reactive ${t} contains both the raw and reactive versions of the same object${"Map"===t?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}const ge=new WeakMap,ye=new WeakMap,Ee=new WeakMap,me=new WeakMap;function _e(e){return Ne(e)?e:Se(e,!1,G,pe,ge)}function be(e){return Se(e,!0,J,ve,Ee)}function Se(e,t,n,i,r){if(!d(e))return"production"!==process.env.NODE_ENV&&console.warn(`value cannot be made reactive: ${String(e)}`),e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const s=r.get(e);if(s)return s;const o=(a=e).__v_skip||!Object.isExtensible(a)?0:function(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(p(a));var a;if(0===o)return e;const c=new Proxy(e,2===o?i:n);return r.set(e,c),c}function Ne(e){return!(!e||!e.__v_isReadonly)}function Oe(e){const t=e&&e.__v_raw;return t?Oe(t):e}const ke=e=>d(e)?_e(e):e,xe=e=>d(e)?be(e):e;function je(e){return!(!e||!0!==e.__v_isRef)}const Ae={removeNonExistedBroadcast:e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but ${e} hasn't been registed as a broadcast event`,wrongBroadcastCallback:e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but the listener hasn't been registed`,broadcastCallbackError:e=>`[@rallie/core] one of the callbacks of the broadcast event ${e} throws an uncaught error`,removeNonExistedUnicast:e=>`[@rallie/core] you are trying to remove a listener of the unicast event ${e}, but ${e} hasn't been registed as a unicast event`,registedExistedUnicast:e=>`[@rallie/core] you are trying to register a unicast event ${e}, but it has been registered before`,emittedNonExistedUnicast:e=>`[@rallie/core] you have emitted ${e} unicast, but there is no listener of this event`,createExistingApp:e=>`[@rallie/core] ${e} is existing, you are not allowed to create it again`,resourceNotDeclared:(e,t)=>`[@rallie/core] can not find any assets of the app ${e} on the bus ${t}`,appNotCreated:e=>`[@rallie/core] you are trying to activate app ${e}, but it was not created`,modifyPrivateState:e=>`[@rallie/core] state ${e} is private, you are not allowed to set it`,actionIsNotDefined:e=>`[@rallie/core] please describe your action when you modify the state ${e}`,accessUninitializedState:e=>`[@rallie/core] it's not allowed to set or watch state ${e} before it is initialized`,duplicatedInitial:e=>`[@rallie/core] duplicated initialized state ${e}`,initializePrimitiveState:e=>`[@rallie/core] it's not allowed to initialized state ${e} to a primitive value`,duplicatedBus:e=>`[@rallie/core] the bus named ${e} has been defined before, please rename your bus`,circularDependencies:(e,t)=>`[@rallie/core] There is a circular dependency when activating the app ${e}, and the circular path is ${t.join("->")}`,multipleCalledNextFn:()=>"[@rallie/core] next() called multiple times in the middleware",wrongMiddlewareType:()=>"[@rallie/core] the middleware must be a function"},Re={handlerIsNotInTheEventsPool:(e,t)=>`[@rallie/core] the event ${e} is not in the events pool that you specified when calling on${t?"Unicast":"Broadcast"}`};const Pe=e=>(t,n)=>{let i=-1;const r=s=>{if(s<=i)return Promise.reject(new Error(Ae.multipleCalledNextFn()));i=s;let o=e[s];if(s===e.length&&(o=n),!o)return Promise.resolve();try{return Promise.resolve(o(t,r.bind(null,s+1)))}catch(e){return Promise.reject(e)}};return r(0)};var $e,Be,Le,Me,Te,Ue,We,De,Ve;class ze{constructor(){$e.set(this,{}),Be.set(this,{})}addBroadcastEventListener(e,t){n(this,$e,"f")[e]=n(this,$e,"f")[e]||new Set;n(this,$e,"f")[e].add(t)}addUnicastEventListener(e,t){if(n(this,Be,"f")[e])throw new Error(Ae.registedExistedUnicast(e));n(this,Be,"f")[e]=t}removeBroadcastEventListener(e,t){const i=n(this,$e,"f")[e];if(!i){const t=Ae.removeNonExistedBroadcast(e);throw new Error(t)}if(!i.has(t)){const t=Ae.wrongBroadcastCallback(e);throw new Error(t)}i.delete(t)}removeUnicastEventListener(e){if(!n(this,Be,"f")[e]){const t=Ae.removeNonExistedUnicast(e);throw new Error(t)}delete n(this,Be,"f")[e]}emitBroadcast(e,...t){n(this,$e,"f")[e]=n(this,$e,"f")[e]||new Set;n(this,$e,"f")[e].forEach((n=>{try{n(...t)}catch(t){console.error(Ae.broadcastCallbackError(e)),console.error(t)}}))}emitUnicast(e,...t){const i=n(this,Be,"f")[e];if(i)return i(...t);throw new Error(Ae.emittedNonExistedUnicast(e))}}$e=new WeakMap,Be=new WeakMap;class Ce{constructor(e,t){Le.set(this,void 0),Me.set(this,void 0),i(this,Le,e,"f"),i(this,Me,t,"f"),n(this,Me,"f")[e].watchers.add(this)}do(e){return this.handler=e,()=>this.unwatch()}unwatch(){null==this||this.stopEffect(),this.handler=null;const e=n(this,Me,"f")[n(this,Le,"f")].watchers;e.has(this)&&e.delete(this)}}Le=new WeakMap,Me=new WeakMap;class Ie{constructor(e,t){Te.add(this),Ue.set(this,void 0),We.set(this,void 0),i(this,Ue,e,"f"),i(this,We,t,"f")}onBroadcast(e){return Object.entries(e).forEach((([e,t])=>{n(this,Ue,"f").addBroadcastEventListener(e,t)})),t=>{n(this,Te,"m",De).call(this,e,!1,t)}}onUnicast(e){return Object.entries(e).forEach((([e,t])=>{try{n(this,Ue,"f").addUnicastEventListener(e,t)}catch(e){console.error(e)}})),t=>{n(this,Te,"m",De).call(this,e,!0,t)}}createBroadcaster(e){return new Proxy({},{get:(t,i)=>(...t)=>n(this,Ue,"f").emitBroadcast(i,...t,null==e?void 0:e(i)),set:()=>!1})}createUnicaster(e){return new Proxy({},{get:(t,i)=>(...t)=>n(this,Ue,"f").emitUnicast(i,...t,null==e?void 0:e(i)),set:()=>!1})}existState(e){return!!n(this,We,"f")[e]}initState(e,t,i=!1){if(this.existState(e))throw new Error(Ae.duplicatedInitial(e));if(["string","number","boolean","undefined"].includes(typeof t))throw new Error(Ae.initializePrimitiveState(e));return n(this,We,"f")[e]={state:_e(t),owner:i?this:null,watchers:new Set},n(this,Ue,"f").emitBroadcast("$state-initialized",e),this.getState(e)}getState(e,t){if(this.existState(e)){const i=be(n(this,We,"f")[e].state);return t?t(i):i}return null}setState(e,i,r){return t(this,void 0,void 0,(function*(){const t=n(this,Te,"m",Ve).call(this,e);if(!i)throw new Error(Ae.actionIsNotDefined(e));{const e=r(t);yield Promise.resolve(e)}}))}watchState(e,t){if(!this.existState(e)){const t=Ae.accessUninitializedState(e);throw new Error(t)}let i=!1;const r=be(n(this,We,"f")[e].state),o=new Ce(e,n(this,We,"f")),a=function(e,t){e.effect&&(e=e.effect.fn);const n=new $(e);t&&(s(n,t),t.scope&&_(n,t.scope)),t&&t.lazy||n.run();const i=n.run.bind(n);return i.effect=n,i}((()=>t(r)),{lazy:!0,scheduler:()=>{i||(i=!0,Promise.resolve().then((()=>{var e;const n=Oe(t(r));null===(e=o.handler)||void 0===e||e.call(o,n,o.oldWatchingStates),o.oldWatchingStates=Oe(n),i=!1})))}});return o.oldWatchingStates=a(),o.stopEffect=()=>a.effect.stop(),o}}Ue=new WeakMap,We=new WeakMap,Te=new WeakSet,De=function(e,t,i){let r=t?n(this,Ue,"f").removeUnicastEventListener:n(this,Ue,"f").removeBroadcastEventListener;r=r.bind(n(this,Ue,"f")),i?e[i]?(r(i,e[i]),delete e[i]):console.warn(Re.handlerIsNotInTheEventsPool(i,t)):Object.entries(e).forEach((([e,t])=>{r(e,t)}))},Ve=function(e){if(!this.existState(e)){const t=Ae.accessUninitializedState(e);throw new Error(t)}const t=n(this,We,"f")[e].owner;if(t!==this&&null!==t){const t=Ae.modifyPrivateState(e);throw new Error(t)}return n(this,We,"f")[e].state};class Fe{constructor(e){this.name=e,this.activated=null,this.dependencies=[],this.relatedApps=[],this.name=e,this.isRallieCoreApp=!0}relateTo(e){return this.relatedApps=Array.from(new Set([...this.relatedApps,...e])),this}relyOn(e){return this.relateTo(e),this.dependencies=Array.from(new Set([...this.dependencies,...e])),this}onActivate(e){return this.doActivate=e,this}}var He,Ke,qe,Ge,Je,Qe,Xe,Ye,Ze,et,tt,nt,it,rt,st={loadScript:e=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{let n=null;if(e instanceof HTMLScriptElement)n=e;else{n=document.createElement("script");const t="string"!=typeof e?e:{type:"text/javascript",src:e};Object.entries(t).forEach((([e,t])=>{n.setAttribute(e,t)}))}n.src&&(n.onload=n.onerror=()=>{t()}),document.body.appendChild(n),n.src||t()}))})),loadLink:e=>{let t=null;if(e instanceof HTMLLinkElement)t=e;else{const n="string"!=typeof e?e:{rel:"stylesheet",type:"text/css",href:e};t=document.createElement("link"),Object.entries(n).forEach((([e,n])=>{t.setAttribute(e,n)}))}document.head.appendChild(t)}};class ot{constructor(e){He.add(this),Ke.set(this,void 0),qe.set(this,new ze),Ge.set(this,{}),Je.set(this,{}),Qe.set(this,{}),this.conf=be({assets:{}}),Xe.set(this,[]),Ye.set(this,void 0),i(this,Ke,e,"f"),i(this,Ye,Pe(n(this,Xe,"f")),"f")}createSocket(){return new Ie(n(this,qe,"f"),n(this,Ge,"f"))}existApp(e){return!!n(this,Je,"f")[e]}createApp(e){if(this.existApp(e))throw new Error(Ae.createExistingApp(e));const t=new Fe(e);return n(this,Je,"f")[e]=t,t}loadApp(e){return t(this,void 0,void 0,(function*(){n(this,Je,"f")[e]||(n(this,Qe,"f")[e]||(n(this,Qe,"f")[e]=new Promise(((t,i)=>{const r=n(this,He,"m",et).call(this,e);n(this,Ye,"f").call(this,r,n(this,He,"m",tt).bind(this)).then((()=>{e.startsWith("lib:")&&!n(this,Je,"f")[e]&&(n(this,Je,"f")[e]=!0),n(this,Je,"f")[e]||i(new Error(Ae.appNotCreated(e))),t()})).catch((e=>{i(e)}))}))),yield n(this,Qe,"f")[e])}))}activateApp(e){return t(this,void 0,void 0,(function*(){yield n(this,He,"m",nt).call(this,e,[])}))}config(e){return this.conf=Object.assign(Object.assign(Object.assign({},this.conf),e),{assets:Object.assign(Object.assign({},this.conf.assets),(null==e?void 0:e.assets)||{})}),this}use(e){if("function"!=typeof e)throw new Error(Ae.wrongMiddlewareType());return n(this,Xe,"f").push(e),i(this,Ye,Pe(n(this,Xe,"f")),"f"),this}}Ke=new WeakMap,qe=new WeakMap,Ge=new WeakMap,Je=new WeakMap,Qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,He=new WeakSet,Ze=function(e){return n(this,Je,"f")[e]&&"boolean"!=typeof n(this,Je,"f")[e]},et=function(e){return{name:e,loadScript:st.loadScript,loadLink:st.loadLink}},tt=function(e){return t(this,void 0,void 0,(function*(){const{name:t,loadScript:i=st.loadScript,loadLink:r=st.loadLink}=e,{assets:s}=this.conf;if(!s[t])throw new Error(Ae.resourceNotDeclared(t,n(this,Ke,"f")));if(s[t].css&&s[t].css.forEach((e=>{r(e)})),s[t].js)for(const e of s[t].js)yield i(e)}))},nt=function(e,i){return t(this,void 0,void 0,(function*(){if(yield this.loadApp(e),n(this,He,"m",Ze).call(this,e)){const r=n(this,Je,"f")[e];if(yield n(this,He,"m",rt).call(this,r),i.includes(e)){const t=i.indexOf(e),n=[...i.slice(t),e];throw new Error(Ae.circularDependencies(e,n))}if(i.push(e),!r.activated){const e=()=>t(this,void 0,void 0,(function*(){yield n(this,He,"m",it).call(this,r,i),r.doActivate&&(yield Promise.resolve(r.doActivate()))}));r.activated=e()}yield r.activated,i.pop()}}))},it=function(e,i){return t(this,void 0,void 0,(function*(){if(0!==e.dependencies.length)for(const t of e.dependencies)yield n(this,He,"m",nt).call(this,t,i)}))},rt=function(e){return t(this,void 0,void 0,(function*(){yield Promise.all(e.relatedApps.map((e=>this.loadApp(e))))}))};const at={},ct="DEFAULT_BUS",lt=(e=ct)=>{if(void 0===window.RALLIE_BUS_STORE&&Reflect.defineProperty(window,"RALLIE_BUS_STORE",{value:at,writable:!1}),window.RALLIE_BUS_STORE[e])throw new Error(Ae.duplicatedBus(e));{const t=new ot(e);return Reflect.defineProperty(window.RALLIE_BUS_STORE,e,{value:t,writable:!1}),t}},ht=(e=ct)=>window.RALLIE_BUS_STORE&&window.RALLIE_BUS_STORE[e],dt=(e=ct)=>{let t=null,n=!1;const i=ht(e);return i?(t=i,n=!1):(t=lt(e),n=!0),[t,n]},ut={createBus:lt,getBus:ht,touchBus:dt,Bus:ot};e.App=Fe,e.Bus=ot,e.Errors=Ae,e.Socket=Ie,e.Warnings=Re,e.createBus=lt,e.default=ut,e.getBus=ht,e.touchBus=dt,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RallieCore={})}(this,(function(e){"use strict";function t(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function n(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function i(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}function r(e,t){const n=Object.create(null),i=e.split(",");for(let e=0;e<i.length;e++)n[i[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}"production"===process.env.NODE_ENV||Object.freeze({}),"production"===process.env.NODE_ENV||Object.freeze([]);const s=Object.assign,o=Object.prototype.hasOwnProperty,a=(e,t)=>o.call(e,t),c=Array.isArray,l=e=>"[object Map]"===f(e),h=e=>"symbol"==typeof e,d=e=>null!==e&&"object"==typeof e,u=Object.prototype.toString,f=e=>u.call(e),p=e=>f(e).slice(8,-1),v=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,w=(e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))})((e=>e.charAt(0).toUpperCase()+e.slice(1))),g=(e,t)=>!Object.is(e,t),y=e=>{const t=parseFloat(e);return isNaN(t)?e:t};function E(e,...t){console.warn(`[Vue warn] ${e}`,...t)}let m;function _(e,t=m){t&&t.active&&t.effects.push(e)}const b=e=>{const t=new Set(e);return t.w=0,t.n=0,t},S=e=>(e.w&x)>0,N=e=>(e.n&x)>0,O=new WeakMap;let k=0,x=1;const j=30;let A;const R=Symbol("production"!==process.env.NODE_ENV?"iterate":""),P=Symbol("production"!==process.env.NODE_ENV?"Map key iterate":"");class ${constructor(e,t=null,n){this.fn=e,this.scheduler=t,this.active=!0,this.deps=[],this.parent=void 0,_(this,n)}run(){if(!this.active)return this.fn();let e=A,t=L;for(;e;){if(e===this)return;e=e.parent}try{return this.parent=A,A=this,L=!0,x=1<<++k,k<=j?(({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=x})(this):B(this),this.fn()}finally{k<=j&&(e=>{const{deps:t}=e;if(t.length){let n=0;for(let i=0;i<t.length;i++){const r=t[i];S(r)&&!N(r)?r.delete(e):t[n++]=r,r.w&=~x,r.n&=~x}t.length=n}})(this),x=1<<--k,A=this.parent,L=t,this.parent=void 0,this.deferStop&&this.stop()}}stop(){A===this?this.deferStop=!0:this.active&&(B(this),this.onStop&&this.onStop(),this.active=!1)}}function B(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}let L=!0;const M=[];function T(e,t,n){if(L&&A){let i=O.get(e);i||O.set(e,i=new Map);let r=i.get(n);r||i.set(n,r=b());!function(e,t){let n=!1;k<=j?N(e)||(e.n|=x,n=!S(e)):n=!e.has(A);n&&(e.add(A),A.deps.push(e),"production"!==process.env.NODE_ENV&&A.onTrack&&A.onTrack(Object.assign({effect:A},t)))}(r,"production"!==process.env.NODE_ENV?{effect:A,target:e,type:t,key:n}:void 0)}}function U(e,t,n,i,r,s){const o=O.get(e);if(!o)return;let a=[];if("clear"===t)a=[...o.values()];else if("length"===n&&c(e)){const e=y(i);o.forEach(((t,n)=>{("length"===n||n>=e)&&a.push(t)}))}else switch(void 0!==n&&a.push(o.get(n)),t){case"add":c(e)?v(n)&&a.push(o.get("length")):(a.push(o.get(R)),l(e)&&a.push(o.get(P)));break;case"delete":c(e)||(a.push(o.get(R)),l(e)&&a.push(o.get(P)));break;case"set":l(e)&&a.push(o.get(R))}const h="production"!==process.env.NODE_ENV?{target:e,type:t,key:n,newValue:i,oldValue:r,oldTarget:s}:void 0;if(1===a.length)a[0]&&("production"!==process.env.NODE_ENV?W(a[0],h):W(a[0]));else{const e=[];for(const t of a)t&&e.push(...t);"production"!==process.env.NODE_ENV?W(b(e),h):W(b(e))}}function W(e,t){const n=c(e)?e:[...e];for(const e of n)e.computed&&D(e,t);for(const e of n)e.computed||D(e,t)}function D(e,t){(e!==A||e.allowRecurse)&&("production"!==process.env.NODE_ENV&&e.onTrigger&&e.onTrigger(s({effect:e},t)),e.scheduler?e.scheduler():e.run())}const V=r("__proto__,__v_isRef,__isVue"),z=new Set(Object.getOwnPropertyNames(Symbol).filter((e=>"arguments"!==e&&"caller"!==e)).map((e=>Symbol[e])).filter(h)),C=K(),I=K(!0),F=H();function H(){const e={};return["includes","indexOf","lastIndexOf"].forEach((t=>{e[t]=function(...e){const n=Oe(this);for(let e=0,t=this.length;e<t;e++)T(n,"get",e+"");const i=n[t](...e);return-1===i||!1===i?n[t](...e.map(Oe)):i}})),["push","pop","shift","unshift","splice"].forEach((t=>{e[t]=function(...e){M.push(L),L=!1;const n=Oe(this)[t].apply(this,e);return function(){const e=M.pop();L=void 0===e||e}(),n}})),e}function K(e=!1,t=!1){return function(n,i,r){if("__v_isReactive"===i)return!e;if("__v_isReadonly"===i)return e;if("__v_isShallow"===i)return t;if("__v_raw"===i&&r===(e?t?me:Ee:t?ye:ge).get(n))return n;const s=c(n);if(!e&&s&&a(F,i))return Reflect.get(F,i,r);const o=Reflect.get(n,i,r);return(h(i)?z.has(i):V(i))?o:(e||T(n,"get",i),t?o:je(o)?s&&v(i)?o:o.value:d(o)?e?be(o):_e(o):o)}}function q(e=!1){return function(t,n,i,r){let s=t[n];if(Ne(s)&&je(s)&&!je(i))return!1;if(!e&&(function(e){return!(!e||!e.__v_isShallow)}(i)||Ne(i)||(s=Oe(s),i=Oe(i)),!c(t)&&je(s)&&!je(i)))return s.value=i,!0;const o=c(t)&&v(n)?Number(n)<t.length:a(t,n),l=Reflect.set(t,n,i,r);return t===Oe(r)&&(o?g(i,s)&&U(t,"set",n,i,s):U(t,"add",n,i)),l}}const G={get:C,set:q(),deleteProperty:function(e,t){const n=a(e,t),i=e[t],r=Reflect.deleteProperty(e,t);return r&&n&&U(e,"delete",t,void 0,i),r},has:function(e,t){const n=Reflect.has(e,t);return h(t)&&z.has(t)||T(e,"has",t),n},ownKeys:function(e){return T(e,"iterate",c(e)?"length":R),Reflect.ownKeys(e)}},J={get:I,set:(e,t)=>("production"!==process.env.NODE_ENV&&E(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0),deleteProperty:(e,t)=>("production"!==process.env.NODE_ENV&&E(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0)},Q=e=>e,X=e=>Reflect.getPrototypeOf(e);function Y(e,t,n=!1,i=!1){const r=Oe(e=e.__v_raw),s=Oe(t);n||(t!==s&&T(r,"get",t),T(r,"get",s));const{has:o}=X(r),a=i?Q:n?xe:ke;return o.call(r,t)?a(e.get(t)):o.call(r,s)?a(e.get(s)):void(e!==r&&e.get(t))}function Z(e,t=!1){const n=this.__v_raw,i=Oe(n),r=Oe(e);return t||(e!==r&&T(i,"has",e),T(i,"has",r)),e===r?n.has(e):n.has(e)||n.has(r)}function ee(e,t=!1){return e=e.__v_raw,!t&&T(Oe(e),"iterate",R),Reflect.get(e,"size",e)}function te(e){e=Oe(e);const t=Oe(this);return X(t).has.call(t,e)||(t.add(e),U(t,"add",e,e)),this}function ne(e,t){t=Oe(t);const n=Oe(this),{has:i,get:r}=X(n);let s=i.call(n,e);s?"production"!==process.env.NODE_ENV&&we(n,i,e):(e=Oe(e),s=i.call(n,e));const o=r.call(n,e);return n.set(e,t),s?g(t,o)&&U(n,"set",e,t,o):U(n,"add",e,t),this}function ie(e){const t=Oe(this),{has:n,get:i}=X(t);let r=n.call(t,e);r?"production"!==process.env.NODE_ENV&&we(t,n,e):(e=Oe(e),r=n.call(t,e));const s=i?i.call(t,e):void 0,o=t.delete(e);return r&&U(t,"delete",e,void 0,s),o}function re(){const e=Oe(this),t=0!==e.size,n="production"!==process.env.NODE_ENV?l(e)?new Map(e):new Set(e):void 0,i=e.clear();return t&&U(e,"clear",void 0,void 0,n),i}function se(e,t){return function(n,i){const r=this,s=r.__v_raw,o=Oe(s),a=t?Q:e?xe:ke;return!e&&T(o,"iterate",R),s.forEach(((e,t)=>n.call(i,a(e),a(t),r)))}}function oe(e,t,n){return function(...i){const r=this.__v_raw,s=Oe(r),o=l(s),a="entries"===e||e===Symbol.iterator&&o,c="keys"===e&&o,h=r[e](...i),d=n?Q:t?xe:ke;return!t&&T(s,"iterate",c?P:R),{next(){const{value:e,done:t}=h.next();return t?{value:e,done:t}:{value:a?[d(e[0]),d(e[1])]:d(e),done:t}},[Symbol.iterator](){return this}}}}function ae(e){return function(...t){if("production"!==process.env.NODE_ENV){const n=t[0]?`on key "${t[0]}" `:"";console.warn(`${w(e)} operation ${n}failed: target is readonly.`,Oe(this))}return"delete"!==e&&this}}function ce(){const e={get(e){return Y(this,e)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:ie,clear:re,forEach:se(!1,!1)},t={get(e){return Y(this,e,!1,!0)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:ie,clear:re,forEach:se(!1,!0)},n={get(e){return Y(this,e,!0)},get size(){return ee(this,!0)},has(e){return Z.call(this,e,!0)},add:ae("add"),set:ae("set"),delete:ae("delete"),clear:ae("clear"),forEach:se(!0,!1)},i={get(e){return Y(this,e,!0,!0)},get size(){return ee(this,!0)},has(e){return Z.call(this,e,!0)},add:ae("add"),set:ae("set"),delete:ae("delete"),clear:ae("clear"),forEach:se(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((r=>{e[r]=oe(r,!1,!1),n[r]=oe(r,!0,!1),t[r]=oe(r,!1,!0),i[r]=oe(r,!0,!0)})),[e,n,t,i]}const[le,he,de,ue]=ce();function fe(e,t){const n=t?e?ue:de:e?he:le;return(t,i,r)=>"__v_isReactive"===i?!e:"__v_isReadonly"===i?e:"__v_raw"===i?t:Reflect.get(a(n,i)&&i in t?n:t,i,r)}const pe={get:fe(!1,!1)},ve={get:fe(!0,!1)};function we(e,t,n){const i=Oe(n);if(i!==n&&t.call(e,i)){const t=p(e);console.warn(`Reactive ${t} contains both the raw and reactive versions of the same object${"Map"===t?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}const ge=new WeakMap,ye=new WeakMap,Ee=new WeakMap,me=new WeakMap;function _e(e){return Ne(e)?e:Se(e,!1,G,pe,ge)}function be(e){return Se(e,!0,J,ve,Ee)}function Se(e,t,n,i,r){if(!d(e))return"production"!==process.env.NODE_ENV&&console.warn(`value cannot be made reactive: ${String(e)}`),e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const s=r.get(e);if(s)return s;const o=(a=e).__v_skip||!Object.isExtensible(a)?0:function(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(p(a));var a;if(0===o)return e;const c=new Proxy(e,2===o?i:n);return r.set(e,c),c}function Ne(e){return!(!e||!e.__v_isReadonly)}function Oe(e){const t=e&&e.__v_raw;return t?Oe(t):e}const ke=e=>d(e)?_e(e):e,xe=e=>d(e)?be(e):e;function je(e){return!(!e||!0!==e.__v_isRef)}const Ae={removeNonExistedBroadcast:e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but ${e} hasn't been registed as a broadcast event`,wrongBroadcastCallback:e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but the listener hasn't been registed`,broadcastCallbackError:e=>`[@rallie/core] one of the callbacks of the broadcast event ${e} throws an uncaught error`,removeNonExistedUnicast:e=>`[@rallie/core] you are trying to remove a listener of the unicast event ${e}, but ${e} hasn't been registed as a unicast event`,registedExistedUnicast:e=>`[@rallie/core] you are trying to register a unicast event ${e}, but it has been registered before`,emittedNonExistedUnicast:e=>`[@rallie/core] you have emitted ${e} unicast, but there is no listener of this event`,createExistingApp:e=>`[@rallie/core] ${e} is existing, you are not allowed to create it again`,resourceNotDeclared:(e,t)=>`[@rallie/core] can not find any assets of the app ${e} on the bus ${t}`,appNotCreated:e=>`[@rallie/core] you are trying to activate app ${e}, but it was not created`,modifyPrivateState:e=>`[@rallie/core] state ${e} is private, you are not allowed to set it`,actionIsNotDefined:e=>`[@rallie/core] please describe your action when you modify the state ${e}`,accessUninitializedState:e=>`[@rallie/core] it's not allowed to set or watch state ${e} before it is initialized`,duplicatedInitial:e=>`[@rallie/core] duplicated initialized state ${e}`,initializePrimitiveState:e=>`[@rallie/core] it's not allowed to initialized state ${e} to a primitive value`,duplicatedBus:e=>`[@rallie/core] the bus named ${e} has been defined before, please rename your bus`,circularDependencies:(e,t)=>`[@rallie/core] There is a circular dependency when activating the app ${e}, and the circular path is ${t.join("->")}`,multipleCalledNextFn:()=>"[@rallie/core] next() called multiple times in the middleware",wrongMiddlewareType:()=>"[@rallie/core] the middleware must be a function"},Re={handlerIsNotInTheEventsPool:(e,t)=>`[@rallie/core] the event ${e} is not in the events pool that you specified when calling on${t?"Unicast":"Broadcast"}`};const Pe=e=>(t,n)=>{let i=-1;const r=s=>{if(s<=i)return Promise.reject(new Error(Ae.multipleCalledNextFn()));i=s;let o=e[s];if(s===e.length&&(o=n),!o)return Promise.resolve();try{return Promise.resolve(o(t,r.bind(null,s+1)))}catch(e){return Promise.reject(e)}};return r(0)};var $e,Be,Le,Me,Te,Ue,We,De,Ve;class ze{constructor(){$e.set(this,{}),Be.set(this,{})}addBroadcastEventListener(e,t){n(this,$e,"f")[e]=n(this,$e,"f")[e]||new Set;n(this,$e,"f")[e].add(t)}addUnicastEventListener(e,t){if(n(this,Be,"f")[e])throw new Error(Ae.registedExistedUnicast(e));n(this,Be,"f")[e]=t}removeBroadcastEventListener(e,t){const i=n(this,$e,"f")[e];if(!i){const t=Ae.removeNonExistedBroadcast(e);throw new Error(t)}if(!i.has(t)){const t=Ae.wrongBroadcastCallback(e);throw new Error(t)}i.delete(t)}removeUnicastEventListener(e){if(!n(this,Be,"f")[e]){const t=Ae.removeNonExistedUnicast(e);throw new Error(t)}delete n(this,Be,"f")[e]}emitBroadcast(e,...t){n(this,$e,"f")[e]=n(this,$e,"f")[e]||new Set;n(this,$e,"f")[e].forEach((n=>{try{n(...t)}catch(t){console.error(Ae.broadcastCallbackError(e)),console.error(t)}}))}emitUnicast(e,...t){const i=n(this,Be,"f")[e];if(i)return i(...t);throw new Error(Ae.emittedNonExistedUnicast(e))}}$e=new WeakMap,Be=new WeakMap;class Ce{constructor(e,t){Le.set(this,void 0),Me.set(this,void 0),i(this,Le,e,"f"),i(this,Me,t,"f"),n(this,Me,"f")[e].watchers.add(this)}do(e){return this.handler=e,()=>this.unwatch()}unwatch(){null==this||this.stopEffect(),this.handler=null;const e=n(this,Me,"f")[n(this,Le,"f")].watchers;e.has(this)&&e.delete(this)}}Le=new WeakMap,Me=new WeakMap;class Ie{constructor(e,t){Te.add(this),Ue.set(this,void 0),We.set(this,void 0),i(this,Ue,e,"f"),i(this,We,t,"f")}onBroadcast(e){return Object.entries(e).forEach((([e,t])=>{n(this,Ue,"f").addBroadcastEventListener(e,t)})),t=>{n(this,Te,"m",De).call(this,e,!1,t)}}onUnicast(e){return Object.entries(e).forEach((([e,t])=>{try{n(this,Ue,"f").addUnicastEventListener(e,t)}catch(e){console.error(e)}})),t=>{n(this,Te,"m",De).call(this,e,!0,t)}}createBroadcaster(e){return new Proxy({},{get:(t,i)=>(...t)=>(null==e||e(i),n(this,Ue,"f").emitBroadcast(i,...t)),set:()=>!1})}createUnicaster(e){return new Proxy({},{get:(t,i)=>(...t)=>(null==e||e(i),n(this,Ue,"f").emitUnicast(i,...t)),set:()=>!1})}existState(e){return!!n(this,We,"f")[e]}initState(e,t,i=!1){if(this.existState(e))throw new Error(Ae.duplicatedInitial(e));if(["string","number","boolean","undefined"].includes(typeof t))throw new Error(Ae.initializePrimitiveState(e));return n(this,We,"f")[e]={state:_e(t),owner:i?this:null,watchers:new Set},n(this,Ue,"f").emitBroadcast("$state-initialized",e),this.getState(e)}getState(e,t){if(this.existState(e)){const i=be(n(this,We,"f")[e].state);return t?t(i):i}return null}setState(e,i,r){return t(this,void 0,void 0,(function*(){const t=n(this,Te,"m",Ve).call(this,e);if(!i)throw new Error(Ae.actionIsNotDefined(e));{const e=r(t);yield Promise.resolve(e)}}))}watchState(e,t){if(!this.existState(e)){const t=Ae.accessUninitializedState(e);throw new Error(t)}let i=!1;const r=be(n(this,We,"f")[e].state),o=new Ce(e,n(this,We,"f")),a=function(e,t){e.effect&&(e=e.effect.fn);const n=new $(e);t&&(s(n,t),t.scope&&_(n,t.scope)),t&&t.lazy||n.run();const i=n.run.bind(n);return i.effect=n,i}((()=>t(r)),{lazy:!0,scheduler:()=>{i||(i=!0,Promise.resolve().then((()=>{var e;const n=Oe(t(r));null===(e=o.handler)||void 0===e||e.call(o,n,o.oldWatchingStates),o.oldWatchingStates=Oe(n),i=!1})))}});return o.oldWatchingStates=a(),o.stopEffect=()=>a.effect.stop(),o}}Ue=new WeakMap,We=new WeakMap,Te=new WeakSet,De=function(e,t,i){let r=t?n(this,Ue,"f").removeUnicastEventListener:n(this,Ue,"f").removeBroadcastEventListener;r=r.bind(n(this,Ue,"f")),i?e[i]?(r(i,e[i]),delete e[i]):console.warn(Re.handlerIsNotInTheEventsPool(i,t)):Object.entries(e).forEach((([e,t])=>{r(e,t)}))},Ve=function(e){if(!this.existState(e)){const t=Ae.accessUninitializedState(e);throw new Error(t)}const t=n(this,We,"f")[e].owner;if(t!==this&&null!==t){const t=Ae.modifyPrivateState(e);throw new Error(t)}return n(this,We,"f")[e].state};class Fe{constructor(e){this.name=e,this.activated=null,this.dependencies=[],this.relatedApps=[],this.name=e,this.isRallieCoreApp=!0}relateTo(e){return this.relatedApps=Array.from(new Set([...this.relatedApps,...e])),this}relyOn(e){return this.relateTo(e),this.dependencies=Array.from(new Set([...this.dependencies,...e])),this}onActivate(e){return this.doActivate=e,this}}var He,Ke,qe,Ge,Je,Qe,Xe,Ye,Ze,et,tt,nt,it,rt,st={loadScript:e=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{let n=null;if(e instanceof HTMLScriptElement)n=e;else{n=document.createElement("script");const t="string"!=typeof e?e:{type:"text/javascript",src:e};Object.entries(t).forEach((([e,t])=>{n.setAttribute(e,t)}))}n.src&&(n.onload=n.onerror=()=>{t()}),document.body.appendChild(n),n.src||t()}))})),loadLink:e=>{let t=null;if(e instanceof HTMLLinkElement)t=e;else{const n="string"!=typeof e?e:{rel:"stylesheet",type:"text/css",href:e};t=document.createElement("link"),Object.entries(n).forEach((([e,n])=>{t.setAttribute(e,n)}))}document.head.appendChild(t)}};class ot{constructor(e){He.add(this),Ke.set(this,void 0),qe.set(this,new ze),Ge.set(this,{}),Je.set(this,{}),Qe.set(this,{}),this.conf=be({assets:{}}),Xe.set(this,[]),Ye.set(this,void 0),i(this,Ke,e,"f"),i(this,Ye,Pe(n(this,Xe,"f")),"f")}createSocket(){return new Ie(n(this,qe,"f"),n(this,Ge,"f"))}existApp(e){return!!n(this,Je,"f")[e]}createApp(e){if(this.existApp(e))throw new Error(Ae.createExistingApp(e));const t=new Fe(e);return n(this,Je,"f")[e]=t,t}loadApp(e){return t(this,void 0,void 0,(function*(){n(this,Je,"f")[e]||(n(this,Qe,"f")[e]||(n(this,Qe,"f")[e]=new Promise(((t,i)=>{const r=n(this,He,"m",et).call(this,e);n(this,Ye,"f").call(this,r,n(this,He,"m",tt).bind(this)).then((()=>{e.startsWith("lib:")&&!n(this,Je,"f")[e]&&(n(this,Je,"f")[e]=!0),n(this,Je,"f")[e]||i(new Error(Ae.appNotCreated(e))),t()})).catch((e=>{i(e)}))}))),yield n(this,Qe,"f")[e])}))}activateApp(e){return t(this,void 0,void 0,(function*(){yield n(this,He,"m",nt).call(this,e,[])}))}config(e){return this.conf=Object.assign(Object.assign(Object.assign({},this.conf),e),{assets:Object.assign(Object.assign({},this.conf.assets),(null==e?void 0:e.assets)||{})}),this}use(e){if("function"!=typeof e)throw new Error(Ae.wrongMiddlewareType());return n(this,Xe,"f").push(e),i(this,Ye,Pe(n(this,Xe,"f")),"f"),this}}Ke=new WeakMap,qe=new WeakMap,Ge=new WeakMap,Je=new WeakMap,Qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,He=new WeakSet,Ze=function(e){return n(this,Je,"f")[e]&&"boolean"!=typeof n(this,Je,"f")[e]},et=function(e){return{name:e,loadScript:st.loadScript,loadLink:st.loadLink}},tt=function(e){return t(this,void 0,void 0,(function*(){const{name:t,loadScript:i=st.loadScript,loadLink:r=st.loadLink}=e,{assets:s}=this.conf;if(!s[t])throw new Error(Ae.resourceNotDeclared(t,n(this,Ke,"f")));if(s[t].css&&s[t].css.forEach((e=>{r(e)})),s[t].js)for(const e of s[t].js)yield i(e)}))},nt=function(e,i){return t(this,void 0,void 0,(function*(){if(yield this.loadApp(e),n(this,He,"m",Ze).call(this,e)){const r=n(this,Je,"f")[e];if(yield n(this,He,"m",rt).call(this,r),i.includes(e)){const t=i.indexOf(e),n=[...i.slice(t),e];throw new Error(Ae.circularDependencies(e,n))}if(i.push(e),!r.activated){const e=()=>t(this,void 0,void 0,(function*(){yield n(this,He,"m",it).call(this,r,i),r.doActivate&&(yield Promise.resolve(r.doActivate()))}));r.activated=e()}yield r.activated,i.pop()}}))},it=function(e,i){return t(this,void 0,void 0,(function*(){if(0!==e.dependencies.length)for(const t of e.dependencies)yield n(this,He,"m",nt).call(this,t,i)}))},rt=function(e){return t(this,void 0,void 0,(function*(){yield Promise.all(e.relatedApps.map((e=>this.loadApp(e))))}))};const at={},ct="DEFAULT_BUS",lt=(e=ct)=>{if(void 0===window.RALLIE_BUS_STORE&&Reflect.defineProperty(window,"RALLIE_BUS_STORE",{value:at,writable:!1}),window.RALLIE_BUS_STORE[e])throw new Error(Ae.duplicatedBus(e));{const t=new ot(e);return Reflect.defineProperty(window.RALLIE_BUS_STORE,e,{value:t,writable:!1}),t}},ht=(e=ct)=>window.RALLIE_BUS_STORE&&window.RALLIE_BUS_STORE[e],dt=(e=ct)=>{let t=null,n=!1;const i=ht(e);return i?(t=i,n=!1):(t=lt(e),n=!0),[t,n]},ut={createBus:lt,getBus:ht,touchBus:dt,Bus:ot};e.App=Fe,e.Bus=ot,e.Errors=Ae,e.Socket=Ie,e.Warnings=Re,e.createBus=lt,e.default=ut,e.getBus=ht,e.touchBus=dt,Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -1,1 +0,1 @@ | ||
function e(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function t(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function n(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}function i(e,t){const n=Object.create(null),i=e.split(",");for(let e=0;e<i.length;e++)n[i[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}"production"===process.env.NODE_ENV||Object.freeze({}),"production"===process.env.NODE_ENV||Object.freeze([]);const r=Object.assign,s=Object.prototype.hasOwnProperty,o=(e,t)=>s.call(e,t),a=Array.isArray,c=e=>"[object Map]"===u(e),l=e=>"symbol"==typeof e,h=e=>null!==e&&"object"==typeof e,d=Object.prototype.toString,u=e=>d.call(e),f=e=>u(e).slice(8,-1),p=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,v=(e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))})((e=>e.charAt(0).toUpperCase()+e.slice(1))),w=(e,t)=>!Object.is(e,t),g=e=>{const t=parseFloat(e);return isNaN(t)?e:t};function E(e,...t){console.warn(`[Vue warn] ${e}`,...t)}let y;function m(e,t=y){t&&t.active&&t.effects.push(e)}const _=e=>{const t=new Set(e);return t.w=0,t.n=0,t},b=e=>(e.w&k)>0,S=e=>(e.n&k)>0,N=new WeakMap;let O=0,k=1;const x=30;let j;const A=Symbol("production"!==process.env.NODE_ENV?"iterate":""),R=Symbol("production"!==process.env.NODE_ENV?"Map key iterate":"");class ${constructor(e,t=null,n){this.fn=e,this.scheduler=t,this.active=!0,this.deps=[],this.parent=void 0,m(this,n)}run(){if(!this.active)return this.fn();let e=j,t=L;for(;e;){if(e===this)return;e=e.parent}try{return this.parent=j,j=this,L=!0,k=1<<++O,O<=x?(({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=k})(this):P(this),this.fn()}finally{O<=x&&(e=>{const{deps:t}=e;if(t.length){let n=0;for(let i=0;i<t.length;i++){const r=t[i];b(r)&&!S(r)?r.delete(e):t[n++]=r,r.w&=~k,r.n&=~k}t.length=n}})(this),k=1<<--O,j=this.parent,L=t,this.parent=void 0,this.deferStop&&this.stop()}}stop(){j===this?this.deferStop=!0:this.active&&(P(this),this.onStop&&this.onStop(),this.active=!1)}}function P(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}let L=!0;const M=[];function B(e,t,n){if(L&&j){let i=N.get(e);i||N.set(e,i=new Map);let r=i.get(n);r||i.set(n,r=_());!function(e,t){let n=!1;O<=x?S(e)||(e.n|=k,n=!b(e)):n=!e.has(j);n&&(e.add(j),j.deps.push(e),"production"!==process.env.NODE_ENV&&j.onTrack&&j.onTrack(Object.assign({effect:j},t)))}(r,"production"!==process.env.NODE_ENV?{effect:j,target:e,type:t,key:n}:void 0)}}function U(e,t,n,i,r,s){const o=N.get(e);if(!o)return;let l=[];if("clear"===t)l=[...o.values()];else if("length"===n&&a(e)){const e=g(i);o.forEach(((t,n)=>{("length"===n||n>=e)&&l.push(t)}))}else switch(void 0!==n&&l.push(o.get(n)),t){case"add":a(e)?p(n)&&l.push(o.get("length")):(l.push(o.get(A)),c(e)&&l.push(o.get(R)));break;case"delete":a(e)||(l.push(o.get(A)),c(e)&&l.push(o.get(R)));break;case"set":c(e)&&l.push(o.get(A))}const h="production"!==process.env.NODE_ENV?{target:e,type:t,key:n,newValue:i,oldValue:r,oldTarget:s}:void 0;if(1===l.length)l[0]&&("production"!==process.env.NODE_ENV?T(l[0],h):T(l[0]));else{const e=[];for(const t of l)t&&e.push(...t);"production"!==process.env.NODE_ENV?T(_(e),h):T(_(e))}}function T(e,t){const n=a(e)?e:[...e];for(const e of n)e.computed&&W(e,t);for(const e of n)e.computed||W(e,t)}function W(e,t){(e!==j||e.allowRecurse)&&("production"!==process.env.NODE_ENV&&e.onTrigger&&e.onTrigger(r({effect:e},t)),e.scheduler?e.scheduler():e.run())}const D=i("__proto__,__v_isRef,__isVue"),V=new Set(Object.getOwnPropertyNames(Symbol).filter((e=>"arguments"!==e&&"caller"!==e)).map((e=>Symbol[e])).filter(l)),z=H(),I=H(!0),C=F();function F(){const e={};return["includes","indexOf","lastIndexOf"].forEach((t=>{e[t]=function(...e){const n=Ne(this);for(let e=0,t=this.length;e<t;e++)B(n,"get",e+"");const i=n[t](...e);return-1===i||!1===i?n[t](...e.map(Ne)):i}})),["push","pop","shift","unshift","splice"].forEach((t=>{e[t]=function(...e){M.push(L),L=!1;const n=Ne(this)[t].apply(this,e);return function(){const e=M.pop();L=void 0===e||e}(),n}})),e}function H(e=!1,t=!1){return function(n,i,r){if("__v_isReactive"===i)return!e;if("__v_isReadonly"===i)return e;if("__v_isShallow"===i)return t;if("__v_raw"===i&&r===(e?t?ye:Ee:t?ge:we).get(n))return n;const s=a(n);if(!e&&s&&o(C,i))return Reflect.get(C,i,r);const c=Reflect.get(n,i,r);return(l(i)?V.has(i):D(i))?c:(e||B(n,"get",i),t?c:xe(c)?s&&p(i)?c:c.value:h(c)?e?_e(c):me(c):c)}}function K(e=!1){return function(t,n,i,r){let s=t[n];if(Se(s)&&xe(s)&&!xe(i))return!1;if(!e&&(function(e){return!(!e||!e.__v_isShallow)}(i)||Se(i)||(s=Ne(s),i=Ne(i)),!a(t)&&xe(s)&&!xe(i)))return s.value=i,!0;const c=a(t)&&p(n)?Number(n)<t.length:o(t,n),l=Reflect.set(t,n,i,r);return t===Ne(r)&&(c?w(i,s)&&U(t,"set",n,i,s):U(t,"add",n,i)),l}}const q={get:z,set:K(),deleteProperty:function(e,t){const n=o(e,t),i=e[t],r=Reflect.deleteProperty(e,t);return r&&n&&U(e,"delete",t,void 0,i),r},has:function(e,t){const n=Reflect.has(e,t);return l(t)&&V.has(t)||B(e,"has",t),n},ownKeys:function(e){return B(e,"iterate",a(e)?"length":A),Reflect.ownKeys(e)}},G={get:I,set:(e,t)=>("production"!==process.env.NODE_ENV&&E(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0),deleteProperty:(e,t)=>("production"!==process.env.NODE_ENV&&E(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0)},J=e=>e,Q=e=>Reflect.getPrototypeOf(e);function X(e,t,n=!1,i=!1){const r=Ne(e=e.__v_raw),s=Ne(t);n||(t!==s&&B(r,"get",t),B(r,"get",s));const{has:o}=Q(r),a=i?J:n?ke:Oe;return o.call(r,t)?a(e.get(t)):o.call(r,s)?a(e.get(s)):void(e!==r&&e.get(t))}function Y(e,t=!1){const n=this.__v_raw,i=Ne(n),r=Ne(e);return t||(e!==r&&B(i,"has",e),B(i,"has",r)),e===r?n.has(e):n.has(e)||n.has(r)}function Z(e,t=!1){return e=e.__v_raw,!t&&B(Ne(e),"iterate",A),Reflect.get(e,"size",e)}function ee(e){e=Ne(e);const t=Ne(this);return Q(t).has.call(t,e)||(t.add(e),U(t,"add",e,e)),this}function te(e,t){t=Ne(t);const n=Ne(this),{has:i,get:r}=Q(n);let s=i.call(n,e);s?"production"!==process.env.NODE_ENV&&ve(n,i,e):(e=Ne(e),s=i.call(n,e));const o=r.call(n,e);return n.set(e,t),s?w(t,o)&&U(n,"set",e,t,o):U(n,"add",e,t),this}function ne(e){const t=Ne(this),{has:n,get:i}=Q(t);let r=n.call(t,e);r?"production"!==process.env.NODE_ENV&&ve(t,n,e):(e=Ne(e),r=n.call(t,e));const s=i?i.call(t,e):void 0,o=t.delete(e);return r&&U(t,"delete",e,void 0,s),o}function ie(){const e=Ne(this),t=0!==e.size,n="production"!==process.env.NODE_ENV?c(e)?new Map(e):new Set(e):void 0,i=e.clear();return t&&U(e,"clear",void 0,void 0,n),i}function re(e,t){return function(n,i){const r=this,s=r.__v_raw,o=Ne(s),a=t?J:e?ke:Oe;return!e&&B(o,"iterate",A),s.forEach(((e,t)=>n.call(i,a(e),a(t),r)))}}function se(e,t,n){return function(...i){const r=this.__v_raw,s=Ne(r),o=c(s),a="entries"===e||e===Symbol.iterator&&o,l="keys"===e&&o,h=r[e](...i),d=n?J:t?ke:Oe;return!t&&B(s,"iterate",l?R:A),{next(){const{value:e,done:t}=h.next();return t?{value:e,done:t}:{value:a?[d(e[0]),d(e[1])]:d(e),done:t}},[Symbol.iterator](){return this}}}}function oe(e){return function(...t){if("production"!==process.env.NODE_ENV){const n=t[0]?`on key "${t[0]}" `:"";console.warn(`${v(e)} operation ${n}failed: target is readonly.`,Ne(this))}return"delete"!==e&&this}}function ae(){const e={get(e){return X(this,e)},get size(){return Z(this)},has:Y,add:ee,set:te,delete:ne,clear:ie,forEach:re(!1,!1)},t={get(e){return X(this,e,!1,!0)},get size(){return Z(this)},has:Y,add:ee,set:te,delete:ne,clear:ie,forEach:re(!1,!0)},n={get(e){return X(this,e,!0)},get size(){return Z(this,!0)},has(e){return Y.call(this,e,!0)},add:oe("add"),set:oe("set"),delete:oe("delete"),clear:oe("clear"),forEach:re(!0,!1)},i={get(e){return X(this,e,!0,!0)},get size(){return Z(this,!0)},has(e){return Y.call(this,e,!0)},add:oe("add"),set:oe("set"),delete:oe("delete"),clear:oe("clear"),forEach:re(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((r=>{e[r]=se(r,!1,!1),n[r]=se(r,!0,!1),t[r]=se(r,!1,!0),i[r]=se(r,!0,!0)})),[e,n,t,i]}const[ce,le,he,de]=ae();function ue(e,t){const n=t?e?de:he:e?le:ce;return(t,i,r)=>"__v_isReactive"===i?!e:"__v_isReadonly"===i?e:"__v_raw"===i?t:Reflect.get(o(n,i)&&i in t?n:t,i,r)}const fe={get:ue(!1,!1)},pe={get:ue(!0,!1)};function ve(e,t,n){const i=Ne(n);if(i!==n&&t.call(e,i)){const t=f(e);console.warn(`Reactive ${t} contains both the raw and reactive versions of the same object${"Map"===t?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}const we=new WeakMap,ge=new WeakMap,Ee=new WeakMap,ye=new WeakMap;function me(e){return Se(e)?e:be(e,!1,q,fe,we)}function _e(e){return be(e,!0,G,pe,Ee)}function be(e,t,n,i,r){if(!h(e))return"production"!==process.env.NODE_ENV&&console.warn(`value cannot be made reactive: ${String(e)}`),e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const s=r.get(e);if(s)return s;const o=(a=e).__v_skip||!Object.isExtensible(a)?0:function(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(f(a));var a;if(0===o)return e;const c=new Proxy(e,2===o?i:n);return r.set(e,c),c}function Se(e){return!(!e||!e.__v_isReadonly)}function Ne(e){const t=e&&e.__v_raw;return t?Ne(t):e}const Oe=e=>h(e)?me(e):e,ke=e=>h(e)?_e(e):e;function xe(e){return!(!e||!0!==e.__v_isRef)}const je={removeNonExistedBroadcast:e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but ${e} hasn't been registed as a broadcast event`,wrongBroadcastCallback:e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but the listener hasn't been registed`,broadcastCallbackError:e=>`[@rallie/core] one of the callbacks of the broadcast event ${e} throws an uncaught error`,removeNonExistedUnicast:e=>`[@rallie/core] you are trying to remove a listener of the unicast event ${e}, but ${e} hasn't been registed as a unicast event`,registedExistedUnicast:e=>`[@rallie/core] you are trying to register a unicast event ${e}, but it has been registered before`,emittedNonExistedUnicast:e=>`[@rallie/core] you have emitted ${e} unicast, but there is no listener of this event`,createExistingApp:e=>`[@rallie/core] ${e} is existing, you are not allowed to create it again`,resourceNotDeclared:(e,t)=>`[@rallie/core] can not find any assets of the app ${e} on the bus ${t}`,appNotCreated:e=>`[@rallie/core] you are trying to activate app ${e}, but it was not created`,modifyPrivateState:e=>`[@rallie/core] state ${e} is private, you are not allowed to set it`,actionIsNotDefined:e=>`[@rallie/core] please describe your action when you modify the state ${e}`,accessUninitializedState:e=>`[@rallie/core] it's not allowed to set or watch state ${e} before it is initialized`,duplicatedInitial:e=>`[@rallie/core] duplicated initialized state ${e}`,initializePrimitiveState:e=>`[@rallie/core] it's not allowed to initialized state ${e} to a primitive value`,duplicatedBus:e=>`[@rallie/core] the bus named ${e} has been defined before, please rename your bus`,circularDependencies:(e,t)=>`[@rallie/core] There is a circular dependency when activating the app ${e}, and the circular path is ${t.join("->")}`,multipleCalledNextFn:()=>"[@rallie/core] next() called multiple times in the middleware",wrongMiddlewareType:()=>"[@rallie/core] the middleware must be a function"},Ae={handlerIsNotInTheEventsPool:(e,t)=>`[@rallie/core] the event ${e} is not in the events pool that you specified when calling on${t?"Unicast":"Broadcast"}`};const Re=e=>(t,n)=>{let i=-1;const r=s=>{if(s<=i)return Promise.reject(new Error(je.multipleCalledNextFn()));i=s;let o=e[s];if(s===e.length&&(o=n),!o)return Promise.resolve();try{return Promise.resolve(o(t,r.bind(null,s+1)))}catch(e){return Promise.reject(e)}};return r(0)};var $e,Pe,Le,Me,Be,Ue,Te,We,De;class Ve{constructor(){$e.set(this,{}),Pe.set(this,{})}addBroadcastEventListener(e,n){t(this,$e,"f")[e]=t(this,$e,"f")[e]||new Set;t(this,$e,"f")[e].add(n)}addUnicastEventListener(e,n){if(t(this,Pe,"f")[e])throw new Error(je.registedExistedUnicast(e));t(this,Pe,"f")[e]=n}removeBroadcastEventListener(e,n){const i=t(this,$e,"f")[e];if(!i){const t=je.removeNonExistedBroadcast(e);throw new Error(t)}if(!i.has(n)){const t=je.wrongBroadcastCallback(e);throw new Error(t)}i.delete(n)}removeUnicastEventListener(e){if(!t(this,Pe,"f")[e]){const t=je.removeNonExistedUnicast(e);throw new Error(t)}delete t(this,Pe,"f")[e]}emitBroadcast(e,...n){t(this,$e,"f")[e]=t(this,$e,"f")[e]||new Set;t(this,$e,"f")[e].forEach((t=>{try{t(...n)}catch(t){console.error(je.broadcastCallbackError(e)),console.error(t)}}))}emitUnicast(e,...n){const i=t(this,Pe,"f")[e];if(i)return i(...n);throw new Error(je.emittedNonExistedUnicast(e))}}$e=new WeakMap,Pe=new WeakMap;class ze{constructor(e,i){Le.set(this,void 0),Me.set(this,void 0),n(this,Le,e,"f"),n(this,Me,i,"f"),t(this,Me,"f")[e].watchers.add(this)}do(e){return this.handler=e,()=>this.unwatch()}unwatch(){null==this||this.stopEffect(),this.handler=null;const e=t(this,Me,"f")[t(this,Le,"f")].watchers;e.has(this)&&e.delete(this)}}Le=new WeakMap,Me=new WeakMap;class Ie{constructor(e,t){Be.add(this),Ue.set(this,void 0),Te.set(this,void 0),n(this,Ue,e,"f"),n(this,Te,t,"f")}onBroadcast(e){return Object.entries(e).forEach((([e,n])=>{t(this,Ue,"f").addBroadcastEventListener(e,n)})),n=>{t(this,Be,"m",We).call(this,e,!1,n)}}onUnicast(e){return Object.entries(e).forEach((([e,n])=>{try{t(this,Ue,"f").addUnicastEventListener(e,n)}catch(e){console.error(e)}})),n=>{t(this,Be,"m",We).call(this,e,!0,n)}}createBroadcaster(e){return new Proxy({},{get:(n,i)=>(...n)=>t(this,Ue,"f").emitBroadcast(i,...n,null==e?void 0:e(i)),set:()=>!1})}createUnicaster(e){return new Proxy({},{get:(n,i)=>(...n)=>t(this,Ue,"f").emitUnicast(i,...n,null==e?void 0:e(i)),set:()=>!1})}existState(e){return!!t(this,Te,"f")[e]}initState(e,n,i=!1){if(this.existState(e))throw new Error(je.duplicatedInitial(e));if(["string","number","boolean","undefined"].includes(typeof n))throw new Error(je.initializePrimitiveState(e));return t(this,Te,"f")[e]={state:me(n),owner:i?this:null,watchers:new Set},t(this,Ue,"f").emitBroadcast("$state-initialized",e),this.getState(e)}getState(e,n){if(this.existState(e)){const i=_e(t(this,Te,"f")[e].state);return n?n(i):i}return null}setState(n,i,r){return e(this,void 0,void 0,(function*(){const e=t(this,Be,"m",De).call(this,n);if(!i)throw new Error(je.actionIsNotDefined(n));{const t=r(e);yield Promise.resolve(t)}}))}watchState(e,n){if(!this.existState(e)){const t=je.accessUninitializedState(e);throw new Error(t)}let i=!1;const s=_e(t(this,Te,"f")[e].state),o=new ze(e,t(this,Te,"f")),a=function(e,t){e.effect&&(e=e.effect.fn);const n=new $(e);t&&(r(n,t),t.scope&&m(n,t.scope)),t&&t.lazy||n.run();const i=n.run.bind(n);return i.effect=n,i}((()=>n(s)),{lazy:!0,scheduler:()=>{i||(i=!0,Promise.resolve().then((()=>{var e;const t=Ne(n(s));null===(e=o.handler)||void 0===e||e.call(o,t,o.oldWatchingStates),o.oldWatchingStates=Ne(t),i=!1})))}});return o.oldWatchingStates=a(),o.stopEffect=()=>a.effect.stop(),o}}Ue=new WeakMap,Te=new WeakMap,Be=new WeakSet,We=function(e,n,i){let r=n?t(this,Ue,"f").removeUnicastEventListener:t(this,Ue,"f").removeBroadcastEventListener;r=r.bind(t(this,Ue,"f")),i?e[i]?(r(i,e[i]),delete e[i]):console.warn(Ae.handlerIsNotInTheEventsPool(i,n)):Object.entries(e).forEach((([e,t])=>{r(e,t)}))},De=function(e){if(!this.existState(e)){const t=je.accessUninitializedState(e);throw new Error(t)}const n=t(this,Te,"f")[e].owner;if(n!==this&&null!==n){const t=je.modifyPrivateState(e);throw new Error(t)}return t(this,Te,"f")[e].state};class Ce{constructor(e){this.name=e,this.activated=null,this.dependencies=[],this.relatedApps=[],this.name=e,this.isRallieCoreApp=!0}relateTo(e){return this.relatedApps=Array.from(new Set([...this.relatedApps,...e])),this}relyOn(e){return this.relateTo(e),this.dependencies=Array.from(new Set([...this.dependencies,...e])),this}onActivate(e){return this.doActivate=e,this}}var Fe,He,Ke,qe,Ge,Je,Qe,Xe,Ye,Ze,et,tt,nt,it,rt={loadScript:t=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>{let n=null;if(t instanceof HTMLScriptElement)n=t;else{n=document.createElement("script");const e="string"!=typeof t?t:{type:"text/javascript",src:t};Object.entries(e).forEach((([e,t])=>{n.setAttribute(e,t)}))}n.src&&(n.onload=n.onerror=()=>{e()}),document.body.appendChild(n),n.src||e()}))})),loadLink:e=>{let t=null;if(e instanceof HTMLLinkElement)t=e;else{const n="string"!=typeof e?e:{rel:"stylesheet",type:"text/css",href:e};t=document.createElement("link"),Object.entries(n).forEach((([e,n])=>{t.setAttribute(e,n)}))}document.head.appendChild(t)}};class st{constructor(e){Fe.add(this),He.set(this,void 0),Ke.set(this,new Ve),qe.set(this,{}),Ge.set(this,{}),Je.set(this,{}),this.conf=_e({assets:{}}),Qe.set(this,[]),Xe.set(this,void 0),n(this,He,e,"f"),n(this,Xe,Re(t(this,Qe,"f")),"f")}createSocket(){return new Ie(t(this,Ke,"f"),t(this,qe,"f"))}existApp(e){return!!t(this,Ge,"f")[e]}createApp(e){if(this.existApp(e))throw new Error(je.createExistingApp(e));const n=new Ce(e);return t(this,Ge,"f")[e]=n,n}loadApp(n){return e(this,void 0,void 0,(function*(){t(this,Ge,"f")[n]||(t(this,Je,"f")[n]||(t(this,Je,"f")[n]=new Promise(((e,i)=>{const r=t(this,Fe,"m",Ze).call(this,n);t(this,Xe,"f").call(this,r,t(this,Fe,"m",et).bind(this)).then((()=>{n.startsWith("lib:")&&!t(this,Ge,"f")[n]&&(t(this,Ge,"f")[n]=!0),t(this,Ge,"f")[n]||i(new Error(je.appNotCreated(n))),e()})).catch((e=>{i(e)}))}))),yield t(this,Je,"f")[n])}))}activateApp(n){return e(this,void 0,void 0,(function*(){yield t(this,Fe,"m",tt).call(this,n,[])}))}config(e){return this.conf=Object.assign(Object.assign(Object.assign({},this.conf),e),{assets:Object.assign(Object.assign({},this.conf.assets),(null==e?void 0:e.assets)||{})}),this}use(e){if("function"!=typeof e)throw new Error(je.wrongMiddlewareType());return t(this,Qe,"f").push(e),n(this,Xe,Re(t(this,Qe,"f")),"f"),this}}He=new WeakMap,Ke=new WeakMap,qe=new WeakMap,Ge=new WeakMap,Je=new WeakMap,Qe=new WeakMap,Xe=new WeakMap,Fe=new WeakSet,Ye=function(e){return t(this,Ge,"f")[e]&&"boolean"!=typeof t(this,Ge,"f")[e]},Ze=function(e){return{name:e,loadScript:rt.loadScript,loadLink:rt.loadLink}},et=function(n){return e(this,void 0,void 0,(function*(){const{name:e,loadScript:i=rt.loadScript,loadLink:r=rt.loadLink}=n,{assets:s}=this.conf;if(!s[e])throw new Error(je.resourceNotDeclared(e,t(this,He,"f")));if(s[e].css&&s[e].css.forEach((e=>{r(e)})),s[e].js)for(const t of s[e].js)yield i(t)}))},tt=function(n,i){return e(this,void 0,void 0,(function*(){if(yield this.loadApp(n),t(this,Fe,"m",Ye).call(this,n)){const r=t(this,Ge,"f")[n];if(yield t(this,Fe,"m",it).call(this,r),i.includes(n)){const e=i.indexOf(n),t=[...i.slice(e),n];throw new Error(je.circularDependencies(n,t))}if(i.push(n),!r.activated){const n=()=>e(this,void 0,void 0,(function*(){yield t(this,Fe,"m",nt).call(this,r,i),r.doActivate&&(yield Promise.resolve(r.doActivate()))}));r.activated=n()}yield r.activated,i.pop()}}))},nt=function(n,i){return e(this,void 0,void 0,(function*(){if(0!==n.dependencies.length)for(const e of n.dependencies)yield t(this,Fe,"m",tt).call(this,e,i)}))},it=function(t){return e(this,void 0,void 0,(function*(){yield Promise.all(t.relatedApps.map((e=>this.loadApp(e))))}))};const ot={},at="DEFAULT_BUS",ct=(e=at)=>{if(void 0===window.RALLIE_BUS_STORE&&Reflect.defineProperty(window,"RALLIE_BUS_STORE",{value:ot,writable:!1}),window.RALLIE_BUS_STORE[e])throw new Error(je.duplicatedBus(e));{const t=new st(e);return Reflect.defineProperty(window.RALLIE_BUS_STORE,e,{value:t,writable:!1}),t}},lt=(e=at)=>window.RALLIE_BUS_STORE&&window.RALLIE_BUS_STORE[e],ht=(e=at)=>{let t=null,n=!1;const i=lt(e);return i?(t=i,n=!1):(t=ct(e),n=!0),[t,n]},dt={createBus:ct,getBus:lt,touchBus:ht,Bus:st};export{Ce as App,st as Bus,je as Errors,Ie as Socket,Ae as Warnings,ct as createBus,dt as default,lt as getBus,ht as touchBus}; | ||
function e(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function t(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function n(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}function i(e,t){const n=Object.create(null),i=e.split(",");for(let e=0;e<i.length;e++)n[i[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}"production"===process.env.NODE_ENV||Object.freeze({}),"production"===process.env.NODE_ENV||Object.freeze([]);const r=Object.assign,s=Object.prototype.hasOwnProperty,o=(e,t)=>s.call(e,t),a=Array.isArray,c=e=>"[object Map]"===u(e),l=e=>"symbol"==typeof e,h=e=>null!==e&&"object"==typeof e,d=Object.prototype.toString,u=e=>d.call(e),f=e=>u(e).slice(8,-1),p=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,v=(e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))})((e=>e.charAt(0).toUpperCase()+e.slice(1))),w=(e,t)=>!Object.is(e,t),g=e=>{const t=parseFloat(e);return isNaN(t)?e:t};function E(e,...t){console.warn(`[Vue warn] ${e}`,...t)}let y;function m(e,t=y){t&&t.active&&t.effects.push(e)}const _=e=>{const t=new Set(e);return t.w=0,t.n=0,t},b=e=>(e.w&k)>0,S=e=>(e.n&k)>0,N=new WeakMap;let O=0,k=1;const x=30;let j;const A=Symbol("production"!==process.env.NODE_ENV?"iterate":""),R=Symbol("production"!==process.env.NODE_ENV?"Map key iterate":"");class ${constructor(e,t=null,n){this.fn=e,this.scheduler=t,this.active=!0,this.deps=[],this.parent=void 0,m(this,n)}run(){if(!this.active)return this.fn();let e=j,t=L;for(;e;){if(e===this)return;e=e.parent}try{return this.parent=j,j=this,L=!0,k=1<<++O,O<=x?(({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=k})(this):P(this),this.fn()}finally{O<=x&&(e=>{const{deps:t}=e;if(t.length){let n=0;for(let i=0;i<t.length;i++){const r=t[i];b(r)&&!S(r)?r.delete(e):t[n++]=r,r.w&=~k,r.n&=~k}t.length=n}})(this),k=1<<--O,j=this.parent,L=t,this.parent=void 0,this.deferStop&&this.stop()}}stop(){j===this?this.deferStop=!0:this.active&&(P(this),this.onStop&&this.onStop(),this.active=!1)}}function P(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}let L=!0;const M=[];function B(e,t,n){if(L&&j){let i=N.get(e);i||N.set(e,i=new Map);let r=i.get(n);r||i.set(n,r=_());!function(e,t){let n=!1;O<=x?S(e)||(e.n|=k,n=!b(e)):n=!e.has(j);n&&(e.add(j),j.deps.push(e),"production"!==process.env.NODE_ENV&&j.onTrack&&j.onTrack(Object.assign({effect:j},t)))}(r,"production"!==process.env.NODE_ENV?{effect:j,target:e,type:t,key:n}:void 0)}}function U(e,t,n,i,r,s){const o=N.get(e);if(!o)return;let l=[];if("clear"===t)l=[...o.values()];else if("length"===n&&a(e)){const e=g(i);o.forEach(((t,n)=>{("length"===n||n>=e)&&l.push(t)}))}else switch(void 0!==n&&l.push(o.get(n)),t){case"add":a(e)?p(n)&&l.push(o.get("length")):(l.push(o.get(A)),c(e)&&l.push(o.get(R)));break;case"delete":a(e)||(l.push(o.get(A)),c(e)&&l.push(o.get(R)));break;case"set":c(e)&&l.push(o.get(A))}const h="production"!==process.env.NODE_ENV?{target:e,type:t,key:n,newValue:i,oldValue:r,oldTarget:s}:void 0;if(1===l.length)l[0]&&("production"!==process.env.NODE_ENV?T(l[0],h):T(l[0]));else{const e=[];for(const t of l)t&&e.push(...t);"production"!==process.env.NODE_ENV?T(_(e),h):T(_(e))}}function T(e,t){const n=a(e)?e:[...e];for(const e of n)e.computed&&W(e,t);for(const e of n)e.computed||W(e,t)}function W(e,t){(e!==j||e.allowRecurse)&&("production"!==process.env.NODE_ENV&&e.onTrigger&&e.onTrigger(r({effect:e},t)),e.scheduler?e.scheduler():e.run())}const D=i("__proto__,__v_isRef,__isVue"),V=new Set(Object.getOwnPropertyNames(Symbol).filter((e=>"arguments"!==e&&"caller"!==e)).map((e=>Symbol[e])).filter(l)),z=H(),I=H(!0),C=F();function F(){const e={};return["includes","indexOf","lastIndexOf"].forEach((t=>{e[t]=function(...e){const n=Ne(this);for(let e=0,t=this.length;e<t;e++)B(n,"get",e+"");const i=n[t](...e);return-1===i||!1===i?n[t](...e.map(Ne)):i}})),["push","pop","shift","unshift","splice"].forEach((t=>{e[t]=function(...e){M.push(L),L=!1;const n=Ne(this)[t].apply(this,e);return function(){const e=M.pop();L=void 0===e||e}(),n}})),e}function H(e=!1,t=!1){return function(n,i,r){if("__v_isReactive"===i)return!e;if("__v_isReadonly"===i)return e;if("__v_isShallow"===i)return t;if("__v_raw"===i&&r===(e?t?ye:Ee:t?ge:we).get(n))return n;const s=a(n);if(!e&&s&&o(C,i))return Reflect.get(C,i,r);const c=Reflect.get(n,i,r);return(l(i)?V.has(i):D(i))?c:(e||B(n,"get",i),t?c:xe(c)?s&&p(i)?c:c.value:h(c)?e?_e(c):me(c):c)}}function K(e=!1){return function(t,n,i,r){let s=t[n];if(Se(s)&&xe(s)&&!xe(i))return!1;if(!e&&(function(e){return!(!e||!e.__v_isShallow)}(i)||Se(i)||(s=Ne(s),i=Ne(i)),!a(t)&&xe(s)&&!xe(i)))return s.value=i,!0;const c=a(t)&&p(n)?Number(n)<t.length:o(t,n),l=Reflect.set(t,n,i,r);return t===Ne(r)&&(c?w(i,s)&&U(t,"set",n,i,s):U(t,"add",n,i)),l}}const q={get:z,set:K(),deleteProperty:function(e,t){const n=o(e,t),i=e[t],r=Reflect.deleteProperty(e,t);return r&&n&&U(e,"delete",t,void 0,i),r},has:function(e,t){const n=Reflect.has(e,t);return l(t)&&V.has(t)||B(e,"has",t),n},ownKeys:function(e){return B(e,"iterate",a(e)?"length":A),Reflect.ownKeys(e)}},G={get:I,set:(e,t)=>("production"!==process.env.NODE_ENV&&E(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0),deleteProperty:(e,t)=>("production"!==process.env.NODE_ENV&&E(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0)},J=e=>e,Q=e=>Reflect.getPrototypeOf(e);function X(e,t,n=!1,i=!1){const r=Ne(e=e.__v_raw),s=Ne(t);n||(t!==s&&B(r,"get",t),B(r,"get",s));const{has:o}=Q(r),a=i?J:n?ke:Oe;return o.call(r,t)?a(e.get(t)):o.call(r,s)?a(e.get(s)):void(e!==r&&e.get(t))}function Y(e,t=!1){const n=this.__v_raw,i=Ne(n),r=Ne(e);return t||(e!==r&&B(i,"has",e),B(i,"has",r)),e===r?n.has(e):n.has(e)||n.has(r)}function Z(e,t=!1){return e=e.__v_raw,!t&&B(Ne(e),"iterate",A),Reflect.get(e,"size",e)}function ee(e){e=Ne(e);const t=Ne(this);return Q(t).has.call(t,e)||(t.add(e),U(t,"add",e,e)),this}function te(e,t){t=Ne(t);const n=Ne(this),{has:i,get:r}=Q(n);let s=i.call(n,e);s?"production"!==process.env.NODE_ENV&&ve(n,i,e):(e=Ne(e),s=i.call(n,e));const o=r.call(n,e);return n.set(e,t),s?w(t,o)&&U(n,"set",e,t,o):U(n,"add",e,t),this}function ne(e){const t=Ne(this),{has:n,get:i}=Q(t);let r=n.call(t,e);r?"production"!==process.env.NODE_ENV&&ve(t,n,e):(e=Ne(e),r=n.call(t,e));const s=i?i.call(t,e):void 0,o=t.delete(e);return r&&U(t,"delete",e,void 0,s),o}function ie(){const e=Ne(this),t=0!==e.size,n="production"!==process.env.NODE_ENV?c(e)?new Map(e):new Set(e):void 0,i=e.clear();return t&&U(e,"clear",void 0,void 0,n),i}function re(e,t){return function(n,i){const r=this,s=r.__v_raw,o=Ne(s),a=t?J:e?ke:Oe;return!e&&B(o,"iterate",A),s.forEach(((e,t)=>n.call(i,a(e),a(t),r)))}}function se(e,t,n){return function(...i){const r=this.__v_raw,s=Ne(r),o=c(s),a="entries"===e||e===Symbol.iterator&&o,l="keys"===e&&o,h=r[e](...i),d=n?J:t?ke:Oe;return!t&&B(s,"iterate",l?R:A),{next(){const{value:e,done:t}=h.next();return t?{value:e,done:t}:{value:a?[d(e[0]),d(e[1])]:d(e),done:t}},[Symbol.iterator](){return this}}}}function oe(e){return function(...t){if("production"!==process.env.NODE_ENV){const n=t[0]?`on key "${t[0]}" `:"";console.warn(`${v(e)} operation ${n}failed: target is readonly.`,Ne(this))}return"delete"!==e&&this}}function ae(){const e={get(e){return X(this,e)},get size(){return Z(this)},has:Y,add:ee,set:te,delete:ne,clear:ie,forEach:re(!1,!1)},t={get(e){return X(this,e,!1,!0)},get size(){return Z(this)},has:Y,add:ee,set:te,delete:ne,clear:ie,forEach:re(!1,!0)},n={get(e){return X(this,e,!0)},get size(){return Z(this,!0)},has(e){return Y.call(this,e,!0)},add:oe("add"),set:oe("set"),delete:oe("delete"),clear:oe("clear"),forEach:re(!0,!1)},i={get(e){return X(this,e,!0,!0)},get size(){return Z(this,!0)},has(e){return Y.call(this,e,!0)},add:oe("add"),set:oe("set"),delete:oe("delete"),clear:oe("clear"),forEach:re(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((r=>{e[r]=se(r,!1,!1),n[r]=se(r,!0,!1),t[r]=se(r,!1,!0),i[r]=se(r,!0,!0)})),[e,n,t,i]}const[ce,le,he,de]=ae();function ue(e,t){const n=t?e?de:he:e?le:ce;return(t,i,r)=>"__v_isReactive"===i?!e:"__v_isReadonly"===i?e:"__v_raw"===i?t:Reflect.get(o(n,i)&&i in t?n:t,i,r)}const fe={get:ue(!1,!1)},pe={get:ue(!0,!1)};function ve(e,t,n){const i=Ne(n);if(i!==n&&t.call(e,i)){const t=f(e);console.warn(`Reactive ${t} contains both the raw and reactive versions of the same object${"Map"===t?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}const we=new WeakMap,ge=new WeakMap,Ee=new WeakMap,ye=new WeakMap;function me(e){return Se(e)?e:be(e,!1,q,fe,we)}function _e(e){return be(e,!0,G,pe,Ee)}function be(e,t,n,i,r){if(!h(e))return"production"!==process.env.NODE_ENV&&console.warn(`value cannot be made reactive: ${String(e)}`),e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const s=r.get(e);if(s)return s;const o=(a=e).__v_skip||!Object.isExtensible(a)?0:function(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(f(a));var a;if(0===o)return e;const c=new Proxy(e,2===o?i:n);return r.set(e,c),c}function Se(e){return!(!e||!e.__v_isReadonly)}function Ne(e){const t=e&&e.__v_raw;return t?Ne(t):e}const Oe=e=>h(e)?me(e):e,ke=e=>h(e)?_e(e):e;function xe(e){return!(!e||!0!==e.__v_isRef)}const je={removeNonExistedBroadcast:e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but ${e} hasn't been registed as a broadcast event`,wrongBroadcastCallback:e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but the listener hasn't been registed`,broadcastCallbackError:e=>`[@rallie/core] one of the callbacks of the broadcast event ${e} throws an uncaught error`,removeNonExistedUnicast:e=>`[@rallie/core] you are trying to remove a listener of the unicast event ${e}, but ${e} hasn't been registed as a unicast event`,registedExistedUnicast:e=>`[@rallie/core] you are trying to register a unicast event ${e}, but it has been registered before`,emittedNonExistedUnicast:e=>`[@rallie/core] you have emitted ${e} unicast, but there is no listener of this event`,createExistingApp:e=>`[@rallie/core] ${e} is existing, you are not allowed to create it again`,resourceNotDeclared:(e,t)=>`[@rallie/core] can not find any assets of the app ${e} on the bus ${t}`,appNotCreated:e=>`[@rallie/core] you are trying to activate app ${e}, but it was not created`,modifyPrivateState:e=>`[@rallie/core] state ${e} is private, you are not allowed to set it`,actionIsNotDefined:e=>`[@rallie/core] please describe your action when you modify the state ${e}`,accessUninitializedState:e=>`[@rallie/core] it's not allowed to set or watch state ${e} before it is initialized`,duplicatedInitial:e=>`[@rallie/core] duplicated initialized state ${e}`,initializePrimitiveState:e=>`[@rallie/core] it's not allowed to initialized state ${e} to a primitive value`,duplicatedBus:e=>`[@rallie/core] the bus named ${e} has been defined before, please rename your bus`,circularDependencies:(e,t)=>`[@rallie/core] There is a circular dependency when activating the app ${e}, and the circular path is ${t.join("->")}`,multipleCalledNextFn:()=>"[@rallie/core] next() called multiple times in the middleware",wrongMiddlewareType:()=>"[@rallie/core] the middleware must be a function"},Ae={handlerIsNotInTheEventsPool:(e,t)=>`[@rallie/core] the event ${e} is not in the events pool that you specified when calling on${t?"Unicast":"Broadcast"}`};const Re=e=>(t,n)=>{let i=-1;const r=s=>{if(s<=i)return Promise.reject(new Error(je.multipleCalledNextFn()));i=s;let o=e[s];if(s===e.length&&(o=n),!o)return Promise.resolve();try{return Promise.resolve(o(t,r.bind(null,s+1)))}catch(e){return Promise.reject(e)}};return r(0)};var $e,Pe,Le,Me,Be,Ue,Te,We,De;class Ve{constructor(){$e.set(this,{}),Pe.set(this,{})}addBroadcastEventListener(e,n){t(this,$e,"f")[e]=t(this,$e,"f")[e]||new Set;t(this,$e,"f")[e].add(n)}addUnicastEventListener(e,n){if(t(this,Pe,"f")[e])throw new Error(je.registedExistedUnicast(e));t(this,Pe,"f")[e]=n}removeBroadcastEventListener(e,n){const i=t(this,$e,"f")[e];if(!i){const t=je.removeNonExistedBroadcast(e);throw new Error(t)}if(!i.has(n)){const t=je.wrongBroadcastCallback(e);throw new Error(t)}i.delete(n)}removeUnicastEventListener(e){if(!t(this,Pe,"f")[e]){const t=je.removeNonExistedUnicast(e);throw new Error(t)}delete t(this,Pe,"f")[e]}emitBroadcast(e,...n){t(this,$e,"f")[e]=t(this,$e,"f")[e]||new Set;t(this,$e,"f")[e].forEach((t=>{try{t(...n)}catch(t){console.error(je.broadcastCallbackError(e)),console.error(t)}}))}emitUnicast(e,...n){const i=t(this,Pe,"f")[e];if(i)return i(...n);throw new Error(je.emittedNonExistedUnicast(e))}}$e=new WeakMap,Pe=new WeakMap;class ze{constructor(e,i){Le.set(this,void 0),Me.set(this,void 0),n(this,Le,e,"f"),n(this,Me,i,"f"),t(this,Me,"f")[e].watchers.add(this)}do(e){return this.handler=e,()=>this.unwatch()}unwatch(){null==this||this.stopEffect(),this.handler=null;const e=t(this,Me,"f")[t(this,Le,"f")].watchers;e.has(this)&&e.delete(this)}}Le=new WeakMap,Me=new WeakMap;class Ie{constructor(e,t){Be.add(this),Ue.set(this,void 0),Te.set(this,void 0),n(this,Ue,e,"f"),n(this,Te,t,"f")}onBroadcast(e){return Object.entries(e).forEach((([e,n])=>{t(this,Ue,"f").addBroadcastEventListener(e,n)})),n=>{t(this,Be,"m",We).call(this,e,!1,n)}}onUnicast(e){return Object.entries(e).forEach((([e,n])=>{try{t(this,Ue,"f").addUnicastEventListener(e,n)}catch(e){console.error(e)}})),n=>{t(this,Be,"m",We).call(this,e,!0,n)}}createBroadcaster(e){return new Proxy({},{get:(n,i)=>(...n)=>(null==e||e(i),t(this,Ue,"f").emitBroadcast(i,...n)),set:()=>!1})}createUnicaster(e){return new Proxy({},{get:(n,i)=>(...n)=>(null==e||e(i),t(this,Ue,"f").emitUnicast(i,...n)),set:()=>!1})}existState(e){return!!t(this,Te,"f")[e]}initState(e,n,i=!1){if(this.existState(e))throw new Error(je.duplicatedInitial(e));if(["string","number","boolean","undefined"].includes(typeof n))throw new Error(je.initializePrimitiveState(e));return t(this,Te,"f")[e]={state:me(n),owner:i?this:null,watchers:new Set},t(this,Ue,"f").emitBroadcast("$state-initialized",e),this.getState(e)}getState(e,n){if(this.existState(e)){const i=_e(t(this,Te,"f")[e].state);return n?n(i):i}return null}setState(n,i,r){return e(this,void 0,void 0,(function*(){const e=t(this,Be,"m",De).call(this,n);if(!i)throw new Error(je.actionIsNotDefined(n));{const t=r(e);yield Promise.resolve(t)}}))}watchState(e,n){if(!this.existState(e)){const t=je.accessUninitializedState(e);throw new Error(t)}let i=!1;const s=_e(t(this,Te,"f")[e].state),o=new ze(e,t(this,Te,"f")),a=function(e,t){e.effect&&(e=e.effect.fn);const n=new $(e);t&&(r(n,t),t.scope&&m(n,t.scope)),t&&t.lazy||n.run();const i=n.run.bind(n);return i.effect=n,i}((()=>n(s)),{lazy:!0,scheduler:()=>{i||(i=!0,Promise.resolve().then((()=>{var e;const t=Ne(n(s));null===(e=o.handler)||void 0===e||e.call(o,t,o.oldWatchingStates),o.oldWatchingStates=Ne(t),i=!1})))}});return o.oldWatchingStates=a(),o.stopEffect=()=>a.effect.stop(),o}}Ue=new WeakMap,Te=new WeakMap,Be=new WeakSet,We=function(e,n,i){let r=n?t(this,Ue,"f").removeUnicastEventListener:t(this,Ue,"f").removeBroadcastEventListener;r=r.bind(t(this,Ue,"f")),i?e[i]?(r(i,e[i]),delete e[i]):console.warn(Ae.handlerIsNotInTheEventsPool(i,n)):Object.entries(e).forEach((([e,t])=>{r(e,t)}))},De=function(e){if(!this.existState(e)){const t=je.accessUninitializedState(e);throw new Error(t)}const n=t(this,Te,"f")[e].owner;if(n!==this&&null!==n){const t=je.modifyPrivateState(e);throw new Error(t)}return t(this,Te,"f")[e].state};class Ce{constructor(e){this.name=e,this.activated=null,this.dependencies=[],this.relatedApps=[],this.name=e,this.isRallieCoreApp=!0}relateTo(e){return this.relatedApps=Array.from(new Set([...this.relatedApps,...e])),this}relyOn(e){return this.relateTo(e),this.dependencies=Array.from(new Set([...this.dependencies,...e])),this}onActivate(e){return this.doActivate=e,this}}var Fe,He,Ke,qe,Ge,Je,Qe,Xe,Ye,Ze,et,tt,nt,it,rt={loadScript:t=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>{let n=null;if(t instanceof HTMLScriptElement)n=t;else{n=document.createElement("script");const e="string"!=typeof t?t:{type:"text/javascript",src:t};Object.entries(e).forEach((([e,t])=>{n.setAttribute(e,t)}))}n.src&&(n.onload=n.onerror=()=>{e()}),document.body.appendChild(n),n.src||e()}))})),loadLink:e=>{let t=null;if(e instanceof HTMLLinkElement)t=e;else{const n="string"!=typeof e?e:{rel:"stylesheet",type:"text/css",href:e};t=document.createElement("link"),Object.entries(n).forEach((([e,n])=>{t.setAttribute(e,n)}))}document.head.appendChild(t)}};class st{constructor(e){Fe.add(this),He.set(this,void 0),Ke.set(this,new Ve),qe.set(this,{}),Ge.set(this,{}),Je.set(this,{}),this.conf=_e({assets:{}}),Qe.set(this,[]),Xe.set(this,void 0),n(this,He,e,"f"),n(this,Xe,Re(t(this,Qe,"f")),"f")}createSocket(){return new Ie(t(this,Ke,"f"),t(this,qe,"f"))}existApp(e){return!!t(this,Ge,"f")[e]}createApp(e){if(this.existApp(e))throw new Error(je.createExistingApp(e));const n=new Ce(e);return t(this,Ge,"f")[e]=n,n}loadApp(n){return e(this,void 0,void 0,(function*(){t(this,Ge,"f")[n]||(t(this,Je,"f")[n]||(t(this,Je,"f")[n]=new Promise(((e,i)=>{const r=t(this,Fe,"m",Ze).call(this,n);t(this,Xe,"f").call(this,r,t(this,Fe,"m",et).bind(this)).then((()=>{n.startsWith("lib:")&&!t(this,Ge,"f")[n]&&(t(this,Ge,"f")[n]=!0),t(this,Ge,"f")[n]||i(new Error(je.appNotCreated(n))),e()})).catch((e=>{i(e)}))}))),yield t(this,Je,"f")[n])}))}activateApp(n){return e(this,void 0,void 0,(function*(){yield t(this,Fe,"m",tt).call(this,n,[])}))}config(e){return this.conf=Object.assign(Object.assign(Object.assign({},this.conf),e),{assets:Object.assign(Object.assign({},this.conf.assets),(null==e?void 0:e.assets)||{})}),this}use(e){if("function"!=typeof e)throw new Error(je.wrongMiddlewareType());return t(this,Qe,"f").push(e),n(this,Xe,Re(t(this,Qe,"f")),"f"),this}}He=new WeakMap,Ke=new WeakMap,qe=new WeakMap,Ge=new WeakMap,Je=new WeakMap,Qe=new WeakMap,Xe=new WeakMap,Fe=new WeakSet,Ye=function(e){return t(this,Ge,"f")[e]&&"boolean"!=typeof t(this,Ge,"f")[e]},Ze=function(e){return{name:e,loadScript:rt.loadScript,loadLink:rt.loadLink}},et=function(n){return e(this,void 0,void 0,(function*(){const{name:e,loadScript:i=rt.loadScript,loadLink:r=rt.loadLink}=n,{assets:s}=this.conf;if(!s[e])throw new Error(je.resourceNotDeclared(e,t(this,He,"f")));if(s[e].css&&s[e].css.forEach((e=>{r(e)})),s[e].js)for(const t of s[e].js)yield i(t)}))},tt=function(n,i){return e(this,void 0,void 0,(function*(){if(yield this.loadApp(n),t(this,Fe,"m",Ye).call(this,n)){const r=t(this,Ge,"f")[n];if(yield t(this,Fe,"m",it).call(this,r),i.includes(n)){const e=i.indexOf(n),t=[...i.slice(e),n];throw new Error(je.circularDependencies(n,t))}if(i.push(n),!r.activated){const n=()=>e(this,void 0,void 0,(function*(){yield t(this,Fe,"m",nt).call(this,r,i),r.doActivate&&(yield Promise.resolve(r.doActivate()))}));r.activated=n()}yield r.activated,i.pop()}}))},nt=function(n,i){return e(this,void 0,void 0,(function*(){if(0!==n.dependencies.length)for(const e of n.dependencies)yield t(this,Fe,"m",tt).call(this,e,i)}))},it=function(t){return e(this,void 0,void 0,(function*(){yield Promise.all(t.relatedApps.map((e=>this.loadApp(e))))}))};const ot={},at="DEFAULT_BUS",ct=(e=at)=>{if(void 0===window.RALLIE_BUS_STORE&&Reflect.defineProperty(window,"RALLIE_BUS_STORE",{value:ot,writable:!1}),window.RALLIE_BUS_STORE[e])throw new Error(je.duplicatedBus(e));{const t=new st(e);return Reflect.defineProperty(window.RALLIE_BUS_STORE,e,{value:t,writable:!1}),t}},lt=(e=at)=>window.RALLIE_BUS_STORE&&window.RALLIE_BUS_STORE[e],ht=(e=at)=>{let t=null,n=!1;const i=lt(e);return i?(t=i,n=!1):(t=ct(e),n=!0),[t,n]},dt={createBus:ct,getBus:lt,touchBus:ht,Bus:st};export{Ce as App,st as Bus,je as Errors,Ie as Socket,Ae as Warnings,ct as createBus,dt as default,lt as getBus,ht as touchBus}; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RallieCore={})}(this,(function(e){"use strict";function t(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function n(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function i(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}function r(e,t){const n=Object.create(null),i=e.split(",");for(let e=0;e<i.length;e++)n[i[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}"production"===process.env.NODE_ENV||Object.freeze({}),"production"===process.env.NODE_ENV||Object.freeze([]);const s=Object.assign,o=Object.prototype.hasOwnProperty,a=(e,t)=>o.call(e,t),c=Array.isArray,l=e=>"[object Map]"===f(e),h=e=>"symbol"==typeof e,d=e=>null!==e&&"object"==typeof e,u=Object.prototype.toString,f=e=>u.call(e),p=e=>f(e).slice(8,-1),v=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,w=(e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))})((e=>e.charAt(0).toUpperCase()+e.slice(1))),g=(e,t)=>!Object.is(e,t),y=e=>{const t=parseFloat(e);return isNaN(t)?e:t};function E(e,...t){console.warn(`[Vue warn] ${e}`,...t)}let m;function _(e,t=m){t&&t.active&&t.effects.push(e)}const b=e=>{const t=new Set(e);return t.w=0,t.n=0,t},S=e=>(e.w&x)>0,N=e=>(e.n&x)>0,O=new WeakMap;let k=0,x=1;const j=30;let A;const R=Symbol("production"!==process.env.NODE_ENV?"iterate":""),P=Symbol("production"!==process.env.NODE_ENV?"Map key iterate":"");class ${constructor(e,t=null,n){this.fn=e,this.scheduler=t,this.active=!0,this.deps=[],this.parent=void 0,_(this,n)}run(){if(!this.active)return this.fn();let e=A,t=L;for(;e;){if(e===this)return;e=e.parent}try{return this.parent=A,A=this,L=!0,x=1<<++k,k<=j?(({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=x})(this):B(this),this.fn()}finally{k<=j&&(e=>{const{deps:t}=e;if(t.length){let n=0;for(let i=0;i<t.length;i++){const r=t[i];S(r)&&!N(r)?r.delete(e):t[n++]=r,r.w&=~x,r.n&=~x}t.length=n}})(this),x=1<<--k,A=this.parent,L=t,this.parent=void 0,this.deferStop&&this.stop()}}stop(){A===this?this.deferStop=!0:this.active&&(B(this),this.onStop&&this.onStop(),this.active=!1)}}function B(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}let L=!0;const M=[];function T(e,t,n){if(L&&A){let i=O.get(e);i||O.set(e,i=new Map);let r=i.get(n);r||i.set(n,r=b());!function(e,t){let n=!1;k<=j?N(e)||(e.n|=x,n=!S(e)):n=!e.has(A);n&&(e.add(A),A.deps.push(e),"production"!==process.env.NODE_ENV&&A.onTrack&&A.onTrack(Object.assign({effect:A},t)))}(r,"production"!==process.env.NODE_ENV?{effect:A,target:e,type:t,key:n}:void 0)}}function U(e,t,n,i,r,s){const o=O.get(e);if(!o)return;let a=[];if("clear"===t)a=[...o.values()];else if("length"===n&&c(e)){const e=y(i);o.forEach(((t,n)=>{("length"===n||n>=e)&&a.push(t)}))}else switch(void 0!==n&&a.push(o.get(n)),t){case"add":c(e)?v(n)&&a.push(o.get("length")):(a.push(o.get(R)),l(e)&&a.push(o.get(P)));break;case"delete":c(e)||(a.push(o.get(R)),l(e)&&a.push(o.get(P)));break;case"set":l(e)&&a.push(o.get(R))}const h="production"!==process.env.NODE_ENV?{target:e,type:t,key:n,newValue:i,oldValue:r,oldTarget:s}:void 0;if(1===a.length)a[0]&&("production"!==process.env.NODE_ENV?W(a[0],h):W(a[0]));else{const e=[];for(const t of a)t&&e.push(...t);"production"!==process.env.NODE_ENV?W(b(e),h):W(b(e))}}function W(e,t){const n=c(e)?e:[...e];for(const e of n)e.computed&&D(e,t);for(const e of n)e.computed||D(e,t)}function D(e,t){(e!==A||e.allowRecurse)&&("production"!==process.env.NODE_ENV&&e.onTrigger&&e.onTrigger(s({effect:e},t)),e.scheduler?e.scheduler():e.run())}const V=r("__proto__,__v_isRef,__isVue"),z=new Set(Object.getOwnPropertyNames(Symbol).filter((e=>"arguments"!==e&&"caller"!==e)).map((e=>Symbol[e])).filter(h)),C=K(),I=K(!0),F=H();function H(){const e={};return["includes","indexOf","lastIndexOf"].forEach((t=>{e[t]=function(...e){const n=Oe(this);for(let e=0,t=this.length;e<t;e++)T(n,"get",e+"");const i=n[t](...e);return-1===i||!1===i?n[t](...e.map(Oe)):i}})),["push","pop","shift","unshift","splice"].forEach((t=>{e[t]=function(...e){M.push(L),L=!1;const n=Oe(this)[t].apply(this,e);return function(){const e=M.pop();L=void 0===e||e}(),n}})),e}function K(e=!1,t=!1){return function(n,i,r){if("__v_isReactive"===i)return!e;if("__v_isReadonly"===i)return e;if("__v_isShallow"===i)return t;if("__v_raw"===i&&r===(e?t?me:Ee:t?ye:ge).get(n))return n;const s=c(n);if(!e&&s&&a(F,i))return Reflect.get(F,i,r);const o=Reflect.get(n,i,r);return(h(i)?z.has(i):V(i))?o:(e||T(n,"get",i),t?o:je(o)?s&&v(i)?o:o.value:d(o)?e?be(o):_e(o):o)}}function q(e=!1){return function(t,n,i,r){let s=t[n];if(Ne(s)&&je(s)&&!je(i))return!1;if(!e&&(function(e){return!(!e||!e.__v_isShallow)}(i)||Ne(i)||(s=Oe(s),i=Oe(i)),!c(t)&&je(s)&&!je(i)))return s.value=i,!0;const o=c(t)&&v(n)?Number(n)<t.length:a(t,n),l=Reflect.set(t,n,i,r);return t===Oe(r)&&(o?g(i,s)&&U(t,"set",n,i,s):U(t,"add",n,i)),l}}const G={get:C,set:q(),deleteProperty:function(e,t){const n=a(e,t),i=e[t],r=Reflect.deleteProperty(e,t);return r&&n&&U(e,"delete",t,void 0,i),r},has:function(e,t){const n=Reflect.has(e,t);return h(t)&&z.has(t)||T(e,"has",t),n},ownKeys:function(e){return T(e,"iterate",c(e)?"length":R),Reflect.ownKeys(e)}},J={get:I,set:(e,t)=>("production"!==process.env.NODE_ENV&&E(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0),deleteProperty:(e,t)=>("production"!==process.env.NODE_ENV&&E(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0)},Q=e=>e,X=e=>Reflect.getPrototypeOf(e);function Y(e,t,n=!1,i=!1){const r=Oe(e=e.__v_raw),s=Oe(t);n||(t!==s&&T(r,"get",t),T(r,"get",s));const{has:o}=X(r),a=i?Q:n?xe:ke;return o.call(r,t)?a(e.get(t)):o.call(r,s)?a(e.get(s)):void(e!==r&&e.get(t))}function Z(e,t=!1){const n=this.__v_raw,i=Oe(n),r=Oe(e);return t||(e!==r&&T(i,"has",e),T(i,"has",r)),e===r?n.has(e):n.has(e)||n.has(r)}function ee(e,t=!1){return e=e.__v_raw,!t&&T(Oe(e),"iterate",R),Reflect.get(e,"size",e)}function te(e){e=Oe(e);const t=Oe(this);return X(t).has.call(t,e)||(t.add(e),U(t,"add",e,e)),this}function ne(e,t){t=Oe(t);const n=Oe(this),{has:i,get:r}=X(n);let s=i.call(n,e);s?"production"!==process.env.NODE_ENV&&we(n,i,e):(e=Oe(e),s=i.call(n,e));const o=r.call(n,e);return n.set(e,t),s?g(t,o)&&U(n,"set",e,t,o):U(n,"add",e,t),this}function ie(e){const t=Oe(this),{has:n,get:i}=X(t);let r=n.call(t,e);r?"production"!==process.env.NODE_ENV&&we(t,n,e):(e=Oe(e),r=n.call(t,e));const s=i?i.call(t,e):void 0,o=t.delete(e);return r&&U(t,"delete",e,void 0,s),o}function re(){const e=Oe(this),t=0!==e.size,n="production"!==process.env.NODE_ENV?l(e)?new Map(e):new Set(e):void 0,i=e.clear();return t&&U(e,"clear",void 0,void 0,n),i}function se(e,t){return function(n,i){const r=this,s=r.__v_raw,o=Oe(s),a=t?Q:e?xe:ke;return!e&&T(o,"iterate",R),s.forEach(((e,t)=>n.call(i,a(e),a(t),r)))}}function oe(e,t,n){return function(...i){const r=this.__v_raw,s=Oe(r),o=l(s),a="entries"===e||e===Symbol.iterator&&o,c="keys"===e&&o,h=r[e](...i),d=n?Q:t?xe:ke;return!t&&T(s,"iterate",c?P:R),{next(){const{value:e,done:t}=h.next();return t?{value:e,done:t}:{value:a?[d(e[0]),d(e[1])]:d(e),done:t}},[Symbol.iterator](){return this}}}}function ae(e){return function(...t){if("production"!==process.env.NODE_ENV){const n=t[0]?`on key "${t[0]}" `:"";console.warn(`${w(e)} operation ${n}failed: target is readonly.`,Oe(this))}return"delete"!==e&&this}}function ce(){const e={get(e){return Y(this,e)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:ie,clear:re,forEach:se(!1,!1)},t={get(e){return Y(this,e,!1,!0)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:ie,clear:re,forEach:se(!1,!0)},n={get(e){return Y(this,e,!0)},get size(){return ee(this,!0)},has(e){return Z.call(this,e,!0)},add:ae("add"),set:ae("set"),delete:ae("delete"),clear:ae("clear"),forEach:se(!0,!1)},i={get(e){return Y(this,e,!0,!0)},get size(){return ee(this,!0)},has(e){return Z.call(this,e,!0)},add:ae("add"),set:ae("set"),delete:ae("delete"),clear:ae("clear"),forEach:se(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((r=>{e[r]=oe(r,!1,!1),n[r]=oe(r,!0,!1),t[r]=oe(r,!1,!0),i[r]=oe(r,!0,!0)})),[e,n,t,i]}const[le,he,de,ue]=ce();function fe(e,t){const n=t?e?ue:de:e?he:le;return(t,i,r)=>"__v_isReactive"===i?!e:"__v_isReadonly"===i?e:"__v_raw"===i?t:Reflect.get(a(n,i)&&i in t?n:t,i,r)}const pe={get:fe(!1,!1)},ve={get:fe(!0,!1)};function we(e,t,n){const i=Oe(n);if(i!==n&&t.call(e,i)){const t=p(e);console.warn(`Reactive ${t} contains both the raw and reactive versions of the same object${"Map"===t?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}const ge=new WeakMap,ye=new WeakMap,Ee=new WeakMap,me=new WeakMap;function _e(e){return Ne(e)?e:Se(e,!1,G,pe,ge)}function be(e){return Se(e,!0,J,ve,Ee)}function Se(e,t,n,i,r){if(!d(e))return"production"!==process.env.NODE_ENV&&console.warn(`value cannot be made reactive: ${String(e)}`),e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const s=r.get(e);if(s)return s;const o=(a=e).__v_skip||!Object.isExtensible(a)?0:function(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(p(a));var a;if(0===o)return e;const c=new Proxy(e,2===o?i:n);return r.set(e,c),c}function Ne(e){return!(!e||!e.__v_isReadonly)}function Oe(e){const t=e&&e.__v_raw;return t?Oe(t):e}const ke=e=>d(e)?_e(e):e,xe=e=>d(e)?be(e):e;function je(e){return!(!e||!0!==e.__v_isRef)}const Ae={removeNonExistedBroadcast:e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but ${e} hasn't been registed as a broadcast event`,wrongBroadcastCallback:e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but the listener hasn't been registed`,broadcastCallbackError:e=>`[@rallie/core] one of the callbacks of the broadcast event ${e} throws an uncaught error`,removeNonExistedUnicast:e=>`[@rallie/core] you are trying to remove a listener of the unicast event ${e}, but ${e} hasn't been registed as a unicast event`,registedExistedUnicast:e=>`[@rallie/core] you are trying to register a unicast event ${e}, but it has been registered before`,emittedNonExistedUnicast:e=>`[@rallie/core] you have emitted ${e} unicast, but there is no listener of this event`,createExistingApp:e=>`[@rallie/core] ${e} is existing, you are not allowed to create it again`,resourceNotDeclared:(e,t)=>`[@rallie/core] can not find any assets of the app ${e} on the bus ${t}`,appNotCreated:e=>`[@rallie/core] you are trying to activate app ${e}, but it was not created`,modifyPrivateState:e=>`[@rallie/core] state ${e} is private, you are not allowed to set it`,actionIsNotDefined:e=>`[@rallie/core] please describe your action when you modify the state ${e}`,accessUninitializedState:e=>`[@rallie/core] it's not allowed to set or watch state ${e} before it is initialized`,duplicatedInitial:e=>`[@rallie/core] duplicated initialized state ${e}`,initializePrimitiveState:e=>`[@rallie/core] it's not allowed to initialized state ${e} to a primitive value`,duplicatedBus:e=>`[@rallie/core] the bus named ${e} has been defined before, please rename your bus`,circularDependencies:(e,t)=>`[@rallie/core] There is a circular dependency when activating the app ${e}, and the circular path is ${t.join("->")}`,multipleCalledNextFn:()=>"[@rallie/core] next() called multiple times in the middleware",wrongMiddlewareType:()=>"[@rallie/core] the middleware must be a function"},Re={handlerIsNotInTheEventsPool:(e,t)=>`[@rallie/core] the event ${e} is not in the events pool that you specified when calling on${t?"Unicast":"Broadcast"}`};const Pe=e=>(t,n)=>{let i=-1;const r=s=>{if(s<=i)return Promise.reject(new Error(Ae.multipleCalledNextFn()));i=s;let o=e[s];if(s===e.length&&(o=n),!o)return Promise.resolve();try{return Promise.resolve(o(t,r.bind(null,s+1)))}catch(e){return Promise.reject(e)}};return r(0)};var $e,Be,Le,Me,Te,Ue,We,De,Ve;class ze{constructor(){$e.set(this,{}),Be.set(this,{})}addBroadcastEventListener(e,t){n(this,$e,"f")[e]=n(this,$e,"f")[e]||new Set;n(this,$e,"f")[e].add(t)}addUnicastEventListener(e,t){if(n(this,Be,"f")[e])throw new Error(Ae.registedExistedUnicast(e));n(this,Be,"f")[e]=t}removeBroadcastEventListener(e,t){const i=n(this,$e,"f")[e];if(!i){const t=Ae.removeNonExistedBroadcast(e);throw new Error(t)}if(!i.has(t)){const t=Ae.wrongBroadcastCallback(e);throw new Error(t)}i.delete(t)}removeUnicastEventListener(e){if(!n(this,Be,"f")[e]){const t=Ae.removeNonExistedUnicast(e);throw new Error(t)}delete n(this,Be,"f")[e]}emitBroadcast(e,...t){n(this,$e,"f")[e]=n(this,$e,"f")[e]||new Set;n(this,$e,"f")[e].forEach((n=>{try{n(...t)}catch(t){console.error(Ae.broadcastCallbackError(e)),console.error(t)}}))}emitUnicast(e,...t){const i=n(this,Be,"f")[e];if(i)return i(...t);throw new Error(Ae.emittedNonExistedUnicast(e))}}$e=new WeakMap,Be=new WeakMap;class Ce{constructor(e,t){Le.set(this,void 0),Me.set(this,void 0),i(this,Le,e,"f"),i(this,Me,t,"f"),n(this,Me,"f")[e].watchers.add(this)}do(e){return this.handler=e,()=>this.unwatch()}unwatch(){null==this||this.stopEffect(),this.handler=null;const e=n(this,Me,"f")[n(this,Le,"f")].watchers;e.has(this)&&e.delete(this)}}Le=new WeakMap,Me=new WeakMap;class Ie{constructor(e,t){Te.add(this),Ue.set(this,void 0),We.set(this,void 0),i(this,Ue,e,"f"),i(this,We,t,"f")}onBroadcast(e){return Object.entries(e).forEach((([e,t])=>{n(this,Ue,"f").addBroadcastEventListener(e,t)})),t=>{n(this,Te,"m",De).call(this,e,!1,t)}}onUnicast(e){return Object.entries(e).forEach((([e,t])=>{try{n(this,Ue,"f").addUnicastEventListener(e,t)}catch(e){console.error(e)}})),t=>{n(this,Te,"m",De).call(this,e,!0,t)}}createBroadcaster(e){return new Proxy({},{get:(t,i)=>(...t)=>n(this,Ue,"f").emitBroadcast(i,...t,null==e?void 0:e(i)),set:()=>!1})}createUnicaster(e){return new Proxy({},{get:(t,i)=>(...t)=>n(this,Ue,"f").emitUnicast(i,...t,null==e?void 0:e(i)),set:()=>!1})}existState(e){return!!n(this,We,"f")[e]}initState(e,t,i=!1){if(this.existState(e))throw new Error(Ae.duplicatedInitial(e));if(["string","number","boolean","undefined"].includes(typeof t))throw new Error(Ae.initializePrimitiveState(e));return n(this,We,"f")[e]={state:_e(t),owner:i?this:null,watchers:new Set},n(this,Ue,"f").emitBroadcast("$state-initialized",e),this.getState(e)}getState(e,t){if(this.existState(e)){const i=be(n(this,We,"f")[e].state);return t?t(i):i}return null}setState(e,i,r){return t(this,void 0,void 0,(function*(){const t=n(this,Te,"m",Ve).call(this,e);if(!i)throw new Error(Ae.actionIsNotDefined(e));{const e=r(t);yield Promise.resolve(e)}}))}watchState(e,t){if(!this.existState(e)){const t=Ae.accessUninitializedState(e);throw new Error(t)}let i=!1;const r=be(n(this,We,"f")[e].state),o=new Ce(e,n(this,We,"f")),a=function(e,t){e.effect&&(e=e.effect.fn);const n=new $(e);t&&(s(n,t),t.scope&&_(n,t.scope)),t&&t.lazy||n.run();const i=n.run.bind(n);return i.effect=n,i}((()=>t(r)),{lazy:!0,scheduler:()=>{i||(i=!0,Promise.resolve().then((()=>{var e;const n=Oe(t(r));null===(e=o.handler)||void 0===e||e.call(o,n,o.oldWatchingStates),o.oldWatchingStates=Oe(n),i=!1})))}});return o.oldWatchingStates=a(),o.stopEffect=()=>a.effect.stop(),o}}Ue=new WeakMap,We=new WeakMap,Te=new WeakSet,De=function(e,t,i){let r=t?n(this,Ue,"f").removeUnicastEventListener:n(this,Ue,"f").removeBroadcastEventListener;r=r.bind(n(this,Ue,"f")),i?e[i]?(r(i,e[i]),delete e[i]):console.warn(Re.handlerIsNotInTheEventsPool(i,t)):Object.entries(e).forEach((([e,t])=>{r(e,t)}))},Ve=function(e){if(!this.existState(e)){const t=Ae.accessUninitializedState(e);throw new Error(t)}const t=n(this,We,"f")[e].owner;if(t!==this&&null!==t){const t=Ae.modifyPrivateState(e);throw new Error(t)}return n(this,We,"f")[e].state};class Fe{constructor(e){this.name=e,this.activated=null,this.dependencies=[],this.relatedApps=[],this.name=e,this.isRallieCoreApp=!0}relateTo(e){return this.relatedApps=Array.from(new Set([...this.relatedApps,...e])),this}relyOn(e){return this.relateTo(e),this.dependencies=Array.from(new Set([...this.dependencies,...e])),this}onActivate(e){return this.doActivate=e,this}}var He,Ke,qe,Ge,Je,Qe,Xe,Ye,Ze,et,tt,nt,it,rt,st={loadScript:e=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{let n=null;if(e instanceof HTMLScriptElement)n=e;else{n=document.createElement("script");const t="string"!=typeof e?e:{type:"text/javascript",src:e};Object.entries(t).forEach((([e,t])=>{n.setAttribute(e,t)}))}n.src&&(n.onload=n.onerror=()=>{t()}),document.body.appendChild(n),n.src||t()}))})),loadLink:e=>{let t=null;if(e instanceof HTMLLinkElement)t=e;else{const n="string"!=typeof e?e:{rel:"stylesheet",type:"text/css",href:e};t=document.createElement("link"),Object.entries(n).forEach((([e,n])=>{t.setAttribute(e,n)}))}document.head.appendChild(t)}};class ot{constructor(e){He.add(this),Ke.set(this,void 0),qe.set(this,new ze),Ge.set(this,{}),Je.set(this,{}),Qe.set(this,{}),this.conf=be({assets:{}}),Xe.set(this,[]),Ye.set(this,void 0),i(this,Ke,e,"f"),i(this,Ye,Pe(n(this,Xe,"f")),"f")}createSocket(){return new Ie(n(this,qe,"f"),n(this,Ge,"f"))}existApp(e){return!!n(this,Je,"f")[e]}createApp(e){if(this.existApp(e))throw new Error(Ae.createExistingApp(e));const t=new Fe(e);return n(this,Je,"f")[e]=t,t}loadApp(e){return t(this,void 0,void 0,(function*(){n(this,Je,"f")[e]||(n(this,Qe,"f")[e]||(n(this,Qe,"f")[e]=new Promise(((t,i)=>{const r=n(this,He,"m",et).call(this,e);n(this,Ye,"f").call(this,r,n(this,He,"m",tt).bind(this)).then((()=>{e.startsWith("lib:")&&!n(this,Je,"f")[e]&&(n(this,Je,"f")[e]=!0),n(this,Je,"f")[e]||i(new Error(Ae.appNotCreated(e))),t()})).catch((e=>{i(e)}))}))),yield n(this,Qe,"f")[e])}))}activateApp(e){return t(this,void 0,void 0,(function*(){yield n(this,He,"m",nt).call(this,e,[])}))}config(e){return this.conf=Object.assign(Object.assign(Object.assign({},this.conf),e),{assets:Object.assign(Object.assign({},this.conf.assets),(null==e?void 0:e.assets)||{})}),this}use(e){if("function"!=typeof e)throw new Error(Ae.wrongMiddlewareType());return n(this,Xe,"f").push(e),i(this,Ye,Pe(n(this,Xe,"f")),"f"),this}}Ke=new WeakMap,qe=new WeakMap,Ge=new WeakMap,Je=new WeakMap,Qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,He=new WeakSet,Ze=function(e){return n(this,Je,"f")[e]&&"boolean"!=typeof n(this,Je,"f")[e]},et=function(e){return{name:e,loadScript:st.loadScript,loadLink:st.loadLink}},tt=function(e){return t(this,void 0,void 0,(function*(){const{name:t,loadScript:i=st.loadScript,loadLink:r=st.loadLink}=e,{assets:s}=this.conf;if(!s[t])throw new Error(Ae.resourceNotDeclared(t,n(this,Ke,"f")));if(s[t].css&&s[t].css.forEach((e=>{r(e)})),s[t].js)for(const e of s[t].js)yield i(e)}))},nt=function(e,i){return t(this,void 0,void 0,(function*(){if(yield this.loadApp(e),n(this,He,"m",Ze).call(this,e)){const r=n(this,Je,"f")[e];if(yield n(this,He,"m",rt).call(this,r),i.includes(e)){const t=i.indexOf(e),n=[...i.slice(t),e];throw new Error(Ae.circularDependencies(e,n))}if(i.push(e),!r.activated){const e=()=>t(this,void 0,void 0,(function*(){yield n(this,He,"m",it).call(this,r,i),r.doActivate&&(yield Promise.resolve(r.doActivate()))}));r.activated=e()}yield r.activated,i.pop()}}))},it=function(e,i){return t(this,void 0,void 0,(function*(){if(0!==e.dependencies.length)for(const t of e.dependencies)yield n(this,He,"m",nt).call(this,t,i)}))},rt=function(e){return t(this,void 0,void 0,(function*(){yield Promise.all(e.relatedApps.map((e=>this.loadApp(e))))}))};const at={},ct="DEFAULT_BUS",lt=(e=ct)=>{if(void 0===window.RALLIE_BUS_STORE&&Reflect.defineProperty(window,"RALLIE_BUS_STORE",{value:at,writable:!1}),window.RALLIE_BUS_STORE[e])throw new Error(Ae.duplicatedBus(e));{const t=new ot(e);return Reflect.defineProperty(window.RALLIE_BUS_STORE,e,{value:t,writable:!1}),t}},ht=(e=ct)=>window.RALLIE_BUS_STORE&&window.RALLIE_BUS_STORE[e],dt=(e=ct)=>{let t=null,n=!1;const i=ht(e);return i?(t=i,n=!1):(t=lt(e),n=!0),[t,n]},ut={createBus:lt,getBus:ht,touchBus:dt,Bus:ot};e.App=Fe,e.Bus=ot,e.Errors=Ae,e.Socket=Ie,e.Warnings=Re,e.createBus=lt,e.default=ut,e.getBus=ht,e.touchBus=dt,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RallieCore={})}(this,(function(e){"use strict";function t(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function n(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function i(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}function r(e,t){const n=Object.create(null),i=e.split(",");for(let e=0;e<i.length;e++)n[i[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}"production"===process.env.NODE_ENV||Object.freeze({}),"production"===process.env.NODE_ENV||Object.freeze([]);const s=Object.assign,o=Object.prototype.hasOwnProperty,a=(e,t)=>o.call(e,t),c=Array.isArray,l=e=>"[object Map]"===f(e),h=e=>"symbol"==typeof e,d=e=>null!==e&&"object"==typeof e,u=Object.prototype.toString,f=e=>u.call(e),p=e=>f(e).slice(8,-1),v=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,w=(e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))})((e=>e.charAt(0).toUpperCase()+e.slice(1))),g=(e,t)=>!Object.is(e,t),y=e=>{const t=parseFloat(e);return isNaN(t)?e:t};function E(e,...t){console.warn(`[Vue warn] ${e}`,...t)}let m;function _(e,t=m){t&&t.active&&t.effects.push(e)}const b=e=>{const t=new Set(e);return t.w=0,t.n=0,t},S=e=>(e.w&x)>0,N=e=>(e.n&x)>0,O=new WeakMap;let k=0,x=1;const j=30;let A;const R=Symbol("production"!==process.env.NODE_ENV?"iterate":""),P=Symbol("production"!==process.env.NODE_ENV?"Map key iterate":"");class ${constructor(e,t=null,n){this.fn=e,this.scheduler=t,this.active=!0,this.deps=[],this.parent=void 0,_(this,n)}run(){if(!this.active)return this.fn();let e=A,t=L;for(;e;){if(e===this)return;e=e.parent}try{return this.parent=A,A=this,L=!0,x=1<<++k,k<=j?(({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=x})(this):B(this),this.fn()}finally{k<=j&&(e=>{const{deps:t}=e;if(t.length){let n=0;for(let i=0;i<t.length;i++){const r=t[i];S(r)&&!N(r)?r.delete(e):t[n++]=r,r.w&=~x,r.n&=~x}t.length=n}})(this),x=1<<--k,A=this.parent,L=t,this.parent=void 0,this.deferStop&&this.stop()}}stop(){A===this?this.deferStop=!0:this.active&&(B(this),this.onStop&&this.onStop(),this.active=!1)}}function B(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}let L=!0;const M=[];function T(e,t,n){if(L&&A){let i=O.get(e);i||O.set(e,i=new Map);let r=i.get(n);r||i.set(n,r=b());!function(e,t){let n=!1;k<=j?N(e)||(e.n|=x,n=!S(e)):n=!e.has(A);n&&(e.add(A),A.deps.push(e),"production"!==process.env.NODE_ENV&&A.onTrack&&A.onTrack(Object.assign({effect:A},t)))}(r,"production"!==process.env.NODE_ENV?{effect:A,target:e,type:t,key:n}:void 0)}}function U(e,t,n,i,r,s){const o=O.get(e);if(!o)return;let a=[];if("clear"===t)a=[...o.values()];else if("length"===n&&c(e)){const e=y(i);o.forEach(((t,n)=>{("length"===n||n>=e)&&a.push(t)}))}else switch(void 0!==n&&a.push(o.get(n)),t){case"add":c(e)?v(n)&&a.push(o.get("length")):(a.push(o.get(R)),l(e)&&a.push(o.get(P)));break;case"delete":c(e)||(a.push(o.get(R)),l(e)&&a.push(o.get(P)));break;case"set":l(e)&&a.push(o.get(R))}const h="production"!==process.env.NODE_ENV?{target:e,type:t,key:n,newValue:i,oldValue:r,oldTarget:s}:void 0;if(1===a.length)a[0]&&("production"!==process.env.NODE_ENV?W(a[0],h):W(a[0]));else{const e=[];for(const t of a)t&&e.push(...t);"production"!==process.env.NODE_ENV?W(b(e),h):W(b(e))}}function W(e,t){const n=c(e)?e:[...e];for(const e of n)e.computed&&D(e,t);for(const e of n)e.computed||D(e,t)}function D(e,t){(e!==A||e.allowRecurse)&&("production"!==process.env.NODE_ENV&&e.onTrigger&&e.onTrigger(s({effect:e},t)),e.scheduler?e.scheduler():e.run())}const V=r("__proto__,__v_isRef,__isVue"),z=new Set(Object.getOwnPropertyNames(Symbol).filter((e=>"arguments"!==e&&"caller"!==e)).map((e=>Symbol[e])).filter(h)),C=K(),I=K(!0),F=H();function H(){const e={};return["includes","indexOf","lastIndexOf"].forEach((t=>{e[t]=function(...e){const n=Oe(this);for(let e=0,t=this.length;e<t;e++)T(n,"get",e+"");const i=n[t](...e);return-1===i||!1===i?n[t](...e.map(Oe)):i}})),["push","pop","shift","unshift","splice"].forEach((t=>{e[t]=function(...e){M.push(L),L=!1;const n=Oe(this)[t].apply(this,e);return function(){const e=M.pop();L=void 0===e||e}(),n}})),e}function K(e=!1,t=!1){return function(n,i,r){if("__v_isReactive"===i)return!e;if("__v_isReadonly"===i)return e;if("__v_isShallow"===i)return t;if("__v_raw"===i&&r===(e?t?me:Ee:t?ye:ge).get(n))return n;const s=c(n);if(!e&&s&&a(F,i))return Reflect.get(F,i,r);const o=Reflect.get(n,i,r);return(h(i)?z.has(i):V(i))?o:(e||T(n,"get",i),t?o:je(o)?s&&v(i)?o:o.value:d(o)?e?be(o):_e(o):o)}}function q(e=!1){return function(t,n,i,r){let s=t[n];if(Ne(s)&&je(s)&&!je(i))return!1;if(!e&&(function(e){return!(!e||!e.__v_isShallow)}(i)||Ne(i)||(s=Oe(s),i=Oe(i)),!c(t)&&je(s)&&!je(i)))return s.value=i,!0;const o=c(t)&&v(n)?Number(n)<t.length:a(t,n),l=Reflect.set(t,n,i,r);return t===Oe(r)&&(o?g(i,s)&&U(t,"set",n,i,s):U(t,"add",n,i)),l}}const G={get:C,set:q(),deleteProperty:function(e,t){const n=a(e,t),i=e[t],r=Reflect.deleteProperty(e,t);return r&&n&&U(e,"delete",t,void 0,i),r},has:function(e,t){const n=Reflect.has(e,t);return h(t)&&z.has(t)||T(e,"has",t),n},ownKeys:function(e){return T(e,"iterate",c(e)?"length":R),Reflect.ownKeys(e)}},J={get:I,set:(e,t)=>("production"!==process.env.NODE_ENV&&E(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0),deleteProperty:(e,t)=>("production"!==process.env.NODE_ENV&&E(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0)},Q=e=>e,X=e=>Reflect.getPrototypeOf(e);function Y(e,t,n=!1,i=!1){const r=Oe(e=e.__v_raw),s=Oe(t);n||(t!==s&&T(r,"get",t),T(r,"get",s));const{has:o}=X(r),a=i?Q:n?xe:ke;return o.call(r,t)?a(e.get(t)):o.call(r,s)?a(e.get(s)):void(e!==r&&e.get(t))}function Z(e,t=!1){const n=this.__v_raw,i=Oe(n),r=Oe(e);return t||(e!==r&&T(i,"has",e),T(i,"has",r)),e===r?n.has(e):n.has(e)||n.has(r)}function ee(e,t=!1){return e=e.__v_raw,!t&&T(Oe(e),"iterate",R),Reflect.get(e,"size",e)}function te(e){e=Oe(e);const t=Oe(this);return X(t).has.call(t,e)||(t.add(e),U(t,"add",e,e)),this}function ne(e,t){t=Oe(t);const n=Oe(this),{has:i,get:r}=X(n);let s=i.call(n,e);s?"production"!==process.env.NODE_ENV&&we(n,i,e):(e=Oe(e),s=i.call(n,e));const o=r.call(n,e);return n.set(e,t),s?g(t,o)&&U(n,"set",e,t,o):U(n,"add",e,t),this}function ie(e){const t=Oe(this),{has:n,get:i}=X(t);let r=n.call(t,e);r?"production"!==process.env.NODE_ENV&&we(t,n,e):(e=Oe(e),r=n.call(t,e));const s=i?i.call(t,e):void 0,o=t.delete(e);return r&&U(t,"delete",e,void 0,s),o}function re(){const e=Oe(this),t=0!==e.size,n="production"!==process.env.NODE_ENV?l(e)?new Map(e):new Set(e):void 0,i=e.clear();return t&&U(e,"clear",void 0,void 0,n),i}function se(e,t){return function(n,i){const r=this,s=r.__v_raw,o=Oe(s),a=t?Q:e?xe:ke;return!e&&T(o,"iterate",R),s.forEach(((e,t)=>n.call(i,a(e),a(t),r)))}}function oe(e,t,n){return function(...i){const r=this.__v_raw,s=Oe(r),o=l(s),a="entries"===e||e===Symbol.iterator&&o,c="keys"===e&&o,h=r[e](...i),d=n?Q:t?xe:ke;return!t&&T(s,"iterate",c?P:R),{next(){const{value:e,done:t}=h.next();return t?{value:e,done:t}:{value:a?[d(e[0]),d(e[1])]:d(e),done:t}},[Symbol.iterator](){return this}}}}function ae(e){return function(...t){if("production"!==process.env.NODE_ENV){const n=t[0]?`on key "${t[0]}" `:"";console.warn(`${w(e)} operation ${n}failed: target is readonly.`,Oe(this))}return"delete"!==e&&this}}function ce(){const e={get(e){return Y(this,e)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:ie,clear:re,forEach:se(!1,!1)},t={get(e){return Y(this,e,!1,!0)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:ie,clear:re,forEach:se(!1,!0)},n={get(e){return Y(this,e,!0)},get size(){return ee(this,!0)},has(e){return Z.call(this,e,!0)},add:ae("add"),set:ae("set"),delete:ae("delete"),clear:ae("clear"),forEach:se(!0,!1)},i={get(e){return Y(this,e,!0,!0)},get size(){return ee(this,!0)},has(e){return Z.call(this,e,!0)},add:ae("add"),set:ae("set"),delete:ae("delete"),clear:ae("clear"),forEach:se(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((r=>{e[r]=oe(r,!1,!1),n[r]=oe(r,!0,!1),t[r]=oe(r,!1,!0),i[r]=oe(r,!0,!0)})),[e,n,t,i]}const[le,he,de,ue]=ce();function fe(e,t){const n=t?e?ue:de:e?he:le;return(t,i,r)=>"__v_isReactive"===i?!e:"__v_isReadonly"===i?e:"__v_raw"===i?t:Reflect.get(a(n,i)&&i in t?n:t,i,r)}const pe={get:fe(!1,!1)},ve={get:fe(!0,!1)};function we(e,t,n){const i=Oe(n);if(i!==n&&t.call(e,i)){const t=p(e);console.warn(`Reactive ${t} contains both the raw and reactive versions of the same object${"Map"===t?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}const ge=new WeakMap,ye=new WeakMap,Ee=new WeakMap,me=new WeakMap;function _e(e){return Ne(e)?e:Se(e,!1,G,pe,ge)}function be(e){return Se(e,!0,J,ve,Ee)}function Se(e,t,n,i,r){if(!d(e))return"production"!==process.env.NODE_ENV&&console.warn(`value cannot be made reactive: ${String(e)}`),e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const s=r.get(e);if(s)return s;const o=(a=e).__v_skip||!Object.isExtensible(a)?0:function(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(p(a));var a;if(0===o)return e;const c=new Proxy(e,2===o?i:n);return r.set(e,c),c}function Ne(e){return!(!e||!e.__v_isReadonly)}function Oe(e){const t=e&&e.__v_raw;return t?Oe(t):e}const ke=e=>d(e)?_e(e):e,xe=e=>d(e)?be(e):e;function je(e){return!(!e||!0!==e.__v_isRef)}const Ae={removeNonExistedBroadcast:e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but ${e} hasn't been registed as a broadcast event`,wrongBroadcastCallback:e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but the listener hasn't been registed`,broadcastCallbackError:e=>`[@rallie/core] one of the callbacks of the broadcast event ${e} throws an uncaught error`,removeNonExistedUnicast:e=>`[@rallie/core] you are trying to remove a listener of the unicast event ${e}, but ${e} hasn't been registed as a unicast event`,registedExistedUnicast:e=>`[@rallie/core] you are trying to register a unicast event ${e}, but it has been registered before`,emittedNonExistedUnicast:e=>`[@rallie/core] you have emitted ${e} unicast, but there is no listener of this event`,createExistingApp:e=>`[@rallie/core] ${e} is existing, you are not allowed to create it again`,resourceNotDeclared:(e,t)=>`[@rallie/core] can not find any assets of the app ${e} on the bus ${t}`,appNotCreated:e=>`[@rallie/core] you are trying to activate app ${e}, but it was not created`,modifyPrivateState:e=>`[@rallie/core] state ${e} is private, you are not allowed to set it`,actionIsNotDefined:e=>`[@rallie/core] please describe your action when you modify the state ${e}`,accessUninitializedState:e=>`[@rallie/core] it's not allowed to set or watch state ${e} before it is initialized`,duplicatedInitial:e=>`[@rallie/core] duplicated initialized state ${e}`,initializePrimitiveState:e=>`[@rallie/core] it's not allowed to initialized state ${e} to a primitive value`,duplicatedBus:e=>`[@rallie/core] the bus named ${e} has been defined before, please rename your bus`,circularDependencies:(e,t)=>`[@rallie/core] There is a circular dependency when activating the app ${e}, and the circular path is ${t.join("->")}`,multipleCalledNextFn:()=>"[@rallie/core] next() called multiple times in the middleware",wrongMiddlewareType:()=>"[@rallie/core] the middleware must be a function"},Re={handlerIsNotInTheEventsPool:(e,t)=>`[@rallie/core] the event ${e} is not in the events pool that you specified when calling on${t?"Unicast":"Broadcast"}`};const Pe=e=>(t,n)=>{let i=-1;const r=s=>{if(s<=i)return Promise.reject(new Error(Ae.multipleCalledNextFn()));i=s;let o=e[s];if(s===e.length&&(o=n),!o)return Promise.resolve();try{return Promise.resolve(o(t,r.bind(null,s+1)))}catch(e){return Promise.reject(e)}};return r(0)};var $e,Be,Le,Me,Te,Ue,We,De,Ve;class ze{constructor(){$e.set(this,{}),Be.set(this,{})}addBroadcastEventListener(e,t){n(this,$e,"f")[e]=n(this,$e,"f")[e]||new Set;n(this,$e,"f")[e].add(t)}addUnicastEventListener(e,t){if(n(this,Be,"f")[e])throw new Error(Ae.registedExistedUnicast(e));n(this,Be,"f")[e]=t}removeBroadcastEventListener(e,t){const i=n(this,$e,"f")[e];if(!i){const t=Ae.removeNonExistedBroadcast(e);throw new Error(t)}if(!i.has(t)){const t=Ae.wrongBroadcastCallback(e);throw new Error(t)}i.delete(t)}removeUnicastEventListener(e){if(!n(this,Be,"f")[e]){const t=Ae.removeNonExistedUnicast(e);throw new Error(t)}delete n(this,Be,"f")[e]}emitBroadcast(e,...t){n(this,$e,"f")[e]=n(this,$e,"f")[e]||new Set;n(this,$e,"f")[e].forEach((n=>{try{n(...t)}catch(t){console.error(Ae.broadcastCallbackError(e)),console.error(t)}}))}emitUnicast(e,...t){const i=n(this,Be,"f")[e];if(i)return i(...t);throw new Error(Ae.emittedNonExistedUnicast(e))}}$e=new WeakMap,Be=new WeakMap;class Ce{constructor(e,t){Le.set(this,void 0),Me.set(this,void 0),i(this,Le,e,"f"),i(this,Me,t,"f"),n(this,Me,"f")[e].watchers.add(this)}do(e){return this.handler=e,()=>this.unwatch()}unwatch(){null==this||this.stopEffect(),this.handler=null;const e=n(this,Me,"f")[n(this,Le,"f")].watchers;e.has(this)&&e.delete(this)}}Le=new WeakMap,Me=new WeakMap;class Ie{constructor(e,t){Te.add(this),Ue.set(this,void 0),We.set(this,void 0),i(this,Ue,e,"f"),i(this,We,t,"f")}onBroadcast(e){return Object.entries(e).forEach((([e,t])=>{n(this,Ue,"f").addBroadcastEventListener(e,t)})),t=>{n(this,Te,"m",De).call(this,e,!1,t)}}onUnicast(e){return Object.entries(e).forEach((([e,t])=>{try{n(this,Ue,"f").addUnicastEventListener(e,t)}catch(e){console.error(e)}})),t=>{n(this,Te,"m",De).call(this,e,!0,t)}}createBroadcaster(e){return new Proxy({},{get:(t,i)=>(...t)=>(null==e||e(i),n(this,Ue,"f").emitBroadcast(i,...t)),set:()=>!1})}createUnicaster(e){return new Proxy({},{get:(t,i)=>(...t)=>(null==e||e(i),n(this,Ue,"f").emitUnicast(i,...t)),set:()=>!1})}existState(e){return!!n(this,We,"f")[e]}initState(e,t,i=!1){if(this.existState(e))throw new Error(Ae.duplicatedInitial(e));if(["string","number","boolean","undefined"].includes(typeof t))throw new Error(Ae.initializePrimitiveState(e));return n(this,We,"f")[e]={state:_e(t),owner:i?this:null,watchers:new Set},n(this,Ue,"f").emitBroadcast("$state-initialized",e),this.getState(e)}getState(e,t){if(this.existState(e)){const i=be(n(this,We,"f")[e].state);return t?t(i):i}return null}setState(e,i,r){return t(this,void 0,void 0,(function*(){const t=n(this,Te,"m",Ve).call(this,e);if(!i)throw new Error(Ae.actionIsNotDefined(e));{const e=r(t);yield Promise.resolve(e)}}))}watchState(e,t){if(!this.existState(e)){const t=Ae.accessUninitializedState(e);throw new Error(t)}let i=!1;const r=be(n(this,We,"f")[e].state),o=new Ce(e,n(this,We,"f")),a=function(e,t){e.effect&&(e=e.effect.fn);const n=new $(e);t&&(s(n,t),t.scope&&_(n,t.scope)),t&&t.lazy||n.run();const i=n.run.bind(n);return i.effect=n,i}((()=>t(r)),{lazy:!0,scheduler:()=>{i||(i=!0,Promise.resolve().then((()=>{var e;const n=Oe(t(r));null===(e=o.handler)||void 0===e||e.call(o,n,o.oldWatchingStates),o.oldWatchingStates=Oe(n),i=!1})))}});return o.oldWatchingStates=a(),o.stopEffect=()=>a.effect.stop(),o}}Ue=new WeakMap,We=new WeakMap,Te=new WeakSet,De=function(e,t,i){let r=t?n(this,Ue,"f").removeUnicastEventListener:n(this,Ue,"f").removeBroadcastEventListener;r=r.bind(n(this,Ue,"f")),i?e[i]?(r(i,e[i]),delete e[i]):console.warn(Re.handlerIsNotInTheEventsPool(i,t)):Object.entries(e).forEach((([e,t])=>{r(e,t)}))},Ve=function(e){if(!this.existState(e)){const t=Ae.accessUninitializedState(e);throw new Error(t)}const t=n(this,We,"f")[e].owner;if(t!==this&&null!==t){const t=Ae.modifyPrivateState(e);throw new Error(t)}return n(this,We,"f")[e].state};class Fe{constructor(e){this.name=e,this.activated=null,this.dependencies=[],this.relatedApps=[],this.name=e,this.isRallieCoreApp=!0}relateTo(e){return this.relatedApps=Array.from(new Set([...this.relatedApps,...e])),this}relyOn(e){return this.relateTo(e),this.dependencies=Array.from(new Set([...this.dependencies,...e])),this}onActivate(e){return this.doActivate=e,this}}var He,Ke,qe,Ge,Je,Qe,Xe,Ye,Ze,et,tt,nt,it,rt,st={loadScript:e=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{let n=null;if(e instanceof HTMLScriptElement)n=e;else{n=document.createElement("script");const t="string"!=typeof e?e:{type:"text/javascript",src:e};Object.entries(t).forEach((([e,t])=>{n.setAttribute(e,t)}))}n.src&&(n.onload=n.onerror=()=>{t()}),document.body.appendChild(n),n.src||t()}))})),loadLink:e=>{let t=null;if(e instanceof HTMLLinkElement)t=e;else{const n="string"!=typeof e?e:{rel:"stylesheet",type:"text/css",href:e};t=document.createElement("link"),Object.entries(n).forEach((([e,n])=>{t.setAttribute(e,n)}))}document.head.appendChild(t)}};class ot{constructor(e){He.add(this),Ke.set(this,void 0),qe.set(this,new ze),Ge.set(this,{}),Je.set(this,{}),Qe.set(this,{}),this.conf=be({assets:{}}),Xe.set(this,[]),Ye.set(this,void 0),i(this,Ke,e,"f"),i(this,Ye,Pe(n(this,Xe,"f")),"f")}createSocket(){return new Ie(n(this,qe,"f"),n(this,Ge,"f"))}existApp(e){return!!n(this,Je,"f")[e]}createApp(e){if(this.existApp(e))throw new Error(Ae.createExistingApp(e));const t=new Fe(e);return n(this,Je,"f")[e]=t,t}loadApp(e){return t(this,void 0,void 0,(function*(){n(this,Je,"f")[e]||(n(this,Qe,"f")[e]||(n(this,Qe,"f")[e]=new Promise(((t,i)=>{const r=n(this,He,"m",et).call(this,e);n(this,Ye,"f").call(this,r,n(this,He,"m",tt).bind(this)).then((()=>{e.startsWith("lib:")&&!n(this,Je,"f")[e]&&(n(this,Je,"f")[e]=!0),n(this,Je,"f")[e]||i(new Error(Ae.appNotCreated(e))),t()})).catch((e=>{i(e)}))}))),yield n(this,Qe,"f")[e])}))}activateApp(e){return t(this,void 0,void 0,(function*(){yield n(this,He,"m",nt).call(this,e,[])}))}config(e){return this.conf=Object.assign(Object.assign(Object.assign({},this.conf),e),{assets:Object.assign(Object.assign({},this.conf.assets),(null==e?void 0:e.assets)||{})}),this}use(e){if("function"!=typeof e)throw new Error(Ae.wrongMiddlewareType());return n(this,Xe,"f").push(e),i(this,Ye,Pe(n(this,Xe,"f")),"f"),this}}Ke=new WeakMap,qe=new WeakMap,Ge=new WeakMap,Je=new WeakMap,Qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,He=new WeakSet,Ze=function(e){return n(this,Je,"f")[e]&&"boolean"!=typeof n(this,Je,"f")[e]},et=function(e){return{name:e,loadScript:st.loadScript,loadLink:st.loadLink}},tt=function(e){return t(this,void 0,void 0,(function*(){const{name:t,loadScript:i=st.loadScript,loadLink:r=st.loadLink}=e,{assets:s}=this.conf;if(!s[t])throw new Error(Ae.resourceNotDeclared(t,n(this,Ke,"f")));if(s[t].css&&s[t].css.forEach((e=>{r(e)})),s[t].js)for(const e of s[t].js)yield i(e)}))},nt=function(e,i){return t(this,void 0,void 0,(function*(){if(yield this.loadApp(e),n(this,He,"m",Ze).call(this,e)){const r=n(this,Je,"f")[e];if(yield n(this,He,"m",rt).call(this,r),i.includes(e)){const t=i.indexOf(e),n=[...i.slice(t),e];throw new Error(Ae.circularDependencies(e,n))}if(i.push(e),!r.activated){const e=()=>t(this,void 0,void 0,(function*(){yield n(this,He,"m",it).call(this,r,i),r.doActivate&&(yield Promise.resolve(r.doActivate()))}));r.activated=e()}yield r.activated,i.pop()}}))},it=function(e,i){return t(this,void 0,void 0,(function*(){if(0!==e.dependencies.length)for(const t of e.dependencies)yield n(this,He,"m",nt).call(this,t,i)}))},rt=function(e){return t(this,void 0,void 0,(function*(){yield Promise.all(e.relatedApps.map((e=>this.loadApp(e))))}))};const at={},ct="DEFAULT_BUS",lt=(e=ct)=>{if(void 0===window.RALLIE_BUS_STORE&&Reflect.defineProperty(window,"RALLIE_BUS_STORE",{value:at,writable:!1}),window.RALLIE_BUS_STORE[e])throw new Error(Ae.duplicatedBus(e));{const t=new ot(e);return Reflect.defineProperty(window.RALLIE_BUS_STORE,e,{value:t,writable:!1}),t}},ht=(e=ct)=>window.RALLIE_BUS_STORE&&window.RALLIE_BUS_STORE[e],dt=(e=ct)=>{let t=null,n=!1;const i=ht(e);return i?(t=i,n=!1):(t=lt(e),n=!0),[t,n]},ut={createBus:lt,getBus:ht,touchBus:dt,Bus:ot};e.App=Fe,e.Bus=ot,e.Errors=Ae,e.Socket=Ie,e.Warnings=Re,e.createBus=lt,e.default=ut,e.getBus=ht,e.touchBus=dt,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@rallie/core", | ||
"version": "0.14.1", | ||
"version": "0.14.2", | ||
"description": "a progressive micro front framework", | ||
@@ -27,3 +27,3 @@ "main": "./dist/index.umd.js", | ||
"homepage": "https://github.com/ralliejs/rallie#readme", | ||
"gitHead": "0ac37e1b43ff349f18a2a59e5b03161163b44ffd" | ||
"gitHead": "f58095182b2dfa9dd917b80671b7079063c74cb9" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
72301
437