@ztimson/momentum 0.50.7 → 0.51.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,gBAAgB,EAAM,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,CAAC;AAEnF,qBAAa,MAAO,SAAQ,gBAAgB;IAqC/B,OAAO,CAAC,GAAG;IAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAnCvD,IAAI,MAAM,YAAyD;IAEnE,OAAO,CAAC,cAAc,CAAS;IAC/B,IAAI,aAAa,IACkB,OAAO,CADS;IACnD,OAAO,KAAK,aAAa,QAGxB;IAED,OAAO,CAAC,SAAS,CAAC,CAAW;IAC7B,IAAI,QAAQ,IAAI,QAAQ,CAWvB;IAED,IAAI,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAGvD;IAED,OAAO,CAAC,IAAI,CAAC,CAAU;IACvB,IAAI,GAAG,IAAI,OAAO,CAIjB;gBAEmB,GAAG,EAAE,GAAG,EAAmB,QAAQ,EAAE,QAAQ;IAK3D,MAAM,CAAC,MAAM,UAAQ,EAAE,SAAS,UAAO;IAiF7C,SAAS,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;IAoIhC,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAa7C,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;CAO3C"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,gBAAgB,EAAM,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,CAAC;AAEnF,qBAAa,MAAO,SAAQ,gBAAgB;IAqC/B,OAAO,CAAC,GAAG;IAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAnCvD,IAAI,MAAM,YAAyD;IAEnE,OAAO,CAAC,cAAc,CAAS;IAC/B,IAAI,aAAa,IACkB,OAAO,CADS;IACnD,OAAO,KAAK,aAAa,QAGxB;IAED,OAAO,CAAC,SAAS,CAAC,CAAW;IAC7B,IAAI,QAAQ,IAAI,QAAQ,CAWvB;IAED,IAAI,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAGvD;IAED,OAAO,CAAC,IAAI,CAAC,CAAU;IACvB,IAAI,GAAG,IAAI,OAAO,CAIjB;gBAEmB,GAAG,EAAE,GAAG,EAAmB,QAAQ,EAAE,QAAQ;IAK3D,MAAM,CAAC,MAAM,UAAQ,EAAE,SAAS,UAAO;IAqH7C,SAAS,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;IAoIhC,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAa7C,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;CAO3C"}
package/dist/index.cjs CHANGED
@@ -1350,11 +1350,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1350
1350
  get pushSubscription() {
1351
1351
  var _a;
1352
1352
  if (!((_a = navigator.serviceWorker) == null ? void 0 : _a.controller)) return Promise.resolve(null);
1353
- return navigator.serviceWorker.ready.then((sw) => sw.pushManager.getSubscription());
1353
+ return navigator.serviceWorker.ready.then((sw) => {
1354
+ var _a2;
1355
+ return (_a2 = sw == null ? void 0 : sw.pushManager) == null ? void 0 : _a2.getSubscription();
1356
+ });
1354
1357
  }
1355
1358
  get pwa() {
1356
1359
  if (this._pwa == null)
1357
- this._pwa = window.matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone) || document.referrer.includes("android-app://");
1360
+ this._pwa = matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone) || document.referrer.includes("android-app://");
1358
1361
  return this._pwa;
1359
1362
  }
