Initial commit
This commit is contained in:
commit
78f8d225ee
21173 changed files with 2907774 additions and 0 deletions
144
node_modules/next/dist/server/web/spec-extension/revalidate.js
generated
vendored
Normal file
144
node_modules/next/dist/server/web/spec-extension/revalidate.js
generated
vendored
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
revalidatePath: null,
|
||||
revalidateTag: null,
|
||||
unstable_expirePath: null,
|
||||
unstable_expireTag: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
revalidatePath: function() {
|
||||
return revalidatePath;
|
||||
},
|
||||
revalidateTag: function() {
|
||||
return revalidateTag;
|
||||
},
|
||||
unstable_expirePath: function() {
|
||||
return unstable_expirePath;
|
||||
},
|
||||
unstable_expireTag: function() {
|
||||
return unstable_expireTag;
|
||||
}
|
||||
});
|
||||
const _dynamicrendering = require("../../app-render/dynamic-rendering");
|
||||
const _utils = require("../../../shared/lib/router/utils");
|
||||
const _constants = require("../../../lib/constants");
|
||||
const _workasyncstorageexternal = require("../../app-render/work-async-storage.external");
|
||||
const _workunitasyncstorageexternal = require("../../app-render/work-unit-async-storage.external");
|
||||
const _hooksservercontext = require("../../../client/components/hooks-server-context");
|
||||
function revalidateTag(tag) {
|
||||
return revalidate([
|
||||
tag
|
||||
], `revalidateTag ${tag}`);
|
||||
}
|
||||
function unstable_expirePath(originalPath, type) {
|
||||
if (originalPath.length > _constants.NEXT_CACHE_SOFT_TAG_MAX_LENGTH) {
|
||||
console.warn(`Warning: expirePath received "${originalPath}" which exceeded max length of ${_constants.NEXT_CACHE_SOFT_TAG_MAX_LENGTH}. See more info here https://nextjs.org/docs/app/api-reference/functions/unstable_expirePath`);
|
||||
return;
|
||||
}
|
||||
let normalizedPath = `${_constants.NEXT_CACHE_IMPLICIT_TAG_ID}${originalPath}`;
|
||||
if (type) {
|
||||
normalizedPath += `${normalizedPath.endsWith('/') ? '' : '/'}${type}`;
|
||||
} else if ((0, _utils.isDynamicRoute)(originalPath)) {
|
||||
console.warn(`Warning: a dynamic page path "${originalPath}" was passed to "expirePath", but the "type" parameter is missing. This has no effect by default, see more info here https://nextjs.org/docs/app/api-reference/functions/unstable_expirePath`);
|
||||
}
|
||||
return revalidate([
|
||||
normalizedPath
|
||||
], `unstable_expirePath ${originalPath}`);
|
||||
}
|
||||
function unstable_expireTag(...tags) {
|
||||
return revalidate(tags, `unstable_expireTag ${tags.join(', ')}`);
|
||||
}
|
||||
function revalidatePath(originalPath, type) {
|
||||
if (originalPath.length > _constants.NEXT_CACHE_SOFT_TAG_MAX_LENGTH) {
|
||||
console.warn(`Warning: revalidatePath received "${originalPath}" which exceeded max length of ${_constants.NEXT_CACHE_SOFT_TAG_MAX_LENGTH}. See more info here https://nextjs.org/docs/app/api-reference/functions/revalidatePath`);
|
||||
return;
|
||||
}
|
||||
let normalizedPath = `${_constants.NEXT_CACHE_IMPLICIT_TAG_ID}${originalPath}`;
|
||||
if (type) {
|
||||
normalizedPath += `${normalizedPath.endsWith('/') ? '' : '/'}${type}`;
|
||||
} else if ((0, _utils.isDynamicRoute)(originalPath)) {
|
||||
console.warn(`Warning: a dynamic page path "${originalPath}" was passed to "revalidatePath", but the "type" parameter is missing. This has no effect by default, see more info here https://nextjs.org/docs/app/api-reference/functions/revalidatePath`);
|
||||
}
|
||||
return revalidate([
|
||||
normalizedPath
|
||||
], `revalidatePath ${originalPath}`);
|
||||
}
|
||||
function revalidate(tags, expression) {
|
||||
const store = _workasyncstorageexternal.workAsyncStorage.getStore();
|
||||
if (!store || !store.incrementalCache) {
|
||||
throw Object.defineProperty(new Error(`Invariant: static generation store missing in ${expression}`), "__NEXT_ERROR_CODE", {
|
||||
value: "E263",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
|
||||
if (workUnitStore) {
|
||||
if (workUnitStore.type === 'cache') {
|
||||
throw Object.defineProperty(new Error(`Route ${store.route} used "${expression}" inside a "use cache" which is unsupported. To ensure revalidation is performed consistently it must always happen outside of renders and cached functions. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`), "__NEXT_ERROR_CODE", {
|
||||
value: "E181",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
} else if (workUnitStore.type === 'unstable-cache') {
|
||||
throw Object.defineProperty(new Error(`Route ${store.route} used "${expression}" inside a function cached with "unstable_cache(...)" which is unsupported. To ensure revalidation is performed consistently it must always happen outside of renders and cached functions. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`), "__NEXT_ERROR_CODE", {
|
||||
value: "E306",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (workUnitStore.phase === 'render') {
|
||||
throw Object.defineProperty(new Error(`Route ${store.route} used "${expression}" during render which is unsupported. To ensure revalidation is performed consistently it must always happen outside of renders and cached functions. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`), "__NEXT_ERROR_CODE", {
|
||||
value: "E7",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (workUnitStore.type === 'prerender') {
|
||||
// dynamicIO Prerender
|
||||
const error = Object.defineProperty(new Error(`Route ${store.route} used ${expression} without first calling \`await connection()\`.`), "__NEXT_ERROR_CODE", {
|
||||
value: "E406",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
(0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(store.route, expression, error, workUnitStore);
|
||||
} else if (workUnitStore.type === 'prerender-ppr') {
|
||||
// PPR Prerender
|
||||
(0, _dynamicrendering.postponeWithTracking)(store.route, expression, workUnitStore.dynamicTracking);
|
||||
} else if (workUnitStore.type === 'prerender-legacy') {
|
||||
// legacy Prerender
|
||||
workUnitStore.revalidate = 0;
|
||||
const err = Object.defineProperty(new _hooksservercontext.DynamicServerError(`Route ${store.route} couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`), "__NEXT_ERROR_CODE", {
|
||||
value: "E558",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
store.dynamicUsageDescription = expression;
|
||||
store.dynamicUsageStack = err.stack;
|
||||
throw err;
|
||||
} else if (process.env.NODE_ENV === 'development' && workUnitStore && workUnitStore.type === 'request') {
|
||||
workUnitStore.usedDynamic = true;
|
||||
}
|
||||
}
|
||||
if (!store.pendingRevalidatedTags) {
|
||||
store.pendingRevalidatedTags = [];
|
||||
}
|
||||
for (const tag of tags){
|
||||
if (!store.pendingRevalidatedTags.includes(tag)) {
|
||||
store.pendingRevalidatedTags.push(tag);
|
||||
}
|
||||
}
|
||||
// TODO: only revalidate if the path matches
|
||||
store.pathWasRevalidated = true;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=revalidate.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue