* support for iframebridge

* patch: update jacdac-ts
This commit is contained in:
Peli de Halleux 2021-09-27 15:31:25 -07:00 коммит произвёл GitHub
Родитель 1a12fdc18d
Коммит 3d77ca5d8a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 450 добавлений и 395 удалений

Просмотреть файл

@ -31,37 +31,37 @@
}
},
"dependencies": {
"jacdac-ts": "^1.16.32",
"jacdac-ts": "^1.18.0",
"webusb": "^2.2.0"
},
"devDependencies": {
"@rollup/plugin-typescript": "^8.2.5",
"@semantic-release/exec": "^5.0.0",
"@semantic-release/git": "^9.0.1",
"@semantic-release/exec": "^6.0.1",
"@semantic-release/git": "^10.0.0",
"@types/express": "^4.17.13",
"@types/jest": "^27.0.1",
"@types/node": "^16.9.1",
"@types/jest": "^27.0.2",
"@types/node": "^16.10.1",
"@types/node-red": "^1.1.1",
"@types/node-red-node-test-helper": "^0.2.2",
"@types/sinon": "^10.0.2",
"@types/sinon": "^10.0.4",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"colorette": "^1.4.0",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"colorette": "^2.0.12",
"concurrently": "^6.2.1",
"copyfiles": "^2.4.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^24.4.0",
"glob": "^7.1.7",
"jest": "^27.2.0",
"eslint-plugin-jest": "^24.4.2",
"glob": "^7.2.0",
"jest": "^27.2.2",
"mustache": "^4.2.0",
"node-red": "^2.0.6",
"node-red-node-test-helper": "^0.2.7",
"onchange": "^7.1.0",
"prettier": "^2.4.0",
"rollup": "^2.56.3",
"semantic-release": "^17.4.7",
"prettier": "^2.4.1",
"rollup": "^2.57.0",
"semantic-release": "^18.0.0",
"ts-jest": "^27.0.5",
"typescript": "^4.4.3"
},

Просмотреть файл

@ -23,7 +23,7 @@ const nodeInit: NodeInitializer = (RED): void => {
const { payload } = msg
for (const dev of bus
.devices({ ignoreSelf: true, announced: true })
.devices({ ignoreInfrastructure: true, announced: true })
.filter(filterDevice)) {
for (const srv of dev
.services({ specification: true })

Просмотреть файл

@ -1,5 +1,13 @@
import { Node } from "node-red";
import { createUSBTransport, createNodeUSBOptions, JDBus, CONNECTION_STATE, JDDevice, DEVICE_ANNOUNCE, CONNECT } from "jacdac-ts"
import { Node } from "node-red"
import {
createUSBTransport,
createNodeUSBOptions,
JDBus,
CONNECTION_STATE,
JDDevice,
DEVICE_ANNOUNCE,
CONNECT,
} from "jacdac-ts"
const opts = createNodeUSBOptions()
const transport = createUSBTransport(opts)
@ -8,8 +16,11 @@ export const bus = new JDBus([transport])
export function connectStatus(node: Node) {
const updateStatus = () => {
node.log(`connection: ${bus.connected ? "connected" : "disconnected"}`)
node.status(bus.connected ? { fill: "green", shape: "dot", text: "connected" }
: { fill: "red", shape: "ring" })
node.status(
bus.connected
? { fill: "green", shape: "dot", text: "connected" }
: { fill: "red", shape: "ring" }
)
}
bus.on(CONNECTION_STATE, updateStatus)
@ -18,9 +29,12 @@ export function connectStatus(node: Node) {
bus.connect()
}
export function connectNode(node: Node, registerDevice: (dev: JDDevice) => void) {
export function connectNode(
node: Node,
registerDevice: (dev: JDDevice) => void
) {
const registerAllDevices = () => {
for (const dev of bus.devices({ ignoreSelf: true }))
for (const dev of bus.devices({ ignoreInfrastructure: true }))
registerDevice(dev)
}
@ -32,9 +46,8 @@ export function connectNode(node: Node, registerDevice: (dev: JDDevice) => void)
}
export function cleanPayload(payload: any) {
for(const key in payload) {
if (payload[key] === undefined)
delete payload[key]
for (const key in payload) {
if (payload[key] === undefined) delete payload[key]
}
return payload
}
}

780
yarn.lock

Разница между файлами не показана из-за своего большого размера Загрузить разницу