mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Add depreaction warning for hterm css
* Notify user when its config conatins deprecated CSS classes * Add warning in devtools console about plugins using deprecated classes
This commit is contained in:
parent
c91c025edd
commit
a9bb9b697b
3 changed files with 58 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ const _watch = function () {
|
|||
cfg = _import();
|
||||
notify('Configuration updated', 'Hyper configuration reloaded!');
|
||||
watchers.forEach(fn => fn());
|
||||
checkDeprecatedConfig()
|
||||
});
|
||||
|
||||
_watcher.on('error', error => {
|
||||
|
|
@ -70,7 +71,38 @@ exports.extendKeymaps = function (keymaps) {
|
|||
exports.setup = function () {
|
||||
cfg = _import();
|
||||
_watch();
|
||||
checkDeprecatedConfig()
|
||||
};
|
||||
|
||||
exports.getWin = win.get;
|
||||
exports.winRecord = win.recordState;
|
||||
|
||||
const getDeprecatedCSS = function (config) {
|
||||
const deprecated = [];
|
||||
const deprecatedCSS = [
|
||||
'x-screen',
|
||||
'x-row',
|
||||
'cursor-node',
|
||||
'::selection'
|
||||
];
|
||||
deprecatedCSS.forEach(css => {
|
||||
if ((config.css && config.css.indexOf(css) !== -1) ||
|
||||
(config.termCSS && config.termCSS.indexOf(css) !== -1)) {
|
||||
deprecated.push(css);
|
||||
}
|
||||
})
|
||||
return deprecated;
|
||||
}
|
||||
exports.getDeprecatedCSS = getDeprecatedCSS;
|
||||
|
||||
const checkDeprecatedConfig = function () {
|
||||
if (!cfg.config) {
|
||||
return;
|
||||
}
|
||||
const deprecated = getDeprecatedCSS(cfg.config);
|
||||
if (deprecated.length === 0) {
|
||||
return;
|
||||
}
|
||||
const deprecatedStr = deprecated.join(', ');
|
||||
notify('Configuration warning', `Your configuration uses some deprecated CSS classes (${deprecatedStr})`)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -304,6 +304,24 @@ exports.extendKeymaps = function () {
|
|||
});
|
||||
};
|
||||
|
||||
exports.getDeprecatedConfig = () => {
|
||||
const deprecated = {};
|
||||
const baseConfig = config.getConfig();
|
||||
modules.forEach(plugin => {
|
||||
if (!plugin.decorateConfig) {
|
||||
return;
|
||||
}
|
||||
// We need to clone config in case of plugin modifies config directly.
|
||||
const configTmp = plugin.decorateConfig(JSON.parse(JSON.stringify(baseConfig)));
|
||||
const pluginCSSDeprecated = config.getDeprecatedCSS(configTmp);
|
||||
if (pluginCSSDeprecated.length === 0) {
|
||||
return;
|
||||
}
|
||||
deprecated[plugin._name] = {css: pluginCSSDeprecated};
|
||||
})
|
||||
return deprecated;
|
||||
}
|
||||
|
||||
exports.decorateMenu = function (tpl) {
|
||||
return decorateObject(tpl, 'decorateMenu');
|
||||
};
|
||||
|
|
|
|||
|
|
@ -228,6 +228,14 @@ const loadModules = () => {
|
|||
return mod;
|
||||
})
|
||||
.filter(mod => Boolean(mod));
|
||||
|
||||
const deprecatedPlugins = plugins.getDeprecatedConfig();
|
||||
Object.keys(deprecatedPlugins).forEach(name => {
|
||||
const { css } = deprecatedPlugins[name];
|
||||
if (css) {
|
||||
console.warn(`Warning: "${name}" plugin uses some deprecated CSS classes (${css.join(', ')}).`);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// load modules for initial decoration
|
||||
|
|
|
|||
Loading…
Reference in a new issue