@cocreate/pwa 1.10.0 → 1.10.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## [1.10.2](https://github.com/CoCreate-app/CoCreate-pwa/compare/v1.10.1...v1.10.2) (2023-09-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * fileUl using pathname ([b25f638](https://github.com/CoCreate-app/CoCreate-pwa/commit/b25f63862c27fdc0a68fb7b1ad10fe730f968e07))
7
+
8
+ ## [1.10.1](https://github.com/CoCreate-app/CoCreate-pwa/compare/v1.10.0...v1.10.1) (2023-09-18)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Add path and pathname ([1eaa09c](https://github.com/CoCreate-app/CoCreate-pwa/commit/1eaa09c1bb7dab55868e02ac4b994b1464a4f38e))
14
+ * bug in cache ([35229bc](https://github.com/CoCreate-app/CoCreate-pwa/commit/35229bc521e867ece5bc8140d9cdfcde0587220b))
15
+ * set cache name ([35fcedd](https://github.com/CoCreate-app/CoCreate-pwa/commit/35fceddf099cb74a028a8ae2448e6d6ee4cb9ee4))
16
+ * Update CoCreate depndencies to latest versions ([42fca0a](https://github.com/CoCreate-app/CoCreate-pwa/commit/42fca0a8852974cf5aec912e00c1b2d8dc7ff0f6))
17
+
1
18
  # [1.10.0](https://github.com/CoCreate-app/CoCreate-pwa/compare/v1.9.2...v1.10.0) (2023-09-17)
2
19
 
3
20
 
@@ -8,17 +8,16 @@ module.exports = {
8
8
  "object": {
9
9
  "_id": "637ca5ac50234ef1671ce327",
10
10
  "name": "index.html",
11
- "path": "/docs/pwa/index.html",
11
+ "path": "/docs/pwa",
12
+ "pathname": "/docs/pwa/index.html",
12
13
  "src": "{{./docs/index.html}}",
13
14
  "host": [
14
15
  "cocreate.app",
15
16
  "general.cocreate.app"
16
17
  ],
17
- "directory": "/docs/pwa",
18
- "parentDirectory": "{{parentDirectory}}",
18
+ "directory": "pwa",
19
19
  "content-type": "{{content-type}}",
20
- "public": "true",
21
- "website_id": "614298c2829b690010a5c031"
20
+ "public": "true"
22
21
  }
23
22
  }
24
23
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/pwa",
3
- "version": "1.10.0",
3
+ "version": "1.10.2",
4
4
  "description": "A simple pwa component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "pwa",
@@ -59,6 +59,6 @@
59
59
  "webpack-log": "^3.0.1"
60
60
  },
61
61
  "dependencies": {
62
- "@cocreate/local-storage": "^1.10.0"
62
+ "@cocreate/local-storage": "^1.10.2"
63
63
  }
64
64
  }
package/src/cache.js CHANGED
@@ -9,9 +9,6 @@ function putFile(cacheName, data) {
9
9
  return
10
10
  // Open the cache and update it with the new file data
11
11
  caches.open(cacheName).then((cache) => {
12
- // Construct the URL for the file based on the fileObject's path and src
13
- const fileUrl = new URL(data.name, window.location.origin + data.path).toString();
14
-
15
12
  // Create a Response object with the file data
16
13
  const fileResponse = new Response(data.src, {
17
14
  headers: {
@@ -20,6 +17,7 @@ function putFile(cacheName, data) {
20
17
  });
21
18
 
22
19
  // Update the cache with the new version (or add it if not in the cache)
20
+ const fileUrl = window.location.origin + data.pathname;
23
21
  cache.put(fileUrl, fileResponse).then(() => {
24
22
  console.log(`Updated cache for ${fileUrl}`);
25
23
  });
@@ -54,7 +52,7 @@ function fileChange(data) {
54
52
  return
55
53
 
56
54
  for (let i = 0; i < data.object.length; i++)
57
- putFile('test', data.object[i])
55
+ putFile('dynamic-v2', data.object[i])
58
56
  }
59
57
 
60
58
  socket.listen('create.object', (data) => fileChange(data));
@@ -46,7 +46,7 @@ self.addEventListener("fetch", async (e) => {
46
46
  caches
47
47
  .match(e.request)
48
48
  .then(async (cacheResponse) => {
49
- if (!navigator.onLine && !!cacheResponse && cacheType !== 'false') {
49
+ if (!navigator.onLine || !!cacheResponse && cacheType !== 'false') {
50
50
  return cacheResponse;
51
51
  } else {
52
52
  const networkResponse = await fetch(e.request);
@@ -58,10 +58,6 @@ self.addEventListener("fetch", async (e) => {
58
58
  if (storageHeader)
59
59
  storage = storageHeader
60
60
 
61
- if (!cacheResponse || cacheType === 'false' || cacheType === 'offline') {
62
- return networkResponse.clone();
63
- }
64
-
65
61
  if (cacheType && cacheType !== 'false') {
66
62
  console.log('caching')
67
63
 
@@ -86,6 +82,10 @@ self.addEventListener("fetch", async (e) => {
86
82
  });
87
83
  }
88
84
 
85
+ if (!cacheResponse || cacheType === 'false' || cacheType === 'offline') {
86
+ return networkResponse.clone();
87
+ }
88
+
89
89
  }
90
90
 
91
91
  if (!!cacheResponse && cacheType !== 'false' && cacheType !== 'offline') {