heartbeat-monitor/node_modules/next/dist/server/after/revalidation-utils.js
Matt Bruce bed1169443 Initial commit: Heartbeat Monitor dashboard
- Full-featured monitoring dashboard for local web apps
- Real-time status tracking with uptime percentages
- Visual sparklines for status history
- Add/Edit/Delete apps dynamically
- Categories and color coding
- Auto-refresh every 30 seconds
- API endpoints for apps and status management
2026-02-18 11:16:01 -06:00

57 lines
2.2 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "withExecuteRevalidates", {
enumerable: true,
get: function() {
return withExecuteRevalidates;
}
});
async function withExecuteRevalidates(store, callback) {
if (!store) {
return callback();
}
// If we executed any revalidates during the request, then we don't want to execute them again.
// save the state so we can check if anything changed after we're done running callbacks.
const savedRevalidationState = cloneRevalidationState(store);
try {
return await callback();
} finally{
// Check if we have any new revalidates, and if so, wait until they are all resolved.
const newRevalidates = diffRevalidationState(savedRevalidationState, cloneRevalidationState(store));
await executeRevalidates(store, newRevalidates);
}
}
function cloneRevalidationState(store) {
return {
revalidatedTags: store.revalidatedTags ? [
...store.revalidatedTags
] : [],
pendingRevalidates: {
...store.pendingRevalidates
},
pendingRevalidateWrites: store.pendingRevalidateWrites ? [
...store.pendingRevalidateWrites
] : []
};
}
function diffRevalidationState(prev, curr) {
const prevTags = new Set(prev.revalidatedTags);
const prevRevalidateWrites = new Set(prev.pendingRevalidateWrites);
return {
revalidatedTags: curr.revalidatedTags.filter((tag)=>!prevTags.has(tag)),
pendingRevalidates: Object.fromEntries(Object.entries(curr.pendingRevalidates).filter(([key])=>!(key in prev.pendingRevalidates))),
pendingRevalidateWrites: curr.pendingRevalidateWrites.filter((promise)=>!prevRevalidateWrites.has(promise))
};
}
async function executeRevalidates(workStore, { revalidatedTags, pendingRevalidates, pendingRevalidateWrites }) {
var _workStore_incrementalCache;
return Promise.all([
(_workStore_incrementalCache = workStore.incrementalCache) == null ? void 0 : _workStore_incrementalCache.revalidateTag(revalidatedTags),
...Object.values(pendingRevalidates),
...pendingRevalidateWrites
]);
}
//# sourceMappingURL=revalidation-utils.js.map