Add coexistence checks to all enqueue methods to prevent loading both React and Grid.js assets simultaneously. Changes: - ReactAdmin.php: Only enqueue React assets when ?react=1 - Init.php: Skip Grid.js when React active on admin pages - Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0 - Customer.php, Product.php, License.php: Add coexistence checks Now the toggle between Classic and React versions works correctly. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
62 lines
1.7 KiB
JavaScript
62 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
const { visit } = require('../xast.js');
|
|
|
|
/**
|
|
* Plugins engine.
|
|
*
|
|
* @module plugins
|
|
*
|
|
* @param {Object} ast input ast
|
|
* @param {Object} info extra information
|
|
* @param {Array} plugins plugins object from config
|
|
* @return {Object} output ast
|
|
*/
|
|
const invokePlugins = (ast, info, plugins, overrides, globalOverrides) => {
|
|
for (const plugin of plugins) {
|
|
const override = overrides?.[plugin.name];
|
|
if (override === false) {
|
|
continue;
|
|
}
|
|
const params = { ...plugin.params, ...globalOverrides, ...override };
|
|
|
|
const visitor = plugin.fn(ast, params, info);
|
|
if (visitor != null) {
|
|
visit(ast, visitor);
|
|
}
|
|
}
|
|
};
|
|
exports.invokePlugins = invokePlugins;
|
|
|
|
const createPreset = ({ name, plugins }) => {
|
|
return {
|
|
name,
|
|
fn: (ast, params, info) => {
|
|
const { floatPrecision, overrides } = params;
|
|
const globalOverrides = {};
|
|
if (floatPrecision != null) {
|
|
globalOverrides.floatPrecision = floatPrecision;
|
|
}
|
|
if (overrides) {
|
|
const pluginNames = plugins.map(({ name }) => name);
|
|
for (const pluginName of Object.keys(overrides)) {
|
|
if (!pluginNames.includes(pluginName)) {
|
|
console.warn(
|
|
`You are trying to configure ${pluginName} which is not part of ${name}.\n` +
|
|
`Try to put it before or after, for example\n\n` +
|
|
`plugins: [\n` +
|
|
` {\n` +
|
|
` name: '${name}',\n` +
|
|
` },\n` +
|
|
` '${pluginName}'\n` +
|
|
`]\n`,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
invokePlugins(ast, info, plugins, overrides, globalOverrides);
|
|
},
|
|
};
|
|
};
|
|
exports.createPreset = createPreset;
|