@trunkjs/browser-utils 1.0.39 → 1.0.40

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,7 @@
1
+ ## 1.0.40 (2026-04-11)
2
+
3
+ This was a version bump only for browser-utils to align it with other projects, there were no code changes.
4
+
1
5
  ## 1.0.39 (2026-03-06)
2
6
 
3
7
  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,18 +1,18 @@
1
- var $ = Object.defineProperty;
2
- var T = (e) => {
1
+ var N = Object.defineProperty;
2
+ var v = (e) => {
3
3
  throw TypeError(e);
4
4
  };
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 = [
5
+ var B = (e, t, n) => t in e ? N(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
6
+ var l = (e, t, n) => B(e, typeof t != "symbol" ? t + "" : t, n), L = (e, t, n) => t.has(e) || v("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) ? v("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 T = [
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
- ], x = k.reduce(
15
+ ], x = T.reduce(
16
16
  (e, t) => (e[t.name] = t.minWidth, e),
17
17
  {}
18
18
  );
@@ -21,11 +21,11 @@ function E(e) {
21
21
  throw new Error(`Unknown breakpoint: ${e}`);
22
22
  return x[e];
23
23
  }
24
- function B(e) {
24
+ function D(e) {
25
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;
26
+ for (let t = T.length - 1; t >= 0; t--)
27
+ if (e >= T[t].minWidth)
28
+ return T[t].name;
29
29
  return "xs";
30
30
  }
31
31
  function H(e, t = {}, n = []) {
@@ -104,20 +104,23 @@ function J(e) {
104
104
  return { file: e.fileName || e.sourceURL };
105
105
  }
106
106
  class R {
107
- constructor(t, n, i = "main") {
108
- this._debug = t, this.myElementId = n, this.instanceId = i;
107
+ constructor(t, n, i, r = "main") {
108
+ this._debug = t, this.myTag = n, this.myElementId = i, this.instanceId = r;
109
+ }
110
+ debug(...t) {
111
+ this._debug && console.debug(`[DEBUG][${this.myTag}:${this.myElementId}:${this.instanceId}]`, ...t);
109
112
  }
110
113
  log(...t) {
111
- this._debug && console.log(`[LOG][ID:${this.myElementId}:${this.instanceId}]`, ...t);
114
+ console.log(`[LOG][${this.myTag}:${this.myElementId}:${this.instanceId}]`, ...t);
112
115
  }
113
116
  warn(...t) {
114
- console.warn(`[WARN][ID:${this.myElementId}:${this.instanceId}]`, ...t);
117
+ console.warn(`[WARN][${this.myTag}:${this.myElementId}:${this.instanceId}]`, ...t);
115
118
  }
116
119
  error(...t) {
117
- console.error(`[ERROR][ID:${this.myElementId}:${this.instanceId}]`, ...t);
120
+ console.error(`[ERROR][${this.myTag}:${this.myElementId}:${this.instanceId}]`, ...t);
118
121
  }
119
122
  throwError(...t) {
120
- const n = `[ERROR][ID:${this.myElementId}:${this.instanceId}] ${t.join(" ")}`;
123
+ const n = `[ERROR][${this.myTag}:${this.myElementId}:${this.instanceId}] ${t.join(" ")}`;
121
124
  throw this.error(...t), new Error(n);
122
125
  }
123
126
  }
@@ -239,15 +242,15 @@ class P {
239
242
  return new Proxy({}, t);
240
243
  }
241
244
  }
242
- function I(e) {
245
+ function A(e) {
243
246
  const t = globalThis.window;
244
247
  return (e === "session" ? t == null ? void 0 : t.sessionStorage : t == null ? void 0 : t.localStorage) ?? void 0;
245
248
  }
246
249
  function X(e, t) {
247
- return new P(I("session"), e, t).asProxy();
250
+ return new P(A("session"), e, t).asProxy();
248
251
  }
249
252
  function Q(e, t) {
250
- return new P(I("local"), e, t).asProxy();
253
+ return new P(A("local"), e, t).asProxy();
251
254
  }
252
255
  function Y(e, t, n) {
253
256
  return new Promise((i, r) => {
@@ -293,7 +296,7 @@ function nt(e) {
293
296
  if (!o || o === "")
294
297
  return;
295
298
  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);
299
+ const d = o.split(","), m = d[0].trim(), f = ((b = d[1]) == null ? void 0 : b.trim()) ?? m, g = D(s);
297
300
  this.currentBreakPoint !== g && (E(f) <= E(g) ? c.setAttribute("mode", "desktop") : E(m) > E(g) ? c.setAttribute("mode", "mobile") : c.setAttribute("mode", "tablet"));
298
301
  });
299
302
  }
@@ -311,20 +314,20 @@ function nt(e) {
311
314
  }
312
315
  return n = new WeakMap(), i = new WeakMap(), t;
313
316
  }
314
- const v = Symbol("listenerDefs"), A = Symbol("withEventBindings");
317
+ const k = Symbol("listenerDefs"), $ = Symbol("withEventBindings");
315
318
  function it(e, t) {
316
319
  const n = Array.isArray(e) ? e : [e];
317
320
  return function(i, r) {
318
321
  if (r.kind !== "method") throw new Error("@Listen nur für Methoden");
319
322
  return r.addInitializer(function() {
320
323
  const a = this;
321
- (a[v] || (a[v] = [])).push({
324
+ (a[k] || (a[k] = [])).push({
322
325
  method: r.name,
323
326
  events: [...n],
324
327
  opts: t
325
328
  });
326
329
  }), function(...a) {
327
- if (!this[A])
330
+ if (!this[$])
328
331
  throw new Error("[EventBindings] @Listen - decorator requires EventBindingMixin.");
329
332
  return i.apply(this, a);
330
333
  };
@@ -335,31 +338,31 @@ function F(e, t) {
335
338
  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;
336
339
  }
337
340
  function rt(e) {
338
- var n, i, W;
341
+ var n, i, I;
339
342
  class t extends e {
340
343
  constructor(...s) {
341
344
  super(...s);
342
345
  h(this, i);
343
346
  h(this, n);
344
- this[A] = !0;
347
+ this[$] = !0;
345
348
  }
346
349
  connectedCallback() {
347
350
  var s;
348
- (s = super.connectedCallback) == null || s.call(this), y(this, i, W).call(this);
351
+ (s = super.connectedCallback) == null || s.call(this), y(this, i, I).call(this);
349
352
  }
350
353
  disconnectedCallback() {
351
354
  var s, o;
352
355
  (s = u(this, n)) == null || s.abort(), (o = super.disconnectedCallback) == null || o.call(this);
353
356
  }
354
357
  }
355
- return n = new WeakMap(), i = new WeakSet(), W = function() {
358
+ return n = new WeakMap(), i = new WeakSet(), I = function() {
356
359
  var o, d, m;
357
360
  (o = u(this, n)) == null || o.abort(), w(this, n, new AbortController());
358
- const s = this[v] || [];
361
+ const s = this[k] || [];
359
362
  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 });
363
+ const g = F(this, (d = f.opts) == null ? void 0 : d.target), b = ((m = f.opts) == null ? void 0 : m.options) ?? {}, _ = this[f.method].bind(this);
364
+ for (const C of f.events)
365
+ g.addEventListener(C, _, { ...b, signal: u(this, n).signal });
363
366
  }
364
367
  }, t;
365
368
  }
@@ -381,10 +384,18 @@ function st(e) {
381
384
  w(this, n, null);
382
385
  }
383
386
  get _debug() {
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);
387
+ 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(
388
+ // @ts-expect-error - it says tagName is not defined -whatever
389
+ `[DEBUG][ID:${u(this, i)}] LoggingMixin: Debug mode is enabled for <${this.tagName}>`,
390
+ this
391
+ ), u(this, n) ?? !1);
385
392
  }
386
393
  getLogger(s = "main") {
387
- return u(this, r) || w(this, r, new R(this._debug, `${u(this, i)}`, s)), u(this, r);
394
+ const o = "<" + (this.tagName || this.constructor.name || "UnknownElement") + ">";
395
+ return u(this, r) || w(this, r, new R(this._debug, o, `${u(this, i)}`, s)), u(this, r);
396
+ }
397
+ debug(...s) {
398
+ this.getLogger().debug(...s);
388
399
  }
389
400
  log(...s) {
390
401
  this.getLogger().log(...s);
@@ -402,28 +413,28 @@ function st(e) {
402
413
  return n = new WeakMap(), i = new WeakMap(), r = new WeakMap(), t;
403
414
  }
404
415
  function ot(e) {
405
- var n, S, r, _;
416
+ var n, W, r, S;
406
417
  class t extends e {
407
418
  constructor() {
408
419
  super(...arguments);
409
420
  h(this, n);
410
421
  h(this, r, (o) => {
411
422
  const d = o.target;
412
- d.assignedNodes({ flatten: !0 }).filter((g) => y(this, n, _).call(this, g)).length > 0 && d.classList.remove("slot-empty");
423
+ d.assignedNodes({ flatten: !0 }).filter((g) => y(this, n, S).call(this, g)).length > 0 && d.classList.remove("slot-empty");
413
424
  });
414
425
  }
415
426
  firstUpdated(o) {
416
427
  var d;
417
- (d = super.firstUpdated) == null || d.call(this, o), y(this, n, S).call(this);
428
+ (d = super.firstUpdated) == null || d.call(this, o), y(this, n, W).call(this);
418
429
  }
419
430
  }
420
- return n = new WeakSet(), S = function() {
431
+ return n = new WeakSet(), W = function() {
421
432
  var d;
422
433
  const o = (d = this.shadowRoot) == null ? void 0 : d.querySelectorAll("slot");
423
434
  o == null || o.forEach((m) => {
424
435
  m.classList.add("slot-empty"), m.addEventListener("slotchange", (f) => u(this, r).call(this, f));
425
436
  });
426
- }, r = new WeakMap(), _ = function(o) {
437
+ }, r = new WeakMap(), S = function(o) {
427
438
  return o.nodeType === Node.TEXT_NODE ? (o.textContent || "").trim().length > 0 : o.nodeType === Node.ELEMENT_NODE;
428
439
  }, t;
429
440
  }
@@ -437,11 +448,11 @@ export {
437
448
  ot as SlotVisibilityMixin,
438
449
  q as Stopwatch,
439
450
  x as breakpointMap,
440
- k as breakpoints,
451
+ T as breakpoints,
441
452
  H as create_element,
442
453
  G as debounce,
443
454
  E as getBreakpointMinWidth,
444
- B as getCurrentBreakpoint,
455
+ D as getCurrentBreakpoint,
445
456
  J as getErrorLocation,
446
457
  Q as local_storage,
447
458
  X as session_storage,
package/lib/Logger.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  export declare class Logger {
2
2
  private _debug;
3
+ private myTag;
3
4
  private myElementId;
4
5
  private instanceId;
5
- constructor(_debug: boolean, myElementId: string, instanceId?: string);
6
+ constructor(_debug: boolean, myTag: string, myElementId: string, instanceId?: string);
7
+ debug(...args: any[]): void;
6
8
  log(...args: any[]): void;
7
9
  warn(...args: any[]): void;
8
10
  error(...args: any[]): void;
@@ -2,6 +2,7 @@ import { Logger } from '../lib/Logger';
2
2
  type Constructor<T = object> = abstract new (...args: any[]) => T;
3
3
  export interface LoggerMixinInterface {
4
4
  getLogger(instanceId?: string): Logger;
5
+ debug(...args: any[]): void;
5
6
  log(...args: any[]): void;
6
7
  warn(...args: any[]): void;
7
8
  error(...args: any[]): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trunkjs/browser-utils",
3
- "version": "1.0.39",
3
+ "version": "1.0.40",
4
4
  "main": "./index.js",
5
5
  "dependencies": {},
6
6
  "type": "module",