fix: prevent asset conflicts between React and Grid.js versions

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>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

View File

@@ -0,0 +1,57 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StyleProvider = StyleProvider;
exports.default = void 0;
var _react = require("react");
var _react2 = require("@emotion/react");
var _cache = _interopRequireDefault(require("@emotion/cache"));
var uuid = _interopRequireWildcard(require("uuid"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**
* External dependencies
*/
const uuidCache = new Set();
// Use a weak map so that when the container is detached it's automatically
// dereferenced to avoid memory leak.
const containerCacheMap = new WeakMap();
const memoizedCreateCacheWithContainer = container => {
if (containerCacheMap.has(container)) {
return containerCacheMap.get(container);
}
// Emotion only accepts alphabetical and hyphenated keys so we just
// strip the numbers from the UUID. It _should_ be fine.
let key = uuid.v4().replace(/[0-9]/g, '');
while (uuidCache.has(key)) {
key = uuid.v4().replace(/[0-9]/g, '');
}
uuidCache.add(key);
const cache = (0, _cache.default)({
container,
key
});
containerCacheMap.set(container, cache);
return cache;
};
function StyleProvider(props) {
const {
children,
document
} = props;
if (!document) {
return null;
}
const cache = memoizedCreateCacheWithContainer(document.head);
return (0, _react.createElement)(_react2.CacheProvider, {
value: cache
}, children);
}
var _default = StyleProvider;
exports.default = _default;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_react2","require","_cache","_interopRequireDefault","uuid","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","uuidCache","Set","containerCacheMap","memoizedCreateCacheWithContainer","container","v4","replace","add","createCache","StyleProvider","props","children","document","head","_react","createElement","CacheProvider","value","_default","exports"],"sources":["@wordpress/components/src/style-provider/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport { CacheProvider } from '@emotion/react';\nimport createCache from '@emotion/cache';\nimport * as uuid from 'uuid';\n\n/**\n * Internal dependencies\n */\nimport type { StyleProviderProps } from './types';\n\nconst uuidCache = new Set();\n// Use a weak map so that when the container is detached it's automatically\n// dereferenced to avoid memory leak.\nconst containerCacheMap = new WeakMap();\n\nconst memoizedCreateCacheWithContainer = ( container: HTMLElement ) => {\n\tif ( containerCacheMap.has( container ) ) {\n\t\treturn containerCacheMap.get( container );\n\t}\n\n\t// Emotion only accepts alphabetical and hyphenated keys so we just\n\t// strip the numbers from the UUID. It _should_ be fine.\n\tlet key = uuid.v4().replace( /[0-9]/g, '' );\n\twhile ( uuidCache.has( key ) ) {\n\t\tkey = uuid.v4().replace( /[0-9]/g, '' );\n\t}\n\tuuidCache.add( key );\n\n\tconst cache = createCache( { container, key } );\n\tcontainerCacheMap.set( container, cache );\n\treturn cache;\n};\n\nexport function StyleProvider( props: StyleProviderProps ) {\n\tconst { children, document } = props;\n\n\tif ( ! document ) {\n\t\treturn null;\n\t}\n\n\tconst cache = memoizedCreateCacheWithContainer( document.head );\n\n\treturn <CacheProvider value={ cache }>{ children }</CacheProvider>;\n}\n\nexport default StyleProvider;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,IAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAA6B,SAAAK,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW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G;EAC1D,MAAM;IAAEC,QAAQ;IAAEC;EAAS,CAAC,GAAGF,KAAK;EAEpC,IAAK,CAAEE,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,MAAM1B,KAAK,GAAGiB,gCAAgC,CAAES,QAAQ,CAACC,IAAK,CAAC;EAE/D,OAAO,IAAAC,MAAA,CAAAC,aAAA,EAAC3C,OAAA,CAAA4C,aAAa;IAACC,KAAK,EAAG/B;EAAO,GAAGyB,QAAyB,CAAC;AACnE;AAAC,IAAAO,QAAA,GAEcT,aAAa;AAAAU,OAAA,CAAAlC,OAAA,GAAAiC,QAAA"}

View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = StyleProvider;
function StyleProvider({
children
}) {
return children;
}
//# sourceMappingURL=index.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["StyleProvider","children"],"sources":["@wordpress/components/src/style-provider/index.native.js"],"sourcesContent":["export default function StyleProvider( { children } ) {\n\treturn children;\n}\n"],"mappings":";;;;;;AAAe,SAASA,aAAaA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACrD,OAAOA,QAAQ;AAChB"}

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sources":["@wordpress/components/src/style-provider/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\nexport type StyleProviderProps = {\n\t/**\n\t * The children elements.\n\t */\n\tchildren: ReactNode;\n\t/**\n\t * Current document.\n\t */\n\tdocument: Document;\n};\n"],"mappings":""}