@auxilium/datalynk-client 1.3.17-1 → 1.3.18

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.cjs CHANGED
@@ -2343,6 +2343,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2343
2343
  constructor(api) {
2344
2344
  /** Capture Install Event */
2345
2345
  __publicField(this, "nativeInstallPrompt", null);
2346
+ /** Resolved icon URL used for prompt + manifest */
2347
+ __publicField(this, "resolvedIconUrl", "https://datalynk-client.primary.auxilium.world/logo.png");
2346
2348
  this.api = api;
2347
2349
  }
2348
2350
  get headless() {
@@ -2380,19 +2382,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2380
2382
  const installBtn = document.querySelector("#installPwaBtn");
2381
2383
  if (!installBtn) return;
2382
2384
  installBtn.onclick = async () => {
2383
- var _a, _b, _c;
2385
+ var _a;
2384
2386
  if (!this.nativeInstallPrompt) return console.warn("PWA is not supported");
2385
2387
  this.nativeInstallPrompt.prompt();
2386
2388
  const choice = await this.nativeInstallPrompt.userChoice;
2387
- const storageKey = `${this.api.options.name}:pwa`;
2388
- const expiryDays = Number(((_b = (_a = this.api.options) == null ? void 0 : _a.pwaSettings) == null ? void 0 : _b.dismissExpiry) ?? 7);
2389
2389
  if (choice.outcome === "accepted") {
2390
2390
  console.log("PWA installed");
2391
- localStorage.setItem(storageKey, "installed");
2391
+ localStorage.setItem(`${this.api.options.name}:pwa`, "installed");
2392
2392
  } else {
2393
- expiryDays === 0 ? localStorage.removeItem(storageKey) : localStorage.setItem(storageKey, Date.now().toString());
2393
+ localStorage.setItem(`${this.api.options.name}:pwa`, Date.now().toString());
2394
2394
  }
2395
- (_c = document.querySelector(".pwa-prompt")) == null ? void 0 : _c.remove();
2395
+ (_a = document.querySelector(".pwa-prompt")) == null ? void 0 : _a.remove();
2396
2396
  };
2397
2397
  }
2398
2398
  /** Setup the PWA */
@@ -2422,19 +2422,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2422
2422
  hidePWAPrompt: false,
2423
2423
  ...this.api.options.pwaSettings
2424
2424
  };
2425
- const meta = (key, name, value) => {
2426
- const exists = document.querySelector(`meta[${key}="${name}"]`);
2427
- if (value === void 0 || exists) return exists;
2428
- const meta2 = document.createElement("meta");
2429
- meta2.setAttribute(key, name);
2430
- meta2.content = value;
2431
- document.head.append(meta2);
2432
- };
2433
- meta("name", "mobile-web-app-capable", "yes");
2434
- meta("name", "apple-mobile-web-app-status-bar-style", "default");
2435
- meta("name", "apple-mobile-web-app-title", this.api.options.name);
2436
- meta("name", "apple-touch-icon", `https://datalynk-client.primary.auxilium.world/logo.png`);
2437
- meta("name", "apple-touch-startup-image", `https://datalynk-client.primary.auxilium.world/logo.png`);
2438
2425
  const defaultIcon = "https://datalynk-client.primary.auxilium.world/logo.png";
2439
2426
  let iconUrl = ((_b = (_a = this.api.options) == null ? void 0 : _a.pwaSettings) == null ? void 0 : _b.icon) || defaultIcon;
