@ztimson/momentum 1.1.8 → 1.1.9

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.
File without changes
package/dist/index.js CHANGED
@@ -2,6 +2,193 @@
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.momentum = {}));
3
3
  })(this, (function(exports2) {
4
4
  "use strict";
5
+ var dist = {};
6
+ var persist = {};
7
+ var hasRequiredPersist;
8
+ function requirePersist() {
9
+ if (hasRequiredPersist) return persist;
10
+ hasRequiredPersist = 1;
11
+ Object.defineProperty(persist, "__esModule", { value: true });
12
+ persist.persist = persist.Persist = void 0;
13
+ class Persist {
14
+ key;
15
+ options;
16
+ /** Backend service to store data, must implement `Storage` interface */
17
+ storage;
18
+ /** Listeners which should be notified on changes */
19
+ watches = {};
20
+ /** Private value field */
21
+ _value;
22
+ /** Current value or default if undefined */
23
+ get value() {
24
+ return this._value !== void 0 ? this._value : this.options?.default;
25
+ }
26
+ /** Set value with proxy object wrapper to sync future changes */
27
+ set value(v) {
28
+ if (v == null || typeof v != "object")
29
+ this._value = v;
30
+ else
31
+ this._value = new Proxy(v, {
32
+ get: (target, p) => {
33
+ const f = typeof target[p] == "function";
34
+ if (!f)
35
+ return target[p];
36
+ return (...args) => {
37
+ const value = target[p](...args);
38
+ this.save();
39
+ return value;
40
+ };
41
+ },
42
+ set: (target, p, newValue) => {
43
+ target[p] = newValue;
44
+ this.save();
45
+ return true;
46
+ }
47
+ });
48
+ this.save();
49
+ }
50
+ /**
51
+ * @param {string} key Primary key value will be stored under
52
+ * @param {PersistOptions<T>} options Configure using {@link PersistOptions}
53
+ */
54
+ constructor(key, options = {}) {
55
+ this.key = key;
56
+ this.options = options;
57
+ this.storage = options.storage || localStorage;
58
+ this.load();
59
+ }
60
+ /** Notify listeners of change */
61
+ notify(value) {
62
+ Object.values(this.watches).forEach((watch) => watch(value));
63
+ }
64
+ /** Delete value from storage */
65
+ clear() {
66
+ this.storage.removeItem(this.key);
67
+ }
68
+ /** Save current value to storage */
69
+ save() {
70
+ if (this._value === void 0)
71
+ this.clear();
72
+ else
73
+ this.storage.setItem(this.key, JSON.stringify(this._value));
74
+ this.notify(this.value);
75
+ }
76
+ /** Load value from storage */
77
+ load() {
78
+ if (this.storage[this.key] != void 0) {
79
+ let value = JSON.parse(this.storage.getItem(this.key));
80
+ if (value != null && typeof value == "object" && this.options.type)
81
+ value.__proto__ = this.options.type.prototype;
82
+ this.value = value;
83
+ } else
84
+ this.value = this.options.default || void 0;
85
+ }
86
+ /**
87
+ * Callback function which is run when there are changes
88
+ *
89
+ * @param {(value: T) => any} fn Callback will run on each change; it's passed the next value & it's return is ignored
90
+ * @returns {() => void} Function which will unsubscribe the watch/callback when called
91
+ */
92
+ watch(fn2) {
93
+ const index = Object.keys(this.watches).length;
94
+ this.watches[index] = fn2;
95
+ return () => {
96
+ delete this.watches[index];
97
+ };
98
+ }
99
+ /**
100
+ * Return value as JSON string
101
+ *
102
+ * @returns {string} Stringified object as JSON
103
+ */
104
+ toString() {
105
+ return JSON.stringify(this.value);
106
+ }
107
+ /**
108
+ * Return current value
109
+ *
110
+ * @returns {T} Current value
111
+ */
112
+ valueOf() {
113
+ return this.value;
114
+ }
115
+ }
116
+ persist.Persist = Persist;
117
+ function persist$1(options) {
118
+ return (target, prop) => {
119
+ const key = options?.key || `${target.constructor.name}.${prop.toString()}`;
120
+ const wrapper = new Persist(key, options);
121
+ Object.defineProperty(target, prop, {
122
+ get: function() {
123
+ return wrapper.value;
124
+ },
125
+ set: function(v) {
126
+ wrapper.value = v;
127
+ }
128
+ });
129
+ };
130
+ }
131
+ persist.persist = persist$1;
132
+ return persist;
133
+ }
134
+ var memoryStorage = {};
135
+ var hasRequiredMemoryStorage;
136
+ function requireMemoryStorage() {
137
+ if (hasRequiredMemoryStorage) return memoryStorage;
138
+ hasRequiredMemoryStorage = 1;
139
+ Object.defineProperty(memoryStorage, "__esModule", { value: true });
140
+ memoryStorage.MemoryStorage = void 0;
141
+ class MemoryStorage {
142
+ get length() {
143
+ return Object.keys(this).length;
144
+ }
145
+ clear() {
146
+ Object.keys(this).forEach((k) => this.removeItem(k));
147
+ }
148
+ getItem(key) {
149
+ return this[key];
150
+ }
151
+ key(index) {
152
+ return Object.keys(this)[index];
153
+ }
154
+ removeItem(key) {
155
+ delete this[key];
156
+ }
157
+ setItem(key, value) {
158
+ this[key] = value;
159
+ }
160
+ }
161
+ memoryStorage.MemoryStorage = MemoryStorage;
162
+ return memoryStorage;
163
+ }
164
+ var hasRequiredDist;
165
+ function requireDist() {
166
+ if (hasRequiredDist) return dist;
167
+ hasRequiredDist = 1;
168
+ (function(exports$1) {
169
+ var __createBinding = dist && dist.__createBinding || (Object.create ? (function(o, m, k, k2) {
170
+ if (k2 === void 0) k2 = k;
171
+ var desc = Object.getOwnPropertyDescriptor(m, k);
172
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
173
+ desc = { enumerable: true, get: function() {
174
+ return m[k];
175
+ } };
176
+ }
177
+ Object.defineProperty(o, k2, desc);
178
+ }) : (function(o, m, k, k2) {
179
+ if (k2 === void 0) k2 = k;
180
+ o[k2] = m[k];
181
+ }));
182
+ var __exportStar = dist && dist.__exportStar || function(m, exports$12) {
183
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$12, p)) __createBinding(exports$12, m, p);
184
+ };
185
+ Object.defineProperty(exports$1, "__esModule", { value: true });
186
+ __exportStar(requirePersist(), exports$1);
187
+ __exportStar(requireMemoryStorage(), exports$1);
188
+ })(dist);
189
+ return dist;
190
+ }
191
+ requireDist();
5
192
  function JSONAttemptParse(json, fallback) {
6
193
  try {
7
194
  return JSON.parse(json);
@@ -258,6 +445,8 @@
258
445
  }
259
446
  });
