@rallie/block
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).RallieBlock={})}(this,(function(e){"use strict";function t(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function n(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function s(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}function i(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function r(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function o(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}"production"===process.env.NODE_ENV||Object.freeze({}),"production"===process.env.NODE_ENV||Object.freeze([]);const a=Object.assign,c=Object.prototype.hasOwnProperty,l=(e,t)=>c.call(e,t),h=Array.isArray,f=e=>"[object Map]"===w(e),u=e=>"symbol"==typeof e,d=e=>null!==e&&"object"==typeof e,p=Object.prototype.toString,w=e=>p.call(e),v=e=>w(e).slice(8,-1),y=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,g=(e=>{const t=Object.create(null);return e=>t[e]||(t[e]=(e=>e.charAt(0).toUpperCase()+e.slice(1))(e))})(),m=(e,t)=>!Object.is(e,t),E=e=>{const t=parseFloat(e);return isNaN(t)?e:t};function b(e,...t){console.warn(`[Vue warn] ${e}`,...t)}let _;function S(e,t=_){t&&t.active&&t.effects.push(e)}const k=e=>{const t=new Set(e);return t.w=0,t.n=0,t},O=e=>(e.w&$)>0,N=e=>(e.n&$)>0,A=new WeakMap;let R=0,$=1;const j=30;let M;const x=Symbol("production"!==process.env.NODE_ENV?"iterate":""),W=Symbol("production"!==process.env.NODE_ENV?"Map key iterate":"");class P{constructor(e,t=null,n){this.fn=e,this.scheduler=t,this.active=!0,this.deps=[],this.parent=void 0,S(this,n)}run(){if(!this.active)return this.fn();let e=M,t=T;for(;e;){if(e===this)return;e=e.parent}try{return this.parent=M,M=this,T=!0,$=1<<++R,R<=j?(({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=$})(this):B(this),this.fn()}finally{R<=j&&(e=>{const{deps:t}=e;if(t.length){let n=0;for(let s=0;s<t.length;s++){const i=t[s];O(i)&&!N(i)?i.delete(e):t[n++]=i,i.w&=~$,i.n&=~$}t.length=n}})(this),$=1<<--R,M=this.parent,T=t,this.parent=void 0,this.deferStop&&this.stop()}}stop(){M===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 T=!0;const L=[];function z(e,t,n){if(T&&M){let s=A.get(e);s||A.set(e,s=new Map);let i=s.get(n);i||s.set(n,i=k()),function(e,t){let n=!1;R<=j?N(e)||(e.n|=$,n=!O(e)):n=!e.has(M),n&&(e.add(M),M.deps.push(e),"production"!==process.env.NODE_ENV&&M.onTrack&&M.onTrack(Object.assign({effect:M},t)))}(i,"production"!==process.env.NODE_ENV?{effect:M,target:e,type:t,key:n}:void 0)}}function V(e,t,n,s,i,r){const o=A.get(e);if(!o)return;let a=[];if("clear"===t)a=[...o.values()];else if("length"===n&&h(e)){const e=E(s);o.forEach(((t,n)=>{("length"===n||n>=e)&&a.push(t)}))}else switch(void 0!==n&&a.push(o.get(n)),t){case"add":h(e)?y(n)&&a.push(o.get("length")):(a.push(o.get(x)),f(e)&&a.push(o.get(W)));break;case"delete":h(e)||(a.push(o.get(x)),f(e)&&a.push(o.get(W)));break;case"set":f(e)&&a.push(o.get(x))}const c="production"!==process.env.NODE_ENV?{target:e,type:t,key:n,newValue:s,oldValue:i,oldTarget:r}:void 0;if(1===a.length)a[0]&&("production"!==process.env.NODE_ENV?U(a[0],c):U(a[0]));else{const e=[];for(const t of a)t&&e.push(...t);"production"!==process.env.NODE_ENV?U(k(e),c):U(k(e))}}function U(e,t){const n=h(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!==M||e.allowRecurse)&&("production"!==process.env.NODE_ENV&&e.onTrigger&&e.onTrigger(a({effect:e},t)),e.scheduler?e.scheduler():e.run())}const I=function(e,t){const n=Object.create(null),s=e.split(",");for(let e=0;e<s.length;e++)n[s[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}("__proto__,__v_isRef,__isVue"),C=new Set(Object.getOwnPropertyNames(Symbol).filter((e=>"arguments"!==e&&"caller"!==e)).map((e=>Symbol[e])).filter(u)),G=J(),F=J(!0),H=function(){const e={};return["includes","indexOf","lastIndexOf"].forEach((t=>{e[t]=function(...e){const n=ke(this);for(let e=0,t=this.length;e<t;e++)z(n,"get",e+"");const s=n[t](...e);return-1===s||!1===s?n[t](...e.map(ke)):s}})),["push","pop","shift","unshift","splice"].forEach((t=>{e[t]=function(...e){L.push(T),T=!1;const n=ke(this)[t].apply(this,e);return function(){const e=L.pop();T=void 0===e||e}(),n}})),e}();function J(e=!1,t=!1){return function(n,s,i){if("__v_isReactive"===s)return!e;if("__v_isReadonly"===s)return e;if("__v_isShallow"===s)return t;if("__v_raw"===s&&i===(e?t?me:ge:t?ye:ve).get(n))return n;const r=h(n);if(!e&&r&&l(H,s))return Reflect.get(H,s,i);const o=Reflect.get(n,s,i);return(u(s)?C.has(s):I(s))?o:(e||z(n,"get",s),t?o:Ae(o)?r&&y(s)?o:o.value:d(o)?e?be(o):Ee(o):o)}}const K={get:G,set:function(e=!1){return function(t,n,s,i){let r=t[n];if(Se(r)&&Ae(r)&&!Ae(s))return!1;if(!e&&(function(e){return!(!e||!e.__v_isShallow)}(s)||Se(s)||(r=ke(r),s=ke(s)),!h(t)&&Ae(r)&&!Ae(s)))return r.value=s,!0;const o=h(t)&&y(n)?Number(n)<t.length:l(t,n),a=Reflect.set(t,n,s,i);return t===ke(i)&&(o?m(s,r)&&V(t,"set",n,s,r):V(t,"add",n,s)),a}}(),deleteProperty:function(e,t){const n=l(e,t),s=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&V(e,"delete",t,void 0,s),i},has:function(e,t){const n=Reflect.has(e,t);return u(t)&&C.has(t)||z(e,"has",t),n},ownKeys:function(e){return z(e,"iterate",h(e)?"length":x),Reflect.ownKeys(e)}},q={get:F,set:(e,t)=>("production"!==process.env.NODE_ENV&&b(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0),deleteProperty:(e,t)=>("production"!==process.env.NODE_ENV&&b(`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,s=!1){const i=ke(e=e.__v_raw),r=ke(t);n||(t!==r&&z(i,"get",t),z(i,"get",r));const{has:o}=X(i),a=s?Q:n?Ne:Oe;return o.call(i,t)?a(e.get(t)):o.call(i,r)?a(e.get(r)):void(e!==i&&e.get(t))}function Z(e,t=!1){const n=this.__v_raw,s=ke(n),i=ke(e);return t||(e!==i&&z(s,"has",e),z(s,"has",i)),e===i?n.has(e):n.has(e)||n.has(i)}function ee(e,t=!1){return e=e.__v_raw,!t&&z(ke(e),"iterate",x),Reflect.get(e,"size",e)}function te(e){e=ke(e);const t=ke(this);return X(t).has.call(t,e)||(t.add(e),V(t,"add",e,e)),this}function ne(e,t){t=ke(t);const n=ke(this),{has:s,get:i}=X(n);let r=s.call(n,e);r?"production"!==process.env.NODE_ENV&&we(n,s,e):(e=ke(e),r=s.call(n,e));const o=i.call(n,e);return n.set(e,t),r?m(t,o)&&V(n,"set",e,t,o):V(n,"add",e,t),this}function se(e){const t=ke(this),{has:n,get:s}=X(t);let i=n.call(t,e);i?"production"!==process.env.NODE_ENV&&we(t,n,e):(e=ke(e),i=n.call(t,e));const r=s?s.call(t,e):void 0,o=t.delete(e);return i&&V(t,"delete",e,void 0,r),o}function ie(){const e=ke(this),t=0!==e.size,n="production"!==process.env.NODE_ENV?f(e)?new Map(e):new Set(e):void 0,s=e.clear();return t&&V(e,"clear",void 0,void 0,n),s}function re(e,t){return function(n,s){const i=this,r=i.__v_raw,o=ke(r),a=t?Q:e?Ne:Oe;return!e&&z(o,"iterate",x),r.forEach(((e,t)=>n.call(s,a(e),a(t),i)))}}function oe(e,t,n){return function(...s){const i=this.__v_raw,r=ke(i),o=f(r),a="entries"===e||e===Symbol.iterator&&o,c="keys"===e&&o,l=i[e](...s),h=n?Q:t?Ne:Oe;return!t&&z(r,"iterate",c?W:x),{next(){const{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:a?[h(e[0]),h(e[1])]:h(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(`${g(e)} operation ${n}failed: target is readonly.`,ke(this))}return"delete"!==e&&this}}const[ce,le,he,fe]=function(){const e={get(e){return Y(this,e)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:se,clear:ie,forEach:re(!1,!1)},t={get(e){return Y(this,e,!1,!0)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:se,clear:ie,forEach:re(!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:re(!0,!1)},s={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:re(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{e[i]=oe(i,!1,!1),n[i]=oe(i,!0,!1),t[i]=oe(i,!1,!0),s[i]=oe(i,!0,!0)})),[e,n,t,s]}();function ue(e,t){const n=t?e?fe:he:e?le:ce;return(t,s,i)=>"__v_isReactive"===s?!e:"__v_isReadonly"===s?e:"__v_raw"===s?t:Reflect.get(l(n,s)&&s in t?n:t,s,i)}const de={get:ue(!1,!1)},pe={get:ue(!0,!1)};function we(e,t,n){const s=ke(n);if(s!==n&&t.call(e,s)){const t=v(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 ve=new WeakMap,ye=new WeakMap,ge=new WeakMap,me=new WeakMap;function Ee(e){return Se(e)?e:_e(e,!1,K,de,ve)}function be(e){return _e(e,!0,q,pe,ge)}function _e(e,t,n,s,i){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 r=i.get(e);if(r)return r;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}}(v(a));var a;if(0===o)return e;const c=new Proxy(e,2===o?s:n);return i.set(e,c),c}function Se(e){return!(!e||!e.__v_isReadonly)}function ke(e){const t=e&&e.__v_raw;return t?ke(t):e}const Oe=e=>d(e)?Ee(e):e,Ne=e=>d(e)?be(e):e;function Ae(e){return!(!e||!0!==e.__v_isRef)}const Re=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`,$e=e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but the listener hasn't been registed`,je=e=>`[@rallie/core] one of the callbacks of the broadcast event ${e} throws an uncaught error`,Me=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`,xe=e=>`[@rallie/core] you are trying to register a unicast event ${e}, but it has been registered before`,We=e=>`[@rallie/core] you have emitted ${e} unicast, but there is no listener of this event`,Pe=e=>`[@rallie/core] ${e} is existing, you are not allowed to create it again`,Be=(e,t)=>`[@rallie/core] can not find any assets of the app ${e} on the bus ${t}`,Te=e=>`[@rallie/core] you are trying to activate app ${e}, but it was not created`,Le=e=>`[@rallie/core] state ${e} is private, you are not allowed to set it`,ze=e=>`[@rallie/core] please describe your action when you modify the state ${e}`,Ve=e=>`[@rallie/core] it's not allowed to set or watch state ${e} before it is initialized`,Ue=e=>`[@rallie/core] duplicated initialized state ${e}`,De=e=>`[@rallie/core] it's not allowed to initialized state ${e} to a primitive value`,Ie=e=>`[@rallie/core] the bus named ${e} has been defined before, please rename your bus`,Ce=(e,t)=>`[@rallie/core] There is a circular dependency when activating the app ${e}, and the circular path is ${t.join("->")}`,Ge=()=>"[@rallie/core] next() called multiple times in the middleware",Fe=()=>"[@rallie/core] the middleware must be a function",He=(e,t)=>`[@rallie/core] the event ${e} is not in the events pool that you specified when calling on${t?"Unicast":"Broadcast"}`,Je=e=>(t,n)=>{let s=-1;const i=r=>{if(r<=s)return Promise.reject(new Error(Ge()));s=r;let o=e[r];if(r===e.length&&(o=n),!o)return Promise.resolve();try{return Promise.resolve(o(t,i.bind(null,r+1)))}catch(e){return Promise.reject(e)}};return i(0)};var Ke,qe,Qe,Xe,Ye,Ze,et,tt,nt;class st{constructor(){Ke.set(this,{}),qe.set(this,{})}addBroadcastEventListener(e,t){r(this,Ke,"f")[e]=r(this,Ke,"f")[e]||new Set,r(this,Ke,"f")[e].add(t)}addUnicastEventListener(e,t){if(r(this,qe,"f")[e])throw new Error(xe(e));r(this,qe,"f")[e]=t}removeBroadcastEventListener(e,t){const n=r(this,Ke,"f")[e];if(!n){const t=Re(e);throw new Error(t)}if(!n.has(t)){const t=$e(e);throw new Error(t)}n.delete(t)}removeUnicastEventListener(e){if(!r(this,qe,"f")[e]){const t=Me(e);throw new Error(t)}delete r(this,qe,"f")[e]}emitBroadcast(e,...t){r(this,Ke,"f")[e]=r(this,Ke,"f")[e]||new Set,r(this,Ke,"f")[e].forEach((n=>{try{n(...t)}catch(n){console.error(je(e)),console.error(n)}}))}emitUnicast(e,...t){const n=r(this,qe,"f")[e];if(n)return n(...t);throw new Error(We(e))}}Ke=new WeakMap,qe=new WeakMap;class it{constructor(e,t){Qe.set(this,void 0),Xe.set(this,void 0),o(this,Qe,e,"f"),o(this,Xe,t,"f"),r(this,Xe,"f")[e].watchers.add(this)}do(e){return this.handler=e,()=>this.unwatch()}unwatch(){null==this||this.stopEffect(),this.handler=null;const e=r(this,Xe,"f")[r(this,Qe,"f")].watchers;e.has(this)&&e.delete(this)}}Qe=new WeakMap,Xe=new WeakMap;class rt{constructor(e,t){Ye.add(this),Ze.set(this,void 0),et.set(this,void 0),o(this,Ze,e,"f"),o(this,et,t,"f")}onBroadcast(e){return Object.entries(e).forEach((([e,t])=>{r(this,Ze,"f").addBroadcastEventListener(e,t)})),t=>{r(this,Ye,"m",tt).call(this,e,!1,t)}}onUnicast(e){return Object.entries(e).forEach((([e,t])=>{try{r(this,Ze,"f").addUnicastEventListener(e,t)}catch(e){console.error(e)}})),t=>{r(this,Ye,"m",tt).call(this,e,!0,t)}}createBroadcaster(e){return new Proxy({},{get:(t,n)=>(...t)=>r(this,Ze,"f").emitBroadcast(n,...t,null==e?void 0:e(n)),set:()=>!1})}createUnicaster(e){return new Proxy({},{get:(t,n)=>(...t)=>r(this,Ze,"f").emitUnicast(n,...t,null==e?void 0:e(n)),set:()=>!1})}existState(e){return!!r(this,et,"f")[e]}initState(e,t,n=!1){if(this.existState(e))throw new Error(Ue(e));if(["string","number","boolean","undefined"].includes(typeof t))throw new Error(De(e));return r(this,et,"f")[e]={state:Ee(t),owner:n?this:null,watchers:new Set},r(this,Ze,"f").emitBroadcast("$state-initialized",e),this.getState(e)}getState(e,t){if(this.existState(e)){const n=be(r(this,et,"f")[e].state);return t?t(n):n}return null}setState(e,t,n){return i(this,void 0,void 0,(function*(){const s=r(this,Ye,"m",nt).call(this,e);if(!t)throw new Error(ze(e));{const e=n(s);yield Promise.resolve(e)}}))}watchState(e,t){if(!this.existState(e)){const t=Ve(e);throw new Error(t)}let n=!1;const s=be(r(this,et,"f")[e].state),i=new it(e,r(this,et,"f")),o=function(e,t){e.effect&&(e=e.effect.fn);const n=new P(e);t&&(a(n,t),t.scope&&S(n,t.scope)),t&&t.lazy||n.run();const s=n.run.bind(n);return s.effect=n,s}((()=>t(s)),{lazy:!0,scheduler:()=>{n||(n=!0,Promise.resolve().then((()=>{var e;const r=ke(t(s));null===(e=i.handler)||void 0===e||e.call(i,r,i.oldWatchingStates),i.oldWatchingStates=ke(r),n=!1})))}});return i.oldWatchingStates=o(),i.stopEffect=()=>o.effect.stop(),i}}Ze=new WeakMap,et=new WeakMap,Ye=new WeakSet,tt=function(e,t,n){let s=t?r(this,Ze,"f").removeUnicastEventListener:r(this,Ze,"f").removeBroadcastEventListener;s=s.bind(r(this,Ze,"f")),n?e[n]?(s(n,e[n]),delete e[n]):console.warn(He(n,t)):Object.entries(e).forEach((([e,t])=>{s(e,t)}))},nt=function(e){if(!this.existState(e)){const t=Ve(e);throw new Error(t)}const t=r(this,et,"f")[e].owner;if(t!==this&&null!==t){const t=Le(e);throw new Error(t)}return r(this,et,"f")[e].state};class ot{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 at,ct,lt,ht,ft,ut,dt,pt,wt,vt,yt,gt,mt,Et,bt={loadScript:e=>i(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 _t{constructor(e){at.add(this),ct.set(this,void 0),lt.set(this,new st),ht.set(this,{}),ft.set(this,{}),ut.set(this,{}),this.conf=be({assets:{}}),dt.set(this,[]),pt.set(this,void 0),o(this,ct,e,"f"),o(this,pt,Je(r(this,dt,"f")),"f")}createSocket(){return new rt(r(this,lt,"f"),r(this,ht,"f"))}existApp(e){return!!r(this,ft,"f")[e]}createApp(e){if(this.existApp(e))throw new Error(Pe(e));const t=new ot(e);return r(this,ft,"f")[e]=t,t}loadApp(e){return i(this,void 0,void 0,(function*(){r(this,ft,"f")[e]||(r(this,ut,"f")[e]||(r(this,ut,"f")[e]=new Promise(((t,n)=>{const s=r(this,at,"m",vt).call(this,e);r(this,pt,"f").call(this,s,r(this,at,"m",yt).bind(this)).then((()=>{e.startsWith("lib:")&&!r(this,ft,"f")[e]&&(r(this,ft,"f")[e]=!0),r(this,ft,"f")[e]||n(new Error(Te(e))),t()})).catch((e=>{n(e)}))}))),yield r(this,ut,"f")[e])}))}activateApp(e){return i(this,void 0,void 0,(function*(){yield r(this,at,"m",gt).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(Fe());return r(this,dt,"f").push(e),o(this,pt,Je(r(this,dt,"f")),"f"),this}}ct=new WeakMap,lt=new WeakMap,ht=new WeakMap,ft=new WeakMap,ut=new WeakMap,dt=new WeakMap,pt=new WeakMap,at=new WeakSet,wt=function(e){return r(this,ft,"f")[e]&&"boolean"!=typeof r(this,ft,"f")[e]},vt=function(e){return{name:e,loadScript:bt.loadScript,loadLink:bt.loadLink}},yt=function(e){return i(this,void 0,void 0,(function*(){const{name:t,loadScript:n=bt.loadScript,loadLink:s=bt.loadLink}=e,{assets:i}=this.conf;if(!i[t])throw new Error(Be(t,r(this,ct,"f")));if(i[t].css&&i[t].css.forEach((e=>{s(e)})),i[t].js)for(const e of i[t].js)yield n(e)}))},gt=function(e,t){return i(this,void 0,void 0,(function*(){if(yield this.loadApp(e),r(this,at,"m",wt).call(this,e)){const n=r(this,ft,"f")[e];if(yield r(this,at,"m",Et).call(this,n),t.includes(e)){const n=t.indexOf(e),s=[...t.slice(n),e];throw new Error(Ce(e,s))}if(t.push(e),!n.activated){const e=()=>i(this,void 0,void 0,(function*(){yield r(this,at,"m",mt).call(this,n,t),n.doActivate&&(yield Promise.resolve(n.doActivate()))}));n.activated=e()}yield n.activated,t.pop()}}))},mt=function(e,t){return i(this,void 0,void 0,(function*(){if(0!==e.dependencies.length)for(const n of e.dependencies)yield r(this,at,"m",gt).call(this,n,t)}))},Et=function(e){return i(this,void 0,void 0,(function*(){yield Promise.all(e.relatedApps.map((e=>this.loadApp(e))))}))};const St={},kt="DEFAULT_BUS",Ot=(e=kt)=>{let t=null,n=!1;const s=((e=kt)=>window.RALLIE_BUS_STORE&&window.RALLIE_BUS_STORE[e])(e);return s?(t=s,n=!1):(t=((e=kt)=>{if(void 0===window.RALLIE_BUS_STORE&&Reflect.defineProperty(window,"RALLIE_BUS_STORE",{value:St,writable:!1}),window.RALLIE_BUS_STORE[e])throw new Error(Ie(e));{const t=new _t(e);return Reflect.defineProperty(window.RALLIE_BUS_STORE,e,{value:t,writable:!1}),t}})(e),n=!0),[t,n]},Nt={privateBus:e=>`${e}.bus`,stateNamespace:e=>`${e}.state`,isGlobalBusAccessible:"isGlobalBusAccessible",exportMethodName:"__RallieInnerExport__"},At=e=>`[rallie] ${e}`,Rt={stateNotInitialized:e=>At(` the block ${e}'s state is not initialized, please check:\n1. whether the block ${e} is loaded.\n2. whether the block ${e} has initialized the state`),duplicatedBlockName:e=>At(`the block ${e} is already registered before, please rename your block`),stateIsReadonly:e=>At(`the state of ${e} is readonly`)};var $t,jt,Mt,xt,Wt,Pt,Bt;class Tt{constructor(e,t,i){$t.set(this,void 0),this.name=e,s(this,$t,i,"f"),this.events=n(this,$t,"f").createBroadcaster((()=>t)),this.methods=n(this,$t,"f").createUnicaster((()=>t)),Reflect.defineProperty(this,"state",{get:()=>n(this,$t,"f").getState(Nt.stateNamespace(this.name)),set:()=>{throw new Error(Rt.stateIsReadonly(this.name))}})}setState(e,t){if(n(this,$t,"f").existState(Nt.stateNamespace(this.name)))return n(this,$t,"f").setState(Nt.stateNamespace(this.name),e,t);throw new Error(Rt.stateNotInitialized(this.name))}watchState(e){if(n(this,$t,"f").existState(Nt.stateNamespace(this.name)))return n(this,$t,"f").watchState(Nt.stateNamespace(this.name),e);throw new Error(Rt.stateNotInitialized(this.name))}listenEvents(e){return n(this,$t,"f").onBroadcast(e)}}$t=new WeakMap;class Lt extends Tt{constructor(e,t,n,i){const[r]=Ot(Nt.privateBus(e)),o=r.createSocket();super(e,e,o),jt.set(this,void 0),Mt.set(this,void 0),xt.set(this,void 0),Wt.set(this,void 0),Pt.set(this,void 0),Bt.set(this,{}),s(this,Wt,o,"f"),s(this,jt,t,"f"),s(this,Mt,n,"f"),s(this,Pt,t.createApp(e),"f"),s(this,xt,i,"f")}initState(e,t){return n(this,Wt,"f").initState(Nt.stateNamespace(this.name),e,t),this}addMethods(e){return n(this,Wt,"f").onUnicast(e)}relyOn(e){return n(this,Pt,"f").relyOn(e),this}relateTo(e){return n(this,Pt,"f").relateTo(e),this}onActivate(e){return n(this,Pt,"f").onActivate(e),this}connect(e){if(!n(this,Bt,"f")[e]){const[t]=Ot(Nt.privateBus(e)),s=t.createSocket();n(this,Bt,"f")[e]=new Tt(e,this.name,s)}return n(this,Bt,"f")[e]}load(e){return n(this,jt,"f").loadApp(e)}activate(e){return n(this,jt,"f").activateApp(e)}run(e){var s;return t(this,void 0,void 0,(function*(){const t=n(this,xt,"f")||(null===(s=n(this,Mt,"f").getState(Nt.isGlobalBusAccessible))||void 0===s?void 0:s.value),i=e=>{n(this,xt,"f")&&n(this,Mt,"f").setState(Nt.isGlobalBusAccessible,e?"unfreeze the enviroment":"freeze the enviroment",(t=>{t.value=e}))},r={isEntry:n(this,xt,"f"),use:e=>{t&&n(this,jt,"f").use(e)},config:e=>{t&&n(this,jt,"f").config(e)},freeze:()=>{i(!1)},unfreeze:()=>{i(!0)}},o=e(new Proxy(r,{get:(e,t,s)=>"conf"===t?JSON.parse(JSON.stringify(n(this,jt,"f").conf)):Reflect.get(e,t,s),set:()=>!1}));yield Promise.resolve(o)}))}}jt=new WeakMap,Mt=new WeakMap,xt=new WeakMap,Wt=new WeakMap,Pt=new WeakMap,Bt=new WeakMap,e.createBlock=function(e){const[t,n]=Ot();if(t.existApp(e))throw new Error(Rt.duplicatedBlockName(e));const s=t.createSocket();return n&&s.initState(Nt.isGlobalBusAccessible,{value:!0},!0),new Lt(e,t,s,n)}})); | ||
!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).RallieBlock={})}(this,(function(e){"use strict";function t(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function n(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function s(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}function i(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function r(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function o(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}"production"===process.env.NODE_ENV||Object.freeze({}),"production"===process.env.NODE_ENV||Object.freeze([]);const a=Object.assign,c=Object.prototype.hasOwnProperty,l=(e,t)=>c.call(e,t),h=Array.isArray,f=e=>"[object Map]"===w(e),u=e=>"symbol"==typeof e,d=e=>null!==e&&"object"==typeof e,p=Object.prototype.toString,w=e=>p.call(e),v=e=>w(e).slice(8,-1),y=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,g=(e=>{const t=Object.create(null);return e=>t[e]||(t[e]=(e=>e.charAt(0).toUpperCase()+e.slice(1))(e))})(),m=(e,t)=>!Object.is(e,t),E=e=>{const t=parseFloat(e);return isNaN(t)?e:t};function b(e,...t){console.warn(`[Vue warn] ${e}`,...t)}let _;function S(e,t=_){t&&t.active&&t.effects.push(e)}const k=e=>{const t=new Set(e);return t.w=0,t.n=0,t},O=e=>(e.w&$)>0,N=e=>(e.n&$)>0,A=new WeakMap;let R=0,$=1;const j=30;let M;const x=Symbol("production"!==process.env.NODE_ENV?"iterate":""),W=Symbol("production"!==process.env.NODE_ENV?"Map key iterate":"");class P{constructor(e,t=null,n){this.fn=e,this.scheduler=t,this.active=!0,this.deps=[],this.parent=void 0,S(this,n)}run(){if(!this.active)return this.fn();let e=M,t=T;for(;e;){if(e===this)return;e=e.parent}try{return this.parent=M,M=this,T=!0,$=1<<++R,R<=j?(({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=$})(this):B(this),this.fn()}finally{R<=j&&(e=>{const{deps:t}=e;if(t.length){let n=0;for(let s=0;s<t.length;s++){const i=t[s];O(i)&&!N(i)?i.delete(e):t[n++]=i,i.w&=~$,i.n&=~$}t.length=n}})(this),$=1<<--R,M=this.parent,T=t,this.parent=void 0,this.deferStop&&this.stop()}}stop(){M===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 T=!0;const L=[];function z(e,t,n){if(T&&M){let s=A.get(e);s||A.set(e,s=new Map);let i=s.get(n);i||s.set(n,i=k()),function(e,t){let n=!1;R<=j?N(e)||(e.n|=$,n=!O(e)):n=!e.has(M),n&&(e.add(M),M.deps.push(e),"production"!==process.env.NODE_ENV&&M.onTrack&&M.onTrack(Object.assign({effect:M},t)))}(i,"production"!==process.env.NODE_ENV?{effect:M,target:e,type:t,key:n}:void 0)}}function V(e,t,n,s,i,r){const o=A.get(e);if(!o)return;let a=[];if("clear"===t)a=[...o.values()];else if("length"===n&&h(e)){const e=E(s);o.forEach(((t,n)=>{("length"===n||n>=e)&&a.push(t)}))}else switch(void 0!==n&&a.push(o.get(n)),t){case"add":h(e)?y(n)&&a.push(o.get("length")):(a.push(o.get(x)),f(e)&&a.push(o.get(W)));break;case"delete":h(e)||(a.push(o.get(x)),f(e)&&a.push(o.get(W)));break;case"set":f(e)&&a.push(o.get(x))}const c="production"!==process.env.NODE_ENV?{target:e,type:t,key:n,newValue:s,oldValue:i,oldTarget:r}:void 0;if(1===a.length)a[0]&&("production"!==process.env.NODE_ENV?U(a[0],c):U(a[0]));else{const e=[];for(const t of a)t&&e.push(...t);"production"!==process.env.NODE_ENV?U(k(e),c):U(k(e))}}function U(e,t){const n=h(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!==M||e.allowRecurse)&&("production"!==process.env.NODE_ENV&&e.onTrigger&&e.onTrigger(a({effect:e},t)),e.scheduler?e.scheduler():e.run())}const I=function(e,t){const n=Object.create(null),s=e.split(",");for(let e=0;e<s.length;e++)n[s[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}("__proto__,__v_isRef,__isVue"),C=new Set(Object.getOwnPropertyNames(Symbol).filter((e=>"arguments"!==e&&"caller"!==e)).map((e=>Symbol[e])).filter(u)),G=J(),F=J(!0),H=function(){const e={};return["includes","indexOf","lastIndexOf"].forEach((t=>{e[t]=function(...e){const n=ke(this);for(let e=0,t=this.length;e<t;e++)z(n,"get",e+"");const s=n[t](...e);return-1===s||!1===s?n[t](...e.map(ke)):s}})),["push","pop","shift","unshift","splice"].forEach((t=>{e[t]=function(...e){L.push(T),T=!1;const n=ke(this)[t].apply(this,e);return function(){const e=L.pop();T=void 0===e||e}(),n}})),e}();function J(e=!1,t=!1){return function(n,s,i){if("__v_isReactive"===s)return!e;if("__v_isReadonly"===s)return e;if("__v_isShallow"===s)return t;if("__v_raw"===s&&i===(e?t?me:ge:t?ye:ve).get(n))return n;const r=h(n);if(!e&&r&&l(H,s))return Reflect.get(H,s,i);const o=Reflect.get(n,s,i);return(u(s)?C.has(s):I(s))?o:(e||z(n,"get",s),t?o:Ae(o)?r&&y(s)?o:o.value:d(o)?e?be(o):Ee(o):o)}}const K={get:G,set:function(e=!1){return function(t,n,s,i){let r=t[n];if(Se(r)&&Ae(r)&&!Ae(s))return!1;if(!e&&(function(e){return!(!e||!e.__v_isShallow)}(s)||Se(s)||(r=ke(r),s=ke(s)),!h(t)&&Ae(r)&&!Ae(s)))return r.value=s,!0;const o=h(t)&&y(n)?Number(n)<t.length:l(t,n),a=Reflect.set(t,n,s,i);return t===ke(i)&&(o?m(s,r)&&V(t,"set",n,s,r):V(t,"add",n,s)),a}}(),deleteProperty:function(e,t){const n=l(e,t),s=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&V(e,"delete",t,void 0,s),i},has:function(e,t){const n=Reflect.has(e,t);return u(t)&&C.has(t)||z(e,"has",t),n},ownKeys:function(e){return z(e,"iterate",h(e)?"length":x),Reflect.ownKeys(e)}},q={get:F,set:(e,t)=>("production"!==process.env.NODE_ENV&&b(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0),deleteProperty:(e,t)=>("production"!==process.env.NODE_ENV&&b(`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,s=!1){const i=ke(e=e.__v_raw),r=ke(t);n||(t!==r&&z(i,"get",t),z(i,"get",r));const{has:o}=X(i),a=s?Q:n?Ne:Oe;return o.call(i,t)?a(e.get(t)):o.call(i,r)?a(e.get(r)):void(e!==i&&e.get(t))}function Z(e,t=!1){const n=this.__v_raw,s=ke(n),i=ke(e);return t||(e!==i&&z(s,"has",e),z(s,"has",i)),e===i?n.has(e):n.has(e)||n.has(i)}function ee(e,t=!1){return e=e.__v_raw,!t&&z(ke(e),"iterate",x),Reflect.get(e,"size",e)}function te(e){e=ke(e);const t=ke(this);return X(t).has.call(t,e)||(t.add(e),V(t,"add",e,e)),this}function ne(e,t){t=ke(t);const n=ke(this),{has:s,get:i}=X(n);let r=s.call(n,e);r?"production"!==process.env.NODE_ENV&&we(n,s,e):(e=ke(e),r=s.call(n,e));const o=i.call(n,e);return n.set(e,t),r?m(t,o)&&V(n,"set",e,t,o):V(n,"add",e,t),this}function se(e){const t=ke(this),{has:n,get:s}=X(t);let i=n.call(t,e);i?"production"!==process.env.NODE_ENV&&we(t,n,e):(e=ke(e),i=n.call(t,e));const r=s?s.call(t,e):void 0,o=t.delete(e);return i&&V(t,"delete",e,void 0,r),o}function ie(){const e=ke(this),t=0!==e.size,n="production"!==process.env.NODE_ENV?f(e)?new Map(e):new Set(e):void 0,s=e.clear();return t&&V(e,"clear",void 0,void 0,n),s}function re(e,t){return function(n,s){const i=this,r=i.__v_raw,o=ke(r),a=t?Q:e?Ne:Oe;return!e&&z(o,"iterate",x),r.forEach(((e,t)=>n.call(s,a(e),a(t),i)))}}function oe(e,t,n){return function(...s){const i=this.__v_raw,r=ke(i),o=f(r),a="entries"===e||e===Symbol.iterator&&o,c="keys"===e&&o,l=i[e](...s),h=n?Q:t?Ne:Oe;return!t&&z(r,"iterate",c?W:x),{next(){const{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:a?[h(e[0]),h(e[1])]:h(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(`${g(e)} operation ${n}failed: target is readonly.`,ke(this))}return"delete"!==e&&this}}const[ce,le,he,fe]=function(){const e={get(e){return Y(this,e)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:se,clear:ie,forEach:re(!1,!1)},t={get(e){return Y(this,e,!1,!0)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:se,clear:ie,forEach:re(!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:re(!0,!1)},s={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:re(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{e[i]=oe(i,!1,!1),n[i]=oe(i,!0,!1),t[i]=oe(i,!1,!0),s[i]=oe(i,!0,!0)})),[e,n,t,s]}();function ue(e,t){const n=t?e?fe:he:e?le:ce;return(t,s,i)=>"__v_isReactive"===s?!e:"__v_isReadonly"===s?e:"__v_raw"===s?t:Reflect.get(l(n,s)&&s in t?n:t,s,i)}const de={get:ue(!1,!1)},pe={get:ue(!0,!1)};function we(e,t,n){const s=ke(n);if(s!==n&&t.call(e,s)){const t=v(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 ve=new WeakMap,ye=new WeakMap,ge=new WeakMap,me=new WeakMap;function Ee(e){return Se(e)?e:_e(e,!1,K,de,ve)}function be(e){return _e(e,!0,q,pe,ge)}function _e(e,t,n,s,i){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 r=i.get(e);if(r)return r;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}}(v(a));var a;if(0===o)return e;const c=new Proxy(e,2===o?s:n);return i.set(e,c),c}function Se(e){return!(!e||!e.__v_isReadonly)}function ke(e){const t=e&&e.__v_raw;return t?ke(t):e}const Oe=e=>d(e)?Ee(e):e,Ne=e=>d(e)?be(e):e;function Ae(e){return!(!e||!0!==e.__v_isRef)}const Re=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`,$e=e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but the listener hasn't been registed`,je=e=>`[@rallie/core] one of the callbacks of the broadcast event ${e} throws an uncaught error`,Me=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`,xe=e=>`[@rallie/core] you are trying to register a unicast event ${e}, but it has been registered before`,We=e=>`[@rallie/core] you have emitted ${e} unicast, but there is no listener of this event`,Pe=e=>`[@rallie/core] ${e} is existing, you are not allowed to create it again`,Be=(e,t)=>`[@rallie/core] can not find any assets of the app ${e} on the bus ${t}`,Te=e=>`[@rallie/core] you are trying to activate app ${e}, but it was not created`,Le=e=>`[@rallie/core] state ${e} is private, you are not allowed to set it`,ze=e=>`[@rallie/core] please describe your action when you modify the state ${e}`,Ve=e=>`[@rallie/core] it's not allowed to set or watch state ${e} before it is initialized`,Ue=e=>`[@rallie/core] duplicated initialized state ${e}`,De=e=>`[@rallie/core] it's not allowed to initialized state ${e} to a primitive value`,Ie=e=>`[@rallie/core] the bus named ${e} has been defined before, please rename your bus`,Ce=(e,t)=>`[@rallie/core] There is a circular dependency when activating the app ${e}, and the circular path is ${t.join("->")}`,Ge=()=>"[@rallie/core] next() called multiple times in the middleware",Fe=()=>"[@rallie/core] the middleware must be a function",He=(e,t)=>`[@rallie/core] the event ${e} is not in the events pool that you specified when calling on${t?"Unicast":"Broadcast"}`,Je=e=>(t,n)=>{let s=-1;const i=r=>{if(r<=s)return Promise.reject(new Error(Ge()));s=r;let o=e[r];if(r===e.length&&(o=n),!o)return Promise.resolve();try{return Promise.resolve(o(t,i.bind(null,r+1)))}catch(e){return Promise.reject(e)}};return i(0)};var Ke,qe,Qe,Xe,Ye,Ze,et,tt,nt;class st{constructor(){Ke.set(this,{}),qe.set(this,{})}addBroadcastEventListener(e,t){r(this,Ke,"f")[e]=r(this,Ke,"f")[e]||new Set,r(this,Ke,"f")[e].add(t)}addUnicastEventListener(e,t){if(r(this,qe,"f")[e])throw new Error(xe(e));r(this,qe,"f")[e]=t}removeBroadcastEventListener(e,t){const n=r(this,Ke,"f")[e];if(!n){const t=Re(e);throw new Error(t)}if(!n.has(t)){const t=$e(e);throw new Error(t)}n.delete(t)}removeUnicastEventListener(e){if(!r(this,qe,"f")[e]){const t=Me(e);throw new Error(t)}delete r(this,qe,"f")[e]}emitBroadcast(e,...t){r(this,Ke,"f")[e]=r(this,Ke,"f")[e]||new Set,r(this,Ke,"f")[e].forEach((n=>{try{n(...t)}catch(n){console.error(je(e)),console.error(n)}}))}emitUnicast(e,...t){const n=r(this,qe,"f")[e];if(n)return n(...t);throw new Error(We(e))}}Ke=new WeakMap,qe=new WeakMap;class it{constructor(e,t){Qe.set(this,void 0),Xe.set(this,void 0),o(this,Qe,e,"f"),o(this,Xe,t,"f"),r(this,Xe,"f")[e].watchers.add(this)}do(e){return this.handler=e,()=>this.unwatch()}unwatch(){null==this||this.stopEffect(),this.handler=null;const e=r(this,Xe,"f")[r(this,Qe,"f")].watchers;e.has(this)&&e.delete(this)}}Qe=new WeakMap,Xe=new WeakMap;class rt{constructor(e,t){Ye.add(this),Ze.set(this,void 0),et.set(this,void 0),o(this,Ze,e,"f"),o(this,et,t,"f")}onBroadcast(e){return Object.entries(e).forEach((([e,t])=>{r(this,Ze,"f").addBroadcastEventListener(e,t)})),t=>{r(this,Ye,"m",tt).call(this,e,!1,t)}}onUnicast(e){return Object.entries(e).forEach((([e,t])=>{try{r(this,Ze,"f").addUnicastEventListener(e,t)}catch(e){console.error(e)}})),t=>{r(this,Ye,"m",tt).call(this,e,!0,t)}}createBroadcaster(e){return new Proxy({},{get:(t,n)=>(...t)=>(null==e||e(n),r(this,Ze,"f").emitBroadcast(n,...t)),set:()=>!1})}createUnicaster(e){return new Proxy({},{get:(t,n)=>(...t)=>(null==e||e(n),r(this,Ze,"f").emitUnicast(n,...t)),set:()=>!1})}existState(e){return!!r(this,et,"f")[e]}initState(e,t,n=!1){if(this.existState(e))throw new Error(Ue(e));if(["string","number","boolean","undefined"].includes(typeof t))throw new Error(De(e));return r(this,et,"f")[e]={state:Ee(t),owner:n?this:null,watchers:new Set},r(this,Ze,"f").emitBroadcast("$state-initialized",e),this.getState(e)}getState(e,t){if(this.existState(e)){const n=be(r(this,et,"f")[e].state);return t?t(n):n}return null}setState(e,t,n){return i(this,void 0,void 0,(function*(){const s=r(this,Ye,"m",nt).call(this,e);if(!t)throw new Error(ze(e));{const e=n(s);yield Promise.resolve(e)}}))}watchState(e,t){if(!this.existState(e)){const t=Ve(e);throw new Error(t)}let n=!1;const s=be(r(this,et,"f")[e].state),i=new it(e,r(this,et,"f")),o=function(e,t){e.effect&&(e=e.effect.fn);const n=new P(e);t&&(a(n,t),t.scope&&S(n,t.scope)),t&&t.lazy||n.run();const s=n.run.bind(n);return s.effect=n,s}((()=>t(s)),{lazy:!0,scheduler:()=>{n||(n=!0,Promise.resolve().then((()=>{var e;const r=ke(t(s));null===(e=i.handler)||void 0===e||e.call(i,r,i.oldWatchingStates),i.oldWatchingStates=ke(r),n=!1})))}});return i.oldWatchingStates=o(),i.stopEffect=()=>o.effect.stop(),i}}Ze=new WeakMap,et=new WeakMap,Ye=new WeakSet,tt=function(e,t,n){let s=t?r(this,Ze,"f").removeUnicastEventListener:r(this,Ze,"f").removeBroadcastEventListener;s=s.bind(r(this,Ze,"f")),n?e[n]?(s(n,e[n]),delete e[n]):console.warn(He(n,t)):Object.entries(e).forEach((([e,t])=>{s(e,t)}))},nt=function(e){if(!this.existState(e)){const t=Ve(e);throw new Error(t)}const t=r(this,et,"f")[e].owner;if(t!==this&&null!==t){const t=Le(e);throw new Error(t)}return r(this,et,"f")[e].state};class ot{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 at,ct,lt,ht,ft,ut,dt,pt,wt,vt,yt,gt,mt,Et,bt={loadScript:e=>i(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 _t{constructor(e){at.add(this),ct.set(this,void 0),lt.set(this,new st),ht.set(this,{}),ft.set(this,{}),ut.set(this,{}),this.conf=be({assets:{}}),dt.set(this,[]),pt.set(this,void 0),o(this,ct,e,"f"),o(this,pt,Je(r(this,dt,"f")),"f")}createSocket(){return new rt(r(this,lt,"f"),r(this,ht,"f"))}existApp(e){return!!r(this,ft,"f")[e]}createApp(e){if(this.existApp(e))throw new Error(Pe(e));const t=new ot(e);return r(this,ft,"f")[e]=t,t}loadApp(e){return i(this,void 0,void 0,(function*(){r(this,ft,"f")[e]||(r(this,ut,"f")[e]||(r(this,ut,"f")[e]=new Promise(((t,n)=>{const s=r(this,at,"m",vt).call(this,e);r(this,pt,"f").call(this,s,r(this,at,"m",yt).bind(this)).then((()=>{e.startsWith("lib:")&&!r(this,ft,"f")[e]&&(r(this,ft,"f")[e]=!0),r(this,ft,"f")[e]||n(new Error(Te(e))),t()})).catch((e=>{n(e)}))}))),yield r(this,ut,"f")[e])}))}activateApp(e){return i(this,void 0,void 0,(function*(){yield r(this,at,"m",gt).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(Fe());return r(this,dt,"f").push(e),o(this,pt,Je(r(this,dt,"f")),"f"),this}}ct=new WeakMap,lt=new WeakMap,ht=new WeakMap,ft=new WeakMap,ut=new WeakMap,dt=new WeakMap,pt=new WeakMap,at=new WeakSet,wt=function(e){return r(this,ft,"f")[e]&&"boolean"!=typeof r(this,ft,"f")[e]},vt=function(e){return{name:e,loadScript:bt.loadScript,loadLink:bt.loadLink}},yt=function(e){return i(this,void 0,void 0,(function*(){const{name:t,loadScript:n=bt.loadScript,loadLink:s=bt.loadLink}=e,{assets:i}=this.conf;if(!i[t])throw new Error(Be(t,r(this,ct,"f")));if(i[t].css&&i[t].css.forEach((e=>{s(e)})),i[t].js)for(const e of i[t].js)yield n(e)}))},gt=function(e,t){return i(this,void 0,void 0,(function*(){if(yield this.loadApp(e),r(this,at,"m",wt).call(this,e)){const n=r(this,ft,"f")[e];if(yield r(this,at,"m",Et).call(this,n),t.includes(e)){const n=t.indexOf(e),s=[...t.slice(n),e];throw new Error(Ce(e,s))}if(t.push(e),!n.activated){const e=()=>i(this,void 0,void 0,(function*(){yield r(this,at,"m",mt).call(this,n,t),n.doActivate&&(yield Promise.resolve(n.doActivate()))}));n.activated=e()}yield n.activated,t.pop()}}))},mt=function(e,t){return i(this,void 0,void 0,(function*(){if(0!==e.dependencies.length)for(const n of e.dependencies)yield r(this,at,"m",gt).call(this,n,t)}))},Et=function(e){return i(this,void 0,void 0,(function*(){yield Promise.all(e.relatedApps.map((e=>this.loadApp(e))))}))};const St={},kt="DEFAULT_BUS",Ot=(e=kt)=>{let t=null,n=!1;const s=((e=kt)=>window.RALLIE_BUS_STORE&&window.RALLIE_BUS_STORE[e])(e);return s?(t=s,n=!1):(t=((e=kt)=>{if(void 0===window.RALLIE_BUS_STORE&&Reflect.defineProperty(window,"RALLIE_BUS_STORE",{value:St,writable:!1}),window.RALLIE_BUS_STORE[e])throw new Error(Ie(e));{const t=new _t(e);return Reflect.defineProperty(window.RALLIE_BUS_STORE,e,{value:t,writable:!1}),t}})(e),n=!0),[t,n]},Nt={privateBus:e=>`${e}.bus`,stateNamespace:e=>`${e}.state`,isGlobalBusAccessible:"isGlobalBusAccessible",exportMethodName:"__RallieInnerExport__"},At=e=>`[rallie] ${e}`,Rt={stateNotInitialized:e=>At(` the block ${e}'s state is not initialized, please check:\n1. whether the block ${e} is loaded.\n2. whether the block ${e} has initialized the state`),duplicatedBlockName:e=>At(`the block ${e} is already registered before, please rename your block`),stateIsReadonly:e=>At(`the state of ${e} is readonly`)};var $t,jt,Mt,xt,Wt,Pt,Bt;class Tt{constructor(e,t){$t.set(this,void 0),this.name=e,s(this,$t,t,"f"),this.events=n(this,$t,"f").createBroadcaster(),this.methods=n(this,$t,"f").createUnicaster(),Reflect.defineProperty(this,"state",{get:()=>n(this,$t,"f").getState(Nt.stateNamespace(this.name)),set:()=>{throw new Error(Rt.stateIsReadonly(this.name))}})}setState(e,t){if(n(this,$t,"f").existState(Nt.stateNamespace(this.name)))return n(this,$t,"f").setState(Nt.stateNamespace(this.name),e,t);throw new Error(Rt.stateNotInitialized(this.name))}watchState(e){if(n(this,$t,"f").existState(Nt.stateNamespace(this.name)))return n(this,$t,"f").watchState(Nt.stateNamespace(this.name),e);throw new Error(Rt.stateNotInitialized(this.name))}listenEvents(e){return n(this,$t,"f").onBroadcast(e)}}$t=new WeakMap;class Lt extends Tt{constructor(e,t,n,i){const[r]=Ot(Nt.privateBus(e)),o=r.createSocket();super(e,o),jt.set(this,void 0),Mt.set(this,void 0),xt.set(this,void 0),Wt.set(this,void 0),Pt.set(this,void 0),Bt.set(this,{}),s(this,Wt,o,"f"),s(this,jt,t,"f"),s(this,Mt,n,"f"),s(this,Pt,t.createApp(e),"f"),s(this,xt,i,"f")}initState(e,t){return n(this,Wt,"f").initState(Nt.stateNamespace(this.name),e,t),this}addMethods(e){return n(this,Wt,"f").onUnicast(e)}relyOn(e){return n(this,Pt,"f").relyOn(e),this}relateTo(e){return n(this,Pt,"f").relateTo(e),this}onActivate(e){return n(this,Pt,"f").onActivate(e),this}connect(e){if(!n(this,Bt,"f")[e]){const[t]=Ot(Nt.privateBus(e)),s=t.createSocket();n(this,Bt,"f")[e]=new Tt(e,s)}return n(this,Bt,"f")[e]}load(e){return n(this,jt,"f").loadApp(e)}activate(e){return n(this,jt,"f").activateApp(e)}run(e){var s;return t(this,void 0,void 0,(function*(){const t=n(this,xt,"f")||(null===(s=n(this,Mt,"f").getState(Nt.isGlobalBusAccessible))||void 0===s?void 0:s.value),i=e=>{n(this,xt,"f")&&n(this,Mt,"f").setState(Nt.isGlobalBusAccessible,e?"unfreeze the enviroment":"freeze the enviroment",(t=>{t.value=e}))},r={isEntry:n(this,xt,"f"),use:e=>{t&&n(this,jt,"f").use(e)},config:e=>{t&&n(this,jt,"f").config(e)},freeze:()=>{i(!1)},unfreeze:()=>{i(!0)}},o=e(new Proxy(r,{get:(e,t,s)=>"conf"===t?JSON.parse(JSON.stringify(n(this,jt,"f").conf)):Reflect.get(e,t,s),set:()=>!1}));yield Promise.resolve(o)}))}}jt=new WeakMap,Mt=new WeakMap,xt=new WeakMap,Wt=new WeakMap,Pt=new WeakMap,Bt=new WeakMap,e.createBlock=function(e){const[t,n]=Ot();if(t.existApp(e))throw new Error(Rt.duplicatedBlockName(e));const s=t.createSocket();return n&&s.initState(Nt.isGlobalBusAccessible,{value:!0},!0),new Lt(e,t,s,n)}})); |
@@ -13,3 +13,3 @@ import type { Socket } from '@rallie/core'; | ||
methods: T['methods']; | ||
constructor(name: string, triggerName: string, socket: Socket); | ||
constructor(name: string, socket: Socket); | ||
setState(action: string, setter: (state: T['state']) => void | Promise<void>): Promise<void>; | ||
@@ -16,0 +16,0 @@ watchState<P = any>(getter: (state: T['state']) => undefined | P): import("@rallie/core/dist/lib/watcher").Watcher<P>; |
@@ -1,1 +0,1 @@ | ||
function e(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function t(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function n(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}function s(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function i(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function r(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}"production"===process.env.NODE_ENV||Object.freeze({}),"production"===process.env.NODE_ENV||Object.freeze([]);const o=Object.assign,a=Object.prototype.hasOwnProperty,c=(e,t)=>a.call(e,t),l=Array.isArray,h=e=>"[object Map]"===p(e),f=e=>"symbol"==typeof e,u=e=>null!==e&&"object"==typeof e,d=Object.prototype.toString,p=e=>d.call(e),w=e=>p(e).slice(8,-1),v=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,y=(e=>{const t=Object.create(null);return e=>t[e]||(t[e]=(e=>e.charAt(0).toUpperCase()+e.slice(1))(e))})(),g=(e,t)=>!Object.is(e,t),m=e=>{const t=parseFloat(e);return isNaN(t)?e:t};function E(e,...t){console.warn(`[Vue warn] ${e}`,...t)}let b;function _(e,t=b){t&&t.active&&t.effects.push(e)}const S=e=>{const t=new Set(e);return t.w=0,t.n=0,t},k=e=>(e.w&$)>0,O=e=>(e.n&$)>0,N=new WeakMap;let A=0,$=1;const R=30;let j;const M=Symbol("production"!==process.env.NODE_ENV?"iterate":""),W=Symbol("production"!==process.env.NODE_ENV?"Map key iterate":"");class x{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=j,t=L;for(;e;){if(e===this)return;e=e.parent}try{return this.parent=j,j=this,L=!0,$=1<<++A,A<=R?(({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=$})(this):P(this),this.fn()}finally{A<=R&&(e=>{const{deps:t}=e;if(t.length){let n=0;for(let s=0;s<t.length;s++){const i=t[s];k(i)&&!O(i)?i.delete(e):t[n++]=i,i.w&=~$,i.n&=~$}t.length=n}})(this),$=1<<--A,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 B=[];function T(e,t,n){if(L&&j){let s=N.get(e);s||N.set(e,s=new Map);let i=s.get(n);i||s.set(n,i=S()),function(e,t){let n=!1;A<=R?O(e)||(e.n|=$,n=!k(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)))}(i,"production"!==process.env.NODE_ENV?{effect:j,target:e,type:t,key:n}:void 0)}}function z(e,t,n,s,i,r){const o=N.get(e);if(!o)return;let a=[];if("clear"===t)a=[...o.values()];else if("length"===n&&l(e)){const e=m(s);o.forEach(((t,n)=>{("length"===n||n>=e)&&a.push(t)}))}else switch(void 0!==n&&a.push(o.get(n)),t){case"add":l(e)?v(n)&&a.push(o.get("length")):(a.push(o.get(M)),h(e)&&a.push(o.get(W)));break;case"delete":l(e)||(a.push(o.get(M)),h(e)&&a.push(o.get(W)));break;case"set":h(e)&&a.push(o.get(M))}const c="production"!==process.env.NODE_ENV?{target:e,type:t,key:n,newValue:s,oldValue:i,oldTarget:r}:void 0;if(1===a.length)a[0]&&("production"!==process.env.NODE_ENV?V(a[0],c):V(a[0]));else{const e=[];for(const t of a)t&&e.push(...t);"production"!==process.env.NODE_ENV?V(S(e),c):V(S(e))}}function V(e,t){const n=l(e)?e:[...e];for(const e of n)e.computed&&U(e,t);for(const e of n)e.computed||U(e,t)}function U(e,t){(e!==j||e.allowRecurse)&&("production"!==process.env.NODE_ENV&&e.onTrigger&&e.onTrigger(o({effect:e},t)),e.scheduler?e.scheduler():e.run())}const D=function(e,t){const n=Object.create(null),s=e.split(",");for(let e=0;e<s.length;e++)n[s[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}("__proto__,__v_isRef,__isVue"),I=new Set(Object.getOwnPropertyNames(Symbol).filter((e=>"arguments"!==e&&"caller"!==e)).map((e=>Symbol[e])).filter(f)),C=H(),G=H(!0),F=function(){const e={};return["includes","indexOf","lastIndexOf"].forEach((t=>{e[t]=function(...e){const n=Se(this);for(let e=0,t=this.length;e<t;e++)T(n,"get",e+"");const s=n[t](...e);return-1===s||!1===s?n[t](...e.map(Se)):s}})),["push","pop","shift","unshift","splice"].forEach((t=>{e[t]=function(...e){B.push(L),L=!1;const n=Se(this)[t].apply(this,e);return function(){const e=B.pop();L=void 0===e||e}(),n}})),e}();function H(e=!1,t=!1){return function(n,s,i){if("__v_isReactive"===s)return!e;if("__v_isReadonly"===s)return e;if("__v_isShallow"===s)return t;if("__v_raw"===s&&i===(e?t?ge:ye:t?ve:we).get(n))return n;const r=l(n);if(!e&&r&&c(F,s))return Reflect.get(F,s,i);const o=Reflect.get(n,s,i);return(f(s)?I.has(s):D(s))?o:(e||T(n,"get",s),t?o:Ne(o)?r&&v(s)?o:o.value:u(o)?e?Ee(o):me(o):o)}}const J={get:C,set:function(e=!1){return function(t,n,s,i){let r=t[n];if(_e(r)&&Ne(r)&&!Ne(s))return!1;if(!e&&(function(e){return!(!e||!e.__v_isShallow)}(s)||_e(s)||(r=Se(r),s=Se(s)),!l(t)&&Ne(r)&&!Ne(s)))return r.value=s,!0;const o=l(t)&&v(n)?Number(n)<t.length:c(t,n),a=Reflect.set(t,n,s,i);return t===Se(i)&&(o?g(s,r)&&z(t,"set",n,s,r):z(t,"add",n,s)),a}}(),deleteProperty:function(e,t){const n=c(e,t),s=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&z(e,"delete",t,void 0,s),i},has:function(e,t){const n=Reflect.has(e,t);return f(t)&&I.has(t)||T(e,"has",t),n},ownKeys:function(e){return T(e,"iterate",l(e)?"length":M),Reflect.ownKeys(e)}},K={get:G,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,Q=e=>Reflect.getPrototypeOf(e);function X(e,t,n=!1,s=!1){const i=Se(e=e.__v_raw),r=Se(t);n||(t!==r&&T(i,"get",t),T(i,"get",r));const{has:o}=Q(i),a=s?q:n?Oe:ke;return o.call(i,t)?a(e.get(t)):o.call(i,r)?a(e.get(r)):void(e!==i&&e.get(t))}function Y(e,t=!1){const n=this.__v_raw,s=Se(n),i=Se(e);return t||(e!==i&&T(s,"has",e),T(s,"has",i)),e===i?n.has(e):n.has(e)||n.has(i)}function Z(e,t=!1){return e=e.__v_raw,!t&&T(Se(e),"iterate",M),Reflect.get(e,"size",e)}function ee(e){e=Se(e);const t=Se(this);return Q(t).has.call(t,e)||(t.add(e),z(t,"add",e,e)),this}function te(e,t){t=Se(t);const n=Se(this),{has:s,get:i}=Q(n);let r=s.call(n,e);r?"production"!==process.env.NODE_ENV&&pe(n,s,e):(e=Se(e),r=s.call(n,e));const o=i.call(n,e);return n.set(e,t),r?g(t,o)&&z(n,"set",e,t,o):z(n,"add",e,t),this}function ne(e){const t=Se(this),{has:n,get:s}=Q(t);let i=n.call(t,e);i?"production"!==process.env.NODE_ENV&&pe(t,n,e):(e=Se(e),i=n.call(t,e));const r=s?s.call(t,e):void 0,o=t.delete(e);return i&&z(t,"delete",e,void 0,r),o}function se(){const e=Se(this),t=0!==e.size,n="production"!==process.env.NODE_ENV?h(e)?new Map(e):new Set(e):void 0,s=e.clear();return t&&z(e,"clear",void 0,void 0,n),s}function ie(e,t){return function(n,s){const i=this,r=i.__v_raw,o=Se(r),a=t?q:e?Oe:ke;return!e&&T(o,"iterate",M),r.forEach(((e,t)=>n.call(s,a(e),a(t),i)))}}function re(e,t,n){return function(...s){const i=this.__v_raw,r=Se(i),o=h(r),a="entries"===e||e===Symbol.iterator&&o,c="keys"===e&&o,l=i[e](...s),f=n?q:t?Oe:ke;return!t&&T(r,"iterate",c?W:M),{next(){const{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:a?[f(e[0]),f(e[1])]:f(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(`${y(e)} operation ${n}failed: target is readonly.`,Se(this))}return"delete"!==e&&this}}const[ae,ce,le,he]=function(){const e={get(e){return X(this,e)},get size(){return Z(this)},has:Y,add:ee,set:te,delete:ne,clear:se,forEach:ie(!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:se,forEach:ie(!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:ie(!0,!1)},s={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:ie(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{e[i]=re(i,!1,!1),n[i]=re(i,!0,!1),t[i]=re(i,!1,!0),s[i]=re(i,!0,!0)})),[e,n,t,s]}();function fe(e,t){const n=t?e?he:le:e?ce:ae;return(t,s,i)=>"__v_isReactive"===s?!e:"__v_isReadonly"===s?e:"__v_raw"===s?t:Reflect.get(c(n,s)&&s in t?n:t,s,i)}const ue={get:fe(!1,!1)},de={get:fe(!0,!1)};function pe(e,t,n){const s=Se(n);if(s!==n&&t.call(e,s)){const t=w(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,ve=new WeakMap,ye=new WeakMap,ge=new WeakMap;function me(e){return _e(e)?e:be(e,!1,J,ue,we)}function Ee(e){return be(e,!0,K,de,ye)}function be(e,t,n,s,i){if(!u(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 r=i.get(e);if(r)return r;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}}(w(a));var a;if(0===o)return e;const c=new Proxy(e,2===o?s:n);return i.set(e,c),c}function _e(e){return!(!e||!e.__v_isReadonly)}function Se(e){const t=e&&e.__v_raw;return t?Se(t):e}const ke=e=>u(e)?me(e):e,Oe=e=>u(e)?Ee(e):e;function Ne(e){return!(!e||!0!==e.__v_isRef)}const Ae=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`,$e=e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but the listener hasn't been registed`,Re=e=>`[@rallie/core] one of the callbacks of the broadcast event ${e} throws an uncaught error`,je=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`,Me=e=>`[@rallie/core] you are trying to register a unicast event ${e}, but it has been registered before`,We=e=>`[@rallie/core] you have emitted ${e} unicast, but there is no listener of this event`,xe=e=>`[@rallie/core] ${e} is existing, you are not allowed to create it again`,Pe=(e,t)=>`[@rallie/core] can not find any assets of the app ${e} on the bus ${t}`,Le=e=>`[@rallie/core] you are trying to activate app ${e}, but it was not created`,Be=e=>`[@rallie/core] state ${e} is private, you are not allowed to set it`,Te=e=>`[@rallie/core] please describe your action when you modify the state ${e}`,ze=e=>`[@rallie/core] it's not allowed to set or watch state ${e} before it is initialized`,Ve=e=>`[@rallie/core] duplicated initialized state ${e}`,Ue=e=>`[@rallie/core] it's not allowed to initialized state ${e} to a primitive value`,De=e=>`[@rallie/core] the bus named ${e} has been defined before, please rename your bus`,Ie=(e,t)=>`[@rallie/core] There is a circular dependency when activating the app ${e}, and the circular path is ${t.join("->")}`,Ce=()=>"[@rallie/core] next() called multiple times in the middleware",Ge=()=>"[@rallie/core] the middleware must be a function",Fe=(e,t)=>`[@rallie/core] the event ${e} is not in the events pool that you specified when calling on${t?"Unicast":"Broadcast"}`,He=e=>(t,n)=>{let s=-1;const i=r=>{if(r<=s)return Promise.reject(new Error(Ce()));s=r;let o=e[r];if(r===e.length&&(o=n),!o)return Promise.resolve();try{return Promise.resolve(o(t,i.bind(null,r+1)))}catch(e){return Promise.reject(e)}};return i(0)};var Je,Ke,qe,Qe,Xe,Ye,Ze,et,tt;class nt{constructor(){Je.set(this,{}),Ke.set(this,{})}addBroadcastEventListener(e,t){i(this,Je,"f")[e]=i(this,Je,"f")[e]||new Set,i(this,Je,"f")[e].add(t)}addUnicastEventListener(e,t){if(i(this,Ke,"f")[e])throw new Error(Me(e));i(this,Ke,"f")[e]=t}removeBroadcastEventListener(e,t){const n=i(this,Je,"f")[e];if(!n){const t=Ae(e);throw new Error(t)}if(!n.has(t)){const t=$e(e);throw new Error(t)}n.delete(t)}removeUnicastEventListener(e){if(!i(this,Ke,"f")[e]){const t=je(e);throw new Error(t)}delete i(this,Ke,"f")[e]}emitBroadcast(e,...t){i(this,Je,"f")[e]=i(this,Je,"f")[e]||new Set,i(this,Je,"f")[e].forEach((n=>{try{n(...t)}catch(n){console.error(Re(e)),console.error(n)}}))}emitUnicast(e,...t){const n=i(this,Ke,"f")[e];if(n)return n(...t);throw new Error(We(e))}}Je=new WeakMap,Ke=new WeakMap;class st{constructor(e,t){qe.set(this,void 0),Qe.set(this,void 0),r(this,qe,e,"f"),r(this,Qe,t,"f"),i(this,Qe,"f")[e].watchers.add(this)}do(e){return this.handler=e,()=>this.unwatch()}unwatch(){null==this||this.stopEffect(),this.handler=null;const e=i(this,Qe,"f")[i(this,qe,"f")].watchers;e.has(this)&&e.delete(this)}}qe=new WeakMap,Qe=new WeakMap;class it{constructor(e,t){Xe.add(this),Ye.set(this,void 0),Ze.set(this,void 0),r(this,Ye,e,"f"),r(this,Ze,t,"f")}onBroadcast(e){return Object.entries(e).forEach((([e,t])=>{i(this,Ye,"f").addBroadcastEventListener(e,t)})),t=>{i(this,Xe,"m",et).call(this,e,!1,t)}}onUnicast(e){return Object.entries(e).forEach((([e,t])=>{try{i(this,Ye,"f").addUnicastEventListener(e,t)}catch(e){console.error(e)}})),t=>{i(this,Xe,"m",et).call(this,e,!0,t)}}createBroadcaster(e){return new Proxy({},{get:(t,n)=>(...t)=>i(this,Ye,"f").emitBroadcast(n,...t,null==e?void 0:e(n)),set:()=>!1})}createUnicaster(e){return new Proxy({},{get:(t,n)=>(...t)=>i(this,Ye,"f").emitUnicast(n,...t,null==e?void 0:e(n)),set:()=>!1})}existState(e){return!!i(this,Ze,"f")[e]}initState(e,t,n=!1){if(this.existState(e))throw new Error(Ve(e));if(["string","number","boolean","undefined"].includes(typeof t))throw new Error(Ue(e));return i(this,Ze,"f")[e]={state:me(t),owner:n?this:null,watchers:new Set},i(this,Ye,"f").emitBroadcast("$state-initialized",e),this.getState(e)}getState(e,t){if(this.existState(e)){const n=Ee(i(this,Ze,"f")[e].state);return t?t(n):n}return null}setState(e,t,n){return s(this,void 0,void 0,(function*(){const s=i(this,Xe,"m",tt).call(this,e);if(!t)throw new Error(Te(e));{const e=n(s);yield Promise.resolve(e)}}))}watchState(e,t){if(!this.existState(e)){const t=ze(e);throw new Error(t)}let n=!1;const s=Ee(i(this,Ze,"f")[e].state),r=new st(e,i(this,Ze,"f")),a=function(e,t){e.effect&&(e=e.effect.fn);const n=new x(e);t&&(o(n,t),t.scope&&_(n,t.scope)),t&&t.lazy||n.run();const s=n.run.bind(n);return s.effect=n,s}((()=>t(s)),{lazy:!0,scheduler:()=>{n||(n=!0,Promise.resolve().then((()=>{var e;const i=Se(t(s));null===(e=r.handler)||void 0===e||e.call(r,i,r.oldWatchingStates),r.oldWatchingStates=Se(i),n=!1})))}});return r.oldWatchingStates=a(),r.stopEffect=()=>a.effect.stop(),r}}Ye=new WeakMap,Ze=new WeakMap,Xe=new WeakSet,et=function(e,t,n){let s=t?i(this,Ye,"f").removeUnicastEventListener:i(this,Ye,"f").removeBroadcastEventListener;s=s.bind(i(this,Ye,"f")),n?e[n]?(s(n,e[n]),delete e[n]):console.warn(Fe(n,t)):Object.entries(e).forEach((([e,t])=>{s(e,t)}))},tt=function(e){if(!this.existState(e)){const t=ze(e);throw new Error(t)}const t=i(this,Ze,"f")[e].owner;if(t!==this&&null!==t){const t=Be(e);throw new Error(t)}return i(this,Ze,"f")[e].state};class rt{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 ot,at,ct,lt,ht,ft,ut,dt,pt,wt,vt,yt,gt,mt,Et={loadScript:e=>s(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 bt{constructor(e){ot.add(this),at.set(this,void 0),ct.set(this,new nt),lt.set(this,{}),ht.set(this,{}),ft.set(this,{}),this.conf=Ee({assets:{}}),ut.set(this,[]),dt.set(this,void 0),r(this,at,e,"f"),r(this,dt,He(i(this,ut,"f")),"f")}createSocket(){return new it(i(this,ct,"f"),i(this,lt,"f"))}existApp(e){return!!i(this,ht,"f")[e]}createApp(e){if(this.existApp(e))throw new Error(xe(e));const t=new rt(e);return i(this,ht,"f")[e]=t,t}loadApp(e){return s(this,void 0,void 0,(function*(){i(this,ht,"f")[e]||(i(this,ft,"f")[e]||(i(this,ft,"f")[e]=new Promise(((t,n)=>{const s=i(this,ot,"m",wt).call(this,e);i(this,dt,"f").call(this,s,i(this,ot,"m",vt).bind(this)).then((()=>{e.startsWith("lib:")&&!i(this,ht,"f")[e]&&(i(this,ht,"f")[e]=!0),i(this,ht,"f")[e]||n(new Error(Le(e))),t()})).catch((e=>{n(e)}))}))),yield i(this,ft,"f")[e])}))}activateApp(e){return s(this,void 0,void 0,(function*(){yield i(this,ot,"m",yt).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(Ge());return i(this,ut,"f").push(e),r(this,dt,He(i(this,ut,"f")),"f"),this}}at=new WeakMap,ct=new WeakMap,lt=new WeakMap,ht=new WeakMap,ft=new WeakMap,ut=new WeakMap,dt=new WeakMap,ot=new WeakSet,pt=function(e){return i(this,ht,"f")[e]&&"boolean"!=typeof i(this,ht,"f")[e]},wt=function(e){return{name:e,loadScript:Et.loadScript,loadLink:Et.loadLink}},vt=function(e){return s(this,void 0,void 0,(function*(){const{name:t,loadScript:n=Et.loadScript,loadLink:s=Et.loadLink}=e,{assets:r}=this.conf;if(!r[t])throw new Error(Pe(t,i(this,at,"f")));if(r[t].css&&r[t].css.forEach((e=>{s(e)})),r[t].js)for(const e of r[t].js)yield n(e)}))},yt=function(e,t){return s(this,void 0,void 0,(function*(){if(yield this.loadApp(e),i(this,ot,"m",pt).call(this,e)){const n=i(this,ht,"f")[e];if(yield i(this,ot,"m",mt).call(this,n),t.includes(e)){const n=t.indexOf(e),s=[...t.slice(n),e];throw new Error(Ie(e,s))}if(t.push(e),!n.activated){const e=()=>s(this,void 0,void 0,(function*(){yield i(this,ot,"m",gt).call(this,n,t),n.doActivate&&(yield Promise.resolve(n.doActivate()))}));n.activated=e()}yield n.activated,t.pop()}}))},gt=function(e,t){return s(this,void 0,void 0,(function*(){if(0!==e.dependencies.length)for(const n of e.dependencies)yield i(this,ot,"m",yt).call(this,n,t)}))},mt=function(e){return s(this,void 0,void 0,(function*(){yield Promise.all(e.relatedApps.map((e=>this.loadApp(e))))}))};const _t={},St="DEFAULT_BUS",kt=(e=St)=>{let t=null,n=!1;const s=((e=St)=>window.RALLIE_BUS_STORE&&window.RALLIE_BUS_STORE[e])(e);return s?(t=s,n=!1):(t=((e=St)=>{if(void 0===window.RALLIE_BUS_STORE&&Reflect.defineProperty(window,"RALLIE_BUS_STORE",{value:_t,writable:!1}),window.RALLIE_BUS_STORE[e])throw new Error(De(e));{const t=new bt(e);return Reflect.defineProperty(window.RALLIE_BUS_STORE,e,{value:t,writable:!1}),t}})(e),n=!0),[t,n]},Ot={privateBus:e=>`${e}.bus`,stateNamespace:e=>`${e}.state`,isGlobalBusAccessible:"isGlobalBusAccessible",exportMethodName:"__RallieInnerExport__"},Nt=e=>`[rallie] ${e}`,At={stateNotInitialized:e=>Nt(` the block ${e}'s state is not initialized, please check:\n1. whether the block ${e} is loaded.\n2. whether the block ${e} has initialized the state`),duplicatedBlockName:e=>Nt(`the block ${e} is already registered before, please rename your block`),stateIsReadonly:e=>Nt(`the state of ${e} is readonly`)};var $t,Rt,jt,Mt,Wt,xt,Pt;class Lt{constructor(e,s,i){$t.set(this,void 0),this.name=e,n(this,$t,i,"f"),this.events=t(this,$t,"f").createBroadcaster((()=>s)),this.methods=t(this,$t,"f").createUnicaster((()=>s)),Reflect.defineProperty(this,"state",{get:()=>t(this,$t,"f").getState(Ot.stateNamespace(this.name)),set:()=>{throw new Error(At.stateIsReadonly(this.name))}})}setState(e,n){if(t(this,$t,"f").existState(Ot.stateNamespace(this.name)))return t(this,$t,"f").setState(Ot.stateNamespace(this.name),e,n);throw new Error(At.stateNotInitialized(this.name))}watchState(e){if(t(this,$t,"f").existState(Ot.stateNamespace(this.name)))return t(this,$t,"f").watchState(Ot.stateNamespace(this.name),e);throw new Error(At.stateNotInitialized(this.name))}listenEvents(e){return t(this,$t,"f").onBroadcast(e)}}$t=new WeakMap;class Bt extends Lt{constructor(e,t,s,i){const[r]=kt(Ot.privateBus(e)),o=r.createSocket();super(e,e,o),Rt.set(this,void 0),jt.set(this,void 0),Mt.set(this,void 0),Wt.set(this,void 0),xt.set(this,void 0),Pt.set(this,{}),n(this,Wt,o,"f"),n(this,Rt,t,"f"),n(this,jt,s,"f"),n(this,xt,t.createApp(e),"f"),n(this,Mt,i,"f")}initState(e,n){return t(this,Wt,"f").initState(Ot.stateNamespace(this.name),e,n),this}addMethods(e){return t(this,Wt,"f").onUnicast(e)}relyOn(e){return t(this,xt,"f").relyOn(e),this}relateTo(e){return t(this,xt,"f").relateTo(e),this}onActivate(e){return t(this,xt,"f").onActivate(e),this}connect(e){if(!t(this,Pt,"f")[e]){const[n]=kt(Ot.privateBus(e)),s=n.createSocket();t(this,Pt,"f")[e]=new Lt(e,this.name,s)}return t(this,Pt,"f")[e]}load(e){return t(this,Rt,"f").loadApp(e)}activate(e){return t(this,Rt,"f").activateApp(e)}run(n){var s;return e(this,void 0,void 0,(function*(){const e=t(this,Mt,"f")||(null===(s=t(this,jt,"f").getState(Ot.isGlobalBusAccessible))||void 0===s?void 0:s.value),i=e=>{t(this,Mt,"f")&&t(this,jt,"f").setState(Ot.isGlobalBusAccessible,e?"unfreeze the enviroment":"freeze the enviroment",(t=>{t.value=e}))},r={isEntry:t(this,Mt,"f"),use:n=>{e&&t(this,Rt,"f").use(n)},config:n=>{e&&t(this,Rt,"f").config(n)},freeze:()=>{i(!1)},unfreeze:()=>{i(!0)}},o=n(new Proxy(r,{get:(e,n,s)=>"conf"===n?JSON.parse(JSON.stringify(t(this,Rt,"f").conf)):Reflect.get(e,n,s),set:()=>!1}));yield Promise.resolve(o)}))}}function Tt(e){const[t,n]=kt();if(t.existApp(e))throw new Error(At.duplicatedBlockName(e));const s=t.createSocket();return n&&s.initState(Ot.isGlobalBusAccessible,{value:!0},!0),new Bt(e,t,s,n)}Rt=new WeakMap,jt=new WeakMap,Mt=new WeakMap,Wt=new WeakMap,xt=new WeakMap,Pt=new WeakMap;export{Tt as createBlock}; | ||
function e(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function t(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function n(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}function s(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function i(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function r(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}"production"===process.env.NODE_ENV||Object.freeze({}),"production"===process.env.NODE_ENV||Object.freeze([]);const o=Object.assign,a=Object.prototype.hasOwnProperty,c=(e,t)=>a.call(e,t),l=Array.isArray,h=e=>"[object Map]"===p(e),f=e=>"symbol"==typeof e,u=e=>null!==e&&"object"==typeof e,d=Object.prototype.toString,p=e=>d.call(e),w=e=>p(e).slice(8,-1),v=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,y=(e=>{const t=Object.create(null);return e=>t[e]||(t[e]=(e=>e.charAt(0).toUpperCase()+e.slice(1))(e))})(),g=(e,t)=>!Object.is(e,t),m=e=>{const t=parseFloat(e);return isNaN(t)?e:t};function E(e,...t){console.warn(`[Vue warn] ${e}`,...t)}let b;function _(e,t=b){t&&t.active&&t.effects.push(e)}const S=e=>{const t=new Set(e);return t.w=0,t.n=0,t},k=e=>(e.w&$)>0,O=e=>(e.n&$)>0,N=new WeakMap;let A=0,$=1;const R=30;let j;const M=Symbol("production"!==process.env.NODE_ENV?"iterate":""),W=Symbol("production"!==process.env.NODE_ENV?"Map key iterate":"");class x{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=j,t=L;for(;e;){if(e===this)return;e=e.parent}try{return this.parent=j,j=this,L=!0,$=1<<++A,A<=R?(({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=$})(this):P(this),this.fn()}finally{A<=R&&(e=>{const{deps:t}=e;if(t.length){let n=0;for(let s=0;s<t.length;s++){const i=t[s];k(i)&&!O(i)?i.delete(e):t[n++]=i,i.w&=~$,i.n&=~$}t.length=n}})(this),$=1<<--A,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 B=[];function T(e,t,n){if(L&&j){let s=N.get(e);s||N.set(e,s=new Map);let i=s.get(n);i||s.set(n,i=S()),function(e,t){let n=!1;A<=R?O(e)||(e.n|=$,n=!k(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)))}(i,"production"!==process.env.NODE_ENV?{effect:j,target:e,type:t,key:n}:void 0)}}function z(e,t,n,s,i,r){const o=N.get(e);if(!o)return;let a=[];if("clear"===t)a=[...o.values()];else if("length"===n&&l(e)){const e=m(s);o.forEach(((t,n)=>{("length"===n||n>=e)&&a.push(t)}))}else switch(void 0!==n&&a.push(o.get(n)),t){case"add":l(e)?v(n)&&a.push(o.get("length")):(a.push(o.get(M)),h(e)&&a.push(o.get(W)));break;case"delete":l(e)||(a.push(o.get(M)),h(e)&&a.push(o.get(W)));break;case"set":h(e)&&a.push(o.get(M))}const c="production"!==process.env.NODE_ENV?{target:e,type:t,key:n,newValue:s,oldValue:i,oldTarget:r}:void 0;if(1===a.length)a[0]&&("production"!==process.env.NODE_ENV?V(a[0],c):V(a[0]));else{const e=[];for(const t of a)t&&e.push(...t);"production"!==process.env.NODE_ENV?V(S(e),c):V(S(e))}}function V(e,t){const n=l(e)?e:[...e];for(const e of n)e.computed&&U(e,t);for(const e of n)e.computed||U(e,t)}function U(e,t){(e!==j||e.allowRecurse)&&("production"!==process.env.NODE_ENV&&e.onTrigger&&e.onTrigger(o({effect:e},t)),e.scheduler?e.scheduler():e.run())}const D=function(e,t){const n=Object.create(null),s=e.split(",");for(let e=0;e<s.length;e++)n[s[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}("__proto__,__v_isRef,__isVue"),I=new Set(Object.getOwnPropertyNames(Symbol).filter((e=>"arguments"!==e&&"caller"!==e)).map((e=>Symbol[e])).filter(f)),C=H(),G=H(!0),F=function(){const e={};return["includes","indexOf","lastIndexOf"].forEach((t=>{e[t]=function(...e){const n=Se(this);for(let e=0,t=this.length;e<t;e++)T(n,"get",e+"");const s=n[t](...e);return-1===s||!1===s?n[t](...e.map(Se)):s}})),["push","pop","shift","unshift","splice"].forEach((t=>{e[t]=function(...e){B.push(L),L=!1;const n=Se(this)[t].apply(this,e);return function(){const e=B.pop();L=void 0===e||e}(),n}})),e}();function H(e=!1,t=!1){return function(n,s,i){if("__v_isReactive"===s)return!e;if("__v_isReadonly"===s)return e;if("__v_isShallow"===s)return t;if("__v_raw"===s&&i===(e?t?ge:ye:t?ve:we).get(n))return n;const r=l(n);if(!e&&r&&c(F,s))return Reflect.get(F,s,i);const o=Reflect.get(n,s,i);return(f(s)?I.has(s):D(s))?o:(e||T(n,"get",s),t?o:Ne(o)?r&&v(s)?o:o.value:u(o)?e?Ee(o):me(o):o)}}const J={get:C,set:function(e=!1){return function(t,n,s,i){let r=t[n];if(_e(r)&&Ne(r)&&!Ne(s))return!1;if(!e&&(function(e){return!(!e||!e.__v_isShallow)}(s)||_e(s)||(r=Se(r),s=Se(s)),!l(t)&&Ne(r)&&!Ne(s)))return r.value=s,!0;const o=l(t)&&v(n)?Number(n)<t.length:c(t,n),a=Reflect.set(t,n,s,i);return t===Se(i)&&(o?g(s,r)&&z(t,"set",n,s,r):z(t,"add",n,s)),a}}(),deleteProperty:function(e,t){const n=c(e,t),s=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&z(e,"delete",t,void 0,s),i},has:function(e,t){const n=Reflect.has(e,t);return f(t)&&I.has(t)||T(e,"has",t),n},ownKeys:function(e){return T(e,"iterate",l(e)?"length":M),Reflect.ownKeys(e)}},K={get:G,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,Q=e=>Reflect.getPrototypeOf(e);function X(e,t,n=!1,s=!1){const i=Se(e=e.__v_raw),r=Se(t);n||(t!==r&&T(i,"get",t),T(i,"get",r));const{has:o}=Q(i),a=s?q:n?Oe:ke;return o.call(i,t)?a(e.get(t)):o.call(i,r)?a(e.get(r)):void(e!==i&&e.get(t))}function Y(e,t=!1){const n=this.__v_raw,s=Se(n),i=Se(e);return t||(e!==i&&T(s,"has",e),T(s,"has",i)),e===i?n.has(e):n.has(e)||n.has(i)}function Z(e,t=!1){return e=e.__v_raw,!t&&T(Se(e),"iterate",M),Reflect.get(e,"size",e)}function ee(e){e=Se(e);const t=Se(this);return Q(t).has.call(t,e)||(t.add(e),z(t,"add",e,e)),this}function te(e,t){t=Se(t);const n=Se(this),{has:s,get:i}=Q(n);let r=s.call(n,e);r?"production"!==process.env.NODE_ENV&&pe(n,s,e):(e=Se(e),r=s.call(n,e));const o=i.call(n,e);return n.set(e,t),r?g(t,o)&&z(n,"set",e,t,o):z(n,"add",e,t),this}function ne(e){const t=Se(this),{has:n,get:s}=Q(t);let i=n.call(t,e);i?"production"!==process.env.NODE_ENV&&pe(t,n,e):(e=Se(e),i=n.call(t,e));const r=s?s.call(t,e):void 0,o=t.delete(e);return i&&z(t,"delete",e,void 0,r),o}function se(){const e=Se(this),t=0!==e.size,n="production"!==process.env.NODE_ENV?h(e)?new Map(e):new Set(e):void 0,s=e.clear();return t&&z(e,"clear",void 0,void 0,n),s}function ie(e,t){return function(n,s){const i=this,r=i.__v_raw,o=Se(r),a=t?q:e?Oe:ke;return!e&&T(o,"iterate",M),r.forEach(((e,t)=>n.call(s,a(e),a(t),i)))}}function re(e,t,n){return function(...s){const i=this.__v_raw,r=Se(i),o=h(r),a="entries"===e||e===Symbol.iterator&&o,c="keys"===e&&o,l=i[e](...s),f=n?q:t?Oe:ke;return!t&&T(r,"iterate",c?W:M),{next(){const{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:a?[f(e[0]),f(e[1])]:f(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(`${y(e)} operation ${n}failed: target is readonly.`,Se(this))}return"delete"!==e&&this}}const[ae,ce,le,he]=function(){const e={get(e){return X(this,e)},get size(){return Z(this)},has:Y,add:ee,set:te,delete:ne,clear:se,forEach:ie(!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:se,forEach:ie(!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:ie(!0,!1)},s={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:ie(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{e[i]=re(i,!1,!1),n[i]=re(i,!0,!1),t[i]=re(i,!1,!0),s[i]=re(i,!0,!0)})),[e,n,t,s]}();function fe(e,t){const n=t?e?he:le:e?ce:ae;return(t,s,i)=>"__v_isReactive"===s?!e:"__v_isReadonly"===s?e:"__v_raw"===s?t:Reflect.get(c(n,s)&&s in t?n:t,s,i)}const ue={get:fe(!1,!1)},de={get:fe(!0,!1)};function pe(e,t,n){const s=Se(n);if(s!==n&&t.call(e,s)){const t=w(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,ve=new WeakMap,ye=new WeakMap,ge=new WeakMap;function me(e){return _e(e)?e:be(e,!1,J,ue,we)}function Ee(e){return be(e,!0,K,de,ye)}function be(e,t,n,s,i){if(!u(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 r=i.get(e);if(r)return r;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}}(w(a));var a;if(0===o)return e;const c=new Proxy(e,2===o?s:n);return i.set(e,c),c}function _e(e){return!(!e||!e.__v_isReadonly)}function Se(e){const t=e&&e.__v_raw;return t?Se(t):e}const ke=e=>u(e)?me(e):e,Oe=e=>u(e)?Ee(e):e;function Ne(e){return!(!e||!0!==e.__v_isRef)}const Ae=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`,$e=e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but the listener hasn't been registed`,Re=e=>`[@rallie/core] one of the callbacks of the broadcast event ${e} throws an uncaught error`,je=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`,Me=e=>`[@rallie/core] you are trying to register a unicast event ${e}, but it has been registered before`,We=e=>`[@rallie/core] you have emitted ${e} unicast, but there is no listener of this event`,xe=e=>`[@rallie/core] ${e} is existing, you are not allowed to create it again`,Pe=(e,t)=>`[@rallie/core] can not find any assets of the app ${e} on the bus ${t}`,Le=e=>`[@rallie/core] you are trying to activate app ${e}, but it was not created`,Be=e=>`[@rallie/core] state ${e} is private, you are not allowed to set it`,Te=e=>`[@rallie/core] please describe your action when you modify the state ${e}`,ze=e=>`[@rallie/core] it's not allowed to set or watch state ${e} before it is initialized`,Ve=e=>`[@rallie/core] duplicated initialized state ${e}`,Ue=e=>`[@rallie/core] it's not allowed to initialized state ${e} to a primitive value`,De=e=>`[@rallie/core] the bus named ${e} has been defined before, please rename your bus`,Ie=(e,t)=>`[@rallie/core] There is a circular dependency when activating the app ${e}, and the circular path is ${t.join("->")}`,Ce=()=>"[@rallie/core] next() called multiple times in the middleware",Ge=()=>"[@rallie/core] the middleware must be a function",Fe=(e,t)=>`[@rallie/core] the event ${e} is not in the events pool that you specified when calling on${t?"Unicast":"Broadcast"}`,He=e=>(t,n)=>{let s=-1;const i=r=>{if(r<=s)return Promise.reject(new Error(Ce()));s=r;let o=e[r];if(r===e.length&&(o=n),!o)return Promise.resolve();try{return Promise.resolve(o(t,i.bind(null,r+1)))}catch(e){return Promise.reject(e)}};return i(0)};var Je,Ke,qe,Qe,Xe,Ye,Ze,et,tt;class nt{constructor(){Je.set(this,{}),Ke.set(this,{})}addBroadcastEventListener(e,t){i(this,Je,"f")[e]=i(this,Je,"f")[e]||new Set,i(this,Je,"f")[e].add(t)}addUnicastEventListener(e,t){if(i(this,Ke,"f")[e])throw new Error(Me(e));i(this,Ke,"f")[e]=t}removeBroadcastEventListener(e,t){const n=i(this,Je,"f")[e];if(!n){const t=Ae(e);throw new Error(t)}if(!n.has(t)){const t=$e(e);throw new Error(t)}n.delete(t)}removeUnicastEventListener(e){if(!i(this,Ke,"f")[e]){const t=je(e);throw new Error(t)}delete i(this,Ke,"f")[e]}emitBroadcast(e,...t){i(this,Je,"f")[e]=i(this,Je,"f")[e]||new Set,i(this,Je,"f")[e].forEach((n=>{try{n(...t)}catch(n){console.error(Re(e)),console.error(n)}}))}emitUnicast(e,...t){const n=i(this,Ke,"f")[e];if(n)return n(...t);throw new Error(We(e))}}Je=new WeakMap,Ke=new WeakMap;class st{constructor(e,t){qe.set(this,void 0),Qe.set(this,void 0),r(this,qe,e,"f"),r(this,Qe,t,"f"),i(this,Qe,"f")[e].watchers.add(this)}do(e){return this.handler=e,()=>this.unwatch()}unwatch(){null==this||this.stopEffect(),this.handler=null;const e=i(this,Qe,"f")[i(this,qe,"f")].watchers;e.has(this)&&e.delete(this)}}qe=new WeakMap,Qe=new WeakMap;class it{constructor(e,t){Xe.add(this),Ye.set(this,void 0),Ze.set(this,void 0),r(this,Ye,e,"f"),r(this,Ze,t,"f")}onBroadcast(e){return Object.entries(e).forEach((([e,t])=>{i(this,Ye,"f").addBroadcastEventListener(e,t)})),t=>{i(this,Xe,"m",et).call(this,e,!1,t)}}onUnicast(e){return Object.entries(e).forEach((([e,t])=>{try{i(this,Ye,"f").addUnicastEventListener(e,t)}catch(e){console.error(e)}})),t=>{i(this,Xe,"m",et).call(this,e,!0,t)}}createBroadcaster(e){return new Proxy({},{get:(t,n)=>(...t)=>(null==e||e(n),i(this,Ye,"f").emitBroadcast(n,...t)),set:()=>!1})}createUnicaster(e){return new Proxy({},{get:(t,n)=>(...t)=>(null==e||e(n),i(this,Ye,"f").emitUnicast(n,...t)),set:()=>!1})}existState(e){return!!i(this,Ze,"f")[e]}initState(e,t,n=!1){if(this.existState(e))throw new Error(Ve(e));if(["string","number","boolean","undefined"].includes(typeof t))throw new Error(Ue(e));return i(this,Ze,"f")[e]={state:me(t),owner:n?this:null,watchers:new Set},i(this,Ye,"f").emitBroadcast("$state-initialized",e),this.getState(e)}getState(e,t){if(this.existState(e)){const n=Ee(i(this,Ze,"f")[e].state);return t?t(n):n}return null}setState(e,t,n){return s(this,void 0,void 0,(function*(){const s=i(this,Xe,"m",tt).call(this,e);if(!t)throw new Error(Te(e));{const e=n(s);yield Promise.resolve(e)}}))}watchState(e,t){if(!this.existState(e)){const t=ze(e);throw new Error(t)}let n=!1;const s=Ee(i(this,Ze,"f")[e].state),r=new st(e,i(this,Ze,"f")),a=function(e,t){e.effect&&(e=e.effect.fn);const n=new x(e);t&&(o(n,t),t.scope&&_(n,t.scope)),t&&t.lazy||n.run();const s=n.run.bind(n);return s.effect=n,s}((()=>t(s)),{lazy:!0,scheduler:()=>{n||(n=!0,Promise.resolve().then((()=>{var e;const i=Se(t(s));null===(e=r.handler)||void 0===e||e.call(r,i,r.oldWatchingStates),r.oldWatchingStates=Se(i),n=!1})))}});return r.oldWatchingStates=a(),r.stopEffect=()=>a.effect.stop(),r}}Ye=new WeakMap,Ze=new WeakMap,Xe=new WeakSet,et=function(e,t,n){let s=t?i(this,Ye,"f").removeUnicastEventListener:i(this,Ye,"f").removeBroadcastEventListener;s=s.bind(i(this,Ye,"f")),n?e[n]?(s(n,e[n]),delete e[n]):console.warn(Fe(n,t)):Object.entries(e).forEach((([e,t])=>{s(e,t)}))},tt=function(e){if(!this.existState(e)){const t=ze(e);throw new Error(t)}const t=i(this,Ze,"f")[e].owner;if(t!==this&&null!==t){const t=Be(e);throw new Error(t)}return i(this,Ze,"f")[e].state};class rt{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 ot,at,ct,lt,ht,ft,ut,dt,pt,wt,vt,yt,gt,mt,Et={loadScript:e=>s(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 bt{constructor(e){ot.add(this),at.set(this,void 0),ct.set(this,new nt),lt.set(this,{}),ht.set(this,{}),ft.set(this,{}),this.conf=Ee({assets:{}}),ut.set(this,[]),dt.set(this,void 0),r(this,at,e,"f"),r(this,dt,He(i(this,ut,"f")),"f")}createSocket(){return new it(i(this,ct,"f"),i(this,lt,"f"))}existApp(e){return!!i(this,ht,"f")[e]}createApp(e){if(this.existApp(e))throw new Error(xe(e));const t=new rt(e);return i(this,ht,"f")[e]=t,t}loadApp(e){return s(this,void 0,void 0,(function*(){i(this,ht,"f")[e]||(i(this,ft,"f")[e]||(i(this,ft,"f")[e]=new Promise(((t,n)=>{const s=i(this,ot,"m",wt).call(this,e);i(this,dt,"f").call(this,s,i(this,ot,"m",vt).bind(this)).then((()=>{e.startsWith("lib:")&&!i(this,ht,"f")[e]&&(i(this,ht,"f")[e]=!0),i(this,ht,"f")[e]||n(new Error(Le(e))),t()})).catch((e=>{n(e)}))}))),yield i(this,ft,"f")[e])}))}activateApp(e){return s(this,void 0,void 0,(function*(){yield i(this,ot,"m",yt).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(Ge());return i(this,ut,"f").push(e),r(this,dt,He(i(this,ut,"f")),"f"),this}}at=new WeakMap,ct=new WeakMap,lt=new WeakMap,ht=new WeakMap,ft=new WeakMap,ut=new WeakMap,dt=new WeakMap,ot=new WeakSet,pt=function(e){return i(this,ht,"f")[e]&&"boolean"!=typeof i(this,ht,"f")[e]},wt=function(e){return{name:e,loadScript:Et.loadScript,loadLink:Et.loadLink}},vt=function(e){return s(this,void 0,void 0,(function*(){const{name:t,loadScript:n=Et.loadScript,loadLink:s=Et.loadLink}=e,{assets:r}=this.conf;if(!r[t])throw new Error(Pe(t,i(this,at,"f")));if(r[t].css&&r[t].css.forEach((e=>{s(e)})),r[t].js)for(const e of r[t].js)yield n(e)}))},yt=function(e,t){return s(this,void 0,void 0,(function*(){if(yield this.loadApp(e),i(this,ot,"m",pt).call(this,e)){const n=i(this,ht,"f")[e];if(yield i(this,ot,"m",mt).call(this,n),t.includes(e)){const n=t.indexOf(e),s=[...t.slice(n),e];throw new Error(Ie(e,s))}if(t.push(e),!n.activated){const e=()=>s(this,void 0,void 0,(function*(){yield i(this,ot,"m",gt).call(this,n,t),n.doActivate&&(yield Promise.resolve(n.doActivate()))}));n.activated=e()}yield n.activated,t.pop()}}))},gt=function(e,t){return s(this,void 0,void 0,(function*(){if(0!==e.dependencies.length)for(const n of e.dependencies)yield i(this,ot,"m",yt).call(this,n,t)}))},mt=function(e){return s(this,void 0,void 0,(function*(){yield Promise.all(e.relatedApps.map((e=>this.loadApp(e))))}))};const _t={},St="DEFAULT_BUS",kt=(e=St)=>{let t=null,n=!1;const s=((e=St)=>window.RALLIE_BUS_STORE&&window.RALLIE_BUS_STORE[e])(e);return s?(t=s,n=!1):(t=((e=St)=>{if(void 0===window.RALLIE_BUS_STORE&&Reflect.defineProperty(window,"RALLIE_BUS_STORE",{value:_t,writable:!1}),window.RALLIE_BUS_STORE[e])throw new Error(De(e));{const t=new bt(e);return Reflect.defineProperty(window.RALLIE_BUS_STORE,e,{value:t,writable:!1}),t}})(e),n=!0),[t,n]},Ot={privateBus:e=>`${e}.bus`,stateNamespace:e=>`${e}.state`,isGlobalBusAccessible:"isGlobalBusAccessible",exportMethodName:"__RallieInnerExport__"},Nt=e=>`[rallie] ${e}`,At={stateNotInitialized:e=>Nt(` the block ${e}'s state is not initialized, please check:\n1. whether the block ${e} is loaded.\n2. whether the block ${e} has initialized the state`),duplicatedBlockName:e=>Nt(`the block ${e} is already registered before, please rename your block`),stateIsReadonly:e=>Nt(`the state of ${e} is readonly`)};var $t,Rt,jt,Mt,Wt,xt,Pt;class Lt{constructor(e,s){$t.set(this,void 0),this.name=e,n(this,$t,s,"f"),this.events=t(this,$t,"f").createBroadcaster(),this.methods=t(this,$t,"f").createUnicaster(),Reflect.defineProperty(this,"state",{get:()=>t(this,$t,"f").getState(Ot.stateNamespace(this.name)),set:()=>{throw new Error(At.stateIsReadonly(this.name))}})}setState(e,n){if(t(this,$t,"f").existState(Ot.stateNamespace(this.name)))return t(this,$t,"f").setState(Ot.stateNamespace(this.name),e,n);throw new Error(At.stateNotInitialized(this.name))}watchState(e){if(t(this,$t,"f").existState(Ot.stateNamespace(this.name)))return t(this,$t,"f").watchState(Ot.stateNamespace(this.name),e);throw new Error(At.stateNotInitialized(this.name))}listenEvents(e){return t(this,$t,"f").onBroadcast(e)}}$t=new WeakMap;class Bt extends Lt{constructor(e,t,s,i){const[r]=kt(Ot.privateBus(e)),o=r.createSocket();super(e,o),Rt.set(this,void 0),jt.set(this,void 0),Mt.set(this,void 0),Wt.set(this,void 0),xt.set(this,void 0),Pt.set(this,{}),n(this,Wt,o,"f"),n(this,Rt,t,"f"),n(this,jt,s,"f"),n(this,xt,t.createApp(e),"f"),n(this,Mt,i,"f")}initState(e,n){return t(this,Wt,"f").initState(Ot.stateNamespace(this.name),e,n),this}addMethods(e){return t(this,Wt,"f").onUnicast(e)}relyOn(e){return t(this,xt,"f").relyOn(e),this}relateTo(e){return t(this,xt,"f").relateTo(e),this}onActivate(e){return t(this,xt,"f").onActivate(e),this}connect(e){if(!t(this,Pt,"f")[e]){const[n]=kt(Ot.privateBus(e)),s=n.createSocket();t(this,Pt,"f")[e]=new Lt(e,s)}return t(this,Pt,"f")[e]}load(e){return t(this,Rt,"f").loadApp(e)}activate(e){return t(this,Rt,"f").activateApp(e)}run(n){var s;return e(this,void 0,void 0,(function*(){const e=t(this,Mt,"f")||(null===(s=t(this,jt,"f").getState(Ot.isGlobalBusAccessible))||void 0===s?void 0:s.value),i=e=>{t(this,Mt,"f")&&t(this,jt,"f").setState(Ot.isGlobalBusAccessible,e?"unfreeze the enviroment":"freeze the enviroment",(t=>{t.value=e}))},r={isEntry:t(this,Mt,"f"),use:n=>{e&&t(this,Rt,"f").use(n)},config:n=>{e&&t(this,Rt,"f").config(n)},freeze:()=>{i(!1)},unfreeze:()=>{i(!0)}},o=n(new Proxy(r,{get:(e,n,s)=>"conf"===n?JSON.parse(JSON.stringify(t(this,Rt,"f").conf)):Reflect.get(e,n,s),set:()=>!1}));yield Promise.resolve(o)}))}}function Tt(e){const[t,n]=kt();if(t.existApp(e))throw new Error(At.duplicatedBlockName(e));const s=t.createSocket();return n&&s.initState(Ot.isGlobalBusAccessible,{value:!0},!0),new Bt(e,t,s,n)}Rt=new WeakMap,jt=new WeakMap,Mt=new WeakMap,Wt=new WeakMap,xt=new WeakMap,Pt=new WeakMap;export{Tt as createBlock}; |
@@ -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).RallieBlock={})}(this,(function(e){"use strict";function t(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function n(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function s(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}function i(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function r(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function o(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}"production"===process.env.NODE_ENV||Object.freeze({}),"production"===process.env.NODE_ENV||Object.freeze([]);const a=Object.assign,c=Object.prototype.hasOwnProperty,l=(e,t)=>c.call(e,t),h=Array.isArray,f=e=>"[object Map]"===w(e),u=e=>"symbol"==typeof e,d=e=>null!==e&&"object"==typeof e,p=Object.prototype.toString,w=e=>p.call(e),v=e=>w(e).slice(8,-1),y=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,g=(e=>{const t=Object.create(null);return e=>t[e]||(t[e]=(e=>e.charAt(0).toUpperCase()+e.slice(1))(e))})(),m=(e,t)=>!Object.is(e,t),E=e=>{const t=parseFloat(e);return isNaN(t)?e:t};function b(e,...t){console.warn(`[Vue warn] ${e}`,...t)}let _;function S(e,t=_){t&&t.active&&t.effects.push(e)}const k=e=>{const t=new Set(e);return t.w=0,t.n=0,t},O=e=>(e.w&$)>0,N=e=>(e.n&$)>0,A=new WeakMap;let R=0,$=1;const j=30;let M;const x=Symbol("production"!==process.env.NODE_ENV?"iterate":""),W=Symbol("production"!==process.env.NODE_ENV?"Map key iterate":"");class P{constructor(e,t=null,n){this.fn=e,this.scheduler=t,this.active=!0,this.deps=[],this.parent=void 0,S(this,n)}run(){if(!this.active)return this.fn();let e=M,t=T;for(;e;){if(e===this)return;e=e.parent}try{return this.parent=M,M=this,T=!0,$=1<<++R,R<=j?(({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=$})(this):B(this),this.fn()}finally{R<=j&&(e=>{const{deps:t}=e;if(t.length){let n=0;for(let s=0;s<t.length;s++){const i=t[s];O(i)&&!N(i)?i.delete(e):t[n++]=i,i.w&=~$,i.n&=~$}t.length=n}})(this),$=1<<--R,M=this.parent,T=t,this.parent=void 0,this.deferStop&&this.stop()}}stop(){M===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 T=!0;const L=[];function z(e,t,n){if(T&&M){let s=A.get(e);s||A.set(e,s=new Map);let i=s.get(n);i||s.set(n,i=k()),function(e,t){let n=!1;R<=j?N(e)||(e.n|=$,n=!O(e)):n=!e.has(M),n&&(e.add(M),M.deps.push(e),"production"!==process.env.NODE_ENV&&M.onTrack&&M.onTrack(Object.assign({effect:M},t)))}(i,"production"!==process.env.NODE_ENV?{effect:M,target:e,type:t,key:n}:void 0)}}function V(e,t,n,s,i,r){const o=A.get(e);if(!o)return;let a=[];if("clear"===t)a=[...o.values()];else if("length"===n&&h(e)){const e=E(s);o.forEach(((t,n)=>{("length"===n||n>=e)&&a.push(t)}))}else switch(void 0!==n&&a.push(o.get(n)),t){case"add":h(e)?y(n)&&a.push(o.get("length")):(a.push(o.get(x)),f(e)&&a.push(o.get(W)));break;case"delete":h(e)||(a.push(o.get(x)),f(e)&&a.push(o.get(W)));break;case"set":f(e)&&a.push(o.get(x))}const c="production"!==process.env.NODE_ENV?{target:e,type:t,key:n,newValue:s,oldValue:i,oldTarget:r}:void 0;if(1===a.length)a[0]&&("production"!==process.env.NODE_ENV?U(a[0],c):U(a[0]));else{const e=[];for(const t of a)t&&e.push(...t);"production"!==process.env.NODE_ENV?U(k(e),c):U(k(e))}}function U(e,t){const n=h(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!==M||e.allowRecurse)&&("production"!==process.env.NODE_ENV&&e.onTrigger&&e.onTrigger(a({effect:e},t)),e.scheduler?e.scheduler():e.run())}const I=function(e,t){const n=Object.create(null),s=e.split(",");for(let e=0;e<s.length;e++)n[s[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}("__proto__,__v_isRef,__isVue"),C=new Set(Object.getOwnPropertyNames(Symbol).filter((e=>"arguments"!==e&&"caller"!==e)).map((e=>Symbol[e])).filter(u)),G=J(),F=J(!0),H=function(){const e={};return["includes","indexOf","lastIndexOf"].forEach((t=>{e[t]=function(...e){const n=ke(this);for(let e=0,t=this.length;e<t;e++)z(n,"get",e+"");const s=n[t](...e);return-1===s||!1===s?n[t](...e.map(ke)):s}})),["push","pop","shift","unshift","splice"].forEach((t=>{e[t]=function(...e){L.push(T),T=!1;const n=ke(this)[t].apply(this,e);return function(){const e=L.pop();T=void 0===e||e}(),n}})),e}();function J(e=!1,t=!1){return function(n,s,i){if("__v_isReactive"===s)return!e;if("__v_isReadonly"===s)return e;if("__v_isShallow"===s)return t;if("__v_raw"===s&&i===(e?t?me:ge:t?ye:ve).get(n))return n;const r=h(n);if(!e&&r&&l(H,s))return Reflect.get(H,s,i);const o=Reflect.get(n,s,i);return(u(s)?C.has(s):I(s))?o:(e||z(n,"get",s),t?o:Ae(o)?r&&y(s)?o:o.value:d(o)?e?be(o):Ee(o):o)}}const K={get:G,set:function(e=!1){return function(t,n,s,i){let r=t[n];if(Se(r)&&Ae(r)&&!Ae(s))return!1;if(!e&&(function(e){return!(!e||!e.__v_isShallow)}(s)||Se(s)||(r=ke(r),s=ke(s)),!h(t)&&Ae(r)&&!Ae(s)))return r.value=s,!0;const o=h(t)&&y(n)?Number(n)<t.length:l(t,n),a=Reflect.set(t,n,s,i);return t===ke(i)&&(o?m(s,r)&&V(t,"set",n,s,r):V(t,"add",n,s)),a}}(),deleteProperty:function(e,t){const n=l(e,t),s=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&V(e,"delete",t,void 0,s),i},has:function(e,t){const n=Reflect.has(e,t);return u(t)&&C.has(t)||z(e,"has",t),n},ownKeys:function(e){return z(e,"iterate",h(e)?"length":x),Reflect.ownKeys(e)}},q={get:F,set:(e,t)=>("production"!==process.env.NODE_ENV&&b(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0),deleteProperty:(e,t)=>("production"!==process.env.NODE_ENV&&b(`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,s=!1){const i=ke(e=e.__v_raw),r=ke(t);n||(t!==r&&z(i,"get",t),z(i,"get",r));const{has:o}=X(i),a=s?Q:n?Ne:Oe;return o.call(i,t)?a(e.get(t)):o.call(i,r)?a(e.get(r)):void(e!==i&&e.get(t))}function Z(e,t=!1){const n=this.__v_raw,s=ke(n),i=ke(e);return t||(e!==i&&z(s,"has",e),z(s,"has",i)),e===i?n.has(e):n.has(e)||n.has(i)}function ee(e,t=!1){return e=e.__v_raw,!t&&z(ke(e),"iterate",x),Reflect.get(e,"size",e)}function te(e){e=ke(e);const t=ke(this);return X(t).has.call(t,e)||(t.add(e),V(t,"add",e,e)),this}function ne(e,t){t=ke(t);const n=ke(this),{has:s,get:i}=X(n);let r=s.call(n,e);r?"production"!==process.env.NODE_ENV&&we(n,s,e):(e=ke(e),r=s.call(n,e));const o=i.call(n,e);return n.set(e,t),r?m(t,o)&&V(n,"set",e,t,o):V(n,"add",e,t),this}function se(e){const t=ke(this),{has:n,get:s}=X(t);let i=n.call(t,e);i?"production"!==process.env.NODE_ENV&&we(t,n,e):(e=ke(e),i=n.call(t,e));const r=s?s.call(t,e):void 0,o=t.delete(e);return i&&V(t,"delete",e,void 0,r),o}function ie(){const e=ke(this),t=0!==e.size,n="production"!==process.env.NODE_ENV?f(e)?new Map(e):new Set(e):void 0,s=e.clear();return t&&V(e,"clear",void 0,void 0,n),s}function re(e,t){return function(n,s){const i=this,r=i.__v_raw,o=ke(r),a=t?Q:e?Ne:Oe;return!e&&z(o,"iterate",x),r.forEach(((e,t)=>n.call(s,a(e),a(t),i)))}}function oe(e,t,n){return function(...s){const i=this.__v_raw,r=ke(i),o=f(r),a="entries"===e||e===Symbol.iterator&&o,c="keys"===e&&o,l=i[e](...s),h=n?Q:t?Ne:Oe;return!t&&z(r,"iterate",c?W:x),{next(){const{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:a?[h(e[0]),h(e[1])]:h(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(`${g(e)} operation ${n}failed: target is readonly.`,ke(this))}return"delete"!==e&&this}}const[ce,le,he,fe]=function(){const e={get(e){return Y(this,e)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:se,clear:ie,forEach:re(!1,!1)},t={get(e){return Y(this,e,!1,!0)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:se,clear:ie,forEach:re(!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:re(!0,!1)},s={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:re(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{e[i]=oe(i,!1,!1),n[i]=oe(i,!0,!1),t[i]=oe(i,!1,!0),s[i]=oe(i,!0,!0)})),[e,n,t,s]}();function ue(e,t){const n=t?e?fe:he:e?le:ce;return(t,s,i)=>"__v_isReactive"===s?!e:"__v_isReadonly"===s?e:"__v_raw"===s?t:Reflect.get(l(n,s)&&s in t?n:t,s,i)}const de={get:ue(!1,!1)},pe={get:ue(!0,!1)};function we(e,t,n){const s=ke(n);if(s!==n&&t.call(e,s)){const t=v(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 ve=new WeakMap,ye=new WeakMap,ge=new WeakMap,me=new WeakMap;function Ee(e){return Se(e)?e:_e(e,!1,K,de,ve)}function be(e){return _e(e,!0,q,pe,ge)}function _e(e,t,n,s,i){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 r=i.get(e);if(r)return r;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}}(v(a));var a;if(0===o)return e;const c=new Proxy(e,2===o?s:n);return i.set(e,c),c}function Se(e){return!(!e||!e.__v_isReadonly)}function ke(e){const t=e&&e.__v_raw;return t?ke(t):e}const Oe=e=>d(e)?Ee(e):e,Ne=e=>d(e)?be(e):e;function Ae(e){return!(!e||!0!==e.__v_isRef)}const Re=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`,$e=e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but the listener hasn't been registed`,je=e=>`[@rallie/core] one of the callbacks of the broadcast event ${e} throws an uncaught error`,Me=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`,xe=e=>`[@rallie/core] you are trying to register a unicast event ${e}, but it has been registered before`,We=e=>`[@rallie/core] you have emitted ${e} unicast, but there is no listener of this event`,Pe=e=>`[@rallie/core] ${e} is existing, you are not allowed to create it again`,Be=(e,t)=>`[@rallie/core] can not find any assets of the app ${e} on the bus ${t}`,Te=e=>`[@rallie/core] you are trying to activate app ${e}, but it was not created`,Le=e=>`[@rallie/core] state ${e} is private, you are not allowed to set it`,ze=e=>`[@rallie/core] please describe your action when you modify the state ${e}`,Ve=e=>`[@rallie/core] it's not allowed to set or watch state ${e} before it is initialized`,Ue=e=>`[@rallie/core] duplicated initialized state ${e}`,De=e=>`[@rallie/core] it's not allowed to initialized state ${e} to a primitive value`,Ie=e=>`[@rallie/core] the bus named ${e} has been defined before, please rename your bus`,Ce=(e,t)=>`[@rallie/core] There is a circular dependency when activating the app ${e}, and the circular path is ${t.join("->")}`,Ge=()=>"[@rallie/core] next() called multiple times in the middleware",Fe=()=>"[@rallie/core] the middleware must be a function",He=(e,t)=>`[@rallie/core] the event ${e} is not in the events pool that you specified when calling on${t?"Unicast":"Broadcast"}`,Je=e=>(t,n)=>{let s=-1;const i=r=>{if(r<=s)return Promise.reject(new Error(Ge()));s=r;let o=e[r];if(r===e.length&&(o=n),!o)return Promise.resolve();try{return Promise.resolve(o(t,i.bind(null,r+1)))}catch(e){return Promise.reject(e)}};return i(0)};var Ke,qe,Qe,Xe,Ye,Ze,et,tt,nt;class st{constructor(){Ke.set(this,{}),qe.set(this,{})}addBroadcastEventListener(e,t){r(this,Ke,"f")[e]=r(this,Ke,"f")[e]||new Set,r(this,Ke,"f")[e].add(t)}addUnicastEventListener(e,t){if(r(this,qe,"f")[e])throw new Error(xe(e));r(this,qe,"f")[e]=t}removeBroadcastEventListener(e,t){const n=r(this,Ke,"f")[e];if(!n){const t=Re(e);throw new Error(t)}if(!n.has(t)){const t=$e(e);throw new Error(t)}n.delete(t)}removeUnicastEventListener(e){if(!r(this,qe,"f")[e]){const t=Me(e);throw new Error(t)}delete r(this,qe,"f")[e]}emitBroadcast(e,...t){r(this,Ke,"f")[e]=r(this,Ke,"f")[e]||new Set,r(this,Ke,"f")[e].forEach((n=>{try{n(...t)}catch(n){console.error(je(e)),console.error(n)}}))}emitUnicast(e,...t){const n=r(this,qe,"f")[e];if(n)return n(...t);throw new Error(We(e))}}Ke=new WeakMap,qe=new WeakMap;class it{constructor(e,t){Qe.set(this,void 0),Xe.set(this,void 0),o(this,Qe,e,"f"),o(this,Xe,t,"f"),r(this,Xe,"f")[e].watchers.add(this)}do(e){return this.handler=e,()=>this.unwatch()}unwatch(){null==this||this.stopEffect(),this.handler=null;const e=r(this,Xe,"f")[r(this,Qe,"f")].watchers;e.has(this)&&e.delete(this)}}Qe=new WeakMap,Xe=new WeakMap;class rt{constructor(e,t){Ye.add(this),Ze.set(this,void 0),et.set(this,void 0),o(this,Ze,e,"f"),o(this,et,t,"f")}onBroadcast(e){return Object.entries(e).forEach((([e,t])=>{r(this,Ze,"f").addBroadcastEventListener(e,t)})),t=>{r(this,Ye,"m",tt).call(this,e,!1,t)}}onUnicast(e){return Object.entries(e).forEach((([e,t])=>{try{r(this,Ze,"f").addUnicastEventListener(e,t)}catch(e){console.error(e)}})),t=>{r(this,Ye,"m",tt).call(this,e,!0,t)}}createBroadcaster(e){return new Proxy({},{get:(t,n)=>(...t)=>r(this,Ze,"f").emitBroadcast(n,...t,null==e?void 0:e(n)),set:()=>!1})}createUnicaster(e){return new Proxy({},{get:(t,n)=>(...t)=>r(this,Ze,"f").emitUnicast(n,...t,null==e?void 0:e(n)),set:()=>!1})}existState(e){return!!r(this,et,"f")[e]}initState(e,t,n=!1){if(this.existState(e))throw new Error(Ue(e));if(["string","number","boolean","undefined"].includes(typeof t))throw new Error(De(e));return r(this,et,"f")[e]={state:Ee(t),owner:n?this:null,watchers:new Set},r(this,Ze,"f").emitBroadcast("$state-initialized",e),this.getState(e)}getState(e,t){if(this.existState(e)){const n=be(r(this,et,"f")[e].state);return t?t(n):n}return null}setState(e,t,n){return i(this,void 0,void 0,(function*(){const s=r(this,Ye,"m",nt).call(this,e);if(!t)throw new Error(ze(e));{const e=n(s);yield Promise.resolve(e)}}))}watchState(e,t){if(!this.existState(e)){const t=Ve(e);throw new Error(t)}let n=!1;const s=be(r(this,et,"f")[e].state),i=new it(e,r(this,et,"f")),o=function(e,t){e.effect&&(e=e.effect.fn);const n=new P(e);t&&(a(n,t),t.scope&&S(n,t.scope)),t&&t.lazy||n.run();const s=n.run.bind(n);return s.effect=n,s}((()=>t(s)),{lazy:!0,scheduler:()=>{n||(n=!0,Promise.resolve().then((()=>{var e;const r=ke(t(s));null===(e=i.handler)||void 0===e||e.call(i,r,i.oldWatchingStates),i.oldWatchingStates=ke(r),n=!1})))}});return i.oldWatchingStates=o(),i.stopEffect=()=>o.effect.stop(),i}}Ze=new WeakMap,et=new WeakMap,Ye=new WeakSet,tt=function(e,t,n){let s=t?r(this,Ze,"f").removeUnicastEventListener:r(this,Ze,"f").removeBroadcastEventListener;s=s.bind(r(this,Ze,"f")),n?e[n]?(s(n,e[n]),delete e[n]):console.warn(He(n,t)):Object.entries(e).forEach((([e,t])=>{s(e,t)}))},nt=function(e){if(!this.existState(e)){const t=Ve(e);throw new Error(t)}const t=r(this,et,"f")[e].owner;if(t!==this&&null!==t){const t=Le(e);throw new Error(t)}return r(this,et,"f")[e].state};class ot{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 at,ct,lt,ht,ft,ut,dt,pt,wt,vt,yt,gt,mt,Et,bt={loadScript:e=>i(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 _t{constructor(e){at.add(this),ct.set(this,void 0),lt.set(this,new st),ht.set(this,{}),ft.set(this,{}),ut.set(this,{}),this.conf=be({assets:{}}),dt.set(this,[]),pt.set(this,void 0),o(this,ct,e,"f"),o(this,pt,Je(r(this,dt,"f")),"f")}createSocket(){return new rt(r(this,lt,"f"),r(this,ht,"f"))}existApp(e){return!!r(this,ft,"f")[e]}createApp(e){if(this.existApp(e))throw new Error(Pe(e));const t=new ot(e);return r(this,ft,"f")[e]=t,t}loadApp(e){return i(this,void 0,void 0,(function*(){r(this,ft,"f")[e]||(r(this,ut,"f")[e]||(r(this,ut,"f")[e]=new Promise(((t,n)=>{const s=r(this,at,"m",vt).call(this,e);r(this,pt,"f").call(this,s,r(this,at,"m",yt).bind(this)).then((()=>{e.startsWith("lib:")&&!r(this,ft,"f")[e]&&(r(this,ft,"f")[e]=!0),r(this,ft,"f")[e]||n(new Error(Te(e))),t()})).catch((e=>{n(e)}))}))),yield r(this,ut,"f")[e])}))}activateApp(e){return i(this,void 0,void 0,(function*(){yield r(this,at,"m",gt).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(Fe());return r(this,dt,"f").push(e),o(this,pt,Je(r(this,dt,"f")),"f"),this}}ct=new WeakMap,lt=new WeakMap,ht=new WeakMap,ft=new WeakMap,ut=new WeakMap,dt=new WeakMap,pt=new WeakMap,at=new WeakSet,wt=function(e){return r(this,ft,"f")[e]&&"boolean"!=typeof r(this,ft,"f")[e]},vt=function(e){return{name:e,loadScript:bt.loadScript,loadLink:bt.loadLink}},yt=function(e){return i(this,void 0,void 0,(function*(){const{name:t,loadScript:n=bt.loadScript,loadLink:s=bt.loadLink}=e,{assets:i}=this.conf;if(!i[t])throw new Error(Be(t,r(this,ct,"f")));if(i[t].css&&i[t].css.forEach((e=>{s(e)})),i[t].js)for(const e of i[t].js)yield n(e)}))},gt=function(e,t){return i(this,void 0,void 0,(function*(){if(yield this.loadApp(e),r(this,at,"m",wt).call(this,e)){const n=r(this,ft,"f")[e];if(yield r(this,at,"m",Et).call(this,n),t.includes(e)){const n=t.indexOf(e),s=[...t.slice(n),e];throw new Error(Ce(e,s))}if(t.push(e),!n.activated){const e=()=>i(this,void 0,void 0,(function*(){yield r(this,at,"m",mt).call(this,n,t),n.doActivate&&(yield Promise.resolve(n.doActivate()))}));n.activated=e()}yield n.activated,t.pop()}}))},mt=function(e,t){return i(this,void 0,void 0,(function*(){if(0!==e.dependencies.length)for(const n of e.dependencies)yield r(this,at,"m",gt).call(this,n,t)}))},Et=function(e){return i(this,void 0,void 0,(function*(){yield Promise.all(e.relatedApps.map((e=>this.loadApp(e))))}))};const St={},kt="DEFAULT_BUS",Ot=(e=kt)=>{let t=null,n=!1;const s=((e=kt)=>window.RALLIE_BUS_STORE&&window.RALLIE_BUS_STORE[e])(e);return s?(t=s,n=!1):(t=((e=kt)=>{if(void 0===window.RALLIE_BUS_STORE&&Reflect.defineProperty(window,"RALLIE_BUS_STORE",{value:St,writable:!1}),window.RALLIE_BUS_STORE[e])throw new Error(Ie(e));{const t=new _t(e);return Reflect.defineProperty(window.RALLIE_BUS_STORE,e,{value:t,writable:!1}),t}})(e),n=!0),[t,n]},Nt={privateBus:e=>`${e}.bus`,stateNamespace:e=>`${e}.state`,isGlobalBusAccessible:"isGlobalBusAccessible",exportMethodName:"__RallieInnerExport__"},At=e=>`[rallie] ${e}`,Rt={stateNotInitialized:e=>At(` the block ${e}'s state is not initialized, please check:\n1. whether the block ${e} is loaded.\n2. whether the block ${e} has initialized the state`),duplicatedBlockName:e=>At(`the block ${e} is already registered before, please rename your block`),stateIsReadonly:e=>At(`the state of ${e} is readonly`)};var $t,jt,Mt,xt,Wt,Pt,Bt;class Tt{constructor(e,t,i){$t.set(this,void 0),this.name=e,s(this,$t,i,"f"),this.events=n(this,$t,"f").createBroadcaster((()=>t)),this.methods=n(this,$t,"f").createUnicaster((()=>t)),Reflect.defineProperty(this,"state",{get:()=>n(this,$t,"f").getState(Nt.stateNamespace(this.name)),set:()=>{throw new Error(Rt.stateIsReadonly(this.name))}})}setState(e,t){if(n(this,$t,"f").existState(Nt.stateNamespace(this.name)))return n(this,$t,"f").setState(Nt.stateNamespace(this.name),e,t);throw new Error(Rt.stateNotInitialized(this.name))}watchState(e){if(n(this,$t,"f").existState(Nt.stateNamespace(this.name)))return n(this,$t,"f").watchState(Nt.stateNamespace(this.name),e);throw new Error(Rt.stateNotInitialized(this.name))}listenEvents(e){return n(this,$t,"f").onBroadcast(e)}}$t=new WeakMap;class Lt extends Tt{constructor(e,t,n,i){const[r]=Ot(Nt.privateBus(e)),o=r.createSocket();super(e,e,o),jt.set(this,void 0),Mt.set(this,void 0),xt.set(this,void 0),Wt.set(this,void 0),Pt.set(this,void 0),Bt.set(this,{}),s(this,Wt,o,"f"),s(this,jt,t,"f"),s(this,Mt,n,"f"),s(this,Pt,t.createApp(e),"f"),s(this,xt,i,"f")}initState(e,t){return n(this,Wt,"f").initState(Nt.stateNamespace(this.name),e,t),this}addMethods(e){return n(this,Wt,"f").onUnicast(e)}relyOn(e){return n(this,Pt,"f").relyOn(e),this}relateTo(e){return n(this,Pt,"f").relateTo(e),this}onActivate(e){return n(this,Pt,"f").onActivate(e),this}connect(e){if(!n(this,Bt,"f")[e]){const[t]=Ot(Nt.privateBus(e)),s=t.createSocket();n(this,Bt,"f")[e]=new Tt(e,this.name,s)}return n(this,Bt,"f")[e]}load(e){return n(this,jt,"f").loadApp(e)}activate(e){return n(this,jt,"f").activateApp(e)}run(e){var s;return t(this,void 0,void 0,(function*(){const t=n(this,xt,"f")||(null===(s=n(this,Mt,"f").getState(Nt.isGlobalBusAccessible))||void 0===s?void 0:s.value),i=e=>{n(this,xt,"f")&&n(this,Mt,"f").setState(Nt.isGlobalBusAccessible,e?"unfreeze the enviroment":"freeze the enviroment",(t=>{t.value=e}))},r={isEntry:n(this,xt,"f"),use:e=>{t&&n(this,jt,"f").use(e)},config:e=>{t&&n(this,jt,"f").config(e)},freeze:()=>{i(!1)},unfreeze:()=>{i(!0)}},o=e(new Proxy(r,{get:(e,t,s)=>"conf"===t?JSON.parse(JSON.stringify(n(this,jt,"f").conf)):Reflect.get(e,t,s),set:()=>!1}));yield Promise.resolve(o)}))}}jt=new WeakMap,Mt=new WeakMap,xt=new WeakMap,Wt=new WeakMap,Pt=new WeakMap,Bt=new WeakMap,e.createBlock=function(e){const[t,n]=Ot();if(t.existApp(e))throw new Error(Rt.duplicatedBlockName(e));const s=t.createSocket();return n&&s.initState(Nt.isGlobalBusAccessible,{value:!0},!0),new Lt(e,t,s,n)}})); | ||
!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).RallieBlock={})}(this,(function(e){"use strict";function t(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function n(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function s(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}function i(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function r(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function o(e,t,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,n):i?i.value=n:t.set(e,n),n}"production"===process.env.NODE_ENV||Object.freeze({}),"production"===process.env.NODE_ENV||Object.freeze([]);const a=Object.assign,c=Object.prototype.hasOwnProperty,l=(e,t)=>c.call(e,t),h=Array.isArray,f=e=>"[object Map]"===w(e),u=e=>"symbol"==typeof e,d=e=>null!==e&&"object"==typeof e,p=Object.prototype.toString,w=e=>p.call(e),v=e=>w(e).slice(8,-1),y=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,g=(e=>{const t=Object.create(null);return e=>t[e]||(t[e]=(e=>e.charAt(0).toUpperCase()+e.slice(1))(e))})(),m=(e,t)=>!Object.is(e,t),E=e=>{const t=parseFloat(e);return isNaN(t)?e:t};function b(e,...t){console.warn(`[Vue warn] ${e}`,...t)}let _;function S(e,t=_){t&&t.active&&t.effects.push(e)}const k=e=>{const t=new Set(e);return t.w=0,t.n=0,t},O=e=>(e.w&$)>0,N=e=>(e.n&$)>0,A=new WeakMap;let R=0,$=1;const j=30;let M;const x=Symbol("production"!==process.env.NODE_ENV?"iterate":""),W=Symbol("production"!==process.env.NODE_ENV?"Map key iterate":"");class P{constructor(e,t=null,n){this.fn=e,this.scheduler=t,this.active=!0,this.deps=[],this.parent=void 0,S(this,n)}run(){if(!this.active)return this.fn();let e=M,t=T;for(;e;){if(e===this)return;e=e.parent}try{return this.parent=M,M=this,T=!0,$=1<<++R,R<=j?(({deps:e})=>{if(e.length)for(let t=0;t<e.length;t++)e[t].w|=$})(this):B(this),this.fn()}finally{R<=j&&(e=>{const{deps:t}=e;if(t.length){let n=0;for(let s=0;s<t.length;s++){const i=t[s];O(i)&&!N(i)?i.delete(e):t[n++]=i,i.w&=~$,i.n&=~$}t.length=n}})(this),$=1<<--R,M=this.parent,T=t,this.parent=void 0,this.deferStop&&this.stop()}}stop(){M===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 T=!0;const L=[];function z(e,t,n){if(T&&M){let s=A.get(e);s||A.set(e,s=new Map);let i=s.get(n);i||s.set(n,i=k()),function(e,t){let n=!1;R<=j?N(e)||(e.n|=$,n=!O(e)):n=!e.has(M),n&&(e.add(M),M.deps.push(e),"production"!==process.env.NODE_ENV&&M.onTrack&&M.onTrack(Object.assign({effect:M},t)))}(i,"production"!==process.env.NODE_ENV?{effect:M,target:e,type:t,key:n}:void 0)}}function V(e,t,n,s,i,r){const o=A.get(e);if(!o)return;let a=[];if("clear"===t)a=[...o.values()];else if("length"===n&&h(e)){const e=E(s);o.forEach(((t,n)=>{("length"===n||n>=e)&&a.push(t)}))}else switch(void 0!==n&&a.push(o.get(n)),t){case"add":h(e)?y(n)&&a.push(o.get("length")):(a.push(o.get(x)),f(e)&&a.push(o.get(W)));break;case"delete":h(e)||(a.push(o.get(x)),f(e)&&a.push(o.get(W)));break;case"set":f(e)&&a.push(o.get(x))}const c="production"!==process.env.NODE_ENV?{target:e,type:t,key:n,newValue:s,oldValue:i,oldTarget:r}:void 0;if(1===a.length)a[0]&&("production"!==process.env.NODE_ENV?U(a[0],c):U(a[0]));else{const e=[];for(const t of a)t&&e.push(...t);"production"!==process.env.NODE_ENV?U(k(e),c):U(k(e))}}function U(e,t){const n=h(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!==M||e.allowRecurse)&&("production"!==process.env.NODE_ENV&&e.onTrigger&&e.onTrigger(a({effect:e},t)),e.scheduler?e.scheduler():e.run())}const I=function(e,t){const n=Object.create(null),s=e.split(",");for(let e=0;e<s.length;e++)n[s[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}("__proto__,__v_isRef,__isVue"),C=new Set(Object.getOwnPropertyNames(Symbol).filter((e=>"arguments"!==e&&"caller"!==e)).map((e=>Symbol[e])).filter(u)),G=J(),F=J(!0),H=function(){const e={};return["includes","indexOf","lastIndexOf"].forEach((t=>{e[t]=function(...e){const n=ke(this);for(let e=0,t=this.length;e<t;e++)z(n,"get",e+"");const s=n[t](...e);return-1===s||!1===s?n[t](...e.map(ke)):s}})),["push","pop","shift","unshift","splice"].forEach((t=>{e[t]=function(...e){L.push(T),T=!1;const n=ke(this)[t].apply(this,e);return function(){const e=L.pop();T=void 0===e||e}(),n}})),e}();function J(e=!1,t=!1){return function(n,s,i){if("__v_isReactive"===s)return!e;if("__v_isReadonly"===s)return e;if("__v_isShallow"===s)return t;if("__v_raw"===s&&i===(e?t?me:ge:t?ye:ve).get(n))return n;const r=h(n);if(!e&&r&&l(H,s))return Reflect.get(H,s,i);const o=Reflect.get(n,s,i);return(u(s)?C.has(s):I(s))?o:(e||z(n,"get",s),t?o:Ae(o)?r&&y(s)?o:o.value:d(o)?e?be(o):Ee(o):o)}}const K={get:G,set:function(e=!1){return function(t,n,s,i){let r=t[n];if(Se(r)&&Ae(r)&&!Ae(s))return!1;if(!e&&(function(e){return!(!e||!e.__v_isShallow)}(s)||Se(s)||(r=ke(r),s=ke(s)),!h(t)&&Ae(r)&&!Ae(s)))return r.value=s,!0;const o=h(t)&&y(n)?Number(n)<t.length:l(t,n),a=Reflect.set(t,n,s,i);return t===ke(i)&&(o?m(s,r)&&V(t,"set",n,s,r):V(t,"add",n,s)),a}}(),deleteProperty:function(e,t){const n=l(e,t),s=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&V(e,"delete",t,void 0,s),i},has:function(e,t){const n=Reflect.has(e,t);return u(t)&&C.has(t)||z(e,"has",t),n},ownKeys:function(e){return z(e,"iterate",h(e)?"length":x),Reflect.ownKeys(e)}},q={get:F,set:(e,t)=>("production"!==process.env.NODE_ENV&&b(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0),deleteProperty:(e,t)=>("production"!==process.env.NODE_ENV&&b(`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,s=!1){const i=ke(e=e.__v_raw),r=ke(t);n||(t!==r&&z(i,"get",t),z(i,"get",r));const{has:o}=X(i),a=s?Q:n?Ne:Oe;return o.call(i,t)?a(e.get(t)):o.call(i,r)?a(e.get(r)):void(e!==i&&e.get(t))}function Z(e,t=!1){const n=this.__v_raw,s=ke(n),i=ke(e);return t||(e!==i&&z(s,"has",e),z(s,"has",i)),e===i?n.has(e):n.has(e)||n.has(i)}function ee(e,t=!1){return e=e.__v_raw,!t&&z(ke(e),"iterate",x),Reflect.get(e,"size",e)}function te(e){e=ke(e);const t=ke(this);return X(t).has.call(t,e)||(t.add(e),V(t,"add",e,e)),this}function ne(e,t){t=ke(t);const n=ke(this),{has:s,get:i}=X(n);let r=s.call(n,e);r?"production"!==process.env.NODE_ENV&&we(n,s,e):(e=ke(e),r=s.call(n,e));const o=i.call(n,e);return n.set(e,t),r?m(t,o)&&V(n,"set",e,t,o):V(n,"add",e,t),this}function se(e){const t=ke(this),{has:n,get:s}=X(t);let i=n.call(t,e);i?"production"!==process.env.NODE_ENV&&we(t,n,e):(e=ke(e),i=n.call(t,e));const r=s?s.call(t,e):void 0,o=t.delete(e);return i&&V(t,"delete",e,void 0,r),o}function ie(){const e=ke(this),t=0!==e.size,n="production"!==process.env.NODE_ENV?f(e)?new Map(e):new Set(e):void 0,s=e.clear();return t&&V(e,"clear",void 0,void 0,n),s}function re(e,t){return function(n,s){const i=this,r=i.__v_raw,o=ke(r),a=t?Q:e?Ne:Oe;return!e&&z(o,"iterate",x),r.forEach(((e,t)=>n.call(s,a(e),a(t),i)))}}function oe(e,t,n){return function(...s){const i=this.__v_raw,r=ke(i),o=f(r),a="entries"===e||e===Symbol.iterator&&o,c="keys"===e&&o,l=i[e](...s),h=n?Q:t?Ne:Oe;return!t&&z(r,"iterate",c?W:x),{next(){const{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:a?[h(e[0]),h(e[1])]:h(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(`${g(e)} operation ${n}failed: target is readonly.`,ke(this))}return"delete"!==e&&this}}const[ce,le,he,fe]=function(){const e={get(e){return Y(this,e)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:se,clear:ie,forEach:re(!1,!1)},t={get(e){return Y(this,e,!1,!0)},get size(){return ee(this)},has:Z,add:te,set:ne,delete:se,clear:ie,forEach:re(!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:re(!0,!1)},s={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:re(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{e[i]=oe(i,!1,!1),n[i]=oe(i,!0,!1),t[i]=oe(i,!1,!0),s[i]=oe(i,!0,!0)})),[e,n,t,s]}();function ue(e,t){const n=t?e?fe:he:e?le:ce;return(t,s,i)=>"__v_isReactive"===s?!e:"__v_isReadonly"===s?e:"__v_raw"===s?t:Reflect.get(l(n,s)&&s in t?n:t,s,i)}const de={get:ue(!1,!1)},pe={get:ue(!0,!1)};function we(e,t,n){const s=ke(n);if(s!==n&&t.call(e,s)){const t=v(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 ve=new WeakMap,ye=new WeakMap,ge=new WeakMap,me=new WeakMap;function Ee(e){return Se(e)?e:_e(e,!1,K,de,ve)}function be(e){return _e(e,!0,q,pe,ge)}function _e(e,t,n,s,i){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 r=i.get(e);if(r)return r;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}}(v(a));var a;if(0===o)return e;const c=new Proxy(e,2===o?s:n);return i.set(e,c),c}function Se(e){return!(!e||!e.__v_isReadonly)}function ke(e){const t=e&&e.__v_raw;return t?ke(t):e}const Oe=e=>d(e)?Ee(e):e,Ne=e=>d(e)?be(e):e;function Ae(e){return!(!e||!0!==e.__v_isRef)}const Re=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`,$e=e=>`[@rallie/core] you are trying to remove a listener of the broadcast event ${e}, but the listener hasn't been registed`,je=e=>`[@rallie/core] one of the callbacks of the broadcast event ${e} throws an uncaught error`,Me=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`,xe=e=>`[@rallie/core] you are trying to register a unicast event ${e}, but it has been registered before`,We=e=>`[@rallie/core] you have emitted ${e} unicast, but there is no listener of this event`,Pe=e=>`[@rallie/core] ${e} is existing, you are not allowed to create it again`,Be=(e,t)=>`[@rallie/core] can not find any assets of the app ${e} on the bus ${t}`,Te=e=>`[@rallie/core] you are trying to activate app ${e}, but it was not created`,Le=e=>`[@rallie/core] state ${e} is private, you are not allowed to set it`,ze=e=>`[@rallie/core] please describe your action when you modify the state ${e}`,Ve=e=>`[@rallie/core] it's not allowed to set or watch state ${e} before it is initialized`,Ue=e=>`[@rallie/core] duplicated initialized state ${e}`,De=e=>`[@rallie/core] it's not allowed to initialized state ${e} to a primitive value`,Ie=e=>`[@rallie/core] the bus named ${e} has been defined before, please rename your bus`,Ce=(e,t)=>`[@rallie/core] There is a circular dependency when activating the app ${e}, and the circular path is ${t.join("->")}`,Ge=()=>"[@rallie/core] next() called multiple times in the middleware",Fe=()=>"[@rallie/core] the middleware must be a function",He=(e,t)=>`[@rallie/core] the event ${e} is not in the events pool that you specified when calling on${t?"Unicast":"Broadcast"}`,Je=e=>(t,n)=>{let s=-1;const i=r=>{if(r<=s)return Promise.reject(new Error(Ge()));s=r;let o=e[r];if(r===e.length&&(o=n),!o)return Promise.resolve();try{return Promise.resolve(o(t,i.bind(null,r+1)))}catch(e){return Promise.reject(e)}};return i(0)};var Ke,qe,Qe,Xe,Ye,Ze,et,tt,nt;class st{constructor(){Ke.set(this,{}),qe.set(this,{})}addBroadcastEventListener(e,t){r(this,Ke,"f")[e]=r(this,Ke,"f")[e]||new Set,r(this,Ke,"f")[e].add(t)}addUnicastEventListener(e,t){if(r(this,qe,"f")[e])throw new Error(xe(e));r(this,qe,"f")[e]=t}removeBroadcastEventListener(e,t){const n=r(this,Ke,"f")[e];if(!n){const t=Re(e);throw new Error(t)}if(!n.has(t)){const t=$e(e);throw new Error(t)}n.delete(t)}removeUnicastEventListener(e){if(!r(this,qe,"f")[e]){const t=Me(e);throw new Error(t)}delete r(this,qe,"f")[e]}emitBroadcast(e,...t){r(this,Ke,"f")[e]=r(this,Ke,"f")[e]||new Set,r(this,Ke,"f")[e].forEach((n=>{try{n(...t)}catch(n){console.error(je(e)),console.error(n)}}))}emitUnicast(e,...t){const n=r(this,qe,"f")[e];if(n)return n(...t);throw new Error(We(e))}}Ke=new WeakMap,qe=new WeakMap;class it{constructor(e,t){Qe.set(this,void 0),Xe.set(this,void 0),o(this,Qe,e,"f"),o(this,Xe,t,"f"),r(this,Xe,"f")[e].watchers.add(this)}do(e){return this.handler=e,()=>this.unwatch()}unwatch(){null==this||this.stopEffect(),this.handler=null;const e=r(this,Xe,"f")[r(this,Qe,"f")].watchers;e.has(this)&&e.delete(this)}}Qe=new WeakMap,Xe=new WeakMap;class rt{constructor(e,t){Ye.add(this),Ze.set(this,void 0),et.set(this,void 0),o(this,Ze,e,"f"),o(this,et,t,"f")}onBroadcast(e){return Object.entries(e).forEach((([e,t])=>{r(this,Ze,"f").addBroadcastEventListener(e,t)})),t=>{r(this,Ye,"m",tt).call(this,e,!1,t)}}onUnicast(e){return Object.entries(e).forEach((([e,t])=>{try{r(this,Ze,"f").addUnicastEventListener(e,t)}catch(e){console.error(e)}})),t=>{r(this,Ye,"m",tt).call(this,e,!0,t)}}createBroadcaster(e){return new Proxy({},{get:(t,n)=>(...t)=>(null==e||e(n),r(this,Ze,"f").emitBroadcast(n,...t)),set:()=>!1})}createUnicaster(e){return new Proxy({},{get:(t,n)=>(...t)=>(null==e||e(n),r(this,Ze,"f").emitUnicast(n,...t)),set:()=>!1})}existState(e){return!!r(this,et,"f")[e]}initState(e,t,n=!1){if(this.existState(e))throw new Error(Ue(e));if(["string","number","boolean","undefined"].includes(typeof t))throw new Error(De(e));return r(this,et,"f")[e]={state:Ee(t),owner:n?this:null,watchers:new Set},r(this,Ze,"f").emitBroadcast("$state-initialized",e),this.getState(e)}getState(e,t){if(this.existState(e)){const n=be(r(this,et,"f")[e].state);return t?t(n):n}return null}setState(e,t,n){return i(this,void 0,void 0,(function*(){const s=r(this,Ye,"m",nt).call(this,e);if(!t)throw new Error(ze(e));{const e=n(s);yield Promise.resolve(e)}}))}watchState(e,t){if(!this.existState(e)){const t=Ve(e);throw new Error(t)}let n=!1;const s=be(r(this,et,"f")[e].state),i=new it(e,r(this,et,"f")),o=function(e,t){e.effect&&(e=e.effect.fn);const n=new P(e);t&&(a(n,t),t.scope&&S(n,t.scope)),t&&t.lazy||n.run();const s=n.run.bind(n);return s.effect=n,s}((()=>t(s)),{lazy:!0,scheduler:()=>{n||(n=!0,Promise.resolve().then((()=>{var e;const r=ke(t(s));null===(e=i.handler)||void 0===e||e.call(i,r,i.oldWatchingStates),i.oldWatchingStates=ke(r),n=!1})))}});return i.oldWatchingStates=o(),i.stopEffect=()=>o.effect.stop(),i}}Ze=new WeakMap,et=new WeakMap,Ye=new WeakSet,tt=function(e,t,n){let s=t?r(this,Ze,"f").removeUnicastEventListener:r(this,Ze,"f").removeBroadcastEventListener;s=s.bind(r(this,Ze,"f")),n?e[n]?(s(n,e[n]),delete e[n]):console.warn(He(n,t)):Object.entries(e).forEach((([e,t])=>{s(e,t)}))},nt=function(e){if(!this.existState(e)){const t=Ve(e);throw new Error(t)}const t=r(this,et,"f")[e].owner;if(t!==this&&null!==t){const t=Le(e);throw new Error(t)}return r(this,et,"f")[e].state};class ot{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 at,ct,lt,ht,ft,ut,dt,pt,wt,vt,yt,gt,mt,Et,bt={loadScript:e=>i(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 _t{constructor(e){at.add(this),ct.set(this,void 0),lt.set(this,new st),ht.set(this,{}),ft.set(this,{}),ut.set(this,{}),this.conf=be({assets:{}}),dt.set(this,[]),pt.set(this,void 0),o(this,ct,e,"f"),o(this,pt,Je(r(this,dt,"f")),"f")}createSocket(){return new rt(r(this,lt,"f"),r(this,ht,"f"))}existApp(e){return!!r(this,ft,"f")[e]}createApp(e){if(this.existApp(e))throw new Error(Pe(e));const t=new ot(e);return r(this,ft,"f")[e]=t,t}loadApp(e){return i(this,void 0,void 0,(function*(){r(this,ft,"f")[e]||(r(this,ut,"f")[e]||(r(this,ut,"f")[e]=new Promise(((t,n)=>{const s=r(this,at,"m",vt).call(this,e);r(this,pt,"f").call(this,s,r(this,at,"m",yt).bind(this)).then((()=>{e.startsWith("lib:")&&!r(this,ft,"f")[e]&&(r(this,ft,"f")[e]=!0),r(this,ft,"f")[e]||n(new Error(Te(e))),t()})).catch((e=>{n(e)}))}))),yield r(this,ut,"f")[e])}))}activateApp(e){return i(this,void 0,void 0,(function*(){yield r(this,at,"m",gt).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(Fe());return r(this,dt,"f").push(e),o(this,pt,Je(r(this,dt,"f")),"f"),this}}ct=new WeakMap,lt=new WeakMap,ht=new WeakMap,ft=new WeakMap,ut=new WeakMap,dt=new WeakMap,pt=new WeakMap,at=new WeakSet,wt=function(e){return r(this,ft,"f")[e]&&"boolean"!=typeof r(this,ft,"f")[e]},vt=function(e){return{name:e,loadScript:bt.loadScript,loadLink:bt.loadLink}},yt=function(e){return i(this,void 0,void 0,(function*(){const{name:t,loadScript:n=bt.loadScript,loadLink:s=bt.loadLink}=e,{assets:i}=this.conf;if(!i[t])throw new Error(Be(t,r(this,ct,"f")));if(i[t].css&&i[t].css.forEach((e=>{s(e)})),i[t].js)for(const e of i[t].js)yield n(e)}))},gt=function(e,t){return i(this,void 0,void 0,(function*(){if(yield this.loadApp(e),r(this,at,"m",wt).call(this,e)){const n=r(this,ft,"f")[e];if(yield r(this,at,"m",Et).call(this,n),t.includes(e)){const n=t.indexOf(e),s=[...t.slice(n),e];throw new Error(Ce(e,s))}if(t.push(e),!n.activated){const e=()=>i(this,void 0,void 0,(function*(){yield r(this,at,"m",mt).call(this,n,t),n.doActivate&&(yield Promise.resolve(n.doActivate()))}));n.activated=e()}yield n.activated,t.pop()}}))},mt=function(e,t){return i(this,void 0,void 0,(function*(){if(0!==e.dependencies.length)for(const n of e.dependencies)yield r(this,at,"m",gt).call(this,n,t)}))},Et=function(e){return i(this,void 0,void 0,(function*(){yield Promise.all(e.relatedApps.map((e=>this.loadApp(e))))}))};const St={},kt="DEFAULT_BUS",Ot=(e=kt)=>{let t=null,n=!1;const s=((e=kt)=>window.RALLIE_BUS_STORE&&window.RALLIE_BUS_STORE[e])(e);return s?(t=s,n=!1):(t=((e=kt)=>{if(void 0===window.RALLIE_BUS_STORE&&Reflect.defineProperty(window,"RALLIE_BUS_STORE",{value:St,writable:!1}),window.RALLIE_BUS_STORE[e])throw new Error(Ie(e));{const t=new _t(e);return Reflect.defineProperty(window.RALLIE_BUS_STORE,e,{value:t,writable:!1}),t}})(e),n=!0),[t,n]},Nt={privateBus:e=>`${e}.bus`,stateNamespace:e=>`${e}.state`,isGlobalBusAccessible:"isGlobalBusAccessible",exportMethodName:"__RallieInnerExport__"},At=e=>`[rallie] ${e}`,Rt={stateNotInitialized:e=>At(` the block ${e}'s state is not initialized, please check:\n1. whether the block ${e} is loaded.\n2. whether the block ${e} has initialized the state`),duplicatedBlockName:e=>At(`the block ${e} is already registered before, please rename your block`),stateIsReadonly:e=>At(`the state of ${e} is readonly`)};var $t,jt,Mt,xt,Wt,Pt,Bt;class Tt{constructor(e,t){$t.set(this,void 0),this.name=e,s(this,$t,t,"f"),this.events=n(this,$t,"f").createBroadcaster(),this.methods=n(this,$t,"f").createUnicaster(),Reflect.defineProperty(this,"state",{get:()=>n(this,$t,"f").getState(Nt.stateNamespace(this.name)),set:()=>{throw new Error(Rt.stateIsReadonly(this.name))}})}setState(e,t){if(n(this,$t,"f").existState(Nt.stateNamespace(this.name)))return n(this,$t,"f").setState(Nt.stateNamespace(this.name),e,t);throw new Error(Rt.stateNotInitialized(this.name))}watchState(e){if(n(this,$t,"f").existState(Nt.stateNamespace(this.name)))return n(this,$t,"f").watchState(Nt.stateNamespace(this.name),e);throw new Error(Rt.stateNotInitialized(this.name))}listenEvents(e){return n(this,$t,"f").onBroadcast(e)}}$t=new WeakMap;class Lt extends Tt{constructor(e,t,n,i){const[r]=Ot(Nt.privateBus(e)),o=r.createSocket();super(e,o),jt.set(this,void 0),Mt.set(this,void 0),xt.set(this,void 0),Wt.set(this,void 0),Pt.set(this,void 0),Bt.set(this,{}),s(this,Wt,o,"f"),s(this,jt,t,"f"),s(this,Mt,n,"f"),s(this,Pt,t.createApp(e),"f"),s(this,xt,i,"f")}initState(e,t){return n(this,Wt,"f").initState(Nt.stateNamespace(this.name),e,t),this}addMethods(e){return n(this,Wt,"f").onUnicast(e)}relyOn(e){return n(this,Pt,"f").relyOn(e),this}relateTo(e){return n(this,Pt,"f").relateTo(e),this}onActivate(e){return n(this,Pt,"f").onActivate(e),this}connect(e){if(!n(this,Bt,"f")[e]){const[t]=Ot(Nt.privateBus(e)),s=t.createSocket();n(this,Bt,"f")[e]=new Tt(e,s)}return n(this,Bt,"f")[e]}load(e){return n(this,jt,"f").loadApp(e)}activate(e){return n(this,jt,"f").activateApp(e)}run(e){var s;return t(this,void 0,void 0,(function*(){const t=n(this,xt,"f")||(null===(s=n(this,Mt,"f").getState(Nt.isGlobalBusAccessible))||void 0===s?void 0:s.value),i=e=>{n(this,xt,"f")&&n(this,Mt,"f").setState(Nt.isGlobalBusAccessible,e?"unfreeze the enviroment":"freeze the enviroment",(t=>{t.value=e}))},r={isEntry:n(this,xt,"f"),use:e=>{t&&n(this,jt,"f").use(e)},config:e=>{t&&n(this,jt,"f").config(e)},freeze:()=>{i(!1)},unfreeze:()=>{i(!0)}},o=e(new Proxy(r,{get:(e,t,s)=>"conf"===t?JSON.parse(JSON.stringify(n(this,jt,"f").conf)):Reflect.get(e,t,s),set:()=>!1}));yield Promise.resolve(o)}))}}jt=new WeakMap,Mt=new WeakMap,xt=new WeakMap,Wt=new WeakMap,Pt=new WeakMap,Bt=new WeakMap,e.createBlock=function(e){const[t,n]=Ot();if(t.existApp(e))throw new Error(Rt.duplicatedBlockName(e));const s=t.createSocket();return n&&s.initState(Nt.isGlobalBusAccessible,{value:!0},!0),new Lt(e,t,s,n)}})); |
{ | ||
"name": "@rallie/block", | ||
"version": "0.14.1", | ||
"version": "0.14.2", | ||
"description": "a progressive micro front framework", | ||
@@ -17,3 +17,3 @@ "main": "./dist/index.umd.js", | ||
"dependencies": { | ||
"@rallie/core": "0.14.1" | ||
"@rallie/core": "0.14.2" | ||
}, | ||
@@ -28,3 +28,3 @@ "repository": { | ||
"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
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
77838
+ Added@rallie/core@0.14.2(transitive)
- Removed@rallie/core@0.14.1(transitive)
Updated@rallie/core@0.14.2