Skip to content

Instantly share code, notes, and snippets.

@ridheshcybe
Created January 15, 2022 10:23
Show Gist options
  • Save ridheshcybe/374d92e74d8fb3f80a4f1d72e421cd83 to your computer and use it in GitHub Desktop.
Save ridheshcybe/374d92e74d8fb3f80a4f1d72e421cd83 to your computer and use it in GitHub Desktop.
!(function() {
"use strict";
try {
self["workbox:sw:6.1.5"];
} catch (t) {}
const t = {
backgroundSync: "background-sync",
broadcastUpdate: "broadcast-update",
cacheableResponse: "cacheable-response",
core: "core",
expiration: "expiration",
googleAnalytics: "offline-ga",
navigationPreload: "navigation-preload",
precaching: "precaching",
rangeRequests: "range-requests",
routing: "routing",
strategies: "strategies",
streams: "streams",
recipes: "recipes"
};
self.workbox = new (class {
constructor() {
return (
(this.v = {}),
(this.Pt = {
debug: "localhost" === self.location.hostname,
modulePathPrefix: null,
modulePathCb: null
}),
(this.$t = this.Pt.debug ? "dev" : "prod"),
(this.jt = !1),
new Proxy(this, {
get(e, s) {
if (e[s]) return e[s];
const o = t[s];
return o && e.loadModule("workbox-" + o), e[s];
}
})
);
}
setConfig(t = {}) {
if (this.jt)
throw new Error(
"Config must be set before accessing workbox.* modules"
);
Object.assign(this.Pt, t), (this.$t = this.Pt.debug ? "dev" : "prod");
}
loadModule(t) {
const e = this.St(t);
try {
importScripts(e), (this.jt = !0);
} catch (s) {
throw (console.error(`Unable to import module '${t}' from '${e}'.`), s);
}
}
St(t) {
if (this.Pt.modulePathCb) return this.Pt.modulePathCb(t, this.Pt.debug);
let e = ["https://storage.googleapis.com/workbox-cdn/releases/6.1.5"];
const s = `${t}.${this.$t}.js`,
o = this.Pt.modulePathPrefix;
return (
o &&
((e = o.split("/")),
"" === e[e.length - 1] && e.splice(e.length - 1, 1)),
e.push(s),
e.join("/")
);
}
})();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment