@auxilium/datalynk-client 1.3.16 → 1.3.17-1

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.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;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACZ,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACxB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC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= document.querySelector("#installPwaBtn");
2381
2381
  if (!installBtn) return;
2382
2382
  installBtn.onclick = async () => {
2383
- var _a;
2383
+ var _a, _b, _c;
2384
2384
  if (!this.nativeInstallPrompt) return console.warn("PWA is not supported");
2385
2385
  this.nativeInstallPrompt.prompt();
2386
2386
  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);
2387
2389
  if (choice.outcome === "accepted") {
2388
2390
  console.log("PWA installed");
2389
- localStorage.setItem(`${this.api.options.name}:pwa`, "installed");
2391
+ localStorage.setItem(storageKey, "installed");
2390
2392
  } else {
2391
- localStorage.setItem(`${this.api.options.name}:pwa`, Date.now().toString());
2393
+ expiryDays === 0 ? localStorage.removeItem(storageKey) : localStorage.setItem(storageKey, Date.now().toString());
2392
2394
  }
2393
- (_a = document.querySelector(".pwa-prompt")) == null ? void 0 : _a.remove();
2395
+ (_c = document.querySelector(".pwa-prompt")) == null ? void 0 : _c.remove();
2394
2396
  };
2395
2397
  }
2396
2398
  /** Setup the PWA */
2397
2399
  async setup(manifest = {}) {
2398
- var _a, _b, _c;
2400
+ var _a, _b, _c, _d;
2399
2401
  const storageKey = `${this.api.options.name}:pwa`;
2400
2402
  window.addEventListener("beforeinstallprompt", (e) => {
2401
2403
  e.preventDefault();
@@ -2428,84 +2430,67 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2428
2430
  meta2.content = value;
2429
2431
  document.head.append(meta2);
2430
2432
  };
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";
2467
2433
  meta("name", "mobile-web-app-capable", "yes");
2468
2434
  meta("name", "apple-mobile-web-app-status-bar-style", "default");
2469
2435
  meta("name", "apple-mobile-web-app-title", this.api.options.name);
2470
- link("apple-touch-icon", iconUrl);
2471
- link("apple-touch-startup-image", iconUrl);
2472
- if (!document.querySelector('link[rel="manifest"]')) {
2473
- const link2 = document.createElement("link");
2474
- link2.rel = "manifest";
2475
- const base = String(this.api.url).replace(/\/+$/, "");
2476
- const startUrl = location.pathname;
2477
- const scopePath = startUrl.endsWith("/") ? startUrl : startUrl.replace(/[^/]+$/, "");
2478
- const manifestObj = {
2479
- name: this.api.options.name,
2480
- short_name: this.api.options.name,
2481
- start_url: startUrl,
2482
- scope: scopePath || "/",
2483
- display: "standalone",
2484
- ...this.api.options.manifest || {},
2485
- ...manifest || {}
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
+ const defaultIcon = "https://datalynk-client.primary.auxilium.world/logo.png";
2439
+ let iconUrl = ((_b = (_a = this.api.options) == null ? void 0 : _a.pwaSettings) == null ? void 0 : _b.icon) || defaultIcon;
2440
+ const canLoad = (url) => new Promise((res) => {
2441
+ const img = new Image();
2442
+ const t = setTimeout(() => res(false), 2500);
2443
+ img.onload = () => {
2444
+ clearTimeout(t);
2445
+ res(true);
2486
2446
  };
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);
2447
+ img.onerror = () => {
2448
+ clearTimeout(t);
2449
+ res(false);
2450
+ };
2451
+ img.src = url;
2452
+ });
2453
+ if (iconUrl && iconUrl !== defaultIcon) {
2454
+ const ok = await canLoad(iconUrl);
2455
+ if (!ok) iconUrl = defaultIcon;
2456
+ }
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);
2462
+ }
2463
+ const base = String(this.api.url).replace(/\/+$/, "");
2464
+ const startUrl = location.pathname;
2465
+ const scopePath = startUrl.endsWith("/") ? startUrl : startUrl.replace(/[^/]+$/, "");
2466
+ const manifestObj = {
2467
+ name: this.api.options.name,
2468
+ short_name: this.api.options.name,
2469
+ start_url: startUrl,
2470
+ scope: scopePath || "/",
2471
+ display: "standalone",
2472
+ ...this.api.options.manifest || {},
2473
+ ...manifest || {}
2474
+ };
2475
+ if (!((_c = manifestObj.icons) == null ? void 0 : _c.length)) {
2476
+ manifestObj.icons = [
2477
+ { src: iconUrl, sizes: "192x192", type: "image/png" },
2478
+ { src: iconUrl, sizes: "512x512", type: "image/png" }
2479
+ ];
2496
2480
  }
2497
- if (!((_c = this.api.options.pwaSettings) == null ? void 0 : _c.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
2481
+ manifestLink.href = `${base}/manifest?ts=${Date.now()}&json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2482
+ if (!((_d = this.api.options.pwaSettings) == null ? void 0 : _d.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
2498
2483
  const t = Number(this.api.options.pwaSettings.timeout ?? 30);
2499
2484
  const timeoutMs = t >= 1e3 ? t : t * 1e3;
2500
2485
  setTimeout(() => {
2501
- var _a2, _b2, _c2, _d;
2486
+ var _a2, _b2, _c2, _d2;
2502
2487
  const raw = localStorage.getItem(storageKey);
2503
2488
  if (raw === "installed") return;
2504
2489
  if (((_b2 = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b2.dismissExpiry) === 0) {
2505
2490
  if (raw !== "installed") localStorage.removeItem(storageKey);
2506
2491
  }
2507
2492
  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);
2493
+ const expiryDays = Number(((_d2 = (_c2 = this.api.options) == null ? void 0 : _c2.pwaSettings) == null ? void 0 : _d2.dismissExpiry) ?? 0);
2509
2494
  if (dismissedAt && expiryDays > 0) {
2510
2495
  const expiryMs = expiryDays * 24 * 60 * 60 * 1e3;
2511
2496
  if (Date.now() < dismissedAt + expiryMs) return;
@@ -2516,35 +2501,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2516
2501
  }
2517
2502
  /** Prompt user to install the app */
2518
2503
  async prompt(platform) {
2519
- var _a, _b;
2504
+ var _a, _b, _c;
2520
2505
  const storageKey = `${this.api.options.name}:pwa`;
2521
2506
  if ((_a = this.api.options.pwaSettings) == null ? void 0 : _a.hidePWAPrompt) return;
2522
2507
  if (this.pwa) return;
2523
2508
  if (localStorage.getItem(storageKey) === "installed") return;
2524
2509
  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";
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;
2548
2512
  const targetPlatform = platform || this.platform;
2549
2513
  const isAndroid = targetPlatform == "android";
2550
2514
  const isIOS = targetPlatform == "ios";
@@ -2686,11 +2650,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2686
2650
  `;
2687
2651
  const closeBtn = prompt.querySelector(".pwa-prompt-close");
2688
2652
  closeBtn.onclick = () => {
2689
- var _a2;
2690
- !!((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ? localStorage.setItem(storageKey, Date.now().toString()) : localStorage.removeItem(storageKey);
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());
2691
2656
  prompt.remove();
2692
2657
  };
2693
2658
  document.body.append(prompt);
2659
+ const img = prompt.querySelector(".pwa-prompt-header img");
2660
+ if (img) img.onerror = () => img.src = defaultIcon;
2694
2661
  if (this.nativeInstallPrompt) this.bindInstallButton();
2695
2662
  }
2696
2663
  }
@@ -3802,7 +3769,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3802
3769
  } });
3803
3770
  }
3804
3771
  }
