Skip to content

Commit

Permalink
chore: fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
justmoon committed Sep 10, 2024
1 parent 186fff4 commit 204fa7a
Show file tree
Hide file tree
Showing 40 changed files with 225 additions and 160 deletions.
1 change: 1 addition & 0 deletions packages/app-build/src/utils/download-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const downloadFile = async (
throw new Error("Response body is empty")
}

// eslint-disable-next-line n/no-unsupported-features/node-builtins
await pipeline(Readable.fromWeb(response.body as ReadableStream), writer)

{
Expand Down
3 changes: 3 additions & 0 deletions packages/app-cli/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#!/usr/bin/env node

// eslint-disable-next-line no-console
console.log(`🐻 Dassie is here!`)
3 changes: 3 additions & 0 deletions packages/app-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@
"license": "Apache-2.0",
"engines": {
"node": "=22.8.0"
},
"devDependencies": {
"@dassie/meta-tsconfig": "workspace:^"
}
}
8 changes: 8 additions & 0 deletions packages/app-cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@dassie/meta-tsconfig/vite-node.json",
"include": ["index.js"],
"compilerOptions": {
"outDir": "dist"
},
"references": []
}
2 changes: 1 addition & 1 deletion packages/app-dev/src/backend/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { ViteNodeServer as ViteNodeServerType } from "vite-node/server"

import { createActor, createReactor } from "@dassie/lib-reactive"

