@auxilium/datalynk-client 1.3.14 → 1.3.16

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/api.d.ts CHANGED
@@ -66,6 +66,8 @@ export type ApiOptions = {
66
66
  loginLink?: boolean;
67
67
  /** Hide/disable the in-app PWA install popup entirely */
68
68
  hidePWAPrompt?: boolean;
69
+ /** Optional: override the installed-app icon (should be a PNG, ideally 512x512) */
70
+ icon?: string;
69
71
  };
70
72
  };
71
73
  /**
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,QAAQ,EAAQ,MAAM,gBAAgB,CAAC;AAClG,OAAO,EAAC,eAAe,EAAuB,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,SAAS,CAAC;AACvC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC,MAAM,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;I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EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;CAIjE"}
package/dist/index.cjs CHANGED
@@ -2395,7 +2395,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2395
2395
  }
2396
2396
  /** Setup the PWA */
2397
2397
  async setup(manifest = {}) {
2398
- var _a;
2398
+ var _a, _b, _c;
2399
+ const storageKey = `${this.api.options.name}:pwa`;
2399
2400
  window.addEventListener("beforeinstallprompt", (e) => {
2400
2401
  e.preventDefault();
2401
2402
  this.nativeInstallPrompt = e;
@@ -2405,6 +2406,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2405
2406
  this.bindInstallButton();
2406
2407
  }
2407
2408
  });
2409
+ window.addEventListener("appinstalled", () => {
2410
+ var _a2;
2411
+ localStorage.setItem(storageKey, "installed");
2412
+ (_a2 = document.querySelector(".pwa-prompt")) == null ? void 0 : _a2.remove();
2413
+ });
2408
2414
  this.api.options.pwaSettings = {
2409
2415
  timeout: 30,
2410
2416
  // Seconds
@@ -2422,14 +2428,50 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2422
2428
  meta2.content = value;
2423
2429
  document.head.append(meta2);
2424
2430
  };
2431
+ const link = (rel, href) => {
2432
+ const exists = document.querySelector(`link[rel="${rel}"]`);
2433
+ if (href === void 0) return exists;
2434
+ if (exists) {
2435
+ exists.href = href;
2436
+ return exists;
2437
+ }
2438
+ const link2 = document.createElement("link");
2439
+ link2.rel = rel;
2440
+ link2.href = href;
2441
+ document.head.append(link2);
2442
+ return link2;
2443
+ };
2444
+ const resolveUrl = (href) => {
2445
+ if (!href) return "";
2446
+ try {
2447
+ return new URL(href, location.href).href;
2448
+ } catch (e) {
2449
+ return href;
2450
+ }
2451
+ };
2452
+ const pickFavicon = () => {
2453
+ const touch = document.querySelector('link[rel="apple-touch-icon"]');
2454
+ if (touch == null ? void 0 : touch.href) return resolveUrl(touch.href);
2455
+ const iconWithSizes = Array.from(document.querySelectorAll('link[rel~="icon"][sizes]'));
2456
+ if (iconWithSizes.length) {
2457
+ const best = iconWithSizes.sort((a, b) => {
2458
+ var _a2, _b2;
2459
+ return (parseInt((((_a2 = b.sizes) == null ? void 0 : _a2.value) || "0").split("x")[0]) || 0) - (parseInt((((_b2 = a.sizes) == null ? void 0 : _b2.value) || "0").split("x")[0]) || 0);
2460
+ })[0];
2461
+ if (best == null ? void 0 : best.href) return resolveUrl(best.href);
2462
+ }
2463
+ const anyIcon = document.querySelector('link[rel~="icon"]');
2464
+ return (anyIcon == null ? void 0 : anyIcon.href) ? resolveUrl(anyIcon.href) : "";
2465
+ };
2466
+ const iconUrl = resolveUrl((_a = this.api.options.pwaSettings) == null ? void 0 : _a.icon) || pickFavicon() || "https://datalynk-client.primary.auxilium.world/logo.png";
2425
2467
  meta("name", "mobile-web-app-capable", "yes");
2426
2468
  meta("name", "apple-mobile-web-app-status-bar-style", "default");
