UNPKG

36.3 kBSource Map (JSON)View Raw
1{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///Usync.min.js","webpack:///webpack/bootstrap 1bf43a310a32305931c9","webpack:///./src/core/index.ts","webpack:///./src/core/lifeCycle.ts","webpack:///./src/index.ts","webpack:///./src/utils/index.ts","webpack:///./src/globalAPI/index.ts","webpack:///./src/globalAPI/plugin.ts","webpack:///./src/globalAPI/extend.ts"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","value","STATE","index_1","lifeCycle_1","Usync","state","options","vessel","lifecycleMap","init","Array","isArray","setName","assign","$name","__name__","defferd","index","READY","runHook","LIFECYCLE","fulfilledBroadcast","use","handler","_i","handler_1","length","childHandler","$parent","beforeUse","push","PENDING","__state__","FULFILLED","then","_this","currentDefferd","startTime","Date","getTime","argues","concat","done","bind","setRootProperty","taskStart","returnValue","apply","Promise","catch","err","start","Error","errArgues","$current","$prev","prevDefferd","$next","nextDefferd","endTime","taskEnd","appEnd","undefined","fn","appStart","args","arguments","hookQuene","forEach","hook","protoLifecycleMap","getPrototypeOf","extend","hooks","_a","keys","key","_key","replace","plugin","app","default","isNumberStr","Number","isNaN","list","cycle","core_1","target","restOb","TypeError","source","initGlobalAPI","_Usync","plugin_1","extend_1","initPlugin","$Usync","install","initExtend"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,OAAA,WAAAH,GACA,gBAAAC,SACAA,QAAA,MAAAD,IAEAD,EAAA,MAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAE,EAAAF,EACAG,GAAA,EACAV,WAUA,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AAejB,KAAK+G,EAAQf,KAC7CY,EAAOZ,GAAOe,EAAOf,IAMrC,MAAOY,GL6WXrG,OAAOC,eAAenB,EAAS,cAAgB+B,OAAO,IKhYtD/B,EAAA4C,UL4ZM,SAAU3C,EAAQD,EAASM,GAEjC,YM7ZA,SAAAqH,GAAsCC,GAClCC,EAAAb,QAAWY,GACXE,EAAAd,QAAWY,GN6Zf1G,OAAOC,eAAenB,EAAS,cAAgB+B,OAAO,GMnatD,IAAA8F,GAAAvH,EAAA,GACAwH,EAAAxH,EAAA,EAGAN,GAAAgH,QAAAW,GN2aM,SAAU1H,EAAQD,EAASM,GAEjC,YO9aA,SAAAyH,GAAmCC,GAE/BA,EAAOlB,OAAS,SAAUA,EAAiBzE,GACjB,kBAAXyE,GACPA,EAAOkB,EAAQ3F,GAEU,gBAAXyE,IAAuBA,EAAOmB,SAC5CnB,EAAOmB,QAAQD,EAAQ3F,IPyanCnB,OAAOC,eAAenB,EAAS,cAAgB+B,OAAO,IOhbtD/B,EAAAgH,QAAAe,GPgcM,SAAU9H,EAAQD,EAASM,GAEjC,YQjcA,SAAA4H,GAAmCF,GAE/BA,EAAOzB,OAAS,SAAUC,GACjBc,EAAAN,QAAMrF,UAAUY,eACjB+E,EAAAN,QAAMrF,UAAUY,aAAeL,EAAAM,QAEnC8E,EAAAN,QAAMrF,UAAU4E,OAAO5F,KAAK2G,EAAAN,QAAMrF,UAAW6E,IR6brDtF,OAAOC,eAAenB,EAAS,cAAgB+B,OAAO,GQtctD,IAAAuF,GAAAhH,EAAA,GACA4B,EAAA5B,EAAA,EAEAN,GAAAgH,QAAAkB","file":"Usync.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"Usync\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Usync\"] = factory();\n\telse\n\t\troot[\"Usync\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"Usync\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Usync\"] = factory();\n\telse\n\t\troot[\"Usync\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 2);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar index_1 = __webpack_require__(3);\nvar lifeCycle_1 = __webpack_require__(1);\nvar STATE;\n(function (STATE) {\n STATE[STATE[\"READY\"] = 0] = \"READY\";\n STATE[STATE[\"PENDING\"] = 1] = \"PENDING\";\n STATE[STATE[\"FULFILLED\"] = 2] = \"FULFILLED\";\n STATE[STATE[\"REJECTED\"] = 3] = \"REJECTED\";\n})(STATE || (STATE = {}));\nvar Usync = (function () {\n /**\n * Initialize a Usync APP\n * @param state\n * @param options\n */\n function Usync(state, options) {\n this.vessel = {};\n this.lifecycleMap = lifeCycle_1.init();\n this.root = Array.isArray(state) ? state :\n typeof state === 'string' ? ((this.setName(state)) && {}) :\n typeof state === 'object' ? [state] : {};\n options = index_1.assign({}, options);\n if (options.name) {\n this.setName(options.name);\n }\n this.root.$name = this.__name__;\n this.defferd = [];\n this.index = -1;\n this.state = STATE.READY;\n this.runHook(lifeCycle_1.LIFECYCLE[lifeCycle_1.LIFECYCLE.init], this);\n }\n Usync.prototype.fulfilledBroadcast = function () { };\n Object.defineProperty(Usync.prototype, \"currentDefferd\", {\n get: function () {\n return this.defferd[this.index];\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(Usync.prototype, \"prevDefferd\", {\n get: function () {\n return this.defferd[this.index - 1];\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(Usync.prototype, \"nextDefferd\", {\n get: function () {\n return this.defferd[this.index + 1];\n },\n enumerable: true,\n configurable: true\n });\n Usync.prototype.setName = function (name) {\n this.__name__ = name;\n return this;\n };\n Object.defineProperty(Usync.prototype, \"name\", {\n get: function () {\n return this.__name__;\n },\n enumerable: true,\n configurable: true\n });\n /**\n * Core method to add task\n * @param handler\n * @returns {Usync}\n */\n Usync.prototype.use = function (handler) {\n // Supoort Array syntax\n if (Array.isArray(handler)) {\n for (var _i = 0, handler_1 = handler; _i < handler_1.length; _i++) {\n var childHandler = handler_1[_i];\n this.use(childHandler);\n }\n return this;\n }\n handler.$parent = this;\n this.runHook(lifeCycle_1.LIFECYCLE[lifeCycle_1.LIFECYCLE.beforeUse], this, handler);\n this.defferd.push(handler);\n if (this.defferd.length === 1) {\n this.state = STATE.PENDING;\n this.index = 0;\n }\n else {\n // Previous task has been FULFILLED, directly to the next task execution\n if (this.defferd[this.defferd.length - 2].__state__ === STATE.FULFILLED) {\n this.then();\n }\n }\n return this;\n };\n /**\n * Run next task\n */\n Usync.prototype.then = function () {\n var _this = this;\n // Add Support for time record\n this.currentDefferd.startTime = new Date().getTime();\n var argues = [this.root].concat(this.done.bind(this));\n try {\n this.setRootProperty();\n this.runHook(lifeCycle_1.LIFECYCLE[lifeCycle_1.LIFECYCLE.taskStart], this.root);\n if (typeof this.currentDefferd === 'function') {\n var returnValue = this.currentDefferd.apply(this, argues);\n if (returnValue instanceof Promise) {\n returnValue.then(function () {\n _this.done.call(_this);\n }).catch(function (err) {\n throw err;\n });\n }\n }\n else if (this.currentDefferd instanceof Usync) {\n this.currentDefferd.fulfilledBroadcast = this.done.bind(this);\n this.currentDefferd.start();\n }\n }\n catch (err) {\n if (this.vessel.catch) {\n var errArgues = [err].concat([this.root], this.done.bind(this));\n this.vessel.catch.apply(this, errArgues);\n }\n else {\n throw new Error(err);\n }\n }\n };\n /**\n * Update root state\n */\n Usync.prototype.setRootProperty = function () {\n this.root.$current = this.currentDefferd;\n this.root.$prev = this.prevDefferd;\n this.root.$next = this.nextDefferd;\n };\n /**\n * the next()\n */\n Usync.prototype.done = function () {\n this.currentDefferd.__state__ = STATE.FULFILLED;\n this.currentDefferd.endTime = new Date().getTime();\n this.setRootProperty();\n this.runHook(lifeCycle_1.LIFECYCLE[lifeCycle_1.LIFECYCLE.taskEnd], this.root);\n this.index++;\n // defferd running finished\n if (this.index === this.defferd.length) {\n this.state = STATE.FULFILLED;\n this.defferd = [];\n this.index = -1;\n this.runHook(lifeCycle_1.LIFECYCLE[lifeCycle_1.LIFECYCLE.appEnd], this.root);\n // When a Usync instance set as a child task for another Usync instance\n // fulfilledBroadcast() will tell the parent it was fulfilled\n if (typeof this.fulfilledBroadcast === 'function') {\n this.fulfilledBroadcast();\n }\n return;\n }\n // Synchronous task call next,\n // subsequent task at this time has not yet been push, return directly\n if (this.currentDefferd === undefined) {\n return;\n }\n else if (this.currentDefferd.__state__ === undefined) {\n this.then();\n }\n };\n /**\n * Error catch\n * @param fn\n * @returns {Usync}\n */\n Usync.prototype.catch = function (fn) {\n this.vessel.catch = fn;\n return this;\n };\n /**\n * A Usync application does not run automatically, start() must be called\n */\n Usync.prototype.start = function () {\n this.runHook(lifeCycle_1.LIFECYCLE[lifeCycle_1.LIFECYCLE.appStart], this.root);\n this.startTime = new Date().getTime();\n this.then();\n };\n /**\n * Run life cycle hook\n * @param {String} name\n * @param args\n */\n Usync.prototype.runHook = function (name) {\n var _this = this;\n var args = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n args[_i - 1] = arguments[_i];\n }\n var hookQuene = name + \"Quene\";\n this.lifecycleMap[hookQuene].forEach(function (hook) { return hook.apply(_this, args); });\n if (this.protoLifecycleMap) {\n this.protoLifecycleMap[hookQuene].forEach(function (hook) { return hook.apply(_this, args); });\n }\n };\n Object.defineProperty(Usync.prototype, \"protoLifecycleMap\", {\n get: function () {\n return Object.getPrototypeOf(this).lifecycleMap;\n },\n enumerable: true,\n configurable: true\n });\n /**\n * Extend through life cycle\n * @param hooks\n */\n Usync.prototype.extend = function (hooks) {\n for (var _i = 0, _a = Object.keys(this.lifecycleMap); _i < _a.length; _i++) {\n var key = _a[_i];\n var _key = key.replace('Quene', '');\n if (hooks[_key]) {\n this.lifecycleMap[key].push(hooks[_key]);\n }\n }\n };\n Usync.plugin = function (plugin, options) {\n };\n Usync.app = function (state, options) {\n return new Usync(state, options);\n };\n Usync.extend = function (hooks) {\n };\n return Usync;\n}());\nexports.default = Usync;\n\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar LIFECYCLE;\n(function (LIFECYCLE) {\n LIFECYCLE[LIFECYCLE[\"appStart\"] = 1] = \"appStart\";\n LIFECYCLE[LIFECYCLE[\"taskStart\"] = 2] = \"taskStart\";\n LIFECYCLE[LIFECYCLE[\"taskEnd\"] = 3] = \"taskEnd\";\n LIFECYCLE[LIFECYCLE[\"appEnd\"] = 4] = \"appEnd\";\n LIFECYCLE[LIFECYCLE[\"beforeUse\"] = 5] = \"beforeUse\";\n LIFECYCLE[LIFECYCLE[\"init\"] = 6] = \"init\";\n})(LIFECYCLE = exports.LIFECYCLE || (exports.LIFECYCLE = {}));\n/**\n * Check if a string only contains Number string\n * @param value\n * @returns {boolean}\n */\nfunction isNumberStr(value) {\n // Cannot to use the parseInt API\n // because parseInt will ignore the partial that aren't Number\n var n = Number(value);\n return !isNaN(n);\n}\n/**\n * Init the life cycle map\n * @returns {ILifecycleMap}\n */\nfunction init() {\n var list = {};\n for (var _i = 0, _a = Object.keys(LIFECYCLE); _i < _a.length; _i++) {\n var cycle = _a[_i];\n if (!isNumberStr(cycle)) {\n list[cycle + \"Quene\"] = [];\n }\n }\n return list;\n}\nexports.init = init;\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n/// <reference path=\"./index.d.ts\" />\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @license\n * Copyright toxichl All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/toxichl/usync/blob/master/LICENSE\n */\nvar core_1 = __webpack_require__(0);\nvar globalAPI_1 = __webpack_require__(4);\nglobalAPI_1.default(core_1.default);\nmodule.exports = core_1.default;\n\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction assign(target) {\n var restOb = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n restOb[_i - 1] = arguments[_i];\n }\n if (target == null) {\n throw new TypeError('Cannot convert undefined or null to object');\n }\n target = Object(target);\n for (var index = 0; index < restOb.length; index++) {\n var source = restOb[index];\n if (source != null) {\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n }\n return target;\n}\nexports.assign = assign;\n;\n\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar plugin_1 = __webpack_require__(5);\nvar extend_1 = __webpack_require__(6);\nfunction initGlobalAPI(_Usync) {\n plugin_1.default(_Usync);\n extend_1.default(_Usync);\n}\nexports.default = initGlobalAPI;\n\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nfunction initPlugin($Usync) {\n $Usync.plugin = function (plugin, options) {\n if (typeof plugin === 'function') {\n plugin($Usync, options);\n }\n else if (typeof plugin === 'object' && plugin.install) {\n plugin.install($Usync, options);\n }\n };\n}\nexports.default = initPlugin;\n\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar core_1 = __webpack_require__(0);\nvar lifeCycle_1 = __webpack_require__(1);\nfunction initExtend($Usync) {\n $Usync.extend = function (hooks) {\n if (!core_1.default.prototype.lifecycleMap) {\n core_1.default.prototype.lifecycleMap = lifeCycle_1.init();\n }\n core_1.default.prototype.extend.call(core_1.default.prototype, hooks);\n };\n}\nexports.default = initExtend;\n\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// Usync.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 1bf43a310a32305931c9","import {assign} from '../utils/index'\nimport {init as initlifeCycle, LIFECYCLE as LIFE} from './lifeCycle'\nimport {IPlugin, IpluginOpts} from '../types/plugin'\nimport {IObject, IState, IHandler, ILifeCycle, ILifecycleMap, IHookArgs} from '../types/baseType'\n\nenum STATE {\n READY = 0,\n PENDING = 1,\n FULFILLED = 2,\n REJECTED = 3\n}\n\nexport default class Usync {\n\n public root: IObject;\n public vessel: IObject = {};\n public defferd: IHandler[];\n public index: number;\n public state: number;\n public startTime: number;\n public endTime: number;\n public __name__: string;\n public __state__: number;\n public depth: number;\n public $parent: Usync;\n public fulfilledBroadcast() {}\n\n /**\n * Initialize a Usync APP\n * @param state\n * @param options\n */\n constructor(state: IState, options?: IObject) {\n\n this.root = Array.isArray(state) ? state :\n typeof state === 'string' ? ((this.setName(state)) && <IObject>{}) :\n typeof state === 'object' ? [state] : <IObject>{}\n\n options = assign({}, options)\n\n if (<string>options.name) {\n this.setName(options.name)\n }\n\n this.root.$name = this.__name__\n\n this.defferd = []\n this.index = -1\n this.state = STATE.READY\n this.runHook(LIFE[LIFE.init], this)\n }\n\n get currentDefferd() {\n return <IHandler>this.defferd[this.index]\n }\n\n get prevDefferd() {\n return <IHandler>this.defferd[this.index - 1]\n }\n\n get nextDefferd() {\n return <IHandler>this.defferd[this.index + 1]\n }\n\n public setName(name: string) {\n this.__name__ = name\n return this\n }\n\n get name() {\n return this.__name__\n }\n\n /**\n * Core method to add task\n * @param handler\n * @returns {Usync}\n */\n public use(handler: IHandler | IHandler[]) {\n\n // Supoort Array syntax\n if (Array.isArray(handler)) {\n for (let childHandler of handler) {\n this.use(childHandler)\n }\n return this;\n }\n\n handler.$parent = this\n this.runHook(LIFE[LIFE.beforeUse], this, handler)\n\n this.defferd.push(<IHandler>handler)\n\n if (this.defferd.length === 1) {\n this.state = STATE.PENDING\n this.index = 0\n\n } else {\n // Previous task has been FULFILLED, directly to the next task execution\n if (this.defferd[this.defferd.length - 2].__state__ === STATE.FULFILLED) {\n this.then()\n }\n }\n\n return this\n }\n\n /**\n * Run next task\n */\n then() {\n // Add Support for time record\n this.currentDefferd.startTime = new Date().getTime()\n\n let argues = [this.root].concat(this.done.bind(this))\n\n try {\n\n this.setRootProperty()\n this.runHook(LIFE[LIFE.taskStart], this.root)\n if (typeof this.currentDefferd === 'function') {\n let returnValue = this.currentDefferd.apply(this, argues)\n\n if (returnValue instanceof Promise) {\n returnValue.then(() => {\n this.done.call(this)\n }).catch(err => {\n throw err\n })\n }\n\n } else if (this.currentDefferd instanceof Usync) {\n this.currentDefferd.fulfilledBroadcast = this.done.bind(this)\n this.currentDefferd.start()\n }\n\n } catch (err) {\n\n if (this.vessel.catch) {\n let errArgues = [err].concat([this.root], this.done.bind(this))\n this.vessel.catch.apply(this, errArgues)\n\n } else {\n throw new Error(err)\n }\n\n }\n }\n\n /**\n * Update root state\n */\n setRootProperty() {\n this.root.$current = this.currentDefferd\n this.root.$prev = this.prevDefferd\n this.root.$next = this.nextDefferd\n }\n\n /**\n * the next()\n */\n done() {\n\n this.currentDefferd.__state__ = STATE.FULFILLED\n this.currentDefferd.endTime = new Date().getTime()\n this.setRootProperty()\n\n this.runHook(LIFE[LIFE.taskEnd], this.root)\n this.index++\n // defferd running finished\n if (this.index === this.defferd.length) {\n this.state = STATE.FULFILLED\n this.defferd = []\n this.index = -1\n this.runHook(LIFE[LIFE.appEnd], this.root)\n\n // When a Usync instance set as a child task for another Usync instance\n // fulfilledBroadcast() will tell the parent it was fulfilled\n if (typeof this.fulfilledBroadcast === 'function') {\n this.fulfilledBroadcast()\n }\n\n return;\n }\n\n // Synchronous task call next,\n // subsequent task at this time has not yet been push, return directly\n if (this.currentDefferd === undefined) {\n return;\n }\n // Asynchronous task, subsequent task was already pushed\n // but didn't execute\n else if (this.currentDefferd.__state__ === undefined) {\n this.then()\n }\n }\n\n /**\n * Error catch\n * @param fn\n * @returns {Usync}\n */\n public catch(fn: (err: any) => any) {\n this.vessel.catch = fn;\n return this;\n }\n\n /**\n * A Usync application does not run automatically, start() must be called\n */\n public start() {\n this.runHook(LIFE[LIFE.appStart], this.root)\n this.startTime = new Date().getTime()\n this.then()\n }\n\n /**\n * Run life cycle hook\n * @param {String} name\n * @param args\n */\n runHook(name: string, ...args: IHookArgs) {\n let hookQuene = `${name}Quene`\n this.lifecycleMap[hookQuene].forEach(hook => hook.apply(this, args))\n\n if (this.protoLifecycleMap) {\n this.protoLifecycleMap[hookQuene].forEach(hook => hook.apply(this, args))\n }\n }\n\n get protoLifecycleMap() {\n return <ILifecycleMap>Object.getPrototypeOf(this).lifecycleMap;\n }\n\n /**\n * Extend through life cycle\n * @param hooks\n */\n public extend(hooks: ILifeCycle) {\n for (let key of Object.keys(this.lifecycleMap)) {\n let _key = key.replace('Quene', '')\n if (hooks[_key]) {\n this.lifecycleMap[key].push(hooks[_key])\n }\n }\n }\n\n lifecycleMap = <ILifecycleMap>initlifeCycle();\n\n static plugin(plugin: IPlugin, options?: IpluginOpts) {\n }\n\n static app(state: IState, options?: IObject) {\n return new Usync(state, options)\n }\n\n static extend(hooks: ILifeCycle) {\n }\n}\n\n\n\n\n// WEBPACK FOOTER //\n// ./src/core/index.ts","import {ILifecycleMap} from '../types/baseType'\n\nexport enum LIFECYCLE {\n appStart = 1,\n taskStart = 2,\n taskEnd = 3,\n appEnd = 4,\n beforeUse = 5,\n init = 6,\n}\n\n/**\n * Check if a string only contains Number string\n * @param value\n * @returns {boolean}\n */\nfunction isNumberStr(value: string): boolean {\n // Cannot to use the parseInt API\n // because parseInt will ignore the partial that aren't Number\n var n = Number(value)\n return !isNaN(n)\n}\n\n/**\n * Init the life cycle map\n * @returns {ILifecycleMap}\n */\nexport function init() {\n let list = <ILifecycleMap>{}\n for (let cycle of Object.keys(LIFECYCLE)) {\n if (!isNumberStr(cycle)) {\n list[`${cycle}Quene`] = []\n }\n }\n return <ILifecycleMap>list;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/core/lifeCycle.ts","/// <reference path=\"./index.d.ts\" />\n\n/**\n * @license\n * Copyright toxichl All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/toxichl/usync/blob/master/LICENSE\n */\n\nimport Usync from './core';\nimport initGlobalAPI from './globalAPI'\n\ninitGlobalAPI(Usync);\n\nmodule.exports = Usync;\n\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.ts","import {IObject} from '../types/baseType'\n\n\nexport function assign(target: IObject, ...restOb: IObject[]): IObject {\n\n if (target == null) {\n throw new TypeError('Cannot convert undefined or null to object');\n }\n\n target = Object(target);\n\n for (var index = 0; index < restOb.length; index++) {\n var source = restOb[index]\n if (source != null) {\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key]\n }\n }\n }\n }\n\n return target;\n};\n\n\n// WEBPACK FOOTER //\n// ./src/utils/index.ts","import initPlugin from './plugin'\nimport initExtend from './extend'\nimport Usync from '../core'\n\nexport default function initGlobalAPI(_Usync: typeof Usync) {\n initPlugin(_Usync)\n initExtend(_Usync)\n}\n\n\n// WEBPACK FOOTER //\n// ./src/globalAPI/index.ts","import {IPlugin, IpluginOpts} from '../types/plugin'\nimport Usync from '../core'\n\nexport default function initPlugin($Usync: typeof Usync) {\n\n $Usync.plugin = function (plugin: IPlugin, options?: IpluginOpts) {\n if (typeof plugin === 'function') {\n plugin($Usync, options)\n\n } else if (typeof plugin === 'object' && plugin.install) {\n plugin.install($Usync, options)\n }\n }\n\n}\n\n\n// WEBPACK FOOTER //\n// ./src/globalAPI/plugin.ts","import {ILifeCycle} from '../types/baseType'\nimport Usync from '../core'\nimport {init as initLifeCycle} from '../core/lifeCycle'\n\nexport default function initExtend($Usync: typeof Usync) {\n\n $Usync.extend = function (hooks: ILifeCycle) {\n if (!Usync.prototype.lifecycleMap) {\n Usync.prototype.lifecycleMap = initLifeCycle()\n }\n Usync.prototype.extend.call(Usync.prototype, hooks)\n }\n}\n\n\n// WEBPACK FOOTER //\n// ./src/globalAPI/extend.ts"],"sourceRoot":""}
\No newline at end of file