"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/hoppscotch-app/newstore/WebSocketSession.ts" between
hoppscotch-2.2.1.tar.gz and hoppscotch-3.0.0.tar.gz

About: Hoppscotch is a light-weight, web based API development suite.

WebSocketSession.ts  (hoppscotch-2.2.1):WebSocketSession.ts  (hoppscotch-3.0.0)
import { pluck, distinctUntilChanged } from "rxjs/operators" import { pluck, distinctUntilChanged } from "rxjs/operators"
import DispatchingStore, { defineDispatchers } from "./DispatchingStore" import DispatchingStore, { defineDispatchers } from "./DispatchingStore"
import { import {
HoppRealtimeLog, HoppRealtimeLog,
HoppRealtimeLogLine, HoppRealtimeLogLine,
} from "~/helpers/types/HoppRealtimeLog" } from "~/helpers/types/HoppRealtimeLog"
import { WSConnection } from "~/helpers/realtime/WSConnection"
type HoppWSProtocol = { export type HoppWSProtocol = {
value: string value: string
active: boolean active: boolean
} }
type HoppWSRequest = { type HoppWSRequest = {
endpoint: string endpoint: string
protocols: HoppWSProtocol[] protocols: HoppWSProtocol[]
} }
export type HoppWSSession = { export type HoppWSSession = {
request: HoppWSRequest request: HoppWSRequest
connectingState: boolean
connectionState: boolean
log: HoppRealtimeLog log: HoppRealtimeLog
socket: WebSocket | null socket: WSConnection
} }
const defaultWSRequest: HoppWSRequest = { const defaultWSRequest: HoppWSRequest = {
endpoint: "wss://hoppscotch-websocket.herokuapp.com", endpoint: "wss://echo-websocket.hoppscotch.io",
protocols: [], protocols: [],
} }
const defaultWSSession: HoppWSSession = { const defaultWSSession: HoppWSSession = {
request: defaultWSRequest, request: defaultWSRequest,
connectionState: false, socket: new WSConnection(),
connectingState: false,
socket: null,
log: [], log: [],
} }
const dispatchers = defineDispatchers({ const dispatchers = defineDispatchers({
setRequest(_: HoppWSSession, { newRequest }: { newRequest: HoppWSRequest }) { setRequest(_: HoppWSSession, { newRequest }: { newRequest: HoppWSRequest }) {
return { return {
request: newRequest, request: newRequest,
} }
}, },
setEndpoint(curr: HoppWSSession, { newEndpoint }: { newEndpoint: string }) { setEndpoint(curr: HoppWSSession, { newEndpoint }: { newEndpoint: string }) {
skipping to change at line 104 skipping to change at line 101
) { ) {
return { return {
request: { request: {
endpoint: curr.request.endpoint, endpoint: curr.request.endpoint,
protocols: curr.request.protocols.map((proto, idx) => { protocols: curr.request.protocols.map((proto, idx) => {
return index === idx ? updatedProtocol : proto return index === idx ? updatedProtocol : proto
}), }),
}, },
} }
}, },
setSocket(_: HoppWSSession, { socket }: { socket: WebSocket }) { setSocket(_: HoppWSSession, { socket }: { socket: WSConnection }) {
return { return {
socket, socket,
} }
}, },
setConnectionState(_: HoppWSSession, { state }: { state: boolean }) {
return {
connectionState: state,
}
},
setConnectingState(_: HoppWSSession, { state }: { state: boolean }) {
return {
connectingState: state,
}
},
setLog(_: HoppWSSession, { log }: { log: HoppRealtimeLog }) { setLog(_: HoppWSSession, { log }: { log: HoppRealtimeLog }) {
return { return {
log, log,
} }
}, },
addLogLine(curr: HoppWSSession, { line }: { line: HoppRealtimeLogLine }) { addLogLine(curr: HoppWSSession, { line }: { line: HoppRealtimeLogLine }) {
return { return {
log: [...curr.log, line], log: [...curr.log, line],
} }
}, },
skipping to change at line 198 skipping to change at line 185
) { ) {
WSSessionStore.dispatch({ WSSessionStore.dispatch({
dispatcher: "updateProtocol", dispatcher: "updateProtocol",
payload: { payload: {
index, index,
updatedProtocol, updatedProtocol,
}, },
}) })
} }
export function setWSSocket(socket: WebSocket) { export function setWSSocket(socket: WSConnection) {
WSSessionStore.dispatch({ WSSessionStore.dispatch({
dispatcher: "setSocket", dispatcher: "setSocket",
payload: { payload: {
socket, socket,
}, },
}) })
} }
export function setWSConnectionState(state: boolean) {
WSSessionStore.dispatch({
dispatcher: "setConnectionState",
payload: {
state,
},
})
}
export function setWSConnectingState(state: boolean) {
WSSessionStore.dispatch({
dispatcher: "setConnectingState",
payload: {
state,
},
})
}
export function setWSLog(log: HoppRealtimeLog) { export function setWSLog(log: HoppRealtimeLog) {
WSSessionStore.dispatch({ WSSessionStore.dispatch({
dispatcher: "setLog", dispatcher: "setLog",
payload: { payload: {
log, log,
}, },
}) })
} }
export function addWSLogLine(line: HoppRealtimeLogLine) { export function addWSLogLine(line: HoppRealtimeLogLine) {
 End of changes. 10 change blocks. 
37 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)