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>
65 lines
2.2 KiB
JavaScript
65 lines
2.2 KiB
JavaScript
System.register(['@babel/helper-module-imports', '@babel/types', 'aslemammad-vite-plugin-macro', 'babel-plugin-macros'], (function (exports) {
|
|
'use strict';
|
|
var babelModuleImports, t, plugin, babelMacro;
|
|
return {
|
|
setters: [function (module) {
|
|
babelModuleImports = module;
|
|
}, function (module) {
|
|
t = module;
|
|
}, function (module) {
|
|
plugin = module;
|
|
}, function (module) {
|
|
babelMacro = module;
|
|
}],
|
|
execute: (function () {
|
|
|
|
exports('provideValtioMacro', provideValtioMacro);
|
|
|
|
const { defineMacro, defineMacroProvider, createMacroPlugin } = "default" in plugin ? plugin.default : plugin;
|
|
const valtioMacro = exports('valtioMacro', defineMacro(`useProxy`).withSignature(`<T extends object>(proxyObject: T): void`).withHandler((ctx) => {
|
|
var _a, _b, _c, _d;
|
|
const { path, args } = ctx;
|
|
const hook = babelModuleImports.addNamed(path, "useSnapshot", "valtio");
|
|
const proxy = (_a = args[0]) == null ? void 0 : _a.node;
|
|
if (!t.isIdentifier(proxy)) {
|
|
throw new babelMacro.MacroError("no proxy object");
|
|
}
|
|
const snap = t.identifier(`valtio_macro_snap_${proxy.name}`);
|
|
(_b = path.parentPath) == null ? void 0 : _b.replaceWith(
|
|
t.variableDeclaration("const", [
|
|
t.variableDeclarator(snap, t.callExpression(hook, [proxy]))
|
|
])
|
|
);
|
|
let inFunction = 0;
|
|
(_d = (_c = path.parentPath) == null ? void 0 : _c.getFunctionParent()) == null ? void 0 : _d.traverse({
|
|
Identifier(p) {
|
|
if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) {
|
|
p.node.name = snap.name;
|
|
}
|
|
},
|
|
Function: {
|
|
enter() {
|
|
++inFunction;
|
|
},
|
|
exit() {
|
|
--inFunction;
|
|
}
|
|
}
|
|
});
|
|
}));
|
|
function provideValtioMacro() {
|
|
return defineMacroProvider({
|
|
id: "valtio/macro",
|
|
exports: {
|
|
"valtio/macro": {
|
|
macros: [valtioMacro]
|
|
}
|
|
}
|
|
});
|
|
}
|
|
const macroPlugin = exports('default', createMacroPlugin({}).use(provideValtioMacro()));
|
|
|
|
})
|
|
};
|
|
}));
|