UNPKG

@kvaser/canking-api

Version:

CanKing API to communicate with the CanKing service using Node.js.

157 lines (156 loc) 5.48 kB
import { electronApiFake as y, calculateSubscriptionKey as l, deserializeFrame as u, calculateSubscriptionKeyFromFrame as w } from "./models.mjs"; import { W as k } from "./status_params.mjs"; const t = window.electron ?? y, p = (e) => e != null && typeof e.message == "string", r = (e, a, n) => { t.ipcRenderer.invoke("main-add-log-message", { time: Date.now(), logLevel: e, categoryName: a, message: n }); }; class v { categoryName; constructor(a) { this.categoryName = a; } trace(a) { r(0, this.categoryName, a); } debug(a) { r(1, this.categoryName, a); } info(a) { r(2, this.categoryName, a); } warn(a) { r(3, this.categoryName, a); } error(a, n) { typeof a == "string" ? r(4, this.categoryName, a) : p(a) && r(4, this.categoryName, a.message), p(n) && r(4, this.categoryName, n.message); } critical(a) { r(5, this.categoryName, a); } } const R = (e) => new v(e), N = async (e, a) => { await t.ipcRenderer.invoke("main-show-message-box", e, a); }, T = async (e, a, n, i, o) => await t.ipcRenderer.invoke("main-show-question-box", e, a, n, i, o), b = async () => { await t.ipcRenderer.invoke("mm-start-measurement"); }, L = async () => { await t.ipcRenderer.invoke("mm-stop-measurement"); }, D = async (e) => { await t.ipcRenderer.invoke("mm-add-source", e); }, x = async (e) => { await t.ipcRenderer.invoke("mm-update-source", e); }, P = async (e) => { await t.ipcRenderer.invoke("mm-delete-source", e); }, S = async (e, a, n) => { await t.ipcRenderer.invoke("mm-add-data-processor", e, a, n); }, I = async (e) => { await t.ipcRenderer.invoke("mm-update-data-processor", e); }, K = async (e) => { await t.ipcRenderer.invoke("mm-delete-data-processor", e); }, q = async (e) => { await t.ipcRenderer.invoke("mm-add-target", e); }, B = async (e) => { await t.ipcRenderer.invoke("mm-update-target", e); }, C = async (e) => { await t.ipcRenderer.invoke("mm-delete-target", e); }, E = async (e, a) => { await t.ipcRenderer.invoke("mm-connect-nodes", e, a); }, A = async (e, a) => { await t.ipcRenderer.invoke("mm-disconnect-nodes", e, a); }, W = async (e) => { await t.ipcRenderer.invoke("mm-enable-node", e); }, $ = async (e) => { await t.ipcRenderer.invoke("mm-disable-node", e); }, f = async (e, a) => { await t.ipcRenderer.invoke("mm-send-message", e, a); }, z = async (e, a, n, ...i) => { const o = k.fromPartial({ id: a, data: n, canFrameFlags: { flags: i } }); await f(e, o); }, Q = async (e, a) => { await t.ipcRenderer.invoke("mm-update-lin-message", e, a); }, j = async (e, a) => { await t.ipcRenderer.invoke("mm-clear-lin-message", e, a); }, G = async (e, a) => { await t.ipcRenderer.invoke("mm-request-lin-message", e, a); }, H = async (e) => await t.ipcRenderer.invoke("mm-start-periodic-transmission", e), J = async (e, a) => { await t.ipcRenderer.invoke("mm-update-periodic-transmission", e, a); }, O = async (e) => { await t.ipcRenderer.invoke("mm-stop-periodic-transmission", e); }, U = async (e) => { await t.ipcRenderer.invoke("mm-start-log-replay", e); }, V = async (e) => { await t.ipcRenderer.invoke("mm-stop-log-replay", e); }, X = async () => await t.ipcRenderer.invoke("mm-get-message-log-file-formats"), Y = async () => await t.ipcRenderer.invoke("mm-get-signal-log-file-formats"), Z = async (e) => { try { const a = await t.ipcRenderer.invoke("mm-get-frame-definitions-with-meta", e); return a?.truncated && R("ipc").warn(`Frame definitions response was truncated by IPC payload limits. Returned ${a.items.length} of ${a.originalCount}.`), a?.items ?? []; } catch { return await t.ipcRenderer.invoke("mm-get-frame-definitions", e); } }, _ = async (e, a, n) => { const i = await t.ipcRenderer.invoke("mm-get-measurement-data-before-timestamp", e, a); if (n && n.length > 0) { const o = /* @__PURE__ */ new Map(); return n.forEach((s) => { const c = l(s); o.set(c, { ignoreSource: s.sourceId === void 0 || s.sourceId === "", ignoreDirection: s.tx === void 0, ignoreMux: s.mux === void 0 }); }), i.filter((s) => { const c = u(s); let d = !1; return o.forEach((m, g) => { w(c, m.ignoreSource, m.ignoreDirection, m.ignoreMux) === g && (d = !0); }), d; }); } return i; }, ee = async () => await t.ipcRenderer.invoke("mm-get-first-timestamp"), ae = async () => await t.ipcRenderer.invoke("mm-get-latest-timestamp"), te = async () => await t.ipcRenderer.invoke("mm-get-first-and-latest-timestamp"); export { S as addDataProcessor, D as addSource, q as addTarget, j as clearLinMessage, E as connectNodes, K as deleteDataProcessor, P as deleteSource, C as deleteTarget, $ as disableNode, A as disconnectNodes, W as enableNode, te as getFirstAndLatestTimestamp, ee as getFirstTimestamp, Z as getFrameDefinitions, ae as getLatestTimestamp, R as getLogger, _ as getMessageDataBeforeTimestamp, X as getMessageLogFileFormats, Y as getSignalLogFileFormats, G as requestLinMessage, z as sendCanMessage, f as sendMessage, N as showMessageBox, T as showQuestionBox, U as startLogReplay, b as startMeasurement, H as startPeriodicTransmission, V as stopLogReplay, L as stopMeasurement, O as stopPeriodicTransmission, I as updateDataProcessor, Q as updateLinMessage, J as updatePeriodicTransmission, x as updateSource, B as updateTarget };