3805
- const version = "1.3.16";
3772
+ const version = "1.3.17-1";
3806
3773
  class WebRtc {
3807
3774
  constructor(api) {
3808
3775
  __publicField(this, "ice");
@@ -4039,39 +4006,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4039
4006
  (_b = this.options.offline) == null ? void 0 : _b.forEach((id) => this.slice(id));
4040
4007
  if (this.options.serviceWorker && typeof navigator["serviceWorker"] != "undefined") {
4041
4008
  (async () => {
4042
- let initDone = false;
4043
4009
  const init = () => {
4044
4010
  var _a2;
4045
- if (initDone) return;
4046
- initDone = true;
4047
4011
  (_a2 = navigator.serviceWorker.controller) == null ? void 0 : _a2.postMessage({ options: { ...this.options, url: this.url } });
4048
4012
  this.token$.subscribe((token) => {
4049
4013
  var _a3;
4050
4014
  return (_a3 = navigator.serviceWorker.controller) == null ? void 0 : _a3.postMessage({ token });
4051
4015
  });
4052
4016
  };
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
- }
4017
+ await navigator.serviceWorker.getRegistration(this.options.serviceWorker).then((reg) => reg ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
4065
4018
  navigator.serviceWorker.ready.then(() => {
4066
4019
  if (navigator.serviceWorker.controller) navigator.serviceWorker.ready.then(() => init());
4067
4020
  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
- });
4075
4021
  });
4076
4022
  })();
4077
4023
  }
@@ -4129,9 +4075,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4129
4075
  }),
4130
4076
  body: JSON.stringify(_Api.translateTokens(req))