2427
2469
  meta("name", "apple-mobile-web-app-title", this.api.options.name);
2428
- meta("name", "apple-touch-icon", `https://datalynk-client.primary.auxilium.world/logo.png`);
2429
- meta("name", "apple-touch-startup-image", `https://datalynk-client.primary.auxilium.world/logo.png`);
2470
+ link("apple-touch-icon", iconUrl);
2471
+ link("apple-touch-startup-image", iconUrl);
2430
2472
  if (!document.querySelector('link[rel="manifest"]')) {
2431
- const link = document.createElement("link");
2432
- link.rel = "manifest";
2473
+ const link2 = document.createElement("link");
2474
+ link2.rel = "manifest";
2433
2475
  const base = String(this.api.url).replace(/\/+$/, "");
2434
2476
  const startUrl = location.pathname;
2435
2477
  const scopePath = startUrl.endsWith("/") ? startUrl : startUrl.replace(/[^/]+$/, "");
@@ -2442,23 +2484,67 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2442
2484
  ...this.api.options.manifest || {},
2443
2485
  ...manifest || {}
2444
2486
  };
2445
- link.href = `${base}/manifest?json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2446
- document.head.append(link);
2487
+ if (!((_b = manifestObj.icons) == null ? void 0 : _b.length)) {
2488
+ manifestObj.icons = [
2489
+ { src: iconUrl, sizes: "192x192", type: "image/png", purpose: "any" },
2490
+ { src: iconUrl, sizes: "512x512", type: "image/png", purpose: "any" },
2491
+ { src: iconUrl, sizes: "512x512", type: "image/png", purpose: "maskable" }
2492
+ ];
2493
+ }
2494
+ link2.href = `${base}/manifest?json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2495
+ document.head.append(link2);
2496
+ }
2497
+ if (!((_c = this.api.options.pwaSettings) == null ? void 0 : _c.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
2498
+ const t = Number(this.api.options.pwaSettings.timeout ?? 30);
2499
+ const timeoutMs = t >= 1e3 ? t : t * 1e3;
2500
+ setTimeout(() => {
2501
+ var _a2, _b2, _c2, _d;
2502
+ const raw = localStorage.getItem(storageKey);
2503
+ if (raw === "installed") return;
2504
+ if (((_b2 = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b2.dismissExpiry) === 0) {
2505
+ if (raw !== "installed") localStorage.removeItem(storageKey);
2506
+ }
2507
+ const dismissedAt = raw ? Number(raw) : 0;
2508
+ const expiryDays = Number(((_d = (_c2 = this.api.options) == null ? void 0 : _c2.pwaSettings) == null ? void 0 : _d.dismissExpiry) ?? 0);
2509
+ if (dismissedAt && expiryDays > 0) {
2510
+ const expiryMs = expiryDays * 24 * 60 * 60 * 1e3;
2511
+ if (Date.now() < dismissedAt + expiryMs) return;
2512
+ }
2513
+ this.prompt();
2514
+ }, timeoutMs);
2447
2515
  }
2448
- if (!((_a = this.api.options.pwaSettings) == null ? void 0 : _a.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") setTimeout(() => {
2449
- var _a2, _b, _c, _d;
2450
- if (((_b = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b.dismissExpiry) === 0) localStorage.removeItem(`${this.api.options.name}:pwa`);
2451
- let dismissedDate = localStorage.getItem(`${this.api.options.name}:pwa`);
2452
- if (dismissedDate) dismissedDate = JSON.parse(dismissedDate);
2453
- if (!!dismissedDate && Date.now() > dismissedDate + ((_d = (_c = this.api.options) == null ? void 0 : _c.pwaSettings) == null ? void 0 : _d.dismissExpiry) * 6e4 * 60 * 24) return;
2454
- this.prompt();
2455
- }, this.api.options.pwaSettings.timeout);
2456
2516
  }
2457
2517
  /** Prompt user to install the app */
2458
2518
  async prompt(platform) {
2459
- var _a;
2519
+ var _a, _b;
2520
+ const storageKey = `${this.api.options.name}:pwa`;
2460
2521
  if ((_a = this.api.options.pwaSettings) == null ? void 0 : _a.hidePWAPrompt) return;
2522
+ if (this.pwa) return;
2523
+ if (localStorage.getItem(storageKey) === "installed") return;
2461
2524
  if (document.querySelector(".pwa-prompt")) return;
2525
+ const resolveUrl = (href) => {
2526
+ if (!href) return "";
2527
+ try {
2528
+ return new URL(href, location.href).href;
2529
+ } catch (e) {
2530
+ return href;
2531
+ }
2532
+ };
2533
+ const pickFavicon = () => {
2534
+ const touch = document.querySelector('link[rel="apple-touch-icon"]');
2535
+ if (touch == null ? void 0 : touch.href) return resolveUrl(touch.href);
2536
+ const iconWithSizes = Array.from(document.querySelectorAll('link[rel~="icon"][sizes]'));
2537
+ if (iconWithSizes.length) {
2538
+ const best = iconWithSizes.sort((a, b) => {
2539
+ var _a2, _b2;
2540
+ return (parseInt((((_a2 = b.sizes) == null ? void 0 : _a2.value) || "0").split("x")[0]) || 0) - (parseInt((((_b2 = a.sizes) == null ? void 0 : _b2.value) || "0").split("x")[0]) || 0);
2541
+ })[0];
2542
+ if (best == null ? void 0 : best.href) return resolveUrl(best.href);
2543
+ }
2544
+ const anyIcon = document.querySelector('link[rel~="icon"]');
2545
+ return (anyIcon == null ? void 0 : anyIcon.href) ? resolveUrl(anyIcon.href) : "";
2546
+ };
2547
+ const iconUrl = resolveUrl((_b = this.api.options.pwaSettings) == null ? void 0 : _b.icon) || pickFavicon() || "https://datalynk-client.primary.auxilium.world/logo.png";
2462
2548
  const targetPlatform = platform || this.platform;
2463
2549
  const isAndroid = targetPlatform == "android";
2464
2550
  const isIOS = targetPlatform == "ios";
@@ -2584,7 +2670,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2584
2670
  prompt.classList.add("pwa-prompt");
2585
2671
  prompt.innerHTML = `
2586
2672
  <div class="pwa-prompt-header">
2587
- <img src="https://datalynk-client.primary.auxilium.world/logo.png" alt="Logo" />
2673
+ <img src="${iconUrl}" alt="Logo" />
2588
2674
  <h1>Install ${this.api.options.name}</h1>
2589
2675
  <button class="pwa-prompt-close">&times;</button>
2590
2676
  </div>
@@ -2601,7 +2687,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2601
2687
  const closeBtn = prompt.querySelector(".pwa-prompt-close");
2602
2688
  closeBtn.onclick = () => {
2603
2689
  var _a2;
2604
- !!((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ? localStorage.setItem(`${this.api.options.name}:pwa`, Date.now().toString()) : localStorage.removeItem(`${this.api.options.name}:pwa`);
2690
+ !!((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ? localStorage.setItem(storageKey, Date.now().toString()) : localStorage.removeItem(storageKey);
2605
2691
  prompt.remove();
2606
2692
  };
2607
2693
  document.body.append(prompt);
@@ -3716,7 +3802,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3716
3802
  } });
3717
3803
  }
3718
3804
  }
3719
- const version = "1.3.14";
3805
+ const version = "1.3.16";
3720
3806
  class WebRtc {
3721
3807
  constructor(api) {
3722
3808
  __publicField(this, "ice");
@@ -3953,18 +4039,39 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3953
4039
  (_b = this.options.offline) == null ? void 0 : _b.forEach((id) => this.slice(id));
3954
4040
  if (this.options.serviceWorker && typeof navigator["serviceWorker"] != "undefined") {
3955
4041
  (async () => {
4042
+ let initDone = false;
3956
4043
  const init = () => {
3957
4044
  var _a2;
4045
+ if (initDone) return;
4046
+ initDone = true;
3958
4047
  (_a2 = navigator.serviceWorker.controller) == null ? void 0 : _a2.postMessage({ options: { ...this.options, url: this.url } });
3959
4048
  this.token$.subscribe((token) => {
3960
4049
  var _a3;
3961
4050
  return (_a3 = navigator.serviceWorker.controller) == null ? void 0 : _a3.postMessage({ token });
3962
4051
  });
3963
4052
  };
3964
- await navigator.serviceWorker.getRegistration(this.options.serviceWorker).then((reg) => reg ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
4053
+ const scope = "/";
4054
+ const reg = await navigator.serviceWorker.getRegistration(scope).then((reg2) => reg2 ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
4055
+ try {
4056
+ await reg.update();
4057
+ } catch (e) {
4058
+ }
4059
+ if (typeof document !== "undefined") {
4060
+ document.addEventListener("visibilitychange", () => {
4061
+ if (document.visibilityState === "visible") reg.update().catch(() => {
4062
+ });
4063
+ });
4064
+ }
3965
4065
  navigator.serviceWorker.ready.then(() => {
3966
4066
  if (navigator.serviceWorker.controller) navigator.serviceWorker.ready.then(() => init());
3967
4067
  else navigator.serviceWorker.addEventListener("controllerchange", () => init(), { once: true });
4068
+ let refreshed = false;
4069
+ navigator.serviceWorker.addEventListener("controllerchange", () => {
4070
+ if (refreshed) return;
4071
+ refreshed = true;
4072
+ const standalone = matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone);
4073
+ if (standalone) location.reload();
4074
+ });
3968
4075
  });
3969
4076
  })();
3970
4077
  }
@@ -4022,9 +4129,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4022
4129
  }),
4023
4130
  body: JSON.stringify(_Api.translateTokens(req))
4024
4131
  }).then(async (resp) => {
4025
- const warning = resp.headers["X-Warning"];
4132
+ const warning = resp.headers.get("X-Warning");
4026
4133
  if (warning) console.warn(warning);
4027
- const banner = resp.headers["X-User-Notice"];
4134
+ const banner = resp.headers.get("X-User-Notice");
4028
4135
  if (banner) {
4029
4136
  createBanner(banner);
4030
4137
  setTimeout(() => removeBanner(), 1e4);
package/dist/index.mjs CHANGED
@@ -2391,7 +2391,8 @@ class PWA {
2391
2391
  }
2392
2392
  /** Setup the PWA */
2393
2393
  async setup(manifest = {}) {
2394
- var _a;
2394
+ var _a, _b, _c;
2395
+ const storageKey = `${this.api.options.name}:pwa`;
2395
2396
  window.addEventListener("beforeinstallprompt", (e) => {
2396
2397
  e.preventDefault();
2397
2398
  this.nativeInstallPrompt = e;
@@ -2401,6 +2402,11 @@ class PWA {
2401
2402
  this.bindInstallButton();
2402
2403
  }
2403
2404
  });
2405
+ window.addEventListener("appinstalled", () => {
2406
+ var _a2;
2407
+ localStorage.setItem(storageKey, "installed");
2408
+ (_a2 = document.querySelector(".pwa-prompt")) == null ? void 0 : _a2.remove();
2409
+ });
2404
2410
  this.api.options.pwaSettings = {
2405
2411
  timeout: 30,
2406
2412
  // Seconds
@@ -2418,14 +2424,50 @@ class PWA {
2418
2424
  meta2.content = value;
2419
2425
  document.head.append(meta2);
2420
2426
  };
2427
+ const link = (rel, href) => {
2428
+ const exists = document.querySelector(`link[rel="${rel}"]`);
2429
+ if (href === void 0) return exists;
2430
+ if (exists) {
2431
+ exists.href = href;
2432
+ return exists;
2433
+ }
2434
+ const link2 = document.createElement("link");
2435
+ link2.rel = rel;
2436
+ link2.href = href;
2437
+ document.head.append(link2);
2438
+ return link2;
2439
+ };
2440
+ const resolveUrl = (href) => {
2441
+ if (!href) return "";
2442
+ try {
2443
+ return new URL(href, location.href).href;
2444
+ } catch (e) {
2445
+ return href;
2446
+ }
2447
+ };
2448
+ const pickFavicon = () => {
2449
+ const touch = document.querySelector('link[rel="apple-touch-icon"]');
2450
+ if (touch == null ? void 0 : touch.href) return resolveUrl(touch.href);
2451
+ const iconWithSizes = Array.from(document.querySelectorAll('link[rel~="icon"][sizes]'));
2452
+ if (iconWithSizes.length) {
2453
+ const best = iconWithSizes.sort((a, b) => {
2454
+ var _a2, _b2;
2455
+ return (parseInt((((_a2 = b.sizes) == null ? void 0 : _a2.value) || "0").split("x")[0]) || 0) - (parseInt((((_b2 = a.sizes) == null ? void 0 : _b2.value) || "0").split("x")[0]) || 0);
2456
+ })[0];
2457
+ if (best == null ? void 0 : best.href) return resolveUrl(best.href);
2458
+ }
2459
+ const anyIcon = document.querySelector('link[rel~="icon"]');
2460
+ return (anyIcon == null ? void 0 : anyIcon.href) ? resolveUrl(anyIcon.href) : "";
2461
+ };
2462
+ const iconUrl = resolveUrl((_a = this.api.options.pwaSettings) == null ? void 0 : _a.icon) || pickFavicon() || "https://datalynk-client.primary.auxilium.world/logo.png";
2421
2463
  meta("name", "mobile-web-app-capable", "yes");
2422
2464
  meta("name", "apple-mobile-web-app-status-bar-style", "default");
2423
2465
  meta("name", "apple-mobile-web-app-title", this.api.options.name);
2424
- meta("name", "apple-touch-icon", `https://datalynk-client.primary.auxilium.world/logo.png`);
2425
- meta("name", "apple-touch-startup-image", `https://datalynk-client.primary.auxilium.world/logo.png`);
2466
+ link("apple-touch-icon", iconUrl);
2467
+ link("apple-touch-startup-image", iconUrl);
2426
2468
  if (!document.querySelector('link[rel="manifest"]')) {
2427
- const link = document.createElement("link");
2428
- link.rel = "manifest";
2469
+ const link2 = document.createElement("link");
2470
+ link2.rel = "manifest";
2429
2471
  const base = String(this.api.url).replace(/\/+$/, "");
2430
2472
  const startUrl = location.pathname;
2431
2473
  const scopePath = startUrl.endsWith("/") ? startUrl : startUrl.replace(/[^/]+$/, "");
@@ -2438,23 +2480,67 @@ class PWA {
2438
2480
  ...this.api.options.manifest || {},
2439
2481
  ...manifest || {}
2440
2482
  };
2441
- link.href = `${base}/manifest?json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2442
- document.head.append(link);
2483
+ if (!((_b = manifestObj.icons) == null ? void 0 : _b.length)) {
2484
+ manifestObj.icons = [
2485
+ { src: iconUrl, sizes: "192x192", type: "image/png", purpose: "any" },
2486
+ { src: iconUrl, sizes: "512x512", type: "image/png", purpose: "any" },
2487
+ { src: iconUrl, sizes: "512x512", type: "image/png", purpose: "maskable" }
2488
+ ];
2489
+ }
2490
+ link2.href = `${base}/manifest?json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2491
+ document.head.append(link2);
2492
+ }
2493
+ if (!((_c = this.api.options.pwaSettings) == null ? void 0 : _c.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
2494
+ const t = Number(this.api.options.pwaSettings.timeout ?? 30);
2495
+ const timeoutMs = t >= 1e3 ? t : t * 1e3;
2496
+ setTimeout(() => {
2497
+ var _a2, _b2, _c2, _d;
2498
+ const raw = localStorage.getItem(storageKey);
2499
+ if (raw === "installed") return;
2500
+ if (((_b2 = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b2.dismissExpiry) === 0) {
2501
+ if (raw !== "installed") localStorage.removeItem(storageKey);
2502
+ }
2503
+ const dismissedAt = raw ? Number(raw) : 0;
2504
+ const expiryDays = Number(((_d = (_c2 = this.api.options) == null ? void 0 : _c2.pwaSettings) == null ? void 0 : _d.dismissExpiry) ?? 0);
2505
+ if (dismissedAt && expiryDays > 0) {
2506
+ const expiryMs = expiryDays * 24 * 60 * 60 * 1e3;
2507
+ if (Date.now() < dismissedAt + expiryMs) return;
2508
+ }
2509
+ this.prompt();
2510
+ }, timeoutMs);
2443
2511
  }
2444
- if (!((_a = this.api.options.pwaSettings) == null ? void 0 : _a.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") setTimeout(() => {
2445
- var _a2, _b, _c, _d;
2446
- if (((_b = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b.dismissExpiry) === 0) localStorage.removeItem(`${this.api.options.name}:pwa`);
2447
- let dismissedDate = localStorage.getItem(`${this.api.options.name}:pwa`);
2448
- if (dismissedDate) dismissedDate = JSON.parse(dismissedDate);
2449
- if (!!dismissedDate && Date.now() > dismissedDate + ((_d = (_c = this.api.options) == null ? void 0 : _c.pwaSettings) == null ? void 0 : _d.dismissExpiry) * 6e4 * 60 * 24) return;
2450
- this.prompt();
2451
- }, this.api.options.pwaSettings.timeout);
2452
2512
  }
2453
2513
  /** Prompt user to install the app */
2454
2514
  async prompt(platform) {
2455
- var _a;
2515
+ var _a, _b;
2516
+ const storageKey = `${this.api.options.name}:pwa`;
2456
2517
  if ((_a = this.api.options.pwaSettings) == null ? void 0 : _a.hidePWAPrompt) return;
2518
+ if (this.pwa) return;
2519
+ if (localStorage.getItem(storageKey) === "installed") return;
2457
2520
  if (document.querySelector(".pwa-prompt")) return;
2521
+ const resolveUrl = (href) => {
2522
+ if (!href) return "";
2523
+ try {
2524
+ return new URL(href, location.href).href;
2525
+ } catch (e) {
2526
+ return href;
2527
+ }
2528
+ };
2529
+ const pickFavicon = () => {
2530
+ const touch = document.querySelector('link[rel="apple-touch-icon"]');
2531
+ if (touch == null ? void 0 : touch.href) return resolveUrl(touch.href);
2532
+ const iconWithSizes = Array.from(document.querySelectorAll('link[rel~="icon"][sizes]'));
2533
+ if (iconWithSizes.length) {
2534
+ const best = iconWithSizes.sort((a, b) => {
2535
+ var _a2, _b2;
2536
+ return (parseInt((((_a2 = b.sizes) == null ? void 0 : _a2.value) || "0").split("x")[0]) || 0) - (parseInt((((_b2 = a.sizes) == null ? void 0 : _b2.value) || "0").split("x")[0]) || 0);
2537
+ })[0];
2538
+ if (best == null ? void 0 : best.href) return resolveUrl(best.href);
2539
+ }
2540
+ const anyIcon = document.querySelector('link[rel~="icon"]');
2541
+ return (anyIcon == null ? void 0 : anyIcon.href) ? resolveUrl(anyIcon.href) : "";
2542
+ };
2543
+ const iconUrl = resolveUrl((_b = this.api.options.pwaSettings) == null ? void 0 : _b.icon) || pickFavicon() || "https://datalynk-client.primary.auxilium.world/logo.png";
2458
2544
  const targetPlatform = platform || this.platform;
2459
2545
  const isAndroid = targetPlatform == "android";
2460
2546
  const isIOS = targetPlatform == "ios";
@@ -2580,7 +2666,7 @@ class PWA {
2580
2666
  prompt.classList.add("pwa-prompt");
2581
2667
  prompt.innerHTML = `
2582
2668
  <div class="pwa-prompt-header">
2583
- <img src="https://datalynk-client.primary.auxilium.world/logo.png" alt="Logo" />
2669
+ <img src="${iconUrl}" alt="Logo" />
2584
2670
  <h1>Install ${this.api.options.name}</h1>
2585
2671
  <button class="pwa-prompt-close">&times;</button>
2586
2672
  </div>
@@ -2597,7 +2683,7 @@ class PWA {
2597
2683
  const closeBtn = prompt.querySelector(".pwa-prompt-close");
2598
2684
  closeBtn.onclick = () => {
2599
2685
  var _a2;
2600
- !!((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ? localStorage.setItem(`${this.api.options.name}:pwa`, Date.now().toString()) : localStorage.removeItem(`${this.api.options.name}:pwa`);
2686
+ !!((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ? localStorage.setItem(storageKey, Date.now().toString()) : localStorage.removeItem(storageKey);
2601
2687
  prompt.remove();
2602
2688
  };
2603
2689
  document.body.append(prompt);
@@ -3712,7 +3798,7 @@ class Superuser {
3712
3798
  } });
3713
3799
  }
3714
3800
  }
3715
- const version = "1.3.14";
3801
+ const version = "1.3.16";
3716
3802
  class WebRtc {
3717
3803
  constructor(api) {
3718
3804
  __publicField(this, "ice");
@@ -3949,18 +4035,39 @@ const _Api = class _Api {
3949
4035
  (_b = this.options.offline) == null ? void 0 : _b.forEach((id) => this.slice(id));
3950
4036
  if (this.options.serviceWorker && typeof navigator["serviceWorker"] != "undefined") {
3951
4037
  (async () => {
4038
+ let initDone = false;
3952
4039
  const init = () => {
3953
4040
  var _a2;
4041
+ if (initDone) return;
4042
+ initDone = true;
3954
4043
  (_a2 = navigator.serviceWorker.controller) == null ? void 0 : _a2.postMessage({ options: { ...this.options, url: this.url } });
3955
4044
  this.token$.subscribe((token) => {
3956
4045
  var _a3;
3957
4046
  return (_a3 = navigator.serviceWorker.controller) == null ? void 0 : _a3.postMessage({ token });
3958
4047
  });
3959
4048
  };
3960
- await navigator.serviceWorker.getRegistration(this.options.serviceWorker).then((reg) => reg ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
4049
+ const scope = "/";
4050
+ const reg = await navigator.serviceWorker.getRegistration(scope).then((reg2) => reg2 ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
4051
+ try {
4052
+ await reg.update();
4053
+ } catch (e) {
4054
+ }
4055
+ if (typeof document !== "undefined") {
4056
+ document.addEventListener("visibilitychange", () => {
4057
+ if (document.visibilityState === "visible") reg.update().catch(() => {
4058
+ });
4059
+ });
4060
+ }
3961
4061
  navigator.serviceWorker.ready.then(() => {
3962
4062
  if (navigator.serviceWorker.controller) navigator.serviceWorker.ready.then(() => init());
3963
4063
  else navigator.serviceWorker.addEventListener("controllerchange", () => init(), { once: true });
4064
+ let refreshed = false;
4065
+ navigator.serviceWorker.addEventListener("controllerchange", () => {
4066
+ if (refreshed) return;
4067
+ refreshed = true;
4068
+ const standalone = matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone);
4069
+ if (standalone) location.reload();
4070
+ });
3964
4071
  });
3965
4072
  })();
3966
4073
  }
@@ -4018,9 +4125,9 @@ const _Api = class _Api {
4018
4125
  }),
4019
4126
  body: JSON.stringify(_Api.translateTokens(req))
4020
4127
  }).then(async (resp) => {
4021
- const warning = resp.headers["X-Warning"];
4128
+ const warning = resp.headers.get("X-Warning");
4022
4129
  if (warning) console.warn(warning);
4023
- const banner = resp.headers["X-User-Notice"];
4130
+ const banner = resp.headers.get("X-User-Notice");
4024
4131
  if (banner) {
4025
4132
  createBanner(banner);
4026
4133
  setTimeout(() => removeBanner(), 1e4);
package/dist/pwa.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pwa.d.ts","sourceRoot":"","sources":["../src/pwa.ts"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Q,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;IAoJ9B,qCAAqC;IAC/B,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;CAyMzC"}
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.14",
5
+ "version": "1.3.16",
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
7
7
  "private": false,
8
8
  "main": "./dist/index.cjs",