@auxilium/datalynk-client 1.3.17 → 1.3.19

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,W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
2344
2344
  /** Capture Install Event */
2345
2345
  __publicField(this, "nativeInstallPrompt", null);
2346
- /** Resolved icon URL used for prompt + manifest (validated with fallback) */
2346
+ /** Resolved icon URL used for prompt + manifest */
2347
2347
  __publicField(this, "resolvedIconUrl", "https://datalynk-client.primary.auxilium.world/logo.png");
2348
+ /** Resolved manifest icons (prefer true 192/512 PNG data URLs) */
2349
+ __publicField(this, "resolvedManifestIcons", []);
2350
+ __publicField(this, "createSizedPng", async (url, size) => {
2351
+ if (this.headless || !url) return null;
2352
+ try {
2353
+ const img = await new Promise((res, rej) => {
2354
+ const el = new Image();
2355
+ const t = setTimeout(() => rej(new Error("icon-timeout")), 3500);
2356
+ el.crossOrigin = "anonymous";
2357
+ el.onload = () => {
2358
+ clearTimeout(t);
2359
+ res(el);
2360
+ };
2361
+ el.onerror = () => {
2362
+ clearTimeout(t);
2363
+ rej(new Error("icon-load-failed"));
2364
+ };
2365
+ el.src = url;
2366
+ });
2367
+ const canvas = document.createElement("canvas");
2368
+ canvas.width = size;
2369
+ canvas.height = size;
2370
+ const ctx = canvas.getContext("2d");
2371
+ if (!ctx) return null;
2372
+ ctx.clearRect(0, 0, size, size);
2373
+ ctx.drawImage(img, 0, 0, size, size);
2374
+ return canvas.toDataURL("image/png");
2375
+ } catch {
2376
+ return null;
2377
+ }
2378
+ });
2348
2379
  this.api = api;
2349
2380
  }
2350
2381
  get headless() {
@@ -2382,24 +2413,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2382
2413
  const installBtn = document.querySelector("#installPwaBtn");
2383
2414
  if (!installBtn) return;
2384
2415
  installBtn.onclick = async () => {
2385
- var _a, _b;
2416
+ var _a;
2386
2417
  if (!this.nativeInstallPrompt) return console.warn("PWA is not supported");
2387
2418
  this.nativeInstallPrompt.prompt();
2388
2419
  const choice = await this.nativeInstallPrompt.userChoice;
2389
- const storageKey = `${this.api.options.name}:pwa`;
2390
- const expiryDays = Number(((_a = this.api.options.pwaSettings) == null ? void 0 : _a.dismissExpiry) ?? 7);
2391
2420
  if (choice.outcome === "accepted") {
2392
2421
  console.log("PWA installed");
2393
- localStorage.setItem(storageKey, "installed");
2422
+ localStorage.setItem(`${this.api.options.name}:pwa`, "installed");
2394
2423
  } else {
2395
- expiryDays === 0 ? localStorage.removeItem(storageKey) : localStorage.setItem(storageKey, Date.now().toString());
2424
+ localStorage.setItem(`${this.api.options.name}:pwa`, Date.now().toString());
2396
2425
  }
2397
- (_b = document.querySelector(".pwa-prompt")) == null ? void 0 : _b.remove();
2426
+ (_a = document.querySelector(".pwa-prompt")) == null ? void 0 : _a.remove();
2398
2427
  };
2399
2428
  }
2400
2429
  /** Setup the PWA */