import { HandleShutdownSignalsActor } from "../common/actors/handle-shutdown-signals"
import { ApplyDebugLoggingScopes } from "./actors/apply-debug-logging-scopes"
import { HandleFileChangeActor } from "./actors/handle-file-change"
import { HandleShutdownSignalsActor } from "./actors/handle-shutdown-signals"
import { ProxyByHostnameActor } from "./actors/proxy-by-hostname"
import { RegisterReactiveLoggerActor } from "./actors/register-reactive-logger"
import { RunScenarioActor } from "./actors/run-scenario"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const NodeHeader = ({ nodeId }: BasicNodeElementProperties) => {

const createNodeRpcClients = (securityToken: string, nodeId: string) => {
const queryClient = new QueryClient()
// eslint-disable-next-line n/no-unsupported-features/node-builtins
const websocket = new WebSocket(
`wss://${nodeId}.localhost/rpc?token=${securityToken}`,
)
Expand Down
2 changes: 1 addition & 1 deletion packages/app-dev/src/runner/launchers/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HasTlsSignal } from "@dassie/app-node/src/backend/config/computed/has-t
import { createActor, createReactor } from "@dassie/lib-reactive"
import { createRuntime } from "@dassie/lib-reactive-io/node"

import { HandleShutdownSignalsActor } from "../../common/actors/handle-shutdown-signals"
import { HandleShutdownSignalsActor } from "../../backend/actors/handle-shutdown-signals"
import { ForwardLogsActor } from "../actors/forward-logs"
import { ForwardPeerTrafficActor } from "../actors/forward-peer-traffic"
import { HandleDisconnectActor } from "../actors/handle-disconnect"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { $ } from "execa"

import {
access,
cp, // eslint-disable-line n/no-unsupported-features/node-builtins
cp,
constants as fsConstants,
mkdir,
rm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const LogViewer = <TLogLine extends ViewableLogLine>({
const [shouldStick, setShouldStick] = useState(true)
const scrollPositionReference = useRef<number | undefined>(undefined)
const [keywordFilter, setKeywordFilter] = useState("")
const latestLogLine = logs.at(-1)
const filteredLogs = useMemo(
() =>
logs.filter((item) => {
Expand All @@ -78,7 +77,7 @@ const LogViewer = <TLogLine extends ViewableLogLine>({

return true
}),
[keywordFilter, externalFilter, logs, latestLogLine],
[keywordFilter, externalFilter, logs],
)

const virtualizer = useVirtualizer({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition, n/no-unsupported-features/node-builtins */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
import { CheckIcon, CopyIcon, EyeIcon, EyeOffIcon, XIcon } from "lucide-react"
import { useRef, useState } from "react"

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,24 @@ export default function StreamConfigurator({
type="number"
id="max_packet_amount"
value={String(configuration.maxPacketAmount)}
onChange={(event) =>
onChange={(event) => {
onConfigurationChange((configuration) => ({
...configuration,
maxPacketAmount: BigInt(event.target.value),
}))
}
}}
/>
<Label htmlFor="latency">Latency</Label>
<Input
type="number"
id="latency"
value={String(configuration.latency)}
onChange={(event) =>
onChange={(event) => {
onConfigurationChange((configuration) => ({
...configuration,
latency: Number(event.target.value),
}))
}
}}
/>
<Label htmlFor="max_packets_in_flight">
Max. # of Packets in Flight
Expand All @@ -68,12 +68,12 @@ export default function StreamConfigurator({
type="number"
id="max_packets_in_flight"
value={String(configuration.maxPacketsInFlight)}
onChange={(event) =>
onChange={(event) => {
onConfigurationChange((configuration) => ({
...configuration,
maxPacketsInFlight: Number(event.target.value),
}))
}
}}
/>
</div>
</div>
Expand All @@ -85,16 +85,22 @@ export default function StreamConfigurator({
type="number"
id="send_amount"
value={String(configuration.amount)}
onChange={(event) =>
onChange={(event) => {
onConfigurationChange((configuration) => ({
...configuration,
amount: BigInt(event.target.value),
}))
}
}}
/>
</div>
</div>
<Button onClick={() => onStartClick()}>Simulate</Button>
<Button
onClick={() => {
onStartClick()
}}
>
Simulate
</Button>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { StreamPacket } from "@dassie/lib-protocol-stream"
import { isFailure } from "@dassie/lib-type-utils"

import StreamFrameDetails from "./stream-frame-details"
import type { StreamPacketParseFailure } from "./use-parsed-stream-packet"

interface StreamPacketDetailsProperties {
packet: StreamPacket | StreamPacketParseFailure | undefined
response?: boolean | undefined
}

export default function StreamPacketDetails({
packet,
response,
}: StreamPacketDetailsProperties) {
return (
<div className="grid grid-cols-subgrid col-span-2">
{packet ?
isFailure(packet) ?
<div className="text-red-300 col-span-2">{packet.reason}</div>
: <>
<div className="text-muted-foreground">
{response ? "Received Amount" : "Expected Amount"}
</div>
<div>{String(packet.amount)}</div>
<div className="text-muted-foreground">Sequence</div>
<div>{String(packet.sequence)}</div>
{packet.frames.length > 0 ?
<div className="col-span-2 flex flex-col gap-1">
<div className="text-muted-foreground">Frames</div>
{packet.frames.map((frame, index) => (
<StreamFrameDetails key={index} frame={frame} />
))}
</div>
: <div className="text-muted-foreground">No frames</div>}
</>

: null}
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {
type IlpPreparePacket,
type IlpResponsePacket,
IlpType,
humanReadableIlpErrors,
getHumanReadableIlpError,
} from "@dassie/lib-protocol-ilp"
import type { PskEnvironment } from "@dassie/lib-protocol-stream"

import AmountTooLargeResponseDetails from "./AmountTooLargeResponseDetails"
import IlpPacketDetails from "./IlpPacketDetails"
import StreamPacketDetails from "./StreamPacketDetails"
import AmountTooLargeResponseDetails from "./amount-too-large-response-details"
import IlpPacketDetails from "./ilp-packet-details"
import StreamPacketDetails from "./stream-packet-details"
import { useParsedStreamPacket } from "./use-parsed-stream-packet"

interface StreamPacketLogEntryProperties {
Expand All @@ -32,10 +32,11 @@ export default function StreamPacketLogEntry({

const [isExpanded, setIsExpanded] = useState(false)

const requestStreamPacket =
pskEnvironment && useParsedStreamPacket(packet.data, pskEnvironment)
const responseStreamPacket =
pskEnvironment && useParsedStreamPacket(response?.data.data, pskEnvironment)
const requestStreamPacket = useParsedStreamPacket(packet.data, pskEnvironment)
const responseStreamPacket = useParsedStreamPacket(
response?.data.data,
pskEnvironment,
)

const ArrowIcon = sender === "client" ? ArrowRightIcon : ArrowLeftIcon
// response = undefined
Expand All @@ -45,7 +46,9 @@ export default function StreamPacketLogEntry({
>
<div
className="flex flex-row items-center justify-between cursor-pointer hover:bg-slate-700 transition-colors"
onClick={() => setIsExpanded((value) => !value)}
onClick={() => {
setIsExpanded((value) => !value)
}}
>
<div
className={combine(
Expand All @@ -57,24 +60,22 @@ export default function StreamPacketLogEntry({
<ArrowIcon
className={combine(
"size-4 rounded-full stroke-6",
!!response ?
response ?
response.type === IlpType.Fulfill ?
"text-green-500"
: "text-red-500"
: "text-slate-400",
)}
/>
<div className="font-bold">
{!!response ?
{response ?
response.type === IlpType.Fulfill ?
"Fulfilled"
: <div className="flex flex-row gap-3">
<div>Rejected</div>
<div className="text-red-300">
{response.data.code}{" "}
{humanReadableIlpErrors[
response.data.code as IlpErrorCode
] ?? "Unknown Error"}
{getHumanReadableIlpError(response.data.code)}
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
} from "@dassie/lib-protocol-ilp"
import type { PskEnvironment } from "@dassie/lib-protocol-stream"

import StreamPacketLogEntry from "./StreamPacketLogEntry"
import StreamPacketLogEntry from "./stream-packet-log-entry"

interface StreamPacketLogProperties {
packets: IndexedPreparePacketEvent[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type StreamPacket,
streamPacketSchema,
} from "@dassie/lib-protocol-stream"
import { Failure, isFailure } from "@dassie/lib-type-utils"
import { Failure, isError, isFailure } from "@dassie/lib-type-utils"

export class StreamPacketParseFailure extends Failure {
readonly name = "StreamPacketParseFailure"
Expand All @@ -17,7 +17,7 @@ export class StreamPacketParseFailure extends Failure {

export function useParsedStreamPacket(
data: Uint8Array | undefined,
pskEnvironment: PskEnvironment,
pskEnvironment: PskEnvironment | undefined,
) {
const [parsedStreamPacket, setParsedStreamPacket] = useState<
StreamPacket | StreamPacketParseFailure | undefined
Expand All @@ -26,7 +26,7 @@ export function useParsedStreamPacket(
useEffect(() => {
setParsedStreamPacket(undefined)

if (!data) return
if (!data || !pskEnvironment) return

if (data.length === 0) {
setParsedStreamPacket(new StreamPacketParseFailure("No data"))
Expand Down Expand Up @@ -54,8 +54,12 @@ export function useParsedStreamPacket(

setParsedStreamPacket(parseResult.value)
})
.catch((error) => {
setParsedStreamPacket(new StreamPacketParseFailure(error.message))
.catch((error: unknown) => {
if (isError(error)) {
setParsedStreamPacket(new StreamPacketParseFailure(error.message))
return
}
throw error
})
}, [data, pskEnvironment, setParsedStreamPacket])

Expand Down
Loading

0 comments on commit 204fa7a

Please sign in to comment.