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

44
node_modules/@wordpress/jest-console/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
require("./matchers");
var _supportedMatchers = _interopRequireDefault(require("./supported-matchers"));
/**
* Internal dependencies
*/
/**
* Sets spy on the console object's method to make it possible to fail test when method called without assertion.
*
* @param {Array} args
* @param {string} args."0" Name of console method.
* @param {string} args."1" Name of Jest matcher.
*/
const setConsoleMethodSpy = ([methodName, matcherName]) => {
const spy = jest.spyOn(console, methodName).mockName(`console.${methodName}`);
/**
* Resets the spy to its initial state.
*/
function resetSpy() {
spy.mockReset();
spy.assertionsNumber = 0;
}
/**
* Verifies that the spy has only been called if expected.
*/
function assertExpectedCalls() {
if (spy.assertionsNumber === 0 && spy.mock.calls.length > 0) {
expect(console).not[matcherName]();
}
}
beforeAll(resetSpy);
beforeEach(() => {
assertExpectedCalls();
resetSpy();
});
afterEach(assertExpectedCalls);
};
Object.entries(_supportedMatchers.default).forEach(setConsoleMethodSpy);
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["require","_supportedMatchers","_interopRequireDefault","setConsoleMethodSpy","methodName","matcherName","spy","jest","spyOn","console","mockName","resetSpy","mockReset","assertionsNumber","assertExpectedCalls","mock","calls","length","expect","not","beforeAll","beforeEach","afterEach","Object","entries","supportedMatchers","forEach"],"sources":["@wordpress/jest-console/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './matchers';\nimport supportedMatchers from './supported-matchers';\n\n/**\n * Sets spy on the console object's method to make it possible to fail test when method called without assertion.\n *\n * @param {Array} args\n * @param {string} args.\"0\" Name of console method.\n * @param {string} args.\"1\" Name of Jest matcher.\n */\nconst setConsoleMethodSpy = ( [ methodName, matcherName ] ) => {\n\tconst spy = jest\n\t\t.spyOn( console, methodName )\n\t\t.mockName( `console.${ methodName }` );\n\n\t/**\n\t * Resets the spy to its initial state.\n\t */\n\tfunction resetSpy() {\n\t\tspy.mockReset();\n\t\tspy.assertionsNumber = 0;\n\t}\n\n\t/**\n\t * Verifies that the spy has only been called if expected.\n\t */\n\tfunction assertExpectedCalls() {\n\t\tif ( spy.assertionsNumber === 0 && spy.mock.calls.length > 0 ) {\n\t\t\texpect( console ).not[ matcherName ]();\n\t\t}\n\t}\n\n\tbeforeAll( resetSpy );\n\n\tbeforeEach( () => {\n\t\tassertExpectedCalls();\n\t\tresetSpy();\n\t} );\n\n\tafterEach( assertExpectedCalls );\n};\n\nObject.entries( supportedMatchers ).forEach( setConsoleMethodSpy );\n"],"mappings":";;;AAGAA,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,mBAAmB,GAAGA,CAAE,CAAEC,UAAU,EAAEC,WAAW,CAAE,KAAM;EAC9D,MAAMC,GAAG,GAAGC,IAAI,CACdC,KAAK,CAAEC,OAAO,EAAEL,UAAW,CAAC,CAC5BM,QAAQ,CAAG,WAAWN,UAAY,EAAE,CAAC;;EAEvC;AACD;AACA;EACC,SAASO,QAAQA,CAAA,EAAG;IACnBL,GAAG,CAACM,SAAS,CAAC,CAAC;IACfN,GAAG,CAACO,gBAAgB,GAAG,CAAC;EACzB;;EAEA;AACD;AACA;EACC,SAASC,mBAAmBA,CAAA,EAAG;IAC9B,IAAKR,GAAG,CAACO,gBAAgB,KAAK,CAAC,IAAIP,GAAG,CAACS,IAAI,CAACC,KAAK,CAACC,MAAM,GAAG,CAAC,EAAG;MAC9DC,MAAM,CAAET,OAAQ,CAAC,CAACU,GAAG,CAAEd,WAAW,CAAE,CAAC,CAAC;IACvC;EACD;EAEAe,SAAS,CAAET,QAAS,CAAC;EAErBU,UAAU,CAAE,MAAM;IACjBP,mBAAmB,CAAC,CAAC;IACrBH,QAAQ,CAAC,CAAC;EACX,CAAE,CAAC;EAEHW,SAAS,CAAER,mBAAoB,CAAC;AACjC,CAAC;AAEDS,MAAM,CAACC,OAAO,CAAEC,0BAAkB,CAAC,CAACC,OAAO,CAAEvB,mBAAoB,CAAC","ignoreList":[]}

