@shimotsuki/core 1.0.31 → 1.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -430,13 +430,11 @@ declare class CoreToast extends BaseComponent<ToastProps> {
430
430
  slide_node: Node;
431
431
  fixed_label: Label;
432
432
  slide_label: Label;
433
- private _onEndCallback;
434
433
  onLoad(): void;
435
434
  protected start(): void;
436
435
  show(): Promise<void>;
437
436
  private playAnim;
438
437
  onDestroy(): void;
439
- onEnd(cb: () => void): void;
440
438
  }
441
439
 
442
440
  /**
@@ -607,13 +605,12 @@ declare class Gui extends BaseComponent {
607
605
  protected onEventListener(): void;
608
606
  init(cat: Manager): this;
609
607
  protected start(): void;
610
- private lastTotalTime;
608
+ private lastShowTime;
611
609
  private toastQueue;
612
- private isProcessingToast;
613
- /**显示提示 */
610
+ private minInterval;
614
611
  showToast(props: ToastProps): void;
615
- /** 处理提示队列 */
616
- private processToastQueue;
612
+ private processQueueWithInterval;
613
+ private showNextToast;
617
614
  /**隐藏提示 */
618
615
  hideToast(): this;
619
616
  /**显示Loading */
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{AudioSource as e,_decorator as t,AudioClip as s,error as i,Node as o,director as n,log as r,sys as a,Component as c,Prefab as l,instantiate as h,isValid as d,Layers as p,view as u,Widget as f,v3 as _,tween as g,Enum as m,game as y,UITransform as v,UIOpacity as E,Tween as b,Label as C,BlockInputEvents as w,Button as k,Director as O,warn as x,assetManager as T,Asset as S,resources as N,SpriteFrame as R,Sprite as A,AsyncDelegate as I}from"cc";import{PREVIEW as M,DEBUG as D}from"cc/env";import{makeObservable as F,observable as P,autorun as U,reaction as H}from"@shimotsuki/mobx";import L from"crypto-es";import{clone as B,create as G}from"@bufbuild/protobuf";import{SocialGameClient as $,AudienceOptionsSchema as j}from"sgc";class q extends e{cat;initAudio(e){return this.cat=e,this}}const{ccclass:K,menu:V}=t;class J extends q{effects=new Map;load(e){return new Promise(((t,i)=>{this.cat.res.load(e,s,((s,o)=>{if(s)return i(s);this.effects.set(e,o),this.playOneShot(o,this.volume),t(o)}))}))}release(){for(let e in this.effects)this.cat.res.release(e);this.effects.clear()}}const{ccclass:Q,menu:W}=t;class X extends q{onComplete=null;_progress=0;_url=null;_isPlay=!1;get progress(){return this.duration>0&&(this._progress=this.currentTime/this.duration),this._progress}set progress(e){this._progress=e,this.currentTime=e*this.duration}load(e,t){this.cat.res.load(e,s,((s,o)=>{s&&i(s),this.playing&&(this._isPlay=!1,this.stop(),this.cat.res.release(this._url)),this.playOnAwake=!1,this.enabled=!0,this.clip=o,this._url=e,t&&t()}))}update(e){this.currentTime>0&&(this._isPlay=!0),this._isPlay&&0==this.playing&&(this._isPlay=!1,this.enabled=!1,this.onComplete&&this.onComplete())}release(){this._url&&(this.cat.res.release(this._url),this._url=null)}}class z{cat;constructor(e){this.cat=e}}var Z;!function(e){e.MUSIC_ON="AudioEventConstant/MUSIC_ON",e.MUSIC_OFF="AudioEventConstant/MUSIC_OFF",e.EFFECT_ON="AudioEventConstant/EFFECT_ON",e.EFFECT_OFF="AudioEventConstant/EFFECT_OFF",e.PAUSE_AUDIO="AudioEventConstant/PAUSE_AUDIO",e.RESUME_AUDIO="AudioEventConstant/RESUME_AUDIO"}(Z||(Z={}));class Y extends z{local_data={};music;effect;_volume_music=1;_volume_effect=1;_switch_music=!0;_switch_effect=!0;local_store_key="game_audio";extra={};constructor(e){super(e),this.local_store_key=this.cat.audio_local_store_key;var t=new o("UIAudioManager");n.addPersistRootNode(t);var s=new o("UIMusic");s.parent=t,this.music=s.addComponent(X).initAudio(e);var i=new o("UIEffect");i.parent=t,this.effect=i.addComponent(J).initAudio(e),this.load()}setMusicComplete(e=null){this.music.onComplete=e}playMusic(e,t){this.music.loop=!0,e&&this.music.load(e,(()=>{this._switch_music&&this.music?.play(),t&&t()}))}stopMusic(){0!=this.music.state&&this.music?.stop()}pauseMusic(){1==this.music.state&&this.music?.pause()}resumeMusic(){[0,2].includes(this.music.state)&&this.music?.play()}get progressMusic(){return this.music.progress}set progressMusic(e){this.music.progress=e}get volumeMusic(){return this._volume_music}set volumeMusic(e){this._volume_music=e,this.music.volume=e}get switchMusic(){return this._switch_music}set switchMusic(e){if(r("设置背景音乐开关值",e,this._switch_music),e==this._switch_music)return;this._switch_music=e,e?this.resumeMusic():this.pauseMusic();const t=e?Z.MUSIC_ON:Z.MUSIC_OFF;this.cat.event.has(t)&&this.cat.event.dispatchEvent(t),this.save()}async playEffect(e){this._switch_effect&&e&&await this.effect.load(e).then((()=>{this.effect.play()}))}stopEffect(){this.effect?.stop()}get volumeEffect(){return this._volume_effect}set volumeEffect(e){this._volume_effect=e,this.effect.volume=e}get switchEffect(){return this._switch_effect}set switchEffect(e){if(e==this._switch_effect)return;this._switch_effect=e,e?this.effect?.play():this.effect?.stop();const t=e?Z.EFFECT_ON:Z.EFFECT_OFF;this.cat.event.has(t)&&this.cat.event.dispatchEvent(t),this.save()}resumeAll(){this.switchMusic&&this.music?.play(),this.switchEffect&&this.effect?.play()}pauseAll(){this.music?.pause(),this.effect?.pause()}stopAll(){this.music?.stop(),this.effect?.stop()}save(){this.local_data.volume_music=this._volume_music,this.local_data.volume_effect=this._volume_effect,this.local_data.switch_music=this._switch_music,this.local_data.switch_effect=this._switch_effect,this.local_data.extra=this.extra;let e=JSON.stringify(this.local_data);return this.cat.storage.set(this.local_store_key,e),this}load(){try{let e=this.cat.storage.get(this.local_store_key);this.local_data=JSON.parse(e),this._volume_music=this.local_data.volume_music,this._volume_effect=this.local_data.volume_effect,this._switch_music=this.local_data.switch_music,this._switch_effect=this.local_data.switch_effect,this.extra=this.local_data.extra}catch(e){this.local_data={},this._volume_music=.6,this._volume_effect=1,this._switch_music=!0,this._switch_effect=!0,this.extra={}}this.music&&(this.music.volume=this._volume_music),this.effect&&(this.effect.volume=this._volume_effect)}}class ee extends z{_key=null;_iv=null;_id="";init(e,t){this.cat.util.encryptUtil.initCrypto(e,t),this._key=this.cat.util.encryptUtil.md5(e),this._iv=this.cat.util.encryptUtil.md5(t)}setUser(e){this._id=e}set(e,t){if(null!=(e=`${e}_${this._id}`)){if(M||(e=this.cat.util.encryptUtil.md5(e)),null==t)return console.warn("存储的值为空,则直接移除该存储"),void this.remove(e);if("function"!=typeof t){if("object"==typeof t)try{t=JSON.stringify(t)}catch(e){return void console.error(`解析失败,str = ${t}`)}else"number"==typeof t&&(t+="");M||null==this._key||null==this._iv||(t=this.cat.util.encryptUtil.aesEncrypt(`${t}`,this._key,this._iv)),a.localStorage.setItem(e,t)}else console.error("储存的值不能为方法")}else console.error("存储的key不能为空")}get(e,t){if(null==e)return console.error("存储的key不能为空"),null;e=`${e}_${this._id}`,M||(e=this.cat.util.encryptUtil.md5(e));let s=a.localStorage.getItem(e);return null==s||""===s||M||null==this._key||null==this._iv||(s=this.cat.util.encryptUtil.aesDecrypt(s,this._key,this._iv)),null===s?t:s}getNumber(e,t=0){var s=this.get(e);return Number(s)||t}getBoolean(e){var t=this.get(e);return Boolean(t)||!1}getJson(e,t){var s=this.get(e);return s&&JSON.parse(s)||t}remove(e){null!=e?(e=`${e}_${this._id}`,M||(e=this.cat.util.encryptUtil.md5(e)),a.localStorage.removeItem(e)):console.error("存储的key不能为空")}clear(){a.localStorage.clear()}}function te(e,t,s,i){var o,n=arguments.length,r=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(n<3?o(r):n>3?o(t,s,r):o(t,s))||r);return n>3&&r&&Object.defineProperty(t,s,r),r}function se(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}"function"==typeof SuppressedError&&SuppressedError;class ie extends c{props={};data={};autorunDisposers=[];reactionDisposers=[];messageManagers=[];hook={destroyed:()=>{},started:()=>{}};initUI(){}__preload(){this.initUI(),this.onAutoObserver()}constructor(){super(),F(this,{props:P,data:P})}onAutoObserver(){}addAutorun(e){return(Array.isArray(e)?e:[e]).forEach((e=>{const t=U(e);this.autorunDisposers.push(t)})),this}addReaction(e,t,s){const i=H(e,t,s);return this.reactionDisposers.push(i),this}addAudoListener(e){return this.messageManagers.includes(e)||this.messageManagers.push(e),e}_onPreDestroy(){this.autorunDisposers.forEach((e=>{e()})),this.reactionDisposers.forEach((e=>{e()})),this.autorunDisposers=[],this.reactionDisposers=[],super._onPreDestroy()}onDisable(){this.onHide(),st.event.deleteEventByComponent(this),this.messageManagers.forEach((e=>{e.deleteEventByComponent(this)})),this.messageManagers=[],this.removeListener()}onEnable(){this.onShow(),this.addListener(),this.onEventListener()}onEventListener(){}addListener(){}removeListener(){}addToParent(e,t){let s=e instanceof l?h(e):e instanceof c?e.node:e;return this.setOptions(t),s.addChild(this.node),this}setOptions(e){if(e)for(let t in e)switch(t){case"hook":e.hook&&(this.hook=e.hook);break;case"props":null!==e.props&&"object"==typeof e.props&&(this.props=e.props);break;case"data":null!==e.data&&"object"==typeof e.data&&(this.data=e.data)}}setUpdateData(e){return e&&Object.assign(this.data,e),this}setUpdateProps(e){return this.props,e&&Object.assign(this.props,e),this}removeAndDestroy(){d(this?.node)&&(this.node.removeFromParent(),this.node.destroy())}setPosition(e){return this.node.setPosition(e),this}setScale(e){return this.node.setScale(e),this}setAngle(e){return this.node.angle=e,this}setRotation(e){return this.node.setRotation(e),this}onShow(){}onHide(){}setNodeAndChildrenLayer(e){return oe(this.node,e),this}}const oe=(e,t)=>{e.layer="string"==typeof t?2**p.nameToLayer(t):t,e?.children.forEach((e=>{oe(e,t)}))};class ne extends ie{lastEnterDirection="center";screen;isClosing=!1;root;constructor(){super(),this._init()}_init(){this.root=this.node,this.screen=u.getVisibleSize()}async showTween({isMotion:e=!0,direction:t="center",duration:s=.1,isBounce:i=!0,bounceDuration:o=.05}){if(this.lastEnterDirection=t,e){const e=this.node.getComponent(f);let o,n;e&&(e.updateAlignment(),e.enabled=!1),_(1.1,1.1,1),"center"==t?(o=_(.01,.01,.01),n=_(1,1,1)):(o="left"==t?_(-this.screen.width,0,0):"right"==t?_(this.screen.width,0,0):_(0,"top"==t?this.screen.height:-this.screen.height,0),n=_(0,0,0)),await this.handle(t,s,o,n,i),e&&(e.enabled=!0)}}async hideTween({isMotion:e=!0,direction:t,duration:s=.1}){if(t=t||this.lastEnterDirection,!this.isClosing){if(this.isClosing=!0,g(this.node).removeSelf(),e){const e=this.node.getComponent(f);let i,o;e&&(e.enabled=!1),"center"==t?(i=this.node.scale,o=_(0,0,0)):(o="left"==t?_(-this.screen.width,0,0):"right"==t?_(this.screen.width,0,0):_(0,"top"==t?this.screen.height:-this.screen.height,0),i=this.node.getPosition()),await this.handle(t,s,i,o,!1)}this.removeAndDestroy()}}async handle(e,t,s,i,o){"center"==e?this.node.setScale(s):this.node.setPosition(s),await this.deftween(t,{["center"==e?"scale":"position"]:i},o)}deftween(e,t,s,i){return new Promise(((s,i)=>{g(this.node).to(e,t).call((()=>{s()})).start()}))}}const{ccclass:re,property:ae}=t;var ce;!function(e){e[e.EFFECT=0]="EFFECT",e[e.BGM=1]="BGM"}(ce||(ce={}));class le extends ie{type=ce.EFFECT;clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=new e;onEnable(){super.onEnable(),this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,st.event.on(Z.EFFECT_ON,this.onPlayEffectHandler,this).on(Z.EFFECT_OFF,this.onStopEffectHandler,this).on(Z.MUSIC_ON,this.onPlayMusicHandler,this).on(Z.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){super.__preload();const{volumeEffect:e,volumeMusic:t}=st.audio;this.audioSource.volume=this.type===ce.BGM?t:e}start(){}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:e,switchMusic:t}=st.audio;this.audioSource.playing||!(this.type===ce.BGM?t:e)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}te([ae({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:m(ce)}),se("design:type",Object)],le.prototype,"type",void 0),te([ae({tooltip:"音源",type:s}),se("design:type",Object)],le.prototype,"clip",void 0),te([ae({tooltip:"循环"}),se("design:type",Object)],le.prototype,"loop",void 0),te([ae({tooltip:"音量"}),se("design:type",Object)],le.prototype,"volume",void 0),te([ae({tooltip:"是否启用自动播放"}),se("design:type",Object)],le.prototype,"playOnAwake",void 0);const{ccclass:he,property:de}=t;class pe extends ne{type=ce.EFFECT;clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=new e;onEnable(){super.onEnable(),st.event.on(Z.EFFECT_ON,this.onPlayEffectHandler,this).on(Z.EFFECT_OFF,this.onStopEffectHandler,this).on(Z.MUSIC_ON,this.onPlayMusicHandler,this).on(Z.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,super.__preload();const{volumeEffect:e,volumeMusic:t}=st.audio;this.audioSource.volume=this.type===ce.BGM?t:e}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:e,switchMusic:t}=st.audio;this.audioSource.playing||!(this.type===ce.BGM?t:e)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}te([de({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:m(ce)}),se("design:type",Object)],pe.prototype,"type",void 0),te([de({tooltip:"音源",type:s}),se("design:type",Object)],pe.prototype,"clip",void 0),te([de({tooltip:"循环"}),se("design:type",Object)],pe.prototype,"loop",void 0),te([de({tooltip:"音量"}),se("design:type",Object)],pe.prototype,"volume",void 0),te([de({tooltip:"是否启用自动播放"}),se("design:type",Object)],pe.prototype,"playOnAwake",void 0);const{ccclass:ue,property:fe}=t;var _e;!function(e){e[e.FIXED=0]="FIXED",e[e.SLIDE=1]="SLIDE"}(_e||(_e={}));let ge=class extends ie{fixed_node;slide_node;fixed_label;slide_label;_onEndCallback=null;onLoad(){this.fixed_node.active=this.slide_node.active=!1}start(){this.show()}async show(){return new Promise((async(e,t)=>{const{title:s,type:i,fixed_time:o}=this.props;if(i==_e.FIXED){this.fixed_node.active=!0,this.fixed_label.string=`${s}`,this.fixed_label.updateRenderData(!0);const t=this.fixed_label.node.getComponent(v).height;t-this.fixed_node.getComponent(v).height>0&&(this.fixed_node.getComponent(v).height=t+100),this.scheduleOnce((()=>{this.node.destroy(),e()}),o)}else{this.slide_node.active=!0,this.slide_label.string=`${s}`,this.slide_label.updateRenderData(!0);const t=this.slide_label.node.getComponent(v).width;this.slide_node.getComponent(v).width-t<100&&(this.slide_node.getComponent(v).width=t+100),this.playAnim(this.node).then((()=>{e()}))}}))}playAnim(e){return new Promise(((t,s)=>{const i=this.node.getComponent(E),o=g(i).delay(1.2).to(.5,{opacity:0}).call((()=>{b.stopAllByTarget(e),this.node.destroy(),t()}));g(e).by(.5,{position:_(0,400,0)}).call((()=>{o.start()})).start()}))}onDestroy(){this._onEndCallback?.(),b.stopAllByTarget(this.node),this.unscheduleAllCallbacks(),this._onEndCallback=null}onEnd(e){this._onEndCallback=e}};var me;te([fe({type:o,tooltip:"固定节点"}),se("design:type",o)],ge.prototype,"fixed_node",void 0),te([fe({type:o,tooltip:"滑动节点"}),se("design:type",o)],ge.prototype,"slide_node",void 0),te([fe({type:C,tooltip:"固定标签节点"}),se("design:type",C)],ge.prototype,"fixed_label",void 0),te([fe({type:C,tooltip:"滑动标签节点"}),se("design:type",C)],ge.prototype,"slide_label",void 0),ge=te([ue("CoreToast")],ge),function(e){e.EVENT_SHOW="GlobalEventConstant/EVENT_SHOW",e.EVENT_HIDE="GlobalEventConstant/EVENT_HIDE",e.GAME_RESIZE="GlobalEventConstant/GAME_RESIZE",e.EVENT_CLOSE="GlobalEventConstant/EVENT_CLOSE",e.ONLINE="GlobalEventConstant/ONLINE",e.OFFLINE="GlobalEventConstant/OFFLINE",e.ROOT_MASK_UPDATE="GlobalEventConstant/ROOT_MASK_UPDATE",e.ROOT_MASK_CHANGE="GlobalEventConstant/ROOT_MASK_CHANGE"}(me||(me={}));const{ccclass:ye,property:ve}=t;let Ee=class extends ne{scene_mask_node;ui_container;gui=null;onLoad(){this.setSceneMaskActive(!1)}get scene_mask(){return this.scene_mask_node.getComponent(Le)}get brother(){return this.ui_container.children||[]}get tweenChildren(){return this.scene_mask.tween.children}onEventListener(){st.event.on(me.ROOT_MASK_CHANGE,this.uiMaskChanged,this)}addMask(){const e=this.brother[this.brother.length-1];e&&this.scene_mask.node.setSiblingIndex(e.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}subMask(){const e=this.brother[this.brother.length-2];e&&this.scene_mask.node.setSiblingIndex(e.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}blockMaskSiblingIndexChanged(){this.tweenChildren.length>1||this.brother.length>1?this.show():this.hide()}addNodeToTween(e){return d(this)&&this.scene_mask&&this.scene_mask.tween.addChild(e),this}show(){this.setSceneMaskActive(!0)}hide(){this.setSceneMaskActive(!1)}setGui(e){return this.gui=e,this}uiMaskChanged(){this.blockMaskSiblingIndexChanged()}setSceneMaskActive(e){this.scene_mask.node.active=!this.gui.root_mask.active&&e}};te([ve({type:o}),se("design:type",o)],Ee.prototype,"scene_mask_node",void 0),te([ve({type:o}),se("design:type",o)],Ee.prototype,"ui_container",void 0),Ee=te([ye("CoreUIContainer")],Ee);class be extends ne{onEnable(){super.onEnable(),this.updateMask()}onDisable(){super.onDisable(),this.updateMask()}updateMask(){st.event.dispatchEvent(me.ROOT_MASK_UPDATE)}}const{ccclass:Ce,property:we}=t;let ke=class extends be{title;loadingTween;loading_rotate=0;onAutoObserver(){this.addAutorun([()=>{this.props?.title&&(this.title.string=`${this.props?.title}`),this.title.node.active=!!this.props?.title?.length},()=>{this.getComponent(w).enabled=!!this.props?.mask}])}update(e){this.loading_rotate+=220*e,this.loadingTween.setRotationFromEuler(0,0,-this.loading_rotate%360),this.loading_rotate>360&&(this.loading_rotate-=360)}};te([we({type:C,tooltip:"标题"}),se("design:type",C)],ke.prototype,"title",void 0),te([we({type:o,tooltip:"动画"}),se("design:type",o)],ke.prototype,"loadingTween",void 0),ke=te([Ce("CoreShowLoading")],ke);const{ccclass:Oe,property:xe}=t;var Te;!function(e){e.RECONNECTED="重连成功",e.RECONNECTING="正在重连",e.MAX_RECONNECT="重连次数超出限制,请检查网络",e.RECONNECTED_ERROR="重连失败,请检查网络",e.CONNECT_PARAM_ERROR="游戏参数错误,请重新加载",e.KICK="账号已下线",e.OFFLINE="网络已断开",e.ONLINE="网络已连接",e.GAME_ERROR="连接游戏服错误"}(Te||(Te={}));let Se=class extends be{common_prompt_text;btn_confirm;is_close=!1;props={content:null};initUI(){this.btn_confirm.node.active=!1}onLoad(){this.btn_confirm.node.on(k.EventType.CLICK,this.onConfirmHandler,this),this.addAutorun([()=>{this.common_prompt_text.string=this.props.content??""}])}onDestroy(){this.unscheduleAllCallbacks()}updateProps(e){this.updatePromptText(e,e==Te.RECONNECTING)}updatePromptText(e,t=!1){if(this.unscheduleAllCallbacks(),this.props.content=e,r("更新提示文案:",e),t){let t=0;const s=()=>{t=(t+1)%4,this.common_prompt_text.string=e+["","·","··","···"][t]};this.schedule(s,.5)}}onConfirmHandler(){this.is_close=!0,st.gui.hideReconnect()}};te([xe({type:C,tooltip:"通用提示文本"}),se("design:type",C)],Se.prototype,"common_prompt_text",void 0),te([xe({type:k,tooltip:"确定按钮"}),se("design:type",k)],Se.prototype,"btn_confirm",void 0),Se=te([Oe("CoreReconnection")],Se);const{ccclass:Ne,property:Re}=t;let Ae=class extends be{text;btn_confirm;onLoad(){this.btn_confirm.node.on(k.EventType.CLICK,this.onConfrimHandler,this)}start(){this.props&&this.updateProps(this.props)}onConfrimHandler(){this.props?.confrim?.(),st.gui.hideNotice()}updateProps(e){this.text.string=`${e.text}`}};te([Re({type:C,tooltip:"提示文本"}),se("design:type",C)],Ae.prototype,"text",void 0),te([Re({type:k,tooltip:"确定按钮"}),se("design:type",k)],Ae.prototype,"btn_confirm",void 0),Ae=te([Ne("CoreNotice")],Ae);class Ie extends ie{isReload}const{ccclass:Me,property:De}=t;var Fe;!function(e){e[e.UI=0]="UI",e[e.LOADING=1]="LOADING",e[e.TOAST=2]="TOAST",e[e.RECONNECTTION=3]="RECONNECTTION",e[e.NOTICE=4]="NOTICE"}(Fe||(Fe={}));let Pe=class extends ie{reconnection_ui_prefab;toast_ui_prefab;loading_ui_prefab;notice_ui_prefab;ui_prefab;root_ui;root_toast;root_mask;cat;ui_container_component;reconnection_ui_component;notice_ui_component;loading_ui_component;toast_ui_component;currentScene;onEventListener(){this.cat.event.on(me.ROOT_MASK_UPDATE,this.onRootUpdate,this)}init(e){this.cat=e;const t=n.getScene();return r("init scene"),t&&this.changeScene(t),this}start(){this.onRootUpdate()}lastTotalTime=0;toastQueue=[];isProcessingToast=!1;showToast(e){this.toastQueue.push(e),this.processToastQueue()}processToastQueue(){if(this.isProcessingToast||0===this.toastQueue.length)return;this.isProcessingToast=!0;const e=this.toastQueue.shift(),t=()=>{const t=h(this.toast_ui_prefab);if(!e.title)return this.isProcessingToast=!1,void this.processToastQueue();const s=t.getComponent(ge);s.addToParent(this.root_toast,{props:e}),s.onEnd((()=>{this.isProcessingToast=!1,this.processToastQueue()}))},s=y.totalTime,i=s-this.lastTotalTime,o=i>200?0:i;this.lastTotalTime=s,0===o?t():this.scheduleOnce(t,o/1e3)}hideToast(){return this.toast_ui_component?.removeAndDestroy(),this}showLoading({title:e="",mask:t=!0,black:s=!0}={}){if(r("showLoading",e),this.loading_ui_component)this.loading_ui_component.setOptions({props:{title:e,mask:t,black:s}});else{const i=h(this.loading_ui_prefab);this.loading_ui_component=i.getComponent(ke).addToParent(this.root_ui,{props:{title:e,mask:t,black:s}})}return this}hideLoading(){return this.loading_ui_component?.removeAndDestroy(),this.loading_ui_component=null,this}showReconnect(e){if(this.reconnection_ui_component)this.reconnection_ui_component.setUpdateProps({content:e});else{const t=h(this.reconnection_ui_prefab);this.reconnection_ui_component=t.getComponent(Se).addToParent(this.root_ui,{props:{content:e}})}return this}hideReconnect(){return this.reconnection_ui_component?.removeAndDestroy(),this.reconnection_ui_component=null,this}showNotice(e){const t=h(this.notice_ui_prefab);return this.notice_ui_component=t.getComponent(Ae).addToParent(this.root_ui,{props:e}),this}hideNotice(){return this.notice_ui_component?.removeAndDestroy(),this}loadScene(e,t,s){r("加载场景",e,t,s);let i={},o=s??!1;return"boolean"==typeof t?o=t:i=t??{},r("当前场景",n.getScene()?.uuid,n.getScene()?.name),n.once(O.EVENT_BEFORE_SCENE_LAUNCH,(e=>{r("Director.EVENT_BEFORE_SCENE_LAUNCH",e),this.changeScene(e,i,o)})),n.loadScene(e),this}resetScene(e=""){return e=e||this.currentScene,this.loadScene(e)}cleanScene(){this.resetScene().hideLoading().hideNotice().hideReconnect().hideToast()}changeScene(e,t,s){this.currentScene=e.name,this.createUILayer(e);const i=e.getComponentInChildren(Ie);i&&(i.isReload=s??!1),i?.setOptions(t)}createUILayer(e){this.ui_container_component?.removeAndDestroy(),this.ui_container_component=null;const t=h(this.ui_prefab);this.ui_container_component=t.getComponent(Ee).setGui(this).addToParent(e)}reloadScene(){this.loadScene(this.currentScene,!0)}async closeUI(e,t){const{component:s}=this.findUIBaseLayer(e,!1);s&&(s.setOptions({...t?.hook??{},...t?.props??{}}),await s.hideTween(t||{}),this.ui_container_component?.subMask())}async openUI(e,t){const{rootNode:s,component:i}=this.findUIBaseLayer(e,!0);s.getComponent(ne),i?.setOptions(t),s&&this.ui_container_component?.addNodeToTween(s).addMask(),i&&await i.showTween(t||{}),this.ui_container_component?.ui_container&&i?.addToParent(this.ui_container_component.ui_container)}findUIBaseLayer(e,t){let s,n=null;if(e instanceof o){s=e;const t=e.components.filter((e=>e instanceof ne));if(!t.length)return i(`${e.name}节点未找到继承自BaseLayer的组件`),{rootNode:s,component:n};1==t.length?n=t[0]:x(`${e.name}节点存在多个继承自BaseLayer的组件`)}else if(s=e.node,n=e,t){for(;s.parent;)s=s.parent;n.root=s}else s=e.root;return{rootNode:s,component:n}}onRootUpdate(){const e=this.root_ui.children.length;if(this.root_mask.active=e>1,e>1){const t=this.root_ui.children[e-2];this.root_mask.setSiblingIndex(t.getSiblingIndex())}this.cat.event.dispatchEvent(me.ROOT_MASK_CHANGE)}};te([De({type:l,tooltip:"断线重连UI预制体"}),se("design:type",l)],Pe.prototype,"reconnection_ui_prefab",void 0),te([De({type:l,tooltip:"提示UI预制体"}),se("design:type",l)],Pe.prototype,"toast_ui_prefab",void 0),te([De({type:l,tooltip:"加载UI预制体"}),se("design:type",l)],Pe.prototype,"loading_ui_prefab",void 0),te([De({type:l,tooltip:"公告UI预制体"}),se("design:type",l)],Pe.prototype,"notice_ui_prefab",void 0),te([De({type:l,tooltip:"UI层预制体"}),se("design:type",l)],Pe.prototype,"ui_prefab",void 0),te([De({type:o,tooltip:"root-UI层"}),se("design:type",o)],Pe.prototype,"root_ui",void 0),te([De({type:o,tooltip:"root-组件层"}),se("design:type",o)],Pe.prototype,"root_toast",void 0),te([De({type:o,tooltip:"root-mask"}),se("design:type",o)],Pe.prototype,"root_mask",void 0),Pe=te([Me("Gui")],Pe);const{ccclass:Ue,property:He}=t;let Le=class extends ie{tween};var Be;te([He({type:o,tooltip:"动画节点"}),se("design:type",o)],Le.prototype,"tween",void 0),Le=te([Ue("CoreBlackMask")],Le),function(e){e.Root="prefabs/root",e.Toast="prefabs/toast",e.BlackMask="prefabs/black-mask",e.Loading="prefabs/loading",e.Notice="prefabs/notice",e.Reconnection="prefabs/reconnection"}(Be||(Be={}));class Ge extends z{gui;#e="resources";getGuiPrefabByType=(e,t)=>new Promise(((s,i)=>{console.log(e,`${t}`),this.cat.res.load(e,t,((e,t)=>{e?i(e):s(t)}))}));async init(){this.#e=this.cat.gui_bundle_name;const e=await this.getGuiPrefabByType(this.#e,Be.Root),t=h(e);return this.gui=t.getComponent(Pe).init(this.cat),n.addPersistRootNode(t),this}}class $e{get=(e,t,s="resources")=>T.getBundle(s).get(e,t);isAssetType=e=>"function"==typeof e&&e.prototype instanceof S;async load(...e){let t=null,s=null,i=null;"string"==typeof e[0]&&"string"==typeof e[1]&&(t=e.shift());let o=e.shift();this.isAssetType(e[0])&&(s=e.shift()),2==e.length&&(i=e.shift());const n=e.shift();let r=N;if(t&&"resources"!=t){T.bundles.has(t)||await this.loadBundle(t);let e=T.bundles.get(t);e&&(r=e)}i&&n?r.load(o,s,i,n):n?r.load(o,s,n):r.load(o,s)}async loadDir(...e){let t=null,s=null,i=null,o=null;"string"==typeof e[0]&&"string"==typeof e[1]&&(t=e.shift());let n=e.shift();this.isAssetType(e[0])&&(s=e.shift()),2==e.length&&(i=e.shift()),o=e.shift();let r=N;if(t&&"resources"!=t){T.bundles.has(t)||await this.loadBundle(t);let e=T.bundles.get(t);e&&(r=e)}i&&o?r.loadDir(n,s,i,o):o?r.loadDir(n,s,o):r.loadDir(n,s)}loadRemote(e,...t){var s,i=null;2==t.length&&(i=t.shift()),s=t.shift(),T.loadRemote(e,{ext:".png",...i},s)}loadBundle=(e,t)=>new Promise(((s,i)=>{const o=(e,t)=>{if(e)return i(e);s(t)};t?T.loadBundle(e,{version:t},o):T.loadBundle(e,o)}));releasePrefabtDepsRecursively=e=>{var t=T.assets.get(e);(T.releaseAsset(t),t instanceof l)&&T.dependUtil.getDepsRecursively(e).forEach((e=>{T.assets.get(e).decRef()}))};release=(e,t="resources")=>{var s=T.getBundle(t);if(s){var i=s.get(e);i&&this.releasePrefabtDepsRecursively(i._uuid)}};releaseDir=(e,t="resources")=>{var s=T.getBundle(t),i=s?.getDirWithPath(e);i?.map((e=>{this.releasePrefabtDepsRecursively(e.uuid)})),!e&&"resources"!=t&&s&&T.removeBundle(s)};dump=()=>{T.assets.forEach(((e,t)=>{r(T.assets.get(t))})),r(`当前资源总数:${T.assets.count}`)}}class je{events=new Map;on(e,t,s){if(!e||!t)return x(`注册【${e}】事件的侦听器函数为空`),this;const i=this.events.get(e)??this.events.set(e,new Map).get(e);return i.has(s)?(x(`名为【${e}】的事件重复注册侦听器`),this):(i.set(s,t),this)}once(e,t,s){let i=(o,n)=>{this.off(e,i,s),i=null,t.call(s,o,n)};this.on(e,i,s)}off(e,t,s){if(!this.events.get(e)?.has(s))return this;const o=this.events.get(e);return o.get(s)!==t?(i(`${s}注册事件和取消事件不一致`),this):(o.delete(s),this)}dispatchEvent(e,t){if(!this.events.has(e))return this;const s=this.events.get(e);for(const[i,o]of s)o.call(i,t,e);return this}offAll(){this.events.clear()}has(e){return this.events.has(e)}deleteEventByComponent(e){for(const[t,s]of this.events){for(const[t]of s)t===e&&s.delete(t);0===s.size&&this.events.delete(t)}}}let qe=null;const Ke={stringify:e=>{const t={ct:e.ciphertext.toString(L.enc.Base64)};return e.iv&&(t.iv=e.iv.toString()),e.salt&&(t.s=e.salt.toString()),JSON.stringify(t)},parse:e=>{const t=JSON.parse(e),s=L.lib.CipherParams.create({ciphertext:L.enc.Base64.parse(t.ct)});return t.iv&&(s.iv=L.enc.Hex.parse(t.iv)),t.s&&(s.salt=L.enc.Hex.parse(t.s)),s}};var Ve=Object.freeze({__proto__:null,JsonFormatter:Ke,aesDecrypt:(e,t,s)=>L.AES.decrypt(e,t,{iv:qe,format:Ke}).toString(L.enc.Utf8),aesEncrypt:(e,t,s)=>L.AES.encrypt(e,t,{iv:qe,format:Ke}).toString(),initCrypto:(e,t)=>{qe=L.enc.Hex.parse(t)},md5:e=>L.MD5(e).toString()});class Je extends z{encryptUtil=Ve}class Qe extends ${isNeedReconnect=!1;isOnline=!0;isInBackground=!1;running=!1;index=0;logBlackList=[];constructor(e,t,s){super(e,t,s),this.running=!0,this.addEvent()}addEvent(){this.on("connected",(()=>this.handleEvent({type:"connected"}))).on("reconnected",(()=>this.handleEvent({type:"reconnected"}))).on("disconnect",(e=>this.handleEvent({type:"disconnect",ev:e}))).on("handshakeError",(e=>this.handleEvent({type:"handshakeError",ret:e}))).on("kick",(()=>this.handleEvent({type:"kick"}))).on("reconnecting",(()=>this.handleEvent({type:"reconnecting"}))).on("maxReconnect",(()=>this.handleEvent({type:"maxReconnect"}))).on("error",(e=>this.handleEvent({type:"error",ev:e}))),st.event.on(me.EVENT_SHOW,this.onShowHandler,this).on(me.EVENT_HIDE,this.onHideHandler,this).on(me.ONLINE,this.onOnlineHandler,this).on(me.OFFLINE,this.onOfflineHandler,this)}removeEvent(){this.removeAllListeners(),st.event.off(me.EVENT_SHOW,this.onShowHandler,this).off(me.EVENT_HIDE,this.onHideHandler,this).off(me.ONLINE,this.onOnlineHandler,this).off(me.OFFLINE,this.onOfflineHandler,this)}onShowHandler(){r("[SHOW]"),this.isInBackground=!1,this.isNeedReconnect&&this.isOnline&&this.handleEvent({type:"show"})}onHideHandler(e){r("[HIDE]"),e().finally((()=>{this.isInBackground=!0,this.handleEvent({type:"hide"})}))}onOnlineHandler(){this.isOnline=!0,r("正在检查网络状态:"+(this.isOnline?"在线":"断开")),this.handleEvent({type:"online"})}onOfflineHandler(){this.isOnline=!1,r("正在检查网络状态:"+(this.isOnline?"在线":"断开")),this.handleEvent({type:"offline"})}async handleEvent(e){if(this.running)switch(e.type){case"init":break;case"connected":r("ws连接成功状态 connected"),this.isNeedReconnect=!1;break;case"reconnected":r("ws重连成功状态 reconnected",this.isSocketConnected),this.isNeedReconnect=!1,r("%c 重连成功状态","background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",this.index);try{await this.connectRequest(),r("重连成功状态 connectRequest "),st.gui.showToast({title:Te.RECONNECTED}),st.gui.hideReconnect().hideLoading(),st.gui.reloadScene()}catch(e){console.error(e),st.gui.showReconnect(Te.GAME_ERROR)}break;case"disconnect":r("断开连接状态 disconnect",e.ev),r("%c 断开连接状态","background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",this.index),this.isNeedReconnect=!0,this.handleEvent({type:"reconnect"});break;case"handshakeError":r("参数错误状态 handshakeError",e.ret),st.gui.showReconnect(Te.CONNECT_PARAM_ERROR),this.handleEvent({type:"destroy"});break;case"kick":r("%c 被踢出状态","background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",this.index),r("被踢出状态 kick"),st.gui.showReconnect(Te.KICK),this.handleEvent({type:"destroy"});break;case"reconnecting":r("正在重连状态 reconnecting"),this.isOnline&&this.isInBackground;break;case"maxReconnect":r("超出最大重连状态 maxReconnect"),st.gui.showReconnect(Te.MAX_RECONNECT);break;case"error":this.isOnline&&(r("ws报错状态 error",e.ev),"string"==typeof e.ev&&st.gui.showToast({title:e.ev}),st.gui.showReconnect(Te.RECONNECTED_ERROR));break;case"online":st.gui.showReconnect(Te.ONLINE),r("在线状态 online"),this.handleEvent({type:"reconnect"});break;case"offline":this.disconnect(!0),r("离线状态 offline"),this.isNeedReconnect=!0,st.gui.showReconnect(Te.OFFLINE);break;case"show":r("前台状态 show"),this.handleEvent({type:"reconnect"});break;case"hide":r("后台状态 hide"),this.disconnect(!0),this.isNeedReconnect=!0;break;case"reconnect":r("重连状态 reconnect"),this.isNeedReconnect&&!this.isInBackground&&this.isOnline&&(st.gui.showLoading({title:"正在重连"}),this.reset(),this.index+=1,r("%c ws重连次数","background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",this.index),this.reconnectImmediately());break;case"destroy":r("销毁状态 destroy"),this.destroyStateMachine();break;default:r("Unknown event:",e.type)}}destroy(){this.handleEvent({type:"destroy"})}disconnect(e=!1){super.disconnect(e)}destroyStateMachine(){r("Destroying state machine"),this.running=!1,this.removeEvent(),this.disconnect(!0)}request(e,t,s){return D&&r(`%c ws客户端消息 %c [Request][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7d3d ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(t.desc,t.message)),new Promise(((o,n)=>{super.request(e,t,s).then((t=>{D&&r(`%c ws服务端消息 %c [Response][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7daa ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(s,t)),o(t)}),(e=>{i("request err",e),n(e)}))}))}async Request(e,t,s,{audOptions:i={forwardReq:!1,forwardResp:!1},show_log:o=!0}={}){if(!this.isSocketConnected)throw""+(this.isSocketConnected?"未加入战局/观战":"Socket未连接");return D&&o&&r(`%c ws客户端消息 %c [Request][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7d3d ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(t.desc,t.message)),this.GameRequest(e,t,s,G(j,i))}async GameRequest(e,t,s,i){return new Promise(((o,n)=>{super.GameRequest(e,t,s,i).then((t=>{D&&r(`%c ws服务端消息 %c [Response][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7daa ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(s,t)),o(t)}),(e=>{st.gui.showToast({title:e.msg}),n(e)}))}))}async gameRequest(e,t,s){return D&&r(`%c ws客户端消息 %c [Request][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7d3d ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(t.desc,t.message)),super.gameRequest(e,t,s)}GameNotify=async(e,t,s)=>{try{super.GameNotify(e,t,s)}catch(t){throw console.error(`Error in connectRequest for route ${e}: `,t),t}};Notify=async(e,t,{audOptions:s={forwardReq:!1,forwardResp:!1},show_log:i=!0}={})=>{this.isSocketConnected&&(D&&i&&r(`%c ws客户端消息 %c[Notify][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7d3d ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(t.desc,t.message)),this.GameNotify(e,t,G(j,s)))};subscribe(e,t,s){return super.subscribe(e,t,(i=>{D&&!this.logBlackList.includes(e)&&r(`%c ws服务端消息:[${new Date}] %c ${e} %c`,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#410083 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(t,i)),st.event.dispatchEvent(e,B(t,i)),s?.(i)})),this}onData(e){super.onData(e)}}const{ccclass:We,property:Xe}=t;let ze=class extends ne{default_title=null;title;prompt_content_str;prompt_content_spriteFrame;btn_confirm;confirm_spriteFrame;btn_cancel;cancel_spriteFrame;btn_close;isConfirm=!1;props={title:this.default_title,content:null,confirmCB:()=>{},cancelCB:()=>{},style:null};onLoad(){this.btn_cancel.node.on(k.EventType.CLICK,this.onCancelHandler,this),this.btn_confirm.node.on(k.EventType.CLICK,this.onConfirmHandler,this),this.btn_close.node.on(k.EventType.CLICK,this.onCloseHandler,this),this.addAutorun([()=>{this.title.spriteFrame=this.props?.title||this.default_title},()=>{this.props.content instanceof R?this.prompt_content_spriteFrame.spriteFrame=this.props.content:"string"==typeof this.props.content?this.prompt_content_str.string=this.props.content:console.error("未知类型的【UIModal】内容")},()=>{null===this.props?.style?.confirm?this.btn_confirm.node.active=!1:(this.btn_confirm.node.active=!0,this.btn_confirm.getComponent(A).spriteFrame=this.props.style?.confirm||this.confirm_spriteFrame),null===this.props?.style?.cancel?this.btn_cancel.node.active=!1:(this.btn_cancel.node.active=!0,this.btn_cancel.getComponent(A).spriteFrame=this.props.style?.cancel||this.cancel_spriteFrame)}])}close(){this.props.cancelCB?.(),st.gui.closeUI(this)}onCancelHandler(){this.close()}onConfirmHandler(){this.props.confirmCB?.()}onDestroy(){this.isConfirm&&this.props.onDestroy?.()}onCloseHandler(){this.close()}};var Ze;te([Xe({type:R,tooltip:"默认标题"}),se("design:type",R)],ze.prototype,"default_title",void 0),te([Xe({type:A,tooltip:"标题节点"}),se("design:type",A)],ze.prototype,"title",void 0),te([Xe({type:C,tooltip:"字符串内容按钮"}),se("design:type",C)],ze.prototype,"prompt_content_str",void 0),te([Xe({type:A,tooltip:"图片精灵内容按钮"}),se("design:type",A)],ze.prototype,"prompt_content_spriteFrame",void 0),te([Xe({type:k,tooltip:"确认按钮"}),se("design:type",k)],ze.prototype,"btn_confirm",void 0),te([Xe({type:R,tooltip:"确认按钮精灵图"}),se("design:type",R)],ze.prototype,"confirm_spriteFrame",void 0),te([Xe({type:k,tooltip:"取消按钮"}),se("design:type",k)],ze.prototype,"btn_cancel",void 0),te([Xe({type:R,tooltip:"取消按钮精灵图"}),se("design:type",R)],ze.prototype,"cancel_spriteFrame",void 0),te([Xe({type:k,tooltip:"关闭按钮"}),se("design:type",k)],ze.prototype,"btn_close",void 0),ze=te([We("CoreUIModal")],ze),function(e){e[e.Delay=0]="Delay",e[e.Interval=1]="Interval"}(Ze||(Ze={}));class Ye{tag;type;callback;remainingTime;executionTime=0;initialTime;constructor(e,t,s,i){this.tag=e,this.type=t,this.remainingTime=s,this.initialTime=s,this.callback=i}}class et extends z{timers=new Map;lastUpdateTime=Date.now();constructor(e){super(e),e.event.on(me.EVENT_HIDE,this.onHandleAppBackground,this),e.event.on(me.EVENT_SHOW,this.onHandleAppForeground,this),setInterval(this.update.bind(this),1e3)}onHandleAppBackground(){this.lastUpdateTime=Date.now()}onHandleAppForeground(){const e=Date.now(),t=e-this.lastUpdateTime;r("elapsedTime",t);for(const e of this.timers.values())e.remainingTime>0&&(e.remainingTime-=t,e.executionTime+=t);this.lastUpdateTime=e}registerInterval(e,t,s){if(this.has(e))return i(`${e}定时器已存在,请勿重复注册`);const o=new Ye(e,Ze.Interval,t,s);this.timers.set(e,o)}registerDelay(e,t,s){if(this.has(e))return i(`${e}延时器已存在,请勿重复注册`);const o=new Ye(e,Ze.Delay,t,s);this.timers.set(e,o)}unregister(e){this.has(e)&&this.timers.delete(e)}has(e){return this.timers.has(e)}update(){const e=[];for(const[t,s]of this.timers.entries())s.remainingTime-=1e3,s.remainingTime<=0&&(s.type===Ze.Interval&&(s.executionTime+=s.initialTime),s.callback(s.executionTime),s.type===Ze.Interval?s.remainingTime=s.initialTime:e.push(t));for(const t of e)this.timers.delete(t)}}class tt{static#t;static get instance(){return this.#t||(this.#t=new tt),this.#t}onAppInitDelegate=new I;audio;event;gui;storage;res;util;gui_bundle_name="";audio_local_store_key="";setConfig=({gui_bundleName:e="resources",audio_local_store_key:t="game_audio"}={})=>(this.gui_bundle_name=e,this.audio_local_store_key=t,this);async boot(){this.res=new $e,this.util=new Je(this),this.storage=new ee(this),this.event=new je,this.audio=new Y(this),this.gui=(await new Ge(this).init()).gui}}const st=tt.instance;y.onPostProjectInitDelegate.add((async()=>{console.time("[Init App]"),await st.boot(),await st.onAppInitDelegate.dispatch(),console.timeEnd("[Init App]")}));export{Z as AudioEventConstant,Y as AudioManager,le as AudioSourceBaseComponent,pe as AudioSourceUILayer,ce as AudioTypeEnum,ie as BaseComponent,z as BaseManager,Be as BasePrefab,Le as CoreBlackMask,Ae as CoreNotice,Se as CoreReconnection,ke as CoreShowLoading,ge as CoreToast,Ee as CoreUIContainer,ze as CoreUIModal,Je as CoreUtil,me as GlobalEventConstant,Pe as Gui,Ge as GuiManager,Fe as LayerType,tt as Manager,je as MessageManager,Te as ReconnectPrompt,be as RootUILayer,Ie as SceneLayer,et as TimerManager,_e as ToastType,ne as UILayer,Qe as WrapperSocialGameClient,st as cat};
1
+ import{AudioSource as e,_decorator as t,AudioClip as s,error as i,Node as o,director as n,log as r,sys as a,Component as c,Prefab as l,instantiate as h,isValid as d,Layers as p,view as u,Widget as f,v3 as _,tween as m,Enum as g,game as y,UITransform as v,UIOpacity as E,Tween as b,Label as w,BlockInputEvents as C,Button as k,Director as O,warn as x,assetManager as S,Asset as T,resources as N,SpriteFrame as I,Sprite as R,AsyncDelegate as A}from"cc";import{PREVIEW as M,DEBUG as D}from"cc/env";import{makeObservable as F,observable as U,autorun as H,reaction as P}from"@shimotsuki/mobx";import L from"crypto-es";import{clone as B,create as G}from"@bufbuild/protobuf";import{SocialGameClient as $,AudienceOptionsSchema as j}from"sgc";class q extends e{cat;initAudio(e){return this.cat=e,this}}const{ccclass:K,menu:V}=t;class W extends q{effects=new Map;load(e){return new Promise(((t,i)=>{this.cat.res.load(e,s,((s,o)=>{if(s)return i(s);this.effects.set(e,o),this.playOneShot(o,this.volume),t(o)}))}))}release(){for(let e in this.effects)this.cat.res.release(e);this.effects.clear()}}const{ccclass:J,menu:Q}=t;class X extends q{onComplete=null;_progress=0;_url=null;_isPlay=!1;get progress(){return this.duration>0&&(this._progress=this.currentTime/this.duration),this._progress}set progress(e){this._progress=e,this.currentTime=e*this.duration}load(e,t){this.cat.res.load(e,s,((s,o)=>{s&&i(s),this.playing&&(this._isPlay=!1,this.stop(),this.cat.res.release(this._url)),this.playOnAwake=!1,this.enabled=!0,this.clip=o,this._url=e,t&&t()}))}update(e){this.currentTime>0&&(this._isPlay=!0),this._isPlay&&0==this.playing&&(this._isPlay=!1,this.enabled=!1,this.onComplete&&this.onComplete())}release(){this._url&&(this.cat.res.release(this._url),this._url=null)}}class z{cat;constructor(e){this.cat=e}}var Z;!function(e){e.MUSIC_ON="AudioEventConstant/MUSIC_ON",e.MUSIC_OFF="AudioEventConstant/MUSIC_OFF",e.EFFECT_ON="AudioEventConstant/EFFECT_ON",e.EFFECT_OFF="AudioEventConstant/EFFECT_OFF",e.PAUSE_AUDIO="AudioEventConstant/PAUSE_AUDIO",e.RESUME_AUDIO="AudioEventConstant/RESUME_AUDIO"}(Z||(Z={}));class Y extends z{local_data={};music;effect;_volume_music=1;_volume_effect=1;_switch_music=!0;_switch_effect=!0;local_store_key="game_audio";extra={};constructor(e){super(e),this.local_store_key=this.cat.audio_local_store_key;var t=new o("UIAudioManager");n.addPersistRootNode(t);var s=new o("UIMusic");s.parent=t,this.music=s.addComponent(X).initAudio(e);var i=new o("UIEffect");i.parent=t,this.effect=i.addComponent(W).initAudio(e),this.load()}setMusicComplete(e=null){this.music.onComplete=e}playMusic(e,t){this.music.loop=!0,e&&this.music.load(e,(()=>{this._switch_music&&this.music?.play(),t&&t()}))}stopMusic(){0!=this.music.state&&this.music?.stop()}pauseMusic(){1==this.music.state&&this.music?.pause()}resumeMusic(){[0,2].includes(this.music.state)&&this.music?.play()}get progressMusic(){return this.music.progress}set progressMusic(e){this.music.progress=e}get volumeMusic(){return this._volume_music}set volumeMusic(e){this._volume_music=e,this.music.volume=e}get switchMusic(){return this._switch_music}set switchMusic(e){if(r("设置背景音乐开关值",e,this._switch_music),e==this._switch_music)return;this._switch_music=e,e?this.resumeMusic():this.pauseMusic();const t=e?Z.MUSIC_ON:Z.MUSIC_OFF;this.cat.event.has(t)&&this.cat.event.dispatchEvent(t),this.save()}async playEffect(e){this._switch_effect&&e&&await this.effect.load(e).then((()=>{this.effect.play()}))}stopEffect(){this.effect?.stop()}get volumeEffect(){return this._volume_effect}set volumeEffect(e){this._volume_effect=e,this.effect.volume=e}get switchEffect(){return this._switch_effect}set switchEffect(e){if(e==this._switch_effect)return;this._switch_effect=e,e?this.effect?.play():this.effect?.stop();const t=e?Z.EFFECT_ON:Z.EFFECT_OFF;this.cat.event.has(t)&&this.cat.event.dispatchEvent(t),this.save()}resumeAll(){this.switchMusic&&this.music?.play(),this.switchEffect&&this.effect?.play()}pauseAll(){this.music?.pause(),this.effect?.pause()}stopAll(){this.music?.stop(),this.effect?.stop()}save(){this.local_data.volume_music=this._volume_music,this.local_data.volume_effect=this._volume_effect,this.local_data.switch_music=this._switch_music,this.local_data.switch_effect=this._switch_effect,this.local_data.extra=this.extra;let e=JSON.stringify(this.local_data);return this.cat.storage.set(this.local_store_key,e),this}load(){try{let e=this.cat.storage.get(this.local_store_key);this.local_data=JSON.parse(e),this._volume_music=this.local_data.volume_music,this._volume_effect=this.local_data.volume_effect,this._switch_music=this.local_data.switch_music,this._switch_effect=this.local_data.switch_effect,this.extra=this.local_data.extra}catch(e){this.local_data={},this._volume_music=.6,this._volume_effect=1,this._switch_music=!0,this._switch_effect=!0,this.extra={}}this.music&&(this.music.volume=this._volume_music),this.effect&&(this.effect.volume=this._volume_effect)}}class ee extends z{_key=null;_iv=null;_id="";init(e,t){this.cat.util.encryptUtil.initCrypto(e,t),this._key=this.cat.util.encryptUtil.md5(e),this._iv=this.cat.util.encryptUtil.md5(t)}setUser(e){this._id=e}set(e,t){if(null!=(e=`${e}_${this._id}`)){if(M||(e=this.cat.util.encryptUtil.md5(e)),null==t)return console.warn("存储的值为空,则直接移除该存储"),void this.remove(e);if("function"!=typeof t){if("object"==typeof t)try{t=JSON.stringify(t)}catch(e){return void console.error(`解析失败,str = ${t}`)}else"number"==typeof t&&(t+="");M||null==this._key||null==this._iv||(t=this.cat.util.encryptUtil.aesEncrypt(`${t}`,this._key,this._iv)),a.localStorage.setItem(e,t)}else console.error("储存的值不能为方法")}else console.error("存储的key不能为空")}get(e,t){if(null==e)return console.error("存储的key不能为空"),null;e=`${e}_${this._id}`,M||(e=this.cat.util.encryptUtil.md5(e));let s=a.localStorage.getItem(e);return null==s||""===s||M||null==this._key||null==this._iv||(s=this.cat.util.encryptUtil.aesDecrypt(s,this._key,this._iv)),null===s?t:s}getNumber(e,t=0){var s=this.get(e);return Number(s)||t}getBoolean(e){var t=this.get(e);return Boolean(t)||!1}getJson(e,t){var s=this.get(e);return s&&JSON.parse(s)||t}remove(e){null!=e?(e=`${e}_${this._id}`,M||(e=this.cat.util.encryptUtil.md5(e)),a.localStorage.removeItem(e)):console.error("存储的key不能为空")}clear(){a.localStorage.clear()}}function te(e,t,s,i){var o,n=arguments.length,r=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(n<3?o(r):n>3?o(t,s,r):o(t,s))||r);return n>3&&r&&Object.defineProperty(t,s,r),r}function se(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}"function"==typeof SuppressedError&&SuppressedError;class ie extends c{props={};data={};autorunDisposers=[];reactionDisposers=[];messageManagers=[];hook={destroyed:()=>{},started:()=>{}};initUI(){}__preload(){this.initUI(),this.onAutoObserver()}constructor(){super(),F(this,{props:U,data:U})}onAutoObserver(){}addAutorun(e){return(Array.isArray(e)?e:[e]).forEach((e=>{const t=H(e);this.autorunDisposers.push(t)})),this}addReaction(e,t,s){const i=P(e,t,s);return this.reactionDisposers.push(i),this}addAudoListener(e){return this.messageManagers.includes(e)||this.messageManagers.push(e),e}_onPreDestroy(){this.autorunDisposers.forEach((e=>{e()})),this.reactionDisposers.forEach((e=>{e()})),this.autorunDisposers=[],this.reactionDisposers=[],super._onPreDestroy()}onDisable(){this.onHide(),st.event.deleteEventByComponent(this),this.messageManagers.forEach((e=>{e.deleteEventByComponent(this)})),this.messageManagers=[],this.removeListener()}onEnable(){this.onShow(),this.addListener(),this.onEventListener()}onEventListener(){}addListener(){}removeListener(){}addToParent(e,t){let s=e instanceof l?h(e):e instanceof c?e.node:e;return this.setOptions(t),s.addChild(this.node),this}setOptions(e){if(e)for(let t in e)switch(t){case"hook":e.hook&&(this.hook=e.hook);break;case"props":null!==e.props&&"object"==typeof e.props&&(this.props=e.props);break;case"data":null!==e.data&&"object"==typeof e.data&&(this.data=e.data)}}setUpdateData(e){return e&&Object.assign(this.data,e),this}setUpdateProps(e){return this.props,e&&Object.assign(this.props,e),this}removeAndDestroy(){d(this?.node)&&(this.node.removeFromParent(),this.node.destroy())}setPosition(e){return this.node.setPosition(e),this}setScale(e){return this.node.setScale(e),this}setAngle(e){return this.node.angle=e,this}setRotation(e){return this.node.setRotation(e),this}onShow(){}onHide(){}setNodeAndChildrenLayer(e){return oe(this.node,e),this}}const oe=(e,t)=>{e.layer="string"==typeof t?2**p.nameToLayer(t):t,e?.children.forEach((e=>{oe(e,t)}))};class ne extends ie{lastEnterDirection="center";screen;isClosing=!1;root;constructor(){super(),this._init()}_init(){this.root=this.node,this.screen=u.getVisibleSize()}async showTween({isMotion:e=!0,direction:t="center",duration:s=.1,isBounce:i=!0,bounceDuration:o=.05}){if(this.lastEnterDirection=t,e){const e=this.node.getComponent(f);let o,n;e&&(e.updateAlignment(),e.enabled=!1),_(1.1,1.1,1),"center"==t?(o=_(.01,.01,.01),n=_(1,1,1)):(o="left"==t?_(-this.screen.width,0,0):"right"==t?_(this.screen.width,0,0):_(0,"top"==t?this.screen.height:-this.screen.height,0),n=_(0,0,0)),await this.handle(t,s,o,n,i),e&&(e.enabled=!0)}}async hideTween({isMotion:e=!0,direction:t,duration:s=.1}){if(t=t||this.lastEnterDirection,!this.isClosing){if(this.isClosing=!0,m(this.node).removeSelf(),e){const e=this.node.getComponent(f);let i,o;e&&(e.enabled=!1),"center"==t?(i=this.node.scale,o=_(0,0,0)):(o="left"==t?_(-this.screen.width,0,0):"right"==t?_(this.screen.width,0,0):_(0,"top"==t?this.screen.height:-this.screen.height,0),i=this.node.getPosition()),await this.handle(t,s,i,o,!1)}this.removeAndDestroy()}}async handle(e,t,s,i,o){"center"==e?this.node.setScale(s):this.node.setPosition(s),await this.deftween(t,{["center"==e?"scale":"position"]:i},o)}deftween(e,t,s,i){return new Promise(((s,i)=>{m(this.node).to(e,t).call((()=>{s()})).start()}))}}const{ccclass:re,property:ae}=t;var ce;!function(e){e[e.EFFECT=0]="EFFECT",e[e.BGM=1]="BGM"}(ce||(ce={}));class le extends ie{type=ce.EFFECT;clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=new e;onEnable(){super.onEnable(),this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,st.event.on(Z.EFFECT_ON,this.onPlayEffectHandler,this).on(Z.EFFECT_OFF,this.onStopEffectHandler,this).on(Z.MUSIC_ON,this.onPlayMusicHandler,this).on(Z.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){super.__preload();const{volumeEffect:e,volumeMusic:t}=st.audio;this.audioSource.volume=this.type===ce.BGM?t:e}start(){}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:e,switchMusic:t}=st.audio;this.audioSource.playing||!(this.type===ce.BGM?t:e)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}te([ae({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(ce)}),se("design:type",Object)],le.prototype,"type",void 0),te([ae({tooltip:"音源",type:s}),se("design:type",Object)],le.prototype,"clip",void 0),te([ae({tooltip:"循环"}),se("design:type",Object)],le.prototype,"loop",void 0),te([ae({tooltip:"音量"}),se("design:type",Object)],le.prototype,"volume",void 0),te([ae({tooltip:"是否启用自动播放"}),se("design:type",Object)],le.prototype,"playOnAwake",void 0);const{ccclass:he,property:de}=t;class pe extends ne{type=ce.EFFECT;clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=new e;onEnable(){super.onEnable(),st.event.on(Z.EFFECT_ON,this.onPlayEffectHandler,this).on(Z.EFFECT_OFF,this.onStopEffectHandler,this).on(Z.MUSIC_ON,this.onPlayMusicHandler,this).on(Z.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,super.__preload();const{volumeEffect:e,volumeMusic:t}=st.audio;this.audioSource.volume=this.type===ce.BGM?t:e}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:e,switchMusic:t}=st.audio;this.audioSource.playing||!(this.type===ce.BGM?t:e)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}te([de({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(ce)}),se("design:type",Object)],pe.prototype,"type",void 0),te([de({tooltip:"音源",type:s}),se("design:type",Object)],pe.prototype,"clip",void 0),te([de({tooltip:"循环"}),se("design:type",Object)],pe.prototype,"loop",void 0),te([de({tooltip:"音量"}),se("design:type",Object)],pe.prototype,"volume",void 0),te([de({tooltip:"是否启用自动播放"}),se("design:type",Object)],pe.prototype,"playOnAwake",void 0);const{ccclass:ue,property:fe}=t;var _e;!function(e){e[e.FIXED=0]="FIXED",e[e.SLIDE=1]="SLIDE"}(_e||(_e={}));let me=class extends ie{fixed_node;slide_node;fixed_label;slide_label;onLoad(){this.fixed_node.active=this.slide_node.active=!1}start(){this.show()}async show(){return new Promise((async(e,t)=>{const{title:s,type:i,fixed_time:o}=this.props;if(i==_e.FIXED){this.fixed_node.active=!0,this.fixed_label.string=`${s}`,this.fixed_label.updateRenderData(!0);const t=this.fixed_label.node.getComponent(v).height;t-this.fixed_node.getComponent(v).height>0&&(this.fixed_node.getComponent(v).height=t+100),this.scheduleOnce((()=>{this.node.destroy(),e()}),o)}else{this.slide_node.active=!0,this.slide_label.string=`${s}`,this.slide_label.updateRenderData(!0);const t=this.slide_label.node.getComponent(v).width;this.slide_node.getComponent(v).width-t<100&&(this.slide_node.getComponent(v).width=t+100),this.playAnim(this.node).then((()=>{e()}))}}))}playAnim(e){return new Promise(((t,s)=>{const i=this.node.getComponent(E),o=m(i).delay(1.2).to(.5,{opacity:0}).call((()=>{b.stopAllByTarget(e),this.node.destroy(),t()}));m(e).by(.5,{position:_(0,400,0)}).call((()=>{o.start()})).start()}))}onDestroy(){b.stopAllByTarget(this.node),this.unscheduleAllCallbacks()}};var ge;te([fe({type:o,tooltip:"固定节点"}),se("design:type",o)],me.prototype,"fixed_node",void 0),te([fe({type:o,tooltip:"滑动节点"}),se("design:type",o)],me.prototype,"slide_node",void 0),te([fe({type:w,tooltip:"固定标签节点"}),se("design:type",w)],me.prototype,"fixed_label",void 0),te([fe({type:w,tooltip:"滑动标签节点"}),se("design:type",w)],me.prototype,"slide_label",void 0),me=te([ue("CoreToast")],me),function(e){e.EVENT_SHOW="GlobalEventConstant/EVENT_SHOW",e.EVENT_HIDE="GlobalEventConstant/EVENT_HIDE",e.GAME_RESIZE="GlobalEventConstant/GAME_RESIZE",e.EVENT_CLOSE="GlobalEventConstant/EVENT_CLOSE",e.ONLINE="GlobalEventConstant/ONLINE",e.OFFLINE="GlobalEventConstant/OFFLINE",e.ROOT_MASK_UPDATE="GlobalEventConstant/ROOT_MASK_UPDATE",e.ROOT_MASK_CHANGE="GlobalEventConstant/ROOT_MASK_CHANGE"}(ge||(ge={}));const{ccclass:ye,property:ve}=t;let Ee=class extends ne{scene_mask_node;ui_container;gui=null;onLoad(){this.setSceneMaskActive(!1)}get scene_mask(){return this.scene_mask_node.getComponent(Le)}get brother(){return this.ui_container.children||[]}get tweenChildren(){return this.scene_mask.tween.children}onEventListener(){st.event.on(ge.ROOT_MASK_CHANGE,this.uiMaskChanged,this)}addMask(){const e=this.brother[this.brother.length-1];e&&this.scene_mask.node.setSiblingIndex(e.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}subMask(){const e=this.brother[this.brother.length-2];e&&this.scene_mask.node.setSiblingIndex(e.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}blockMaskSiblingIndexChanged(){this.tweenChildren.length>1||this.brother.length>1?this.show():this.hide()}addNodeToTween(e){return d(this)&&this.scene_mask&&this.scene_mask.tween.addChild(e),this}show(){this.setSceneMaskActive(!0)}hide(){this.setSceneMaskActive(!1)}setGui(e){return this.gui=e,this}uiMaskChanged(){this.blockMaskSiblingIndexChanged()}setSceneMaskActive(e){this.scene_mask.node.active=!this.gui.root_mask.active&&e}};te([ve({type:o}),se("design:type",o)],Ee.prototype,"scene_mask_node",void 0),te([ve({type:o}),se("design:type",o)],Ee.prototype,"ui_container",void 0),Ee=te([ye("CoreUIContainer")],Ee);class be extends ne{onEnable(){super.onEnable(),this.updateMask()}onDisable(){super.onDisable(),this.updateMask()}updateMask(){st.event.dispatchEvent(ge.ROOT_MASK_UPDATE)}}const{ccclass:we,property:Ce}=t;let ke=class extends be{title;loadingTween;loading_rotate=0;onAutoObserver(){this.addAutorun([()=>{this.props?.title&&(this.title.string=`${this.props?.title}`),this.title.node.active=!!this.props?.title?.length},()=>{this.getComponent(C).enabled=!!this.props?.mask}])}update(e){this.loading_rotate+=220*e,this.loadingTween.setRotationFromEuler(0,0,-this.loading_rotate%360),this.loading_rotate>360&&(this.loading_rotate-=360)}};te([Ce({type:w,tooltip:"标题"}),se("design:type",w)],ke.prototype,"title",void 0),te([Ce({type:o,tooltip:"动画"}),se("design:type",o)],ke.prototype,"loadingTween",void 0),ke=te([we("CoreShowLoading")],ke);const{ccclass:Oe,property:xe}=t;var Se;!function(e){e.RECONNECTED="重连成功",e.RECONNECTING="正在重连",e.MAX_RECONNECT="重连次数超出限制,请检查网络",e.RECONNECTED_ERROR="重连失败,请检查网络",e.CONNECT_PARAM_ERROR="游戏参数错误,请重新加载",e.KICK="账号已下线",e.OFFLINE="网络已断开",e.ONLINE="网络已连接",e.GAME_ERROR="连接游戏服错误"}(Se||(Se={}));let Te=class extends be{common_prompt_text;btn_confirm;is_close=!1;props={content:null};initUI(){this.btn_confirm.node.active=!1}onLoad(){this.btn_confirm.node.on(k.EventType.CLICK,this.onConfirmHandler,this),this.addAutorun([()=>{this.common_prompt_text.string=this.props.content??""}])}onDestroy(){this.unscheduleAllCallbacks()}updateProps(e){this.updatePromptText(e,e==Se.RECONNECTING)}updatePromptText(e,t=!1){if(this.unscheduleAllCallbacks(),this.props.content=e,r("更新提示文案:",e),t){let t=0;const s=()=>{t=(t+1)%4,this.common_prompt_text.string=e+["","·","··","···"][t]};this.schedule(s,.5)}}onConfirmHandler(){this.is_close=!0,st.gui.hideReconnect()}};te([xe({type:w,tooltip:"通用提示文本"}),se("design:type",w)],Te.prototype,"common_prompt_text",void 0),te([xe({type:k,tooltip:"确定按钮"}),se("design:type",k)],Te.prototype,"btn_confirm",void 0),Te=te([Oe("CoreReconnection")],Te);const{ccclass:Ne,property:Ie}=t;let Re=class extends be{text;btn_confirm;onLoad(){this.btn_confirm.node.on(k.EventType.CLICK,this.onConfrimHandler,this)}start(){this.props&&this.updateProps(this.props)}onConfrimHandler(){this.props?.confrim?.(),st.gui.hideNotice()}updateProps(e){this.text.string=`${e.text}`}};te([Ie({type:w,tooltip:"提示文本"}),se("design:type",w)],Re.prototype,"text",void 0),te([Ie({type:k,tooltip:"确定按钮"}),se("design:type",k)],Re.prototype,"btn_confirm",void 0),Re=te([Ne("CoreNotice")],Re);class Ae extends ie{isReload}const{ccclass:Me,property:De}=t;var Fe;!function(e){e[e.UI=0]="UI",e[e.LOADING=1]="LOADING",e[e.TOAST=2]="TOAST",e[e.RECONNECTTION=3]="RECONNECTTION",e[e.NOTICE=4]="NOTICE"}(Fe||(Fe={}));let Ue=class extends ie{reconnection_ui_prefab;toast_ui_prefab;loading_ui_prefab;notice_ui_prefab;ui_prefab;root_ui;root_toast;root_mask;cat;ui_container_component;reconnection_ui_component;notice_ui_component;loading_ui_component;toast_ui_component;currentScene;onEventListener(){this.cat.event.on(ge.ROOT_MASK_UPDATE,this.onRootUpdate,this)}init(e){this.cat=e;const t=n.getScene();return r("init scene"),t&&this.changeScene(t),this}start(){this.onRootUpdate()}lastShowTime=0;toastQueue=[];minInterval=200;showToast(e){this.toastQueue.push(e),this.processQueueWithInterval()}processQueueWithInterval(){if(0===this.toastQueue.length)return;const e=Date.now()-this.lastShowTime;if(e<this.minInterval){const t=(this.minInterval-e)/1e3;this.scheduleOnce((()=>this.showNextToast()),t)}else this.showNextToast()}showNextToast(){if(0===this.toastQueue.length)return;const e=this.toastQueue.shift();this.lastShowTime=Date.now();h(this.toast_ui_prefab).getComponent(me).addToParent(this.root_toast,{props:e}),this.processQueueWithInterval()}hideToast(){return this.toast_ui_component?.removeAndDestroy(),this}showLoading({title:e="",mask:t=!0,black:s=!0}={}){if(r("showLoading",e),this.loading_ui_component)this.loading_ui_component.setOptions({props:{title:e,mask:t,black:s}});else{const i=h(this.loading_ui_prefab);this.loading_ui_component=i.getComponent(ke).addToParent(this.root_ui,{props:{title:e,mask:t,black:s}})}return this}hideLoading(){return this.loading_ui_component?.removeAndDestroy(),this.loading_ui_component=null,this}showReconnect(e){if(this.reconnection_ui_component)this.reconnection_ui_component.setUpdateProps({content:e});else{const t=h(this.reconnection_ui_prefab);this.reconnection_ui_component=t.getComponent(Te).addToParent(this.root_ui,{props:{content:e}})}return this}hideReconnect(){return this.reconnection_ui_component?.removeAndDestroy(),this.reconnection_ui_component=null,this}showNotice(e){const t=h(this.notice_ui_prefab);return this.notice_ui_component=t.getComponent(Re).addToParent(this.root_ui,{props:e}),this}hideNotice(){return this.notice_ui_component?.removeAndDestroy(),this}loadScene(e,t,s){r("加载场景",e,t,s);let i={},o=s??!1;return"boolean"==typeof t?o=t:i=t??{},r("当前场景",n.getScene()?.uuid,n.getScene()?.name),n.once(O.EVENT_BEFORE_SCENE_LAUNCH,(e=>{r("Director.EVENT_BEFORE_SCENE_LAUNCH",e),this.changeScene(e,i,o)})),n.loadScene(e),this}resetScene(e=""){return e=e||this.currentScene,this.loadScene(e)}cleanScene(){this.resetScene().hideLoading().hideNotice().hideReconnect().hideToast()}changeScene(e,t,s){this.currentScene=e.name,this.createUILayer(e);const i=e.getComponentInChildren(Ae);i&&(i.isReload=s??!1),i?.setOptions(t)}createUILayer(e){this.ui_container_component?.removeAndDestroy(),this.ui_container_component=null;const t=h(this.ui_prefab);this.ui_container_component=t.getComponent(Ee).setGui(this).addToParent(e)}reloadScene(){this.loadScene(this.currentScene,!0)}async closeUI(e,t){const{component:s}=this.findUIBaseLayer(e,!1);s&&(s.setOptions({...t?.hook??{},...t?.props??{}}),await s.hideTween(t||{}),this.ui_container_component?.subMask())}async openUI(e,t){const{rootNode:s,component:i}=this.findUIBaseLayer(e,!0);s.getComponent(ne),i?.setOptions(t),s&&this.ui_container_component?.addNodeToTween(s).addMask(),i&&await i.showTween(t||{}),this.ui_container_component?.ui_container&&i?.addToParent(this.ui_container_component.ui_container)}findUIBaseLayer(e,t){let s,n=null;if(e instanceof o){s=e;const t=e.components.filter((e=>e instanceof ne));if(!t.length)return i(`${e.name}节点未找到继承自BaseLayer的组件`),{rootNode:s,component:n};1==t.length?n=t[0]:x(`${e.name}节点存在多个继承自BaseLayer的组件`)}else if(s=e.node,n=e,t){for(;s.parent;)s=s.parent;n.root=s}else s=e.root;return{rootNode:s,component:n}}onRootUpdate(){const e=this.root_ui.children.length;if(this.root_mask.active=e>1,e>1){const t=this.root_ui.children[e-2];this.root_mask.setSiblingIndex(t.getSiblingIndex())}this.cat.event.dispatchEvent(ge.ROOT_MASK_CHANGE)}};te([De({type:l,tooltip:"断线重连UI预制体"}),se("design:type",l)],Ue.prototype,"reconnection_ui_prefab",void 0),te([De({type:l,tooltip:"提示UI预制体"}),se("design:type",l)],Ue.prototype,"toast_ui_prefab",void 0),te([De({type:l,tooltip:"加载UI预制体"}),se("design:type",l)],Ue.prototype,"loading_ui_prefab",void 0),te([De({type:l,tooltip:"公告UI预制体"}),se("design:type",l)],Ue.prototype,"notice_ui_prefab",void 0),te([De({type:l,tooltip:"UI层预制体"}),se("design:type",l)],Ue.prototype,"ui_prefab",void 0),te([De({type:o,tooltip:"root-UI层"}),se("design:type",o)],Ue.prototype,"root_ui",void 0),te([De({type:o,tooltip:"root-组件层"}),se("design:type",o)],Ue.prototype,"root_toast",void 0),te([De({type:o,tooltip:"root-mask"}),se("design:type",o)],Ue.prototype,"root_mask",void 0),Ue=te([Me("Gui")],Ue);const{ccclass:He,property:Pe}=t;let Le=class extends ie{tween};var Be;te([Pe({type:o,tooltip:"动画节点"}),se("design:type",o)],Le.prototype,"tween",void 0),Le=te([He("CoreBlackMask")],Le),function(e){e.Root="prefabs/root",e.Toast="prefabs/toast",e.BlackMask="prefabs/black-mask",e.Loading="prefabs/loading",e.Notice="prefabs/notice",e.Reconnection="prefabs/reconnection"}(Be||(Be={}));class Ge extends z{gui;#e="resources";getGuiPrefabByType=(e,t)=>new Promise(((s,i)=>{console.log(e,`${t}`),this.cat.res.load(e,t,((e,t)=>{e?i(e):s(t)}))}));async init(){this.#e=this.cat.gui_bundle_name;const e=await this.getGuiPrefabByType(this.#e,Be.Root),t=h(e);return this.gui=t.getComponent(Ue).init(this.cat),n.addPersistRootNode(t),this}}class $e{get=(e,t,s="resources")=>S.getBundle(s).get(e,t);isAssetType=e=>"function"==typeof e&&e.prototype instanceof T;async load(...e){let t=null,s=null,i=null;"string"==typeof e[0]&&"string"==typeof e[1]&&(t=e.shift());let o=e.shift();this.isAssetType(e[0])&&(s=e.shift()),2==e.length&&(i=e.shift());const n=e.shift();let r=N;if(t&&"resources"!=t){S.bundles.has(t)||await this.loadBundle(t);let e=S.bundles.get(t);e&&(r=e)}i&&n?r.load(o,s,i,n):n?r.load(o,s,n):r.load(o,s)}async loadDir(...e){let t=null,s=null,i=null,o=null;"string"==typeof e[0]&&"string"==typeof e[1]&&(t=e.shift());let n=e.shift();this.isAssetType(e[0])&&(s=e.shift()),2==e.length&&(i=e.shift()),o=e.shift();let r=N;if(t&&"resources"!=t){S.bundles.has(t)||await this.loadBundle(t);let e=S.bundles.get(t);e&&(r=e)}i&&o?r.loadDir(n,s,i,o):o?r.loadDir(n,s,o):r.loadDir(n,s)}loadRemote(e,...t){var s,i=null;2==t.length&&(i=t.shift()),s=t.shift(),S.loadRemote(e,{ext:".png",...i},s)}loadBundle=(e,t)=>new Promise(((s,i)=>{const o=(e,t)=>{if(e)return i(e);s(t)};t?S.loadBundle(e,{version:t},o):S.loadBundle(e,o)}));releasePrefabtDepsRecursively=e=>{var t=S.assets.get(e);(S.releaseAsset(t),t instanceof l)&&S.dependUtil.getDepsRecursively(e).forEach((e=>{S.assets.get(e).decRef()}))};release=(e,t="resources")=>{var s=S.getBundle(t);if(s){var i=s.get(e);i&&this.releasePrefabtDepsRecursively(i._uuid)}};releaseDir=(e,t="resources")=>{var s=S.getBundle(t),i=s?.getDirWithPath(e);i?.map((e=>{this.releasePrefabtDepsRecursively(e.uuid)})),!e&&"resources"!=t&&s&&S.removeBundle(s)};dump=()=>{S.assets.forEach(((e,t)=>{r(S.assets.get(t))})),r(`当前资源总数:${S.assets.count}`)}}class je{events=new Map;on(e,t,s){if(!e||!t)return x(`注册【${e}】事件的侦听器函数为空`),this;const i=this.events.get(e)??this.events.set(e,new Map).get(e);return i.has(s)?(x(`名为【${e}】的事件重复注册侦听器`),this):(i.set(s,t),this)}once(e,t,s){let i=(o,n)=>{this.off(e,i,s),i=null,t.call(s,o,n)};this.on(e,i,s)}off(e,t,s){if(!this.events.get(e)?.has(s))return this;const o=this.events.get(e);return o.get(s)!==t?(i(`${s}注册事件和取消事件不一致`),this):(o.delete(s),this)}dispatchEvent(e,t){if(!this.events.has(e))return this;const s=this.events.get(e);for(const[i,o]of s)o.call(i,t,e);return this}offAll(){this.events.clear()}has(e){return this.events.has(e)}deleteEventByComponent(e){for(const[t,s]of this.events){for(const[t]of s)t===e&&s.delete(t);0===s.size&&this.events.delete(t)}}}let qe=null;const Ke={stringify:e=>{const t={ct:e.ciphertext.toString(L.enc.Base64)};return e.iv&&(t.iv=e.iv.toString()),e.salt&&(t.s=e.salt.toString()),JSON.stringify(t)},parse:e=>{const t=JSON.parse(e),s=L.lib.CipherParams.create({ciphertext:L.enc.Base64.parse(t.ct)});return t.iv&&(s.iv=L.enc.Hex.parse(t.iv)),t.s&&(s.salt=L.enc.Hex.parse(t.s)),s}};var Ve=Object.freeze({__proto__:null,JsonFormatter:Ke,aesDecrypt:(e,t,s)=>L.AES.decrypt(e,t,{iv:qe,format:Ke}).toString(L.enc.Utf8),aesEncrypt:(e,t,s)=>L.AES.encrypt(e,t,{iv:qe,format:Ke}).toString(),initCrypto:(e,t)=>{qe=L.enc.Hex.parse(t)},md5:e=>L.MD5(e).toString()});class We extends z{encryptUtil=Ve}class Je extends ${isNeedReconnect=!1;isOnline=!0;isInBackground=!1;running=!1;index=0;logBlackList=[];constructor(e,t,s){super(e,t,s),this.running=!0,this.addEvent()}addEvent(){this.on("connected",(()=>this.handleEvent({type:"connected"}))).on("reconnected",(()=>this.handleEvent({type:"reconnected"}))).on("disconnect",(e=>this.handleEvent({type:"disconnect",ev:e}))).on("handshakeError",(e=>this.handleEvent({type:"handshakeError",ret:e}))).on("kick",(()=>this.handleEvent({type:"kick"}))).on("reconnecting",(()=>this.handleEvent({type:"reconnecting"}))).on("maxReconnect",(()=>this.handleEvent({type:"maxReconnect"}))).on("error",(e=>this.handleEvent({type:"error",ev:e}))),st.event.on(ge.EVENT_SHOW,this.onShowHandler,this).on(ge.EVENT_HIDE,this.onHideHandler,this).on(ge.ONLINE,this.onOnlineHandler,this).on(ge.OFFLINE,this.onOfflineHandler,this)}removeEvent(){this.removeAllListeners(),st.event.off(ge.EVENT_SHOW,this.onShowHandler,this).off(ge.EVENT_HIDE,this.onHideHandler,this).off(ge.ONLINE,this.onOnlineHandler,this).off(ge.OFFLINE,this.onOfflineHandler,this)}onShowHandler(){r("[SHOW]"),this.isInBackground=!1,this.isNeedReconnect&&this.isOnline&&this.handleEvent({type:"show"})}onHideHandler(e){r("[HIDE]"),e().finally((()=>{this.isInBackground=!0,this.handleEvent({type:"hide"})}))}onOnlineHandler(){this.isOnline=!0,r("正在检查网络状态:"+(this.isOnline?"在线":"断开")),this.handleEvent({type:"online"})}onOfflineHandler(){this.isOnline=!1,r("正在检查网络状态:"+(this.isOnline?"在线":"断开")),this.handleEvent({type:"offline"})}async handleEvent(e){if(this.running)switch(e.type){case"init":break;case"connected":r("ws连接成功状态 connected"),this.isNeedReconnect=!1;break;case"reconnected":r("ws重连成功状态 reconnected",this.isSocketConnected),this.isNeedReconnect=!1,r("%c 重连成功状态","background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",this.index);try{await this.connectRequest(),r("重连成功状态 connectRequest "),st.gui.showToast({title:Se.RECONNECTED}),st.gui.hideReconnect().hideLoading(),st.gui.reloadScene()}catch(e){console.error(e),st.gui.showReconnect(Se.GAME_ERROR)}break;case"disconnect":r("断开连接状态 disconnect",e.ev),r("%c 断开连接状态","background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",this.index),this.isNeedReconnect=!0,this.handleEvent({type:"reconnect"});break;case"handshakeError":r("参数错误状态 handshakeError",e.ret),st.gui.showReconnect(Se.CONNECT_PARAM_ERROR),this.handleEvent({type:"destroy"});break;case"kick":r("%c 被踢出状态","background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",this.index),r("被踢出状态 kick"),st.gui.showReconnect(Se.KICK),this.handleEvent({type:"destroy"});break;case"reconnecting":r("正在重连状态 reconnecting"),this.isOnline&&this.isInBackground;break;case"maxReconnect":r("超出最大重连状态 maxReconnect"),st.gui.showReconnect(Se.MAX_RECONNECT);break;case"error":this.isOnline&&(r("ws报错状态 error",e.ev),"string"==typeof e.ev&&st.gui.showToast({title:e.ev}),st.gui.showReconnect(Se.RECONNECTED_ERROR));break;case"online":st.gui.showReconnect(Se.ONLINE),r("在线状态 online"),this.handleEvent({type:"reconnect"});break;case"offline":this.disconnect(!0),r("离线状态 offline"),this.isNeedReconnect=!0,st.gui.showReconnect(Se.OFFLINE);break;case"show":r("前台状态 show"),this.handleEvent({type:"reconnect"});break;case"hide":r("后台状态 hide"),this.disconnect(!0),this.isNeedReconnect=!0;break;case"reconnect":r("重连状态 reconnect"),this.isNeedReconnect&&!this.isInBackground&&this.isOnline&&(st.gui.showLoading({title:"正在重连"}),this.reset(),this.index+=1,r("%c ws重连次数","background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",this.index),this.reconnectImmediately());break;case"destroy":r("销毁状态 destroy"),this.destroyStateMachine();break;default:r("Unknown event:",e.type)}}destroy(){this.handleEvent({type:"destroy"})}disconnect(e=!1){super.disconnect(e)}destroyStateMachine(){r("Destroying state machine"),this.running=!1,this.removeEvent(),this.disconnect(!0)}request(e,t,s){return D&&r(`%c ws客户端消息 %c [Request][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7d3d ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(t.desc,t.message)),new Promise(((o,n)=>{super.request(e,t,s).then((t=>{D&&r(`%c ws服务端消息 %c [Response][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7daa ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(s,t)),o(t)}),(e=>{i("request err",e),n(e)}))}))}async Request(e,t,s,{audOptions:i={forwardReq:!1,forwardResp:!1},show_log:o=!0}={}){if(!this.isSocketConnected)throw""+(this.isSocketConnected?"未加入战局/观战":"Socket未连接");return D&&o&&r(`%c ws客户端消息 %c [Request][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7d3d ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(t.desc,t.message)),this.GameRequest(e,t,s,G(j,i))}async GameRequest(e,t,s,i){return new Promise(((o,n)=>{super.GameRequest(e,t,s,i).then((t=>{D&&r(`%c ws服务端消息 %c [Response][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7daa ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(s,t)),o(t)}),(e=>{st.gui.showToast({title:e.msg}),n(e)}))}))}async gameRequest(e,t,s){return D&&r(`%c ws客户端消息 %c [Request][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7d3d ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(t.desc,t.message)),super.gameRequest(e,t,s)}GameNotify=async(e,t,s)=>{try{super.GameNotify(e,t,s)}catch(t){throw console.error(`Error in connectRequest for route ${e}: `,t),t}};Notify=async(e,t,{audOptions:s={forwardReq:!1,forwardResp:!1},show_log:i=!0}={})=>{this.isSocketConnected&&(D&&i&&r(`%c ws客户端消息 %c[Notify][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7d3d ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(t.desc,t.message)),this.GameNotify(e,t,G(j,s)))};subscribe(e,t,s){return super.subscribe(e,t,(i=>{D&&!this.logBlackList.includes(e)&&r(`%c ws服务端消息:[${new Date}] %c ${e} %c`,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#410083 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(t,i)),st.event.dispatchEvent(e,B(t,i)),s?.(i)})),this}onData(e){super.onData(e)}}const{ccclass:Qe,property:Xe}=t;let ze=class extends ne{default_title=null;title;prompt_content_str;prompt_content_spriteFrame;btn_confirm;confirm_spriteFrame;btn_cancel;cancel_spriteFrame;btn_close;isConfirm=!1;props={title:this.default_title,content:null,confirmCB:()=>{},cancelCB:()=>{},style:null};onLoad(){this.btn_cancel.node.on(k.EventType.CLICK,this.onCancelHandler,this),this.btn_confirm.node.on(k.EventType.CLICK,this.onConfirmHandler,this),this.btn_close.node.on(k.EventType.CLICK,this.onCloseHandler,this),this.addAutorun([()=>{this.title.spriteFrame=this.props?.title||this.default_title},()=>{this.props.content instanceof I?this.prompt_content_spriteFrame.spriteFrame=this.props.content:"string"==typeof this.props.content?this.prompt_content_str.string=this.props.content:console.error("未知类型的【UIModal】内容")},()=>{null===this.props?.style?.confirm?this.btn_confirm.node.active=!1:(this.btn_confirm.node.active=!0,this.btn_confirm.getComponent(R).spriteFrame=this.props.style?.confirm||this.confirm_spriteFrame),null===this.props?.style?.cancel?this.btn_cancel.node.active=!1:(this.btn_cancel.node.active=!0,this.btn_cancel.getComponent(R).spriteFrame=this.props.style?.cancel||this.cancel_spriteFrame)}])}close(){this.props.cancelCB?.(),st.gui.closeUI(this)}onCancelHandler(){this.close()}onConfirmHandler(){this.props.confirmCB?.()}onDestroy(){this.isConfirm&&this.props.onDestroy?.()}onCloseHandler(){this.close()}};var Ze;te([Xe({type:I,tooltip:"默认标题"}),se("design:type",I)],ze.prototype,"default_title",void 0),te([Xe({type:R,tooltip:"标题节点"}),se("design:type",R)],ze.prototype,"title",void 0),te([Xe({type:w,tooltip:"字符串内容按钮"}),se("design:type",w)],ze.prototype,"prompt_content_str",void 0),te([Xe({type:R,tooltip:"图片精灵内容按钮"}),se("design:type",R)],ze.prototype,"prompt_content_spriteFrame",void 0),te([Xe({type:k,tooltip:"确认按钮"}),se("design:type",k)],ze.prototype,"btn_confirm",void 0),te([Xe({type:I,tooltip:"确认按钮精灵图"}),se("design:type",I)],ze.prototype,"confirm_spriteFrame",void 0),te([Xe({type:k,tooltip:"取消按钮"}),se("design:type",k)],ze.prototype,"btn_cancel",void 0),te([Xe({type:I,tooltip:"取消按钮精灵图"}),se("design:type",I)],ze.prototype,"cancel_spriteFrame",void 0),te([Xe({type:k,tooltip:"关闭按钮"}),se("design:type",k)],ze.prototype,"btn_close",void 0),ze=te([Qe("CoreUIModal")],ze),function(e){e[e.Delay=0]="Delay",e[e.Interval=1]="Interval"}(Ze||(Ze={}));class Ye{tag;type;callback;remainingTime;executionTime=0;initialTime;constructor(e,t,s,i){this.tag=e,this.type=t,this.remainingTime=s,this.initialTime=s,this.callback=i}}class et extends z{timers=new Map;lastUpdateTime=Date.now();constructor(e){super(e),e.event.on(ge.EVENT_HIDE,this.onHandleAppBackground,this),e.event.on(ge.EVENT_SHOW,this.onHandleAppForeground,this),setInterval(this.update.bind(this),1e3)}onHandleAppBackground(){this.lastUpdateTime=Date.now()}onHandleAppForeground(){const e=Date.now(),t=e-this.lastUpdateTime;r("elapsedTime",t);for(const e of this.timers.values())e.remainingTime>0&&(e.remainingTime-=t,e.executionTime+=t);this.lastUpdateTime=e}registerInterval(e,t,s){if(this.has(e))return i(`${e}定时器已存在,请勿重复注册`);const o=new Ye(e,Ze.Interval,t,s);this.timers.set(e,o)}registerDelay(e,t,s){if(this.has(e))return i(`${e}延时器已存在,请勿重复注册`);const o=new Ye(e,Ze.Delay,t,s);this.timers.set(e,o)}unregister(e){this.has(e)&&this.timers.delete(e)}has(e){return this.timers.has(e)}update(){const e=[];for(const[t,s]of this.timers.entries())s.remainingTime-=1e3,s.remainingTime<=0&&(s.type===Ze.Interval&&(s.executionTime+=s.initialTime),s.callback(s.executionTime),s.type===Ze.Interval?s.remainingTime=s.initialTime:e.push(t));for(const t of e)this.timers.delete(t)}}class tt{static#t;static get instance(){return this.#t||(this.#t=new tt),this.#t}onAppInitDelegate=new A;audio;event;gui;storage;res;util;gui_bundle_name="";audio_local_store_key="";setConfig=({gui_bundleName:e="resources",audio_local_store_key:t="game_audio"}={})=>(this.gui_bundle_name=e,this.audio_local_store_key=t,this);async boot(){this.res=new $e,this.util=new We(this),this.storage=new ee(this),this.event=new je,this.audio=new Y(this),this.gui=(await new Ge(this).init()).gui}}const st=tt.instance;y.onPostProjectInitDelegate.add((async()=>{console.time("[Init App]"),await st.boot(),await st.onAppInitDelegate.dispatch(),console.timeEnd("[Init App]")}));export{Z as AudioEventConstant,Y as AudioManager,le as AudioSourceBaseComponent,pe as AudioSourceUILayer,ce as AudioTypeEnum,ie as BaseComponent,z as BaseManager,Be as BasePrefab,Le as CoreBlackMask,Re as CoreNotice,Te as CoreReconnection,ke as CoreShowLoading,me as CoreToast,Ee as CoreUIContainer,ze as CoreUIModal,We as CoreUtil,ge as GlobalEventConstant,Ue as Gui,Ge as GuiManager,Fe as LayerType,tt as Manager,je as MessageManager,Se as ReconnectPrompt,be as RootUILayer,Ae as SceneLayer,et as TimerManager,_e as ToastType,ne as UILayer,Je as WrapperSocialGameClient,st as cat};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shimotsuki/core",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",