@cocreate/pwa 1.6.27 → 1.7.0

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/demo/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <meta charset="utf-8" />
6
6
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
7
7
  <meta
8
- name="viewport"
8
+ key="viewport"
9
9
  content="width=device-width; initial-scale=1; viewport-fit=cover" />
10
10
  <!-- import the webpage's stylesheet -->
11
11
  <link
@@ -23,7 +23,7 @@
23
23
  <meta name="apple-mobile-web-app-capable" content="yes" />
24
24
  <!--<hides status bar for a full screen experience omn ios only>-->
25
25
  <meta
26
- name="apple-mobile-web-app-status-bar-style"
26
+ key="apple-mobile-web-app-status-bar-style"
27
27
  content="black-translucent" />
28
28
 
29
29
  <link rel="apple-touch-startup-image" href="ios-startup.png" />
@@ -72,6 +72,7 @@
72
72
  <button actions="install" type="button" hidden>Install</button>
73
73
 
74
74
  <!-- <script src="../src/index.js" defer></script> -->
75
- <script src="../dist/CoCreate-pwa.js" defer></script>
75
+ <!-- <script src="../dist/CoCreate-pwa.js" defer></script> -->
76
+ <!-- <script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script> -->
76
77
  </body>
77
78
  </html>
@@ -1,92 +1,88 @@
1
- {
2
- "short_name": "CoCreate",
3
- "name": "CoCreate",
4
- "description": "Build your business in miutes",
5
- "protocol_handlers": [
6
- {
7
- "protocol": "web+jngl",
8
- "url": "/lookup?type=%s"
9
- },
10
- {
11
- "protocol": "web+jnglstore",
12
- "url": "/shop?for=%s"
13
- }
14
- ],
15
- "orientation": "portrait-primary",
16
- "icons": [
17
- {
18
- "src": "./assets/icons/icon-72x72.png",
19
- "type": "image/png",
20
- "sizes": "72x72"
21
- },
22
- {
23
- "src": "./assets/icons/icon-96x96.png",
24
- "type": "image/png",
25
- "sizes": "96x96"
26
- },
27
- {
28
- "src": "./assets/icons/icon-128x128.png",
29
- "type": "image/png",
30
- "sizes": "128x128"
31
- },
32
- {
33
- "src": "./assets/icons/icon-144x144.png",
34
- "type": "image/png",
35
- "sizes": "144x144"
36
- },
37
- {
38
- "src": "./assets/icons/icon-152x152.png",
39
- "type": "image/png",
40
- "sizes": "152x152"
41
- },
42
- {
43
- "src": "./assets/icons/icon-192x192.png",
44
- "type": "image/png",
45
- "sizes": "192x192"
46
- },
47
- {
48
- "src": "./assets/icons/icon-384x384.png",
49
- "type": "image/png",
50
- "sizes": "384x384"
51
- },
52
- {
53
- "src": "./assets/icons/icon-512x512.png",
54
- "type": "image/png",
55
- "sizes": "512x512",
56
- "purpose": "maskable"
57
- }
58
- ],
59
- "start_url": "/",
60
- "id": "/",
61
- "background_color": "whitesmoke",
62
- "display": "fullscreen",
63
- "theme_color": "#c7c7c7",
64
- "screenshots": [
65
- {
66
- "src": "./assets/screenshot-1.png",
67
- "type": "image/png",
68
- "sizes": "1903x950"
69
- }
70
- ],
71
- "categories": "productivity",
72
- "file_handlers": [
73
- {
74
- "action": "/open-file",
75
- "accept": {
76
- "text/*": [
77
- ".txt"
78
- ]
79
- }
80
- }
81
- ],
82
- "share_target": {
83
- "action": "/",
84
- "method": "GET",
85
- "enctype": "application/x-www-form-urlencoded",
86
- "params": {
87
- "title": "title",
88
- "text": "text",
89
- "url": "url"
90
- }
91
- }
1
+ {
2
+ "short_name": "CoCreate",
3
+ "name": "CoCreate",
4
+ "description": "Build your business in miutes",
5
+ "protocol_handlers": [
6
+ {
7
+ "protocol": "web+jngl",
8
+ "url": "/lookup?type=%s"
9
+ }
10
+ ],
11
+ "orientation": "portrait-primary",
12
+ "icons": [
13
+ {
14
+ "src": "./assets/icons/icon-72x72.png",
15
+ "type": "image/png",
16
+ "sizes": "72x72"
17
+ },
18
+ {
19
+ "src": "./assets/icons/icon-96x96.png",
20
+ "type": "image/png",
21
+ "sizes": "96x96"
22
+ },
23
+ {
24
+ "src": "./assets/icons/icon-128x128.png",
25
+ "type": "image/png",
26
+ "sizes": "128x128"
27
+ },
28
+ {
29
+ "src": "./assets/icons/icon-144x144.png",
30
+ "type": "image/png",
31
+ "sizes": "144x144"
32
+ },
33
+ {
34
+ "src": "./assets/icons/icon-152x152.png",
35
+ "type": "image/png",
36
+ "sizes": "152x152"
37
+ },
38
+ {
39
+ "src": "./assets/icons/icon-192x192.png",
40
+ "type": "image/png",
41
+ "sizes": "192x192"
42
+ },
43
+ {
44
+ "src": "./assets/icons/icon-384x384.png",
45
+ "type": "image/png",
46
+ "sizes": "384x384"
47
+ },
48
+ {
49
+ "src": "./assets/icons/icon-512x512.png",
50
+ "type": "image/png",
51
+ "sizes": "512x512",
52
+ "purpose": "maskable"
53
+ }
54
+ ],
55
+ "start_url": "/",
56
+ "id": "/",
57
+ "background_color": "whitesmoke",
58
+ "display": "fullscreen",
59
+ "theme_color": "#c7c7c7",
60
+ "screenshots": [
61
+ {
62
+ "src": "./assets/screenshot-1.png",
63
+ "type": "image/png",
64
+ "sizes": "1903x950"
65
+ }
66
+ ],
67
+ "categories": "productivity",
68
+ "file_handlers": [
69
+ {
70
+ "action": "/open-file",
71
+ "accept": {
72
+ "text/*": [
73
+ ".txt"
74
+ ]
75
+ }
76
+ }
77
+ ],
78
+ "share_target": {
79
+ "action": "/",
80
+ "method": "GET",
81
+ "enctype": "application/x-www-form-urlencoded",
82
+ "params": {
83
+ "title": "title",
84
+ "text": "text",
85
+ "url": "url"
86
+ }
87
+ }
92
88
  }
package/demo/offline.html CHANGED
@@ -6,7 +6,7 @@
6
6
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1" />
8
8
  <meta name="theme-color" content="#3f51b5" />
9
- <link rel="manifest" href="./manifest.webmanifest" />
9
+ <link rel="manifest" href="/manifest.webmanifest" />
10
10
  <style>
11
11
  body {
12
12
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
@@ -13,7 +13,6 @@
13
13
  <link rel="stylesheet" href="../css/test3.css" />
14
14
  <!-- Manifest -->
15
15
  <link rel="manifest" href="../manifest.webmanifest" />
16
- <!--<link rel="manifest" href="./manifest.webmanifest"> -->
17
16
  <link rel="manifest" href="/manifest.webmanifest" />
18
17
  </head>
19
18
 
package/docs/index.html CHANGED
@@ -11,10 +11,10 @@
11
11
  sizes="32x32"
12
12
  href="https://cocreate.app/images/favicon.ico" />
13
13
  <meta
14
- name="description"
14
+ key="description"
15
15
  content="A simple HTML5 and pure javascript component. Easy configuration using data-attributes and highly styleable." />
16
16
  <meta
17
- name="keywords"
17
+ key="keywords"
18
18
  content="helper classes, utility classes, css framework, css library, inline style classes" />
19
19
  <meta name="robots" content="index,follow" />
20
20
 
@@ -28,7 +28,7 @@
28
28
  </head>
29
29
 
30
30
  <body>
31
- <div collection="" document_id="" name="" id="cocreate-pwa">
31
+ <div array="" object="" key="" id="cocreate-pwa">
32
32
  <div
33
33
  class="display:flex flex-wrap:wrap justify-content:space-between margin:10px">
34
34
  <div class="display:flex align-items:center">
@@ -169,9 +169,9 @@
169
169
  <textarea
170
170
  type="code"
171
171
  lang="html"
172
- collection="demos"
173
- document_id=""
174
- name="demo"
172
+ array="demos"
173
+ object=""
174
+ key="demo"
175
175
  save="false"
176
176
  id="demo"
177
177
  class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
@@ -194,7 +194,7 @@
194
194
  show="#eye-slash"
195
195
  hide="#eye, #demo-preview"
196
196
  toggle="code-height"
197
- toggle-target="#demo-code"
197
+ toggle-selector="#demo-code"
198
198
  ><i
199
199
  class="height:18px fill:#505050"
200
200
  src="/assets/svg/eye.svg"></i
@@ -206,7 +206,7 @@
206
206
  show="#eye, #demo-preview"
207
207
  hide="#eye-slash"
208
208
  toggle="code-height"
209
- toggle-target="#demo-code"
209
+ toggle-selector="#demo-code"
210
210
  ><i
211
211
  class="height:20px fill:#505050"
212
212
  src="/assets/svg/eye-slash.svg"></i
@@ -233,7 +233,7 @@
233
233
  <a
234
234
  class="margin-right:5px"
235
235
  fullscreen
236
- fullscreen-target="#playground"></a>
236
+ fullscreen-selector="#playground"></a>
237
237
  </div>
238
238
  </div>
239
239
  <!-- End SandBox -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/pwa",
3
- "version": "1.6.27",
3
+ "version": "1.7.0",
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",
@@ -24,8 +24,10 @@
24
24
  "access": "public"
25
25
  },
26
26
  "scripts": {
27
- "start": "npx webpack --config webpack.config.js --watch",
28
- "build": "SET NODE_ENV=production npx webpack --config webpack.config.js",
27
+ "start": "npx webpack --config webpack.config.js",
28
+ "build": "npx webpack --mode=production --config webpack.config.js",
29
+ "dev": "npx webpack --config webpack.config.js --watch",
30
+ "pwa": "node ./node_modules/@cocreate/cli/src/commands/other/symlinkPwa.js",
29
31
  "postinstall": "node -e \"const { execSync } = require('child_process'); try { execSync('coc --version', { stdio: 'ignore' }); } catch (error) { try { execSync('npm install -g @cocreate/cli', { stdio: 'inherit' }); console.log('Installed \"@cocreate/cli\" globally.'); } catch (error) { console.error('Failed to install \"@cocreate/cli\" globally:', error); } }\""
30
32
  },
31
33
  "repository": {
@@ -33,7 +35,7 @@
33
35
  "url": "git+https://github.com/CoCreate-app/CoCreate-pwa.git"
34
36
  },
35
37
  "author": "CoCreate LLC",
36
- "license": "MIT",
38
+ "license": "AGPL-3.0",
37
39
  "bugs": {
38
40
  "url": "https://github.com/CoCreate-app/CoCreate-pwa/issues"
39
41
  },
@@ -57,6 +59,6 @@
57
59
  "webpack-log": "^3.0.1"
58
60
  },
