QML's JS engine does not support ES module export/import syntax. Replace bare export with a CommonJS guard that only runs under Node.js, so the plugin loads in QML while tests still work.
21 lines
661 B
JavaScript
21 lines
661 B
JavaScript
function parsePeers(peerMap) {
|
|
if (!peerMap) return []
|
|
return Object.keys(peerMap).map(function (key) {
|
|
var p = peerMap[key]
|
|
return {
|
|
hostname: p.HostName || key,
|
|
ip: (p.TailscaleIPs && p.TailscaleIPs.length) ? p.TailscaleIPs[0] : "",
|
|
online: p.Online || false,
|
|
exitNode: p.ExitNodeOption || false
|
|
}
|
|
})
|
|
}
|
|
|
|
function makeExitNodeCommand(hostname) {
|
|
return ["tailscale", "set", "--exit-node=" + hostname]
|
|
}
|
|
|
|
// CommonJS export for Node.js tests (ignored by QML)
|
|
if (typeof module !== "undefined" && module.exports) {
|
|
module.exports = { parsePeers, makeExitNodeCommand }
|
|
}
|