Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added typescript typings #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
41 changes: 41 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
type DebuggerMessage<State> = {
readonly type: 'START' | 'ACTION' | 'DISPATCH'
readonly payload:
| {
readonly type: 'JUMP_TO_STATE' | 'JUMP_TO_ACTION'
}
| {
readonly type: 'IMPORT_STATE'
readonly nextLiftedState: {
readonly computedStates: ReadonlyArray<{
readonly state: State
}>
}
}
}

type DebuggerAction = {
readonly type: string
readonly [key: string]: unknown
}

type Connection<State, Action> = {
readonly init: (state: State) => void
readonly send: (action: Action, state: State) => void
readonly subscribe: (listener: (message: DebuggerMessage<State>) => void) => () => void
}

type ConnectionOptions<Action> = {
readonly name?: string
readonly remote?: boolean
readonly port?: number
readonly hostname?: string
readonly secure?: boolean
readonly getActionType?: (action: Action) => DebuggerAction
}

export declare function connectViaExtension<State, Action>(
options?: ConnectionOptions<Action>
): Connection<State, Action>

export declare function extractState<State>(message: DebuggerMessage<State>): State
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"version": "0.2.9",
"description": "Remote debugging for any flux implementation.",
"main": "lib/index.js",
"types": "index.d.ts",
"files": [
"lib",
"dist"
"dist",
"index.d.ts"
],
"scripts": {
"clean": "rimraf lib",
Expand Down