@trunkjs/browser-utils 1.0.53 → 1.0.55

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/index.js +193 -182
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## 1.0.55 (2026-09-09)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - **browser-utils:** notify loader before disconnect cleanup via window ([1440729](https://github.com/trunkjs/trunkjs-monorepo/commit/1440729))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - Matthias Leuffen
10
+
11
+ ## 1.0.54 (2026-09-07)
12
+
13
+ This was a version bump only for browser-utils to align it with other projects, there were no code changes.
14
+
1
15
  ## 1.0.53 (2026-09-01)
2
16
 
3
17
  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,37 +1,37 @@
1
- var O = Object.defineProperty;
2
- var P = (n) => {
1
+ var j = Object.defineProperty;
2
+ var I = (n) => {
3
3
  throw TypeError(n);
4
4
  };
5
- var j = (n, t, e) => t in n ? O(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
- var f = (n, t, e) => j(n, typeof t != "symbol" ? t + "" : t, e), T = (n, t, e) => t.has(n) || P("Cannot " + e);
7
- var l = (n, t, e) => (T(n, t, "read from private field"), e ? e.call(n) : t.get(n)), m = (n, t, e) => t.has(n) ? P("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), y = (n, t, e, i) => (T(n, t, "write to private field"), i ? i.call(n, e) : t.set(n, e), e), w = (n, t, e) => (T(n, t, "access private method"), e);
8
- const E = [
5
+ var F = (n, t, e) => t in n ? j(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
+ var f = (n, t, e) => F(n, typeof t != "symbol" ? t + "" : t, e), L = (n, t, e) => t.has(n) || I("Cannot " + e);
7
+ var c = (n, t, e) => (L(n, t, "read from private field"), e ? e.call(n) : t.get(n)), m = (n, t, e) => t.has(n) ? I("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), p = (n, t, e, i) => (L(n, t, "write to private field"), i ? i.call(n, e) : t.set(n, e), e), g = (n, t, e) => (L(n, t, "access private method"), e);
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
- ], S = E.reduce(
15
+ ], W = k.reduce(
16
16
  (n, t) => (n[t.name] = t.minWidth, n),
17
17
  {}
18
18
  );
19
- function p(n) {
20
- if (!(n in S))
19
+ function E(n) {
20
+ if (!(n in W))
21
21
  throw new Error(`Unknown breakpoint: ${n}`);
22
- return S[n];
22
+ return W[n];
23
23
  }
24
- function F() {
24
+ function H() {
25
25
  return window.visualViewport ? window.visualViewport.width : window.innerWidth;
26
26
  }
27
27
  function U(n) {
28
- n === void 0 && (n = F());
29
- for (let t = E.length - 1; t >= 0; t--)
30
- if (n >= E[t].minWidth)
31
- return E[t].name;
28
+ n === void 0 && (n = H());
29
+ for (let t = k.length - 1; t >= 0; t--)
30
+ if (n >= k[t].minWidth)
31
+ return k[t].name;
32
32
  return "xs";
33
33
  }
34
- function nt(n, t = {}, e = []) {
34
+ function it(n, t = {}, e = []) {
35
35
  Array.isArray(e) || (e = [e]);
36
36
  const i = document.createElement(n);
37
37
  for (const r in t)
@@ -40,7 +40,7 @@ function nt(n, t = {}, e = []) {
40
40
  i.append(typeof r == "string" ? document.createTextNode(r) : r);
41
41
  return i;
42
42
  }
43
- class C {
43
+ class N {
44
44
  /**
45
45
  *
46
46
  * @param delay Debounce delay in milliseconds
@@ -75,27 +75,27 @@ class C {
75
75
  }
76
76
  }
77
77
  }
78
- function it(n, t = !1) {
78
+ function rt(n, t = !1) {
79
79
  const e = /* @__PURE__ */ new WeakMap();
80
80
  return function(i, r) {
81
81
  if (r.kind !== "method") return i;
82
82
  const s = r.name;
83
- return function(...a) {
84
- let o = e.get(this);
85
- o || (o = /* @__PURE__ */ new Map(), e.set(this, o));
86
- let u = o.get(s);
87
- u || (u = new C(n, t), o.set(s, u)), u.debounce(() => i.apply(this, a));
83
+ return function(...o) {
84
+ let a = e.get(this);
85
+ a || (a = /* @__PURE__ */ new Map(), e.set(this, a));
86
+ let d = a.get(s);
87
+ d || (d = new N(n, t), a.set(s, d)), d.debounce(() => i.apply(this, o));
88
88
  };
89
89
  };
90
90
  }
91
- const H = /* @__PURE__ */ new Set(["button", "image", "reset", "submit"]);
92
- function z(n) {
91
+ const z = /* @__PURE__ */ new Set(["button", "image", "reset", "submit"]);
92
+ function G(n) {
93
93
  return n.endsWith("[]") ? n.slice(0, -2) : n;
94
94
  }
95
- function L(n) {
95
+ function A(n) {
96
96
  return n instanceof HTMLInputElement ? n.type.toLowerCase() : "";
97
97
  }
98
- function G(n) {
98
+ function K(n) {
99
99
  if (n instanceof HTMLSelectElement && n.multiple)
100
100
  return Array.from(n.selectedOptions, (t) => t.value);
101
101
  if (n instanceof HTMLInputElement) {
@@ -108,7 +108,7 @@ function G(n) {
108
108
  }
109
109
  return n.value;
110
110
  }
111
- function K(n, t) {
111
+ function q(n, t) {
112
112
  if (n instanceof HTMLSelectElement && n.multiple) {
113
113
  const e = new Set(Array.isArray(t) ? t.map(String) : t == null ? [] : [String(t)]);
114
114
  for (const i of Array.from(n.options))
@@ -131,14 +131,14 @@ function K(n, t) {
131
131
  }
132
132
  n.value = t;
133
133
  }
134
- function A(n, t, e) {
134
+ function x(n, t, e) {
135
135
  if (!(e == null || e === !1)) {
136
136
  if (e instanceof FormData) {
137
137
  e.forEach((i, r) => n.append(r, i));
138
138
  return;
139
139
  }
140
140
  if (Array.isArray(e)) {
141
- e.forEach((i) => A(n, t, i));
141
+ e.forEach((i) => x(n, t, i));
142
142
  return;
143
143
  }
144
144
  if (e instanceof Blob) {
@@ -148,7 +148,7 @@ function A(n, t, e) {
148
148
  n.append(t, String(e));
149
149
  }
150
150
  }
151
- class rt {
151
+ class st {
152
152
  constructor(t) {
153
153
  this.root = t;
154
154
  }
@@ -160,10 +160,10 @@ class rt {
160
160
  name: i,
161
161
  element: e,
162
162
  get value() {
163
- return G(e);
163
+ return K(e);
164
164
  },
165
165
  set value(r) {
166
- K(e, r);
166
+ q(e, r);
167
167
  }
168
168
  });
169
169
  }
@@ -186,20 +186,20 @@ class rt {
186
186
  for (const e of this.entries) {
187
187
  if (this.isDisabled(e.element))
188
188
  continue;
189
- const i = L(e.element);
189
+ const i = A(e.element);
190
190
  if (i === "checkbox" || i === "radio") {
191
191
  const r = e.element;
192
- r.checked && A(t, e.name, r.value);
192
+ r.checked && x(t, e.name, r.value);
193
193
  continue;
194
194
  }
195
- A(t, e.name, e.value);
195
+ x(t, e.name, e.value);
196
196
  }
197
197
  return t;
198
198
  }
199
199
  get groupedEntries() {
200
200
  const t = /* @__PURE__ */ new Map();
201
201
  for (const e of this.entries) {
202
- const i = z(e.name), r = t.get(i) ?? [];
202
+ const i = G(e.name), r = t.get(i) ?? [];
203
203
  r.push(e), t.set(i, r);
204
204
  }
205
205
  return t;
@@ -210,7 +210,7 @@ class rt {
210
210
  return (e == null ? void 0 : e.trim()) || ((i = t.getAttribute("name")) == null ? void 0 : i.trim()) || null;
211
211
  }
212
212
  isValueElement(t) {
213
- return !("value" in t) || t instanceof HTMLButtonElement ? !1 : !(t instanceof HTMLInputElement && H.has(t.type.toLowerCase()));
213
+ return !("value" in t) || t instanceof HTMLButtonElement ? !1 : !(t instanceof HTMLInputElement && z.has(t.type.toLowerCase()));
214
214
  }
215
215
  /** A named value element owns its value, so its descendants are not collected twice. */
216
216
  hasValueElementParent(t) {
@@ -227,18 +227,18 @@ class rt {
227
227
  }
228
228
  readGroup(t) {
229
229
  var r;
230
- const e = new Set(t.map((s) => L(s.element))), i = t.some((s) => s.name.endsWith("[]"));
230
+ const e = new Set(t.map((s) => A(s.element))), i = t.some((s) => s.name.endsWith("[]"));
231
231
  return e.size === 1 && e.has("radio") ? (r = t.find((s) => s.element.checked)) == null ? void 0 : r.element.value : e.size === 1 && e.has("checkbox") ? t.length === 1 && !i ? t[0].element.checked : t.filter((s) => s.element.checked).map((s) => s.element.value) : i ? t.flatMap((s) => {
232
- const a = s.value;
233
- return a === void 0 ? [] : Array.isArray(a) ? a : [a];
232
+ const o = s.value;
233
+ return o === void 0 ? [] : Array.isArray(o) ? o : [o];
234
234
  }) : t.length === 1 ? t[0].value : t.map((s) => s.value).at(-1);
235
235
  }
236
236
  writeGroup(t, e) {
237
- const i = new Set(t.map((s) => L(s.element))), r = t.some((s) => s.name.endsWith("[]"));
237
+ const i = new Set(t.map((s) => A(s.element))), r = t.some((s) => s.name.endsWith("[]"));
238
238
  if (i.size === 1 && i.has("radio")) {
239
239
  t.forEach((s) => {
240
- const a = s.element;
241
- a.checked = a.value === String(e);
240
+ const o = s.element;
241
+ o.checked = o.value === String(e);
242
242
  });
243
243
  return;
244
244
  }
@@ -248,15 +248,15 @@ class rt {
248
248
  return;
249
249
  }
250
250
  const s = new Set((Array.isArray(e) ? e : e == null ? [] : [e]).map(String));
251
- t.forEach((a) => {
252
- const o = a.element;
253
- o.checked = s.has(o.value);
251
+ t.forEach((o) => {
252
+ const a = o.element;
253
+ a.checked = s.has(a.value);
254
254
  });
255
255
  return;
256
256
  }
257
257
  if (r && Array.isArray(e) && t.length > 1) {
258
- t.forEach((s, a) => {
259
- s.value = e[a];
258
+ t.forEach((s, o) => {
259
+ s.value = e[o];
260
260
  });
261
261
  return;
262
262
  }
@@ -265,7 +265,7 @@ class rt {
265
265
  });
266
266
  }
267
267
  }
268
- function st(n) {
268
+ function ot(n) {
269
269
  if (typeof n.lineNumber == "number")
270
270
  return {
271
271
  file: n.fileName || n.sourceURL,
@@ -287,7 +287,7 @@ function st(n) {
287
287
  }
288
288
  return { file: n.fileName || n.sourceURL };
289
289
  }
290
- class q {
290
+ class J {
291
291
  constructor(t, e, i, r = "main") {
292
292
  this._debug = t, this.myTag = e, this.myElementId = i, this.instanceId = r;
293
293
  }
@@ -308,7 +308,7 @@ class q {
308
308
  throw this.error(...t), new Error(e);
309
309
  }
310
310
  }
311
- class ot {
311
+ class at {
312
312
  constructor(t, e = !0) {
313
313
  f(this, "label");
314
314
  f(this, "last");
@@ -338,10 +338,10 @@ class ot {
338
338
  return this.running;
339
339
  }
340
340
  }
341
- function J(n) {
341
+ function X(n) {
342
342
  return typeof n == "object" && n !== null && !Array.isArray(n);
343
343
  }
344
- function X(n) {
344
+ function Q(n) {
345
345
  if (n != null)
346
346
  try {
347
347
  return JSON.parse(n);
@@ -349,28 +349,28 @@ function X(n) {
349
349
  return;
350
350
  }
351
351
  }
352
- function _(n) {
352
+ function $(n) {
353
353
  const t = JSON.stringify(n);
354
354
  return t === void 0 ? "null" : t;
355
355
  }
356
- function Q(n, t) {
356
+ function Y(n, t) {
357
357
  const e = { ...t };
358
- if (J(n))
358
+ if (X(n))
359
359
  for (const i of Object.keys(t))
360
360
  i in n && (e[i] = n[i]);
361
361
  return e;
362
362
  }
363
- class I {
363
+ class D {
364
364
  constructor(t, e, i) {
365
365
  f(this, "cache");
366
366
  this.backend = t, this.storageKey = e, this.initialValue = i;
367
367
  }
368
368
  read() {
369
369
  if (this.cache) return this.cache;
370
- const t = this.backend ? X(this.backend.getItem(this.storageKey)) : void 0, e = Q(t, this.initialValue);
370
+ const t = this.backend ? Q(this.backend.getItem(this.storageKey)) : void 0, e = Y(t, this.initialValue);
371
371
  if (this.backend && this.backend.getItem(this.storageKey) == null)
372
372
  try {
373
- this.backend.setItem(this.storageKey, _(e));
373
+ this.backend.setItem(this.storageKey, $(e));
374
374
  } catch {
375
375
  }
376
376
  return this.cache = e, e;
@@ -378,7 +378,7 @@ class I {
378
378
  write(t) {
379
379
  if (this.cache = t, !!this.backend)
380
380
  try {
381
- this.backend.setItem(this.storageKey, _(t));
381
+ this.backend.setItem(this.storageKey, $(t));
382
382
  } catch {
383
383
  }
384
384
  }
@@ -392,8 +392,8 @@ class I {
392
392
  },
393
393
  set: (e, i, r) => {
394
394
  if (typeof i != "string") return !1;
395
- const a = { ...this.read() };
396
- return a[i] = r, this.write(a), !0;
395
+ const o = { ...this.read() };
396
+ return o[i] = r, this.write(o), !0;
397
397
  },
398
398
  deleteProperty: (e, i) => {
399
399
  if (typeof i != "string") return !1;
@@ -426,47 +426,47 @@ class I {
426
426
  return new Proxy({}, t);
427
427
  }
428
428
  }
429
- function W(n) {
429
+ function B(n) {
430
430
  const t = globalThis.window;
431
431
  return (n === "session" ? t == null ? void 0 : t.sessionStorage : t == null ? void 0 : t.localStorage) ?? void 0;
432
432
  }
433
- function at(n, t) {
434
- return new I(W("session"), n, t).asProxy();
435
- }
436
433
  function ut(n, t) {
437
- return new I(W("local"), n, t).asProxy();
434
+ return new D(B("session"), n, t).asProxy();
438
435
  }
439
- function x(n, t, e) {
436
+ function ct(n, t) {
437
+ return new D(B("local"), n, t).asProxy();
438
+ }
439
+ function _(n, t, e) {
440
440
  return new Promise((i, r) => {
441
- const s = (a) => {
442
- n.removeEventListener(t, s, e), i(a);
441
+ const s = (o) => {
442
+ n.removeEventListener(t, s, e), i(o);
443
443
  };
444
444
  n.addEventListener(t, s, e);
445
445
  });
446
446
  }
447
- function Y() {
447
+ function Z() {
448
448
  return document.readyState === "loading" ? new Promise((n) => {
449
449
  document.addEventListener("DOMContentLoaded", () => n());
450
450
  }) : Promise.resolve();
451
451
  }
452
- function ct() {
453
- return window.tj_loader_state ? window.tj_loader_state !== "loading" ? Promise.resolve() : x(window, "loader:ready") : M();
454
- }
455
452
  function dt() {
456
- return window.tj_loader_state ? window.tj_loader_state === "pre-visual" || window.tj_loader_state === "visual" ? Promise.resolve() : x(window, "loader:pre-visual") : M();
453
+ return window.tj_loader_state ? window.tj_loader_state !== "loading" ? Promise.resolve() : _(window, "loader:ready") : C();
457
454
  }
458
455
  function lt() {
459
- return window.tj_loader_state ? window.tj_loader_state === "visual" ? Promise.resolve() : x(window, "loader:visual") : M();
456
+ return window.tj_loader_state ? window.tj_loader_state === "pre-visual" || window.tj_loader_state === "visual" ? Promise.resolve() : _(window, "loader:pre-visual") : C();
460
457
  }
461
- function M(n = window) {
458
+ function ht() {
459
+ return window.tj_loader_state ? window.tj_loader_state === "visual" ? Promise.resolve() : _(window, "loader:visual") : C();
460
+ }
461
+ function C(n = window) {
462
462
  return n || (n = window), n === window ? document.readyState === "complete" ? Promise.resolve() : new Promise((t) => window.addEventListener("load", () => t(), { once: !0 })) : n instanceof HTMLImageElement ? n.complete && n.naturalWidth !== 0 ? Promise.resolve() : new Promise((t, e) => {
463
463
  n.addEventListener("load", () => t(), { once: !0 }), n.addEventListener("error", () => e(new Error("image error")), { once: !0 });
464
464
  }) : n instanceof HTMLMediaElement ? n.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA ? Promise.resolve() : new Promise((t) => n.addEventListener("loadeddata", () => t(), { once: !0 })) : new Promise((t) => n.addEventListener("load", () => t(), { once: !0 }));
465
465
  }
466
- function ht(n) {
466
+ function ft(n) {
467
467
  return new Promise((t) => setTimeout(t, n));
468
468
  }
469
- function ft(n) {
469
+ function mt(n) {
470
470
  return new Promise((t) => {
471
471
  const e = (i) => {
472
472
  n.removeEventListener("animationend", e), t(i);
@@ -474,99 +474,99 @@ function ft(n) {
474
474
  n.addEventListener("animationend", e);
475
475
  });
476
476
  }
477
- function mt(n) {
477
+ function gt(n) {
478
478
  var e, i;
479
479
  class t extends n {
480
480
  constructor() {
481
481
  super(...arguments);
482
- m(this, e, new C(200, 5e3));
482
+ m(this, e, new N(200, 5e3));
483
483
  f(this, "currentBreakPoint", null);
484
484
  m(this, i, async () => {
485
- var b;
486
- await l(this, e).wait(), await Y();
487
- const a = this, o = window.innerWidth;
488
- let u = getComputedStyle(a).getPropertyValue("--breakpoint");
489
- if (!u || u === "")
485
+ var h;
486
+ await c(this, e).wait(), await Z();
487
+ const o = this, a = window.innerWidth;
488
+ let d = getComputedStyle(o).getPropertyValue("--breakpoint");
489
+ if (!d || d === "")
490
490
  return;
491
- u = u.trim().replace(/^['"]|['"]$/g, "");
492
- const c = u.split(","), d = c[0].trim(), h = ((b = c[1]) == null ? void 0 : b.trim()) ?? d, g = U(o);
493
- this.currentBreakPoint !== g && (p(h) <= p(g) ? a.setAttribute("mode", "desktop") : p(d) > p(g) ? a.setAttribute("mode", "mobile") : a.setAttribute("mode", "tablet"));
491
+ d = d.trim().replace(/^['"]|['"]$/g, "");
492
+ const w = d.split(","), y = w[0].trim(), u = ((h = w[1]) == null ? void 0 : h.trim()) ?? y, l = U(a);
493
+ this.currentBreakPoint !== l && (E(u) <= E(l) ? o.setAttribute("mode", "desktop") : E(y) > E(l) ? o.setAttribute("mode", "mobile") : o.setAttribute("mode", "tablet"));
494
494
  });
495
495
  }
496
496
  connectedCallback() {
497
497
  super.connectedCallback();
498
498
  try {
499
- l(this, i).call(this), window.addEventListener("resize", l(this, i)), l(this, i).call(this);
500
- } catch (a) {
501
- throw console.error("Error in BreakPointMixin:", a, "in element", this), a;
499
+ c(this, i).call(this), window.addEventListener("resize", c(this, i)), c(this, i).call(this);
500
+ } catch (o) {
501
+ throw console.error("Error in BreakPointMixin:", o, "in element", this), o;
502
502
  }
503
503
  }
504
504
  disconnectedCallback() {
505
- super.disconnectedCallback(), window.removeEventListener("resize", l(this, i));
505
+ super.disconnectedCallback(), window.removeEventListener("resize", c(this, i));
506
506
  }
507
507
  }
508
508
  return e = new WeakMap(), i = new WeakMap(), t;
509
509
  }
510
- const k = Symbol("listenerDefs"), N = Symbol("withEventBindings");
511
- function gt(n, t) {
510
+ const v = Symbol("listenerDefs"), V = Symbol("withEventBindings");
511
+ function wt(n, t) {
512
512
  const e = Array.isArray(n) ? n : [n];
513
513
  return function(i, r) {
514
514
  if (r.kind !== "method") throw new Error("@Listen nur für Methoden");
515
515
  return r.addInitializer(function() {
516
516
  const s = this;
517
- (s[k] || (s[k] = [])).push({
517
+ (s[v] || (s[v] = [])).push({
518
518
  method: r.name,
519
519
  events: [...e],
520
520
  opts: t
521
521
  });
522
522
  }), function(...s) {
523
- if (!this[N])
523
+ if (!this[V])
524
524
  throw new Error("[EventBindings] @Listen - decorator requires EventBindingMixin.");
525
525
  return i.apply(this, s);
526
526
  };
527
527
  };
528
528
  }
529
- function Z(n, t) {
529
+ function tt(n, t) {
530
530
  var e;
531
531
  return !t || t === "host" ? n : t === "document" ? n.ownerDocument ?? document : t === "window" ? ((e = n.ownerDocument) == null ? void 0 : e.defaultView) ?? window : t === "shadowRoot" ? n.shadowRoot ?? n : typeof t == "function" ? t(n) : t;
532
532
  }
533
- function wt(n) {
534
- var e, i, $;
533
+ function yt(n) {
534
+ var e, i, R;
535
535
  class t extends n {
536
- constructor(...o) {
537
- super(...o);
536
+ constructor(...a) {
537
+ super(...a);
538
538
  m(this, i);
539
539
  m(this, e);
540
- this[N] = !0;
540
+ this[V] = !0;
541
541
  }
542
542
  connectedCallback() {
543
- var o;
544
- (o = super.connectedCallback) == null || o.call(this), w(this, i, $).call(this);
543
+ var a;
544
+ (a = super.connectedCallback) == null || a.call(this), g(this, i, R).call(this);
545
545
  }
546
546
  disconnectedCallback() {
547
- var o, u;
548
- (o = l(this, e)) == null || o.abort(), (u = super.disconnectedCallback) == null || u.call(this);
547
+ var a, d;
548
+ (a = c(this, e)) == null || a.abort(), (d = super.disconnectedCallback) == null || d.call(this);
549
549
  }
550
550
  }
551
- return e = new WeakMap(), i = new WeakSet(), $ = function() {
552
- var u, c, d;
553
- (u = l(this, e)) == null || u.abort(), y(this, e, new AbortController());
554
- const o = this[k] || [];
555
- for (const h of o) {
556
- const g = Z(this, (c = h.opts) == null ? void 0 : c.target), b = ((d = h.opts) == null ? void 0 : d.options) ?? {}, V = this[h.method].bind(this);
557
- for (const R of h.events)
558
- g.addEventListener(R, V, { ...b, signal: l(this, e).signal });
551
+ return e = new WeakMap(), i = new WeakSet(), R = function() {
552
+ var d, w, y;
553
+ (d = c(this, e)) == null || d.abort(), p(this, e, new AbortController());
554
+ const a = this[v] || [];
555
+ for (const u of a) {
556
+ const l = tt(this, (w = u.opts) == null ? void 0 : w.target), h = ((y = u.opts) == null ? void 0 : y.options) ?? {}, b = this[u.method].bind(this);
557
+ for (const T of u.events)
558
+ l.addEventListener(T, b, { ...h, signal: c(this, e).signal });
559
559
  }
560
560
  }, t;
561
561
  }
562
- let tt = 1;
563
- function yt(n) {
562
+ let et = 1;
563
+ function pt(n) {
564
564
  var e, i, r;
565
565
  class t extends n {
566
566
  constructor() {
567
567
  super(...arguments);
568
568
  m(this, e, null);
569
- m(this, i, tt++);
569
+ m(this, i, et++);
570
570
  m(this, r, null);
571
571
  }
572
572
  /**
@@ -574,33 +574,33 @@ function yt(n) {
574
574
  * on the next log/warn/error call.
575
575
  */
576
576
  invalidateDebugCache() {
577
- y(this, e, null);
577
+ p(this, e, null);
578
578
  }
579
579
  get _debug() {
580
- return l(this, e) !== null ? l(this, e) : (this instanceof HTMLElement && y(this, e, this.hasAttribute("debug") && !["false", "0", "off", "no"].includes(this.getAttribute("debug") || "")), l(this, e) === !0 && console.info(
580
+ return c(this, e) !== null ? c(this, e) : (this instanceof HTMLElement && p(this, e, this.hasAttribute("debug") && !["false", "0", "off", "no"].includes(this.getAttribute("debug") || "")), c(this, e) === !0 && console.info(
581
581
  // @ts-expect-error - it says tagName is not defined -whatever
582
- `[DEBUG][ID:${l(this, i)}] LoggingMixin: Debug mode is enabled for <${this.tagName}>`,
582
+ `[DEBUG][ID:${c(this, i)}] LoggingMixin: Debug mode is enabled for <${this.tagName}>`,
583
583
  this
584
- ), l(this, e) ?? !1);
584
+ ), c(this, e) ?? !1);
585
585
  }
586
- getLogger(o = "main") {
587
- const u = "<" + (this.tagName || this.constructor.name || "UnknownElement") + ">";
588
- return l(this, r) || y(this, r, new q(this._debug, u, `${l(this, i)}`, o)), l(this, r);
586
+ getLogger(a = "main") {
587
+ const d = "<" + (this.tagName || this.constructor.name || "UnknownElement") + ">";
588
+ return c(this, r) || p(this, r, new J(this._debug, d, `${c(this, i)}`, a)), c(this, r);
589
589
  }
590
- debug(...o) {
591
- this.getLogger().debug(...o);
590
+ debug(...a) {
591
+ this.getLogger().debug(...a);
592
592
  }
593
- log(...o) {
594
- this.getLogger().log(...o);
593
+ log(...a) {
594
+ this.getLogger().log(...a);
595
595
  }
596
- warn(...o) {
597
- this.getLogger().warn(...o);
596
+ warn(...a) {
597
+ this.getLogger().warn(...a);
598
598
  }
599
- error(...o) {
600
- this.getLogger().error(...o);
599
+ error(...a) {
600
+ this.getLogger().error(...a);
601
601
  }
602
- throwError(...o) {
603
- return this.getLogger().throwError(...o);
602
+ throwError(...a) {
603
+ return this.getLogger().throwError(...a);
604
604
  }
605
605
  }
606
606
  return e = new WeakMap(), i = new WeakMap(), r = new WeakMap(), t;
@@ -633,7 +633,7 @@ function bt(n) {
633
633
  );
634
634
  }
635
635
  disconnectedCallback() {
636
- super.disconnectedCallback(), this.dispatchEvent(
636
+ window.dispatchEvent(
637
637
  new CustomEvent("init:child-ready", {
638
638
  detail: {
639
639
  element: this,
@@ -642,66 +642,77 @@ function bt(n) {
642
642
  bubbles: !0,
643
643
  composed: !0
644
644
  })
645
- );
645
+ ), super.disconnectedCallback();
646
646
  }
647
647
  }
648
648
  return t;
649
649
  }
650
- function pt(n) {
651
- var e, D, r, v, B;
650
+ function Et(n) {
651
+ var e, i, M, S, o, P, O;
652
652
  class t extends n {
653
653
  constructor() {
654
654
  super(...arguments);
655
- m(this, e);
656
- m(this, r, (c) => {
657
- const d = c.target, h = w(this, e, v).call(this, d.assignedNodes({ flatten: !0 })), g = w(this, e, v).call(this, d.childNodes);
658
- h || g ? d.classList.remove("slot-empty") : d.classList.add("slot-empty");
655
+ m(this, i);
656
+ // Slots können bei Lit-Updates neu entstehen; die WeakMap verhindert doppelte Listener auf bestehenden Slots.
657
+ m(this, e, /* @__PURE__ */ new WeakMap());
658
+ m(this, o, (u) => {
659
+ g(this, i, S).call(this, u.target);
659
660
  });
660
661
  }
661
- firstUpdated(c) {
662
- var d;
663
- (d = super.firstUpdated) == null || d.call(this, c), w(this, e, D).call(this);
662
+ firstUpdated(u) {
663
+ var l;
664
+ (l = super.firstUpdated) == null || l.call(this, u), g(this, i, M).call(this);
665
+ }
666
+ updated(u) {
667
+ var l;
668
+ (l = super.updated) == null || l.call(this, u), g(this, i, M).call(this);
664
669
  }
665
670
  }
666
- return e = new WeakSet(), D = function() {
667
- var d;
668
- const c = (d = this.shadowRoot) == null ? void 0 : d.querySelectorAll("slot");
669
- c == null || c.forEach((h) => {
670
- w(this, e, v).call(this, h.childNodes) || h.classList.add("slot-empty"), h.addEventListener("slotchange", (g) => l(this, r).call(this, g));
671
+ return e = new WeakMap(), i = new WeakSet(), M = function() {
672
+ var l;
673
+ const u = (l = this.shadowRoot) == null ? void 0 : l.querySelectorAll("slot");
674
+ u == null || u.forEach((h) => {
675
+ if (g(this, i, S).call(this, h), !c(this, e).has(h)) {
676
+ const b = (T) => c(this, o).call(this, T);
677
+ c(this, e).set(h, b), h.addEventListener("slotchange", b);
678
+ }
671
679
  });
672
- }, r = new WeakMap(), v = function(c) {
673
- return Array.from(c).some((d) => w(this, e, B).call(this, d));
674
- }, B = function(c) {
675
- return c.nodeType === Node.TEXT_NODE ? (c.textContent || "").trim().length > 0 : c.nodeType === Node.ELEMENT_NODE;
680
+ }, S = function(u) {
681
+ const l = g(this, i, P).call(this, u.assignedNodes({ flatten: !0 })), h = g(this, i, P).call(this, u.childNodes);
682
+ l || h ? u.classList.remove("slot-empty") : u.classList.add("slot-empty");
683
+ }, o = new WeakMap(), P = function(u) {
684
+ return Array.from(u).some((l) => g(this, i, O).call(this, l));
685
+ }, O = function(u) {
686
+ return u.nodeType === Node.TEXT_NODE ? (u.textContent || "").trim().length > 0 : u.nodeType === Node.ELEMENT_NODE;
676
687
  }, t;
677
688
  }
678
689
  export {
679
- mt as BreakPointMixin,
680
- C as Debouncer,
681
- wt as EventBindingsMixin,
682
- rt as FormDataAccessor,
683
- gt as Listen,
690
+ gt as BreakPointMixin,
691
+ N as Debouncer,
692
+ yt as EventBindingsMixin,
693
+ st as FormDataAccessor,
694
+ wt as Listen,
684
695
  bt as LoaderMixin,
685
- q as Logger,
686
- yt as LoggingMixin,
687
- pt as SlotVisibilityMixin,
688
- ot as Stopwatch,
689
- S as breakpointMap,
690
- E as breakpoints,
691
- nt as create_element,
692
- it as debounce,
693
- p as getBreakpointMinWidth,
696
+ J as Logger,
697
+ pt as LoggingMixin,
698
+ Et as SlotVisibilityMixin,
699
+ at as Stopwatch,
700
+ W as breakpointMap,
701
+ k as breakpoints,
702
+ it as create_element,
703
+ rt as debounce,
704
+ E as getBreakpointMinWidth,
694
705
  U as getCurrentBreakpoint,
695
- st as getErrorLocation,
696
- F as getViewportWidth,
697
- ut as local_storage,
698
- at as session_storage,
699
- ht as sleep,
700
- x as waitFor,
701
- ft as waitForAnimationEnd,
702
- Y as waitForDomContentLoaded,
703
- M as waitForLoad,
704
- dt as waitForPreVisual,
705
- ct as waitForReady,
706
- lt as waitForVisual
706
+ ot as getErrorLocation,
707
+ H as getViewportWidth,
708
+ ct as local_storage,
709
+ ut as session_storage,
710
+ ft as sleep,
711
+ _ as waitFor,
712
+ mt as waitForAnimationEnd,
713
+ Z as waitForDomContentLoaded,
714
+ C as waitForLoad,
715
+ lt as waitForPreVisual,
716
+ dt as waitForReady,
717
+ ht as waitForVisual
707
718
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trunkjs/browser-utils",
3
- "version": "1.0.53",
3
+ "version": "1.0.55",
4
4
  "main": "./index.js",
5
5
  "repository": {
6
6
  "directory": "packages/browser-utils",