vuesp-components 5.2.2 → 5.3.0

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.
@@ -0,0 +1,41 @@
1
+ import { ISerialConsoleProps } from './types';
2
+ declare function __VLS_template(): {
3
+ attrs: Partial<{}>;
4
+ slots: {
5
+ 'header-actions'?(_: {}): any;
6
+ settings?(_: {}): any;
7
+ };
8
+ refs: {
9
+ logEl: HTMLDivElement;
10
+ };
11
+ rootEl: any;
12
+ };
13
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
14
+ declare const __VLS_component: import('vue').DefineComponent<ISerialConsoleProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
15
+ clear: () => any;
16
+ disconnect: () => any;
17
+ send: (bytes: Uint8Array<ArrayBufferLike>) => any;
18
+ connect: () => any;
19
+ }, string, import('vue').PublicProps, Readonly<ISerialConsoleProps> & Readonly<{
20
+ onClear?: (() => any) | undefined;
21
+ onDisconnect?: (() => any) | undefined;
22
+ onSend?: ((bytes: Uint8Array<ArrayBufferLike>) => any) | undefined;
23
+ onConnect?: (() => any) | undefined;
24
+ }>, {
25
+ error: string;
26
+ compact: boolean;
27
+ status: import('./types').TSerialConsoleStatus;
28
+ locale: import('./types').TSerialConsoleLocale;
29
+ portLabel: string;
30
+ maxLines: number;
31
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
32
+ logEl: HTMLDivElement;
33
+ }, any>;
34
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
35
+ export default _default;
36
+ type __VLS_WithTemplateSlots<T, S> = T & {
37
+ new (): {
38
+ $slots: S;
39
+ };
40
+ };
41
+ //# sourceMappingURL=SerialConsole.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SerialConsole.vue.d.ts","sourceRoot":"","sources":["../../../src/components/serial/SerialConsole.vue"],"names":[],"mappings":"AAoQA;AAkcA,OAAO,KAAK,EAGV,mBAAmB,EAIpB,MAAM,2BAA2B,CAAC;AA2LnC,iBAAS,cAAc;WAigCT,OAAO,IAA6B;;kCAZZ,GAAG;0BACV,GAAG;;;;;;EAgBjC;AAoED,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;OAUnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAapG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { default as SerialConsole } from './SerialConsole.vue';
2
+ export { SerialConsole };
3
+ export * from './types';
4
+ export { serialConsoleLabels } from './labels';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/serial/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,uCAAuC,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { ISerialConsoleLabels, TSerialConsoleLocale } from './types';
2
+ export declare const serialConsoleLabels: (locale: TSerialConsoleLocale) => ISerialConsoleLabels;
3
+ //# sourceMappingURL=labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../../src/components/serial/labels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AA4I5F,eAAO,MAAM,mBAAmB,GAAI,QAAQ,oBAAoB,KAAG,oBAC1B,CAAC"}
@@ -0,0 +1,123 @@
1
+ export type TSerialConsoleStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
2
+ export type TSerialConsoleDirection = 'rx' | 'tx';
3
+ export type TSerialConsoleEncoding = 'utf8' | 'cp1251';
4
+ export type TSerialConsoleFraming = 'line' | 'gap';
5
+ export type TSerialConsoleLineEnding = 'none' | 'cr' | 'lf' | 'crlf';
6
+ export type TSerialConsoleLocale = 'ru' | 'en';
7
+ export interface ISelectItem<T> {
8
+ name: string;
9
+ value: T;
10
+ }
11
+ export interface ISerialConsoleLine {
12
+ id: number;
13
+ dir: TSerialConsoleDirection;
14
+ at: string;
15
+ text: string;
16
+ hex: string;
17
+ bytes: number;
18
+ }
19
+ export interface ISerialConsoleView {
20
+ encoding: TSerialConsoleEncoding;
21
+ framing: TSerialConsoleFraming;
22
+ gapMs: number;
23
+ paused: boolean;
24
+ }
25
+ export interface ISerialConsoleTransport {
26
+ start: () => void | Promise<void>;
27
+ stop: () => void | Promise<void>;
28
+ send: (bytes: Uint8Array) => Promise<boolean>;
29
+ subscribe: (onData: (bytes: Uint8Array) => void) => () => void;
30
+ }
31
+ export interface ISerialConsoleCapabilities {
32
+ connection?: boolean;
33
+ pause?: boolean;
34
+ framing?: boolean;
35
+ encoding?: boolean;
36
+ search?: boolean;
37
+ counters?: boolean;
38
+ quickCommands?: boolean;
39
+ download?: boolean;
40
+ history?: boolean;
41
+ }
42
+ export interface ISerialConsoleLabels {
43
+ connect: string;
44
+ disconnect: string;
45
+ connected: string;
46
+ connecting: string;
47
+ disconnected: string;
48
+ error: string;
49
+ noPort: string;
50
+ usb: string;
51
+ settings: string;
52
+ hexView: string;
53
+ showTime: string;
54
+ wrap: string;
55
+ autoscroll: string;
56
+ lines: string;
57
+ pause: string;
58
+ resume: string;
59
+ paused: string;
60
+ search: string;
61
+ searchPlaceholder: string;
62
+ noMatches: string;
63
+ clear: string;
64
+ copy: string;
65
+ copied: string;
66
+ download: string;
67
+ empty: string;
68
+ waiting: string;
69
+ follow: string;
70
+ input: string;
71
+ placeholder: string;
72
+ send: string;
73
+ quickCommands: string;
74
+ quickAdd: string;
75
+ quickPlaceholder: string;
76
+ quickAddButton: string;
77
+ quickRemove: string;
78
+ quickEmpty: string;
79
+ textMode: string;
80
+ hexMode: string;
81
+ hexLabel: string;
82
+ hexPlaceholder: string;
83
+ hexHint: string;
84
+ hexInvalid: string;
85
+ hexOdd: string;
86
+ bytes: string;
87
+ lineEnding: string;
88
+ lineNone: string;
89
+ lineCr: string;
90
+ lineLf: string;
91
+ lineCrlf: string;
92
+ encoding: string;
93
+ encodingUtf8: string;
94
+ encodingCp1251: string;
95
+ framing: string;
96
+ framingLine: string;
97
+ framingGap: string;
98
+ framingHint: string;
99
+ gap: string;
100
+ ms: string;
101
+ rx: string;
102
+ tx: string;
103
+ byteShort: string;
104
+ kiloShort: string;
105
+ megaShort: string;
106
+ perSecond: string;
107
+ shortcuts: string;
108
+ }
109
+ export interface ISerialConsoleProps {
110
+ status?: TSerialConsoleStatus;
111
+ error?: string;
112
+ portLabel?: string;
113
+ transport: ISerialConsoleTransport;
114
+ locale?: TSerialConsoleLocale;
115
+ labels?: Partial<ISerialConsoleLabels>;
116
+ maxLines?: number;
117
+ capabilities?: ISerialConsoleCapabilities;
118
+ initialQuickCommands?: string[];
119
+ initialLineEnding?: TSerialConsoleLineEnding;
120
+ storageKey?: string;
121
+ compact?: boolean;
122
+ }
123
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/serial/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,CAAC;AACzF,MAAM,MAAM,uBAAuB,GAAG,IAAI,GAAG,IAAI,CAAC;AAClD,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,QAAQ,CAAC;AACvD,MAAM,M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AAM,EAAE,CAAC;IAChC,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -2,4 +2,6 @@ export { useForm } from './useForms';
2
2
  export { useDialog } from './useDialog';