63
node_modules/@wordpress/jest-console/build/matchers.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _jestMatcherUtils = require("jest-matcher-utils");
var _supportedMatchers = _interopRequireDefault(require("./supported-matchers"));
/**
* External dependencies
*/
/**
* Internal dependencies
*/
const createErrorMessage = spyInfo => {
const {
spy,
pass,
calls,
matcherName,
methodName,
expected
} = spyInfo;
const hint = pass ? `.not${matcherName}` : matcherName;
const message = pass ? `Expected mock function not to be called but it was called with:\n${calls.map(_jestMatcherUtils.printReceived)}` : `Expected mock function to be called${expected ? ` with:\n${(0, _jestMatcherUtils.printExpected)(expected)}\n` : '.'}\nbut it was called with:\n${calls.map(_jestMatcherUtils.printReceived)}`;
return () => `${(0, _jestMatcherUtils.matcherHint)(hint, spy.getMockName())}` + '\n\n' + message + '\n\n' + `console.${methodName}() should not be used unless explicitly expected\n` + 'See https://www.npmjs.com/package/@wordpress/jest-console for details.';
};
const createSpyInfo = (spy, matcherName, methodName, expected) => {
const calls = spy.mock.calls;
const pass = expected ? JSON.stringify(calls).includes(JSON.stringify(expected)) : calls.length > 0;
const message = createErrorMessage({
spy,
pass,
calls,
matcherName,
methodName,
expected
});
return {
pass,
message
};
};
const createToHaveBeenCalledMatcher = (matcherName, methodName) => received => {
const spy = received[methodName];
const spyInfo = createSpyInfo(spy, matcherName, methodName);
spy.assertionsNumber += 1;
return spyInfo;
};
const createToHaveBeenCalledWith = (matcherName, methodName) => function (received, ...expected) {
const spy = received[methodName];
const spyInfo = createSpyInfo(spy, matcherName, methodName, expected);
spy.assertionsNumber += 1;
return spyInfo;
};
expect.extend(Object.entries(_supportedMatchers.default).reduce((result, [methodName, matcherName]) => {
const matcherNameWith = `${matcherName}With`;
return {
...result,
[matcherName]: createToHaveBeenCalledMatcher(`.${matcherName}`, methodName),
[matcherNameWith]: createToHaveBeenCalledWith(`.${matcherNameWith}`, methodName)
};
}, {}));
//# sourceMappingURL=matchers.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
const supportedMatchers = {
error: 'toHaveErrored',
info: 'toHaveInformed',
log: 'toHaveLogged',
warn: 'toHaveWarned'
};
var _default = exports.default = supportedMatchers;
//# sourceMappingURL=supported-matchers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["supportedMatchers","error","info","log","warn","_default","exports","default"],"sources":["@wordpress/jest-console/src/supported-matchers.js"],"sourcesContent":["const supportedMatchers = {\n\terror: 'toHaveErrored',\n\tinfo: 'toHaveInformed',\n\tlog: 'toHaveLogged',\n\twarn: 'toHaveWarned',\n};\n\nexport default supportedMatchers;\n"],"mappings":";;;;;;AAAA,MAAMA,iBAAiB,GAAG;EACzBC,KAAK,EAAE,eAAe;EACtBC,IAAI,EAAE,gBAAgB;EACtBC,GAAG,EAAE,cAAc;EACnBC,IAAI,EAAE;AACP,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaP,iBAAiB","ignoreList":[]}