@gongxh/bit-core 0.0.4 → 0.0.6
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/LICENSE +21 -0
- package/README.md +175 -56
- package/dist/bit-core.cjs +2190 -209
- package/dist/bit-core.d.ts +559 -20
- package/dist/bit-core.min.cjs +1 -1
- package/dist/bit-core.min.mjs +1 -1
- package/dist/bit-core.mjs +2179 -211
- package/package.json +33 -51
package/dist/bit-core.min.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{view as e,ResolutionPolicy as i,sys as t,screen as s,Component as r,_decorator as n,game as o,director as a}from"cc";let h=!1;function c(e){1==e?(h=!0,console.warn("调试模式已开启")):h=!1}function l(...e){console.log("bit-framework:",...e)}function d(...e){h&&console.log("bit-framework:",...e)}function f(...e){h&&console.info("bit-framework:",...e)}function g(...e){h&&console.warn("bit-framework:",...e)}function S(...e){h&&console.error("bit-framework:",...e)}class p{}class u{constructor(){this.listeners=[]}addResizeListener(e){this.listeners.push(e)}removeResizeListener(e){this.listeners=this.listeners.filter(i=>i!==e)}init(){u.instance=this,d("初始化适配器");let t=this.getDesignSize();p.DesignHeight=t.height,p.DesignWidth=t.width,e.setDesignResolutionSize(p.DesignWidth,p.DesignHeight,i.SHOW_ALL),this.resize(),this.registerListener((...e)=>{d("屏幕发生变化",...e),this.resize();for(const i of this.listeners)i(...e)})}resize(){p.SafeAreaHeight=60;const e=this.getScreenSize(),i=p.DesignWidth>p.DesignHeight;i==e.width>e.height?(p.ScreenWidth=e.width,p.ScreenHeight=e.height):(p.ScreenWidth=e.height,p.ScreenHeight=e.width),i?(p.SafeWidth=p.ScreenWidth-2*p.SafeAreaHeight,p.SafeHeight=p.ScreenHeight):(p.SafeWidth=p.ScreenWidth,p.SafeHeight=p.ScreenHeight-2*p.SafeAreaHeight),this.printScreen()}printScreen(){d(`设计分辨率: ${p.DesignWidth}x${p.DesignHeight}`),d(`屏幕分辨率: ${p.ScreenWidth}x${p.ScreenHeight}`),d(`安全区域高度: ${p.SafeAreaHeight}`),d(`安全区宽高: ${p.SafeWidth}x${p.SafeHeight}`)}}var w;!function(e){e[e.Android=1]="Android",e[e.IOS=2]="IOS",e[e.HarmonyOS=3]="HarmonyOS",e[e.WX=4]="WX",e[e.Alipay=5]="Alipay",e[e.Bytedance=6]="Bytedance",e[e.HuaweiQuick=7]="HuaweiQuick",e[e.Browser=1001]="Browser"}(w||(w={}));class m{}m.isNative=!1,m.isMobile=!1,m.isNativeMobile=!1,m.isAndroid=!1,m.isIOS=!1,m.isHarmonyOS=!1,m.isWX=!1,m.isAlipay=!1,m.isBytedance=!1,m.isHuaweiQuick=!1,m.isBrowser=!1;class b{constructor(){this.initPlatform()}initPlatform(){switch(m.isNative=t.isNative,m.isMobile=t.isMobile,m.isNativeMobile=t.isNative&&t.isMobile,t.os){case t.OS.ANDROID:m.isAndroid=!0,d("系统类型 Android");break;case t.OS.IOS:m.isIOS=!0,d("系统类型 IOS");break;case t.OS.OPENHARMONY:m.isHarmonyOS=!0,d("系统类型 HarmonyOS")}switch(t.platform){case t.Platform.WECHAT_GAME:m.isWX=!0,m.platform=w.WX;break;case t.Platform.ALIPAY_MINI_GAME:m.isAlipay=!0,m.platform=w.Alipay;break;case t.Platform.BYTEDANCE_MINI_GAME:m.isBytedance=!0,m.platform=w.Bytedance;break;case t.Platform.HUAWEI_QUICK_GAME:m.isHuaweiQuick=!0,m.platform=w.HuaweiQuick;break;default:m.isBrowser=!0,m.platform=w.Browser}d(`platform: ${w[m.platform]}`)}}function H(e,i,t,s){var r,n=arguments.length,o=n<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,t):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,i,t,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(i,t,o):r(i,t))||o);return n>3&&o&&Object.defineProperty(i,t,o),o}"function"==typeof SuppressedError&&SuppressedError;class A extends u{getScreenSize(){let i=s.windowSize;return{width:Math.ceil(i.width/e.getScaleX()),height:Math.ceil(i.height/e.getScaleY())}}getDesignSize(){let i=e.getDesignResolutionSize();return{width:i.width,height:i.height}}registerListener(i){s&&s.on?(s.on("window-resize",(...e)=>{d("window-resize"),i(...e)},this),s.on("orientation-change",(...e)=>{d("orientation-change"),i(...e)},this),s.on("fullscreen-change",(...e)=>{d("fullscreen-change"),i(...e)},this)):e.setResizeCallback(i)}}class y extends r{init(){this.onInit()}}const{property:O}=n;class W extends r{constructor(){super(...arguments),this.fps=60,this.enableDebug=!1}start(){this.enableDebug&&c(!0),d("开始初始化【bit-framework】"),o.frameRate=this.fps,a.addPersistRootNode(this.node),this.node.setSiblingIndex(this.node.children.length-1),new b,(new A).init(),this.initModule(),d("【bit-framework】初始化完成"),this.onInit()}initModule(){const e=this.getComponentsInChildren(y);for(const i of e)i.init()}}H([O({displayName:"游戏帧率"})],W.prototype,"fps",void 0),H([O({displayName:"开启调试输出"})],W.prototype,"enableDebug",void 0);export{u as Adapter,W as CocosEntry,y as Module,m as Platform,w as PlatformType,p as Screen,d as debug,c as enableDebugMode,S as error,f as info,l as log,g as warn};
|
|
1
|
+
import{view as t,ResolutionPolicy as e,game as i,screen as s,Component as r,sys as n,_decorator as o,director as a,macro as h}from"cc";let c=!1;function l(t){1==t?(c=!0,console.warn("调试模式已开启")):c=!1}function u(...t){console.log("bit-framework:",...t)}function m(...t){c&&console.log("bit-framework:",...t)}function f(...t){c&&console.info("bit-framework:",...t)}function g(...t){c&&console.warn("bit-framework:",...t)}function p(...t){c&&console.error("bit-framework:",...t)}class d{}class _{constructor(){this.listeners=[]}addResizeListener(t){this.listeners.push(t)}removeResizeListener(t){this.listeners=this.listeners.filter(e=>e!==t)}init(){_.instance=this,m("初始化适配器");let i=this.getDesignSize();d.DesignHeight=i.height,d.DesignWidth=i.width,t.setDesignResolutionSize(d.DesignWidth,d.DesignHeight,e.SHOW_ALL),this.resize(),this.registerListener((...t)=>{m("屏幕发生变化",...t),this.resize();for(const e of this.listeners)e(...t)})}resize(){d.SafeAreaHeight=60;const t=this.getScreenSize(),e=d.DesignWidth>d.DesignHeight;e==t.width>t.height?(d.ScreenWidth=t.width,d.ScreenHeight=t.height):(d.ScreenWidth=t.height,d.ScreenHeight=t.width),e?(d.SafeWidth=d.ScreenWidth-2*d.SafeAreaHeight,d.SafeHeight=d.ScreenHeight):(d.SafeWidth=d.ScreenWidth,d.SafeHeight=d.ScreenHeight-2*d.SafeAreaHeight),this.printScreen()}printScreen(){m(`设计分辨率: ${d.DesignWidth}x${d.DesignHeight}`),m(`屏幕分辨率: ${d.ScreenWidth}x${d.ScreenHeight}`),m(`安全区域高度: ${d.SafeAreaHeight}`),m(`安全区宽高: ${d.SafeWidth}x${d.SafeHeight}`)}}function T(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o}"function"==typeof SuppressedError&&SuppressedError;class w{}class y{constructor(t){this._size=0,this._capacity=t<=0?4:t,this._nodes=new Array(this._capacity)}clear(){this._size=0}get(t){return this._nodes[t]}top(){return this._nodes[0]}contains(t){return t.index>=0&&t.index<this._size}push(t){const e=++this._size;e>this._capacity&&(this._capacity=this._nodes.length*=2),this._sortUp(t,e-1)}pop(){if(0==this._size)return null;const t=this._nodes,e=t[0];e.index=-1,t[0]=null;const i=--this._size;if(i>0){const e=t[i];t[i]=null,this._sortDown(e,0)}return e}remove(t){if(!this.contains(t))return;const e=--this._size,i=this._nodes;if(t.index<e){const s=i[t.index]=i[e];s.index=t.index,i[e]=null,this.update(s)}else i[e]=null;t.index=-1}update(t){if(!this.contains(t))return!1;const e=t.index,i=this._nodes;return e>0&&i[e].lessThan(i[this._parent(e)])?this._sortUp(i[e],e):this._sortDown(i[e],e),!0}_parent(t){return t-1>>1}get count(){return this._size}get empty(){return 0==this._size}_sortUp(t,e){let i=this._parent(e);const s=this._nodes;for(;e>0&&t.lessThan(s[i]);)s[i].index=e,s[e]=s[i],e=i,i=this._parent(i);t.index=e,s[e]=t}_sortDown(t,e){let i=1+(e<<1);const s=this._nodes,r=this._size;for(;i<r;){let n=t;if(s[i].lessThan(n)&&(n=s[i]),i+1<r&&s[i+1].lessThan(n)&&(++i,n=s[i]),t==n)break;n.index=e,s[e]=n,e=i,i=1+(i<<1)}t.index=e,s[e]=t}}class S extends w{constructor(t){super(),this.loop=0,this.id=t}lessThan(t){const e=t;return Math.abs(this.expireTime-e.expireTime)<=1e-5?this.orderIndex<e.orderIndex:this.expireTime<e.expireTime}}const x=19,D=524287,M=D;class A{constructor(t){this._pool=new Array,this._freeIndices=new Array;for(let e=0;e<t;++e){const t=new S(e<<x);t.recycled=!0,this._pool.push(t),this._freeIndices.push(e)}}allocate(){let t;const e=this._pool;if(0==this._freeIndices.length){if(8192==e.length)throw new Error("超出时钟个数: 8192");t=new S(e.length<<x),e.push(t)}else{if(t=e[this._freeIndices.pop()],t.recycled=!1,(t.id&D)==M)throw new Error("时钟版本号过高: "+M);++t.id}return t}recycle(t){const e=t>>>x;if(e<0||e>=this._pool.length)throw new Error("定时器不存在");const i=this._pool[e];if(i.recycled)throw new Error("定时器已经被回收");i.recycled=!0,i.callback=null,this._freeIndices.push(e)}get(t){const e=t>>>x,i=t&D;if(e<0||e>=this._pool.length)return null;const s=this._pool[e];if(s.recycled)return null;return(s.id&D)!=i?null:s}clear(){const t=this._pool,e=t.length,i=this._freeIndices;i.length=0;for(let s=0;s<e;++s)t[s].recycled=!0,t[s].callback=null,i.push(s)}}class b{get timerCount(){return this._heap.count}constructor(t){this._timerNodeOrder=0,this._elapsedTime=0,this._heap=new y(t),this._pool=new A(t),this._pausedTimers=new Map}start(t,e,i=0){const s=this._getTimerNode(t,e,i);return this._heap.push(s),s.id}stop(t){const e=this._pool.get(t);e&&(e.pause&&this._pausedTimers.delete(t),this._heap.remove(e),this._pool.recycle(t))}pause(t){const e=this._pool.get(t);e&&(e.pause=!0,e.pauseRemainTime=e.expireTime-this._elapsedTime,this._heap.remove(e),this._pausedTimers.set(t,e))}resume(t){const e=this._pausedTimers.get(t);e&&(e.pause=!1,e.expireTime=this._elapsedTime+e.pauseRemainTime,this._pausedTimers.delete(t),this._heap.push(e))}update(t){const e=this._elapsedTime+=t,i=this._heap;let s=i.top();for(;s&&s.expireTime<=e;){const t=s.callback;0==s.loop||s.loop>0&&0==--s.loop?(i.pop(),this._recycle(s)):(s.expireTime=s.expireTime+s.interval,i.update(s)),t(),s=i.top()}}clear(){this._heap.clear(),this._pool.clear(),this._pausedTimers.clear(),this._timerNodeOrder=0}_getTimerNode(t,e,i){const s=this._pool.allocate();return s.orderIndex=++this._timerNodeOrder,s.callback=t,s.interval=e,s.expireTime=this._elapsedTime+e,s.loop=i,s.pause=!1,s}_recycle(t){this._pool.recycle(t.id)}}class v{static initTimer(){this._timer=new b(16)}static get Timer(){return this._timer||this.initTimer(),this._timer}static startTimer(t,e,i=0){return this.Timer.start(t,e,i)}static stopTimer(t){this.Timer.stop(t)}static pauseTimer(t){this.Timer.pause(t)}static resumeTimer(t){this.Timer.resume(t)}static clearAllTimer(){this.Timer.clear()}static update(t){var e;null===(e=this._timer)||void 0===e||e.update(t)}}v._timer=null;class H{static initTimer(){this._timer=new b(16)}static startTimer(t,e,i=0){return this._timer.start(t,e,i)}static stopTimer(t){this._timer.stop(t)}static update(t){var e;null===(e=this._timer)||void 0===e||e.update(t)}}H._timer=null;let U=null;class k{static get osBootTime(){return this._osBootTime}static get netTime(){return this._netTime}static get netTimeDiff(){return this._netTimeDiff}static get runTime(){return Math.floor(i.totalTime)}static _configBoot(){this._osBootTime=Math.floor(Date.now()),U=new Date,this._nowTimestamp=()=>this._osBootTime+this.runTime,m("系统启动时间",this.formatTime(this._osBootTime))}static setNetTime(t){if(0==t)return;this._netTime=t;const e=this._nowTimestamp();this._netTimeDiff=Math.floor(this.netTime-e),m(`设置网络时间: net(${this.formatTime(this.netTime)}), boot(${this.formatTime(this.osBootTime)}), diff(${Math.abs(this.netTimeDiff/1e3)}秒)`)}static now(){return this._nowTimestamp()+this.netTimeDiff}static msTos(t){return Math.floor((t||0)/1e3)}static sToMs(t){return 1e3*(t||0)}static getYear(t){return U.setTime(t||this.now()),U.getFullYear()}static getMonth(t){return U.setTime(t||this.now()),U.getMonth()+1}static getDay(t){return U.setTime(t||this.now()),U.getDate()}static getHour(t){return U.setTime(t||this.now()),U.getHours()}static getMinute(t){return U.setTime(t||this.now()),U.getMinutes()}static getSecond(t){return U.setTime(t||this.now()),U.getSeconds()}static getDayStartTime(t){return U.setTime(t||this.now()),U.setHours(0,0,0,0),U.getTime()}static getDayEndTime(t){return this.getDayStartTime(t)+864e5}static getWeekDay(t){return U.setTime(t||k.now()),U.getDay()||7}static getWeekStartTime(t){return this.getDayStartTime(t-864e5*this.getWeekDay(t))}static getWeekEndTime(t){return this.getWeekStartTime(t)+6048e5}static getMonthStartTime(t){return U.setTime(t||this.now()),U.setDate(1),U.setHours(0,0,0,0),U.getTime()}static getMonthEndTime(t){return U.setTime(t||this.now()),U.setDate(1),U.setHours(0,0,0,0),U.setMonth(U.getMonth()+1),U.getTime()}static getYearStartTime(t){return U.setTime(t||this.now()),U.setMonth(0),U.setDate(1),U.setHours(0,0,0,0),U.getTime()}static getYearEndTime(t){return U.setTime(t||this.now()),U.setMonth(0),U.setDate(1),U.setHours(0,0,0,0),U.setFullYear(U.getFullYear()+1),U.getTime()}static getMonthDays(t){const e=this.getMonthEndTime(t),i=this.getMonthStartTime(t);return Math.round((e-i)/864e5)}static isSameDay(t,e){return!((e=e||this.now())-t>864e5)&&this.getDayStartTime(t)===this.getDayStartTime(e)}static isSameWeek(t,e){return!((e=e||this.now())-t>6048e5)&&this.getWeekStartTime(t)===this.getWeekStartTime(e)}static isSameMonth(t,e){e=e||this.now(),U.setTime(t);const i=U.getMonth(),s=U.getFullYear();U.setTime(e);const r=U.getMonth(),n=U.getFullYear();return i===r&&s===n}static isSameYear(t,e){e=e||this.now(),U.setTime(t);const i=U.getFullYear();U.setTime(e);return i===U.getFullYear()}static format(t,e){U.setTime(t);const i=U.getFullYear(),s=U.getMonth()+1,r=U.getDate(),n=U.getHours(),o=U.getMinutes(),a=U.getSeconds(),h=t=>t<10?`0${t}`:`${t}`;return e.replace(/YYYY/g,`${i}`).replace(/YY/g,h(i%100)).replace(/MM/g,h(s)).replace(/M/g,`${s}`).replace(/DD/g,h(r)).replace(/D/g,`${r}`).replace(/hh/g,h(n)).replace(/h/g,`${n}`).replace(/mm/g,h(o)).replace(/m/g,`${o}`).replace(/ss/g,h(a)).replace(/s/g,`${a}`)}static formatTime(t){return this.format(t,"YYYY-MM-DD hh:mm:ss")}static formatTimeChinese(t){return this.format(t,"YYYY年MM月DD日 hh:mm:ss")}static formatDuration(t,e,i){const s=Math.floor(t<0?0:t),r=Math.floor(s/86400),n=Math.floor(s/3600),o=Math.floor(s/60),a=Math.floor(s%86400/3600),h=Math.floor(s%3600/60),c=s%60,l=t=>t<10?`0${t}`:`${t}`;let u=e;return(null==i?void 0:i.autoHide)&&(0===r&&(u=u.replace(/DD天?|D天?/g,"")),0===r&&0===a&&0===n&&(u=u.replace(/HH[时:]?|H[时:]?|hh[时:]?|h[时:]?/g,"")),0===r&&0===a&&0===n&&0===h&&0===o&&(u=u.replace(/MM[分:]?|M[分:]?|mm[分:]?|m[分:]?/g,"")),u=u.replace(/^[:\s]+|[:\s]+$/g,"").replace(/\s{2,}/g," ")),u.replace(/DD/g,l(r)).replace(/D/g,`${r}`).replace(/HH/g,l(n)).replace(/H/g,`${n}`).replace(/hh/g,l(a)).replace(/h/g,`${a}`).replace(/MM/g,l(o)).replace(/M/g,`${o}`).replace(/mm/g,l(h)).replace(/m/g,`${h}`).replace(/ss/g,l(c)).replace(/s/g,`${c}`)}static formatSmart(t,e="D天h小时m分s秒"){return this.formatDuration(t,e,{autoHide:!0})}static formatSmartSimple(t,e="D天h小时|h小时m分|m分s秒"){const i=Math.floor(t<0?0:t),[s="D天h小时",r="h小时m分",n="m分s秒",o="s秒"]=e.split("|");if(i>=86400){const t=Math.floor(i/86400),e=Math.ceil(i%86400/3600);return this.formatDuration(86400*t+3600*e,s)}if(i>=3600){const t=Math.floor(i/3600),e=Math.ceil(i%3600/60);return this.formatDuration(3600*t+60*e,r)}if(i>=60){const t=Math.floor(i/60),e=Math.ceil(i%60);return this.formatDuration(60*t+e,n)}return this.formatDuration(i,o)}}k._osBootTime=0,k._netTime=0,k._netTimeDiff=0;class E extends _{getScreenSize(){let e=s.windowSize;return{width:Math.ceil(e.width/t.getScaleX()),height:Math.ceil(e.height/t.getScaleY())}}getDesignSize(){let e=t.getDesignResolutionSize();return{width:e.width,height:e.height}}registerListener(e){s&&s.on?(s.on("window-resize",(...t)=>{m("window-resize"),e(...t)},this),s.on("orientation-change",(...t)=>{m("orientation-change"),e(...t)},this),s.on("fullscreen-change",(...t)=>{m("fullscreen-change"),e(...t)},this)):t.setResizeCallback(e)}}class O extends r{init(){this.onInit()}}var $;!function(t){t[t.Android=1]="Android",t[t.IOS=2]="IOS",t[t.HarmonyOS=3]="HarmonyOS",t[t.WX=4]="WX",t[t.Alipay=5]="Alipay",t[t.Bytedance=6]="Bytedance",t[t.HuaweiQuick=7]="HuaweiQuick",t[t.Browser=1001]="Browser"}($||($={}));class B{}B.isNative=!1,B.isMobile=!1,B.isNativeMobile=!1,B.isAndroid=!1,B.isIOS=!1,B.isHarmonyOS=!1,B.isWX=!1,B.isAlipay=!1,B.isBytedance=!1,B.isHuaweiQuick=!1,B.isBrowser=!1;class I{constructor(){this.initPlatform()}initPlatform(){switch(B.isNative=n.isNative,B.isMobile=n.isMobile,B.isNativeMobile=n.isNative&&n.isMobile,n.os){case n.OS.ANDROID:B.isAndroid=!0,m("系统类型 Android");break;case n.OS.IOS:B.isIOS=!0,m("系统类型 IOS");break;case n.OS.OPENHARMONY:B.isHarmonyOS=!0,m("系统类型 HarmonyOS")}switch(n.platform){case n.Platform.WECHAT_GAME:B.isWX=!0,B.platform=$.WX;break;case n.Platform.ALIPAY_MINI_GAME:B.isAlipay=!0,B.platform=$.Alipay;break;case n.Platform.BYTEDANCE_MINI_GAME:B.isBytedance=!0,B.platform=$.Bytedance;break;case n.Platform.HUAWEI_QUICK_GAME:B.isHuaweiQuick=!0,B.platform=$.HuaweiQuick;break;default:B.isBrowser=!0,B.platform=$.Browser}m(`platform: ${$[B.platform]}`)}}const{property:z}=o;class W extends r{constructor(){super(...arguments),this.fps=60,this.enableDebug=!1}start(){this.enableDebug&&l(!0),m("====================开始初始化====================="),i.frameRate=this.fps,a.addPersistRootNode(this.node),this.node.setSiblingIndex(this.node.children.length-1),new I,(new E).init(),this.initTime(),this.initModule(),m("=====================初始化完成====================="),this.onInit()}initTime(){k._configBoot(),H.initTimer(),v.initTimer(),this.schedule(this.tick.bind(this),0,h.REPEAT_FOREVER)}initModule(){const t=this.getComponentsInChildren(O);for(const e of t)e.init()}tick(t){H.update(t),v.update(t)}}T([z({displayName:"游戏帧率"})],W.prototype,"fps",void 0),T([z({displayName:"开启调试输出"})],W.prototype,"enableDebug",void 0);class Y{static toBinary(t){const e=[];this.writeValue(t,e);const i=e.reduce((t,e)=>t+e.length,0),s=new Uint8Array(i);let r=0;for(const t of e)s.set(t,r),r+=t.length;return s}static toJson(t){const e=t instanceof ArrayBuffer?new Uint8Array(t):t;if(!this.isBinaryFormat(e))return t;const i=new DataView(e.buffer);return this.readValue(i,0)}static isBinaryFormat(t){if(!t||!t.length||t.length<1)return!1;const e=t[0];if(e<0||e>5)return!1;try{const e=new DataView(t.buffer);let i=0;return this.validateBinaryFormat(e,i),!0}catch(t){return!1}}static validateBinaryFormat(t,e){switch(t.getUint8(e)){case 0:return 1;case 1:return 9;case 2:return 5+t.getUint32(e+1,!0);case 3:return 2;case 4:{const i=t.getUint32(e+1,!0);let s=5;for(let r=0;r<i;r++)s+=this.validateBinaryFormat(t,e+s);return s}case 5:{const i=t.getUint32(e+1,!0);let s=5;for(let r=0;r<i;r++){s+=4+t.getUint32(e+s,!0),s+=this.validateBinaryFormat(t,e+s)}return s}default:throw new Error("无效的类型标记")}}static readValue(t,e){const i=t.getUint8(e++);switch(i){case 0:return null;case 1:return t.getFloat64(e,!0);case 2:{const i=t.getUint32(e,!0);e+=4;const s=new Uint8Array(t.buffer,e,i);return this.utf8ArrayToString(s)}case 3:return 1===t.getUint8(e);case 4:const s=t.getUint32(e,!0);e+=4;const r=[];for(let i=0;i<s;i++)r.push(this.readValue(t,e)),e+=this.getNextOffset(t,e);return r;case 5:{const i=t.getUint32(e,!0);e+=4;const s={};for(let r=0;r<i;r++){const i=t.getUint32(e,!0);e+=4;let r="";for(let s=0;s<i;s++)r+=String.fromCharCode(t.getUint8(e+s));e+=i,s[r]=this.readValue(t,e),e+=this.getNextOffset(t,e)}return s}default:throw new Error(`未知的类型: ${i}`)}}static writeValue(t,e){if(null!==t)switch(typeof t){case"number":{const i=new Uint8Array(9);i[0]=1;new DataView(i.buffer).setFloat64(1,t,!0),e.push(i);break}case"string":{const i=this.stringToUtf8Array(t),s=i.length,r=new Uint8Array(5+s);r[0]=2;new DataView(r.buffer).setUint32(1,s,!0),r.set(i,5),e.push(r);break}case"boolean":{const i=new Uint8Array(2);i[0]=3,i[1]=t?1:0,e.push(i);break}case"object":if(Array.isArray(t)){const i=new Uint8Array(5);i[0]=4;new DataView(i.buffer).setUint32(1,t.length,!0),e.push(i);for(const i of t)this.writeValue(i,e)}else{const i=Object.keys(t),s=new Uint8Array(5);s[0]=5;new DataView(s.buffer).setUint32(1,i.length,!0),e.push(s);for(const s of i){const i=s.length,r=new Uint8Array(4+i);new DataView(r.buffer).setUint32(0,i,!0);const n=(new TextEncoder).encode(s);r.set(n,4),e.push(r),this.writeValue(t[s],e)}}break;default:throw new Error("不支持的类型: "+typeof t)}else e.push(new Uint8Array([0]))}static getNextOffset(t,e){const i=t.getUint8(e);switch(i){case 0:return 1;case 1:return 9;case 2:return 5+t.getUint32(e+1,!0);case 3:return 2;case 4:{const i=t.getUint32(e+1,!0);let s=5;for(let r=0;r<i;r++)s+=this.getNextOffset(t,e+s);return s}case 5:{const i=t.getUint32(e+1,!0);let s=5;for(let r=0;r<i;r++){s+=4+t.getUint32(e+s,!0),s+=this.getNextOffset(t,e+s)}return s}default:throw new Error(`未知的类型: ${i}`)}}static utf8ArrayToString(t){if(!t||0===t.length)return"";let e="",i=0;try{for(;i<t.length;){let s=t[i++];if(s>127)if(s>191&&s<224){if(i>=t.length)break;s=(31&s)<<6|63&t[i++]}else if(s>223&&s<240){if(i+1>=t.length)break;s=(15&s)<<12|(63&t[i++])<<6|63&t[i++]}else{if(!(s>239&&s<248))continue;if(i+2>=t.length)break;s=(7&s)<<18|(63&t[i++])<<12|(63&t[i++])<<6|63&t[i++]}s<=65535?e+=String.fromCharCode(s):s<=1114111&&(s-=65536,e+=String.fromCharCode(s>>10|55296),e+=String.fromCharCode(1023&s|56320))}}catch(t){return console.error("UTF-8 解码错误:",t),""}return e}static stringToUtf8Array(t){if(!t||0===t.length)return new Uint8Array(0);const e=[];try{for(let i=0;i<t.length;i++){let s=t.charCodeAt(i);if(s<128)e.push(s);else if(s<2048)e.push(192|s>>6),e.push(128|63&s);else if(s<55296||s>=57344)e.push(224|s>>12),e.push(128|s>>6&63),e.push(128|63&s);else{if(i+1>=t.length)break;i++,s=(1023&s)<<10|1023&t.charCodeAt(i),s+=65536,e.push(240|s>>18),e.push(128|s>>12&63),e.push(128|s>>6&63),e.push(128|63&s)}}}catch(t){return console.error("UTF-8 编码错误:",t),new Uint8Array(0)}return new Uint8Array(e)}}class N{static rotl(t,e){return t<<e|t>>>32-e}static rotr(t,e){return t<<32-e|t>>>e}static endianNumber(t){return 16711935&N.rotl(t,8)|4278255360&N.rotl(t,24)}static endianArray(t){for(let e=0,i=t.length;e<i;e++)t[e]=N.endianNumber(t[e]);return t}static randomBytes(t){const e=[];for(;t>0;t--)e.push(Math.floor(256*Math.random()));return e}static bytesToWords(t){const e=[];for(let i=0,s=0,r=t.length;i<r;i++,s+=8)e[s>>>5]|=t[i]<<24-s%32;return e}static wordsToBytes(t){const e=[];for(let i=0,s=32*t.length;i<s;i+=8)e.push(t[i>>>5]>>>24-i%32&255);return e}static bytesToHex(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push((t[i]>>>4).toString(16)),e.push((15&t[i]).toString(16));return e.join("")}static hexToBytes(t){const e=[];for(let i=0,s=t.length;i<s;i+=2)e.push(parseInt(t.substr(i,2),16));return e}}const F=function(t){const e=function(t){const e=[];for(let i=0,s=(t=unescape(encodeURIComponent(t))).length;i<s;i++)e.push(255&t.charCodeAt(i));return e}(t),i=N.bytesToWords(e),s=8*e.length;let r=i.length,n=1732584193,o=-271733879,a=-1732584194,h=271733878;for(let t=0;t<r;t++)i[t]=16711935&(i[t]<<8|i[t]>>>24)|4278255360&(i[t]<<24|i[t]>>>8);i[s>>>5]|=128<<s%32,i[14+(s+64>>>9<<4)]=s;const c=F._ff,l=F._gg,u=F._hh,m=F._ii;r=i.length;for(let t=0;t<r;t+=16){const e=n,s=o,r=a,f=h;n=c(n,o,a,h,i[t+0],7,-680876936),h=c(h,n,o,a,i[t+1],12,-389564586),a=c(a,h,n,o,i[t+2],17,606105819),o=c(o,a,h,n,i[t+3],22,-1044525330),n=c(n,o,a,h,i[t+4],7,-176418897),h=c(h,n,o,a,i[t+5],12,1200080426),a=c(a,h,n,o,i[t+6],17,-1473231341),o=c(o,a,h,n,i[t+7],22,-45705983),n=c(n,o,a,h,i[t+8],7,1770035416),h=c(h,n,o,a,i[t+9],12,-1958414417),a=c(a,h,n,o,i[t+10],17,-42063),o=c(o,a,h,n,i[t+11],22,-1990404162),n=c(n,o,a,h,i[t+12],7,1804603682),h=c(h,n,o,a,i[t+13],12,-40341101),a=c(a,h,n,o,i[t+14],17,-1502002290),o=c(o,a,h,n,i[t+15],22,1236535329),n=l(n,o,a,h,i[t+1],5,-165796510),h=l(h,n,o,a,i[t+6],9,-1069501632),a=l(a,h,n,o,i[t+11],14,643717713),o=l(o,a,h,n,i[t+0],20,-373897302),n=l(n,o,a,h,i[t+5],5,-701558691),h=l(h,n,o,a,i[t+10],9,38016083),a=l(a,h,n,o,i[t+15],14,-660478335),o=l(o,a,h,n,i[t+4],20,-405537848),n=l(n,o,a,h,i[t+9],5,568446438),h=l(h,n,o,a,i[t+14],9,-1019803690),a=l(a,h,n,o,i[t+3],14,-187363961),o=l(o,a,h,n,i[t+8],20,1163531501),n=l(n,o,a,h,i[t+13],5,-1444681467),h=l(h,n,o,a,i[t+2],9,-51403784),a=l(a,h,n,o,i[t+7],14,1735328473),o=l(o,a,h,n,i[t+12],20,-1926607734),n=u(n,o,a,h,i[t+5],4,-378558),h=u(h,n,o,a,i[t+8],11,-2022574463),a=u(a,h,n,o,i[t+11],16,1839030562),o=u(o,a,h,n,i[t+14],23,-35309556),n=u(n,o,a,h,i[t+1],4,-1530992060),h=u(h,n,o,a,i[t+4],11,1272893353),a=u(a,h,n,o,i[t+7],16,-155497632),o=u(o,a,h,n,i[t+10],23,-1094730640),n=u(n,o,a,h,i[t+13],4,681279174),h=u(h,n,o,a,i[t+0],11,-358537222),a=u(a,h,n,o,i[t+3],16,-722521979),o=u(o,a,h,n,i[t+6],23,76029189),n=u(n,o,a,h,i[t+9],4,-640364487),h=u(h,n,o,a,i[t+12],11,-421815835),a=u(a,h,n,o,i[t+15],16,530742520),o=u(o,a,h,n,i[t+2],23,-995338651),n=m(n,o,a,h,i[t+0],6,-198630844),h=m(h,n,o,a,i[t+7],10,1126891415),a=m(a,h,n,o,i[t+14],15,-1416354905),o=m(o,a,h,n,i[t+5],21,-57434055),n=m(n,o,a,h,i[t+12],6,1700485571),h=m(h,n,o,a,i[t+3],10,-1894986606),a=m(a,h,n,o,i[t+10],15,-1051523),o=m(o,a,h,n,i[t+1],21,-2054922799),n=m(n,o,a,h,i[t+8],6,1873313359),h=m(h,n,o,a,i[t+15],10,-30611744),a=m(a,h,n,o,i[t+6],15,-1560198380),o=m(o,a,h,n,i[t+13],21,1309151649),n=m(n,o,a,h,i[t+4],6,-145523070),h=m(h,n,o,a,i[t+11],10,-1120210379),a=m(a,h,n,o,i[t+2],15,718787259),o=m(o,a,h,n,i[t+9],21,-343485551),n=n+e>>>0,o=o+s>>>0,a=a+r>>>0,h=h+f>>>0}return N.endianArray([n,o,a,h])};function C(t){if(null==t)throw new Error("Illegal argument "+t);return N.bytesToHex(N.wordsToBytes(F(t)))}F._ff=function(t,e,i,s,r,n,o){const a=t+(e&i|~e&s)+(r>>>0)+o;return(a<<n|a>>>32-n)+e},F._gg=function(t,e,i,s,r,n,o){const a=t+(e&s|i&~s)+(r>>>0)+o;return(a<<n|a>>>32-n)+e},F._hh=function(t,e,i,s,r,n,o){const a=t+(e^i^s)+(r>>>0)+o;return(a<<n|a>>>32-n)+e},F._ii=function(t,e,i,s,r,n,o){const a=t+(i^(e|~s))+(r>>>0)+o;return(a<<n|a>>>32-n)+e};class R{static compareVersion(t,e){let i=t.split("."),s=e.split(".");const r=Math.max(i.length,s.length);for(;i.length<r;)i.push("0");for(;s.length<r;)s.push("0");for(let t=0;t<r;++t){let e=parseInt(i[t]),r=parseInt(s[t]);if(e>r)return 1;if(e<r)return-1}return 0}static isJsonString(t){try{return JSON.parse(t),!0}catch(t){return!1}}static getUrlParam(t){let e={url:"",params:{}},i=t.split("?");if(e.url=i[0],i.length>1){let t=i[1].split("&");for(let i=0;i<t.length;i++){let s=t[i],[r,n]=s.split("=");e.params[r]=n}}return e}static addUrlParam(t,e,i){let s=this.getUrlParam(t);return s.params[e]=i,s.url+"?"+Object.entries(s.params).map(([t,e])=>`${t}=${e}`).join("&")}}function V(t,e){return t===e}class P{constructor(t){this.element=t,this.next=void 0}}class j extends P{constructor(t){super(t),this.prev=void 0}}class L{constructor(t){this._equalsFn=t||V,this._count=0,this._head=void 0}push(t){const e=new P(t);let i;if(void 0===this._head)this._head=e;else{for(i=this._head;void 0!==i.next;)i=i.next;i.next=e}this._count++}insert(t,e){if(e>=0&&e<=this._count){const i=new P(t);if(0===e){const t=this._head;i.next=t,this._head=i}else{const t=this.getElementAt(e-1),s=t.next;i.next=s,t.next=i}return this._count++,!0}return!1}getElementAt(t){if(t>=0&&t<=this._count){let e=this._head;for(let i=0;i<t&&void 0!==e;i++)e=e.next;return e}}remove(t){return this.removeAt(this.indexOf(t))}removeAt(t){if(t>=0&&t<this._count){let e=this._head;if(0===t)this._head=e.next;else{const i=this.getElementAt(t-1);e=i.next,i.next=e.next}return this._count--,e.next=void 0,e.element}}indexOf(t){let e=this._head;for(let i=0;i<this._count&&void 0!==e;i++){if(this._equalsFn(t,e.element))return i;e=e.next}return-1}clear(){this._head=void 0,this._count=0}getHead(){return this._head}isEmpty(){return 0===this.size()}size(){return this._count}toString(){if(void 0===this._head)return"";let t=`${this._head.element}`,e=this._head.next;for(let i=0;i<this.size()&&void 0!==e;i++)t=`${t},${e.element}`,e=e.next;return t}}class Q extends L{constructor(t){super(t),this._tail=void 0}push(t){this.insert(t,this._count)}insert(t,e){if(e>=0&&e<=this._count){const i=new j(t);let s=this._head;if(0===e)void 0===this._head?(this._head=i,this._tail=i):(i.next=s,s.prev=i,this._head=i);else if(e===this._count)s=this._tail,s.next=i,i.prev=s,this._tail=i;else{const t=this.getElementAt(e-1);s=t.next,i.next=s,t.next=i,s.prev=i,i.prev=t}return this._count++,!0}return!1}removeAt(t){if(t>=0&&t<this._count){let e=this._head;if(0===t)this._head=e.next,1===this._count?this._tail=void 0:this._head.prev=void 0;else if(t===this._count-1)e=this._tail,this._tail=e.prev,this._tail.next=void 0;else{e=this.getElementAt(t);const i=e.prev;i.next=e.next,e.next.prev=i}return this._count--,e.next=void 0,e.prev=void 0,e.element}return null}getElementAt(t){if(t>=0&&t<=this._count){if(t>.5*this._count){let e=this._tail;for(let i=this._count-1;i>t&&void 0!==e;i--)e=e.prev;return e}{let e=this._head;for(let i=0;i<t&&void 0!==e;i++)e=e.next;return e}}}getHead(){return this._head}getTail(){return this._tail}clear(){this._head=void 0,this._tail=void 0,this._count=0}}class X{constructor(t){this._items=new Q(t)}push(t){this._items.push(t)}pop(){if(!this.isEmpty())return this._items.removeAt(this.size()-1)}peek(){if(!this.isEmpty())return this._items.getTail().element}size(){return this._items.size()}isEmpty(){return this._items.isEmpty()}clear(){this._items.clear()}toString(){return this._items.toString()}}export{_ as Adapter,Y as Binary,y as BinaryHeap,W as CocosEntry,Q as DoublyLinkedList,j as DoublyNode,v as GlobalTimer,w as HeapNode,H as InnerTimer,L as LinkedList,P as LinkedNode,O as Module,B as Platform,$ as PlatformType,d as Screen,X as Stack,k as Time,R as Utils,m as debug,l as enableDebugMode,p as error,f as info,u as log,C as md5,g as warn};
|