@shimotsuki/core 1.0.17 → 1.0.19

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
@@ -20,13 +20,13 @@ declare class BaseManager {
20
20
  * 音频管理
21
21
  */
22
22
  declare class AudioManager extends BaseManager {
23
- private local_data;
23
+ local_data: any;
24
24
  private music;
25
25
  private effect;
26
26
  private _volume_music;
27
27
  private _volume_effect;
28
- _switch_music: boolean;
29
- _switch_effect: boolean;
28
+ private _switch_music;
29
+ private _switch_effect;
30
30
  constructor(cat: Manager);
31
31
  /**
32
32
  * 设置背景音乐播放完成回调
@@ -111,16 +111,6 @@ declare class AudioManager extends BaseManager {
111
111
  protected save(): void;
112
112
  /** 本地加载音乐音效的音量、开关配置数据并设置到游戏中 */
113
113
  protected load(): void;
114
- /**autorun销毁 */
115
- private autorunDisposers;
116
- /**reaction销毁 */
117
- private reactionDisposers;
118
- /**添加自动收集 */
119
- protected addAutorun(cb: (() => void) | (() => void)[]): this;
120
- /**添加自动收集 */
121
- protected addReaction<T, FireImmediately extends boolean = false>(expression: (r: IReactionPublic) => T, effect: (arg: T, prev: FireImmediately extends true ? T | undefined : T, r: IReactionPublic) => void, opts?: IReactionOptions<T, FireImmediately>): this;
122
- removeAutorun(): void;
123
- removeReaction(): void;
124
114
  }
125
115
 
126
116
  /**
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 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 A,Sprite as R,AsyncDelegate as I}from"cc";import{makeObservable as D,observable as M,autorun as F,reaction as U}from"@shimotsuki/mobx";import{PREVIEW as H,DEBUG as P}from"cc/env";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:W,menu:X}=t;class z 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 Q;!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"}(Q||(Q={}));const Y="game_audio";class ee extends Z{local_data={};music;effect;_volume_music=1;_volume_effect=1;_switch_music=!0;_switch_effect=!0;constructor(e){super(e),D(this,{_switch_music:M,_switch_effect:M});var t=new o("UIAudioManager");n.addPersistRootNode(t);var s=new o("UIMusic");s.parent=t,this.music=s.addComponent(z).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?Q.MUSIC_ON:Q.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?Q.EFFECT_ON:Q.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;let e=JSON.stringify(this.local_data);this.cat.storage.set(Y,e)}load(){try{let e=this.cat.storage.get(Y);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}catch(e){this.local_data={},this._volume_music=.6,this._volume_effect=1,this._switch_music=!0,this._switch_effect=!0}this.music&&(this.music.volume=this._volume_music),this.effect&&(this.effect.volume=this._volume_effect)}autorunDisposers=[];reactionDisposers=[];addAutorun(e){return(Array.isArray(e)?e:[e]).forEach((e=>{const t=F(e);this.autorunDisposers.push(t)})),this}addReaction(e,t,s){const i=U(e,t,s);return this.reactionDisposers.push(i),this}removeAutorun(){this.autorunDisposers.forEach((e=>{e()})),this.autorunDisposers=[]}removeReaction(){this.reactionDisposers.forEach((e=>{e()})),this.reactionDisposers=[]}}class te 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(H||(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+="");H||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}`,H||(e=this.cat.util.encryptUtil.md5(e));let s=a.localStorage.getItem(e);return null==s||""===s||H||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}`,H||(e=this.cat.util.encryptUtil.md5(e)),a.localStorage.removeItem(e)):console.error("存储的key不能为空")}clear(){a.localStorage.clear()}}function se(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 ie(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}"function"==typeof SuppressedError&&SuppressedError;class oe extends c{props={};data={};autorunDisposers=[];reactionDisposers=[];messageManagers=[];hook={destroyed:()=>{},started:()=>{}};initUI(){}__preload(){this.initUI(),this.onAutoObserver()}constructor(){super(),D(this,{props:M,data:M})}onAutoObserver(){}addAutorun(e){return(Array.isArray(e)?e:[e]).forEach((e=>{const t=F(e);this.autorunDisposers.push(t)})),this}addReaction(e,t,s){const i=U(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(),it.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 ne(this.node,e),this}}const ne=(e,t)=>{e.layer="string"==typeof t?2**p.nameToLayer(t):t,e?.children.forEach((e=>{ne(e,t)}))};class re extends oe{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:ae,property:ce}=t;var le;!function(e){e[e.EFFECT=0]="EFFECT",e[e.BGM=1]="BGM"}(le||(le={}));class he extends oe{type=le.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,it.event.on(Q.EFFECT_ON,this.onPlayEffectHandler,this).on(Q.EFFECT_OFF,this.onStopEffectHandler,this).on(Q.MUSIC_ON,this.onPlayMusicHandler,this).on(Q.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){super.__preload();const{volumeEffect:e,volumeMusic:t}=it.audio;this.audioSource.volume=this.type===le.BGM?t:e}start(){}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:e,switchMusic:t}=it.audio;this.audioSource.playing||!(this.type===le.BGM?t:e)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}se([ce({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(le)}),ie("design:type",Object)],he.prototype,"type",void 0),se([ce({tooltip:"音源",type:s}),ie("design:type",Object)],he.prototype,"clip",void 0),se([ce({tooltip:"循环"}),ie("design:type",Object)],he.prototype,"loop",void 0),se([ce({tooltip:"音量"}),ie("design:type",Object)],he.prototype,"volume",void 0),se([ce({tooltip:"是否启用自动播放"}),ie("design:type",Object)],he.prototype,"playOnAwake",void 0);const{ccclass:de,property:pe}=t;class ue extends re{type=le.EFFECT;clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=new e;onEnable(){super.onEnable(),it.event.on(Q.EFFECT_ON,this.onPlayEffectHandler,this).on(Q.EFFECT_OFF,this.onStopEffectHandler,this).on(Q.MUSIC_ON,this.onPlayMusicHandler,this).on(Q.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}=it.audio;this.audioSource.volume=this.type===le.BGM?t:e}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:e,switchMusic:t}=it.audio;this.audioSource.playing||!(this.type===le.BGM?t:e)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}se([pe({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(le)}),ie("design:type",Object)],ue.prototype,"type",void 0),se([pe({tooltip:"音源",type:s}),ie("design:type",Object)],ue.prototype,"clip",void 0),se([pe({tooltip:"循环"}),ie("design:type",Object)],ue.prototype,"loop",void 0),se([pe({tooltip:"音量"}),ie("design:type",Object)],ue.prototype,"volume",void 0),se([pe({tooltip:"是否启用自动播放"}),ie("design:type",Object)],ue.prototype,"playOnAwake",void 0);const{ccclass:fe,property:_e}=t;var me;!function(e){e[e.FIXED=0]="FIXED",e[e.SLIDE=1]="SLIDE"}(me||(me={}));let ge=class extends oe{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==me.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 ye;se([_e({type:o,tooltip:"固定节点"}),ie("design:type",o)],ge.prototype,"fixed_node",void 0),se([_e({type:o,tooltip:"滑动节点"}),ie("design:type",o)],ge.prototype,"slide_node",void 0),se([_e({type:w,tooltip:"固定标签节点"}),ie("design:type",w)],ge.prototype,"fixed_label",void 0),se([_e({type:w,tooltip:"滑动标签节点"}),ie("design:type",w)],ge.prototype,"slide_label",void 0),ge=se([fe("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"}(ye||(ye={}));const{ccclass:ve,property:Ee}=t;let be=class extends re{scene_mask_node;ui_container;gui=null;onLoad(){this.setSceneMaskActive(!1)}get scene_mask(){return this.scene_mask_node.getComponent(Be)}get brother(){return this.ui_container.children||[]}get tweenChildren(){return this.scene_mask.tween.children}onEventListener(){it.event.on(ye.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}};se([Ee({type:o}),ie("design:type",o)],be.prototype,"scene_mask_node",void 0),se([Ee({type:o}),ie("design:type",o)],be.prototype,"ui_container",void 0),be=se([ve("CoreUIContainer")],be);class we extends re{onEnable(){super.onEnable(),this.updateMask()}onDisable(){super.onDisable(),this.updateMask()}updateMask(){it.event.dispatchEvent(ye.ROOT_MASK_UPDATE)}}const{ccclass:Ce,property:ke}=t;let Oe=class extends we{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)}};se([ke({type:w,tooltip:"标题"}),ie("design:type",w)],Oe.prototype,"title",void 0),se([ke({type:o,tooltip:"动画"}),ie("design:type",o)],Oe.prototype,"loadingTween",void 0),Oe=se([Ce("CoreShowLoading")],Oe);const{ccclass:xe,property:Se}=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 Ne=class extends we{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,it.gui.hideReconnect()}};se([Se({type:w,tooltip:"通用提示文本"}),ie("design:type",w)],Ne.prototype,"common_prompt_text",void 0),se([Se({type:k,tooltip:"确定按钮"}),ie("design:type",k)],Ne.prototype,"btn_confirm",void 0),Ne=se([xe("CoreReconnection")],Ne);const{ccclass:Ae,property:Re}=t;let Ie=class extends we{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?.(),it.gui.hideNotice()}updateProps(e){this.text.string=`${e.text}`}};se([Re({type:w,tooltip:"提示文本"}),ie("design:type",w)],Ie.prototype,"text",void 0),se([Re({type:k,tooltip:"确定按钮"}),ie("design:type",k)],Ie.prototype,"btn_confirm",void 0),Ie=se([Ae("CoreNotice")],Ie);class De extends oe{isReload}const{ccclass:Me,property:Fe}=t;var Ue;!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"}(Ue||(Ue={}));let He=class extends oe{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(ye.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()}showToast({title:e="",type:t=me.SLIDE,fixed_time:s=2}){const i=h(this.toast_ui_prefab);return r("showToast",e),this.toast_ui_component=i.getComponent(ge).addToParent(this.root_toast,{props:{title:e,type:t,fixed_time:s}}),this}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(Oe).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(Ne).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(Ie).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(De);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(be).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(re),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 re));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(ye.ROOT_MASK_CHANGE)}};se([Fe({type:l,tooltip:"断线重连UI预制体"}),ie("design:type",l)],He.prototype,"reconnection_ui_prefab",void 0),se([Fe({type:l,tooltip:"提示UI预制体"}),ie("design:type",l)],He.prototype,"toast_ui_prefab",void 0),se([Fe({type:l,tooltip:"加载UI预制体"}),ie("design:type",l)],He.prototype,"loading_ui_prefab",void 0),se([Fe({type:l,tooltip:"公告UI预制体"}),ie("design:type",l)],He.prototype,"notice_ui_prefab",void 0),se([Fe({type:l,tooltip:"UI层预制体"}),ie("design:type",l)],He.prototype,"ui_prefab",void 0),se([Fe({type:o,tooltip:"root-UI层"}),ie("design:type",o)],He.prototype,"root_ui",void 0),se([Fe({type:o,tooltip:"root-组件层"}),ie("design:type",o)],He.prototype,"root_toast",void 0),se([Fe({type:o,tooltip:"root-mask"}),ie("design:type",o)],He.prototype,"root_mask",void 0),He=se([Me("Gui")],He);const{ccclass:Pe,property:Le}=t;let Be=class extends oe{tween};var Ge;se([Le({type:o,tooltip:"动画节点"}),ie("design:type",o)],Be.prototype,"tween",void 0),Be=se([Pe("CoreBlackMask")],Be),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"}(Ge||(Ge={}));class $e 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(e="resources"){this.#e=e;const t=await this.getGuiPrefabByType(this.#e,Ge.Root),s=h(t);return this.gui=s.getComponent(He).init(this.cat),n.addPersistRootNode(s),this}}class je{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 qe{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 Ke=null;const Ve={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 Je=Object.freeze({__proto__:null,JsonFormatter:Ve,aesDecrypt:(e,t,s)=>L.AES.decrypt(e,t,{iv:Ke,format:Ve}).toString(L.enc.Utf8),aesEncrypt:(e,t,s)=>L.AES.encrypt(e,t,{iv:Ke,format:Ve}).toString(),initCrypto:(e,t)=>{Ke=L.enc.Hex.parse(t)},md5:e=>L.MD5(e).toString()});class We extends Z{encryptUtil=Je}class Xe 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}))),it.event.on(ye.EVENT_SHOW,this.onShowHandler,this).on(ye.EVENT_HIDE,this.onHideHandler,this).on(ye.ONLINE,this.onOnlineHandler,this).on(ye.OFFLINE,this.onOfflineHandler,this)}removeEvent(){this.removeAllListeners(),it.event.off(ye.EVENT_SHOW,this.onShowHandler,this).off(ye.EVENT_HIDE,this.onHideHandler,this).off(ye.ONLINE,this.onOnlineHandler,this).off(ye.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 "),it.gui.showToast({title:Te.RECONNECTED}),it.gui.hideReconnect().hideLoading(),it.gui.reloadScene()}catch(e){console.error(e),it.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),it.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"),it.gui.showReconnect(Te.KICK),this.handleEvent({type:"destroy"});break;case"reconnecting":r("正在重连状态 reconnecting"),this.isOnline&&this.isInBackground;break;case"maxReconnect":r("超出最大重连状态 maxReconnect"),it.gui.showReconnect(Te.MAX_RECONNECT);break;case"error":this.isOnline&&(r("ws报错状态 error",e.ev),"string"==typeof e.ev&&it.gui.showToast({title:e.ev}),it.gui.showReconnect(Te.RECONNECTED_ERROR));break;case"online":it.gui.showReconnect(Te.ONLINE),r("在线状态 online"),this.handleEvent({type:"reconnect"});break;case"offline":this.disconnect(!0),r("离线状态 offline"),this.isNeedReconnect=!0,it.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&&(it.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 P&&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=>{P&&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 P&&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=>{P&&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=>{it.gui.showToast({title:e.msg}),n(e)}))}))}async gameRequest(e,t,s){return P&&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=G(j,{forwardReq:!1,forwardResp:!1}),show_log:i=!0}={})=>{this.isSocketConnected&&(P&&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,s))};subscribe(e,t,s){return super.subscribe(e,t,(i=>{P&&!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)),it.event.dispatchEvent(e,B(t,i)),s?.(i)})),this}onData(e){super.onData(e)}}const{ccclass:ze,property:Ze}=t;let Qe=class extends re{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 A?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?.(),it.gui.closeUI(this)}onCancelHandler(){this.close()}onConfirmHandler(){this.props.confirmCB?.()}onDestroy(){this.isConfirm&&this.props.onDestroy?.()}onCloseHandler(){this.close()}};var Ye;se([Ze({type:A,tooltip:"默认标题"}),ie("design:type",A)],Qe.prototype,"default_title",void 0),se([Ze({type:R,tooltip:"标题节点"}),ie("design:type",R)],Qe.prototype,"title",void 0),se([Ze({type:w,tooltip:"字符串内容按钮"}),ie("design:type",w)],Qe.prototype,"prompt_content_str",void 0),se([Ze({type:R,tooltip:"图片精灵内容按钮"}),ie("design:type",R)],Qe.prototype,"prompt_content_spriteFrame",void 0),se([Ze({type:k,tooltip:"确认按钮"}),ie("design:type",k)],Qe.prototype,"btn_confirm",void 0),se([Ze({type:A,tooltip:"确认按钮精灵图"}),ie("design:type",A)],Qe.prototype,"confirm_spriteFrame",void 0),se([Ze({type:k,tooltip:"取消按钮"}),ie("design:type",k)],Qe.prototype,"btn_cancel",void 0),se([Ze({type:A,tooltip:"取消按钮精灵图"}),ie("design:type",A)],Qe.prototype,"cancel_spriteFrame",void 0),se([Ze({type:k,tooltip:"关闭按钮"}),ie("design:type",k)],Qe.prototype,"btn_close",void 0),Qe=se([ze("CoreUIModal")],Qe),function(e){e[e.Delay=0]="Delay",e[e.Interval=1]="Interval"}(Ye||(Ye={}));class et{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 tt extends Z{timers=new Map;lastUpdateTime=Date.now();constructor(e){super(e),e.event.on(ye.EVENT_HIDE,this.onHandleAppBackground,this),e.event.on(ye.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 et(e,Ye.Interval,t,s);this.timers.set(e,o)}registerDelay(e,t,s){if(this.has(e))return i(`${e}延时器已存在,请勿重复注册`);const o=new et(e,Ye.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===Ye.Interval&&(s.executionTime+=s.initialTime),s.callback(s.executionTime),s.type===Ye.Interval?s.remainingTime=s.initialTime:e.push(t));for(const t of e)this.timers.delete(t)}}class st{static#t;static get instance(){return this.#t||(this.#t=new st),this.#t}onAppInitDelegate=new I;audio;event;gui;storage;res;util;#s="resources";setConfig=({gui_bundleName:e="resources"}={})=>(this.#s=e,console.log("GUI资源配置",this.#s),this);async boot(){this.res=new je,this.util=new We(this),this.storage=new te(this),this.event=new qe,this.audio=new ee(this),this.gui=(await new $e(this).init(this.#s)).gui}}const it=st.instance;y.onPostProjectInitDelegate.add((async()=>{console.time("[Init App]"),await it.boot(),await it.onAppInitDelegate.dispatch(),console.timeEnd("[Init App]")}));export{Q as AudioEventConstant,ee as AudioManager,he as AudioSourceBaseComponent,ue as AudioSourceUILayer,le as AudioTypeEnum,oe as BaseComponent,Z as BaseManager,Ge as BasePrefab,Be as CoreBlackMask,Ie as CoreNotice,Ne as CoreReconnection,Oe as CoreShowLoading,ge as CoreToast,be as CoreUIContainer,Qe as CoreUIModal,We as CoreUtil,ye as GlobalEventConstant,He as Gui,$e as GuiManager,Ue as LayerType,st as Manager,qe as MessageManager,Te as ReconnectPrompt,De as SceneLayer,tt as TimerManager,me as ToastType,Xe as WrapperSocialGameClient,it 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 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 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 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:W,menu:X}=t;class z 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 Q;!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"}(Q||(Q={}));const Y="game_audio";class ee extends Z{local_data={};music;effect;_volume_music=1;_volume_effect=1;_switch_music=!0;_switch_effect=!0;constructor(e){super(e);var t=new o("UIAudioManager");n.addPersistRootNode(t);var s=new o("UIMusic");s.parent=t,this.music=s.addComponent(z).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?Q.MUSIC_ON:Q.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?Q.EFFECT_ON:Q.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;let e=JSON.stringify(this.local_data);this.cat.storage.set(Y,e)}load(){try{let e=this.cat.storage.get(Y);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}catch(e){this.local_data={},this._volume_music=.6,this._volume_effect=1,this._switch_music=!0,this._switch_effect=!0}this.music&&(this.music.volume=this._volume_music),this.effect&&(this.effect.volume=this._volume_effect)}}class te 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 se(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 ie(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}"function"==typeof SuppressedError&&SuppressedError;class oe 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(),it.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 ne(this.node,e),this}}const ne=(e,t)=>{e.layer="string"==typeof t?2**p.nameToLayer(t):t,e?.children.forEach((e=>{ne(e,t)}))};class re extends oe{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:ae,property:ce}=t;var le;!function(e){e[e.EFFECT=0]="EFFECT",e[e.BGM=1]="BGM"}(le||(le={}));class he extends oe{type=le.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,it.event.on(Q.EFFECT_ON,this.onPlayEffectHandler,this).on(Q.EFFECT_OFF,this.onStopEffectHandler,this).on(Q.MUSIC_ON,this.onPlayMusicHandler,this).on(Q.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){super.__preload();const{volumeEffect:e,volumeMusic:t}=it.audio;this.audioSource.volume=this.type===le.BGM?t:e}start(){}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:e,switchMusic:t}=it.audio;this.audioSource.playing||!(this.type===le.BGM?t:e)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}se([ce({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(le)}),ie("design:type",Object)],he.prototype,"type",void 0),se([ce({tooltip:"音源",type:s}),ie("design:type",Object)],he.prototype,"clip",void 0),se([ce({tooltip:"循环"}),ie("design:type",Object)],he.prototype,"loop",void 0),se([ce({tooltip:"音量"}),ie("design:type",Object)],he.prototype,"volume",void 0),se([ce({tooltip:"是否启用自动播放"}),ie("design:type",Object)],he.prototype,"playOnAwake",void 0);const{ccclass:de,property:pe}=t;class ue extends re{type=le.EFFECT;clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=new e;onEnable(){super.onEnable(),it.event.on(Q.EFFECT_ON,this.onPlayEffectHandler,this).on(Q.EFFECT_OFF,this.onStopEffectHandler,this).on(Q.MUSIC_ON,this.onPlayMusicHandler,this).on(Q.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}=it.audio;this.audioSource.volume=this.type===le.BGM?t:e}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:e,switchMusic:t}=it.audio;this.audioSource.playing||!(this.type===le.BGM?t:e)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}se([pe({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(le)}),ie("design:type",Object)],ue.prototype,"type",void 0),se([pe({tooltip:"音源",type:s}),ie("design:type",Object)],ue.prototype,"clip",void 0),se([pe({tooltip:"循环"}),ie("design:type",Object)],ue.prototype,"loop",void 0),se([pe({tooltip:"音量"}),ie("design:type",Object)],ue.prototype,"volume",void 0),se([pe({tooltip:"是否启用自动播放"}),ie("design:type",Object)],ue.prototype,"playOnAwake",void 0);const{ccclass:fe,property:_e}=t;var me;!function(e){e[e.FIXED=0]="FIXED",e[e.SLIDE=1]="SLIDE"}(me||(me={}));let ge=class extends oe{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==me.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 ye;se([_e({type:o,tooltip:"固定节点"}),ie("design:type",o)],ge.prototype,"fixed_node",void 0),se([_e({type:o,tooltip:"滑动节点"}),ie("design:type",o)],ge.prototype,"slide_node",void 0),se([_e({type:w,tooltip:"固定标签节点"}),ie("design:type",w)],ge.prototype,"fixed_label",void 0),se([_e({type:w,tooltip:"滑动标签节点"}),ie("design:type",w)],ge.prototype,"slide_label",void 0),ge=se([fe("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"}(ye||(ye={}));const{ccclass:ve,property:Ee}=t;let be=class extends re{scene_mask_node;ui_container;gui=null;onLoad(){this.setSceneMaskActive(!1)}get scene_mask(){return this.scene_mask_node.getComponent(Be)}get brother(){return this.ui_container.children||[]}get tweenChildren(){return this.scene_mask.tween.children}onEventListener(){it.event.on(ye.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}};se([Ee({type:o}),ie("design:type",o)],be.prototype,"scene_mask_node",void 0),se([Ee({type:o}),ie("design:type",o)],be.prototype,"ui_container",void 0),be=se([ve("CoreUIContainer")],be);class we extends re{onEnable(){super.onEnable(),this.updateMask()}onDisable(){super.onDisable(),this.updateMask()}updateMask(){it.event.dispatchEvent(ye.ROOT_MASK_UPDATE)}}const{ccclass:Ce,property:ke}=t;let Oe=class extends we{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)}};se([ke({type:w,tooltip:"标题"}),ie("design:type",w)],Oe.prototype,"title",void 0),se([ke({type:o,tooltip:"动画"}),ie("design:type",o)],Oe.prototype,"loadingTween",void 0),Oe=se([Ce("CoreShowLoading")],Oe);const{ccclass:xe,property:Se}=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 Ne=class extends we{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,it.gui.hideReconnect()}};se([Se({type:w,tooltip:"通用提示文本"}),ie("design:type",w)],Ne.prototype,"common_prompt_text",void 0),se([Se({type:k,tooltip:"确定按钮"}),ie("design:type",k)],Ne.prototype,"btn_confirm",void 0),Ne=se([xe("CoreReconnection")],Ne);const{ccclass:Re,property:Ae}=t;let Ie=class extends we{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?.(),it.gui.hideNotice()}updateProps(e){this.text.string=`${e.text}`}};se([Ae({type:w,tooltip:"提示文本"}),ie("design:type",w)],Ie.prototype,"text",void 0),se([Ae({type:k,tooltip:"确定按钮"}),ie("design:type",k)],Ie.prototype,"btn_confirm",void 0),Ie=se([Re("CoreNotice")],Ie);class Me extends oe{isReload}const{ccclass:De,property:Fe}=t;var Ue;!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"}(Ue||(Ue={}));let He=class extends oe{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(ye.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()}showToast({title:e="",type:t=me.SLIDE,fixed_time:s=2}){const i=h(this.toast_ui_prefab);return r("showToast",e),this.toast_ui_component=i.getComponent(ge).addToParent(this.root_toast,{props:{title:e,type:t,fixed_time:s}}),this}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(Oe).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(Ne).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(Ie).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(Me);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(be).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(re),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 re));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(ye.ROOT_MASK_CHANGE)}};se([Fe({type:l,tooltip:"断线重连UI预制体"}),ie("design:type",l)],He.prototype,"reconnection_ui_prefab",void 0),se([Fe({type:l,tooltip:"提示UI预制体"}),ie("design:type",l)],He.prototype,"toast_ui_prefab",void 0),se([Fe({type:l,tooltip:"加载UI预制体"}),ie("design:type",l)],He.prototype,"loading_ui_prefab",void 0),se([Fe({type:l,tooltip:"公告UI预制体"}),ie("design:type",l)],He.prototype,"notice_ui_prefab",void 0),se([Fe({type:l,tooltip:"UI层预制体"}),ie("design:type",l)],He.prototype,"ui_prefab",void 0),se([Fe({type:o,tooltip:"root-UI层"}),ie("design:type",o)],He.prototype,"root_ui",void 0),se([Fe({type:o,tooltip:"root-组件层"}),ie("design:type",o)],He.prototype,"root_toast",void 0),se([Fe({type:o,tooltip:"root-mask"}),ie("design:type",o)],He.prototype,"root_mask",void 0),He=se([De("Gui")],He);const{ccclass:Pe,property:Le}=t;let Be=class extends oe{tween};var Ge;se([Le({type:o,tooltip:"动画节点"}),ie("design:type",o)],Be.prototype,"tween",void 0),Be=se([Pe("CoreBlackMask")],Be),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"}(Ge||(Ge={}));class $e 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(e="resources"){this.#e=e;const t=await this.getGuiPrefabByType(this.#e,Ge.Root),s=h(t);return this.gui=s.getComponent(He).init(this.cat),n.addPersistRootNode(s),this}}class je{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 qe{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 Ke=null;const Ve={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 Je=Object.freeze({__proto__:null,JsonFormatter:Ve,aesDecrypt:(e,t,s)=>L.AES.decrypt(e,t,{iv:Ke,format:Ve}).toString(L.enc.Utf8),aesEncrypt:(e,t,s)=>L.AES.encrypt(e,t,{iv:Ke,format:Ve}).toString(),initCrypto:(e,t)=>{Ke=L.enc.Hex.parse(t)},md5:e=>L.MD5(e).toString()});class We extends Z{encryptUtil=Je}class Xe 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}))),it.event.on(ye.EVENT_SHOW,this.onShowHandler,this).on(ye.EVENT_HIDE,this.onHideHandler,this).on(ye.ONLINE,this.onOnlineHandler,this).on(ye.OFFLINE,this.onOfflineHandler,this)}removeEvent(){this.removeAllListeners(),it.event.off(ye.EVENT_SHOW,this.onShowHandler,this).off(ye.EVENT_HIDE,this.onHideHandler,this).off(ye.ONLINE,this.onOnlineHandler,this).off(ye.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 "),it.gui.showToast({title:Te.RECONNECTED}),it.gui.hideReconnect().hideLoading(),it.gui.reloadScene()}catch(e){console.error(e),it.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),it.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"),it.gui.showReconnect(Te.KICK),this.handleEvent({type:"destroy"});break;case"reconnecting":r("正在重连状态 reconnecting"),this.isOnline&&this.isInBackground;break;case"maxReconnect":r("超出最大重连状态 maxReconnect"),it.gui.showReconnect(Te.MAX_RECONNECT);break;case"error":this.isOnline&&(r("ws报错状态 error",e.ev),"string"==typeof e.ev&&it.gui.showToast({title:e.ev}),it.gui.showReconnect(Te.RECONNECTED_ERROR));break;case"online":it.gui.showReconnect(Te.ONLINE),r("在线状态 online"),this.handleEvent({type:"reconnect"});break;case"offline":this.disconnect(!0),r("离线状态 offline"),this.isNeedReconnect=!0,it.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&&(it.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=>{it.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=G(j,{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,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)),it.event.dispatchEvent(e,B(t,i)),s?.(i)})),this}onData(e){super.onData(e)}}const{ccclass:ze,property:Ze}=t;let Qe=class extends re{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?.(),it.gui.closeUI(this)}onCancelHandler(){this.close()}onConfirmHandler(){this.props.confirmCB?.()}onDestroy(){this.isConfirm&&this.props.onDestroy?.()}onCloseHandler(){this.close()}};var Ye;se([Ze({type:R,tooltip:"默认标题"}),ie("design:type",R)],Qe.prototype,"default_title",void 0),se([Ze({type:A,tooltip:"标题节点"}),ie("design:type",A)],Qe.prototype,"title",void 0),se([Ze({type:w,tooltip:"字符串内容按钮"}),ie("design:type",w)],Qe.prototype,"prompt_content_str",void 0),se([Ze({type:A,tooltip:"图片精灵内容按钮"}),ie("design:type",A)],Qe.prototype,"prompt_content_spriteFrame",void 0),se([Ze({type:k,tooltip:"确认按钮"}),ie("design:type",k)],Qe.prototype,"btn_confirm",void 0),se([Ze({type:R,tooltip:"确认按钮精灵图"}),ie("design:type",R)],Qe.prototype,"confirm_spriteFrame",void 0),se([Ze({type:k,tooltip:"取消按钮"}),ie("design:type",k)],Qe.prototype,"btn_cancel",void 0),se([Ze({type:R,tooltip:"取消按钮精灵图"}),ie("design:type",R)],Qe.prototype,"cancel_spriteFrame",void 0),se([Ze({type:k,tooltip:"关闭按钮"}),ie("design:type",k)],Qe.prototype,"btn_close",void 0),Qe=se([ze("CoreUIModal")],Qe),function(e){e[e.Delay=0]="Delay",e[e.Interval=1]="Interval"}(Ye||(Ye={}));class et{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 tt extends Z{timers=new Map;lastUpdateTime=Date.now();constructor(e){super(e),e.event.on(ye.EVENT_HIDE,this.onHandleAppBackground,this),e.event.on(ye.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 et(e,Ye.Interval,t,s);this.timers.set(e,o)}registerDelay(e,t,s){if(this.has(e))return i(`${e}延时器已存在,请勿重复注册`);const o=new et(e,Ye.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===Ye.Interval&&(s.executionTime+=s.initialTime),s.callback(s.executionTime),s.type===Ye.Interval?s.remainingTime=s.initialTime:e.push(t));for(const t of e)this.timers.delete(t)}}class st{static#t;static get instance(){return this.#t||(this.#t=new st),this.#t}onAppInitDelegate=new I;audio;event;gui;storage;res;util;#s="resources";setConfig=({gui_bundleName:e="resources"}={})=>(this.#s=e,console.log("GUI资源配置",this.#s),this);async boot(){this.res=new je,this.util=new We(this),this.storage=new te(this),this.event=new qe,this.audio=new ee(this),this.gui=(await new $e(this).init(this.#s)).gui}}const it=st.instance;y.onPostProjectInitDelegate.add((async()=>{console.time("[Init App]"),await it.boot(),await it.onAppInitDelegate.dispatch(),console.timeEnd("[Init App]")}));export{Q as AudioEventConstant,ee as AudioManager,he as AudioSourceBaseComponent,ue as AudioSourceUILayer,le as AudioTypeEnum,oe as BaseComponent,Z as BaseManager,Ge as BasePrefab,Be as CoreBlackMask,Ie as CoreNotice,Ne as CoreReconnection,Oe as CoreShowLoading,ge as CoreToast,be as CoreUIContainer,Qe as CoreUIModal,We as CoreUtil,ye as GlobalEventConstant,He as Gui,$e as GuiManager,Ue as LayerType,st as Manager,qe as MessageManager,Te as ReconnectPrompt,Me as SceneLayer,tt as TimerManager,me as ToastType,Xe as WrapperSocialGameClient,it as cat};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shimotsuki/core",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",