From 4275bdd0c0d4e4d8d100eeb7d7c07e048ceb4e93 Mon Sep 17 00:00:00 2001 From: Jeremy Gallant <8975765+philon-@users.noreply.github.com> Date: Wed, 11 Jun 2025 16:09:29 +0200 Subject: [PATCH] Remove deprecated meshtastic/js dependency (#638) * Remove deprecated meshtastic/js dependency * Bump dependency version * Fix linting --------- Co-authored-by: philon- --- package.json | 7 +++---- .../UnsafeRolesDialog/UnsafeRolesDialog.test.tsx | 12 ++++++------ src/components/PageComponents/Connect/BLE.tsx | 15 +++++++-------- .../PageComponents/Messages/MessageItem.tsx | 2 +- src/core/dto/PacketToMessageDTO.ts | 10 +++------- src/pages/Messages.tsx | 2 +- 6 files changed, 21 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index 47ef278c..77709964 100644 --- a/package.json +++ b/package.json @@ -36,10 +36,9 @@ "dependencies": { "@bufbuild/protobuf": "^2.2.5", "@meshtastic/core": "npm:@jsr/meshtastic__core@2.6.2", - "@meshtastic/js": "npm:@jsr/meshtastic__js@2.6.0-0", - "@meshtastic/transport-http": "npm:@jsr/meshtastic__transport-http", - "@meshtastic/transport-web-bluetooth": "npm:@jsr/meshtastic__transport-web-bluetooth", - "@meshtastic/transport-web-serial": "npm:@jsr/meshtastic__transport-web-serial", + "@meshtastic/transport-http": "npm:@jsr/meshtastic__transport-http@0.2.1", + "@meshtastic/transport-web-bluetooth": "npm:@jsr/meshtastic__transport-web-bluetooth@0.1.2", + "@meshtastic/transport-web-serial": "npm:@jsr/meshtastic__transport-web-serial@0.2.1", "@noble/curves": "^1.9.0", "@radix-ui/react-accordion": "^1.2.8", "@radix-ui/react-checkbox": "^1.2.3", diff --git a/src/components/Dialog/UnsafeRolesDialog/UnsafeRolesDialog.test.tsx b/src/components/Dialog/UnsafeRolesDialog/UnsafeRolesDialog.test.tsx index b174eea8..1584f7e8 100644 --- a/src/components/Dialog/UnsafeRolesDialog/UnsafeRolesDialog.test.tsx +++ b/src/components/Dialog/UnsafeRolesDialog/UnsafeRolesDialog.test.tsx @@ -34,7 +34,7 @@ describe.skip("UnsafeRolesDialog", () => { it("renders the dialog when open is true", () => { renderWithProviders( - , + , ); const dialog = screen.getByRole("dialog"); @@ -52,7 +52,7 @@ describe.skip("UnsafeRolesDialog", () => { it("displays the correct links", () => { renderWithProviders( - , + , ); const docLink = screen.getByRole("link", { @@ -74,7 +74,7 @@ describe.skip("UnsafeRolesDialog", () => { it("does not allow confirmation until checkbox is checked", () => { renderWithProviders( - , + , ); const confirmButton = screen.getByRole("button", { name: /confirm/i }); @@ -90,7 +90,7 @@ describe.skip("UnsafeRolesDialog", () => { it("emits the correct event when closing via close button", () => { const eventSpy = vi.spyOn(eventBus, "emit"); renderWithProviders( - , + , ); const dismissButton = screen.getByRole("button", { name: /close/i }); @@ -104,7 +104,7 @@ describe.skip("UnsafeRolesDialog", () => { it("emits the correct event when dismissing", () => { const eventSpy = vi.spyOn(eventBus, "emit"); renderWithProviders( - , + , ); const dismissButton = screen.getByRole("button", { name: /dismiss/i }); @@ -118,7 +118,7 @@ describe.skip("UnsafeRolesDialog", () => { it("emits the correct event when confirming", () => { const eventSpy = vi.spyOn(eventBus, "emit"); renderWithProviders( - , + , ); const checkbox = screen.getByRole("checkbox"); diff --git a/src/components/PageComponents/Connect/BLE.tsx b/src/components/PageComponents/Connect/BLE.tsx index 44aa508b..a3458792 100644 --- a/src/components/PageComponents/Connect/BLE.tsx +++ b/src/components/PageComponents/Connect/BLE.tsx @@ -5,9 +5,10 @@ import { useAppStore } from "@core/stores/appStore.ts"; import { useDeviceStore } from "@core/stores/deviceStore.ts"; import { subscribeAll } from "@core/subscriptions.ts"; import { randId } from "@core/utils/randId.ts"; -import { BleConnection, ServiceUuid } from "@meshtastic/js"; +import { TransportWebBluetooth } from "@meshtastic/transport-web-bluetooth"; +import { MeshDevice } from "@meshtastic/core"; import { useCallback, useEffect, useState } from "react"; -import { useMessageStore } from "../../../core/stores/messageStore/index.ts"; +import { useMessageStore } from "@core/stores/messageStore/index.ts"; import { useTranslation } from "react-i18next"; export const BLE = ( @@ -30,15 +31,13 @@ export const BLE = ( const onConnect = async (bleDevice: BluetoothDevice) => { const id = randId(); + const transport = await TransportWebBluetooth.createFromDevice(bleDevice); const device = addDevice(id); + const connection = new MeshDevice(transport, id); + connection.configure(); setSelectedDevice(id); - const connection = new BleConnection(id); - await connection.connect({ - device: bleDevice, - }); device.addConnection(connection); subscribeAll(device, connection, messageStore); - closeDialog(); }; @@ -71,7 +70,7 @@ export const BLE = ( onClick={async () => { await navigator.bluetooth .requestDevice({ - filters: [{ services: [ServiceUuid] }], + filters: [{ services: [TransportWebBluetooth.ServiceUuid] }], }) .then((device) => { const exists = bleDevices.findIndex((d) => d.id === device.id); diff --git a/src/components/PageComponents/Messages/MessageItem.tsx b/src/components/PageComponents/Messages/MessageItem.tsx index ea8dce86..7a932a1d 100644 --- a/src/components/PageComponents/Messages/MessageItem.tsx +++ b/src/components/PageComponents/Messages/MessageItem.tsx @@ -15,7 +15,7 @@ import { MessageState, useMessageStore, } from "@core/stores/messageStore/index.ts"; -import { Protobuf, Types } from "@meshtastic/js"; +import { Protobuf, Types } from "@meshtastic/core"; import { Message } from "@core/stores/messageStore/types.ts"; import { useTranslation } from "react-i18next"; // import { MessageActionsMenu } from "@components/PageComponents/Messages/MessageActionsMenu.tsx"; // TODO: Uncomment when actions menu is implemented diff --git a/src/core/dto/PacketToMessageDTO.ts b/src/core/dto/PacketToMessageDTO.ts index 6b50ebb4..f6d4c575 100644 --- a/src/core/dto/PacketToMessageDTO.ts +++ b/src/core/dto/PacketToMessageDTO.ts @@ -1,10 +1,6 @@ -import type { Types } from "@meshtastic/js"; -import { - Message, - MessageState, - MessageType, -} from "../stores/messageStore/index.ts"; - +import type { Types } from "@meshtastic/core"; +import { MessageState, MessageType } from "@core/stores/messageStore/index.ts"; +import { Message } from "@core/stores/messageStore/types.ts"; class PacketToMessageDTO { channel: Types.ChannelNumber; to: number; diff --git a/src/pages/Messages.tsx b/src/pages/Messages.tsx index 95d167b9..7e58d9ab 100644 --- a/src/pages/Messages.tsx +++ b/src/pages/Messages.tsx @@ -140,7 +140,7 @@ export const MessagesPage = () => { } else { console.warn("sendText completed but messageId is undefined"); } - } catch (e: any) { + } catch (e: unknown) { console.error("Failed to send message:", e); const failedId = messageId ?? randId(); if (chatType === MessageType.Broadcast) {