@trunkjs/browser-utils 1.0.25 → 1.0.28

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.28 (2026-02-03)
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.27 (2026-02-03)
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.26 (2026-01-23)
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.25 (2026-01-22)
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.js CHANGED
@@ -1,31 +1,31 @@
1
- var A = Object.defineProperty;
2
- var L = (t) => {
1
+ var D = Object.defineProperty;
2
+ var T = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
- var $ = (t, e, n) => e in t ? A(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
6
- var l = (t, e, n) => $(t, typeof e != "symbol" ? e + "" : e, n), y = (t, e, n) => e.has(t) || L("Cannot " + n);
7
- var u = (t, e, n) => (y(t, e, "read from private field"), n ? n.call(t) : e.get(t)), c = (t, e, n) => e.has(t) ? L("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), g = (t, e, n, i) => (y(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n), w = (t, e, n) => (y(t, e, "access private method"), n);
8
- const b = [
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), y = (t, e, n) => e.has(t) || T("Cannot " + n);
7
+ var u = (t, e, n) => (y(t, e, "read from private field"), n ? n.call(t) : e.get(t)), m = (t, e, n) => e.has(t) ? T("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), w = (t, e, n, i) => (y(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n), b = (t, e, n) => (y(t, e, "access private method"), n);
8
+ const p = [
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
- ], T = b.reduce(
15
+ ], v = p.reduce(
16
16
  (t, e) => (t[e.name] = e.minWidth, t),
17
17
  {}
18
18
  );
19
- function v(t) {
20
- if (!(t in T))
19
+ function E(t) {
20
+ if (!(t in v))
21
21
  throw new Error(`Unknown breakpoint: ${t}`);
22
- return T[t];
22
+ return v[t];
23
23
  }
24
24
  function R(t) {
25
25
  t === void 0 && (t = window.innerWidth);
26
- for (let e = b.length - 1; e >= 0; e--)
27
- if (t >= b[e].minWidth)
28
- return b[e].name;
26
+ for (let e = p.length - 1; e >= 0; e--)
27
+ if (t >= p[e].minWidth)
28
+ return p[e].name;
29
29
  return "xs";
30
30
  }
31
31
  function O(t, e = {}, n = []) {
@@ -44,9 +44,9 @@ class k {
44
44
  * @param max_delay Maximum delay in milliseconds, if false then no maximum delay is applied
45
45
  */
46
46
  constructor(e, n = !1) {
47
- l(this, "timeout", null);
48
- l(this, "startTimeWithMs", 0);
49
- l(this, "maxTimeout", null);
47
+ c(this, "timeout", null);
48
+ c(this, "startTimeWithMs", 0);
49
+ c(this, "maxTimeout", null);
50
50
  this.delay = e, this.max_delay = n;
51
51
  }
52
52
  async wait() {
@@ -73,15 +73,15 @@ function F(t, e = !1) {
73
73
  return function(i, s) {
74
74
  if (s.kind !== "method") return i;
75
75
  const a = s.name;
76
- return function(...m) {
76
+ return function(...h) {
77
77
  let r = n.get(this);
78
78
  r || (r = /* @__PURE__ */ new Map(), n.set(this, r));
79
79
  let o = r.get(a);
80
- o || (o = new k(t, e), r.set(a, o)), o.debounce(() => i.apply(this, m));
80
+ o || (o = new k(t, e), r.set(a, o)), o.debounce(() => i.apply(this, h));
81
81
  };
82
82
  };
83
83
  }
84
- function V(t) {
84
+ function H(t) {
85
85
  if (typeof t.lineNumber == "number")
86
86
  return {
87
87
  file: t.fileName || t.sourceURL,
@@ -121,13 +121,13 @@ class B {
121
121
  throw this.error(...e), new Error(n);
122
122
  }
123
123
  }
124
- class H {
124
+ class V {
125
125
  constructor(e, n = !0) {
126
- l(this, "label");
127
- l(this, "last");
128
- l(this, "startTime");
129
- l(this, "running", !1);
130
- l(this, "enabled");
126
+ c(this, "label");
127
+ c(this, "last");
128
+ c(this, "startTime");
129
+ c(this, "running", !1);
130
+ c(this, "enabled");
131
131
  this.label = e, this.enabled = n, this.startTime = this.last = performance.now(), this.running = !0;
132
132
  }
133
133
  lap(e = "") {
@@ -153,8 +153,8 @@ class H {
153
153
  }
154
154
  function z(t, e, n) {
155
155
  return new Promise((i, s) => {
156
- const a = (m) => {
157
- t.removeEventListener(e, a, n), i(m);
156
+ const a = (h) => {
157
+ t.removeEventListener(e, a, n), i(h);
158
158
  };
159
159
  t.addEventListener(e, a, n);
160
160
  });
@@ -181,19 +181,20 @@ function q(t) {
181
181
  });
182
182
  }
183
183
  function X(t) {
184
- var i;
185
- const e = new k(200, 5e3);
186
- class n extends t {
184
+ var n, i;
185
+ class e extends t {
187
186
  constructor() {
188
187
  super(...arguments);
189
- l(this, "currentBreakPoint", null);
190
- c(this, i, async () => {
191
- await e.wait(), await N();
192
- const m = window.innerWidth;
193
- let r = getComputedStyle(this).getPropertyValue("--breakpoint");
194
- r || (this.style.setProperty("--breakpoint", "md"), r = getComputedStyle(this).getPropertyValue("--breakpoint"));
195
- const o = R(m);
196
- this.currentBreakPoint !== o && (v(r) < v(o) ? this.setAttribute("mode", "desktop") : this.setAttribute("mode", "mobile"));
188
+ m(this, n, new k(200, 5e3));
189
+ c(this, "currentBreakPoint", null);
190
+ m(this, i, async () => {
191
+ var g;
192
+ await u(this, n).wait(), await N();
193
+ const h = window.innerWidth, r = getComputedStyle(this).getPropertyValue("--breakpoint");
194
+ if (!r || r === "")
195
+ return;
196
+ const o = r.split(","), d = o[0].trim(), f = ((g = o[1]) == null ? void 0 : g.trim()) ?? d, l = R(h);
197
+ this.currentBreakPoint !== l && (E(f) <= E(l) ? this.setAttribute("mode", "desktop") : E(d) > E(l) ? this.setAttribute("mode", "mobile") : this.setAttribute("mode", "tablet"));
197
198
  });
198
199
  }
199
200
  connectedCallback() {
@@ -203,16 +204,16 @@ function X(t) {
203
204
  super.disconnectedCallback(), window.removeEventListener("resize", u(this, i));
204
205
  }
205
206
  }
206
- return i = new WeakMap(), n;
207
+ return n = new WeakMap(), i = new WeakMap(), e;
207
208
  }
208
- const E = Symbol("listenerDefs"), M = Symbol("withEventBindings");
209
+ const L = Symbol("listenerDefs"), M = Symbol("withEventBindings");
209
210
  function J(t, e) {
210
211
  const n = Array.isArray(t) ? t : [t];
211
212
  return function(i, s) {
212
213
  if (s.kind !== "method") throw new Error("@Listen nur für Methoden");
213
214
  return s.addInitializer(function() {
214
215
  const a = this.constructor;
215
- (a[E] || (a[E] = [])).push({
216
+ (a[L] || (a[L] = [])).push({
216
217
  method: s.name,
217
218
  events: n,
218
219
  opts: e
@@ -233,13 +234,13 @@ function K(t) {
233
234
  class e extends t {
234
235
  constructor(...r) {
235
236
  super(...r);
236
- c(this, i);
237
- c(this, n);
237
+ m(this, i);
238
+ m(this, n);
238
239
  this[M] = !0;
239
240
  }
240
241
  connectedCallback() {
241
242
  var r;
242
- (r = super.connectedCallback) == null || r.call(this), w(this, i, x).call(this);
243
+ (r = super.connectedCallback) == null || r.call(this), b(this, i, x).call(this);
243
244
  }
244
245
  disconnectedCallback() {
245
246
  var r, o;
@@ -248,12 +249,12 @@ function K(t) {
248
249
  }
249
250
  return n = new WeakMap(), i = new WeakSet(), x = function() {
250
251
  var o, d, f;
251
- (o = u(this, n)) == null || o.abort(), g(this, n, new AbortController());
252
- const r = this.constructor[E] || [];
253
- for (const h of r) {
254
- const p = _(this, (d = h.opts) == null ? void 0 : d.target), C = ((f = h.opts) == null ? void 0 : f.options) ?? {}, I = this[h.method].bind(this);
255
- for (const D of h.events)
256
- p.addEventListener(D, I, { ...C, signal: u(this, n).signal });
252
+ (o = u(this, n)) == null || o.abort(), w(this, n, new AbortController());
253
+ const r = this.constructor[L] || [];
254
+ for (const l of r) {
255
+ const g = _(this, (d = l.opts) == null ? void 0 : d.target), I = ((f = l.opts) == null ? void 0 : f.options) ?? {}, C = this[l.method].bind(this);
256
+ for (const P of l.events)
257
+ g.addEventListener(P, C, { ...I, signal: u(this, n).signal });
257
258
  }
258
259
  }, e;
259
260
  }
@@ -263,22 +264,22 @@ function Q(t) {
263
264
  class e extends t {
264
265
  constructor() {
265
266
  super(...arguments);
266
- c(this, n, null);
267
- c(this, i, S++);
268
- c(this, s, null);
267
+ m(this, n, null);
268
+ m(this, i, S++);
269
+ m(this, s, null);
269
270
  }
270
271
  /**
271
272
  * Clears the cached debug flag so the attribute will be checked again
272
273
  * on the next log/warn/error call.
273
274
  */
274
275
  invalidateDebugCache() {
275
- g(this, n, null);
276
+ w(this, n, null);
276
277
  }
277
278
  get _debug() {
278
- return u(this, n) !== null ? u(this, n) : (this instanceof HTMLElement && g(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);
279
+ 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);
279
280
  }
280
281
  getLogger(r = "main") {
281
- return u(this, s) || g(this, s, new B(this._debug, `${u(this, i)}`, r)), u(this, s);
282
+ return u(this, s) || w(this, s, new B(this._debug, `${u(this, i)}`, r)), u(this, s);
282
283
  }
283
284
  log(...r) {
284
285
  this.getLogger().log(...r);
@@ -296,28 +297,28 @@ function Q(t) {
296
297
  return n = new WeakMap(), i = new WeakMap(), s = new WeakMap(), e;
297
298
  }
298
299
  function Y(t) {
299
- var n, W, s, P;
300
+ var n, A, s, W;
300
301
  class e extends t {
301
302
  constructor() {
302
303
  super(...arguments);
303
- c(this, n);
304
- c(this, s, (o) => {
304
+ m(this, n);
305
+ m(this, s, (o) => {
305
306
  const d = o.target;
306
- d.assignedNodes({ flatten: !0 }).filter((p) => w(this, n, P).call(this, p)).length > 0 && d.classList.remove("slot-empty");
307
+ d.assignedNodes({ flatten: !0 }).filter((g) => b(this, n, W).call(this, g)).length > 0 && d.classList.remove("slot-empty");
307
308
  });
308
309
  }
309
310
  firstUpdated(o) {
310
311
  var d;
311
- (d = super.firstUpdated) == null || d.call(this, o), w(this, n, W).call(this);
312
+ (d = super.firstUpdated) == null || d.call(this, o), b(this, n, A).call(this);
312
313
  }
313
314
  }
314
- return n = new WeakSet(), W = function() {
315
+ return n = new WeakSet(), A = function() {
315
316
  var d;
316
317
  const o = (d = this.shadowRoot) == null ? void 0 : d.querySelectorAll("slot");
317
318
  o == null || o.forEach((f) => {
318
- f.classList.add("slot-empty"), f.addEventListener("slotchange", (h) => u(this, s).call(this, h));
319
+ f.classList.add("slot-empty"), f.addEventListener("slotchange", (l) => u(this, s).call(this, l));
319
320
  });
320
- }, s = new WeakMap(), P = function(o) {
321
+ }, s = new WeakMap(), W = function(o) {
321
322
  return o.nodeType === Node.TEXT_NODE ? (o.textContent || "").trim().length > 0 : o.nodeType === Node.ELEMENT_NODE;
322
323
  }, e;
323
324
  }
@@ -329,14 +330,14 @@ export {
329
330
  B as Logger,
330
331
  Q as LoggingMixin,
331
332
  Y as SlotVisibilityMixin,
332
- H as Stopwatch,
333
- T as breakpointMap,
334
- b as breakpoints,
333
+ V as Stopwatch,
334
+ v as breakpointMap,
335
+ p as breakpoints,
335
336
  O as create_element,
336
337
  F as debounce,
337
- v as getBreakpointMinWidth,
338
+ E as getBreakpointMinWidth,
338
339
  R as getCurrentBreakpoint,
339
- V as getErrorLocation,
340
+ H as getErrorLocation,
340
341
  j as sleep,
341
342
  z as waitFor,
342
343
  q as waitForAnimationEnd,
@@ -1,7 +1,9 @@
1
+ import { Debouncer } from '../lib/Debouncer';
1
2
  type Constructor<T = object> = abstract new (...args: any[]) => T;
2
3
  export declare function BreakPointMixin<TBase extends Constructor<HTMLElement>>(Base: TBase): (abstract new (...args: any[]) => {
4
+ "__#2877@#debouncer": Debouncer;
3
5
  currentBreakPoint: string | null;
4
- "__#2876@#updateBreakPoint": () => Promise<void>;
6
+ "__#2877@#updateBreakPoint": () => Promise<void>;
5
7
  connectedCallback(): void;
6
8
  disconnectedCallback(): void;
7
9
  accessKey: string;
@@ -9,9 +9,9 @@ type OneOrMany<N extends EventName> = N | readonly N[];
9
9
  type EventFromInput<I extends OneOrMany<EventName>> = I extends readonly (infer K)[] ? K extends EventName ? DocumentEventMap[K] : never : I extends EventName ? DocumentEventMap[I] : never;
10
10
  export declare function Listen<I extends OneOrMany<EventName>>(type: I, opts?: ListenOpts): <This, Fn extends (this: This, ev: EventFromInput<I>, ...args: any[]) => any>(value: Fn, context: ClassMethodDecoratorContext<This, Fn>) => Fn;
11
11
  export declare function EventBindingsMixin<TBase extends Ctor<object>>(Base: TBase): (abstract new (...a: any[]) => {
12
- "__#2877@#ac"?: AbortController;
12
+ "__#2878@#ac"?: AbortController;
13
13
  connectedCallback(): void;
14
14
  disconnectedCallback(): void;
15
- "__#2877@#bindEventListeners"(): void;
15
+ "__#2878@#bindEventListeners"(): void;
16
16
  }) & TBase;
17
17
  export {};
@@ -26,14 +26,14 @@ type Constructor<T = object> = abstract new (...args: any[]) => T;
26
26
  * <my-element debug></my-element> // enables debug logging
27
27
  */
28
28
  export declare function LoggingMixin<TBase extends Constructor<object>>(Base: TBase): (abstract new (...args: any[]) => {
29
- "__#2878@#debugCached": boolean | null;
30
- "__#2878@#myElementId": number;
29
+ "__#2879@#debugCached": boolean | null;
30
+ "__#2879@#myElementId": number;
31
31
  /**
32
32
  * Clears the cached debug flag so the attribute will be checked again
33
33
  * on the next log/warn/error call.
34
34
  */
35
35
  invalidateDebugCache(): void;
36
- "__#2878@#myLoggerInstance": Logger | null;
36
+ "__#2879@#myLoggerInstance": Logger | null;
37
37
  readonly _debug: boolean;
38
38
  getLogger(instanceId?: string): Logger;
39
39
  log(...args: any[]): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trunkjs/browser-utils",
3
- "version": "1.0.25",
3
+ "version": "1.0.28",
4
4
  "main": "./index.js",
5
5
  "dependencies": {},
6
6
  "type": "module",