4131
4077
  }).then(async (resp) => {
4132
- const warning = resp.headers.get("X-Warning");
4078
+ const warning = resp.headers["X-Warning"];
4133
4079
  if (warning) console.warn(warning);
4134
- const banner = resp.headers.get("X-User-Notice");
4080
+ const banner = resp.headers["X-User-Notice"];
4135
4081
  if (banner) {
4136
4082
  createBanner(banner);
4137
4083
  setTimeout(() => removeBanner(), 1e4);
package/dist/index.mjs CHANGED
@@ -2376,22 +2376,24 @@ class PWA {
2376
2376
  const installBtn = document.querySelector("#installPwaBtn");
2377
2377
  if (!installBtn) return;
2378
2378
  installBtn.onclick = async () => {
2379
- var _a;
2379
+ var _a, _b, _c;
2380
2380
  if (!this.nativeInstallPrompt) return console.warn("PWA is not supported");
2381
2381
  this.nativeInstallPrompt.prompt();
2382
2382
  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);
2383
2385
  if (choice.outcome === "accepted") {
2384
2386
  console.log("PWA installed");
2385
- localStorage.setItem(`${this.api.options.name}:pwa`, "installed");
2387
+ localStorage.setItem(storageKey, "installed");
2386
2388
  } else {
2387
- localStorage.setItem(`${this.api.options.name}:pwa`, Date.now().toString());
2389
+ expiryDays === 0 ? localStorage.removeItem(storageKey) : localStorage.setItem(storageKey, Date.now().toString());
2388
2390
  }
2389
- (_a = document.querySelector(".pwa-prompt")) == null ? void 0 : _a.remove();
2391
+ (_c = document.querySelector(".pwa-prompt")) == null ? void 0 : _c.remove();
2390
2392
  };
2391
2393
  }
2392
2394
  /** Setup the PWA */
2393
2395
  async setup(manifest = {}) {
2394
- var _a, _b, _c;
2396
+ var _a, _b, _c, _d;
2395
2397
  const storageKey = `${this.api.options.name}:pwa`;
2396
2398
  window.addEventListener("beforeinstallprompt", (e) => {
2397
2399
  e.preventDefault();
@@ -2424,84 +2426,67 @@ class PWA {
2424
2426
  meta2.content = value;
2425
2427
  document.head.append(meta2);
2426
2428
  };
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";
2463
2429
  meta("name", "mobile-web-app-capable", "yes");
2464
2430
  meta("name", "apple-mobile-web-app-status-bar-style", "default");
2465
2431
  meta("name", "apple-mobile-web-app-title", this.api.options.name);
2466
- link("apple-touch-icon", iconUrl);
2467
- link("apple-touch-startup-image", iconUrl);
2468
- if (!document.querySelector('link[rel="manifest"]')) {
2469
- const link2 = document.createElement("link");
2470
- link2.rel = "manifest";
2471
- const base = String(this.api.url).replace(/\/+$/, "");
2472
- const startUrl = location.pathname;
2473
- const scopePath = startUrl.endsWith("/") ? startUrl : startUrl.replace(/[^/]+$/, "");
2474
- const manifestObj = {
2475
- name: this.api.options.name,
2476
- short_name: this.api.options.name,
2477
- start_url: startUrl,
2478
- scope: scopePath || "/",
2479
- display: "standalone",
2480
- ...this.api.options.manifest || {},
2481
- ...manifest || {}
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
+ const defaultIcon = "https://datalynk-client.primary.auxilium.world/logo.png";
2435
+ let iconUrl = ((_b = (_a = this.api.options) == null ? void 0 : _a.pwaSettings) == null ? void 0 : _b.icon) || defaultIcon;
2436
+ const canLoad = (url) => new Promise((res) => {
2437
+ const img = new Image();
2438
+ const t = setTimeout(() => res(false), 2500);
2439
+ img.onload = () => {
2440
+ clearTimeout(t);
2441
+ res(true);
2482
2442
  };
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);
2443
+ img.onerror = () => {
2444
+ clearTimeout(t);
2445
+ res(false);
2446
+ };
2447
+ img.src = url;
2448
+ });
2449
+ if (iconUrl && iconUrl !== defaultIcon) {
2450
+ const ok = await canLoad(iconUrl);
2451
+ if (!ok) iconUrl = defaultIcon;
2452
+ }
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);
2458
+ }
2459
+ const base = String(this.api.url).replace(/\/+$/, "");
2460
+ const startUrl = location.pathname;
2461
+ const scopePath = startUrl.endsWith("/") ? startUrl : startUrl.replace(/[^/]+$/, "");
2462
+ const manifestObj = {
2463
+ name: this.api.options.name,
2464
+ short_name: this.api.options.name,
2465
+ start_url: startUrl,
2466
+ scope: scopePath || "/",
2467
+ display: "standalone",
2468
+ ...this.api.options.manifest || {},
2469
+ ...manifest || {}
2470
+ };
2471
+ if (!((_c = manifestObj.icons) == null ? void 0 : _c.length)) {
2472
+ manifestObj.icons = [
2473
+ { src: iconUrl, sizes: "192x192", type: "image/png" },
2474
+ { src: iconUrl, sizes: "512x512", type: "image/png" }
2475
+ ];
2492
2476
  }
2493
- if (!((_c = this.api.options.pwaSettings) == null ? void 0 : _c.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
2477
+ manifestLink.href = `${base}/manifest?ts=${Date.now()}&json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2478
+ if (!((_d = this.api.options.pwaSettings) == null ? void 0 : _d.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
2494
2479
  const t = Number(this.api.options.pwaSettings.timeout ?? 30);
2495
2480
  const timeoutMs = t >= 1e3 ? t : t * 1e3;
2496
2481
  setTimeout(() => {
2497
- var _a2, _b2, _c2, _d;
2482
+ var _a2, _b2, _c2, _d2;
2498
2483
  const raw = localStorage.getItem(storageKey);
2499
2484
  if (raw === "installed") return;
2500
2485
  if (((_b2 = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b2.dismissExpiry) === 0) {
2501
2486
  if (raw !== "installed") localStorage.removeItem(storageKey);
2502
2487
  }
2503
2488
  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);
2489
+ const expiryDays = Number(((_d2 = (_c2 = this.api.options) == null ? void 0 : _c2.pwaSettings) == null ? void 0 : _d2.dismissExpiry) ?? 0);
2505
2490
  if (dismissedAt && expiryDays > 0) {
2506
2491
  const expiryMs = expiryDays * 24 * 60 * 60 * 1e3;
2507
2492
  if (Date.now() < dismissedAt + expiryMs) return;
@@ -2512,35 +2497,14 @@ class PWA {
2512
2497
  }
2513
2498
  /** Prompt user to install the app */
2514
2499
  async prompt(platform) {
2515
- var _a, _b;
2500
+ var _a, _b, _c;
2516
2501
  const storageKey = `${this.api.options.name}:pwa`;
2517
2502
  if ((_a = this.api.options.pwaSettings) == null ? void 0 : _a.hidePWAPrompt) return;
2518
2503
  if (this.pwa) return;
2519
2504
  if (localStorage.getItem(storageKey) === "installed") return;
2520
2505
  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";
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;
2544
2508
  const targetPlatform = platform || this.platform;
2545
2509
  const isAndroid = targetPlatform == "android";
2546
2510
  const isIOS = targetPlatform == "ios";
@@ -2682,11 +2646,14 @@ class PWA {
2682
2646
  `;
2683
2647
  const closeBtn = prompt.querySelector(".pwa-prompt-close");
2684
2648
  closeBtn.onclick = () => {
2685
- var _a2;
2686
- !!((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ? localStorage.setItem(storageKey, Date.now().toString()) : localStorage.removeItem(storageKey);
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());
2687
2652
  prompt.remove();
2688
2653
  };
2689
2654
  document.body.append(prompt);
2655
+ const img = prompt.querySelector(".pwa-prompt-header img");
2656
+ if (img) img.onerror = () => img.src = defaultIcon;
2690
2657
  if (this.nativeInstallPrompt) this.bindInstallButton();
2691
2658
  }
2692
2659
  }
@@ -3798,7 +3765,7 @@ class Superuser {
3798
3765
  } });
3799
3766
  }
3800
3767
  }
3801
- const version = "1.3.16";
3768
+ const version = "1.3.17-1";
3802
3769
  class WebRtc {
3803
3770
  constructor(api) {
3804
3771
  __publicField(this, "ice");
@@ -4035,39 +4002,18 @@ const _Api = class _Api {
4035
4002
  (_b = this.options.offline) == null ? void 0 : _b.forEach((id) => this.slice(id));
4036
4003
  if (this.options.serviceWorker && typeof navigator["serviceWorker"] != "undefined") {
4037
4004
  (async () => {
4038
- let initDone = false;
4039
4005
  const init = () => {
4040
4006
  var _a2;
4041
- if (initDone) return;
4042
- initDone = true;
4043
4007
  (_a2 = navigator.serviceWorker.controller) == null ? void 0 : _a2.postMessage({ options: { ...this.options, url: this.url } });
4044
4008
  this.token$.subscribe((token) => {
4045
4009
  var _a3;
4046
4010
  return (_a3 = navigator.serviceWorker.controller) == null ? void 0 : _a3.postMessage({ token });
4047
4011
  });
4048
4012
  };
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
- }
4013
+ await navigator.serviceWorker.getRegistration(this.options.serviceWorker).then((reg) => reg ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
4061
4014
  navigator.serviceWorker.ready.then(() => {
4062
4015
  if (navigator.serviceWorker.controller) navigator.serviceWorker.ready.then(() => init());
4063
4016
  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
- });
4071
4017
  });
4072
4018
  })();
4073
4019
  }
@@ -4125,9 +4071,9 @@ const _Api = class _Api {
4125
4071
  }),
4126
4072
  body: JSON.stringify(_Api.translateTokens(req))
4127
4073
  }).then(async (resp) => {
4128
- const warning = resp.headers.get("X-Warning");
4074
+ const warning = resp.headers["X-Warning"];
4129
4075
  if (warning) console.warn(warning);
4130
- const banner = resp.headers.get("X-User-Notice");
4076
+ const banner = resp.headers["X-User-Notice"];
4131
4077
  if (banner) {
4132
4078
  createBanner(banner);
4133
4079
  setTimeout(() => removeBanner(), 1e4);
package/dist/pwa.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pwa.d.ts","sourceRoot":"","sources":["../src/pwa.ts"],"names":[],"mappings":"AACA,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;IAiBzB,oBAAoB;IACd,KAAK,CAAC,QAAQ,GAAE,GAAQ;IAoJ9B,qCAAqC;IAC/B,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;CAyMzC"}
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"}
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.16",
5
+ "version": "1.3.17-1",
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
7
7
  "private": false,
8
8
  "main": "./dist/index.cjs",