From bf6ab3bba8402d8afa34bda40496caa5160b3bda Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 13 Aug 2021 21:06:41 -0400 Subject: [PATCH] plugins: Don't load plugin defs in inner window They're not used there. --- src/static/js/ace.js | 7 ------ src/static/js/pluginfw/client_plugins.js | 32 ------------------------ 2 files changed, 39 deletions(-) diff --git a/src/static/js/ace.js b/src/static/js/ace.js index b0a042570..1ebd16505 100644 --- a/src/static/js/ace.js +++ b/src/static/js/ace.js @@ -293,16 +293,9 @@ const Ace2Editor = function () { require.setLibraryURI(absUrl('../javascripts/lib')); require.setGlobalKeyPath('require'); - // intentially moved before requiring client_plugins to save a 307 innerWindow.Ace2Inner = require('ep_etherpad-lite/static/js/ace2_inner'); - innerWindow.plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins'); - innerWindow.plugins.adoptPluginsFromAncestorsOf(innerWindow); - innerWindow.$ = innerWindow.jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery; - debugLog('Ace2Editor.init() waiting for plugins'); - await new Promise((resolve, reject) => innerWindow.plugins.ensure( - (err) => err != null ? reject(err) : resolve())); debugLog('Ace2Editor.init() waiting for Ace2Inner.init()'); await innerWindow.Ace2Inner.init(info, { inner: makeCSSManager(innerStyle.sheet), diff --git a/src/static/js/pluginfw/client_plugins.js b/src/static/js/pluginfw/client_plugins.js index 221e786f8..b9447a0d0 100644 --- a/src/static/js/pluginfw/client_plugins.js +++ b/src/static/js/pluginfw/client_plugins.js @@ -5,8 +5,6 @@ const defs = require('./plugin_defs'); exports.baseURL = ''; -exports.ensure = (cb) => !defs.loaded ? exports.update(cb) : cb(); - exports.update = (cb) => { // It appears that this response (see #620) may interrupt the current thread // of execution on Firefox. This schedules the response in the run-loop, @@ -26,33 +24,3 @@ exports.update = (cb) => { callback(); }); }; - -const adoptPluginsFromAncestorsOf = (frame) => { - // Bind plugins with parent; - let parentRequire = null; - try { - while ((frame = frame.parent)) { - if (typeof (frame.require) !== 'undefined') { - parentRequire = frame.require; - break; - } - } - } catch (error) { - // Silence (this can only be a XDomain issue). - console.error(error); - } - - if (!parentRequire) throw new Error('Parent plugins could not be found.'); - - const ancestorPluginDefs = parentRequire('ep_etherpad-lite/static/js/pluginfw/plugin_defs'); - defs.hooks = ancestorPluginDefs.hooks; - defs.loaded = ancestorPluginDefs.loaded; - defs.parts = ancestorPluginDefs.parts; - defs.plugins = ancestorPluginDefs.plugins; - const ancestorPlugins = parentRequire('ep_etherpad-lite/static/js/pluginfw/client_plugins'); - exports.baseURL = ancestorPlugins.baseURL; - exports.ensure = ancestorPlugins.ensure; - exports.update = ancestorPlugins.update; -}; - -exports.adoptPluginsFromAncestorsOf = adoptPluginsFromAncestorsOf;