@bridgething/extension
v0.12.1
Published
The client a bridgething extension uses to reach Car Things, settings, storage, and the user's browser from its Deno process.
Maintainers
Readme
@bridgething/extension
The client a bridgething extension uses to talk to its host. An extension is a Deno process the bridgething desktop app runs beside a webapp.
bun add @bridgething/extensionimport { asJson, defineExtension, json } from '@bridgething/extension';
defineExtension({
start(ctx) {
ctx.on('device', e => ctx.log.info(e.type, e.device.name));
ctx.on('message', (device, message) =>
device.send(json({ echo: asJson(message) })),
);
},
});Register listeners synchronously in start; the host replays connected devices
as soon as start runs. The host protocol owns stdin and stdout, so
console.log corrupts it. Log with ctx.log.
Scaffold a webapp with an extension:
bun create bridgething my-app --extension