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>
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
"use strict";
|
|
|
|
/** @typedef {import("./index.js").MinimizedResult} MinimizedResult */
|
|
/** @typedef {import("./index.js").CustomOptions} CustomOptions */
|
|
|
|
/**
|
|
* @template T
|
|
* @param {import("./index.js").InternalOptions<T>} options options
|
|
* @returns {Promise<MinimizedResult>} minified result
|
|
*/
|
|
async function minify(options) {
|
|
const {
|
|
name,
|
|
input,
|
|
inputSourceMap,
|
|
extractComments
|
|
} = options;
|
|
const {
|
|
implementation,
|
|
options: minimizerOptions
|
|
} = options.minimizer;
|
|
return implementation({
|
|
[name]: input
|
|
}, inputSourceMap, minimizerOptions, extractComments);
|
|
}
|
|
|
|
/**
|
|
* @param {string} options options
|
|
* @returns {Promise<MinimizedResult>} minified result
|
|
*/
|
|
async function transform(options) {
|
|
// 'use strict' => this === undefined (Clean Scope)
|
|
// Safer for possible security issues, albeit not critical at all here
|
|
|
|
const evaluatedOptions =
|
|
/**
|
|
* @template T
|
|
* @type {import("./index.js").InternalOptions<T>}
|
|
*/
|
|
|
|
// eslint-disable-next-line no-new-func
|
|
new Function("exports", "require", "module", "__filename", "__dirname", `'use strict'\nreturn ${options}`) // eslint-disable-next-line n/exports-style
|
|
(exports, require, module, __filename, __dirname);
|
|
return minify(evaluatedOptions);
|
|
}
|
|
module.exports = {
|
|
minify,
|
|
transform
|
|
}; |