@trunkjs/browser-utils 1.0.32 → 1.0.37
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 +20 -0
- package/index.d.ts +1 -0
- package/index.js +284 -184
- package/lib/storage.d.ts +4 -0
- package/mixins/BreakPointMixin.d.ts +1 -8
- package/mixins/EventBindingsMixin.d.ts +2 -7
- package/mixins/LoggingMixin.d.ts +1 -16
- package/mixins/tests/mixin-definition.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 1.0.37 (2026-02-08)
|
|
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.36 (2026-02-08)
|
|
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.35 (2026-02-07)
|
|
10
|
+
|
|
11
|
+
This was a version bump only for browser-utils to align it with other projects, there were no code changes.
|
|
12
|
+
|
|
13
|
+
## 1.0.34 (2026-02-07)
|
|
14
|
+
|
|
15
|
+
This was a version bump only for browser-utils to align it with other projects, there were no code changes.
|
|
16
|
+
|
|
17
|
+
## 1.0.33 (2026-02-07)
|
|
18
|
+
|
|
19
|
+
This was a version bump only for browser-utils to align it with other projects, there were no code changes.
|
|
20
|
+
|
|
1
21
|
## 1.0.32 (2026-02-07)
|
|
2
22
|
|
|
3
23
|
This was a version bump only for browser-utils to align it with other projects, there were no code changes.
|
package/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './lib/Debouncer';
|
|
|
4
4
|
export * from './lib/get-error-location';
|
|
5
5
|
export * from './lib/Logger';
|
|
6
6
|
export * from './lib/Stopwatch';
|
|
7
|
+
export * from './lib/storage';
|
|
7
8
|
export * from './lib/wait-for';
|
|
8
9
|
export * from './mixins/BreakPointMixin';
|
|
9
10
|
export * from './mixins/EventBindingsMixin';
|
package/index.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var N = Object.defineProperty;
|
|
2
|
+
var T = (e) => {
|
|
3
|
+
throw TypeError(e);
|
|
4
4
|
};
|
|
5
|
-
var $ = (
|
|
6
|
-
var
|
|
7
|
-
var u = (
|
|
8
|
-
const
|
|
5
|
+
var $ = (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) => $(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 = [
|
|
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
|
-
],
|
|
16
|
-
(
|
|
15
|
+
], x = k.reduce(
|
|
16
|
+
(e, t) => (e[t.name] = t.minWidth, e),
|
|
17
17
|
{}
|
|
18
18
|
);
|
|
19
|
-
function
|
|
20
|
-
if (!(
|
|
21
|
-
throw new Error(`Unknown breakpoint: ${
|
|
22
|
-
return
|
|
19
|
+
function E(e) {
|
|
20
|
+
if (!(e in x))
|
|
21
|
+
throw new Error(`Unknown breakpoint: ${e}`);
|
|
22
|
+
return x[e];
|
|
23
23
|
}
|
|
24
|
-
function R(
|
|
25
|
-
|
|
26
|
-
for (let
|
|
27
|
-
if (
|
|
28
|
-
return
|
|
24
|
+
function R(e) {
|
|
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;
|
|
29
29
|
return "xs";
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function H(e, t = {}, n = []) {
|
|
32
32
|
Array.isArray(n) || (n = [n]);
|
|
33
|
-
const i = document.createElement(
|
|
34
|
-
for (const
|
|
35
|
-
|
|
36
|
-
for (const
|
|
37
|
-
i.append(typeof
|
|
33
|
+
const i = document.createElement(e);
|
|
34
|
+
for (const r in t)
|
|
35
|
+
t[r] !== null && t[r] !== void 0 && i.setAttribute(r, t[r] !== !0 ? t[r] : "");
|
|
36
|
+
for (const r of n)
|
|
37
|
+
i.append(typeof r == "string" ? document.createTextNode(r) : r);
|
|
38
38
|
return i;
|
|
39
39
|
}
|
|
40
40
|
class M {
|
|
@@ -43,97 +43,97 @@ class M {
|
|
|
43
43
|
* @param delay Debounce delay in milliseconds
|
|
44
44
|
* @param max_delay Maximum delay in milliseconds, if false then no maximum delay is applied
|
|
45
45
|
*/
|
|
46
|
-
constructor(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.delay =
|
|
46
|
+
constructor(t, n = !1) {
|
|
47
|
+
l(this, "timeout", null);
|
|
48
|
+
l(this, "startTimeWithMs", 0);
|
|
49
|
+
l(this, "maxTimeout", null);
|
|
50
|
+
this.delay = t, this.max_delay = n;
|
|
51
51
|
}
|
|
52
52
|
async wait() {
|
|
53
|
-
return this.startTimeWithMs === 0 && (this.startTimeWithMs = Date.now()), this.timeout && (this.max_delay === !1 || this.startTimeWithMs + this.max_delay > Date.now()) && clearTimeout(this.timeout), new Promise((
|
|
53
|
+
return this.startTimeWithMs === 0 && (this.startTimeWithMs = Date.now()), this.timeout && (this.max_delay === !1 || this.startTimeWithMs + this.max_delay > Date.now()) && clearTimeout(this.timeout), new Promise((t) => {
|
|
54
54
|
this.timeout = setTimeout(() => {
|
|
55
|
-
this.startTimeWithMs = 0,
|
|
55
|
+
this.startTimeWithMs = 0, t(!0);
|
|
56
56
|
}, this.delay);
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
debounce(
|
|
59
|
+
debounce(t) {
|
|
60
60
|
const n = Date.now();
|
|
61
61
|
this.startTimeWithMs === 0 && (this.startTimeWithMs = n);
|
|
62
62
|
const i = () => {
|
|
63
|
-
this.timeout && (clearTimeout(this.timeout), this.timeout = null), this.maxTimeout && (clearTimeout(this.maxTimeout), this.maxTimeout = null), this.startTimeWithMs = 0,
|
|
63
|
+
this.timeout && (clearTimeout(this.timeout), this.timeout = null), this.maxTimeout && (clearTimeout(this.maxTimeout), this.maxTimeout = null), this.startTimeWithMs = 0, t();
|
|
64
64
|
};
|
|
65
65
|
if (this.timeout && clearTimeout(this.timeout), this.timeout = setTimeout(i, this.delay), this.max_delay !== !1 && !this.maxTimeout) {
|
|
66
|
-
const
|
|
66
|
+
const r = n - this.startTimeWithMs, a = Math.max(0, this.max_delay - r);
|
|
67
67
|
this.maxTimeout = setTimeout(i, a);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function G(e, t = !1) {
|
|
72
72
|
const n = /* @__PURE__ */ new WeakMap();
|
|
73
|
-
return function(i,
|
|
74
|
-
if (
|
|
75
|
-
const a =
|
|
76
|
-
return function(...
|
|
77
|
-
let
|
|
78
|
-
|
|
79
|
-
let o =
|
|
80
|
-
o || (o = new M(
|
|
73
|
+
return function(i, r) {
|
|
74
|
+
if (r.kind !== "method") return i;
|
|
75
|
+
const a = r.name;
|
|
76
|
+
return function(...c) {
|
|
77
|
+
let s = n.get(this);
|
|
78
|
+
s || (s = /* @__PURE__ */ new Map(), n.set(this, s));
|
|
79
|
+
let o = s.get(a);
|
|
80
|
+
o || (o = new M(e, t), s.set(a, o)), o.debounce(() => i.apply(this, c));
|
|
81
81
|
};
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
function
|
|
85
|
-
if (typeof
|
|
84
|
+
function J(e) {
|
|
85
|
+
if (typeof e.lineNumber == "number")
|
|
86
86
|
return {
|
|
87
|
-
file:
|
|
88
|
-
line:
|
|
89
|
-
column:
|
|
87
|
+
file: e.fileName || e.sourceURL,
|
|
88
|
+
line: e.lineNumber,
|
|
89
|
+
column: e.columnNumber ?? void 0
|
|
90
90
|
};
|
|
91
|
-
if (typeof
|
|
91
|
+
if (typeof e.line == "number")
|
|
92
92
|
return {
|
|
93
|
-
file:
|
|
94
|
-
line:
|
|
95
|
-
column:
|
|
93
|
+
file: e.sourceURL,
|
|
94
|
+
line: e.line,
|
|
95
|
+
column: e.column
|
|
96
96
|
};
|
|
97
|
-
const n = String(
|
|
97
|
+
const n = String(e.stack || e.message || "").split(`
|
|
98
98
|
`), i = /(.*?)(?:\(|@)?(.*?):(\d+):(\d+)\)?$/;
|
|
99
|
-
for (const
|
|
100
|
-
const a =
|
|
99
|
+
for (const r of n) {
|
|
100
|
+
const a = r.match(i);
|
|
101
101
|
if (a)
|
|
102
102
|
return { file: a[2], line: +a[3], column: +a[4] };
|
|
103
103
|
}
|
|
104
|
-
return { file:
|
|
104
|
+
return { file: e.fileName || e.sourceURL };
|
|
105
105
|
}
|
|
106
106
|
class B {
|
|
107
|
-
constructor(
|
|
108
|
-
this._debug =
|
|
107
|
+
constructor(t, n, i = "main") {
|
|
108
|
+
this._debug = t, this.myElementId = n, this.instanceId = i;
|
|
109
109
|
}
|
|
110
|
-
log(...
|
|
111
|
-
this._debug && console.log(`[LOG][ID:${this.myElementId}:${this.instanceId}]`, ...
|
|
110
|
+
log(...t) {
|
|
111
|
+
this._debug && console.log(`[LOG][ID:${this.myElementId}:${this.instanceId}]`, ...t);
|
|
112
112
|
}
|
|
113
|
-
warn(...
|
|
114
|
-
console.warn(`[WARN][ID:${this.myElementId}:${this.instanceId}]`, ...
|
|
113
|
+
warn(...t) {
|
|
114
|
+
console.warn(`[WARN][ID:${this.myElementId}:${this.instanceId}]`, ...t);
|
|
115
115
|
}
|
|
116
|
-
error(...
|
|
117
|
-
console.error(`[ERROR][ID:${this.myElementId}:${this.instanceId}]`, ...
|
|
116
|
+
error(...t) {
|
|
117
|
+
console.error(`[ERROR][ID:${this.myElementId}:${this.instanceId}]`, ...t);
|
|
118
118
|
}
|
|
119
|
-
throwError(...
|
|
120
|
-
const n = `[ERROR][ID:${this.myElementId}:${this.instanceId}] ${
|
|
121
|
-
throw this.error(...
|
|
119
|
+
throwError(...t) {
|
|
120
|
+
const n = `[ERROR][ID:${this.myElementId}:${this.instanceId}] ${t.join(" ")}`;
|
|
121
|
+
throw this.error(...t), new Error(n);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
class
|
|
125
|
-
constructor(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
this.label =
|
|
124
|
+
class q {
|
|
125
|
+
constructor(t, n = !0) {
|
|
126
|
+
l(this, "label");
|
|
127
|
+
l(this, "last");
|
|
128
|
+
l(this, "startTime");
|
|
129
|
+
l(this, "running", !1);
|
|
130
|
+
l(this, "enabled");
|
|
131
|
+
this.label = t, this.enabled = n, this.startTime = this.last = performance.now(), this.running = !0;
|
|
132
132
|
}
|
|
133
|
-
lap(
|
|
133
|
+
lap(t = "") {
|
|
134
134
|
if (!this.enabled) return;
|
|
135
135
|
const n = performance.now(), i = (n - this.last) / 1e3;
|
|
136
|
-
this.last = n, console.debug(`[${this.label}] ${
|
|
136
|
+
this.last = n, console.debug(`[${this.label}] ${t} +${i.toFixed(3)}s`);
|
|
137
137
|
}
|
|
138
138
|
elapsed() {
|
|
139
139
|
return performance.now() - this.startTime;
|
|
@@ -151,50 +151,148 @@ class V {
|
|
|
151
151
|
return this.running;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
return
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
function O(e) {
|
|
155
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
156
|
+
}
|
|
157
|
+
function U(e) {
|
|
158
|
+
if (e != null)
|
|
159
|
+
try {
|
|
160
|
+
return JSON.parse(e);
|
|
161
|
+
} catch {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function p(e) {
|
|
166
|
+
const t = JSON.stringify(e);
|
|
167
|
+
return t === void 0 ? "null" : t;
|
|
168
|
+
}
|
|
169
|
+
function K(e, t) {
|
|
170
|
+
const n = { ...t };
|
|
171
|
+
if (O(e))
|
|
172
|
+
for (const i of Object.keys(t))
|
|
173
|
+
i in e && (n[i] = e[i]);
|
|
174
|
+
return n;
|
|
175
|
+
}
|
|
176
|
+
class P {
|
|
177
|
+
constructor(t, n, i) {
|
|
178
|
+
l(this, "cache");
|
|
179
|
+
this.backend = t, this.storageKey = n, this.initialValue = i;
|
|
180
|
+
}
|
|
181
|
+
read() {
|
|
182
|
+
if (this.cache) return this.cache;
|
|
183
|
+
const t = this.backend ? U(this.backend.getItem(this.storageKey)) : void 0, n = K(t, this.initialValue);
|
|
184
|
+
if (this.backend && this.backend.getItem(this.storageKey) == null)
|
|
185
|
+
try {
|
|
186
|
+
this.backend.setItem(this.storageKey, p(n));
|
|
187
|
+
} catch {
|
|
188
|
+
}
|
|
189
|
+
return this.cache = n, n;
|
|
190
|
+
}
|
|
191
|
+
write(t) {
|
|
192
|
+
if (this.cache = t, !!this.backend)
|
|
193
|
+
try {
|
|
194
|
+
this.backend.setItem(this.storageKey, p(t));
|
|
195
|
+
} catch {
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
asProxy() {
|
|
199
|
+
const t = {
|
|
200
|
+
get: (n, i) => {
|
|
201
|
+
if (typeof i == "symbol")
|
|
202
|
+
return i === Symbol.toStringTag ? "Storage" : void 0;
|
|
203
|
+
const r = this.read();
|
|
204
|
+
return i === "toJSON" ? () => ({ ...r }) : r[i];
|
|
205
|
+
},
|
|
206
|
+
set: (n, i, r) => {
|
|
207
|
+
if (typeof i != "string") return !1;
|
|
208
|
+
const c = { ...this.read() };
|
|
209
|
+
return c[i] = r, this.write(c), !0;
|
|
210
|
+
},
|
|
211
|
+
deleteProperty: (n, i) => {
|
|
212
|
+
if (typeof i != "string") return !1;
|
|
213
|
+
const r = this.read();
|
|
214
|
+
if (!(i in r)) return !0;
|
|
215
|
+
const a = { ...r };
|
|
216
|
+
return delete a[i], this.write(a), !0;
|
|
217
|
+
},
|
|
218
|
+
has: (n, i) => {
|
|
219
|
+
if (typeof i != "string") return !1;
|
|
220
|
+
const r = this.read();
|
|
221
|
+
return i in r;
|
|
222
|
+
},
|
|
223
|
+
ownKeys: () => {
|
|
224
|
+
const n = this.read();
|
|
225
|
+
return Reflect.ownKeys(n);
|
|
226
|
+
},
|
|
227
|
+
getOwnPropertyDescriptor: (n, i) => {
|
|
228
|
+
if (typeof i != "string") return;
|
|
229
|
+
const r = this.read();
|
|
230
|
+
if (i in r)
|
|
231
|
+
return {
|
|
232
|
+
enumerable: !0,
|
|
233
|
+
configurable: !0,
|
|
234
|
+
writable: !0,
|
|
235
|
+
value: r[i]
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
return new Proxy({}, t);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function I(e) {
|
|
243
|
+
const t = globalThis.window;
|
|
244
|
+
return (e === "session" ? t == null ? void 0 : t.sessionStorage : t == null ? void 0 : t.localStorage) ?? void 0;
|
|
245
|
+
}
|
|
246
|
+
function X(e, t) {
|
|
247
|
+
return new P(I("session"), e, t).asProxy();
|
|
248
|
+
}
|
|
249
|
+
function Q(e, t) {
|
|
250
|
+
return new P(I("local"), e, t).asProxy();
|
|
251
|
+
}
|
|
252
|
+
function Y(e, t, n) {
|
|
253
|
+
return new Promise((i, r) => {
|
|
254
|
+
const a = (c) => {
|
|
255
|
+
e.removeEventListener(t, a, n), i(c);
|
|
158
256
|
};
|
|
159
|
-
|
|
257
|
+
e.addEventListener(t, a, n);
|
|
160
258
|
});
|
|
161
259
|
}
|
|
162
|
-
function
|
|
163
|
-
return document.readyState === "loading" ? new Promise((
|
|
164
|
-
document.addEventListener("DOMContentLoaded", () =>
|
|
260
|
+
function z() {
|
|
261
|
+
return document.readyState === "loading" ? new Promise((e) => {
|
|
262
|
+
document.addEventListener("DOMContentLoaded", () => e());
|
|
165
263
|
}) : Promise.resolve();
|
|
166
264
|
}
|
|
167
|
-
function
|
|
168
|
-
return
|
|
169
|
-
|
|
170
|
-
}) :
|
|
265
|
+
function Z(e = window) {
|
|
266
|
+
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) => {
|
|
267
|
+
e.addEventListener("load", () => t(), { once: !0 }), e.addEventListener("error", () => n(new Error("image error")), { once: !0 });
|
|
268
|
+
}) : 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 }));
|
|
171
269
|
}
|
|
172
|
-
function
|
|
173
|
-
return new Promise((
|
|
270
|
+
function tt(e) {
|
|
271
|
+
return new Promise((t) => setTimeout(t, e));
|
|
174
272
|
}
|
|
175
|
-
function
|
|
176
|
-
return new Promise((
|
|
273
|
+
function et(e) {
|
|
274
|
+
return new Promise((t) => {
|
|
177
275
|
const n = (i) => {
|
|
178
|
-
|
|
276
|
+
e.removeEventListener("animationend", n), t(i);
|
|
179
277
|
};
|
|
180
|
-
|
|
278
|
+
e.addEventListener("animationend", n);
|
|
181
279
|
});
|
|
182
280
|
}
|
|
183
|
-
function
|
|
281
|
+
function nt(e) {
|
|
184
282
|
var n, i;
|
|
185
|
-
class
|
|
283
|
+
class t extends e {
|
|
186
284
|
constructor() {
|
|
187
285
|
super(...arguments);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
286
|
+
h(this, n, new M(200, 5e3));
|
|
287
|
+
l(this, "currentBreakPoint", null);
|
|
288
|
+
h(this, i, async () => {
|
|
191
289
|
var b;
|
|
192
|
-
await u(this, n).wait(), await
|
|
193
|
-
const
|
|
290
|
+
await u(this, n).wait(), await z();
|
|
291
|
+
const c = this, s = window.innerWidth, o = getComputedStyle(c).getPropertyValue("--breakpoint");
|
|
194
292
|
if (!o || o === "")
|
|
195
293
|
return;
|
|
196
|
-
const d = o.split(","),
|
|
197
|
-
this.currentBreakPoint !== g && (
|
|
294
|
+
const d = o.split(","), m = d[0].trim(), f = ((b = d[1]) == null ? void 0 : b.trim()) ?? m, g = R(s);
|
|
295
|
+
this.currentBreakPoint !== g && (E(f) <= E(g) ? c.setAttribute("mode", "desktop") : E(m) > E(g) ? c.setAttribute("mode", "mobile") : c.setAttribute("mode", "tablet"));
|
|
198
296
|
});
|
|
199
297
|
}
|
|
200
298
|
connectedCallback() {
|
|
@@ -204,69 +302,69 @@ function X(t) {
|
|
|
204
302
|
super.disconnectedCallback(), window.removeEventListener("resize", u(this, i));
|
|
205
303
|
}
|
|
206
304
|
}
|
|
207
|
-
return n = new WeakMap(), i = new WeakMap(),
|
|
305
|
+
return n = new WeakMap(), i = new WeakMap(), t;
|
|
208
306
|
}
|
|
209
|
-
const
|
|
210
|
-
function
|
|
211
|
-
const n = Array.isArray(
|
|
212
|
-
return function(i,
|
|
213
|
-
if (
|
|
214
|
-
return
|
|
307
|
+
const v = Symbol("listenerDefs"), A = Symbol("withEventBindings");
|
|
308
|
+
function it(e, t) {
|
|
309
|
+
const n = Array.isArray(e) ? e : [e];
|
|
310
|
+
return function(i, r) {
|
|
311
|
+
if (r.kind !== "method") throw new Error("@Listen nur für Methoden");
|
|
312
|
+
return r.addInitializer(function() {
|
|
215
313
|
const a = this.constructor;
|
|
216
|
-
(a[
|
|
217
|
-
method:
|
|
314
|
+
(a[v] || (a[v] = [])).push({
|
|
315
|
+
method: r.name,
|
|
218
316
|
events: n,
|
|
219
|
-
opts:
|
|
317
|
+
opts: t
|
|
220
318
|
});
|
|
221
319
|
}), function(...a) {
|
|
222
|
-
if (!this[
|
|
320
|
+
if (!this[A])
|
|
223
321
|
throw new Error("[EventBindings] @Listen - decorator requires EventBindingMixin.");
|
|
224
322
|
return i.apply(this, a);
|
|
225
323
|
};
|
|
226
324
|
};
|
|
227
325
|
}
|
|
228
|
-
function
|
|
326
|
+
function F(e, t) {
|
|
229
327
|
var n;
|
|
230
|
-
return !
|
|
328
|
+
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;
|
|
231
329
|
}
|
|
232
|
-
function
|
|
233
|
-
var n, i,
|
|
234
|
-
class
|
|
235
|
-
constructor(...
|
|
236
|
-
super(...
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
this[
|
|
330
|
+
function rt(e) {
|
|
331
|
+
var n, i, W;
|
|
332
|
+
class t extends e {
|
|
333
|
+
constructor(...s) {
|
|
334
|
+
super(...s);
|
|
335
|
+
h(this, i);
|
|
336
|
+
h(this, n);
|
|
337
|
+
this[A] = !0;
|
|
240
338
|
}
|
|
241
339
|
connectedCallback() {
|
|
242
|
-
var
|
|
243
|
-
(
|
|
340
|
+
var s;
|
|
341
|
+
(s = super.connectedCallback) == null || s.call(this), y(this, i, W).call(this);
|
|
244
342
|
}
|
|
245
343
|
disconnectedCallback() {
|
|
246
|
-
var
|
|
247
|
-
(
|
|
344
|
+
var s, o;
|
|
345
|
+
(s = u(this, n)) == null || s.abort(), (o = super.disconnectedCallback) == null || o.call(this);
|
|
248
346
|
}
|
|
249
347
|
}
|
|
250
|
-
return n = new WeakMap(), i = new WeakSet(),
|
|
251
|
-
var o, d,
|
|
348
|
+
return n = new WeakMap(), i = new WeakSet(), W = function() {
|
|
349
|
+
var o, d, m;
|
|
252
350
|
(o = u(this, n)) == null || o.abort(), w(this, n, new AbortController());
|
|
253
|
-
const
|
|
254
|
-
for (const f of
|
|
255
|
-
const g =
|
|
256
|
-
for (const
|
|
257
|
-
g.addEventListener(
|
|
351
|
+
const s = this.constructor[v] || [];
|
|
352
|
+
for (const f of s) {
|
|
353
|
+
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);
|
|
354
|
+
for (const D of f.events)
|
|
355
|
+
g.addEventListener(D, C, { ...b, signal: u(this, n).signal });
|
|
258
356
|
}
|
|
259
|
-
},
|
|
357
|
+
}, t;
|
|
260
358
|
}
|
|
261
|
-
let
|
|
262
|
-
function
|
|
263
|
-
var n, i,
|
|
264
|
-
class
|
|
359
|
+
let V = 1;
|
|
360
|
+
function st(e) {
|
|
361
|
+
var n, i, r;
|
|
362
|
+
class t extends e {
|
|
265
363
|
constructor() {
|
|
266
364
|
super(...arguments);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
365
|
+
h(this, n, null);
|
|
366
|
+
h(this, i, V++);
|
|
367
|
+
h(this, r, null);
|
|
270
368
|
}
|
|
271
369
|
/**
|
|
272
370
|
* Clears the cached debug flag so the attribute will be checked again
|
|
@@ -278,69 +376,71 @@ function Q(t) {
|
|
|
278
376
|
get _debug() {
|
|
279
377
|
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);
|
|
280
378
|
}
|
|
281
|
-
getLogger(
|
|
282
|
-
return u(this,
|
|
379
|
+
getLogger(s = "main") {
|
|
380
|
+
return u(this, r) || w(this, r, new B(this._debug, `${u(this, i)}`, s)), u(this, r);
|
|
283
381
|
}
|
|
284
|
-
log(...
|
|
285
|
-
this.getLogger().log(...
|
|
382
|
+
log(...s) {
|
|
383
|
+
this.getLogger().log(...s);
|
|
286
384
|
}
|
|
287
|
-
warn(...
|
|
288
|
-
this.getLogger().warn(...
|
|
385
|
+
warn(...s) {
|
|
386
|
+
this.getLogger().warn(...s);
|
|
289
387
|
}
|
|
290
|
-
error(...
|
|
291
|
-
this.getLogger().error(...
|
|
388
|
+
error(...s) {
|
|
389
|
+
this.getLogger().error(...s);
|
|
292
390
|
}
|
|
293
|
-
throwError(...
|
|
294
|
-
return this.getLogger().throwError(...
|
|
391
|
+
throwError(...s) {
|
|
392
|
+
return this.getLogger().throwError(...s);
|
|
295
393
|
}
|
|
296
394
|
}
|
|
297
|
-
return n = new WeakMap(), i = new WeakMap(),
|
|
395
|
+
return n = new WeakMap(), i = new WeakMap(), r = new WeakMap(), t;
|
|
298
396
|
}
|
|
299
|
-
function
|
|
300
|
-
var n,
|
|
301
|
-
class
|
|
397
|
+
function ot(e) {
|
|
398
|
+
var n, S, r, _;
|
|
399
|
+
class t extends e {
|
|
302
400
|
constructor() {
|
|
303
401
|
super(...arguments);
|
|
304
|
-
|
|
305
|
-
|
|
402
|
+
h(this, n);
|
|
403
|
+
h(this, r, (o) => {
|
|
306
404
|
const d = o.target;
|
|
307
|
-
d.assignedNodes({ flatten: !0 }).filter((g) =>
|
|
405
|
+
d.assignedNodes({ flatten: !0 }).filter((g) => y(this, n, _).call(this, g)).length > 0 && d.classList.remove("slot-empty");
|
|
308
406
|
});
|
|
309
407
|
}
|
|
310
408
|
firstUpdated(o) {
|
|
311
409
|
var d;
|
|
312
|
-
(d = super.firstUpdated) == null || d.call(this, o),
|
|
410
|
+
(d = super.firstUpdated) == null || d.call(this, o), y(this, n, S).call(this);
|
|
313
411
|
}
|
|
314
412
|
}
|
|
315
|
-
return n = new WeakSet(),
|
|
413
|
+
return n = new WeakSet(), S = function() {
|
|
316
414
|
var d;
|
|
317
415
|
const o = (d = this.shadowRoot) == null ? void 0 : d.querySelectorAll("slot");
|
|
318
|
-
o == null || o.forEach((
|
|
319
|
-
|
|
416
|
+
o == null || o.forEach((m) => {
|
|
417
|
+
m.classList.add("slot-empty"), m.addEventListener("slotchange", (f) => u(this, r).call(this, f));
|
|
320
418
|
});
|
|
321
|
-
},
|
|
419
|
+
}, r = new WeakMap(), _ = function(o) {
|
|
322
420
|
return o.nodeType === Node.TEXT_NODE ? (o.textContent || "").trim().length > 0 : o.nodeType === Node.ELEMENT_NODE;
|
|
323
|
-
},
|
|
421
|
+
}, t;
|
|
324
422
|
}
|
|
325
423
|
export {
|
|
326
|
-
|
|
424
|
+
nt as BreakPointMixin,
|
|
327
425
|
M as Debouncer,
|
|
328
|
-
|
|
329
|
-
|
|
426
|
+
rt as EventBindingsMixin,
|
|
427
|
+
it as Listen,
|
|
330
428
|
B as Logger,
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
429
|
+
st as LoggingMixin,
|
|
430
|
+
ot as SlotVisibilityMixin,
|
|
431
|
+
q as Stopwatch,
|
|
432
|
+
x as breakpointMap,
|
|
433
|
+
k as breakpoints,
|
|
434
|
+
H as create_element,
|
|
435
|
+
G as debounce,
|
|
436
|
+
E as getBreakpointMinWidth,
|
|
339
437
|
R as getCurrentBreakpoint,
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
438
|
+
J as getErrorLocation,
|
|
439
|
+
Q as local_storage,
|
|
440
|
+
X as session_storage,
|
|
441
|
+
tt as sleep,
|
|
442
|
+
Y as waitFor,
|
|
443
|
+
et as waitForAnimationEnd,
|
|
444
|
+
z as waitForDomContentLoaded,
|
|
445
|
+
Z as waitForLoad
|
|
346
446
|
};
|
package/lib/storage.d.ts
ADDED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import { Debouncer } from '../lib/Debouncer';
|
|
2
1
|
type Constructor<T = object> = abstract new (...args: any[]) => T;
|
|
3
2
|
export interface BreakPointMixinInterface {
|
|
4
3
|
currentBreakPoint: string | null;
|
|
5
4
|
}
|
|
6
|
-
export declare function BreakPointMixin<TBase extends Constructor<object>>(Base: TBase):
|
|
7
|
-
"__#2564@#debouncer": Debouncer;
|
|
8
|
-
currentBreakPoint: string | null;
|
|
9
|
-
"__#2564@#updateBreakPoint": () => Promise<void>;
|
|
10
|
-
connectedCallback(): void;
|
|
11
|
-
disconnectedCallback(): void;
|
|
12
|
-
}) & TBase;
|
|
5
|
+
export declare function BreakPointMixin<TBase extends Constructor<object>>(Base: TBase): TBase & Constructor<BreakPointMixinInterface>;
|
|
13
6
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Ctor<T = object> = new (...args: any[]) => T;
|
|
1
|
+
type Ctor<T = object> = abstract new (...args: any[]) => T;
|
|
2
2
|
type TargetSpec = 'host' | 'document' | 'window' | 'shadowRoot' | EventTarget | ((host: HTMLElement) => EventTarget);
|
|
3
3
|
type ListenOpts = {
|
|
4
4
|
target?: TargetSpec;
|
|
@@ -8,10 +8,5 @@ type EventName = keyof DocumentEventMap;
|
|
|
8
8
|
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
|
-
export declare function EventBindingsMixin<TBase extends Ctor<object>>(Base: TBase):
|
|
12
|
-
"__#2565@#ac"?: AbortController;
|
|
13
|
-
connectedCallback(): void;
|
|
14
|
-
disconnectedCallback(): void;
|
|
15
|
-
"__#2565@#bindEventListeners"(): void;
|
|
16
|
-
}) & TBase;
|
|
11
|
+
export declare function EventBindingsMixin<TBase extends Ctor<object>>(Base: TBase): TBase;
|
|
17
12
|
export {};
|
package/mixins/LoggingMixin.d.ts
CHANGED
|
@@ -32,20 +32,5 @@ export interface LoggerMixinInterface {
|
|
|
32
32
|
*
|
|
33
33
|
* <my-element debug></my-element> // enables debug logging
|
|
34
34
|
*/
|
|
35
|
-
export declare function LoggingMixin<TBase extends Constructor<object>>(Base: TBase):
|
|
36
|
-
"__#2566@#debugCached": boolean | null;
|
|
37
|
-
"__#2566@#myElementId": number;
|
|
38
|
-
/**
|
|
39
|
-
* Clears the cached debug flag so the attribute will be checked again
|
|
40
|
-
* on the next log/warn/error call.
|
|
41
|
-
*/
|
|
42
|
-
invalidateDebugCache(): void;
|
|
43
|
-
"__#2566@#myLoggerInstance": Logger | null;
|
|
44
|
-
readonly _debug: boolean;
|
|
45
|
-
getLogger(instanceId?: string): Logger;
|
|
46
|
-
log(...args: any[]): void;
|
|
47
|
-
warn(...args: any[]): void;
|
|
48
|
-
error(...args: any[]): void;
|
|
49
|
-
throwError(...args: any[]): never;
|
|
50
|
-
}) & TBase;
|
|
35
|
+
export declare function LoggingMixin<TBase extends Constructor<object>>(Base: TBase): TBase & Constructor<LoggerMixinInterface>;
|
|
51
36
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|