1360
1363
  async inject(reload = false, firstLoad = true) {
@@ -1362,6 +1365,50 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1362
1365
  let settings = this.settings.cache;
1363
1366
  if (firstLoad) this.settings.all(false, reload).then(() => this.inject(false, false)).catch(() => {
1364
1367
  });
1368
+ if (settings["title"] && !document.head.querySelector('meta[property="og:title"]')) {
1369
+ const meta = document.createElement("meta");
1370
+ meta.setAttribute("property", "og:title");
1371
+ meta.content = settings["title"];
1372
+ document.head.append(meta);
1373
+ }
1374
+ if (!document.querySelector('meta[property="og:type"]')) {
1375
+ const meta = document.createElement("meta");
1376
+ meta.setAttribute("property", "og:type");
1377
+ meta.content = "article";
1378
+ document.head.append(meta);
1379
+ }
1380
+ if (settings["public_url"] && !document.querySelector('meta[property="og:url"]')) {
1381
+ const meta = document.createElement("meta");
1382
+ meta.setAttribute("property", "og:url");
1383
+ meta.content = settings["public_url"];
1384
+ document.head.append(meta);
1385
+ }
1386
+ if (settings["description"]) {
1387
+ if (!document.querySelector('meta[property="og:description"]')) {
1388
+ const meta = document.createElement("meta");
1389
+ meta.setAttribute("property", "og:description");
1390
+ meta.content = settings["description"];
1391
+ document.head.append(meta);
1392
+ }
1393
+ if (!document.querySelector('meta[property="description"]')) {
1394
+ const meta = document.createElement("meta");
1395
+ meta.setAttribute("property", "description");
1396
+ meta.content = settings["description"];
1397
+ document.head.append(meta);
1398
+ }
1399
+ if (!document.querySelector('meta[property="twitter:card"]')) {
1400
+ const meta = document.createElement("meta");
1401
+ meta.setAttribute("property", "twitter:card");
1402
+ meta.content = settings["description"];
1403
+ document.head.append(meta);
1404
+ }
1405
+ }
1406
+ if (settings["public_url"] && !document.querySelector('meta[property="og:image"]')) {
1407
+ const meta = document.createElement("meta");
1408
+ meta.setAttribute("property", "og:image");
1409
+ meta.content = settings["public_url"] + "/favicon.ico";
1410
+ document.head.append(meta);
1411
+ }
1365
1412
  if (!document.querySelector('meta[name="mobile-web-app-capable"]')) {
1366
1413
  const meta = document.createElement("meta");
1367
1414
  meta.name = "mobile-web-app-capable";
@@ -1374,46 +1421,41 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1374
1421
  meta.content = "default";
1375
1422
  document.head.append(meta);
1376
1423
  }
1377
- if (!document.querySelector('meta[name="apple-mobile-web-app-title"]')) {
1424
+ if (settings["title"] && !document.querySelector('meta[name="apple-mobile-web-app-title"]')) {
1378
1425
  const meta = document.createElement("meta");
1379
1426
  meta.name = "apple-mobile-web-app-title";
1380
1427
  meta.content = settings["title"];
1381
1428
  document.head.append(meta);
1382
1429
  }
1383
- if (!document.querySelector('link[rel="apple-touch-icon"]')) {
1430
+ if (settings["public_url"] && !document.querySelector('link[rel="apple-touch-icon"]')) {
1384
1431
  const meta = document.createElement("link");
1385
1432
  meta.rel = "apple-touch-icon";
1386
- meta.href = settings["logo"];
1433
+ meta.href = settings["public_url"] + "/favicon.ico";
1387
1434
  document.head.append(meta);
1388
1435
  }
1389
- if (!document.querySelector('link[rel="apple-touch-startup-image"]')) {
1436
+ if (settings["public_url"] && !document.querySelector('link[rel="apple-touch-startup-image"]')) {
1390
1437
  const meta = document.createElement("link");
1391
1438
  meta.rel = "apple-touch-startup-image";
1392
- meta.href = settings["logo"];
1439
+ meta.href = settings["public_url"] + "/favicon.ico";
1393
1440
  document.head.append(meta);
1394
1441
  }
1395
- window.document.body.classList.add(((_a = settings["theme"]) == null ? void 0 : _a.darkMode) ? "theme-dark" : "theme-light");
1396
- window.document.body.classList.remove(((_b = settings["theme"]) == null ? void 0 : _b.darkMode) ? "theme-light" : "theme-dark");
1397
- if (settings["title"])
1398
- window.document.querySelectorAll(".momentum-title").forEach((el) => el.innerText = settings["title"]);
1399
- if (settings["description"])
1400
- window.document.querySelectorAll(".momentum-description").forEach((el) => el.innerText = settings["description"]);
1401
- if (settings.version)
1402
- window.document.querySelectorAll(".momentum-version").forEach((el) => el.innerText = settings["version"]);
1403
- if (settings["logo"]) {
1404
- window.document.querySelectorAll(".momentum-logo").forEach((el) => el.src = settings["logo"]);
1405
- }
1442
+ if (settings["title"]) document.querySelectorAll(".momentum-title").forEach((el) => el.innerText = settings["title"]);
1443
+ if (settings["description"]) document.querySelectorAll(".momentum-description").forEach((el) => el.innerText = settings["description"]);
1444
+ if (settings["version"]) document.querySelectorAll(".momentum-version").forEach((el) => el.innerText = settings["version"]);
1445
+ if (settings["logo"]) document.querySelectorAll(".momentum-logo").forEach((el) => el.src = settings["logo"]);
1406
1446
  if (settings["theme"]) {
1447
+ document.body.classList.add(((_a = settings["theme"]) == null ? void 0 : _a.darkMode) ? "theme-dark" : "theme-light");
1448
+ document.body.classList.remove(((_b = settings["theme"]) == null ? void 0 : _b.darkMode) ? "theme-light" : "theme-dark");
1407
1449
  document.body.style.setProperty("--theme-backdrop", (_c = settings["theme"]) == null ? void 0 : _c.background);
1408
1450
  document.body.style.setProperty("--theme-primary", (_d = settings["theme"]) == null ? void 0 : _d.primary);
1409
1451
  document.body.style.setProperty("--theme-accent", (_e = settings["theme"]) == null ? void 0 : _e.accent);
1410
1452
  document.body.style.setProperty("--theme-contrast", blackOrWhite((_f = settings["theme"]) == null ? void 0 : _f.background));
1411
1453
  }
1412
1454
  if (settings["pwa"]) {
1413
- const link = window.document.createElement("link");
1455
+ const link = document.createElement("link");
1414
1456
  link.setAttribute("rel", "manifest");
1415
1457
  link.setAttribute("href", this.settings.api.url + "/manifest.json");
1416
- window.document.head.append(link);
1458
+ document.head.append(link);
1417
1459
  setTimeout(() => {
1418
1460
  const dismissed = !!localStorage.getItem("momentum:install-prompt");
1419
1461
  if (!dismissed && !this.pwa && this.mobile) this.pwaPrompt();
@@ -1986,60 +2028,61 @@ ${log}`;
1986
2028
  __publicField(_Socket, "pollingSpeed", 3e4);
1987
2029
  let Socket = _Socket;
1988
2030
  let Storage$1 = class Storage extends PathEventEmitter {
1989
- constructor(api) {
2031
+ constructor(api, path = "storage") {
1990
2032
  super();
1991
2033
  __publicField(this, "api");
2034
+ this.path = path;
1992
2035
  this.api = typeof api == "string" ? new Api(api) : api;
1993
2036
  }
1994
2037
  copy(source, destination) {
1995
2038
  if (!source || !destination) throw new Error("Cannot copy file or folder, missing source or destination");
1996
- return this.api.request({ url: "/api/" + PES`storage/${destination}`, body: { from: source } }).then((response) => {
1997
- this.emit(PES`storage/${destination}:c`, response);
2039
+ return this.api.request({ url: "/api/" + PES`${this.path}/${destination}`, body: { from: source } }).then((response) => {
2040
+ this.emit(PES`${this.path}/${destination}:c`, response);
1998
2041
  return response;
1999
2042
  });
2000
2043
  }
2001
2044
  delete(path) {
2002
2045
  if (!path) throw new Error("Cannot delete file or folder, missing path");
2003
- return this.api.request({ url: "/api/" + PES`storage/${path}`, method: "DELETE" }).then(() => {
2004
- this.emit(PES`storage/${path}:d`, path);
2046
+ return this.api.request({ url: "/api/" + PES`${this.path}/${path}`, method: "DELETE" }).then(() => {
2047
+ this.emit(PES`${this.path}/${path}:d`, path);
2005
2048
  });
2006
2049
  }
2007
2050
  download(path, opts = {}) {
2008
2051
  if (!path) throw new Error("Cannot download file, missing path");
2009
- return this.api.request({ ...opts, url: "/api/" + PES`storage/${path}`, decode: false }).then(async (response) => {
2052
+ return this.api.request({ ...opts, url: "/api/" + PES`${this.path}/${path}`, decode: false }).then(async (response) => {
2010
2053
  const blob = await response.blob();
2011
2054
  const name = opts.downloadAs || path.split("/").pop();
2012
- this.emit(PES`storage/${path}:r`, blob);
2055
+ this.emit(PES`${this.path}/${path}:r`, blob);
2013
2056
  downloadFile(blob, name);
2014
2057
  return response;
2015
2058
  });
2016
2059
  }
2017
2060
  list(path) {
2018
2061
  if (!path) path = "/";
2019
- return this.api.request({ url: "/api/" + PES`storage/${path}` + "?list" }).then((resp) => {
2020
- this.emit(PES`storage/${path}:r`, resp);
2062
+ return this.api.request({ url: "/api/" + PES`${this.path}/${path}` + "?list" }).then((resp) => {
2063
+ this.emit(PES`${this.path}/${path}:r`, resp);
2021
2064
  return resp;
2022
2065
  });
2023
2066
  }
2024
2067
  open(path, target = "_blank") {
2025
2068
  if (!path) throw new Error("Cannot download file, missing path");
2026
- const link = `${this.api.url}/api/` + PES`storage/${path}` + (this.api.token ? `?token=${this.api.token}` : "");
2069
+ const link = `${this.api.url}/api/` + PES`${this.path}/${path}` + (this.api.token ? `?token=${this.api.token}` : "");
2027
2070
  if (!target) return link;
2028
- this.emit(PES`storage/${path}:r`, path);
2071
+ this.emit(PES`${this.path}/${path}:r`, path);
2029
2072
  return window.open(link, target);
2030
2073
  }
2031
2074
  mkdir(path) {
2032
2075
  if (!path) throw new Error("Cannot make directory, missing path");
2033
- return this.api.request({ url: "/api/" + PES`storage/${path}`, body: { directory: true } }).then((resp) => {
2034
- this.emit(PES`storage/${path}:c`, resp);
2076
+ return this.api.request({ url: "/api/" + PES`${this.path}/${path}`, body: { directory: true } }).then((resp) => {
2077
+ this.emit(PES`${this.path}/${path}:c`, resp);
2035
2078
  return resp;
2036
2079
  });
2037
2080
  }
2038
2081
  move(source, destination) {
2039
2082
  if (!source || !destination) throw new Error("Cannot move file or folder, missing source or destination");
2040
2083
  if (source == destination) return this.list(destination);
2041
- return this.api.request({ url: "/api/" + PES`storage/${source}`, method: "PATCH", body: { move: destination } }).then((response) => {
2042
- this.emit(PES`storage/${source}:u`, response);
2084
+ return this.api.request({ url: "/api/" + PES`${this.path}/${source}`, method: "PATCH", body: { move: destination } }).then((response) => {
2085
+ this.emit(PES`${this.path}/${source}:u`, response);
2043
2086
  return response;
2044
2087
  });
2045
2088
  }
@@ -2049,13 +2092,13 @@ ${log}`;
2049
2092
  if (!files || Array.isArray(files) && !files.length) return [];
2050
2093
  const path = (opts && typeof opts == "object" ? opts == null ? void 0 : opts.path : opts) || "/";
2051
2094
  return uploadWithProgress({
2052
- url: `${this.api.url}/api/` + PES`storage/${path}`,
2095
+ url: `${this.api.url}/api/` + PES`${this.path}/${path}`,
2053
2096
  files: makeArray(files),
2054
2097
  headers: this.api.headers
2055
2098
  }).onProgress((p) => {
2056
2099
  prog(p);
2057
2100
  }).then((resp) => {
2058
- this.emit(PES`storage/${path}:c`, resp);
2101
+ this.emit(PES`${this.path}/${path}:c`, resp);
2059
2102
  res(resp);
2060
2103
  }).catch((err) => rej(err));
2061
2104
  });
@@ -2170,32 +2213,9 @@ ${log}`;
2170
2213
  });
2171
2214
  }
2172
2215
  }
2173
- class Static extends PathEventEmitter {
2216
+ class Static extends Storage$1 {
2174
2217
  constructor(api) {
2175
- super();
2176
- __publicField(this, "api");
2177
- this.api = typeof api == "string" ? new Api(api) : api;
2178
- }
2179
- delete(path) {
2180
- if (!path) throw new Error("Cannot delete static asset, missing path");
2181
- return this.api.request({ url: `/api/` + PES`static/${path}`, method: "DELETE" }).then(() => {
2182
- this.emit(PES`static/${path}:d`, path);
2183
- });
2184
- }
2185
- upload(files, path = "/") {
2186
- if (!files) throw new Error("Cannot upload static assets, missing file");
2187
- return new PromiseProgress(async (res, rej, prog) => {
2188
- return uploadWithProgress({
2189
- url: this.api.url + "/api/" + PES`static/${path}`,
2190
- files: makeArray(files),
2191
- headers: this.api.headers
2192
- }).onProgress((p) => {
2193
- prog(p);
2194
- }).then((resp) => {
2195
- this.emit(PES`static/${path}:c`, resp);
2196
- res(resp);
2197
- }).catch((err) => rej(err));
2198
- });
2218
+ super(api, "static");
2199
2219
  }
2200
2220
  }
2201
2221
  class Momentum extends PathEventEmitter {
@@ -2224,7 +2244,7 @@ ${log}`;
2224
2244
  this.actions = new Actions(this.api);
2225
2245
  this.ai = new Ai(this.api);
2226
2246
  this.analytics = new Analytics(this.api);
2227
- this.auth = new Auth(this.api, { loginUrl: opts == null ? void 0 : opts.loginUrl });
2247
+ this.auth = new Auth(this.api, opts);
2228
2248
  this.data = new Data(this.api);
2229
2249
  this.email = new Email(this.api);
2230
2250
  this.forms = new Forms(this.api);
package/dist/index.mjs CHANGED
@@ -1346,11 +1346,14 @@ class Client extends PathEventEmitter {
1346
1346
  get pushSubscription() {
1347
1347
  var _a;
1348
1348
  if (!((_a = navigator.serviceWorker) == null ? void 0 : _a.controller)) return Promise.resolve(null);
1349
- return navigator.serviceWorker.ready.then((sw) => sw.pushManager.getSubscription());
1349
+ return navigator.serviceWorker.ready.then((sw) => {
1350
+ var _a2;
1351
+ return (_a2 = sw == null ? void 0 : sw.pushManager) == null ? void 0 : _a2.getSubscription();
1352
+ });
1350
1353
  }
1351
1354
  get pwa() {
1352
1355
  if (this._pwa == null)
1353
- this._pwa = window.matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone) || document.referrer.includes("android-app://");
1356
+ this._pwa = matchMedia("(display-mode: standalone)").matches || (navigator == null ? void 0 : navigator.standalone) || document.referrer.includes("android-app://");
1354
1357
  return this._pwa;
1355
1358
  }
1356
1359
  async inject(reload = false, firstLoad = true) {
@@ -1358,6 +1361,50 @@ class Client extends PathEventEmitter {
1358
1361
  let settings = this.settings.cache;
1359
1362
  if (firstLoad) this.settings.all(false, reload).then(() => this.inject(false, false)).catch(() => {
1360
1363
  });
1364
+ if (settings["title"] && !document.head.querySelector('meta[property="og:title"]')) {
1365
+ const meta = document.createElement("meta");
1366
+ meta.setAttribute("property", "og:title");
1367
+ meta.content = settings["title"];
1368
+ document.head.append(meta);
1369
+ }
1370
+ if (!document.querySelector('meta[property="og:type"]')) {
1371
+ const meta = document.createElement("meta");
1372
+ meta.setAttribute("property", "og:type");
1373
+ meta.content = "article";
1374
+ document.head.append(meta);
1375
+ }
1376
+ if (settings["public_url"] && !document.querySelector('meta[property="og:url"]')) {
1377
+ const meta = document.createElement("meta");
1378
+ meta.setAttribute("property", "og:url");
1379
+ meta.content = settings["public_url"];
1380
+ document.head.append(meta);
1381
+ }
1382
+ if (settings["description"]) {
1383
+ if (!document.querySelector('meta[property="og:description"]')) {
1384
+ const meta = document.createElement("meta");
1385
+ meta.setAttribute("property", "og:description");
1386
+ meta.content = settings["description"];
1387
+ document.head.append(meta);
1388
+ }
1389
+ if (!document.querySelector('meta[property="description"]')) {
1390
+ const meta = document.createElement("meta");
1391
+ meta.setAttribute("property", "description");
1392
+ meta.content = settings["description"];
1393
+ document.head.append(meta);
1394
+ }
1395
+ if (!document.querySelector('meta[property="twitter:card"]')) {
1396
+ const meta = document.createElement("meta");
1397
+ meta.setAttribute("property", "twitter:card");
1398
+ meta.content = settings["description"];
1399
+ document.head.append(meta);
1400
+ }
1401
+ }
1402
+ if (settings["public_url"] && !document.querySelector('meta[property="og:image"]')) {
1403
+ const meta = document.createElement("meta");
1404
+ meta.setAttribute("property", "og:image");
1405
+ meta.content = settings["public_url"] + "/favicon.ico";
1406
+ document.head.append(meta);
1407
+ }
1361
1408
  if (!document.querySelector('meta[name="mobile-web-app-capable"]')) {
1362
1409
  const meta = document.createElement("meta");
1363
1410
  meta.name = "mobile-web-app-capable";
@@ -1370,46 +1417,41 @@ class Client extends PathEventEmitter {
1370
1417
  meta.content = "default";
1371
1418
  document.head.append(meta);
1372
1419
  }
1373
- if (!document.querySelector('meta[name="apple-mobile-web-app-title"]')) {
1420
+ if (settings["title"] && !document.querySelector('meta[name="apple-mobile-web-app-title"]')) {
1374
1421
  const meta = document.createElement("meta");
1375
1422
  meta.name = "apple-mobile-web-app-title";
1376
1423
  meta.content = settings["title"];
1377
1424
  document.head.append(meta);
1378
1425
  }
1379
- if (!document.querySelector('link[rel="apple-touch-icon"]')) {
1426
+ if (settings["public_url"] && !document.querySelector('link[rel="apple-touch-icon"]')) {
1380
1427
  const meta = document.createElement("link");
1381
1428
  meta.rel = "apple-touch-icon";
1382
- meta.href = settings["logo"];
1429
+ meta.href = settings["public_url"] + "/favicon.ico";
1383
1430
  document.head.append(meta);
1384
1431
  }
1385
- if (!document.querySelector('link[rel="apple-touch-startup-image"]')) {
1432
+ if (settings["public_url"] && !document.querySelector('link[rel="apple-touch-startup-image"]')) {
1386
1433
  const meta = document.createElement("link");
1387
1434
  meta.rel = "apple-touch-startup-image";
1388
- meta.href = settings["logo"];
1435
+ meta.href = settings["public_url"] + "/favicon.ico";
1389
1436
  document.head.append(meta);
1390
1437
  }
1391
- window.document.body.classList.add(((_a = settings["theme"]) == null ? void 0 : _a.darkMode) ? "theme-dark" : "theme-light");
1392
- window.document.body.classList.remove(((_b = settings["theme"]) == null ? void 0 : _b.darkMode) ? "theme-light" : "theme-dark");
1393
- if (settings["title"])
1394
- window.document.querySelectorAll(".momentum-title").forEach((el) => el.innerText = settings["title"]);
1395
- if (settings["description"])
1396
- window.document.querySelectorAll(".momentum-description").forEach((el) => el.innerText = settings["description"]);
1397
- if (settings.version)
1398
- window.document.querySelectorAll(".momentum-version").forEach((el) => el.innerText = settings["version"]);
1399
- if (settings["logo"]) {
1400
- window.document.querySelectorAll(".momentum-logo").forEach((el) => el.src = settings["logo"]);
1401
- }
1438
+ if (settings["title"]) document.querySelectorAll(".momentum-title").forEach((el) => el.innerText = settings["title"]);
1439
+ if (settings["description"]) document.querySelectorAll(".momentum-description").forEach((el) => el.innerText = settings["description"]);
1440
+ if (settings["version"]) document.querySelectorAll(".momentum-version").forEach((el) => el.innerText = settings["version"]);
1441
+ if (settings["logo"]) document.querySelectorAll(".momentum-logo").forEach((el) => el.src = settings["logo"]);
1402
1442
  if (settings["theme"]) {
1443
+ document.body.classList.add(((_a = settings["theme"]) == null ? void 0 : _a.darkMode) ? "theme-dark" : "theme-light");
1444
+ document.body.classList.remove(((_b = settings["theme"]) == null ? void 0 : _b.darkMode) ? "theme-light" : "theme-dark");
1403
1445
  document.body.style.setProperty("--theme-backdrop", (_c = settings["theme"]) == null ? void 0 : _c.background);
1404
1446
  document.body.style.setProperty("--theme-primary", (_d = settings["theme"]) == null ? void 0 : _d.primary);
1405
1447
  document.body.style.setProperty("--theme-accent", (_e = settings["theme"]) == null ? void 0 : _e.accent);
1406
1448
  document.body.style.setProperty("--theme-contrast", blackOrWhite((_f = settings["theme"]) == null ? void 0 : _f.background));
1407
1449
  }
1408
1450
  if (settings["pwa"]) {
1409
- const link = window.document.createElement("link");
1451
+ const link = document.createElement("link");
1410
1452
  link.setAttribute("rel", "manifest");
1411
1453
  link.setAttribute("href", this.settings.api.url + "/manifest.json");
1412
- window.document.head.append(link);
1454
+ document.head.append(link);
1413
1455
  setTimeout(() => {
1414
1456
  const dismissed = !!localStorage.getItem("momentum:install-prompt");
1415
1457
  if (!dismissed && !this.pwa && this.mobile) this.pwaPrompt();
@@ -1982,60 +2024,61 @@ const _Socket = class _Socket {
1982
2024
  __publicField(_Socket, "pollingSpeed", 3e4);
1983
2025
  let Socket = _Socket;
1984
2026
  let Storage$1 = class Storage2 extends PathEventEmitter {
1985
- constructor(api) {
2027
+ constructor(api, path = "storage") {
1986
2028
  super();
1987
2029
  __publicField(this, "api");
2030
+ this.path = path;
1988
2031
  this.api = typeof api == "string" ? new Api(api) : api;
1989
2032
  }
1990
2033
  copy(source, destination) {
1991
2034
  if (!source || !destination) throw new Error("Cannot copy file or folder, missing source or destination");
1992
- return this.api.request({ url: "/api/" + PES`storage/${destination}`, body: { from: source } }).then((response) => {
1993
- this.emit(PES`storage/${destination}:c`, response);
2035
+ return this.api.request({ url: "/api/" + PES`${this.path}/${destination}`, body: { from: source } }).then((response) => {
2036
+ this.emit(PES`${this.path}/${destination}:c`, response);
1994
2037
  return response;
1995
2038
  });
1996
2039
  }
1997
2040
  delete(path) {
1998
2041
  if (!path) throw new Error("Cannot delete file or folder, missing path");
1999
- return this.api.request({ url: "/api/" + PES`storage/${path}`, method: "DELETE" }).then(() => {
2000
- this.emit(PES`storage/${path}:d`, path);
2042
+ return this.api.request({ url: "/api/" + PES`${this.path}/${path}`, method: "DELETE" }).then(() => {
2043
+ this.emit(PES`${this.path}/${path}:d`, path);
2001
2044
  });
2002
2045
  }
2003
2046
  download(path, opts = {}) {
2004
2047
  if (!path) throw new Error("Cannot download file, missing path");
2005
- return this.api.request({ ...opts, url: "/api/" + PES`storage/${path}`, decode: false }).then(async (response) => {
2048
+ return this.api.request({ ...opts, url: "/api/" + PES`${this.path}/${path}`, decode: false }).then(async (response) => {
2006
2049
  const blob = await response.blob();
2007
2050
  const name = opts.downloadAs || path.split("/").pop();
2008
- this.emit(PES`storage/${path}:r`, blob);
2051
+ this.emit(PES`${this.path}/${path}:r`, blob);
2009
2052
  downloadFile(blob, name);
2010
2053
  return response;
2011
2054
  });
2012
2055
  }
2013
2056
  list(path) {
2014
2057
  if (!path) path = "/";
2015
- return this.api.request({ url: "/api/" + PES`storage/${path}` + "?list" }).then((resp) => {
2016
- this.emit(PES`storage/${path}:r`, resp);
2058
+ return this.api.request({ url: "/api/" + PES`${this.path}/${path}` + "?list" }).then((resp) => {
2059
+ this.emit(PES`${this.path}/${path}:r`, resp);
2017
2060
  return resp;
2018
2061
  });
2019
2062
  }
2020
2063
  open(path, target = "_blank") {
2021
2064
  if (!path) throw new Error("Cannot download file, missing path");
2022
- const link = `${this.api.url}/api/` + PES`storage/${path}` + (this.api.token ? `?token=${this.api.token}` : "");
2065
+ const link = `${this.api.url}/api/` + PES`${this.path}/${path}` + (this.api.token ? `?token=${this.api.token}` : "");
2023
2066
  if (!target) return link;
2024
- this.emit(PES`storage/${path}:r`, path);
2067
+ this.emit(PES`${this.path}/${path}:r`, path);
2025
2068
  return window.open(link, target);
2026
2069
  }
2027
2070
  mkdir(path) {
2028
2071
  if (!path) throw new Error("Cannot make directory, missing path");
2029
- return this.api.request({ url: "/api/" + PES`storage/${path}`, body: { directory: true } }).then((resp) => {
2030
- this.emit(PES`storage/${path}:c`, resp);
2072
+ return this.api.request({ url: "/api/" + PES`${this.path}/${path}`, body: { directory: true } }).then((resp) => {
2073
+ this.emit(PES`${this.path}/${path}:c`, resp);
2031
2074
  return resp;
2032
2075
  });
2033
2076
  }
2034
2077
  move(source, destination) {
2035
2078
  if (!source || !destination) throw new Error("Cannot move file or folder, missing source or destination");
2036
2079
  if (source == destination) return this.list(destination);
2037
- return this.api.request({ url: "/api/" + PES`storage/${source}`, method: "PATCH", body: { move: destination } }).then((response) => {
2038
- this.emit(PES`storage/${source}:u`, response);
2080
+ return this.api.request({ url: "/api/" + PES`${this.path}/${source}`, method: "PATCH", body: { move: destination } }).then((response) => {
2081
+ this.emit(PES`${this.path}/${source}:u`, response);
2039
2082
  return response;
2040
2083
  });
2041
2084
  }
@@ -2045,13 +2088,13 @@ let Storage$1 = class Storage2 extends PathEventEmitter {
2045
2088
  if (!files || Array.isArray(files) && !files.length) return [];
2046
2089
  const path = (opts && typeof opts == "object" ? opts == null ? void 0 : opts.path : opts) || "/";
2047
2090
  return uploadWithProgress({
2048
- url: `${this.api.url}/api/` + PES`storage/${path}`,
2091
+ url: `${this.api.url}/api/` + PES`${this.path}/${path}`,
2049
2092
  files: makeArray(files),
2050
2093
  headers: this.api.headers
2051
2094
  }).onProgress((p) => {
2052
2095
  prog(p);
2053
2096
  }).then((resp) => {
2054
- this.emit(PES`storage/${path}:c`, resp);
2097
+ this.emit(PES`${this.path}/${path}:c`, resp);
2055
2098
  res(resp);
2056
2099
  }).catch((err) => rej(err));
2057
2100
  });
@@ -2166,32 +2209,9 @@ class Settings extends PathEventEmitter {
2166
2209
  });
2167
2210
  }
2168
2211
  }
2169
- class Static extends PathEventEmitter {
2212
+ class Static extends Storage$1 {
2170
2213
  constructor(api) {
2171
- super();
2172
- __publicField(this, "api");
2173
- this.api = typeof api == "string" ? new Api(api) : api;
2174
- }
2175
- delete(path) {
2176
- if (!path) throw new Error("Cannot delete static asset, missing path");
2177
- return this.api.request({ url: `/api/` + PES`static/${path}`, method: "DELETE" }).then(() => {
2178
- this.emit(PES`static/${path}:d`, path);
2179
- });
2180
- }
2181
- upload(files, path = "/") {
2182
- if (!files) throw new Error("Cannot upload static assets, missing file");
2183
- return new PromiseProgress(async (res, rej, prog) => {
2184
- return uploadWithProgress({
2185
- url: this.api.url + "/api/" + PES`static/${path}`,
2186
- files: makeArray(files),
2187
- headers: this.api.headers
2188
- }).onProgress((p) => {
2189
- prog(p);
2190
- }).then((resp) => {
2191
- this.emit(PES`static/${path}:c`, resp);
2192
- res(resp);
2193
- }).catch((err) => rej(err));
2194
- });
2214
+ super(api, "static");
2195
2215
  }
2196
2216
  }
2197
2217
  class Momentum extends PathEventEmitter {
@@ -2220,7 +2240,7 @@ class Momentum extends PathEventEmitter {
2220
2240
  this.actions = new Actions(this.api);
2221
2241
  this.ai = new Ai(this.api);
2222
2242
  this.analytics = new Analytics(this.api);
2223
- this.auth = new Auth(this.api, { loginUrl: opts == null ? void 0 : opts.loginUrl });
2243
+ this.auth = new Auth(this.api, opts);
2224
2244
  this.data = new Data(this.api);
2225
2245
  this.email = new Email(this.api);
2226
2246
  this.forms = new Forms(this.api);
package/dist/static.d.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  import { Api } from './api';
2
- import { PathEventEmitter, PromiseProgress } from '@ztimson/utils';
3
- export declare class Static extends PathEventEmitter {
4
- private readonly api;
2
+ import { Storage } from './storage';
3
+ export declare class Static extends Storage {
5
4
  constructor(api: Api | string);
6
- delete(path: string): Promise<void>;
7
- upload(files: File | File[], path?: string): PromiseProgress<string[]>;
8
5
  }
9
6
  //# sourceMappingURL=static.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../src/static.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAY,gBAAgB,EAAO,eAAe,EAAqB,MAAM,gBAAgB,CAAC;AAErG,qBAAa,MAAO,SAAQ,gBAAgB;IAC3C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;gBAEf,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnC,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EAAE,IAAI,SAAM,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC;CAenE"}
1
+ {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../src/static.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC,qBAAa,MAAO,SAAQ,OAAO;gBACtB,GAAG,EAAE,GAAG,GAAG,MAAM;CAG7B"}
package/dist/storage.d.ts CHANGED
@@ -16,8 +16,9 @@ export type FileMeta = Meta & {
16
16
  missing?: boolean;
17
17
  };
18
18
  export declare class Storage extends PathEventEmitter {
19
+ private readonly path;
19
20
  readonly api: Api;
20
- constructor(api: Api | string);
21
+ constructor(api: Api | string, path?: string);
21
22
  copy(source: string, destination: string): Promise<DirMeta | FileMeta>;
22
23
  delete(path: string): Promise<void>;
23
24
  download(path: string, opts?: HttpRequestOptions & {
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,KAAK,IAAI,EAAC,MAAM,QAAQ,CAAC;AACjC,OAAO,EACN,eAAe,EACf,kBAAkB,EAKlB,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,OAAO,GAAG;IACrB,QAAQ,EAAE,CAAC,OAAO,GAAG,QAAQ,CAAC,EAAE,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACb,CAA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AAC,EAAE,MAAM,CAAA;KAAM,GAAG,eAAe,CAAC,IAAI,CAAC;IAWtG,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC;IAQhD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAG,MAAM;IACzC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI;IAS9D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQrC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC;IAStE,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAC,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC;CAiBvI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ztimson/momentum",
3
- "version": "0.50.7",
3
+ "version": "0.51.0",
4
4
  "description": "Client library for momentum",
5
5
  "keywords": ["Momentum"],
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",