@auxilium/datalynk-client 1.2.8 → 1.2.91

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/dist/index.js CHANGED
@@ -2256,8 +2256,14 @@ class Auth {
2256
2256
  }
2257
2257
  class PWA {
2258
2258
  constructor(api) {
2259
+ __publicField(this, "deferredPrompt", null);
2259
2260
  this.api = api;
2261
+ window.addEventListener("beforeinstallprompt", (e) => {
2262
+ e.preventDefault();
2263
+ this.deferredPrompt = e;
2264
+ });
2260
2265
  }
2266
+ // Holds the beforeinstallprompt event
2261
2267
  get iframe() {
2262
2268
  return (parent == null ? void 0 : parent.location) != location;
2263
2269
  }
@@ -2306,16 +2312,16 @@ class PWA {
2306
2312
  if (!this.iframe && !this.pwa && this.platform != "mac") setTimeout(() => {
2307
2313
  const dismissed = !!localStorage.getItem(`${this.api.options.name}:pwa`);
2308
2314
  if (!dismissed) this.prompt();
2309
- }, 6e4);
2315
+ }, 1e4);
2310
2316
  }
2311
2317
  /** Prompt user to install the app */
2312
2318
  async prompt(platform) {
2313
2319
  if (document.querySelector(".pwa-prompt")) return;
2314
- this.api.url;
2315
2320
  const android = (platform || this.platform) == "android";
2316
2321
  let style = document.querySelector("style.pwa");
2317
2322
  if (!style) {
2318
2323
  style = document.createElement("style");
2324
+ style.classList.add("pwa");
2319
2325
  style.innerHTML = `
2320
2326
  .pwa-prompt-backdrop {
2321
2327
  position: fixed;
@@ -2393,26 +2399,25 @@ class PWA {
2393
2399
  </div>
2394
2400
  <div style="display: flex; flex-direction: column; align-items: center">
2395
2401
  <div style="border-top: 2px solid #00000020; border-bottom: 2px solid #00000020; padding: 0 1rem">
2396
- <p style="margin-top: 1rem; text-align: center">This website can be installed as an App! Add it to your home screen for quick access & fullscreen use.</p>
2402
+ <p style="margin-top: 1rem; text-align: center">
2403
+ ${this.deferredPrompt ? "Click the button below to install the app directly to your device." : "This website can be installed as an App! Add it to your home screen for quick access & fullscreen use."}
2404
+ </p>
2397
2405
  </div>
2398
- <table style="margin: 1.5rem 0">
2399
- <tr>
2400
- <td style="width: 50px; text-align: center">
2401
- ${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="black" style="transform: scale(1.5)"><path d="M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"/></svg>' : '<svg viewBox="0 0 566 670" xmlns="http://www.w3.org/2000/svg" fill="#0B76FC" height="40px"><path d="M255 12c4-4 10-8 16-8s12 3 16 8l94 89c3 4 6 7 8 12 2 6 0 14-5 19-7 8-20 9-28 2l-7-7-57-60 2 54v276c0 12-10 22-22 22-12 1-24-10-23-22V110l1-43-60 65c-5 5-13 8-21 6a19 19 0 0 1-16-17c-1-7 2-13 7-18l95-91z" /><path d="M43 207c16-17 40-23 63-23h83v46h-79c-12 0-25 3-33 13-8 9-10 21-10 33v260c0 13 0 27 6 38 5 12 18 18 30 19l14 1h302c14 0 28 0 40-8 11-7 16-21 16-34V276c0-11-2-24-9-33-8-10-22-13-34-13h-78v-46h75c13 0 25 1 37 4 16 4 31 13 41 27 11 17 14 37 14 57v280c0 20-3 41-15 58a71 71 0 0 1-45 27c-11 2-23 3-34 3H109c-19-1-40-4-56-15-14-9-23-23-27-38-4-12-5-25-5-38V270c1-22 6-47 22-63z" /></svg>'}
2402
- </td>
2403
- <td>
2404
- <p style="margin: 1rem 0">1) ${android ? "Open the dropdown menu" : 'Press the "Share" button'}</p>
2405
- </td>
2406
- </tr>
2407
- <tr>
2408
- <td style="width: 50px; text-align: center">
2409
- ${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="black" style="transform: scale(-1.5, 1.5)"><path d="M280-40q-33 0-56.5-23.5T200-120v-720q0-33 23.5-56.5T280-920h280v80H280v40h280v80H280v480h400v-80h80v200q0 33-23.5 56.5T680-40H280Zm0-120v40h400v-40H280Zm440-240L520-600l56-56 104 104v-288h80v288l104-104 56 56-200 200ZM280-800v-40 40Zm0 640v40-40Z"/></svg>' : '<svg viewBox="0 0 578 584" xmlns="http://www.w3.org/2000/svg" fill="black" height="34px"><path d="M101 35l19-1h333c12 0 23 0 35 3 17 3 34 12 44 27 13 16 16 38 16 58v329c0 19 0 39-8 57a65 65 0 0 1-37 37c-18 7-38 7-57 7H130c-21 1-44 0-63-10-14-7-25-20-30-34-6-15-8-30-8-45V121c1-21 5-44 19-61 13-16 33-23 53-25m7 46c-10 1-19 6-24 14-7 8-9 20-9 31v334c0 12 2 25 10 34 9 10 23 12 35 12h336c14 1 30-3 38-15 6-9 8-20 8-31V125c0-12-2-24-10-33-9-9-22-12-35-12H121l-13 1z" /><path d="M271 161c9-11 31-10 38 4 3 5 3 11 3 17v87h88c7 0 16 1 21 7 6 6 7 14 6 22a21 21 0 0 1-10 14c-5 4-11 5-17 5h-88v82c0 7-1 15-6 20-10 10-29 10-37-2-3-6-4-13-4-19v-81h-87c-8-1-17-3-23-9-5-6-6-15-4-22a21 21 0 0 1 11-14c6-3 13-3 19-3h84v-88c0-7 1-14 6-20z" /></svg>'}
2410
- </td>
2411
- <td>
2412
- <p style="margin: 1rem 0">2) Press "Add to Home Screen"</p>
2413
- </td>
2414
- </tr>
2415
- </table>
2406
+ ${this.deferredPrompt ? `<button id="installPwaBtn" style="background:#0B76FC;color:white;border:none;padding:.5rem 1rem;border-radius:5px;cursor:pointer;margin:1rem 0">Install</button>` : `
2407
+ <table style="margin: 1.5rem 0">
2408
+ <tr>
2409
+ <td style="width: 50px; text-align: center">
2410
+ ${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="black" style="transform: scale(1.5)">...</svg>' : '<svg viewBox="0 0 566 670" xmlns="http://www.w3.org/2000/svg" fill="#0B76FC" height="40px">...</svg>'}
2411
+ </td>
2412
+ <td><p style="margin: 1rem 0">1) ${android ? "Open the dropdown menu" : 'Press the "Share" button'}</p></td>
2413
+ </tr>
2414
+ <tr>
2415
+ <td style="width: 50px; text-align: center">
2416
+ ${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px">...</svg>' : '<svg viewBox="0 0 578 584" xmlns="http://www.w3.org/2000/svg" fill="black" height="34px">...</svg>'}
2417
+ </td>
2418
+ <td><p style="margin: 1rem 0">2) Press "Add to Home Screen"</p></td>
2419
+ </tr>
2420
+ </table>`}
2416
2421
  </div>`;
2417
2422
  const close = document.createElement("button");
2418
2423
  close.classList.add("pwa-prompt-close");
@@ -2429,6 +2434,18 @@ class PWA {
2429
2434
  prompt.append(close);
2430
2435
  backdrop.append(prompt);
2431
2436
  document.body.append(backdrop);
2437
+ if (this.deferredPrompt) {
2438
+ const installBtn = prompt.querySelector("#installPwaBtn");
2439
+ if (installBtn) {
2440
+ installBtn.onclick = async () => {
2441
+ this.deferredPrompt.prompt();
2442
+ const choice = await this.deferredPrompt.userChoice;
2443
+ if (choice.outcome === "accepted") console.log("PWA installed");
2444
+ this.deferredPrompt = null;
2445
+ close.click();
2446
+ };
2447
+ }
2448
+ }
2432
2449
  }
2433
2450
  }
2434
2451
  class Files {
@@ -3354,7 +3371,7 @@ class Superuser {
3354
3371
  } });
