156 lines
6.4 KiB
JavaScript
156 lines
6.4 KiB
JavaScript
/**
|
|
* Entry point to the Segment Cache implementation.
|
|
*
|
|
* All code related to the Segment Cache lives `segment-cache-impl` directory.
|
|
* Callers access it through this indirection.
|
|
*
|
|
* This is to ensure the code is dead code eliminated from the bundle if the
|
|
* flag is disabled.
|
|
*
|
|
* TODO: This is super tedious. Since experimental flags are an essential part
|
|
* of our workflow, we should establish a better pattern for dead code
|
|
* elimination. Ideally it would be done at the bundler level, like how React's
|
|
* build process works. In the React repo, you don't even need to add any extra
|
|
* configuration per experiment — if the code is not reachable, it gets stripped
|
|
* from the build automatically by Rollup. Or, shorter term, we could stub out
|
|
* experimental modules at build time by updating the build config, i.e. a more
|
|
* automated version of what I'm doing manually in this file.
|
|
*/ "use strict";
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
0 && (module.exports = {
|
|
NavigationResultTag: null,
|
|
PrefetchPriority: null,
|
|
cancelPrefetchTask: null,
|
|
createCacheKey: null,
|
|
getCurrentCacheVersion: null,
|
|
navigate: null,
|
|
prefetch: null,
|
|
reschedulePrefetchTask: null,
|
|
revalidateEntireCache: null,
|
|
schedulePrefetchTask: null
|
|
});
|
|
function _export(target, all) {
|
|
for(var name in all)Object.defineProperty(target, name, {
|
|
enumerable: true,
|
|
get: all[name]
|
|
});
|
|
}
|
|
_export(exports, {
|
|
NavigationResultTag: function() {
|
|
return NavigationResultTag;
|
|
},
|
|
PrefetchPriority: function() {
|
|
return PrefetchPriority;
|
|
},
|
|
cancelPrefetchTask: function() {
|
|
return cancelPrefetchTask;
|
|
},
|
|
createCacheKey: function() {
|
|
return createCacheKey;
|
|
},
|
|
getCurrentCacheVersion: function() {
|
|
return getCurrentCacheVersion;
|
|
},
|
|
navigate: function() {
|
|
return navigate;
|
|
},
|
|
prefetch: function() {
|
|
return prefetch;
|
|
},
|
|
reschedulePrefetchTask: function() {
|
|
return reschedulePrefetchTask;
|
|
},
|
|
revalidateEntireCache: function() {
|
|
return revalidateEntireCache;
|
|
},
|
|
schedulePrefetchTask: function() {
|
|
return schedulePrefetchTask;
|
|
}
|
|
});
|
|
const notEnabled = ()=>{
|
|
throw Object.defineProperty(new Error('Segment Cache experiment is not enabled. This is a bug in Next.js.'), "__NEXT_ERROR_CODE", {
|
|
value: "E654",
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
};
|
|
const prefetch = process.env.__NEXT_CLIENT_SEGMENT_CACHE ? function() {
|
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
args[_key] = arguments[_key];
|
|
}
|
|
return require('./segment-cache-impl/prefetch').prefetch(...args);
|
|
} : notEnabled;
|
|
const navigate = process.env.__NEXT_CLIENT_SEGMENT_CACHE ? function() {
|
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
args[_key] = arguments[_key];
|
|
}
|
|
return require('./segment-cache-impl/navigation').navigate(...args);
|
|
} : notEnabled;
|
|
const revalidateEntireCache = process.env.__NEXT_CLIENT_SEGMENT_CACHE ? function() {
|
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
args[_key] = arguments[_key];
|
|
}
|
|
return require('./segment-cache-impl/cache').revalidateEntireCache(...args);
|
|
} : notEnabled;
|
|
const getCurrentCacheVersion = process.env.__NEXT_CLIENT_SEGMENT_CACHE ? function() {
|
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
args[_key] = arguments[_key];
|
|
}
|
|
return require('./segment-cache-impl/cache').getCurrentCacheVersion(...args);
|
|
} : notEnabled;
|
|
const schedulePrefetchTask = process.env.__NEXT_CLIENT_SEGMENT_CACHE ? function() {
|
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
args[_key] = arguments[_key];
|
|
}
|
|
return require('./segment-cache-impl/scheduler').schedulePrefetchTask(...args);
|
|
} : notEnabled;
|
|
const cancelPrefetchTask = process.env.__NEXT_CLIENT_SEGMENT_CACHE ? function() {
|
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
args[_key] = arguments[_key];
|
|
}
|
|
return require('./segment-cache-impl/scheduler').cancelPrefetchTask(...args);
|
|
} : notEnabled;
|
|
const reschedulePrefetchTask = process.env.__NEXT_CLIENT_SEGMENT_CACHE ? function() {
|
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
args[_key] = arguments[_key];
|
|
}
|
|
return require('./segment-cache-impl/scheduler').reschedulePrefetchTask(...args);
|
|
} : notEnabled;
|
|
const createCacheKey = process.env.__NEXT_CLIENT_SEGMENT_CACHE ? function() {
|
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
args[_key] = arguments[_key];
|
|
}
|
|
return require('./segment-cache-impl/cache-key').createCacheKey(...args);
|
|
} : notEnabled;
|
|
var NavigationResultTag = /*#__PURE__*/ function(NavigationResultTag) {
|
|
NavigationResultTag[NavigationResultTag["MPA"] = 0] = "MPA";
|
|
NavigationResultTag[NavigationResultTag["Success"] = 1] = "Success";
|
|
NavigationResultTag[NavigationResultTag["NoOp"] = 2] = "NoOp";
|
|
NavigationResultTag[NavigationResultTag["Async"] = 3] = "Async";
|
|
return NavigationResultTag;
|
|
}({});
|
|
var PrefetchPriority = /*#__PURE__*/ function(PrefetchPriority) {
|
|
/**
|
|
* Assigned to any visible link that was hovered/touched at some point. This
|
|
* is not removed on mouse exit, because a link that was momentarily
|
|
* hovered is more likely to to be interacted with than one that was not.
|
|
*/ PrefetchPriority[PrefetchPriority["Intent"] = 2] = "Intent";
|
|
/**
|
|
* The default priority for prefetch tasks.
|
|
*/ PrefetchPriority[PrefetchPriority["Default"] = 1] = "Default";
|
|
/**
|
|
* Assigned to tasks when they spawn non-blocking background work, like
|
|
* revalidating a partially cached entry to see if more data is available.
|
|
*/ PrefetchPriority[PrefetchPriority["Background"] = 0] = "Background";
|
|
return PrefetchPriority;
|
|
}({});
|
|
|
|
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
Object.assign(exports.default, exports);
|
|
module.exports = exports.default;
|
|
}
|
|
|
|
//# sourceMappingURL=segment-cache.js.map
|