diff --git a/bun.lock b/bun.lock index 378b1a1f..8bbaa95a 100644 --- a/bun.lock +++ b/bun.lock @@ -5,7 +5,9 @@ "name": "meshtastic-web", "dependencies": { "@bufbuild/protobuf": "^2.2.3", + "@meshtastic/core": "npm:@jsr/meshtastic__core@2.6.0-0", "@meshtastic/js": "npm:@jsr/meshtastic__js@2.6.0-0", + "@meshtastic/transport-web-serial": "npm:@jsr/meshtastic__transport-web-serial", "@noble/curves": "^1.8.1", "@radix-ui/react-accordion": "^1.2.3", "@radix-ui/react-checkbox": "^1.1.4", @@ -359,6 +361,8 @@ "@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.25", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ=="], + "@jsr/meshtastic__core": ["@jsr/meshtastic__core@2.6.0-0", "https://npm.jsr.io/~/11/@jsr/meshtastic__core/2.6.0-0.tgz", { "dependencies": { "@bufbuild/protobuf": "^2.2.3", "@jsr/meshtastic__protobufs": "^2.6.0", "crc": "^4.3.2", "ste-simple-events": "^3.0.11", "tslog": "^4.9.3" } }, "sha512-Ks71sRagbBipotznULpsJZ1EMcQIqCEJQx6mf628dmCNVf2YECi2zi/i/5zErp1hGPgfbDvCz9oPogvsd/7fMA=="], + "@jsr/meshtastic__protobufs": ["@jsr/meshtastic__protobufs@2.6.0", "https://npm.jsr.io/~/11/@jsr/meshtastic__protobufs/2.6.0.tgz", { "dependencies": { "@bufbuild/protobuf": "^2.2.3" } }, "sha512-CGlgBdzAuQCZuGPrnzP8zU+EcLlmyYeeMbqFHuJ834cYfArWXDjDh1UYaPo2rI03LTjqa3MeWpfqDlzBR8kIMg=="], "@mapbox/geojson-rewind": ["@mapbox/geojson-rewind@0.5.2", "", { "dependencies": { "get-stream": "^6.0.1", "minimist": "^1.2.6" }, "bin": { "geojson-rewind": "geojson-rewind" } }, "sha512-tJaT+RbYGJYStt7wI3cq4Nl4SXxG8W7JDG5DMJu97V25RnbNg3QtQtf+KD+VLjNpWKYsRvXDNmNrBgEETr1ifA=="], @@ -379,8 +383,12 @@ "@maplibre/maplibre-gl-style-spec": ["@maplibre/maplibre-gl-style-spec@23.1.0", "", { "dependencies": { "@mapbox/jsonlint-lines-primitives": "~2.0.2", "@mapbox/unitbezier": "^0.0.1", "json-stringify-pretty-compact": "^4.0.0", "minimist": "^1.2.8", "quickselect": "^3.0.0", "rw": "^1.3.3", "tinyqueue": "^3.0.0" }, "bin": { "gl-style-migrate": "dist/gl-style-migrate.mjs", "gl-style-validate": "dist/gl-style-validate.mjs", "gl-style-format": "dist/gl-style-format.mjs" } }, "sha512-R6/ihEuC5KRexmKIYkWqUv84Gm+/QwsOUgHyt1yy2XqCdGdLvlBWVWIIeTZWN4NGdwmY6xDzdSGU2R9oBLNg2w=="], + "@meshtastic/core": ["@jsr/meshtastic__core@2.6.0-0", "https://npm.jsr.io/~/11/@jsr/meshtastic__core/2.6.0-0.tgz", { "dependencies": { "@bufbuild/protobuf": "^2.2.3", "@jsr/meshtastic__protobufs": "^2.6.0", "crc": "^4.3.2", "ste-simple-events": "^3.0.11", "tslog": "^4.9.3" } }, "sha512-Ks71sRagbBipotznULpsJZ1EMcQIqCEJQx6mf628dmCNVf2YECi2zi/i/5zErp1hGPgfbDvCz9oPogvsd/7fMA=="], + "@meshtastic/js": ["@jsr/meshtastic__js@2.6.0-0", "https://npm.jsr.io/~/11/@jsr/meshtastic__js/2.6.0-0.tgz", { "dependencies": { "@bufbuild/protobuf": "^2.2.3", "@jsr/meshtastic__protobufs": "^2.6.0", "crc": "^4.3.2", "ste-simple-events": "^3.0.11", "tslog": "^4.9.3" } }, "sha512-+xpZpxK6oUIVOuEs7C+LyxRr2druvc7UNNNTK9Rl8ioXj63Jz1uQXlYe2Gj0xjnRAiSQLR7QVaPef21BR/YTxA=="], + "@meshtastic/transport-web-serial": ["@jsr/meshtastic__transport-web-serial@0.2.0", "https://npm.jsr.io/~/11/@jsr/meshtastic__transport-web-serial/0.2.0.tgz", { "dependencies": { "@jsr/meshtastic__core": "^2.6.0-0" } }, "sha512-mP/nxOj0syABh3FkG5iIolWhUMiFh/qtJtvqihxLkaRoxdabUyW62mOtfhCMBEjxgVnKg4Gy7GkaXfC/eFy19Q=="], + "@noble/curves": ["@noble/curves@1.8.1", "", { "dependencies": { "@noble/hashes": "1.7.1" } }, "sha512-warwspo+UYUPep0Q+vtdVB4Ugn8GGQj8iyB3gnRWsztmUHTI3S1nhdiWNsPUGL0vud7JlRRk1XEu7Lq1KGTnMQ=="], "@noble/hashes": ["@noble/hashes@1.7.1", "", {}, "sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ=="], diff --git a/package.json b/package.json index 6b060bcb..c001aff5 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,9 @@ "homepage": "https://meshtastic.org", "dependencies": { "@bufbuild/protobuf": "^2.2.3", + "@meshtastic/core": "npm:@jsr/meshtastic__core@2.6.0-0", "@meshtastic/js": "npm:@jsr/meshtastic__js@2.6.0-0", + "@meshtastic/transport-web-serial": "npm:@jsr/meshtastic__transport-web-serial", "@noble/curves": "^1.8.1", "@radix-ui/react-accordion": "^1.2.3", "@radix-ui/react-checkbox": "^1.1.4", diff --git a/src/components/Dialog/DeviceNameDialog.tsx b/src/components/Dialog/DeviceNameDialog.tsx index 44fe6d7a..655840cc 100644 --- a/src/components/Dialog/DeviceNameDialog.tsx +++ b/src/components/Dialog/DeviceNameDialog.tsx @@ -11,7 +11,7 @@ import { } from "@components/UI/Dialog.tsx"; import { Input } from "@components/UI/Input.tsx"; import { Label } from "@components/UI/Label.tsx"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { useForm } from "react-hook-form"; export interface User { diff --git a/src/components/Dialog/ImportDialog.tsx b/src/components/Dialog/ImportDialog.tsx index 3823538c..91947608 100644 --- a/src/components/Dialog/ImportDialog.tsx +++ b/src/components/Dialog/ImportDialog.tsx @@ -13,7 +13,7 @@ import { Input } from "@components/UI/Input.tsx"; import { Label } from "@components/UI/Label.tsx"; import { Switch } from "@components/UI/Switch.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { toByteArray } from "base64-js"; import { type JSX, useEffect, useState } from "react"; @@ -73,10 +73,9 @@ export const ImportDialog = ({ connection?.setChannel( create(Protobuf.Channel.ChannelSchema, { index, - role: - index === 0 - ? Protobuf.Channel.Channel_Role.PRIMARY - : Protobuf.Channel.Channel_Role.SECONDARY, + role: index === 0 + ? Protobuf.Channel.Channel_Role.PRIMARY + : Protobuf.Channel.Channel_Role.SECONDARY, settings: ch, }), ); @@ -123,21 +122,25 @@ export const ImportDialog = ({ checked={channelSet?.loraConfig?.usePreset ?? true} /> - {/* */} + */ + } - {/* */} + */ + } Channels: diff --git a/src/components/Dialog/LocationResponseDialog.tsx b/src/components/Dialog/LocationResponseDialog.tsx index 825046e6..5c79c487 100644 --- a/src/components/Dialog/LocationResponseDialog.tsx +++ b/src/components/Dialog/LocationResponseDialog.tsx @@ -6,7 +6,7 @@ import { DialogHeader, DialogTitle, } from "@components/UI/Dialog"; -import type { Protobuf, Types } from "@meshtastic/js"; +import type { Protobuf, Types } from "@meshtastic/core"; import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; import type { JSX } from "react"; @@ -24,11 +24,9 @@ export const LocationResponseDialog = ({ const { nodes } = useDevice(); const from = nodes.get(location?.from ?? 0); - const longName = - from?.user?.longName ?? + const longName = from?.user?.longName ?? (from ? `!${numberToHexUnpadded(from?.num)}` : "Unknown"); - const shortName = - from?.user?.shortName ?? + const shortName = from?.user?.shortName ?? (from ? `${numberToHexUnpadded(from?.num).substring(0, 4)}` : "UNK"); return ( @@ -44,7 +42,9 @@ export const LocationResponseDialog = ({ Coordinates:{" "} diff --git a/src/components/Dialog/NodeDetailsDialog.tsx b/src/components/Dialog/NodeDetailsDialog.tsx index b3a8f1a1..325da884 100644 --- a/src/components/Dialog/NodeDetailsDialog.tsx +++ b/src/components/Dialog/NodeDetailsDialog.tsx @@ -13,7 +13,7 @@ import { DialogHeader, DialogTitle, } from "@components/UI/Dialog"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; import { DeviceImage } from "../generic/DeviceImage"; import { TimeAgo } from "../generic/TimeAgo"; @@ -32,132 +32,159 @@ export const NodeDetailsDialog = ({ const { nodeNumDetails } = useAppStore(); const device: Protobuf.Mesh.NodeInfo = nodes.get(nodeNumDetails); - return device ? ( - - - - - Node Details for {device.user?.longName ?? "UNKNOWN"} ( - {device.user?.shortName ?? "UNK"}) - - - -
- -
-

- Details: -

-

- Hardware:{" "} - {Protobuf.Mesh.HardwareModel[device.user?.hwModel ?? 0]} -

-

Node Number: {device.num}

-

Node HEX: !{numberToHexUnpadded(device.num)}

-

- Role:{" "} - { - Protobuf.Config.Config_DeviceConfig_Role[ - device.user?.role ?? 0 - ] - } -

-

- Last Heard:{" "} - {device.lastHeard === 0 ? ( - "Never" - ) : ( - - )} -

-
- - {device.position ? ( -
+ return device + ? ( + + + + + Node Details for {device.user?.longName ?? "UNKNOWN"} ( + {device.user?.shortName ?? "UNK"}) + + + +
+ +

- Position: + Details:

- {device.position.latitudeI && device.position.longitudeI ? ( -

- Coordinates:{" "} - - {device.position.latitudeI / 1e7},{" "} - {device.position.longitudeI / 1e7} - -

- ) : null} - {device.position.altitude ? ( -

Altitude: {device.position.altitude}m

- ) : null} -
- ) : null} - - {device.deviceMetrics ? ( -
-

- Device Metrics: +

+ Hardware:{" "} + {Protobuf.Mesh.HardwareModel[device.user?.hwModel ?? 0]} +

+

Node Number: {device.num}

+

Node HEX: !{numberToHexUnpadded(device.num)}

+

+ Role: {Protobuf.Config.Config_DeviceConfig_Role[ + device.user?.role ?? 0 + ]} +

+

+ Last Heard: {device.lastHeard === 0 + ? ( + "Never" + ) + : }

- {device.deviceMetrics.airUtilTx ? ( -

- Air TX utilization:{" "} - {device.deviceMetrics.airUtilTx.toFixed(2)}% -

- ) : null} - {device.deviceMetrics.channelUtilization ? ( -

- Channel utilization:{" "} - {device.deviceMetrics.channelUtilization.toFixed(2)}% -

- ) : null} - {device.deviceMetrics.batteryLevel ? ( -

- Battery level:{" "} - {device.deviceMetrics.batteryLevel.toFixed(2)}% -

- ) : null} - {device.deviceMetrics.voltage ? ( -

Voltage: {device.deviceMetrics.voltage.toFixed(2)}V

- ) : null} - {device.deviceMetrics.uptimeSeconds ? ( -

- Uptime:{" "} - -

- ) : null}
- ) : null} - {device ? ( -
- - - -

- All Raw Metrics: -

-
- -
+              {device.position
+                ? (
+                  
+

+ Position: +

+ {device.position.latitudeI && device.position.longitudeI + ? ( +

+ Coordinates:{" "} + + {device.position.latitudeI / 1e7},{" "} + {device.position.longitudeI / 1e7} + +

+ ) + : null} + {device.position.altitude + ?

Altitude: {device.position.altitude}m

+ : null} +
+ ) + : null} + + {device.deviceMetrics + ? ( +
+

+ Device Metrics: +

+ {device.deviceMetrics.airUtilTx + ? ( +

+ Air TX utilization:{" "} + {device.deviceMetrics.airUtilTx.toFixed(2)}% +

+ ) + : null} + {device.deviceMetrics.channelUtilization + ? ( +

+ Channel utilization:{" "} + {device.deviceMetrics.channelUtilization.toFixed(2)}% +

+ ) + : null} + {device.deviceMetrics.batteryLevel + ? ( +

+ Battery level:{" "} + {device.deviceMetrics.batteryLevel.toFixed(2)}% +

+ ) + : null} + {device.deviceMetrics.voltage + ? ( +

+ Voltage: {device.deviceMetrics.voltage.toFixed(2)}V +

+ ) + : null} + {device.deviceMetrics.uptimeSeconds + ? ( +

+ Uptime:{" "} + +

+ ) + : null} +
+ ) + : null} + + {device + ? ( +
+ + + +

+ All Raw Metrics: +

+
+ +
                         {JSON.stringify(device, null, 2)}
-                      
-
-
-
-
- ) : null} -
- - - - ) : null; + + + + +
+ ) + : null} +
+ + + + ) + : null; }; diff --git a/src/components/Dialog/NodeOptionsDialog.tsx b/src/components/Dialog/NodeOptionsDialog.tsx index d62e4065..d95ea7ab 100644 --- a/src/components/Dialog/NodeOptionsDialog.tsx +++ b/src/components/Dialog/NodeOptionsDialog.tsx @@ -7,7 +7,7 @@ import { DialogHeader, DialogTitle, } from "@components/UI/Dialog"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; import { TrashIcon } from "lucide-react"; import type { JSX } from "react"; @@ -31,11 +31,9 @@ export const NodeOptionsDialog = ({ setChatType, setActiveChat, } = useAppStore(); - const longName = - node?.user?.longName ?? + const longName = node?.user?.longName ?? (node ? `!${numberToHexUnpadded(node?.num)}` : "Unknown"); - const shortName = - node?.user?.shortName ?? + const shortName = node?.user?.shortName ?? (node ? `${numberToHexUnpadded(node?.num).substring(0, 4)}` : "UNK"); function handleDirectMessage() { @@ -53,7 +51,7 @@ export const NodeOptionsDialog = ({ connection?.requestPosition(node.num).then(() => toast({ title: "Position request sent.", - }), + }) ); onOpenChange(); } @@ -66,7 +64,7 @@ export const NodeOptionsDialog = ({ connection?.traceRoute(node.num).then(() => toast({ title: "Traceroute sent.", - }), + }) ); onOpenChange(); } diff --git a/src/components/Dialog/QRDialog.tsx b/src/components/Dialog/QRDialog.tsx index 4b612a8d..751b6f69 100644 --- a/src/components/Dialog/QRDialog.tsx +++ b/src/components/Dialog/QRDialog.tsx @@ -10,7 +10,7 @@ import { } from "@components/UI/Dialog.tsx"; import { Input } from "@components/UI/Input.tsx"; import { Label } from "@components/UI/Label.tsx"; -import { Protobuf, type Types } from "@meshtastic/js"; +import { Protobuf, type Types } from "@meshtastic/core"; import { fromByteArray } from "base64-js"; import { ClipboardIcon } from "lucide-react"; import { useEffect, useMemo, useState } from "react"; @@ -77,8 +77,8 @@ export const QRDialog = ({ {channel.settings?.name.length ? channel.settings.name : channel.role === Protobuf.Channel.Channel_Role.PRIMARY - ? "Primary" - : `Channel: ${channel.index}`} + ? "Primary" + : `Channel: ${channel.index}`} { if (selectedChannels.includes(channel.index)) { setSelectedChannels( - selectedChannels.filter((c) => c !== channel.index), + selectedChannels.filter((c) => + c !== channel.index + ), ); } else { setSelectedChannels([ diff --git a/src/components/Dialog/TracerouteResponseDialog.tsx b/src/components/Dialog/TracerouteResponseDialog.tsx index 9fce1cfa..7e97fb81 100644 --- a/src/components/Dialog/TracerouteResponseDialog.tsx +++ b/src/components/Dialog/TracerouteResponseDialog.tsx @@ -6,7 +6,7 @@ import { DialogHeader, DialogTitle, } from "@components/UI/Dialog"; -import type { Protobuf, Types } from "@meshtastic/js"; +import type { Protobuf, Types } from "@meshtastic/core"; import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; import type { JSX } from "react"; import { TraceRoute } from "../PageComponents/Messages/TraceRoute"; @@ -28,11 +28,9 @@ export const TracerouteResponseDialog = ({ const snrTowards = traceroute?.data.snrTowards ?? []; const snrBack = traceroute?.data.snrBack ?? []; const from = nodes.get(traceroute?.from ?? 0); - const longName = - from?.user?.longName ?? + const longName = from?.user?.longName ?? (from ? `!${numberToHexUnpadded(from?.num)}` : "Unknown"); - const shortName = - from?.user?.shortName ?? + const shortName = from?.user?.shortName ?? (from ? `${numberToHexUnpadded(from?.num).substring(0, 4)}` : "UNK"); const to = nodes.get(traceroute?.to ?? 0); return ( diff --git a/src/components/PageComponents/Channel.tsx b/src/components/PageComponents/Channel.tsx index f3c7a1df..53e9c68f 100644 --- a/src/components/PageComponents/Channel.tsx +++ b/src/components/PageComponents/Channel.tsx @@ -3,7 +3,7 @@ import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useToast } from "@core/hooks/useToast.ts"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { fromByteArray, toByteArray } from "base64-js"; import cryptoRandomString from "crypto-random-string"; import { useState } from "react"; @@ -24,8 +24,9 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => { channel?.settings?.psk.length ?? 16, ); const [validationText, setValidationText] = useState(); - const [preSharedDialogOpen, setPreSharedDialogOpen] = - useState(false); + const [preSharedDialogOpen, setPreSharedDialogOpen] = useState( + false, + ); const onSubmit = (data: ChannelValidation) => { const channel = create(Protobuf.Channel.ChannelSchema, { @@ -107,7 +108,7 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => { channel?.settings?.moduleSettings?.positionPrecision === 32, positionPrecision: channel?.settings?.moduleSettings?.positionPrecision === - undefined + undefined ? 10 : channel?.settings?.moduleSettings?.positionPrecision, }, @@ -126,10 +127,9 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => { description: "Device telemetry is sent over PRIMARY. Only one PRIMARY allowed", properties: { - enumValue: - channel.index === 0 - ? { PRIMARY: 1 } - : { DISABLED: 0, SECONDARY: 2 }, + enumValue: channel.index === 0 + ? { PRIMARY: 1 } + : { DISABLED: 0, SECONDARY: 2 }, }, }, { @@ -192,32 +192,31 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => { description: "If not sharing precise location, position shared on channel will be accurate within this distance", properties: { - enumValue: - config.display?.units === 0 - ? { - "Within 23 km": 10, - "Within 12 km": 11, - "Within 5.8 km": 12, - "Within 2.9 km": 13, - "Within 1.5 km": 14, - "Within 700 m": 15, - "Within 350 m": 16, - "Within 200 m": 17, - "Within 90 m": 18, - "Within 50 m": 19, - } - : { - "Within 15 miles": 10, - "Within 7.3 miles": 11, - "Within 3.6 miles": 12, - "Within 1.8 miles": 13, - "Within 0.9 miles": 14, - "Within 0.5 miles": 15, - "Within 0.2 miles": 16, - "Within 600 feet": 17, - "Within 300 feet": 18, - "Within 150 feet": 19, - }, + enumValue: config.display?.units === 0 + ? { + "Within 23 km": 10, + "Within 12 km": 11, + "Within 5.8 km": 12, + "Within 2.9 km": 13, + "Within 1.5 km": 14, + "Within 700 m": 15, + "Within 350 m": 16, + "Within 200 m": 17, + "Within 90 m": 18, + "Within 50 m": 19, + } + : { + "Within 15 miles": 10, + "Within 7.3 miles": 11, + "Within 3.6 miles": 12, + "Within 1.8 miles": 13, + "Within 0.9 miles": 14, + "Within 0.5 miles": 15, + "Within 0.2 miles": 16, + "Within 600 feet": 17, + "Within 300 feet": 18, + "Within 150 feet": 19, + }, }, }, ], diff --git a/src/components/PageComponents/Config/Bluetooth.tsx b/src/components/PageComponents/Config/Bluetooth.tsx index 362606bb..97f137b1 100644 --- a/src/components/PageComponents/Config/Bluetooth.tsx +++ b/src/components/PageComponents/Config/Bluetooth.tsx @@ -3,7 +3,7 @@ import type { BluetoothValidation } from "@app/validation/config/bluetooth.tsx"; import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { useState } from "react"; export const Bluetooth = () => { @@ -111,9 +111,8 @@ export const Bluetooth = () => { disabledBy: [ { fieldName: "mode", - selector: - Protobuf.Config.Config_BluetoothConfig_PairingMode - .FIXED_PIN, + selector: Protobuf.Config.Config_BluetoothConfig_PairingMode + .FIXED_PIN, invert: true, }, { diff --git a/src/components/PageComponents/Config/Device.tsx b/src/components/PageComponents/Config/Device.tsx index c06fe178..30629bed 100644 --- a/src/components/PageComponents/Config/Device.tsx +++ b/src/components/PageComponents/Config/Device.tsx @@ -2,7 +2,7 @@ import type { DeviceValidation } from "@app/validation/config/device.tsx"; import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const Device = (): JSX.Element => { const { config, setWorkingConfig } = useDevice(); diff --git a/src/components/PageComponents/Config/Display.tsx b/src/components/PageComponents/Config/Display.tsx index 64b5b368..e0d1e671 100644 --- a/src/components/PageComponents/Config/Display.tsx +++ b/src/components/PageComponents/Config/Display.tsx @@ -2,7 +2,7 @@ import type { DisplayValidation } from "@app/validation/config/display.tsx"; import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const Display = (): JSX.Element => { const { config, setWorkingConfig } = useDevice(); diff --git a/src/components/PageComponents/Config/LoRa.tsx b/src/components/PageComponents/Config/LoRa.tsx index 8dfb81c9..c1f3aa47 100644 --- a/src/components/PageComponents/Config/LoRa.tsx +++ b/src/components/PageComponents/Config/LoRa.tsx @@ -2,7 +2,7 @@ import type { LoRaValidation } from "@app/validation/config/lora.tsx"; import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const LoRa = (): JSX.Element => { const { config, setWorkingConfig } = useDevice(); diff --git a/src/components/PageComponents/Config/Network.tsx b/src/components/PageComponents/Config/Network.tsx index 76f1d54d..42d724d8 100644 --- a/src/components/PageComponents/Config/Network.tsx +++ b/src/components/PageComponents/Config/Network.tsx @@ -6,7 +6,7 @@ import { convertIntToIpAddress, convertIpAddressToInt, } from "@core/utils/ip.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const Network = (): JSX.Element => { const { config, setWorkingConfig } = useDevice(); diff --git a/src/components/PageComponents/Config/Position.tsx b/src/components/PageComponents/Config/Position.tsx index 4aa3abba..8d1992cc 100644 --- a/src/components/PageComponents/Config/Position.tsx +++ b/src/components/PageComponents/Config/Position.tsx @@ -6,7 +6,7 @@ import type { PositionValidation } from "@app/validation/config/position.tsx"; import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { useCallback } from "react"; export const Position = () => { diff --git a/src/components/PageComponents/Config/Power.tsx b/src/components/PageComponents/Config/Power.tsx index e49d7ff6..b1e389c6 100644 --- a/src/components/PageComponents/Config/Power.tsx +++ b/src/components/PageComponents/Config/Power.tsx @@ -2,7 +2,7 @@ import type { PowerValidation } from "@app/validation/config/power.tsx"; import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const Power = (): JSX.Element => { const { config, setWorkingConfig } = useDevice(); diff --git a/src/components/PageComponents/Config/Security/Security.tsx b/src/components/PageComponents/Config/Security/Security.tsx index 7aee9907..c1468efc 100644 --- a/src/components/PageComponents/Config/Security/Security.tsx +++ b/src/components/PageComponents/Config/Security/Security.tsx @@ -8,7 +8,7 @@ import { import type { SecurityValidation } from "@app/validation/config/security.tsx"; import { create } from "@bufbuild/protobuf"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { fromByteArray, toByteArray } from "base64-js"; import { Eye, EyeOff } from "lucide-react"; import { useReducer } from "react"; diff --git a/src/components/PageComponents/Connect/Serial.tsx b/src/components/PageComponents/Connect/Serial.tsx index 529b8c3d..f5288403 100644 --- a/src/components/PageComponents/Connect/Serial.tsx +++ b/src/components/PageComponents/Connect/Serial.tsx @@ -5,7 +5,8 @@ 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 { SerialConnection } from "@meshtastic/js"; +import { MeshDevice } from "@meshtastic/core"; +import { TransportWebSerial } from "@meshtastic/transport-web-serial"; import { useCallback, useEffect, useState } from "react"; export const Serial = ({ closeDialog }: TabElementProps): JSX.Element => { @@ -31,14 +32,9 @@ export const Serial = ({ closeDialog }: TabElementProps): JSX.Element => { const id = randId(); const device = addDevice(id); setSelectedDevice(id); - const connection = new SerialConnection(id); - await connection - .connect({ - port, - baudRate: undefined, - concurrentLogOutput: true, - }) - .catch((e: Error) => console.log(`Unable to Connect: ${e.message}`)); + const transport = await TransportWebSerial.createFromPort(port); + const connection = new MeshDevice(transport, id); + connection.configure(); device.addConnection(connection); subscribeAll(device, connection); diff --git a/src/components/PageComponents/Map/NodeDetail.tsx b/src/components/PageComponents/Map/NodeDetail.tsx index e89dcd1b..7342bdf0 100644 --- a/src/components/PageComponents/Map/NodeDetail.tsx +++ b/src/components/PageComponents/Map/NodeDetail.tsx @@ -5,8 +5,8 @@ import { formatQuantity } from "@app/core/utils/string"; import { Avatar } from "@components/UI/Avatar"; import { Mono } from "@components/generic/Mono.tsx"; import { TimeAgo } from "@components/generic/TimeAgo.tsx"; -import { Protobuf } from "@meshtastic/js"; -import type { Protobuf as ProtobufType } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; +import type { Protobuf as ProtobufType } from "@meshtastic/core"; import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; import { BatteryChargingIcon, @@ -37,21 +37,23 @@ export const NodeDetail = ({ node }: NodeDetailProps) => {
- {node.user?.publicKey && node.user?.publicKey.length > 0 ? ( - - ) : ( - - )} + {node.user?.publicKey && node.user?.publicKey.length > 0 + ? ( + + ) + : ( + + )}
{ node.deviceMetrics?.voltage?.toPrecision(3) ?? "Unknown" } volts`} > - {node.deviceMetrics?.batteryLevel > 100 ? ( - - ) : node.deviceMetrics?.batteryLevel > 80 ? ( - - ) : node.deviceMetrics?.batteryLevel > 20 ? ( - - ) : ( - - )} + {node.deviceMetrics?.batteryLevel > 100 + ? + : node.deviceMetrics?.batteryLevel > 80 + ? + : node.deviceMetrics?.batteryLevel > 20 + ? + : } {node.deviceMetrics?.batteryLevel > 100 ? "Charging" diff --git a/src/components/PageComponents/Messages/ChannelChat.tsx b/src/components/PageComponents/Messages/ChannelChat.tsx index a5231496..7969782b 100644 --- a/src/components/PageComponents/Messages/ChannelChat.tsx +++ b/src/components/PageComponents/Messages/ChannelChat.tsx @@ -4,7 +4,7 @@ import { } from "@app/core/stores/deviceStore.ts"; import { Message } from "@components/PageComponents/Messages/Message.tsx"; import { MessageInput } from "@components/PageComponents/Messages/MessageInput.tsx"; -import type { Types } from "@meshtastic/js"; +import type { Types } from "@meshtastic/core"; import { InboxIcon } from "lucide-react"; import { useCallback, useEffect, useRef } from "react"; import type { JSX } from "react"; @@ -34,8 +34,7 @@ export const ChannelChat = ({ const scrollToBottom = useCallback(() => { const scrollContainer = scrollContainerRef.current; if (scrollContainer) { - const isNearBottom = - scrollContainer.scrollHeight - + const isNearBottom = scrollContainer.scrollHeight - scrollContainer.scrollTop - scrollContainer.clientHeight < 100; @@ -72,9 +71,8 @@ export const ChannelChat = ({ key={message.id} message={message} sender={nodes.get(message.from)} - lastMsgSameUser={ - index > 0 && messages[index - 1].from === message.from - } + lastMsgSameUser={index > 0 && + messages[index - 1].from === message.from} /> ); })} diff --git a/src/components/PageComponents/Messages/Message.tsx b/src/components/PageComponents/Messages/Message.tsx index 6c6fa79a..17b659b2 100644 --- a/src/components/PageComponents/Messages/Message.tsx +++ b/src/components/PageComponents/Messages/Message.tsx @@ -12,7 +12,7 @@ import { } from "@app/core/stores/deviceStore.ts"; import { cn } from "@app/core/utils/cn"; import { Avatar } from "@components/UI/Avatar"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { AlertCircle, CheckCircle2, CircleEllipsis } from "lucide-react"; import type { LucideIcon } from "lucide-react"; import { useMemo } from "react"; diff --git a/src/components/PageComponents/Messages/MessageInput.tsx b/src/components/PageComponents/Messages/MessageInput.tsx index 1e4887cd..c91612be 100644 --- a/src/components/PageComponents/Messages/MessageInput.tsx +++ b/src/components/PageComponents/Messages/MessageInput.tsx @@ -2,7 +2,7 @@ import { debounce } from "@app/core/utils/debounce"; import { Button } from "@components/UI/Button.tsx"; import { Input } from "@components/UI/Input.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import type { Types } from "@meshtastic/js"; +import type { Types } from "@meshtastic/core"; import { SendIcon } from "lucide-react"; import { type JSX, @@ -51,7 +51,7 @@ export const MessageInput = ({ myNodeNum, id, "ack", - ), + ) ) .catch((e: Types.PacketError) => setMessageState( @@ -61,7 +61,7 @@ export const MessageInput = ({ myNodeNum, e.id, e.error, - ), + ) ); }, [channel, connection, myNodeNum, setMessageState, to], diff --git a/src/components/PageComponents/Messages/TraceRoute.tsx b/src/components/PageComponents/Messages/TraceRoute.tsx index 2c9e813a..aa5580a8 100644 --- a/src/components/PageComponents/Messages/TraceRoute.tsx +++ b/src/components/PageComponents/Messages/TraceRoute.tsx @@ -1,5 +1,5 @@ import { useDevice } from "@app/core/stores/deviceStore.ts"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; import type { JSX } from "react"; @@ -38,23 +38,25 @@ export const TraceRoute = ({ ))} {from?.user?.longName} - {routeBack ? ( - -

Route back:

-

{from?.user?.longName}

-

↓ {snrBack?.[0] ? snrBack[0] : "??"}dB

- {routeBack.map((hop, i) => ( - -

- {nodes.get(hop)?.user?.longName ?? - `!${numberToHexUnpadded(hop)}`} -

-

↓ {snrBack?.[i + 1] ? snrBack[i + 1] : "??"}dB

-
- ))} - {to?.user?.longName} -
- ) : null} + {routeBack + ? ( + +

Route back:

+

{from?.user?.longName}

+

↓ {snrBack?.[0] ? snrBack[0] : "??"}dB

+ {routeBack.map((hop, i) => ( + +

+ {nodes.get(hop)?.user?.longName ?? + `!${numberToHexUnpadded(hop)}`} +

+

↓ {snrBack?.[i + 1] ? snrBack[i + 1] : "??"}dB

+
+ ))} + {to?.user?.longName} +
+ ) + : null}
); }; diff --git a/src/components/PageComponents/ModuleConfig/AmbientLighting.tsx b/src/components/PageComponents/ModuleConfig/AmbientLighting.tsx index f7853710..effe7471 100644 --- a/src/components/PageComponents/ModuleConfig/AmbientLighting.tsx +++ b/src/components/PageComponents/ModuleConfig/AmbientLighting.tsx @@ -2,7 +2,7 @@ import { useDevice } from "@app/core/stores/deviceStore.ts"; import type { AmbientLightingValidation } from "@app/validation/moduleConfig/ambientLighting.tsx"; import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const AmbientLighting = (): JSX.Element => { const { moduleConfig, setWorkingModuleConfig } = useDevice(); diff --git a/src/components/PageComponents/ModuleConfig/Audio.tsx b/src/components/PageComponents/ModuleConfig/Audio.tsx index 46d2176c..08960704 100644 --- a/src/components/PageComponents/ModuleConfig/Audio.tsx +++ b/src/components/PageComponents/ModuleConfig/Audio.tsx @@ -2,7 +2,7 @@ import type { AudioValidation } from "@app/validation/moduleConfig/audio.tsx"; import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const Audio = (): JSX.Element => { const { moduleConfig, setWorkingModuleConfig } = useDevice(); diff --git a/src/components/PageComponents/ModuleConfig/CannedMessage.tsx b/src/components/PageComponents/ModuleConfig/CannedMessage.tsx index 97595ddc..b800035d 100644 --- a/src/components/PageComponents/ModuleConfig/CannedMessage.tsx +++ b/src/components/PageComponents/ModuleConfig/CannedMessage.tsx @@ -2,7 +2,7 @@ import type { CannedMessageValidation } from "@app/validation/moduleConfig/canne import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const CannedMessage = (): JSX.Element => { const { moduleConfig, setWorkingModuleConfig } = useDevice(); diff --git a/src/components/PageComponents/ModuleConfig/DetectionSensor.tsx b/src/components/PageComponents/ModuleConfig/DetectionSensor.tsx index e547fab1..056c48dd 100644 --- a/src/components/PageComponents/ModuleConfig/DetectionSensor.tsx +++ b/src/components/PageComponents/ModuleConfig/DetectionSensor.tsx @@ -2,7 +2,7 @@ import { useDevice } from "@app/core/stores/deviceStore.ts"; import type { DetectionSensorValidation } from "@app/validation/moduleConfig/detectionSensor.tsx"; import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const DetectionSensor = (): JSX.Element => { const { moduleConfig, setWorkingModuleConfig } = useDevice(); diff --git a/src/components/PageComponents/ModuleConfig/ExternalNotification.tsx b/src/components/PageComponents/ModuleConfig/ExternalNotification.tsx index dfe61fad..6d767ea1 100644 --- a/src/components/PageComponents/ModuleConfig/ExternalNotification.tsx +++ b/src/components/PageComponents/ModuleConfig/ExternalNotification.tsx @@ -2,7 +2,7 @@ import type { ExternalNotificationValidation } from "@app/validation/moduleConfi import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const ExternalNotification = (): JSX.Element => { const { moduleConfig, setWorkingModuleConfig } = useDevice(); diff --git a/src/components/PageComponents/ModuleConfig/MQTT.tsx b/src/components/PageComponents/ModuleConfig/MQTT.tsx index 5b2d3f60..28e3cba9 100644 --- a/src/components/PageComponents/ModuleConfig/MQTT.tsx +++ b/src/components/PageComponents/ModuleConfig/MQTT.tsx @@ -2,7 +2,7 @@ import { useDevice } from "@app/core/stores/deviceStore.ts"; import type { MqttValidation } from "@app/validation/moduleConfig/mqtt.tsx"; import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const MQTT = (): JSX.Element => { const { config, moduleConfig, setWorkingModuleConfig } = useDevice(); diff --git a/src/components/PageComponents/ModuleConfig/NeighborInfo.tsx b/src/components/PageComponents/ModuleConfig/NeighborInfo.tsx index 1dfa9532..b3391f0f 100644 --- a/src/components/PageComponents/ModuleConfig/NeighborInfo.tsx +++ b/src/components/PageComponents/ModuleConfig/NeighborInfo.tsx @@ -2,7 +2,7 @@ import { useDevice } from "@app/core/stores/deviceStore.ts"; import type { NeighborInfoValidation } from "@app/validation/moduleConfig/neighborInfo.tsx"; import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const NeighborInfo = (): JSX.Element => { const { moduleConfig, setWorkingModuleConfig } = useDevice(); diff --git a/src/components/PageComponents/ModuleConfig/Paxcounter.tsx b/src/components/PageComponents/ModuleConfig/Paxcounter.tsx index d4118b8e..fd5b372f 100644 --- a/src/components/PageComponents/ModuleConfig/Paxcounter.tsx +++ b/src/components/PageComponents/ModuleConfig/Paxcounter.tsx @@ -2,7 +2,7 @@ import type { PaxcounterValidation } from "@app/validation/moduleConfig/paxcount import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const Paxcounter = (): JSX.Element => { const { moduleConfig, setWorkingModuleConfig } = useDevice(); diff --git a/src/components/PageComponents/ModuleConfig/RangeTest.tsx b/src/components/PageComponents/ModuleConfig/RangeTest.tsx index 6c98d45a..e0fbdf2f 100644 --- a/src/components/PageComponents/ModuleConfig/RangeTest.tsx +++ b/src/components/PageComponents/ModuleConfig/RangeTest.tsx @@ -2,7 +2,7 @@ import type { RangeTestValidation } from "@app/validation/moduleConfig/rangeTest import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const RangeTest = (): JSX.Element => { const { moduleConfig, setWorkingModuleConfig } = useDevice(); diff --git a/src/components/PageComponents/ModuleConfig/Serial.tsx b/src/components/PageComponents/ModuleConfig/Serial.tsx index e7afd3eb..05713f20 100644 --- a/src/components/PageComponents/ModuleConfig/Serial.tsx +++ b/src/components/PageComponents/ModuleConfig/Serial.tsx @@ -2,7 +2,7 @@ import type { SerialValidation } from "@app/validation/moduleConfig/serial.tsx"; import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const Serial = (): JSX.Element => { const { moduleConfig, setWorkingModuleConfig } = useDevice(); diff --git a/src/components/PageComponents/ModuleConfig/StoreForward.tsx b/src/components/PageComponents/ModuleConfig/StoreForward.tsx index dbd17c28..72ca9bee 100644 --- a/src/components/PageComponents/ModuleConfig/StoreForward.tsx +++ b/src/components/PageComponents/ModuleConfig/StoreForward.tsx @@ -2,7 +2,7 @@ import type { StoreForwardValidation } from "@app/validation/moduleConfig/storeF import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const StoreForward = (): JSX.Element => { const { moduleConfig, setWorkingModuleConfig } = useDevice(); diff --git a/src/components/PageComponents/ModuleConfig/Telemetry.tsx b/src/components/PageComponents/ModuleConfig/Telemetry.tsx index c6e9f4fb..c2de366e 100644 --- a/src/components/PageComponents/ModuleConfig/Telemetry.tsx +++ b/src/components/PageComponents/ModuleConfig/Telemetry.tsx @@ -2,7 +2,7 @@ import type { TelemetryValidation } from "@app/validation/moduleConfig/telemetry import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; export const Telemetry = (): JSX.Element => { const { moduleConfig, setWorkingModuleConfig } = useDevice(); diff --git a/src/core/stores/appStore.ts b/src/core/stores/appStore.ts index bf8644ce..cd943fc0 100644 --- a/src/core/stores/appStore.ts +++ b/src/core/stores/appStore.ts @@ -1,4 +1,4 @@ -import { Types } from "@meshtastic/js"; +import { Types } from "@meshtastic/core"; import { produce } from "immer"; import { create } from "zustand"; diff --git a/src/core/stores/deviceStore.ts b/src/core/stores/deviceStore.ts index e7682530..0822473f 100644 --- a/src/core/stores/deviceStore.ts +++ b/src/core/stores/deviceStore.ts @@ -1,5 +1,5 @@ import { create } from "@bufbuild/protobuf"; -import { Protobuf, Types } from "@meshtastic/js"; +import { Protobuf, Types } from "@meshtastic/core"; import { produce } from "immer"; import { createContext, useContext } from "react"; import { create as createStore } from "zustand"; @@ -299,11 +299,11 @@ export const useDeviceStore = createStore((set, get) => ({ if (!device) { return; } - const workingModuleConfigIndex = - device?.workingModuleConfig.findIndex( + const workingModuleConfigIndex = device?.workingModuleConfig + .findIndex( (wmc) => wmc.payloadVariant.case === - moduleConfig.payloadVariant.case, + moduleConfig.payloadVariant.case, ); if (workingModuleConfigIndex !== -1) { device.workingModuleConfig[workingModuleConfigIndex] = @@ -445,8 +445,7 @@ export const useDeviceStore = createStore((set, get) => ({ if (!device) { return; } - const currentNode = - device.nodes.get(user.from) ?? + const currentNode = device.nodes.get(user.from) ?? create(Protobuf.Mesh.NodeInfoSchema); currentNode.user = user.data; device.nodes.set(user.from, currentNode); @@ -460,8 +459,7 @@ export const useDeviceStore = createStore((set, get) => ({ if (!device) { return; } - const currentNode = - device.nodes.get(position.from) ?? + const currentNode = device.nodes.get(position.from) ?? create(Protobuf.Mesh.NodeInfoSchema); currentNode.position = position.data; device.nodes.set(position.from, currentNode); @@ -486,12 +484,11 @@ export const useDeviceStore = createStore((set, get) => ({ return; } const messageGroup = device.messages[message.type]; - const messageIndex = - message.type === "direct" - ? message.from === device.hardware.myNodeNum - ? message.to - : message.from - : message.channel; + const messageIndex = message.type === "direct" + ? message.from === device.hardware.myNodeNum + ? message.to + : message.from + : message.channel; const messages = messageGroup.get(messageIndex); if (messages) { @@ -564,12 +561,9 @@ export const useDeviceStore = createStore((set, get) => ({ } const messageGroup = device.messages[type]; - const messageIndex = - type === "direct" - ? from === device.hardware.myNodeNum - ? to - : from - : channelIndex; + const messageIndex = type === "direct" + ? from === device.hardware.myNodeNum ? to : from + : channelIndex; const messages = messageGroup.get(messageIndex); if (!messages) { diff --git a/src/core/subscriptions.ts b/src/core/subscriptions.ts index afba12b7..8dac29db 100644 --- a/src/core/subscriptions.ts +++ b/src/core/subscriptions.ts @@ -1,5 +1,5 @@ import type { Device } from "@core/stores/deviceStore.ts"; -import { Protobuf, type Types } from "@meshtastic/js"; +import { Protobuf, type Types } from "@meshtastic/core"; export const subscribeAll = ( device: Device, diff --git a/src/pages/Channels.tsx b/src/pages/Channels.tsx index 3a47455c..4a2b3954 100644 --- a/src/pages/Channels.tsx +++ b/src/pages/Channels.tsx @@ -8,8 +8,8 @@ import { Channel } from "@components/PageComponents/Channel.tsx"; import { PageLayout } from "@components/PageLayout.tsx"; import { Sidebar } from "@components/Sidebar.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Types } from "@meshtastic/js"; -import type { Protobuf } from "@meshtastic/js"; +import { Types } from "@meshtastic/core"; +import type { Protobuf } from "@meshtastic/core"; import { ImportIcon, QrCodeIcon } from "lucide-react"; import { useState } from "react"; @@ -17,8 +17,8 @@ export const getChannelName = (channel: Protobuf.Channel.Channel) => channel.settings?.name.length ? channel.settings?.name : channel.index === 0 - ? "Primary" - : `Ch ${channel.index}`; + ? "Primary" + : `Ch ${channel.index}`; const ChannelsPage = () => { const { channels, setDialogOpen } = useDevice(); diff --git a/src/pages/Map/index.tsx b/src/pages/Map/index.tsx index ee833720..c1c484a5 100644 --- a/src/pages/Map/index.tsx +++ b/src/pages/Map/index.tsx @@ -4,7 +4,7 @@ import { useTheme } from "@app/core/hooks/useTheme"; import { PageLayout } from "@components/PageLayout.tsx"; import { Sidebar } from "@components/Sidebar.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { bbox, lineString } from "@turf/turf"; import { current } from "immer"; import { MapPinIcon } from "lucide-react"; diff --git a/src/pages/Messages.tsx b/src/pages/Messages.tsx index 670bab74..2ac0d274 100644 --- a/src/pages/Messages.tsx +++ b/src/pages/Messages.tsx @@ -7,7 +7,7 @@ import { SidebarSection } from "@components/UI/Sidebar/SidebarSection.tsx"; import { SidebarButton } from "@components/UI/Sidebar/sidebarButton.tsx"; import { useToast } from "@core/hooks/useToast.ts"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf, Types } from "@meshtastic/js"; +import { Protobuf, Types } from "@meshtastic/core"; import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; import { getChannelName } from "@pages/Channels.tsx"; import { HashIcon, LockIcon, LockOpenIcon, WaypointsIcon } from "lucide-react"; @@ -39,13 +39,11 @@ export const MessagesPage = () => { {filteredChannels.map((channel) => ( { setChatType("broadcast"); @@ -69,9 +67,8 @@ export const MessagesPage = () => { {filteredNodes.map((node) => ( { setChatType("direct"); @@ -94,32 +91,30 @@ export const MessagesPage = () => { chatType === "broadcast" && currentChannel ? getChannelName(currentChannel) : chatType === "direct" && nodes.get(activeChat) - ? (nodes.get(activeChat)?.user?.longName ?? nodeHex) - : "Loading..." + ? (nodes.get(activeChat)?.user?.longName ?? nodeHex) + : "Loading..." }`} - actions={ - chatType === "direct" - ? [ - { - icon: nodes.get(activeChat)?.user?.publicKey.length - ? LockIcon - : LockOpenIcon, - iconClasses: nodes.get(activeChat)?.user?.publicKey.length - ? "text-green-600" - : "text-yellow-300", - async onClick() { - const targetNode = nodes.get(activeChat)?.num; - if (targetNode === undefined) return; - toast({ - title: nodes.get(activeChat)?.user?.publicKey.length - ? "Chat is using PKI encryption." - : "Chat is using PSK encryption.", - }); - }, - }, - ] - : [] - } + actions={chatType === "direct" + ? [ + { + icon: nodes.get(activeChat)?.user?.publicKey.length + ? LockIcon + : LockOpenIcon, + iconClasses: nodes.get(activeChat)?.user?.publicKey.length + ? "text-green-600" + : "text-yellow-300", + async onClick() { + const targetNode = nodes.get(activeChat)?.num; + if (targetNode === undefined) return; + toast({ + title: nodes.get(activeChat)?.user?.publicKey.length + ? "Chat is using PKI encryption." + : "Chat is using PSK encryption.", + }); + }, + }, + ] + : []} > {allChannels.map( (channel) => diff --git a/src/pages/Nodes.tsx b/src/pages/Nodes.tsx index 0fadf0ca..30daaa84 100644 --- a/src/pages/Nodes.tsx +++ b/src/pages/Nodes.tsx @@ -8,7 +8,7 @@ import { Mono } from "@components/generic/Mono.tsx"; import { Table } from "@components/generic/Table/index.tsx"; import { TimeAgo } from "@components/generic/TimeAgo.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; -import { Protobuf, type Types } from "@meshtastic/js"; +import { Protobuf, type Types } from "@meshtastic/core"; import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; import { LockIcon, LockOpenIcon } from "lucide-react"; import { Fragment, type JSX, useCallback, useEffect, useState } from "react"; @@ -107,9 +107,11 @@ const NodesPage = (): JSX.Element => { > {node.user?.shortName ?? (node.user?.macaddr - ? `${base16 + ? `${ + base16 .stringify(node.user?.macaddr.subarray(4, 6) ?? []) - .toLowerCase()}` + .toLowerCase() + }` : `${numberToHexUnpadded(node.num).slice(-4)}`)} , @@ -120,9 +122,11 @@ const NodesPage = (): JSX.Element => { > {node.user?.longName ?? (node.user?.macaddr - ? `Meshtastic ${base16 + ? `Meshtastic ${ + base16 .stringify(node.user?.macaddr.subarray(4, 6) ?? []) - .toLowerCase()}` + .toLowerCase() + }` : `!${numberToHexUnpadded(node.num)}`)} , @@ -136,11 +140,9 @@ const NodesPage = (): JSX.Element => { ?.join(":") ?? "UNK"} , - {node.lastHeard === 0 ? ( -

Never

- ) : ( - - )} + {node.lastHeard === 0 + ?

Never

+ : }
, {node.snr}db/ @@ -148,19 +150,17 @@ const NodesPage = (): JSX.Element => { {(node.snr + 10) * 5}raw , - {node.user?.publicKey && node.user?.publicKey.length > 0 ? ( - - ) : ( - - )} + {node.user?.publicKey && node.user?.publicKey.length > 0 + ? + : } , {node.lastHeard !== 0 ? node.viaMqtt === false && node.hopsAway === 0 ? "Direct" : `${node.hopsAway.toString()} ${ - node.hopsAway > 1 ? "hops" : "hop" - } away` + node.hopsAway > 1 ? "hops" : "hop" + } away` : "-"} {node.viaMqtt === true ? ", via MQTT" : ""} , diff --git a/src/validation/channel.ts b/src/validation/channel.ts index 33349d06..4f4d43bb 100644 --- a/src/validation/channel.ts +++ b/src/validation/channel.ts @@ -1,5 +1,5 @@ import type { Message } from "@bufbuild/protobuf"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsEnum, @@ -10,8 +10,7 @@ import { } from "class-validator"; export class ChannelValidation - implements Omit -{ + implements Omit { @IsNumber() index: number; @@ -22,8 +21,7 @@ export class ChannelValidation } export class Channel_SettingsValidation - implements Omit -{ + implements Omit { @IsNumber() channelNum: number; diff --git a/src/validation/config/bluetooth.ts b/src/validation/config/bluetooth.ts index efaca6e9..67492240 100644 --- a/src/validation/config/bluetooth.ts +++ b/src/validation/config/bluetooth.ts @@ -1,14 +1,12 @@ import type { Message } from "@bufbuild/protobuf"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsEnum, IsInt } from "class-validator"; -export class BluetoothValidation - implements - Omit< - Protobuf.Config.Config_BluetoothConfig, - keyof Message | "deviceLoggingEnabled" - > -{ +export class BluetoothValidation implements + Omit< + Protobuf.Config.Config_BluetoothConfig, + keyof Message | "deviceLoggingEnabled" + > { @IsBoolean() enabled: boolean; diff --git a/src/validation/config/device.ts b/src/validation/config/device.ts index b61be39f..5c79d583 100644 --- a/src/validation/config/device.ts +++ b/src/validation/config/device.ts @@ -1,5 +1,5 @@ import type { Message } from "@bufbuild/protobuf"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsEnum, IsInt, IsString } from "class-validator"; export class DeviceValidation diff --git a/src/validation/config/display.ts b/src/validation/config/display.ts index 48831052..ed21d3f9 100644 --- a/src/validation/config/display.ts +++ b/src/validation/config/display.ts @@ -1,5 +1,5 @@ import type { Message } from "@bufbuild/protobuf"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsEnum, IsInt } from "class-validator"; export class DisplayValidation diff --git a/src/validation/config/lora.ts b/src/validation/config/lora.ts index e8ff5cef..4fb5646a 100644 --- a/src/validation/config/lora.ts +++ b/src/validation/config/lora.ts @@ -1,5 +1,5 @@ import type { Message } from "@bufbuild/protobuf"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { IsArray, IsBoolean, IsEnum, IsInt, Max, Min } from "class-validator"; export class LoRaValidation diff --git a/src/validation/config/network.ts b/src/validation/config/network.ts index 41db88d7..922f9563 100644 --- a/src/validation/config/network.ts +++ b/src/validation/config/network.ts @@ -1,5 +1,5 @@ import type { Message } from "@bufbuild/protobuf"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsEnum, diff --git a/src/validation/config/position.ts b/src/validation/config/position.ts index 7eb42c56..4163db76 100644 --- a/src/validation/config/position.ts +++ b/src/validation/config/position.ts @@ -1,16 +1,14 @@ import type { Message } from "@bufbuild/protobuf"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { IsArray, IsBoolean, IsEnum, IsInt } from "class-validator"; const DeprecatedPositionValidationFields = ["gpsEnabled", "gpsAttemptTime"]; -export class PositionValidation - implements - Omit< - Protobuf.Config.Config_PositionConfig, - keyof Message | (typeof DeprecatedPositionValidationFields)[number] - > -{ +export class PositionValidation implements + Omit< + Protobuf.Config.Config_PositionConfig, + keyof Message | (typeof DeprecatedPositionValidationFields)[number] + > { @IsInt() positionBroadcastSecs: number; diff --git a/src/validation/config/power.ts b/src/validation/config/power.ts index 67bd1cd0..0e1012d3 100644 --- a/src/validation/config/power.ts +++ b/src/validation/config/power.ts @@ -1,5 +1,5 @@ import type { Message } from "@bufbuild/protobuf"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsInt, IsNumber, Max, Min } from "class-validator"; export class PowerValidation diff --git a/src/validation/config/security.ts b/src/validation/config/security.ts index d1a35808..b856d521 100644 --- a/src/validation/config/security.ts +++ b/src/validation/config/security.ts @@ -1,14 +1,12 @@ import type { Message } from "@bufbuild/protobuf"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsString } from "class-validator"; -export class SecurityValidation - implements - Omit< - Protobuf.Config.Config_SecurityConfig, - keyof Message | "adminKey" | "privateKey" | "publicKey" - > -{ +export class SecurityValidation implements + Omit< + Protobuf.Config.Config_SecurityConfig, + keyof Message | "adminKey" | "privateKey" | "publicKey" + > { @IsBoolean() adminChannelEnabled: boolean; diff --git a/src/validation/moduleConfig/ambientLighting.ts b/src/validation/moduleConfig/ambientLighting.ts index 2e72f00e..93124502 100644 --- a/src/validation/moduleConfig/ambientLighting.ts +++ b/src/validation/moduleConfig/ambientLighting.ts @@ -1,14 +1,12 @@ import type { Message } from "@bufbuild/protobuf"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsInt } from "class-validator"; -export class AmbientLightingValidation - implements - Omit< - Protobuf.ModuleConfig.ModuleConfig_AmbientLightingConfig, - keyof Message - > -{ +export class AmbientLightingValidation implements + Omit< + Protobuf.ModuleConfig.ModuleConfig_AmbientLightingConfig, + keyof Message + > { @IsBoolean() ledState: boolean; diff --git a/src/validation/moduleConfig/audio.ts b/src/validation/moduleConfig/audio.ts index da527a66..091350f7 100644 --- a/src/validation/moduleConfig/audio.ts +++ b/src/validation/moduleConfig/audio.ts @@ -1,5 +1,5 @@ import type { Message } from "@bufbuild/protobuf"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsEnum, IsInt } from "class-validator"; export class AudioValidation diff --git a/src/validation/moduleConfig/cannedMessage.ts b/src/validation/moduleConfig/cannedMessage.ts index 85c8d6a7..59ecf755 100644 --- a/src/validation/moduleConfig/cannedMessage.ts +++ b/src/validation/moduleConfig/cannedMessage.ts @@ -1,11 +1,13 @@ import type { Message } from "@bufbuild/protobuf"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsEnum, IsInt, Length } from "class-validator"; export class CannedMessageValidation implements - Omit -{ + Omit< + Protobuf.ModuleConfig.ModuleConfig_CannedMessageConfig, + keyof Message + > { @IsBoolean() rotary1Enabled: boolean; @@ -19,13 +21,16 @@ export class CannedMessageValidation inputbrokerPinPress: number; @IsEnum(Protobuf.ModuleConfig.ModuleConfig_CannedMessageConfig_InputEventChar) - inputbrokerEventCw: Protobuf.ModuleConfig.ModuleConfig_CannedMessageConfig_InputEventChar; + inputbrokerEventCw: + Protobuf.ModuleConfig.ModuleConfig_CannedMessageConfig_InputEventChar; @IsEnum(Protobuf.ModuleConfig.ModuleConfig_CannedMessageConfig_InputEventChar) - inputbrokerEventCcw: Protobuf.ModuleConfig.ModuleConfig_CannedMessageConfig_InputEventChar; + inputbrokerEventCcw: + Protobuf.ModuleConfig.ModuleConfig_CannedMessageConfig_InputEventChar; @IsEnum(Protobuf.ModuleConfig.ModuleConfig_CannedMessageConfig_InputEventChar) - inputbrokerEventPress: Protobuf.ModuleConfig.ModuleConfig_CannedMessageConfig_InputEventChar; + inputbrokerEventPress: + Protobuf.ModuleConfig.ModuleConfig_CannedMessageConfig_InputEventChar; @IsBoolean() updown1Enabled: boolean; diff --git a/src/validation/moduleConfig/detectionSensor.ts b/src/validation/moduleConfig/detectionSensor.ts index 3e026fee..b812df17 100644 --- a/src/validation/moduleConfig/detectionSensor.ts +++ b/src/validation/moduleConfig/detectionSensor.ts @@ -1,14 +1,12 @@ import type { Message } from "@bufbuild/protobuf"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsInt, Length } from "class-validator"; -export class DetectionSensorValidation - implements - Omit< - Protobuf.ModuleConfig.ModuleConfig_DetectionSensorConfig, - keyof Message - > -{ +export class DetectionSensorValidation implements + Omit< + Protobuf.ModuleConfig.ModuleConfig_DetectionSensorConfig, + keyof Message + > { @IsBoolean() enabled: boolean; diff --git a/src/validation/moduleConfig/externalNotification.ts b/src/validation/moduleConfig/externalNotification.ts index cf08a321..5b68ffa3 100644 --- a/src/validation/moduleConfig/externalNotification.ts +++ b/src/validation/moduleConfig/externalNotification.ts @@ -1,14 +1,12 @@ import type { Message } from "@bufbuild/protobuf"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsInt } from "class-validator"; -export class ExternalNotificationValidation - implements - Omit< - Protobuf.ModuleConfig.ModuleConfig_ExternalNotificationConfig, - keyof Message - > -{ +export class ExternalNotificationValidation implements + Omit< + Protobuf.ModuleConfig.ModuleConfig_ExternalNotificationConfig, + keyof Message + > { @IsBoolean() enabled: boolean; diff --git a/src/validation/moduleConfig/mqtt.ts b/src/validation/moduleConfig/mqtt.ts index 7a2c9170..79608610 100644 --- a/src/validation/moduleConfig/mqtt.ts +++ b/src/validation/moduleConfig/mqtt.ts @@ -1,5 +1,5 @@ import type { Message } from "@bufbuild/protobuf"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsNumber, diff --git a/src/validation/moduleConfig/neighborInfo.ts b/src/validation/moduleConfig/neighborInfo.ts index f6b48a01..513b8d7c 100644 --- a/src/validation/moduleConfig/neighborInfo.ts +++ b/src/validation/moduleConfig/neighborInfo.ts @@ -1,11 +1,10 @@ import type { Message } from "@bufbuild/protobuf"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsInt } from "class-validator"; export class NeighborInfoValidation implements - Omit -{ + Omit { @IsBoolean() enabled: boolean; diff --git a/src/validation/moduleConfig/paxcounter.ts b/src/validation/moduleConfig/paxcounter.ts index 6f5bc66a..6b3eeb9b 100644 --- a/src/validation/moduleConfig/paxcounter.ts +++ b/src/validation/moduleConfig/paxcounter.ts @@ -1,11 +1,10 @@ import type { Message } from "@bufbuild/protobuf"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsInt } from "class-validator"; export class PaxcounterValidation implements - Omit -{ + Omit { @IsBoolean() enabled: boolean; diff --git a/src/validation/moduleConfig/rangeTest.ts b/src/validation/moduleConfig/rangeTest.ts index 9cc9a96e..fa7a1feb 100644 --- a/src/validation/moduleConfig/rangeTest.ts +++ b/src/validation/moduleConfig/rangeTest.ts @@ -1,5 +1,5 @@ import type { Message } from "@bufbuild/protobuf"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsInt } from "class-validator"; export class RangeTestValidation diff --git a/src/validation/moduleConfig/serial.ts b/src/validation/moduleConfig/serial.ts index 75861abd..c814a71b 100644 --- a/src/validation/moduleConfig/serial.ts +++ b/src/validation/moduleConfig/serial.ts @@ -1,11 +1,10 @@ import type { Message } from "@bufbuild/protobuf"; -import { Protobuf } from "@meshtastic/js"; +import { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsEnum, IsInt } from "class-validator"; export class SerialValidation implements - Omit -{ + Omit { @IsBoolean() enabled: boolean; diff --git a/src/validation/moduleConfig/storeForward.ts b/src/validation/moduleConfig/storeForward.ts index 773a2539..39007de8 100644 --- a/src/validation/moduleConfig/storeForward.ts +++ b/src/validation/moduleConfig/storeForward.ts @@ -1,5 +1,5 @@ import type { Message } from "@bufbuild/protobuf"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsInt } from "class-validator"; export class StoreForwardValidation diff --git a/src/validation/moduleConfig/telemetry.ts b/src/validation/moduleConfig/telemetry.ts index 48b89025..921fb04a 100644 --- a/src/validation/moduleConfig/telemetry.ts +++ b/src/validation/moduleConfig/telemetry.ts @@ -1,11 +1,10 @@ import type { Message } from "@bufbuild/protobuf"; -import type { Protobuf } from "@meshtastic/js"; +import type { Protobuf } from "@meshtastic/core"; import { IsBoolean, IsInt } from "class-validator"; export class TelemetryValidation implements - Omit -{ + Omit { @IsInt() deviceUpdateInterval: number;