create-walpole-ar 2.1.1 → 2.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-walpole-ar",
3
- "version": "2.1.1",
3
+ "version": "2.2.2",
4
4
  "description": "CLI para crear PWAs listas para producción",
5
5
  "bin": {
6
6
  "create-walpole-ar": "./index.js"
@@ -4,13 +4,19 @@
4
4
  <meta charset="UTF-8">
5
5
  <title>{{projectName}}</title>
6
6
  <link rel="manifest" href="manifest.json">
7
+ <link rel="stylesheet" href="style.css">
7
8
  </head>
8
9
  <body>
10
+ <!-- index.html -->
11
+ <div id="statusIndicator" class="status-circle"></div>
9
12
  <h1>Bienvenido a {{projectName}}</h1>
13
+ <!-- index.html -->
14
+ <button id="btnInstallApp" class="btn-install-pwa">Instalar App</button>
10
15
  <script>
11
16
  if ("serviceWorker" in navigator) {
12
17
  navigator.serviceWorker.register("sw.js");
13
18
  }
14
19
  </script>
20
+ <script type="module" src="script.js"></script>
15
21
  </body>
16
22
  </html>
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "{{projectName}}",
3
3
  "short_name": "{{projectName}}",
4
- "description": "Version 1.1.1 - WebPole AR PWA Core",
4
+ "description": "Version 2.1.2 - WebPole AR PWA Core",
5
5
  "start_url": ".",
6
6
  "display": "standalone",
7
7
  "background_color": "#ffffff",
@@ -0,0 +1,35 @@
1
+ // script.js
2
+ let deferredPrompt;
3
+ const installBtn = document.getElementById('btnInstallApp');
4
+
5
+ window.addEventListener('beforeinstallprompt', (e) => {
6
+ e.preventDefault();
7
+ deferredPrompt = e;
8
+ installBtn.style.display = 'inline-flex';
9
+ });
10
+
11
+ installBtn.addEventListener('click', async () => {
12
+ if(deferredPrompt){
13
+ deferredPrompt.prompt();
14
+ const { outcome } = await deferredPrompt.userChoice;
15
+ deferredPrompt = null;
16
+ if(outcome === 'accepted') installBtn.style.display = 'none';
17
+ }
18
+ });
19
+ // script.js
20
+ const statusCircle = document.getElementById('statusIndicator');
21
+
22
+ function updateOnlineStatus() {
23
+ if(navigator.onLine) {
24
+ statusCircle.classList.remove('offline');
25
+ } else {
26
+ statusCircle.classList.add('offline');
27
+ }
28
+ }
29
+
30
+ // Escuchar cambios en la conexión
31
+ window.addEventListener('online', updateOnlineStatus);
32
+ window.addEventListener('offline', updateOnlineStatus);
33
+
34
+ // Estado inicial
35
+ updateOnlineStatus();
@@ -0,0 +1,35 @@
1
+ /* estilo.css */
2
+ .btn-install-pwa {
3
+ background: linear-gradient(45deg,#4CAF50,#2E7D32); /* verde inicial */
4
+ color:white;
5
+ border:none;
6
+ padding:12px 25px;
7
+ border-radius:50px;
8
+ font-weight:700;
9
+ box-shadow:0 4px 15px rgba(0,0,0,0.2);
10
+ display:inline-flex;
11
+ align-items:center;
12
+ gap:10px;
13
+ transition: all 0.3s ease;
14
+ }
15
+ .btn-install-pwa:hover {
16
+ transform: translateY(-3px);
17
+ box-shadow:0 6px 18px rgba(0,0,0,0.3);
18
+ }
19
+ .btn-install-pwa.disabled {
20
+ background: #B71C1C; /* rojo cuando no se puede instalar */
21
+ cursor: not-allowed;
22
+ opacity:0.8;
23
+ }
24
+ /* estilo.css */
25
+ .status-circle {
26
+ width:20px;
27
+ height:20px;
28
+ border-radius:50%;
29
+ background-color:#4CAF50; /* verde = conectado */
30
+ border:2px solid #000;
31
+ transition: background-color 0.3s ease;
32
+ }
33
+ .status-circle.offline {
34
+ background-color:#F44336; /* rojo = sin conexión */
35
+ }
package/template/sw,js CHANGED
@@ -1,11 +1,13 @@
1
- const CACHE_NAME = "walpole-ar-v3";
1
+ const CACHE_NAME = "walpole-ar-v5";
2
2
 
3
3
  const FILES_TO_CACHE = [
4
4
  "/",
5
5
  "/index.html",
6
6
  "/offline.html",
7
7
  "/manifest.json",
8
- "/icon-192.png"
8
+ "/icon-192.png",
9
+ "/style.css",
10
+ "/script.js"
9
11
  ];
10
12
 
11
13
  self.addEventListener("install", event => {