260
447
  }
448
+ key;
449
+ options;
261
450
  _loading;
262
451
  store = /* @__PURE__ */ new Map();
263
452
  timers = /* @__PURE__ */ new Map();
@@ -434,8 +623,8 @@
434
623
  /** Get all cached items */
435
624
  values = this.all;
436
625
  }
437
- function contrast(background) {
438
- const exploded = background?.match(background.length >= 6 ? /[0-9a-fA-F]{2}/g : /[0-9a-fA-F]/g);
626
+ function contrast(color) {
627
+ const exploded = color?.match(color.length >= 6 ? /[0-9a-fA-F]{2}/g : /[0-9a-fA-F]/g);
439
628
  if (!exploded || exploded?.length < 3) return "black";
440
629
  const [r, g, b] = exploded.map((hex) => parseInt(hex.length == 1 ? `${hex}${hex}` : hex, 16));
441
630
  const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
@@ -682,6 +871,8 @@
682
871
  };
683
872
  });
684
873
  }
874
+ database;
875
+ version;
685
876
  schemaLock = new AsyncLock();
686
877
  upgrading = false;
687
878
  connection;
@@ -733,6 +924,9 @@
733
924
  if (!exists) this.database.createTable(this.name);
734
925
  });
735
926
  }
927
+ database;
928
+ name;
929
+ key;
736
930
  async tx(table, fn2, readonly = false) {
737
931
  await this.database.waitForUpgrade();
738
932
  const db = await this.database.connection;
@@ -1325,6 +1519,7 @@
1325
1519
  constructor(prefix = "") {
1326
1520
  this.prefix = prefix;
1327
1521
  }
1522
+ prefix;
1328
1523
  listeners = [];
1329
1524
  emit(event, ...args) {
1330
1525
  const parsed = event instanceof PathEvent ? event : new PathEvent(`${this.prefix}/${event}`);
@@ -1367,193 +1562,6 @@
1367
1562
  emitter.on("**", (event, ...args) => this.emit(event, ...args));
1368
1563
  }
1369
1564
  }
1370
- var dist = {};
1371
- var persist = {};
1372
- var hasRequiredPersist;
1373
- function requirePersist() {
1374
- if (hasRequiredPersist) return persist;
1375
- hasRequiredPersist = 1;
1376
- Object.defineProperty(persist, "__esModule", { value: true });
1377
- persist.persist = persist.Persist = void 0;
1378
- class Persist {
1379
- key;
1380
- options;
1381
- /** Backend service to store data, must implement `Storage` interface */
1382
- storage;
1383
- /** Listeners which should be notified on changes */
1384
- watches = {};
1385
- /** Private value field */
1386
- _value;
1387
- /** Current value or default if undefined */
1388
- get value() {
1389
- return this._value !== void 0 ? this._value : this.options?.default;
1390
- }
1391
- /** Set value with proxy object wrapper to sync future changes */
1392
- set value(v) {
1393
- if (v == null || typeof v != "object")
1394
- this._value = v;
1395
- else
1396
- this._value = new Proxy(v, {
1397
- get: (target, p) => {
1398
- const f = typeof target[p] == "function";
1399
- if (!f)
1400
- return target[p];
1401
- return (...args) => {
1402
- const value = target[p](...args);
1403
- this.save();
1404
- return value;
1405
- };
1406
- },
1407
- set: (target, p, newValue) => {
1408
- target[p] = newValue;
1409
- this.save();
1410
- return true;
1411
- }
1412
- });
1413
- this.save();
1414
- }
1415
- /**
1416
- * @param {string} key Primary key value will be stored under
1417
- * @param {PersistOptions<T>} options Configure using {@link PersistOptions}
1418
- */
1419
- constructor(key, options = {}) {
1420
- this.key = key;
1421
- this.options = options;
1422
- this.storage = options.storage || localStorage;
1423
- this.load();
1424
- }
1425
- /** Notify listeners of change */
1426
- notify(value) {
1427
- Object.values(this.watches).forEach((watch) => watch(value));
1428
- }
1429
- /** Delete value from storage */
1430
- clear() {
1431
- this.storage.removeItem(this.key);
1432
- }
1433
- /** Save current value to storage */
1434
- save() {
1435
- if (this._value === void 0)
1436
- this.clear();
1437
- else
1438
- this.storage.setItem(this.key, JSON.stringify(this._value));
1439
- this.notify(this.value);
1440
- }
1441
- /** Load value from storage */
1442
- load() {
1443
- if (this.storage[this.key] != void 0) {
1444
- let value = JSON.parse(this.storage.getItem(this.key));
1445
- if (value != null && typeof value == "object" && this.options.type)
1446
- value.__proto__ = this.options.type.prototype;
1447
- this.value = value;
1448
- } else
1449
- this.value = this.options.default || void 0;
1450
- }
1451
- /**
1452
- * Callback function which is run when there are changes
1453
- *
1454
- * @param {(value: T) => any} fn Callback will run on each change; it's passed the next value & it's return is ignored
1455
- * @returns {() => void} Function which will unsubscribe the watch/callback when called
1456
- */
1457
- watch(fn2) {
1458
- const index = Object.keys(this.watches).length;
1459
- this.watches[index] = fn2;
1460
- return () => {
1461
- delete this.watches[index];
1462
- };
1463
- }
1464
- /**
1465
- * Return value as JSON string
1466
- *
1467
- * @returns {string} Stringified object as JSON
1468
- */
1469
- toString() {
1470
- return JSON.stringify(this.value);
1471
- }
1472
- /**
1473
- * Return current value
1474
- *
1475
- * @returns {T} Current value
1476
- */
1477
- valueOf() {
1478
- return this.value;
1479
- }
1480
- }
1481
- persist.Persist = Persist;
1482
- function persist$1(options) {
1483
- return (target, prop) => {
1484
- const key = options?.key || `${target.constructor.name}.${prop.toString()}`;
1485
- const wrapper = new Persist(key, options);
1486
- Object.defineProperty(target, prop, {
1487
- get: function() {
1488
- return wrapper.value;
1489
- },
1490
- set: function(v) {
1491
- wrapper.value = v;
1492
- }
1493
- });
1494
- };
1495
- }
1496
- persist.persist = persist$1;
1497
- return persist;
1498
- }
1499
- var memoryStorage = {};
1500
- var hasRequiredMemoryStorage;
1501
- function requireMemoryStorage() {
1502
- if (hasRequiredMemoryStorage) return memoryStorage;
1503
- hasRequiredMemoryStorage = 1;
1504
- Object.defineProperty(memoryStorage, "__esModule", { value: true });
1505
- memoryStorage.MemoryStorage = void 0;
1506
- class MemoryStorage {
1507
- get length() {
1508
- return Object.keys(this).length;
1509
- }
1510
- clear() {
1511
- Object.keys(this).forEach((k) => this.removeItem(k));
1512
- }
1513
- getItem(key) {
1514
- return this[key];
1515
- }
1516
- key(index) {
1517
- return Object.keys(this)[index];
1518
- }
1519
- removeItem(key) {
1520
- delete this[key];
1521
- }
1522
- setItem(key, value) {
1523
- this[key] = value;
1524
- }
1525
- }
1526
- memoryStorage.MemoryStorage = MemoryStorage;
1527
- return memoryStorage;
1528
- }
1529
- var hasRequiredDist;
1530
- function requireDist() {
1531
- if (hasRequiredDist) return dist;
1532
- hasRequiredDist = 1;
1533
- (function(exports$1) {
1534
- var __createBinding = dist && dist.__createBinding || (Object.create ? (function(o, m, k, k2) {
1535
- if (k2 === void 0) k2 = k;
1536
- var desc = Object.getOwnPropertyDescriptor(m, k);
1537
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1538
- desc = { enumerable: true, get: function() {
1539
- return m[k];
1540
- } };
1541
- }
1542
- Object.defineProperty(o, k2, desc);
1543
- }) : (function(o, m, k, k2) {
1544
- if (k2 === void 0) k2 = k;
1545
- o[k2] = m[k];
1546
- }));
1547
- var __exportStar = dist && dist.__exportStar || function(m, exports$12) {
1548
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$12, p)) __createBinding(exports$12, m, p);
1549
- };
1550
- Object.defineProperty(exports$1, "__esModule", { value: true });
1551
- __exportStar(requirePersist(), exports$1);
1552
- __exportStar(requireMemoryStorage(), exports$1);
1553
- })(dist);
1554
- return dist;
1555
- }
1556
- requireDist();
1557
1565
  function treeBuilder(schemas) {
1558
1566
  const tree = [];
1559
1567
  function findOrCreateNode(tree2, segment, fullPath) {
@@ -1638,6 +1646,7 @@
1638
1646
  }
1639
1647
  });
