vuesp-components 5.4.0 → 6.0.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.
Files changed (121) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +14 -1
  3. package/dist/{VDialog.vue_vue_type_script_setup_true_lang-Bh-tnwGM.js → VDialog.vue_vue_type_script_setup_true_lang-Eo7yIqxr.js} +168 -165
  4. package/dist/components/dashboard/cards/CardDate.vue.d.ts +2 -0
  5. package/dist/components/dashboard/cards/CardDate.vue.d.ts.map +1 -1
  6. package/dist/components/index.d.ts +1 -0
  7. package/dist/components/index.d.ts.map +1 -1
  8. package/dist/components/index.es.js +5256 -3345
  9. package/dist/components/modbus/ModbusConnectionCard.vue.d.ts +37 -0
  10. package/dist/components/modbus/ModbusConnectionCard.vue.d.ts.map +1 -0
  11. package/dist/components/modbus/ModbusDeleteDialog.vue.d.ts +10 -0
  12. package/dist/components/modbus/ModbusDeleteDialog.vue.d.ts.map +1 -0
  13. package/dist/components/modbus/ModbusDeviceDialog.vue.d.ts +16 -0
  14. package/dist/components/modbus/ModbusDeviceDialog.vue.d.ts.map +1 -0
  15. package/dist/components/modbus/ModbusDeviceList.vue.d.ts +12 -0
  16. package/dist/components/modbus/ModbusDeviceList.vue.d.ts.map +1 -0
  17. package/dist/components/modbus/ModbusMapDetails.vue.d.ts +12 -0
  18. package/dist/components/modbus/ModbusMapDetails.vue.d.ts.map +1 -0
  19. package/dist/components/modbus/ModbusMapTable.vue.d.ts +10 -0
  20. package/dist/components/modbus/ModbusMapTable.vue.d.ts.map +1 -0
  21. package/dist/components/modbus/ModbusPointDialog.vue.d.ts +28 -0
  22. package/dist/components/modbus/ModbusPointDialog.vue.d.ts.map +1 -0
  23. package/dist/components/modbus/ModbusPointList.vue.d.ts +16 -0
  24. package/dist/components/modbus/ModbusPointList.vue.d.ts.map +1 -0
  25. package/dist/components/modbus/ModbusProfileToolbar.vue.d.ts +16 -0
  26. package/dist/components/modbus/ModbusProfileToolbar.vue.d.ts.map +1 -0
  27. package/dist/components/modbus/ModbusSlaveDialog.vue.d.ts +22 -0
  28. package/dist/components/modbus/ModbusSlaveDialog.vue.d.ts.map +1 -0
  29. package/dist/components/modbus/ModbusSlaveValueList.vue.d.ts +12 -0
  30. package/dist/components/modbus/ModbusSlaveValueList.vue.d.ts.map +1 -0
  31. package/dist/components/modbus/ModbusVarDialog.vue.d.ts +18 -0
  32. package/dist/components/modbus/ModbusVarDialog.vue.d.ts.map +1 -0
  33. package/dist/components/modbus/ModbusVarList.vue.d.ts +12 -0
  34. package/dist/components/modbus/ModbusVarList.vue.d.ts.map +1 -0
  35. package/dist/components/modbus/index.d.ts +16 -0
  36. package/dist/components/modbus/index.d.ts.map +1 -0
  37. package/dist/components/modbus/modbusMapTypes.d.ts +31 -0
  38. package/dist/components/modbus/modbusMapTypes.d.ts.map +1 -0
  39. package/dist/components/modbus/types.d.ts +310 -0
  40. package/dist/components/modbus/types.d.ts.map +1 -0
  41. package/dist/components/script/ScriptDeleteDialog.vue.d.ts +10 -0
  42. package/dist/components/script/ScriptDeleteDialog.vue.d.ts.map +1 -0
  43. package/dist/components/script/ScriptDetailsDialog.vue.d.ts +8 -0
  44. package/dist/components/script/ScriptDetailsDialog.vue.d.ts.map +1 -0
  45. package/dist/components/script/ScriptDiscardDialog.vue.d.ts +11 -0
  46. package/dist/components/script/ScriptDiscardDialog.vue.d.ts.map +1 -0
  47. package/dist/components/script/ScriptRenameDialog.vue.d.ts +10 -0
  48. package/dist/components/script/ScriptRenameDialog.vue.d.ts.map +1 -0
  49. package/dist/components/script/ScriptStudioActionBar.vue.d.ts +10 -0
  50. package/dist/components/script/ScriptStudioActionBar.vue.d.ts.map +1 -0
  51. package/dist/components/script/ScriptStudioLogs.vue.d.ts +15 -0
  52. package/dist/components/script/ScriptStudioLogs.vue.d.ts.map +1 -0
  53. package/dist/components/script/ScriptStudioMetrics.vue.d.ts +19 -0
  54. package/dist/components/script/ScriptStudioMetrics.vue.d.ts.map +1 -0
  55. package/dist/components/script/ScriptStudioTabs.vue.d.ts +18 -0
  56. package/dist/components/script/ScriptStudioTabs.vue.d.ts.map +1 -0
  57. package/dist/components/script/ScriptStudioToolbar.vue.d.ts +35 -0
  58. package/dist/components/script/ScriptStudioToolbar.vue.d.ts.map +1 -0
  59. package/dist/components/script/editor/suggestions.d.ts +1 -1
  60. package/dist/components/script/editor/suggestions.d.ts.map +1 -1
  61. package/dist/components/script/helpers.d.ts +28 -0
  62. package/dist/components/script/helpers.d.ts.map +1 -0
  63. package/dist/components/script/index.d.ts +11 -5
  64. package/dist/components/script/index.d.ts.map +1 -1
  65. package/dist/components/script/types.d.ts +112 -3
  66. package/dist/components/script/types.d.ts.map +1 -1
  67. package/dist/components/serial/SerialConsole.vue.d.ts.map +1 -1
  68. package/dist/components/ui/select/VSelect.vue.d.ts.map +1 -1
  69. package/dist/components/ui/select/types.d.ts +1 -0
  70. package/dist/components/ui/select/types.d.ts.map +1 -1
  71. package/dist/components/ui/tabs/VTabs.vue.d.ts.map +1 -1
  72. package/dist/components/ui/text-field/types.d.ts +2 -0
  73. package/dist/components/ui/text-field/types.d.ts.map +1 -1
  74. package/dist/components/ui/text-field/useTextField.d.ts +2 -2
  75. package/dist/components/ui/text-field/useTextField.d.ts.map +1 -1
  76. package/dist/composables/index.d.ts +2 -0
  77. package/dist/composables/index.d.ts.map +1 -1
  78. package/dist/composables/index.es.js +101 -512
  79. package/dist/composables/useI18n.d.ts +3 -0
  80. package/dist/composables/useI18n.d.ts.map +1 -0
  81. package/dist/composables/useScriptStudioLogs.d.ts +30 -0
  82. package/dist/composables/useScriptStudioLogs.d.ts.map +1 -0
  83. package/dist/composables/useSerialConsole.d.ts +1 -1
  84. package/dist/helpers/index.d.ts +0 -1
  85. package/dist/helpers/index.d.ts.map +1 -1
  86. package/dist/helpers/index.es.js +60 -77
  87. package/dist/index.es.js +1 -1
  88. package/dist/pages/kit/KitShowcase.vue.d.ts.map +1 -1
  89. package/dist/style.css +1 -1
  90. package/dist/types/index.d.ts +1 -0
  91. package/dist/types/index.d.ts.map +1 -1
  92. package/dist/{useDialog-Buvn63AR.js → useDialog-XDF9alzt.js} +2 -2
  93. package/dist/useSerialConsole-DaedwQe_.js +564 -0
  94. package/package.json +1 -1
  95. package/dist/app-3Zj29UoC.js +0 -64
  96. package/dist/components/script/dialog/ScriptDialog.vue.d.ts +0 -10
  97. package/dist/components/script/dialog/ScriptDialog.vue.d.ts.map +0 -1
  98. package/dist/components/script/dialog/types.d.ts +0 -8
  99. package/dist/components/script/dialog/types.d.ts.map +0 -1
  100. package/dist/components/script/editor/ScriptEditor.vue.d.ts +0 -10
  101. package/dist/components/script/editor/ScriptEditor.vue.d.ts.map +0 -1
  102. package/dist/components/script/editor/format.d.ts +0 -3
  103. package/dist/components/script/editor/format.d.ts.map +0 -1
  104. package/dist/components/script/editor/highlighters/index.d.ts +0 -3
  105. package/dist/components/script/editor/highlighters/index.d.ts.map +0 -1
  106. package/dist/components/script/editor/plugins/autoSemicolon.d.ts +0 -3
  107. package/dist/components/script/editor/plugins/autoSemicolon.d.ts.map +0 -1
  108. package/dist/components/script/editor/plugins/autocomplete.d.ts +0 -4
  109. package/dist/components/script/editor/plugins/autocomplete.d.ts.map +0 -1
  110. package/dist/components/script/editor/plugins/index.d.ts +0 -3
  111. package/dist/components/script/editor/plugins/index.d.ts.map +0 -1
  112. package/dist/components/script/editor/plugins/render/index.d.ts +0 -7
  113. package/dist/components/script/editor/plugins/render/index.d.ts.map +0 -1
  114. package/dist/components/script/editor/plugins/types.d.ts +0 -24
  115. package/dist/components/script/editor/plugins/types.d.ts.map +0 -1
  116. package/dist/components/script/editor/types.d.ts +0 -10
  117. package/dist/components/script/editor/types.d.ts.map +0 -1
  118. package/dist/components/script/viewDocs/ScriptViewDocs.vue.d.ts +0 -13
  119. package/dist/components/script/viewDocs/ScriptViewDocs.vue.d.ts.map +0 -1
  120. package/dist/components/script/viewDocs/types.d.ts +0 -4
  121. package/dist/components/script/viewDocs/types.d.ts.map +0 -1
