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>
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = createRuntime;
|
|
var _rungen = require("rungen");
|
|
var _isPromise = _interopRequireDefault(require("is-promise"));
|
|
var _isAction = require("./is-action");
|
|
/**
|
|
* External dependencies
|
|
*/
|
|
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
|
|
/**
|
|
* Create a co-routine runtime.
|
|
*
|
|
* @param controls Object of control handlers.
|
|
* @param dispatch Unhandled action dispatch.
|
|
*/
|
|
function createRuntime(controls = {}, dispatch) {
|
|
const rungenControls = Object.entries(controls).map(([actionType, control]) => (value, next, iterate, yieldNext, yieldError) => {
|
|
if (!(0, _isAction.isActionOfType)(value, actionType)) {
|
|
return false;
|
|
}
|
|
const routine = control(value);
|
|
if ((0, _isPromise.default)(routine)) {
|
|
// Async control routine awaits resolution.
|
|
routine.then(yieldNext, yieldError);
|
|
} else {
|
|
yieldNext(routine);
|
|
}
|
|
return true;
|
|
});
|
|
const unhandledActionControl = (value, next) => {
|
|
if (!(0, _isAction.isAction)(value)) {
|
|
return false;
|
|
}
|
|
dispatch(value);
|
|
next();
|
|
return true;
|
|
};
|
|
rungenControls.push(unhandledActionControl);
|
|
const rungenRuntime = (0, _rungen.create)(rungenControls);
|
|
return action => new Promise((resolve, reject) => rungenRuntime(action, result => {
|
|
if ((0, _isAction.isAction)(result)) {
|
|
dispatch(result);
|
|
}
|
|
resolve(result);
|
|
}, reject));
|
|
}
|
|
//# sourceMappingURL=runtime.js.map
|