2440
2427
  const canLoad = (url) => new Promise((res) => {
@@ -2454,11 +2441,25 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2454
2441
  const ok = await canLoad(iconUrl);
2455
2442
  if (!ok) iconUrl = defaultIcon;
2456
2443
  }
2457
- let manifestLink = document.querySelector('link[rel="manifest"]');
2458
- if (!manifestLink) {
2459
- manifestLink = document.createElement("link");
2460
- manifestLink.rel = "manifest";
2461
- document.head.append(manifestLink);
2444
+ this.resolvedIconUrl = iconUrl;
2445
+ const meta = (key, name, value) => {
2446
+ const exists = document.querySelector(`meta[${key}="${name}"]`);
2447
+ if (value === void 0 || exists) return exists;
2448
+ const meta2 = document.createElement("meta");
2449
+ meta2.setAttribute(key, name);
2450
+ meta2.content = value;
2451
+ document.head.append(meta2);
2452
+ };
2453
+ meta("name", "mobile-web-app-capable", "yes");
2454
+ meta("name", "apple-mobile-web-app-status-bar-style", "default");
2455
+ meta("name", "apple-mobile-web-app-title", this.api.options.name);
2456
+ meta("name", "apple-touch-icon", this.resolvedIconUrl);
2457
+ meta("name", "apple-touch-startup-image", this.resolvedIconUrl);
2458
+ let link = document.querySelector('link[rel="manifest"]');
2459
+ if (!link) {
2460
+ link = document.createElement("link");
2461
+ link.rel = "manifest";
2462
+ document.head.append(link);
2462
2463
  }
2463
2464
  const base = String(this.api.url).replace(/\/+$/, "");
2464
2465
  const startUrl = location.pathname;
@@ -2474,11 +2475,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2474
2475
  };
2475
2476
  if (!((_c = manifestObj.icons) == null ? void 0 : _c.length)) {
2476
2477
  manifestObj.icons = [
2477
- { src: iconUrl, sizes: "192x192", type: "image/png" },
2478
- { src: iconUrl, sizes: "512x512", type: "image/png" }
2478
+ { src: this.resolvedIconUrl, sizes: "192x192", type: "image/png", purpose: "any" },
2479
+ { src: this.resolvedIconUrl, sizes: "512x512", type: "image/png", purpose: "any" },
2480
+ { src: this.resolvedIconUrl, sizes: "512x512", type: "image/png", purpose: "maskable" }
2479
2481
  ];
2480
2482
  }
2481
- manifestLink.href = `${base}/manifest?ts=${Date.now()}&json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2483
+ link.href = `${base}/manifest?json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2482
2484
  if (!((_d = this.api.options.pwaSettings) == null ? void 0 : _d.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
2483
2485
  const t = Number(this.api.options.pwaSettings.timeout ?? 30);
2484
2486
  const timeoutMs = t >= 1e3 ? t : t * 1e3;
@@ -2501,14 +2503,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2501
2503
  }
2502
2504
  /** Prompt user to install the app */
2503
2505
  async prompt(platform) {
2504
- var _a, _b, _c;
2506
+ var _a;
2505
2507
  const storageKey = `${this.api.options.name}:pwa`;
2506
2508
  if ((_a = this.api.options.pwaSettings) == null ? void 0 : _a.hidePWAPrompt) return;
2507
2509
  if (this.pwa) return;
2508
2510
  if (localStorage.getItem(storageKey) === "installed") return;
2509
2511
  if (document.querySelector(".pwa-prompt")) return;
2510
- const defaultIcon = "https://datalynk-client.primary.auxilium.world/logo.png";
2511
- const iconUrl = ((_c = (_b = this.api.options) == null ? void 0 : _b.pwaSettings) == null ? void 0 : _c.icon) || defaultIcon;
2512
2512
  const targetPlatform = platform || this.platform;
2513
2513
  const isAndroid = targetPlatform == "android";
2514
2514
  const isIOS = targetPlatform == "ios";
@@ -2630,6 +2630,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2630
2630
  }`;
2631
2631
  document.head.append(style);
2632
2632
  }
2633
+ const iconUrl = this.resolvedIconUrl || "https://datalynk-client.primary.auxilium.world/logo.png";
2633
2634
  const prompt = document.createElement("div");
2634
2635
  prompt.classList.add("pwa-prompt");
2635
2636
  prompt.innerHTML = `
@@ -2650,14 +2651,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2650
2651
  `;
2651
2652
  const closeBtn = prompt.querySelector(".pwa-prompt-close");
2652
2653
  closeBtn.onclick = () => {
2653
- var _a2, _b2;
2654
- const expiryDays = Number(((_b2 = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b2.dismissExpiry) ?? 7);
2655
- expiryDays === 0 ? localStorage.removeItem(storageKey) : localStorage.setItem(storageKey, Date.now().toString());
2654
+ var _a2;
2655
+ !!((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ? localStorage.setItem(storageKey, Date.now().toString()) : localStorage.removeItem(storageKey);
2656
2656
  prompt.remove();
2657
2657
  };
2658
2658
  document.body.append(prompt);
2659
2659
  const img = prompt.querySelector(".pwa-prompt-header img");
2660
- if (img) img.onerror = () => img.src = defaultIcon;
2660
+ if (img) img.onerror = () => img.src = "https://datalynk-client.primary.auxilium.world/logo.png";
2661
2661
  if (this.nativeInstallPrompt) this.bindInstallButton();
2662
2662
  }
2663
2663
  }
@@ -3769,7 +3769,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3769
3769
  } });
3770
3770
  }
3771
3771
  }
3772
- const version = "1.3.17-1";
3772
+ const version = "1.3.18";
3773
3773
  class WebRtc {
3774
3774
  constructor(api) {
3775
3775
  __publicField(this, "ice");
package/dist/index.mjs CHANGED
@@ -2339,6 +2339,8 @@ class PWA {
2339
2339
  constructor(api) {
2340
2340
  /** Capture Install Event */
2341
2341
  __publicField(this, "nativeInstallPrompt", null);
2342
+ /** Resolved icon URL used for prompt + manifest */
2343
+ __publicField(this, "resolvedIconUrl", "https://datalynk-client.primary.auxilium.world/logo.png");
2342
2344
  this.api = api;
2343
2345
  }
2344
2346
  get headless() {
@@ -2376,19 +2378,17 @@ class PWA {
2376
2378
  const installBtn = document.querySelector("#installPwaBtn");
2377
2379
  if (!installBtn) return;
2378
2380
  installBtn.onclick = async () => {
2379
- var _a, _b, _c;
2381
+ var _a;
2380
2382
  if (!this.nativeInstallPrompt) return console.warn("PWA is not supported");
2381
2383
  this.nativeInstallPrompt.prompt();
2382
2384
  const choice = await this.nativeInstallPrompt.userChoice;
2383
- const storageKey = `${this.api.options.name}:pwa`;
2384
- const expiryDays = Number(((_b = (_a = this.api.options) == null ? void 0 : _a.pwaSettings) == null ? void 0 : _b.dismissExpiry) ?? 7);
2385
2385
  if (choice.outcome === "accepted") {
2386
2386
  console.log("PWA installed");
2387
- localStorage.setItem(storageKey, "installed");
2387
+ localStorage.setItem(`${this.api.options.name}:pwa`, "installed");
2388
2388
  } else {
2389
- expiryDays === 0 ? localStorage.removeItem(storageKey) : localStorage.setItem(storageKey, Date.now().toString());
2389
+ localStorage.setItem(`${this.api.options.name}:pwa`, Date.now().toString());
2390
2390
  }
2391
- (_c = document.querySelector(".pwa-prompt")) == null ? void 0 : _c.remove();
2391
+ (_a = document.querySelector(".pwa-prompt")) == null ? void 0 : _a.remove();
2392
2392
  };
2393
2393
  }
2394
2394
  /** Setup the PWA */
@@ -2418,19 +2418,6 @@ class PWA {
2418
2418
  hidePWAPrompt: false,
2419
2419
  ...this.api.options.pwaSettings
2420
2420
  };
2421
- const meta = (key, name, value) => {
2422
- const exists = document.querySelector(`meta[${key}="${name}"]`);
2423
- if (value === void 0 || exists) return exists;
2424
- const meta2 = document.createElement("meta");
2425
- meta2.setAttribute(key, name);
2426
- meta2.content = value;
2427
- document.head.append(meta2);
2428
- };
2429
- meta("name", "mobile-web-app-capable", "yes");
2430
- meta("name", "apple-mobile-web-app-status-bar-style", "default");
2431
- meta("name", "apple-mobile-web-app-title", this.api.options.name);
2432
- meta("name", "apple-touch-icon", `https://datalynk-client.primary.auxilium.world/logo.png`);
2433
- meta("name", "apple-touch-startup-image", `https://datalynk-client.primary.auxilium.world/logo.png`);
2434
2421
  const defaultIcon = "https://datalynk-client.primary.auxilium.world/logo.png";
2435
2422
  let iconUrl = ((_b = (_a = this.api.options) == null ? void 0 : _a.pwaSettings) == null ? void 0 : _b.icon) || defaultIcon;
2436
2423
  const canLoad = (url) => new Promise((res) => {
@@ -2450,11 +2437,25 @@ class PWA {
2450
2437
  const ok = await canLoad(iconUrl);
2451
2438
  if (!ok) iconUrl = defaultIcon;
2452
2439
  }
2453
- let manifestLink = document.querySelector('link[rel="manifest"]');
2454
- if (!manifestLink) {
2455
- manifestLink = document.createElement("link");
2456
- manifestLink.rel = "manifest";
2457
- document.head.append(manifestLink);
2440
+ this.resolvedIconUrl = iconUrl;
2441
+ const meta = (key, name, value) => {
2442
+ const exists = document.querySelector(`meta[${key}="${name}"]`);
2443
+ if (value === void 0 || exists) return exists;
2444
+ const meta2 = document.createElement("meta");
2445
+ meta2.setAttribute(key, name);
2446
+ meta2.content = value;
2447
+ document.head.append(meta2);
2448
+ };
2449
+ meta("name", "mobile-web-app-capable", "yes");
2450
+ meta("name", "apple-mobile-web-app-status-bar-style", "default");
2451
+ meta("name", "apple-mobile-web-app-title", this.api.options.name);
2452
+ meta("name", "apple-touch-icon", this.resolvedIconUrl);
2453
+ meta("name", "apple-touch-startup-image", this.resolvedIconUrl);
2454
+ let link = document.querySelector('link[rel="manifest"]');
2455
+ if (!link) {
2456
+ link = document.createElement("link");
2457
+ link.rel = "manifest";
2458
+ document.head.append(link);
2458
2459
  }
2459
2460
  const base = String(this.api.url).replace(/\/+$/, "");
2460
2461
  const startUrl = location.pathname;
@@ -2470,11 +2471,12 @@ class PWA {
2470
2471
  };
2471
2472
  if (!((_c = manifestObj.icons) == null ? void 0 : _c.length)) {
2472
2473
  manifestObj.icons = [
2473
- { src: iconUrl, sizes: "192x192", type: "image/png" },
2474
- { src: iconUrl, sizes: "512x512", type: "image/png" }
2474
+ { src: this.resolvedIconUrl, sizes: "192x192", type: "image/png", purpose: "any" },
2475
+ { src: this.resolvedIconUrl, sizes: "512x512", type: "image/png", purpose: "any" },
2476
+ { src: this.resolvedIconUrl, sizes: "512x512", type: "image/png", purpose: "maskable" }
2475
2477
  ];
2476
2478
  }
2477
- manifestLink.href = `${base}/manifest?ts=${Date.now()}&json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2479
+ link.href = `${base}/manifest?json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2478
2480
  if (!((_d = this.api.options.pwaSettings) == null ? void 0 : _d.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
2479
2481
  const t = Number(this.api.options.pwaSettings.timeout ?? 30);
2480
2482
  const timeoutMs = t >= 1e3 ? t : t * 1e3;
@@ -2497,14 +2499,12 @@ class PWA {
2497
2499
  }
2498
2500
  /** Prompt user to install the app */
2499
2501
  async prompt(platform) {
2500
- var _a, _b, _c;
2502
+ var _a;
2501
2503
  const storageKey = `${this.api.options.name}:pwa`;
2502
2504
  if ((_a = this.api.options.pwaSettings) == null ? void 0 : _a.hidePWAPrompt) return;
2503
2505
  if (this.pwa) return;
2504
2506
  if (localStorage.getItem(storageKey) === "installed") return;
2505
2507
  if (document.querySelector(".pwa-prompt")) return;
2506
- const defaultIcon = "https://datalynk-client.primary.auxilium.world/logo.png";
2507
- const iconUrl = ((_c = (_b = this.api.options) == null ? void 0 : _b.pwaSettings) == null ? void 0 : _c.icon) || defaultIcon;
2508
2508
  const targetPlatform = platform || this.platform;
2509
2509
  const isAndroid = targetPlatform == "android";
2510
2510
  const isIOS = targetPlatform == "ios";
@@ -2626,6 +2626,7 @@ class PWA {
2626
2626
  }`;
2627
2627
  document.head.append(style);
2628
2628
  }
2629
+ const iconUrl = this.resolvedIconUrl || "https://datalynk-client.primary.auxilium.world/logo.png";
2629
2630
  const prompt = document.createElement("div");
2630
2631
  prompt.classList.add("pwa-prompt");
2631
2632
  prompt.innerHTML = `
@@ -2646,14 +2647,13 @@ class PWA {
2646
2647
  `;
2647
2648
  const closeBtn = prompt.querySelector(".pwa-prompt-close");
2648
2649
  closeBtn.onclick = () => {
2649
- var _a2, _b2;
2650
- const expiryDays = Number(((_b2 = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b2.dismissExpiry) ?? 7);
2651
- expiryDays === 0 ? localStorage.removeItem(storageKey) : localStorage.setItem(storageKey, Date.now().toString());
2650
+ var _a2;
2651
+ !!((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ? localStorage.setItem(storageKey, Date.now().toString()) : localStorage.removeItem(storageKey);
2652
2652
  prompt.remove();
2653
2653
  };
2654
2654
  document.body.append(prompt);
2655
2655
  const img = prompt.querySelector(".pwa-prompt-header img");
2656
- if (img) img.onerror = () => img.src = defaultIcon;
2656
+ if (img) img.onerror = () => img.src = "https://datalynk-client.primary.auxilium.world/logo.png";
2657
2657
  if (this.nativeInstallPrompt) this.bindInstallButton();
2658
2658
  }
2659
2659
  }
@@ -3765,7 +3765,7 @@ class Superuser {
3765
3765
  } });
3766
3766
  }
3767
3767
  }
3768
- const version = "1.3.17-1";
3768
+ const version = "1.3.18";
3769
3769
  class WebRtc {
3770
3770
  constructor(api) {
3771
3771
  __publicField(this, "ice");
package/dist/pwa.d.ts CHANGED
@@ -3,6 +3,8 @@ export declare class PWA {
3
3
  private readonly api;
4
4
  /** Capture Install Event */
5
5
  nativeInstallPrompt: any;
6
+ /** Resolved icon URL used for prompt + manifest */
7
+ private resolvedIconUrl;
6
8
  get headless(): boolean;
7
9
  get iframe(): boolean;
8
10
  get mobile(): boolean;
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;IAmCH,OAAO,CAAC,QAAQ,CAAC,GAAG;IAlChC,4BAA4B;IACrB,mBAAmB,EAAE,GAAG,CAAQ;IAEvC,IAAI,QAAQ,IAAI,OAAO,CAAyC;IAEhE,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,OAAO,IAAI,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CASxF;IAED,IAAI,GAAG,IAAI,OAAO,CAEjB;gBAE4B,GAAG,EAAE,GAAG;IAErC,OAAO,CAAC,iBAAiB;IAuBzB,oBAAoB;IACd,KAAK,CAAC,QAAQ,GAAE,GAAQ;IA8H9B,qCAAqC;IAC/B,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;CA2LzC"}
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;IAsCH,OAAO,CAAC,QAAQ,CAAC,GAAG;IArChC,4BAA4B;IACrB,mBAAmB,EAAE,GAAG,CAAQ;IAEvC,mDAAmD;IACnD,OAAO,CAAC,eAAe,CAAqE;IAE5F,IAAI,QAAQ,IAAI,OAAO,CAAyC;IAEhE,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,OAAO,IAAI,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CASxF;IAED,IAAI,GAAG,IAAI,OAAO,CAEjB;gBAE4B,GAAG,EAAE,GAAG;IAErC,OAAO,CAAC,iBAAiB;IAiBzB,oBAAoB;IACd,KAAK,CAAC,QAAQ,GAAE,GAAQ;IA8H9B,qCAAqC;IAC/B,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;CAyLzC"}
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.3.17-1",
5
+ "version": "1.3.18",
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
7
7
  "private": false,
8
8
  "main": "./dist/index.cjs",