1640
1648
  }
1649
+ momentum;
1641
1650
  subscribers = {};
1642
1651
  cache;
1643
1652
  opts;
@@ -1785,6 +1794,7 @@
1785
1794
  super(momentum, { module: "actions", key: "_id" });
1786
1795
  this.momentum = momentum;
1787
1796
  }
1797
+ momentum;
1788
1798
  /**
1789
1799
  * Manually trigger an actions execution
1790
1800
  * @param {string} id Action ID
@@ -1809,6 +1819,7 @@
1809
1819
  super("ai");
1810
1820
  this.momentum = momentum;
1811
1821
  }
1822
+ momentum;
1812
1823
  /** Cancel current AI requests */
1813
1824
  abort() {
1814
1825
  return this.momentum.api.request({ url: "/api/ai/abort", method: "POST" });
@@ -2125,6 +2136,7 @@
2125
2136
  setTimeout(() => this.consentPrompt(), 1e3);
2126
2137
  }
2127
2138
  }
2139
+ momentum;
2128
2140
  lastPage;
2129
2141
  _ready;
2130
2142
  ready = new Promise((res) => this._ready = res);
@@ -2321,6 +2333,7 @@
2321
2333
  if (token) this.token = token;
2322
2334
  }
2323
2335
  }
2336
+ momentum;
2324
2337
  emitter = new PathEventEmitter("api");
2325
2338
  pending = {};
2326
2339
  storageKey;
@@ -2389,6 +2402,7 @@
2389
2402
  super("audit");
2390
2403
  this.momentum = momentum;
2391
2404
  }
2405
+ momentum;
2392
2406
  async available(module2) {
2393
2407
  return this.momentum.api.request({ url: `api/audit/${module2 || ""}` });
2394
2408
  }
@@ -2405,6 +2419,7 @@
2405
2419
  constructor(momentum) {
2406
2420
  this.momentum = momentum;
2407
2421
  }
2422
+ momentum;
2408
2423
  /**
2409
2424
  * Set default 2FA method
2410
2425
  * @param {string} username User to set 2FA method on
@@ -2464,6 +2479,7 @@
2464
2479
  if (this.momentum.opts.expiredStrategy == "reload") window.location.reload();
2465
2480
  });
2466
2481
  }
2482
+ momentum;
2467
2483
  /** Manage user 2FA */
2468
2484
  totp;
2469
2485
  session;
@@ -2637,6 +2653,7 @@ Must be either: call, email or sms`);
2637
2653
  super();
2638
2654
  this.momentum = momentum;
2639
2655
  }
2656
+ momentum;
2640
2657
  /**
2641
2658
  * Place a call to number
2642
2659
  * @param {Call} message Text that will be converted to speech
@@ -2764,6 +2781,7 @@ Must be either: call, email or sms`);
2764
2781
  }
2765
2782
  }
2766
2783
  }
2784
+ momentum;
2767
2785
  captcha = new Captcha();
2768
2786
  installTimeout;
2769
2787
  nativePwaPrompt;
@@ -3051,6 +3069,7 @@ Must be either: call, email or sms`);
3051
3069
  super();
3052
3070
  this.momentum = momentum;
3053
3071
  }
3072
+ momentum;
3054
3073
  subscribers = {};
3055
3074
  /**
3056
3075
  * Create new document in collection
@@ -3155,12 +3174,14 @@ Must be either: call, email or sms`);
3155
3174
  super(momentum, { module: "discounts", key: "_id" });
3156
3175
  this.momentum = momentum;
3157
3176
  }
3177
+ momentum;
3158
3178
  }
3159
3179
  class Email extends PathEventEmitter {
3160
3180
  constructor(momentum) {
3161
3181
  super();
3162
3182
  this.momentum = momentum;
3163
3183
  }
3184
+ momentum;
3164
3185
  /**
3165
3186
  * Send an Email
3166
3187
  * @param {Mail} email Email information
@@ -3178,12 +3199,14 @@ Must be either: call, email or sms`);
3178
3199
  super(momentum, { module: "forms", key: "path" });
3179
3200
  this.momentum = momentum;
3180
3201
  }
3202
+ momentum;
3181
3203
  }
3182
3204
  class Groups extends AssetController {
3183
3205
  constructor(momentum) {
3184
3206
  super(momentum, { module: "groups", key: "_id" });
3185
3207
  this.momentum = momentum;
3186
3208
  }
3209
+ momentum;
3187
3210
  }
3188
3211
  class Logger extends PathEventEmitter {
3189
3212
  constructor(momentum) {
@@ -3254,6 +3277,7 @@ ${log}`;
3254
3277
  }
3255
3278
  };
3256
3279
  }
3280
+ momentum;
3257
3281
  static cache = {};
3258
3282
  channel;
3259
3283
  logLevel;
@@ -3401,6 +3425,7 @@ ${log}`;
3401
3425
  this.momentum = momentum;
3402
3426
  this.subscription.then((resp) => this.enabled = !!resp);
3403
3427
  }
3428
+ momentum;
3404
3429
  _enabled = false;
3405
3430
  /** Are notifications enabled */
3406
3431
  get enabled() {
@@ -3458,6 +3483,7 @@ ${log}`;
3458
3483
  super(momentum, { module: "blacklist", path: "routes/blacklist", key: "_id" });
3459
3484
  this.momentum = momentum;
3460
3485
  }
3486
+ momentum;
3461
3487
  async update(ignore) {
3462
3488
  throw new Error("Not supported");
3463
3489
  }
@@ -3467,6 +3493,7 @@ ${log}`;
3467
3493
  super(momentum, { module: "rate_limit", path: "routes/limit", key: "_id" });
3468
3494
  this.momentum = momentum;
3469
3495
  }
3496
+ momentum;
3470
3497
  }