2401
2430
  async setup(manifest = {}) {
2402
- var _a, _b, _c;
2431
+ var _a, _b, _c, _d;
2403
2432
  const storageKey = `${this.api.options.name}:pwa`;
2404
2433
  window.addEventListener("beforeinstallprompt", (e) => {
2405
2434
  e.preventDefault();
@@ -2424,6 +2453,42 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2424
2453
  hidePWAPrompt: false,
2425
2454
  ...this.api.options.pwaSettings
2426
2455
  };
2456
+ const defaultIcon = "https://datalynk-client.primary.auxilium.world/logo.png";
2457
+ let iconUrl = ((_b = (_a = this.api.options) == null ? void 0 : _a.pwaSettings) == null ? void 0 : _b.icon) || defaultIcon;
2458
+ const canLoad = (url) => new Promise((res) => {
2459
+ const img = new Image();
2460
+ const t = setTimeout(() => res(false), 2500);
2461
+ img.onload = () => {
2462
+ clearTimeout(t);
2463
+ res(true);
2464
+ };
2465
+ img.onerror = () => {
2466
+ clearTimeout(t);
2467
+ res(false);
2468
+ };
2469
+ img.src = url;
2470
+ });
2471
+ if (iconUrl && iconUrl !== defaultIcon) {
2472
+ const ok = await canLoad(iconUrl);
2473
+ if (!ok) iconUrl = defaultIcon;
2474
+ }
2475
+ this.resolvedIconUrl = iconUrl;
2476
+ let icon192 = await this.createSizedPng(this.resolvedIconUrl, 192);
2477
+ let icon512 = await this.createSizedPng(this.resolvedIconUrl, 512);
2478
+ if ((!icon192 || !icon512) && this.resolvedIconUrl !== defaultIcon) {
2479
+ this.resolvedIconUrl = defaultIcon;
2480
+ icon192 = await this.createSizedPng(this.resolvedIconUrl, 192);
2481
+ icon512 = await this.createSizedPng(this.resolvedIconUrl, 512);
2482
+ }
2483
+ this.resolvedManifestIcons = icon192 && icon512 ? [
2484
+ { src: icon192, sizes: "192x192", type: "image/png", purpose: "any" },
2485
+ { src: icon512, sizes: "512x512", type: "image/png", purpose: "any" },
2486
+ { src: icon512, sizes: "512x512", type: "image/png", purpose: "maskable" }
2487
+ ] : [
2488
+ { src: this.resolvedIconUrl, sizes: "192x192", type: "image/png", purpose: "any" },
2489
+ { src: this.resolvedIconUrl, sizes: "512x512", type: "image/png", purpose: "any" },
2490
+ { src: this.resolvedIconUrl, sizes: "512x512", type: "image/png", purpose: "maskable" }
2491
+ ];
2427
2492
  const meta = (key, name, value) => {
2428
2493
  const exists = document.querySelector(`meta[${key}="${name}"]`);
2429
2494
  if (value === void 0 || exists) return exists;
@@ -2432,78 +2497,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2432
2497
  meta2.content = value;
2433
2498
  document.head.append(meta2);
2434
2499
  };
2435
- const link = (rel, href) => {
2436
- const exists = document.querySelector(`link[rel="${rel}"]`);
2437
- if (href === void 0) return exists;
2438
- if (exists) {
2439
- exists.href = href;
2440
- return exists;
2441
- }
2442
- const el = document.createElement("link");
2443
- el.rel = rel;
2444
- el.href = href;
2445
- document.head.append(el);
2446
- return el;
2447
- };
2448
- const resolveUrl = (href) => {
2449
- if (!href) return "";
2450
- try {
2451
- return new URL(href, location.href).href;
2452
- } catch (e) {
2453
- return href;
2454
- }
2455
- };
2456
- const pickFavicon = () => {
2457
- const touch = document.querySelector('link[rel="apple-touch-icon"]');
2458
- if (touch == null ? void 0 : touch.href) return resolveUrl(touch.href);
2459
- const iconWithSizes = Array.from(document.querySelectorAll('link[rel~="icon"][sizes]'));
2460
- if (iconWithSizes.length) {
2461
- const best = iconWithSizes.sort((a, b) => {
2462
- var _a2, _b2;
2463
- 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);
2464
- })[0];
2465
- if (best == null ? void 0 : best.href) return resolveUrl(best.href);
2466
- }
2467
- const anyIcon = document.querySelector('link[rel~="icon"]');
2468
- return (anyIcon == null ? void 0 : anyIcon.href) ? resolveUrl(anyIcon.href) : "";
2469
- };
2470
- const firstWorkingIcon = async (...candidates) => {
2471
- for (const c of candidates) {
2472
- const url = resolveUrl(c);
2473
- if (!url) continue;
2474
- const ok = await new Promise((res) => {
2475
- const img = new Image();
2476
- const t = setTimeout(() => res(false), 2500);
2477
- img.onload = () => {
2478
- clearTimeout(t);
2479
- res(true);
2480
- };
2481
- img.onerror = () => {
2482
- clearTimeout(t);
2483
- res(false);
2484
- };
2485
- img.src = url;
2486
- });
2487
- if (ok) return url;
2488
- }
2489
- return "https://datalynk-client.primary.auxilium.world/logo.png";
2490
- };
2491
- const iconUrl = await firstWorkingIcon(
2492
- ((_a = this.api.options.pwaSettings) == null ? void 0 : _a.icon) || "",
2493
- pickFavicon() || "",
2494
- "https://datalynk-client.primary.auxilium.world/logo.png"
2495
- );
2496
- this.resolvedIconUrl = iconUrl;
2497
2500
  meta("name", "mobile-web-app-capable", "yes");
2498
2501
  meta("name", "apple-mobile-web-app-status-bar-style", "default");
2499
2502
  meta("name", "apple-mobile-web-app-title", this.api.options.name);
2500
- link("apple-touch-icon", iconUrl);
2501
- link("apple-touch-startup-image", iconUrl);
2502
- let manifestLink = document.querySelector('link[rel="manifest"]');
2503
- if (!manifestLink) {
2504
- manifestLink = document.createElement("link");
2505
- manifestLink.rel = "manifest";
2506
- document.head.append(manifestLink);
2503
+ meta("name", "apple-touch-icon", this.resolvedIconUrl);
2504
+ meta("name", "apple-touch-startup-image", this.resolvedIconUrl);
2505
+ let link = document.querySelector('link[rel="manifest"]');
2506
+ if (!link) {
2507
+ link = document.createElement("link");
2508
+ link.rel = "manifest";
2509
+ document.head.append(link);
2507
2510
  }
2508
2511
  const base = String(this.api.url).replace(/\/+$/, "");
2509
2512
  const startUrl = location.pathname;
@@ -2517,26 +2520,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2517
2520
  ...this.api.options.manifest || {},
2518
2521
  ...manifest || {}
2519
2522
  };
2520
- if (!((_b = manifestObj.icons) == null ? void 0 : _b.length)) {
2521
- manifestObj.icons = [
2522
- { src: iconUrl, sizes: "192x192", type: "image/png", purpose: "any" },
2523
- { src: iconUrl, sizes: "512x512", type: "image/png", purpose: "any" },
2524
- { src: iconUrl, sizes: "512x512", type: "image/png", purpose: "maskable" }
2525
- ];
2523
+ if (!((_c = manifestObj.icons) == null ? void 0 : _c.length)) {
2524
+ manifestObj.icons = this.resolvedManifestIcons;
2526
2525
  }
2527
- manifestLink.href = `${base}/manifest?ts=${Date.now()}&json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2528
- if (!((_c = this.api.options.pwaSettings) == null ? void 0 : _c.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
2526
+ link.href = `${base}/manifest?json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2527
+ if (!((_d = this.api.options.pwaSettings) == null ? void 0 : _d.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
2529
2528
  const t = Number(this.api.options.pwaSettings.timeout ?? 30);
2530
2529
  const timeoutMs = t >= 1e3 ? t : t * 1e3;
2531
2530
  setTimeout(() => {
2532
- var _a2, _b2, _c2, _d;
2531
+ var _a2, _b2, _c2, _d2;
2533
2532
  const raw = localStorage.getItem(storageKey);
2534
2533
  if (raw === "installed") return;
2535
2534
  if (((_b2 = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b2.dismissExpiry) === 0) {
2536
2535
  if (raw !== "installed") localStorage.removeItem(storageKey);
2537
2536
  }
2538
2537
  const dismissedAt = raw ? Number(raw) : 0;
2539
- const expiryDays = Number(((_d = (_c2 = this.api.options) == null ? void 0 : _c2.pwaSettings) == null ? void 0 : _d.dismissExpiry) ?? 0);
2538
+ const expiryDays = Number(((_d2 = (_c2 = this.api.options) == null ? void 0 : _c2.pwaSettings) == null ? void 0 : _d2.dismissExpiry) ?? 0);
2540
2539
  if (dismissedAt && expiryDays > 0) {
2541
2540
  const expiryMs = expiryDays * 24 * 60 * 60 * 1e3;
2542
2541
  if (Date.now() < dismissedAt + expiryMs) return;
@@ -2553,7 +2552,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2553
2552
  if (this.pwa) return;
2554
2553
  if (localStorage.getItem(storageKey) === "installed") return;
2555
2554
  if (document.querySelector(".pwa-prompt")) return;
2556
- const iconUrl = this.resolvedIconUrl || "https://datalynk-client.primary.auxilium.world/logo.png";
2557
2555
  const targetPlatform = platform || this.platform;
2558
2556
  const isAndroid = targetPlatform == "android";
2559
2557
  const isIOS = targetPlatform == "ios";
@@ -2675,6 +2673,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2675
2673
  }`;
2676
2674
  document.head.append(style);
2677
2675
  }
2676
+ const iconUrl = this.resolvedIconUrl || "https://datalynk-client.primary.auxilium.world/logo.png";
2678
2677
  const prompt = document.createElement("div");
2679
2678
  prompt.classList.add("pwa-prompt");
2680
2679
  prompt.innerHTML = `
@@ -2696,8 +2695,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2696
2695
  const closeBtn = prompt.querySelector(".pwa-prompt-close");
2697
2696
  closeBtn.onclick = () => {
2698
2697
  var _a2;
2699
- const expiryDays = Number(((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ?? 7);
2700
- expiryDays === 0 ? localStorage.removeItem(storageKey) : localStorage.setItem(storageKey, Date.now().toString());
2698
+ !!((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ? localStorage.setItem(storageKey, Date.now().toString()) : localStorage.removeItem(storageKey);
2701
2699
  prompt.remove();
2702
2700
  };
2703
2701
  document.body.append(prompt);
@@ -3814,7 +3812,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3814
3812
  } });
3815
3813
  }
3816
3814
  }
3817
- const version = "1.3.17";
3815
+ const version = "1.3.19";
3818
3816
  class WebRtc {
3819
3817
  constructor(api) {
3820
3818
  __publicField(this, "ice");
@@ -4051,39 +4049,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4051
4049
  (_b = this.options.offline) == null ? void 0 : _b.forEach((id) => this.slice(id));
4052
4050
  if (this.options.serviceWorker && typeof navigator["serviceWorker"] != "undefined") {
4053
4051
  (async () => {
4054
- let initDone = false;
4055
4052
  const init = () => {
4056
4053
  var _a2;
4057
- if (initDone) return;
4058
- initDone = true;
4059
4054
  (_a2 = navigator.serviceWorker.controller) == null ? void 0 : _a2.postMessage({ options: { ...this.options, url: this.url } });
4060
4055
  this.token$.subscribe((token) => {
4061
4056
  var _a3;
4062
4057
  return (_a3 = navigator.serviceWorker.controller) == null ? void 0 : _a3.postMessage({ token });
4063
4058
  });
4064
4059
  };
4065
- const scope = "/";
4066
- const reg = await navigator.serviceWorker.getRegistration(scope).then((reg2) => reg2 ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
4067
- try {
4068
- await reg.update();
4069
- } catch (e) {
4070
- }
4071
- if (typeof document !== "undefined") {
4072
- document.addEventListener("visibilitychange", () => {
4073
- if (document.visibilityState === "visible") reg.update().catch(() => {
4074
- });
4075
- });
4076
- }
4060
+ await navigator.serviceWorker.getRegistration(this.options.serviceWorker).then((reg) => reg ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
4077
4061
  navigator.serviceWorker.ready.then(() => {
4078
4062
  if (navigator.serviceWorker.controller) navigator.serviceWorker.ready.then(() => init());
4079
4063
  else navigator.serviceWorker.addEventListener("controllerchange", () => init(), { once: true });
4080
- let refreshed = false;
4081
- navigator.serviceWorker.addEventListener("controllerchange", () => {
4082
- if (refreshed) return;
4083
- refreshed = true;
4084
- const standalone = matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone);
4085
- if (standalone) location.reload();
4086
- });
4087
4064
  });
4088
4065
  })();
4089
4066
  }
@@ -4141,9 +4118,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4141
4118
  }),
4142
4119
  body: JSON.stringify(_Api.translateTokens(req))
4143
4120
  }).then(async (resp) => {
4144
- const warning = resp.headers.get("X-Warning");
4121
+ const warning = resp.headers["X-Warning"];
4145
4122
  if (warning) console.warn(warning);
4146
- const banner = resp.headers.get("X-User-Notice");
4123
+ const banner = resp.headers["X-User-Notice"];
4147
4124
  if (banner) {
4148
4125
  createBanner(banner);
4149
4126
  setTimeout(() => removeBanner(), 1e4);
package/dist/index.mjs CHANGED
@@ -2339,8 +2339,39 @@ 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 (validated with fallback) */
2342
+ /** Resolved icon URL used for prompt + manifest */
2343
2343
  __publicField(this, "resolvedIconUrl", "https://datalynk-client.primary.auxilium.world/logo.png");
2344
+ /** Resolved manifest icons (prefer true 192/512 PNG data URLs) */
2345
+ __publicField(this, "resolvedManifestIcons", []);
2346
+ __publicField(this, "createSizedPng", async (url, size) => {
2347
+ if (this.headless || !url) return null;
2348
+ try {
2349
+ const img = await new Promise((res, rej) => {
2350
+ const el = new Image();
2351
+ const t = setTimeout(() => rej(new Error("icon-timeout")), 3500);
2352
+ el.crossOrigin = "anonymous";
2353
+ el.onload = () => {
2354
+ clearTimeout(t);
2355
+ res(el);
2356
+ };
2357
+ el.onerror = () => {
2358
+ clearTimeout(t);
2359
+ rej(new Error("icon-load-failed"));
2360
+ };
2361
+ el.src = url;
2362
+ });
2363
+ const canvas = document.createElement("canvas");
2364
+ canvas.width = size;
2365
+ canvas.height = size;
2366
+ const ctx = canvas.getContext("2d");
2367
+ if (!ctx) return null;
2368
+ ctx.clearRect(0, 0, size, size);
2369
+ ctx.drawImage(img, 0, 0, size, size);
2370
+ return canvas.toDataURL("image/png");
2371
+ } catch {
2372
+ return null;
2373
+ }
2374
+ });
2344
2375
  this.api = api;
2345
2376
  }
2346
2377
  get headless() {
@@ -2378,24 +2409,22 @@ class PWA {
2378
2409
  const installBtn = document.querySelector("#installPwaBtn");
2379
2410
  if (!installBtn) return;
2380
2411
  installBtn.onclick = async () => {
2381
- var _a, _b;
2412
+ var _a;
2382
2413
  if (!this.nativeInstallPrompt) return console.warn("PWA is not supported");
2383
2414
  this.nativeInstallPrompt.prompt();
2384
2415
  const choice = await this.nativeInstallPrompt.userChoice;
2385
- const storageKey = `${this.api.options.name}:pwa`;
2386
- const expiryDays = Number(((_a = this.api.options.pwaSettings) == null ? void 0 : _a.dismissExpiry) ?? 7);
2387
2416
  if (choice.outcome === "accepted") {
2388
2417
  console.log("PWA installed");
2389
- localStorage.setItem(storageKey, "installed");
2418
+ localStorage.setItem(`${this.api.options.name}:pwa`, "installed");
2390
2419
  } else {
2391
- expiryDays === 0 ? localStorage.removeItem(storageKey) : localStorage.setItem(storageKey, Date.now().toString());
2420
+ localStorage.setItem(`${this.api.options.name}:pwa`, Date.now().toString());
2392
2421
  }
2393
- (_b = document.querySelector(".pwa-prompt")) == null ? void 0 : _b.remove();
2422
+ (_a = document.querySelector(".pwa-prompt")) == null ? void 0 : _a.remove();
2394
2423
  };
2395
2424
  }
2396
2425
  /** Setup the PWA */
2397
2426
  async setup(manifest = {}) {
2398
- var _a, _b, _c;
2427
+ var _a, _b, _c, _d;
2399
2428
  const storageKey = `${this.api.options.name}:pwa`;
2400
2429
  window.addEventListener("beforeinstallprompt", (e) => {
2401
2430
  e.preventDefault();
@@ -2420,6 +2449,42 @@ class PWA {
2420
2449
  hidePWAPrompt: false,
2421
2450
  ...this.api.options.pwaSettings
2422
2451
  };
2452
+ const defaultIcon = "https://datalynk-client.primary.auxilium.world/logo.png";
2453
+ let iconUrl = ((_b = (_a = this.api.options) == null ? void 0 : _a.pwaSettings) == null ? void 0 : _b.icon) || defaultIcon;
2454
+ const canLoad = (url) => new Promise((res) => {
2455
+ const img = new Image();
2456
+ const t = setTimeout(() => res(false), 2500);
2457
+ img.onload = () => {
2458
+ clearTimeout(t);
2459
+ res(true);
2460
+ };
2461
+ img.onerror = () => {
2462
+ clearTimeout(t);
2463
+ res(false);
2464
+ };
2465
+ img.src = url;
2466
+ });
2467
+ if (iconUrl && iconUrl !== defaultIcon) {
2468
+ const ok = await canLoad(iconUrl);
2469
+ if (!ok) iconUrl = defaultIcon;
2470
+ }
2471
+ this.resolvedIconUrl = iconUrl;
2472
+ let icon192 = await this.createSizedPng(this.resolvedIconUrl, 192);
2473
+ let icon512 = await this.createSizedPng(this.resolvedIconUrl, 512);
2474
+ if ((!icon192 || !icon512) && this.resolvedIconUrl !== defaultIcon) {
2475
+ this.resolvedIconUrl = defaultIcon;
2476
+ icon192 = await this.createSizedPng(this.resolvedIconUrl, 192);
2477
+ icon512 = await this.createSizedPng(this.resolvedIconUrl, 512);
2478
+ }
2479
+ this.resolvedManifestIcons = icon192 && icon512 ? [
2480
+ { src: icon192, sizes: "192x192", type: "image/png", purpose: "any" },
2481
+ { src: icon512, sizes: "512x512", type: "image/png", purpose: "any" },
2482
+ { src: icon512, sizes: "512x512", type: "image/png", purpose: "maskable" }
2483
+ ] : [
2484
+ { src: this.resolvedIconUrl, sizes: "192x192", type: "image/png", purpose: "any" },
2485
+ { src: this.resolvedIconUrl, sizes: "512x512", type: "image/png", purpose: "any" },
2486
+ { src: this.resolvedIconUrl, sizes: "512x512", type: "image/png", purpose: "maskable" }
2487
+ ];
2423
2488
  const meta = (key, name, value) => {
2424
2489
  const exists = document.querySelector(`meta[${key}="${name}"]`);
2425
2490
  if (value === void 0 || exists) return exists;
@@ -2428,78 +2493,16 @@ class PWA {
2428
2493
  meta2.content = value;
2429
2494
  document.head.append(meta2);
2430
2495
  };
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 el = document.createElement("link");
2439
- el.rel = rel;
2440
- el.href = href;
2441
- document.head.append(el);
2442
- return el;
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 firstWorkingIcon = async (...candidates) => {
2467
- for (const c of candidates) {
2468
- const url = resolveUrl(c);
2469
- if (!url) continue;
2470
- const ok = await new Promise((res) => {
2471
- const img = new Image();
2472
- const t = setTimeout(() => res(false), 2500);
2473
- img.onload = () => {
2474
- clearTimeout(t);
2475
- res(true);
2476
- };
2477
- img.onerror = () => {
2478
- clearTimeout(t);
2479
- res(false);
2480
- };
2481
- img.src = url;
2482
- });
2483
- if (ok) return url;
2484
- }
2485
- return "https://datalynk-client.primary.auxilium.world/logo.png";
2486
- };
2487
- const iconUrl = await firstWorkingIcon(
2488
- ((_a = this.api.options.pwaSettings) == null ? void 0 : _a.icon) || "",
2489
- pickFavicon() || "",
2490
- "https://datalynk-client.primary.auxilium.world/logo.png"
2491
- );
2492
- this.resolvedIconUrl = iconUrl;
2493
2496
  meta("name", "mobile-web-app-capable", "yes");
2494
2497
  meta("name", "apple-mobile-web-app-status-bar-style", "default");
2495
2498
  meta("name", "apple-mobile-web-app-title", this.api.options.name);
2496
- link("apple-touch-icon", iconUrl);
2497
- link("apple-touch-startup-image", iconUrl);
2498
- let manifestLink = document.querySelector('link[rel="manifest"]');
2499
- if (!manifestLink) {
2500
- manifestLink = document.createElement("link");
2501
- manifestLink.rel = "manifest";
2502
- document.head.append(manifestLink);
2499
+ meta("name", "apple-touch-icon", this.resolvedIconUrl);
2500
+ meta("name", "apple-touch-startup-image", this.resolvedIconUrl);
2501
+ let link = document.querySelector('link[rel="manifest"]');
2502
+ if (!link) {
2503
+ link = document.createElement("link");
2504
+ link.rel = "manifest";
2505
+ document.head.append(link);
2503
2506
  }
2504
2507
  const base = String(this.api.url).replace(/\/+$/, "");
2505
2508
  const startUrl = location.pathname;
@@ -2513,26 +2516,22 @@ class PWA {
2513
2516
  ...this.api.options.manifest || {},
2514
2517
  ...manifest || {}
2515
2518
  };
2516
- if (!((_b = manifestObj.icons) == null ? void 0 : _b.length)) {
2517
- manifestObj.icons = [
2518
- { src: iconUrl, sizes: "192x192", type: "image/png", purpose: "any" },
2519
- { src: iconUrl, sizes: "512x512", type: "image/png", purpose: "any" },
2520
- { src: iconUrl, sizes: "512x512", type: "image/png", purpose: "maskable" }
2521
- ];
2519
+ if (!((_c = manifestObj.icons) == null ? void 0 : _c.length)) {
2520
+ manifestObj.icons = this.resolvedManifestIcons;
2522
2521
  }
2523
- manifestLink.href = `${base}/manifest?ts=${Date.now()}&json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2524
- if (!((_c = this.api.options.pwaSettings) == null ? void 0 : _c.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
2522
+ link.href = `${base}/manifest?json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2523
+ if (!((_d = this.api.options.pwaSettings) == null ? void 0 : _d.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
2525
2524
  const t = Number(this.api.options.pwaSettings.timeout ?? 30);
2526
2525
  const timeoutMs = t >= 1e3 ? t : t * 1e3;
2527
2526
  setTimeout(() => {
2528
- var _a2, _b2, _c2, _d;
2527
+ var _a2, _b2, _c2, _d2;
2529
2528
  const raw = localStorage.getItem(storageKey);
2530
2529
  if (raw === "installed") return;
2531
2530
  if (((_b2 = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b2.dismissExpiry) === 0) {
2532
2531
  if (raw !== "installed") localStorage.removeItem(storageKey);
2533
2532
  }
2534
2533
  const dismissedAt = raw ? Number(raw) : 0;
2535
- const expiryDays = Number(((_d = (_c2 = this.api.options) == null ? void 0 : _c2.pwaSettings) == null ? void 0 : _d.dismissExpiry) ?? 0);
2534
+ const expiryDays = Number(((_d2 = (_c2 = this.api.options) == null ? void 0 : _c2.pwaSettings) == null ? void 0 : _d2.dismissExpiry) ?? 0);
2536
2535
  if (dismissedAt && expiryDays > 0) {
2537
2536
  const expiryMs = expiryDays * 24 * 60 * 60 * 1e3;
2538
2537
  if (Date.now() < dismissedAt + expiryMs) return;
@@ -2549,7 +2548,6 @@ class PWA {
2549
2548
  if (this.pwa) return;
2550
2549
  if (localStorage.getItem(storageKey) === "installed") return;
2551
2550
  if (document.querySelector(".pwa-prompt")) return;
2552
- const iconUrl = this.resolvedIconUrl || "https://datalynk-client.primary.auxilium.world/logo.png";
2553
2551
  const targetPlatform = platform || this.platform;
2554
2552
  const isAndroid = targetPlatform == "android";
2555
2553
  const isIOS = targetPlatform == "ios";
@@ -2671,6 +2669,7 @@ class PWA {
2671
2669
  }`;
2672
2670
  document.head.append(style);
2673
2671
  }
2672
+ const iconUrl = this.resolvedIconUrl || "https://datalynk-client.primary.auxilium.world/logo.png";
2674
2673
  const prompt = document.createElement("div");
2675
2674
  prompt.classList.add("pwa-prompt");
2676
2675
  prompt.innerHTML = `
@@ -2692,8 +2691,7 @@ class PWA {
2692
2691
  const closeBtn = prompt.querySelector(".pwa-prompt-close");
2693
2692
  closeBtn.onclick = () => {
2694
2693
  var _a2;
2695
- const expiryDays = Number(((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ?? 7);
2696
- expiryDays === 0 ? localStorage.removeItem(storageKey) : localStorage.setItem(storageKey, Date.now().toString());
2694
+ !!((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ? localStorage.setItem(storageKey, Date.now().toString()) : localStorage.removeItem(storageKey);
2697
2695
  prompt.remove();
2698
2696
  };
2699
2697
  document.body.append(prompt);
@@ -3810,7 +3808,7 @@ class Superuser {
3810
3808
  } });
3811
3809
  }
3812
3810
  }
3813
- const version = "1.3.17";
3811
+ const version = "1.3.19";
3814
3812
  class WebRtc {
3815
3813
  constructor(api) {
3816
3814
  __publicField(this, "ice");
@@ -4047,39 +4045,18 @@ const _Api = class _Api {
4047
4045
  (_b = this.options.offline) == null ? void 0 : _b.forEach((id) => this.slice(id));
4048
4046
  if (this.options.serviceWorker && typeof navigator["serviceWorker"] != "undefined") {
4049
4047
  (async () => {
4050
- let initDone = false;
4051
4048
  const init = () => {
4052
4049
  var _a2;
4053
- if (initDone) return;
4054
- initDone = true;
4055
4050
  (_a2 = navigator.serviceWorker.controller) == null ? void 0 : _a2.postMessage({ options: { ...this.options, url: this.url } });
4056
4051
  this.token$.subscribe((token) => {
4057
4052
  var _a3;
4058
4053
  return (_a3 = navigator.serviceWorker.controller) == null ? void 0 : _a3.postMessage({ token });
4059
4054
  });
4060
4055
  };
4061
- const scope = "/";
4062
- const reg = await navigator.serviceWorker.getRegistration(scope).then((reg2) => reg2 ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
4063
- try {
4064
- await reg.update();
4065
- } catch (e) {
4066
- }
4067
- if (typeof document !== "undefined") {
4068
- document.addEventListener("visibilitychange", () => {
4069
- if (document.visibilityState === "visible") reg.update().catch(() => {
4070
- });
4071
- });
4072
- }
4056
+ await navigator.serviceWorker.getRegistration(this.options.serviceWorker).then((reg) => reg ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
4073
4057
  navigator.serviceWorker.ready.then(() => {
4074
4058
  if (navigator.serviceWorker.controller) navigator.serviceWorker.ready.then(() => init());
4075
4059
  else navigator.serviceWorker.addEventListener("controllerchange", () => init(), { once: true });
4076
- let refreshed = false;
4077
- navigator.serviceWorker.addEventListener("controllerchange", () => {
4078
- if (refreshed) return;
4079
- refreshed = true;
4080
- const standalone = matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone);
4081
- if (standalone) location.reload();
4082
- });
4083
4060
  });
4084
4061
  })();
4085
4062
  }
@@ -4137,9 +4114,9 @@ const _Api = class _Api {
4137
4114
  }),
4138
4115
  body: JSON.stringify(_Api.translateTokens(req))
4139
4116
  }).then(async (resp) => {
4140
- const warning = resp.headers.get("X-Warning");
4117
+ const warning = resp.headers["X-Warning"];
4141
4118
  if (warning) console.warn(warning);
4142
- const banner = resp.headers.get("X-User-Notice");
4119
+ const banner = resp.headers["X-User-Notice"];
4143
4120
  if (banner) {
4144
4121
  createBanner(banner);
4145
4122
  setTimeout(() => removeBanner(), 1e4);
package/dist/pwa.d.ts CHANGED
@@ -3,8 +3,10 @@ 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 (validated with fallback) */
6
+ /** Resolved icon URL used for prompt + manifest */
7
7
  private resolvedIconUrl;
8
+ /** Resolved manifest icons (prefer true 192/512 PNG data URLs) */
9
+ private resolvedManifestIcons;
8
10
  get headless(): boolean;
9
11
  get iframe(): boolean;
10
12
  get mobile(): boolean;
@@ -13,6 +15,7 @@ export declare class PWA {
13
15
  get pwa(): boolean;
14
16
  constructor(api: Api);
15
17
  private bindInstallButton;
18
+ private createSizedPng;
16
19
  /** Setup the PWA */
17
20
  setup(manifest?: any): Promise<void>;
18
21
  /** Prompt user to install the app */
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;IAsCH,OAAO,CAAC,QAAQ,CAAC,GAAG;IArChC,4BAA4B;IACrB,mBAAmB,EAAE,GAAG,CAAQ;IAEvC,6EAA6E;IAC7E,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;IAsBzB,oBAAoB;IACd,KAAK,CAAC,QAAQ,GAAE,GAAQ;IA0K9B,qCAAqC;IAC/B,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;CA0LzC"}
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;IAyCH,OAAO,CAAC,QAAQ,CAAC,GAAG;IAxChC,4BAA4B;IACrB,mBAAmB,EAAE,GAAG,CAAQ;IAEvC,mDAAmD;IACnD,OAAO,CAAC,eAAe,CAAqE;IAE5F,kEAAkE;IAClE,OAAO,CAAC,qBAAqB,CAAa;IAE1C,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,OAAO,CAAC,cAAc,CA0BrB;IAED,oBAAoB;IACd,KAAK,CAAC,QAAQ,GAAE,GAAQ;IAiJ9B,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",
5
+ "version": "1.3.19",
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
7
7
  "private": false,
8
8
  "main": "./dist/index.cjs",