@govflanders/vl-widget-plugin
Advanced tools
Comparing version 1.2.2 to 1.3.2-0
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var vlWidgetUtility=require("@govflanders/vl-widget-utility"),vlWidgetEvent=require("@govflanders/vl-widget-event"),extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};function __extends(t,e){function n(){this.constructor=t}extendStatics(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var PluginEventBase=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(vlWidgetEvent.EventBase),GenericPluginEvent=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(PluginEventBase),GenericPluginExtensionEvent=function(i){function t(t,e,n,r){void 0===r&&(r=vlWidgetEvent.EventScope.Broadcast);var o=i.call(this,t,e,r)||this;return o.pluginExtension=n,o}return __extends(t,i),t.prototype.getExtension=function(){return this.pluginExtension},t}(PluginEventBase),GenericPluginErrorEvent=function(i){function t(t,e,n,r){void 0===r&&(r=vlWidgetEvent.EventScope.Broadcast);var o=i.call(this,t,e,r)||this;return o.error=n,o}return __extends(t,i),t.prototype.getError=function(){return this.error},t}(PluginEventBase),PluginManagerBase=function(){function t(t,e){this.pluginHost=t,this.pluginDiscovery=e,this.pluginRegistry=[]}return t.prototype.getPluginHost=function(){return this.pluginHost},t.prototype.getPluginDiscovery=function(){return this.pluginDiscovery},t.prototype.createPluginInstance=function(n){var r=this;return this.getPluginDiscovery().resolvePluginFactory(n).then(function(t){var e=r.getPluginHost();return t.createPluginInstance(e,n)}).then(function(t){return t.initialize()}).then(function(t){return r.pluginRegistry.push(t),t})},t.prototype.list=function(t){for(var e=[],n="function"==typeof t?t:null,r=0,o=this.pluginRegistry;r<o.length;r++){var i=o[r];null!==n&&!n(i)||e.push(i)}return e},t.prototype.each=function(t){for(var e=[],n=0,r=this.pluginRegistry;n<r.length;n++){var o=r[n];e.push(t(o))}return Promise.all(e)},t.prototype.has=function(t){return null!==this.get(t)},t.prototype.get=function(e){return this.pluginRegistry.find(function(t){return t.getPluginId()===e})||null},t}(),PluginExtensionManagerBase=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(PluginManagerBase),HookablePluginExtensionManager=function(){function t(t,e){this.pluginExtensionManager=t,this.createPluginInstanceCallback=e}return t.prototype.getPluginHost=function(){return this.pluginExtensionManager.getPluginHost()},t.prototype.getPluginDiscovery=function(){return this.pluginExtensionManager.getPluginDiscovery()},t.prototype.createPluginInstance=function(t){return this.pluginExtensionManager.createPluginInstance(t).then(this.createPluginInstanceCallback)},t.prototype.has=function(t){return this.pluginExtensionManager.has(t)},t.prototype.get=function(t){return this.pluginExtensionManager.get(t)},t.prototype.list=function(t){return this.pluginExtensionManager.list(t)},t.prototype.each=function(t){return this.pluginExtensionManager.each(t)},t}();!function(t){t.None="none",t.Initialize="initialize",t.Ready="ready",t.Failed="failed"}(exports.PluginState||(exports.PluginState={}));var PluginFactoryError=function(i){function s(t,e,n,r){void 0===r&&(r=null);var o=i.call(this,n,r)||this;return Object.setPrototypeOf(o,s.prototype),o.pluginHost=t,o.pluginContext=e,o}return __extends(s,i),s}(vlWidgetUtility.Error.RuntimeError),PluginContextError=function(o){function i(t,e,n){void 0===n&&(n=null);var r=o.call(this,e,n)||this;return Object.setPrototypeOf(r,i.prototype),r.pluginContext=t,r}return __extends(i,o),i}(vlWidgetUtility.Error.RuntimeError),PluginError=function(o){function i(t,e,n){void 0===n&&(n=null);var r=o.call(this,e,n)||this;return Object.setPrototypeOf(r,i.prototype),r.plugin=t,r}return __extends(i,o),i}(vlWidgetUtility.Error.RuntimeError),PluginBase=function(r){function t(t,e){var n=r.call(this)||this;return n.pluginHost=t,n.pluginContext=e,n.pluginState=exports.PluginState.None,n}return __extends(t,r),t.prototype.onBeforeInitialize=function(){var t=this;return Promise.resolve(this).then(function(){return t.validatePluginContext(t.getPluginContext()),t})},t.prototype.onInitialize=function(){return Promise.resolve(this)},t.prototype.onBeforeReady=function(){return Promise.resolve(this)},t.prototype.onReady=function(){return Promise.resolve(this)},t.prototype.onFailed=function(){return Promise.resolve(this)},t.prototype.onError=function(t){return Promise.resolve(this)},t.prototype.createHookEvent=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];switch(t){case"error":return new GenericPluginErrorEvent(t,this,e[0]);default:return new GenericPluginEvent(t,this)}},t.prototype.invokeHook=function(t){for(var e,n=this,r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(0<t.length){var i=[],s="on"+(t.charAt(0).toUpperCase()+t.slice(1));if("function"==typeof this[s]&&i.push((e=this)[s].apply(e,r)),this.getPluginState()===exports.PluginState.Ready){var u=this.createHookEvent.apply(this,[t].concat(r));i.push(this.getEventEmitter().emit(u))}return Promise.all(i).then(function(){return n})}return Promise.resolve(this)},t.prototype.validatePluginContext=function(t){if("string"!=typeof t.pluginTypeId)throw new PluginError(this,'Context property "pluginTypeId" should be a string')},t.prototype.initialize=function(){var e=this;return void 0===this.pluginInitPromise?(this.pluginState=exports.PluginState.Initialize,this.pluginInitPromise=Promise.resolve().then(function(){return e.invokeHook("beforeInitialize")}).then(function(){return e.invokeHook("initialize")}).then(function(){return e.invokeHook("beforeReady")}).then(function(){return e.pluginState=exports.PluginState.Ready,e.invokeHook("ready")}).catch(function(t){return e.pluginState=exports.PluginState.Failed,e.invokeHook("failed",t).then(function(){return Promise.reject(t)})})):this.invokeHook("error",new PluginError(this,'Plugin "'+this.getPluginTypeId()+'" is being initialized multiple times')),this.pluginInitPromise},t.prototype.getPluginState=function(){return this.pluginState},t.prototype.getPluginHost=function(){return this.pluginHost},t.prototype.getPluginContext=function(){return this.pluginContext},t.prototype.getPluginTypeId=function(){return this.getPluginContext().pluginTypeId},t.prototype.toString=function(){return this.getPluginTypeId()+":"+this.getPluginId()},t}(vlWidgetEvent.EventSourceBase);!function(t){t.Internal="internal",t.Required="required",t.Optional="optional"}(exports.PluginExtensionConstraint||(exports.PluginExtensionConstraint={})),function(t){t.UnSafe="unsafe",t.Safe="safe"}(exports.PluginExtensionResolveMethod||(exports.PluginExtensionResolveMethod={}));var ExtensiblePluginBase=function(r){function t(t,e){var n=r.call(this,t,e)||this;return n.extensionPromiseCache={},n}return __extends(t,r),t.prototype.createHookEvent=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];switch(t){case"extension":return new GenericPluginExtensionEvent(t,this,e[0]);default:return r.prototype.createHookEvent.apply(this,[t].concat(e))}},t.prototype.onBeforeReady=function(){var t=this;return r.prototype.onBeforeReady.call(this).then(function(){return t.createExtensionsByConstraint(exports.PluginExtensionConstraint.Internal)}).then(function(){return t})},t.prototype.onReady=function(){var e=this;return r.prototype.onReady.call(this).then(function(){return e.createExtensionsByConstraint(exports.PluginExtensionConstraint.Required)}).then(function(){return e.createExtensionsByConstraint(exports.PluginExtensionConstraint.Optional).catch(function(t){return e.invokeHook("error",t)}),e})},t.prototype.onExtension=function(n){var r=this;return Promise.resolve(this).then(function(){var t=n.getPluginId(),e=r.extensionPromiseCache[t]||null;return null!==e&&null!==e.resolve&&(e.resolve(n),delete r.extensionPromiseCache[t]),r})},t.prototype.createExtensionsByConstraint=function(t){var e=this;return Promise.resolve().then(function(){return e.resolveExtensionContexts(t)}).then(function(t){return e.createExtensionsByContexts(t)})},t.prototype.createExtensionsByContexts=function(s){var u=this;return Promise.resolve().then(function(){for(var t=[],e=u.getExtensionManager(),n=0,r=s;n<r.length;n++){var o=r[n],i=e.createPluginInstance(o);t.push(i)}return Promise.all(t)})},t.prototype.getExtensionManager=function(){var e=this;if(void 0===this.extensionManager){var t=this.createExtensionManager();this.extensionManager=new HookablePluginExtensionManager(t,function(t){return e.invokeHook("extension",t).then(function(){return t})})}return this.extensionManager},t.prototype.getExtensionSafe=function(n){var r=this;return Promise.resolve().then(function(){return r.tryGetExtensionUnsafe(n)}).then(function(t){if(null!==t)return t;var e=r.extensionPromiseCache[n]||null;return null!==e&&null!==e.promise||((e=r.extensionPromiseCache[n]={promise:null,resolve:null}).promise=new Promise(function(t){e.resolve=t})),e.promise})},t.prototype.tryGetExtensionUnsafe=function(t){if(this.getPluginState()!==exports.PluginState.Ready)throw new vlWidgetUtility.Error.RuntimeError('Cannot retrieve "'+t+'" extension as plugin is not ready');return this.getExtensionManager().get(t)},t.prototype.getExtensionUnsafe=function(t){var e=this.tryGetExtensionUnsafe(t);if(null===e)throw new vlWidgetUtility.Error.RuntimeError('Failed to resolve "'+t+'" extension');return e},t.prototype.getExtension=function(t,e){void 0===e&&(e=exports.PluginExtensionResolveMethod.Safe);var n=extractPluginExtensionPathInfo(t);switch(e){case exports.PluginExtensionResolveMethod.UnSafe:return resolveNestedPluginExtensionUnsafe(this.getExtensionUnsafe(n.id),n.nested);default:return this.getExtensionSafe(n.id).then(function(t){return resolveNestedPluginExtensionSafe(t,n.nested)})}},t}(PluginBase);function extractPluginExtensionPathInfo(t){var e=t.split(".");return{id:e.shift()||"",nested:e.join(".")||null}}function resolveNestedPluginExtensionUnsafe(t,e){if(e){if("function"!=typeof t.getExtension)throw new vlWidgetUtility.Error.RuntimeError('Plugin "'+t.getPluginId()+'" does not support retrieving nested extensions');return t.getExtension(e,exports.PluginExtensionResolveMethod.UnSafe)}return t}function resolveNestedPluginExtensionSafe(t,e){if(e){if("function"!=typeof t.getExtension)throw new vlWidgetUtility.Error.RuntimeError('Plugin "'+t.getPluginId()+'" does not support retrieving nested extensions');return t.getExtension(e,exports.PluginExtensionResolveMethod.Safe)}return Promise.resolve(t)}function installPluginModule(e,t){return Promise.resolve().then(function(){switch(_typeof(t)){case"string":return e.import(t);default:return t}}).then(function(t){return e.install(t)})}function installPluginContext(e,n){return Promise.resolve().then(function(){var t=n.pluginModule||null;return installPluginModule(e,t)}).then(function(){return n})}var ContainerPluginDiscovery=function(){function t(t,e){this.container=t,this.pluginFactoryServiceId=e}return t.prototype.getContainer=function(){return this.container},t.prototype.getPluginFactoryServiceId=function(){return this.pluginFactoryServiceId},t.prototype.getPluginFactoryFromContainer=function(t){var e=this.getPluginFactoryServiceId();return this.getContainer().getNamed(e,t.pluginTypeId)},t.prototype.resolvePluginFactory=function(e){var n=this;return new Promise(function(t){t(n.getPluginFactoryFromContainer(e))})},t}(),ModulePluginDiscovery=function(o){function t(t,e,n){var r=o.call(this,e,n)||this;return r.moduleManager=t,r}return __extends(t,o),t.prototype.getModuleManager=function(){return this.moduleManager},t.prototype.resolvePluginFactory=function(t){var e=this;return Promise.resolve().then(function(){return installPluginContext(e.getModuleManager(),t)}).then(function(t){return o.prototype.resolvePluginFactory.call(e,t)})},t}(ContainerPluginDiscovery),ContainerPluginContextProcessorDiscovery=function(){function t(t,e){this.container=t,this.processorFactoryServiceId=e}return t.prototype.getContainer=function(){return this.container},t.prototype.getPluginContextProcessorFactoryServiceId=function(){return this.processorFactoryServiceId},t.prototype.getPluginContextProcessorFactoryFromContainer=function(t){var e=this.getPluginContextProcessorFactoryServiceId();return this.getContainer().getNamed(e,t.pluginTypeId)},t.prototype.resolvePluginContextProcessorFactory=function(t){var e=this;return Promise.resolve().then(function(){return e.getPluginContextProcessorFactoryFromContainer(t)})},t}(),ModulePluginContextProcessorDiscovery=function(o){function t(t,e,n){var r=o.call(this,e,n)||this;return r.moduleManager=t,r}return __extends(t,o),t.prototype.getModuleManager=function(){return this.moduleManager},t.prototype.resolvePluginContextProcessorFactory=function(t){var e=this;return Promise.resolve().then(function(){return installPluginContext(e.getModuleManager(),t)}).then(function(t){return o.prototype.resolvePluginContextProcessorFactory.call(e,t)})},t}(ContainerPluginContextProcessorDiscovery),PluginContextPipelineBase=function(){function t(t){this.processorDiscovery=t}return t.prototype.getProcessorDiscovery=function(){return this.processorDiscovery},t.prototype.process=function(e){var n=this;return this.getProcessorDiscovery().resolvePluginContextProcessorFactory(e).then(function(t){return t.createPluginContextProcessor(e)}).then(function(t){return t.process(e,n)})},t}(),PluginContextProcessorBase=function(){function t(){}return t.prototype.onPreProcess=function(t,e){return Promise.resolve(t)},t.prototype.onProcess=function(t,e){return Promise.resolve(t)},t.prototype.onPostProcess=function(t,e){return Promise.resolve(t)},t.prototype.process=function(t,e){var n=this;return Promise.resolve(t).then(function(t){return n.onPreProcess(t,e)}).then(function(t){return n.onProcess(t,e)}).then(function(t){return n.onPostProcess(t,e)})},t}();exports.ContainerPluginContextProcessorDiscovery=ContainerPluginContextProcessorDiscovery,exports.ContainerPluginDiscovery=ContainerPluginDiscovery,exports.ExtensiblePluginBase=ExtensiblePluginBase,exports.GenericPluginErrorEvent=GenericPluginErrorEvent,exports.GenericPluginEvent=GenericPluginEvent,exports.GenericPluginExtensionEvent=GenericPluginExtensionEvent,exports.HookablePluginExtensionManager=HookablePluginExtensionManager,exports.ModulePluginContextProcessorDiscovery=ModulePluginContextProcessorDiscovery,exports.ModulePluginDiscovery=ModulePluginDiscovery,exports.PluginBase=PluginBase,exports.PluginContextError=PluginContextError,exports.PluginContextPipelineBase=PluginContextPipelineBase,exports.PluginContextProcessorBase=PluginContextProcessorBase,exports.PluginError=PluginError,exports.PluginEventBase=PluginEventBase,exports.PluginExtensionManagerBase=PluginExtensionManagerBase,exports.PluginFactoryError=PluginFactoryError,exports.PluginManagerBase=PluginManagerBase,exports.extractPluginExtensionPathInfo=extractPluginExtensionPathInfo,exports.installPluginContext=installPluginContext,exports.installPluginModule=installPluginModule,exports.resolveNestedPluginExtensionSafe=resolveNestedPluginExtensionSafe,exports.resolveNestedPluginExtensionUnsafe=resolveNestedPluginExtensionUnsafe; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var vlWidgetUtility=require("@govflanders/vl-widget-utility"),vlWidgetEvent=require("@govflanders/vl-widget-event"),extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};function __extends(t,e){function n(){this.constructor=t}extendStatics(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function __awaiter(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{a(r.next(t))}catch(t){i(t)}}function u(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):new n(function(e){e(t.value)}).then(s,u)}a((r=r.apply(t,e||[])).next())})}function __generator(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=r[2&i[0]?"return":i[0]?"throw":"next"])&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[0,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var PluginEventBase=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(vlWidgetEvent.EventBase),GenericPluginEvent=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(PluginEventBase),GenericPluginExtensionEvent=function(t){function e(e,n,r,o){void 0===o&&(o=vlWidgetEvent.EventScope.Broadcast);var i=t.call(this,e,n,o)||this;return i.pluginExtension=r,i}return __extends(e,t),e.prototype.getExtension=function(){return this.pluginExtension},e}(PluginEventBase),GenericPluginErrorEvent=function(t){function e(e,n,r,o){void 0===o&&(o=vlWidgetEvent.EventScope.Broadcast);var i=t.call(this,e,n,o)||this;return i.error=r,i}return __extends(e,t),e.prototype.getError=function(){return this.error},e}(PluginEventBase),PluginManagerBase=function(){function t(t,e){this.pluginHost=t,this.pluginDiscovery=e,this.pluginRegistry=[]}return t.prototype.getPluginHost=function(){return this.pluginHost},t.prototype.getPluginDiscovery=function(){return this.pluginDiscovery},t.prototype.createPluginInstance=function(t){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(n){switch(n.label){case 0:return[4,this.getPluginDiscovery().resolvePluginFactory(t)];case 1:return[4,n.sent().createPluginInstance(this.getPluginHost(),t)];case 2:return[4,(e=n.sent()).initialize()];case 3:return n.sent(),this.pluginRegistry.push(e),[2,e]}})})},t.prototype.list=function(t){for(var e=[],n="function"==typeof t?t:null,r=0,o=this.pluginRegistry;r<o.length;r++){var i=o[r];(null===n||n(i))&&e.push(i)}return e},t.prototype.each=function(t){return __awaiter(this,void 0,void 0,function(){var e,n,r,o;return __generator(this,function(i){for(e=[],n=0,r=this.pluginRegistry;n<r.length;n++)o=r[n],e.push(t(o));return[2,Promise.all(e)]})})},t.prototype.has=function(t){return null!==this.get(t)},t.prototype.get=function(t){return this.pluginRegistry.find(function(e){return e.getPluginId()===t})||null},t}(),PluginExtensionManagerBase=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(PluginManagerBase),HookablePluginExtensionManager=function(){function t(t,e){this.pluginExtensionManager=t,this.createPluginInstanceCallback=e}return t.prototype.getPluginHost=function(){return this.pluginExtensionManager.getPluginHost()},t.prototype.getPluginDiscovery=function(){return this.pluginExtensionManager.getPluginDiscovery()},t.prototype.createPluginInstance=function(t){return this.pluginExtensionManager.createPluginInstance(t).then(this.createPluginInstanceCallback)},t.prototype.has=function(t){return this.pluginExtensionManager.has(t)},t.prototype.get=function(t){return this.pluginExtensionManager.get(t)},t.prototype.list=function(t){return this.pluginExtensionManager.list(t)},t.prototype.each=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,this.pluginExtensionManager.each(t)]})})},t}();!function(t){t.None="none",t.Initialize="initialize",t.Ready="ready",t.Failed="failed"}(exports.PluginState||(exports.PluginState={}));var PluginFactoryError=function(t){function e(n,r,o,i){void 0===i&&(i=null);var s=t.call(this,o,i)||this;return Object.setPrototypeOf(s,e.prototype),s.pluginHost=n,s.pluginContext=r,s}return __extends(e,t),e}(vlWidgetUtility.Error.RuntimeError),PluginContextError=function(t){function e(n,r,o){void 0===o&&(o=null);var i=t.call(this,r,o)||this;return Object.setPrototypeOf(i,e.prototype),i.pluginContext=n,i}return __extends(e,t),e}(vlWidgetUtility.Error.RuntimeError),PluginError=function(t){function e(n,r,o){void 0===o&&(o=null);var i=t.call(this,r,o)||this;return Object.setPrototypeOf(i,e.prototype),i.plugin=n,i}return __extends(e,t),e}(vlWidgetUtility.Error.RuntimeError),PluginBase=function(t){function e(e,n){var r=t.call(this)||this;return r.pluginHost=e,r.pluginContext=n,r.pluginState=exports.PluginState.None,r}return __extends(e,t),e.prototype.onBeforeInitialize=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return this.validatePluginContext(this.getPluginContext()),[2]})})},e.prototype.onInitialize=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2]})})},e.prototype.onBeforeReady=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2]})})},e.prototype.onReady=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2]})})},e.prototype.onFailed=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2]})})},e.prototype.onError=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2]})})},e.prototype.createHookEvent=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];switch(t){case"error":return new GenericPluginErrorEvent(t,this,e[0]);default:return new GenericPluginEvent(t,this)}},e.prototype.invokeHook=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return __awaiter(this,void 0,void 0,function(){var n,r,o,i;return __generator(this,function(s){switch(s.label){case 0:return t.length>0?(r=[],"function"==typeof this[o="on"+(t.charAt(0).toUpperCase()+t.slice(1))]&&r.push((n=this)[o].apply(n,e)),this.getPluginState()===exports.PluginState.Ready&&(i=this.createHookEvent.apply(this,[t].concat(e)),r.push(this.getEventEmitter().emit(i))),[4,Promise.all(r).then(function(){})]):[3,2];case 1:s.sent(),s.label=2;case 2:return[2]}})})},e.prototype.validatePluginContext=function(t){if("string"!=typeof t.pluginTypeId)throw new PluginError(this,'Context property "pluginTypeId" should be a string')},e.prototype.initialize=function(){var t=this;return void 0===this.pluginInitPromise?(this.pluginState=exports.PluginState.Initialize,this.pluginInitPromise=Promise.resolve().then(function(){return t.invokeHook("beforeInitialize")}).then(function(){return t.invokeHook("initialize")}).then(function(){return t.invokeHook("beforeReady")}).then(function(){return t.pluginState=exports.PluginState.Ready,t.invokeHook("ready")}).catch(function(e){return t.pluginState=exports.PluginState.Failed,t.invokeHook("failed",e).then(function(){return Promise.reject(e)})})):this.invokeHook("error",new PluginError(this,'Plugin "'+this.getPluginTypeId()+'" is being initialized multiple times')),this.pluginInitPromise},e.prototype.getPluginState=function(){return this.pluginState},e.prototype.getPluginHost=function(){return this.pluginHost},e.prototype.getPluginContext=function(){return this.pluginContext},e.prototype.getPluginTypeId=function(){return this.getPluginContext().pluginTypeId},e.prototype.toString=function(){return this.getPluginTypeId()+":"+this.getPluginId()},e}(vlWidgetEvent.EventSourceBase);!function(t){t.Internal="internal",t.Required="required",t.Optional="optional"}(exports.PluginExtensionConstraint||(exports.PluginExtensionConstraint={})),function(t){t.UnSafe="unsafe",t.Safe="safe"}(exports.PluginExtensionResolveMethod||(exports.PluginExtensionResolveMethod={}));var ExtensiblePluginBase=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.extensionPromiseCache={},r}return __extends(e,t),e.prototype.createHookEvent=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];switch(e){case"extension":return new GenericPluginExtensionEvent(e,this,n[0]);default:return t.prototype.createHookEvent.apply(this,[e].concat(n))}},e.prototype.onBeforeReady=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,t.prototype.onBeforeReady.call(this)];case 1:return e.sent(),[4,this.createExtensionsByConstraint(exports.PluginExtensionConstraint.Internal)];case 2:return e.sent(),[2]}})})},e.prototype.onReady=function(){return __awaiter(this,void 0,void 0,function(){var e=this;return __generator(this,function(n){switch(n.label){case 0:return[4,t.prototype.onReady.call(this)];case 1:return n.sent(),[4,this.createExtensionsByConstraint(exports.PluginExtensionConstraint.Required)];case 2:return n.sent(),this.createExtensionsByConstraint(exports.PluginExtensionConstraint.Optional).catch(function(t){return e.invokeHook("error",t)}),[2]}})})},e.prototype.onExtension=function(t){return __awaiter(this,void 0,void 0,function(){var e,n;return __generator(this,function(r){return e=t.getPluginId(),null!==(n=this.extensionPromiseCache[e]||null)&&null!==n.resolve&&(n.resolve(t),delete this.extensionPromiseCache[e]),[2]})})},e.prototype.createExtensionsByConstraint=function(t){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(n){switch(n.label){case 0:return[4,this.resolveExtensionContexts(t)];case 1:return e=n.sent(),[2,this.createExtensionsByContexts(e)]}})})},e.prototype.createExtensionsByContexts=function(t){var e=this;return Promise.resolve().then(function(){for(var n=[],r=e.getExtensionManager(),o=0,i=t;o<i.length;o++){var s=i[o],u=r.createPluginInstance(s);n.push(u)}return Promise.all(n)})},e.prototype.getExtensionManager=function(){var t=this;if(void 0===this.extensionManager){var e=this.createExtensionManager();this.extensionManager=new HookablePluginExtensionManager(e,function(e){return t.invokeHook("extension",e).then(function(){return e})})}return this.extensionManager},e.prototype.getExtensionSafe=function(t){var e=this;return Promise.resolve().then(function(){return e.tryGetExtensionUnsafe(t)}).then(function(n){if(null===n){var r=e.extensionPromiseCache[t]||null;return null!==r&&null!==r.promise||((r=e.extensionPromiseCache[t]={promise:null,resolve:null}).promise=new Promise(function(t){r.resolve=t})),r.promise}return n})},e.prototype.tryGetExtensionUnsafe=function(t){if(this.getPluginState()!==exports.PluginState.Ready)throw new vlWidgetUtility.Error.RuntimeError('Cannot retrieve "'+t+'" extension as plugin is not ready');return this.getExtensionManager().get(t)},e.prototype.getExtensionUnsafe=function(t){var e=this.tryGetExtensionUnsafe(t);if(null===e)throw new vlWidgetUtility.Error.RuntimeError('Failed to resolve "'+t+'" extension');return e},e.prototype.getExtension=function(t,e){void 0===e&&(e=exports.PluginExtensionResolveMethod.Safe);var n=extractPluginExtensionPathInfo(t);switch(e){case exports.PluginExtensionResolveMethod.UnSafe:return resolveNestedPluginExtensionUnsafe(this.getExtensionUnsafe(n.id),n.nested);default:return this.getExtensionSafe(n.id).then(function(t){return resolveNestedPluginExtensionSafe(t,n.nested)})}},e}(PluginBase);function extractPluginExtensionPathInfo(t){var e=t.split(".");return{id:e.shift()||"",nested:e.join(".")||null}}function resolveNestedPluginExtensionUnsafe(t,e){if(e){if("function"!=typeof t.getExtension)throw new vlWidgetUtility.Error.RuntimeError('Plugin "'+t.getPluginId()+'" does not support retrieving nested extensions');return t.getExtension(e,exports.PluginExtensionResolveMethod.UnSafe)}return t}function resolveNestedPluginExtensionSafe(t,e){if(e){if("function"!=typeof t.getExtension)throw new vlWidgetUtility.Error.RuntimeError('Plugin "'+t.getPluginId()+'" does not support retrieving nested extensions');return t.getExtension(e,exports.PluginExtensionResolveMethod.Safe)}return Promise.resolve(t)}function installPluginModule(t,e){return Promise.resolve().then(function(){switch(_typeof(e)){case"string":return t.import(e);default:return e}}).then(function(e){return t.install(e)})}function installPluginContext(t,e){return Promise.resolve().then(function(){var n=e.pluginModule||null;return installPluginModule(t,n)}).then(function(){return e})}var ContainerPluginDiscovery=function(){function t(t,e){this.container=t,this.pluginFactoryServiceId=e}return t.prototype.getContainer=function(){return this.container},t.prototype.getPluginFactoryServiceId=function(){return this.pluginFactoryServiceId},t.prototype.getPluginFactoryFromContainer=function(t){var e=this.getPluginFactoryServiceId();return this.getContainer().getNamed(e,t.pluginTypeId)},t.prototype.resolvePluginFactory=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,this.getPluginFactoryFromContainer(t)]})})},t}(),ModulePluginDiscovery=function(t){function e(e,n,r){var o=t.call(this,n,r)||this;return o.moduleManager=e,o}return __extends(e,t),e.prototype.getModuleManager=function(){return this.moduleManager},e.prototype.resolvePluginFactory=function(e){return __awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(r){switch(r.label){case 0:return[4,installPluginContext(this.getModuleManager(),e)];case 1:return n=r.sent(),[2,t.prototype.resolvePluginFactory.call(this,n)]}})})},e}(ContainerPluginDiscovery),ContainerPluginContextProcessorDiscovery=function(){function t(t,e){this.container=t,this.processorFactoryServiceId=e}return t.prototype.getContainer=function(){return this.container},t.prototype.getPluginContextProcessorFactoryServiceId=function(){return this.processorFactoryServiceId},t.prototype.getPluginContextProcessorFactoryFromContainer=function(t){var e=this.getPluginContextProcessorFactoryServiceId();return this.getContainer().getNamed(e,t.pluginTypeId)},t.prototype.resolvePluginContextProcessorFactory=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,this.getPluginContextProcessorFactoryFromContainer(t)]})})},t}(),ModulePluginContextProcessorDiscovery=function(t){function e(e,n,r){var o=t.call(this,n,r)||this;return o.moduleManager=e,o}return __extends(e,t),e.prototype.getModuleManager=function(){return this.moduleManager},e.prototype.resolvePluginContextProcessorFactory=function(e){var n=this;return Promise.resolve().then(function(){return installPluginContext(n.getModuleManager(),e)}).then(function(e){return t.prototype.resolvePluginContextProcessorFactory.call(n,e)})},e}(ContainerPluginContextProcessorDiscovery),PluginContextPipelineBase=function(){function t(t){this.processorDiscovery=t}return t.prototype.getProcessorDiscovery=function(){return this.processorDiscovery},t.prototype.process=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,this.getProcessorDiscovery().resolvePluginContextProcessorFactory(t)];case 1:return[4,e.sent().createPluginContextProcessor(t)];case 2:return[2,e.sent().process(t,this)]}})})},t}(),PluginContextProcessorBase=function(){function t(){}return t.prototype.onPreProcess=function(t,e){return Promise.resolve(t)},t.prototype.onProcess=function(t,e){return Promise.resolve(t)},t.prototype.onPostProcess=function(t,e){return Promise.resolve(t)},t.prototype.process=function(t,e){var n=this;return Promise.resolve(t).then(function(t){return n.onPreProcess(t,e)}).then(function(t){return n.onProcess(t,e)}).then(function(t){return n.onPostProcess(t,e)})},t}();exports.ContainerPluginContextProcessorDiscovery=ContainerPluginContextProcessorDiscovery,exports.ContainerPluginDiscovery=ContainerPluginDiscovery,exports.ExtensiblePluginBase=ExtensiblePluginBase,exports.GenericPluginErrorEvent=GenericPluginErrorEvent,exports.GenericPluginEvent=GenericPluginEvent,exports.GenericPluginExtensionEvent=GenericPluginExtensionEvent,exports.HookablePluginExtensionManager=HookablePluginExtensionManager,exports.ModulePluginContextProcessorDiscovery=ModulePluginContextProcessorDiscovery,exports.ModulePluginDiscovery=ModulePluginDiscovery,exports.PluginBase=PluginBase,exports.PluginContextError=PluginContextError,exports.PluginContextPipelineBase=PluginContextPipelineBase,exports.PluginContextProcessorBase=PluginContextProcessorBase,exports.PluginError=PluginError,exports.PluginEventBase=PluginEventBase,exports.PluginExtensionManagerBase=PluginExtensionManagerBase,exports.PluginFactoryError=PluginFactoryError,exports.PluginManagerBase=PluginManagerBase,exports.extractPluginExtensionPathInfo=extractPluginExtensionPathInfo,exports.installPluginContext=installPluginContext,exports.installPluginModule=installPluginModule,exports.resolveNestedPluginExtensionSafe=resolveNestedPluginExtensionSafe,exports.resolveNestedPluginExtensionUnsafe=resolveNestedPluginExtensionUnsafe; |
{ | ||
"name": "@govflanders/vl-widget-plugin", | ||
"version": "1.2.2", | ||
"version": "1.3.2-0", | ||
"license": "MIT", | ||
@@ -24,9 +24,10 @@ "contributors": [ | ||
"main": "dist/index.js", | ||
"module": "dist/index.esm.js", | ||
"typings": "types/index.d.ts", | ||
"dependencies": { | ||
"@govflanders/vl-widget-dependency-injection": "^1.2.2", | ||
"@govflanders/vl-widget-event": "^1.2.2", | ||
"@govflanders/vl-widget-module": "^1.2.2", | ||
"@govflanders/vl-widget-utility": "^1.2.2" | ||
"@govflanders/vl-widget-dependency-injection": "^1.3.2-0", | ||
"@govflanders/vl-widget-event": "^1.3.2-0", | ||
"@govflanders/vl-widget-module": "^1.3.2-0", | ||
"@govflanders/vl-widget-utility": "^1.3.2-0" | ||
} | ||
} |
@@ -144,7 +144,7 @@ import { PluginContext } from './context'; | ||
*/ | ||
protected onBeforeReady(): Promise<this>; | ||
protected onBeforeReady(): Promise<void>; | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected onReady(): Promise<this>; | ||
protected onReady(): Promise<void>; | ||
/** | ||
@@ -156,3 +156,3 @@ * Handle tasks after a extension was created. | ||
*/ | ||
protected onExtension(extension: Plugin<PluginExtensionHost<PluginRuntimeType>, PluginContext, PluginRuntimeType>): Promise<this>; | ||
protected onExtension(extension: Plugin<PluginExtensionHost<PluginRuntimeType>, PluginContext, PluginRuntimeType>): Promise<void>; | ||
/** | ||
@@ -159,0 +159,0 @@ * Resolve the extension contexts. |
@@ -23,6 +23,6 @@ import { EventSourceBase, EventEmitter } from '@govflanders/vl-widget-event'; | ||
* | ||
* @return {Promise<this>} | ||
* @return {Promise<void>} | ||
* A promise to initialize the plugin. | ||
*/ | ||
initialize(): Promise<this>; | ||
initialize(): Promise<void>; | ||
/** | ||
@@ -88,5 +88,5 @@ * Get the current plugin state. | ||
* | ||
* @var {Promise<this>} | ||
* @var {Promise<void>} | ||
*/ | ||
protected pluginInitPromise: Promise<this> | undefined; | ||
protected pluginInitPromise: Promise<void> | undefined; | ||
/** | ||
@@ -107,31 +107,34 @@ * Create a PluginBase object. | ||
* | ||
* @return {Promise<this>} | ||
* @return {Promise<void>} | ||
* A promise to perform the task. | ||
*/ | ||
protected onBeforeInitialize(): Promise<this>; | ||
protected onBeforeInitialize(): Promise<void>; | ||
/** | ||
* Handle task to initialize the plugin. | ||
* | ||
* @return {Promise<this>} | ||
* @return {Promise<void>} | ||
* A promise to perform the task. | ||
*/ | ||
protected onInitialize(): Promise<this>; | ||
protected onInitialize(): Promise<void>; | ||
/** | ||
* Handle task when plugin is about to transition to ready. | ||
* | ||
* @return {Promise<this>} | ||
* @return {Promise<void>} | ||
* A promise to perform the task. | ||
*/ | ||
protected onBeforeReady(): Promise<this>; | ||
protected onBeforeReady(): Promise<void>; | ||
/** | ||
* Handle task when plugin transitioned to ready. | ||
* | ||
* @return {Promise<this>} | ||
* @return {Promise<void>} | ||
* A promise to perform the task. | ||
*/ | ||
protected onReady(): Promise<this>; | ||
protected onReady(): Promise<void>; | ||
/** | ||
* Handle task when plugin transitioned to failure. | ||
* | ||
* @return {Promise<void>} | ||
* A promise to perform the task. | ||
*/ | ||
protected onFailed(): Promise<this>; | ||
protected onFailed(): Promise<void>; | ||
/** | ||
@@ -143,6 +146,6 @@ * Handle tasks when plugin triggers an error. | ||
* | ||
* @return {Promise<this>} | ||
* @return {Promise<void>} | ||
* A promise to perform the task. | ||
*/ | ||
protected onError(error: Error): Promise<this>; | ||
protected onError(error: Error): Promise<void>; | ||
/** | ||
@@ -168,6 +171,6 @@ * Create an event for given plugin hook. | ||
* | ||
* @return {Promise<this>} | ||
* @return {Promise<void>} | ||
* A promise to invoke a hook. | ||
*/ | ||
protected invokeHook(hook: string, ...args: any[]): Promise<this>; | ||
protected invokeHook(hook: string, ...args: any[]): Promise<void>; | ||
/** | ||
@@ -189,3 +192,3 @@ * Validate the plugin context. | ||
*/ | ||
initialize(): Promise<this>; | ||
initialize(): Promise<void>; | ||
/** | ||
@@ -192,0 +195,0 @@ * {@inheritdoc} |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
82151
24
1524
3