@auxilium/datalynk-client 1.3.17 → 1.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts.map +1 -1
- package/dist/index.cjs +47 -113
- package/dist/index.mjs +47 -113
- package/dist/pwa.d.ts +1 -1
- package/dist/pwa.d.ts.map +1 -1
- package/package.json +1 -1
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,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,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;CAIjE"}
|
package/dist/index.cjs
CHANGED
|
@@ -2343,7 +2343,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2343
2343
|
constructor(api) {
|
|
2344
2344
|
/** Capture Install Event */
|
|
2345
2345
|
__publicField(this, "nativeInstallPrompt", null);
|
|
2346
|
-
/** Resolved icon URL used for prompt + manifest
|
|
2346
|
+
/** Resolved icon URL used for prompt + manifest */
|
|
2347
2347
|
__publicField(this, "resolvedIconUrl", "https://datalynk-client.primary.auxilium.world/logo.png");
|
|
2348
2348
|
this.api = api;
|
|
2349
2349
|
}
|
|
@@ -2382,24 +2382,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2382
2382
|
const installBtn = document.querySelector("#installPwaBtn");
|
|
2383
2383
|
if (!installBtn) return;
|
|
2384
2384
|
installBtn.onclick = async () => {
|
|
2385
|
-
var _a
|
|
2385
|
+
var _a;
|
|
2386
2386
|
if (!this.nativeInstallPrompt) return console.warn("PWA is not supported");
|
|
2387
2387
|
this.nativeInstallPrompt.prompt();
|
|
2388
2388
|
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
2389
|
if (choice.outcome === "accepted") {
|
|
2392
2390
|
console.log("PWA installed");
|
|
2393
|
-
localStorage.setItem(
|
|
2391
|
+
localStorage.setItem(`${this.api.options.name}:pwa`, "installed");
|
|
2394
2392
|
} else {
|
|
2395
|
-
|
|
2393
|
+
localStorage.setItem(`${this.api.options.name}:pwa`, Date.now().toString());
|
|
2396
2394
|
}
|
|
2397
|
-
(
|
|
2395
|
+
(_a = document.querySelector(".pwa-prompt")) == null ? void 0 : _a.remove();
|
|
2398
2396
|
};
|
|
2399
2397
|
}
|
|
2400
2398
|
/** Setup the PWA */
|
|
2401
2399
|
async setup(manifest = {}) {
|
|
2402
|
-
var _a, _b, _c;
|
|
2400
|
+
var _a, _b, _c, _d;
|
|
2403
2401
|
const storageKey = `${this.api.options.name}:pwa`;
|
|
2404
2402
|
window.addEventListener("beforeinstallprompt", (e) => {
|
|
2405
2403
|
e.preventDefault();
|
|
@@ -2424,6 +2422,26 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2424
2422
|
hidePWAPrompt: false,
|
|
2425
2423
|
...this.api.options.pwaSettings
|
|
2426
2424
|
};
|
|
2425
|
+
const defaultIcon = "https://datalynk-client.primary.auxilium.world/logo.png";
|
|
2426
|
+
let iconUrl = ((_b = (_a = this.api.options) == null ? void 0 : _a.pwaSettings) == null ? void 0 : _b.icon) || defaultIcon;
|
|
2427
|
+
const canLoad = (url) => new Promise((res) => {
|
|
2428
|
+
const img = new Image();
|
|
2429
|
+
const t = setTimeout(() => res(false), 2500);
|
|
2430
|
+
img.onload = () => {
|
|
2431
|
+
clearTimeout(t);
|
|
2432
|
+
res(true);
|
|
2433
|
+
};
|
|
2434
|
+
img.onerror = () => {
|
|
2435
|
+
clearTimeout(t);
|
|
2436
|
+
res(false);
|
|
2437
|
+
};
|
|
2438
|
+
img.src = url;
|
|
2439
|
+
});
|
|
2440
|
+
if (iconUrl && iconUrl !== defaultIcon) {
|
|
2441
|
+
const ok = await canLoad(iconUrl);
|
|
2442
|
+
if (!ok) iconUrl = defaultIcon;
|
|
2443
|
+
}
|
|
2444
|
+
this.resolvedIconUrl = iconUrl;
|
|
2427
2445
|
const meta = (key, name, value) => {
|
|
2428
2446
|
const exists = document.querySelector(`meta[${key}="${name}"]`);
|
|
2429
2447
|
if (value === void 0 || exists) return exists;
|
|
@@ -2432,78 +2450,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2432
2450
|
meta2.content = value;
|
|
2433
2451
|
document.head.append(meta2);
|
|
2434
2452
|
};
|
|
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
2453
|
meta("name", "mobile-web-app-capable", "yes");
|
|
2498
2454
|
meta("name", "apple-mobile-web-app-status-bar-style", "default");
|
|
2499
2455
|
meta("name", "apple-mobile-web-app-title", this.api.options.name);
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
let
|
|
2503
|
-
if (!
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
document.head.append(
|
|
2456
|
+
meta("name", "apple-touch-icon", this.resolvedIconUrl);
|
|
2457
|
+
meta("name", "apple-touch-startup-image", this.resolvedIconUrl);
|
|
2458
|
+
let link = document.querySelector('link[rel="manifest"]');
|
|
2459
|
+
if (!link) {
|
|
2460
|
+
link = document.createElement("link");
|
|
2461
|
+
link.rel = "manifest";
|
|
2462
|
+
document.head.append(link);
|
|
2507
2463
|
}
|
|
2508
2464
|
const base = String(this.api.url).replace(/\/+$/, "");
|
|
2509
2465
|
const startUrl = location.pathname;
|
|
@@ -2517,26 +2473,26 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2517
2473
|
...this.api.options.manifest || {},
|
|
2518
2474
|
...manifest || {}
|
|
2519
2475
|
};
|
|
2520
|
-
if (!((
|
|
2476
|
+
if (!((_c = manifestObj.icons) == null ? void 0 : _c.length)) {
|
|
2521
2477
|
manifestObj.icons = [
|
|
2522
|
-
{ src:
|
|
2523
|
-
{ src:
|
|
2524
|
-
{ src:
|
|
2478
|
+
{ src: this.resolvedIconUrl, sizes: "192x192", type: "image/png", purpose: "any" },
|
|
2479
|
+
{ src: this.resolvedIconUrl, sizes: "512x512", type: "image/png", purpose: "any" },
|
|
2480
|
+
{ src: this.resolvedIconUrl, sizes: "512x512", type: "image/png", purpose: "maskable" }
|
|
2525
2481
|
];
|
|
2526
2482
|
}
|
|
2527
|
-
|
|
2528
|
-
if (!((
|
|
2483
|
+
link.href = `${base}/manifest?json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
|
|
2484
|
+
if (!((_d = this.api.options.pwaSettings) == null ? void 0 : _d.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
|
|
2529
2485
|
const t = Number(this.api.options.pwaSettings.timeout ?? 30);
|
|
2530
2486
|
const timeoutMs = t >= 1e3 ? t : t * 1e3;
|
|
2531
2487
|
setTimeout(() => {
|
|
2532
|
-
var _a2, _b2, _c2,
|
|
2488
|
+
var _a2, _b2, _c2, _d2;
|
|
2533
2489
|
const raw = localStorage.getItem(storageKey);
|
|
2534
2490
|
if (raw === "installed") return;
|
|
2535
2491
|
if (((_b2 = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b2.dismissExpiry) === 0) {
|
|
2536
2492
|
if (raw !== "installed") localStorage.removeItem(storageKey);
|
|
2537
2493
|
}
|
|
2538
2494
|
const dismissedAt = raw ? Number(raw) : 0;
|
|
2539
|
-
const expiryDays = Number(((
|
|
2495
|
+
const expiryDays = Number(((_d2 = (_c2 = this.api.options) == null ? void 0 : _c2.pwaSettings) == null ? void 0 : _d2.dismissExpiry) ?? 0);
|
|
2540
2496
|
if (dismissedAt && expiryDays > 0) {
|
|
2541
2497
|
const expiryMs = expiryDays * 24 * 60 * 60 * 1e3;
|
|
2542
2498
|
if (Date.now() < dismissedAt + expiryMs) return;
|
|
@@ -2553,7 +2509,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2553
2509
|
if (this.pwa) return;
|
|
2554
2510
|
if (localStorage.getItem(storageKey) === "installed") return;
|
|
2555
2511
|
if (document.querySelector(".pwa-prompt")) return;
|
|
2556
|
-
const iconUrl = this.resolvedIconUrl || "https://datalynk-client.primary.auxilium.world/logo.png";
|
|
2557
2512
|
const targetPlatform = platform || this.platform;
|
|
2558
2513
|
const isAndroid = targetPlatform == "android";
|
|
2559
2514
|
const isIOS = targetPlatform == "ios";
|
|
@@ -2675,6 +2630,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2675
2630
|
}`;
|
|
2676
2631
|
document.head.append(style);
|
|
2677
2632
|
}
|
|
2633
|
+
const iconUrl = this.resolvedIconUrl || "https://datalynk-client.primary.auxilium.world/logo.png";
|
|
2678
2634
|
const prompt = document.createElement("div");
|
|
2679
2635
|
prompt.classList.add("pwa-prompt");
|
|
2680
2636
|
prompt.innerHTML = `
|
|
@@ -2696,8 +2652,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2696
2652
|
const closeBtn = prompt.querySelector(".pwa-prompt-close");
|
|
2697
2653
|
closeBtn.onclick = () => {
|
|
2698
2654
|
var _a2;
|
|
2699
|
-
|
|
2700
|
-
expiryDays === 0 ? localStorage.removeItem(storageKey) : localStorage.setItem(storageKey, Date.now().toString());
|
|
2655
|
+
!!((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ? localStorage.setItem(storageKey, Date.now().toString()) : localStorage.removeItem(storageKey);
|
|
2701
2656
|
prompt.remove();
|
|
2702
2657
|
};
|
|
2703
2658
|
document.body.append(prompt);
|
|
@@ -3814,7 +3769,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3814
3769
|
} });
|
|
3815
3770
|
}
|
|
3816
3771
|
}
|
|
3817
|
-
const version = "1.3.
|
|
3772
|
+
const version = "1.3.18";
|
|
3818
3773
|
class WebRtc {
|
|
3819
3774
|
constructor(api) {
|
|
3820
3775
|
__publicField(this, "ice");
|
|
@@ -4051,39 +4006,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4051
4006
|
(_b = this.options.offline) == null ? void 0 : _b.forEach((id) => this.slice(id));
|
|
4052
4007
|
if (this.options.serviceWorker && typeof navigator["serviceWorker"] != "undefined") {
|
|
4053
4008
|
(async () => {
|
|
4054
|
-
let initDone = false;
|
|
4055
4009
|
const init = () => {
|
|
4056
4010
|
var _a2;
|
|
4057
|
-
if (initDone) return;
|
|
4058
|
-
initDone = true;
|
|
4059
4011
|
(_a2 = navigator.serviceWorker.controller) == null ? void 0 : _a2.postMessage({ options: { ...this.options, url: this.url } });
|
|
4060
4012
|
this.token$.subscribe((token) => {
|
|
4061
4013
|
var _a3;
|
|
4062
4014
|
return (_a3 = navigator.serviceWorker.controller) == null ? void 0 : _a3.postMessage({ token });
|
|
4063
4015
|
});
|
|
4064
4016
|
};
|
|
4065
|
-
|
|
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
|
-
}
|
|
4017
|
+
await navigator.serviceWorker.getRegistration(this.options.serviceWorker).then((reg) => reg ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
|
|
4077
4018
|
navigator.serviceWorker.ready.then(() => {
|
|
4078
4019
|
if (navigator.serviceWorker.controller) navigator.serviceWorker.ready.then(() => init());
|
|
4079
4020
|
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
4021
|
});
|
|
4088
4022
|
})();
|
|
4089
4023
|
}
|
|
@@ -4141,9 +4075,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4141
4075
|
}),
|
|
4142
4076
|
body: JSON.stringify(_Api.translateTokens(req))
|
|
4143
4077
|
}).then(async (resp) => {
|
|
4144
|
-
const warning = resp.headers
|
|
4078
|
+
const warning = resp.headers["X-Warning"];
|
|
4145
4079
|
if (warning) console.warn(warning);
|
|
4146
|
-
const banner = resp.headers
|
|
4080
|
+
const banner = resp.headers["X-User-Notice"];
|
|
4147
4081
|
if (banner) {
|
|
4148
4082
|
createBanner(banner);
|
|
4149
4083
|
setTimeout(() => removeBanner(), 1e4);
|
package/dist/index.mjs
CHANGED
|
@@ -2339,7 +2339,7 @@ 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
|
|
2342
|
+
/** Resolved icon URL used for prompt + manifest */
|
|
2343
2343
|
__publicField(this, "resolvedIconUrl", "https://datalynk-client.primary.auxilium.world/logo.png");
|
|
2344
2344
|
this.api = api;
|
|
2345
2345
|
}
|
|
@@ -2378,24 +2378,22 @@ class PWA {
|
|
|
2378
2378
|
const installBtn = document.querySelector("#installPwaBtn");
|
|
2379
2379
|
if (!installBtn) return;
|
|
2380
2380
|
installBtn.onclick = async () => {
|
|
2381
|
-
var _a
|
|
2381
|
+
var _a;
|
|
2382
2382
|
if (!this.nativeInstallPrompt) return console.warn("PWA is not supported");
|
|
2383
2383
|
this.nativeInstallPrompt.prompt();
|
|
2384
2384
|
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
2385
|
if (choice.outcome === "accepted") {
|
|
2388
2386
|
console.log("PWA installed");
|
|
2389
|
-
localStorage.setItem(
|
|
2387
|
+
localStorage.setItem(`${this.api.options.name}:pwa`, "installed");
|
|
2390
2388
|
} else {
|
|
2391
|
-
|
|
2389
|
+
localStorage.setItem(`${this.api.options.name}:pwa`, Date.now().toString());
|
|
2392
2390
|
}
|
|
2393
|
-
(
|
|
2391
|
+
(_a = document.querySelector(".pwa-prompt")) == null ? void 0 : _a.remove();
|
|
2394
2392
|
};
|
|
2395
2393
|
}
|
|
2396
2394
|
/** Setup the PWA */
|
|
2397
2395
|
async setup(manifest = {}) {
|
|
2398
|
-
var _a, _b, _c;
|
|
2396
|
+
var _a, _b, _c, _d;
|
|
2399
2397
|
const storageKey = `${this.api.options.name}:pwa`;
|
|
2400
2398
|
window.addEventListener("beforeinstallprompt", (e) => {
|
|
2401
2399
|
e.preventDefault();
|
|
@@ -2420,6 +2418,26 @@ class PWA {
|
|
|
2420
2418
|
hidePWAPrompt: false,
|
|
2421
2419
|
...this.api.options.pwaSettings
|
|
2422
2420
|
};
|
|
2421
|
+
const defaultIcon = "https://datalynk-client.primary.auxilium.world/logo.png";
|
|
2422
|
+
let iconUrl = ((_b = (_a = this.api.options) == null ? void 0 : _a.pwaSettings) == null ? void 0 : _b.icon) || defaultIcon;
|
|
2423
|
+
const canLoad = (url) => new Promise((res) => {
|
|
2424
|
+
const img = new Image();
|
|
2425
|
+
const t = setTimeout(() => res(false), 2500);
|
|
2426
|
+
img.onload = () => {
|
|
2427
|
+
clearTimeout(t);
|
|
2428
|
+
res(true);
|
|
2429
|
+
};
|
|
2430
|
+
img.onerror = () => {
|
|
2431
|
+
clearTimeout(t);
|
|
2432
|
+
res(false);
|
|
2433
|
+
};
|
|
2434
|
+
img.src = url;
|
|
2435
|
+
});
|
|
2436
|
+
if (iconUrl && iconUrl !== defaultIcon) {
|
|
2437
|
+
const ok = await canLoad(iconUrl);
|
|
2438
|
+
if (!ok) iconUrl = defaultIcon;
|
|
2439
|
+
}
|
|
2440
|
+
this.resolvedIconUrl = iconUrl;
|
|
2423
2441
|
const meta = (key, name, value) => {
|
|
2424
2442
|
const exists = document.querySelector(`meta[${key}="${name}"]`);
|
|
2425
2443
|
if (value === void 0 || exists) return exists;
|
|
@@ -2428,78 +2446,16 @@ class PWA {
|
|
|
2428
2446
|
meta2.content = value;
|
|
2429
2447
|
document.head.append(meta2);
|
|
2430
2448
|
};
|
|
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
2449
|
meta("name", "mobile-web-app-capable", "yes");
|
|
2494
2450
|
meta("name", "apple-mobile-web-app-status-bar-style", "default");
|
|
2495
2451
|
meta("name", "apple-mobile-web-app-title", this.api.options.name);
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
let
|
|
2499
|
-
if (!
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
document.head.append(
|
|
2452
|
+
meta("name", "apple-touch-icon", this.resolvedIconUrl);
|
|
2453
|
+
meta("name", "apple-touch-startup-image", this.resolvedIconUrl);
|
|
2454
|
+
let link = document.querySelector('link[rel="manifest"]');
|
|
2455
|
+
if (!link) {
|
|
2456
|
+
link = document.createElement("link");
|
|
2457
|
+
link.rel = "manifest";
|
|
2458
|
+
document.head.append(link);
|
|
2503
2459
|
}
|
|
2504
2460
|
const base = String(this.api.url).replace(/\/+$/, "");
|
|
2505
2461
|
const startUrl = location.pathname;
|
|
@@ -2513,26 +2469,26 @@ class PWA {
|
|
|
2513
2469
|
...this.api.options.manifest || {},
|
|
2514
2470
|
...manifest || {}
|
|
2515
2471
|
};
|
|
2516
|
-
if (!((
|
|
2472
|
+
if (!((_c = manifestObj.icons) == null ? void 0 : _c.length)) {
|
|
2517
2473
|
manifestObj.icons = [
|
|
2518
|
-
{ src:
|
|
2519
|
-
{ src:
|
|
2520
|
-
{ src:
|
|
2474
|
+
{ src: this.resolvedIconUrl, sizes: "192x192", type: "image/png", purpose: "any" },
|
|
2475
|
+
{ src: this.resolvedIconUrl, sizes: "512x512", type: "image/png", purpose: "any" },
|
|
2476
|
+
{ src: this.resolvedIconUrl, sizes: "512x512", type: "image/png", purpose: "maskable" }
|
|
2521
2477
|
];
|
|
2522
2478
|
}
|
|
2523
|
-
|
|
2524
|
-
if (!((
|
|
2479
|
+
link.href = `${base}/manifest?json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
|
|
2480
|
+
if (!((_d = this.api.options.pwaSettings) == null ? void 0 : _d.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
|
|
2525
2481
|
const t = Number(this.api.options.pwaSettings.timeout ?? 30);
|
|
2526
2482
|
const timeoutMs = t >= 1e3 ? t : t * 1e3;
|
|
2527
2483
|
setTimeout(() => {
|
|
2528
|
-
var _a2, _b2, _c2,
|
|
2484
|
+
var _a2, _b2, _c2, _d2;
|
|
2529
2485
|
const raw = localStorage.getItem(storageKey);
|
|
2530
2486
|
if (raw === "installed") return;
|
|
2531
2487
|
if (((_b2 = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b2.dismissExpiry) === 0) {
|
|
2532
2488
|
if (raw !== "installed") localStorage.removeItem(storageKey);
|
|
2533
2489
|
}
|
|
2534
2490
|
const dismissedAt = raw ? Number(raw) : 0;
|
|
2535
|
-
const expiryDays = Number(((
|
|
2491
|
+
const expiryDays = Number(((_d2 = (_c2 = this.api.options) == null ? void 0 : _c2.pwaSettings) == null ? void 0 : _d2.dismissExpiry) ?? 0);
|
|
2536
2492
|
if (dismissedAt && expiryDays > 0) {
|
|
2537
2493
|
const expiryMs = expiryDays * 24 * 60 * 60 * 1e3;
|
|
2538
2494
|
if (Date.now() < dismissedAt + expiryMs) return;
|
|
@@ -2549,7 +2505,6 @@ class PWA {
|
|
|
2549
2505
|
if (this.pwa) return;
|
|
2550
2506
|
if (localStorage.getItem(storageKey) === "installed") return;
|
|
2551
2507
|
if (document.querySelector(".pwa-prompt")) return;
|
|
2552
|
-
const iconUrl = this.resolvedIconUrl || "https://datalynk-client.primary.auxilium.world/logo.png";
|
|
2553
2508
|
const targetPlatform = platform || this.platform;
|
|
2554
2509
|
const isAndroid = targetPlatform == "android";
|
|
2555
2510
|
const isIOS = targetPlatform == "ios";
|
|
@@ -2671,6 +2626,7 @@ class PWA {
|
|
|
2671
2626
|
}`;
|
|
2672
2627
|
document.head.append(style);
|
|
2673
2628
|
}
|
|
2629
|
+
const iconUrl = this.resolvedIconUrl || "https://datalynk-client.primary.auxilium.world/logo.png";
|
|
2674
2630
|
const prompt = document.createElement("div");
|
|
2675
2631
|
prompt.classList.add("pwa-prompt");
|
|
2676
2632
|
prompt.innerHTML = `
|
|
@@ -2692,8 +2648,7 @@ class PWA {
|
|
|
2692
2648
|
const closeBtn = prompt.querySelector(".pwa-prompt-close");
|
|
2693
2649
|
closeBtn.onclick = () => {
|
|
2694
2650
|
var _a2;
|
|
2695
|
-
|
|
2696
|
-
expiryDays === 0 ? localStorage.removeItem(storageKey) : localStorage.setItem(storageKey, Date.now().toString());
|
|
2651
|
+
!!((_a2 = this.api.options.pwaSettings) == null ? void 0 : _a2.dismissExpiry) ? localStorage.setItem(storageKey, Date.now().toString()) : localStorage.removeItem(storageKey);
|
|
2697
2652
|
prompt.remove();
|
|
2698
2653
|
};
|
|
2699
2654
|
document.body.append(prompt);
|
|
@@ -3810,7 +3765,7 @@ class Superuser {
|
|
|
3810
3765
|
} });
|
|
3811
3766
|
}
|
|
3812
3767
|
}
|
|
3813
|
-
const version = "1.3.
|
|
3768
|
+
const version = "1.3.18";
|
|
3814
3769
|
class WebRtc {
|
|
3815
3770
|
constructor(api) {
|
|
3816
3771
|
__publicField(this, "ice");
|
|
@@ -4047,39 +4002,18 @@ const _Api = class _Api {
|
|
|
4047
4002
|
(_b = this.options.offline) == null ? void 0 : _b.forEach((id) => this.slice(id));
|
|
4048
4003
|
if (this.options.serviceWorker && typeof navigator["serviceWorker"] != "undefined") {
|
|
4049
4004
|
(async () => {
|
|
4050
|
-
let initDone = false;
|
|
4051
4005
|
const init = () => {
|
|
4052
4006
|
var _a2;
|
|
4053
|
-
if (initDone) return;
|
|
4054
|
-
initDone = true;
|
|
4055
4007
|
(_a2 = navigator.serviceWorker.controller) == null ? void 0 : _a2.postMessage({ options: { ...this.options, url: this.url } });
|
|
4056
4008
|
this.token$.subscribe((token) => {
|
|
4057
4009
|
var _a3;
|
|
4058
4010
|
return (_a3 = navigator.serviceWorker.controller) == null ? void 0 : _a3.postMessage({ token });
|
|
4059
4011
|
});
|
|
4060
4012
|
};
|
|
4061
|
-
|
|
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
|
-
}
|
|
4013
|
+
await navigator.serviceWorker.getRegistration(this.options.serviceWorker).then((reg) => reg ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
|
|
4073
4014
|
navigator.serviceWorker.ready.then(() => {
|
|
4074
4015
|
if (navigator.serviceWorker.controller) navigator.serviceWorker.ready.then(() => init());
|
|
4075
4016
|
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
4017
|
});
|
|
4084
4018
|
})();
|
|
4085
4019
|
}
|
|
@@ -4137,9 +4071,9 @@ const _Api = class _Api {
|
|
|
4137
4071
|
}),
|
|
4138
4072
|
body: JSON.stringify(_Api.translateTokens(req))
|
|
4139
4073
|
}).then(async (resp) => {
|
|
4140
|
-
const warning = resp.headers
|
|
4074
|
+
const warning = resp.headers["X-Warning"];
|
|
4141
4075
|
if (warning) console.warn(warning);
|
|
4142
|
-
const banner = resp.headers
|
|
4076
|
+
const banner = resp.headers["X-User-Notice"];
|
|
4143
4077
|
if (banner) {
|
|
4144
4078
|
createBanner(banner);
|
|
4145
4079
|
setTimeout(() => removeBanner(), 1e4);
|
package/dist/pwa.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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
|
|
6
|
+
/** Resolved icon URL used for prompt + manifest */
|
|
7
7
|
private resolvedIconUrl;
|
|
8
8
|
get headless(): boolean;
|
|
9
9
|
get iframe(): boolean;
|
package/dist/pwa.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pwa.d.ts","sourceRoot":"","sources":["../src/pwa.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,qBAAa,GAAG;IAsCH,OAAO,CAAC,QAAQ,CAAC,GAAG;IArChC,4BAA4B;IACrB,mBAAmB,EAAE,GAAG,CAAQ;IAEvC,
|
|
1
|
+
{"version":3,"file":"pwa.d.ts","sourceRoot":"","sources":["../src/pwa.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,qBAAa,GAAG;IAsCH,OAAO,CAAC,QAAQ,CAAC,GAAG;IArChC,4BAA4B;IACrB,mBAAmB,EAAE,GAAG,CAAQ;IAEvC,mDAAmD;IACnD,OAAO,CAAC,eAAe,CAAqE;IAE5F,IAAI,QAAQ,IAAI,OAAO,CAAyC;IAEhE,IAAI,MAAM,IAAI,OAAO,CAAyC;IAE9D,IAAI,MAAM,IAAI,OAAO,CAAuD;IAE5E,IAAI,QAAQ,IAAI,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAQ1E;IAED,IAAI,OAAO,IAAI,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CASxF;IAED,IAAI,GAAG,IAAI,OAAO,CAEjB;gBAE4B,GAAG,EAAE,GAAG;IAErC,OAAO,CAAC,iBAAiB;IAiBzB,oBAAoB;IACd,KAAK,CAAC,QAAQ,GAAE,GAAQ;IA8H9B,qCAAqC;IAC/B,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;CAyLzC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@auxilium/datalynk-client",
|
|
3
3
|
"description": "Datalynk client library",
|
|
4
4
|
"repository": "https://gitlab.auxiliumgroup.com/auxilium/datalynk/datalynk-client",
|
|
5
|
-
"version": "1.3.
|
|
5
|
+
"version": "1.3.18",
|
|
6
6
|
"author": "Zak Timson <zaktimson@gmail.com>",
|
|
7
7
|
"private": false,
|
|
8
8
|
"main": "./dist/index.cjs",
|