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>
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = void 0;
|
|
/**
|
|
* Set of HTTP methods which are eligible to be overridden.
|
|
*
|
|
* @type {Set<string>}
|
|
*/
|
|
const OVERRIDE_METHODS = new Set(['PATCH', 'PUT', 'DELETE']);
|
|
|
|
/**
|
|
* Default request method.
|
|
*
|
|
* "A request has an associated method (a method). Unless stated otherwise it
|
|
* is `GET`."
|
|
*
|
|
* @see https://fetch.spec.whatwg.org/#requests
|
|
*
|
|
* @type {string}
|
|
*/
|
|
const DEFAULT_METHOD = 'GET';
|
|
|
|
/**
|
|
* API Fetch middleware which overrides the request method for HTTP v1
|
|
* compatibility leveraging the REST API X-HTTP-Method-Override header.
|
|
*
|
|
* @type {import('../types').APIFetchMiddleware}
|
|
*/
|
|
const httpV1Middleware = (options, next) => {
|
|
const {
|
|
method = DEFAULT_METHOD
|
|
} = options;
|
|
if (OVERRIDE_METHODS.has(method.toUpperCase())) {
|
|
options = {
|
|
...options,
|
|
headers: {
|
|
...options.headers,
|
|
'X-HTTP-Method-Override': method,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
method: 'POST'
|
|
};
|
|
}
|
|
return next(options);
|
|
};
|
|
var _default = exports.default = httpV1Middleware;
|
|
//# sourceMappingURL=http-v1.js.map
|