3471
3498
  class Routes extends PathEventEmitter {
3472
3499
  constructor(momentum) {
@@ -3477,6 +3504,7 @@ ${log}`;
3477
3504
  this.relayEvents(this.blacklist);
3478
3505
  this.relayEvents(this.rateLimiter);
3479
3506
  }
3507
+ momentum;
3480
3508
  blacklist;
3481
3509
  rateLimiter;
3482
3510
  }
@@ -3485,6 +3513,7 @@ ${log}`;
3485
3513
  super(momentum, { module: "templates", key: "_id" });
3486
3514
  this.momentum = momentum;
3487
3515
  }
3516
+ momentum;
3488
3517
  render(id, data) {
3489
3518
  return this.momentum.api.request({ url: `/api/templates/render/${id}`, method: "POST", body: data });
3490
3519
  }
@@ -3497,6 +3526,7 @@ ${log}`;
3497
3526
  super(momentum, { module: "transactions", key: "_id" });
3498
3527
  this.momentum = momentum;
3499
3528
  }
3529
+ momentum;
3500
3530
  /** Stripe object */
3501
3531
  stripe;
3502
3532
  /**
@@ -3618,6 +3648,7 @@ ${log}`;
3618
3648
  super();
3619
3649
  this.momentum = momentum;
3620
3650
  }
