Files
formipay/node_modules/valtio/esm/index.mjs
dwindown e8fbfb14c1 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>
2026-04-18 17:02:14 +07:00

60 lines
2.0 KiB
JavaScript

import { useRef, useCallback, useEffect, useMemo, useDebugValue } from 'react';
import { isChanged, createProxy, affectedToPathList } from 'proxy-compare';
import useSyncExternalStoreExports from 'use-sync-external-store/shim/index.js';
import { subscribe, snapshot } from 'valtio/vanilla';
export { getVersion, proxy, ref, snapshot, subscribe, unstable_buildProxyFunction } from 'valtio/vanilla';
const { useSyncExternalStore } = useSyncExternalStoreExports;
const useAffectedDebugValue = (state, affected) => {
const pathList = useRef();
useEffect(() => {
pathList.current = affectedToPathList(state, affected);
});
useDebugValue(pathList.current);
};
function useSnapshot(proxyObject, options) {
const notifyInSync = options == null ? void 0 : options.sync;
const lastSnapshot = useRef();
const lastAffected = useRef();
let inRender = true;
const currSnapshot = useSyncExternalStore(
useCallback(
(callback) => {
const unsub = subscribe(proxyObject, callback, notifyInSync);
callback();
return unsub;
},
[proxyObject, notifyInSync]
),
() => {
const nextSnapshot = snapshot(proxyObject);
try {
if (!inRender && lastSnapshot.current && lastAffected.current && !isChanged(
lastSnapshot.current,
nextSnapshot,
lastAffected.current,
/* @__PURE__ */ new WeakMap()
)) {
return lastSnapshot.current;
}
} catch (e) {
}
return nextSnapshot;
},
() => snapshot(proxyObject)
);
inRender = false;
const currAffected = /* @__PURE__ */ new WeakMap();
useEffect(() => {
lastSnapshot.current = currSnapshot;
lastAffected.current = currAffected;
});
if ((import.meta.env && import.meta.env.MODE) !== "production") {
useAffectedDebugValue(currSnapshot, currAffected);
}
const proxyCache = useMemo(() => /* @__PURE__ */ new WeakMap(), []);
return createProxy(currSnapshot, currAffected, proxyCache);
}
export { useSnapshot };