@3cr/viewer-browser 0.0.153 → 0.0.155

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3cr/viewer-browser",
3
- "version": "0.0.153",
3
+ "version": "0.0.155",
4
4
  "main": "./dist/Viewer3CR.umd.js",
5
5
  "module": "dist/Viewer3CR.umd.js",
6
6
  "homepage": "https://docs.3cr.singular.health",
@@ -8,10 +8,8 @@
8
8
  <script src="https://cdn.jsdelivr.net/npm/@3cr/viewer-browser@{{version}}/dist/Viewer3CR.umd.js"> </script>
9
9
  <script type="module">
10
10
  function invokeServiceWorkerUpdateFlow(registration) {
11
- if (registration.waiting) {
12
- // let waiting Service Worker know it should became active
11
+ console.log('[SW] Found update, pushing')
13
12
  registration.waiting.postMessage('SKIP_WAITING')
14
- }
15
13
  }
16
14
  function initServiceWorker() {
17
15
  // Only enable service worker in production
package/playground/sw.js CHANGED
@@ -8,12 +8,18 @@ self.addEventListener("activate", async () => {
8
8
  });
9
9
  });
10
10
 
11
- self.addEventListener("message", (event) => {
11
+ self.addEventListener("message", async (event) => {
12
12
  if (event.data === "SKIP_WAITING") {
13
- self.skipWaiting().then((r) => {});
13
+ await self.skipWaiting();
14
14
  }
15
15
  });
16
16
  self.addEventListener("fetch", (event) => {
17
+ if (
18
+ event.request.url.includes("statsigapi") ||
19
+ event.request.url.includes("featuregates")
20
+ ) {
21
+ return;
22
+ }
17
23
  event.respondWith(handleServerRequest(event.request));
18
24
  });
19
25
 
@@ -34,6 +40,8 @@ async function handleServerRequest(request) {
34
40
  // If not in cache, fetch from the network
35
41
  const networkResponse = await fetch(request);
36
42
  // Save the fetched response in the cache for future use
37
- cache.put(request, networkResponse.clone());
43
+ if (request.method === "GET")
44
+ await cache.put(request, networkResponse.clone());
45
+
38
46
  return networkResponse; // Return the fetched response
39
47
  }