3651
+ momentum;
3621
3652
  createPdf(body, options) {
3622
3653
  return this.momentum.api.request({ url: `api/` + PES`pdf`, body: { ...body, options } }).then(async (resp) => {
3623
3654
  if (options?.downloadAs) {
@@ -3676,6 +3707,7 @@ ${log}`;
3676
3707
  this.controller = new AssetController(momentum, { module: "products", key: "_id" });
3677
3708
  this.relayEvents(this.controller);
3678
3709
  }
3710
+ momentum;
3679
3711
  controller;
3680
3712
  get cache() {
3681
3713
  return this.controller.cache;
@@ -3712,12 +3744,14 @@ ${log}`;
3712
3744
  super(momentum, { module: "schemas", key: "path" });
3713
3745
  this.momentum = momentum;
3714
3746
  }
3747
+ momentum;
3715
3748
  }
3716
3749
  class Sms extends PathEventEmitter {
3717
3750
  constructor(momentum) {
3718
3751
  super();
3719
3752
  this.momentum = momentum;
3720
3753
  }
3754
+ momentum;
3721
3755
  /**
3722
3756
  * Send an sms to a number
3723
3757
  * @param {Message} message Text that will be sent
@@ -3735,6 +3769,7 @@ ${log}`;
3735
3769
  if (user !== void 0 && this.momentum.api.token != this.token) this.connect();
3736
3770
  });
3737
3771
  }
3772
+ momentum;
3738
3773
  static pollingSpeed = 15e3;
3739
3774
  connection;
3740
3775
  connecting;
@@ -3870,6 +3905,8 @@ ${log}`;
3870
3905
  }
3871
3906
  });
3872
3907
  }
3908
+ momentum;
3909
+ module;
3873
3910
  subscribers = {};
3874
3911
  cache = new Cache("path");
3875
3912
  /**
@@ -4034,6 +4071,7 @@ ${log}`;
4034
4071
  this.controller = new AssetController(momentum, { module: "tokens", key: "_id" });
4035
4072
  this.relayEvents(this.controller);
4036
4073
  }
4074
+ momentum;
4037
4075
  controller;
4038
4076
  get cache() {
4039
4077
  return this.controller.cache;
@@ -4079,6 +4117,8 @@ ${log}`;
4079
4117
  this.momentum = momentum;
4080
4118
  this.socket = socket;
4081
4119
  }
4120
+ momentum;
4121
+ socket;
4082
4122
  afterRead(user) {
4083
4123
  if (user == null) return null;
4084
4124
  user.image = this.profileImage(user._id);
@@ -4120,6 +4160,7 @@ ${log}`;
4120
4160
  this.all(true);
4121
4161
  });
4122
4162
  }
4163
+ momentum;
4123
4164
  /**
4124
4165
  * Get all schemas organized into a map
4125
4166
  * @param {boolean} reload Reload instead of using cache
@@ -4144,13 +4185,15 @@ ${log}`;
4144
4185
  super(momentum, "static");
4145
4186
  this.momentum = momentum;
4146
4187
  }
4188
+ momentum;
4147
4189
  }
4148
- const version = "1.1.8";
4190
+ const version = "1.1.9";
4149
4191
  class WebRtc extends PathEventEmitter {
4150
4192
  constructor(momentum) {
4151
4193
  super("webrtc");
4152
4194
  this.momentum = momentum;
4153
4195
  }
4196
+ momentum;
4154
4197
  get ice() {
4155
4198
  const host = this.momentum.url.hostname.replace("localhost", "127.0.0.1");
4156
4199
  const port = this.momentum.settings.cache.get("webrtc_port")?.value;
@@ -4264,6 +4307,7 @@ ${log}`;
4264
4307
  constructor(momentum) {
4265
4308
  this.momentum = momentum;
4266
4309
  }
4310
+ momentum;
4267
4311
  /** Get all permissions */
4268
4312
  all = () => this.momentum.auth.session?.permissions || [];
4269
4313
  /** Filter list of permissions to ones the user has */
package/dist/index.mjs CHANGED
@@ -1,3 +1,190 @@
1
+ var dist = {};
2
+ var persist = {};
3
+ var hasRequiredPersist;
4
+ function requirePersist() {
5
+ if (hasRequiredPersist) return persist;
6
+ hasRequiredPersist = 1;
7
+ Object.defineProperty(persist, "__esModule", { value: true });
8
+ persist.persist = persist.Persist = void 0;
9
+ class Persist {
10
+ key;
11
+ options;
12
+ /** Backend service to store data, must implement `Storage` interface */
13
+ storage;
14
+ /** Listeners which should be notified on changes */
15
+ watches = {};
16
+ /** Private value field */
17
+ _value;
18
+ /** Current value or default if undefined */
19
+ get value() {
20
+ return this._value !== void 0 ? this._value : this.options?.default;
21
+ }
22
+ /** Set value with proxy object wrapper to sync future changes */
23
+ set value(v) {
24
+ if (v == null || typeof v != "object")
25
+ this._value = v;
26
+ else
27
+ this._value = new Proxy(v, {
28
+ get: (target, p) => {
29
+ const f = typeof target[p] == "function";
30
+ if (!f)
31
+ return target[p];
32
+ return (...args) => {
33
+ const value = target[p](...args);
34
+ this.save();
35
+ return value;
36
+ };
37
+ },
38
+ set: (target, p, newValue) => {
39
+ target[p] = newValue;
40
+ this.save();
41
+ return true;
42
+ }
43
+ });
44
+ this.save();
45
+ }
46
+ /**
47
+ * @param {string} key Primary key value will be stored under
48
+ * @param {PersistOptions<T>} options Configure using {@link PersistOptions}
49
+ */
50
+ constructor(key, options = {}) {
51
+ this.key = key;
52
+ this.options = options;
53
+ this.storage = options.storage || localStorage;
54
+ this.load();
55
+ }
56
+ /** Notify listeners of change */
57
+ notify(value) {
58
+ Object.values(this.watches).forEach((watch) => watch(value));
59
+ }
60
+ /** Delete value from storage */
61
+ clear() {
62
+ this.storage.removeItem(this.key);
63
+ }
64
+ /** Save current value to storage */
65
+ save() {
66
+ if (this._value === void 0)
67
+ this.clear();
68
+ else
69
+ this.storage.setItem(this.key, JSON.stringify(this._value));
70
+ this.notify(this.value);
71
+ }
72
+ /** Load value from storage */
73
+ load() {
74
+ if (this.storage[this.key] != void 0) {
75
+ let value = JSON.parse(this.storage.getItem(this.key));
76
+ if (value != null && typeof value == "object" && this.options.type)
77
+ value.__proto__ = this.options.type.prototype;
78
+ this.value = value;
79
+ } else
80
+ this.value = this.options.default || void 0;
81
+ }
82
+ /**
83
+ * Callback function which is run when there are changes
84
+ *
85
+ * @param {(value: T) => any} fn Callback will run on each change; it's passed the next value & it's return is ignored
86
+ * @returns {() => void} Function which will unsubscribe the watch/callback when called
87
+ */
88
+ watch(fn2) {
89
+ const index = Object.keys(this.watches).length;
90
+ this.watches[index] = fn2;
91
+ return () => {
92
+ delete this.watches[index];
93
+ };
94
+ }
95
+ /**
96
+ * Return value as JSON string
97
+ *
98
+ * @returns {string} Stringified object as JSON
99
+ */
100
+ toString() {
101
+ return JSON.stringify(this.value);
102
+ }
103
+ /**
104
+ * Return current value
105
+ *
106
+ * @returns {T} Current value
107
+ */
108
+ valueOf() {
109
+ return this.value;
110
+ }
111
+ }
112
+ persist.Persist = Persist;
113
+ function persist$1(options) {
114
+ return (target, prop) => {
115
+ const key = options?.key || `${target.constructor.name}.${prop.toString()}`;
116
+ const wrapper = new Persist(key, options);
117
+ Object.defineProperty(target, prop, {
118
+ get: function() {
119
+ return wrapper.value;
120
+ },
121
+ set: function(v) {
122
+ wrapper.value = v;
123
+ }
124
+ });
125
+ };
126
+ }
127
+ persist.persist = persist$1;
128
+ return persist;
129
+ }
130
+ var memoryStorage = {};
131
+ var hasRequiredMemoryStorage;
132
+ function requireMemoryStorage() {
133
+ if (hasRequiredMemoryStorage) return memoryStorage;
134
+ hasRequiredMemoryStorage = 1;
135
+ Object.defineProperty(memoryStorage, "__esModule", { value: true });
136
+ memoryStorage.MemoryStorage = void 0;
137
+ class MemoryStorage {
138
+ get length() {
139
+ return Object.keys(this).length;
140
+ }
141
+ clear() {
142
+ Object.keys(this).forEach((k) => this.removeItem(k));
143
+ }
144
+ getItem(key) {
145
+ return this[key];
146
+ }
147
+ key(index) {
148
+ return Object.keys(this)[index];
149
+ }
150
+ removeItem(key) {
151
+ delete this[key];
152
+ }
153
+ setItem(key, value) {
154
+ this[key] = value;
155
+ }
156
+ }
157
+ memoryStorage.MemoryStorage = MemoryStorage;
158
+ return memoryStorage;
159
+ }
160
+ var hasRequiredDist;
161
+ function requireDist() {
162
+ if (hasRequiredDist) return dist;
163
+ hasRequiredDist = 1;
164
+ (function(exports$1) {
165
+ var __createBinding = dist && dist.__createBinding || (Object.create ? (function(o, m, k, k2) {
166
+ if (k2 === void 0) k2 = k;
167
+ var desc = Object.getOwnPropertyDescriptor(m, k);
168
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
169
+ desc = { enumerable: true, get: function() {
170
+ return m[k];
171
+ } };
172
+ }
173
+ Object.defineProperty(o, k2, desc);
174
+ }) : (function(o, m, k, k2) {
175
+ if (k2 === void 0) k2 = k;
176
+ o[k2] = m[k];
177
+ }));
178
+ var __exportStar = dist && dist.__exportStar || function(m, exports$12) {
179
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$12, p)) __createBinding(exports$12, m, p);
180
+ };
181
+ Object.defineProperty(exports$1, "__esModule", { value: true });
182
+ __exportStar(requirePersist(), exports$1);
183
+ __exportStar(requireMemoryStorage(), exports$1);
184
+ })(dist);
185
+ return dist;
186
+ }
187
+ requireDist();
1
188
  function JSONAttemptParse(json, fallback) {
2
189
  try {
3
190
  return JSON.parse(json);
@@ -254,6 +441,8 @@ class Cache {
254
441
  }
255
442
  });
256
443
  }
444
+ key;
445
+ options;
257
446
  _loading;
258
447
  store = /* @__PURE__ */ new Map();
259
448
  timers = /* @__PURE__ */ new Map();
@@ -430,8 +619,8 @@ class Cache {
430
619
  /** Get all cached items */
431
620
  values = this.all;
432
621
  }
