-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.min.js
executable file
·1 lines (1 loc) · 6.5 KB
/
index.min.js
1
!function(){var a,o,n,e,i,_,s,r,c,f,u,t="object"==typeof global&&global&&global.Object===Object&&global,p="object"==typeof self&&self&&self.Object===Object&&self,t=t||p||Function("return this")(),p="object"==typeof exports&&exports&&!exports.nodeType&&exports,l=p&&"object"==typeof module&&module&&!module.nodeType&&module,h=t.nx=t.nx||{BREAKER:{},NIL:{},VERSION:"1.2.6",DEBUG:!1,GLOBAL:t};function d(t){return t.toString().replace(_,".$1").replace(s,a).replace(r,"")}function y(){}function m(t,e){this.type=t,this.meta=e,this.base=e.extends||h.RootClass,this.$base=this.base.prototype,this.__class_meta__={},this.__class__=null,this.__constructor__=null}"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.nx=h,define(function(){return h})):l?((l.exports=h).nx=h,p.nx=h):t.nx=h,a=".",o="undefined",n=Array.prototype,e=Object.prototype.toString,i=Object.prototype.hasOwnProperty,_=/\[(\w+)\]/g,s=/[.]+/g,r=/^\.|\.$/g,h.noop=function(){},h.typeof=function(t){return null==t||"object"!=typeof t?null===t?"null":void 0===t?"undefined":typeof t:e.call(t).slice(8,-1).toLowerCase()},h.stubTrue=function(){return!0},h.stubFalse=function(){return!1},h.stubValue=function(t){return t},h.stubPromise=function(t){return Promise.resolve(t)},h.error=function(t){throw new Error(t)},h.try=function(t,e){e=e||h.noop;try{t()}catch(t){e(t)}},h.forEach=function(t,e,_){for(var n=t.length,o=0;o<n&&e.call(_,t[o],o,t)!==h.BREAKER;o++);},h.forIn=function(t,e,_){for(var n in t)if(i.call(t,n)&&e.call(_,n,t[n],t)===h.BREAKER)break},h.each=function(n,o,s){function t(t,e,_){return o.call(s,t,e,n,_)===h.BREAKER}var e,_;if(n)if("number"==typeof(_=n.length))for(e=0;e<_&&!t(e,n[e],!0);e++);else for(e in n)if(i.call(n,e)&&t(e,n[e],!1))break},h.map=function(t,e,_){var n=[];return h.each(t,function(){var t=e.apply(_,arguments);if(t===h.BREAKER)return h.BREAKER;n.push(t)}),n},h.mix=function(t){for(var _=t||{},e=arguments,n=1,o=e.length;n<o;n++)h.forIn(e[n],function(t,e){_[t]=e});return _},h.slice=function(t,e,_){return n.slice.call(t,e,_)},h.set=function(t,e,_){for(var n=d(e).split(a),o=t||h.GLOBAL,s=n.length-1,e=n[s],i=0;i<s;i++)var r=n[i],c=isNaN(+n[i+1])?{}:[],o=o[r]=o[r]||c;return o[e]=_,t},h.get=function(t,e,_){var n;return e?(e=d(e).split(a),n=t||h.GLOBAL,e.forEach(function(t){n=n&&n[t]}),typeof _!=o&&typeof n==o?_:n):t},h.del=function(t,e){for(var _=d(e).split(a),n=0;n<_.length;n++){var o=_[n];if(n===_.length-1)return null!=t&&("object"==typeof t&&delete t[o],!0);t=t[o]}return!1},h.to=function(t){return t.then(function(t){return[void 0,t]}).catch(function(t){return[t]})},h.createOverload=function(){var n={};function t(){var t=h.slice(arguments),e=t.map(h.typeof).join(),_=n[t.length]||n[e];if(_)return _.apply(this,t);throw new Error("No matching function, parameter type: ["+e+"]")}return t.add=function(t){var e=t.args,t=t.fn,e=Array.isArray(e)?e.join():e;if("function"!=typeof t)throw new Error("The fn must be a function");n[e]=t},t},l={__class_id__:0,__type__:"nx.RootClass",__base__:Object,__meta__:{},__static__:!1,__statics__:{},__properties__:{},__methods__:{},__method_init__:h.noop,__static_init__:h.noop},p={base:function(){var t=this.base.caller;if(t&&(t=t.__base__))return t.apply(this,arguments)},parent:function(t){var e=void 0===this.__id__,_=h.slice(arguments,1),n=e?this.__base__:this.__base__.prototype,e=this["@"+t].__type__,o=["get","set"][_.length];switch(e){case"method":return n[t].apply(this,_);case"property":return n["@"+t][o].apply(this,_)}}},l.__methods__=y.prototype=h.mix({constructor:y,init:h.noop,destroy:h.noop,toString:function(){return"[Class@"+this.__type__+"]"}},p),h.mix(l.__statics__,p),h.mix(y,l),h.mix(y,l.__statics__),h.RootClass=y,h.defineProperty=function(t,e,_,n){var o,s,i,r="@"+e,c=_&&"object"==typeof _?_:{value:_},c="value"in c?(s=c.value,i="_"+e,o=function(){return i in this?this[i]:"function"==typeof s?s.call(this):s},function(t){this[i]=t}):(o=_.get||t[r]&&t[r].get||h.noop,_.set||t[r]&&t[r].set||h.noop);return r in t&&(o.__base__=t[r].get,c.__base__=t[r].set),r=t[r]={__meta__:_,__name__:e,__type__:"property",__static__:!!n,get:o,set:c,configurable:!0},Object.defineProperty(t,e,r),r},h.defineMethod=function(t,e,_,n){var o="@"+e;return t[e]=_,t[o]={__meta__:_,__name__:e,__type__:"method",__static__:!!n}},h.defineBombMethod=function(_,t,n,o){t.split(",").forEach(function(t,e){h.defineMethod(_,t,n.call(_,t,e),o)})},h.defineMembers=function(_,n,t,o){h.forIn(t,function(t,e){-1<t.indexOf(",")?h.defineBombMethod(n,t,e,o):h["define"+_](n,t,e,o)})},c=1,f=0,u="nx.Anonymous",m.prototype={constructor:m,initMetaProcessor:function(){var t=this.meta,e=t.methods||{},_=t.statics||{};h.mix(this.__class_meta__,{__type__:this.type,__meta__:t,__base__:this.base,__class_id__:c++,__method_init__:e.init||this.base.__method_init__,__static_init__:_.init||this.base.__static_init__,__static__:!t.methods&&!!t.statics})},createClassProcessor:function(){var t=this;this.__class__=function(){this.__id__=f++,t.__constructor__.apply(this,arguments),t.registerDebug(this)}},inheritProcessor:function(){var t=this.__class_meta__;this.inheritedClass(t),this.defineMethods(t,!0),this.defineMethods(t,!1),this.defineProperties(t)},inheritedClass:function(t){function e(){}var _=this.__class__;e.prototype=this.$base,_.prototype=new e,_.prototype.$base=this.$base,_.prototype.constructor=_},defineMethods:function(t,e){var _=e?"statics":"methods",n="__"+_+"__",o=e?this.__class__:this.__class__.prototype,s=(e?this.base:this.base.prototype)[n]||{};h.forIn(this.meta[_],function(t,e){s[t]&&"function"==typeof e&&(e.__base__=s[t])}),o[n]=h.mix(t[n],s,this.meta[_]),h.defineMembers("Method",o,o[n],e)},defineProperties:function(t){var e=t.__static__,_=e?this.__class__:this.__class__.prototype,n=e?this.base:this.base.prototype;_.__properties__=h.mix(null,n.__properties__,t.__properties__,this.meta.properties),h.defineMembers("Property",_,_.__properties__,e)},methodsConstructorProcessor:function(){var t=this.__class_meta__;this.__constructor__=function(){t.__method_init__.apply(this,arguments)}},staticsConstructorProcessor:function(){this.__class_meta__.__static_init__.call(this.__class__)},registerProcessor:function(){var t=this.__class__,e=this.type,_=this.__class_meta__;h.mix(t.prototype,_),h.mix(t,_),-1===e.indexOf(u)&&h.set(h.GLOBAL,e,t)},registerDebug:function(t){h.DEBUG&&(h.set(h,"__instances__."+(f-1),t),h.set(h,"__instances__.length",f))}},h.declare=function(t,e){e=new m("string"==typeof t?t:u+c,e||t);return e.initMetaProcessor(),e.createClassProcessor(),e.inheritProcessor(),e.methodsConstructorProcessor(),e.staticsConstructorProcessor(),e.registerProcessor(),e.__class__}}.call(this);