PageSourceSearch

https://escarpe.it/sw.js

js escarpe.it collected 2026-09-25 03:00:06 UTC 7,812 bytes, 211 lines download raw bytes

1const options = {"workboxURL":"https://cdn.jsdelivr.net/npm/[email protected]/workbox/workbox-sw.js","importScripts":[],"config":{"debug":false},"cacheOptions":{"cacheId":"modivo-pwa-cache","directoryIndex":"/","revision":"1"},"clientsClaim":true,"skipWaiting":true,"cleanupOutdatedCaches":true,"offlineAnalytics":false,"preCaching":[{"url":"/pwa/static/fonts/Lato/Lato-400-Regular.woff2?v=1__44b3b2","revision":null},{"url":"/pwa/static/fonts/Lato/Lato-600-Semibold.woff2?v=1__e02a36","revision":null},{"url":"/pwa/static/fonts/Lato/Lato-700-Bold.woff2?v=1__0f7ffe","revision":null},{"url":"/pwa/static/offline/scripts.js?v=1__e971e1","revision":null},{"url":"/pwa/static/offline/styles.css?v=1__7cf19f","revision":null},{"url":"/offline","revision":"1__ce94df-ba82e6-e1cebb"}],"runtimeCaching":[{"urlPattern":"/.*\\.(js|css|webp|jpg|gif|png|svg|woff2|woff|ttf|eot)","handler":"CacheFirst","method":"GET","strategyOptions":{"cacheName":"modivo-pwa-assets-cache"},"strategyPlugins":[{"use":"expiration.ExpirationPlugin","config":[{"maxEntries":60,"maxAgeSeconds":604800}]}]}],"offlinePage":false,"pagesURLPattern":"^((?:https?:\\/\\/)?(?:www\\.)?((modivo)([^\\/])*\\.(([^\\/]{2,3})|(local))\\/?((?:(?!((pwa\\/static)|(pwa\\/assets)|(trans\\/)|(rest\\/)|(graphql))).))*))$","offlineStrategy":"NetworkOnly"}
2
3importScripts(...[ options.workboxURL, ...options.importScripts ]);
4
5initWorkbox(workbox, options);
6workboxExtensions(workbox, options);
7precacheAssets(workbox, options);
8cachingExtensions(workbox, options);
9runtimeCaching(workbox, options);
10offlinePage(workbox, options);
11routingExtensions(workbox, options);
12
13function getProp(obj, prop) {
14    return prop.split('.').reduce((p, c) => p[c], obj);
15}
16
17function initWorkbox(workbox, options) {
18    if (options.config) {
19        // Set workbox config
20        workbox.setConfig(options.config);
21    }
22
23    if (options.cacheNames) {
24        // Set workbox cache names
25        workbox.core.setCacheNameDetails(options.cacheNames);
26    }
27
28    if (options.clientsClaim) {
29        // Start controlling any existing clients as soon as it activates
30        workbox.core.clientsClaim();
31    }
32
33    if (options.skipWaiting) {
34        workbox.core.skipWaiting();
35    }
36
37    if (options.cleanupOutdatedCaches) {
38        workbox.precaching.cleanupOutdatedCaches();
39    }
40
41    if (options.offlineAnalytics) {
42        // Enable offline Google Analytics tracking
43        workbox.googleAnalytics.initialize();
44    }
45}
46
47function precacheAssets(workbox, options) {
48    if (options.preCaching.length) {
49        workbox.precaching.precacheAndRoute(options.preCaching, options.cacheOptions);
50    }
51}
52
53function runtimeCaching(workbox, options) {
54    const requestInterceptor = {
55        requestWillFetch({ request }) {
56            if (request.cache === 'only-if-cached' && request.mode === 'no-cors') {
57                return new Request(request.url, { ...request, cache: 'default', mode: 'no-cors' });
58            }
59            return request;
60        },
61        fetchDidFail(ctx) {
62            ctx.error.message =
63                '[workbox] Network request for ' +
64                ctx.request.url +
65                ' threw an error: ' +
66                ctx.error.message;
67            console.error(ctx.error, 'Details:', ctx);
68        },
69        handlerDidError(ctx) {
70            ctx.error.message = `[workbox] Network handler threw an error: ` + ctx.error.message;
71            console.error(ctx.error, 'Details:', ctx);
72            return null;
73        },
74    };
75
76    for (const entry of options.runtimeCaching) {
77        const urlPattern = new RegExp(entry.urlPattern);
78        const method = entry.method || 'GET';
79
80        const plugins = (entry.strategyPlugins || []).map(
81            p => new (getProp(workbox, p.use))(...p.config)
82        );
83
84        plugins.unshift(requestInterceptor);
85
86        const strategyOptions = { ...entry.strategyOptions, plugins };
87
88        const strategy = new workbox.strategies[entry.handler](strategyOptions);
89
90        workbox.routing.registerRoute(urlPattern, strategy, method);
91    }
92}
93
94function offlinePage(workbox, options) {
95    if (options.offlinePage) {
96        // Register router handler for offlinePage
97        workbox.routing.registerRoute(new RegExp(options.pagesURLPattern), ({ request, event }) => {
98            const strategy = new workbox.strategies[options.offlineStrategy]();
99            return strategy
100                .handle({ request, event })
101                .catch(() => caches.match(options.offlinePage));
102        });
103    }
104}
105
106function workboxExtensions(workbox, options) {
107    const SYNERISE_TEST_KEY = 'test_key';
108
109const SYNERISE_SERVICE_WORKER_TOKENS = {
110    [SYNERISE_TEST_KEY]: 'hC1uOvuTOPF6',
111    pl: 'pHqNb4hGeK7Y',
112    cz: 'nyJ5vvIf7P9O',
113    sk: 'U7OJrhMWIyAv',
114    ro: 'TfxKDCpdfpC6',
115    bg: 'oQNKlW9LT2nM',
116    hu: 'kUU72eocfdqj',
117    gr: 'gK03vDZiOTpg',
118    it: 'yMYwq7i3jLQ4',
119    de: 'wDAFNMDZs9gY',
120    lt: 'iCCY4iCdc6cq',
121    ua: 'CXJrJz8pbmPt',
122    hr: 'wEskfxbx7UE2',
123    ee: 'A04swHQD33gA',
124    lv: 'HFDnNQNivLsY',
125    si: 'GBiYYIjAEuZj',
126};
127
128const getLangCodeFromHostname = hostname => {
129    const isk8sDev = hostname.endsWith('.dev.modivo.io') && hostname.startsWith('modivo-');
130    const isk8sStage = hostname.endsWith('.stage.modivo.io') && hostname.startsWith('modivo-');
131
132    if (isk8sDev || isk8sStage) {
133        return SYNERISE_TEST_KEY;
134    }
135
136    if (hostname.endsWith('.eobuwie.org') && hostname.startsWith('modivo-')) {
137        return /modivo-[a-z]*-([a-z]{2}).eobuwie.org/gm.exec(hostname)[1];
138    }
139
140    return hostname.split('.')[1];
141};
142
143function handleWorkboxExtensions() {
144    const {
145        location: { hostname },
146        importScripts,
147        // eslint-disable-next-line no-restricted-globals
148    } = self;
149
150    const syneriseServiceWorkerToken =
151        SYNERISE_SERVICE_WORKER_TOKENS[getLangCodeFromHostname(hostname)] || null;
152    const syneriseServiceWorkerPath = syneriseServiceWorkerToken
153        ? `https://s-api.modivo.pl/p/${syneriseServiceWorkerToken}.js`
154        : '';
155
156    try {
157        if (syneriseServiceWorkerPath) {
158            importScripts(syneriseServiceWorkerPath);
159        } else {
160            console.error(
161                '[sw] There is no SNR service worker hash for hostname',
162                hostname,
163                syneriseServiceWorkerPath
164            );
165        }
166    } catch (err) {
167        console.error('[sw] Error on importScripts from Synerise', err, syneriseServiceWorkerPath);
168    }
169}
170
171handleWorkboxExtensions();
172}
173
174function cachingExtensions(workbox, options) {
175    
176}
177
178function routingExtensions(workbox, options) {
179    /* eslint-disable no-undef */
180function handleOfflinePage(workbox, options, offlinePagePath) {
181    const WORKBOX_REVISION_KEY = '__WB_REVISION__';
182    let offlinePagePrecacheConfig = null;
183
184    if (options.preCaching && options.preCaching.length) {
185        offlinePagePrecacheConfig = options.preCaching.find(preCaching => {
186            if (typeof preCaching === 'object' && !Array.isArray(preCaching)) {
187                return preCaching.url === offlinePagePath;
188            }
189
190            return false;
191        });
192    }
193
194    if (options.pagesURLPattern && offlinePagePath && offlinePagePrecacheConfig) {
195        const { url, revision } = offlinePagePrecacheConfig;
196
197        // Register router handler for offlinePage
198        workbox.routing.registerRoute(new RegExp(options.pagesURLPattern), ({ request, event }) => {
199            const strategy = new workbox.strategies[options.offlineStrategy]();
200
201            const offlinePagePathWithRevision = `${url}?${WORKBOX_REVISION_KEY}=${revision}`;
202
203            return strategy
204                .handle({ request, event })
205                .catch(() => caches.match(offlinePagePathWithRevision));
206        });
207    }
208}
209
210handleOfflinePage(workbox, options, '/offline');
211}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.