433
- function contrast(background) {
434
- const exploded = background?.match(background.length >= 6 ? /[0-9a-fA-F]{2}/g : /[0-9a-fA-F]/g);
622
+ function contrast(color) {
623
+ const exploded = color?.match(color.length >= 6 ? /[0-9a-fA-F]{2}/g : /[0-9a-fA-F]/g);
435
624
  if (!exploded || exploded?.length < 3) return "black";
436
625
  const [r, g, b] = exploded.map((hex) => parseInt(hex.length == 1 ? `${hex}${hex}` : hex, 16));
437
626
  const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
@@ -678,6 +867,8 @@ class Database {
678
867
  };
679
868
  });
680
869
  }
870
+ database;
871
+ version;
681
872
  schemaLock = new AsyncLock();
682
873
  upgrading = false;
683
874
  connection;
@@ -729,6 +920,9 @@ class Table {
729
920
  if (!exists) this.database.createTable(this.name);
730
921
  });
731
922
  }
923
+ database;
924
+ name;
925
+ key;
732
926
  async tx(table, fn2, readonly = false) {
733
927
  await this.database.waitForUpgrade();
734
928
  const db = await this.database.connection;
@@ -1321,6 +1515,7 @@ class PathEventEmitter {
1321
1515
  constructor(prefix = "") {
1322
1516
  this.prefix = prefix;
1323
1517
  }
1518
+ prefix;
1324
1519
  listeners = [];
1325
1520
  emit(event, ...args) {
1326
1521
  const parsed = event instanceof PathEvent ? event : new PathEvent(`${this.prefix}/${event}`);
@@ -1363,193 +1558,6 @@ class PathEventEmitter {
1363
1558
  emitter.on("**", (event, ...args) => this.emit(event, ...args));
1364
1559
  }
1365
1560
  }
1366
- var dist = {};
1367
- var persist = {};
1368
- var hasRequiredPersist;
1369
- function requirePersist() {
1370
- if (hasRequiredPersist) return persist;
1371
- hasRequiredPersist = 1;
1372
- Object.defineProperty(persist, "__esModule", { value: true });
1373
- persist.persist = persist.Persist = void 0;
1374
- class Persist {
1375
- key;
1376
- options;
1377
- /** Backend service to store data, must implement `Storage` interface */
1378
- storage;
1379
- /** Listeners which should be notified on changes */
1380
- watches = {};
1381
- /** Private value field */
1382
- _value;
1383
- /** Current value or default if undefined */
1384
- get value() {
1385
- return this._value !== void 0 ? this._value : this.options?.default;
1386
- }
1387
- /** Set value with proxy object wrapper to sync future changes */
1388
- set value(v) {
1389
- if (v == null || typeof v != "object")
1390
- this._value = v;
1391
- else
1392
- this._value = new Proxy(v, {
1393
- get: (target, p) => {
1394
- const f = typeof target[p] == "function";
1395
- if (!f)
1396
- return target[p];
1397
- return (...args) => {
1398
- const value = target[p](...args);
1399
- this.save();
1400
- return value;
1401
- };
1402
- },
1403
- set: (target, p, newValue) => {
1404
- target[p] = newValue;
1405
- this.save();
1406
- return true;
1407
- }
1408
- });
1409
- this.save();
1410
- }
1411
- /**
1412
- * @param {string} key Primary key value will be stored under
1413
- * @param {PersistOptions<T>} options Configure using {@link PersistOptions}
1414
- */
1415
- constructor(key, options = {}) {
1416
- this.key = key;
1417
- this.options = options;
1418
- this.storage = options.storage || localStorage;
1419
- this.load();
1420
- }
1421
- /** Notify listeners of change */
1422
- notify(value) {
1423
- Object.values(this.watches).forEach((watch) => watch(value));
1424
- }
1425
- /** Delete value from storage */
1426
- clear() {
1427
- this.storage.removeItem(this.key);
1428
- }
1429
- /** Save current value to storage */
1430
- save() {
1431
- if (this._value === void 0)
1432
- this.clear();
1433
- else
1434
- this.storage.setItem(this.key, JSON.stringify(this._value));
1435
- this.notify(this.value);
1436
- }
1437
- /** Load value from storage */
1438
- load() {
1439
- if (this.storage[this.key] != void 0) {
1440
- let value = JSON.parse(this.storage.getItem(this.key));
1441
- if (value != null && typeof value == "object" && this.options.type)
1442
- value.__proto__ = this.options.type.prototype;
1443
- this.value = value;
1444
- } else
1445
- this.value = this.options.default || void 0;
1446
- }
1447
- /**
1448
- * Callback function which is run when there are changes
1449
- *
1450
- * @param {(value: T) => any} fn Callback will run on each change; it's passed the next value & it's return is ignored
1451
- * @returns {() => void} Function which will unsubscribe the watch/callback when called
1452
- */
1453
- watch(fn2) {
1454
- const index = Object.keys(this.watches).length;
1455
- this.watches[index] = fn2;
1456
- return () => {
1457
- delete this.watches[index];
1458
- };
1459
- }
1460
- /**
1461
- * Return value as JSON string
1462
- *
1463
- * @returns {string} Stringified object as JSON
1464
- */
1465
- toString() {
1466
- return JSON.stringify(this.value);
1467
- }
1468
- /**
1469
- * Return current value
1470
- *
1471
- * @returns {T} Current value
1472
- */
1473
- valueOf() {
1474
- return this.value;
1475
- }
1476
- }
1477
- persist.Persist = Persist;
1478
- function persist$1(options) {
1479
- return (target, prop) => {
1480
- const key = options?.key || `${target.constructor.name}.${prop.toString()}`;
1481
- const wrapper = new Persist(key, options);
1482
- Object.defineProperty(target, prop, {
1483
- get: function() {
1484
- return wrapper.value;
1485
- },
1486
- set: function(v) {
1487
- wrapper.value = v;
1488
- }
1489
- });
1490
- };
1491
- }
1492
- persist.persist = persist$1;
1493
- return persist;
1494
- }
1495
- var memoryStorage = {};
1496
- var hasRequiredMemoryStorage;
1497
- function requireMemoryStorage() {
1498
- if (hasRequiredMemoryStorage) return memoryStorage;
1499
- hasRequiredMemoryStorage = 1;
1500
- Object.defineProperty(memoryStorage, "__esModule", { value: true });
1501
- memoryStorage.MemoryStorage = void 0;
1502
- class MemoryStorage {
1503
- get length() {
1504
- return Object.keys(this).length;
1505
- }
1506
- clear() {
1507
- Object.keys(this).forEach((k) => this.removeItem(k));
1508
- }
1509
- getItem(key) {
1510
- return this[key];
1511
- }
1512
- key(index) {
1513
- return Object.keys(this)[index];
1514
- }
1515
- removeItem(key) {
1516
- delete this[key];
1517
- }
1518
- setItem(key, value) {
1519
- this[key] = value;
1520
- }
1521
- }
1522
- memoryStorage.MemoryStorage = MemoryStorage;
1523
- return memoryStorage;
1524
- }
1525
- var hasRequiredDist;
1526
- function requireDist() {
1527
- if (hasRequiredDist) return dist;
1528
- hasRequiredDist = 1;
1529
- (function(exports$1) {
1530
- var __createBinding = dist && dist.__createBinding || (Object.create ? (function(o, m, k, k2) {
1531
- if (k2 === void 0) k2 = k;
1532
- var desc = Object.getOwnPropertyDescriptor(m, k);
1533
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1534
- desc = { enumerable: true, get: function() {
1535
- return m[k];
1536
- } };
1537
- }
1538
- Object.defineProperty(o, k2, desc);
1539
- }) : (function(o, m, k, k2) {
1540
- if (k2 === void 0) k2 = k;
1541
- o[k2] = m[k];
1542
- }));
1543
- var __exportStar = dist && dist.__exportStar || function(m, exports$12) {
1544
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$12, p)) __createBinding(exports$12, m, p);
1545
- };
1546
- Object.defineProperty(exports$1, "__esModule", { value: true });
1547
- __exportStar(requirePersist(), exports$1);
1548
- __exportStar(requireMemoryStorage(), exports$1);
1549
- })(dist);
1550
- return dist;
1551
- }
1552
- requireDist();
1553
1561
  function treeBuilder(schemas) {
1554
1562
  const tree = [];
1555
1563
  function findOrCreateNode(tree2, segment, fullPath) {
@@ -1634,6 +1642,7 @@ class AssetController extends PathEventEmitter {
1634
1642
  }
1635
1643
  });