59
61
  "dependencies": {
60
- "@cocreate/local-storage": "^1.7.20"
62
+ "@cocreate/local-storage": "^1.7.21"
61
63
  }
62
64
  }
package/src/cache.js CHANGED
@@ -3,7 +3,7 @@ const cacheBtn = document.getElementById('cacheBtn');
3
3
  function deleteCache(cache) {
4
4
  if ('serviceWorker' in navigator) {
5
5
  return caches.delete(key);
6
-
6
+
7
7
  // caches.keys().then(function(cacheNames) {
8
8
  // cacheNames.forEach(function(cacheName) {
9
9
  // if (cacheName == cache)
@@ -25,8 +25,8 @@ function deleteCache(cache) {
25
25
 
26
26
  function deleteFile(cacheName, fileName) {
27
27
  if ('serviceWorker' in navigator) {
28
- caches.open(cacheName).then(function(cache) {
29
- cache.delete(fileName).then(function(response) {
28
+ caches.open(cacheName).then(function (cache) {
29
+ cache.delete(fileName).then(function (response) {
30
30
  return response
31
31
  // console.log(cacheName, fileName, response)
32
32
  });
@@ -36,9 +36,9 @@ function deleteFile(cacheName, fileName) {
36
36
 
37
37
 
38
38
  if (cacheBtn) {
39
- cacheBtn.addEventListener('click', function() {
39
+ cacheBtn.addEventListener('click', function () {
40
40
  deleteFile('dynamic-v2', '/CoCreate-components/CoCreate-pwa/src/index.js');
41
41
  });
42
42
  }
43
43
 
44
- export {deleteCache, deleteFile}
44
+ export { deleteCache, deleteFile }
package/src/index.js CHANGED
@@ -1,4 +1,26 @@
1
- import {deleteCache, deleteFile} from './cache.js'
1
+ /********************************************************************************
2
+ * Copyright (C) 2023 CoCreate and Contributors.
3
+ *
4
+ * This program is free software: you can redistribute it and/or modify
5
+ * it under the terms of the GNU Affero General Public License as published
6
+ * by the Free Software Foundation, either version 3 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ ********************************************************************************/
17
+
18
+ // Commercial Licensing Information:
19
+ // For commercial use of this software without the copyleft provisions of the AGPLv3,
20
+ // you must obtain a commercial license from CoCreate LLC.
21
+ // For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
22
+
23
+ import { deleteCache, deleteFile } from './cache.js'
2
24
  import localStorage from '@cocreate/local-storage'
3
25
 
4
26
  const button = document.querySelector('[actions*="install"]');
@@ -26,7 +48,7 @@ window.addEventListener('beforeinstallprompt', (event) => {
26
48
  });
27
49
 
28
50
  if (button) {
29
- button.addEventListener('click', async() => {
51
+ button.addEventListener('click', async () => {
30
52
  // console.log('👍', 'installBtn-clicked');
31
53
  const promptEvent = window.deferredPrompt;
32
54
  if (!promptEvent) {
@@ -54,8 +76,8 @@ window.addEventListener('appinstalled', (event) => {
54
76
 
55
77
  async function persistData() {
56
78
  if (navigator.storage && navigator.storage.persist) {
57
- const result = await navigator.storage.persist();
58
- // console.log(`Data persisted: ${result}`);
79
+ const result = await navigator.storage.persist();
80
+ // console.log(`Data persisted: ${result}`);
59
81
  }
60
82
  }
61
83
 
@@ -64,36 +86,44 @@ if ('serviceWorker' in navigator) {
64
86
  if (window.CoCreateConfig && window.CoCreateConfig.serviceWorker)
65
87
  workerPath = window.CoCreateConfig.serviceWorker
66
88
  else
67
- workerPath = localStorage.getItem("serviceWorker") || '/sw.js'
89
+ workerPath = localStorage.getItem("serviceWorker") || '/service-worker.js'
68
90
 
69
91
  localStorage.setItem("serviceWorker", workerPath);
70
92
 
93
+ let cache
94
+ if (window.CoCreateConfig && window.CoCreateConfig.cache)
95
+ cache = window.CoCreateConfig.cache
96
+ else
97
+ cache = localStorage.getItem("cache") || 'false'
98
+
99
+ localStorage.setItem("cache", cache);
100
+ workerPath += `?cache=${cache}`
101
+
71
102
  let isPwa = true
72
103
  if (workerPath) {
73
104
  navigator.serviceWorker.getRegistrations().then(registrations => {
74
105
  if (registrations.length === 0 || isPwa == true)
75
- window.addEventListener("load", function(event) {
106
+ window.addEventListener("load", function () {
76
107
  navigator.serviceWorker.getRegistration(workerPath).then(registration => {
77
- if (registration && registration.active) {
108
+ if (registration && registration.active && registration.active.scriptURL.includes(workerPath)) {
78
109
  console.log('Service Worker Active')
79
110
  } else {
80
111
  navigator.serviceWorker.register(workerPath)
81
- .then(reg => {
82
- reg.onupdatefound = () => {
83
- const installingWorker = reg.installing;
84
- installingWorker.onstatechange = () => {
85
- // console.log('Service Worker', installingWorker.state);
112
+ .then(reg => {
113
+ reg.onupdatefound = () => {
114
+ const installingWorker = reg.installing;
115
+ installingWorker.onstatechange = () => {
116
+ // console.log('Service Worker', installingWorker.state);
117
+ }
86
118
  }
87
- }
88
- })
89
- .catch(err => console.log('SW ERROR', err));
119
+ })
120
+ .catch(err => console.log('SW ERROR', err));
90
121
  }
91
122
  });
92
- });
123
+ });
93
124
  });
94
125
 
95
126
  }
96
127
  }
97
128
 
98
-
99
- export default {deleteCache, deleteFile, persistData}
129
+ export default { deleteCache, deleteFile, persistData }