Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/reactotron-core-client/src/plugins/api-response.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ApiResponsePayload } from "reactotron-core-contract"
import type { ReactotronCore, Plugin } from "../reactotron-core-client"

/**
Expand All @@ -6,7 +7,11 @@ import type { ReactotronCore, Plugin } from "../reactotron-core-client"
const apiResponse = () => (reactotron: ReactotronCore) => {
return {
features: {
apiResponse: (request: { status: number }, response: any, duration: number) => {
apiResponse: (
request: ApiResponsePayload["request"],
response: ApiResponsePayload["response"],
duration: number
) => {
const ok =
response &&
response.status &&
Expand Down
3 changes: 2 additions & 1 deletion lib/reactotron-core-client/src/plugins/benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { BenchmarkReportPayload } from "reactotron-core-contract"
import type { ReactotronCore, Plugin } from "../reactotron-core-client"

/**
Expand All @@ -7,7 +8,7 @@ const benchmark = () => (reactotron: ReactotronCore) => {
const { startTimer } = reactotron

const benchmark = (title: string) => {
const steps = [] as Array<{title: string, time: number, delta: number}>
const steps: BenchmarkReportPayload["steps"] = []
const elapsed = startTimer()
const step = (stepTitle: string) => {
const previousTime = steps.length === 0 ? 0 : (steps[steps.length - 1] as any).time
Expand Down
10 changes: 1 addition & 9 deletions lib/reactotron-core-client/src/plugins/image.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import type { ImagePayload } from "reactotron-core-contract"
import type { ReactotronCore, Plugin } from "../reactotron-core-client"

export interface ImagePayload {
uri: string
preview: string
caption?: string
width?: number
height?: number
filename?: string
}

/**
* Provides an image.
*/
Expand Down
5 changes: 3 additions & 2 deletions lib/reactotron-core-client/src/plugins/repl.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ReplExecuteResponsePayload, ReplLsResponsePayload } from "reactotron-core-contract"
import type { ReactotronCore, Plugin } from "../reactotron-core-client"

// eslint-disable-next-line @typescript-eslint/ban-types
Expand All @@ -12,7 +13,7 @@ const repl = () => (reactotron: ReactotronCore) => {

switch (type.substr(5)) {
case "ls":
reactotron.send("repl.ls.response", Object.keys(myRepls))
reactotron.send("repl.ls.response", Object.keys(myRepls) as ReplLsResponsePayload)
break
// case "cd":
// const changeTo = myRepls.find(r => r.name === payload)
Expand Down Expand Up @@ -40,7 +41,7 @@ const repl = () => (reactotron: ReactotronCore) => {
"repl.execute.response",
function () {
return eval(payload) // eslint-disable-line no-eval
}.call(myRepls)
}.call(myRepls) as ReplExecuteResponsePayload
)
break
}
Expand Down
24 changes: 10 additions & 14 deletions lib/reactotron-core-client/src/reactotron-core-client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import WebSocket from "ws"
import type { Command, CommandTypeKey } from "reactotron-core-contract"
import type { Command, CommandTypeKey, DisplayPayload } from "reactotron-core-contract"
import validate from "./validate"
import logger from "./plugins/logger"
import image from "./plugins/image"
Expand Down Expand Up @@ -44,11 +44,7 @@ export interface Plugin<Client> extends LifeCycleMethods {

export type PluginCreator<Client> = (client: Client) => Plugin<Client>

interface DisplayConfig {
name: string
value?: object | string | number | boolean | null | undefined
preview?: string
image?: string | { uri: string }
interface DisplayConfig extends DisplayPayload {
important?: boolean
}

Expand Down Expand Up @@ -291,7 +287,7 @@ export class ReactotronImpl
this.send("client.intro", {
environment,
...client,
name,
name: name!,
clientId,
reactotronCoreClientVersion: "REACTOTRON_CORE_CLIENT_VERSION",
})
Expand Down Expand Up @@ -421,11 +417,11 @@ export class ReactotronImpl
*/
display(config: DisplayConfig) {
const { name, value, preview, image: img, important = false } = config
const payload = {
const payload: DisplayPayload = {
name,
value: value || null,
preview: preview || null,
image: img || null,
value: value || undefined,
preview: preview || undefined,
image: img || undefined,
}
this.send("display", payload, important)
}
Expand Down Expand Up @@ -531,7 +527,7 @@ export class ReactotronImpl
this.customCommands = this.customCommands.filter((cc) => cc.id !== command.id)

this.send("customCommand.unregister", {
id: command.id,
id: command.id!,
command: command.command,
})
})
Expand Down Expand Up @@ -572,7 +568,7 @@ export class ReactotronImpl
this.customCommands.push(customHandler)

this.send("customCommand.register", {
id: customHandler.id,
id: customHandler.id!,
command: customHandler.command,
title: customHandler.title,
description: customHandler.description,
Expand All @@ -583,7 +579,7 @@ export class ReactotronImpl
this.customCommands = this.customCommands.filter((cc) => cc.id !== customHandler.id)

this.send("customCommand.unregister", {
id: customHandler.id,
id: customHandler.id!,
command: customHandler.command,
})
}
Expand Down
Loading