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>
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
import AxiosError from '../core/AxiosError.js';
|
|
import parseProtocol from './parseProtocol.js';
|
|
import platform from '../platform/index.js';
|
|
|
|
const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
|
|
|
|
/**
|
|
* Parse data uri to a Buffer or Blob
|
|
*
|
|
* @param {String} uri
|
|
* @param {?Boolean} asBlob
|
|
* @param {?Object} options
|
|
* @param {?Function} options.Blob
|
|
*
|
|
* @returns {Buffer|Blob}
|
|
*/
|
|
export default function fromDataURI(uri, asBlob, options) {
|
|
const _Blob = (options && options.Blob) || platform.classes.Blob;
|
|
const protocol = parseProtocol(uri);
|
|
|
|
if (asBlob === undefined && _Blob) {
|
|
asBlob = true;
|
|
}
|
|
|
|
if (protocol === 'data') {
|
|
uri = protocol.length ? uri.slice(protocol.length + 1) : uri;
|
|
|
|
const match = DATA_URL_PATTERN.exec(uri);
|
|
|
|
if (!match) {
|
|
throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
|
|
}
|
|
|
|
const mime = match[1];
|
|
const isBase64 = match[2];
|
|
const body = match[3];
|
|
const buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8');
|
|
|
|
if (asBlob) {
|
|
if (!_Blob) {
|
|
throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
|
|
}
|
|
|
|
return new _Blob([buffer], { type: mime });
|
|
}
|
|
|
|
return buffer;
|
|
}
|
|
|
|
throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
|
|
}
|