1636
1644
  }
1645
+ momentum;
1637
1646
  subscribers = {};
1638
1647
  cache;
1639
1648
  opts;
@@ -1781,6 +1790,7 @@ class Actions extends AssetController {
1781
1790
  super(momentum, { module: "actions", key: "_id" });
1782
1791
  this.momentum = momentum;
1783
1792
  }
1793
+ momentum;
1784
1794
  /**
1785
1795
  * Manually trigger an actions execution
1786
1796
  * @param {string} id Action ID
@@ -1805,6 +1815,7 @@ class Ai extends PathEventEmitter {
1805
1815
  super("ai");
1806
1816
  this.momentum = momentum;
1807
1817
  }
1818
+ momentum;
1808
1819
  /** Cancel current AI requests */
1809
1820
  abort() {
1810
1821
  return this.momentum.api.request({ url: "/api/ai/abort", method: "POST" });
@@ -2121,6 +2132,7 @@ class Analytics extends AssetController {
2121
2132
  setTimeout(() => this.consentPrompt(), 1e3);
2122
2133
  }
2123
2134
  }
2135
+ momentum;
2124
2136
  lastPage;
2125
2137
  _ready;
2126
2138
  ready = new Promise((res) => this._ready = res);
@@ -2317,6 +2329,7 @@ class Api extends Http {
2317
2329
  if (token) this.token = token;
2318
2330
  }
2319
2331
  }
2332
+ momentum;
2320
2333
  emitter = new PathEventEmitter("api");
2321
2334
  pending = {};
2322
2335
  storageKey;
@@ -2385,6 +2398,7 @@ class Audit extends PathEventEmitter {
2385
2398
  super("audit");
2386
2399
  this.momentum = momentum;
2387
2400
  }
2401
+ momentum;
2388
2402
  async available(module) {
2389
2403
  return this.momentum.api.request({ url: `api/audit/${module || ""}` });
2390
2404
  }
