@stomp/stompjs 6.1.1 → 7.0.0-beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/stomp.umd.js +325 -308
- package/bundles/stomp.umd.min.js +1 -2
- package/esm6/augment-websocket.js +4 -3
- package/esm6/augment-websocket.js.map +1 -0
- package/esm6/byte.js.map +1 -0
- package/esm6/client.d.ts +29 -13
- package/esm6/client.js +75 -16
- package/esm6/client.js.map +1 -0
- package/esm6/compatibility/compat-client.d.ts +26 -20
- package/esm6/compatibility/compat-client.js.map +1 -0
- package/esm6/compatibility/heartbeat-info.d.ts +4 -2
- package/esm6/compatibility/heartbeat-info.js.map +1 -0
- package/esm6/compatibility/stomp.js.map +1 -0
- package/esm6/frame-impl.d.ts +2 -2
- package/esm6/frame-impl.js +2 -1
- package/esm6/frame-impl.js.map +1 -0
- package/esm6/i-frame.js +1 -0
- package/esm6/i-frame.js.map +1 -0
- package/esm6/i-message.js +1 -0
- package/esm6/i-message.js.map +1 -0
- package/esm6/i-transaction.js +1 -0
- package/esm6/i-transaction.js.map +1 -0
- package/esm6/index.js +3 -0
- package/esm6/index.js.map +1 -0
- package/esm6/parser.js +10 -2
- package/esm6/parser.js.map +1 -0
- package/esm6/stomp-config.js.map +1 -0
- package/esm6/stomp-handler.d.ts +5 -8
- package/esm6/stomp-handler.js +33 -15
- package/esm6/stomp-handler.js.map +1 -0
- package/esm6/stomp-headers.js.map +1 -0
- package/esm6/stomp-subscription.d.ts +1 -1
- package/esm6/stomp-subscription.js +1 -7
- package/esm6/stomp-subscription.js.map +1 -0
- package/esm6/types.d.ts +28 -2
- package/esm6/types.js.map +1 -0
- package/esm6/versions.js +2 -2
- package/esm6/versions.js.map +1 -0
- package/package.json +26 -24
- package/src/augment-websocket.ts +39 -0
- package/src/byte.ts +13 -0
- package/src/client.ts +858 -0
- package/src/compatibility/compat-client.ts +269 -0
- package/src/compatibility/heartbeat-info.ts +26 -0
- package/src/compatibility/stomp.ts +118 -0
- package/src/frame-impl.ts +254 -0
- package/src/i-frame.ts +41 -0
- package/src/i-message.ts +35 -0
- package/src/i-transaction.ts +23 -0
- package/src/index.ts +15 -0
- package/src/parser.ts +267 -0
- package/src/stomp-config.ts +152 -0
- package/src/stomp-handler.ts +555 -0
- package/src/stomp-headers.ts +12 -0
- package/src/stomp-subscription.ts +18 -0
- package/src/types.ts +183 -0
- package/src/versions.ts +50 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { IFrame } from './i-frame';
|
|
2
|
+
import { IMessage } from './i-message';
|
|
3
|
+
import { StompHeaders } from './stomp-headers';
|
|
4
|
+
import { Versions } from './versions';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This callback will receive a `string` as parameter.
|
|
8
|
+
*
|
|
9
|
+
* Part of `@stomp/stompjs`.
|
|
10
|
+
*/
|
|
11
|
+
export type debugFnType = (msg: string) => void;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This callback will receive a {@link IMessage} as parameter.
|
|
15
|
+
*
|
|
16
|
+
* Part of `@stomp/stompjs`.
|
|
17
|
+
*/
|
|
18
|
+
export type messageCallbackType = (message: IMessage) => void;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This callback will receive a {@link IFrame} as parameter.
|
|
22
|
+
*
|
|
23
|
+
* Part of `@stomp/stompjs`.
|
|
24
|
+
*/
|
|
25
|
+
export type frameCallbackType = (receipt: IFrame) => void;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* This callback will receive a [CloseEvent]{@link https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent}
|
|
29
|
+
* as parameter.
|
|
30
|
+
*
|
|
31
|
+
* Part of `@stomp/stompjs`.
|
|
32
|
+
*/
|
|
33
|
+
export type closeEventCallbackType<T = any> = (evt: T) => void;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* This callback will receive an [Event]{@link https://developer.mozilla.org/en-US/docs/Web/API/Event}
|
|
37
|
+
* as parameter.
|
|
38
|
+
*
|
|
39
|
+
* Part of `@stomp/stompjs`.
|
|
40
|
+
*/
|
|
41
|
+
export type wsErrorCallbackType<T = any> = (evt: T) => void;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Parameters for [Client#publish]{@link Client#publish}.
|
|
45
|
+
* Aliased as publishParams as well.
|
|
46
|
+
*
|
|
47
|
+
* Part of `@stomp/stompjs`.
|
|
48
|
+
*/
|
|
49
|
+
export interface IPublishParams {
|
|
50
|
+
/**
|
|
51
|
+
* destination end point
|
|
52
|
+
*/
|
|
53
|
+
destination: string;
|
|
54
|
+
/**
|
|
55
|
+
* headers (optional)
|
|
56
|
+
*/
|
|
57
|
+
headers?: StompHeaders;
|
|
58
|
+
/**
|
|
59
|
+
* body (optional)
|
|
60
|
+
*/
|
|
61
|
+
body?: string;
|
|
62
|
+
/**
|
|
63
|
+
* binary body (optional)
|
|
64
|
+
*/
|
|
65
|
+
binaryBody?: Uint8Array;
|
|
66
|
+
/**
|
|
67
|
+
* By default a `content-length` header will be added in the Frame to the broker.
|
|
68
|
+
* Set it to `true` for the header to be skipped.
|
|
69
|
+
*/
|
|
70
|
+
skipContentLengthHeader?: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Backward compatibility, switch to {@link IPublishParams}.
|
|
75
|
+
*/
|
|
76
|
+
export type publishParams = IPublishParams;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Used in {@link IRawFrameType}
|
|
80
|
+
*
|
|
81
|
+
* Part of `@stomp/stompjs`.
|
|
82
|
+
*
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
export type RawHeaderType = [string, string];
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The parser yield frames in this structure
|
|
89
|
+
*
|
|
90
|
+
* Part of `@stomp/stompjs`.
|
|
91
|
+
*
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
export interface IRawFrameType {
|
|
95
|
+
command: string | undefined;
|
|
96
|
+
headers: RawHeaderType[];
|
|
97
|
+
binaryBody: Uint8Array | undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
export interface IStompSocketMessageEvent {
|
|
104
|
+
data?: string | ArrayBuffer;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Copied from Websocket interface to avoid dom typelib dependency.
|
|
109
|
+
*
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
export interface IStompSocket {
|
|
113
|
+
onclose: ((this: IStompSocket, ev?: any) => any) | null;
|
|
114
|
+
onerror: ((this: IStompSocket, ev: any) => any) | null;
|
|
115
|
+
onmessage: ((this: IStompSocket, ev: IStompSocketMessageEvent) => any) | null;
|
|
116
|
+
onopen: ((this: IStompSocket, ev?: any) => any) | null;
|
|
117
|
+
terminate?: ((this: IStompSocket) => any) | null;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Returns a string that indicates how binary data from the socket is exposed to scripts:
|
|
121
|
+
* We support only 'arraybuffer'.
|
|
122
|
+
*/
|
|
123
|
+
binaryType: 'arraybuffer';
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Returns the state of the socket connection. It can have the values of StompSocketState.
|
|
127
|
+
*/
|
|
128
|
+
readonly readyState: number;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Closes the connection.
|
|
132
|
+
*/
|
|
133
|
+
close(): void;
|
|
134
|
+
/**
|
|
135
|
+
* Transmits data using the connection. data can be a string or an ArrayBuffer.
|
|
136
|
+
*/
|
|
137
|
+
send(data: string | ArrayBuffer): void;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Possible states for the IStompSocket
|
|
142
|
+
*/
|
|
143
|
+
export enum StompSocketState {
|
|
144
|
+
CONNECTING,
|
|
145
|
+
OPEN,
|
|
146
|
+
CLOSING,
|
|
147
|
+
CLOSED,
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Possible activation state
|
|
152
|
+
*/
|
|
153
|
+
export enum ActivationState {
|
|
154
|
+
ACTIVE,
|
|
155
|
+
DEACTIVATING,
|
|
156
|
+
INACTIVE,
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @internal
|
|
161
|
+
*/
|
|
162
|
+
export interface IStomptHandlerConfig {
|
|
163
|
+
debug: debugFnType;
|
|
164
|
+
stompVersions: Versions;
|
|
165
|
+
connectHeaders: StompHeaders;
|
|
166
|
+
disconnectHeaders: StompHeaders;
|
|
167
|
+
heartbeatIncoming: number;
|
|
168
|
+
heartbeatOutgoing: number;
|
|
169
|
+
splitLargeFrames: boolean;
|
|
170
|
+
maxWebSocketChunkSize: number;
|
|
171
|
+
forceBinaryWSFrames: boolean;
|
|
172
|
+
logRawCommunication: boolean;
|
|
173
|
+
appendMissingNULLonIncoming: boolean;
|
|
174
|
+
discardWebsocketOnCommFailure: boolean;
|
|
175
|
+
onConnect: frameCallbackType;
|
|
176
|
+
onDisconnect: frameCallbackType;
|
|
177
|
+
onStompError: frameCallbackType;
|
|
178
|
+
onWebSocketClose: closeEventCallbackType;
|
|
179
|
+
onWebSocketError: wsErrorCallbackType;
|
|
180
|
+
onUnhandledMessage: messageCallbackType;
|
|
181
|
+
onUnhandledReceipt: frameCallbackType;
|
|
182
|
+
onUnhandledFrame: frameCallbackType;
|
|
183
|
+
}
|
package/src/versions.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported STOMP versions
|
|
3
|
+
*
|
|
4
|
+
* Part of `@stomp/stompjs`.
|
|
5
|
+
*/
|
|
6
|
+
export class Versions {
|
|
7
|
+
/**
|
|
8
|
+
* Indicates protocol version 1.0
|
|
9
|
+
*/
|
|
10
|
+
public static V1_0 = '1.0';
|
|
11
|
+
/**
|
|
12
|
+
* Indicates protocol version 1.1
|
|
13
|
+
*/
|
|
14
|
+
public static V1_1 = '1.1';
|
|
15
|
+
/**
|
|
16
|
+
* Indicates protocol version 1.2
|
|
17
|
+
*/
|
|
18
|
+
public static V1_2 = '1.2';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
public static default = new Versions([
|
|
24
|
+
Versions.V1_2,
|
|
25
|
+
Versions.V1_1,
|
|
26
|
+
Versions.V1_0,
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Takes an array of string of versions, typical elements '1.0', '1.1', or '1.2'
|
|
31
|
+
*
|
|
32
|
+
* You will an instance if this class if you want to override supported versions to be declared during
|
|
33
|
+
* STOMP handshake.
|
|
34
|
+
*/
|
|
35
|
+
constructor(public versions: string[]) {}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Used as part of CONNECT STOMP Frame
|
|
39
|
+
*/
|
|
40
|
+
public supportedVersions() {
|
|
41
|
+
return this.versions.join(',');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Used while creating a WebSocket
|
|
46
|
+
*/
|
|
47
|
+
public protocolVersions() {
|
|
48
|
+
return this.versions.map(x => `v${x.replace('.', '')}.stomp`);
|
|
49
|
+
}
|
|
50
|
+
}
|