@trunkjs/browser-utils 1.0.35 → 1.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 1.0.38 (2026-02-12)
2
+
3
+ This was a version bump only for browser-utils to align it with other projects, there were no code changes.
4
+
5
+ ## 1.0.37 (2026-02-08)
6
+
7
+ This was a version bump only for browser-utils to align it with other projects, there were no code changes.
8
+
9
+ ## 1.0.36 (2026-02-08)
10
+
11
+ This was a version bump only for browser-utils to align it with other projects, there were no code changes.
12
+
1
13
  ## 1.0.35 (2026-02-07)
2
14
 
3
15
  This was a version bump only for browser-utils to align it with other projects, there were no code changes.
package/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from './lib/Debouncer';
4
4
  export * from './lib/get-error-location';
5
5
  export * from './lib/Logger';
6
6
  export * from './lib/Stopwatch';
7
+ export * from './lib/storage';
7
8
  export * from './lib/wait-for';
8
9
  export * from './mixins/BreakPointMixin';
9
10
  export * from './mixins/EventBindingsMixin';
package/index.js CHANGED
@@ -1,40 +1,40 @@
1
- var D = Object.defineProperty;
2
- var v = (t) => {
3
- throw TypeError(t);
1
+ var $ = Object.defineProperty;
2
+ var T = (e) => {
3
+ throw TypeError(e);
4
4
  };
5
- var $ = (t, e, n) => e in t ? D(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
6
- var c = (t, e, n) => $(t, typeof e != "symbol" ? e + "" : e, n), T = (t, e, n) => e.has(t) || v("Cannot " + n);
7
- var u = (t, e, n) => (T(t, e, "read from private field"), n ? n.call(t) : e.get(t)), m = (t, e, n) => e.has(t) ? v("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), w = (t, e, n, i) => (T(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n), E = (t, e, n) => (T(t, e, "access private method"), n);
8
- const L = [
5
+ var N = (e, t, n) => t in e ? $(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
6
+ var l = (e, t, n) => N(e, typeof t != "symbol" ? t + "" : t, n), L = (e, t, n) => t.has(e) || T("Cannot " + n);
7
+ var u = (e, t, n) => (L(e, t, "read from private field"), n ? n.call(e) : t.get(e)), h = (e, t, n) => t.has(e) ? T("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), w = (e, t, n, i) => (L(e, t, "write to private field"), i ? i.call(e, n) : t.set(e, n), n), y = (e, t, n) => (L(e, t, "access private method"), n);
8
+ const k = [
9
9
  { name: "xs", minWidth: 0 },
10
10
  { name: "sm", minWidth: 576 },
11
11
  { name: "md", minWidth: 768 },
12
12
  { name: "lg", minWidth: 992 },
13
13
  { name: "xl", minWidth: 1200 },
14
14
  { name: "xxl", minWidth: 1400 }
15
- ], k = L.reduce(
16
- (t, e) => (t[e.name] = e.minWidth, t),
15
+ ], x = k.reduce(
16
+ (e, t) => (e[t.name] = t.minWidth, e),
17
17
  {}
18
18
  );
19
- function p(t) {
20
- if (!(t in k))
21
- throw new Error(`Unknown breakpoint: ${t}`);
22
- return k[t];
19
+ function E(e) {
20
+ if (!(e in x))
21
+ throw new Error(`Unknown breakpoint: ${e}`);
22
+ return x[e];
23
23
  }
24
- function R(t) {
25
- t === void 0 && (t = window.innerWidth);
26
- for (let e = L.length - 1; e >= 0; e--)
27
- if (t >= L[e].minWidth)
28
- return L[e].name;
24
+ function B(e) {
25
+ e === void 0 && (e = window.innerWidth);
26
+ for (let t = k.length - 1; t >= 0; t--)
27
+ if (e >= k[t].minWidth)
28
+ return k[t].name;
29
29
  return "xs";
30
30
  }
31
- function O(t, e = {}, n = []) {
31
+ function H(e, t = {}, n = []) {
32
32
  Array.isArray(n) || (n = [n]);
33
- const i = document.createElement(t);
34
- for (const s in e)
35
- e[s] !== null && e[s] !== void 0 && i.setAttribute(s, e[s] !== !0 ? e[s] : "");
36
- for (const s of n)
37
- i.append(typeof s == "string" ? document.createTextNode(s) : s);
33
+ const i = document.createElement(e);
34
+ for (const r in t)
35
+ t[r] !== null && t[r] !== void 0 && i.setAttribute(r, t[r] !== !0 ? t[r] : "");
36
+ for (const r of n)
37
+ i.append(typeof r == "string" ? document.createTextNode(r) : r);
38
38
  return i;
39
39
  }
40
40
  class M {
@@ -43,97 +43,97 @@ class M {
43
43
  * @param delay Debounce delay in milliseconds
44
44
  * @param max_delay Maximum delay in milliseconds, if false then no maximum delay is applied
45
45
  */
46
- constructor(e, n = !1) {
47
- c(this, "timeout", null);
48
- c(this, "startTimeWithMs", 0);
49
- c(this, "maxTimeout", null);
50
- this.delay = e, this.max_delay = n;
46
+ constructor(t, n = !1) {
47
+ l(this, "timeout", null);
48
+ l(this, "startTimeWithMs", 0);
49
+ l(this, "maxTimeout", null);
50
+ this.delay = t, this.max_delay = n;
51
51
  }
52
52
  async wait() {
53
- return this.startTimeWithMs === 0 && (this.startTimeWithMs = Date.now()), this.timeout && (this.max_delay === !1 || this.startTimeWithMs + this.max_delay > Date.now()) && clearTimeout(this.timeout), new Promise((e) => {
53
+ return this.startTimeWithMs === 0 && (this.startTimeWithMs = Date.now()), this.timeout && (this.max_delay === !1 || this.startTimeWithMs + this.max_delay > Date.now()) && clearTimeout(this.timeout), new Promise((t) => {
54
54
  this.timeout = setTimeout(() => {
55
- this.startTimeWithMs = 0, e(!0);
55
+ this.startTimeWithMs = 0, t(!0);
56
56
  }, this.delay);
57
57
  });
58
58
  }
59
- debounce(e) {
59
+ debounce(t) {
60
60
  const n = Date.now();
61
61
  this.startTimeWithMs === 0 && (this.startTimeWithMs = n);
62
62
  const i = () => {
63
- this.timeout && (clearTimeout(this.timeout), this.timeout = null), this.maxTimeout && (clearTimeout(this.maxTimeout), this.maxTimeout = null), this.startTimeWithMs = 0, e();
63
+ this.timeout && (clearTimeout(this.timeout), this.timeout = null), this.maxTimeout && (clearTimeout(this.maxTimeout), this.maxTimeout = null), this.startTimeWithMs = 0, t();
64
64
  };
65
65
  if (this.timeout && clearTimeout(this.timeout), this.timeout = setTimeout(i, this.delay), this.max_delay !== !1 && !this.maxTimeout) {
66
- const s = n - this.startTimeWithMs, a = Math.max(0, this.max_delay - s);
66
+ const r = n - this.startTimeWithMs, a = Math.max(0, this.max_delay - r);
67
67
  this.maxTimeout = setTimeout(i, a);
68
68
  }
69
69
  }
70
70
  }
71
- function F(t, e = !1) {
71
+ function G(e, t = !1) {
72
72
  const n = /* @__PURE__ */ new WeakMap();
73
- return function(i, s) {
74
- if (s.kind !== "method") return i;
75
- const a = s.name;
76
- return function(...l) {
77
- let r = n.get(this);
78
- r || (r = /* @__PURE__ */ new Map(), n.set(this, r));
79
- let o = r.get(a);
80
- o || (o = new M(t, e), r.set(a, o)), o.debounce(() => i.apply(this, l));
73
+ return function(i, r) {
74
+ if (r.kind !== "method") return i;
75
+ const a = r.name;
76
+ return function(...c) {
77
+ let s = n.get(this);
78
+ s || (s = /* @__PURE__ */ new Map(), n.set(this, s));
79
+ let o = s.get(a);
80
+ o || (o = new M(e, t), s.set(a, o)), o.debounce(() => i.apply(this, c));
81
81
  };
82
82
  };
83
83
  }
84
- function H(t) {
85
- if (typeof t.lineNumber == "number")
84
+ function J(e) {
85
+ if (typeof e.lineNumber == "number")
86
86
  return {
87
- file: t.fileName || t.sourceURL,
88
- line: t.lineNumber,
89
- column: t.columnNumber ?? void 0
87
+ file: e.fileName || e.sourceURL,
88
+ line: e.lineNumber,
89
+ column: e.columnNumber ?? void 0
90
90
  };
91
- if (typeof t.line == "number")
91
+ if (typeof e.line == "number")
92
92
  return {
93
- file: t.sourceURL,
94
- line: t.line,
95
- column: t.column
93
+ file: e.sourceURL,
94
+ line: e.line,
95
+ column: e.column
96
96
  };
97
- const n = String(t.stack || t.message || "").split(`
97
+ const n = String(e.stack || e.message || "").split(`
98
98
  `), i = /(.*?)(?:\(|@)?(.*?):(\d+):(\d+)\)?$/;
99
- for (const s of n) {
100
- const a = s.match(i);
99
+ for (const r of n) {
100
+ const a = r.match(i);
101
101
  if (a)
102
102
  return { file: a[2], line: +a[3], column: +a[4] };
103
103
  }
104
- return { file: t.fileName || t.sourceURL };
104
+ return { file: e.fileName || e.sourceURL };
105
105
  }
106
- class B {
107
- constructor(e, n, i = "main") {
108
- this._debug = e, this.myElementId = n, this.instanceId = i;
106
+ class R {
107
+ constructor(t, n, i = "main") {
108
+ this._debug = t, this.myElementId = n, this.instanceId = i;
109
109
  }
110
- log(...e) {
111
- this._debug && console.log(`[LOG][ID:${this.myElementId}:${this.instanceId}]`, ...e);
110
+ log(...t) {
111
+ this._debug && console.log(`[LOG][ID:${this.myElementId}:${this.instanceId}]`, ...t);
112
112
  }
113
- warn(...e) {
114
- console.warn(`[WARN][ID:${this.myElementId}:${this.instanceId}]`, ...e);
113
+ warn(...t) {
114
+ console.warn(`[WARN][ID:${this.myElementId}:${this.instanceId}]`, ...t);
115
115
  }
116
- error(...e) {
117
- console.error(`[ERROR][ID:${this.myElementId}:${this.instanceId}]`, ...e);
116
+ error(...t) {
117
+ console.error(`[ERROR][ID:${this.myElementId}:${this.instanceId}]`, ...t);
118
118
  }
119
- throwError(...e) {
120
- const n = `[ERROR][ID:${this.myElementId}:${this.instanceId}] ${e.join(" ")}`;
121
- throw this.error(...e), new Error(n);
119
+ throwError(...t) {
120
+ const n = `[ERROR][ID:${this.myElementId}:${this.instanceId}] ${t.join(" ")}`;
121
+ throw this.error(...t), new Error(n);
122
122
  }
123
123
  }
124
- class V {
125
- constructor(e, n = !0) {
126
- c(this, "label");
127
- c(this, "last");
128
- c(this, "startTime");
129
- c(this, "running", !1);
130
- c(this, "enabled");
131
- this.label = e, this.enabled = n, this.startTime = this.last = performance.now(), this.running = !0;
124
+ class q {
125
+ constructor(t, n = !0) {
126
+ l(this, "label");
127
+ l(this, "last");
128
+ l(this, "startTime");
129
+ l(this, "running", !1);
130
+ l(this, "enabled");
131
+ this.label = t, this.enabled = n, this.startTime = this.last = performance.now(), this.running = !0;
132
132
  }
133
- lap(e = "") {
133
+ lap(t = "") {
134
134
  if (!this.enabled) return;
135
135
  const n = performance.now(), i = (n - this.last) / 1e3;
136
- this.last = n, console.debug(`[${this.label}] ${e} +${i.toFixed(3)}s`);
136
+ this.last = n, console.debug(`[${this.label}] ${t} +${i.toFixed(3)}s`);
137
137
  }
138
138
  elapsed() {
139
139
  return performance.now() - this.startTime;
@@ -151,122 +151,227 @@ class V {
151
151
  return this.running;
152
152
  }
153
153
  }
154
- function z(t, e, n) {
155
- return new Promise((i, s) => {
156
- const a = (l) => {
157
- t.removeEventListener(e, a, n), i(l);
154
+ function O(e) {
155
+ return typeof e == "object" && e !== null && !Array.isArray(e);
156
+ }
157
+ function U(e) {
158
+ if (e != null)
159
+ try {
160
+ return JSON.parse(e);
161
+ } catch {
162
+ return;
163
+ }
164
+ }
165
+ function p(e) {
166
+ const t = JSON.stringify(e);
167
+ return t === void 0 ? "null" : t;
168
+ }
169
+ function K(e, t) {
170
+ const n = { ...t };
171
+ if (O(e))
172
+ for (const i of Object.keys(t))
173
+ i in e && (n[i] = e[i]);
174
+ return n;
175
+ }
176
+ class P {
177
+ constructor(t, n, i) {
178
+ l(this, "cache");
179
+ this.backend = t, this.storageKey = n, this.initialValue = i;
180
+ }
181
+ read() {
182
+ if (this.cache) return this.cache;
183
+ const t = this.backend ? U(this.backend.getItem(this.storageKey)) : void 0, n = K(t, this.initialValue);
184
+ if (this.backend && this.backend.getItem(this.storageKey) == null)
185
+ try {
186
+ this.backend.setItem(this.storageKey, p(n));
187
+ } catch {
188
+ }
189
+ return this.cache = n, n;
190
+ }
191
+ write(t) {
192
+ if (this.cache = t, !!this.backend)
193
+ try {
194
+ this.backend.setItem(this.storageKey, p(t));
195
+ } catch {
196
+ }
197
+ }
198
+ asProxy() {
199
+ const t = {
200
+ get: (n, i) => {
201
+ if (typeof i == "symbol")
202
+ return i === Symbol.toStringTag ? "Storage" : void 0;
203
+ const r = this.read();
204
+ return i === "toJSON" ? () => ({ ...r }) : r[i];
205
+ },
206
+ set: (n, i, r) => {
207
+ if (typeof i != "string") return !1;
208
+ const c = { ...this.read() };
209
+ return c[i] = r, this.write(c), !0;
210
+ },
211
+ deleteProperty: (n, i) => {
212
+ if (typeof i != "string") return !1;
213
+ const r = this.read();
214
+ if (!(i in r)) return !0;
215
+ const a = { ...r };
216
+ return delete a[i], this.write(a), !0;
217
+ },
218
+ has: (n, i) => {
219
+ if (typeof i != "string") return !1;
220
+ const r = this.read();
221
+ return i in r;
222
+ },
223
+ ownKeys: () => {
224
+ const n = this.read();
225
+ return Reflect.ownKeys(n);
226
+ },
227
+ getOwnPropertyDescriptor: (n, i) => {
228
+ if (typeof i != "string") return;
229
+ const r = this.read();
230
+ if (i in r)
231
+ return {
232
+ enumerable: !0,
233
+ configurable: !0,
234
+ writable: !0,
235
+ value: r[i]
236
+ };
237
+ }
238
+ };
239
+ return new Proxy({}, t);
240
+ }
241
+ }
242
+ function I(e) {
243
+ const t = globalThis.window;
244
+ return (e === "session" ? t == null ? void 0 : t.sessionStorage : t == null ? void 0 : t.localStorage) ?? void 0;
245
+ }
246
+ function X(e, t) {
247
+ return new P(I("session"), e, t).asProxy();
248
+ }
249
+ function Q(e, t) {
250
+ return new P(I("local"), e, t).asProxy();
251
+ }
252
+ function Y(e, t, n) {
253
+ return new Promise((i, r) => {
254
+ const a = (c) => {
255
+ e.removeEventListener(t, a, n), i(c);
158
256
  };
159
- t.addEventListener(e, a, n);
257
+ e.addEventListener(t, a, n);
160
258
  });
161
259
  }
162
- function N() {
163
- return document.readyState === "loading" ? new Promise((t) => {
164
- document.addEventListener("DOMContentLoaded", () => t());
260
+ function z() {
261
+ return document.readyState === "loading" ? new Promise((e) => {
262
+ document.addEventListener("DOMContentLoaded", () => e());
165
263
  }) : Promise.resolve();
166
264
  }
167
- function G(t = window) {
168
- return t || (t = window), t === window ? document.readyState === "complete" ? Promise.resolve() : new Promise((e) => window.addEventListener("load", () => e(), { once: !0 })) : t instanceof HTMLImageElement ? t.complete && t.naturalWidth !== 0 ? Promise.resolve() : new Promise((e, n) => {
169
- t.addEventListener("load", () => e(), { once: !0 }), t.addEventListener("error", () => n(new Error("image error")), { once: !0 });
170
- }) : t instanceof HTMLMediaElement ? t.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA ? Promise.resolve() : new Promise((e) => t.addEventListener("loadeddata", () => e(), { once: !0 })) : new Promise((e) => t.addEventListener("load", () => e(), { once: !0 }));
265
+ function Z(e = window) {
266
+ return e || (e = window), e === window ? document.readyState === "complete" ? Promise.resolve() : new Promise((t) => window.addEventListener("load", () => t(), { once: !0 })) : e instanceof HTMLImageElement ? e.complete && e.naturalWidth !== 0 ? Promise.resolve() : new Promise((t, n) => {
267
+ e.addEventListener("load", () => t(), { once: !0 }), e.addEventListener("error", () => n(new Error("image error")), { once: !0 });
268
+ }) : e instanceof HTMLMediaElement ? e.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA ? Promise.resolve() : new Promise((t) => e.addEventListener("loadeddata", () => t(), { once: !0 })) : new Promise((t) => e.addEventListener("load", () => t(), { once: !0 }));
171
269
  }
172
- function j(t) {
173
- return new Promise((e) => setTimeout(e, t));
270
+ function tt(e) {
271
+ return new Promise((t) => setTimeout(t, e));
174
272
  }
175
- function q(t) {
176
- return new Promise((e) => {
273
+ function et(e) {
274
+ return new Promise((t) => {
177
275
  const n = (i) => {
178
- t.removeEventListener("animationend", n), e(i);
276
+ e.removeEventListener("animationend", n), t(i);
179
277
  };
180
- t.addEventListener("animationend", n);
278
+ e.addEventListener("animationend", n);
181
279
  });
182
280
  }
183
- function X(t) {
281
+ function nt(e) {
184
282
  var n, i;
185
- class e extends t {
283
+ class t extends e {
186
284
  constructor() {
187
285
  super(...arguments);
188
- m(this, n, new M(200, 5e3));
189
- c(this, "currentBreakPoint", null);
190
- m(this, i, async () => {
286
+ h(this, n, new M(200, 5e3));
287
+ l(this, "currentBreakPoint", null);
288
+ h(this, i, async () => {
191
289
  var b;
192
- await u(this, n).wait(), await N();
193
- const l = this, r = window.innerWidth, o = getComputedStyle(l).getPropertyValue("--breakpoint");
290
+ await u(this, n).wait(), await z();
291
+ const c = this, s = window.innerWidth;
292
+ let o = getComputedStyle(c).getPropertyValue("--breakpoint");
194
293
  if (!o || o === "")
195
294
  return;
196
- const d = o.split(","), h = d[0].trim(), f = ((b = d[1]) == null ? void 0 : b.trim()) ?? h, g = R(r);
197
- this.currentBreakPoint !== g && (p(f) <= p(g) ? l.setAttribute("mode", "desktop") : p(h) > p(g) ? l.setAttribute("mode", "mobile") : l.setAttribute("mode", "tablet"));
295
+ o = o.trim().replace(/^['"]|['"]$/g, "");
296
+ const d = o.split(","), m = d[0].trim(), f = ((b = d[1]) == null ? void 0 : b.trim()) ?? m, g = B(s);
297
+ this.currentBreakPoint !== g && (E(f) <= E(g) ? c.setAttribute("mode", "desktop") : E(m) > E(g) ? c.setAttribute("mode", "mobile") : c.setAttribute("mode", "tablet"));
198
298
  });
199
299
  }
200
300
  connectedCallback() {
201
- super.connectedCallback(), u(this, i).call(this), window.addEventListener("resize", u(this, i)), u(this, i).call(this);
301
+ super.connectedCallback();
302
+ try {
303
+ u(this, i).call(this), window.addEventListener("resize", u(this, i)), u(this, i).call(this);
304
+ } catch (c) {
305
+ throw console.error("Error in BreakPointMixin:", c, "in element", this), c;
306
+ }
202
307
  }
203
308
  disconnectedCallback() {
204
309
  super.disconnectedCallback(), window.removeEventListener("resize", u(this, i));
205
310
  }
206
311
  }
207
- return n = new WeakMap(), i = new WeakMap(), e;
312
+ return n = new WeakMap(), i = new WeakMap(), t;
208
313
  }
209
- const y = Symbol("listenerDefs"), x = Symbol("withEventBindings");
210
- function J(t, e) {
211
- const n = Array.isArray(t) ? t : [t];
212
- return function(i, s) {
213
- if (s.kind !== "method") throw new Error("@Listen nur für Methoden");
214
- return s.addInitializer(function() {
314
+ const v = Symbol("listenerDefs"), A = Symbol("withEventBindings");
315
+ function it(e, t) {
316
+ const n = Array.isArray(e) ? e : [e];
317
+ return function(i, r) {
318
+ if (r.kind !== "method") throw new Error("@Listen nur für Methoden");
319
+ return r.addInitializer(function() {
215
320
  const a = this.constructor;
216
- (a[y] || (a[y] = [])).push({
217
- method: s.name,
321
+ (a[v] || (a[v] = [])).push({
322
+ method: r.name,
218
323
  events: n,
219
- opts: e
324
+ opts: t
220
325
  });
221
326
  }), function(...a) {
222
- if (!this[x])
327
+ if (!this[A])
223
328
  throw new Error("[EventBindings] @Listen - decorator requires EventBindingMixin.");
224
329
  return i.apply(this, a);
225
330
  };
226
331
  };
227
332
  }
228
- function _(t, e) {
333
+ function F(e, t) {
229
334
  var n;
230
- return !e || e === "host" ? t : e === "document" ? t.ownerDocument ?? document : e === "window" ? ((n = t.ownerDocument) == null ? void 0 : n.defaultView) ?? window : e === "shadowRoot" ? t.shadowRoot ?? t : typeof e == "function" ? e(t) : e;
335
+ return !t || t === "host" ? e : t === "document" ? e.ownerDocument ?? document : t === "window" ? ((n = e.ownerDocument) == null ? void 0 : n.defaultView) ?? window : t === "shadowRoot" ? e.shadowRoot ?? e : typeof t == "function" ? t(e) : t;
231
336
  }
232
- function K(t) {
233
- var n, i, A;
234
- class e extends t {
235
- constructor(...r) {
236
- super(...r);
237
- m(this, i);
238
- m(this, n);
239
- this[x] = !0;
337
+ function rt(e) {
338
+ var n, i, W;
339
+ class t extends e {
340
+ constructor(...s) {
341
+ super(...s);
342
+ h(this, i);
343
+ h(this, n);
344
+ this[A] = !0;
240
345
  }
241
346
  connectedCallback() {
242
- var r;
243
- (r = super.connectedCallback) == null || r.call(this), E(this, i, A).call(this);
347
+ var s;
348
+ (s = super.connectedCallback) == null || s.call(this), y(this, i, W).call(this);
244
349
  }
245
350
  disconnectedCallback() {
246
- var r, o;
247
- (r = u(this, n)) == null || r.abort(), (o = super.disconnectedCallback) == null || o.call(this);
351
+ var s, o;
352
+ (s = u(this, n)) == null || s.abort(), (o = super.disconnectedCallback) == null || o.call(this);
248
353
  }
249
354
  }
250
- return n = new WeakMap(), i = new WeakSet(), A = function() {
251
- var o, d, h;
355
+ return n = new WeakMap(), i = new WeakSet(), W = function() {
356
+ var o, d, m;
252
357
  (o = u(this, n)) == null || o.abort(), w(this, n, new AbortController());
253
- const r = this.constructor[y] || [];
254
- for (const f of r) {
255
- const g = _(this, (d = f.opts) == null ? void 0 : d.target), b = ((h = f.opts) == null ? void 0 : h.options) ?? {}, C = this[f.method].bind(this);
256
- for (const P of f.events)
257
- g.addEventListener(P, C, { ...b, signal: u(this, n).signal });
358
+ const s = this.constructor[v] || [];
359
+ for (const f of s) {
360
+ const g = F(this, (d = f.opts) == null ? void 0 : d.target), b = ((m = f.opts) == null ? void 0 : m.options) ?? {}, C = this[f.method].bind(this);
361
+ for (const D of f.events)
362
+ g.addEventListener(D, C, { ...b, signal: u(this, n).signal });
258
363
  }
259
- }, e;
364
+ }, t;
260
365
  }
261
- let S = 1;
262
- function Q(t) {
263
- var n, i, s;
264
- class e extends t {
366
+ let V = 1;
367
+ function st(e) {
368
+ var n, i, r;
369
+ class t extends e {
265
370
  constructor() {
266
371
  super(...arguments);
267
- m(this, n, null);
268
- m(this, i, S++);
269
- m(this, s, null);
372
+ h(this, n, null);
373
+ h(this, i, V++);
374
+ h(this, r, null);
270
375
  }
271
376
  /**
272
377
  * Clears the cached debug flag so the attribute will be checked again
@@ -278,69 +383,71 @@ function Q(t) {
278
383
  get _debug() {
279
384
  return u(this, n) !== null ? u(this, n) : (this instanceof HTMLElement && w(this, n, this.hasAttribute("debug") && !["false", "0", "off", "no"].includes(this.getAttribute("debug") || "")), u(this, n) === !0 && console.log(`[DEBUG][ID:${u(this, i)}] LoggingMixin: Debug mode is enabled for <${this.tagName}>`, this), u(this, n) ?? !1);
280
385
  }
281
- getLogger(r = "main") {
282
- return u(this, s) || w(this, s, new B(this._debug, `${u(this, i)}`, r)), u(this, s);
386
+ getLogger(s = "main") {
387
+ return u(this, r) || w(this, r, new R(this._debug, `${u(this, i)}`, s)), u(this, r);
283
388
  }
284
- log(...r) {
285
- this.getLogger().log(...r);
389
+ log(...s) {
390
+ this.getLogger().log(...s);
286
391
  }
287
- warn(...r) {
288
- this.getLogger().warn(...r);
392
+ warn(...s) {
393
+ this.getLogger().warn(...s);
289
394
  }
290
- error(...r) {
291
- this.getLogger().error(...r);
395
+ error(...s) {
396
+ this.getLogger().error(...s);
292
397
  }
293
- throwError(...r) {
294
- return this.getLogger().throwError(...r);
398
+ throwError(...s) {
399
+ return this.getLogger().throwError(...s);
295
400
  }
296
401
  }
297
- return n = new WeakMap(), i = new WeakMap(), s = new WeakMap(), e;
402
+ return n = new WeakMap(), i = new WeakMap(), r = new WeakMap(), t;
298
403
  }
299
- function Y(t) {
300
- var n, W, s, I;
301
- class e extends t {
404
+ function ot(e) {
405
+ var n, S, r, _;
406
+ class t extends e {
302
407
  constructor() {
303
408
  super(...arguments);
304
- m(this, n);
305
- m(this, s, (o) => {
409
+ h(this, n);
410
+ h(this, r, (o) => {
306
411
  const d = o.target;
307
- d.assignedNodes({ flatten: !0 }).filter((g) => E(this, n, I).call(this, g)).length > 0 && d.classList.remove("slot-empty");
412
+ d.assignedNodes({ flatten: !0 }).filter((g) => y(this, n, _).call(this, g)).length > 0 && d.classList.remove("slot-empty");
308
413
  });
309
414
  }
310
415
  firstUpdated(o) {
311
416
  var d;
312
- (d = super.firstUpdated) == null || d.call(this, o), E(this, n, W).call(this);
417
+ (d = super.firstUpdated) == null || d.call(this, o), y(this, n, S).call(this);
313
418
  }
314
419
  }
315
- return n = new WeakSet(), W = function() {
420
+ return n = new WeakSet(), S = function() {
316
421
  var d;
317
422
  const o = (d = this.shadowRoot) == null ? void 0 : d.querySelectorAll("slot");
318
- o == null || o.forEach((h) => {
319
- h.classList.add("slot-empty"), h.addEventListener("slotchange", (f) => u(this, s).call(this, f));
423
+ o == null || o.forEach((m) => {
424
+ m.classList.add("slot-empty"), m.addEventListener("slotchange", (f) => u(this, r).call(this, f));
320
425
  });
321
- }, s = new WeakMap(), I = function(o) {
426
+ }, r = new WeakMap(), _ = function(o) {
322
427
  return o.nodeType === Node.TEXT_NODE ? (o.textContent || "").trim().length > 0 : o.nodeType === Node.ELEMENT_NODE;
323
- }, e;
428
+ }, t;
324
429
  }
325
430
  export {
326
- X as BreakPointMixin,
431
+ nt as BreakPointMixin,
327
432
  M as Debouncer,
328
- K as EventBindingsMixin,
329
- J as Listen,
330
- B as Logger,
331
- Q as LoggingMixin,
332
- Y as SlotVisibilityMixin,
333
- V as Stopwatch,
334
- k as breakpointMap,
335
- L as breakpoints,
336
- O as create_element,
337
- F as debounce,
338
- p as getBreakpointMinWidth,
339
- R as getCurrentBreakpoint,
340
- H as getErrorLocation,
341
- j as sleep,
342
- z as waitFor,
343
- q as waitForAnimationEnd,
344
- N as waitForDomContentLoaded,
345
- G as waitForLoad
433
+ rt as EventBindingsMixin,
434
+ it as Listen,
435
+ R as Logger,
436
+ st as LoggingMixin,
437
+ ot as SlotVisibilityMixin,
438
+ q as Stopwatch,
439
+ x as breakpointMap,
440
+ k as breakpoints,
441
+ H as create_element,
442
+ G as debounce,
443
+ E as getBreakpointMinWidth,
444
+ B as getCurrentBreakpoint,
445
+ J as getErrorLocation,
446
+ Q as local_storage,
447
+ X as session_storage,
448
+ tt as sleep,
449
+ Y as waitFor,
450
+ et as waitForAnimationEnd,
451
+ z as waitForDomContentLoaded,
452
+ Z as waitForLoad
346
453
  };
@@ -0,0 +1,4 @@
1
+ type JsonRecord = Record<string, unknown>;
2
+ export declare function session_storage<T extends JsonRecord>(storageKey: string, initialValue: T): T;
3
+ export declare function local_storage<T extends JsonRecord>(storageKey: string, initialValue: T): T;
4
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trunkjs/browser-utils",
3
- "version": "1.0.35",
3
+ "version": "1.0.38",
4
4
  "main": "./index.js",
5
5
  "dependencies": {},
6
6
  "type": "module",