repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
serwist | github_2023 | serwist | typescript | Serwist.matchPrecache | async matchPrecache(request: string | Request): Promise<Response | undefined> {
const url = request instanceof Request ? request.url : request;
const cacheKey = this.getPrecacheKeyForUrl(url);
if (cacheKey) {
const cache = await self.caches.open(this.precacheStrategy.cacheName);
return cache.mat... | /**
* This acts as a drop-in replacement for
* [`cache.match()`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/match)
* with the following differences:
*
* - It knows what the name of the precache is, and only checks in that cache.
* - It allows you to pass in an "original" URL without versio... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/Serwist.ts#L632-L640 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Serwist.createHandlerBoundToUrl | createHandlerBoundToUrl(url: string): RouteHandlerCallback {
const cacheKey = this.getPrecacheKeyForUrl(url);
if (!cacheKey) {
throw new SerwistError("non-precached-url", { url });
}
return (options) => {
options.request = new Request(url);
options.params = { cacheKey, ...options.param... | /**
* Returns a function that looks up `url` in the precache (taking into
* account revision information), and returns the corresponding `Response`.
*
* @param url The precached URL which will be used to lookup the response.
* @return
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/Serwist.ts#L649-L660 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Serwist.handleRequest | handleRequest({
request,
event,
}: {
/**
* The request to handle.
*/
request: Request;
/**
* The event that triggered the request.
*/
event: ExtendableEvent;
}): Promise<Response> | undefined {
if (process.env.NODE_ENV !== "production") {
assert!.isInstance(requ... | /**
* Applies the routing rules to a `FetchEvent` object to get a response from an
* appropriate route.
*
* @param options
* @returns A promise is returned if a registered route can handle the request.
* If there is no matching route and there's no default handler, `undefined`
* is returned.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/Serwist.ts#L671-L807 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Serwist.findMatchingRoute | findMatchingRoute({ url, sameOrigin, request, event }: RouteMatchCallbackOptions): {
route?: Route;
params?: RouteHandlerCallbackOptions["params"];
} {
const routes = this._routes.get(request.method as HTTPMethod) || [];
for (const route of routes) {
let params: Promise<any> | undefined;
/... | /**
* Checks a request and URL (and optionally an event) against the list of
* registered routes, and if there's a match, returns the corresponding
* route along with any params generated by the match.
*
* @param options
* @returns An object with `route` and `params` properties. They are populated
... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/Serwist.ts#L818-L866 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheController.constructor | constructor({ cacheName, plugins = [], fallbackToNetwork = true, concurrentPrecaching = 1 }: PrecacheControllerOptions = {}) {
this._concurrentPrecaching = concurrentPrecaching;
this._strategy = new PrecacheStrategy({
cacheName: privateCacheNames.getPrecacheName(cacheName),
plugins: [...plugins, new... | /**
* Create a new PrecacheController.
*
* @param options
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheController.ts#L68-L78 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheController.strategy | get strategy(): Strategy {
return this._strategy;
} | /**
* The strategy created by this controller and
* used to cache assets and respond to `fetch` events.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheController.ts#L84-L86 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheController.precache | precache(entries: (PrecacheEntry | string)[]): void {
this.addToCacheList(entries);
if (!this._installAndActiveListenersAdded) {
self.addEventListener("install", this.install);
self.addEventListener("activate", this.activate);
this._installAndActiveListenersAdded = true;
}
} | /**
* Adds items to the precache list, removing any duplicates and
* stores the files in the precache cache when the service
* worker installs.
*
* This method can be called multiple times.
*
* @param entries Array of entries to precache.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheController.ts#L97-L105 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheController.addToCacheList | addToCacheList(entries: (PrecacheEntry | string)[]): void {
if (process.env.NODE_ENV !== "production") {
assert!.isArray(entries, {
moduleName: "serwist/legacy",
className: "PrecacheController",
funcName: "addToCacheList",
paramName: "entries",
});
}
const urlsTo... | /**
* This method will add items to the precache list, removing duplicates
* and ensuring the information is valid.
*
* @param entries Array of entries to precache.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheController.ts#L113-L167 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheController.install | install(event: ExtendableEvent): Promise<InstallResult> {
return waitUntil<InstallResult>(event, async () => {
const installReportPlugin = new PrecacheInstallReportPlugin();
this.strategy.plugins.push(installReportPlugin);
await parallel(this._concurrentPrecaching, Array.from(this._urlsToCacheKey... | /**
* Precaches new and updated assets. Call this method from the service worker
* install event.
*
* Note: this method calls `event.waitUntil()` for you, so you do not need
* to call it yourself in your event handlers.
*
* @param event
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheController.ts#L179-L212 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheController.activate | activate(event: ExtendableEvent): Promise<CleanupResult> {
return waitUntil<CleanupResult>(event, async () => {
const cache = await self.caches.open(this.strategy.cacheName);
const currentlyCachedRequests = await cache.keys();
const expectedCacheKeys = new Set(this._urlsToCacheKeys.values());
... | /**
* Deletes assets that are no longer present in the current precache manifest.
* Call this method from the service worker activate event.
*
* Note: this method calls `event.waitUntil()` for you, so you do not need
* to call it yourself in your event handlers.
*
* @param event
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheController.ts#L224-L245 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheController.getURLsToCacheKeys | getURLsToCacheKeys(): Map<string, string> {
return this._urlsToCacheKeys;
} | /**
* Returns a mapping of a precached URL to the corresponding cache key, taking
* into account the revision information for the URL.
*
* @returns A URL to cache key mapping.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheController.ts#L253-L255 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheController.getCachedURLs | getCachedURLs(): string[] {
return [...this._urlsToCacheKeys.keys()];
} | /**
* Returns a list of all the URLs that have been precached by the current
* service worker.
*
* @returns The precached URLs.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheController.ts#L263-L265 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheController.getCacheKeyForURL | getCacheKeyForURL(url: string): string | undefined {
const urlObject = new URL(url, location.href);
return this._urlsToCacheKeys.get(urlObject.href);
} | /**
* Returns the cache key used for storing a given URL. If that URL is
* unversioned, like `/index.html', then the cache key will be the original
* URL with a search parameter appended to it.
*
* @param url A URL whose cache key you want to look up.
* @returns The versioned URL that corresponds to a... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheController.ts#L276-L279 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheController.getIntegrityForCacheKey | getIntegrityForCacheKey(cacheKey: string): string | undefined {
return this._cacheKeysToIntegrities.get(cacheKey);
} | /**
* @param url A cache key whose SRI you want to look up.
* @returns The subresource integrity associated with the cache key,
* or undefined if it's not set.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheController.ts#L286-L288 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheController.matchPrecache | async matchPrecache(request: string | Request): Promise<Response | undefined> {
const url = request instanceof Request ? request.url : request;
const cacheKey = this.getCacheKeyForURL(url);
if (cacheKey) {
const cache = await self.caches.open(this.strategy.cacheName);
return cache.match(cacheKey... | /**
* This acts as a drop-in replacement for
* [`cache.match()`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/match)
* with the following differences:
*
* - It knows what the name of the precache is, and only checks in that cache.
* - It allows you to pass in an "original" URL without versio... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheController.ts#L308-L316 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheController.createHandlerBoundToURL | createHandlerBoundToURL(url: string): RouteHandlerCallback {
const cacheKey = this.getCacheKeyForURL(url);
if (!cacheKey) {
throw new SerwistError("non-precached-url", { url });
}
return (options) => {
options.request = new Request(url);
options.params = { cacheKey, ...options.params }... | /**
* Returns a function that looks up `url` in the precache (taking into
* account revision information), and returns the corresponding `Response`.
*
* @param url The precached URL which will be used to lookup the response.
* @return
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheController.ts#L325-L336 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheFallbackPlugin.constructor | constructor({ fallbackUrls, precacheController }: PrecacheFallbackPluginOptions) {
this._fallbackUrls = fallbackUrls;
this._precacheController = precacheController || getSingletonPrecacheController();
} | /**
* Constructs a new instance with the associated `fallbackUrls`.
*
* @param config
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheFallbackPlugin.ts#L66-L69 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheFallbackPlugin.handlerDidError | async handlerDidError(param: HandlerDidErrorCallbackParam) {
for (const fallback of this._fallbackUrls) {
if (typeof fallback === "string") {
const fallbackResponse = await this._precacheController.matchPrecache(fallback);
if (fallbackResponse !== undefined) {
return fallbackResponse... | /**
* @returns The precache response for one of the fallback URLs, or `undefined` if
* nothing satisfies the conditions.
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheFallbackPlugin.ts#L76-L91 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | PrecacheRoute.constructor | constructor(precacheController: PrecacheController, options?: PrecacheRouteOptions) {
const match: RouteMatchCallback = ({ request }: RouteMatchCallbackOptions) => {
const urlsToCacheKeys = precacheController.getURLsToCacheKeys();
for (const possibleURL of generateURLVariations(request.url, options)) {
... | /**
* @param precacheController A {@linkcode PrecacheController}
* instance used to both match requests and respond to `fetch` events.
* @param options Options to control how requests are matched
* against the list of precached URLs.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/PrecacheRoute.ts#L30-L47 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Router.constructor | constructor() {
this._routes = new Map();
this._defaultHandlerMap = new Map();
} | /**
* Initializes a new Router.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/Router.ts#L53-L56 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Router.routes | get routes(): Map<HTTPMethod, Route[]> {
return this._routes;
} | /**
* @returns routes A `Map` of HTTP method name (`'GET'`, etc.) to an array of all
* the corresponding {@linkcode Route} instances that are registered.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/Router.ts#L62-L64 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Router.addFetchListener | addFetchListener(): void {
if (!this._fetchListenerHandler) {
this._fetchListenerHandler = (event) => {
const { request } = event;
const responsePromise = this.handleRequest({ request, event });
if (responsePromise) {
event.respondWith(responsePromise);
}
};
... | /**
* Adds a `fetch` event listener to respond to events when a route matches
* the event's request. Effectively no-op if `addFetchListener` has been
* called, but `removeFetchListener` has not.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/Router.ts#L71-L82 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Router.removeFetchListener | removeFetchListener(): void {
if (this._fetchListenerHandler) {
self.removeEventListener("fetch", this._fetchListenerHandler);
this._fetchListenerHandler = null;
}
} | /**
* Removes `fetch` event listener added by `addFetchListener`.
* Effectively no-op if either `addFetchListener` has not been called or,
* if it has, so has `removeFetchListener`.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/Router.ts#L89-L94 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Router.addCacheListener | addCacheListener(): void {
if (!this._cacheListenerHandler) {
this._cacheListenerHandler = (event) => {
if (event.data && event.data.type === "CACHE_URLS") {
const { payload }: CacheURLsMessageData = event.data;
if (process.env.NODE_ENV !== "production") {
logger.debug... | /**
* Adds a `message` event listener for URLs to cache from the window.
* This is useful to cache resources loaded on the page prior to when the
* service worker started controlling it. Effectively no-op if `addCacheListener`
* has been called, but `removeCacheListener` hasn't.
*
* The format of the ... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/Router.ts#L119-L150 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Router.removeCacheListener | removeCacheListener(): void {
if (this._cacheListenerHandler) {
self.removeEventListener("message", this._cacheListenerHandler);
}
} | /**
* Removes the `message` event listener added by `addCacheListener`.
* Effectively no-op if either `addCacheListener` has not been called or,
* if it has, so has `removeCacheListener`.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/Router.ts#L157-L161 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Router.handleRequest | handleRequest({
request,
event,
}: {
/**
* The request to handle.
*/
request: Request;
/**
* The event that triggered the request.
*/
event: ExtendableEvent;
}): Promise<Response> | undefined {
if (process.env.NODE_ENV !== "production") {
assert!.isInstance(requ... | /**
* Apply the routing rules to a `fetch` event to get a response from an
* appropriate route.
*
* @param options
* @returns A promise is returned if a registered route can handle the request.
* If there is no matching route and there's no `defaultHandler`, `undefined`
* is returned.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/Router.ts#L172-L308 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Router.findMatchingRoute | findMatchingRoute({ url, sameOrigin, request, event }: RouteMatchCallbackOptions): {
route?: Route;
params?: RouteHandlerCallbackOptions["params"];
} {
const routes = this._routes.get(request.method as HTTPMethod) || [];
for (const route of routes) {
let params: Promise<any> | undefined;
/... | /**
* Checks a request and URL (and optionally an event) against the list of
* registered routes, and if there's a match, returns the corresponding
* route along with any params generated by the match.
*
* @param options
* @returns An object with `route` and `params` properties. They are populated
... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/Router.ts#L319-L367 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Router.setDefaultHandler | setDefaultHandler(handler: RouteHandler, method: HTTPMethod = defaultMethod): void {
this._defaultHandlerMap.set(method, normalizeHandler(handler));
} | /**
* Define a default handler that's called when no routes explicitly
* match the incoming request.
*
* Each HTTP method (`'GET'`, `'POST'`, etc.) gets its own default handler.
*
* Without a default handler, unmatched requests will go against the
* network as if there were no service worker presen... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/Router.ts#L382-L384 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Router.setCatchHandler | setCatchHandler(handler: RouteHandler): void {
this._catchHandler = normalizeHandler(handler);
} | /**
* If a `Route` throws an error while handling a request, this `handler`
* will be called and given a chance to provide a response.
*
* @param handler A callback function that returns a Promise resulting
* in a Response.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/Router.ts#L393-L395 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Router.registerCapture | registerCapture(capture: RegExp | string | RouteMatchCallback | Route, handler?: RouteHandler, method?: HTTPMethod): Route {
const route = parseRoute(capture, handler, method);
this.registerRoute(route);
return route;
} | /**
* Registers a `RegExp`, string, or function with a caching
* strategy to the router.
*
* @param capture If the capture param is a {@linkcode Route} object, all other arguments will be ignored.
* @param handler A callback function that returns a promise resulting in a response.
* This parameter is ... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/Router.ts#L407-L411 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Router.registerRoute | registerRoute(route: Route): void {
if (process.env.NODE_ENV !== "production") {
assert!.isType(route, "object", {
moduleName: "serwist/legacy",
className: "Router",
funcName: "registerRoute",
paramName: "route",
});
assert!.hasMethod(route, "match", {
modu... | /**
* Registers a route with the router.
*
* @param route The route to register.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/Router.ts#L418-L463 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | Router.unregisterRoute | unregisterRoute(route: Route): void {
if (!this._routes.has(route.method)) {
throw new SerwistError("unregister-route-but-not-found-with-method", {
method: route.method,
});
}
const routeIndex = this._routes.get(route.method)!.indexOf(route);
if (routeIndex > -1) {
this._route... | /**
* Unregisters a route from the router.
*
* @param route The route to unregister.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/Router.ts#L470-L483 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | createOnSyncCallback | const createOnSyncCallback = (config: Pick<GoogleAnalyticsInitializeOptions, "parameterOverrides" | "hitFilter">) => {
return async ({ queue }: { queue: BackgroundSyncQueue }) => {
let entry: BackgroundSyncQueueEntry | undefined = undefined;
while ((entry = await queue.shiftRequest())) {
const { request... | /**
* Creates the requestWillDequeue callback to be used with the background
* sync plugin. The callback takes the failed request and adds the
* `qt` param based on the current time, as well as applies any other
* user-defined hit modifications.
*
* @param config
* @returns The requestWillDequeue callback functi... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/initializeGoogleAnalytics.ts#L69-L130 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | createCollectRoutes | const createCollectRoutes = (bgSyncPlugin: BackgroundSyncPlugin) => {
const match = ({ url }: RouteMatchCallbackOptions) => url.hostname === GOOGLE_ANALYTICS_HOST && COLLECT_PATHS_REGEX.test(url.pathname);
const handler = new NetworkOnly({
plugins: [bgSyncPlugin],
});
return [new Route(match, handler, "GE... | /**
* Creates GET and POST routes to catch failed Measurement Protocol hits.
*
* @param bgSyncPlugin
* @returns The created routes.
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/initializeGoogleAnalytics.ts#L139-L147 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | createAnalyticsJsRoute | const createAnalyticsJsRoute = (cacheName: string) => {
const match = ({ url }: RouteMatchCallbackOptions) => url.hostname === GOOGLE_ANALYTICS_HOST && url.pathname === ANALYTICS_JS_PATH;
const handler = new NetworkFirst({ cacheName });
return new Route(match, handler, "GET");
}; | /**
* Creates a route with a network first strategy for the analytics.js script.
*
* @param cacheName
* @returns The created route.
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/initializeGoogleAnalytics.ts#L156-L162 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | createGtagJsRoute | const createGtagJsRoute = (cacheName: string) => {
const match = ({ url }: RouteMatchCallbackOptions) => url.hostname === GTM_HOST && url.pathname === GTAG_JS_PATH;
const handler = new NetworkFirst({ cacheName });
return new Route(match, handler, "GET");
}; | /**
* Creates a route with a network first strategy for the gtag.js script.
*
* @param cacheName
* @returns The created route.
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/initializeGoogleAnalytics.ts#L171-L177 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | createGtmJsRoute | const createGtmJsRoute = (cacheName: string) => {
const match = ({ url }: RouteMatchCallbackOptions) => url.hostname === GTM_HOST && url.pathname === GTM_JS_PATH;
const handler = new NetworkFirst({ cacheName });
return new Route(match, handler, "GET");
}; | /**
* Creates a route with a network first strategy for the gtm.js script.
*
* @param cacheName
* @returns The created route.
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/legacy/initializeGoogleAnalytics.ts#L186-L192 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncPlugin.constructor | constructor(name: string, options?: BackgroundSyncQueueOptions) {
this._queue = new BackgroundSyncQueue(name, options);
} | /**
* @param name See the {@linkcode BackgroundSyncQueue}
* documentation for parameter details.
* @param options See the {@linkcode BackgroundSyncQueue}
* documentation for parameter details.
* @see https://serwist.pages.dev/docs/serwist/core/background-sync-queue
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncPlugin.ts#L27-L29 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncPlugin.fetchDidFail | async fetchDidFail({ request }: FetchDidFailCallbackParam) {
await this._queue.pushRequest({ request });
} | /**
* @param options
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncPlugin.ts#L35-L37 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | convertEntry | const convertEntry = (queueStoreEntry: UnidentifiedQueueStoreEntry): BackgroundSyncQueueEntry => {
const queueEntry: BackgroundSyncQueueEntry = {
request: new StorableRequest(queueStoreEntry.requestData).toRequest(),
timestamp: queueStoreEntry.timestamp,
};
if (queueStoreEntry.metadata) {
queueEntry.m... | /**
* Converts a QueueStore entry into the format exposed by Queue. This entails
* converting the request data into a real request and omitting the `id` and
* `queueName` properties.
*
* @param queueStoreEntry
* @returns
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L109-L118 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue.constructor | constructor(name: string, { forceSyncFallback, onSync, maxRetentionTime }: BackgroundSyncQueueOptions = {}) {
// Ensure the store name is not already being used
if (queueNames.has(name)) {
throw new SerwistError("duplicate-queue-name", { name });
}
queueNames.add(name);
this._name = name;
... | /**
* Creates an instance of Queue with the given options
*
* @param name The unique name for this queue. This name must be
* unique as it's used to register sync events and store requests
* in IndexedDB specific to this instance. An error will be thrown if
* a duplicate name is detected.
* @param ... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L143-L157 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue.name | get name(): string {
return this._name;
} | /**
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L162-L164 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue.pushRequest | async pushRequest(entry: BackgroundSyncQueueEntry): Promise<void> {
if (process.env.NODE_ENV !== "production") {
assert!.isType(entry, "object", {
moduleName: "serwist",
className: "BackgroundSyncQueue",
funcName: "pushRequest",
paramName: "entry",
});
assert!.isIns... | /**
* Stores the passed request in IndexedDB (with its timestamp and any
* metadata) at the end of the queue.
*
* @param entry
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L172-L189 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue.unshiftRequest | async unshiftRequest(entry: BackgroundSyncQueueEntry): Promise<void> {
if (process.env.NODE_ENV !== "production") {
assert!.isType(entry, "object", {
moduleName: "serwist",
className: "BackgroundSyncQueue",
funcName: "unshiftRequest",
paramName: "entry",
});
assert!... | /**
* Stores the passed request in IndexedDB (with its timestamp and any
* metadata) at the beginning of the queue.
*
* @param entry
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L197-L214 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue.popRequest | async popRequest(): Promise<BackgroundSyncQueueEntry | undefined> {
return this._removeRequest("pop");
} | /**
* Removes and returns the last request in the queue (along with its
* timestamp and any metadata).
*
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L222-L224 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue.shiftRequest | async shiftRequest(): Promise<BackgroundSyncQueueEntry | undefined> {
return this._removeRequest("shift");
} | /**
* Removes and returns the first request in the queue (along with its
* timestamp and any metadata).
*
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L232-L234 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue.getAll | async getAll(): Promise<BackgroundSyncQueueEntry[]> {
const allEntries = await this._queueStore.getAll();
const now = Date.now();
const unexpiredEntries = [];
for (const entry of allEntries) {
// Ignore requests older than maxRetentionTime. Call this function
// recursively until an unexpir... | /**
* Returns all the entries that have not expired (per `maxRetentionTime`).
* Any expired entries are removed from the queue.
*
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L242-L259 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue.size | async size(): Promise<number> {
return await this._queueStore.size();
} | /**
* Returns the number of entries present in the queue.
* Note that expired entries (per `maxRetentionTime`) are also included in this count.
*
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L267-L269 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue._addRequest | async _addRequest({ request, metadata, timestamp = Date.now() }: BackgroundSyncQueueEntry, operation: "push" | "unshift"): Promise<void> {
const storableRequest = await StorableRequest.fromRequest(request.clone());
const entry: UnidentifiedQueueStoreEntry = {
requestData: storableRequest.toObject(),
... | /**
* Adds the entry to the QueueStore and registers for a sync event.
*
* @param entry
* @param operation
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L278-L311 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue._removeRequest | async _removeRequest(operation: "pop" | "shift"): Promise<BackgroundSyncQueueEntry | undefined> {
const now = Date.now();
let entry: BackgroundSyncQueueStoreEntry | undefined;
switch (operation) {
case "pop":
entry = await this._queueStore.popEntry();
break;
case "shift":
... | /**
* Removes and returns the first or last (depending on `operation`) entry
* from the {@linkcode BackgroundSyncQueueStore} that's not older than the `maxRetentionTime`.
*
* @param operation
* @returns
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L321-L345 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue.replayRequests | async replayRequests(): Promise<void> {
let entry: BackgroundSyncQueueEntry | undefined = undefined;
while ((entry = await this.shiftRequest())) {
try {
await fetch(entry.request.clone());
if (process.env.NODE_ENV !== "production") {
logger.log(`Request for '${getFriendlyURL(ent... | /**
* Loops through each request in the queue and attempts to re-fetch it.
* If any request fails to re-fetch, it's put back in the same position in
* the queue (which registers a retry for the next sync event).
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L352-L373 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue.registerSync | async registerSync(): Promise<void> {
// See https://github.com/GoogleChrome/workbox/issues/2393
if ("sync" in self.registration && !this._forceSyncFallback) {
try {
await self.registration.sync.register(`${TAG_PREFIX}:${this._name}`);
} catch (err) {
// This means the registration f... | /**
* Registers a sync event with a tag unique to this instance.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L378-L391 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue._addSyncListener | private _addSyncListener() {
// See https://github.com/GoogleChrome/workbox/issues/2393
if ("sync" in self.registration && !this._forceSyncFallback) {
self.addEventListener("sync", (event: SyncEvent) => {
if (event.tag === `${TAG_PREFIX}:${this._name}`) {
if (process.env.NODE_ENV !== "pr... | /**
* In sync-supporting browsers, this adds a listener for the sync event.
* In non-sync-supporting browsers, or if _forceSyncFallback is true, this
* will retry the queue on service worker startup.
*
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L400-L449 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueue._queueNames | static get _queueNames(): Set<string> {
return queueNames;
} | /**
* Returns the set of queue names. This is primarily used to reset the list
* of queue names in tests.
*
* @returns
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueue.ts#L458-L460 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueDb.addEntry | async addEntry(entry: UnidentifiedQueueStoreEntry): Promise<void> {
const db = await this.getDb();
const tx = db.transaction(REQUEST_OBJECT_STORE_NAME, "readwrite", {
durability: "relaxed",
});
await tx.store.add(entry as BackgroundSyncQueueStoreEntry);
await tx.done;
} | /**
* Add QueueStoreEntry to underlying db.
*
* @param entry
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueDb.ts#L55-L62 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueDb.getFirstEntryId | async getFirstEntryId(): Promise<number | undefined> {
const db = await this.getDb();
const cursor = await db.transaction(REQUEST_OBJECT_STORE_NAME).store.openCursor();
return cursor?.value.id;
} | /**
* Returns the first entry id in the ObjectStore.
*
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueDb.ts#L69-L73 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueDb.getAllEntriesByQueueName | async getAllEntriesByQueueName(queueName: string): Promise<BackgroundSyncQueueStoreEntry[]> {
const db = await this.getDb();
const results = await db.getAllFromIndex(REQUEST_OBJECT_STORE_NAME, QUEUE_NAME_INDEX, IDBKeyRange.only(queueName));
return results ? results : new Array<BackgroundSyncQueueStoreEntry>... | /**
* Get all the entries filtered by index
*
* @param queueName
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueDb.ts#L81-L85 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueDb.getEntryCountByQueueName | async getEntryCountByQueueName(queueName: string): Promise<number> {
const db = await this.getDb();
return db.countFromIndex(REQUEST_OBJECT_STORE_NAME, QUEUE_NAME_INDEX, IDBKeyRange.only(queueName));
} | /**
* Returns the number of entries filtered by index
*
* @param queueName
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueDb.ts#L93-L96 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueDb.deleteEntry | async deleteEntry(id: number): Promise<void> {
const db = await this.getDb();
await db.delete(REQUEST_OBJECT_STORE_NAME, id);
} | /**
* Deletes a single entry by id.
*
* @param id the id of the entry to be deleted
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueDb.ts#L103-L106 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueDb.getFirstEntryByQueueName | async getFirstEntryByQueueName(queueName: string): Promise<BackgroundSyncQueueStoreEntry | undefined> {
return await this.getEndEntryFromIndex(IDBKeyRange.only(queueName), "next");
} | /**
*
* @param queueName
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueDb.ts#L113-L115 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueDb.getLastEntryByQueueName | async getLastEntryByQueueName(queueName: string): Promise<BackgroundSyncQueueStoreEntry | undefined> {
return await this.getEndEntryFromIndex(IDBKeyRange.only(queueName), "prev");
} | /**
*
* @param queueName
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueDb.ts#L122-L124 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueDb.getEndEntryFromIndex | async getEndEntryFromIndex(query: IDBKeyRange, direction: IDBCursorDirection): Promise<BackgroundSyncQueueStoreEntry | undefined> {
const db = await this.getDb();
const cursor = await db.transaction(REQUEST_OBJECT_STORE_NAME).store.index(QUEUE_NAME_INDEX).openCursor(query, direction);
return cursor?.value;... | /**
* Returns either the first or the last entries, depending on direction.
* Filtered by index.
*
* @param direction
* @param query
* @returns
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueDb.ts#L135-L140 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueDb.getDb | private async getDb() {
if (!this._db) {
this._db = await openDB(BACKGROUND_SYNC_DB_NAME, BACKGROUND_SYNC_DB_VERSION, {
upgrade: this._upgradeDb,
});
}
return this._db;
} | /**
* Returns an open connection to the database.
*
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueDb.ts#L147-L154 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueDb._upgradeDb | private _upgradeDb(db: IDBPDatabase<BackgroundSyncQueueDBSchema>, oldVersion: number) {
if (oldVersion > 0 && oldVersion < BACKGROUND_SYNC_DB_VERSION) {
if (db.objectStoreNames.contains(REQUEST_OBJECT_STORE_NAME)) {
db.deleteObjectStore(REQUEST_OBJECT_STORE_NAME);
}
}
const objStore = d... | /**
* Upgrades QueueDB
*
* @param db
* @param oldVersion
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueDb.ts#L163-L175 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueStore.constructor | constructor(queueName: string) {
this._queueName = queueName;
this._queueDb = new BackgroundSyncQueueDb();
} | /**
* Associates this instance with a Queue instance, so entries added can be
* identified by their queue name.
*
* @param queueName
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueStore.ts#L29-L32 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueStore.pushEntry | async pushEntry(entry: UnidentifiedQueueStoreEntry): Promise<void> {
if (process.env.NODE_ENV !== "production") {
assert!.isType(entry, "object", {
moduleName: "serwist",
className: "BackgroundSyncQueueStore",
funcName: "pushEntry",
paramName: "entry",
});
assert!.i... | /**
* Append an entry last in the queue.
*
* @param entry
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueStore.ts#L39-L60 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueStore.unshiftEntry | async unshiftEntry(entry: UnidentifiedQueueStoreEntry): Promise<void> {
if (process.env.NODE_ENV !== "production") {
assert!.isType(entry, "object", {
moduleName: "serwist",
className: "BackgroundSyncQueueStore",
funcName: "unshiftEntry",
paramName: "entry",
});
ass... | /**
* Prepend an entry first in the queue.
*
* @param entry
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueStore.ts#L67-L95 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueStore.popEntry | async popEntry(): Promise<BackgroundSyncQueueStoreEntry | undefined> {
return this._removeEntry(await this._queueDb.getLastEntryByQueueName(this._queueName));
} | /**
* Removes and returns the last entry in the queue matching the `queueName`.
*
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueStore.ts#L102-L104 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueStore.shiftEntry | async shiftEntry(): Promise<BackgroundSyncQueueStoreEntry | undefined> {
return this._removeEntry(await this._queueDb.getFirstEntryByQueueName(this._queueName));
} | /**
* Removes and returns the first entry in the queue matching the `queueName`.
*
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueStore.ts#L111-L113 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueStore.getAll | async getAll(): Promise<BackgroundSyncQueueStoreEntry[]> {
return await this._queueDb.getAllEntriesByQueueName(this._queueName);
} | /**
* Returns all entries in the store matching the `queueName`.
*
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueStore.ts#L120-L122 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueStore.size | async size(): Promise<number> {
return await this._queueDb.getEntryCountByQueueName(this._queueName);
} | /**
* Returns the number of entries in the store matching the `queueName`.
*
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueStore.ts#L129-L131 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueStore.deleteEntry | async deleteEntry(id: number): Promise<void> {
await this._queueDb.deleteEntry(id);
} | /**
* Deletes the entry for the given ID.
*
* WARNING: this method does not ensure the deleted entry belongs to this
* queue (i.e. matches the `queueName`). But this limitation is acceptable
* as this class is not publicly exposed. An additional check would make
* this method slower than it needs to b... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueStore.ts#L143-L145 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BackgroundSyncQueueStore._removeEntry | async _removeEntry(entry?: BackgroundSyncQueueStoreEntry): Promise<BackgroundSyncQueueStoreEntry | undefined> {
if (entry) {
await this.deleteEntry(entry.id);
}
return entry;
} | /**
* Removes and returns the first or last entry in the queue (based on the
* `direction` argument) matching the `queueName`.
*
* @returns
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/BackgroundSyncQueueStore.ts#L154-L159 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | StorableRequest.fromRequest | static async fromRequest(request: Request): Promise<StorableRequest> {
const requestData: RequestData = {
url: request.url,
headers: {},
};
// Set the body if present.
if (request.method !== "GET") {
// Use ArrayBuffer to support non-text request bodies.
// NOTE: we can't use Bl... | /**
* Converts a Request object to a plain object that can be structured
* cloned or stringified to JSON.
*
* @param request
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/StorableRequest.ts#L49-L76 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | StorableRequest.constructor | constructor(requestData: RequestData) {
if (process.env.NODE_ENV !== "production") {
assert!.isType(requestData, "object", {
moduleName: "serwist",
className: "StorableRequest",
funcName: "constructor",
paramName: "requestData",
});
assert!.isType(requestData.url, "... | /**
* Accepts an object of request data that can be used to construct a
* `Request` object but can also be stored in IndexedDB.
*
* @param requestData An object of request data that includes the `url` plus any relevant property of
* [`requestInit`](https://fetch.spec.whatwg.org/#requestinit).
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/StorableRequest.ts#L85-L108 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | StorableRequest.toObject | toObject(): RequestData {
const requestData = Object.assign({}, this._requestData);
requestData.headers = Object.assign({}, this._requestData.headers);
if (requestData.body) {
requestData.body = requestData.body.slice(0);
}
return requestData;
} | /**
* Returns a deep clone of the instance's `requestData` object.
*
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/StorableRequest.ts#L115-L123 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | StorableRequest.toRequest | toRequest(): Request {
return new Request(this._requestData.url, this._requestData);
} | /**
* Converts this instance to a Request.
*
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/StorableRequest.ts#L130-L132 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | StorableRequest.clone | clone(): StorableRequest {
return new StorableRequest(this.toObject());
} | /**
* Creates and returns a deep clone of the instance.
*
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/backgroundSync/StorableRequest.ts#L139-L141 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | defaultPayloadGenerator | const defaultPayloadGenerator = (data: CacheDidUpdateCallbackParam): BroadcastPayload => {
return {
cacheName: data.cacheName,
updatedURL: data.request.url,
};
}; | /**
* Generates the default payload used in update messages. By default the
* payload includes the `cacheName` and `updatedURL` fields.
*
* @returns
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/broadcastUpdate/BroadcastCacheUpdate.ts#L37-L42 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BroadcastCacheUpdate.constructor | constructor({ generatePayload, headersToCheck, notifyAllClients }: BroadcastCacheUpdateOptions = {}) {
this._headersToCheck = headersToCheck || BROADCAST_UPDATE_DEFAULT_HEADERS;
this._generatePayload = generatePayload || defaultPayloadGenerator;
this._notifyAllClients = notifyAllClients ?? BROADCAST_UPDATE_... | /**
* Construct an instance of `BroadcastCacheUpdate`.
*
* @param options
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/broadcastUpdate/BroadcastCacheUpdate.ts#L61-L65 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BroadcastCacheUpdate.notifyIfUpdated | async notifyIfUpdated(options: CacheDidUpdateCallbackParam): Promise<void> {
if (process.env.NODE_ENV !== "production") {
assert!.isType(options.cacheName, "string", {
moduleName: "serwist",
className: "BroadcastCacheUpdate",
funcName: "notifyIfUpdated",
paramName: "cacheName",... | /**
* Compares two responses and sends a message (via `postMessage()`) to all window clients if the
* responses differ. Neither of the Responses can be opaque.
*
* The message that's posted has the following format (where `payload` can
* be customized via the `generatePayload` option the instance is crea... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/broadcastUpdate/BroadcastCacheUpdate.ts#L89-L164 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BroadcastUpdatePlugin.constructor | constructor(options?: BroadcastCacheUpdateOptions) {
this._broadcastUpdate = new BroadcastCacheUpdate(options);
} | /**
* Construct a {@linkcode BroadcastCacheUpdate} instance with
* the passed options and calls its {@linkcode BroadcastCacheUpdate.notifyIfUpdated}
* method whenever the plugin's {@linkcode BroadcastUpdatePlugin.cacheDidUpdate} callback
* is invoked.
*
* @param options
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/broadcastUpdate/BroadcastUpdatePlugin.ts#L28-L30 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | BroadcastUpdatePlugin.cacheDidUpdate | cacheDidUpdate(options: CacheDidUpdateCallbackParam) {
void this._broadcastUpdate.notifyIfUpdated(options);
} | /**
* @private
* @param options The input object to this function.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/broadcastUpdate/BroadcastUpdatePlugin.ts#L36-L38 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | CacheableResponse.constructor | constructor(config: CacheableResponseOptions = {}) {
if (process.env.NODE_ENV !== "production") {
if (!(config.statuses || config.headers)) {
throw new SerwistError("statuses-or-headers-required", {
moduleName: "serwist",
className: "CacheableResponse",
funcName: "constru... | /**
* To construct a new `CacheableResponse` instance you must provide at least
* one of the `config` properties.
*
* If both `statuses` and `headers` are specified, then both conditions must
* be met for the response to be considered cacheable.
*
* @param config
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/cacheableResponse/CacheableResponse.ts#L44-L77 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | CacheableResponse.isResponseCacheable | isResponseCacheable(response: Response): boolean {
if (process.env.NODE_ENV !== "production") {
assert!.isInstance(response, Response, {
moduleName: "serwist",
className: "CacheableResponse",
funcName: "isResponseCacheable",
paramName: "response",
});
}
let cache... | /**
* Checks a response to see whether it's cacheable or not.
*
* @param response The response whose cacheability is being
* checked.
* @returns `true` if the response is cacheable, and `false`
* otherwise.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/cacheableResponse/CacheableResponse.ts#L87-L143 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | CacheableResponsePlugin.constructor | constructor(config: CacheableResponseOptions) {
this._cacheableResponse = new CacheableResponse(config);
} | /**
* To construct a new `CacheableResponsePlugin` instance you must provide at
* least one of the `config` properties.
*
* If both `statuses` and `headers` are specified, then both conditions must
* be met for the response to be considered cacheable.
*
* @param config
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/cacheableResponse/CacheableResponsePlugin.ts#L30-L32 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | CacheableResponsePlugin.cacheWillUpdate | cacheWillUpdate: SerwistPlugin["cacheWillUpdate"] = async ({ response }) => {
if (this._cacheableResponse.isResponseCacheable(response)) {
return response;
}
return null;
} | /**
* @param options
* @returns
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/cacheableResponse/CacheableResponsePlugin.ts | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | CacheExpiration.constructor | constructor(cacheName: string, config: CacheExpirationConfig = {}) {
if (process.env.NODE_ENV !== "production") {
assert!.isType(cacheName, "string", {
moduleName: "serwist",
className: "CacheExpiration",
funcName: "constructor",
paramName: "cacheName",
});
if (!(c... | /**
* To construct a new `CacheExpiration` instance you must provide at least
* one of the `config` properties.
*
* @param cacheName Name of the cache to apply restrictions to.
* @param config
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/expiration/CacheExpiration.ts#L51-L92 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | CacheExpiration.expireEntries | async expireEntries(): Promise<void> {
if (this._isRunning) {
this._rerunRequested = true;
return;
}
this._isRunning = true;
const minTimestamp = this._maxAgeSeconds ? Date.now() - this._maxAgeSeconds * 1000 : 0;
const urlsExpired = await this._timestampModel.expireEntries(minTimestamp... | /**
* Expires entries for the given cache and given criteria.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/expiration/CacheExpiration.ts#L97-L137 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | CacheExpiration.updateTimestamp | async updateTimestamp(url: string): Promise<void> {
if (process.env.NODE_ENV !== "production") {
assert!.isType(url, "string", {
moduleName: "serwist",
className: "CacheExpiration",
funcName: "updateTimestamp",
paramName: "url",
});
}
await this._timestampModel.s... | /**
* Updates the timestamp for the given URL, allowing it to be correctly
* tracked by the class.
*
* @param url
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/expiration/CacheExpiration.ts#L145-L156 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | CacheExpiration.isURLExpired | async isURLExpired(url: string): Promise<boolean> {
if (!this._maxAgeSeconds) {
if (process.env.NODE_ENV !== "production") {
throw new SerwistError("expired-test-without-max-age", {
methodName: "isURLExpired",
paramName: "maxAgeSeconds",
});
}
return false;
... | /**
* Checks if a URL has expired or not before it's used.
*
* This looks the timestamp up in IndexedDB and can be slow.
*
* Note: This method does not remove an expired entry, call
* `expireEntries()` to remove such entries instead.
*
* @param url
* @returns
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/expiration/CacheExpiration.ts#L169-L182 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | CacheExpiration.delete | async delete(): Promise<void> {
// Make sure we don't attempt another rerun if we're called in the middle of
// a cache expiration.
this._rerunRequested = false;
await this._timestampModel.expireEntries(Number.POSITIVE_INFINITY); // Expires all.
} | /**
* Removes the IndexedDB used to keep track of cache expiration metadata.
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/expiration/CacheExpiration.ts#L187-L192 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | ExpirationPlugin.constructor | constructor(config: ExpirationPluginOptions = {}) {
if (process.env.NODE_ENV !== "production") {
if (!(config.maxEntries || config.maxAgeSeconds)) {
throw new SerwistError("max-entries-or-age-required", {
moduleName: "serwist",
className: "ExpirationPlugin",
funcName: "co... | /**
* @param config
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/expiration/ExpirationPlugin.ts#L76-L124 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | ExpirationPlugin._getCacheExpiration | private _getCacheExpiration(cacheName: string): CacheExpiration {
if (cacheName === privateCacheNames.getRuntimeName()) {
throw new SerwistError("expire-custom-caches-only");
}
let cacheExpiration = this._cacheExpirations.get(cacheName);
if (!cacheExpiration) {
cacheExpiration = new CacheEx... | /**
* A simple helper method to return a CacheExpiration instance for a given
* cache name.
*
* @param cacheName
* @returns
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/expiration/ExpirationPlugin.ts#L134-L145 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | ExpirationPlugin.cachedResponseWillBeUsed | cachedResponseWillBeUsed({ event, cacheName, request, cachedResponse }: CachedResponseWillBeUsedCallbackParam) {
if (!cachedResponse) {
return null;
}
const isFresh = this._isResponseDateFresh(cachedResponse);
// Expire entries to ensure that even if the expiration date has
// expired, it'll... | /**
* A lifecycle callback that will be triggered automatically when a
* response is about to be returned from a [`Cache`](https://developer.mozilla.org/en-US/docs/Web/API/Cache).
* It allows the response to be inspected for freshness and
* prevents it from being used if the response's `Date` header value i... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/expiration/ExpirationPlugin.ts#L159-L194 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | ExpirationPlugin._isResponseDateFresh | private _isResponseDateFresh(cachedResponse: Response): boolean {
const isMaxAgeFromLastUsed = this._config.maxAgeFrom === "last-used";
// If `maxAgeFrom` is `"last-used"`, the `Date` header doesn't really
// matter since it is about when the response was created.
if (isMaxAgeFromLastUsed) {
retur... | /**
* @param cachedResponse
* @returns
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/expiration/ExpirationPlugin.ts#L201-L223 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | ExpirationPlugin._getDateHeaderTimestamp | private _getDateHeaderTimestamp(cachedResponse: Response): number | null {
if (!cachedResponse.headers.has("date")) {
return null;
}
const dateHeader = cachedResponse.headers.get("date")!;
const parsedDate = new Date(dateHeader);
const headerTime = parsedDate.getTime();
// If the `Date` ... | /**
* Extracts the `Date` header and parse it into an useful value.
*
* @param cachedResponse
* @returns
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/expiration/ExpirationPlugin.ts#L232-L248 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | ExpirationPlugin.cacheDidUpdate | async cacheDidUpdate({ cacheName, request }: CacheDidUpdateCallbackParam) {
if (process.env.NODE_ENV !== "production") {
assert!.isType(cacheName, "string", {
moduleName: "serwist",
className: "Plugin",
funcName: "cacheDidUpdate",
paramName: "cacheName",
});
assert!... | /**
* A lifecycle callback that will be triggered automatically when an entry is added
* to a cache.
*
* @param options
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/expiration/ExpirationPlugin.ts#L257-L276 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | ExpirationPlugin.deleteCacheAndMetadata | async deleteCacheAndMetadata(): Promise<void> {
// Do this one at a time instead of all at once via `Promise.all()` to
// reduce the chance of inconsistency if a promise rejects.
for (const [cacheName, cacheExpiration] of this._cacheExpirations) {
await self.caches.delete(cacheName);
await cache... | /**
* Deletes the underlying `Cache` instance associated with this instance and the metadata
* from IndexedDB used to keep track of expiration details for each `Cache` instance.
*
* When using cache expiration, calling this method is preferable to calling
* `caches.delete()` directly, since this will ens... | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/expiration/ExpirationPlugin.ts#L290-L300 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
serwist | github_2023 | serwist | typescript | CacheTimestampsModel.constructor | constructor(cacheName: string) {
this._cacheName = cacheName;
} | /**
*
* @param cacheName
*
* @private
*/ | https://github.com/serwist/serwist/blob/9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f/packages/core/src/lib/expiration/models/CacheTimestampsModel.ts#L52-L54 | 9dc72e205f8079b7ace12d2d4ea9aad7bc1cb83f |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.