-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathindex.d.ts
More file actions
116 lines (91 loc) · 3.04 KB
/
index.d.ts
File metadata and controls
116 lines (91 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { Transport } from '../transport/index.js'
import { Logger, LogLevel } from '../logger/index.js'
import { Encoder } from '../encoder/index.js'
import { Monitor, ReconnectStrategy } from '../monitor/index.js'
import { Cable } from '../cable/index.js'
import { Protocol } from '../protocol/index.js'
import { Channel, Message, ChannelParamsMap } from '../channel/index.js'
import { Options } from '../action_cable/index.js'
import { ExtendedOptions } from '../action_cable_ext/index.js'
export type ExtendedProtocolID =
| 'actioncable-v1-ext-json'
| 'actioncable-v1-ext-msgpack'
| 'actioncable-v1-ext-protobuf'
export type ProtocolID =
| 'actioncable-v1-json'
| 'actioncable-v1-msgpack'
| 'actioncable-v1-protobuf'
| ExtendedProtocolID
export type TokenRefresher = (transport: Transport) => Promise<void>
type ProtocolOptions<T extends Protocol | ProtocolID> = T extends Protocol
? never
: T extends ExtendedProtocolID
? ExtendedOptions
: Options
export interface CreateOptions<P extends ProtocolID | Protocol> {
protocol: P
subprotocol: string
protocolOptions: ProtocolOptions<P>
transport: Transport
/* eslint-disable @typescript-eslint/no-explicit-any */
websocketImplementation: any
websocketFormat: string
websocketOptions: object
fallbacks: Transport[]
encoder: Encoder
logger: Logger
logLevel: LogLevel
monitor: Monitor | false
pingInterval: number
lazy: boolean
tokenRefresher: TokenRefresher
reconnectStrategy: ReconnectStrategy
maxMissingPings: number
maxReconnectAttempts: number
historyTimestamp: number | false
concurrentSubscribes: boolean
}
export const DEFAULT_OPTIONS: Partial<CreateOptions<ProtocolID | Protocol>>
export function createCable(
url: string,
opts?: Partial<CreateOptions<ProtocolID | Protocol>>
): Cable
export function createCable(
opts?: Partial<CreateOptions<ProtocolID | Protocol>>
): Cable
export type ActionCableMixin<T extends Message> = Partial<{
initialized: () => void
connected: () => void
rejected: () => void
received: (data: T) => void
disconnected: () => void
}>
export class ActionCableSubscription {
channel: ActionCableChannel
identifier: string
perform(action: string, payload?: object): Promise<void>
send(payload: object): void
unsubscribe(): void
}
export class ActionCableChannel extends Channel {
subscription: ActionCableSubscription
}
export class ActionCableSubscriptions {
create<M extends ActionCableMixin<T> = {}, T extends Message = Message>(
params: ChannelParamsMap | string,
mixin: ActionCableMixin<T>
): ActionCableSubscription & M
create(params: ChannelParamsMap | string): ActionCableSubscription
findAll(identifier: string): ActionCableSubscription[]
}
export class ActionCableConsumer {
readonly cable: Cable
readonly subscriptions: ActionCableSubscriptions
}
export function createConsumer(
url: string,
opts?: Partial<CreateOptions<ProtocolID | Protocol>>
): ActionCableConsumer
export function createConsumer(
opts?: Partial<CreateOptions<ProtocolID | Protocol>>
): ActionCableConsumer