@trunkjs/browser-utils 1.0.12 → 1.0.13
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 +4 -0
- package/index.js +41 -39
- package/mixins/LoggingMixin.d.ts +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## 1.0.13 (2025-08-13)
|
|
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.12 (2025-08-11)
|
|
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,11 +1,11 @@
|
|
|
1
1
|
var h = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var c = (e) => {
|
|
3
3
|
throw TypeError(e);
|
|
4
4
|
};
|
|
5
5
|
var f = (e, t, n) => t in e ? h(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
function
|
|
6
|
+
var a = (e, t, n) => f(e, typeof t != "symbol" ? t + "" : t, n), d = (e, t, n) => t.has(e) || c("Cannot " + n);
|
|
7
|
+
var o = (e, t, n) => (d(e, t, "read from private field"), n ? n.call(e) : t.get(e)), l = (e, t, n) => t.has(e) ? c("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), m = (e, t, n, i) => (d(e, t, "write to private field"), i ? i.call(e, n) : t.set(e, n), n);
|
|
8
|
+
function w(e, t = {}, n = []) {
|
|
9
9
|
Array.isArray(n) || (n = [n]);
|
|
10
10
|
const i = document.createElement(e);
|
|
11
11
|
for (const s in t)
|
|
@@ -14,15 +14,15 @@ function b(e, t = {}, n = []) {
|
|
|
14
14
|
i.append(typeof s == "string" ? document.createTextNode(s) : s);
|
|
15
15
|
return i;
|
|
16
16
|
}
|
|
17
|
-
class
|
|
17
|
+
class L {
|
|
18
18
|
/**
|
|
19
19
|
*
|
|
20
20
|
* @param delay Debounce delay in milliseconds
|
|
21
21
|
* @param max_delay Maximum delay in milliseconds, if false then no maximum delay is applied
|
|
22
22
|
*/
|
|
23
23
|
constructor(t, n = !1) {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
a(this, "timeout", null);
|
|
25
|
+
a(this, "startTimeWithMs", 0);
|
|
26
26
|
this.delay = t, this.max_delay = n;
|
|
27
27
|
}
|
|
28
28
|
async wait() {
|
|
@@ -54,19 +54,19 @@ function p(e) {
|
|
|
54
54
|
const n = String(e.stack || e.message || "").split(`
|
|
55
55
|
`), i = /(.*?)(?:\(|@)?(.*?):(\d+):(\d+)\)?$/;
|
|
56
56
|
for (const s of n) {
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
return { file:
|
|
57
|
+
const r = s.match(i);
|
|
58
|
+
if (r)
|
|
59
|
+
return { file: r[2], line: +r[3], column: +r[4] };
|
|
60
60
|
}
|
|
61
61
|
return { file: e.fileName || e.sourceURL };
|
|
62
62
|
}
|
|
63
|
-
class
|
|
63
|
+
class T {
|
|
64
64
|
constructor(t, n = !0) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
a(this, "label");
|
|
66
|
+
a(this, "last");
|
|
67
|
+
a(this, "startTime");
|
|
68
|
+
a(this, "running", !1);
|
|
69
|
+
a(this, "enabled");
|
|
70
70
|
this.label = t, this.enabled = n, this.startTime = this.last = performance.now(), this.running = !0;
|
|
71
71
|
}
|
|
72
72
|
lap(t = "") {
|
|
@@ -90,15 +90,15 @@ class L {
|
|
|
90
90
|
return this.running;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function y(e, t, n) {
|
|
94
94
|
return new Promise((i, s) => {
|
|
95
|
-
const
|
|
96
|
-
e.removeEventListener(t,
|
|
95
|
+
const r = (u) => {
|
|
96
|
+
e.removeEventListener(t, r, n), i(u);
|
|
97
97
|
};
|
|
98
|
-
e.addEventListener(t,
|
|
98
|
+
e.addEventListener(t, r, n);
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function E() {
|
|
102
102
|
return document.readyState === "loading" ? new Promise((e) => {
|
|
103
103
|
document.addEventListener("DOMContentLoaded", () => e());
|
|
104
104
|
}) : Promise.resolve();
|
|
@@ -108,7 +108,7 @@ function v() {
|
|
|
108
108
|
window.addEventListener("load", () => e());
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function D(e) {
|
|
112
112
|
return new Promise((t) => setTimeout(t, e));
|
|
113
113
|
}
|
|
114
114
|
function x(e) {
|
|
@@ -119,44 +119,46 @@ function x(e) {
|
|
|
119
119
|
e.addEventListener("animationend", n);
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
+
let g = 1;
|
|
122
123
|
function M(e) {
|
|
123
|
-
var n;
|
|
124
|
+
var n, i;
|
|
124
125
|
class t extends e {
|
|
125
126
|
constructor() {
|
|
126
127
|
super(...arguments);
|
|
127
|
-
|
|
128
|
+
l(this, n, null);
|
|
129
|
+
l(this, i, g++);
|
|
128
130
|
}
|
|
129
131
|
/**
|
|
130
132
|
* Clears the cached debug flag so the attribute will be checked again
|
|
131
133
|
* on the next log/warn/error call.
|
|
132
134
|
*/
|
|
133
135
|
invalidateDebugCache() {
|
|
134
|
-
|
|
136
|
+
m(this, n, null);
|
|
135
137
|
}
|
|
136
138
|
get _debug() {
|
|
137
|
-
return
|
|
139
|
+
return o(this, n) !== null ? o(this, n) : (this instanceof HTMLElement && m(this, n, this.hasAttribute("debug") && !["false", "0", "off", "no"].includes(this.getAttribute("debug") || "")), o(this, n) === !0 && console.log(`[DEBUG][ID:${o(this, i)}] LoggingMixin: Debug mode is enabled for <${this.tagName}>`, this), o(this, n));
|
|
138
140
|
}
|
|
139
|
-
log(...
|
|
140
|
-
this._debug && console.log(
|
|
141
|
+
log(...u) {
|
|
142
|
+
this._debug && console.log(`[LOG][ID:${o(this, i)}]`, ...u);
|
|
141
143
|
}
|
|
142
|
-
warn(...
|
|
143
|
-
console.warn(
|
|
144
|
+
warn(...u) {
|
|
145
|
+
console.warn(`[WARN][ID:${o(this, i)}]`, ...u);
|
|
144
146
|
}
|
|
145
|
-
error(...
|
|
146
|
-
console.error(
|
|
147
|
+
error(...u) {
|
|
148
|
+
console.error(`[ERROR][ID:${o(this, i)}]`, ...u);
|
|
147
149
|
}
|
|
148
150
|
}
|
|
149
|
-
return n = new WeakMap(), t;
|
|
151
|
+
return n = new WeakMap(), i = new WeakMap(), t;
|
|
150
152
|
}
|
|
151
153
|
export {
|
|
152
|
-
|
|
154
|
+
L as Debouncer,
|
|
153
155
|
M as LoggingMixin,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
T as Stopwatch,
|
|
157
|
+
w as create_element,
|
|
156
158
|
p as getErrorLocation,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
D as sleep,
|
|
160
|
+
y as waitFor,
|
|
159
161
|
x as waitForAnimationEnd,
|
|
160
|
-
|
|
162
|
+
E as waitForDomContentLoaded,
|
|
161
163
|
v as waitForLoad
|
|
162
164
|
};
|
package/mixins/LoggingMixin.d.ts
CHANGED
|
@@ -20,7 +20,8 @@ type Constructor<T = object> = abstract new (...args: any[]) => T;
|
|
|
20
20
|
* <my-element debug></my-element> // enables debug logging
|
|
21
21
|
*/
|
|
22
22
|
export declare function LoggingMixin<TBase extends Constructor<object>>(Base: TBase): (abstract new (...args: any[]) => {
|
|
23
|
-
"__#
|
|
23
|
+
"__#1703@#debugCached": boolean | null;
|
|
24
|
+
"__#1703@#myElementId": number;
|
|
24
25
|
/**
|
|
25
26
|
* Clears the cached debug flag so the attribute will be checked again
|
|
26
27
|
* on the next log/warn/error call.
|