@ztimson/momentum 0.50.3 → 0.50.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.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAM,MAAM,gBAAgB,CAAC;AACrD,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;IAgF7C,SAAS,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;IAqIhC,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;IAiF7C,SAAS,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;IAqIhC,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAa7C,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;CAO3C"}
package/dist/index.cjs CHANGED
@@ -6,26 +6,26 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
6
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
7
 
8
8
  var __defProp2 = Object.defineProperty;
9
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
9
+ var __defNormalProp2 = (obj, key, value2) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
10
+ var __publicField2 = (obj, key, value2) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value2);
11
11
  function clean(obj, undefinedOnly = false) {
12
12
  if (obj == null) throw new Error("Cannot clean a NULL value");
13
13
  if (Array.isArray(obj)) {
14
14
  obj = obj.filter((o) => o != null);
15
15
  } else {
16
- Object.entries(obj).forEach(([key, value]) => {
17
- if (undefinedOnly && value === void 0 || !undefinedOnly && value == null) delete obj[key];
16
+ Object.entries(obj).forEach(([key, value2]) => {
17
+ if (undefinedOnly && value2 === void 0 || !undefinedOnly && value2 == null) delete obj[key];
18
18
  });
19
19
  }
20
20
  return obj;
21
21
  }
22
- function isEqual(a, b) {
23
- const ta = typeof a, tb = typeof b;
24
- if (ta != "object" || a == null || (tb != "object" || b == null))
25
- return ta == "function" && tb == "function" ? a.toString() == b.toString() : a === b;
26
- const keys = Object.keys(a);
27
- if (keys.length != Object.keys(b).length) return false;
28
- return Object.keys(a).every((key) => isEqual(a[key], b[key]));
22
+ function isEqual(a2, b2) {
23
+ const ta = typeof a2, tb = typeof b2;
24
+ if (ta != "object" || a2 == null || (tb != "object" || b2 == null))
25
+ return ta == "function" && tb == "function" ? a2.toString() == b2.toString() : a2 === b2;
26
+ const keys = Object.keys(a2);
27
+ if (keys.length != Object.keys(b2).length) return false;
28
+ return Object.keys(a2).every((key) => isEqual(a2[key], b2[key]));
29
29
  }
30
30
  function JSONAttemptParse(json) {
31
31
  try {
@@ -35,12 +35,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
35
35
  }
36
36
  }
37
37
  function JSONSanitize(obj, space) {
38
- return JSON.stringify(obj, (key, value) => {
39
- return value;
38
+ return JSON.stringify(obj, (key, value2) => {
39
+ return value2;
40
40
  }, space);
41
41
  }
42
- function makeArray(value) {
43
- return Array.isArray(value) ? value : [value];
42
+ function makeArray(value2) {
43
+ return Array.isArray(value2) ? value2 : [value2];
44
44
  }
45
45
  class ASet extends Array {
46
46
  /** Number of elements in set */
@@ -98,8 +98,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
98
98
  * @param {number} fromIndex Starting index position
99
99
  * @return {number} Element index number or -1 if missing
100
100
  */
101
- indexOf(search, fromIndex) {
102
- return super.findIndex((el) => isEqual(el, search), fromIndex);
101
+ indexOf(search2, fromIndex) {
102
+ return super.findIndex((el) => isEqual(el, search2), fromIndex);
103
103
  }
104
104
  /**
105
105
  * Create list of elements this set has in common with the comparison set
@@ -175,20 +175,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
175
175
  }
176
176
  }
177
177
  return new Proxy(this, {
178
- get: (target, prop) => {
179
- if (prop in target) return target[prop];
180
- return target.store[prop];
178
+ get: (target, prop2) => {
179
+ if (prop2 in target) return target[prop2];
180
+ return target.store[prop2];
181
181
  },
182
- set: (target, prop, value) => {
183
- if (prop in target) target[prop] = value;
184
- else target.store[prop] = value;
182
+ set: (target, prop2, value2) => {
183
+ if (prop2 in target) target[prop2] = value2;
184
+ else target.store[prop2] = value2;
185
185
  return true;
186
186
  }
187
187
  });
188
188
  }
189
- getKey(value) {
189
+ getKey(value2) {
190
190
  if (!this.key) throw new Error("No key defined");
191
- return value[this.key];
191
+ return value2[this.key];
192
192
  }
193
193
  /**
194
194
  * Get all cached items
@@ -205,9 +205,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
205
205
  * @param {number | undefined} ttl Override default expiry
206
206
  * @return {this}
207
207
  */
208
- add(value, ttl = this.ttl) {
209
- const key = this.getKey(value);
210
- this.set(key, value, ttl);
208
+ add(value2, ttl = this.ttl) {
209
+ const key = this.getKey(value2);
210
+ this.set(key, value2, ttl);
211
211
  return this;
212
212
  }
213
213
  /**
@@ -217,8 +217,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
217
217
  * @param complete Mark cache as complete & reliable, defaults to true
218
218
  * @return {this}
219
219
  */
220
- addAll(rows, complete = true) {
221
- rows.forEach((r) => this.add(r));
220
+ addAll(rows2, complete = true) {
221
+ rows2.forEach((r2) => this.add(r2));
222
222
  this.complete = complete;
223
223
  return this;
224
224
  }
@@ -277,8 +277,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
277
277
  * @param {number | undefined} ttl Override default expiry in seconds
278
278
  * @return {this}
279
279
  */
280
- set(key, value, ttl = this.options.ttl) {
281
- this.store[key] = value;
280
+ set(key, value2, ttl = this.options.ttl) {
281
+ this.store[key] = value2;
282
282
  if (this.options.storageKey && this.options.storage)
283
283
  this.options.storage.setItem(this.options.storageKey, JSON.stringify(this.store));
284
284
  if (ttl) setTimeout(() => {
@@ -288,10 +288,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
288
288
  return this;
289
289
  }
290
290
  }
291
+ function blackOrWhite(background) {
292
+ const exploded = background.match(background.length >= 6 ? /\w\w/g : /\w/g);
293
+ if (!exploded) return "black";
294
+ const [r2, g, b2] = exploded.map((hex) => parseInt(hex, 16));
295
+ const luminance = (0.299 * r2 + 0.587 * g + 0.114 * b2) / 255;
296
+ return luminance > 0.5 ? "black" : "white";
297
+ }
291
298
  class PromiseProgress extends Promise {
292
299
  constructor(executor) {
293
300
  super((resolve, reject) => executor(
294
- (value) => resolve(value),
301
+ (value2) => resolve(value2),
295
302
  (reason) => reject(reason),
296
303
  (progress) => this.progress = progress
297
304
  ));
@@ -301,10 +308,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
301
308
  get progress() {
302
309
  return this._progress;
303
310
  }
304
- set progress(p) {
305
- if (p == this._progress) return;
306
- this._progress = p;
307
- this.listeners.forEach((l) => l(p));
311
+ set progress(p2) {
312
+ if (p2 == this._progress) return;
313
+ this._progress = p2;
314
+ this.listeners.forEach((l) => l(p2));
308
315
  }
309
316
  static from(promise) {
310
317
  if (promise instanceof PromiseProgress) return promise;
@@ -312,7 +319,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
312
319
  }
313
320
  from(promise) {
314
321
  const newPromise = PromiseProgress.from(promise);
315
- this.onProgress((p) => newPromise.progress = p);
322
+ this.onProgress((p2) => newPromise.progress = p2);
316
323
  return newPromise;
317
324
  }
318
325
  onProgress(callback) {
@@ -337,12 +344,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
337
344
  URL.revokeObjectURL(url);
338
345
  }
339
346
  function downloadUrl(href, name) {
340
- const a = document.createElement("a");
341
- a.href = href;
342
- a.download = name || href.split("/").pop();
343
- document.body.appendChild(a);
344
- a.click();
345
- document.body.removeChild(a);
347
+ const a2 = document.createElement("a");
348
+ a2.href = href;
349
+ a2.download = name || href.split("/").pop();
350
+ document.body.appendChild(a2);
351
+ a2.click();
352
+ document.body.removeChild(a2);
346
353
  }
347
354
  function fileBrowser(options = {}) {
348
355
  return new Promise((res) => {
@@ -375,7 +382,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
375
382
  xhr.addEventListener("error", () => rej(JSONAttemptParse(xhr.responseText)));
376
383
  xhr.addEventListener("timeout", () => rej({ error: "Request timed out" }));
377
384
  xhr.open("POST", options.url);
378
- Object.entries(options.headers || {}).forEach(([key, value]) => xhr.setRequestHeader(key, value));
385
+ Object.entries(options.headers || {}).forEach(([key, value2]) => xhr.setRequestHeader(key, value2));
379
386
  xhr.send(formData2);
380
387
  });
381
388
  }
@@ -764,15 +771,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
764
771
  __publicField2(this, "methods");
765
772
  var _a;
766
773
  if (typeof Event == "object") return Object.assign(this, Event);
767
- let [p, scope, method] = Event.replaceAll(/\/{2,}/g, "/").split(":");
774
+ let [p2, scope, method] = Event.replaceAll(/\/{2,}/g, "/").split(":");
768
775
  if (!method) method = scope || "*";
769
- if (p == "*" || !p && method == "*") {
770
- p = "";
776
+ if (p2 == "*" || !p2 && method == "*") {
777
+ p2 = "";
771
778
  method = "*";
772
779
  }
773
- let temp = p.split("/").filter((p2) => !!p2);
780
+ let temp = p2.split("/").filter((p22) => !!p22);
774
781
  this.module = ((_a = temp.splice(0, 1)[0]) == null ? void 0 : _a.toLowerCase()) || "";
775
- this.fullPath = p;
782
+ this.fullPath = p2;
776
783
  this.path = temp.join("/");
777
784
  this.name = temp.pop() || "";
778
785
  this.methods = new ASet(method.split(""));
@@ -781,43 +788,43 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
781
788
  get all() {
782
789
  return this.methods.has("*");
783
790
  }
784
- set all(v) {
785
- v ? new ASet(["*"]) : this.methods.delete("*");
791
+ set all(v2) {
792
+ v2 ? new ASet(["*"]) : this.methods.delete("*");
786
793
  }
787
794
  /** None specified */
788
795
  get none() {
789
796
  return this.methods.has("n");
790
797
  }
791
- set none(v) {
792
- v ? this.methods = new ASet(["n"]) : this.methods.delete("n");
798
+ set none(v2) {
799
+ v2 ? this.methods = new ASet(["n"]) : this.methods.delete("n");
793
800
  }
794
801
  /** Create method specified */
795
802
  get create() {
796
803
  return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("c"));
797
804
  }
798
- set create(v) {
799
- v ? this.methods.delete("n").add("c") : this.methods.delete("c");
805
+ set create(v2) {
806
+ v2 ? this.methods.delete("n").add("c") : this.methods.delete("c");
800
807
  }
801
808
  /** Read method specified */
802
809
  get read() {
803
810
  return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("r"));
804
811
  }
805
- set read(v) {
806
- v ? this.methods.delete("n").add("r") : this.methods.delete("r");
812
+ set read(v2) {
813
+ v2 ? this.methods.delete("n").add("r") : this.methods.delete("r");
807
814
  }
808
815
  /** Update method specified */
809
816
  get update() {
810
817
  return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("u"));
811
818
  }
812
- set update(v) {
813
- v ? this.methods.delete("n").add("u") : this.methods.delete("u");
819
+ set update(v2) {
820
+ v2 ? this.methods.delete("n").add("u") : this.methods.delete("u");
814
821
  }
815
822
  /** Delete method specified */
816
823
  get delete() {
817
824
  return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("d"));
818
825
  }
819
- set delete(v) {
820
- v ? this.methods.delete("n").add("d") : this.methods.delete("d");
826
+ set delete(v2) {
827
+ v2 ? this.methods.delete("n").add("d") : this.methods.delete("d");
821
828
  }
822
829
  /**
823
830
  * Combine multiple events into one parsed object. Longest path takes precedent, but all subsequent methods are
@@ -828,14 +835,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
828
835
  */
829
836
  static combine(...paths) {
830
837
  let hitNone = false;
831
- const combined = paths.map((p) => new PathEvent(p)).toSorted((p1, p2) => {
838
+ const combined = paths.map((p2) => new PathEvent(p2)).toSorted((p1, p2) => {
832
839
  const l1 = p1.fullPath.length, l2 = p2.fullPath.length;
833
840
  return l1 < l2 ? 1 : l1 > l2 ? -1 : 0;
834
- }).reduce((acc, p) => {
835
- if (p.none) hitNone = true;
836
- if (!acc) return p;
841
+ }).reduce((acc, p2) => {
842
+ if (p2.none) hitNone = true;
843
+ if (!acc) return p2;
837
844
  if (hitNone) return acc;
838
- acc.methods = [...acc.methods, ...p.methods];
845
+ acc.methods = [...acc.methods, ...p2.methods];
839
846
  return acc;
840
847
  }, null);
841
848
  combined.methods = new ASet(combined.methods);
@@ -866,12 +873,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
866
873
  static has(target, ...has) {
867
874
  const parsedRequired = makeArray(has).map((pe) => new PathEvent(pe));
868
875
  const parsedTarget = makeArray(target).map((pe) => new PathEvent(pe));
869
- return !!parsedRequired.find((r) => {
870
- if (!r.fullPath && r.all) return true;
871
- const filtered = parsedTarget.filter((p) => r.fullPath.startsWith(p.fullPath));
876
+ return !!parsedRequired.find((r2) => {
877
+ if (!r2.fullPath && r2.all) return true;
878
+ const filtered = parsedTarget.filter((p2) => r2.fullPath.startsWith(p2.fullPath));
872
879
  if (!filtered.length) return false;
873
880
  const combined = PathEvent.combine(...filtered);
874
- return !combined.none && (combined.all || r.all) || combined.methods.intersection(r.methods).length;
881
+ return !combined.none && (combined.all || r2.all) || combined.methods.intersection(r2.methods).length;
875
882
  });
876
883
  }
877
884
  /**
@@ -910,10 +917,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
910
917
  * @return {string} String representation of Event
911
918
  */
912
919
  static toString(path, methods) {
913
- let p = makeArray(path).filter((p2) => p2 != null).join("/");
914
- p = p == null ? void 0 : p.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
915
- if (methods == null ? void 0 : methods.length) p += `:${makeArray(methods).map((m) => m.toLowerCase()).join("")}`;
916
- return p;
920
+ let p2 = makeArray(path).filter((p22) => p22 != null).join("/");
921
+ p2 = p2 == null ? void 0 : p2.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
922
+ if (methods == null ? void 0 : methods.length) p2 += `:${makeArray(methods).map((m) => m.toLowerCase()).join("")}`;
923
+ return p2;
917
924
  }
918
925
  /**
919
926
  * Filter a set of paths based on this event
@@ -1321,7 +1328,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1321
1328
  return this._pwa;
1322
1329
  }
1323
1330
  async inject(reload = false, firstLoad = true) {
1324
- var _a, _b, _c, _d, _e;
1331
+ var _a, _b, _c, _d, _e, _f;
1325
1332
  let settings = this.settings.cache;
1326
1333
  if (firstLoad) this.settings.all(false, reload).then(() => this.inject(false, false)).catch(() => {
1327
1334
  });
@@ -1370,6 +1377,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1370
1377
  document.body.style.setProperty("--theme-backdrop", (_c = settings["theme"]) == null ? void 0 : _c.background);
1371
1378
  document.body.style.setProperty("--theme-primary", (_d = settings["theme"]) == null ? void 0 : _d.primary);
1372
1379
  document.body.style.setProperty("--theme-accent", (_e = settings["theme"]) == null ? void 0 : _e.secondary);
1380
+ document.body.style.setProperty("--theme-contrast", blackOrWhite((_f = settings["theme"]) == null ? void 0 : _f.background));
1373
1381
  }
1374
1382
  if (settings["pwa"]) {
1375
1383
  const link = window.document.createElement("link");
package/dist/index.mjs CHANGED
@@ -2,26 +2,26 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  var __defProp2 = Object.defineProperty;
5
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ var __defNormalProp2 = (obj, key, value2) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
6
+ var __publicField2 = (obj, key, value2) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value2);
7
7
  function clean(obj, undefinedOnly = false) {
8
8
  if (obj == null) throw new Error("Cannot clean a NULL value");
9
9
  if (Array.isArray(obj)) {
10
10
  obj = obj.filter((o) => o != null);
11
11
  } else {
12
- Object.entries(obj).forEach(([key, value]) => {
13
- if (undefinedOnly && value === void 0 || !undefinedOnly && value == null) delete obj[key];
12
+ Object.entries(obj).forEach(([key, value2]) => {
13
+ if (undefinedOnly && value2 === void 0 || !undefinedOnly && value2 == null) delete obj[key];
14
14
  });
15
15
  }
16
16
  return obj;
17
17
  }
18
- function isEqual(a, b) {
19
- const ta = typeof a, tb = typeof b;
20
- if (ta != "object" || a == null || (tb != "object" || b == null))
21
- return ta == "function" && tb == "function" ? a.toString() == b.toString() : a === b;
22
- const keys = Object.keys(a);
23
- if (keys.length != Object.keys(b).length) return false;
24
- return Object.keys(a).every((key) => isEqual(a[key], b[key]));
18
+ function isEqual(a2, b2) {
19
+ const ta = typeof a2, tb = typeof b2;
20
+ if (ta != "object" || a2 == null || (tb != "object" || b2 == null))
21
+ return ta == "function" && tb == "function" ? a2.toString() == b2.toString() : a2 === b2;
22
+ const keys = Object.keys(a2);
23
+ if (keys.length != Object.keys(b2).length) return false;
24
+ return Object.keys(a2).every((key) => isEqual(a2[key], b2[key]));
25
25
  }
26
26
  function JSONAttemptParse(json) {
27
27
  try {
@@ -31,12 +31,12 @@ function JSONAttemptParse(json) {
31
31
  }
32
32
  }
33
33
  function JSONSanitize(obj, space) {
34
- return JSON.stringify(obj, (key, value) => {
35
- return value;
34
+ return JSON.stringify(obj, (key, value2) => {
35
+ return value2;
36
36
  }, space);
37
37
  }
38
- function makeArray(value) {
39
- return Array.isArray(value) ? value : [value];
38
+ function makeArray(value2) {
39
+ return Array.isArray(value2) ? value2 : [value2];
40
40
  }
41
41
  class ASet extends Array {
42
42
  /** Number of elements in set */
@@ -94,8 +94,8 @@ class ASet extends Array {
94
94
  * @param {number} fromIndex Starting index position
95
95
  * @return {number} Element index number or -1 if missing
96
96
  */
97
- indexOf(search, fromIndex) {
98
- return super.findIndex((el) => isEqual(el, search), fromIndex);
97
+ indexOf(search2, fromIndex) {
98
+ return super.findIndex((el) => isEqual(el, search2), fromIndex);
99
99
  }
100
100
  /**
101
101
  * Create list of elements this set has in common with the comparison set
@@ -171,20 +171,20 @@ class Cache {
171
171
  }
172
172
  }
173
173
  return new Proxy(this, {
174
- get: (target, prop) => {
175
- if (prop in target) return target[prop];
176
- return target.store[prop];
174
+ get: (target, prop2) => {
175
+ if (prop2 in target) return target[prop2];
176
+ return target.store[prop2];
177
177
  },
178
- set: (target, prop, value) => {
179
- if (prop in target) target[prop] = value;
180
- else target.store[prop] = value;
178
+ set: (target, prop2, value2) => {
179
+ if (prop2 in target) target[prop2] = value2;
180
+ else target.store[prop2] = value2;
181
181
  return true;
182
182
  }
183
183
  });
184
184
  }
185
- getKey(value) {
185
+ getKey(value2) {
186
186
  if (!this.key) throw new Error("No key defined");
187
- return value[this.key];
187
+ return value2[this.key];
188
188
  }
189
189
  /**
190
190
  * Get all cached items
@@ -201,9 +201,9 @@ class Cache {
201
201
  * @param {number | undefined} ttl Override default expiry
202
202
  * @return {this}
203
203
  */
204
- add(value, ttl = this.ttl) {
205
- const key = this.getKey(value);
206
- this.set(key, value, ttl);
204
+ add(value2, ttl = this.ttl) {
205
+ const key = this.getKey(value2);
206
+ this.set(key, value2, ttl);
207
207
  return this;
208
208
  }
209
209
  /**
@@ -213,8 +213,8 @@ class Cache {
213
213
  * @param complete Mark cache as complete & reliable, defaults to true
214
214
  * @return {this}
215
215
  */
216
- addAll(rows, complete = true) {
217
- rows.forEach((r) => this.add(r));
216
+ addAll(rows2, complete = true) {
217
+ rows2.forEach((r2) => this.add(r2));
218
218
  this.complete = complete;
219
219
  return this;
220
220
  }
@@ -273,8 +273,8 @@ class Cache {
273
273
  * @param {number | undefined} ttl Override default expiry in seconds
274
274
  * @return {this}
275
275
  */
276
- set(key, value, ttl = this.options.ttl) {
277
- this.store[key] = value;
276
+ set(key, value2, ttl = this.options.ttl) {
277
+ this.store[key] = value2;
278
278
  if (this.options.storageKey && this.options.storage)
279
279
  this.options.storage.setItem(this.options.storageKey, JSON.stringify(this.store));
280
280
  if (ttl) setTimeout(() => {
@@ -284,10 +284,17 @@ class Cache {
284
284
  return this;
285
285
  }
286
286
  }
287
+ function blackOrWhite(background) {
288
+ const exploded = background.match(background.length >= 6 ? /\w\w/g : /\w/g);
289
+ if (!exploded) return "black";
290
+ const [r2, g, b2] = exploded.map((hex) => parseInt(hex, 16));
291
+ const luminance = (0.299 * r2 + 0.587 * g + 0.114 * b2) / 255;
292
+ return luminance > 0.5 ? "black" : "white";
293
+ }
287
294
  class PromiseProgress extends Promise {
288
295
  constructor(executor) {
289
296
  super((resolve, reject) => executor(
290
- (value) => resolve(value),
297
+ (value2) => resolve(value2),
291
298
  (reason) => reject(reason),
292
299
  (progress) => this.progress = progress
293
300
  ));
@@ -297,10 +304,10 @@ class PromiseProgress extends Promise {
297
304
  get progress() {
298
305
  return this._progress;
299
306
  }
300
- set progress(p) {
301
- if (p == this._progress) return;
302
- this._progress = p;
303
- this.listeners.forEach((l) => l(p));
307
+ set progress(p2) {
308
+ if (p2 == this._progress) return;
309
+ this._progress = p2;
310
+ this.listeners.forEach((l) => l(p2));
304
311
  }
305
312
  static from(promise) {
306
313
  if (promise instanceof PromiseProgress) return promise;
@@ -308,7 +315,7 @@ class PromiseProgress extends Promise {
308
315
  }
309
316
  from(promise) {
310
317
  const newPromise = PromiseProgress.from(promise);
311
- this.onProgress((p) => newPromise.progress = p);
318
+ this.onProgress((p2) => newPromise.progress = p2);
312
319
  return newPromise;
313
320
  }
314
321
  onProgress(callback) {
@@ -333,12 +340,12 @@ function downloadFile(blob, name) {
333
340
  URL.revokeObjectURL(url);
334
341
  }
335
342
  function downloadUrl(href, name) {
336
- const a = document.createElement("a");
337
- a.href = href;
338
- a.download = name || href.split("/").pop();
339
- document.body.appendChild(a);
340
- a.click();
341
- document.body.removeChild(a);
343
+ const a2 = document.createElement("a");
344
+ a2.href = href;
345
+ a2.download = name || href.split("/").pop();
346
+ document.body.appendChild(a2);
347
+ a2.click();
348
+ document.body.removeChild(a2);
342
349
  }
343
350
  function fileBrowser(options = {}) {
344
351
  return new Promise((res) => {
@@ -371,7 +378,7 @@ function uploadWithProgress(options) {
371
378
  xhr.addEventListener("error", () => rej(JSONAttemptParse(xhr.responseText)));
372
379
  xhr.addEventListener("timeout", () => rej({ error: "Request timed out" }));
373
380
  xhr.open("POST", options.url);
374
- Object.entries(options.headers || {}).forEach(([key, value]) => xhr.setRequestHeader(key, value));
381
+ Object.entries(options.headers || {}).forEach(([key, value2]) => xhr.setRequestHeader(key, value2));
375
382
  xhr.send(formData2);
376
383
  });
377
384
  }
@@ -760,15 +767,15 @@ class PathEvent {
760
767
  __publicField2(this, "methods");
761
768
  var _a;
762
769
  if (typeof Event == "object") return Object.assign(this, Event);
763
- let [p, scope, method] = Event.replaceAll(/\/{2,}/g, "/").split(":");
770
+ let [p2, scope, method] = Event.replaceAll(/\/{2,}/g, "/").split(":");
764
771
  if (!method) method = scope || "*";
765
- if (p == "*" || !p && method == "*") {
766
- p = "";
772
+ if (p2 == "*" || !p2 && method == "*") {
773
+ p2 = "";
767
774
  method = "*";
768
775
  }
769
- let temp = p.split("/").filter((p2) => !!p2);
776
+ let temp = p2.split("/").filter((p22) => !!p22);
770
777
  this.module = ((_a = temp.splice(0, 1)[0]) == null ? void 0 : _a.toLowerCase()) || "";
771
- this.fullPath = p;
778
+ this.fullPath = p2;
772
779
  this.path = temp.join("/");
773
780
  this.name = temp.pop() || "";
774
781
  this.methods = new ASet(method.split(""));
@@ -777,43 +784,43 @@ class PathEvent {
777
784
  get all() {
778
785
  return this.methods.has("*");
779
786
  }
780
- set all(v) {
781
- v ? new ASet(["*"]) : this.methods.delete("*");
787
+ set all(v2) {
788
+ v2 ? new ASet(["*"]) : this.methods.delete("*");
782
789
  }
783
790
  /** None specified */
784
791
  get none() {
785
792
  return this.methods.has("n");
786
793
  }
787
- set none(v) {
788
- v ? this.methods = new ASet(["n"]) : this.methods.delete("n");
794
+ set none(v2) {
795
+ v2 ? this.methods = new ASet(["n"]) : this.methods.delete("n");
789
796
  }
790
797
  /** Create method specified */
791
798
  get create() {
792
799
  return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("c"));
793
800
  }
794
- set create(v) {
795
- v ? this.methods.delete("n").add("c") : this.methods.delete("c");
801
+ set create(v2) {
802
+ v2 ? this.methods.delete("n").add("c") : this.methods.delete("c");
796
803
  }
797
804
  /** Read method specified */
798
805
  get read() {
799
806
  return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("r"));
800
807
  }
801
- set read(v) {
802
- v ? this.methods.delete("n").add("r") : this.methods.delete("r");
808
+ set read(v2) {
809
+ v2 ? this.methods.delete("n").add("r") : this.methods.delete("r");
803
810
  }
804
811
  /** Update method specified */
805
812
  get update() {
806
813
  return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("u"));
807
814
  }
808
- set update(v) {
809
- v ? this.methods.delete("n").add("u") : this.methods.delete("u");
815
+ set update(v2) {
816
+ v2 ? this.methods.delete("n").add("u") : this.methods.delete("u");
810
817
  }
811
818
  /** Delete method specified */
812
819
  get delete() {
813
820
  return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("d"));
814
821
  }
815
- set delete(v) {
816
- v ? this.methods.delete("n").add("d") : this.methods.delete("d");
822
+ set delete(v2) {
823
+ v2 ? this.methods.delete("n").add("d") : this.methods.delete("d");
817
824
  }
818
825
  /**
819
826
  * Combine multiple events into one parsed object. Longest path takes precedent, but all subsequent methods are
@@ -824,14 +831,14 @@ class PathEvent {
824
831
  */
825
832
  static combine(...paths) {
826
833
  let hitNone = false;
827
- const combined = paths.map((p) => new PathEvent(p)).toSorted((p1, p2) => {
834
+ const combined = paths.map((p2) => new PathEvent(p2)).toSorted((p1, p2) => {
828
835
  const l1 = p1.fullPath.length, l2 = p2.fullPath.length;
829
836
  return l1 < l2 ? 1 : l1 > l2 ? -1 : 0;
830
- }).reduce((acc, p) => {
831
- if (p.none) hitNone = true;
832
- if (!acc) return p;
837
+ }).reduce((acc, p2) => {
838
+ if (p2.none) hitNone = true;
839
+ if (!acc) return p2;
833
840
  if (hitNone) return acc;
834
- acc.methods = [...acc.methods, ...p.methods];
841
+ acc.methods = [...acc.methods, ...p2.methods];
835
842
  return acc;
836
843
  }, null);
837
844
  combined.methods = new ASet(combined.methods);
@@ -862,12 +869,12 @@ class PathEvent {
862
869
  static has(target, ...has) {
863
870
  const parsedRequired = makeArray(has).map((pe) => new PathEvent(pe));
864
871
  const parsedTarget = makeArray(target).map((pe) => new PathEvent(pe));
865
- return !!parsedRequired.find((r) => {
866
- if (!r.fullPath && r.all) return true;
867
- const filtered = parsedTarget.filter((p) => r.fullPath.startsWith(p.fullPath));
872
+ return !!parsedRequired.find((r2) => {
873
+ if (!r2.fullPath && r2.all) return true;
874
+ const filtered = parsedTarget.filter((p2) => r2.fullPath.startsWith(p2.fullPath));
868
875
  if (!filtered.length) return false;
869
876
  const combined = PathEvent.combine(...filtered);
870
- return !combined.none && (combined.all || r.all) || combined.methods.intersection(r.methods).length;
877
+ return !combined.none && (combined.all || r2.all) || combined.methods.intersection(r2.methods).length;
871
878
  });
872
879
  }
873
880
  /**
@@ -906,10 +913,10 @@ class PathEvent {
906
913
  * @return {string} String representation of Event
907
914
  */
908
915
  static toString(path, methods) {
909
- let p = makeArray(path).filter((p2) => p2 != null).join("/");
910
- p = p == null ? void 0 : p.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
911
- if (methods == null ? void 0 : methods.length) p += `:${makeArray(methods).map((m) => m.toLowerCase()).join("")}`;
912
- return p;
916
+ let p2 = makeArray(path).filter((p22) => p22 != null).join("/");
917
+ p2 = p2 == null ? void 0 : p2.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
918
+ if (methods == null ? void 0 : methods.length) p2 += `:${makeArray(methods).map((m) => m.toLowerCase()).join("")}`;
919
+ return p2;
913
920
  }
914
921
  /**
915
922
  * Filter a set of paths based on this event
@@ -1317,7 +1324,7 @@ class Client extends PathEventEmitter {
1317
1324
  return this._pwa;
1318
1325
  }
1319
1326
  async inject(reload = false, firstLoad = true) {
1320
- var _a, _b, _c, _d, _e;
1327
+ var _a, _b, _c, _d, _e, _f;
1321
1328
  let settings = this.settings.cache;
1322
1329
  if (firstLoad) this.settings.all(false, reload).then(() => this.inject(false, false)).catch(() => {
1323
1330
  });
@@ -1366,6 +1373,7 @@ class Client extends PathEventEmitter {
1366
1373
  document.body.style.setProperty("--theme-backdrop", (_c = settings["theme"]) == null ? void 0 : _c.background);
1367
1374
  document.body.style.setProperty("--theme-primary", (_d = settings["theme"]) == null ? void 0 : _d.primary);
1368
1375
  document.body.style.setProperty("--theme-accent", (_e = settings["theme"]) == null ? void 0 : _e.secondary);
1376
+ document.body.style.setProperty("--theme-contrast", blackOrWhite((_f = settings["theme"]) == null ? void 0 : _f.background));
1369
1377
  }
1370
1378
  if (settings["pwa"]) {
1371
1379
  const link = window.document.createElement("link");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ztimson/momentum",
3
- "version": "0.50.3",
3
+ "version": "0.50.4",
4
4
  "description": "Client library for momentum",
5
5
  "keywords": ["Momentum"],
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
@@ -24,7 +24,7 @@
24
24
  "postbuild": "node -e \"const fs=require('fs');fs.cpSync('dist/index.mjs','../server/public/momentum.mjs');fs.cpSync('dist/index.cjs','../server/public/momentum.js')\""
25
25
  },
26
26
  "dependencies": {
27
- "@ztimson/utils": "0.22.6",
27
+ "@ztimson/utils": "0.23.6",
28
28
  "var-persist": "^1.0.1"
29
29
  },
30
30
  "devDependencies": {