From 2dc6f4a38afabaef2621a63a4d7157ace14636a0 Mon Sep 17 00:00:00 2001 From: Valentin Boulanger Date: Sat, 29 Nov 2025 18:01:34 +0100 Subject: [PATCH] load and unload syntax --- frontend/jsconfig.json | 38 ---------------------------------- frontend/src/runtime-events.js | 8 +++---- hardware/hardware.go | 8 +++++-- 3 files changed, 10 insertions(+), 44 deletions(-) delete mode 100644 frontend/jsconfig.json diff --git a/frontend/jsconfig.json b/frontend/jsconfig.json deleted file mode 100644 index 3918b4f..0000000 --- a/frontend/jsconfig.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "compilerOptions": { - "moduleResolution": "Node", - "target": "ESNext", - "module": "ESNext", - /** - * svelte-preprocess cannot figure out whether you have - * a value or a type, so tell TypeScript to enforce using - * `import type` instead of `import` for Types. - */ - "importsNotUsedAsValues": "error", - "isolatedModules": true, - "resolveJsonModule": true, - /** - * To have warnings / errors of the Svelte compiler at the - * correct position, enable source maps by default. - */ - "sourceMap": true, - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "baseUrl": ".", - /** - * Typecheck JS in `.svelte` and `.js` files by default. - * Disable this if you'd like to use dynamic types. - */ - "checkJs": true - }, - /** - * Use global.d.ts instead of compilerOptions.types - * to avoid limiting type declarations. - */ - "include": [ - "src/**/*.d.ts", - "src/**/*.js", - "src/**/*.svelte" - ] -} diff --git a/frontend/src/runtime-events.js b/frontend/src/runtime-events.js index d509a83..b67dfb8 100644 --- a/frontend/src/runtime-events.js +++ b/frontend/src/runtime-events.js @@ -165,10 +165,10 @@ export function initRuntimeEvents(){ EventsOn('LOAD_PROJECT', loadProject) // Handle a peripheral loaded in the project - EventsOn('LOAD_PERIPHERAL', loadPeripheral) + EventsOn('PERIPHERAL_LOAD', loadPeripheral) // Handle a peripheral unloaded from the project - EventsOn('UNLOAD_PERIPHERAL', unloadPeripheral) + EventsOn('PERIPHERAL_UNLOAD', unloadPeripheral) // Handle a peripheral event EventsOn('PERIPHERAL_EVENT_EMITTED', onPeripheralEvent) @@ -191,10 +191,10 @@ export function destroyRuntimeEvents(){ EventsOff('LOAD_PROJECT') // Handle a peripheral loaded in the project - EventsOff('LOAD_PERIPHERAL') + EventsOff('PERIPHERAL_LOAD') // Handle a peripheral unloaded from the project - EventsOff('UNLOAD_PERIPHERAL') + EventsOff('PERIPHERAL_UNLOAD') // Handle a peripheral event EventsOff('PERIPHERAL_EVENT_EMITTED') diff --git a/hardware/hardware.go b/hardware/hardware.go index e7ded7f..641e682 100644 --- a/hardware/hardware.go +++ b/hardware/hardware.go @@ -22,6 +22,10 @@ const ( PeripheralArrival PeripheralEvent = "PERIPHERAL_ARRIVAL" // PeripheralRemoval is triggered when a peripheral has been disconnected from the system PeripheralRemoval PeripheralEvent = "PERIPHERAL_REMOVAL" + // PeripheralLoad is triggered when a peripheral is added to the project + PeripheralLoad PeripheralEvent = "PERIPHERAL_LOAD" + // PeripheralUnload is triggered when a peripheral is removed from the project + PeripheralUnload PeripheralEvent = "PERIPHERAL_UNLOAD" // PeripheralStatusUpdated is triggered when a peripheral status has been updated (disconnected - connecting - deactivated - activated) PeripheralStatusUpdated PeripheralEvent = "PERIPHERAL_STATUS" // PeripheralEventEmitted is triggered when a peripheral event is emitted @@ -85,7 +89,7 @@ func (h *Manager) RegisterPeripheral(ctx context.Context, peripheralData Periphe } // Emits the event in the hardware - runtime.EventsEmit(ctx, "LOAD_PERIPHERAL", peripheralData) + runtime.EventsEmit(ctx, string(PeripheralLoad), peripheralData) return peripheralData.SerialNumber, nil } @@ -110,7 +114,7 @@ func (h *Manager) UnregisterPeripheral(ctx context.Context, peripheralData Perip } } delete(h.savedPeripherals, peripheralData.SerialNumber) - runtime.EventsEmit(ctx, "UNLOAD_PERIPHERAL", peripheralData) + runtime.EventsEmit(ctx, string(PeripheralUnload), peripheralData) return nil }