3355
3372
  }
3356
3373
  }
3357
- const version = "1.2.8";
3374
+ const version = "1.2.91";
3358
3375
  class WebRtc {
3359
3376
  constructor(api) {
3360
3377
  __publicField(this, "ice");
package/dist/index.mjs CHANGED
@@ -2254,8 +2254,14 @@ class Auth {
2254
2254
  }
2255
2255
  class PWA {
2256
2256
  constructor(api) {
2257
+ __publicField(this, "deferredPrompt", null);
2257
2258
  this.api = api;
2259
+ window.addEventListener("beforeinstallprompt", (e) => {
2260
+ e.preventDefault();
2261
+ this.deferredPrompt = e;
2262
+ });
2258
2263
  }
2264
+ // Holds the beforeinstallprompt event
2259
2265
  get iframe() {
2260
2266
  return (parent == null ? void 0 : parent.location) != location;
2261
2267
  }
@@ -2304,16 +2310,16 @@ class PWA {
2304
2310
  if (!this.iframe && !this.pwa && this.platform != "mac") setTimeout(() => {
2305
2311
  const dismissed = !!localStorage.getItem(`${this.api.options.name}:pwa`);
2306
2312
  if (!dismissed) this.prompt();
2307
- }, 6e4);
2313
+ }, 1e4);
2308
2314
  }
2309
2315
  /** Prompt user to install the app */
2310
2316
  async prompt(platform) {
2311
2317
  if (document.querySelector(".pwa-prompt")) return;
2312
- this.api.url;
2313
2318
  const android = (platform || this.platform) == "android";
2314
2319
  let style = document.querySelector("style.pwa");
2315
2320
  if (!style) {
2316
2321
  style = document.createElement("style");
2322
+ style.classList.add("pwa");
2317
2323
  style.innerHTML = `
2318
2324
  .pwa-prompt-backdrop {
2319
2325
  position: fixed;
@@ -2391,26 +2397,25 @@ class PWA {
2391
2397
  </div>
2392
2398
  <div style="display: flex; flex-direction: column; align-items: center">
2393
2399
  <div style="border-top: 2px solid #00000020; border-bottom: 2px solid #00000020; padding: 0 1rem">
2394
- <p style="margin-top: 1rem; text-align: center">This website can be installed as an App! Add it to your home screen for quick access & fullscreen use.</p>
2400
+ <p style="margin-top: 1rem; text-align: center">
2401
+ ${this.deferredPrompt ? "Click the button below to install the app directly to your device." : "This website can be installed as an App! Add it to your home screen for quick access & fullscreen use."}
2402
+ </p>
2395
2403
  </div>
2396
- <table style="margin: 1.5rem 0">
2397
- <tr>
2398
- <td style="width: 50px; text-align: center">
2399
- ${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="black" style="transform: scale(1.5)"><path d="M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"/></svg>' : '<svg viewBox="0 0 566 670" xmlns="http://www.w3.org/2000/svg" fill="#0B76FC" height="40px"><path d="M255 12c4-4 10-8 16-8s12 3 16 8l94 89c3 4 6 7 8 12 2 6 0 14-5 19-7 8-20 9-28 2l-7-7-57-60 2 54v276c0 12-10 22-22 22-12 1-24-10-23-22V110l1-43-60 65c-5 5-13 8-21 6a19 19 0 0 1-16-17c-1-7 2-13 7-18l95-91z" /><path d="M43 207c16-17 40-23 63-23h83v46h-79c-12 0-25 3-33 13-8 9-10 21-10 33v260c0 13 0 27 6 38 5 12 18 18 30 19l14 1h302c14 0 28 0 40-8 11-7 16-21 16-34V276c0-11-2-24-9-33-8-10-22-13-34-13h-78v-46h75c13 0 25 1 37 4 16 4 31 13 41 27 11 17 14 37 14 57v280c0 20-3 41-15 58a71 71 0 0 1-45 27c-11 2-23 3-34 3H109c-19-1-40-4-56-15-14-9-23-23-27-38-4-12-5-25-5-38V270c1-22 6-47 22-63z" /></svg>'}
2400
- </td>
2401
- <td>
2402
- <p style="margin: 1rem 0">1) ${android ? "Open the dropdown menu" : 'Press the "Share" button'}</p>
2403
- </td>
2404
- </tr>
2405
- <tr>
2406
- <td style="width: 50px; text-align: center">
2407
- ${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="black" style="transform: scale(-1.5, 1.5)"><path d="M280-40q-33 0-56.5-23.5T200-120v-720q0-33 23.5-56.5T280-920h280v80H280v40h280v80H280v480h400v-80h80v200q0 33-23.5 56.5T680-40H280Zm0-120v40h400v-40H280Zm440-240L520-600l56-56 104 104v-288h80v288l104-104 56 56-200 200ZM280-800v-40 40Zm0 640v40-40Z"/></svg>' : '<svg viewBox="0 0 578 584" xmlns="http://www.w3.org/2000/svg" fill="black" height="34px"><path d="M101 35l19-1h333c12 0 23 0 35 3 17 3 34 12 44 27 13 16 16 38 16 58v329c0 19 0 39-8 57a65 65 0 0 1-37 37c-18 7-38 7-57 7H130c-21 1-44 0-63-10-14-7-25-20-30-34-6-15-8-30-8-45V121c1-21 5-44 19-61 13-16 33-23 53-25m7 46c-10 1-19 6-24 14-7 8-9 20-9 31v334c0 12 2 25 10 34 9 10 23 12 35 12h336c14 1 30-3 38-15 6-9 8-20 8-31V125c0-12-2-24-10-33-9-9-22-12-35-12H121l-13 1z" /><path d="M271 161c9-11 31-10 38 4 3 5 3 11 3 17v87h88c7 0 16 1 21 7 6 6 7 14 6 22a21 21 0 0 1-10 14c-5 4-11 5-17 5h-88v82c0 7-1 15-6 20-10 10-29 10-37-2-3-6-4-13-4-19v-81h-87c-8-1-17-3-23-9-5-6-6-15-4-22a21 21 0 0 1 11-14c6-3 13-3 19-3h84v-88c0-7 1-14 6-20z" /></svg>'}
2408
- </td>
2409
- <td>
2410
- <p style="margin: 1rem 0">2) Press "Add to Home Screen"</p>
2411
- </td>
2412
- </tr>
2413
- </table>
2404
+ ${this.deferredPrompt ? `<button id="installPwaBtn" style="background:#0B76FC;color:white;border:none;padding:.5rem 1rem;border-radius:5px;cursor:pointer;margin:1rem 0">Install</button>` : `
2405
+ <table style="margin: 1.5rem 0">
2406
+ <tr>
2407
+ <td style="width: 50px; text-align: center">
2408
+ ${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="black" style="transform: scale(1.5)">...</svg>' : '<svg viewBox="0 0 566 670" xmlns="http://www.w3.org/2000/svg" fill="#0B76FC" height="40px">...</svg>'}
2409
+ </td>
2410
+ <td><p style="margin: 1rem 0">1) ${android ? "Open the dropdown menu" : 'Press the "Share" button'}</p></td>
2411
+ </tr>
2412
+ <tr>
2413
+ <td style="width: 50px; text-align: center">
2414
+ ${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px">...</svg>' : '<svg viewBox="0 0 578 584" xmlns="http://www.w3.org/2000/svg" fill="black" height="34px">...</svg>'}
2415
+ </td>
2416
+ <td><p style="margin: 1rem 0">2) Press "Add to Home Screen"</p></td>
2417
+ </tr>
2418
+ </table>`}
2414
2419
  </div>`;
2415
2420
  const close = document.createElement("button");
2416
2421
  close.classList.add("pwa-prompt-close");
@@ -2427,6 +2432,18 @@ class PWA {
2427
2432
  prompt.append(close);
2428
2433
  backdrop.append(prompt);
2429
2434
  document.body.append(backdrop);
2435
+ if (this.deferredPrompt) {
2436
+ const installBtn = prompt.querySelector("#installPwaBtn");
2437
+ if (installBtn) {
2438
+ installBtn.onclick = async () => {
2439
+ this.deferredPrompt.prompt();
2440
+ const choice = await this.deferredPrompt.userChoice;
2441
+ if (choice.outcome === "accepted") console.log("PWA installed");
2442
+ this.deferredPrompt = null;
2443
+ close.click();
2444
+ };
2445
+ }
2446
+ }
2430
2447
  }
2431
2448
  }
2432
2449
  class Files {
@@ -3352,7 +3369,7 @@ class Superuser {
3352
3369
  } });
3353
3370
  }
