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>
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
/*
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
Author Natsu @xiaoxiaojx
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
// data URL scheme: "data:text/javascript;charset=utf-8;base64,some-string"
|
|
// http://www.ietf.org/rfc/rfc2397.txt
|
|
const URIRegEx = /^data:([^;,]+)?((?:;[^;,]+)*?)(?:;(base64)?)?,(.*)$/i;
|
|
|
|
/**
|
|
* Decodes the provided uri.
|
|
* @param {string} uri data URI
|
|
* @returns {Buffer | null} decoded data
|
|
*/
|
|
const decodeDataURI = (uri) => {
|
|
const match = URIRegEx.exec(uri);
|
|
if (!match) return null;
|
|
|
|
const isBase64 = match[3];
|
|
const body = match[4];
|
|
|
|
if (isBase64) {
|
|
return Buffer.from(body, "base64");
|
|
}
|
|
|
|
// CSS allows to use `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="stroke: rgb(223,224,225); stroke-width: 2px; fill: none; stroke-dasharray: 6px 3px" /></svg>`
|
|
// so we return original body if we can't `decodeURIComponent`
|
|
try {
|
|
return Buffer.from(decodeURIComponent(body), "ascii");
|
|
} catch (_) {
|
|
return Buffer.from(body, "ascii");
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
URIRegEx,
|
|
decodeDataURI
|
|
};
|