This commit is contained in:
kacper 2026-03-06 22:51:19 -05:00
parent 6acf267d48
commit b7614eb3f8
4794 changed files with 1280808 additions and 1546 deletions

View file

@ -0,0 +1,46 @@
const compareSignatures = (prev, next) => {
const prevSignature = self.__PREFRESH__.getSignature(prev) || {};
const nextSignature = self.__PREFRESH__.getSignature(next) || {};
if (
prevSignature.key !== nextSignature.key ||
self.__PREFRESH__.computeKey(prevSignature) !==
self.__PREFRESH__.computeKey(nextSignature) ||
nextSignature.forceReset
) {
self.__PREFRESH__.replaceComponent(prev, next, true);
} else {
self.__PREFRESH__.replaceComponent(prev, next, false);
}
};
const flush = () => {
const pending = [...self.__PREFRESH__.getPendingUpdates()];
self.__PREFRESH__.flush();
if (pending.length > 0) {
pending.forEach(([prev, next]) => {
compareSignatures(prev, next);
});
}
};
const isComponent = exportValue => {
if (typeof exportValue === 'function') {
if (
exportValue.prototype != null &&
exportValue.prototype.isReactComponent
) {
return true;
}
const name = exportValue.name || exportValue.displayName;
return (
typeof name === 'string' && name[0] && name[0] == name[0].toUpperCase()
);
}
return false;
};
exports.flush=flush;
exports.isComponent=isComponent;