Commit e8f81782 authored by Master Q's avatar Master Q

测试看看

parent 2a0a7d35
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
// ["@babel/plugin-transform-runtime", { // ["@babel/plugin-transform-runtime", {
// // "corejs": 3 // // "corejs": 3
// }], // }],
["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-optional-chaining", "@babel/plugin-proposal-optional-chaining",
"./babel-plugins/babel-plugins-test.js" "./babel-plugins/babel-plugins-test.js"
] ]
......
...@@ -52,7 +52,10 @@ ...@@ -52,7 +52,10 @@
<script src="output.js"></script> <script src="output.js"></script>
<script type="module"> <script type="module">
window.addEventListener("load", function () { window.addEventListener("load", function () {
const canvas = document.getElementById('stage')
canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1)
canvas.height = document.body.clientHeight * (window.devicePixelRatio || 1)
new Main(canvas)
}) })
</script> </script>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
declare module SvgaParser {
/**
* 加载方法
* @param url 资源路径
* @param success
* @param failure
*/
export function loadSvga(url: string, success: (videoItem: VideoEntity) => void, failure?: (err: string) => void): void;
/**
* 导出只是当作类型接口用
*/
export interface VideoEntity {
/**
* SVGA 文件版本
*/
version: string;
/**
* 影片尺寸
*/
videoSize: {
width: number;
height: number;
};
/**
* 帧率,60,30等每秒
*/
FPS: number;
/**
* 总帧数
*/
frames: number;
/**
* base64图片数据记录
*/
images: {
[key: string]: string
};
/**
* 图片是否已被缓存,缓存全局,注意名字覆盖
*/
hasBeenCached: boolean;
/**
* sprite对象数据
*/
sprites: SpriteEntity[];
}
interface SpriteEntity {
/**
* 标识
*/
matteKey: string;
/**
* 图片key值
*/
imageKey: string;
/**
* 帧数据数组
*/
frames: FrameEntity[];
}
/**
* 还有很多其他数据,暂不需要,比如矢量路径和遮罩路径暂时都无
*/
interface FrameEntity {
/**
* 透明度
*/
alpha: number;
/**
* 2维矩阵数据
*/
transform: {
a: number,
b: number,
c: number,
d: number,
tx: number,
ty: number,
};
}
}
declare module "svga-parser" { export = SvgaParser; }
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
// Type definitions for howler.js v2.1.1
// Project: https://github.com/goldfire/howler.js
// Definitions by: Pedro Casaubon <https://github.com/xperiments>
// Alexander Leon <https://github.com/alien35>
// Nicholas Higgins <https://github.com/nicholashza>
// Carlos Urango <https://github.com/cjurango>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface HowlerGlobal {
mute(muted: boolean): this;
volume(): number;
volume(volume: number): this;
codecs(ext: string): boolean;
unload(): this;
usingWebAudio: boolean;
html5PoolSize: number;
noAudio: boolean;
autoUnlock: boolean;
autoSuspend: boolean;
ctx: AudioContext;
masterGain: GainNode;
stereo(pan: number): this;
pos(x: number, y: number, z: number): this | void;
orientation(x: number, y: number, z: number, xUp: number, yUp: number, zUp: number): this | void;
}
declare let Howler: HowlerGlobal;
interface IHowlSoundSpriteDefinition {
[name: string]: [number, number] | [number, number, boolean]
}
interface IHowlProperties {
src: string | string[];
volume?: number;
html5?: boolean;
loop?: boolean;
preload?: boolean;
autoplay?: boolean;
mute?: boolean;
sprite?: IHowlSoundSpriteDefinition;
rate?: number;
pool?: number;
format?: string[] | string;
xhrWithCredentials?: boolean;
onload?: () => void;
onloaderror?: (soundId: number, error: any) => void;
onplay?: (soundId: number) => void;
onplayerror?: (soundId: number, error: any) => void;
onend?: (soundId: number) => void;
onpause?: (soundId: number) => void;
onstop?: (soundId: number) => void;
onmute?: (soundId: number) => void;
onvolume?: (soundId: number) => void;
onrate?: (soundId: number) => void;
onseek?: (soundId: number) => void;
onfade?: (soundId: number) => void;
onunlock?: (soundId: number) => void;
}
interface Howl {
play(spriteOrId?: string | number): number; // .play() is not chainable; the other methods are
pause(id?: number): this;
stop(id?: number): this;
mute(): boolean;
mute(muted: boolean, id?: number): this;
volume(): number;
volume(idOrSetVolume: number): this | number;
volume(volume: number, id: number): this;
fade(from: number, to: number, duration: number, id?: number): this;
rate(): number;
rate(idOrSetRate: number): this | number;
rate(rate: number, id: number): this;
seek(seek?: number, id?: number): this | number;
loop(id?: number): boolean;
loop(loop: boolean, id?: number): this;
playing(id?: number): boolean;
duration(id?: number): number;
state(): 'unloaded' | 'loading' | 'loaded';
load(): this;
unload(): void;
on(event: 'load', callback: () => void, id?: number): this;
on(event: 'loaderror', callback: (soundId: number, error: any) => void, id?: number): this;
on(event: 'play', callback: (soundId: number) => void, id?: number): this;
on(event: 'playerror', callback: (soundId: number, error: any) => void, id?: number): this;
on(event: 'end', callback: (soundId: number) => void, id?: number): this;
on(event: 'pause', callback: (soundId: number) => void, id?: number): this;
on(event: 'stop', callback: (soundId: number) => void, id?: number): this;
on(event: 'mute', callback: (soundId: number) => void, id?: number): this;
on(event: 'volume', callback: (soundId: number) => void, id?: number): this;
on(event: 'rate', callback: (soundId: number) => void, id?: number): this;
on(event: 'seek', callback: (soundId: number) => void, id?: number): this;
on(event: 'fade', callback: (soundId: number) => void, id?: number): this;
on(event: string, callback: Function, id?: number): this;
on(event: 'unlock', callback: (soundId: number) => void, id?: number): this;
once(event: 'load', callback: () => void, id?: number): this;
once(event: 'loaderror', callback: (soundId: number, error: any) => void, id?: number): this;
once(event: 'play', callback: (soundId: number) => void, id?: number): this;
once(event: 'playerror', callback: (soundId: number, error: any) => void, id?: number): this;
once(event: 'end', callback: (soundId: number) => void, id?: number): this;
once(event: 'pause', callback: (soundId: number) => void, id?: number): this;
once(event: 'stop', callback: (soundId: number) => void, id?: number): this;
once(event: 'mute', callback: (soundId: number) => void, id?: number): this;
once(event: 'volume', callback: (soundId: number) => void, id?: number): this;
once(event: 'rate', callback: (soundId: number) => void, id?: number): this;
once(event: 'seek', callback: (soundId: number) => void, id?: number): this;
once(event: 'fade', callback: (soundId: number) => void, id?: number): this;
once(event: string, callback: Function, id?: number): this;
once(event: 'unlock', callback: (soundId: number) => void, id?: number): this;
off(event: string, callback?: Function, id?: number): this;
off(): this;
stereo(pan: number, id?: number): this | void;
pos(x: number, y: number, z: number, id?: number): this | void;
orientation(x: number, y: number, z: number, xUp: number, yUp: number, zUp: number): this | void;
pannerAttr(o: {
coneInnerAngle?: number,
coneOuterAngle?: number, coneOuterGain?: number,
distanceModel: 'inverse' | 'linear', maxDistance: number,
panningModel: 'HRTF' | 'equalpower', refDistance: number, rolloffFactor: number
}, id?: number): this;
}
interface HowlStatic {
new(properties: IHowlProperties): Howl;
}
declare let Howl: HowlStatic;
declare module "howler" {
export let Howler: HowlerGlobal;
export let Howl: HowlStatic;
}
/*
* lib.d.ts
* Created by 还有醋v on 2022/5/27.
* Copyright © 2022 haiyoucuv. All rights reserved.
*/
declare const __ENV__: "development" | "production";
declare const __version__: string;
declare const __buildDate__: string;
/**
* shader文件类型
*/
declare module '*.vert' {
const source: string;
export default source;
}
declare module '*.frag' {
const source: string;
export default source;
}
declare module '*.vs' {
const source: string;
export default source;
}
declare module '*.fs' {
const source: string;
export default source;
}
declare module '*.glsl' {
const source: string;
export default source;
}
/* Polyfill service DEVELOPMENT MODE - for live use set NODE_ENV to 'production'
* Disable minification (remove `.min` from URL path) for more info */
(function(self, undefined) {function ArrayCreate(r){if(1/r==-1/0&&(r=0),r>Math.pow(2,32)-1)throw new RangeError("Invalid array length");var a=[];return a.length=r,a}function Call(t,l){var n=arguments.length>2?arguments[2]:[];if(!1===IsCallable(t))throw new TypeError(Object.prototype.toString.call(t)+"is not a function.");return t.apply(l,n)}function CreateDataProperty(e,r,t){var a={value:t,writable:!0,enumerable:!0,configurable:!0};try{return Object.defineProperty(e,r,a),!0}catch(e){return!1}}function CreateDataPropertyOrThrow(t,r,o){var e=CreateDataProperty(t,r,o);if(!e)throw new TypeError("Cannot assign value `"+Object.prototype.toString.call(o)+"` to property `"+Object.prototype.toString.call(r)+"` on object `"+Object.prototype.toString.call(t)+"`");return e}function CreateMethodProperty(e,r,t){var a={value:t,writable:!0,enumerable:!1,configurable:!0};Object.defineProperty(e,r,a)}function Get(n,t){return n[t]}function IsCallable(n){return"function"==typeof n}function RequireObjectCoercible(e){if(null===e||void 0===e)throw TypeError(Object.prototype.toString.call(e)+" is not coercible to Object.");return e}function SameValueNonNumber(e,n){return e===n}function ToBoolean(o){return Boolean(o)}function ToObject(r){if(null===r||void 0===r)throw TypeError();return Object(r)}function GetV(t,e){return ToObject(t)[e]}function GetMethod(e,l){var t=GetV(e,l);if(null!==t&&void 0!==t){if(!1===IsCallable(t))throw new TypeError("Method not callable: "+l);return t}}function Invoke(n,e){var t=arguments.length>2?arguments[2]:[],l=GetV(n,e);return Call(l,n,t)}function Type(e){switch(typeof e){case"undefined":return"undefined";case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"symbol":return"symbol";default:return null===e?"null":"Symbol"in self&&(e instanceof self.Symbol||e.constructor===self.Symbol)?"symbol":"object"}}function CreateIterResultObject(e,r){if("boolean"!==Type(r))throw new Error;var t={};return CreateDataProperty(t,"value",e),CreateDataProperty(t,"done",r),t}function GetPrototypeFromConstructor(t,o){var r=Get(t,"prototype");return"object"!==Type(r)&&(r=o),r}function OrdinaryCreateFromConstructor(r,e){var t=arguments[2]||{},o=GetPrototypeFromConstructor(r,e),a=Object.create(o);for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&Object.defineProperty(a,n,{configurable:!0,enumerable:!1,writable:!0,value:t[n]});return a}var GetSubstitution=function(){function e(e){return/^[0-9]$/.test(e)}return function t(n,r,l,i,a,f){for(var s=n.length,h=r.length,c=l+s,u=i.length,v="",g=0;g<f.length;g+=1){var o=f.charAt(g),$=g+1>=f.length,d=g+2>=f.length;if("$"!==o||$)v+=f.charAt(g);else{var p=f.charAt(g+1);if("$"===p)v+="$",g+=1;else if("&"===p)v+=n,g+=1;else if("`"===p)v+=0===l?"":r.slice(0,l-1),g+=1;else if("'"===p)v+=c>=h?"":r.slice(c),g+=1;else{var A=d?null:f.charAt(g+2);if(!e(p)||"0"===p||!d&&e(A))if(e(p)&&(d||e(A))){var y=p+A,I=parseInt(y,10)-1;v+=y<=u&&"Undefined"===Type(i[I])?"":i[I],g+=2}else v+="$";else{var T=parseInt(p,10);v+=T<=u&&"Undefined"===Type(i[T-1])?"":i[T-1],g+=1}}}}return v}}();function IsConstructor(t){return"object"===Type(t)&&("function"==typeof t&&!!t.prototype)}function Construct(r){var t=arguments.length>2?arguments[2]:r,o=arguments.length>1?arguments[1]:[];if(!IsConstructor(r))throw new TypeError("F must be a constructor.");if(!IsConstructor(t))throw new TypeError("newTarget must be a constructor.");if(t===r)return new(Function.prototype.bind.apply(r,[null].concat(o)));var n=OrdinaryCreateFromConstructor(t,Object.prototype);return Call(r,n,o)}function IsRegExp(e){if("object"!==Type(e))return!1;var t="Symbol"in self&&"match"in self.Symbol?Get(e,self.Symbol.match):void 0;if(void 0!==t)return ToBoolean(t);try{var l=e.lastIndex;return e.lastIndex=0,RegExp.prototype.exec.call(e),!0}catch(e){}finally{e.lastIndex=l}return!1}function IteratorClose(r,t){if("object"!==Type(r["[[Iterator]]"]))throw new Error(Object.prototype.toString.call(r["[[Iterator]]"])+"is not an Object.");var e=r["[[Iterator]]"],o=GetMethod(e,"return");if(void 0===o)return t;try{var n=Call(o,e)}catch(r){var a=r}if(t)return t;if(a)throw a;if("object"!==Type(n))throw new TypeError("Iterator's return method returned a non-object.");return t}function IteratorComplete(t){if("object"!==Type(t))throw new Error(Object.prototype.toString.call(t)+"is not an Object.");return ToBoolean(Get(t,"done"))}function IteratorNext(t){if(arguments.length<2)var e=Call(t["[[NextMethod]]"],t["[[Iterator]]"]);else e=Call(t["[[NextMethod]]"],t["[[Iterator]]"],[arguments[1]]);if("object"!==Type(e))throw new TypeError("bad iterator");return e}function IteratorStep(t){var r=IteratorNext(t);return!0!==IteratorComplete(r)&&r}function IteratorValue(t){if("object"!==Type(t))throw new Error(Object.prototype.toString.call(t)+"is not an Object.");return Get(t,"value")}function OrdinaryToPrimitive(r,t){if("string"===t)var e=["toString","valueOf"];else e=["valueOf","toString"];for(var i=0;i<e.length;++i){var n=e[i],a=Get(r,n);if(IsCallable(a)){var o=Call(a,r);if("object"!==Type(o))return o}}throw new TypeError("Cannot convert to primitive.")}function RegExpExec(e,l){var r=Get(e,"exec");if(IsCallable(r)){var t=Call(r,e,[l]);if("object"!==Type(t)&&"null"!==Type(t))throw new TypeError("Invalid result: must be an object or null.");return t}return Call(RegExp.prototype.exec,e,[l])}function SameValueZero(e,a){return Type(e)===Type(a)&&("number"===Type(e)?!(!isNaN(e)||!isNaN(a))||(1/e==1/0&&1/a==-1/0||(1/e==-1/0&&1/a==1/0||e===a)):SameValueNonNumber(e,a))}function SpeciesConstructor(o,r){var t=Get(o,"constructor");if(void 0===t)return r;if("object"!==Type(t))throw new TypeError("O.constructor is not an Object");var e="function"==typeof self.Symbol&&"symbol"==typeof self.Symbol.species?t[self.Symbol.species]:void 0;if(void 0===e||null===e)return r;if(IsConstructor(e))return e;throw new TypeError("No constructor found")}function StringIndexOf(r,n,e){var f=r.length;if(""===n&&e<=f)return e;for(var t=n.length,a=e,i=-1;a+t<=f;){for(var g=!0,o=0;o<t;o+=1)if(r[a+o]!==n[o]){g=!1;break}if(g){i=a;break}a+=1}return i}function ToInteger(r){if("symbol"===Type(r))throw new TypeError("Cannot convert a Symbol value to a number");var o=Number(r);return isNaN(o)?0:1/o==1/0||1/o==-1/0||o===1/0||o===-1/0?o:(o<0?-1:1)*Math.floor(Math.abs(o))}function ToLength(n){var t=ToInteger(n);return t<=0?0:Math.min(t,Math.pow(2,53)-1)}function ToPrimitive(e){var t=arguments.length>1?arguments[1]:void 0;if("object"===Type(e)){if(arguments.length<2)var i="default";else t===String?i="string":t===Number&&(i="number");var r="function"==typeof self.Symbol&&"symbol"==typeof self.Symbol.toPrimitive?GetMethod(e,self.Symbol.toPrimitive):void 0;if(void 0!==r){var o=Call(r,e,[i]);if("object"!==Type(o))return o;throw new TypeError("Cannot convert exotic object to primitive.")}return"default"===i&&(i="number"),OrdinaryToPrimitive(e,i)}return e}function ToString(t){switch(Type(t)){case"symbol":throw new TypeError("Cannot convert a Symbol value to a string");case"object":return ToString(ToPrimitive(t,String));default:return String(t)}}function ToPropertyKey(r){var i=ToPrimitive(r,String);return"symbol"===Type(i)?i:ToString(i)}function TrimString(e,u){var r=RequireObjectCoercible(e),t=ToString(r),n=/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/.source;if("start"===u)var p=String.prototype.replace.call(t,new RegExp("^"+n,"g"),"");else p="end"===u?String.prototype.replace.call(t,new RegExp(n+"$","g"),""):String.prototype.replace.call(t,new RegExp("^"+n+"|"+n+"$","g"),"");return p}function UTF16Decode(e,n){return 1024*(e-55296)+(n-56320)+65536}CreateMethodProperty(Array.prototype,"includes",function e(r){"use strict";var t=ToObject(this),o=ToLength(Get(t,"length"));if(0===o)return!1;var n=ToInteger(arguments[1]);if(n>=0)var a=n;else(a=o+n)<0&&(a=0);for(;a<o;){var i=Get(t,ToString(a));if(SameValueZero(r,i))return!0;a+=1}return!1});"use strict";var origSort=Array.prototype.sort;CreateMethodProperty(Array.prototype,"sort",function r(t){if(void 0!==t&&!1===IsCallable(t))throw new TypeError("The comparison function must be either a function or undefined");if(void 0===t)origSort.call(this);else{var e=Array.prototype.map.call(this,function(r,t){return{item:r,index:t}});origSort.call(e,function(r,e){var o=t.call(void 0,r.item,e.item);return 0===o?r.index-e.index:o});for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&e[o].item!==this[o]&&(this[o]=e[o].item)}return this});CreateMethodProperty(Number,"isInteger",function e(r){return"number"===Type(r)&&(!isNaN(r)&&r!==1/0&&r!==-1/0&&ToInteger(r)===r)});Object.defineProperty(Number,"MAX_SAFE_INTEGER",{enumerable:!1,configurable:!1,writable:!1,value:Math.pow(2,53)-1});!function(){var t=Object.getOwnPropertyDescriptor,r={}.toString,e="".split;CreateMethodProperty(Object,"getOwnPropertyDescriptor",function o(n,c){var i=ToObject(n);i=("string"===Type(i)||i instanceof String)&&"[object String]"==r.call(n)?e.call(n,""):Object(n);var p=ToPropertyKey(c);return t(i,p)})}();!function(e){CreateMethodProperty(Object,"isExtensible",function t(n){return"object"===Type(n)&&(!e||e(n))})}(Object.isExtensible);CreateMethodProperty(Object,"keys",function(){"use strict";function t(){var t;try{t=Object.create({})}catch(t){return!0}return o.call(t,"__proto__")}function r(t){var r=n.call(t),e="[object Arguments]"===r;return e||(e="[object Array]"!==r&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===n.call(t.callee)),e}var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,o=Object.prototype.propertyIsEnumerable,c=!o.call({toString:null},"toString"),l=o.call(function(){},"prototype"),i=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],u=function(t){var r=t.constructor;return r&&r.prototype===t},a={$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},f=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!a["$"+t]&&e.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{u(window[t])}catch(t){return!0}}catch(t){return!0}return!1}(),p=function(t){if("undefined"==typeof window||!f)return u(t);try{return u(t)}catch(t){return!1}};return function o(u){var a="[object Function]"===n.call(u),f=r(u),s="[object String]"===n.call(u),y=[];if(void 0===u||null===u)throw new TypeError("Cannot convert undefined or null to object");var h=l&&a;if(s&&u.length>0&&!e.call(u,0))for(var g=0;g<u.length;++g)y.push(String(g));if(f&&u.length>0)for(var w=0;w<u.length;++w)y.push(String(w));else for(var $ in u)t()&&"__proto__"===$||h&&"prototype"===$||!e.call(u,$)||y.push(String($));if(c)for(var d=p(u),b=0;b<i.length;++b)d&&"constructor"===i[b]||!e.call(u,i[b])||y.push(i[b]);return y}}());function EnumerableOwnProperties(e,r){for(var t=Object.keys(e),n=[],s=t.length,a=0;a<s;a++){var i=t[a];if("string"===Type(i)){var u=Object.getOwnPropertyDescriptor(e,i);if(u&&u.enumerable)if("key"===r)n.push(i);else{var p=Get(e,i);if("value"===r)n.push(p);else{var f=[i,p];n.push(f)}}}}return n}!function(){var e={}.toString,t="".split;CreateMethodProperty(Object,"entries",function r(n){var i=ToObject(n);return i=("string"===Type(i)||i instanceof String)&&"[object String]"==e.call(n)?t.call(n,""):Object(n),EnumerableOwnProperties(i,"key+value")})}();CreateMethodProperty(Object,"assign",function t(e,r){var o=ToObject(e);if(1===arguments.length)return o;var c,a,l,n,i=Array.prototype.slice.call(arguments,1);for(c=0;c<i.length;c++){var p=i[c];for(void 0===p||null===p?l=[]:(n="[object String]"===Object.prototype.toString.call(p)?String(p).split(""):ToObject(p),l=Object.keys(n)),a=0;a<l.length;a++){var b,y=l[a];try{var g=Object.getOwnPropertyDescriptor(n,y);b=void 0!==g&&!0===g.enumerable}catch(t){b=Object.prototype.propertyIsEnumerable.call(n,y)}if(b){var j=Get(n,y);o[y]=j}}}return o});!function(){var t={}.toString,e="".split,r=[].concat,o=Object.prototype.hasOwnProperty,c=Object.getOwnPropertyNames||Object.keys,n="object"==typeof self?c(self):[];CreateMethodProperty(Object,"getOwnPropertyNames",function l(a){var p=ToObject(a);if("[object Window]"===t.call(p))try{return c(p)}catch(t){return r.call([],n)}p="[object String]"==t.call(p)?e.call(p,""):Object(p);for(var i=c(p),s=["length","prototype"],O=0;O<s.length;O++){var b=s[O];o.call(p,b)&&!i.includes(b)&&i.push(b)}if(i.includes("__proto__")){var f=i.indexOf("__proto__");i.splice(f,1)}return i})}();!function(){if(!Object.setPrototypeOf){var t,e,o=Object.getOwnPropertyNames,r=Object.getOwnPropertyDescriptor,n=Object.create,c=Object.defineProperty,_=Object.getPrototypeOf,f=Object.prototype,p=function(t,e){return o(e).forEach(function(o){c(t,o,r(e,o))}),t},O=function t(e,o){return p(n(o),e)};try{t=r(f,"__proto__").set,t.call({},null),e=function e(o,r){return t.call(o,r),o}}catch(o){t={__proto__:null},t instanceof Object?e=O:(t.__proto__=f,e=t instanceof Object?function t(e,o){return e.__proto__=o,e}:function t(e,o){return _(e)?(e.__proto__=o,e):O(e,o)})}CreateMethodProperty(Object,"setPrototypeOf",e)}}();!function(){var t={}.toString,e="".split;CreateMethodProperty(Object,"values",function r(n){var c="[object String]"==t.call(n)?e.call(n,""):ToObject(n);return Object.keys(c).map(function(t){return c[t]})})}();Object.defineProperty(RegExp.prototype,"flags",{configurable:!0,enumerable:!1,get:function(){var e=this;if("object"!==Type(e))throw new TypeError("Method called on incompatible type: must be an object.");var o="";return ToBoolean(Get(e,"global"))&&(o+="g"),ToBoolean(Get(e,"ignoreCase"))&&(o+="i"),ToBoolean(Get(e,"multiline"))&&(o+="m"),ToBoolean(Get(e,"unicode"))&&(o+="u"),ToBoolean(Get(e,"sticky"))&&(o+="y"),o}});CreateMethodProperty(String.prototype,"codePointAt",function t(e){var r=RequireObjectCoercible(this),o=ToString(r),i=ToInteger(e),n=o.length;if(!(i<0||i>=n)){var c=String.prototype.charCodeAt.call(o,i);if(c<55296||c>56319||i+1===n)return c;var a=String.prototype.charCodeAt.call(o,i+1);return a<56320||a>57343?c:UTF16Decode(c,a)}});function AdvanceStringIndex(e,n,t){if(n>Number.MAX_SAFE_INTEGER)throw new TypeError("Assertion failed: `index` must be <= 2**53");return!1===t?n+1:n+1>=e.length?n+1:n+e.codePointAt(n).length}CreateMethodProperty(String.prototype,"includes",function t(e){"use strict";var r=arguments.length>1?arguments[1]:void 0,n=RequireObjectCoercible(this),o=ToString(n);if(IsRegExp(e))throw new TypeError("First argument to String.prototype.includes must not be a regular expression");var i=ToString(e),g=ToInteger(r),a=o.length,p=Math.min(Math.max(g,0),a);return-1!==String.prototype.indexOf.call(o,i,p)});CreateMethodProperty(String.prototype,"repeat",function r(e){"use strict";var t=RequireObjectCoercible(this),n=ToString(t),o=ToInteger(e);if(o<0)throw new RangeError("Invalid count value");if(o===1/0)throw new RangeError("Invalid count value");return 0===o?"":new Array(o+1).join(n)});CreateMethodProperty(String.prototype,"trim",function t(){"use strict";var r=this;return TrimString(r,"start+end")});!function(r,t){var e=function t(e){var a=String(e).trim(),o=r(a);return 0===o&&"-"==a.charAt(0)?-0:o};CreateMethodProperty(t,"parseFloat",e),CreateMethodProperty(Number,"parseFloat",t.parseFloat)}(parseFloat,this);!function(t,r){var e=function r(e,n){var a=String(e).trim();return t(a,n>>>0||(/^[-+]?0[xX]/.test(a)?16:10))};CreateMethodProperty(r,"parseInt",e),CreateMethodProperty(Number,"parseInt",r.parseInt)}(parseInt,this);CreateMethodProperty(String.prototype,"trimEnd",function t(){"use strict";var r=this;return TrimString(r,"end")});CreateMethodProperty(String.prototype,"trimStart",function t(){"use strict";var r=this;return TrimString(r,"start")});!function(r,t,n){"use strict";function e(r){if("symbol"===Type(r))return r;throw TypeError(r+" is not a symbol")}var o,u=0,i=""+Math.random(),a="__symbol:",l=a.length,c="__symbol@@"+i,f={},s="defineProperty",v="defineProperties",y="getOwnPropertyNames",b="getOwnPropertyDescriptor",h="propertyIsEnumerable",p=r.prototype,m=p.hasOwnProperty,g=p[h],d=p.toString,w=Array.prototype.concat,S=r.getOwnPropertyNames?r.getOwnPropertyNames(self):[],P=r[y],O=function r(t){if("[object Window]"===d.call(t))try{return P(t)}catch(r){return w.call([],S)}return P(t)},j=r[b],E=r.create,N=r.keys,T=r.freeze||r,_=r[s],k=r[v],F=j(r,y),I=function(r,t,n){if(!m.call(r,c))try{_(r,c,{enumerable:!1,configurable:!1,writable:!1,value:{}})}catch(t){r[c]={}}r[c]["@@"+t]=n},x=function(r,t){var n=E(r);return O(t).forEach(function(r){W.call(t,r)&&K(n,r,t[r])}),n},z=function(r){var t=E(r);return t.enumerable=!1,t},A=function r(){},D=function(r){return r!=c&&!m.call(G,r)},M=function(r){return r!=c&&m.call(G,r)},W=function r(t){var n=""+t;return M(n)?m.call(this,n)&&this[c]&&this[c]["@@"+n]:g.call(this,t)},q=function(t){var n={enumerable:!1,configurable:!0,get:A,set:function(r){o(this,t,{enumerable:!1,configurable:!0,writable:!0,value:r}),I(this,t,!0)}};try{_(p,t,n)}catch(r){p[t]=n.value}G[t]=_(r(t),"constructor",H);var e=j(C.prototype,"description");return e&&_(G[t],"description",e),T(G[t])},B=function(r){var t=e(r);if(X){var n=U(t);if(""!==n)return n.slice(1,-1)}if(void 0!==f[t])return f[t];var o=t.toString(),u=o.lastIndexOf("0.");return""!==(o=o.slice(10,u))?o:void 0},C=function r(){var t=arguments[0];if(this instanceof r)throw new TypeError("Symbol is not a constructor");var n=a.concat(t||"",i,++u);return void 0===t||null!==t&&!isNaN(t)&&""!==String(t)||(f[n]=String(t)),q(n)},G=E(null),H={value:C},J=function(r){return G[r]},K=function r(t,n,e){var u=""+n;return M(u)?(o(t,u,e.enumerable?z(e):e),I(t,u,!!e.enumerable)):_(t,n,e),t},L=function(r){return function(t){return m.call(r,c)&&m.call(r[c],"@@"+t)}},Q=function r(t){return O(t).filter(t===p?L(t):M).map(J)};F.value=K,_(r,s,F),F.value=Q,_(r,"getOwnPropertySymbols",F),F.value=function r(t){return O(t).filter(D)},_(r,y,F),F.value=function r(t,n){var e=Q(n);return e.length?N(n).concat(e).forEach(function(r){W.call(n,r)&&K(t,r,n[r])}):k(t,n),t},_(r,v,F),F.value=W,_(p,h,F),F.value=C,_(n,"Symbol",F),F.value=function(r){var t=a.concat(a,r,i);return t in p?G[t]:q(t)},_(C,"for",F),F.value=function(r){if(D(r))throw new TypeError(r+" is not a symbol");return m.call(G,r)?r.slice(2*l,-i.length):void 0},_(C,"keyFor",F),F.value=function r(t,n){var e=j(t,n);return e&&M(n)&&(e.enumerable=W.call(t,n)),e},_(r,b,F),F.value=function r(t,n){return 1===arguments.length||void 0===n?E(t):x(t,n)},_(r,"create",F);var R=null===function(){return this}.call(null);if(F.value=R?function(){var r=d.call(this);return"[object String]"===r&&M(this)?"[object Symbol]":r}:function(){if(this===window)return"[object Null]";var r=d.call(this);return"[object String]"===r&&M(this)?"[object Symbol]":r},_(p,"toString",F),o=function(r,t,n){var e=j(p,t);delete p[t],_(r,t,n),r!==p&&_(p,t,e)},function(){try{var t={};return r.defineProperty(t,"t",{configurable:!0,enumerable:!1,get:function(){return!0},set:void 0}),!!t.t}catch(r){return!1}}()){var U;try{U=Function("s","var v = s.valueOf(); return { [v]() {} }[v].name;")}catch(r){}var V=function(){},X=U&&"inferred"===V.name?U:null;r.defineProperty(n.Symbol.prototype,"description",{configurable:!0,enumerable:!1,get:function(){return B(this)}})}}(Object,0,self);Object.defineProperty(self.Symbol,"iterator",{value:self.Symbol("iterator")});function GetIterator(t){var e=arguments.length>1?arguments[1]:GetMethod(t,Symbol.iterator),r=Call(e,t);if("object"!==Type(r))throw new TypeError("bad iterator");var o=GetV(r,"next"),a=Object.create(null);return a["[[Iterator]]"]=r,a["[[NextMethod]]"]=o,a["[[Done]]"]=!1,a}Object.defineProperty(Symbol,"matchAll",{value:Symbol("matchAll")});Object.defineProperty(Symbol,"replace",{value:Symbol("replace")});CreateMethodProperty(String.prototype,"replaceAll",function e(r,t){"use strict";var i=RequireObjectCoercible(this);if(void 0!==r&&null!==r){if(IsRegExp(r)){var o=Get(r,"flags");if(!("flags"in RegExp.prototype||!0===r.global))throw TypeError("");if("flags"in RegExp.prototype&&(RequireObjectCoercible(o),-1===ToString(o).indexOf("g")))throw TypeError("")}var l="Symbol"in self&&"replace"in self.Symbol?GetMethod(r,self.Symbol.replace):void 0;if(void 0!==l)return Call(l,r,[i,t])}var n=ToString(i),a=ToString(r),g=IsCallable(t);!1===g&&(t=ToString(t));for(var f=a.length,s=Math.max(1,f),p=[],v=StringIndexOf(n,a,0);-1!==v;)p.push(v),v=StringIndexOf(n,a,v+s);for(var b=0,u="",S=0;S<p.length;S++){var d=n.substring(b,p[S]);if(g)var h=ToString(Call(t,void 0,[a,p[S],n]));else{var c=[];h=GetSubstitution(a,n,p[S],c,void 0,t)}u=u+d+h,b=p[S]+f}return b<n.length&&(u+=n.substring(b)),u});Object.defineProperty(Symbol,"species",{value:Symbol("species")});!function(e){function t(e,t){if("object"!==Type(e))throw new TypeError("createMapIterator called on incompatible receiver "+Object.prototype.toString.call(e));if(!0!==e._es6Map)throw new TypeError("createMapIterator called on incompatible receiver "+Object.prototype.toString.call(e));var r=Object.create(y);return Object.defineProperty(r,"[[Map]]",{configurable:!0,enumerable:!1,writable:!0,value:e}),Object.defineProperty(r,"[[MapNextIndex]]",{configurable:!0,enumerable:!1,writable:!0,value:0}),Object.defineProperty(r,"[[MapIterationKind]]",{configurable:!0,enumerable:!1,writable:!0,value:t}),r}var r=0,o=Symbol("meta_"+(1e8*Math.random()+"").replace(".","")),a=function(e){if("object"==typeof e?null!==e:"function"==typeof e){if(!Object.isExtensible(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,o)){var t=typeof e+"-"+ ++r;Object.defineProperty(e,o,{configurable:!1,enumerable:!1,writable:!1,value:t})}return e[o]}return""+e},p=function(e,t){var r=a(t);if(!1===r)return i(e,t);var o=e._table[r];return void 0!==o&&o},i=function(e,t){for(var r=0;r<e._keys.length;r++){var o=e._keys[r];if(o!==l&&SameValueZero(o,t))return r}return!1},n=function(e,t,r){var o=a(t);return!1!==o&&(!1===r?delete e._table[o]:e._table[o]=r,!0)},l=Symbol("undef"),c=function e(){if(!(this instanceof e))throw new TypeError('Constructor Map requires "new"');var t=OrdinaryCreateFromConstructor(this,e.prototype,{_table:{},_keys:[],_values:[],_size:0,_es6Map:!0}),r=arguments.length>0?arguments[0]:void 0;if(null===r||void 0===r)return t;var o=t.set;if(!IsCallable(o))throw new TypeError("Map.prototype.set is not a function");try{for(var a=GetIterator(r);;){var p=IteratorStep(a);if(!1===p)return t;var i=IteratorValue(p);if("object"!==Type(i))try{throw new TypeError("Iterator value "+i+" is not an entry object")}catch(e){return IteratorClose(a,e)}try{var n=i[0],l=i[1];o.call(t,n,l)}catch(e){return IteratorClose(a,e)}}}catch(e){if(Array.isArray(r)||"[object Arguments]"===Object.prototype.toString.call(r)){var c,y=r.length;for(c=0;c<y;c++)o.call(t,r[c][0],r[c][1])}}return t};Object.defineProperty(c,"prototype",{configurable:!1,enumerable:!1,writable:!1,value:{}}),Object.defineProperty(c,Symbol.species,{configurable:!0,enumerable:!1,get:function(){return this},set:void 0}),CreateMethodProperty(c.prototype,"clear",function e(){var t=this;if("object"!==Type(t))throw new TypeError("Method Map.prototype.clear called on incompatible receiver "+Object.prototype.toString.call(t));if(!0!==t._es6Map)throw new TypeError("Method Map.prototype.clear called on incompatible receiver "+Object.prototype.toString.call(t));for(var r=t._keys,o=0;o<r.length;o++)t._keys[o]=l,t._values[o]=l;this._size=0,this._table={}}),CreateMethodProperty(c.prototype,"constructor",c),CreateMethodProperty(c.prototype,"delete",function(e){var t=this;if("object"!==Type(t))throw new TypeError("Method Map.prototype.clear called on incompatible receiver "+Object.prototype.toString.call(t));if(!0!==t._es6Map)throw new TypeError("Method Map.prototype.clear called on incompatible receiver "+Object.prototype.toString.call(t));var r=p(t,e);if(!1!==r){var o=t._keys[r];if(o!==l&&SameValueZero(o,e))return this._keys[r]=l,this._values[r]=l,this._size=--this._size,n(this,e,!1),!0}return!1}),CreateMethodProperty(c.prototype,"entries",function e(){return t(this,"key+value")}),CreateMethodProperty(c.prototype,"forEach",function(e){var t=this;if("object"!==Type(t))throw new TypeError("Method Map.prototype.forEach called on incompatible receiver "+Object.prototype.toString.call(t));if(!0!==t._es6Map)throw new TypeError("Method Map.prototype.forEach called on incompatible receiver "+Object.prototype.toString.call(t));if(!IsCallable(e))throw new TypeError(Object.prototype.toString.call(e)+" is not a function.");if(arguments[1])var r=arguments[1];for(var o=t._keys,a=0;a<o.length;a++)t._keys[a]!==l&&t._values[a]!==l&&e.call(r,t._values[a],t._keys[a],t)}),CreateMethodProperty(c.prototype,"get",function e(t){var r=this;if("object"!==Type(r))throw new TypeError("Method Map.prototype.get called on incompatible receiver "+Object.prototype.toString.call(r));if(!0!==r._es6Map)throw new TypeError("Method Map.prototype.get called on incompatible receiver "+Object.prototype.toString.call(r));var o=p(r,t);if(!1!==o){var a=r._keys[o];if(a!==l&&SameValueZero(a,t))return r._values[o]}}),CreateMethodProperty(c.prototype,"has",function e(t){var r=this;if("object"!=typeof r)throw new TypeError("Method Map.prototype.has called on incompatible receiver "+Object.prototype.toString.call(r));if(!0!==r._es6Map)throw new TypeError("Method Map.prototype.has called on incompatible receiver "+Object.prototype.toString.call(r));var o=p(r,t);if(!1!==o){var a=r._keys[o];if(a!==l&&SameValueZero(a,t))return!0}return!1}),CreateMethodProperty(c.prototype,"keys",function e(){return t(this,"key")}),CreateMethodProperty(c.prototype,"set",function e(t,r){var o=this;if("object"!==Type(o))throw new TypeError("Method Map.prototype.set called on incompatible receiver "+Object.prototype.toString.call(o));if(!0!==o._es6Map)throw new TypeError("Method Map.prototype.set called on incompatible receiver "+Object.prototype.toString.call(o));var a=p(o,t);if(!1!==a)o._values[a]=r;else{-0===t&&(t=0);var i={"[[Key]]":t,"[[Value]]":r};o._keys.push(i["[[Key]]"]),o._values.push(i["[[Value]]"]),n(o,t,o._keys.length-1),++o._size}return o}),Object.defineProperty(c.prototype,"size",{configurable:!0,enumerable:!1,get:function(){var e=this;if("object"!==Type(e))throw new TypeError("Method Map.prototype.size called on incompatible receiver "+Object.prototype.toString.call(e));if(!0!==e._es6Map)throw new TypeError("Method Map.prototype.size called on incompatible receiver "+Object.prototype.toString.call(e));return this._size},set:void 0}),CreateMethodProperty(c.prototype,"values",function e(){return t(this,"value")}),CreateMethodProperty(c.prototype,Symbol.iterator,c.prototype.entries),"name"in c||Object.defineProperty(c,"name",{configurable:!0,enumerable:!1,writable:!1,value:"Map"});var y={};Object.defineProperty(y,"isMapIterator",{configurable:!1,enumerable:!1,writable:!1,value:!0}),CreateMethodProperty(y,"next",function e(){var t=this;if("object"!==Type(t))throw new TypeError("Method %MapIteratorPrototype%.next called on incompatible receiver "+Object.prototype.toString.call(t));if(!t.isMapIterator)throw new TypeError("Method %MapIteratorPrototype%.next called on incompatible receiver "+Object.prototype.toString.call(t));var r=t["[[Map]]"],o=t["[[MapNextIndex]]"],a=t["[[MapIterationKind]]"];if(void 0===r)return CreateIterResultObject(void 0,!0);if(!r._es6Map)throw new Error(Object.prototype.toString.call(r)+" has a [[MapData]] internal slot.");for(var p=r._keys,i=p.length;o<i;){var n=Object.create(null);if(n["[[Key]]"]=r._keys[o],n["[[Value]]"]=r._values[o],o+=1,t["[[MapNextIndex]]"]=o,n["[[Key]]"]!==l){if("key"===a)var c=n["[[Key]]"];else if("value"===a)c=n["[[Value]]"];else{if("key+value"!==a)throw new Error;c=[n["[[Key]]"],n["[[Value]]"]]}return CreateIterResultObject(c,!1)}}return t["[[Map]]"]=void 0,CreateIterResultObject(void 0,!0)}),CreateMethodProperty(y,Symbol.iterator,function e(){return this}),CreateMethodProperty(e,"Map",c)}(self);!function(e){function t(e,t){if("object"!=typeof e)throw new TypeError("createSetIterator called on incompatible receiver "+Object.prototype.toString.call(e));if(!0!==e._es6Set)throw new TypeError("createSetIterator called on incompatible receiver "+Object.prototype.toString.call(e));var r=Object.create(i);return Object.defineProperty(r,"[[IteratedSet]]",{configurable:!0,enumerable:!1,writable:!0,value:e}),Object.defineProperty(r,"[[SetNextIndex]]",{configurable:!0,enumerable:!1,writable:!0,value:0}),Object.defineProperty(r,"[[SetIterationKind]]",{configurable:!0,enumerable:!1,writable:!0,value:t}),r}var r=Symbol("undef"),o=function e(){if(!(this instanceof e))throw new TypeError('Constructor Set requires "new"');var t=OrdinaryCreateFromConstructor(this,e.prototype,{_values:[],_size:0,_es6Set:!0}),r=arguments.length>0?arguments[0]:void 0;if(null===r||void 0===r)return t;var o=t.add;if(!IsCallable(o))throw new TypeError("Set.prototype.add is not a function");try{for(var a=GetIterator(r);;){var i=IteratorStep(a);if(!1===i)return t;var n=IteratorValue(i);try{o.call(t,n)}catch(e){return IteratorClose(a,e)}}}catch(e){if(!Array.isArray(r)&&"[object Arguments]"!==Object.prototype.toString.call(r))throw e;var l,p=r.length;for(l=0;l<p;l++)o.call(t,r[l])}return t};Object.defineProperty(o,"prototype",{configurable:!1,enumerable:!1,writable:!1,value:{}}),Object.defineProperty(o,Symbol.species,{configurable:!0,enumerable:!1,get:function(){return this},set:void 0}),CreateMethodProperty(o.prototype,"add",function e(t){var o=this;if("object"!=typeof o)throw new TypeError("Method Set.prototype.add called on incompatible receiver "+Object.prototype.toString.call(o));if(!0!==o._es6Set)throw new TypeError("Method Set.prototype.add called on incompatible receiver "+Object.prototype.toString.call(o));for(var a=o._values,i=0;i<a.length;i++){var n=a[i];if(n!==r&&SameValueZero(n,t))return o}return 0===t&&1/t==-1/0&&(t=0),o._values.push(t),this._size=++this._size,o}),CreateMethodProperty(o.prototype,"clear",function e(){var t=this;if("object"!=typeof t)throw new TypeError("Method Set.prototype.clear called on incompatible receiver "+Object.prototype.toString.call(t));if(!0!==t._es6Set)throw new TypeError("Method Set.prototype.clear called on incompatible receiver "+Object.prototype.toString.call(t));for(var o=t._values,a=0;a<o.length;a++)o[a]=r;this._size=0}),CreateMethodProperty(o.prototype,"constructor",o),CreateMethodProperty(o.prototype,"delete",function(e){var t=this;if("object"!=typeof t)throw new TypeError("Method Set.prototype.delete called on incompatible receiver "+Object.prototype.toString.call(t));if(!0!==t._es6Set)throw new TypeError("Method Set.prototype.delete called on incompatible receiver "+Object.prototype.toString.call(t));for(var o=t._values,a=0;a<o.length;a++){var i=o[a];if(i!==r&&SameValueZero(i,e))return o[a]=r,this._size=--this._size,!0}return!1}),CreateMethodProperty(o.prototype,"entries",function e(){return t(this,"key+value")}),CreateMethodProperty(o.prototype,"forEach",function e(t){var o=this;if("object"!=typeof o)throw new TypeError("Method Set.prototype.forEach called on incompatible receiver "+Object.prototype.toString.call(o));if(!0!==o._es6Set)throw new TypeError("Method Set.prototype.forEach called on incompatible receiver "+Object.prototype.toString.call(o));if(!IsCallable(t))throw new TypeError(Object.prototype.toString.call(t)+" is not a function.");if(arguments[1])var a=arguments[1];for(var i=o._values,n=0;n<i.length;n++){var l=i[n];l!==r&&t.call(a,l,l,o)}}),CreateMethodProperty(o.prototype,"has",function e(t){var o=this;if("object"!=typeof o)throw new TypeError("Method Set.prototype.forEach called on incompatible receiver "+Object.prototype.toString.call(o));if(!0!==o._es6Set)throw new TypeError("Method Set.prototype.forEach called on incompatible receiver "+Object.prototype.toString.call(o));for(var a=o._values,i=0;i<a.length;i++){var n=a[i];if(n!==r&&SameValueZero(n,t))return!0}return!1});var a=function e(){return t(this,"value")};CreateMethodProperty(o.prototype,"values",a),CreateMethodProperty(o.prototype,"keys",a),Object.defineProperty(o.prototype,"size",{configurable:!0,enumerable:!1,get:function(){var e=this;if("object"!=typeof e)throw new TypeError("Method Set.prototype.size called on incompatible receiver "+Object.prototype.toString.call(e));if(!0!==e._es6Set)throw new TypeError("Method Set.prototype.size called on incompatible receiver "+Object.prototype.toString.call(e));for(var t=e._values,o=0,a=0;a<t.length;a++){t[a]!==r&&(o+=1)}return o},set:void 0}),CreateMethodProperty(o.prototype,Symbol.iterator,a),"name"in o||Object.defineProperty(o,"name",{configurable:!0,enumerable:!1,writable:!1,value:"Set"});var i={};Object.defineProperty(i,"isSetIterator",{configurable:!1,enumerable:!1,writable:!1,value:!0}),CreateMethodProperty(i,"next",function e(){var t=this;if("object"!=typeof t)throw new TypeError("Method %SetIteratorPrototype%.next called on incompatible receiver "+Object.prototype.toString.call(t));if(!t.isSetIterator)throw new TypeError("Method %SetIteratorPrototype%.next called on incompatible receiver "+Object.prototype.toString.call(t));var o=t["[[IteratedSet]]"],a=t["[[SetNextIndex]]"],i=t["[[SetIterationKind]]"];if(void 0===o)return CreateIterResultObject(void 0,!0);if(!o._es6Set)throw new Error(Object.prototype.toString.call(o)+" does not have [[SetData]] internal slot.");for(var n=o._values,l=n.length;a<l;){var p=n[a];if(a+=1,t["[[SetNextIndex]]"]=a,p!==r)return"key+value"===i?CreateIterResultObject([p,p],!1):CreateIterResultObject(p,!1)}return t["[[IteratedSet]]"]=void 0,CreateIterResultObject(void 0,!0)}),CreateMethodProperty(i,Symbol.iterator,function e(){return this}),CreateMethodProperty(e,"Set",o)}(self);!function(){function r(r){return"string"==typeof r||"object"==typeof r&&"[object String]"===t.call(r)}var t=Object.prototype.toString,e=String.prototype.match;CreateMethodProperty(Array,"from",function t(o){var a=this,n=arguments.length>1?arguments[1]:void 0;if(void 0===n)var i=!1;else{if(!1===IsCallable(n))throw new TypeError(Object.prototype.toString.call(n)+" is not a function.");var l=arguments.length>2?arguments[2]:void 0;if(void 0!==l)var c=l;else c=void 0;i=!0}var u=GetMethod(o,Symbol.iterator);if(void 0!==u){if(IsConstructor(a))var v=Construct(a);else v=ArrayCreate(0);for(var f=GetIterator(o,u),s=0;;){if(s>=Math.pow(2,53)-1){var h=new TypeError("Iteration count can not be greater than or equal 9007199254740991.");return IteratorClose(f,h)}var y=ToString(s),C=IteratorStep(f);if(!1===C)return v.length=s,v;var g=IteratorValue(C);if(i)try{var p=Call(n,c,[g,s])}catch(r){return IteratorClose(f,r)}else p=g;try{CreateDataPropertyOrThrow(v,y,p)}catch(r){return IteratorClose(f,r)}s+=1}}if(r(o))var I=e.call(o,/[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g)||[];else I=ToObject(o);var b=ToLength(Get(I,"length"));for(v=IsConstructor(a)?Construct(a,[b]):ArrayCreate(b),s=0;s<b;){y=ToString(s);var d=Get(I,y);p=!0===i?Call(n,c,[d,s]):d,CreateDataPropertyOrThrow(v,y,p),s+=1}return v.length=b,v})}();Object.defineProperty(Symbol,"toStringTag",{value:Symbol("toStringTag")});function CreateRegExpStringIterator(e,t,r,n){var a={};return CreateMethodProperty(a,"next",function a(){if(!0===this["[[Done]]"])return CreateIterResultObject(void 0,!0);var i=RegExpExec(e,t);if(null===i)return this["[[Done]]"]=!0,CreateIterResultObject(void 0,!0);if(!1===r){var o=CreateIterResultObject(i,!1);return this["[[Done]]"]=!0,o}if(""===ToString(Get(i,"0"))){var u=ToLength(Get(e,"lastIndex")),l=AdvanceStringIndex(t,u,n);e.lastIndex=l}return CreateIterResultObject(i,!1)}),Object.defineProperty(a,Symbol.toStringTag,{configurable:!0,enumerable:!1,writable:!1,value:"RegExp String Iterator"}),CreateMethodProperty(a,Symbol.iterator,function e(){return this}),a}var supportsRegexpLiteralConstructorWithFlags=function(){try{return new RegExp(/x/,"g"),!0}catch(t){return!1}}();CreateMethodProperty(RegExp.prototype,Symbol.matchAll,function(t){"use strict";var e=this;if("object"!==Type(e))throw new TypeError("Method called on incompatible type: must be an object.");var r=ToString(t),o=SpeciesConstructor(e,RegExp),n=ToString(Get(e,"flags"));"flags"in RegExp.prototype||(n="",!0===e.global&&(n+="g"),!0===e.ignoreCase&&(n+="i"),!0===e.multiline&&(n+="m"));var a=Construct(o,[supportsRegexpLiteralConstructorWithFlags?e:e.source,n]),i=ToLength(Get(e,"lastIndex"));a.lastIndex=i;var p=n.indexOf("g")>-1,s=n.indexOf("u")>-1;return CreateRegExpStringIterator(a,r,p,s)});CreateMethodProperty(String.prototype,"matchAll",function e(l){"use strict";var r=RequireObjectCoercible(this);if(void 0!==l&&null!==l){if(IsRegExp(l)){var t=Get(l,"flags");if(!("flags"in RegExp.prototype||!0===l.global))throw TypeError("");if("flags"in RegExp.prototype&&(RequireObjectCoercible(t),-1===ToString(t).indexOf("g")))throw TypeError("")}var o="Symbol"in self&&"matchAll"in self.Symbol?GetMethod(l,self.Symbol.matchAll):void 0;if(void 0!==o)return Call(o,l,[r])}var i=ToString(r),n=new RegExp(l,"g");return Invoke(n,"Symbol"in self&&"matchAll"in self.Symbol&&self.Symbol.matchAll,[i])});var Iterator=function(){var e=function(){return this.length=0,this},t=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e},_=function(e,n){if(!(this instanceof _))return new _(e,n);Object.defineProperties(this,{__list__:{writable:!0,value:e},__context__:{writable:!0,value:n},__nextIndex__:{writable:!0,value:0}}),n&&(t(n.on),n.on("_add",this._onAdd.bind(this)),n.on("_delete",this._onDelete.bind(this)),n.on("_clear",this._onClear.bind(this)))};return Object.defineProperties(_.prototype,Object.assign({constructor:{value:_,configurable:!0,enumerable:!1,writable:!0},_next:{value:function(){var e;if(this.__list__)return this.__redo__&&void 0!==(e=this.__redo__.shift())?e:this.__nextIndex__<this.__list__.length?this.__nextIndex__++:void this._unBind()},configurable:!0,enumerable:!1,writable:!0},next:{value:function(){return this._createResult(this._next())},configurable:!0,enumerable:!1,writable:!0},_createResult:{value:function(e){return void 0===e?{done:!0,value:void 0}:{done:!1,value:this._resolve(e)}},configurable:!0,enumerable:!1,writable:!0},_resolve:{value:function(e){return this.__list__[e]},configurable:!0,enumerable:!1,writable:!0},_unBind:{value:function(){this.__list__=null,delete this.__redo__,this.__context__&&(this.__context__.off("_add",this._onAdd.bind(this)),this.__context__.off("_delete",this._onDelete.bind(this)),this.__context__.off("_clear",this._onClear.bind(this)),this.__context__=null)},configurable:!0,enumerable:!1,writable:!0},toString:{value:function(){return"[object Iterator]"},configurable:!0,enumerable:!1,writable:!0}},{_onAdd:{value:function(e){if(!(e>=this.__nextIndex__)){if(++this.__nextIndex__,!this.__redo__)return void Object.defineProperty(this,"__redo__",{value:[e],configurable:!0,enumerable:!1,writable:!1});this.__redo__.forEach(function(t,_){t>=e&&(this.__redo__[_]=++t)},this),this.__redo__.push(e)}},configurable:!0,enumerable:!1,writable:!0},_onDelete:{value:function(e){var t;e>=this.__nextIndex__||(--this.__nextIndex__,this.__redo__&&(t=this.__redo__.indexOf(e),-1!==t&&this.__redo__.splice(t,1),this.__redo__.forEach(function(t,_){t>e&&(this.__redo__[_]=--t)},this)))},configurable:!0,enumerable:!1,writable:!0},_onClear:{value:function(){this.__redo__&&e.call(this.__redo__),this.__nextIndex__=0},configurable:!0,enumerable:!1,writable:!0}})),Object.defineProperty(_.prototype,Symbol.iterator,{value:function(){return this},configurable:!0,enumerable:!1,writable:!0}),Object.defineProperty(_.prototype,Symbol.toStringTag,{value:"Iterator",configurable:!1,enumerable:!1,writable:!0}),_}();var ArrayIterator=function(){var e=function(t,r){if(!(this instanceof e))return new e(t,r);Iterator.call(this,t),r=r?String.prototype.includes.call(r,"key+value")?"key+value":String.prototype.includes.call(r,"key")?"key":"value":"value",Object.defineProperty(this,"__kind__",{value:r,configurable:!1,enumerable:!1,writable:!1})};return Object.setPrototypeOf&&Object.setPrototypeOf(e,Iterator.prototype),e.prototype=Object.create(Iterator.prototype,{constructor:{value:e,configurable:!0,enumerable:!1,writable:!0},_resolve:{value:function(e){return"value"===this.__kind__?this.__list__[e]:"key+value"===this.__kind__?[e,this.__list__[e]]:e},configurable:!0,enumerable:!1,writable:!0},toString:{value:function(){return"[object Array Iterator]"},configurable:!0,enumerable:!1,writable:!0}}),e}();CreateMethodProperty(Array.prototype,"entries",function r(){var e=ToObject(this);return new ArrayIterator(e,"key+value")});!function(){"use strict";function n(){return tn[q][B]||D}function t(n){return n&&"object"==typeof n}function e(n){return"function"==typeof n}function r(n,t){return n instanceof t}function o(n){return r(n,A)}function i(n,t,e){if(!t(n))throw a(e)}function u(){try{return b.apply(R,arguments)}catch(n){return Y.e=n,Y}}function c(n,t){return b=n,R=t,u}function f(n,t){function e(){for(var e=0;e<o;)t(r[e],r[e+1]),r[e++]=T,r[e++]=T;o=0,r.length>n&&(r.length=n)}var r=L(n),o=0;return function(n,t){r[o++]=n,r[o++]=t,2===o&&tn.nextTick(e)}}function s(n,t){var o,i,u,f,s=0;if(!n)throw a(N);var l=n[tn[q][z]];if(e(l))i=l.call(n);else{if(!e(n.next)){if(r(n,L)){for(o=n.length;s<o;)t(n[s],s++);return s}throw a(N)}i=n}for(;!(u=i.next()).done;)if((f=c(t)(u.value,s++))===Y)throw e(i[G])&&i[G](),f.e;return s}function a(n){return new TypeError(n)}function l(n){return(n?"":Q)+(new A).stack}function h(n,t){var e="on"+n.toLowerCase(),r=F[e];E&&E.listeners(n).length?n===X?E.emit(n,t._v,t):E.emit(n,t):r?r({reason:t._v,promise:t}):tn[n](t._v,t)}function v(n){return n&&n._s}function _(n){if(v(n))return new n(Z);var t,r,o;return t=new n(function(n,e){if(t)throw a();r=n,o=e}),i(r,e),i(o,e),t}function d(n,t){var e=!1;return function(r){e||(e=!0,I&&(n[M]=l(!0)),t===U?g(n,r):y(n,t,r))}}function p(n,t,r,o){return e(r)&&(t._onFulfilled=r),e(o)&&(n[J]&&h(W,n),t._onRejected=o),I&&(t._p=n),n[n._c++]=t,n._s!==$&&rn(n,t),t}function m(n){if(n._umark)return!0;n._umark=!0;for(var t,e=0,r=n._c;e<r;)if(t=n[e++],t._onRejected||m(t))return!0}function w(n,t){function e(n){return r.push(n.replace(/^\s+|\s+$/g,""))}var r=[];return I&&(t[M]&&e(t[M]),function n(t){t&&K in t&&(n(t._next),e(t[K]+""),n(t._p))}(t)),(n&&n.stack?n.stack:n)+("\n"+r.join("\n")).replace(nn,"")}function j(n,t){return n(t)}function y(n,t,e){var r=0,i=n._c;if(n._s===$)for(n._s=t,n._v=e,t===O&&(I&&o(e)&&(e.longStack=w(e,n)),on(n));r<i;)rn(n,n[r++]);return n}function g(n,r){if(r===n&&r)return y(n,O,a(V)),n;if(r!==S&&(e(r)||t(r))){var o=c(k)(r);if(o===Y)return y(n,O,o.e),n;e(o)?(I&&v(r)&&(n._next=r),v(r)?x(n,r,o):tn.nextTick(function(){x(n,r,o)})):y(n,U,r)}else y(n,U,r);return n}function k(n){return n.then}function x(n,t,e){var r=c(e,t)(function(e){t&&(t=S,g(n,e))},function(e){t&&(t=S,y(n,O,e))});r===Y&&t&&(y(n,O,r.e),t=S)}var T,b,R,S=null,C="object"==typeof self,F=self,P=F.Promise,E=F.process,H=F.console,I=!0,L=Array,A=Error,O=1,U=2,$=3,q="Symbol",z="iterator",B="species",D=q+"("+B+")",G="return",J="_uh",K="_pt",M="_st",N="Invalid argument",Q="\nFrom previous ",V="Chaining cycle detected for promise",W="rejectionHandled",X="unhandledRejection",Y={e:S},Z=function(){},nn=/^.+\/node_modules\/yaku\/.+\n?/gm,tn=function(n){var r,o=this;if(!t(o)||o._s!==T)throw a("Invalid this");if(o._s=$,I&&(o[K]=l()),n!==Z){if(!e(n))throw a(N);r=c(n)(d(o,U),d(o,O)),r===Y&&y(o,O,r.e)}};tn.default=tn,function en(n,t){for(var e in t)n[e]=t[e]}(tn.prototype,{then:function(n,t){if(void 0===this._s)throw a();return p(this,_(tn.speciesConstructor(this,tn)),n,t)},catch:function(n){return this.then(T,n)},finally:function(n){return this.then(function(t){return tn.resolve(n()).then(function(){return t})},function(t){return tn.resolve(n()).then(function(){throw t})})},_c:0,_p:S}),tn.resolve=function(n){return v(n)?n:g(_(this),n)},tn.reject=function(n){return y(_(this),O,n)},tn.race=function(n){var t=this,e=_(t),r=function(n){y(e,U,n)},o=function(n){y(e,O,n)},i=c(s)(n,function(n){t.resolve(n).then(r,o)});return i===Y?t.reject(i.e):e},tn.all=function(n){function t(n){y(o,O,n)}var e,r=this,o=_(r),i=[];return(e=c(s)(n,function(n,u){r.resolve(n).then(function(n){i[u]=n,--e||y(o,U,i)},t)}))===Y?r.reject(e.e):(e||y(o,U,[]),o)},tn.Symbol=F[q]||{},c(function(){Object.defineProperty(tn,n(),{get:function(){return this}})})(),tn.speciesConstructor=function(t,e){var r=t.constructor;return r?r[n()]||e:e},tn.unhandledRejection=function(n,t){H&&H.error("Uncaught (in promise)",I?t.longStack:w(n,t))},tn.rejectionHandled=Z,tn.enableLongStackTrace=function(){I=!0},tn.nextTick=C?function(n){P?new P(function(n){n()}).then(n):setTimeout(n)}:E.nextTick,tn._s=1;var rn=f(999,function(n,t){var e,r;return(r=n._s!==O?t._onFulfilled:t._onRejected)===T?void y(t,n._s,n._v):(e=c(j)(r,n._v))===Y?void y(t,O,e.e):void g(t,e)}),on=f(9,function(n){m(n)||(n[J]=1,h(X,n))});F.Promise=tn}();})('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
\ No newline at end of file
{
"groups": [],
"path": "./resource/"
}
\ No newline at end of file
var fs = require("fs");
var del = require('del');
function delDir(path, isSelf) {
let files = [];
if (fs.existsSync(path)) {
files = fs.readdirSync(path);
files.forEach((file, index) => {
let curPath = path + "/" + file;
if (fs.statSync(curPath).isDirectory()) {
delDir(curPath); //递归删除文件夹
} else {
fs.unlinkSync(curPath); //删除文件
}
});
if (!isSelf) fs.rmdirSync(path);
}
}
var paths = './released/';//设置删除路径
// delDir(paths, true);//删除文件夹
del(paths).then(() => {
fs.mkdirSync(paths);
}).catch(()=>{
fs.mkdirSync(paths);
})
\ No newline at end of file
...@@ -5,6 +5,36 @@ const config = require('../webpack.dev.js') ...@@ -5,6 +5,36 @@ const config = require('../webpack.dev.js')
const compiler = webpack(config) const compiler = webpack(config)
const server = new webpackDevServer(config.devServer, compiler) const server = new webpackDevServer(config.devServer, compiler)
const path = require("path");
const runScript = require("./runScript");
const fs = require("fs");
// const skinUrl = "./resource/skin.json";
// fs.watchFile(skinUrl, { persistent: true, interval: 2000 }, (curr, prev) => {
// const skinDataAll = fs.readFileSync(skinUrl)
// var endFile = `export const SkinJson = ${skinDataAll}`
// fs.writeFileSync("./src/SkinJson.ts", endFile);
// console.log("SkinJson.ts文件已更新")
// })
// 修改resource文件夹任意内容自动刷新资源
fs.watch('./resource/', { recursive: true }, (event, filename) => {
if (
filename === ".DS_Store"
|| filename === "res.json"
|| filename === "skin.json"
) return;
runScript(path.resolve('./scripts/flushRes.js'), (err) => {
console.log(err);
});
});
runScript(path.resolve('./scripts/flushRes.js'), (err) => {
console.log(err);
});
const argv = process.argv; const argv = process.argv;
const runServer = async () => { const runServer = async () => {
......
//生成res.json
//遍历资源文件夹,生成
var fs = require('fs');
var path = require("path");
var readPath = "./resource/"
var files = fs.readdirSync(readPath);
var obj = { groups: [] };//每项包括keys合name
files.forEach(function (file) {
//路径
let fPath = path.join(readPath, file);
//只处理文件夹
if (fs.statSync(fPath).isDirectory()) {
//继续读每个子文件夹,json和png名字有相同的,只留json,
var sonFiles = fs.readdirSync(fPath);
//没有文件
if (!sonFiles.length) return
//取出所有json
var jsons = sonFiles.filter((f) => { return f.substr(-5) == ".json" })
//去掉json所带png的图片
sonFiles = sonFiles.filter((f) => { return jsons.indexOf(f.substring(0, f.length - 4) + ".json") == -1 })
//去掉mac上的缓存文件
sonFiles = sonFiles.filter((f) => { return f != '.DS_Store' })
var group = {
keys: "",
name: file
}
for (var i = 0; i < sonFiles.length; i++) {
if (i != 0) group.keys += ",";
group.keys += sonFiles[i]
}
obj.groups.push(group)
}
})
obj.path="./resource/"
console.log("资源更新完成")
//生成json
fs.writeFileSync(readPath + "res.json", JSON.stringify(obj, "", "\t"));
//TS也更新
var endPath = './src/';
var endFile = `export const ResJson = ${JSON.stringify(obj, "", "\t")}`
fs.writeFileSync(endPath + "ResJson.ts", endFile);
\ No newline at end of file
var fs = require("fs");
// fs.writeFileSync(
// "./released/output.js",
// fs.readFileSync("./output.js")
// )
var endPath = './released/';
fs.writeFileSync(endPath + "output.js",
// 'import * as FYGE from "fyge-tbmini";\n' +
// 'import * as FYGE from "fyge";\n' +//以后改成这个
// 'import * as SvgaParser from "svga-parser";\n' +
'/* eslint-disable */\n' +
fs.readFileSync("./output.js"));
console.log("js生成")
/*
* runScript.js
* Created by 还有醋v on 2021/5/8.
* Copyright © 2021 haiyoucuv. All rights reserved.
*/
const childProcess = require('child_process');
module.exports = function runScript(scriptPath, callback) {
let invoked = false;
const process = childProcess.fork(scriptPath);
process.on('error', function (err) {
if (invoked) return;
invoked = true;
callback(err);
});
process.on('exit', function (code) {
if (invoked) return;
invoked = true;
const err = code === 0 ? null : new Error('exit code ' + code);
callback(err);
});
}
var fs = require('fs');
var path = require('path');
const co = require('co');
const OSS = require('ali-oss');
const chalk = require('chalk');
const ProgressBar = require('progress');
class TuiaAutoUpload {
constructor(props, type) {
this.type = type;
const defaultOptions = {
dir: undefined,
originDir: undefined
}
this.options = Object.assign({}, defaultOptions, props);
if (!this.options.dir || !this.options.originDir) {
console.log(chalk.red('缺少参数,初始化失败'))
return;
}
this.init();
}
init() {
var _this = this;
this.client = new OSS({
region: 'oss-cn-hangzhou',
accessKeyId: 'LTAI4Fw25WcfcGv7FvcHoiHK',
accessKeySecret: 'NZk1NtT9J5HFaAolNbtQdzTzLLvLYm',
bucket: _this.type === 'prod' ? 'duiba' : 'daily-duiba'
});
this.bar = new ProgressBar(chalk.yellow(` 文件上传中 [:bar] :current/${this.files().length} :percent :elapseds`), {
complete: '●',
incomplete: '○',
width: 20,
total: this.files().length,
callback: () => {
console.log(chalk.green('\n All complete.'));
console.log(chalk.blue(`\n 本次队列文件共${this.files().length}个,已存在文件${this.existFiles}个,上传文件${this.uploadFiles}个,上传失败文件${this.errorFiles}个\n`));
}
})
return this;
}
files() {
var _this = this;
if (this._files) return this._files;
this._files = [];
/**
* 文件遍历方法
* @param filePath 需要遍历的文件路径
*/
function fileDisplay(filePath) {
//根据文件路径读取文件,返回文件列表
var files = fs.readdirSync(filePath);
files.forEach(function (filename) {
//获取当前文件的绝对路径
var filedir = path.join(filePath, filename);
//根据文件路径获取文件信息,返回一个fs.Stats对象
var stats = fs.statSync(filedir);
var isFile = stats.isFile();//是文件
var isDir = stats.isDirectory();//是文件夹
if (isFile) {
var sep = '/';
if ('win32' == process.platform)
sep = '\\';
var newDirArr = filedir.split(sep);
newDirArr.shift();
_this._files.push(newDirArr.join('/'));
}
if (isDir) {
fileDisplay(filedir);//递归,如果是文件夹,就继续遍历该文件夹下面的文件
}
});
}
//调用文件遍历方法
fileDisplay(this.options.dir);
return this._files;
}
start() {
this.files().map((file, index) => {
let _this = this;
const path1 = path.join(path.resolve(__dirname, '..'), 'released', file);
let originFile;
this.existFiles = 0;
this.uploadFiles = 0;
this.errorFiles = 0;
co(function* () {
const originPath = `${_this.options.originDir}${file}`;
try {
originFile = yield _this.client.head(originPath);
} catch (error) {
originFile = error;
}
if (_this.type === 'prod') {
if (originFile.status === 404) {
yield _this.client.put(originPath, path1);
_this.uploadFiles += 1;
} else {
_this.existFiles += 1;
}
} else if (_this.type === 'dev') {
if (originFile.status === 404 || originFile.status === 200) {
_this.existFiles += 1;
}
yield _this.client.put(originPath, path1, {
headers: {
'Cache-Control': 'no-cache'
}
})
_this.uploadFiles += 1;
}
_this.bar.tick();
}).catch(function (err) {
_this.errorFiles += 1;
console.log(err);
});
});
}
}
const configFileName = 'project.json';
if (!fs.existsSync(configFileName)) {
throw new Error(`${configFileName}不存在.`)
}
let config = fs.readFileSync('project.json');
config = JSON.parse(config + '');
if (!config.type) {
throw new Error(`${configFileName}的type不存在.`)
}
if (!config.name) {
throw new Error(`${configFileName}的name不存在.`)
}
const now = new Date();
const version = Math.round(now.getTime() / 1000);
console.log(`版本号:
${version}`)
const autoupload = new TuiaAutoUpload({
dir: './released/',
// dir: path.join(__dirname, './released/'),
originDir: `/db_games/${config.type}/${config.name}/${version}/`
}, "prod")
autoupload.start()
var iconv = require('iconv-lite');
var readPath = "./released/resource/";
//读取json文件
var data = iconv.decode(fs.readFileSync(readPath + "res.json"), "utf-8");//GBK
//反序列化
data = JSON.parse(data);
data.path = `https://yun.duiba.com.cn/db_games/${config.type}/${config.name}/${version}/resource/`
//写入目标文件夹,可配置,每个项目必须修改,或者直接和project的保持一致(淘宝项目文件固定后)
var endPath = './src/';
var endFile = `export const ResJson = ${JSON.stringify(data, "", "\t")}`
endFile = endFile.replace(
`"path": "${data.path}"`,
`// eslint-disable-next-line\n\t"path": "${data.path}"`
);
fs.writeFileSync(endPath + "ResJson.ts", endFile);
//根据参数吧,有就是web。需要生成皮肤和js,没有就不执行后续
let arg = process.argv.splice(2);
if (!arg[0]) return;
//有版本号了,模板也生成吧
require("./createHtml")(`${config.type}/${config.name}/${version}`);
var uploadSingleJs = require("./uploadSingleJs")
var exec = require('child_process').exec;
//打包js
exec("webpack --config webpack.prod.js", { encoding: 'utf8' }, (e) => {
if (e) {
console.log('webpack error:', e)
return
}
uploadSingleJs(`${config.type}/${config.name}/${version}`)
//再打印一次
console.log(`版本号:
${version}`)
})
\ No newline at end of file
const co = require('co');
const OSS = require('ali-oss');
var fs = require('fs');
let arg = process.argv.splice(2);
//只打包js时,自执行上传
if(arg[0])uploadSingleJs();
function uploadSingleJs(url) {
if (!url) {//不传的时候
const configFileName = 'project.json';
if (!fs.existsSync(configFileName)) {
throw new Error(`${configFileName}不存在.`)
}
let config = fs.readFileSync('project.json');
config = JSON.parse(config + '');
if (!config.type) {
throw new Error(`${configFileName}的type不存在.`)
}
if (!config.name) {
throw new Error(`${configFileName}的name不存在.`)
}
const now = new Date();
const version = Math.round(now.getTime() / 1000);
console.log(`版本号:
${version}`)
url = `${config.type}/${config.name}/${version}`;
require("./createHtml")(`${config.type}/${config.name}/${version}`);
}
//单js文件上传
co(function* () {
const originPath = `/db_games/${url}/output.js`;
var client = new OSS({
region: 'oss-cn-hangzhou',
accessKeyId: 'LTAI4Fw25WcfcGv7FvcHoiHK',
accessKeySecret: 'NZk1NtT9J5HFaAolNbtQdzTzLLvLYm',
bucket: 'duiba'
})
var originFile;
try {
originFile = yield client.head(originPath);
} catch (error) {
originFile = error;
}
if (originFile.status === 404)
yield client.put(originPath, "./output.js");
})
}
module.exports = uploadSingleJs
\ No newline at end of file
import Dream from ".."
import { UseAni } from "../../modules/UseDecorator/useAni"
import {
EventsMap
} from '../types'
type DreamFC<T extends Record<string, any> = {}, R extends any = FYGE.Container> = (props: {
ref?: (c: R) => void,
inlineProps?: Record<string, any>
children?: FYGE.Container[], // 这样写的话,外面也能提示了 -。-
} & T) => FYGE.Container
type OriginalElementWidthEvents<extraProps={}, T = FYGE.Container> = DreamFC<EventsMap & extraProps, T>
type DrawData = {
'rect': [number, number, number, number],
'circle': [number, number, number]
}
export const FPShapeOfRectV2: DreamFC<Partial<{
type: keyof DrawData,
drawData: any,
fillColor: string,
alpha: number
}>> = function ({
type = 'rect',
fillColor = '#000000',
alpha = 1,
drawData = [0, 0, 750, 1624]
}) {
const graphicsIns = new FYGE.Shape()
graphicsIns.beginFill(fillColor)
if (type === 'rect') {
graphicsIns.drawRect(drawData[0], drawData[1], drawData[2], drawData[3])
} else if (type === 'circle') {
graphicsIns.drawCircle(drawData[0], drawData[1], drawData[2])
}
graphicsIns.endFill()
graphicsIns.alpha = alpha
return graphicsIns
}
function ScaleAni(t: number) {
return function(c: FYGE.Container) {
return new Promise(async (r) => {
FYGE.Tween.removeTweens(c)
c.scale.set(0, 0)
await new Promise(resolve => setTimeout(resolve, t))
FYGE.Tween.get(c, {
loop: true
})
.to({scaleX: 1, scaleY: 1}, 500, FYGE.Ease.quadInOut)
.to({scaleX: 0, scaleY: 0}, 500, FYGE.Ease.quadInOut)
.wait(1000)
})
}
}
export const DotAni: OriginalElementWidthEvents<{
delay: number,
radius: number
}> = function({
delay,
radius
}) {
const Cls: any = UseAni({
showCall: ScaleAni(delay)
})(function() {
const shapIns = new FYGE.Shape()
shapIns.beginFill('#43b99f')
shapIns.drawCircle(0, 0, radius)
shapIns.endFill()
return shapIns
})
return <Cls></Cls>
}
export class DreamDotAni extends Dream.RenderContainer {
render() {
return (
<FYGE.Container>
<FPShapeOfRectV2 type="rect" alpha={0.6} fillColor="#00000"></FPShapeOfRectV2>
{
Array.from({
length: 3
}, (_, index) => {
return (
<DotAni inlineProps={{
x: 270 + 100 * index,
y: 780
}} delay={index * 150} radius={40}></DotAni>
)
})
}
</FYGE.Container>
)
}
}
export const Container: OriginalElementWidthEvents = function() {
return (
<FYGE.Container>
</FYGE.Container>
)
}
export class DreamSpriteV2 extends Dream.RenderContainer<{
src: string | FYGE.Texture
}> {
notifyDisplayChange(w: number, h: number) {
let t = this.wrapperCont.parent
if (t.isInDisplay) {
t.sw = w
t.sh = h
}
while(t) {
t.dispatchEvent('updateDisplay')
t = t.parent
}
}
wrapperCont: FYGE.Container
render() {
const {
src
} = this.props
let _sp: FYGE.Sprite
if (typeof src === 'string') {
_sp = new FYGE.Sprite()
// 记得改一下 可能是加载过的
FYGE.GlobalLoader.loadImage((s, image) => {
if (s && image) {
const texture = FYGE.Texture.fromImage(image!)
_sp.texture = texture
this.notifyDisplayChange(texture.width, texture.height)
}
}, src)
} else {
_sp = new FYGE.Sprite(src)
}
this.wrapperCont = _sp
return _sp
}
}
\ No newline at end of file
import { RenderContainer } from "./renderContainer"
import { EventsMap } from "./types"
import { isFunction, nextTick } from "./utils"
type GetConstructType<T extends abstract new(...args: any)=>any> =
T extends abstract new (...args: infer P) => any
? P
: never
type ChildType = RenderContainer | FYGE.Container
type ChildrenTypeArray = Array<RenderContainer | FYGE.Container>
export function addChildFromParent(parent: FYGE.Container, children: ChildType[] | ChildType) {
if (Array.isArray(children)) {
children.forEach((child) => {
if (Array.isArray(child)) {
addChildFromParent(parent, child)
} else {
if (typeof child === 'number') {
// @ts-ignore
child = child + ''
}
if (typeof child === 'string') {
const t = new FYGE.TextField()
t.text = child
t.fillColor = '#000000'
// @ts-ignore
child = t
}
if (child instanceof RenderContainer) {
const node = child.render()
node! && parent.addChild(node)
} else {
// 可能createElement 会return null or undefined
child && parent.addChild(child)
}
}
})
} else {
if (children instanceof RenderContainer) {
const node = children.render()
node! && parent.addChild(node)
} else {
parent.addChild(children)
}
}
}
export function createElement<K extends new(p?: any) => ChildType, T extends ChildType>(ConstructType: K, props: Record<string, any> & {
inlineProps: Record<string, any>,
children: any[],
ref?: (c: ChildType) => void,
} & EventsMap, ...children: ChildrenTypeArray) {
if (typeof ConstructType === 'string') {
throw TypeError('Dream create cannot effect for string element type')
}
// TODO Object.freeze
props = props || Object.create(null)
// delete props.children
props.children = children
// Object.freeze(props)
// type tk = GetConstructType<K>
let eleins = new ConstructType(props)
if (
!(eleins instanceof RenderContainer || eleins instanceof FYGE.Container)
) {
throw TypeError(`class ${ConstructType} must extends RenderContainer or FYGE.Container...`)
}
const ref = props.ref
if (typeof ref === 'function') {
nextTick(function() {
ref(eleins)
})
// 别往下传播了
delete props.ref
}
if (eleins instanceof FYGE.Container) {
const inlineProps = props.inlineProps
if (inlineProps) {
// 简单点直接赋值
for (let k in inlineProps) {
// @ts-ignore 里面是 getter 和 setter 写的
(eleins[k] = inlineProps[k])
}
}
if (isFunction(props.onClick)) {
eleins.addEventListener(FYGE.MouseEvent.CLICK, props.onClick!)
}
if (isFunction(props.onClickCapture)) {
eleins.addEventListener(FYGE.MouseEvent.CLICK, props.onClickCapture!, eleins, true)
}
if (isFunction(props.onEnterFrame)) {
eleins.addEventListener(FYGE.Event.ENTER_FRAME, props.onEnterFrame!)
}
if (isFunction(props.onAddedToStage)) {
eleins.addEventListener(FYGE.Event.ADDED_TO_STAGE, props.onAddedToStage!)
}
// _noap 不会加到后面
!props._noap && addChildFromParent(eleins, children)
} else if (eleins instanceof RenderContainer) {
// 因为是 倒序的 nextTick 这里就先 didRendered 注册一下, 先让 render 里面的 ref 跑完
nextTick(function() {
(eleins as RenderContainer).didRendered()
}, eleins)
const node = eleins.render()
// Promise.resolve().then(() => {
// // @ts-ignore
// eleins.didRendered()
// })
// node && (eleins = node)
return node
}
return eleins
}
\ No newline at end of file
import { addChildFromParent, createElement } from "./development";
import { RenderContainer } from "./renderContainer";
export default {
createElement: createElement,
RenderContainer: RenderContainer,
VirtualRender: addChildFromParent
}
\ No newline at end of file
type PropsWithRef<P extends Record<string, any>> = P & { ref?: (e: any) => any };
export class RenderContainer<P extends Record<string, any> = any> {
readonly props: Readonly<P> & Readonly<{ children?: FYGE.Container[] }>;
constructor(props: Readonly<P> | P | Readonly<{ref?: (e: RenderContainer) => any} & P>) {
this.props = props
}
didRendered() {
}
render(): any {
}
}
\ No newline at end of file
type EventCallBack<T extends any = any> = (e: T) => any
export type EventsMap = {
onClick?: EventCallBack<FYGE.MouseEvent>
onClickCapture?: EventCallBack<FYGE.MouseEvent>
onEnterFrame?: EventCallBack<FYGE.Event>
onAddedToStage?: EventCallBack<FYGE.Event>
}
\ No newline at end of file
export function isFunction(p: any) {
return typeof p === 'function'
}
const inBrowser = !!document // 简单 的 判断 是否在浏览器中
// nextTick 简单原理
// 借助 MutationObserver 来进行处理 下一事件循环
// Mo 会在所有 同步代码执行之后 才会执行回调
const hasMutationObserverBug = false // 这里就简单这样处理吧
export const nextTick = (function () {
var callbacks: Function[] = []
var pending = false
var timerFunc: Function
function nextTickHandler () {
pending = false
// 之所以要slice复制一份出来是因为有的cb执行过程中又会往callbacks中加入内容
// 比如$nextTick的回调函数里又有$nextTick
// 这些是应该放入到下一个轮次的nextTick去执行的,
// 所以拷贝一份当前的,遍历执行完当前的即可,避免无休止的执行下去
var copies = callbacks.slice(0)
callbacks = []
// console.log(copies)
// for (var i = 0; i < copies.length; i++) {
// copies[i]()
// }
// 这里专门处理了一下
for (var i = copies.length - 1; i >= 0; i--) {
copies[i]()
}
}
if (typeof Promise !== 'undefined') {
timerFunc = function() {
Promise.resolve().then(() => {
nextTickHandler()
})
}
} else if (typeof MutationObserver !== 'undefined' && !hasMutationObserverBug) {
/* istanbul ignore if */
// ios9.3以上的WebView的MutationObserver有bug,
//所以在hasMutationObserverBug中存放了是否是这种情况
var counter = 1
// 创建一个MutationObserver,observer监听到dom改动之后后执行回调nextTickHandler
var observer = new MutationObserver(nextTickHandler)
var textNode = document.createTextNode(counter + '')
// 调用MutationObserver的接口,观测文本节点的字符内容
observer.observe(textNode, {
characterData: true
})
// 每次执行timerFunc都会让文本节点的内容在0/1之间切换,
// 不用true/false可能是有的浏览器对于文本节点设置内容为true/false有bug?
// 切换之后将新值赋值到那个我们MutationObserver观测的文本节点上去
timerFunc = function () {
counter = (counter + 1) % 2
textNode.data = counter + ''
}
} else {
// webpack attempts to inject a shim for setImmediate
// if it is used as a global, so we have to work around that to
// avoid bundling unnecessary code.
// webpack默认会在代码中插入setImmediate的垫片
// 没有MutationObserver就优先用setImmediate,不行再用setTimeout
const context = inBrowser
? window
: typeof global !== 'undefined' ? global : {
setImmediate
}
timerFunc = context.setImmediate || setTimeout
}
return function (cb: Function, ctx?: any) {
var func = ctx
? function () { cb.call(ctx) }
: cb
callbacks.push(func)
// 如果pending为true, 就其实表明本轮事件循环中已经执行过timerFunc(nextTickHandler, 0)
if (pending) return
pending = true
timerFunc(nextTickHandler, 0)
}
})()
\ No newline at end of file
export const ResJson = {
"groups": [],
"path": "./resource/"
}
\ No newline at end of file
console.log(123)
\ No newline at end of file
import { destroyLayers, layers } from "./modules/layers";
import { SceneController } from "./modules/layers/ctrls";
import { RES } from "./modules/RES";
import { ResJson } from "./ResJson";
import { HomeScene } from "./scenes/home";
import Tween = FYGE.Tween;
import EventDispatcher = FYGE.EventDispatcher;
import Stage = FYGE.Stage;
import RENDERER_TYPE = FYGE.RENDERER_TYPE
import Event = FYGE.Event
import getEnv = FYGE.getEnv;
export class Main {
//主舞台
stage: Stage;
private requestID: number;
private _pause: boolean;
private canvas: HTMLCanvasElement;
constructor(
canvas: HTMLCanvasElement,
desWidth = 750,
desHeight = 1624,
divWidth?: number,
divHeight?: number,
renderType = RENDERER_TYPE.WEBGL,
stageCenter = true,
fixedHeight = false,
resolution?: any,
) {
let sysInfo;
// 淘宝小程序环境就用canvas初始化
if (!window) { // 自行处理吧,这么判断也不保险,万一淘宝小程序加进了window
FYGE.initedByCanvas(canvas); // 里面会设置env为tb,这个很重要
// @ts-ignore 存在my就初始化
sysInfo = my.getSystemInfoSync();
}
divWidth = divWidth || sysInfo?.windowWidth || document.body.clientWidth;
divHeight = divHeight || sysInfo?.windowHeight || document.body.clientHeight;
resolution = resolution || sysInfo?.pixelRatio || window.devicePixelRatio || 1;
// 建舞台
const stage = this.stage = new Stage(
canvas,
desWidth, // 设计宽度,按设计搞给的就行
desHeight, // 设计高度
divWidth, // 显示宽度,全屏就是屏幕宽度
divHeight, // 显示高度,全屏就是屏幕高度
renderType, // 渲染模式canvas
stageCenter, // 视窗居中裁切
fixedHeight, // 不定高,定宽适配
resolution, // 分辨率
);
this.canvas = canvas; // 赋值下,为了下面的destroy的cancelAnimationFrame
// stage初始化
stage.addEventListener(Event.INIT_STAGE, this.onAddToStage, this);
//循环
this.loop();
if (document) {
this.initWebEvent()
}
}
private loop = () => {
if (!this._pause) {
Tween.flush();
this.stage.flush();
}
// @ts-ignore
getEnv() == "tb" ? this.requestID = this.canvas.requestAnimationFrame(this.loop) :
this.requestID = window.requestAnimationFrame(this.loop);
}
onAddToStage() {
layers.init(this.stage)
SceneController.init(layers.sceneLayer)
RES.loadConfig(ResJson)
SceneController.changeScene(HomeScene)
}
initWebEvent(){
const mouseEvent = this.stage.onMouseEvent.bind(this.stage);
this.canvas.addEventListener("touchstart", mouseEvent, false);
this.canvas.addEventListener('touchmove', mouseEvent, false);
this.canvas.addEventListener('touchend', mouseEvent, false);
}
run() {
this._pause = false;
// @ts-ignore Tween计时清零
Tween._lastTime = null;
}
/**
* 在小程序隐藏时调用onHide
*/
pause() {
// this._pause = true;//先不暂停了
}
//在小程序页面卸载时调用onUnload,多次销毁后会有问题,再检查
destroy() {
// Tween都移除,注意吧,可能原先的也被移除,对于多page时注意,会把其他页面的也去掉
Tween.removeAllTweens();
// 停掉计时器
// @ts-ignore 为了兼容多page的canvas
FYGE.getEnv() == "tb" ? this.canvas.cancelAnimationFrame(this.requestID) :
window.cancelAnimationFrame(this.requestID);
// 层级销毁
destroyLayers();
// 销毁控制器
// destroyAllCtrls();
// 舞台销毁
this.stage.destroy();
// 全局事件置空
// GDispatcher.removeAllEventListener();
// 淘宝环境网络数据记录清
// destroyTbNetData();
// // 网络数据记录清空
// destroyWebNetData();
}
}
\ No newline at end of file
interface ResData {
/**
* 分组数据
*/
groups: GroupInt[];
//暂时没有工具,不用
resources?: any;
path?: string;
}
interface GroupInt {
/**
* 所有的资源名字,根据,分割,根据后缀区分类型
*
*/
keys: string;//"aa.png,bb.jpg,name.json"
/**
* 文件夹名字吧
*/
name: string;
/**
* 图集
* 线上打包合图可能有多张,暂时发现texturePacker版本问题只有一张
*/
atlas: {
[name: string]: {
"x": number,
"y": number,
"w": number,
"h": number,
"ox": number,
"oy": number,
"sw": number,
"sh": number,
"ro": boolean
},
};
}
interface SkinInt {
name: string,
x: 0,
y: 0,
type: 'container' | 'text' | 'button' | 'sprite' | 'rect' | 'item',//item的不初始化进节点,只作为数据
children?: SkinInt[],
id?: string,
alpha: number,
props?: {
source?: string,
text: string,
size: number,
fillColor: string,
textAlpha: number,
width: number,
height: number,
tUp: string,
tDown: string,
tDisable: string
}
}
/**
* 简单点,有工具的话像egret那样玩,可以自动生成图片组数据
*/
export namespace RES {
let resData: ResData
/**
* 资源路径
*/
let resPath: string;
/**
* RES单独缓存一下纹理,全局的FYGE缓存纹理对于多page有覆盖的问题;
*/
let textureHash: {
[name: string]: FYGE.Texture;
} = {};
/**
* movieClip的ve数据
*/
let videoEntityHash: {
[name: string]: SvgaParser.VideoEntity
} = {};
/**
* 音频的加载
*/
let soundHash: Record<string, any> = {}
/**
* 记录组加载完成
*/
let groupsCompleteHash: {
[name: string]: boolean
} = {}
/**
* 记录加载的promise
*/
let groupsPromiseHash: {
[name: string]: Promise<any>
} = {}
/**
* 单独资源加载的promise记录
*/
let singleResPromiseHash: {
[name: string]: Promise<any>
} = {}
/**
*
* @param res 资源数据,就是对象,不考虑加载json先
* res格式{
* path:1111/
* groups: [
* {
*
* }
* ];
* }
*/
export function loadConfig(res: any) {
resData = res;
resPath = res.path;
}
/**
* 根据组名加载一组资源,通常用于加载一个视图的的所有资源
* 里的promise的resolve并没有返回值
* @param name
*/
export function loadGroup(name: string): Promise<void> {
//已经加载完成的直接返回
if (groupsCompleteHash[name]) {//其实直接return就行
return new Promise((resolve) => {
resolve()
})
}
//如果是正在加载中的,返回正在加载中的promise
if (groupsPromiseHash[name]) {
return groupsPromiseHash[name];
}
//如果首次加载
//获取资源组
let arr = getGroupResByName(name);
//如果不存在arr,直接返回空p,且标记完成
if (!arr || !arr.length) {
groupsCompleteHash[name] = true;
return new Promise((resolve) => {
resolve()
})
}
// 建一个promise
let p: Promise<void> = new Promise((resolve, reject) => {
loadResList((s) => {
//移除
delete groupsPromiseHash[name];
if (s) {
groupsCompleteHash[name] = true;
resolve()
} else {
reject();
}
}, arr/*, resPath + name*/)
})
groupsPromiseHash[name] = p;
return p;
}
/**
* var textue = await RES.getResAsync(str);
* @param str 可以是网络图片路径或键值
* @param comFun 加载回调
* @param thisObj this指向
*/
export function getResAsync(str: string, comFun?: (res: any, str: string) => void, thisObj?: any): Promise<any> {
// var arr = str.split(".");
var type = str.substring(str.lastIndexOf(".") + 1, str.length);
//如果是图片
if (type == "png" || type == "jpg") {
//原先就有了,加载过的,且已加载完成的
let cached = textureHash[str] || FYGE.TextureCache[str];
if (cached) {
//回调形式
comFun && comFun.call(thisObj, cached, str)
// return cached;
return new Promise((r) => { //为了能.then
r(cached)
})
}
//未加载完成的
else if (singleResPromiseHash[str]) {
return returnSingleResPromise(str, comFun, thisObj)
}
else {
//判断是否在资源里,判断是否要加载图集,注意已排除jpg
var groupName = hasRes(str);
if (groupName && type != "jpg") {
var group = getGroupByName(groupName);
if (group && group.atlas) {
//加载图集,现在就一张,以后有机会改
var json = groupName + ".json"//group.atlas.split(",")[0];
//找json是否在加载中
if (singleResPromiseHash[json]) {
return singleResPromiseHash[json].then(
(r) => {
//正在加载中,getResAsync首次加载的回调会缓存,完成后返回需要的,
let cached = textureHash[str] || FYGE.TextureCache[str]
comFun && comFun.call(thisObj, cached, str)
return cached;
},
() => {
comFun && comFun.call(thisObj, null, str)
return null
}
)
} else {
return getResAsync(json)
.then(() => {
let cached = textureHash[str] || FYGE.TextureCache[str]
comFun && comFun.call(thisObj, cached, str)
return cached
}, () => {
comFun && comFun.call(thisObj, null, str)
return null
})
}
}
}
var src = groupName ? resPath + groupName + "/" + str : str;
var p = new Promise((resolve, reject) => {
FYGE.GlobalLoader.loadImage((s, image) => {
//移除
delete singleResPromiseHash[str];
//入缓存
if (s) {
let cached = FYGE.Texture.from(image);
//入RES,
textureHash[str] = cached;
//入全局
FYGE.Texture.addToCache(cached, str);
comFun && comFun.call(thisObj, cached, str)
resolve(cached)
} else {
comFun && comFun.call(thisObj, null, str)
reject()
}
}, src)
})
singleResPromiseHash[str] = p
return p
}
}
else if (type == "svga") {
if (videoEntityHash[str]) {
comFun && comFun.call(thisObj, videoEntityHash[str], str)
return new Promise((r) => {
r(videoEntityHash[str])
})
}
//未加载完成的
else if (singleResPromiseHash[str]) {
return returnSingleResPromise(str, comFun, thisObj)
} else {
var groupName = hasRes(str);
var src = groupName ? resPath + groupName + "/" + str : str;
var p = new Promise((resolve, reject) => {
SvgaParser.loadSvga(
src,
(v) => {
delete singleResPromiseHash[str];
videoEntityHash[str] = v;
comFun && comFun.call(thisObj, v, str)
resolve(v)
},
(err) => {
delete singleResPromiseHash[str];
comFun && comFun.call(thisObj, null, str)
reject(err)
}
)
})
singleResPromiseHash[str] = p;
return p
}
}
//json图集的话,不晓得用啥判断加载完成,所以不删除promise吧,其实json可能只是数据,不管先
else if (type == "json") {
if (singleResPromiseHash[str]) {
return returnSingleResPromise(str, comFun, thisObj)
} else {
var groupName = hasRes(str);//json现在肯定在内,暂时不能加载其他域名的json
var src = groupName ? resPath + groupName + "/" + str : str;
var p = new Promise((resolve, reject) => {
var jsonData = getGroupByName(groupName).atlas
FYGE.GlobalLoader.loadImage((s, data) => {
if (s) {
//createTextureSheet会自行缓存全局
var t = FYGE.createTextureSheet(new FYGE.BaseTexture(data/*.img*/), jsonData)
//缓存进RES
for (let key in t) textureHash[key] = t[key];
comFun && comFun.call(thisObj, t, str)
resolve(t)
} else {
//加载失败,移除要,否则再次触发加载会出问题
delete singleResPromiseHash[str];
comFun && comFun.call(thisObj, null, str)
reject()
}
}, src.replace("json", "png"))
})
singleResPromiseHash[str] = p
return p
}
}
}
/**
* 待写,根据网络路径加载图片
*/
export function getResByUrl() {
}
/**
* 获取素材,
* @param str
* @return 已加载好得素材或null
*/
export function getRes(str: string)/*: Texture | VideoEntity*/ {
if (!str) return null;
var type = str.substring(str.lastIndexOf(".") + 1, str.length);
if (type == "png" || type == "jpg") {
return textureHash[str] || FYGE.TextureCache[str] || null;
}
else if (type == "svga") {
return videoEntityHash[str] || null;
}
else if (type == "mp3") {
return soundHash[str] || null;
}
}
/**
* 偷懒的方法,加载配置里所有的资源,基本也不用
*/
export function loadAllGroup() {
var groups = resData.groups;
var p: any[] = []
groups.forEach((g) => {
p.push(loadGroup(g.name))
})
return Promise.all(p)
}
/**
* 判断是否在资源组里
* 考虑是否init就做表
* 有就返回组名,为了加载路径,不然以后有工具可以放入resources
*/
function hasRes(str: string): string {
for (var i = 0; i < resData.groups.length; i++) {
var group = resData.groups[i];
var keys = group.keys;
if (keys && keys.split(",").indexOf(str) > -1) {
return group.name;
}
//如果是图集的json,altas现在是图集
if (group.atlas && group.name + ".json" == str) {
return group.name;
}
}
return null
}
/**
* 处理数据,获得所有资源单项
* @param name
*/
function getGroupResByName(name: string) {
var group: GroupInt = getGroupByName(name);
if (!group) return null;
//判断加载图集还是单图
if (group.atlas) {
// var arr: string[] = [].concat(group.atlas.split(","));
var arr = [name + ".json"]
//再添加非图片的资源,和图集已排除jpg
if (group.keys) {
arr = arr.concat(group.keys.split(",").filter((k: string) => {
return k.substr(-4) != ".png" //&& k.substr(-4) != ".jpg"
}))
}
return arr
}
else if (group.keys) {
return group.keys.split(",")
} else {
return null
}
}
/**
* 根据名字找组
* @param name
*/
function getGroupByName(name: string): GroupInt {
var groups = resData.groups;
var group: GroupInt;
for (var i = 0; i < groups.length; i++) {
if (groups[i].name === name) {
group = groups[i];
break;
}
}
return group
}
/**
* 新版的加载一列资源
* @param callback
* @param arr
*/
function loadResList(callback: (allLoaded: boolean) => void, arr: string[]) {
let count = 0;
let countAll = arr.length;
if (!countAll) callback(true);
let mark = true;
for (var i = 0; i < countAll; i++) {
let resName = arr[i];
getResAsync(resName, (res, str) => {
//标记失败,如果有一项资源加载失败,标记下
if (!res) mark = false
if (++count == countAll) callback(mark);
}, this)
}
}
/**
*
* @param str
* @param comFun
* @param thisObj
*/
function returnSingleResPromise(str: string, comFun?: (res: any, str: string) => void, thisObj?: any) {
//已判断是否存在
singleResPromiseHash[str].then(
(r) => {
comFun && comFun.call(thisObj, r, str)
},
() => {
comFun && comFun.call(thisObj, null, str)
}
)
return singleResPromiseHash[str];
}
//皮肤相关的也放在RES吧
let skinData: SkinInt
/**
* 添加皮肤配置文件
*/
export function loadSkinConfig(skinJson: any) {
skinData = skinJson;
}
/**
* 根据
* @param con 添加显示对象的容器
* @param skin 皮肤名字或数据
* @param root 根容器,为了添加自定义引用
*/
export function initSkinDisplay(con: FYGE.Container, skin: string | SkinInt, root?: FYGE.Container) {
//@ts-ignore
var data: SkinInt = typeof (skin) == 'string' ? getSkinDataByName(skin) : skin;
if (!data.children || !data.children.length) return;
// for (var i = data.children.length - 1; i >= 0; i--) {
for (var i = 0; i < data.children.length; i++) {
var child = data.children[i];
if (child.type == "item") continue;
var dis = con.addChild(getDisplayByData(child));
// @ts-ignore
if (root && child.id) (root[child.id] as any) = dis;
if (child.type == "container") initSkinDisplay(dis, child, root);
}
}
/**
* 遍历根据名字找节点数据,只会是container的
* @param skinName
*/
export function getSkinDataByName(skinName: string, skinNode: SkinInt = skinData): SkinInt {
if (!skinNode || !skinNode.children || !skinNode.children.length) return null;
for (var i = 0; i < skinNode.children.length; i++) {
var child = skinNode.children[i];
if (child.name == skinName && (child.type == "container" || child.type == "item")) return child;
var gson = getSkinDataByName(skinName, child);
if (gson) return gson
}
return null;
}
/**
* 通过数据创建显示对象
* @param data
*/
function getDisplayByData(data: SkinInt): FYGE.Container {
var dis: FYGE.Container;
switch (data.type) {
case "container":
dis = new FYGE.Container();
break;
case "button":
dis = new FYGE.Button(
getRes(data.props.tUp),
data.props.tDown ? getRes(data.props.tDown) : null,
data.props.tDisable ? getRes(data.props.tDisable) : null,
);
break;
case "text":
dis = new FYGE.TextField();
// @ts-ignore
for (let key in data.props) dis[key] = data.props[key];
break;
case "sprite":
dis = new FYGE.Sprite(getRes(data.props.source));
break;
case "rect":
// dis = new FYGE.Graphics()
// .beginFill(data.props.fillColor)
// .drawRect(0, 0, data.props.width, data.props.height)
// .endFill();
dis = new FYGE.Shape()
//@ts-ignore
dis.beginFill(FYGE.string2hex(data.props.fillColor))
//@ts-ignore
dis.drawRect(0, 0, data.props.width, data.props.height)
//@ts-ignore
dis.endFill();
break;
}
dis.name = data.name;
dis.alpha = data.alpha || 1;
dis.position.set(data.x, data.y);
// if (data.type == "text") dis.y -= 4;//文本莫名偏下,移动下,手机调试的时候也试试
return dis;
}
/**
* 销毁组纹理
* 线上才有用,待测试,TODO
* @param name
*/
export function destroyGroup(name: string) {
var group: GroupInt = getGroupByName(name);
if (!group) return;
var arr: any[] = [];
if (group.keys) {
arr = group.keys.split(",")
}
var removedBase = [];
//散图清除
for (var i = 0; i < arr.length; i++) {
var t: FYGE.Texture = getRes(arr[i]);
if (t) {
//base的清除,不要重复清除
if (removedBase.indexOf(t.baseTexture) == -1) {
t.baseTexture.destroy();
removedBase.push(t.baseTexture)
}
//自己纹理清除
t.destroy();
}
//RES里单独缓存的清除
delete textureHash[arr[i]]
}
}
//貌似不需要,为了加载过一次的资源不用重新加载
function destroyRES() {
}
}
import Dream from "../../Dream"
import { Container } from "../../Dream/UI"
type UseAniConfig = {
showCall?: (c: FYGE.Container, ...args: any[]) => Promise<any>
hideCall?: (c: FYGE.Container) => Promise<any>
}
export function UseAni(cfg: UseAniConfig) {
return function(Node: any) {
return class extends Dream.RenderContainer<{
getAniIns: (ins: any) => any
}> {
aniCont: FYGE.Container
didRendered(): void {
this.showAni()
}
async showAni() {
this.aniCont.visible = true
if (cfg.showCall) {
await cfg.showCall(this.aniCont)
}
}
async hideAni() {
if (cfg.hideCall) {
await cfg.hideCall(this.aniCont)
}
this.aniCont.visible = false
}
render() {
const {
getAniIns,
...othersProps
} = this.props
return (
<Container ref={el => {
this.aniCont = el
}}>
<Node {...othersProps}></Node>
</Container>
)
}
}
}
}
\ No newline at end of file
export type ResolveCallback<T> = (value: T | PromiseLike<T>) => void
export type RejectCallback = (reason?: any) => void
export type CancelCallback = () => void
export type ImperativePromise<T> = {
promise: Promise<T>
resolve: ResolveCallback<T>
reject: RejectCallback
cancel: CancelCallback
}
/**
* 创建指令shi Promise
* @param promiseArg
* @returns
*/
export function createImperativePromise<T>(promiseArg?: Promise<T> | null | undefined): ImperativePromise<T> {
let resolve: ResolveCallback<T> | null = null
let reject: RejectCallback | null = null
const wrappedPromise = new Promise<T>((_resolve, _reject) => {
resolve = _resolve
reject = _reject
})
promiseArg && promiseArg.then(
val => {
resolve && resolve(val)
},
error => {
reject && reject(error)
}
)
return {
promise: wrappedPromise,
resolve: (value: T | PromiseLike<T>) => {
resolve && resolve(value)
},
reject: (reason?: any) => {
reject && reject(reason)
},
cancel: () => {
resolve = null
reject = null
}
}
}
\ No newline at end of file
import Dream from "../../Dream";
import { RenderContainer } from "../../Dream/renderContainer"
type SignleContainer = FYGE.Container
type TagType = SignleContainer | RenderContainer | (FC)
type FC<P = {}> = FunctionComponent<P>;
type PropsWithChildren<P> = P & { children?: any[] };
interface FunctionComponent<P = {}> {
(props: PropsWithChildren<P>): SignleContainer;
}
// class SceneCompent extends Dream.RenderContainer {
// }
function SceneWrapper(SceneNode: any) {
return class extends Dream.RenderContainer{
sceneContainer: FYGE.Container
wrapperContainer: FYGE.Container
show() {
// 做动画
this.wrapperContainer.visible = true
}
hide() {
this.wrapperContainer.visible = false
}
render() {
return (
<FYGE.Container ref={(el: any) => this.wrapperContainer = el}>
<FYGE.Container ref={(el: FYGE.Container) => this.sceneContainer = el}>
<SceneNode {...this.props}></SceneNode>
</FYGE.Container>
</FYGE.Container>
)
}
}
}
export const SceneController = (function() {
let controller: FYGE.Container
const SceneMap = new Map()
return {
init(cont: FYGE.Container) {
if (!controller) {
controller = cont
}
},
changeScene(SceneNode: any, props?: Record<string, any>) {
if (!controller) {
throw new Error('没有场景controller')
}
const _ = SceneMap.get(SceneNode)
if (_) {
// props ?
_.show()
return
}
const S = SceneWrapper(SceneNode)
const cont = new FYGE.Container()
controller.addChild(cont)
Dream.VirtualRender(cont, <S
{...props}
ref={(el: { show: () => void; }) => {
SceneMap.set(SceneNode, el)
el.show()
}}
></S>)
}
}
})()
\ No newline at end of file
/**
* 添加进舞台的所有层级
* 仿白鹭的那套
*/
class Layers extends FYGE.Container {
[x: string]: any
private _bottomLayer: FYGE.Container;
private _sceneLayer: FYGE.Container;
private _commonUILayer: FYGE.Container;
private _popupLayer: FYGE.Container;
private _toastLayer: FYGE.Container;
private _topLayer: FYGE.Container;
private _shareLayer: FYGE.Container;
init(stage: FYGE.Stage) {
stage.addChild(this);
const arr = [
"_bottomLayer",
"_sceneLayer",
"_commonUILayer",
"_popupLayer",
"_toastLayer",
"_topLayer",
"_shareLayer"
];
for (let i = 0; i < arr.length; i++) {
this[arr[i]] = new FYGE.Container();
//有些时候,定宽的时候,部分layer置顶,部分居中,再处理
//为了都置顶和置左,stage的方式永远居中视窗,要么改stage永远左上为00
// this[arr[i]].y = this.stageOffsetY;
//如果定宽这里没必要,肯定是0
// this[arr[i]].x = this.stageOffsetX;//去掉,定高时就居中了
this.addChild(this[arr[i]]);
}
//都以顶部适配
// this.sceneLayer.y = this.stageOffsetY;
// this.popupLayer.y = this.stageOffsetY;
//都以底部适配
// this.sceneLayer.y = -this.stageOffsetY;
// this.popupLayer.y = -this.stageOffsetY;
//这个因为psd弹框不规范
// this.popupLayer.y -= 420 / 2;
this.shareLayer.y = -this.stageOffsetY;
//初始化场景层级
// SceneCtrl.instance.init(this.sceneLayer);
// //初始化场景层级
// CommonUICtrl.instance.init(this.commonUILayer);
// //初始化弹框层级
// PanelCtrl.instance.init(this.popupLayer);
}
/**
* 底图所在层级,比如统一的背景
*/
get bottomLayer() { return this._bottomLayer }
/**
* 场景
*/
get sceneLayer() { return this._sceneLayer }
/**
* UI
*/
get commonUILayer() { return this._commonUILayer }
/**
* 弹框
*/
get popupLayer() { return this._popupLayer }
/**
* toast所在层级
*/
get toastLayer() { return this._toastLayer }
/**
* 顶层,比如统一标题栏等
*/
get topLayer() { return this._topLayer }
/**
* 分享引导层
*/
get shareLayer() { return this._shareLayer }
/**
* 舞台信息都放在layers里吧
* 舞台可见高度,初始化后才能使用
*/
get stageHeight() {
if (!this.stage) return 0;
return this.stage.viewRect.height;
}
/**
* 舞台可见宽度
*/
get stageWidth() {
if (!this.stage) return 0;
return this.stage.viewRect.width;
}
/**
* 适配方式x两边偏移的量,固定宽度x为0
*/
get stageOffsetX() {
if (!this.stage) return 0;
return this.stage.viewRect.x;
}
get stageOffsetY() {
if (!this.stage) return 0;
return this.stage.viewRect.y;
}
/**
* 舞台中心点位置x
*/
// get stageCenterX(): number {
// return this.stage.viewRect.x + this.stage.viewRect.width >> 1;
// }
/**
* 舞台中心点位置y,layer位置做过偏移的就不对了,所以还是自行算吧
*/
// get stageCenterY(): number {
// return this.stage.viewRect.y + this.stage.viewRect.height >> 1;
// }
}
export const layers = new Layers();
//先执行,在淘宝小程序中重新进入会再次初始化
export function destroyLayers() {
//所有层级移除,init会重新建
layers.removeChildren();
//从父级stage移除自己,init会重新加
if (layers.parent) layers.parent.removeChild(layers)
}
import Dream from "../Dream";
import { DotAni, DreamDotAni, DreamSpriteV2 } from "../Dream/UI";
import { UseAni } from "../modules/UseDecorator/useAni";
function fadeIn(cont: FYGE.Container) {
return new Promise(r => {
FYGE.Tween.removeTweens(cont)
FYGE.Tween.get(cont)
.set({alpha: 0})
.to({
alpha: 1
}, 500, FYGE.Ease.quadIn)
.call(r)
})
}
function fadeOut(cont: FYGE.Container) {
return new Promise(r => {
FYGE.Tween.removeTweens(cont)
FYGE.Tween.get(cont)
.to({
alpha: 0
}, 500, FYGE.Ease.quadIn)
.call(r)
})
}
@UseAni({
showCall: fadeIn,
hideCall: fadeOut
})
class Test extends Dream.RenderContainer{
render() {
console.log(this.props)
return (
<FYGE.Container>
<DreamSpriteV2 src="http://qnpic.top/yoona2.jpg"></DreamSpriteV2>
</FYGE.Container>
)
}
}
export class HomeScene extends Dream.RenderContainer {
cont: FYGE.Container
addFadeinCont() {
this.cont.addChild(<Test tt={3} ref={el => {
setTimeout(() => {
el.hideAni()
}, 3000)
}}></Test>)
}
render() {
return (
// <DreamSpriteV2 src="http://qnpic.top/yoona2.jpg"></DreamSpriteV2>
<FYGE.Container ref={(el: any) => {
this.cont = el
}}>
<FYGE.TextField onClick={() => {
this.addFadeinCont()
}} inlineProps={{
text: '爱的爱我',
size: 90,
fillColor: '#000000'
}}></FYGE.TextField>
<DreamDotAni></DreamDotAni>
</FYGE.Container>
)
}
}
\ No newline at end of file
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"jsx": "preserve", /* Specify what JSX code is generated. */ "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */ /* Type Checking */
"strict": true, /* Enable all strict type-checking options. */ "strict": false, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
......
...@@ -203,7 +203,7 @@ ...@@ -203,7 +203,7 @@
"@babel/helper-wrap-function" "^7.18.9" "@babel/helper-wrap-function" "^7.18.9"
"@babel/types" "^7.18.9" "@babel/types" "^7.18.9"
"@babel/helper-replace-supers@^7.18.6", "@babel/helper-replace-supers@^7.18.9": "@babel/helper-replace-supers@^7.18.6", "@babel/helper-replace-supers@^7.18.9", "@babel/helper-replace-supers@^7.19.1":
version "7.19.1" version "7.19.1"
resolved "http://npm.dui88.com:80/@babel%2fhelper-replace-supers/-/helper-replace-supers-7.19.1.tgz#e1592a9b4b368aa6bdb8784a711e0bcbf0612b78" resolved "http://npm.dui88.com:80/@babel%2fhelper-replace-supers/-/helper-replace-supers-7.19.1.tgz#e1592a9b4b368aa6bdb8784a711e0bcbf0612b78"
integrity sha512-T7ahH7wV0Hfs46SFh5Jz3s0B6+o8g3c+7TMxu7xKfmHikg7EAZ3I2Qk9LFhjxXq8sL7UkP5JflezNwoZa8WvWw== integrity sha512-T7ahH7wV0Hfs46SFh5Jz3s0B6+o8g3c+7TMxu7xKfmHikg7EAZ3I2Qk9LFhjxXq8sL7UkP5JflezNwoZa8WvWw==
...@@ -326,6 +326,17 @@ ...@@ -326,6 +326,17 @@
"@babel/helper-plugin-utils" "^7.18.6" "@babel/helper-plugin-utils" "^7.18.6"
"@babel/plugin-syntax-class-static-block" "^7.14.5" "@babel/plugin-syntax-class-static-block" "^7.14.5"
"@babel/plugin-proposal-decorators@^7.19.3":
version "7.19.3"
resolved "http://npm.dui88.com:80/@babel%2fplugin-proposal-decorators/-/plugin-proposal-decorators-7.19.3.tgz#c1977e4902a18cdf9051bf7bf08d97db2fd8b110"
integrity sha512-MbgXtNXqo7RTKYIXVchVJGPvaVufQH3pxvQyfbGvNw1DObIhph+PesYXJTcd8J4DdWibvf6Z2eanOyItX8WnJg==
dependencies:
"@babel/helper-create-class-features-plugin" "^7.19.0"
"@babel/helper-plugin-utils" "^7.19.0"
"@babel/helper-replace-supers" "^7.19.1"
"@babel/helper-split-export-declaration" "^7.18.6"
"@babel/plugin-syntax-decorators" "^7.19.0"
"@babel/plugin-proposal-dynamic-import@^7.18.6": "@babel/plugin-proposal-dynamic-import@^7.18.6":
version "7.18.6" version "7.18.6"
resolved "http://npm.dui88.com:80/@babel%2fplugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.18.6.tgz#72bcf8d408799f547d759298c3c27c7e7faa4d94" resolved "http://npm.dui88.com:80/@babel%2fplugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.18.6.tgz#72bcf8d408799f547d759298c3c27c7e7faa4d94"
...@@ -449,6 +460,13 @@ ...@@ -449,6 +460,13 @@
dependencies: dependencies:
"@babel/helper-plugin-utils" "^7.14.5" "@babel/helper-plugin-utils" "^7.14.5"
"@babel/plugin-syntax-decorators@^7.19.0":
version "7.19.0"
resolved "http://npm.dui88.com:80/@babel%2fplugin-syntax-decorators/-/plugin-syntax-decorators-7.19.0.tgz#5f13d1d8fce96951bea01a10424463c9a5b3a599"
integrity sha512-xaBZUEDntt4faL1yN8oIFlhfXeQAWJW7CLKYsHTUqriCUbj8xOra8bfxxKGi/UwExPFBuPdH4XfHc9rGQhrVkQ==
dependencies:
"@babel/helper-plugin-utils" "^7.19.0"
"@babel/plugin-syntax-dynamic-import@^7.8.3": "@babel/plugin-syntax-dynamic-import@^7.8.3":
version "7.8.3" version "7.8.3"
resolved "http://npm.dui88.com:80/@babel%2fplugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz#62bf98b2da3cd21d626154fc96ee5b3cb68eacb3" resolved "http://npm.dui88.com:80/@babel%2fplugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz#62bf98b2da3cd21d626154fc96ee5b3cb68eacb3"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment