@auxilium/datalynk-client 1.1.10 → 1.2.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 +3 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +198 -21
- package/dist/index.mjs +198 -21
- package/dist/login-prompt.d.ts +6 -0
- package/dist/login-prompt.d.ts.map +1 -1
- package/dist/pwa.d.ts +14 -0
- package/dist/pwa.d.ts.map +1 -0
- package/dist/themes.d.ts +18 -1
- package/dist/themes.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Database } from '@ztimson/utils';
|
|
2
2
|
import { BehaviorSubject } from 'rxjs';
|
|
3
3
|
import { Auth } from './auth';
|
|
4
|
+
import { PWA } from './pwa';
|
|
4
5
|
import { Files } from './files';
|
|
5
6
|
import { Meta } from './meta';
|
|
6
7
|
import { Pdf } from './pdf';
|
|
@@ -98,6 +99,8 @@ export declare class Api {
|
|
|
98
99
|
readonly files: Files;
|
|
99
100
|
/** PDF */
|
|
100
101
|
readonly pdf: Pdf;
|
|
102
|
+
/** PWA setup & prompt */
|
|
103
|
+
readonly pwa: PWA;
|
|
101
104
|
/** Socket */
|
|
102
105
|
readonly socket: Socket;
|
|
103
106
|
/** Superuser */
|
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,EAAC,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAC,eAAe,EAAuB,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,I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CAAC,CAAC;CAIjE"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1166,20 +1166,20 @@ var Subscription = function() {
|
|
|
1166
1166
|
}
|
|
1167
1167
|
}
|
|
1168
1168
|
};
|
|
1169
|
-
Subscription2.prototype._hasParent = function(
|
|
1169
|
+
Subscription2.prototype._hasParent = function(parent2) {
|
|
1170
1170
|
var _parentage = this._parentage;
|
|
1171
|
-
return _parentage ===
|
|
1171
|
+
return _parentage === parent2 || Array.isArray(_parentage) && _parentage.includes(parent2);
|
|
1172
1172
|
};
|
|
1173
|
-
Subscription2.prototype._addParent = function(
|
|
1173
|
+
Subscription2.prototype._addParent = function(parent2) {
|
|
1174
1174
|
var _parentage = this._parentage;
|
|
1175
|
-
this._parentage = Array.isArray(_parentage) ? (_parentage.push(
|
|
1175
|
+
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent2), _parentage) : _parentage ? [_parentage, parent2] : parent2;
|
|
1176
1176
|
};
|
|
1177
|
-
Subscription2.prototype._removeParent = function(
|
|
1177
|
+
Subscription2.prototype._removeParent = function(parent2) {
|
|
1178
1178
|
var _parentage = this._parentage;
|
|
1179
|
-
if (_parentage ===
|
|
1179
|
+
if (_parentage === parent2) {
|
|
1180
1180
|
this._parentage = null;
|
|
1181
1181
|
} else if (Array.isArray(_parentage)) {
|
|
1182
|
-
arrRemove(_parentage,
|
|
1182
|
+
arrRemove(_parentage, parent2);
|
|
1183
1183
|
}
|
|
1184
1184
|
};
|
|
1185
1185
|
Subscription2.prototype.remove = function(teardown) {
|
|
@@ -1819,6 +1819,8 @@ async function getTheme(spoke, scope) {
|
|
|
1819
1819
|
logo: `https://${spoke}.auxiliumgroup.com/static/js/auxilium/dijits/templates/login/${spoke}/logo.png`,
|
|
1820
1820
|
title: spoke.toUpperCase(),
|
|
1821
1821
|
textColor: "white",
|
|
1822
|
+
titleFontFamily: "'AR BLANCA', serif",
|
|
1823
|
+
titleFontUrl: "https://fonts.cdnfonts.com/css/ar-blanca",
|
|
1822
1824
|
...theme || {}
|
|
1823
1825
|
};
|
|
1824
1826
|
}
|
|
@@ -1905,7 +1907,7 @@ const _LoginPrompt = class _LoginPrompt {
|
|
|
1905
1907
|
/** Dynamically create CSS style */
|
|
1906
1908
|
__publicField(_LoginPrompt, "css", (options) => `
|
|
1907
1909
|
<style id="datalynk-login-styles">
|
|
1908
|
-
|
|
1910
|
+
${options.titleFontUrl ? `@import url('${options.titleFontUrl}');` : `@import url('https://fonts.cdnfonts.com/css/ar-blanca');`}
|
|
1909
1911
|
|
|
1910
1912
|
#datalynk-login {
|
|
1911
1913
|
--theme-background: ${options.backgroundColor ? options.backgroundColor : `url(${options.background})`};
|
|
@@ -1980,7 +1982,11 @@ __publicField(_LoginPrompt, "css", (options) => `
|
|
|
1980
1982
|
font-size: 32px;
|
|
1981
1983
|
margin-bottom: 2rem;
|
|
1982
1984
|
}
|
|
1983
|
-
|
|
1985
|
+
|
|
1986
|
+
#datalynk-login .login-title {
|
|
1987
|
+
font-family: ${options.titleFontFamily ? options.titleFontFamily : "'AR BLANCA', serif"};
|
|
1988
|
+
${options.titleTextShadow ? `text-shadow: ${options.titleTextShadow};` : ""}
|
|
1989
|
+
}
|
|
1984
1990
|
#datalynk-login .login-content {
|
|
1985
1991
|
display: flex;
|
|
1986
1992
|
flex-direction: column;
|
|
@@ -2321,6 +2327,183 @@ class Auth {
|
|
|
2321
2327
|
return this.api.request({ "$/auth/mobile/generate": { user: login, method: mode } });
|
|
2322
2328
|
}
|
|
2323
2329
|
}
|
|
2330
|
+
class PWA {
|
|
2331
|
+
constructor(api) {
|
|
2332
|
+
this.api = api;
|
|
2333
|
+
}
|
|
2334
|
+
get iframe() {
|
|
2335
|
+
return (parent == null ? void 0 : parent.location) != location;
|
|
2336
|
+
}
|
|
2337
|
+
get mobile() {
|
|
2338
|
+
return ["android", "ios"].includes(this.platform);
|
|
2339
|
+
}
|
|
2340
|
+
get platform() {
|
|
2341
|
+
const userAgent = navigator.userAgent || navigator.vendor;
|
|
2342
|
+
if (/windows/i.test(userAgent)) return "windows";
|
|
2343
|
+
else if (/android/i.test(userAgent)) return "android";
|
|
2344
|
+
else if (/iPad|iPhone|iPod/.test(userAgent)) return "ios";
|
|
2345
|
+
else if (/macintosh|mac os x/i.test(userAgent)) return "mac";
|
|
2346
|
+
else if (/linux/i.test(userAgent)) return "linux";
|
|
2347
|
+
else return "unknown";
|
|
2348
|
+
}
|
|
2349
|
+
get pwa() {
|
|
2350
|
+
return matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone) || document.referrer.includes("android-app://");
|
|
2351
|
+
}
|
|
2352
|
+
/** Setup the PWA */
|
|
2353
|
+
async setup(manifest = {}) {
|
|
2354
|
+
const meta = (key, name, value) => {
|
|
2355
|
+
const exists = document.querySelector(`meta[${key}="${name}"]`);
|
|
2356
|
+
if (value === void 0 || exists) return exists;
|
|
2357
|
+
const meta2 = document.createElement("meta");
|
|
2358
|
+
meta2.setAttribute(key, name);
|
|
2359
|
+
meta2.content = value;
|
|
2360
|
+
document.head.append(meta2);
|
|
2361
|
+
};
|
|
2362
|
+
meta("name", "mobile-web-app-capable", "yes");
|
|
2363
|
+
meta("name", "apple-mobile-web-app-status-bar-style", "default");
|
|
2364
|
+
meta("name", "apple-mobile-web-app-title", this.api.options.name);
|
|
2365
|
+
meta("name", "apple-touch-icon", `https://datalynk-client.scarborough.auxilium.world/logo.png`);
|
|
2366
|
+
meta("name", "apple-touch-startup-image", `https://datalynk-client.scarborough.auxilium.world/logo.png`);
|
|
2367
|
+
if (!document.querySelector('link[rel="manifest"]')) {
|
|
2368
|
+
const link = document.createElement("link");
|
|
2369
|
+
link.setAttribute("rel", "manifest");
|
|
2370
|
+
link.setAttribute("href", `${this.api.url}/manifest?json=${encodeURI(JSON.stringify({
|
|
2371
|
+
name: this.api.options.name,
|
|
2372
|
+
short_name: this.api.options.name,
|
|
2373
|
+
start_url: location.origin + location.pathname,
|
|
2374
|
+
...this.api.options.manifest,
|
|
2375
|
+
...manifest
|
|
2376
|
+
}))}`);
|
|
2377
|
+
document.head.append(link);
|
|
2378
|
+
}
|
|
2379
|
+
if (!this.iframe && !this.pwa && this.platform != "mac") setTimeout(() => {
|
|
2380
|
+
const dismissed = !!localStorage.getItem(`${this.api.options.name}:pwa`);
|
|
2381
|
+
if (!dismissed) this.prompt();
|
|
2382
|
+
}, 6e4);
|
|
2383
|
+
}
|
|
2384
|
+
/** Prompt user to install the app */
|
|
2385
|
+
async prompt(platform) {
|
|
2386
|
+
if (document.querySelector(".pwa-prompt")) return;
|
|
2387
|
+
this.api.url;
|
|
2388
|
+
const android = (platform || this.platform) == "android";
|
|
2389
|
+
let style = document.querySelector("style.pwa");
|
|
2390
|
+
if (!style) {
|
|
2391
|
+
style = document.createElement("style");
|
|
2392
|
+
style.innerHTML = `
|
|
2393
|
+
.pwa-prompt-backdrop {
|
|
2394
|
+
position: fixed;
|
|
2395
|
+
display: relative;
|
|
2396
|
+
left: 0;
|
|
2397
|
+
top: 0;
|
|
2398
|
+
right: 0;
|
|
2399
|
+
bottom: 0;
|
|
2400
|
+
background: rgba(0,0,0,.5);
|
|
2401
|
+
z-index: 9999;
|
|
2402
|
+
animation: fadeIn 0.5s ease-in-out forwards;
|
|
2403
|
+
opacity: 0;
|
|
2404
|
+
}
|
|
2405
|
+
.pwa-prompt-backdrop.exit {
|
|
2406
|
+
animation: fadeOut 0.5s ease-in-out forwards !important;
|
|
2407
|
+
}
|
|
2408
|
+
.pwa-prompt {
|
|
2409
|
+
position: fixed;
|
|
2410
|
+
background: #fff;
|
|
2411
|
+
color: black;
|
|
2412
|
+
bottom: 0;
|
|
2413
|
+
left: 50%;
|
|
2414
|
+
width: min(100vw, 450px);
|
|
2415
|
+
transform: translate(-50%, 0);
|
|
2416
|
+
animation: slideUp 0.5s ease-in-out forwards;
|
|
2417
|
+
}
|
|
2418
|
+
.pwa-prompt.exit {
|
|
2419
|
+
animation: slideDown 0.5s ease-in-out forwards !important;
|
|
2420
|
+
}
|
|
2421
|
+
.pwa-prompt img {
|
|
2422
|
+
width: 18px;
|
|
2423
|
+
height: 18px;
|
|
2424
|
+
}
|
|
2425
|
+
.pwa-prompt h1 {
|
|
2426
|
+
font-size: 1.25rem;
|
|
2427
|
+
font-weight: bold;
|
|
2428
|
+
}
|
|
2429
|
+
.pwa-prompt-close {
|
|
2430
|
+
position: absolute;
|
|
2431
|
+
right: 5px;
|
|
2432
|
+
top: 10px;
|
|
2433
|
+
background: transparent;
|
|
2434
|
+
border: none;
|
|
2435
|
+
cursor: pointer;
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
@keyframes fadeIn {
|
|
2439
|
+
from { opacity: 0; }
|
|
2440
|
+
to { opacity: 1; }
|
|
2441
|
+
}
|
|
2442
|
+
@keyframes fadeOut {
|
|
2443
|
+
from { opacity: 1; }
|
|
2444
|
+
to { opacity: 0; }
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
@keyframes slideUp {
|
|
2448
|
+
from { transform: translate(-50%, 100%); }
|
|
2449
|
+
to { transform: translate(-50%, 0); }
|
|
2450
|
+
}
|
|
2451
|
+
@keyframes slideDown {
|
|
2452
|
+
from { transform: translate(-50%, 0); }
|
|
2453
|
+
to { transform: translate(-50%, 100%); }
|
|
2454
|
+
}
|
|
2455
|
+
`;
|
|
2456
|
+
document.head.append(style);
|
|
2457
|
+
}
|
|
2458
|
+
const backdrop = document.createElement("div");
|
|
2459
|
+
backdrop.classList.add("pwa-prompt-backdrop");
|
|
2460
|
+
const prompt = document.createElement("div");
|
|
2461
|
+
prompt.classList.add("pwa-prompt");
|
|
2462
|
+
prompt.innerHTML = `
|
|
2463
|
+
<div style="display: flex; padding: 1rem; align-items: center">
|
|
2464
|
+
<img src="https://datalynk-client.scarborough.auxilium.world/logo.png" alt="Logo" style="height: 40px; width: auto; margin-right: .5rem;" />
|
|
2465
|
+
<h1 style="margin: 0">Install ${this.api.options.name}</h1>
|
|
2466
|
+
</div>
|
|
2467
|
+
<div style="display: flex; flex-direction: column; align-items: center">
|
|
2468
|
+
<div style="border-top: 2px solid #00000020; border-bottom: 2px solid #00000020; padding: 0 1rem">
|
|
2469
|
+
<p style="margin-top: 1rem; text-align: center">This website can be installed as an App! Add it to your home screen for quick access & fullscreen use.</p>
|
|
2470
|
+
</div>
|
|
2471
|
+
<table style="margin: 1.5rem 0">
|
|
2472
|
+
<tr>
|
|
2473
|
+
<td style="width: 50px; text-align: center">
|
|
2474
|
+
${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="black" style="transform: scale(1.5)"><path d="M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"/></svg>' : '<svg viewBox="0 0 566 670" xmlns="http://www.w3.org/2000/svg" fill="#0B76FC" height="40px"><path d="M255 12c4-4 10-8 16-8s12 3 16 8l94 89c3 4 6 7 8 12 2 6 0 14-5 19-7 8-20 9-28 2l-7-7-57-60 2 54v276c0 12-10 22-22 22-12 1-24-10-23-22V110l1-43-60 65c-5 5-13 8-21 6a19 19 0 0 1-16-17c-1-7 2-13 7-18l95-91z" /><path d="M43 207c16-17 40-23 63-23h83v46h-79c-12 0-25 3-33 13-8 9-10 21-10 33v260c0 13 0 27 6 38 5 12 18 18 30 19l14 1h302c14 0 28 0 40-8 11-7 16-21 16-34V276c0-11-2-24-9-33-8-10-22-13-34-13h-78v-46h75c13 0 25 1 37 4 16 4 31 13 41 27 11 17 14 37 14 57v280c0 20-3 41-15 58a71 71 0 0 1-45 27c-11 2-23 3-34 3H109c-19-1-40-4-56-15-14-9-23-23-27-38-4-12-5-25-5-38V270c1-22 6-47 22-63z" /></svg>'}
|
|
2475
|
+
</td>
|
|
2476
|
+
<td>
|
|
2477
|
+
<p style="margin: 1rem 0">1) ${android ? "Open the dropdown menu" : 'Press the "Share" button'}</p>
|
|
2478
|
+
</td>
|
|
2479
|
+
</tr>
|
|
2480
|
+
<tr>
|
|
2481
|
+
<td style="width: 50px; text-align: center">
|
|
2482
|
+
${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="black" style="transform: scale(-1.5, 1.5)"><path d="M280-40q-33 0-56.5-23.5T200-120v-720q0-33 23.5-56.5T280-920h280v80H280v40h280v80H280v480h400v-80h80v200q0 33-23.5 56.5T680-40H280Zm0-120v40h400v-40H280Zm440-240L520-600l56-56 104 104v-288h80v288l104-104 56 56-200 200ZM280-800v-40 40Zm0 640v40-40Z"/></svg>' : '<svg viewBox="0 0 578 584" xmlns="http://www.w3.org/2000/svg" fill="black" height="34px"><path d="M101 35l19-1h333c12 0 23 0 35 3 17 3 34 12 44 27 13 16 16 38 16 58v329c0 19 0 39-8 57a65 65 0 0 1-37 37c-18 7-38 7-57 7H130c-21 1-44 0-63-10-14-7-25-20-30-34-6-15-8-30-8-45V121c1-21 5-44 19-61 13-16 33-23 53-25m7 46c-10 1-19 6-24 14-7 8-9 20-9 31v334c0 12 2 25 10 34 9 10 23 12 35 12h336c14 1 30-3 38-15 6-9 8-20 8-31V125c0-12-2-24-10-33-9-9-22-12-35-12H121l-13 1z" /><path d="M271 161c9-11 31-10 38 4 3 5 3 11 3 17v87h88c7 0 16 1 21 7 6 6 7 14 6 22a21 21 0 0 1-10 14c-5 4-11 5-17 5h-88v82c0 7-1 15-6 20-10 10-29 10-37-2-3-6-4-13-4-19v-81h-87c-8-1-17-3-23-9-5-6-6-15-4-22a21 21 0 0 1 11-14c6-3 13-3 19-3h84v-88c0-7 1-14 6-20z" /></svg>'}
|
|
2483
|
+
</td>
|
|
2484
|
+
<td>
|
|
2485
|
+
<p style="margin: 1rem 0">2) Press "Add to Home Screen"</p>
|
|
2486
|
+
</td>
|
|
2487
|
+
</tr>
|
|
2488
|
+
</table>
|
|
2489
|
+
</div>`;
|
|
2490
|
+
const close = document.createElement("button");
|
|
2491
|
+
close.classList.add("pwa-prompt-close");
|
|
2492
|
+
close.innerText = "x";
|
|
2493
|
+
close.onclick = () => {
|
|
2494
|
+
prompt.classList.add("exit");
|
|
2495
|
+
backdrop.classList.add("exit");
|
|
2496
|
+
localStorage.setItem(`${this.api.options.name}:pwa`, "dismissed");
|
|
2497
|
+
setTimeout(() => {
|
|
2498
|
+
prompt.remove();
|
|
2499
|
+
backdrop.remove();
|
|
2500
|
+
}, 500);
|
|
2501
|
+
};
|
|
2502
|
+
prompt.append(close);
|
|
2503
|
+
backdrop.append(prompt);
|
|
2504
|
+
document.body.append(backdrop);
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2324
2507
|
class Files {
|
|
2325
2508
|
constructor(api) {
|
|
2326
2509
|
this.api = api;
|
|
@@ -3245,7 +3428,7 @@ class Superuser {
|
|
|
3245
3428
|
} });
|
|
3246
3429
|
}
|
|
3247
3430
|
}
|
|
3248
|
-
const version = "1.1
|
|
3431
|
+
const version = "1.2.1";
|
|
3249
3432
|
class WebRtc {
|
|
3250
3433
|
constructor(api) {
|
|
3251
3434
|
__publicField(this, "ice");
|
|
@@ -3394,6 +3577,8 @@ const _Api = class _Api {
|
|
|
3394
3577
|
__publicField(this, "files");
|
|
3395
3578
|
/** PDF */
|
|
3396
3579
|
__publicField(this, "pdf");
|
|
3580
|
+
/** PWA setup & prompt */
|
|
3581
|
+
__publicField(this, "pwa");
|
|
3397
3582
|
/** Socket */
|
|
3398
3583
|
__publicField(this, "socket");
|
|
3399
3584
|
/** Superuser */
|
|
@@ -3442,9 +3627,11 @@ const _Api = class _Api {
|
|
|
3442
3627
|
this.auth = new Auth(this);
|
|
3443
3628
|
this.files = new Files(this);
|
|
3444
3629
|
this.pdf = new Pdf(this);
|
|
3630
|
+
this.pwa = new PWA(this);
|
|
3445
3631
|
this.superuser = new Superuser(this);
|
|
3446
3632
|
this.webrtc = new WebRtc(this);
|
|
3447
3633
|
if ((_a = this.options.offline) == null ? void 0 : _a.length) {
|
|
3634
|
+
this.pwa.setup();
|
|
3448
3635
|
if (typeof indexedDB == "undefined") throw new Error("Cannot enable offline support, indexedDB is not available in this environment");
|
|
3449
3636
|
this.database = new Database("datalynk", this.options.offline);
|
|
3450
3637
|
(_b = this.options.offline) == null ? void 0 : _b.forEach((id) => this.slice(id));
|
|
@@ -3452,17 +3639,6 @@ const _Api = class _Api {
|
|
|
3452
3639
|
navigator.serviceWorker.getRegistration(this.options.serviceWorker).then((reg) => reg ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
|
|
3453
3640
|
}
|
|
3454
3641
|
}
|
|
3455
|
-
if (!document.querySelector('link[rel="manifest"]')) {
|
|
3456
|
-
const link = document.createElement("link");
|
|
3457
|
-
link.setAttribute("rel", "manifest");
|
|
3458
|
-
link.setAttribute("href", `${this.url}/manifest?json=${encodeURI(JSON.stringify({
|
|
3459
|
-
name: this.options.name,
|
|
3460
|
-
short_name: this.options.name,
|
|
3461
|
-
start_url: location.origin + location.pathname,
|
|
3462
|
-
...this.options.manifest
|
|
3463
|
-
}))}`);
|
|
3464
|
-
document.head.append(link);
|
|
3465
|
-
}
|
|
3466
3642
|
}
|
|
3467
3643
|
/** Get session info from JWT payload */
|
|
3468
3644
|
get jwtPayload() {
|
|
@@ -3667,6 +3843,7 @@ exports.ApiCall = ApiCall;
|
|
|
3667
3843
|
exports.Auth = Auth;
|
|
3668
3844
|
exports.Files = Files;
|
|
3669
3845
|
exports.LoginPrompt = LoginPrompt;
|
|
3846
|
+
exports.PWA = PWA;
|
|
3670
3847
|
exports.Pdf = Pdf;
|
|
3671
3848
|
exports.Serializer = Serializer;
|
|
3672
3849
|
exports.Slice = Slice;
|
package/dist/index.mjs
CHANGED
|
@@ -1164,20 +1164,20 @@ var Subscription = function() {
|
|
|
1164
1164
|
}
|
|
1165
1165
|
}
|
|
1166
1166
|
};
|
|
1167
|
-
Subscription2.prototype._hasParent = function(
|
|
1167
|
+
Subscription2.prototype._hasParent = function(parent2) {
|
|
1168
1168
|
var _parentage = this._parentage;
|
|
1169
|
-
return _parentage ===
|
|
1169
|
+
return _parentage === parent2 || Array.isArray(_parentage) && _parentage.includes(parent2);
|
|
1170
1170
|
};
|
|
1171
|
-
Subscription2.prototype._addParent = function(
|
|
1171
|
+
Subscription2.prototype._addParent = function(parent2) {
|
|
1172
1172
|
var _parentage = this._parentage;
|
|
1173
|
-
this._parentage = Array.isArray(_parentage) ? (_parentage.push(
|
|
1173
|
+
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent2), _parentage) : _parentage ? [_parentage, parent2] : parent2;
|
|
1174
1174
|
};
|
|
1175
|
-
Subscription2.prototype._removeParent = function(
|
|
1175
|
+
Subscription2.prototype._removeParent = function(parent2) {
|
|
1176
1176
|
var _parentage = this._parentage;
|
|
1177
|
-
if (_parentage ===
|
|
1177
|
+
if (_parentage === parent2) {
|
|
1178
1178
|
this._parentage = null;
|
|
1179
1179
|
} else if (Array.isArray(_parentage)) {
|
|
1180
|
-
arrRemove(_parentage,
|
|
1180
|
+
arrRemove(_parentage, parent2);
|
|
1181
1181
|
}
|
|
1182
1182
|
};
|
|
1183
1183
|
Subscription2.prototype.remove = function(teardown) {
|
|
@@ -1817,6 +1817,8 @@ async function getTheme(spoke, scope) {
|
|
|
1817
1817
|
logo: `https://${spoke}.auxiliumgroup.com/static/js/auxilium/dijits/templates/login/${spoke}/logo.png`,
|
|
1818
1818
|
title: spoke.toUpperCase(),
|
|
1819
1819
|
textColor: "white",
|
|
1820
|
+
titleFontFamily: "'AR BLANCA', serif",
|
|
1821
|
+
titleFontUrl: "https://fonts.cdnfonts.com/css/ar-blanca",
|
|
1820
1822
|
...theme || {}
|
|
1821
1823
|
};
|
|
1822
1824
|
}
|
|
@@ -1903,7 +1905,7 @@ const _LoginPrompt = class _LoginPrompt {
|
|
|
1903
1905
|
/** Dynamically create CSS style */
|
|
1904
1906
|
__publicField(_LoginPrompt, "css", (options) => `
|
|
1905
1907
|
<style id="datalynk-login-styles">
|
|
1906
|
-
|
|
1908
|
+
${options.titleFontUrl ? `@import url('${options.titleFontUrl}');` : `@import url('https://fonts.cdnfonts.com/css/ar-blanca');`}
|
|
1907
1909
|
|
|
1908
1910
|
#datalynk-login {
|
|
1909
1911
|
--theme-background: ${options.backgroundColor ? options.backgroundColor : `url(${options.background})`};
|
|
@@ -1978,7 +1980,11 @@ __publicField(_LoginPrompt, "css", (options) => `
|
|
|
1978
1980
|
font-size: 32px;
|
|
1979
1981
|
margin-bottom: 2rem;
|
|
1980
1982
|
}
|
|
1981
|
-
|
|
1983
|
+
|
|
1984
|
+
#datalynk-login .login-title {
|
|
1985
|
+
font-family: ${options.titleFontFamily ? options.titleFontFamily : "'AR BLANCA', serif"};
|
|
1986
|
+
${options.titleTextShadow ? `text-shadow: ${options.titleTextShadow};` : ""}
|
|
1987
|
+
}
|
|
1982
1988
|
#datalynk-login .login-content {
|
|
1983
1989
|
display: flex;
|
|
1984
1990
|
flex-direction: column;
|
|
@@ -2319,6 +2325,183 @@ class Auth {
|
|
|
2319
2325
|
return this.api.request({ "$/auth/mobile/generate": { user: login, method: mode } });
|
|
2320
2326
|
}
|
|
2321
2327
|
}
|
|
2328
|
+
class PWA {
|
|
2329
|
+
constructor(api) {
|
|
2330
|
+
this.api = api;
|
|
2331
|
+
}
|
|
2332
|
+
get iframe() {
|
|
2333
|
+
return (parent == null ? void 0 : parent.location) != location;
|
|
2334
|
+
}
|
|
2335
|
+
get mobile() {
|
|
2336
|
+
return ["android", "ios"].includes(this.platform);
|
|
2337
|
+
}
|
|
2338
|
+
get platform() {
|
|
2339
|
+
const userAgent = navigator.userAgent || navigator.vendor;
|
|
2340
|
+
if (/windows/i.test(userAgent)) return "windows";
|
|
2341
|
+
else if (/android/i.test(userAgent)) return "android";
|
|
2342
|
+
else if (/iPad|iPhone|iPod/.test(userAgent)) return "ios";
|
|
2343
|
+
else if (/macintosh|mac os x/i.test(userAgent)) return "mac";
|
|
2344
|
+
else if (/linux/i.test(userAgent)) return "linux";
|
|
2345
|
+
else return "unknown";
|
|
2346
|
+
}
|
|
2347
|
+
get pwa() {
|
|
2348
|
+
return matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone) || document.referrer.includes("android-app://");
|
|
2349
|
+
}
|
|
2350
|
+
/** Setup the PWA */
|
|
2351
|
+
async setup(manifest = {}) {
|
|
2352
|
+
const meta = (key, name, value) => {
|
|
2353
|
+
const exists = document.querySelector(`meta[${key}="${name}"]`);
|
|
2354
|
+
if (value === void 0 || exists) return exists;
|
|
2355
|
+
const meta2 = document.createElement("meta");
|
|
2356
|
+
meta2.setAttribute(key, name);
|
|
2357
|
+
meta2.content = value;
|
|
2358
|
+
document.head.append(meta2);
|
|
2359
|
+
};
|
|
2360
|
+
meta("name", "mobile-web-app-capable", "yes");
|
|
2361
|
+
meta("name", "apple-mobile-web-app-status-bar-style", "default");
|
|
2362
|
+
meta("name", "apple-mobile-web-app-title", this.api.options.name);
|
|
2363
|
+
meta("name", "apple-touch-icon", `https://datalynk-client.scarborough.auxilium.world/logo.png`);
|
|
2364
|
+
meta("name", "apple-touch-startup-image", `https://datalynk-client.scarborough.auxilium.world/logo.png`);
|
|
2365
|
+
if (!document.querySelector('link[rel="manifest"]')) {
|
|
2366
|
+
const link = document.createElement("link");
|
|
2367
|
+
link.setAttribute("rel", "manifest");
|
|
2368
|
+
link.setAttribute("href", `${this.api.url}/manifest?json=${encodeURI(JSON.stringify({
|
|
2369
|
+
name: this.api.options.name,
|
|
2370
|
+
short_name: this.api.options.name,
|
|
2371
|
+
start_url: location.origin + location.pathname,
|
|
2372
|
+
...this.api.options.manifest,
|
|
2373
|
+
...manifest
|
|
2374
|
+
}))}`);
|
|
2375
|
+
document.head.append(link);
|
|
2376
|
+
}
|
|
2377
|
+
if (!this.iframe && !this.pwa && this.platform != "mac") setTimeout(() => {
|
|
2378
|
+
const dismissed = !!localStorage.getItem(`${this.api.options.name}:pwa`);
|
|
2379
|
+
if (!dismissed) this.prompt();
|
|
2380
|
+
}, 6e4);
|
|
2381
|
+
}
|
|
2382
|
+
/** Prompt user to install the app */
|
|
2383
|
+
async prompt(platform) {
|
|
2384
|
+
if (document.querySelector(".pwa-prompt")) return;
|
|
2385
|
+
this.api.url;
|
|
2386
|
+
const android = (platform || this.platform) == "android";
|
|
2387
|
+
let style = document.querySelector("style.pwa");
|
|
2388
|
+
if (!style) {
|
|
2389
|
+
style = document.createElement("style");
|
|
2390
|
+
style.innerHTML = `
|
|
2391
|
+
.pwa-prompt-backdrop {
|
|
2392
|
+
position: fixed;
|
|
2393
|
+
display: relative;
|
|
2394
|
+
left: 0;
|
|
2395
|
+
top: 0;
|
|
2396
|
+
right: 0;
|
|
2397
|
+
bottom: 0;
|
|
2398
|
+
background: rgba(0,0,0,.5);
|
|
2399
|
+
z-index: 9999;
|
|
2400
|
+
animation: fadeIn 0.5s ease-in-out forwards;
|
|
2401
|
+
opacity: 0;
|
|
2402
|
+
}
|
|
2403
|
+
.pwa-prompt-backdrop.exit {
|
|
2404
|
+
animation: fadeOut 0.5s ease-in-out forwards !important;
|
|
2405
|
+
}
|
|
2406
|
+
.pwa-prompt {
|
|
2407
|
+
position: fixed;
|
|
2408
|
+
background: #fff;
|
|
2409
|
+
color: black;
|
|
2410
|
+
bottom: 0;
|
|
2411
|
+
left: 50%;
|
|
2412
|
+
width: min(100vw, 450px);
|
|
2413
|
+
transform: translate(-50%, 0);
|
|
2414
|
+
animation: slideUp 0.5s ease-in-out forwards;
|
|
2415
|
+
}
|
|
2416
|
+
.pwa-prompt.exit {
|
|
2417
|
+
animation: slideDown 0.5s ease-in-out forwards !important;
|
|
2418
|
+
}
|
|
2419
|
+
.pwa-prompt img {
|
|
2420
|
+
width: 18px;
|
|
2421
|
+
height: 18px;
|
|
2422
|
+
}
|
|
2423
|
+
.pwa-prompt h1 {
|
|
2424
|
+
font-size: 1.25rem;
|
|
2425
|
+
font-weight: bold;
|
|
2426
|
+
}
|
|
2427
|
+
.pwa-prompt-close {
|
|
2428
|
+
position: absolute;
|
|
2429
|
+
right: 5px;
|
|
2430
|
+
top: 10px;
|
|
2431
|
+
background: transparent;
|
|
2432
|
+
border: none;
|
|
2433
|
+
cursor: pointer;
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
@keyframes fadeIn {
|
|
2437
|
+
from { opacity: 0; }
|
|
2438
|
+
to { opacity: 1; }
|
|
2439
|
+
}
|
|
2440
|
+
@keyframes fadeOut {
|
|
2441
|
+
from { opacity: 1; }
|
|
2442
|
+
to { opacity: 0; }
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
@keyframes slideUp {
|
|
2446
|
+
from { transform: translate(-50%, 100%); }
|
|
2447
|
+
to { transform: translate(-50%, 0); }
|
|
2448
|
+
}
|
|
2449
|
+
@keyframes slideDown {
|
|
2450
|
+
from { transform: translate(-50%, 0); }
|
|
2451
|
+
to { transform: translate(-50%, 100%); }
|
|
2452
|
+
}
|
|
2453
|
+
`;
|
|
2454
|
+
document.head.append(style);
|
|
2455
|
+
}
|
|
2456
|
+
const backdrop = document.createElement("div");
|
|
2457
|
+
backdrop.classList.add("pwa-prompt-backdrop");
|
|
2458
|
+
const prompt = document.createElement("div");
|
|
2459
|
+
prompt.classList.add("pwa-prompt");
|
|
2460
|
+
prompt.innerHTML = `
|
|
2461
|
+
<div style="display: flex; padding: 1rem; align-items: center">
|
|
2462
|
+
<img src="https://datalynk-client.scarborough.auxilium.world/logo.png" alt="Logo" style="height: 40px; width: auto; margin-right: .5rem;" />
|
|
2463
|
+
<h1 style="margin: 0">Install ${this.api.options.name}</h1>
|
|
2464
|
+
</div>
|
|
2465
|
+
<div style="display: flex; flex-direction: column; align-items: center">
|
|
2466
|
+
<div style="border-top: 2px solid #00000020; border-bottom: 2px solid #00000020; padding: 0 1rem">
|
|
2467
|
+
<p style="margin-top: 1rem; text-align: center">This website can be installed as an App! Add it to your home screen for quick access & fullscreen use.</p>
|
|
2468
|
+
</div>
|
|
2469
|
+
<table style="margin: 1.5rem 0">
|
|
2470
|
+
<tr>
|
|
2471
|
+
<td style="width: 50px; text-align: center">
|
|
2472
|
+
${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="black" style="transform: scale(1.5)"><path d="M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"/></svg>' : '<svg viewBox="0 0 566 670" xmlns="http://www.w3.org/2000/svg" fill="#0B76FC" height="40px"><path d="M255 12c4-4 10-8 16-8s12 3 16 8l94 89c3 4 6 7 8 12 2 6 0 14-5 19-7 8-20 9-28 2l-7-7-57-60 2 54v276c0 12-10 22-22 22-12 1-24-10-23-22V110l1-43-60 65c-5 5-13 8-21 6a19 19 0 0 1-16-17c-1-7 2-13 7-18l95-91z" /><path d="M43 207c16-17 40-23 63-23h83v46h-79c-12 0-25 3-33 13-8 9-10 21-10 33v260c0 13 0 27 6 38 5 12 18 18 30 19l14 1h302c14 0 28 0 40-8 11-7 16-21 16-34V276c0-11-2-24-9-33-8-10-22-13-34-13h-78v-46h75c13 0 25 1 37 4 16 4 31 13 41 27 11 17 14 37 14 57v280c0 20-3 41-15 58a71 71 0 0 1-45 27c-11 2-23 3-34 3H109c-19-1-40-4-56-15-14-9-23-23-27-38-4-12-5-25-5-38V270c1-22 6-47 22-63z" /></svg>'}
|
|
2473
|
+
</td>
|
|
2474
|
+
<td>
|
|
2475
|
+
<p style="margin: 1rem 0">1) ${android ? "Open the dropdown menu" : 'Press the "Share" button'}</p>
|
|
2476
|
+
</td>
|
|
2477
|
+
</tr>
|
|
2478
|
+
<tr>
|
|
2479
|
+
<td style="width: 50px; text-align: center">
|
|
2480
|
+
${android ? '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="black" style="transform: scale(-1.5, 1.5)"><path d="M280-40q-33 0-56.5-23.5T200-120v-720q0-33 23.5-56.5T280-920h280v80H280v40h280v80H280v480h400v-80h80v200q0 33-23.5 56.5T680-40H280Zm0-120v40h400v-40H280Zm440-240L520-600l56-56 104 104v-288h80v288l104-104 56 56-200 200ZM280-800v-40 40Zm0 640v40-40Z"/></svg>' : '<svg viewBox="0 0 578 584" xmlns="http://www.w3.org/2000/svg" fill="black" height="34px"><path d="M101 35l19-1h333c12 0 23 0 35 3 17 3 34 12 44 27 13 16 16 38 16 58v329c0 19 0 39-8 57a65 65 0 0 1-37 37c-18 7-38 7-57 7H130c-21 1-44 0-63-10-14-7-25-20-30-34-6-15-8-30-8-45V121c1-21 5-44 19-61 13-16 33-23 53-25m7 46c-10 1-19 6-24 14-7 8-9 20-9 31v334c0 12 2 25 10 34 9 10 23 12 35 12h336c14 1 30-3 38-15 6-9 8-20 8-31V125c0-12-2-24-10-33-9-9-22-12-35-12H121l-13 1z" /><path d="M271 161c9-11 31-10 38 4 3 5 3 11 3 17v87h88c7 0 16 1 21 7 6 6 7 14 6 22a21 21 0 0 1-10 14c-5 4-11 5-17 5h-88v82c0 7-1 15-6 20-10 10-29 10-37-2-3-6-4-13-4-19v-81h-87c-8-1-17-3-23-9-5-6-6-15-4-22a21 21 0 0 1 11-14c6-3 13-3 19-3h84v-88c0-7 1-14 6-20z" /></svg>'}
|
|
2481
|
+
</td>
|
|
2482
|
+
<td>
|
|
2483
|
+
<p style="margin: 1rem 0">2) Press "Add to Home Screen"</p>
|
|
2484
|
+
</td>
|
|
2485
|
+
</tr>
|
|
2486
|
+
</table>
|
|
2487
|
+
</div>`;
|
|
2488
|
+
const close = document.createElement("button");
|
|
2489
|
+
close.classList.add("pwa-prompt-close");
|
|
2490
|
+
close.innerText = "x";
|
|
2491
|
+
close.onclick = () => {
|
|
2492
|
+
prompt.classList.add("exit");
|
|
2493
|
+
backdrop.classList.add("exit");
|
|
2494
|
+
localStorage.setItem(`${this.api.options.name}:pwa`, "dismissed");
|
|
2495
|
+
setTimeout(() => {
|
|
2496
|
+
prompt.remove();
|
|
2497
|
+
backdrop.remove();
|
|
2498
|
+
}, 500);
|
|
2499
|
+
};
|
|
2500
|
+
prompt.append(close);
|
|
2501
|
+
backdrop.append(prompt);
|
|
2502
|
+
document.body.append(backdrop);
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2322
2505
|
class Files {
|
|
2323
2506
|
constructor(api) {
|
|
2324
2507
|
this.api = api;
|
|
@@ -3243,7 +3426,7 @@ class Superuser {
|
|
|
3243
3426
|
} });
|
|
3244
3427
|
}
|
|
3245
3428
|
}
|
|
3246
|
-
const version = "1.1
|
|
3429
|
+
const version = "1.2.1";
|
|
3247
3430
|
class WebRtc {
|
|
3248
3431
|
constructor(api) {
|
|
3249
3432
|
__publicField(this, "ice");
|
|
@@ -3392,6 +3575,8 @@ const _Api = class _Api {
|
|
|
3392
3575
|
__publicField(this, "files");
|
|
3393
3576
|
/** PDF */
|
|
3394
3577
|
__publicField(this, "pdf");
|
|
3578
|
+
/** PWA setup & prompt */
|
|
3579
|
+
__publicField(this, "pwa");
|
|
3395
3580
|
/** Socket */
|
|
3396
3581
|
__publicField(this, "socket");
|
|
3397
3582
|
/** Superuser */
|
|
@@ -3440,9 +3625,11 @@ const _Api = class _Api {
|
|
|
3440
3625
|
this.auth = new Auth(this);
|
|
3441
3626
|
this.files = new Files(this);
|
|
3442
3627
|
this.pdf = new Pdf(this);
|
|
3628
|
+
this.pwa = new PWA(this);
|
|
3443
3629
|
this.superuser = new Superuser(this);
|
|
3444
3630
|
this.webrtc = new WebRtc(this);
|
|
3445
3631
|
if ((_a = this.options.offline) == null ? void 0 : _a.length) {
|
|
3632
|
+
this.pwa.setup();
|
|
3446
3633
|
if (typeof indexedDB == "undefined") throw new Error("Cannot enable offline support, indexedDB is not available in this environment");
|
|
3447
3634
|
this.database = new Database("datalynk", this.options.offline);
|
|
3448
3635
|
(_b = this.options.offline) == null ? void 0 : _b.forEach((id) => this.slice(id));
|
|
@@ -3450,17 +3637,6 @@ const _Api = class _Api {
|
|
|
3450
3637
|
navigator.serviceWorker.getRegistration(this.options.serviceWorker).then((reg) => reg ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
|
|
3451
3638
|
}
|
|
3452
3639
|
}
|
|
3453
|
-
if (!document.querySelector('link[rel="manifest"]')) {
|
|
3454
|
-
const link = document.createElement("link");
|
|
3455
|
-
link.setAttribute("rel", "manifest");
|
|
3456
|
-
link.setAttribute("href", `${this.url}/manifest?json=${encodeURI(JSON.stringify({
|
|
3457
|
-
name: this.options.name,
|
|
3458
|
-
short_name: this.options.name,
|
|
3459
|
-
start_url: location.origin + location.pathname,
|
|
3460
|
-
...this.options.manifest
|
|
3461
|
-
}))}`);
|
|
3462
|
-
document.head.append(link);
|
|
3463
|
-
}
|
|
3464
3640
|
}
|
|
3465
3641
|
/** Get session info from JWT payload */
|
|
3466
3642
|
get jwtPayload() {
|
|
@@ -3666,6 +3842,7 @@ export {
|
|
|
3666
3842
|
Auth,
|
|
3667
3843
|
Files,
|
|
3668
3844
|
LoginPrompt,
|
|
3845
|
+
PWA,
|
|
3669
3846
|
Pdf,
|
|
3670
3847
|
Serializer,
|
|
3671
3848
|
Slice,
|
package/dist/login-prompt.d.ts
CHANGED
|
@@ -24,6 +24,12 @@ export type LoginPromptOptions = {
|
|
|
24
24
|
title?: string;
|
|
25
25
|
/** Color of headers & links */
|
|
26
26
|
textColor?: string;
|
|
27
|
+
/** Custom font for title */
|
|
28
|
+
titleFontFamily?: string;
|
|
29
|
+
/** Import URL for custom font */
|
|
30
|
+
titleFontUrl?: string;
|
|
31
|
+
/** Text shadow for the title */
|
|
32
|
+
titleTextShadow?: string;
|
|
27
33
|
};
|
|
28
34
|
/** Create a login prompt */
|
|
29
35
|
export declare class LoginPrompt {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-prompt.d.ts","sourceRoot":"","sources":["../src/login-prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAG1B,uCAAuC;AACvC,MAAM,MAAM,kBAAkB,GAAG;IAChC,+BAA+B;IAC/B,QAAQ,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;IACzC,2BAA2B;IAC3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IACzB,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gCAAgC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB,CAAA;AAED,4BAA4B;AAC5B,qBAAa,WAAW;IA2OX,OAAO,CAAC,QAAQ,CAAC,GAAG;aAAuB,KAAK,EAAE,MAAM;IAAS,OAAO,EAAE,kBAAkB;IA1OxG,mCAAmC;IACnC,OAAO,CAAC,MAAM,CAAC,GAAG,CAkKR;IAEV,8BAA8B;IAC9B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAuDrB;IAEF,OAAO,CAAC,KAAK,CAAO;IACpB,OAAO,CAAC,MAAM,CAAO;IACrB,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,QAAQ,CAAO;IACvB,OAAO,CAAC,OAAO,CAAO;IACtB,OAAO,CAAC,QAAQ,CAAO;IAEvB,OAAO,CAAC,KAAK,CAAY;IACzB,oDAAoD;IACpD,IAAI,gBAAmD;gBAE1B,GAAG,EAAE,GAAG,EAAkB,KAAK,EAAE,MAAM,EAAS,OAAO,GAAE,kBAAuB;YAI/F,MAAM;YAkBN,aAAa;IAS3B,6BAA6B;IAC7B,KAAK;IAKL,0CAA0C;IAC1C,MAAM;IAIN,8BAA8B;IAC9B,KAAK,CAAC,KAAK,EAAE,GAAG;CA4BhB"}
|
package/dist/pwa.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Api } from './api';
|
|
2
|
+
export declare class PWA {
|
|
3
|
+
private readonly api;
|
|
4
|
+
get iframe(): boolean;
|
|
5
|
+
get mobile(): boolean;
|
|
6
|
+
get platform(): 'android' | 'ios' | 'mac' | 'windows' | 'linux' | 'unknown';
|
|
7
|
+
get pwa(): boolean;
|
|
8
|
+
constructor(api: Api);
|
|
9
|
+
/** Setup the PWA */
|
|
10
|
+
setup(manifest?: any): Promise<void>;
|
|
11
|
+
/** Prompt user to install the app */
|
|
12
|
+
prompt(platform?: 'android' | 'ios'): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=pwa.d.ts.map
|
|
@@ -0,0 +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;IAoBH,OAAO,CAAC,QAAQ,CAAC,GAAG;IAlBhC,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,GAAG,IAAI,OAAO,CAEjB;gBAE4B,GAAG,EAAE,GAAG;IAErC,oBAAoB;IACd,KAAK,CAAC,QAAQ,GAAE,GAAQ;IAsC9B,qCAAqC;IAC/B,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;CAiIzC"}
|
package/dist/themes.d.ts
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
export interface Theme {
|
|
2
|
+
/** Add links to top of page */
|
|
3
|
+
addLinks?: {
|
|
4
|
+
text: string;
|
|
5
|
+
url: string;
|
|
6
|
+
}[];
|
|
2
7
|
/** Background image URL */
|
|
3
8
|
background?: string;
|
|
4
9
|
/** Background color as hex (overrides background image) */
|
|
5
10
|
backgroundColor?: string;
|
|
6
11
|
/** Primary color as hex: `#000000` */
|
|
7
12
|
color?: string;
|
|
13
|
+
/** Change glow color, defaults to color or set to falsy to disable */
|
|
14
|
+
glow?: string;
|
|
15
|
+
/** Hide app links */
|
|
16
|
+
hideApps?: boolean;
|
|
8
17
|
/** Logo URL */
|
|
9
18
|
logo?: string;
|
|
19
|
+
/** Allow users to stay logged in */
|
|
20
|
+
persist?: boolean;
|
|
10
21
|
/** Header string or HTML: <img alt="logo" src="...">*/
|
|
11
22
|
title?: string;
|
|
12
23
|
/** Color of headers & links */
|
|
13
24
|
textColor?: string;
|
|
25
|
+
/** Custom font for title */
|
|
26
|
+
titleFontFamily?: string;
|
|
27
|
+
/** Import URL for custom font */
|
|
28
|
+
titleFontUrl?: string;
|
|
29
|
+
/** Text shadow for the title */
|
|
30
|
+
titleTextShadow?: string;
|
|
14
31
|
}
|
|
15
32
|
/**
|
|
16
33
|
* Get the theme for a spoke
|
|
17
34
|
* @param {string} spoke Name of spoke
|
|
18
35
|
* @param {string} scope Apply sub-theme
|
|
19
|
-
* @returns {Promise<Theme>}
|
|
36
|
+
* @returns {Promise<Theme & {found: boolean}>}
|
|
20
37
|
*/
|
|
21
38
|
export declare function getTheme(spoke: string, scope?: string): Promise<Theme & {
|
|
22
39
|
found: boolean;
|
package/dist/themes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../src/themes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACrB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../src/themes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACrB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC3C,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gCAAgC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG;IAAC,KAAK,EAAE,OAAO,CAAA;CAAC,CAAC,CAe/F"}
|
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.1
|
|
5
|
+
"version": "1.2.1",
|
|
6
6
|
"author": "Zak Timson <zaktimson@gmail.com>",
|
|
7
7
|
"private": false,
|
|
8
8
|
"main": "./dist/index.cjs",
|