@@ -0,0 +1,564 @@
1
+ import { inject as At, ref as o, useTemplateRef as Pe, computed as k, watch as G, nextTick as xe, onBeforeUnmount as qe, reactive as Ot, onMounted as Ct } from "vue";
2
+ const Jt = () => {
3
+ const a = At("i18n");
4
+ if (!a)
5
+ throw new Error("i18n not provided");
6
+ return a;
7
+ }, $ = {
8
+ ACTIVE: 1,
9
+ LOADED: 2,
10
+ ERROR: 4,
11
+ BOOT: 8
12
+ }, It = {
13
+ amber: "bg-amber-main/10 text-amber-main",
14
+ red: "bg-red-main/10 text-red-main",
15
+ green: "bg-green-main/10 text-green-main",
16
+ blue: "bg-blue-main/10 text-blue-main",
17
+ gray: "bg-gray-main/10 text-gray-main"
18
+ }, Dt = {
19
+ amber: "bg-amber-main",
20
+ red: "bg-red-main",
21
+ green: "bg-green-main",
22
+ blue: "bg-blue-main",
23
+ gray: "bg-gray-main"
24
+ }, Wt = (a) => It[a], Yt = (a) => Dt[a], we = [
25
+ { matches: (a) => (a.state & $.ERROR) !== 0, tone: "red", key: "scriptStudio.stateError" },
26
+ { matches: (a) => (a.state & $.ACTIVE) !== 0, tone: "green", key: "scriptStudio.stateRunning" },
27
+ { matches: (a) => (a.state & $.LOADED) !== 0, tone: "blue", key: "scriptStudio.stateLoaded" },
28
+ { matches: () => !0, tone: "gray", key: "scriptStudio.stateStopped" }
29
+ ], Zt = (a, s) => {
30
+ if (!a) return { label: s("scriptStudio.stateNotSaved"), tone: "amber" };
31
+ const u = we.find((i) => i.matches(a)) ?? we[we.length - 1];
32
+ return { label: s(u.key), tone: u.tone };
33
+ }, en = (a) => (a & $.ACTIVE) !== 0, tn = (a) => (a & $.LOADED) !== 0, nn = (a) => (a & $.ERROR) !== 0, Bt = 15, Ut = new RegExp(`^[a-z_][a-z0-9_-]{0,${Bt - 1}}$`), an = (a) => Ut.test(a), _t = 2, Mt = (a) => Array.from(new TextEncoder().encode(a)).map((s) => s.toString(16).padStart(_t, "0")).join(" "), Ke = (a, s) => s === "text" ? a : Mt(a), Ne = (a, s) => `${a.time} ${Ke(a.text, s)}`, jt = async (a) => {
34
+ var s;
35
+ if (!((s = navigator.clipboard) != null && s.writeText)) return !1;
36
+ try {
37
+ return await navigator.clipboard.writeText(a), !0;
38
+ } catch {
39
+ return !1;
40
+ }
41
+ }, $t = (a, s, u) => {
42
+ const i = new Blob([a], { type: u }), v = URL.createObjectURL(i), m = document.createElement("a");
43
+ m.href = v, m.download = s, m.rel = "noopener", document.body.appendChild(m), m.click(), m.remove(), window.setTimeout(() => URL.revokeObjectURL(v), 0);
44
+ }, Pt = (a) => {
45
+ a == null || a.scrollIntoView({ behavior: "smooth", block: "nearest" });
46
+ }, Nt = 1200, Ft = 24, rn = (a, s, u) => {
47
+ const i = o(!1), v = o(!1), m = o(0), b = o(!1), g = o(!1), S = o(!0), B = o(!1), T = o("text"), U = o(""), L = o([]), _ = Pe("logsPanel"), E = Pe("logEl");
48
+ let y = null;
49
+ const P = k(() => b.value ? L.value : s.value), w = k(() => {
50
+ const f = U.value.trim().toLowerCase();
51
+ return f ? P.value.filter((d) => d.text.toLowerCase().includes(f)) : P.value;
52
+ }), R = k(() => s.value.length), A = () => {
53
+ E.value && (E.value.scrollTop = E.value.scrollHeight);
54
+ }, p = () => {
55
+ i.value = !0, v.value = !1, xe(() => Pt(_.value));
56
+ }, h = () => {
57
+ p();
58
+ }, N = () => {
59
+ if (i.value) {
60
+ i.value = !1;
61
+ return;
62
+ }
63
+ p();
64
+ }, F = () => {
65
+ if (b.value) {
66
+ b.value = !1, L.value = [];
67
+ return;
68
+ }
69
+ L.value = s.value.map((f) => ({ ...f })), b.value = !0;
70
+ }, D = () => {
71
+ g.value = !g.value;
72
+ }, re = () => {
73
+ L.value = [], v.value = !1, u();
74
+ }, se = () => {
75
+ S.value = !0, xe(A);
76
+ }, oe = () => {
77
+ const f = E.value;
78
+ f && (S.value = f.scrollHeight - f.scrollTop - f.clientHeight < Ft);
79
+ }, H = async () => {
80
+ if (w.value.length === 0) return !1;
81
+ const f = w.value.map((d) => Ne(d, T.value)).join(`
82
+ `);
83
+ return await jt(f) ? (B.value = !0, y && clearTimeout(y), y = setTimeout(() => {
84
+ B.value = !1;
85
+ }, Nt), !0) : !1;
86
+ }, M = () => {
87
+ if (w.value.length === 0) return;
88
+ const f = w.value.map((d) => Ne(d, T.value)).join(`
89
+ `);
90
+ $t(f, `script-${a() || "script"}.log`, "text/plain");
91
+ };
92
+ return G(R, (f, d) => {
93
+ !i.value && f > d && (v.value = !0, m.value += 1);
94
+ }), G(
95
+ [() => w.value.length, T, U],
96
+ () => {
97
+ S.value && xe(A);
98
+ }
99
+ ), qe(() => {
100
+ y && clearTimeout(y);
101
+ }), {
102
+ logs: s,
103
+ liveLogs: P,
104
+ visibleLogs: w,
105
+ count: R,
106
+ isOpen: i,
107
+ hasUnread: v,
108
+ pulseSeq: m,
109
+ isPaused: b,
110
+ isSearchOpen: g,
111
+ isAutoScroll: S,
112
+ isCopied: B,
113
+ mode: T,
114
+ search: U,
115
+ logsPanel: _,
116
+ logEl: E,
117
+ onOpen: h,
118
+ onToggleOpen: N,
119
+ onTogglePause: F,
120
+ onToggleSearch: D,
121
+ onClear: re,
122
+ onFollow: se,
123
+ onScroll: oe,
124
+ onCopy: H,
125
+ onDownload: M,
126
+ getLogText: Ke
127
+ };
128
+ }, Ht = 150, qt = 4096, Fe = 256 * 1024, He = 12, Kt = 1200, Qt = { utf8: "utf-8", cp1251: "windows-1251" }, Vt = {
129
+ encoding: "utf8",
130
+ framing: "line",
131
+ gapMs: 25,
132
+ paused: !1
133
+ }, Xt = (a, s) => (
134
+ // eslint-disable-next-line no-control-regex
135
+ new TextDecoder(Qt[s]).decode(a).replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g, ".")
136
+ ), Gt = (a) => Array.from(a, (s) => s.toString(16).padStart(2, "0")).join(" ");
137
+ function sn(a) {
138
+ var _e, Me;
139
+ const s = o([]), u = Ot({ ...Vt }), i = o(0), v = o(0), m = o(0), b = o(0), g = o(""), S = o(!1), B = o(!1), T = o(!1), U = o(1e3), L = o("all"), _ = o(!1), E = o(!1), y = o([]), P = o(!1), w = o(""), R = o(!1), A = o(((_e = a.initialLineEnding) == null ? void 0 : _e.call(a)) ?? "crlf"), p = o([]), h = o(-1), N = o(""), F = o("text"), D = o(null), re = o(!0), se = o(!0), oe = o(!0), H = o(!1), M = o(!1), f = o(!1), d = o([]), le = o("");
140
+ let Se = 0, x = [], O = [], z = null, ce = null, J = null, q = null, W = null, K = !1, ue = "", Q = null, ie = 0, fe = 0, Y = 0, C = null;
141
+ const be = (e) => {
142
+ var n;
143
+ const t = (n = a.storageKey) == null ? void 0 : n.call(a);
144
+ return t ? `${t}:${e}` : null;
145
+ }, de = (e) => {
146
+ const t = be(e);
147
+ if (!t || typeof localStorage > "u") return null;
148
+ try {
149
+ const n = localStorage.getItem(t);
150
+ return n ? JSON.parse(n) : null;
151
+ } catch {
152
+ return null;
153
+ }
154
+ }, Z = (e, t) => {
155
+ const n = be(e);
156
+ if (!(!n || typeof localStorage > "u"))
157
+ try {
158
+ localStorage.setItem(n, JSON.stringify(t));
159
+ } catch {
160
+ }
161
+ }, Te = de("view");
162
+ Te && Object.assign(u, Te, { paused: !1 }), u.paused = !1;
163
+ const ke = de("scenario");
164
+ typeof ke == "string" && (w.value = ke);
165
+ const Qe = de("quick"), Ve = ((Me = a.initialQuickCommands) == null ? void 0 : Me.call(a)) ?? [];
166
+ d.value = (Qe ?? Ve).filter((e) => typeof e == "string").slice(0, He), G(u, () => Z("view", { ...u, paused: !1 }), { deep: !0 });
167
+ const Xe = "vuesp-serial", I = "sessions", ee = () => {
168
+ var t, n;
169
+ const e = (t = a.storageKey) == null ? void 0 : t.call(a);
170
+ return (n = a.session) != null && n.call(a) && e ? `${e}:session` : null;
171
+ }, ve = () => new Promise((e, t) => {
172
+ const n = indexedDB.open(Xe, 1);
173
+ n.onupgradeneeded = () => {
174
+ n.result.objectStoreNames.contains(I) || n.result.createObjectStore(I);
175
+ }, n.onsuccess = () => e(n.result), n.onerror = () => t(n.error);
176
+ }), Ge = async (e) => {
177
+ if (typeof indexedDB > "u") return null;
178
+ const t = await ve();
179
+ return new Promise((n, r) => {
180
+ const l = t.transaction(I, "readonly").objectStore(I).get(e);
181
+ l.onsuccess = () => n(l.result ?? null), l.onerror = () => r(l.error);
182
+ });
183
+ }, ze = async (e, t) => {
184
+ if (typeof indexedDB > "u") return;
185
+ const n = await ve();
186
+ await new Promise((r, l) => {
187
+ const c = n.transaction(I, "readwrite").objectStore(I).put(t, e);
188
+ c.onsuccess = () => r(), c.onerror = () => l(c.error);
189
+ });
190
+ }, Je = async (e) => {
191
+ if (typeof indexedDB > "u") return;
192
+ const t = await ve();
193
+ await new Promise((n, r) => {
194
+ const l = t.transaction(I, "readwrite").objectStore(I).delete(e);
195
+ l.onsuccess = () => n(), l.onerror = () => r(l.error);
196
+ });
197
+ }, We = () => {
198
+ const e = ee();
199
+ e && (q && clearTimeout(q), q = setTimeout(() => {
200
+ const t = {
201
+ lines: s.value.map((n) => ({ ...n, data: n.data ? [...n.data] : void 0 })),
202
+ rxBytes: i.value,
203
+ txBytes: v.value
204
+ };
205
+ ze(e, t).catch(() => {
206
+ });
207
+ }, 800));
208
+ }, Ye = async () => {
209
+ var t;
210
+ const e = ee();
211
+ if (!(!e || s.value.length))
212
+ try {
213
+ const n = await Ge(e);
214
+ if (!((t = n == null ? void 0 : n.lines) != null && t.length)) return;
215
+ s.value = n.lines, Se = n.lines.reduce((r, l) => Math.max(r, l.id), 0), i.value = n.rxBytes ?? 0, v.value = n.txBytes ?? 0, f.value = !0;
216
+ } catch {
217
+ }
218
+ }, ge = (e, t) => {
219
+ const n = Xt(t, u.encoding);
220
+ s.value.push({
221
+ id: ++Se,
222
+ dir: e,
223
+ at: (/* @__PURE__ */ new Date()).toLocaleTimeString(a.locale() === "ru" ? "ru-RU" : "en-GB", { hour12: !1 }),
224
+ text: u.framing === "gap" ? n.replace(/[\r\n]+/g, " ") : n,
225
+ hex: Gt(t),
226
+ bytes: t.length,
227
+ // Keep a bounded copy for the binary view and byte inspector.
228
+ data: Array.from(t.slice(0, 1024))
229
+ });
230
+ const r = a.maxLines();
231
+ s.value.length > r && s.value.splice(0, s.value.length - r), We();
232
+ }, te = () => {
233
+ z && (clearTimeout(z), z = null);
234
+ }, Le = () => {
235
+ if (te(), !x.length) return;
236
+ const e = new Uint8Array(x);
237
+ x = [], ge("rx", e);
238
+ }, Ze = () => {
239
+ te();
240
+ const e = u.framing === "gap" ? Math.max(5, u.gapMs) : Ht;
241
+ z = setTimeout(Le, e);
242
+ }, Ee = (e) => {
243
+ for (const t of e) x.push(t);
244
+ if (u.framing === "line") {
245
+ let t = 0;
246
+ for (let n = 0; n < x.length; n++) {
247
+ const r = x[n];
248
+ if (r !== 10 && r !== 13) continue;
249
+ const l = x.slice(t, n);
250
+ l.length && ge("rx", new Uint8Array(l)), r === 13 && x[n + 1] === 10 && n++, t = n + 1;
251
+ }
252
+ t && (x = x.slice(t));
253
+ }
254
+ x.length >= qt ? Le() : Ze();
255
+ }, V = () => {
256
+ J && clearTimeout(J), J = null, M.value = !1;
257
+ }, et = (e) => {
258
+ var n;
259
+ const t = (n = a.noReplyHint) == null ? void 0 : n.call(a);
260
+ t && (V(), J = setTimeout(() => {
261
+ i.value === e && (M.value = !0);
262
+ }, t.delay ?? 1500));
263
+ }, tt = (e) => {
264
+ if (e != null && e.length) {
265
+ if (M.value && V(), i.value += e.length, u.paused) {
266
+ for (const t of e) O.push(t);
267
+ O.length > Fe && O.splice(0, O.length - Fe);
268
+ return;
269
+ }
270
+ Ee(e);
271
+ }
272
+ }, nt = () => {
273
+ C == null || C(), C = a.transport().subscribe(tt);
274
+ };
275
+ G(
276
+ () => u.paused,
277
+ (e) => {
278
+ if (e || !O.length) return;
279
+ const t = new Uint8Array(O);
280
+ O = [], Ee(t);
281
+ }
282
+ );
283
+ const j = async (e) => {
284
+ const t = await a.transport().send(e);
285
+ return t && (v.value += e.length, ge("tx", e)), t;
286
+ }, he = k(() => g.value.replace(/^0x/i, "").replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "")), at = k(() => {
287
+ const e = g.value.replace(/0x/gi, "").replace(/[\s,;:]/g, "");
288
+ return e.length > 0 && /[^0-9a-fA-F]/.test(e);
289
+ }), Re = k(() => {
290
+ const e = he.value, t = [];
291
+ for (let n = 0; n + 1 < e.length; n += 2) t.push(parseInt(e.slice(n, n + 2), 16));
292
+ return t;
293
+ }), Ae = k(() => S.value ? at.value ? a.labels().hexInvalid : he.value && he.value.length % 2 ? a.labels().hexOdd : "" : ""), rt = (e) => {
294
+ const t = new TextEncoder(), n = [];
295
+ let r = "";
296
+ const l = () => {
297
+ r && (n.push(...t.encode(r)), r = "");
298
+ };
299
+ for (let c = 0; c < e.length; c++) {
300
+ const ye = e[c];
301
+ if (ye !== "\\") {
302
+ r += ye;
303
+ continue;
304
+ }
305
+ const X = e[c + 1], je = e.slice(c + 2, c + 4);
306
+ if ((X === "x" || X === "X") && /^[0-9a-fA-F]{2}$/.test(je)) {
307
+ l(), n.push(parseInt(je, 16)), c += 3;
308
+ continue;
309
+ }
310
+ const $e = { r: 13, n: 10, t: 9, 0: 0, "\\": 92 };
311
+ if (X !== void 0 && X in $e) {
312
+ l(), n.push($e[X]), c += 1;
313
+ continue;
314
+ }
315
+ r += ye;
316
+ }
317
+ return l(), n;
318
+ }, ne = (e, t) => {
319
+ if (t) {
320
+ const r = e.replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "");
321
+ if (!r.length || r.length % 2) return [];
322
+ const l = [];
323
+ for (let c = 0; c + 1 < r.length; c += 2) l.push(parseInt(r.slice(c, c + 2), 16));
324
+ return l;
325
+ }
326
+ const n = B.value ? rt(e) : Array.from(new TextEncoder().encode(e));
327
+ return (A.value === "cr" || A.value === "crlf") && n.push(13), (A.value === "lf" || A.value === "crlf") && n.push(10), n;
328
+ }, st = async () => {
329
+ if (S.value && (Ae.value || !Re.value.length)) return;
330
+ const e = g.value, t = ne(e, S.value);
331
+ !t.length || !await j(new Uint8Array(t.slice(0, 4096))) || (e.trim() && (p.value = [e, ...p.value.filter((r) => r !== e)].slice(0, 50), h.value = -1), g.value = "");
332
+ }, Oe = async (e) => {
333
+ const t = ne(e, !1);
334
+ if (!t.length) return;
335
+ const n = i.value;
336
+ await j(new Uint8Array(t.slice(0, 4096))) && (p.value = [e, ...p.value.filter((l) => l !== e)].slice(0, 50), h.value = -1, ue = e, et(n));
337
+ }, ot = async (e) => {
338
+ const t = new Uint8Array(await e.arrayBuffer());
339
+ if (!t.length) return !1;
340
+ const n = 256;
341
+ for (let r = 0; r < t.length; r += n) {
342
+ if (!await j(t.slice(r, r + n))) return !1;
343
+ await new Promise((c) => setTimeout(c, 8));
344
+ }
345
+ return !0;
346
+ }, ae = () => {
347
+ W && clearInterval(W), W = null, T.value = !1;
348
+ }, lt = async () => {
349
+ if (T.value) {
350
+ ae();
351
+ return;
352
+ }
353
+ const e = ne(g.value, S.value);
354
+ if (!e.length) return;
355
+ const t = new Uint8Array(e.slice(0, 4096));
356
+ await j(t) && (T.value = !0, W = setInterval(() => {
357
+ j(t);
358
+ }, Math.max(50, U.value)));
359
+ }, ct = async () => {
360
+ var t;
361
+ const e = (t = a.noReplyHint) == null ? void 0 : t.call(a);
362
+ e != null && e.onAction && (V(), await e.onAction(), (e.resend ?? !0) && ue && await Oe(ue));
363
+ }, ut = (e) => {
364
+ if (e.key === "ArrowUp") {
365
+ if (!p.value.length) return;
366
+ e.preventDefault(), h.value = h.value === -1 ? p.value.length - 1 : Math.max(0, h.value - 1), g.value = p.value[h.value] ?? "";
367
+ return;
368
+ }
369
+ if (e.key === "ArrowDown") {
370
+ if (h.value === -1) return;
371
+ e.preventDefault(), h.value++, h.value >= p.value.length ? (h.value = -1, g.value = "") : g.value = p.value[h.value] ?? "";
372
+ return;
373
+ }
374
+ e.key === "Escape" && (g.value = "", h.value = -1);
375
+ }, it = (e, t) => {
376
+ if (!t) return !0;
377
+ if (_.value)
378
+ try {
379
+ const n = new RegExp(t, "i");
380
+ return n.test(e.text) || n.test(e.hex);
381
+ } catch {
382
+ return !1;
383
+ }
384
+ return e.text.toLowerCase().includes(t) || e.hex.toLowerCase().includes(t);
385
+ }, ft = k(() => {
386
+ const e = N.value.trim().toLowerCase(), t = new Set(y.value);
387
+ return s.value.filter((n) => L.value !== "all" && n.dir !== L.value || E.value && !t.has(n.id) ? !1 : it(n, e));
388
+ }), Ce = (e) => y.value.includes(e.id), dt = (e) => {
389
+ y.value = Ce(e) ? y.value.filter((t) => t !== e.id) : [...y.value, e.id];
390
+ }, vt = (e) => e.split(`
391
+ `).map((t) => t.trim()).filter(Boolean).map((t) => {
392
+ const n = /^(\d+)\s*:\s*(.*)$/.exec(t);
393
+ return n ? { delay: Number(n[1]), command: n[2] } : { delay: 0, command: t };
394
+ }).filter((t) => t.command.length > 0), me = () => {
395
+ K = !0, R.value = !1;
396
+ }, gt = async () => {
397
+ if (R.value) return;
398
+ const e = vt(w.value);
399
+ if (e.length) {
400
+ K = !1, R.value = !0;
401
+ try {
402
+ for (const t of e) {
403
+ if (K || (t.delay > 0 && await new Promise((r) => setTimeout(r, t.delay)), K)) break;
404
+ const n = ne(t.command, !1);
405
+ n.length && await j(new Uint8Array(n.slice(0, 4096)));
406
+ }
407
+ } finally {
408
+ R.value = !1, K = !1;
409
+ }
410
+ }
411
+ };
412
+ G(w, (e) => Z("scenario", e));
413
+ const ht = (e) => (e.data ?? []).map((t) => t.toString(2).padStart(8, "0")).join(" "), mt = (e) => F.value === "hex" ? e.hex : F.value === "bin" ? ht(e) : e.text || e.hex, pt = k(() => s.value.find((e) => e.id === D.value) ?? null), yt = (e) => {
414
+ D.value = D.value === e.id ? null : e.id;
415
+ }, xt = (e) => {
416
+ const t = N.value.trim().toLowerCase();
417
+ if (!t || _.value) return [{ text: e, match: !1 }];
418
+ const n = e.toLowerCase(), r = [];
419
+ let l = 0;
420
+ for (; l < e.length; ) {
421
+ const c = n.indexOf(t, l);
422
+ if (c === -1) break;
423
+ c > l && r.push({ text: e.slice(l, c), match: !1 }), r.push({ text: e.slice(c, c + t.length), match: !0 }), l = c + t.length;
424
+ }
425
+ return l < e.length && r.push({ text: e.slice(l), match: !1 }), r.length ? r : [{ text: e, match: !1 }];
426
+ }, pe = (e, t) => {
427
+ const n = URL.createObjectURL(t), r = document.createElement("a"), l = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
428
+ return r.href = n, r.download = `serial-${l}.${e}`, r.click(), URL.revokeObjectURL(n), !0;
429
+ }, Ie = () => s.value.map((e) => `${e.at} ${e.dir.toUpperCase()} ${e.text || e.hex}`).join(`
430
+ `), wt = () => {
431
+ if (!s.value.length) return !1;
432
+ const e = (n) => `"${String(n).replace(/"/g, '""')}"`, t = s.value.map((n) => [n.at, n.dir, n.bytes, e(n.text), e(n.hex)].join(","));
433
+ return pe("csv", new Blob([["time,direction,bytes,text,hex", ...t].join(`
434
+ `)], { type: "text/csv;charset=utf-8" }));
435
+ }, St = () => {
436
+ if (!s.value.length) return !1;
437
+ const e = s.value.map((t) => ({ at: t.at, dir: t.dir, bytes: t.bytes, text: t.text, hex: t.hex }));
438
+ return pe("json", new Blob([JSON.stringify(e, null, 2)], { type: "application/json;charset=utf-8" }));
439
+ }, bt = () => {
440
+ var t;
441
+ const e = [];
442
+ for (const n of s.value)
443
+ n.dir === "rx" && ((t = n.data) != null && t.length) && e.push(...n.data);
444
+ return e.length ? pe("bin", new Blob([new Uint8Array(e)], { type: "application/octet-stream" })) : !1;
445
+ }, De = async () => {
446
+ if (!s.value.length) return !1;
447
+ try {
448
+ return await navigator.clipboard.writeText(Ie()), H.value = !0, Q && clearTimeout(Q), Q = setTimeout(() => {
449
+ H.value = !1;
450
+ }, Kt), !0;
451
+ } catch {
452
+ return !1;
453
+ }
454
+ }, Tt = () => {
455
+ if (!s.value.length) return !1;
456
+ const e = new Blob([Ie()], { type: "text/plain;charset=utf-8" }), t = URL.createObjectURL(e), n = document.createElement("a"), r = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
457
+ return n.href = t, n.download = `serial-${r}.log`, n.click(), URL.revokeObjectURL(t), !0;
458
+ }, Be = () => {
459
+ ae(), me(), V(), te();
460
+ const e = ee();
461
+ e && Je(e).catch(() => {
462
+ }), f.value = !1, x = [], O = [], s.value = [], D.value = null, i.value = 0, v.value = 0, m.value = 0, b.value = 0, ie = 0, fe = 0, Y = performance.now();
463
+ }, kt = (e) => {
464
+ const t = a.labels();
465
+ return e < 1024 ? `${e} ${t.byteShort}` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} ${t.kiloShort}` : `${(e / (1024 * 1024)).toFixed(2)} ${t.megaShort}`;
466
+ }, Lt = () => {
467
+ const e = performance.now(), t = (e - Y) / 1e3;
468
+ t <= 0 || (m.value = Math.max(0, Math.round((i.value - ie) / t)), b.value = Math.max(0, Math.round((v.value - fe) / t)), ie = i.value, fe = v.value, Y = e);
469
+ }, Et = () => {
470
+ const e = le.value.trim();
471
+ e && (d.value.includes(e) || (d.value = [...d.value, e].slice(0, He)), le.value = "", Z("quick", d.value));
472
+ }, Rt = (e) => {
473
+ d.value = d.value.filter((t) => t !== e), Z("quick", d.value);
474
+ }, Ue = (e) => {
475
+ e.ctrlKey && (e.key.toLowerCase() === "l" && (e.preventDefault(), Be()), e.shiftKey && e.key.toLowerCase() === "c" && (e.preventDefault(), De()));
476
+ };
477
+ return Ct(() => {
478
+ nt(), ee() && Ye(), Y = performance.now(), ce = setInterval(Lt, 1e3), window.addEventListener("keydown", Ue);
479
+ }), qe(() => {
480
+ C == null || C(), C = null, ae(), me(), V(), te(), ce && clearInterval(ce), Q && clearTimeout(Q), q && clearTimeout(q), window.removeEventListener("keydown", Ue);
481
+ }), {
482
+ lines: s,
483
+ visibleLines: ft,
484
+ view: u,
485
+ rxBytes: i,
486
+ txBytes: v,
487
+ rxRate: m,
488
+ txRate: b,
489
+ input: g,
490
+ hexSend: S,
491
+ escape: B,
492
+ repeat: T,
493
+ repeatMs: U,
494
+ direction: L,
495
+ regex: _,
496
+ onlyBookmarks: E,
497
+ bookmarkIds: y,
498
+ isBookmarked: Ce,
499
+ toggleBookmark: dt,
500
+ scenarioOpen: P,
501
+ scenarioText: w,
502
+ scenarioRunning: R,
503
+ startScenario: gt,
504
+ stopScenario: me,
505
+ sendFile: ot,
506
+ toggleRepeat: lt,
507
+ stopRepeat: ae,
508
+ lineEnding: A,
509
+ history: p,
510
+ filter: N,
511
+ mode: F,
512
+ selectedId: D,
513
+ selectedLine: pt,
514
+ selectLine: yt,
515
+ showTime: re,
516
+ wrapLines: se,
517
+ autoScroll: oe,
518
+ copied: H,
519
+ showNoReply: M,
520
+ quickCommands: d,
521
+ quickInput: le,
522
+ hexBytes: Re,
523
+ hexError: Ae,
524
+ sendText: st,
525
+ sendQuick: Oe,
526
+ onInputKeydown: ut,
527
+ lineContent: mt,
528
+ lineSegments: xt,
529
+ copyLog: De,
530
+ downloadLog: Tt,
531
+ exportCsv: wt,
532
+ exportJson: St,
533
+ exportRxBin: bt,
534
+ sessionRestored: f,
535
+ clearLog: Be,
536
+ formatBytes: kt,
537
+ addQuick: Et,
538
+ removeQuick: Rt,
539
+ applyHintAction: ct
540
+ };
541
+ }
542
+ export {
543
+ Bt as S,
544
+ Dt as T,
545
+ rn as a,
546
+ sn as b,
547
+ jt as c,
548
+ Yt as d,
549
+ en as e,
550
+ Ut as f,
551
+ Zt as g,
552
+ $ as h,
553
+ an as i,
554
+ It as j,
555
+ $t as k,
556
+ Ne as l,
557
+ Ke as m,
558
+ Wt as n,
559
+ nn as o,
560
+ tn as p,
561
+ Pt as s,
562
+ Mt as t,
563
+ Jt as u
564
+ };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.4.0",
2
+ "version": "6.0.0",
3
3
  "name": "vuesp-components",
4
4
  "type": "module",
5
5
  "main": "./dist/index.es.js",
@@ -1,64 +0,0 @@
1
- const c = (t) => {
2
- try {
3
- return t ? JSON.parse(t) : null;
4
- } catch (o) {
5
- return console.warn(o), t;
6
- }
7
- }, i = (t) => typeof t == "object" ? JSON.stringify(t) : t, g = (t) => c(i(t)), h = (t) => {
8
- const o = ["B", "KB", "MB"];
9
- if (t == 0) return "0 B";
10
- let e = Math.floor(Math.log(t) / Math.log(1024));
11
- return e > 1 && (e = 1), Math.round(t / Math.pow(1024, e)) + " " + o[e];
12
- }, p = (t, o = { year: "numeric", month: "numeric", day: "numeric" }, e = []) => new Date(t).toLocaleDateString(e, o), S = (t, o = { minute: "2-digit", hour: "2-digit" }, e = []) => new Date(t).toLocaleTimeString(e, o), s = (t) => t >= 10 ? t : `0${t}`, y = (t) => {
13
- const o = Math.floor(t % 31536e3 % 2628e3 / 86400), e = Math.floor(t % (3600 * 24) / 3600), n = Math.floor(t % 3600 / 60), u = Math.floor(t % 60);
14
- return `${o ? o + " days " : ""} ${s(e)}:${s(n)}:${s(u)}`;
15
- }, w = (t) => t.join("."), M = (t) => t.split(".").map((o) => +o), T = (t = 6) => [...Array(t)].map(() => "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"[Math.random() * 62 | 0]).join(""), E = (t, o = "file") => {
16
- if (typeof document > "u") return;
17
- const e = document.createElement("a");
18
- e.setAttribute("download", o), e.href = t, document.body.appendChild(e), e.click(), e.remove();
19
- }, b = (t) => new Promise((o, e) => {
20
- if (typeof document > "u") {
21
- e(new Error("Script loading is available only in a browser"));
22
- return;
23
- }
24
- const n = document.createElement("script");
25
- n.src = t, n.type = "text/javascript", n.async = !0, n.onload = () => o(n), n.onerror = () => e(new Error(`Ошибка загрузки скрипта: ${t}`)), document.head.appendChild(n);
26
- }), r = typeof window < "u", a = (t) => (o, e) => e ? c(t.getItem(o)) : t.getItem(o), l = (t) => (o, e) => {
27
- t.setItem(o, typeof e == "string" ? e : i(e));
28
- }, m = r ? a(localStorage) : () => null, d = r ? l(localStorage) : () => {
29
- }, j = r ? a(sessionStorage) : () => null, L = r ? l(sessionStorage) : () => {
30
- }, k = (t = "isShow") => {
31
- const o = m(t);
32
- return o || d(t, "true"), !o;
33
- }, B = (t) => {
34
- d("theme", t), !(typeof document > "u") && (document.documentElement.classList.remove("dark"), document.documentElement.classList.remove("light"), document.documentElement.classList.add(t));
35
- }, f = (t, o) => {
36
- if (!t) return null;
37
- for (const e of t)
38
- if (!(o === "/" || e.path === "/") && e.path && (e.path === o || o.includes(e.path)))
39
- return e;
40
- return null;
41
- }, $ = (t, o) => f(t, o);
42
- export {
43
- s as a,
44
- w as b,
45
- B as c,
46
- g as d,
47
- E as e,
48
- p as f,
49
- f as g,
50
- $ as h,
51
- k as i,
52
- c as j,
53
- i as k,
54
- b as l,
55
- m,
56
- d as n,
57
- j as o,
58
- L as p,
59
- M as q,
60
- T as r,
61
- y as s,
62
- S as t,
63
- h as u
64
- };
@@ -1,10 +0,0 @@
1
- import { IScriptDialogProps } from './types';
2
- declare const _default: import('vue').DefineComponent<IScriptDialogProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
3
- close: (v: Event) => any;
4
- add: (v: string) => any;
5
- }, string, import('vue').PublicProps, Readonly<IScriptDialogProps> & Readonly<{
6
- onClose?: ((v: Event) => any) | undefined;
7
- onAdd?: ((v: string) => any) | undefined;
8
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
9
- export default _default;
10
- //# sourceMappingURL=ScriptDialog.vue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScriptDialog.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/script/dialog/ScriptDialog.vue"],"names":[],"mappings":"AA+CA,OAAO,KAAK,EAAE,kBAAkB,EAAsB,MAAM,SAAS,CAAC;;;;;;;;AAqHtE,wBAQG"}
@@ -1,8 +0,0 @@
1
- export interface IScriptDialogProps {
2
- idScript: number;
3
- }
4
- export interface IScriptDialogEmits {
5
- (e: 'add', v: string): void;
6
- (e: 'close', v: Event): void;
7
- }
8
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/script/dialog/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9B"}
@@ -1,10 +0,0 @@
1
- import { IScriptEditorProps } from './types';
2
- declare const _default: import('vue').DefineComponent<IScriptEditorProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
3
- "update:modelValue": (value: string) => any;
4
- update: (value: string) => any;
5
- }, string, import('vue').PublicProps, Readonly<IScriptEditorProps> & Readonly<{
6
- "onUpdate:modelValue"?: ((value: string) => any) | undefined;
7
- onUpdate?: ((value: string) => any) | undefined;
8
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
9
- export default _default;
10
- //# sourceMappingURL=ScriptEditor.vue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScriptEditor.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/script/editor/ScriptEditor.vue"],"names":[],"mappings":"AAkEA,OAAO,KAAK,EAAE,kBAAkB,EAAqB,MAAM,SAAS,CAAC;;;;;;;;AAkGrE,wBAQG"}
@@ -1,3 +0,0 @@
1
- export declare const normalizeScript: (code: string) => string;
2
- export declare function formatScript(codeString: string): string;
3
- //# sourceMappingURL=format.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../src/components/script/editor/format.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,WA6B3C,CAAC;AAOF,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAgEvD"}