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
/**
|
|
* External dependencies
|
|
*/
|
|
|
|
import { create } from 'rungen';
|
|
import isPromise from 'is-promise';
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
import { isActionOfType, isAction } from './is-action';
|
|
|
|
/**
|
|
* Create a co-routine runtime.
|
|
*
|
|
* @param controls Object of control handlers.
|
|
* @param dispatch Unhandled action dispatch.
|
|
*/
|
|
export default function createRuntime(controls = {}, dispatch) {
|
|
const rungenControls = Object.entries(controls).map(([actionType, control]) => (value, next, iterate, yieldNext, yieldError) => {
|
|
if (!isActionOfType(value, actionType)) {
|
|
return false;
|
|
}
|
|
const routine = control(value);
|
|
if (isPromise(routine)) {
|
|
// Async control routine awaits resolution.
|
|
routine.then(yieldNext, yieldError);
|
|
} else {
|
|
yieldNext(routine);
|
|
}
|
|
return true;
|
|
});
|
|
const unhandledActionControl = (value, next) => {
|
|
if (!isAction(value)) {
|
|
return false;
|
|
}
|
|
dispatch(value);
|
|
next();
|
|
return true;
|
|
};
|
|
rungenControls.push(unhandledActionControl);
|
|
const rungenRuntime = create(rungenControls);
|
|
return action => new Promise((resolve, reject) => rungenRuntime(action, result => {
|
|
if (isAction(result)) {
|
|
dispatch(result);
|
|
}
|
|
resolve(result);
|
|
}, reject));
|
|
}
|
|
//# sourceMappingURL=runtime.js.map
|