Skip to content

Commit 4275bdd

Browse files
authored
Remove deprecated meshtastic/js dependency (#638)
* Remove deprecated meshtastic/js dependency * Bump dependency version * Fix linting --------- Co-authored-by: philon- <philon-@users.noreply.github.com>
1 parent 828e5d0 commit 4275bdd

6 files changed

Lines changed: 21 additions & 27 deletions

File tree

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@
3636
"dependencies": {
3737
"@bufbuild/protobuf": "^2.2.5",
3838
"@meshtastic/core": "npm:@jsr/meshtastic__core@2.6.2",
39-
"@meshtastic/js": "npm:@jsr/meshtastic__js@2.6.0-0",
40-
"@meshtastic/transport-http": "npm:@jsr/meshtastic__transport-http",
41-
"@meshtastic/transport-web-bluetooth": "npm:@jsr/meshtastic__transport-web-bluetooth",
42-
"@meshtastic/transport-web-serial": "npm:@jsr/meshtastic__transport-web-serial",
39+
"@meshtastic/transport-http": "npm:@jsr/meshtastic__transport-http@0.2.1",
40+
"@meshtastic/transport-web-bluetooth": "npm:@jsr/meshtastic__transport-web-bluetooth@0.1.2",
41+
"@meshtastic/transport-web-serial": "npm:@jsr/meshtastic__transport-web-serial@0.2.1",
4342
"@noble/curves": "^1.9.0",
4443
"@radix-ui/react-accordion": "^1.2.8",
4544
"@radix-ui/react-checkbox": "^1.2.3",

src/components/Dialog/UnsafeRolesDialog/UnsafeRolesDialog.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe.skip("UnsafeRolesDialog", () => {
3434

3535
it("renders the dialog when open is true", () => {
3636
renderWithProviders(
37-
<UnsafeRolesDialog open={true} onOpenChange={vi.fn()} />,
37+
<UnsafeRolesDialog open onOpenChange={vi.fn()} />,
3838
);
3939

4040
const dialog = screen.getByRole("dialog");
@@ -52,7 +52,7 @@ describe.skip("UnsafeRolesDialog", () => {
5252

5353
it("displays the correct links", () => {
5454
renderWithProviders(
55-
<UnsafeRolesDialog open={true} onOpenChange={vi.fn()} />,
55+
<UnsafeRolesDialog open onOpenChange={vi.fn()} />,
5656
);
5757

5858
const docLink = screen.getByRole("link", {
@@ -74,7 +74,7 @@ describe.skip("UnsafeRolesDialog", () => {
7474

7575
it("does not allow confirmation until checkbox is checked", () => {
7676
renderWithProviders(
77-
<UnsafeRolesDialog open={true} onOpenChange={vi.fn()} />,
77+
<UnsafeRolesDialog open onOpenChange={vi.fn()} />,
7878
);
7979

8080
const confirmButton = screen.getByRole("button", { name: /confirm/i });
@@ -90,7 +90,7 @@ describe.skip("UnsafeRolesDialog", () => {
9090
it("emits the correct event when closing via close button", () => {
9191
const eventSpy = vi.spyOn(eventBus, "emit");
9292
renderWithProviders(
93-
<UnsafeRolesDialog open={true} onOpenChange={vi.fn()} />,
93+
<UnsafeRolesDialog open onOpenChange={vi.fn()} />,
9494
);
9595

9696
const dismissButton = screen.getByRole("button", { name: /close/i });
@@ -104,7 +104,7 @@ describe.skip("UnsafeRolesDialog", () => {
104104
it("emits the correct event when dismissing", () => {
105105
const eventSpy = vi.spyOn(eventBus, "emit");
106106
renderWithProviders(
107-
<UnsafeRolesDialog open={true} onOpenChange={vi.fn()} />,
107+
<UnsafeRolesDialog open onOpenChange={vi.fn()} />,
108108
);
109109

110110
const dismissButton = screen.getByRole("button", { name: /dismiss/i });
@@ -118,7 +118,7 @@ describe.skip("UnsafeRolesDialog", () => {
118118
it("emits the correct event when confirming", () => {
119119
const eventSpy = vi.spyOn(eventBus, "emit");
120120
renderWithProviders(
121-
<UnsafeRolesDialog open={true} onOpenChange={vi.fn()} />,
121+
<UnsafeRolesDialog open onOpenChange={vi.fn()} />,
122122
);
123123

124124
const checkbox = screen.getByRole("checkbox");

src/components/PageComponents/Connect/BLE.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import { useAppStore } from "@core/stores/appStore.ts";
55
import { useDeviceStore } from "@core/stores/deviceStore.ts";
66
import { subscribeAll } from "@core/subscriptions.ts";
77
import { randId } from "@core/utils/randId.ts";
8-
import { BleConnection, ServiceUuid } from "@meshtastic/js";
8+
import { TransportWebBluetooth } from "@meshtastic/transport-web-bluetooth";
9+
import { MeshDevice } from "@meshtastic/core";
910
import { useCallback, useEffect, useState } from "react";
10-
import { useMessageStore } from "../../../core/stores/messageStore/index.ts";
11+
import { useMessageStore } from "@core/stores/messageStore/index.ts";
1112
import { useTranslation } from "react-i18next";
1213

1314
export const BLE = (
@@ -30,15 +31,13 @@ export const BLE = (
3031

3132
const onConnect = async (bleDevice: BluetoothDevice) => {
3233
const id = randId();
34+
const transport = await TransportWebBluetooth.createFromDevice(bleDevice);
3335
const device = addDevice(id);
36+
const connection = new MeshDevice(transport, id);
37+
connection.configure();
3438
setSelectedDevice(id);
35-
const connection = new BleConnection(id);
36-
await connection.connect({
37-
device: bleDevice,
38-
});
3939
device.addConnection(connection);
4040
subscribeAll(device, connection, messageStore);
41-
4241
closeDialog();
4342
};
4443

@@ -71,7 +70,7 @@ export const BLE = (
7170
onClick={async () => {
7271
await navigator.bluetooth
7372
.requestDevice({
74-
filters: [{ services: [ServiceUuid] }],
73+
filters: [{ services: [TransportWebBluetooth.ServiceUuid] }],
7574
})
7675
.then((device) => {
7776
const exists = bleDevices.findIndex((d) => d.id === device.id);

src/components/PageComponents/Messages/MessageItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
MessageState,
1616
useMessageStore,
1717
} from "@core/stores/messageStore/index.ts";
18-
import { Protobuf, Types } from "@meshtastic/js";
18+
import { Protobuf, Types } from "@meshtastic/core";
1919
import { Message } from "@core/stores/messageStore/types.ts";
2020
import { useTranslation } from "react-i18next";
2121
// import { MessageActionsMenu } from "@components/PageComponents/Messages/MessageActionsMenu.tsx"; // TODO: Uncomment when actions menu is implemented

src/core/dto/PacketToMessageDTO.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import type { Types } from "@meshtastic/js";
2-
import {
3-
Message,
4-
MessageState,
5-
MessageType,
6-
} from "../stores/messageStore/index.ts";
7-
1+
import type { Types } from "@meshtastic/core";
2+
import { MessageState, MessageType } from "@core/stores/messageStore/index.ts";
3+
import { Message } from "@core/stores/messageStore/types.ts";
84
class PacketToMessageDTO {
95
channel: Types.ChannelNumber;
106
to: number;

src/pages/Messages.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export const MessagesPage = () => {
140140
} else {
141141
console.warn("sendText completed but messageId is undefined");
142142
}
143-
} catch (e: any) {
143+
} catch (e: unknown) {
144144
console.error("Failed to send message:", e);
145145
const failedId = messageId ?? randId();
146146
if (chatType === MessageType.Broadcast) {

0 commit comments

Comments
 (0)