3
3
  export { useSwipeDown } from './useSwipeDown';
4
4
  export { useFocusTrap } from './useFocusTrap';
5
+ export { useSerialConsole } from './useSerialConsole';
6
+ export type { ISerialConsoleSegment, IUseSerialConsoleOptions } from './useSerialConsole';
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composables/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composables/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,118 +1,333 @@
1
- import { ref as w, reactive as b, watch as B, computed as D } from "vue";
2
- import { u as T, b as W, a as $ } from "../useDialog-Buvn63AR.js";
3
- function I(V) {
4
- const { validationSchema: l, initialValues: v = {} } = V, g = typeof l == "function", m = w(
5
- g ? l(v) : l
6
- ), y = w(!0), E = (t) => {
7
- m.value = t;
8
- const e = Object.keys(t), o = Object.keys(c);
9
- e.forEach((s) => {
10
- s in c || (c[s] = v[s] ?? "", r[s] = [], u[s] = !1, h[s] = !1);
11
- }), o.forEach((s) => {
12
- e.includes(s) || (delete c[s], delete r[s], delete u[s], delete h[s]);
13
- }), j(), d();
14
- }, c = b({}), r = b({}), u = b({}), h = b({}), p = /* @__PURE__ */ new Map(), R = () => {
15
- Object.keys(m.value).forEach((t) => {
16
- c[t] = v[t] ?? "", r[t] = [], u[t] = !1, h[t] = !1;
17
- }), y.value = !0;
18
- }, i = () => g ? l(c) : m.value, F = (t, e) => {
19
- const s = i()[t] || [], n = [];
20
- for (const a of s) {
21
- const f = a(e, c);
22
- f !== !0 && n.push(f);
1
+ import { ref as h, reactive as C, watch as P, computed as D, onMounted as Ee, onBeforeUnmount as Fe } from "vue";
2
+ import { u as Be, b as _e, a as Ke } from "../useDialog-Buvn63AR.js";
3
+ function Ue(o) {
4
+ const { validationSchema: i, initialValues: v = {} } = o, F = typeof i == "function", b = h(
5
+ F ? i(v) : i
6
+ ), T = h(!0), R = (n) => {
7
+ b.value = n;
8
+ const r = Object.keys(n), f = Object.keys(c);
9
+ r.forEach((s) => {
10
+ s in c || (c[s] = v[s] ?? "", y[s] = [], m[s] = !1, g[s] = !1);
11
+ }), f.forEach((s) => {
12
+ r.includes(s) || (delete c[s], delete y[s], delete m[s], delete g[s]);
13
+ }), $(), O();
14
+ }, c = C({}), y = C({}), m = C({}), g = C({}), d = /* @__PURE__ */ new Map(), I = () => {
15
+ Object.keys(b.value).forEach((n) => {
16
+ c[n] = v[n] ?? "", y[n] = [], m[n] = !1, g[n] = !1;
17
+ }), T.value = !0;
18
+ }, E = () => F ? i(c) : b.value, M = (n, r) => {
19
+ const s = E()[n] || [], u = [];
20
+ for (const p of s) {
21
+ const L = p(r, c);
22
+ L !== !0 && u.push(L);
23
23
  }
24
- return r[t] = n, n.length === 0;
25
- }, O = (t, e) => {
26
- const o = i();
27
- if (!o[t]) return;
28
- F(t, e);
29
- const s = p.get(t);
30
- s && s.forEach((n) => {
31
- o[n] && F(n, c[n]);
32
- }), d();
33
- }, j = () => {
34
- p.clear();
35
- const t = i();
36
- Object.keys(t).forEach((e) => {
37
- (t[e] || []).forEach((s) => {
24
+ return y[n] = u, u.length === 0;
25
+ }, j = (n, r) => {
26
+ const f = E();
27
+ if (!f[n]) return;
28
+ M(n, r);
29
+ const s = d.get(n);
30
+ s && s.forEach((u) => {
31
+ f[u] && M(u, c[u]);
32
+ }), O();
33
+ }, $ = () => {
34
+ d.clear();
35
+ const n = E();
36
+ Object.keys(n).forEach((r) => {
37
+ (n[r] || []).forEach((s) => {
38
38
  if (typeof s == "function" && s.name === "sameAs") {
39
- const n = s.toString().match(/['"](.*?)['"]/);
40
- if (n) {
41
- const a = n[1];
42
- p.has(a) || p.set(a, /* @__PURE__ */ new Set()), p.get(a).add(e);
39
+ const u = s.toString().match(/['"](.*?)['"]/);
40
+ if (u) {
41
+ const p = u[1];
42
+ d.has(p) || d.set(p, /* @__PURE__ */ new Set()), d.get(p).add(r);
43
43
  }
44
44
  }
45
45
  });
46
46
  });
47
- }, d = () => {
48
- const t = i();
49
- let e = !0;
50
- return Object.keys(t).forEach((o) => {
51
- F(o, c[o]) || (e = !1);
52
- }), y.value = e, e;
53
- }, x = (t, e = {}) => {
54
- i()[t] || console.warn(`Field "${t}" not found in current validationSchema`);
47
+ }, O = () => {
48
+ const n = E();
49
+ let r = !0;
50
+ return Object.keys(n).forEach((f) => {
51
+ M(f, c[f]) || (r = !1);
52
+ }), T.value = r, r;
53
+ }, k = (n, r = {}) => {
54
+ E()[n] || console.warn(`Field "${n}" not found in current validationSchema`);
55
55
  const s = D({
56
- get: () => c[t],
57
- set: (a) => {
58
- c[t] = a, h[t] = !0, O(t, a);
56
+ get: () => c[n],
57
+ set: (p) => {
58
+ c[n] = p, g[n] = !0, j(n, p);
59
59
  }
60
- }), n = D(() => {
61
- var k;
62
- const a = {
63
- errors: r[t] || [],
64
- touched: u[t] || !1,
65
- dirty: h[t] || !1
66
- }, f = {
67
- message: (k = r[t]) == null ? void 0 : k[0],
68
- onInput: (S) => {
69
- const z = S.target;
70
- s.value = z.value;
60
+ }), u = D(() => {
61
+ var A;
62
+ const p = {
63
+ errors: y[n] || [],
64
+ touched: m[n] || !1,
65
+ dirty: g[n] || !1
66
+ }, L = {
67
+ message: (A = y[n]) == null ? void 0 : A[0],
68
+ onInput: (w) => {
69
+ const B = w.target;
70
+ s.value = B.value;
71
71
  },
72
72
  onBlur: () => {
73
- u[t] = !0, O(t, c[t]);
73
+ m[n] = !0, j(n, c[n]);
74
74
  }
75
75
  };
76
- if (e.props) {
77
- const S = e.props(a);
78
- return { ...f, ...S };
76
+ if (r.props) {
77
+ const w = r.props(p);
78
+ return { ...L, ...w };
79
79
  }
80
- return f;
80
+ return L;
81
81
  });
82
- return [s, n];
83
- }, A = (t) => async (e) => {
84
- e && e.preventDefault();
85
- const o = i();
86
- Object.keys(o).forEach((n) => {
87
- u[n] = !0;
88
- }), d() && await t(c);
82
+ return [s, u];
83
+ }, U = (n) => async (r) => {
84
+ r && r.preventDefault();
85
+ const f = E();
86
+ Object.keys(f).forEach((u) => {
87
+ m[u] = !0;
88
+ }), O() && await n(c);
89
89
  }, K = () => {
90
- const t = i();
91
- Object.keys(t).forEach((e) => {
92
- c[e] = v[e] || "", r[e] = [], u[e] = !1, h[e] = !1;
93
- }), y.value = !0;
90
+ const n = E();
91
+ Object.keys(n).forEach((r) => {
92
+ c[r] = v[r] || "", y[r] = [], m[r] = !1, g[r] = !1;
93
+ }), T.value = !0;
94
94
  };
95
- return R(), j(), g && B(
95
+ return I(), $(), F && P(
96
96
  () => c,
97
97
  () => {
98
- const t = l(c), e = m.value, o = Object.keys(t), s = Object.keys(e);
99
- (o.length !== s.length || o.some((n) => !s.includes(n))) && E(t);
98
+ const n = i(c), r = b.value, f = Object.keys(n), s = Object.keys(r);
99
+ (f.length !== s.length || f.some((u) => !s.includes(u))) && R(n);
100
100
  },
101
101
  { deep: !0 }
102
102
  ), {
103
103
  values: c,
104
- errors: r,
105
- defineField: x,
106
- handleSubmit: A,
104
+ errors: y,
105
+ defineField: k,
106
+ handleSubmit: U,
107
107
  resetForm: K,
108
- validate: d,
109
- updateSchema: E,
110
- isValid: y
108
+ validate: O,
109
+ updateSchema: R,
110
+ isValid: T
111
+ };
112
+ }
113
+ const Le = 150, Te = 4096, se = 256 * 1024, ce = 12, Oe = 1200, Ae = { utf8: "utf-8", cp1251: "windows-1251" }, De = {
114
+ encoding: "utf8",
115
+ framing: "line",
116
+ gapMs: 25,
117
+ paused: !1
118
+ }, Re = (o, i) => (
119
+ // eslint-disable-next-line no-control-regex
120
+ new TextDecoder(Ae[i]).decode(o).replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g, ".")
121
+ ), Ie = (o) => Array.from(o, (i) => i.toString(16).padStart(2, "0")).join(" ");
122
+ function Ce(o) {
123
+ var re, ae;
124
+ const i = h([]), v = C({ ...De }), F = h(0), b = h(0), T = h(0), R = h(0), c = h(""), y = h(!1), m = h(((re = o.initialLineEnding) == null ? void 0 : re.call(o)) ?? "crlf"), g = h([]), d = h(-1), I = h(""), E = h(!1), M = h(!0), j = h(!0), $ = h(!0), O = h(!1), k = h([]), U = h("");
125
+ let K = 0, n = [], r = [], f = null, s = null, u = null, p = 0, L = 0, A = 0, w = null;
126
+ const B = (e) => {
127
+ var a;
128
+ const t = (a = o.storageKey) == null ? void 0 : a.call(o);
129
+ return t ? `${t}:${e}` : null;
130
+ }, X = (e) => {
131
+ const t = B(e);
132
+ if (!t || typeof localStorage > "u") return null;
133
+ try {
134
+ const a = localStorage.getItem(t);
135
+ return a ? JSON.parse(a) : null;
136
+ } catch {
137
+ return null;
138
+ }
139
+ }, V = (e, t) => {
140
+ const a = B(e);
141
+ if (!(!a || typeof localStorage > "u"))
142
+ try {
143
+ localStorage.setItem(a, JSON.stringify(t));
144
+ } catch {
145
+ }
146
+ }, z = X("view");
147
+ z && Object.assign(v, z, { paused: !1 }), v.paused = !1;
148
+ const le = X("quick"), oe = ((ae = o.initialQuickCommands) == null ? void 0 : ae.call(o)) ?? [];
149
+ k.value = (le ?? oe).filter((e) => typeof e == "string").slice(0, ce), P(v, () => V("view", { ...v, paused: !1 }), { deep: !0 });
150
+ const q = (e, t) => {
151
+ const a = Re(t, v.encoding);
152
+ i.value.push({
153
+ id: ++K,
154
+ dir: e,
155
+ at: (/* @__PURE__ */ new Date()).toLocaleTimeString(o.locale() === "ru" ? "ru-RU" : "en-GB", { hour12: !1 }),
156
+ text: v.framing === "gap" ? a.replace(/[\r\n]+/g, " ") : a,
157
+ hex: Ie(t),
158
+ bytes: t.length
159
+ });
160
+ const l = o.maxLines();
161
+ i.value.length > l && i.value.splice(0, i.value.length - l);
162
+ }, _ = () => {
163
+ f && (clearTimeout(f), f = null);
164
+ }, G = () => {
165
+ if (_(), !n.length) return;
166
+ const e = new Uint8Array(n);
167
+ n = [], q("rx", e);
168
+ }, ue = () => {
169
+ _();
170
+ const e = v.framing === "gap" ? Math.max(5, v.gapMs) : Le;
171
+ f = setTimeout(G, e);
172
+ }, J = (e) => {
173
+ for (const t of e) n.push(t);
174
+ if (v.framing === "line") {
175
+ let t = 0;
176
+ for (let a = 0; a < n.length; a++) {
177
+ const l = n[a];
178
+ if (l !== 10 && l !== 13) continue;
179
+ const x = n.slice(t, a);
180
+ x.length && q("rx", new Uint8Array(x)), l === 13 && n[a + 1] === 10 && a++, t = a + 1;
181
+ }
182
+ t && (n = n.slice(t));
183
+ }
184
+ n.length >= Te ? G() : ue();
185
+ }, ie = (e) => {
186
+ if (e != null && e.length) {
187
+ if (F.value += e.length, v.paused) {
188
+ for (const t of e) r.push(t);
189
+ r.length > se && r.splice(0, r.length - se);
190
+ return;
191
+ }
192
+ J(e);
193
+ }
194
+ }, fe = () => {
195
+ w == null || w(), w = o.transport().subscribe(ie);
196
+ };
197
+ P(
198
+ () => v.paused,
199
+ (e) => {
200
+ if (e || !r.length) return;
201
+ const t = new Uint8Array(r);
202
+ r = [], J(t);
203
+ }
204
+ );
205
+ const W = async (e) => {
206
+ const t = await o.transport().send(e);
207
+ return t && (b.value += e.length, q("tx", e)), t;
208
+ }, Q = D(() => c.value.replace(/^0x/i, "").replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "")), he = D(() => {
209
+ const e = c.value.replace(/0x/gi, "").replace(/[\s,;:]/g, "");
210
+ return e.length > 0 && /[^0-9a-fA-F]/.test(e);
211
+ }), H = D(() => {
212
+ const e = Q.value, t = [];
213
+ for (let a = 0; a + 1 < e.length; a += 2) t.push(parseInt(e.slice(a, a + 2), 16));
214
+ return t;
215
+ }), Y = D(() => y.value ? he.value ? o.labels().hexInvalid : Q.value && Q.value.length % 2 ? o.labels().hexOdd : "" : ""), Z = (e, t) => {
216
+ if (t) {
217
+ const l = e.replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "");
218
+ if (!l.length || l.length % 2) return [];
219
+ const x = [];
220
+ for (let S = 0; S + 1 < l.length; S += 2) x.push(parseInt(l.slice(S, S + 2), 16));
221
+ return x;
222
+ }
223
+ const a = Array.from(new TextEncoder().encode(e));
224
+ return (m.value === "cr" || m.value === "crlf") && a.push(13), (m.value === "lf" || m.value === "crlf") && a.push(10), a;
225
+ }, de = async () => {
226
+ if (y.value && (Y.value || !H.value.length)) return;
227
+ const e = c.value, t = Z(e, y.value);
228
+ !t.length || !await W(new Uint8Array(t.slice(0, 4096))) || (e.trim() && (g.value = [e, ...g.value.filter((l) => l !== e)].slice(0, 50), d.value = -1), c.value = "");
229
+ }, ve = async (e) => {
230
+ const t = Z(e, !1);
231
+ !t.length || !await W(new Uint8Array(t.slice(0, 4096))) || (g.value = [e, ...g.value.filter((l) => l !== e)].slice(0, 50), d.value = -1);
232
+ }, ge = (e) => {
233
+ if (e.key === "ArrowUp") {
234
+ if (!g.value.length) return;
235
+ e.preventDefault(), d.value = d.value === -1 ? g.value.length - 1 : Math.max(0, d.value - 1), c.value = g.value[d.value] ?? "";
236
+ return;
237
+ }
238
+ if (e.key === "ArrowDown") {
239
+ if (d.value === -1) return;
240
+ e.preventDefault(), d.value++, d.value >= g.value.length ? (d.value = -1, c.value = "") : c.value = g.value[d.value] ?? "";
241
+ return;
242
+ }
243
+ e.key === "Escape" && (c.value = "", d.value = -1);
244
+ }, pe = D(() => {
245
+ const e = I.value.trim().toLowerCase();
246
+ return e ? i.value.filter((t) => t.text.toLowerCase().includes(e) || t.hex.toLowerCase().includes(e)) : i.value;
247
+ }), ye = (e) => E.value ? e.hex : e.text || e.hex, me = (e) => {
248
+ const t = I.value.trim().toLowerCase();
249
+ if (!t) return [{ text: e, match: !1 }];
250
+ const a = e.toLowerCase(), l = [];
251
+ let x = 0;
252
+ for (; x < e.length; ) {
253
+ const S = a.indexOf(t, x);
254
+ if (S === -1) break;
255
+ S > x && l.push({ text: e.slice(x, S), match: !1 }), l.push({ text: e.slice(S, S + t.length), match: !0 }), x = S + t.length;
256
+ }
257
+ return x < e.length && l.push({ text: e.slice(x), match: !1 }), l.length ? l : [{ text: e, match: !1 }];
258
+ }, N = () => i.value.map((e) => `${e.at} ${e.dir.toUpperCase()} ${e.text || e.hex}`).join(`
259
+ `), ee = async () => {
260
+ if (!i.value.length) return !1;
261
+ try {
262
+ return await navigator.clipboard.writeText(N()), O.value = !0, u && clearTimeout(u), u = setTimeout(() => {
263
+ O.value = !1;
264
+ }, Oe), !0;
265
+ } catch {
266
+ return !1;
267
+ }
268
+ }, xe = () => {
269
+ if (!i.value.length) return !1;
270
+ const e = new Blob([N()], { type: "text/plain;charset=utf-8" }), t = URL.createObjectURL(e), a = document.createElement("a"), l = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
271
+ return a.href = t, a.download = `serial-${l}.log`, a.click(), URL.revokeObjectURL(t), !0;
272
+ }, te = () => {
273
+ _(), n = [], r = [], i.value = [], F.value = 0, b.value = 0, T.value = 0, R.value = 0, p = 0, L = 0, A = performance.now();
274
+ }, we = (e) => {
275
+ const t = o.labels();
276
+ return e < 1024 ? `${e} ${t.byteShort}` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} ${t.kiloShort}` : `${(e / (1024 * 1024)).toFixed(2)} ${t.megaShort}`;
277
+ }, ke = () => {
278
+ const e = performance.now(), t = (e - A) / 1e3;
279
+ t <= 0 || (T.value = Math.max(0, Math.round((F.value - p) / t)), R.value = Math.max(0, Math.round((b.value - L) / t)), p = F.value, L = b.value, A = e);
280
+ }, Se = () => {
281
+ const e = U.value.trim();
282
+ e && (k.value.includes(e) || (k.value = [...k.value, e].slice(0, ce)), U.value = "", V("quick", k.value));
283
+ }, be = (e) => {
284
+ k.value = k.value.filter((t) => t !== e), V("quick", k.value);
285
+ }, ne = (e) => {
286
+ e.ctrlKey && (e.key.toLowerCase() === "l" && (e.preventDefault(), te()), e.shiftKey && e.key.toLowerCase() === "c" && (e.preventDefault(), ee()));
287
+ };
288
+ return Ee(() => {
289
+ fe(), A = performance.now(), s = setInterval(ke, 1e3), window.addEventListener("keydown", ne);
290
+ }), Fe(() => {
291
+ w == null || w(), w = null, _(), s && clearInterval(s), u && clearTimeout(u), window.removeEventListener("keydown", ne);
292
+ }), {
293
+ lines: i,
294
+ visibleLines: pe,
295
+ view: v,
296
+ rxBytes: F,
297
+ txBytes: b,
298
+ rxRate: T,
299
+ txRate: R,
300
+ input: c,
301
+ hexSend: y,
302
+ lineEnding: m,
303
+ history: g,
304
+ filter: I,
305
+ hexMode: E,
306
+ showTime: M,
307
+ wrapLines: j,
308
+ autoScroll: $,
309
+ copied: O,
310
+ quickCommands: k,
311
+ quickInput: U,
312
+ hexBytes: H,
313
+ hexError: Y,
314
+ sendText: de,
315
+ sendQuick: ve,
316
+ onInputKeydown: ge,
317
+ lineContent: ye,
318
+ lineSegments: me,
319
+ copyLog: ee,
320
+ downloadLog: xe,
321
+ clearLog: te,
322
+ formatBytes: we,
323
+ addQuick: Se,
324
+ removeQuick: be
111
325
  };
112
326
  }
113
327
  export {
114
- T as useDialog,
115
- W as useFocusTrap,
116
- I as useForm,
117
- $ as useSwipeDown
328
+ Be as useDialog,
329
+ _e as useFocusTrap,
330
+ Ue as useForm,
331
+ Ce as useSerialConsole,
332
+ Ke as useSwipeDown
118
333
  };