dependency-inject
Advanced tools
Comparing version 1.0.14 to 1.0.15
@@ -1,1 +0,1 @@ | ||
!function(root,factory){if("object"==typeof exports&&"object"==typeof module)module.exports=factory();else if("function"==typeof define&&define.amd)define([],factory);else{var a=factory();for(var i in a)("object"==typeof exports?exports:root)[i]=a[i]}}(this,function(){return function(modules){function hotDisposeChunk(chunkId){delete installedChunks[chunkId]}function hotDownloadUpdateChunk(chunkId){var head=document.getElementsByTagName("head")[0],script=document.createElement("script");script.type="text/javascript",script.charset="utf-8",script.src=__webpack_require__.p+""+chunkId+"."+hotCurrentHash+".hot-update.js",head.appendChild(script)}function hotDownloadManifest(){return new Promise(function(resolve,reject){if("undefined"==typeof XMLHttpRequest)return reject(new Error("No browser support"));try{var request=new XMLHttpRequest,requestPath=__webpack_require__.p+""+hotCurrentHash+".hot-update.json";request.open("GET",requestPath,!0),request.timeout=1e4,request.send(null)}catch(err){return reject(err)}request.onreadystatechange=function(){if(4===request.readyState)if(0===request.status)reject(new Error("Manifest request to "+requestPath+" timed out."));else if(404===request.status)resolve();else if(200!==request.status&&304!==request.status)reject(new Error("Manifest request to "+requestPath+" failed."));else{try{var update=JSON.parse(request.responseText)}catch(e){return void reject(e)}resolve(update)}}})}function hotCreateRequire(moduleId){var me=installedModules[moduleId];if(!me)return __webpack_require__;var fn=function(request){return me.hot.active?(installedModules[request]?installedModules[request].parents.indexOf(moduleId)<0&&installedModules[request].parents.push(moduleId):(hotCurrentParents=[moduleId],hotCurrentChildModule=request),me.children.indexOf(request)<0&&me.children.push(request)):(console.warn("[HMR] unexpected require("+request+") from disposed module "+moduleId),hotCurrentParents=[]),__webpack_require__(request)};for(var name in __webpack_require__)Object.prototype.hasOwnProperty.call(__webpack_require__,name)&&"e"!==name&&Object.defineProperty(fn,name,function(name){return{configurable:!0,enumerable:!0,get:function(){return __webpack_require__[name]},set:function(value){__webpack_require__[name]=value}}}(name));return fn.e=function(chunkId){function finishChunkLoading(){hotChunksLoading--,"prepare"===hotStatus&&(hotWaitingFilesMap[chunkId]||hotEnsureUpdateChunk(chunkId),0===hotChunksLoading&&0===hotWaitingFiles&&hotUpdateDownloaded())}return"ready"===hotStatus&&hotSetStatus("prepare"),hotChunksLoading++,__webpack_require__.e(chunkId).then(finishChunkLoading,function(err){throw finishChunkLoading(),err})},fn}function hotCreateModule(moduleId){var hot={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:hotCurrentChildModule!==moduleId,active:!0,accept:function(dep,callback){if(void 0===dep)hot._selfAccepted=!0;else if("function"==typeof dep)hot._selfAccepted=dep;else if("object"==typeof dep)for(var i=0;i<dep.length;i++)hot._acceptedDependencies[dep[i]]=callback||function(){};else hot._acceptedDependencies[dep]=callback||function(){}},decline:function(dep){if(void 0===dep)hot._selfDeclined=!0;else if("object"==typeof dep)for(var i=0;i<dep.length;i++)hot._declinedDependencies[dep[i]]=!0;else hot._declinedDependencies[dep]=!0},dispose:function(callback){hot._disposeHandlers.push(callback)},addDisposeHandler:function(callback){hot._disposeHandlers.push(callback)},removeDisposeHandler:function(callback){var idx=hot._disposeHandlers.indexOf(callback);idx>=0&&hot._disposeHandlers.splice(idx,1)},check:hotCheck,apply:hotApply,status:function(l){if(!l)return hotStatus;hotStatusHandlers.push(l)},addStatusHandler:function(l){hotStatusHandlers.push(l)},removeStatusHandler:function(l){var idx=hotStatusHandlers.indexOf(l);idx>=0&&hotStatusHandlers.splice(idx,1)},data:hotCurrentModuleData[moduleId]};return hotCurrentChildModule=void 0,hot}function hotSetStatus(newStatus){hotStatus=newStatus;for(var i=0;i<hotStatusHandlers.length;i++)hotStatusHandlers[i].call(null,newStatus)}function toModuleId(id){return+id+""===id?+id:id}function hotCheck(apply){if("idle"!==hotStatus)throw new Error("check() is only allowed in idle status");return hotApplyOnUpdate=apply,hotSetStatus("check"),hotDownloadManifest().then(function(update){if(!update)return hotSetStatus("idle"),null;hotRequestedFilesMap={},hotWaitingFilesMap={},hotAvailableFilesMap=update.c,hotUpdateNewHash=update.h,hotSetStatus("prepare");var promise=new Promise(function(resolve,reject){hotDeferred={resolve:resolve,reject:reject}});hotUpdate={};return hotEnsureUpdateChunk(0),"prepare"===hotStatus&&0===hotChunksLoading&&0===hotWaitingFiles&&hotUpdateDownloaded(),promise})}function hotAddUpdateChunk(chunkId,moreModules){if(hotAvailableFilesMap[chunkId]&&hotRequestedFilesMap[chunkId]){hotRequestedFilesMap[chunkId]=!1;for(var moduleId in moreModules)Object.prototype.hasOwnProperty.call(moreModules,moduleId)&&(hotUpdate[moduleId]=moreModules[moduleId]);0==--hotWaitingFiles&&0===hotChunksLoading&&hotUpdateDownloaded()}}function hotEnsureUpdateChunk(chunkId){hotAvailableFilesMap[chunkId]?(hotRequestedFilesMap[chunkId]=!0,hotWaitingFiles++,hotDownloadUpdateChunk(chunkId)):hotWaitingFilesMap[chunkId]=!0}function hotUpdateDownloaded(){hotSetStatus("ready");var deferred=hotDeferred;if(hotDeferred=null,deferred)if(hotApplyOnUpdate)hotApply(hotApplyOnUpdate).then(function(result){deferred.resolve(result)},function(err){deferred.reject(err)});else{var outdatedModules=[];for(var id in hotUpdate)Object.prototype.hasOwnProperty.call(hotUpdate,id)&&outdatedModules.push(toModuleId(id));deferred.resolve(outdatedModules)}}function hotApply(options){function addAllToSet(a,b){for(var i=0;i<b.length;i++){var item=b[i];a.indexOf(item)<0&&a.push(item)}}if("ready"!==hotStatus)throw new Error("apply() is only allowed in ready status");options=options||{};var cb,i,j,module,moduleId,outdatedDependencies={},outdatedModules=[],appliedUpdate={},warnUnexpectedRequire=function(){console.warn("[HMR] unexpected require("+result.moduleId+") to disposed module")};for(var id in hotUpdate)if(Object.prototype.hasOwnProperty.call(hotUpdate,id)){moduleId=toModuleId(id);var result;result=hotUpdate[id]?function(updateModuleId){for(var outdatedModules=[updateModuleId],outdatedDependencies={},queue=outdatedModules.slice().map(function(id){return{chain:[id],id:id}});queue.length>0;){var queueItem=queue.pop(),moduleId=queueItem.id,chain=queueItem.chain;if((module=installedModules[moduleId])&&!module.hot._selfAccepted){if(module.hot._selfDeclined)return{type:"self-declined",chain:chain,moduleId:moduleId};if(module.hot._main)return{type:"unaccepted",chain:chain,moduleId:moduleId};for(var i=0;i<module.parents.length;i++){var parentId=module.parents[i],parent=installedModules[parentId];if(parent){if(parent.hot._declinedDependencies[moduleId])return{type:"declined",chain:chain.concat([parentId]),moduleId:moduleId,parentId:parentId};outdatedModules.indexOf(parentId)>=0||(parent.hot._acceptedDependencies[moduleId]?(outdatedDependencies[parentId]||(outdatedDependencies[parentId]=[]),addAllToSet(outdatedDependencies[parentId],[moduleId])):(delete outdatedDependencies[parentId],outdatedModules.push(parentId),queue.push({chain:chain.concat([parentId]),id:parentId})))}}}}return{type:"accepted",moduleId:updateModuleId,outdatedModules:outdatedModules,outdatedDependencies:outdatedDependencies}}(moduleId):{type:"disposed",moduleId:id};var abortError=!1,doApply=!1,doDispose=!1,chainInfo="";switch(result.chain&&(chainInfo="\nUpdate propagation: "+result.chain.join(" -> ")),result.type){case"self-declined":options.onDeclined&&options.onDeclined(result),options.ignoreDeclined||(abortError=new Error("Aborted because of self decline: "+result.moduleId+chainInfo));break;case"declined":options.onDeclined&&options.onDeclined(result),options.ignoreDeclined||(abortError=new Error("Aborted because of declined dependency: "+result.moduleId+" in "+result.parentId+chainInfo));break;case"unaccepted":options.onUnaccepted&&options.onUnaccepted(result),options.ignoreUnaccepted||(abortError=new Error("Aborted because "+moduleId+" is not accepted"+chainInfo));break;case"accepted":options.onAccepted&&options.onAccepted(result),doApply=!0;break;case"disposed":options.onDisposed&&options.onDisposed(result),doDispose=!0;break;default:throw new Error("Unexception type "+result.type)}if(abortError)return hotSetStatus("abort"),Promise.reject(abortError);if(doApply){appliedUpdate[moduleId]=hotUpdate[moduleId],addAllToSet(outdatedModules,result.outdatedModules);for(moduleId in result.outdatedDependencies)Object.prototype.hasOwnProperty.call(result.outdatedDependencies,moduleId)&&(outdatedDependencies[moduleId]||(outdatedDependencies[moduleId]=[]),addAllToSet(outdatedDependencies[moduleId],result.outdatedDependencies[moduleId]))}doDispose&&(addAllToSet(outdatedModules,[result.moduleId]),appliedUpdate[moduleId]=warnUnexpectedRequire)}var outdatedSelfAcceptedModules=[];for(i=0;i<outdatedModules.length;i++)moduleId=outdatedModules[i],installedModules[moduleId]&&installedModules[moduleId].hot._selfAccepted&&outdatedSelfAcceptedModules.push({module:moduleId,errorHandler:installedModules[moduleId].hot._selfAccepted});hotSetStatus("dispose"),Object.keys(hotAvailableFilesMap).forEach(function(chunkId){!1===hotAvailableFilesMap[chunkId]&&hotDisposeChunk(chunkId)});for(var idx,queue=outdatedModules.slice();queue.length>0;)if(moduleId=queue.pop(),module=installedModules[moduleId]){var data={},disposeHandlers=module.hot._disposeHandlers;for(j=0;j<disposeHandlers.length;j++)(cb=disposeHandlers[j])(data);for(hotCurrentModuleData[moduleId]=data,module.hot.active=!1,delete installedModules[moduleId],j=0;j<module.children.length;j++){var child=installedModules[module.children[j]];child&&((idx=child.parents.indexOf(moduleId))>=0&&child.parents.splice(idx,1))}}var dependency,moduleOutdatedDependencies;for(moduleId in outdatedDependencies)if(Object.prototype.hasOwnProperty.call(outdatedDependencies,moduleId)&&(module=installedModules[moduleId]))for(moduleOutdatedDependencies=outdatedDependencies[moduleId],j=0;j<moduleOutdatedDependencies.length;j++)dependency=moduleOutdatedDependencies[j],(idx=module.children.indexOf(dependency))>=0&&module.children.splice(idx,1);hotSetStatus("apply"),hotCurrentHash=hotUpdateNewHash;for(moduleId in appliedUpdate)Object.prototype.hasOwnProperty.call(appliedUpdate,moduleId)&&(modules[moduleId]=appliedUpdate[moduleId]);var error=null;for(moduleId in outdatedDependencies)if(Object.prototype.hasOwnProperty.call(outdatedDependencies,moduleId)){module=installedModules[moduleId],moduleOutdatedDependencies=outdatedDependencies[moduleId];var callbacks=[];for(i=0;i<moduleOutdatedDependencies.length;i++)dependency=moduleOutdatedDependencies[i],cb=module.hot._acceptedDependencies[dependency],callbacks.indexOf(cb)>=0||callbacks.push(cb);for(i=0;i<callbacks.length;i++){cb=callbacks[i];try{cb(moduleOutdatedDependencies)}catch(err){options.onErrored&&options.onErrored({type:"accept-errored",moduleId:moduleId,dependencyId:moduleOutdatedDependencies[i],error:err}),options.ignoreErrored||error||(error=err)}}}for(i=0;i<outdatedSelfAcceptedModules.length;i++){var item=outdatedSelfAcceptedModules[i];moduleId=item.module,hotCurrentParents=[moduleId];try{__webpack_require__(moduleId)}catch(err){if("function"==typeof item.errorHandler)try{item.errorHandler(err)}catch(err2){options.onErrored&&options.onErrored({type:"self-accept-error-handler-errored",moduleId:moduleId,error:err2,orginalError:err}),options.ignoreErrored||error||(error=err2),error||(error=err)}else options.onErrored&&options.onErrored({type:"self-accept-errored",moduleId:moduleId,error:err}),options.ignoreErrored||error||(error=err)}}return error?(hotSetStatus("fail"),Promise.reject(error)):(hotSetStatus("idle"),new Promise(function(resolve){resolve(outdatedModules)}))}function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{},hot:hotCreateModule(moduleId),parents:(hotCurrentParentsTemp=hotCurrentParents,hotCurrentParents=[],hotCurrentParentsTemp),children:[]};return modules[moduleId].call(module.exports,module,module.exports,hotCreateRequire(moduleId)),module.l=!0,module.exports}var parentHotUpdateCallback=this.webpackHotUpdate;this.webpackHotUpdate=function(chunkId,moreModules){hotAddUpdateChunk(chunkId,moreModules),parentHotUpdateCallback&&parentHotUpdateCallback(chunkId,moreModules)};var hotCurrentChildModule,hotDeferred,hotUpdate,hotUpdateNewHash,hotApplyOnUpdate=!0,hotCurrentHash="f1429068bc5bfb3fd618",hotCurrentModuleData={},hotCurrentParents=[],hotCurrentParentsTemp=[],hotStatusHandlers=[],hotStatus="idle",hotWaitingFiles=0,hotChunksLoading=0,hotWaitingFilesMap={},hotRequestedFilesMap={},hotAvailableFilesMap={},installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__.h=function(){return hotCurrentHash},hotCreateRequire(3)(__webpack_require__.s=3)}([function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.injectSymbol=Symbol()},function(module,exports,__webpack_require__){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i.return&&_i.return()}finally{if(_d)throw _e}}return _arr}return function(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr))return sliceIterator(arr,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();Object.defineProperty(exports,"__esModule",{value:!0});var handlers_1=__webpack_require__(0),utils_1=__webpack_require__(4),Container=function(){function Container(){_classCallCheck(this,Container)}return _createClass(Container,[{key:"set",value:function(setClass,instance){utils_1.globalState.instances.has(setClass)||utils_1.globalState.instances.set(setClass,instance)}},{key:"get",value:function(getClass){if(!utils_1.globalState.instances.has(getClass))throw new Error(getClass.name+" 未注册。先使用 set 方法注册,再使用 get 获取");var instance=utils_1.globalState.instances.get(getClass);if(!instance[handlers_1.injectSymbol])return instance;var _iteratorNormalCompletion=!0,_didIteratorError=!1,_iteratorError=void 0;try{for(var _step,_iterator=instance[handlers_1.injectSymbol][Symbol.iterator]();!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=!0)!function(){var _step$value=_slicedToArray(_step.value,2),propertyKey=_step$value[0],injectClass=_step$value[1];Object.defineProperty(instance,propertyKey,{enumerable:!0,configurable:!0,get:function(){return utils_1.globalState.instances.get(injectClass)},set:function(newValue){instance.propertyKey=newValue}})}()}catch(err){_didIteratorError=!0,_iteratorError=err}finally{try{!_iteratorNormalCompletion&&_iterator.return&&_iterator.return()}finally{if(_didIteratorError)throw _iteratorError}}return instance}}]),Container}();exports.default=Container},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var handlers_1=__webpack_require__(0);exports.default=function(injectClass){return function(target,propertyKey,descriptor){descriptor&&(descriptor.enumerable=!0,descriptor.configurable=!0,descriptor.writable=!0),target[handlers_1.injectSymbol]||Object.defineProperty(target,handlers_1.injectSymbol,{enumerable:!0,configurable:!0,value:new Map}),target[handlers_1.injectSymbol].set(propertyKey,injectClass)}}},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var container_1=__webpack_require__(1);exports.Container=container_1.default;var decorators_1=__webpack_require__(2);exports.inject=decorators_1.default},function(module,exports,__webpack_require__){"use strict";(function(global){function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj};Object.defineProperty(exports,"__esModule",{value:!0});var tag="ascoders-dependency-inject",globalOrWindow="object"===("undefined"==typeof self?"undefined":_typeof(self))&&self.self===self&&self||"object"===(void 0===global?"undefined":_typeof(global))&&global.global===global&&global||void 0,GlobalState=function GlobalState(){_classCallCheck(this,GlobalState),this.instances=new WeakMap},globalState=new GlobalState;exports.globalState=globalState,globalOrWindow[tag]?exports.globalState=globalState=globalOrWindow[tag]:globalOrWindow[tag]=globalState}).call(exports,__webpack_require__(5))},function(module,exports){var g;g=function(){return this}();try{g=g||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(g=window)}module.exports=g}])}); | ||
!function(root,factory){if("object"==typeof exports&&"object"==typeof module)module.exports=factory();else if("function"==typeof define&&define.amd)define([],factory);else{var a=factory();for(var i in a)("object"==typeof exports?exports:root)[i]=a[i]}}(this,function(){return function(modules){function hotDisposeChunk(chunkId){delete installedChunks[chunkId]}function hotDownloadUpdateChunk(chunkId){var head=document.getElementsByTagName("head")[0],script=document.createElement("script");script.type="text/javascript",script.charset="utf-8",script.src=__webpack_require__.p+""+chunkId+"."+hotCurrentHash+".hot-update.js",head.appendChild(script)}function hotDownloadManifest(){return new Promise(function(resolve,reject){if("undefined"==typeof XMLHttpRequest)return reject(new Error("No browser support"));try{var request=new XMLHttpRequest,requestPath=__webpack_require__.p+""+hotCurrentHash+".hot-update.json";request.open("GET",requestPath,!0),request.timeout=1e4,request.send(null)}catch(err){return reject(err)}request.onreadystatechange=function(){if(4===request.readyState)if(0===request.status)reject(new Error("Manifest request to "+requestPath+" timed out."));else if(404===request.status)resolve();else if(200!==request.status&&304!==request.status)reject(new Error("Manifest request to "+requestPath+" failed."));else{try{var update=JSON.parse(request.responseText)}catch(e){return void reject(e)}resolve(update)}}})}function hotCreateRequire(moduleId){var me=installedModules[moduleId];if(!me)return __webpack_require__;var fn=function(request){return me.hot.active?(installedModules[request]?installedModules[request].parents.indexOf(moduleId)<0&&installedModules[request].parents.push(moduleId):(hotCurrentParents=[moduleId],hotCurrentChildModule=request),me.children.indexOf(request)<0&&me.children.push(request)):(console.warn("[HMR] unexpected require("+request+") from disposed module "+moduleId),hotCurrentParents=[]),__webpack_require__(request)};for(var name in __webpack_require__)Object.prototype.hasOwnProperty.call(__webpack_require__,name)&&"e"!==name&&Object.defineProperty(fn,name,function(name){return{configurable:!0,enumerable:!0,get:function(){return __webpack_require__[name]},set:function(value){__webpack_require__[name]=value}}}(name));return fn.e=function(chunkId){function finishChunkLoading(){hotChunksLoading--,"prepare"===hotStatus&&(hotWaitingFilesMap[chunkId]||hotEnsureUpdateChunk(chunkId),0===hotChunksLoading&&0===hotWaitingFiles&&hotUpdateDownloaded())}return"ready"===hotStatus&&hotSetStatus("prepare"),hotChunksLoading++,__webpack_require__.e(chunkId).then(finishChunkLoading,function(err){throw finishChunkLoading(),err})},fn}function hotCreateModule(moduleId){var hot={_acceptedDependencies:{},_declinedDependencies:{},_selfAccepted:!1,_selfDeclined:!1,_disposeHandlers:[],_main:hotCurrentChildModule!==moduleId,active:!0,accept:function(dep,callback){if(void 0===dep)hot._selfAccepted=!0;else if("function"==typeof dep)hot._selfAccepted=dep;else if("object"==typeof dep)for(var i=0;i<dep.length;i++)hot._acceptedDependencies[dep[i]]=callback||function(){};else hot._acceptedDependencies[dep]=callback||function(){}},decline:function(dep){if(void 0===dep)hot._selfDeclined=!0;else if("object"==typeof dep)for(var i=0;i<dep.length;i++)hot._declinedDependencies[dep[i]]=!0;else hot._declinedDependencies[dep]=!0},dispose:function(callback){hot._disposeHandlers.push(callback)},addDisposeHandler:function(callback){hot._disposeHandlers.push(callback)},removeDisposeHandler:function(callback){var idx=hot._disposeHandlers.indexOf(callback);idx>=0&&hot._disposeHandlers.splice(idx,1)},check:hotCheck,apply:hotApply,status:function(l){if(!l)return hotStatus;hotStatusHandlers.push(l)},addStatusHandler:function(l){hotStatusHandlers.push(l)},removeStatusHandler:function(l){var idx=hotStatusHandlers.indexOf(l);idx>=0&&hotStatusHandlers.splice(idx,1)},data:hotCurrentModuleData[moduleId]};return hotCurrentChildModule=void 0,hot}function hotSetStatus(newStatus){hotStatus=newStatus;for(var i=0;i<hotStatusHandlers.length;i++)hotStatusHandlers[i].call(null,newStatus)}function toModuleId(id){return+id+""===id?+id:id}function hotCheck(apply){if("idle"!==hotStatus)throw new Error("check() is only allowed in idle status");return hotApplyOnUpdate=apply,hotSetStatus("check"),hotDownloadManifest().then(function(update){if(!update)return hotSetStatus("idle"),null;hotRequestedFilesMap={},hotWaitingFilesMap={},hotAvailableFilesMap=update.c,hotUpdateNewHash=update.h,hotSetStatus("prepare");var promise=new Promise(function(resolve,reject){hotDeferred={resolve:resolve,reject:reject}});hotUpdate={};return hotEnsureUpdateChunk(0),"prepare"===hotStatus&&0===hotChunksLoading&&0===hotWaitingFiles&&hotUpdateDownloaded(),promise})}function hotAddUpdateChunk(chunkId,moreModules){if(hotAvailableFilesMap[chunkId]&&hotRequestedFilesMap[chunkId]){hotRequestedFilesMap[chunkId]=!1;for(var moduleId in moreModules)Object.prototype.hasOwnProperty.call(moreModules,moduleId)&&(hotUpdate[moduleId]=moreModules[moduleId]);0==--hotWaitingFiles&&0===hotChunksLoading&&hotUpdateDownloaded()}}function hotEnsureUpdateChunk(chunkId){hotAvailableFilesMap[chunkId]?(hotRequestedFilesMap[chunkId]=!0,hotWaitingFiles++,hotDownloadUpdateChunk(chunkId)):hotWaitingFilesMap[chunkId]=!0}function hotUpdateDownloaded(){hotSetStatus("ready");var deferred=hotDeferred;if(hotDeferred=null,deferred)if(hotApplyOnUpdate)hotApply(hotApplyOnUpdate).then(function(result){deferred.resolve(result)},function(err){deferred.reject(err)});else{var outdatedModules=[];for(var id in hotUpdate)Object.prototype.hasOwnProperty.call(hotUpdate,id)&&outdatedModules.push(toModuleId(id));deferred.resolve(outdatedModules)}}function hotApply(options){function addAllToSet(a,b){for(var i=0;i<b.length;i++){var item=b[i];a.indexOf(item)<0&&a.push(item)}}if("ready"!==hotStatus)throw new Error("apply() is only allowed in ready status");options=options||{};var cb,i,j,module,moduleId,outdatedDependencies={},outdatedModules=[],appliedUpdate={},warnUnexpectedRequire=function(){console.warn("[HMR] unexpected require("+result.moduleId+") to disposed module")};for(var id in hotUpdate)if(Object.prototype.hasOwnProperty.call(hotUpdate,id)){moduleId=toModuleId(id);var result;result=hotUpdate[id]?function(updateModuleId){for(var outdatedModules=[updateModuleId],outdatedDependencies={},queue=outdatedModules.slice().map(function(id){return{chain:[id],id:id}});queue.length>0;){var queueItem=queue.pop(),moduleId=queueItem.id,chain=queueItem.chain;if((module=installedModules[moduleId])&&!module.hot._selfAccepted){if(module.hot._selfDeclined)return{type:"self-declined",chain:chain,moduleId:moduleId};if(module.hot._main)return{type:"unaccepted",chain:chain,moduleId:moduleId};for(var i=0;i<module.parents.length;i++){var parentId=module.parents[i],parent=installedModules[parentId];if(parent){if(parent.hot._declinedDependencies[moduleId])return{type:"declined",chain:chain.concat([parentId]),moduleId:moduleId,parentId:parentId};outdatedModules.indexOf(parentId)>=0||(parent.hot._acceptedDependencies[moduleId]?(outdatedDependencies[parentId]||(outdatedDependencies[parentId]=[]),addAllToSet(outdatedDependencies[parentId],[moduleId])):(delete outdatedDependencies[parentId],outdatedModules.push(parentId),queue.push({chain:chain.concat([parentId]),id:parentId})))}}}}return{type:"accepted",moduleId:updateModuleId,outdatedModules:outdatedModules,outdatedDependencies:outdatedDependencies}}(moduleId):{type:"disposed",moduleId:id};var abortError=!1,doApply=!1,doDispose=!1,chainInfo="";switch(result.chain&&(chainInfo="\nUpdate propagation: "+result.chain.join(" -> ")),result.type){case"self-declined":options.onDeclined&&options.onDeclined(result),options.ignoreDeclined||(abortError=new Error("Aborted because of self decline: "+result.moduleId+chainInfo));break;case"declined":options.onDeclined&&options.onDeclined(result),options.ignoreDeclined||(abortError=new Error("Aborted because of declined dependency: "+result.moduleId+" in "+result.parentId+chainInfo));break;case"unaccepted":options.onUnaccepted&&options.onUnaccepted(result),options.ignoreUnaccepted||(abortError=new Error("Aborted because "+moduleId+" is not accepted"+chainInfo));break;case"accepted":options.onAccepted&&options.onAccepted(result),doApply=!0;break;case"disposed":options.onDisposed&&options.onDisposed(result),doDispose=!0;break;default:throw new Error("Unexception type "+result.type)}if(abortError)return hotSetStatus("abort"),Promise.reject(abortError);if(doApply){appliedUpdate[moduleId]=hotUpdate[moduleId],addAllToSet(outdatedModules,result.outdatedModules);for(moduleId in result.outdatedDependencies)Object.prototype.hasOwnProperty.call(result.outdatedDependencies,moduleId)&&(outdatedDependencies[moduleId]||(outdatedDependencies[moduleId]=[]),addAllToSet(outdatedDependencies[moduleId],result.outdatedDependencies[moduleId]))}doDispose&&(addAllToSet(outdatedModules,[result.moduleId]),appliedUpdate[moduleId]=warnUnexpectedRequire)}var outdatedSelfAcceptedModules=[];for(i=0;i<outdatedModules.length;i++)moduleId=outdatedModules[i],installedModules[moduleId]&&installedModules[moduleId].hot._selfAccepted&&outdatedSelfAcceptedModules.push({module:moduleId,errorHandler:installedModules[moduleId].hot._selfAccepted});hotSetStatus("dispose"),Object.keys(hotAvailableFilesMap).forEach(function(chunkId){!1===hotAvailableFilesMap[chunkId]&&hotDisposeChunk(chunkId)});for(var idx,queue=outdatedModules.slice();queue.length>0;)if(moduleId=queue.pop(),module=installedModules[moduleId]){var data={},disposeHandlers=module.hot._disposeHandlers;for(j=0;j<disposeHandlers.length;j++)(cb=disposeHandlers[j])(data);for(hotCurrentModuleData[moduleId]=data,module.hot.active=!1,delete installedModules[moduleId],j=0;j<module.children.length;j++){var child=installedModules[module.children[j]];child&&((idx=child.parents.indexOf(moduleId))>=0&&child.parents.splice(idx,1))}}var dependency,moduleOutdatedDependencies;for(moduleId in outdatedDependencies)if(Object.prototype.hasOwnProperty.call(outdatedDependencies,moduleId)&&(module=installedModules[moduleId]))for(moduleOutdatedDependencies=outdatedDependencies[moduleId],j=0;j<moduleOutdatedDependencies.length;j++)dependency=moduleOutdatedDependencies[j],(idx=module.children.indexOf(dependency))>=0&&module.children.splice(idx,1);hotSetStatus("apply"),hotCurrentHash=hotUpdateNewHash;for(moduleId in appliedUpdate)Object.prototype.hasOwnProperty.call(appliedUpdate,moduleId)&&(modules[moduleId]=appliedUpdate[moduleId]);var error=null;for(moduleId in outdatedDependencies)if(Object.prototype.hasOwnProperty.call(outdatedDependencies,moduleId)){module=installedModules[moduleId],moduleOutdatedDependencies=outdatedDependencies[moduleId];var callbacks=[];for(i=0;i<moduleOutdatedDependencies.length;i++)dependency=moduleOutdatedDependencies[i],cb=module.hot._acceptedDependencies[dependency],callbacks.indexOf(cb)>=0||callbacks.push(cb);for(i=0;i<callbacks.length;i++){cb=callbacks[i];try{cb(moduleOutdatedDependencies)}catch(err){options.onErrored&&options.onErrored({type:"accept-errored",moduleId:moduleId,dependencyId:moduleOutdatedDependencies[i],error:err}),options.ignoreErrored||error||(error=err)}}}for(i=0;i<outdatedSelfAcceptedModules.length;i++){var item=outdatedSelfAcceptedModules[i];moduleId=item.module,hotCurrentParents=[moduleId];try{__webpack_require__(moduleId)}catch(err){if("function"==typeof item.errorHandler)try{item.errorHandler(err)}catch(err2){options.onErrored&&options.onErrored({type:"self-accept-error-handler-errored",moduleId:moduleId,error:err2,orginalError:err}),options.ignoreErrored||error||(error=err2),error||(error=err)}else options.onErrored&&options.onErrored({type:"self-accept-errored",moduleId:moduleId,error:err}),options.ignoreErrored||error||(error=err)}}return error?(hotSetStatus("fail"),Promise.reject(error)):(hotSetStatus("idle"),new Promise(function(resolve){resolve(outdatedModules)}))}function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{},hot:hotCreateModule(moduleId),parents:(hotCurrentParentsTemp=hotCurrentParents,hotCurrentParents=[],hotCurrentParentsTemp),children:[]};return modules[moduleId].call(module.exports,module,module.exports,hotCreateRequire(moduleId)),module.l=!0,module.exports}var parentHotUpdateCallback=this.webpackHotUpdate;this.webpackHotUpdate=function(chunkId,moreModules){hotAddUpdateChunk(chunkId,moreModules),parentHotUpdateCallback&&parentHotUpdateCallback(chunkId,moreModules)};var hotCurrentChildModule,hotDeferred,hotUpdate,hotUpdateNewHash,hotApplyOnUpdate=!0,hotCurrentHash="ddb2abd45ea62d3a255f",hotCurrentModuleData={},hotCurrentParents=[],hotCurrentParentsTemp=[],hotStatusHandlers=[],hotStatus="idle",hotWaitingFiles=0,hotChunksLoading=0,hotWaitingFilesMap={},hotRequestedFilesMap={},hotAvailableFilesMap={},installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__.h=function(){return hotCurrentHash},hotCreateRequire(3)(__webpack_require__.s=3)}([function(module,exports,__webpack_require__){"use strict";(function(global){function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj};Object.defineProperty(exports,"__esModule",{value:!0});var tag="ascoders-dependency-inject",globalOrWindow="object"===("undefined"==typeof self?"undefined":_typeof(self))&&self.self===self&&self||"object"===(void 0===global?"undefined":_typeof(global))&&global.global===global&&global||void 0,GlobalState=function GlobalState(){_classCallCheck(this,GlobalState),this.instances=new WeakMap,this.injectSymbol=Symbol()},globalState=new GlobalState;exports.globalState=globalState,globalOrWindow[tag]?exports.globalState=globalState=globalOrWindow[tag]:globalOrWindow[tag]=globalState}).call(exports,__webpack_require__(4))},function(module,exports,__webpack_require__){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i.return&&_i.return()}finally{if(_d)throw _e}}return _arr}return function(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr))return sliceIterator(arr,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();Object.defineProperty(exports,"__esModule",{value:!0});var utils_1=__webpack_require__(0),Container=function(){function Container(){_classCallCheck(this,Container)}return _createClass(Container,[{key:"set",value:function(setClass,instance){utils_1.globalState.instances.has(setClass)||utils_1.globalState.instances.set(setClass,instance)}},{key:"get",value:function(getClass){if(!utils_1.globalState.instances.has(getClass))throw new Error(getClass.name+" 未注册。先使用 set 方法注册,再使用 get 获取");var instance=utils_1.globalState.instances.get(getClass);if(!instance[utils_1.globalState.injectSymbol])return instance;var _iteratorNormalCompletion=!0,_didIteratorError=!1,_iteratorError=void 0;try{for(var _step,_iterator=instance[utils_1.globalState.injectSymbol][Symbol.iterator]();!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=!0)!function(){var _step$value=_slicedToArray(_step.value,2),propertyKey=_step$value[0],injectClass=_step$value[1];Object.defineProperty(instance,propertyKey,{enumerable:!0,configurable:!0,get:function(){return utils_1.globalState.instances.get(injectClass)},set:function(newValue){instance.propertyKey=newValue}})}()}catch(err){_didIteratorError=!0,_iteratorError=err}finally{try{!_iteratorNormalCompletion&&_iterator.return&&_iterator.return()}finally{if(_didIteratorError)throw _iteratorError}}return instance}}]),Container}();exports.default=Container},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var utils_1=__webpack_require__(0);exports.default=function(injectClass){return function(target,propertyKey,descriptor){descriptor&&(descriptor.enumerable=!0,descriptor.configurable=!0,descriptor.writable=!0),target[utils_1.globalState.injectSymbol]||Object.defineProperty(target,utils_1.globalState.injectSymbol,{enumerable:!0,configurable:!0,value:new Map}),target[utils_1.globalState.injectSymbol].set(propertyKey,injectClass)}}},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var container_1=__webpack_require__(1);exports.Container=container_1.default;var decorators_1=__webpack_require__(2);exports.inject=decorators_1.default},function(module,exports){var g;g=function(){return this}();try{g=g||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(g=window)}module.exports=g}])}); |
@@ -10,3 +10,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var handlers_1 = require("./handlers"); | ||
var utils_1 = require("./utils"); | ||
@@ -33,3 +32,3 @@ | ||
var instance = utils_1.globalState.instances.get(getClass); | ||
if (!instance[handlers_1.injectSymbol]) { | ||
if (!instance[utils_1.globalState.injectSymbol]) { | ||
return instance; | ||
@@ -59,3 +58,3 @@ } | ||
for (var _iterator = instance[handlers_1.injectSymbol][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
for (var _iterator = instance[utils_1.globalState.injectSymbol][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
_loop(); | ||
@@ -62,0 +61,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var handlers_1 = require("./handlers"); | ||
var utils_1 = require("./utils"); | ||
exports.default = function (injectClass) { | ||
@@ -12,4 +12,4 @@ return function (target, propertyKey, descriptor) { | ||
} | ||
if (!target[handlers_1.injectSymbol]) { | ||
Object.defineProperty(target, handlers_1.injectSymbol, { | ||
if (!target[utils_1.globalState.injectSymbol]) { | ||
Object.defineProperty(target, utils_1.globalState.injectSymbol, { | ||
enumerable: true, | ||
@@ -20,5 +20,5 @@ configurable: true, | ||
} | ||
target[handlers_1.injectSymbol].set(propertyKey, injectClass); | ||
target[utils_1.globalState.injectSymbol].set(propertyKey, injectClass); | ||
}; | ||
}; | ||
//# sourceMappingURL=decorators.js.map |
@@ -15,2 +15,3 @@ "use strict"; | ||
this.instances = new WeakMap(); | ||
this.injectSymbol = Symbol(); | ||
}; | ||
@@ -17,0 +18,0 @@ |
{ | ||
"name": "dependency-inject", | ||
"version": "1.0.14", | ||
"version": "1.0.15", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "built/index.js", |
@@ -1,2 +0,1 @@ | ||
import { injectSymbol } from './handlers' | ||
import { globalState } from "./utils" | ||
@@ -33,7 +32,7 @@ | ||
// 如果这个类没有 inject 过,就不会存在这个 symbol,直接返回实例 | ||
if (!instance[injectSymbol]) { | ||
if (!instance[globalState.injectSymbol]) { | ||
return instance | ||
} | ||
for (let [propertyKey, injectClass] of instance[injectSymbol]) { | ||
for (let [propertyKey, injectClass] of instance[globalState.injectSymbol]) { | ||
// 将其中所有标注注入的字段替换为注入值 | ||
@@ -40,0 +39,0 @@ Object.defineProperty(instance, propertyKey, { |
@@ -1,2 +0,2 @@ | ||
import { injectSymbol } from './handlers' | ||
import { globalState } from './utils' | ||
@@ -12,4 +12,4 @@ export default <T>(injectClass: T) => (target: any, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => { | ||
// 这个字段用来存储所有可能从注入中获取的数据 | ||
if (!target[injectSymbol]) { | ||
Object.defineProperty(target, injectSymbol, { | ||
if (!target[globalState.injectSymbol]) { | ||
Object.defineProperty(target, globalState.injectSymbol, { | ||
enumerable: true, | ||
@@ -21,3 +21,3 @@ configurable: true, | ||
target[injectSymbol].set(propertyKey, injectClass) | ||
target[globalState.injectSymbol].set(propertyKey, injectClass) | ||
} |
@@ -12,2 +12,4 @@ const tag = "ascoders-dependency-inject" | ||
instances = new WeakMap() | ||
injectSymbol = Symbol() | ||
} | ||
@@ -14,0 +16,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
180514
26
376