@auxilium/datalynk-client 1.3.15 → 1.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +2 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/index.cjs +104 -17
- package/dist/index.mjs +104 -17
- package/dist/pwa.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -66,6 +66,8 @@ export type ApiOptions = {
|
|
|
66
66
|
loginLink?: boolean;
|
|
67
67
|
/** Hide/disable the in-app PWA install popup entirely */
|
|
68
68
|
hidePWAPrompt?: boolean;
|
|
69
|
+
/** Optional: override the installed-app icon (should be a PNG, ideally 512x512) */
|
|
70
|
+
icon?: string;
|
|
69
71
|
};
|
|
70
72
|
};
|
|
71
73
|
/**
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,QAAQ,EAAQ,MAAM,gBAAgB,CAAC;AAClG,OAAO,EAAC,eAAe,EAAuB,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,SAAS,CAAC;AACvC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC,MAAM,MAAM,UAAU,GAAG;IACxB,GAA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AO,CAAC,CAAC,CAAC;IAClE,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE;QAAC,OAAO,EAAE,IAAI,CAAA;KAAC,GAAG,iBAAiB,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAWjG;;;;;;;;;;;OAWG;IACI,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC;IACpE,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE;QAAC,OAAO,EAAE,IAAI,CAAA;KAAC,GAAG,iBAAiB,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IA2CnG;;;;;;;;;;;;OAYG;IACI,KAAK,CAAC,CAAC,SAAS,IAAI,GAAG,GAAG,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;CAIjE"}
|
package/dist/index.cjs
CHANGED
|
@@ -2395,7 +2395,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2395
2395
|
}
|
|
2396
2396
|
/** Setup the PWA */
|
|
2397
2397
|
async setup(manifest = {}) {
|
|
2398
|
-
var _a;
|
|
2398
|
+
var _a, _b, _c;
|
|
2399
2399
|
const storageKey = `${this.api.options.name}:pwa`;
|
|
2400
2400
|
window.addEventListener("beforeinstallprompt", (e) => {
|
|
2401
2401
|
e.preventDefault();
|
|
@@ -2428,14 +2428,50 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2428
2428
|
meta2.content = value;
|
|
2429
2429
|
document.head.append(meta2);
|
|
2430
2430
|
};
|
|
2431
|
+
const link = (rel, href) => {
|
|
2432
|
+
const exists = document.querySelector(`link[rel="${rel}"]`);
|
|
2433
|
+
if (href === void 0) return exists;
|
|
2434
|
+
if (exists) {
|
|
2435
|
+
exists.href = href;
|
|
2436
|
+
return exists;
|
|
2437
|
+
}
|
|
2438
|
+
const link2 = document.createElement("link");
|
|
2439
|
+
link2.rel = rel;
|
|
2440
|
+
link2.href = href;
|
|
2441
|
+
document.head.append(link2);
|
|
2442
|
+
return link2;
|
|
2443
|
+
};
|
|
2444
|
+
const resolveUrl = (href) => {
|
|
2445
|
+
if (!href) return "";
|
|
2446
|
+
try {
|
|
2447
|
+
return new URL(href, location.href).href;
|
|
2448
|
+
} catch (e) {
|
|
2449
|
+
return href;
|
|
2450
|
+
}
|
|
2451
|
+
};
|
|
2452
|
+
const pickFavicon = () => {
|
|
2453
|
+
const touch = document.querySelector('link[rel="apple-touch-icon"]');
|
|
2454
|
+
if (touch == null ? void 0 : touch.href) return resolveUrl(touch.href);
|
|
2455
|
+
const iconWithSizes = Array.from(document.querySelectorAll('link[rel~="icon"][sizes]'));
|
|
2456
|
+
if (iconWithSizes.length) {
|
|
2457
|
+
const best = iconWithSizes.sort((a, b) => {
|
|
2458
|
+
var _a2, _b2;
|
|
2459
|
+
return (parseInt((((_a2 = b.sizes) == null ? void 0 : _a2.value) || "0").split("x")[0]) || 0) - (parseInt((((_b2 = a.sizes) == null ? void 0 : _b2.value) || "0").split("x")[0]) || 0);
|
|
2460
|
+
})[0];
|
|
2461
|
+
if (best == null ? void 0 : best.href) return resolveUrl(best.href);
|
|
2462
|
+
}
|
|
2463
|
+
const anyIcon = document.querySelector('link[rel~="icon"]');
|
|
2464
|
+
return (anyIcon == null ? void 0 : anyIcon.href) ? resolveUrl(anyIcon.href) : "";
|
|
2465
|
+
};
|
|
2466
|
+
const iconUrl = resolveUrl((_a = this.api.options.pwaSettings) == null ? void 0 : _a.icon) || pickFavicon() || "https://datalynk-client.primary.auxilium.world/logo.png";
|
|
2431
2467
|
meta("name", "mobile-web-app-capable", "yes");
|
|
2432
2468
|
meta("name", "apple-mobile-web-app-status-bar-style", "default");
|
|
2433
2469
|
meta("name", "apple-mobile-web-app-title", this.api.options.name);
|
|
2434
|
-
|
|
2435
|
-
|
|
2470
|
+
link("apple-touch-icon", iconUrl);
|
|
2471
|
+
link("apple-touch-startup-image", iconUrl);
|
|
2436
2472
|
if (!document.querySelector('link[rel="manifest"]')) {
|
|
2437
|
-
const
|
|
2438
|
-
|
|
2473
|
+
const link2 = document.createElement("link");
|
|
2474
|
+
link2.rel = "manifest";
|
|
2439
2475
|
const base = String(this.api.url).replace(/\/+$/, "");
|
|
2440
2476
|
const startUrl = location.pathname;
|
|
2441
2477
|
const scopePath = startUrl.endsWith("/") ? startUrl : startUrl.replace(/[^/]+$/, "");
|
|
@@ -2448,21 +2484,28 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2448
2484
|
...this.api.options.manifest || {},
|
|
2449
2485
|
...manifest || {}
|
|
2450
2486
|
};
|
|
2451
|
-
|
|
2452
|
-
|
|
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);
|
|
2453
2496
|
}
|
|
2454
|
-
if (!((
|
|
2497
|
+
if (!((_c = this.api.options.pwaSettings) == null ? void 0 : _c.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
|
|
2455
2498
|
const t = Number(this.api.options.pwaSettings.timeout ?? 30);
|
|
2456
2499
|
const timeoutMs = t >= 1e3 ? t : t * 1e3;
|
|
2457
2500
|
setTimeout(() => {
|
|
2458
|
-
var _a2,
|
|
2501
|
+
var _a2, _b2, _c2, _d;
|
|
2459
2502
|
const raw = localStorage.getItem(storageKey);
|
|
2460
2503
|
if (raw === "installed") return;
|
|
2461
|
-
if (((
|
|
2504
|
+
if (((_b2 = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b2.dismissExpiry) === 0) {
|
|
2462
2505
|
if (raw !== "installed") localStorage.removeItem(storageKey);
|
|
2463
2506
|
}
|
|
2464
2507
|
const dismissedAt = raw ? Number(raw) : 0;
|
|
2465
|
-
const expiryDays = Number(((_d = (
|
|
2508
|
+
const expiryDays = Number(((_d = (_c2 = this.api.options) == null ? void 0 : _c2.pwaSettings) == null ? void 0 : _d.dismissExpiry) ?? 0);
|
|
2466
2509
|
if (dismissedAt && expiryDays > 0) {
|
|
2467
2510
|
const expiryMs = expiryDays * 24 * 60 * 60 * 1e3;
|
|
2468
2511
|
if (Date.now() < dismissedAt + expiryMs) return;
|
|
@@ -2473,12 +2516,35 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2473
2516
|
}
|
|
2474
2517
|
/** Prompt user to install the app */
|
|
2475
2518
|
async prompt(platform) {
|
|
2476
|
-
var _a;
|
|
2519
|
+
var _a, _b;
|
|
2477
2520
|
const storageKey = `${this.api.options.name}:pwa`;
|
|
2478
2521
|
if ((_a = this.api.options.pwaSettings) == null ? void 0 : _a.hidePWAPrompt) return;
|
|
2479
2522
|
if (this.pwa) return;
|
|
2480
2523
|
if (localStorage.getItem(storageKey) === "installed") return;
|
|
2481
2524
|
if (document.querySelector(".pwa-prompt")) return;
|
|
2525
|
+
const resolveUrl = (href) => {
|
|
2526
|
+
if (!href) return "";
|
|
2527
|
+
try {
|
|
2528
|
+
return new URL(href, location.href).href;
|
|
2529
|
+
} catch (e) {
|
|
2530
|
+
return href;
|
|
2531
|
+
}
|
|
2532
|
+
};
|
|
2533
|
+
const pickFavicon = () => {
|
|
2534
|
+
const touch = document.querySelector('link[rel="apple-touch-icon"]');
|
|
2535
|
+
if (touch == null ? void 0 : touch.href) return resolveUrl(touch.href);
|
|
2536
|
+
const iconWithSizes = Array.from(document.querySelectorAll('link[rel~="icon"][sizes]'));
|
|
2537
|
+
if (iconWithSizes.length) {
|
|
2538
|
+
const best = iconWithSizes.sort((a, b) => {
|
|
2539
|
+
var _a2, _b2;
|
|
2540
|
+
return (parseInt((((_a2 = b.sizes) == null ? void 0 : _a2.value) || "0").split("x")[0]) || 0) - (parseInt((((_b2 = a.sizes) == null ? void 0 : _b2.value) || "0").split("x")[0]) || 0);
|
|
2541
|
+
})[0];
|
|
2542
|
+
if (best == null ? void 0 : best.href) return resolveUrl(best.href);
|
|
2543
|
+
}
|
|
2544
|
+
const anyIcon = document.querySelector('link[rel~="icon"]');
|
|
2545
|
+
return (anyIcon == null ? void 0 : anyIcon.href) ? resolveUrl(anyIcon.href) : "";
|
|
2546
|
+
};
|
|
2547
|
+
const iconUrl = resolveUrl((_b = this.api.options.pwaSettings) == null ? void 0 : _b.icon) || pickFavicon() || "https://datalynk-client.primary.auxilium.world/logo.png";
|
|
2482
2548
|
const targetPlatform = platform || this.platform;
|
|
2483
2549
|
const isAndroid = targetPlatform == "android";
|
|
2484
2550
|
const isIOS = targetPlatform == "ios";
|
|
@@ -2604,7 +2670,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2604
2670
|
prompt.classList.add("pwa-prompt");
|
|
2605
2671
|
prompt.innerHTML = `
|
|
2606
2672
|
<div class="pwa-prompt-header">
|
|
2607
|
-
<img src="
|
|
2673
|
+
<img src="${iconUrl}" alt="Logo" />
|
|
2608
2674
|
<h1>Install ${this.api.options.name}</h1>
|
|
2609
2675
|
<button class="pwa-prompt-close">×</button>
|
|
2610
2676
|
</div>
|
|
@@ -3736,7 +3802,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3736
3802
|
} });
|
|
3737
3803
|
}
|
|
3738
3804
|
}
|
|
3739
|
-
const version = "1.3.
|
|
3805
|
+
const version = "1.3.16";
|
|
3740
3806
|
class WebRtc {
|
|
3741
3807
|
constructor(api) {
|
|
3742
3808
|
__publicField(this, "ice");
|
|
@@ -3973,18 +4039,39 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3973
4039
|
(_b = this.options.offline) == null ? void 0 : _b.forEach((id) => this.slice(id));
|
|
3974
4040
|
if (this.options.serviceWorker && typeof navigator["serviceWorker"] != "undefined") {
|
|
3975
4041
|
(async () => {
|
|
4042
|
+
let initDone = false;
|
|
3976
4043
|
const init = () => {
|
|
3977
4044
|
var _a2;
|
|
4045
|
+
if (initDone) return;
|
|
4046
|
+
initDone = true;
|
|
3978
4047
|
(_a2 = navigator.serviceWorker.controller) == null ? void 0 : _a2.postMessage({ options: { ...this.options, url: this.url } });
|
|
3979
4048
|
this.token$.subscribe((token) => {
|
|
3980
4049
|
var _a3;
|
|
3981
4050
|
return (_a3 = navigator.serviceWorker.controller) == null ? void 0 : _a3.postMessage({ token });
|
|
3982
4051
|
});
|
|
3983
4052
|
};
|
|
3984
|
-
|
|
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
|
+
}
|
|
3985
4065
|
navigator.serviceWorker.ready.then(() => {
|
|
3986
4066
|
if (navigator.serviceWorker.controller) navigator.serviceWorker.ready.then(() => init());
|
|
3987
4067
|
else navigator.serviceWorker.addEventListener("controllerchange", () => init(), { once: true });
|
|
4068
|
+
let refreshed = false;
|
|
4069
|
+
navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
4070
|
+
if (refreshed) return;
|
|
4071
|
+
refreshed = true;
|
|
4072
|
+
const standalone = matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone);
|
|
4073
|
+
if (standalone) location.reload();
|
|
4074
|
+
});
|
|
3988
4075
|
});
|
|
3989
4076
|
})();
|
|
3990
4077
|
}
|
|
@@ -4042,9 +4129,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4042
4129
|
}),
|
|
4043
4130
|
body: JSON.stringify(_Api.translateTokens(req))
|
|
4044
4131
|
}).then(async (resp) => {
|
|
4045
|
-
const warning = resp.headers
|
|
4132
|
+
const warning = resp.headers.get("X-Warning");
|
|
4046
4133
|
if (warning) console.warn(warning);
|
|
4047
|
-
const banner = resp.headers
|
|
4134
|
+
const banner = resp.headers.get("X-User-Notice");
|
|
4048
4135
|
if (banner) {
|
|
4049
4136
|
createBanner(banner);
|
|
4050
4137
|
setTimeout(() => removeBanner(), 1e4);
|
package/dist/index.mjs
CHANGED
|
@@ -2391,7 +2391,7 @@ class PWA {
|
|
|
2391
2391
|
}
|
|
2392
2392
|
/** Setup the PWA */
|
|
2393
2393
|
async setup(manifest = {}) {
|
|
2394
|
-
var _a;
|
|
2394
|
+
var _a, _b, _c;
|
|
2395
2395
|
const storageKey = `${this.api.options.name}:pwa`;
|
|
2396
2396
|
window.addEventListener("beforeinstallprompt", (e) => {
|
|
2397
2397
|
e.preventDefault();
|
|
@@ -2424,14 +2424,50 @@ class PWA {
|
|
|
2424
2424
|
meta2.content = value;
|
|
2425
2425
|
document.head.append(meta2);
|
|
2426
2426
|
};
|
|
2427
|
+
const link = (rel, href) => {
|
|
2428
|
+
const exists = document.querySelector(`link[rel="${rel}"]`);
|
|
2429
|
+
if (href === void 0) return exists;
|
|
2430
|
+
if (exists) {
|
|
2431
|
+
exists.href = href;
|
|
2432
|
+
return exists;
|
|
2433
|
+
}
|
|
2434
|
+
const link2 = document.createElement("link");
|
|
2435
|
+
link2.rel = rel;
|
|
2436
|
+
link2.href = href;
|
|
2437
|
+
document.head.append(link2);
|
|
2438
|
+
return link2;
|
|
2439
|
+
};
|
|
2440
|
+
const resolveUrl = (href) => {
|
|
2441
|
+
if (!href) return "";
|
|
2442
|
+
try {
|
|
2443
|
+
return new URL(href, location.href).href;
|
|
2444
|
+
} catch (e) {
|
|
2445
|
+
return href;
|
|
2446
|
+
}
|
|
2447
|
+
};
|
|
2448
|
+
const pickFavicon = () => {
|
|
2449
|
+
const touch = document.querySelector('link[rel="apple-touch-icon"]');
|
|
2450
|
+
if (touch == null ? void 0 : touch.href) return resolveUrl(touch.href);
|
|
2451
|
+
const iconWithSizes = Array.from(document.querySelectorAll('link[rel~="icon"][sizes]'));
|
|
2452
|
+
if (iconWithSizes.length) {
|
|
2453
|
+
const best = iconWithSizes.sort((a, b) => {
|
|
2454
|
+
var _a2, _b2;
|
|
2455
|
+
return (parseInt((((_a2 = b.sizes) == null ? void 0 : _a2.value) || "0").split("x")[0]) || 0) - (parseInt((((_b2 = a.sizes) == null ? void 0 : _b2.value) || "0").split("x")[0]) || 0);
|
|
2456
|
+
})[0];
|
|
2457
|
+
if (best == null ? void 0 : best.href) return resolveUrl(best.href);
|
|
2458
|
+
}
|
|
2459
|
+
const anyIcon = document.querySelector('link[rel~="icon"]');
|
|
2460
|
+
return (anyIcon == null ? void 0 : anyIcon.href) ? resolveUrl(anyIcon.href) : "";
|
|
2461
|
+
};
|
|
2462
|
+
const iconUrl = resolveUrl((_a = this.api.options.pwaSettings) == null ? void 0 : _a.icon) || pickFavicon() || "https://datalynk-client.primary.auxilium.world/logo.png";
|
|
2427
2463
|
meta("name", "mobile-web-app-capable", "yes");
|
|
2428
2464
|
meta("name", "apple-mobile-web-app-status-bar-style", "default");
|
|
2429
2465
|
meta("name", "apple-mobile-web-app-title", this.api.options.name);
|
|
2430
|
-
|
|
2431
|
-
|
|
2466
|
+
link("apple-touch-icon", iconUrl);
|
|
2467
|
+
link("apple-touch-startup-image", iconUrl);
|
|
2432
2468
|
if (!document.querySelector('link[rel="manifest"]')) {
|
|
2433
|
-
const
|
|
2434
|
-
|
|
2469
|
+
const link2 = document.createElement("link");
|
|
2470
|
+
link2.rel = "manifest";
|
|
2435
2471
|
const base = String(this.api.url).replace(/\/+$/, "");
|
|
2436
2472
|
const startUrl = location.pathname;
|
|
2437
2473
|
const scopePath = startUrl.endsWith("/") ? startUrl : startUrl.replace(/[^/]+$/, "");
|
|
@@ -2444,21 +2480,28 @@ class PWA {
|
|
|
2444
2480
|
...this.api.options.manifest || {},
|
|
2445
2481
|
...manifest || {}
|
|
2446
2482
|
};
|
|
2447
|
-
|
|
2448
|
-
|
|
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);
|
|
2449
2492
|
}
|
|
2450
|
-
if (!((
|
|
2493
|
+
if (!((_c = this.api.options.pwaSettings) == null ? void 0 : _c.hidePWAPrompt) && !this.headless && !this.iframe && !this.pwa && this.platform != "mac") {
|
|
2451
2494
|
const t = Number(this.api.options.pwaSettings.timeout ?? 30);
|
|
2452
2495
|
const timeoutMs = t >= 1e3 ? t : t * 1e3;
|
|
2453
2496
|
setTimeout(() => {
|
|
2454
|
-
var _a2,
|
|
2497
|
+
var _a2, _b2, _c2, _d;
|
|
2455
2498
|
const raw = localStorage.getItem(storageKey);
|
|
2456
2499
|
if (raw === "installed") return;
|
|
2457
|
-
if (((
|
|
2500
|
+
if (((_b2 = (_a2 = this.api.options) == null ? void 0 : _a2.pwaSettings) == null ? void 0 : _b2.dismissExpiry) === 0) {
|
|
2458
2501
|
if (raw !== "installed") localStorage.removeItem(storageKey);
|
|
2459
2502
|
}
|
|
2460
2503
|
const dismissedAt = raw ? Number(raw) : 0;
|
|
2461
|
-
const expiryDays = Number(((_d = (
|
|
2504
|
+
const expiryDays = Number(((_d = (_c2 = this.api.options) == null ? void 0 : _c2.pwaSettings) == null ? void 0 : _d.dismissExpiry) ?? 0);
|
|
2462
2505
|
if (dismissedAt && expiryDays > 0) {
|
|
2463
2506
|
const expiryMs = expiryDays * 24 * 60 * 60 * 1e3;
|
|
2464
2507
|
if (Date.now() < dismissedAt + expiryMs) return;
|
|
@@ -2469,12 +2512,35 @@ class PWA {
|
|
|
2469
2512
|
}
|
|
2470
2513
|
/** Prompt user to install the app */
|
|
2471
2514
|
async prompt(platform) {
|
|
2472
|
-
var _a;
|
|
2515
|
+
var _a, _b;
|
|
2473
2516
|
const storageKey = `${this.api.options.name}:pwa`;
|
|
2474
2517
|
if ((_a = this.api.options.pwaSettings) == null ? void 0 : _a.hidePWAPrompt) return;
|
|
2475
2518
|
if (this.pwa) return;
|
|
2476
2519
|
if (localStorage.getItem(storageKey) === "installed") return;
|
|
2477
2520
|
if (document.querySelector(".pwa-prompt")) return;
|
|
2521
|
+
const resolveUrl = (href) => {
|
|
2522
|
+
if (!href) return "";
|
|
2523
|
+
try {
|
|
2524
|
+
return new URL(href, location.href).href;
|
|
2525
|
+
} catch (e) {
|
|
2526
|
+
return href;
|
|
2527
|
+
}
|
|
2528
|
+
};
|
|
2529
|
+
const pickFavicon = () => {
|
|
2530
|
+
const touch = document.querySelector('link[rel="apple-touch-icon"]');
|
|
2531
|
+
if (touch == null ? void 0 : touch.href) return resolveUrl(touch.href);
|
|
2532
|
+
const iconWithSizes = Array.from(document.querySelectorAll('link[rel~="icon"][sizes]'));
|
|
2533
|
+
if (iconWithSizes.length) {
|
|
2534
|
+
const best = iconWithSizes.sort((a, b) => {
|
|
2535
|
+
var _a2, _b2;
|
|
2536
|
+
return (parseInt((((_a2 = b.sizes) == null ? void 0 : _a2.value) || "0").split("x")[0]) || 0) - (parseInt((((_b2 = a.sizes) == null ? void 0 : _b2.value) || "0").split("x")[0]) || 0);
|
|
2537
|
+
})[0];
|
|
2538
|
+
if (best == null ? void 0 : best.href) return resolveUrl(best.href);
|
|
2539
|
+
}
|
|
2540
|
+
const anyIcon = document.querySelector('link[rel~="icon"]');
|
|
2541
|
+
return (anyIcon == null ? void 0 : anyIcon.href) ? resolveUrl(anyIcon.href) : "";
|
|
2542
|
+
};
|
|
2543
|
+
const iconUrl = resolveUrl((_b = this.api.options.pwaSettings) == null ? void 0 : _b.icon) || pickFavicon() || "https://datalynk-client.primary.auxilium.world/logo.png";
|
|
2478
2544
|
const targetPlatform = platform || this.platform;
|
|
2479
2545
|
const isAndroid = targetPlatform == "android";
|
|
2480
2546
|
const isIOS = targetPlatform == "ios";
|
|
@@ -2600,7 +2666,7 @@ class PWA {
|
|
|
2600
2666
|
prompt.classList.add("pwa-prompt");
|
|
2601
2667
|
prompt.innerHTML = `
|
|
2602
2668
|
<div class="pwa-prompt-header">
|
|
2603
|
-
<img src="
|
|
2669
|
+
<img src="${iconUrl}" alt="Logo" />
|
|
2604
2670
|
<h1>Install ${this.api.options.name}</h1>
|
|
2605
2671
|
<button class="pwa-prompt-close">×</button>
|
|
2606
2672
|
</div>
|
|
@@ -3732,7 +3798,7 @@ class Superuser {
|
|
|
3732
3798
|
} });
|
|
3733
3799
|
}
|
|
3734
3800
|
}
|
|
3735
|
-
const version = "1.3.
|
|
3801
|
+
const version = "1.3.16";
|
|
3736
3802
|
class WebRtc {
|
|
3737
3803
|
constructor(api) {
|
|
3738
3804
|
__publicField(this, "ice");
|
|
@@ -3969,18 +4035,39 @@ const _Api = class _Api {
|
|
|
3969
4035
|
(_b = this.options.offline) == null ? void 0 : _b.forEach((id) => this.slice(id));
|
|
3970
4036
|
if (this.options.serviceWorker && typeof navigator["serviceWorker"] != "undefined") {
|
|
3971
4037
|
(async () => {
|
|
4038
|
+
let initDone = false;
|
|
3972
4039
|
const init = () => {
|
|
3973
4040
|
var _a2;
|
|
4041
|
+
if (initDone) return;
|
|
4042
|
+
initDone = true;
|
|
3974
4043
|
(_a2 = navigator.serviceWorker.controller) == null ? void 0 : _a2.postMessage({ options: { ...this.options, url: this.url } });
|
|
3975
4044
|
this.token$.subscribe((token) => {
|
|
3976
4045
|
var _a3;
|
|
3977
4046
|
return (_a3 = navigator.serviceWorker.controller) == null ? void 0 : _a3.postMessage({ token });
|
|
3978
4047
|
});
|
|
3979
4048
|
};
|
|
3980
|
-
|
|
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
|
+
}
|
|
3981
4061
|
navigator.serviceWorker.ready.then(() => {
|
|
3982
4062
|
if (navigator.serviceWorker.controller) navigator.serviceWorker.ready.then(() => init());
|
|
3983
4063
|
else navigator.serviceWorker.addEventListener("controllerchange", () => init(), { once: true });
|
|
4064
|
+
let refreshed = false;
|
|
4065
|
+
navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
4066
|
+
if (refreshed) return;
|
|
4067
|
+
refreshed = true;
|
|
4068
|
+
const standalone = matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone);
|
|
4069
|
+
if (standalone) location.reload();
|
|
4070
|
+
});
|
|
3984
4071
|
});
|
|
3985
4072
|
})();
|
|
3986
4073
|
}
|
|
@@ -4038,9 +4125,9 @@ const _Api = class _Api {
|
|
|
4038
4125
|
}),
|
|
4039
4126
|
body: JSON.stringify(_Api.translateTokens(req))
|
|
4040
4127
|
}).then(async (resp) => {
|
|
4041
|
-
const warning = resp.headers
|
|
4128
|
+
const warning = resp.headers.get("X-Warning");
|
|
4042
4129
|
if (warning) console.warn(warning);
|
|
4043
|
-
const banner = resp.headers
|
|
4130
|
+
const banner = resp.headers.get("X-User-Notice");
|
|
4044
4131
|
if (banner) {
|
|
4045
4132
|
createBanner(banner);
|
|
4046
4133
|
setTimeout(() => removeBanner(), 1e4);
|
package/dist/pwa.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pwa.d.ts","sourceRoot":"","sources":["../src/pwa.ts"],"names":[],"mappings":"
|
|
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"}
|
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.16",
|
|
6
6
|
"author": "Zak Timson <zaktimson@gmail.com>",
|
|
7
7
|
"private": false,
|
|
8
8
|
"main": "./dist/index.cjs",
|