vuesp-components 5.3.2 → 5.3.4
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 +15 -0
- package/dist/components/index.es.js +2898 -2744
- package/dist/components/serial/SerialConsole.vue.d.ts +2 -0
- package/dist/components/serial/SerialConsole.vue.d.ts.map +1 -1
- package/dist/components/serial/labels.d.ts.map +1 -1
- package/dist/components/serial/types.d.ts +16 -0
- package/dist/components/serial/types.d.ts.map +1 -1
- package/dist/composables/index.es.js +402 -273
- package/dist/composables/useSerialConsole.d.ts +11 -0
- package/dist/composables/useSerialConsole.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,356 +1,485 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { u as
|
|
3
|
-
function
|
|
4
|
-
const { validationSchema: u, initialValues:
|
|
5
|
-
w ? u(
|
|
6
|
-
),
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}),
|
|
12
|
-
|
|
13
|
-
}),
|
|
14
|
-
},
|
|
15
|
-
Object.keys(
|
|
16
|
-
|
|
17
|
-
}),
|
|
18
|
-
},
|
|
19
|
-
const
|
|
20
|
-
for (const
|
|
21
|
-
const
|
|
22
|
-
|
|
1
|
+
import { ref as d, reactive as Q, watch as ue, computed as F, onMounted as ot, onBeforeUnmount as lt } from "vue";
|
|
2
|
+
import { u as St, b as bt, a as kt } from "../useDialog-Buvn63AR.js";
|
|
3
|
+
function pt(o) {
|
|
4
|
+
const { validationSchema: u, initialValues: p = {} } = o, w = typeof u == "function", b = d(
|
|
5
|
+
w ? u(p) : u
|
|
6
|
+
), L = d(!0), j = (r) => {
|
|
7
|
+
b.value = r;
|
|
8
|
+
const l = Object.keys(r), v = Object.keys(i);
|
|
9
|
+
l.forEach((a) => {
|
|
10
|
+
a in i || (i[a] = p[a] ?? "", x[a] = [], T[a] = !1, k[a] = !1);
|
|
11
|
+
}), v.forEach((a) => {
|
|
12
|
+
l.includes(a) || (delete i[a], delete x[a], delete T[a], delete k[a]);
|
|
13
|
+
}), M(), R();
|
|
14
|
+
}, i = Q({}), x = Q({}), T = Q({}), k = Q({}), O = /* @__PURE__ */ new Map(), I = () => {
|
|
15
|
+
Object.keys(b.value).forEach((r) => {
|
|
16
|
+
i[r] = p[r] ?? "", x[r] = [], T[r] = !1, k[r] = !1;
|
|
17
|
+
}), L.value = !0;
|
|
18
|
+
}, y = () => w ? u(i) : b.value, m = (r, l) => {
|
|
19
|
+
const a = y()[r] || [], h = [];
|
|
20
|
+
for (const S of a) {
|
|
21
|
+
const g = S(l, i);
|
|
22
|
+
g !== !0 && h.push(g);
|
|
23
23
|
}
|
|
24
|
-
return
|
|
25
|
-
},
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}),
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
Object.keys(
|
|
37
|
-
(
|
|
38
|
-
if (typeof
|
|
39
|
-
const h =
|
|
24
|
+
return x[r] = h, h.length === 0;
|
|
25
|
+
}, U = (r, l) => {
|
|
26
|
+
const v = y();
|
|
27
|
+
if (!v[r]) return;
|
|
28
|
+
m(r, l);
|
|
29
|
+
const a = O.get(r);
|
|
30
|
+
a && a.forEach((h) => {
|
|
31
|
+
v[h] && m(h, i[h]);
|
|
32
|
+
}), R();
|
|
33
|
+
}, M = () => {
|
|
34
|
+
O.clear();
|
|
35
|
+
const r = y();
|
|
36
|
+
Object.keys(r).forEach((l) => {
|
|
37
|
+
(r[l] || []).forEach((a) => {
|
|
38
|
+
if (typeof a == "function" && a.name === "sameAs") {
|
|
39
|
+
const h = a.toString().match(/['"](.*?)['"]/);
|
|
40
40
|
if (h) {
|
|
41
|
-
const
|
|
42
|
-
|
|
41
|
+
const S = h[1];
|
|
42
|
+
O.has(S) || O.set(S, /* @__PURE__ */ new Set()), O.get(S).add(l);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
|
-
},
|
|
48
|
-
const
|
|
49
|
-
let
|
|
50
|
-
return Object.keys(
|
|
51
|
-
|
|
52
|
-
}),
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
get: () =>
|
|
57
|
-
set: (
|
|
58
|
-
|
|
47
|
+
}, R = () => {
|
|
48
|
+
const r = y();
|
|
49
|
+
let l = !0;
|
|
50
|
+
return Object.keys(r).forEach((v) => {
|
|
51
|
+
m(v, i[v]) || (l = !1);
|
|
52
|
+
}), L.value = l, l;
|
|
53
|
+
}, W = (r, l = {}) => {
|
|
54
|
+
y()[r] || console.warn(`Field "${r}" not found in current validationSchema`);
|
|
55
|
+
const a = F({
|
|
56
|
+
get: () => i[r],
|
|
57
|
+
set: (S) => {
|
|
58
|
+
i[r] = S, k[r] = !0, U(r, S);
|
|
59
59
|
}
|
|
60
|
-
}), h =
|
|
61
|
-
var
|
|
62
|
-
const
|
|
63
|
-
errors:
|
|
64
|
-
touched:
|
|
65
|
-
dirty:
|
|
66
|
-
},
|
|
67
|
-
message: (
|
|
60
|
+
}), h = F(() => {
|
|
61
|
+
var E;
|
|
62
|
+
const S = {
|
|
63
|
+
errors: x[r] || [],
|
|
64
|
+
touched: T[r] || !1,
|
|
65
|
+
dirty: k[r] || !1
|
|
66
|
+
}, g = {
|
|
67
|
+
message: (E = x[r]) == null ? void 0 : E[0],
|
|
68
68
|
onInput: (A) => {
|
|
69
|
-
const
|
|
70
|
-
|
|
69
|
+
const C = A.target;
|
|
70
|
+
a.value = C.value;
|
|
71
71
|
},
|
|
72
72
|
onBlur: () => {
|
|
73
|
-
|
|
73
|
+
T[r] = !0, U(r, i[r]);
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
if (
|
|
77
|
-
const A =
|
|
78
|
-
return { ...
|
|
76
|
+
if (l.props) {
|
|
77
|
+
const A = l.props(S);
|
|
78
|
+
return { ...g, ...A };
|
|
79
79
|
}
|
|
80
|
-
return
|
|
80
|
+
return g;
|
|
81
81
|
});
|
|
82
|
-
return [
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
Object.keys(
|
|
87
|
-
|
|
88
|
-
}),
|
|
89
|
-
},
|
|
90
|
-
const
|
|
91
|
-
Object.keys(
|
|
92
|
-
|
|
93
|
-
}),
|
|
82
|
+
return [a, h];
|
|
83
|
+
}, Y = (r) => async (l) => {
|
|
84
|
+
l && l.preventDefault();
|
|
85
|
+
const v = y();
|
|
86
|
+
Object.keys(v).forEach((h) => {
|
|
87
|
+
T[h] = !0;
|
|
88
|
+
}), R() && await r(i);
|
|
89
|
+
}, Z = () => {
|
|
90
|
+
const r = y();
|
|
91
|
+
Object.keys(r).forEach((l) => {
|
|
92
|
+
i[l] = p[l] || "", x[l] = [], T[l] = !1, k[l] = !1;
|
|
93
|
+
}), L.value = !0;
|
|
94
94
|
};
|
|
95
|
-
return
|
|
96
|
-
() =>
|
|
95
|
+
return I(), M(), w && ue(
|
|
96
|
+
() => i,
|
|
97
97
|
() => {
|
|
98
|
-
const
|
|
99
|
-
(
|
|
98
|
+
const r = u(i), l = b.value, v = Object.keys(r), a = Object.keys(l);
|
|
99
|
+
(v.length !== a.length || v.some((h) => !a.includes(h))) && j(r);
|
|
100
100
|
},
|
|
101
101
|
{ deep: !0 }
|
|
102
102
|
), {
|
|
103
|
-
values:
|
|
104
|
-
errors:
|
|
105
|
-
defineField:
|
|
106
|
-
handleSubmit:
|
|
107
|
-
resetForm:
|
|
108
|
-
validate:
|
|
109
|
-
updateSchema:
|
|
110
|
-
isValid:
|
|
103
|
+
values: i,
|
|
104
|
+
errors: x,
|
|
105
|
+
defineField: W,
|
|
106
|
+
handleSubmit: Y,
|
|
107
|
+
resetForm: Z,
|
|
108
|
+
validate: R,
|
|
109
|
+
updateSchema: j,
|
|
110
|
+
isValid: L
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
const
|
|
113
|
+
const ut = 150, it = 4096, Re = 256 * 1024, Le = 12, ft = 1200, dt = { utf8: "utf-8", cp1251: "windows-1251" }, ht = {
|
|
114
114
|
encoding: "utf8",
|
|
115
115
|
framing: "line",
|
|
116
116
|
gapMs: 25,
|
|
117
117
|
paused: !1
|
|
118
|
-
},
|
|
118
|
+
}, vt = (o, u) => (
|
|
119
119
|
// eslint-disable-next-line no-control-regex
|
|
120
|
-
new TextDecoder(
|
|
121
|
-
),
|
|
122
|
-
function
|
|
123
|
-
var
|
|
124
|
-
const u =
|
|
125
|
-
let
|
|
126
|
-
const
|
|
127
|
-
var
|
|
128
|
-
const t = (
|
|
120
|
+
new TextDecoder(dt[u]).decode(o).replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g, ".")
|
|
121
|
+
), yt = (o) => Array.from(o, (u) => u.toString(16).padStart(2, "0")).join(" ");
|
|
122
|
+
function mt(o) {
|
|
123
|
+
var be, ke;
|
|
124
|
+
const u = d([]), p = Q({ ...ht }), w = d(0), b = d(0), L = d(0), j = d(0), i = d(""), x = d(!1), T = d(!1), k = d(!1), O = d(1e3), I = d(((be = o.initialLineEnding) == null ? void 0 : be.call(o)) ?? "crlf"), y = d([]), m = d(-1), U = d(""), M = d("text"), R = d(null), W = d(!0), Y = d(!0), Z = d(!0), r = d(!1), l = d(!1), v = d(!1), a = d([]), h = d("");
|
|
125
|
+
let S = 0, g = [], E = [], A = null, C = null, V = null, $ = null, H = null, N = "", _ = null, ee = 0, te = 0, X = 0, D = null;
|
|
126
|
+
const ie = (e) => {
|
|
127
|
+
var n;
|
|
128
|
+
const t = (n = o.storageKey) == null ? void 0 : n.call(o);
|
|
129
129
|
return t ? `${t}:${e}` : null;
|
|
130
|
-
},
|
|
131
|
-
const t =
|
|
130
|
+
}, fe = (e) => {
|
|
131
|
+
const t = ie(e);
|
|
132
132
|
if (!t || typeof localStorage > "u") return null;
|
|
133
133
|
try {
|
|
134
|
-
const
|
|
135
|
-
return
|
|
134
|
+
const n = localStorage.getItem(t);
|
|
135
|
+
return n ? JSON.parse(n) : null;
|
|
136
136
|
} catch {
|
|
137
137
|
return null;
|
|
138
138
|
}
|
|
139
|
-
},
|
|
140
|
-
const
|
|
141
|
-
if (!(!
|
|
139
|
+
}, ne = (e, t) => {
|
|
140
|
+
const n = ie(e);
|
|
141
|
+
if (!(!n || typeof localStorage > "u"))
|
|
142
142
|
try {
|
|
143
|
-
localStorage.setItem(
|
|
143
|
+
localStorage.setItem(n, JSON.stringify(t));
|
|
144
144
|
} catch {
|
|
145
145
|
}
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
146
|
+
}, de = fe("view");
|
|
147
|
+
de && Object.assign(p, de, { paused: !1 }), p.paused = !1;
|
|
148
|
+
const Oe = fe("quick"), Ae = ((ke = o.initialQuickCommands) == null ? void 0 : ke.call(o)) ?? [];
|
|
149
|
+
a.value = (Oe ?? Ae).filter((e) => typeof e == "string").slice(0, Le), ue(p, () => ne("view", { ...p, paused: !1 }), { deep: !0 });
|
|
150
|
+
const De = "vuesp-serial", B = "sessions", J = () => {
|
|
151
|
+
var t, n;
|
|
152
|
+
const e = (t = o.storageKey) == null ? void 0 : t.call(o);
|
|
153
|
+
return (n = o.session) != null && n.call(o) && e ? `${e}:session` : null;
|
|
154
|
+
}, re = () => new Promise((e, t) => {
|
|
155
|
+
const n = indexedDB.open(De, 1);
|
|
156
|
+
n.onupgradeneeded = () => {
|
|
157
|
+
n.result.objectStoreNames.contains(B) || n.result.createObjectStore(B);
|
|
158
|
+
}, n.onsuccess = () => e(n.result), n.onerror = () => t(n.error);
|
|
159
|
+
}), Be = async (e) => {
|
|
160
|
+
if (typeof indexedDB > "u") return null;
|
|
161
|
+
const t = await re();
|
|
162
|
+
return new Promise((n, s) => {
|
|
163
|
+
const c = t.transaction(B, "readonly").objectStore(B).get(e);
|
|
164
|
+
c.onsuccess = () => n(c.result ?? null), c.onerror = () => s(c.error);
|
|
165
|
+
});
|
|
166
|
+
}, Fe = async (e, t) => {
|
|
167
|
+
if (typeof indexedDB > "u") return;
|
|
168
|
+
const n = await re();
|
|
169
|
+
await new Promise((s, c) => {
|
|
170
|
+
const f = n.transaction(B, "readwrite").objectStore(B).put(t, e);
|
|
171
|
+
f.onsuccess = () => s(), f.onerror = () => c(f.error);
|
|
172
|
+
});
|
|
173
|
+
}, Ie = async (e) => {
|
|
174
|
+
if (typeof indexedDB > "u") return;
|
|
175
|
+
const t = await re();
|
|
176
|
+
await new Promise((n, s) => {
|
|
177
|
+
const c = t.transaction(B, "readwrite").objectStore(B).delete(e);
|
|
178
|
+
c.onsuccess = () => n(), c.onerror = () => s(c.error);
|
|
179
|
+
});
|
|
180
|
+
}, je = () => {
|
|
181
|
+
const e = J();
|
|
182
|
+
e && ($ && clearTimeout($), $ = setTimeout(() => {
|
|
183
|
+
const t = {
|
|
184
|
+
lines: u.value.map((n) => ({ ...n, data: n.data ? [...n.data] : void 0 })),
|
|
185
|
+
rxBytes: w.value,
|
|
186
|
+
txBytes: b.value
|
|
187
|
+
};
|
|
188
|
+
Fe(e, t).catch(() => {
|
|
189
|
+
});
|
|
190
|
+
}, 800));
|
|
191
|
+
}, Ue = async () => {
|
|
192
|
+
var t;
|
|
193
|
+
const e = J();
|
|
194
|
+
if (!(!e || u.value.length))
|
|
195
|
+
try {
|
|
196
|
+
const n = await Be(e);
|
|
197
|
+
if (!((t = n == null ? void 0 : n.lines) != null && t.length)) return;
|
|
198
|
+
u.value = n.lines, S = n.lines.reduce((s, c) => Math.max(s, c.id), 0), w.value = n.rxBytes ?? 0, b.value = n.txBytes ?? 0, v.value = !0;
|
|
199
|
+
} catch {
|
|
200
|
+
}
|
|
201
|
+
}, se = (e, t) => {
|
|
202
|
+
const n = vt(t, p.encoding);
|
|
152
203
|
u.value.push({
|
|
153
|
-
id: ++
|
|
204
|
+
id: ++S,
|
|
154
205
|
dir: e,
|
|
155
|
-
at: (/* @__PURE__ */ new Date()).toLocaleTimeString(
|
|
156
|
-
text:
|
|
157
|
-
hex:
|
|
206
|
+
at: (/* @__PURE__ */ new Date()).toLocaleTimeString(o.locale() === "ru" ? "ru-RU" : "en-GB", { hour12: !1 }),
|
|
207
|
+
text: p.framing === "gap" ? n.replace(/[\r\n]+/g, " ") : n,
|
|
208
|
+
hex: yt(t),
|
|
158
209
|
bytes: t.length,
|
|
159
210
|
// Keep a bounded copy for the binary view and byte inspector.
|
|
160
211
|
data: Array.from(t.slice(0, 1024))
|
|
161
212
|
});
|
|
162
|
-
const
|
|
163
|
-
u.value.length >
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
-
},
|
|
167
|
-
if (
|
|
168
|
-
const e = new Uint8Array(
|
|
169
|
-
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
const e =
|
|
173
|
-
|
|
174
|
-
},
|
|
175
|
-
for (const t of e)
|
|
176
|
-
if (
|
|
213
|
+
const s = o.maxLines();
|
|
214
|
+
u.value.length > s && u.value.splice(0, u.value.length - s), je();
|
|
215
|
+
}, z = () => {
|
|
216
|
+
A && (clearTimeout(A), A = null);
|
|
217
|
+
}, he = () => {
|
|
218
|
+
if (z(), !g.length) return;
|
|
219
|
+
const e = new Uint8Array(g);
|
|
220
|
+
g = [], se("rx", e);
|
|
221
|
+
}, Me = () => {
|
|
222
|
+
z();
|
|
223
|
+
const e = p.framing === "gap" ? Math.max(5, p.gapMs) : ut;
|
|
224
|
+
A = setTimeout(he, e);
|
|
225
|
+
}, ve = (e) => {
|
|
226
|
+
for (const t of e) g.push(t);
|
|
227
|
+
if (p.framing === "line") {
|
|
177
228
|
let t = 0;
|
|
178
|
-
for (let
|
|
179
|
-
const
|
|
180
|
-
if (
|
|
181
|
-
const
|
|
182
|
-
|
|
229
|
+
for (let n = 0; n < g.length; n++) {
|
|
230
|
+
const s = g[n];
|
|
231
|
+
if (s !== 10 && s !== 13) continue;
|
|
232
|
+
const c = g.slice(t, n);
|
|
233
|
+
c.length && se("rx", new Uint8Array(c)), s === 13 && g[n + 1] === 10 && n++, t = n + 1;
|
|
183
234
|
}
|
|
184
|
-
t && (
|
|
235
|
+
t && (g = g.slice(t));
|
|
185
236
|
}
|
|
186
|
-
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
},
|
|
190
|
-
var
|
|
191
|
-
const t = (
|
|
192
|
-
t && (
|
|
193
|
-
w.value === e && (
|
|
237
|
+
g.length >= it ? he() : Me();
|
|
238
|
+
}, q = () => {
|
|
239
|
+
V && clearTimeout(V), V = null, l.value = !1;
|
|
240
|
+
}, Ce = (e) => {
|
|
241
|
+
var n;
|
|
242
|
+
const t = (n = o.noReplyHint) == null ? void 0 : n.call(o);
|
|
243
|
+
t && (q(), V = setTimeout(() => {
|
|
244
|
+
w.value === e && (l.value = !0);
|
|
194
245
|
}, t.delay ?? 1500));
|
|
195
|
-
},
|
|
246
|
+
}, $e = (e) => {
|
|
196
247
|
if (e != null && e.length) {
|
|
197
|
-
if (
|
|
198
|
-
for (const t of e)
|
|
199
|
-
|
|
248
|
+
if (l.value && q(), w.value += e.length, p.paused) {
|
|
249
|
+
for (const t of e) E.push(t);
|
|
250
|
+
E.length > Re && E.splice(0, E.length - Re);
|
|
200
251
|
return;
|
|
201
252
|
}
|
|
202
|
-
|
|
253
|
+
ve(e);
|
|
203
254
|
}
|
|
204
|
-
},
|
|
205
|
-
|
|
255
|
+
}, _e = () => {
|
|
256
|
+
D == null || D(), D = o.transport().subscribe($e);
|
|
206
257
|
};
|
|
207
|
-
|
|
208
|
-
() =>
|
|
258
|
+
ue(
|
|
259
|
+
() => p.paused,
|
|
209
260
|
(e) => {
|
|
210
|
-
if (e || !
|
|
211
|
-
const t = new Uint8Array(
|
|
212
|
-
|
|
261
|
+
if (e || !E.length) return;
|
|
262
|
+
const t = new Uint8Array(E);
|
|
263
|
+
E = [], ve(t);
|
|
213
264
|
}
|
|
214
265
|
);
|
|
215
|
-
const
|
|
216
|
-
const t = await
|
|
217
|
-
return t && (
|
|
218
|
-
},
|
|
219
|
-
const e =
|
|
266
|
+
const K = async (e) => {
|
|
267
|
+
const t = await o.transport().send(e);
|
|
268
|
+
return t && (b.value += e.length, se("tx", e)), t;
|
|
269
|
+
}, ae = F(() => i.value.replace(/^0x/i, "").replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "")), qe = F(() => {
|
|
270
|
+
const e = i.value.replace(/0x/gi, "").replace(/[\s,;:]/g, "");
|
|
220
271
|
return e.length > 0 && /[^0-9a-fA-F]/.test(e);
|
|
221
|
-
}),
|
|
222
|
-
const e =
|
|
223
|
-
for (let
|
|
272
|
+
}), ye = F(() => {
|
|
273
|
+
const e = ae.value, t = [];
|
|
274
|
+
for (let n = 0; n + 1 < e.length; n += 2) t.push(parseInt(e.slice(n, n + 2), 16));
|
|
224
275
|
return t;
|
|
225
|
-
}),
|
|
276
|
+
}), ge = F(() => x.value ? qe.value ? o.labels().hexInvalid : ae.value && ae.value.length % 2 ? o.labels().hexOdd : "" : ""), Ke = (e) => {
|
|
277
|
+
const t = new TextEncoder(), n = [];
|
|
278
|
+
let s = "";
|
|
279
|
+
const c = () => {
|
|
280
|
+
s && (n.push(...t.encode(s)), s = "");
|
|
281
|
+
};
|
|
282
|
+
for (let f = 0; f < e.length; f++) {
|
|
283
|
+
const le = e[f];
|
|
284
|
+
if (le !== "\\") {
|
|
285
|
+
s += le;
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
const P = e[f + 1], Ee = e.slice(f + 2, f + 4);
|
|
289
|
+
if ((P === "x" || P === "X") && /^[0-9a-fA-F]{2}$/.test(Ee)) {
|
|
290
|
+
c(), n.push(parseInt(Ee, 16)), f += 3;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
const Te = { r: 13, n: 10, t: 9, 0: 0, "\\": 92 };
|
|
294
|
+
if (P !== void 0 && P in Te) {
|
|
295
|
+
c(), n.push(Te[P]), f += 1;
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
s += le;
|
|
299
|
+
}
|
|
300
|
+
return c(), n;
|
|
301
|
+
}, ce = (e, t) => {
|
|
226
302
|
if (t) {
|
|
227
|
-
const
|
|
228
|
-
if (!
|
|
229
|
-
const
|
|
230
|
-
for (let
|
|
231
|
-
return
|
|
303
|
+
const s = e.replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "");
|
|
304
|
+
if (!s.length || s.length % 2) return [];
|
|
305
|
+
const c = [];
|
|
306
|
+
for (let f = 0; f + 1 < s.length; f += 2) c.push(parseInt(s.slice(f, f + 2), 16));
|
|
307
|
+
return c;
|
|
232
308
|
}
|
|
233
|
-
const
|
|
234
|
-
return (
|
|
235
|
-
},
|
|
236
|
-
if (
|
|
237
|
-
const e =
|
|
238
|
-
!t.length || !await
|
|
239
|
-
},
|
|
240
|
-
const t =
|
|
309
|
+
const n = T.value ? Ke(e) : Array.from(new TextEncoder().encode(e));
|
|
310
|
+
return (I.value === "cr" || I.value === "crlf") && n.push(13), (I.value === "lf" || I.value === "crlf") && n.push(10), n;
|
|
311
|
+
}, Pe = async () => {
|
|
312
|
+
if (x.value && (ge.value || !ye.value.length)) return;
|
|
313
|
+
const e = i.value, t = ce(e, x.value);
|
|
314
|
+
!t.length || !await K(new Uint8Array(t.slice(0, 4096))) || (e.trim() && (y.value = [e, ...y.value.filter((s) => s !== e)].slice(0, 50), m.value = -1), i.value = "");
|
|
315
|
+
}, pe = async (e) => {
|
|
316
|
+
const t = ce(e, !1);
|
|
241
317
|
if (!t.length) return;
|
|
242
|
-
const
|
|
243
|
-
await
|
|
244
|
-
},
|
|
318
|
+
const n = w.value;
|
|
319
|
+
await K(new Uint8Array(t.slice(0, 4096))) && (y.value = [e, ...y.value.filter((c) => c !== e)].slice(0, 50), m.value = -1, N = e, Ce(n));
|
|
320
|
+
}, Qe = async (e) => {
|
|
321
|
+
const t = new Uint8Array(await e.arrayBuffer());
|
|
322
|
+
if (!t.length) return !1;
|
|
323
|
+
const n = 256;
|
|
324
|
+
for (let s = 0; s < t.length; s += n) {
|
|
325
|
+
if (!await K(t.slice(s, s + n))) return !1;
|
|
326
|
+
await new Promise((f) => setTimeout(f, 8));
|
|
327
|
+
}
|
|
328
|
+
return !0;
|
|
329
|
+
}, G = () => {
|
|
330
|
+
H && clearInterval(H), H = null, k.value = !1;
|
|
331
|
+
}, Ve = async () => {
|
|
332
|
+
if (k.value) {
|
|
333
|
+
G();
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const e = ce(i.value, x.value);
|
|
337
|
+
if (!e.length) return;
|
|
338
|
+
const t = new Uint8Array(e.slice(0, 4096));
|
|
339
|
+
await K(t) && (k.value = !0, H = setInterval(() => {
|
|
340
|
+
K(t);
|
|
341
|
+
}, Math.max(50, O.value)));
|
|
342
|
+
}, He = async () => {
|
|
245
343
|
var t;
|
|
246
|
-
const e = (t =
|
|
247
|
-
e != null && e.onAction && (
|
|
248
|
-
},
|
|
344
|
+
const e = (t = o.noReplyHint) == null ? void 0 : t.call(o);
|
|
345
|
+
e != null && e.onAction && (q(), await e.onAction(), (e.resend ?? !0) && N && await pe(N));
|
|
346
|
+
}, Xe = (e) => {
|
|
249
347
|
if (e.key === "ArrowUp") {
|
|
250
|
-
if (!
|
|
251
|
-
e.preventDefault(),
|
|
348
|
+
if (!y.value.length) return;
|
|
349
|
+
e.preventDefault(), m.value = m.value === -1 ? y.value.length - 1 : Math.max(0, m.value - 1), i.value = y.value[m.value] ?? "";
|
|
252
350
|
return;
|
|
253
351
|
}
|
|
254
352
|
if (e.key === "ArrowDown") {
|
|
255
|
-
if (
|
|
256
|
-
e.preventDefault(),
|
|
353
|
+
if (m.value === -1) return;
|
|
354
|
+
e.preventDefault(), m.value++, m.value >= y.value.length ? (m.value = -1, i.value = "") : i.value = y.value[m.value] ?? "";
|
|
257
355
|
return;
|
|
258
356
|
}
|
|
259
|
-
e.key === "Escape" && (
|
|
260
|
-
},
|
|
261
|
-
const e =
|
|
357
|
+
e.key === "Escape" && (i.value = "", m.value = -1);
|
|
358
|
+
}, Je = F(() => {
|
|
359
|
+
const e = U.value.trim().toLowerCase();
|
|
262
360
|
return e ? u.value.filter((t) => t.text.toLowerCase().includes(e) || t.hex.toLowerCase().includes(e)) : u.value;
|
|
263
|
-
}),
|
|
264
|
-
|
|
265
|
-
},
|
|
266
|
-
const t =
|
|
361
|
+
}), ze = (e) => (e.data ?? []).map((t) => t.toString(2).padStart(8, "0")).join(" "), Ge = (e) => M.value === "hex" ? e.hex : M.value === "bin" ? ze(e) : e.text || e.hex, We = F(() => u.value.find((e) => e.id === R.value) ?? null), Ye = (e) => {
|
|
362
|
+
R.value = R.value === e.id ? null : e.id;
|
|
363
|
+
}, Ze = (e) => {
|
|
364
|
+
const t = U.value.trim().toLowerCase();
|
|
267
365
|
if (!t) return [{ text: e, match: !1 }];
|
|
268
|
-
const
|
|
269
|
-
let
|
|
270
|
-
for (;
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
273
|
-
|
|
366
|
+
const n = e.toLowerCase(), s = [];
|
|
367
|
+
let c = 0;
|
|
368
|
+
for (; c < e.length; ) {
|
|
369
|
+
const f = n.indexOf(t, c);
|
|
370
|
+
if (f === -1) break;
|
|
371
|
+
f > c && s.push({ text: e.slice(c, f), match: !1 }), s.push({ text: e.slice(f, f + t.length), match: !0 }), c = f + t.length;
|
|
274
372
|
}
|
|
275
|
-
return
|
|
276
|
-
},
|
|
277
|
-
|
|
373
|
+
return c < e.length && s.push({ text: e.slice(c), match: !1 }), s.length ? s : [{ text: e, match: !1 }];
|
|
374
|
+
}, oe = (e, t) => {
|
|
375
|
+
const n = URL.createObjectURL(t), s = document.createElement("a"), c = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
376
|
+
return s.href = n, s.download = `serial-${c}.${e}`, s.click(), URL.revokeObjectURL(n), !0;
|
|
377
|
+
}, me = () => u.value.map((e) => `${e.at} ${e.dir.toUpperCase()} ${e.text || e.hex}`).join(`
|
|
378
|
+
`), Ne = () => {
|
|
379
|
+
if (!u.value.length) return !1;
|
|
380
|
+
const e = (n) => `"${String(n).replace(/"/g, '""')}"`, t = u.value.map((n) => [n.at, n.dir, n.bytes, e(n.text), e(n.hex)].join(","));
|
|
381
|
+
return oe("csv", new Blob([["time,direction,bytes,text,hex", ...t].join(`
|
|
382
|
+
`)], { type: "text/csv;charset=utf-8" }));
|
|
383
|
+
}, et = () => {
|
|
384
|
+
if (!u.value.length) return !1;
|
|
385
|
+
const e = u.value.map((t) => ({ at: t.at, dir: t.dir, bytes: t.bytes, text: t.text, hex: t.hex }));
|
|
386
|
+
return oe("json", new Blob([JSON.stringify(e, null, 2)], { type: "application/json;charset=utf-8" }));
|
|
387
|
+
}, tt = () => {
|
|
388
|
+
var t;
|
|
389
|
+
const e = [];
|
|
390
|
+
for (const n of u.value)
|
|
391
|
+
n.dir === "rx" && ((t = n.data) != null && t.length) && e.push(...n.data);
|
|
392
|
+
return e.length ? oe("bin", new Blob([new Uint8Array(e)], { type: "application/octet-stream" })) : !1;
|
|
393
|
+
}, xe = async () => {
|
|
278
394
|
if (!u.value.length) return !1;
|
|
279
395
|
try {
|
|
280
|
-
return await navigator.clipboard.writeText(
|
|
281
|
-
|
|
282
|
-
},
|
|
396
|
+
return await navigator.clipboard.writeText(me()), r.value = !0, _ && clearTimeout(_), _ = setTimeout(() => {
|
|
397
|
+
r.value = !1;
|
|
398
|
+
}, ft), !0;
|
|
283
399
|
} catch {
|
|
284
400
|
return !1;
|
|
285
401
|
}
|
|
286
|
-
},
|
|
402
|
+
}, nt = () => {
|
|
287
403
|
if (!u.value.length) return !1;
|
|
288
|
-
const e = new Blob([
|
|
289
|
-
return
|
|
290
|
-
},
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
404
|
+
const e = new Blob([me()], { type: "text/plain;charset=utf-8" }), t = URL.createObjectURL(e), n = document.createElement("a"), s = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
405
|
+
return n.href = t, n.download = `serial-${s}.log`, n.click(), URL.revokeObjectURL(t), !0;
|
|
406
|
+
}, we = () => {
|
|
407
|
+
G(), q(), z();
|
|
408
|
+
const e = J();
|
|
409
|
+
e && Ie(e).catch(() => {
|
|
410
|
+
}), v.value = !1, g = [], E = [], u.value = [], R.value = null, w.value = 0, b.value = 0, L.value = 0, j.value = 0, ee = 0, te = 0, X = performance.now();
|
|
411
|
+
}, rt = (e) => {
|
|
412
|
+
const t = o.labels();
|
|
294
413
|
return e < 1024 ? `${e} ${t.byteShort}` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} ${t.kiloShort}` : `${(e / (1024 * 1024)).toFixed(2)} ${t.megaShort}`;
|
|
295
|
-
},
|
|
296
|
-
const e = performance.now(), t = (e -
|
|
297
|
-
t <= 0 || (
|
|
298
|
-
},
|
|
299
|
-
const e =
|
|
300
|
-
e && (
|
|
301
|
-
},
|
|
302
|
-
|
|
303
|
-
},
|
|
304
|
-
e.ctrlKey && (e.key.toLowerCase() === "l" && (e.preventDefault(),
|
|
414
|
+
}, st = () => {
|
|
415
|
+
const e = performance.now(), t = (e - X) / 1e3;
|
|
416
|
+
t <= 0 || (L.value = Math.max(0, Math.round((w.value - ee) / t)), j.value = Math.max(0, Math.round((b.value - te) / t)), ee = w.value, te = b.value, X = e);
|
|
417
|
+
}, at = () => {
|
|
418
|
+
const e = h.value.trim();
|
|
419
|
+
e && (a.value.includes(e) || (a.value = [...a.value, e].slice(0, Le)), h.value = "", ne("quick", a.value));
|
|
420
|
+
}, ct = (e) => {
|
|
421
|
+
a.value = a.value.filter((t) => t !== e), ne("quick", a.value);
|
|
422
|
+
}, Se = (e) => {
|
|
423
|
+
e.ctrlKey && (e.key.toLowerCase() === "l" && (e.preventDefault(), we()), e.shiftKey && e.key.toLowerCase() === "c" && (e.preventDefault(), xe()));
|
|
305
424
|
};
|
|
306
|
-
return
|
|
307
|
-
|
|
308
|
-
}),
|
|
309
|
-
|
|
425
|
+
return ot(() => {
|
|
426
|
+
_e(), J() && Ue(), X = performance.now(), C = setInterval(st, 1e3), window.addEventListener("keydown", Se);
|
|
427
|
+
}), lt(() => {
|
|
428
|
+
D == null || D(), D = null, G(), q(), z(), C && clearInterval(C), _ && clearTimeout(_), $ && clearTimeout($), window.removeEventListener("keydown", Se);
|
|
310
429
|
}), {
|
|
311
430
|
lines: u,
|
|
312
|
-
visibleLines:
|
|
313
|
-
view:
|
|
431
|
+
visibleLines: Je,
|
|
432
|
+
view: p,
|
|
314
433
|
rxBytes: w,
|
|
315
|
-
txBytes:
|
|
316
|
-
rxRate:
|
|
317
|
-
txRate:
|
|
318
|
-
input:
|
|
319
|
-
hexSend:
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
434
|
+
txBytes: b,
|
|
435
|
+
rxRate: L,
|
|
436
|
+
txRate: j,
|
|
437
|
+
input: i,
|
|
438
|
+
hexSend: x,
|
|
439
|
+
escape: T,
|
|
440
|
+
repeat: k,
|
|
441
|
+
repeatMs: O,
|
|
442
|
+
sendFile: Qe,
|
|
443
|
+
toggleRepeat: Ve,
|
|
444
|
+
stopRepeat: G,
|
|
445
|
+
lineEnding: I,
|
|
446
|
+
history: y,
|
|
447
|
+
filter: U,
|
|
448
|
+
mode: M,
|
|
449
|
+
selectedId: R,
|
|
450
|
+
selectedLine: We,
|
|
451
|
+
selectLine: Ye,
|
|
452
|
+
showTime: W,
|
|
453
|
+
wrapLines: Y,
|
|
454
|
+
autoScroll: Z,
|
|
455
|
+
copied: r,
|
|
456
|
+
showNoReply: l,
|
|
457
|
+
quickCommands: a,
|
|
458
|
+
quickInput: h,
|
|
459
|
+
hexBytes: ye,
|
|
460
|
+
hexError: ge,
|
|
461
|
+
sendText: Pe,
|
|
462
|
+
sendQuick: pe,
|
|
463
|
+
onInputKeydown: Xe,
|
|
464
|
+
lineContent: Ge,
|
|
465
|
+
lineSegments: Ze,
|
|
466
|
+
copyLog: xe,
|
|
467
|
+
downloadLog: nt,
|
|
468
|
+
exportCsv: Ne,
|
|
469
|
+
exportJson: et,
|
|
470
|
+
exportRxBin: tt,
|
|
471
|
+
sessionRestored: v,
|
|
472
|
+
clearLog: we,
|
|
473
|
+
formatBytes: rt,
|
|
474
|
+
addQuick: at,
|
|
475
|
+
removeQuick: ct,
|
|
476
|
+
applyHintAction: He
|
|
348
477
|
};
|
|
349
478
|
}
|
|
350
479
|
export {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
480
|
+
St as useDialog,
|
|
481
|
+
bt as useFocusTrap,
|
|
482
|
+
pt as useForm,
|
|
483
|
+
mt as useSerialConsole,
|
|
484
|
+
kt as useSwipeDown
|
|
356
485
|
};
|