@auxilium/datalynk-client 1.3.3 → 1.3.4

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/index.mjs CHANGED
@@ -2305,6 +2305,9 @@ class PWA {
2305
2305
  this.api = api;
2306
2306
  }
2307
2307
  // Holds the beforeinstallprompt event
2308
+ get headless() {
2309
+ return typeof window == "undefined";
2310
+ }
2308
2311
  get iframe() {
2309
2312
  return (parent == null ? void 0 : parent.location) != location;
2310
2313
  }
@@ -2388,7 +2391,7 @@ class PWA {
2388
2391
  link.href = `${base}/manifest?json=${encodeURIComponent(JSON.stringify(manifestObj))}`;
2389
2392
  document.head.append(link);
2390
2393
  }
2391
- if (!this.iframe && !this.pwa && this.platform != "mac") setTimeout(() => {
2394
+ if (!this.headless && !this.iframe && !this.pwa && this.platform != "mac") setTimeout(() => {
2392
2395
  const dismissedDate = localStorage.getItem(`${this.api.options.name}:pwa`);
2393
2396
  if (settings.dismissExpiry > 0 && dismissedDate) {
2394
2397
  const diffDays = (Date.now() - new Date(dismissedDate).getTime()) / (1e3 * 60 * 60 * 24);
@@ -3450,7 +3453,7 @@ class Superuser {
3450
3453
  } });
3451
3454
  }
3452
3455
  }
3453
- const version = "1.3.3";
3456
+ const version = "1.3.4";
3454
3457
  class WebRtc {
3455
3458
  constructor(api) {
3456
3459
  __publicField(this, "ice");
@@ -3638,7 +3641,7 @@ const _Api = class _Api {
3638
3641
  }
3639
3642
  };
3640
3643
  if (this.options.saveSession) {
3641
- if (localStorage == void 0) return;
3644
+ if (typeof localStorage == "undefined") return;
3642
3645
  this.token = localStorage.getItem(this.localStorageKey) || null;
3643
3646
  this.token$.pipe(distinctUntilChanged()).subscribe((token) => {
3644
3647
  if (token) localStorage.setItem(this.localStorageKey, token);
@@ -3658,7 +3661,21 @@ const _Api = class _Api {
3658
3661
  this.database = new Database("datalynk", this.options.offline);
3659
3662
  (_b = this.options.offline) == null ? void 0 : _b.forEach((id) => this.slice(id));
3660
3663
  if (this.options.serviceWorker && typeof navigator["serviceWorker"] != "undefined") {
3661
- navigator.serviceWorker.getRegistration(this.options.serviceWorker).then((reg) => reg ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
3664
+ (async () => {
3665
+ const init = () => {
3666
+ var _a2;
3667
+ (_a2 = navigator.serviceWorker.controller) == null ? void 0 : _a2.postMessage({ options: { ...this.options, url: this.url } });
3668
+ this.token$.subscribe((token) => {
3669
+ var _a3;
3670
+ return (_a3 = navigator.serviceWorker.controller) == null ? void 0 : _a3.postMessage({ token });
3671
+ });
3672
+ };
3673
+ await navigator.serviceWorker.getRegistration(this.options.serviceWorker).then((reg) => reg ?? navigator.serviceWorker.register(this.options.serviceWorker, { scope: "/", type: "module" }));
3674
+ navigator.serviceWorker.ready.then(() => {
3675
+ if (navigator.serviceWorker.controller) navigator.serviceWorker.ready.then(() => init());
3676
+ else navigator.serviceWorker.addEventListener("controllerchange", () => init(), { once: true });
3677
+ });
3678
+ })();
3662
3679
  }
3663
3680
  }
3664
3681
  }
package/dist/pwa.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Api } from './api';
2
2
  export declare class PWA {
3
3
  private readonly api;
4
4
  deferredPrompt: any;
5
+ get headless(): boolean;
5
6
  get iframe(): boolean;
6
7
  get mobile(): boolean;
7
8
  get platform(): 'android' | 'ios' | 'mac' | 'windows' | 'linux' | 'unknown';
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;IAqBH,OAAO,CAAC,QAAQ,CAAC,GAAG;IApBzB,cAAc,EAAE,GAAG,CAAQ;IAElC,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,OAAO,CAAC,iBAAiB;IAezB,oBAAoB;IACd,KAAK,CAAC,QAAQ,GAAE,GAAQ;IAmE9B,qCAAqC;IAC/B,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;CAgJzC"}
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;IAuBH,OAAO,CAAC,QAAQ,CAAC,GAAG;IAtBzB,cAAc,EAAE,GAAG,CAAQ;IAElC,IAAI,QAAQ,IAAI,OAAO,CAAwC;IAE/D,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,OAAO,CAAC,iBAAiB;IAezB,oBAAoB;IACd,KAAK,CAAC,QAAQ,GAAE,GAAQ;IAmE9B,qCAAqC;IAC/B,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;CAgJzC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=service.worker.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.worker.d.mts","sourceRoot":"","sources":["../src/service.worker.mjs"],"names":[],"mappings":""}
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.3",
5
+ "version": "1.3.4",
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
7
7
  "private": false,
8
8
  "main": "./dist/index.cjs",