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,52 @@
/**
* A constructor (factory) for `ObservableMap`, a map-like key/value data structure
* where the individual entries are observable: using the `subscribe` method, you can
* subscribe to updates for a particular keys. Each subscriber always observes one
* specific key and is not notified about any unrelated changes (for different keys)
* in the `ObservableMap`.
*
* @template K The type of the keys in the map.
* @template V The type of the values in the map.
* @return A new instance of the `ObservableMap` type.
*/
export function observableMap() {
const map = new Map();
const listeners = new Map();
function callListeners(name) {
const list = listeners.get(name);
if (!list) {
return;
}
for (const listener of list) {
listener();
}
}
return {
get(name) {
return map.get(name);
},
set(name, value) {
map.set(name, value);
callListeners(name);
},
delete(name) {
map.delete(name);
callListeners(name);
},
subscribe(name, listener) {
let list = listeners.get(name);
if (!list) {
list = new Set();
listeners.set(name, list);
}
list.add(listener);
return () => {
list.delete(listener);
if (list.size === 0) {
listeners.delete(name);
}
};
}
};
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["observableMap","map","Map","listeners","callListeners","name","list","get","listener","set","value","delete","subscribe","Set","add","size"],"sources":["@wordpress/compose/src/utils/observable-map/index.ts"],"sourcesContent":["export type ObservableMap< K, V > = {\n\tget( name: K ): V | undefined;\n\tset( name: K, value: V ): void;\n\tdelete( name: K ): void;\n\tsubscribe( name: K, listener: () => void ): () => void;\n};\n\n/**\n * A constructor (factory) for `ObservableMap`, a map-like key/value data structure\n * where the individual entries are observable: using the `subscribe` method, you can\n * subscribe to updates for a particular keys. Each subscriber always observes one\n * specific key and is not notified about any unrelated changes (for different keys)\n * in the `ObservableMap`.\n *\n * @template K The type of the keys in the map.\n * @template V The type of the values in the map.\n * @return A new instance of the `ObservableMap` type.\n */\nexport function observableMap< K, V >(): ObservableMap< K, V > {\n\tconst map = new Map< K, V >();\n\tconst listeners = new Map< K, Set< () => void > >();\n\n\tfunction callListeners( name: K ) {\n\t\tconst list = listeners.get( name );\n\t\tif ( ! list ) {\n\t\t\treturn;\n\t\t}\n\t\tfor ( const listener of list ) {\n\t\t\tlistener();\n\t\t}\n\t}\n\n\treturn {\n\t\tget( name ) {\n\t\t\treturn map.get( name );\n\t\t},\n\t\tset( name, value ) {\n\t\t\tmap.set( name, value );\n\t\t\tcallListeners( name );\n\t\t},\n\t\tdelete( name ) {\n\t\t\tmap.delete( name );\n\t\t\tcallListeners( name );\n\t\t},\n\t\tsubscribe( name, listener ) {\n\t\t\tlet list = listeners.get( name );\n\t\t\tif ( ! list ) {\n\t\t\t\tlist = new Set();\n\t\t\t\tlisteners.set( name, list );\n\t\t\t}\n\t\t\tlist.add( listener );\n\n\t\t\treturn () => {\n\t\t\t\tlist.delete( listener );\n\t\t\t\tif ( list.size === 0 ) {\n\t\t\t\t\tlisteners.delete( name );\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t};\n}\n"],"mappings":"AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,aAAaA,CAAA,EAAkC;EAC9D,MAAMC,GAAG,GAAG,IAAIC,GAAG,CAAS,CAAC;EAC7B,MAAMC,SAAS,GAAG,IAAID,GAAG,CAAyB,CAAC;EAEnD,SAASE,aAAaA,CAAEC,IAAO,EAAG;IACjC,MAAMC,IAAI,GAAGH,SAAS,CAACI,GAAG,CAAEF,IAAK,CAAC;IAClC,IAAK,CAAEC,IAAI,EAAG;MACb;IACD;IACA,KAAM,MAAME,QAAQ,IAAIF,IA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