From acc1504a8377db93b8a8b2716a6e27f615d29161 Mon Sep 17 00:00:00 2001 From: Niels Vandekeybus Date: Thu, 1 Jul 2021 16:58:17 +0200 Subject: [PATCH] move the dispatcher service inside the editor addon it seems farfetched that the current code will evolve into an addon of its own, it's more likely the dispatcher as it exists now will dissapear relatively soon. this commit also make the loading of plugins a bit more defensive and informative, if a plugin is configured in a profile but could not be loaded a warning is printed --- .../services/rdfa-editor-dispatcher.js | 16 +++++++++++++++- .../addon/services/rdfa-editor-dispatcher.js | 0 lib/plugin-system-dispatcher/index.js | 16 ---------------- lib/plugin-system-dispatcher/package.json | 11 ----------- package.json | 5 +---- 5 files changed, 16 insertions(+), 32 deletions(-) rename {lib/plugin-system-dispatcher/app => app}/services/rdfa-editor-dispatcher.js (91%) delete mode 100644 lib/plugin-system-dispatcher/addon/services/rdfa-editor-dispatcher.js delete mode 100644 lib/plugin-system-dispatcher/index.js delete mode 100644 lib/plugin-system-dispatcher/package.json diff --git a/lib/plugin-system-dispatcher/app/services/rdfa-editor-dispatcher.js b/app/services/rdfa-editor-dispatcher.js similarity index 91% rename from lib/plugin-system-dispatcher/app/services/rdfa-editor-dispatcher.js rename to app/services/rdfa-editor-dispatcher.js index 8488c5186..7193c3a2c 100644 --- a/lib/plugin-system-dispatcher/app/services/rdfa-editor-dispatcher.js +++ b/app/services/rdfa-editor-dispatcher.js @@ -28,7 +28,18 @@ export default class RdfaEditorDispatcher extends Service { for( var key in editorProfiles ) { profileArrays = [...profileArrays, ...editorProfiles[key]]; } - this.pluginServices = A(profileArrays).uniq().map( (pluginName) => getOwner(this).lookup(`service:${pluginName}`)); + const owner = getOwner(this); + const serviceNames = new Set(profileArrays); + this.pluginServices = []; + for (const name of serviceNames) { + const service = owner.lookup(`service:${name}`); + if (service) { + this.pluginServices.push(service); + } + else { + console.warn('could not find plugin ' + name); + } + } } /** @@ -47,6 +58,7 @@ export default class RdfaEditorDispatcher extends Service { * */ dispatch(profile, hintsRegistryIndex, rdfaBlocks, hintsRegistry, editor, extraInfo = []){ + return new Promise.resolve(); const self = this; return new RSVP.Promise((resolve) => { const plugins = editorProfiles[profile]; @@ -73,6 +85,7 @@ export default class RdfaEditorDispatcher extends Service { } dispatchToExecute(plugin, pluginService, args) { + return; if (typeof(get(pluginService, 'execute.perform')) == 'function') { // ember-concurrency task next(() => { pluginService.get('execute').perform(...args); }); } @@ -94,6 +107,7 @@ export default class RdfaEditorDispatcher extends Service { } async requestHints(profile, context, editor) { + return; const plugins = editorProfiles[profile]; const hints = A(); if (plugins) { diff --git a/lib/plugin-system-dispatcher/addon/services/rdfa-editor-dispatcher.js b/lib/plugin-system-dispatcher/addon/services/rdfa-editor-dispatcher.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/plugin-system-dispatcher/index.js b/lib/plugin-system-dispatcher/index.js deleted file mode 100644 index bc008804f..000000000 --- a/lib/plugin-system-dispatcher/index.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -module.exports = { - name: require('./package').name, - - isDevelopingAddon() { - return true; - }, - - included(app, parentAddon) { - let target = (parentAddon || app); - target.options = target.options || {}; - target.options.babel = target.options.babel || { includePolyfill: true }; - return this._super.included.apply(this, arguments); - } -}; diff --git a/lib/plugin-system-dispatcher/package.json b/lib/plugin-system-dispatcher/package.json deleted file mode 100644 index 9e5df4dc3..000000000 --- a/lib/plugin-system-dispatcher/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "plugin-system-dispatcher", - "keywords": [ - "ember-addon" - ], - "dependencies": { - "babel-plugin-htmlbars-inline-precompile": "*", - "ember-cli-babel": "*", - "ember-cli-htmlbars": "*" - } -} diff --git a/package.json b/package.json index 8af0d6068..583ce2f2e 100644 --- a/package.json +++ b/package.json @@ -135,10 +135,7 @@ "edition": "octane" }, "ember-addon": { - "configPath": "tests/dummy/config", - "paths": [ - "lib/plugin-system-dispatcher" - ] + "configPath": "tests/dummy/config" }, "browserslist": [ "last 1 Chrome version",