@@ -2401,6 +2415,7 @@ class Totp {
2401
2415
  constructor(momentum) {
2402
2416
  this.momentum = momentum;
2403
2417
  }
2418
+ momentum;
2404
2419
  /**
2405
2420
  * Set default 2FA method
2406
2421
  * @param {string} username User to set 2FA method on
@@ -2460,6 +2475,7 @@ class Auth extends PathEventEmitter {
2460
2475
  if (this.momentum.opts.expiredStrategy == "reload") window.location.reload();
2461
2476
  });
2462
2477
  }
2478
+ momentum;
2463
2479
  /** Manage user 2FA */
2464
2480
  totp;
2465
2481
  session;
@@ -2633,6 +2649,7 @@ class Call extends PathEventEmitter {
2633
2649
  super();
2634
2650
  this.momentum = momentum;
2635
2651
  }
2652
+ momentum;
2636
2653
  /**
2637
2654
  * Place a call to number
2638
2655
  * @param {Call} message Text that will be converted to speech
@@ -2760,6 +2777,7 @@ class Client extends PathEventEmitter {
2760
2777
  }
2761
2778
  }
2762
2779
  }
2780
+ momentum;
2763
2781
  captcha = new Captcha();
2764
2782
  installTimeout;
2765
2783
  nativePwaPrompt;
@@ -3047,6 +3065,7 @@ class Data extends PathEventEmitter {
3047
3065
  super();
3048
3066
  this.momentum = momentum;
3049
3067
  }
3068
+ momentum;
3050
3069
  subscribers = {};
3051
3070
  /**
3052
3071
  * Create new document in collection
@@ -3151,12 +3170,14 @@ class Discounts extends AssetController {
3151
3170
  super(momentum, { module: "discounts", key: "_id" });
3152
3171
  this.momentum = momentum;
3153
3172
  }
3173
+ momentum;
3154
3174
  }
3155
3175
  class Email extends PathEventEmitter {
3156
3176
  constructor(momentum) {
3157
3177
  super();
3158
3178
  this.momentum = momentum;
3159
3179
  }
3180
+ momentum;
3160
3181
  /**
3161
3182
  * Send an Email
3162
3183
  * @param {Mail} email Email information
@@ -3174,12 +3195,14 @@ class Forms extends TreeAssetController {
3174
3195
  super(momentum, { module: "forms", key: "path" });
3175
3196
  this.momentum = momentum;
3176
3197
  }
3198
+ momentum;
3177
3199
  }
3178
3200
  class Groups extends AssetController {
3179
3201
  constructor(momentum) {
3180
3202
  super(momentum, { module: "groups", key: "_id" });
3181
3203
  this.momentum = momentum;
3182
3204
  }
3205
+ momentum;
3183
3206
  }
3184
3207
  class Logger extends PathEventEmitter {
3185
3208
  constructor(momentum) {
@@ -3250,6 +3273,7 @@ ${log}`;
3250
3273
  }
3251
3274
  };
3252
3275
  }
3276
+ momentum;
3253
3277
  static cache = {};
3254
3278
  channel;
3255
3279
  logLevel;
@@ -3397,6 +3421,7 @@ class Notifications extends PathEventEmitter {
3397
3421
  this.momentum = momentum;
3398
3422
  this.subscription.then((resp) => this.enabled = !!resp);
3399
3423
  }
3424
+ momentum;
3400
3425
  _enabled = false;
3401
3426
  /** Are notifications enabled */
3402
3427
  get enabled() {
@@ -3454,6 +3479,7 @@ class Blacklist extends AssetController {
3454
3479
  super(momentum, { module: "blacklist", path: "routes/blacklist", key: "_id" });
3455
3480
  this.momentum = momentum;
3456
3481
  }
3482
+ momentum;
3457
3483
  async update(ignore) {
3458
3484
  throw new Error("Not supported");
3459
3485
  }
@@ -3463,6 +3489,7 @@ class RateLimiter extends AssetController {
3463
3489
  super(momentum, { module: "rate_limit", path: "routes/limit", key: "_id" });
3464
3490
  this.momentum = momentum;
3465
3491
  }
3492
+ momentum;
3466
3493
  }
3467
3494
  class Routes extends PathEventEmitter {
3468
3495
  constructor(momentum) {
@@ -3473,6 +3500,7 @@ class Routes extends PathEventEmitter {
3473
3500
  this.relayEvents(this.blacklist);
3474
3501
  this.relayEvents(this.rateLimiter);
3475
3502
  }
3503
+ momentum;
3476
3504
  blacklist;
3477
3505
  rateLimiter;
3478
3506
  }
@@ -3481,6 +3509,7 @@ class Templates extends AssetController {
3481
3509
  super(momentum, { module: "templates", key: "_id" });
3482
3510
  this.momentum = momentum;
3483
3511
  }
3512
+ momentum;
3484
3513
  render(id, data) {
3485
3514
  return this.momentum.api.request({ url: `/api/templates/render/${id}`, method: "POST", body: data });
3486
3515
  }
@@ -3493,6 +3522,7 @@ class Transactions extends AssetController {
3493
3522
  super(momentum, { module: "transactions", key: "_id" });
3494
3523
  this.momentum = momentum;
3495
3524
  }
3525
+ momentum;
3496
3526
  /** Stripe object */
3497
3527
  stripe;
3498
3528
  /**
@@ -3614,6 +3644,7 @@ class Pdf extends PathEventEmitter {
3614
3644
  super();
3615
3645
  this.momentum = momentum;
3616
3646
  }
3647
+ momentum;
3617
3648
  createPdf(body, options) {
3618
3649
  return this.momentum.api.request({ url: `api/` + PES`pdf`, body: { ...body, options } }).then(async (resp) => {
3619
3650
  if (options?.downloadAs) {
@@ -3672,6 +3703,7 @@ class Products extends PathEventEmitter {
3672
3703
  this.controller = new AssetController(momentum, { module: "products", key: "_id" });
3673
3704
  this.relayEvents(this.controller);
3674
3705
  }
3706
+ momentum;
3675
3707
  controller;
3676
3708
  get cache() {
3677
3709
  return this.controller.cache;
@@ -3708,12 +3740,14 @@ class Schemas extends TreeAssetController {
3708
3740
  super(momentum, { module: "schemas", key: "path" });
3709
3741
  this.momentum = momentum;
3710
3742
  }
3743
+ momentum;
3711
3744
  }
3712
3745
  class Sms extends PathEventEmitter {
3713
3746
  constructor(momentum) {
3714
3747
  super();
3715
3748
  this.momentum = momentum;
3716
3749
  }
3750
+ momentum;
3717
3751
  /**
3718
3752
  * Send an sms to a number
3719
3753
  * @param {Message} message Text that will be sent
@@ -3731,6 +3765,7 @@ class Socket extends PathEventEmitter {
3731
3765
  if (user !== void 0 && this.momentum.api.token != this.token) this.connect();
3732
3766
  });
3733
3767
  }
3768
+ momentum;
3734
3769
  static pollingSpeed = 15e3;
3735
3770
  connection;
3736
3771
  connecting;
@@ -3866,6 +3901,8 @@ class Storage extends PathEventEmitter {
3866
3901
  }
3867
3902
  });
3868
3903
  }
3904
+ momentum;
3905
+ module;
3869
3906
  subscribers = {};
3870
3907
  cache = new Cache("path");
3871
3908
  /**
@@ -4030,6 +4067,7 @@ class Tokens extends PathEventEmitter {
4030
4067
  this.controller = new AssetController(momentum, { module: "tokens", key: "_id" });
4031
4068
  this.relayEvents(this.controller);
4032
4069
  }
4070
+ momentum;
4033
4071
  controller;
4034
4072
  get cache() {
4035
4073
  return this.controller.cache;
@@ -4075,6 +4113,8 @@ class Users extends AssetController {
4075
4113
  this.momentum = momentum;
4076
4114
  this.socket = socket;
4077
4115
  }
4116
+ momentum;
4117
+ socket;
4078
4118
  afterRead(user) {
4079
4119
  if (user == null) return null;
4080
4120
  user.image = this.profileImage(user._id);
@@ -4116,6 +4156,7 @@ class Settings extends AssetController {
4116
4156
  this.all(true);
4117
4157
  });
4118
4158
  }
4159
+ momentum;
4119
4160
  /**
4120
4161
  * Get all schemas organized into a map
4121
4162
  * @param {boolean} reload Reload instead of using cache
@@ -4140,13 +4181,15 @@ class Static extends Storage {
4140
4181
  super(momentum, "static");
4141
4182
  this.momentum = momentum;
4142
4183
  }
4184
+ momentum;
4143
4185
  }
4144
- const version = "1.1.8";
4186
+ const version = "1.1.9";
4145
4187
  class WebRtc extends PathEventEmitter {
4146
4188
  constructor(momentum) {
4147
4189
  super("webrtc");
4148
4190
  this.momentum = momentum;
4149
4191
  }
4192
+ momentum;
4150
4193
  get ice() {
4151
4194
  const host = this.momentum.url.hostname.replace("localhost", "127.0.0.1");
4152
4195
  const port = this.momentum.settings.cache.get("webrtc_port")?.value;
@@ -4260,6 +4303,7 @@ class Permissions {
4260
4303
  constructor(momentum) {
4261
4304
  this.momentum = momentum;
4262
4305
  }
4306
+ momentum;
4263
4307
  /** Get all permissions */
4264
4308
  all = () => this.momentum.auth.session?.permissions || [];
4265
4309
  /** Filter list of permissions to ones the user has */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ztimson/momentum",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "description": "Client library for momentum",
5
5
  "keywords": [
6
6
  "Momentum"
@@ -33,7 +33,7 @@
33
33
  "postbuild": "npm run build:docs && node -e \"const fs=require('fs');fs.cpSync('dist/index.mjs','../server/public/momentum.mjs');fs.cpSync('dist/index.js','../server/public/momentum.js');fs.cpSync('dist/momentum.worker.mjs','../server/public/momentum.worker.mjs')\""
34
34
  },
35
35
  "dependencies": {
36
- "@ztimson/utils": "0.28.12"
36
+ "@ztimson/utils": "0.29.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^22.5.4",