3354
3371
  }
3355
- const version = "1.2.8";
3372
+ const version = "1.2.91";
3356
3373
  class WebRtc {
3357
3374
  constructor(api) {
3358
3375
  __publicField(this, "ice");
package/dist/pwa.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Api } from './api';
2
2
  export declare class PWA {
3
3
  private readonly api;
4
+ private deferredPrompt;
4
5
  get iframe(): boolean;
5
6
  get mobile(): boolean;
6
7
  get platform(): 'android' | 'ios' | 'mac' | 'windows' | 'linux' | 'unknown';
package/dist/pwa.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pwa.d.ts","sourceRoot":"","sources":["../src/pwa.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,qBAAa,GAAG;IAoBH,OAAO,CAAC,QAAQ,CAAC,GAAG;IAlBhC,IAAI,MAAM,IAAI,OAAO,CAAyC;IAE9D,IAAI,MAAM,IAAI,OAAO,CAAuD;IAE5E,IAAI,QAAQ,IAAI,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAQ1E;IAED,IAAI,GAAG,IAAI,OAAO,CAEjB;gBAE4B,GAAG,EAAE,GAAG;IAErC,oBAAoB;IACd,KAAK,CAAC,QAAQ,GAAE,GAAQ;IAsC9B,qCAAqC;IAC/B,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;CAiIzC"}
1
+ {"version":3,"file":"pwa.d.ts","sourceRoot":"","sources":["../src/pwa.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,qBAAa,GAAG;IAqBH,OAAO,CAAC,QAAQ,CAAC,GAAG;IApBhC,OAAO,CAAC,cAAc,CAAa;IAEnC,IAAI,MAAM,IAAI,OAAO,CAAyC;IAE9D,IAAI,MAAM,IAAI,OAAO,CAAuD;IAE5E,IAAI,QAAQ,IAAI,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAQ1E;IAED,IAAI,GAAG,IAAI,OAAO,CAEjB;gBAE4B,GAAG,EAAE,GAAG;IAQrC,oBAAoB;IACd,KAAK,CAAC,QAAQ,GAAE,GAAQ;IAsC9B,qCAAqC;IAC/B,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;CAiJzC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@auxilium/datalynk-client",
3
3
  "description": "Datalynk client library",
4
4
  "repository": "https://gitlab.auxiliumgroup.com/auxilium/datalynk/datalynk-client",
5
- "version": "1.2.8",
5
+ "version": "1.2.91",
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
7
7
  "private": false,
8
8
  "main": "./dist/index.cjs",