preact
This commit is contained in:
parent
6acf267d48
commit
b7614eb3f8
4794 changed files with 1280808 additions and 1546 deletions
46
frontend/node_modules/@prefresh/utils/dist/src/index.js
generated
vendored
Normal file
46
frontend/node_modules/@prefresh/utils/dist/src/index.js
generated
vendored
Normal 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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue