@trunkjs/browser-utils 1.0.48 → 1.0.50

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/.ai-usage-info.md CHANGED
@@ -153,6 +153,10 @@ Empty slots get the CSS class:
153
153
  <slot class="slot-empty"></slot>
154
154
  ```
155
155
 
156
+ Notes:
157
+ - whitespace-only text nodes are treated as empty
158
+ - HTML comments are treated as empty as well (important for Lit comment markers)
159
+
156
160
  ## Other exports
157
161
 
158
162
  ```ts
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 1.0.50 (2026-05-19)
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.49 (2026-05-18)
6
+
7
+ This was a version bump only for browser-utils to align it with other projects, there were no code changes.
8
+
1
9
  ## 1.0.48 (2026-05-15)
2
10
 
3
11
  This was a version bump only for browser-utils to align it with other projects, there were no code changes.
package/index.js CHANGED
@@ -1,10 +1,10 @@
1
- var D = Object.defineProperty;
2
- var x = (e) => {
1
+ var B = Object.defineProperty;
2
+ var _ = (e) => {
3
3
  throw TypeError(e);
4
4
  };
5
- var R = (e, t, n) => t in e ? D(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
6
- var c = (e, t, n) => R(e, typeof t != "symbol" ? t + "" : t, n), k = (e, t, n) => t.has(e) || x("Cannot " + n);
7
- var u = (e, t, n) => (k(e, t, "read from private field"), n ? n.call(e) : t.get(e)), h = (e, t, n) => t.has(e) ? x("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), w = (e, t, n, i) => (k(e, t, "write to private field"), i ? i.call(e, n) : t.set(e, n), n), y = (e, t, n) => (k(e, t, "access private method"), n);
5
+ var O = (e, t, n) => t in e ? B(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
6
+ var m = (e, t, n) => O(e, typeof t != "symbol" ? t + "" : t, n), T = (e, t, n) => t.has(e) || _("Cannot " + n);
7
+ var l = (e, t, n) => (T(e, t, "read from private field"), n ? n.call(e) : t.get(e)), f = (e, t, n) => t.has(e) ? _("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), b = (e, t, n, i) => (T(e, t, "write to private field"), i ? i.call(e, n) : t.set(e, n), n), w = (e, t, n) => (T(e, t, "access private method"), n);
8
8
  const v = [
9
9
  { name: "xs", minWidth: 0 },
10
10
  { name: "sm", minWidth: 576 },
@@ -12,26 +12,26 @@ const v = [
12
12
  { name: "lg", minWidth: 992 },
13
13
  { name: "xl", minWidth: 1200 },
14
14
  { name: "xxl", minWidth: 1400 }
15
- ], _ = v.reduce(
15
+ ], M = v.reduce(
16
16
  (e, t) => (e[t.name] = t.minWidth, e),
17
17
  {}
18
18
  );
19
19
  function E(e) {
20
- if (!(e in _))
20
+ if (!(e in M))
21
21
  throw new Error(`Unknown breakpoint: ${e}`);
22
- return _[e];
22
+ return M[e];
23
23
  }
24
- function O() {
24
+ function U() {
25
25
  return window.visualViewport ? window.visualViewport.width : window.innerWidth;
26
26
  }
27
- function U(e) {
28
- e === void 0 && (e = O());
27
+ function j(e) {
28
+ e === void 0 && (e = U());
29
29
  for (let t = v.length - 1; t >= 0; t--)
30
30
  if (e >= v[t].minWidth)
31
31
  return v[t].name;
32
32
  return "xs";
33
33
  }
34
- function J(e, t = {}, n = []) {
34
+ function X(e, t = {}, n = []) {
35
35
  Array.isArray(n) || (n = [n]);
36
36
  const i = document.createElement(e);
37
37
  for (const r in t)
@@ -40,16 +40,16 @@ function J(e, t = {}, n = []) {
40
40
  i.append(typeof r == "string" ? document.createTextNode(r) : r);
41
41
  return i;
42
42
  }
43
- class P {
43
+ class C {
44
44
  /**
45
45
  *
46
46
  * @param delay Debounce delay in milliseconds
47
47
  * @param max_delay Maximum delay in milliseconds, if false then no maximum delay is applied
48
48
  */
49
49
  constructor(t, n = !1) {
50
- c(this, "timeout", null);
51
- c(this, "startTimeWithMs", 0);
52
- c(this, "maxTimeout", null);
50
+ m(this, "timeout", null);
51
+ m(this, "startTimeWithMs", 0);
52
+ m(this, "maxTimeout", null);
53
53
  this.delay = t, this.max_delay = n;
54
54
  }
55
55
  async wait() {
@@ -59,6 +59,10 @@ class P {
59
59
  }, this.delay));
60
60
  });
61
61
  }
62
+ /**
63
+ * @deprecated Use wait() instead and handle the callback logic in the caller function for better control and flexibility.
64
+ * @param callback
65
+ */
62
66
  debounce(t) {
63
67
  const n = Date.now();
64
68
  this.startTimeWithMs === 0 && (this.startTimeWithMs = n);
@@ -66,25 +70,25 @@ class P {
66
70
  this.timeout && (clearTimeout(this.timeout), this.timeout = null), this.maxTimeout && (clearTimeout(this.maxTimeout), this.maxTimeout = null), this.startTimeWithMs = 0, t();
67
71
  };
68
72
  if (this.timeout && clearTimeout(this.timeout), this.timeout = setTimeout(i, this.delay), this.max_delay !== !1 && !this.maxTimeout) {
69
- const r = n - this.startTimeWithMs, a = Math.max(0, this.max_delay - r);
70
- this.maxTimeout = setTimeout(i, a);
73
+ const r = n - this.startTimeWithMs, o = Math.max(0, this.max_delay - r);
74
+ this.maxTimeout = setTimeout(i, o);
71
75
  }
72
76
  }
73
77
  }
74
- function X(e, t = !1) {
78
+ function Q(e, t = !1) {
75
79
  const n = /* @__PURE__ */ new WeakMap();
76
80
  return function(i, r) {
77
81
  if (r.kind !== "method") return i;
78
- const a = r.name;
79
- return function(...d) {
82
+ const o = r.name;
83
+ return function(...c) {
80
84
  let s = n.get(this);
81
85
  s || (s = /* @__PURE__ */ new Map(), n.set(this, s));
82
- let o = s.get(a);
83
- o || (o = new P(e, t), s.set(a, o)), o.debounce(() => i.apply(this, d));
86
+ let a = s.get(o);
87
+ a || (a = new C(e, t), s.set(o, a)), a.debounce(() => i.apply(this, c));
84
88
  };
85
89
  };
86
90
  }
87
- function Q(e) {
91
+ function Y(e) {
88
92
  if (typeof e.lineNumber == "number")
89
93
  return {
90
94
  file: e.fileName || e.sourceURL,
@@ -100,13 +104,13 @@ function Q(e) {
100
104
  const n = String(e.stack || e.message || "").split(`
101
105
  `), i = /(.*?)(?:\(|@)?(.*?):(\d+):(\d+)\)?$/;
102
106
  for (const r of n) {
103
- const a = r.match(i);
104
- if (a)
105
- return { file: a[2], line: +a[3], column: +a[4] };
107
+ const o = r.match(i);
108
+ if (o)
109
+ return { file: o[2], line: +o[3], column: +o[4] };
106
110
  }
107
111
  return { file: e.fileName || e.sourceURL };
108
112
  }
109
- class j {
113
+ class V {
110
114
  constructor(t, n, i, r = "main") {
111
115
  this._debug = t, this.myTag = n, this.myElementId = i, this.instanceId = r;
112
116
  }
@@ -127,13 +131,13 @@ class j {
127
131
  throw this.error(...t), new Error(n);
128
132
  }
129
133
  }
130
- class Y {
134
+ class Z {
131
135
  constructor(t, n = !0) {
132
- c(this, "label");
133
- c(this, "last");
134
- c(this, "startTime");
135
- c(this, "running", !1);
136
- c(this, "enabled");
136
+ m(this, "label");
137
+ m(this, "last");
138
+ m(this, "startTime");
139
+ m(this, "running", !1);
140
+ m(this, "enabled");
137
141
  this.label = t, this.enabled = n, this.startTime = this.last = performance.now(), this.running = !0;
138
142
  }
139
143
  lap(t = "") {
@@ -157,10 +161,10 @@ class Y {
157
161
  return this.running;
158
162
  }
159
163
  }
160
- function V(e) {
164
+ function F(e) {
161
165
  return typeof e == "object" && e !== null && !Array.isArray(e);
162
166
  }
163
- function F(e) {
167
+ function K(e) {
164
168
  if (e != null)
165
169
  try {
166
170
  return JSON.parse(e);
@@ -168,28 +172,28 @@ function F(e) {
168
172
  return;
169
173
  }
170
174
  }
171
- function M(e) {
175
+ function P(e) {
172
176
  const t = JSON.stringify(e);
173
177
  return t === void 0 ? "null" : t;
174
178
  }
175
- function K(e, t) {
179
+ function z(e, t) {
176
180
  const n = { ...t };
177
- if (V(e))
181
+ if (F(e))
178
182
  for (const i of Object.keys(t))
179
183
  i in e && (n[i] = e[i]);
180
184
  return n;
181
185
  }
182
- class C {
186
+ class A {
183
187
  constructor(t, n, i) {
184
- c(this, "cache");
188
+ m(this, "cache");
185
189
  this.backend = t, this.storageKey = n, this.initialValue = i;
186
190
  }
187
191
  read() {
188
192
  if (this.cache) return this.cache;
189
- const t = this.backend ? F(this.backend.getItem(this.storageKey)) : void 0, n = K(t, this.initialValue);
193
+ const t = this.backend ? K(this.backend.getItem(this.storageKey)) : void 0, n = z(t, this.initialValue);
190
194
  if (this.backend && this.backend.getItem(this.storageKey) == null)
191
195
  try {
192
- this.backend.setItem(this.storageKey, M(n));
196
+ this.backend.setItem(this.storageKey, P(n));
193
197
  } catch {
194
198
  }
195
199
  return this.cache = n, n;
@@ -197,7 +201,7 @@ class C {
197
201
  write(t) {
198
202
  if (this.cache = t, !!this.backend)
199
203
  try {
200
- this.backend.setItem(this.storageKey, M(t));
204
+ this.backend.setItem(this.storageKey, P(t));
201
205
  } catch {
202
206
  }
203
207
  }
@@ -211,15 +215,15 @@ class C {
211
215
  },
212
216
  set: (n, i, r) => {
213
217
  if (typeof i != "string") return !1;
214
- const d = { ...this.read() };
215
- return d[i] = r, this.write(d), !0;
218
+ const c = { ...this.read() };
219
+ return c[i] = r, this.write(c), !0;
216
220
  },
217
221
  deleteProperty: (n, i) => {
218
222
  if (typeof i != "string") return !1;
219
223
  const r = this.read();
220
224
  if (!(i in r)) return !0;
221
- const a = { ...r };
222
- return delete a[i], this.write(a), !0;
225
+ const o = { ...r };
226
+ return delete o[i], this.write(o), !0;
223
227
  },
224
228
  has: (n, i) => {
225
229
  if (typeof i != "string") return !1;
@@ -245,47 +249,47 @@ class C {
245
249
  return new Proxy({}, t);
246
250
  }
247
251
  }
248
- function A(e) {
252
+ function W(e) {
249
253
  const t = globalThis.window;
250
254
  return (e === "session" ? t == null ? void 0 : t.sessionStorage : t == null ? void 0 : t.localStorage) ?? void 0;
251
255
  }
252
- function Z(e, t) {
253
- return new C(A("session"), e, t).asProxy();
254
- }
255
256
  function tt(e, t) {
256
- return new C(A("local"), e, t).asProxy();
257
+ return new A(W("session"), e, t).asProxy();
258
+ }
259
+ function et(e, t) {
260
+ return new A(W("local"), e, t).asProxy();
257
261
  }
258
- function T(e, t, n) {
262
+ function L(e, t, n) {
259
263
  return new Promise((i, r) => {
260
- const a = (d) => {
261
- e.removeEventListener(t, a, n), i(d);
264
+ const o = (c) => {
265
+ e.removeEventListener(t, o, n), i(c);
262
266
  };
263
- e.addEventListener(t, a, n);
267
+ e.addEventListener(t, o, n);
264
268
  });
265
269
  }
266
- function z() {
270
+ function H() {
267
271
  return document.readyState === "loading" ? new Promise((e) => {
268
272
  document.addEventListener("DOMContentLoaded", () => e());
269
273
  }) : Promise.resolve();
270
274
  }
271
- function et() {
272
- return window.tj_loader_state ? window.tj_loader_state !== "loading" ? Promise.resolve() : T(window, "loader:ready") : L();
273
- }
274
275
  function nt() {
275
- return window.tj_loader_state ? window.tj_loader_state === "pre-visual" || window.tj_loader_state === "visual" ? Promise.resolve() : T(window, "loader:pre-visual") : L();
276
+ return window.tj_loader_state ? window.tj_loader_state !== "loading" ? Promise.resolve() : L(window, "loader:ready") : x();
276
277
  }
277
278
  function it() {
278
- return window.tj_loader_state ? window.tj_loader_state === "visual" ? Promise.resolve() : T(window, "loader:visual") : L();
279
+ return window.tj_loader_state ? window.tj_loader_state === "pre-visual" || window.tj_loader_state === "visual" ? Promise.resolve() : L(window, "loader:pre-visual") : x();
280
+ }
281
+ function rt() {
282
+ return window.tj_loader_state ? window.tj_loader_state === "visual" ? Promise.resolve() : L(window, "loader:visual") : x();
279
283
  }
280
- function L(e = window) {
284
+ function x(e = window) {
281
285
  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) => {
282
286
  e.addEventListener("load", () => t(), { once: !0 }), e.addEventListener("error", () => n(new Error("image error")), { once: !0 });
283
287
  }) : 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 }));
284
288
  }
285
- function rt(e) {
289
+ function st(e) {
286
290
  return new Promise((t) => setTimeout(t, e));
287
291
  }
288
- function st(e) {
292
+ function ot(e) {
289
293
  return new Promise((t) => {
290
294
  const n = (i) => {
291
295
  e.removeEventListener("animationend", n), t(i);
@@ -293,118 +297,118 @@ function st(e) {
293
297
  e.addEventListener("animationend", n);
294
298
  });
295
299
  }
296
- function ot(e) {
300
+ function at(e) {
297
301
  var n, i;
298
302
  class t extends e {
299
303
  constructor() {
300
304
  super(...arguments);
301
- h(this, n, new P(200, 5e3));
302
- c(this, "currentBreakPoint", null);
303
- h(this, i, async () => {
304
- var b;
305
- await u(this, n).wait(), await z();
306
- const d = this, s = window.innerWidth;
307
- let o = getComputedStyle(d).getPropertyValue("--breakpoint");
308
- if (!o || o === "")
305
+ f(this, n, new C(200, 5e3));
306
+ m(this, "currentBreakPoint", null);
307
+ f(this, i, async () => {
308
+ var y;
309
+ await l(this, n).wait(), await H();
310
+ const c = this, s = window.innerWidth;
311
+ let a = getComputedStyle(c).getPropertyValue("--breakpoint");
312
+ if (!a || a === "")
309
313
  return;
310
- o = o.trim().replace(/^['"]|['"]$/g, "");
311
- const l = o.split(","), m = l[0].trim(), f = ((b = l[1]) == null ? void 0 : b.trim()) ?? m, g = U(s);
312
- this.currentBreakPoint !== g && (E(f) <= E(g) ? d.setAttribute("mode", "desktop") : E(m) > E(g) ? d.setAttribute("mode", "mobile") : d.setAttribute("mode", "tablet"));
314
+ a = a.trim().replace(/^['"]|['"]$/g, "");
315
+ const u = a.split(","), d = u[0].trim(), h = ((y = u[1]) == null ? void 0 : y.trim()) ?? d, g = j(s);
316
+ this.currentBreakPoint !== g && (E(h) <= E(g) ? c.setAttribute("mode", "desktop") : E(d) > E(g) ? c.setAttribute("mode", "mobile") : c.setAttribute("mode", "tablet"));
313
317
  });
314
318
  }
315
319
  connectedCallback() {
316
320
  super.connectedCallback();
317
321
  try {
318
- u(this, i).call(this), window.addEventListener("resize", u(this, i)), u(this, i).call(this);
319
- } catch (d) {
320
- throw console.error("Error in BreakPointMixin:", d, "in element", this), d;
322
+ l(this, i).call(this), window.addEventListener("resize", l(this, i)), l(this, i).call(this);
323
+ } catch (c) {
324
+ throw console.error("Error in BreakPointMixin:", c, "in element", this), c;
321
325
  }
322
326
  }
323
327
  disconnectedCallback() {
324
- super.disconnectedCallback(), window.removeEventListener("resize", u(this, i));
328
+ super.disconnectedCallback(), window.removeEventListener("resize", l(this, i));
325
329
  }
326
330
  }
327
331
  return n = new WeakMap(), i = new WeakMap(), t;
328
332
  }
329
- const p = Symbol("listenerDefs"), W = Symbol("withEventBindings");
330
- function at(e, t) {
333
+ const p = Symbol("listenerDefs"), $ = Symbol("withEventBindings");
334
+ function ut(e, t) {
331
335
  const n = Array.isArray(e) ? e : [e];
332
336
  return function(i, r) {
333
337
  if (r.kind !== "method") throw new Error("@Listen nur für Methoden");
334
338
  return r.addInitializer(function() {
335
- const a = this;
336
- (a[p] || (a[p] = [])).push({
339
+ const o = this;
340
+ (o[p] || (o[p] = [])).push({
337
341
  method: r.name,
338
342
  events: [...n],
339
343
  opts: t
340
344
  });
341
- }), function(...a) {
342
- if (!this[W])
345
+ }), function(...o) {
346
+ if (!this[$])
343
347
  throw new Error("[EventBindings] @Listen - decorator requires EventBindingMixin.");
344
- return i.apply(this, a);
348
+ return i.apply(this, o);
345
349
  };
346
350
  };
347
351
  }
348
- function H(e, t) {
352
+ function G(e, t) {
349
353
  var n;
350
354
  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;
351
355
  }
352
- function ut(e) {
353
- var n, i, $;
356
+ function dt(e) {
357
+ var n, i, I;
354
358
  class t extends e {
355
359
  constructor(...s) {
356
360
  super(...s);
357
- h(this, i);
358
- h(this, n);
359
- this[W] = !0;
361
+ f(this, i);
362
+ f(this, n);
363
+ this[$] = !0;
360
364
  }
361
365
  connectedCallback() {
362
366
  var s;
363
- (s = super.connectedCallback) == null || s.call(this), y(this, i, $).call(this);
367
+ (s = super.connectedCallback) == null || s.call(this), w(this, i, I).call(this);
364
368
  }
365
369
  disconnectedCallback() {
366
- var s, o;
367
- (s = u(this, n)) == null || s.abort(), (o = super.disconnectedCallback) == null || o.call(this);
370
+ var s, a;
371
+ (s = l(this, n)) == null || s.abort(), (a = super.disconnectedCallback) == null || a.call(this);
368
372
  }
369
373
  }
370
- return n = new WeakMap(), i = new WeakSet(), $ = function() {
371
- var o, l, m;
372
- (o = u(this, n)) == null || o.abort(), w(this, n, new AbortController());
374
+ return n = new WeakMap(), i = new WeakSet(), I = function() {
375
+ var a, u, d;
376
+ (a = l(this, n)) == null || a.abort(), b(this, n, new AbortController());
373
377
  const s = this[p] || [];
374
- for (const f of s) {
375
- const g = H(this, (l = f.opts) == null ? void 0 : l.target), b = ((m = f.opts) == null ? void 0 : m.options) ?? {}, N = this[f.method].bind(this);
376
- for (const B of f.events)
377
- g.addEventListener(B, N, { ...b, signal: u(this, n).signal });
378
+ for (const h of s) {
379
+ const g = G(this, (u = h.opts) == null ? void 0 : u.target), y = ((d = h.opts) == null ? void 0 : d.options) ?? {}, D = this[h.method].bind(this);
380
+ for (const R of h.events)
381
+ g.addEventListener(R, D, { ...y, signal: l(this, n).signal });
378
382
  }
379
383
  }, t;
380
384
  }
381
- let G = 1;
382
- function dt(e) {
385
+ let q = 1;
386
+ function lt(e) {
383
387
  var n, i, r;
384
388
  class t extends e {
385
389
  constructor() {
386
390
  super(...arguments);
387
- h(this, n, null);
388
- h(this, i, G++);
389
- h(this, r, null);
391
+ f(this, n, null);
392
+ f(this, i, q++);
393
+ f(this, r, null);
390
394
  }
391
395
  /**
392
396
  * Clears the cached debug flag so the attribute will be checked again
393
397
  * on the next log/warn/error call.
394
398
  */
395
399
  invalidateDebugCache() {
396
- w(this, n, null);
400
+ b(this, n, null);
397
401
  }
398
402
  get _debug() {
399
- 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.info(
403
+ return l(this, n) !== null ? l(this, n) : (this instanceof HTMLElement && b(this, n, this.hasAttribute("debug") && !["false", "0", "off", "no"].includes(this.getAttribute("debug") || "")), l(this, n) === !0 && console.info(
400
404
  // @ts-expect-error - it says tagName is not defined -whatever
401
- `[DEBUG][ID:${u(this, i)}] LoggingMixin: Debug mode is enabled for <${this.tagName}>`,
405
+ `[DEBUG][ID:${l(this, i)}] LoggingMixin: Debug mode is enabled for <${this.tagName}>`,
402
406
  this
403
- ), u(this, n) ?? !1);
407
+ ), l(this, n) ?? !1);
404
408
  }
405
409
  getLogger(s = "main") {
406
- const o = "<" + (this.tagName || this.constructor.name || "UnknownElement") + ">";
407
- return u(this, r) || w(this, r, new j(this._debug, o, `${u(this, i)}`, s)), u(this, r);
410
+ const a = "<" + (this.tagName || this.constructor.name || "UnknownElement") + ">";
411
+ return l(this, r) || b(this, r, new V(this._debug, a, `${l(this, i)}`, s)), l(this, r);
408
412
  }
409
413
  debug(...s) {
410
414
  this.getLogger().debug(...s);
@@ -424,94 +428,102 @@ function dt(e) {
424
428
  }
425
429
  return n = new WeakMap(), i = new WeakMap(), r = new WeakMap(), t;
426
430
  }
427
- function lt(e) {
431
+ function ct(e) {
428
432
  class t extends e {
429
433
  connectedCallback() {
430
- this.dispatchEvent(new CustomEvent("init:child-waitreq", {
431
- detail: {
432
- element: this,
433
- state: "connected"
434
- },
435
- bubbles: !0,
436
- composed: !0
437
- })), super.connectedCallback();
434
+ this.dispatchEvent(
435
+ new CustomEvent("init:child-waitreq", {
436
+ detail: {
437
+ element: this,
438
+ state: "connected"
439
+ },
440
+ bubbles: !0,
441
+ composed: !0
442
+ })
443
+ ), super.connectedCallback();
438
444
  }
439
445
  firstUpdated(i) {
440
446
  var r;
441
- (r = super.firstUpdated) == null || r.call(this, i), this.dispatchEvent(new CustomEvent("init:child-ready", {
442
- detail: {
443
- element: this,
444
- state: "ready"
445
- },
446
- bubbles: !0,
447
- composed: !0
448
- }));
447
+ (r = super.firstUpdated) == null || r.call(this, i), this.dispatchEvent(
448
+ new CustomEvent("init:child-ready", {
449
+ detail: {
450
+ element: this,
451
+ state: "ready"
452
+ },
453
+ bubbles: !0,
454
+ composed: !0
455
+ })
456
+ );
449
457
  }
450
458
  disconnectedCallback() {
451
- super.disconnectedCallback(), this.dispatchEvent(new CustomEvent("init:child-ready", {
452
- detail: {
453
- element: this,
454
- state: "disconnected"
455
- },
456
- bubbles: !0,
457
- composed: !0
458
- }));
459
+ super.disconnectedCallback(), this.dispatchEvent(
460
+ new CustomEvent("init:child-ready", {
461
+ detail: {
462
+ element: this,
463
+ state: "disconnected"
464
+ },
465
+ bubbles: !0,
466
+ composed: !0
467
+ })
468
+ );
459
469
  }
460
470
  }
461
471
  return t;
462
472
  }
463
- function ct(e) {
464
- var n, I, r, S;
473
+ function ht(e) {
474
+ var n, N, r, k, S;
465
475
  class t extends e {
466
476
  constructor() {
467
477
  super(...arguments);
468
- h(this, n);
469
- h(this, r, (o) => {
470
- const l = o.target;
471
- (l.assignedNodes({ flatten: !0 }).filter((g) => y(this, n, S).call(this, g)).length > 0 || l.childNodes.length > 0) && l.classList.remove("slot-empty");
478
+ f(this, n);
479
+ f(this, r, (u) => {
480
+ const d = u.target, h = w(this, n, k).call(this, d.assignedNodes({ flatten: !0 })), g = w(this, n, k).call(this, d.childNodes);
481
+ h || g ? d.classList.remove("slot-empty") : d.classList.add("slot-empty");
472
482
  });
473
483
  }
474
- firstUpdated(o) {
475
- var l;
476
- (l = super.firstUpdated) == null || l.call(this, o), y(this, n, I).call(this);
484
+ firstUpdated(u) {
485
+ var d;
486
+ (d = super.firstUpdated) == null || d.call(this, u), w(this, n, N).call(this);
477
487
  }
478
488
  }
479
- return n = new WeakSet(), I = function() {
480
- var l;
481
- const o = (l = this.shadowRoot) == null ? void 0 : l.querySelectorAll("slot");
482
- o == null || o.forEach((m) => {
483
- m.classList.add("slot-empty"), m.addEventListener("slotchange", (f) => u(this, r).call(this, f));
489
+ return n = new WeakSet(), N = function() {
490
+ var d;
491
+ const u = (d = this.shadowRoot) == null ? void 0 : d.querySelectorAll("slot");
492
+ u == null || u.forEach((h) => {
493
+ w(this, n, k).call(this, h.childNodes) || h.classList.add("slot-empty"), h.addEventListener("slotchange", (g) => l(this, r).call(this, g));
484
494
  });
485
- }, r = new WeakMap(), S = function(o) {
486
- return o.nodeType === Node.TEXT_NODE ? (o.textContent || "").trim().length > 0 : o.nodeType === Node.ELEMENT_NODE;
495
+ }, r = new WeakMap(), k = function(u) {
496
+ return Array.from(u).some((d) => w(this, n, S).call(this, d));
497
+ }, S = function(u) {
498
+ return u.nodeType === Node.TEXT_NODE ? (u.textContent || "").trim().length > 0 : u.nodeType === Node.ELEMENT_NODE;
487
499
  }, t;
488
500
  }
489
501
  export {
490
- ot as BreakPointMixin,
491
- P as Debouncer,
492
- ut as EventBindingsMixin,
493
- at as Listen,
494
- lt as LoaderMixin,
495
- j as Logger,
496
- dt as LoggingMixin,
497
- ct as SlotVisibilityMixin,
498
- Y as Stopwatch,
499
- _ as breakpointMap,
502
+ at as BreakPointMixin,
503
+ C as Debouncer,
504
+ dt as EventBindingsMixin,
505
+ ut as Listen,
506
+ ct as LoaderMixin,
507
+ V as Logger,
508
+ lt as LoggingMixin,
509
+ ht as SlotVisibilityMixin,
510
+ Z as Stopwatch,
511
+ M as breakpointMap,
500
512
  v as breakpoints,
501
- J as create_element,
502
- X as debounce,
513
+ X as create_element,
514
+ Q as debounce,
503
515
  E as getBreakpointMinWidth,
504
- U as getCurrentBreakpoint,
505
- Q as getErrorLocation,
506
- O as getViewportWidth,
507
- tt as local_storage,
508
- Z as session_storage,
509
- rt as sleep,
510
- T as waitFor,
511
- st as waitForAnimationEnd,
512
- z as waitForDomContentLoaded,
513
- L as waitForLoad,
514
- nt as waitForPreVisual,
515
- et as waitForReady,
516
- it as waitForVisual
516
+ j as getCurrentBreakpoint,
517
+ Y as getErrorLocation,
518
+ U as getViewportWidth,
519
+ et as local_storage,
520
+ tt as session_storage,
521
+ st as sleep,
522
+ L as waitFor,
523
+ ot as waitForAnimationEnd,
524
+ H as waitForDomContentLoaded,
525
+ x as waitForLoad,
526
+ it as waitForPreVisual,
527
+ nt as waitForReady,
528
+ rt as waitForVisual
517
529
  };
@@ -11,6 +11,10 @@ export declare class Debouncer {
11
11
  */
12
12
  constructor(delay: number, max_delay?: number | false);
13
13
  wait(): Promise<unknown>;
14
+ /**
15
+ * @deprecated Use wait() instead and handle the callback logic in the caller function for better control and flexibility.
16
+ * @param callback
17
+ */
14
18
  debounce(callback: () => void): void;
15
19
  }
16
20
  type MethodCtx = {
@@ -1,6 +1,6 @@
1
- import { LitElement } from 'lit';
1
+ import { ReactiveElement } from 'lit';
2
2
  type Constructor<T = object> = abstract new (...args: any[]) => T;
3
3
  export interface LoaderMixinInterface {
4
4
  }
5
- export declare function LoaderMixin<TBase extends Constructor<LitElement>>(Base: TBase): TBase & Constructor<LoaderMixinInterface>;
5
+ export declare function LoaderMixin<TBase extends Constructor<ReactiveElement>>(Base: TBase): TBase & Constructor<LoaderMixinInterface>;
6
6
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trunkjs/browser-utils",
3
- "version": "1.0.48",
3
+ "version": "1.0.50",
4
4
  "main": "./index.js",
5
5
  "repository": {
6
6
  "directory": "packages/browser-utils",