oorja 1.5.0 → 1.6.2

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.
Files changed (46) hide show
  1. package/README.md +10 -4
  2. package/bin/oorja +5 -0
  3. package/lib/commands/signout.js +2 -2
  4. package/lib/commands/teletype/index.js +3 -3
  5. package/lib/lib/config.d.ts +5 -6
  6. package/lib/lib/config.js +12 -7
  7. package/lib/lib/encryption.d.ts +1 -1
  8. package/lib/lib/encryption.js +12 -7
  9. package/lib/lib/index.js +1 -0
  10. package/lib/lib/oorja/index.js +14 -13
  11. package/lib/lib/oorja/preflight.d.ts +1 -1
  12. package/lib/lib/oorja/preflight.js +17 -11
  13. package/lib/lib/surya/index.d.ts +2 -2
  14. package/lib/lib/surya/index.js +15 -13
  15. package/lib/lib/surya/types.d.ts +10 -10
  16. package/lib/lib/surya/vendor/phoenix/ajax.d.ts +8 -0
  17. package/lib/lib/surya/vendor/phoenix/ajax.js +85 -0
  18. package/lib/lib/surya/vendor/phoenix/channel.d.ts +154 -0
  19. package/lib/lib/surya/vendor/phoenix/channel.js +311 -0
  20. package/lib/lib/surya/vendor/phoenix/constants.d.ts +33 -0
  21. package/lib/lib/surya/vendor/phoenix/constants.js +32 -0
  22. package/lib/lib/surya/vendor/phoenix/index.d.ts +199 -0
  23. package/lib/lib/surya/vendor/phoenix/index.js +207 -0
  24. package/lib/lib/surya/vendor/phoenix/longpoll.d.ts +12 -0
  25. package/lib/lib/surya/vendor/phoenix/longpoll.js +129 -0
  26. package/lib/lib/surya/vendor/phoenix/presence.d.ts +44 -0
  27. package/lib/lib/surya/vendor/phoenix/presence.js +155 -0
  28. package/lib/lib/surya/vendor/phoenix/push.d.ts +57 -0
  29. package/lib/lib/surya/vendor/phoenix/push.js +125 -0
  30. package/lib/lib/surya/vendor/phoenix/serializer.d.ts +53 -0
  31. package/lib/lib/surya/vendor/phoenix/serializer.js +102 -0
  32. package/lib/lib/surya/vendor/phoenix/socket.d.ts +222 -0
  33. package/lib/lib/surya/vendor/phoenix/socket.js +544 -0
  34. package/lib/lib/surya/vendor/phoenix/timer.d.ts +25 -0
  35. package/lib/lib/surya/vendor/phoenix/timer.js +43 -0
  36. package/lib/lib/surya/vendor/phoenix/utils.d.ts +1 -0
  37. package/lib/lib/surya/vendor/phoenix/utils.js +15 -0
  38. package/lib/lib/teletype/auxiliary.d.ts +1 -1
  39. package/lib/lib/teletype/auxiliary.js +8 -4
  40. package/lib/lib/teletype/index.d.ts +1 -1
  41. package/lib/lib/teletype/index.js +13 -12
  42. package/lib/lib/utils.js +2 -1
  43. package/oclif.manifest.json +1 -1
  44. package/package.json +10 -9
  45. package/lib/lib/surya/vendor/phoenix.d.ts +0 -486
  46. package/lib/lib/surya/vendor/phoenix.js +0 -1299
@@ -14,20 +14,20 @@ var MessageType;
14
14
  MessageType["DIMENSIONS"] = "d";
15
15
  })(MessageType || (MessageType = {}));
16
16
  const SELF = "self";
17
- exports.teletypeApp = (options) => {
17
+ const teletypeApp = (options) => {
18
18
  const username = os.userInfo().username;
19
19
  const hostname = os.hostname();
20
20
  const userDimensions = {};
21
- userDimensions[SELF] = auxiliary_1.getDimensions();
21
+ userDimensions[SELF] = (0, auxiliary_1.getDimensions)();
22
22
  let term;
23
23
  const reEvaluateOwnDimensions = () => {
24
24
  const lastKnown = userDimensions[SELF];
25
- const latest = auxiliary_1.getDimensions();
26
- if (auxiliary_1.areDimensionEqual(lastKnown, latest)) {
25
+ const latest = (0, auxiliary_1.getDimensions)();
26
+ if ((0, auxiliary_1.areDimensionEqual)(lastKnown, latest)) {
27
27
  return;
28
28
  }
29
29
  userDimensions[SELF] = latest;
30
- auxiliary_1.resizeBestFit(term, userDimensions);
30
+ (0, auxiliary_1.resizeBestFit)(term, userDimensions);
31
31
  };
32
32
  return new Promise((resolve, reject) => {
33
33
  const channel = options.joinChannel({
@@ -38,11 +38,11 @@ exports.teletypeApp = (options) => {
38
38
  multiplexed: options.multiplex,
39
39
  },
40
40
  onJoin: () => {
41
- auxiliary_1.initScreen(username, hostname, options.shell, options.multiplex);
41
+ (0, auxiliary_1.initScreen)(username, hostname, options.shell, options.multiplex);
42
42
  const stdin = options.process.stdin;
43
43
  const stdout = options.process.stdout;
44
44
  const dimensions = userDimensions[SELF];
45
- term = node_pty_1.spawn(options.shell, [], {
45
+ term = (0, node_pty_1.spawn)(options.shell, [], {
46
46
  name: "xterm-256color",
47
47
  cols: dimensions.cols,
48
48
  rows: dimensions.rows,
@@ -59,12 +59,12 @@ exports.teletypeApp = (options) => {
59
59
  channel.push("new_msg", {
60
60
  t: MessageType.OUT,
61
61
  b: true,
62
- d: encryption_1.encrypt(d, options.roomKey),
62
+ d: (0, encryption_1.encrypt)(d, options.roomKey),
63
63
  });
64
64
  });
65
65
  term.on("exit", () => {
66
66
  console.log(chalk.blueBright("terminated shell stream to oorja. byee!"));
67
- resolve();
67
+ resolve(null);
68
68
  });
69
69
  stdin.setEncoding("utf8");
70
70
  stdin.setRawMode(true);
@@ -87,10 +87,10 @@ exports.teletypeApp = (options) => {
87
87
  switch (t) {
88
88
  case MessageType.DIMENSIONS:
89
89
  userDimensions[session] = d;
90
- auxiliary_1.resizeBestFit(term, userDimensions);
90
+ (0, auxiliary_1.resizeBestFit)(term, userDimensions);
91
91
  break;
92
92
  case MessageType.IN:
93
- const data = encryption_1.decrypt(d, options.roomKey);
93
+ const data = (0, encryption_1.decrypt)(d, options.roomKey);
94
94
  const userId = session.split(":")[0];
95
95
  if (options.multiplex) {
96
96
  term.write(data);
@@ -108,8 +108,9 @@ exports.teletypeApp = (options) => {
108
108
  handleSessionJoin: (s) => { },
109
109
  handleSessionLeave: (s) => {
110
110
  delete userDimensions[s];
111
- auxiliary_1.resizeBestFit(term, userDimensions);
111
+ (0, auxiliary_1.resizeBestFit)(term, userDimensions);
112
112
  },
113
113
  });
114
114
  });
115
115
  };
116
+ exports.teletypeApp = teletypeApp;
package/lib/lib/utils.js CHANGED
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.promptRoomLink = void 0;
4
4
  const { Input } = require("enquirer");
5
- exports.promptRoomLink = async () => {
5
+ const promptRoomLink = async () => {
6
6
  return await new Input({
7
7
  name: "room secret link",
8
8
  message: "Enter the room secret link. (click the share button in the room)",
9
9
  }).run();
10
10
  };
11
+ exports.promptRoomLink = promptRoomLink;
@@ -1 +1 @@
1
- {"version":"1.5.0","commands":{"signout":{"id":"signout","description":"Sign-out of oorja. Clears saved auth-token","pluginName":"oorja","pluginType":"core","aliases":[],"flags":{},"args":[]},"teletype":{"id":"teletype","description":"Launch a terminal streaming session in oorja.","pluginName":"oorja","pluginType":"core","aliases":["tty"],"examples":["\u001b[94m$ teletype\u001b[39m\nWill prompt to choose streaming destination - existing room or create a new one.\n\n","\u001b[94m$ teletype 'https://oorja.io/rooms?id=foo#key'\u001b[39m\nWill stream to the room specified by secret link, you must have joined the room before streaming.\n\n","\u001b[94m$ teletype -m\u001b[39m\nWill also allow room participants to write to your terminal!\n\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"shell":{"name":"shell","type":"option","char":"s","description":"shell to use. e.g. bash, fish","default":"/usr/bin/zsh"},"multiplex":{"name":"multiplex","type":"boolean","char":"m","description":"Allows room users to WRITE TO YOUR SHELL i.e enables collaboration mode. Make sure you trust room participants. Off by default","allowNo":false}},"args":[{"name":"room"}]}}}
1
+ {"version":"1.6.2","commands":{"signout":{"id":"signout","description":"Sign-out of oorja. Clears saved auth-token","pluginName":"oorja","pluginType":"core","aliases":[],"flags":{},"args":[]},"teletype":{"id":"teletype","description":"Launch a terminal streaming session in oorja.","pluginName":"oorja","pluginType":"core","aliases":["tty"],"examples":["\u001b[94m$ teletype\u001b[39m\nWill prompt to choose streaming destination - existing room or create a new one.\n\n","\u001b[94m$ teletype 'https://oorja.io/rooms?id=foo#key'\u001b[39m\nWill stream to the room specified by secret link, you must have joined the room before streaming.\n\n","\u001b[94m$ teletype -m\u001b[39m\nWill also allow room participants to write to your terminal!\n\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"shell":{"name":"shell","type":"option","char":"s","description":"shell to use. e.g. bash, fish","default":"/usr/bin/zsh"},"multiplex":{"name":"multiplex","type":"boolean","char":"m","description":"Allows room users to WRITE TO YOUR SHELL i.e enables collaboration mode. Make sure you trust room participants. Off by default","allowNo":false}},"args":[{"name":"room"}]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oorja",
3
3
  "description": "stream terminals to the web and more.",
4
- "version": "1.5.0",
4
+ "version": "1.6.2",
5
5
  "author": "Akshay Kumar @akshaykmr",
6
6
  "bin": {
7
7
  "oorja": "./bin/run",
@@ -9,20 +9,21 @@
9
9
  },
10
10
  "bugs": "https://github.com/akshaykmr/TeleType/issues",
11
11
  "dependencies": {
12
- "@msgpack/msgpack": "^1.12.2",
12
+ "@msgpack/msgpack": "^2.8.0",
13
13
  "@oclif/command": "^1",
14
14
  "@oclif/config": "^1",
15
15
  "@oclif/plugin-help": "^3",
16
- "axios": "^0.21.1",
16
+ "axios": "^1.2",
17
17
  "camelcase-keys": "^6.2.2",
18
- "chalk": "^4.1.0",
18
+ "chalk": "^4",
19
19
  "conf-cli": "^0.1.9",
20
20
  "enquirer": "^2.3.6",
21
- "node-pty": "^0.9.0",
22
- "ora": "^4.0.4",
21
+ "node": "16.3.0",
22
+ "node-pty": "^0.10.1",
23
+ "ora": "^4",
23
24
  "term-size": "^2.2.0",
24
25
  "tslib": "^1",
25
- "ws": "^7.3.1"
26
+ "ws": "^8.11"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@oclif/dev-cli": "^1",
@@ -35,10 +36,10 @@
35
36
  "tslint-config-prettier": "^1.18.0",
36
37
  "tslint-plugin-prettier": "^2.3.0",
37
38
  "tslint-react": "^4.2.0",
38
- "typescript": "^3.3"
39
+ "typescript": "^4.9.4"
39
40
  },
40
41
  "engines": {
41
- "node": ">=10.4.0"
42
+ "node": ">=14.0.0"
42
43
  },
43
44
  "files": [
44
45
  "/bin",
@@ -1,486 +0,0 @@
1
- /**
2
- * Initializes the Push
3
- * @param {Channel} channel - The Channel
4
- * @param {string} event - The event, for example `"phx_join"`
5
- * @param {Object} payload - The payload, for example `{user_id: 123}`
6
- * @param {number} timeout - The push timeout in milliseconds
7
- */
8
- declare class Push {
9
- constructor(channel: any, event: any, payload: any, timeout: any);
10
- /**
11
- *
12
- * @param {number} timeout
13
- */
14
- resend(timeout: any): void;
15
- /**
16
- *
17
- */
18
- send(): void;
19
- /**
20
- *
21
- * @param {*} status
22
- * @param {*} callback
23
- */
24
- receive(status: any, callback: any): this;
25
- /**
26
- * @private
27
- */
28
- reset(): void;
29
- /**
30
- * @private
31
- */
32
- matchReceive({ status, response, ref }: {
33
- status: any;
34
- response: any;
35
- ref: any;
36
- }): void;
37
- /**
38
- * @private
39
- */
40
- cancelRefEvent(): void;
41
- /**
42
- * @private
43
- */
44
- cancelTimeout(): void;
45
- /**
46
- * @private
47
- */
48
- startTimeout(): void;
49
- /**
50
- * @private
51
- */
52
- hasReceived(status: any): boolean;
53
- /**
54
- * @private
55
- */
56
- trigger(status: any, response: any): void;
57
- }
58
- /**
59
- *
60
- * @param {string} topic
61
- * @param {(Object|function)} params
62
- * @param {Socket} socket
63
- */
64
- export declare class Channel {
65
- constructor(topic: any, params: any, socket: any);
66
- /**
67
- * Join the channel
68
- * @param {integer} timeout
69
- * @returns {Push}
70
- */
71
- join(timeout?: any): any;
72
- /**
73
- * Hook into channel close
74
- * @param {Function} callback
75
- */
76
- onClose(callback: any): void;
77
- /**
78
- * Hook into channel errors
79
- * @param {Function} callback
80
- */
81
- onError(callback: any): number;
82
- /**
83
- * Subscribes on channel events
84
- *
85
- * Subscription returns a ref counter, which can be used later to
86
- * unsubscribe the exact event listener
87
- *
88
- * @example
89
- * const ref1 = channel.on("event", do_stuff)
90
- * const ref2 = channel.on("event", do_other_stuff)
91
- * channel.off("event", ref1)
92
- * // Since unsubscription, do_stuff won't fire,
93
- * // while do_other_stuff will keep firing on the "event"
94
- *
95
- * @param {string} event
96
- * @param {Function} callback
97
- * @returns {integer} ref
98
- */
99
- on(event: any, callback: any): number;
100
- /**
101
- * Unsubscribes off of channel events
102
- *
103
- * Use the ref returned from a channel.on() to unsubscribe one
104
- * handler, or pass nothing for the ref to unsubscribe all
105
- * handlers for the given event.
106
- *
107
- * @example
108
- * // Unsubscribe the do_stuff handler
109
- * const ref1 = channel.on("event", do_stuff)
110
- * channel.off("event", ref1)
111
- *
112
- * // Unsubscribe all handlers from event
113
- * channel.off("event")
114
- *
115
- * @param {string} event
116
- * @param {integer} ref
117
- */
118
- off(event: any, ref: any): void;
119
- /**
120
- * @private
121
- */
122
- canPush(): boolean;
123
- /**
124
- * Sends a message `event` to phoenix with the payload `payload`.
125
- * Phoenix receives this in the `handle_in(event, payload, socket)`
126
- * function. if phoenix replies or it times out (default 10000ms),
127
- * then optionally the reply can be received.
128
- *
129
- * @example
130
- * channel.push("event")
131
- * .receive("ok", payload => console.log("phoenix replied:", payload))
132
- * .receive("error", err => console.log("phoenix errored", err))
133
- * .receive("timeout", () => console.log("timed out pushing"))
134
- * @param {string} event
135
- * @param {Object} payload
136
- * @param {number} [timeout]
137
- * @returns {Push}
138
- */
139
- push(event: any, payload: any, timeout?: any): Push;
140
- /** Leaves the channel
141
- *
142
- * Unsubscribes from server events, and
143
- * instructs channel to terminate on server
144
- *
145
- * Triggers onClose() hooks
146
- *
147
- * To receive leave acknowledgements, use the `receive`
148
- * hook to bind to the server ack, ie:
149
- *
150
- * @example
151
- * channel.leave().receive("ok", () => alert("left!") )
152
- *
153
- * @param {integer} timeout
154
- * @returns {Push}
155
- */
156
- leave(timeout?: any): Push;
157
- /**
158
- * Overridable message hook
159
- *
160
- * Receives all events for specialized message handling
161
- * before dispatching to the channel callbacks.
162
- *
163
- * Must return the payload, modified or unmodified
164
- * @param {string} event
165
- * @param {Object} payload
166
- * @param {integer} ref
167
- * @returns {Object}
168
- */
169
- onMessage(event: any, payload: any, ref: any): any;
170
- /**
171
- * @private
172
- */
173
- isLifecycleEvent(event: any): boolean;
174
- /**
175
- * @private
176
- */
177
- isMember(topic: any, event: any, payload: any, joinRef: any): boolean;
178
- /**
179
- * @private
180
- */
181
- joinRef(): any;
182
- /**
183
- * @private
184
- */
185
- rejoin(timeout?: any): void;
186
- /**
187
- * @private
188
- */
189
- trigger(event: any, payload: any, ref: any, joinRef: any): void;
190
- /**
191
- * @private
192
- */
193
- replyEventName(ref: any): string;
194
- /**
195
- * @private
196
- */
197
- isClosed(): boolean;
198
- /**
199
- * @private
200
- */
201
- isErrored(): boolean;
202
- /**
203
- * @private
204
- */
205
- isJoined(): boolean;
206
- /**
207
- * @private
208
- */
209
- isJoining(): boolean;
210
- /**
211
- * @private
212
- */
213
- isLeaving(): boolean;
214
- }
215
- export declare let Serializer: {
216
- encode(msg: any, callback: any): any;
217
- decode(rawPayload: any, callback: any): any;
218
- };
219
- /** Initializes the Socket
220
- *
221
- *
222
- * For IE8 support use an ES5-shim (https://github.com/es-shims/es5-shim)
223
- *
224
- * @param {string} endPoint - The string WebSocket endpoint, ie, `"ws://example.com/socket"`,
225
- * `"wss://example.com"`
226
- * `"/socket"` (inherited host & protocol)
227
- * @param {Object} [opts] - Optional configuration
228
- * @param {string} [opts.transport] - The Websocket Transport, for example WebSocket or Phoenix.LongPoll.
229
- *
230
- * Defaults to WebSocket with automatic LongPoll fallback.
231
- * @param {Function} [opts.encode] - The function to encode outgoing messages.
232
- *
233
- * Defaults to JSON encoder.
234
- *
235
- * @param {Function} [opts.decode] - The function to decode incoming messages.
236
- *
237
- * Defaults to JSON:
238
- *
239
- * ```javascript
240
- * (payload, callback) => callback(JSON.parse(payload))
241
- * ```
242
- *
243
- * @param {number} [opts.timeout] - The default timeout in milliseconds to trigger push timeouts.
244
- *
245
- * Defaults `DEFAULT_TIMEOUT`
246
- * @param {number} [opts.heartbeatIntervalMs] - The millisec interval to send a heartbeat message
247
- * @param {number} [opts.reconnectAfterMs] - The optional function that returns the millsec
248
- * socket reconnect interval.
249
- *
250
- * Defaults to stepped backoff of:
251
- *
252
- * ```javascript
253
- * function(tries){
254
- * return [10, 50, 100, 150, 200, 250, 500, 1000, 2000][tries - 1] || 5000
255
- * }
256
- * ````
257
- *
258
- * @param {number} [opts.rejoinAfterMs] - The optional function that returns the millsec
259
- * rejoin interval for individual channels.
260
- *
261
- * ```javascript
262
- * function(tries){
263
- * return [1000, 2000, 5000][tries - 1] || 10000
264
- * }
265
- * ````
266
- *
267
- * @param {Function} [opts.logger] - The optional function for specialized logging, ie:
268
- *
269
- * ```javascript
270
- * function(kind, msg, data) {
271
- * console.log(`${kind}: ${msg}`, data)
272
- * }
273
- * ```
274
- *
275
- * @param {number} [opts.longpollerTimeout] - The maximum timeout of a long poll AJAX request.
276
- *
277
- * Defaults to 20s (double the server long poll timer).
278
- *
279
- * @param {{Object|function)} [opts.params] - The optional params to pass when connecting
280
- * @param {string} [opts.binaryType] - The binary type to use for binary WebSocket frames.
281
- *
282
- * Defaults to "arraybuffer"
283
- *
284
- * @param {vsn} [opts.vsn] - The serializer's protocol version to send on connect.
285
- *
286
- * Defaults to DEFAULT_VSN.
287
- */
288
- export declare class Socket {
289
- constructor(endPoint: any, opts?: {});
290
- /**
291
- * Returns the socket protocol
292
- *
293
- * @returns {string}
294
- */
295
- protocol(): "ws" | "wss";
296
- /**
297
- * The fully qualifed socket url
298
- *
299
- * @returns {string}
300
- */
301
- endPointURL(): any;
302
- /**
303
- * Disconnects the socket
304
- *
305
- * See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes for valid status codes.
306
- *
307
- * @param {Function} callback - Optional callback which is called after socket is disconnected.
308
- * @param {integer} code - A status code for disconnection (Optional).
309
- * @param {string} reason - A textual description of the reason to disconnect. (Optional)
310
- */
311
- disconnect(callback: any, code: any, reason: any): void;
312
- /**
313
- *
314
- * @param {Object} params - The params to send when connecting, for example `{user_id: userToken}`
315
- *
316
- * Passing params to connect is deprecated; pass them in the Socket constructor instead:
317
- * `new Socket("/socket", {params: {user_id: userToken}})`.
318
- */
319
- connect(params: any): void;
320
- /**
321
- * Logs the message. Override `this.logger` for specialized logging. noops by default
322
- * @param {string} kind
323
- * @param {string} msg
324
- * @param {Object} data
325
- */
326
- log(kind: any, msg: any, data: any): void;
327
- /**
328
- * Returns true if a logger has been set on this socket.
329
- */
330
- hasLogger(): boolean;
331
- /**
332
- * Registers callbacks for connection open events
333
- *
334
- * @example socket.onOpen(function(){ console.info("the socket was opened") })
335
- *
336
- * @param {Function} callback
337
- */
338
- onOpen(callback: any): any;
339
- /**
340
- * Registers callbacks for connection close events
341
- * @param {Function} callback
342
- */
343
- onClose(callback: any): any;
344
- /**
345
- * Registers callbacks for connection error events
346
- *
347
- * @example socket.onError(function(error){ alert("An error occurred") })
348
- *
349
- * @param {Function} callback
350
- */
351
- onError(callback: any): any;
352
- /**
353
- * Registers callbacks for connection message events
354
- * @param {Function} callback
355
- */
356
- onMessage(callback: any): any;
357
- /**
358
- * @private
359
- */
360
- onConnOpen(): void;
361
- /**
362
- * @private
363
- */
364
- resetHeartbeat(): void;
365
- teardown(callback: any, code: any, reason: any): any;
366
- waitForBufferDone(callback: any, tries?: number): void;
367
- waitForSocketClosed(callback: any, tries?: number): void;
368
- onConnClose(event: any): void;
369
- /**
370
- * @private
371
- */
372
- onConnError(error: any): void;
373
- /**
374
- * @private
375
- */
376
- triggerChanError(): void;
377
- /**
378
- * @returns {string}
379
- */
380
- connectionState(): "closed" | "connecting" | "open" | "closing";
381
- /**
382
- * @returns {boolean}
383
- */
384
- isConnected(): boolean;
385
- /**
386
- * @private
387
- *
388
- * @param {Channel}
389
- */
390
- remove(channel: any): void;
391
- /**
392
- * Removes `onOpen`, `onClose`, `onError,` and `onMessage` registrations.
393
- *
394
- * @param {refs} - list of refs returned by calls to
395
- * `onOpen`, `onClose`, `onError,` and `onMessage`
396
- */
397
- off(refs: any): void;
398
- /**
399
- * Initiates a new channel for the given topic
400
- *
401
- * @param {string} topic
402
- * @param {Object} chanParams - Parameters for the channel
403
- * @returns {Channel}
404
- */
405
- channel(topic: any, chanParams?: {}): Channel;
406
- /**
407
- * @param {Object} data
408
- */
409
- push(data: any): void;
410
- /**
411
- * Return the next message ref, accounting for overflows
412
- * @returns {string}
413
- */
414
- makeRef(): any;
415
- sendHeartbeat(): void;
416
- abnormalClose(reason: any): void;
417
- flushSendBuffer(): void;
418
- onConnMessage(rawMessage: any): void;
419
- leaveOpenTopic(topic: any): void;
420
- }
421
- export declare class LongPoll {
422
- constructor(endPoint: any);
423
- normalizeEndpoint(endPoint: any): any;
424
- endpointURL(): any;
425
- closeAndRetry(): void;
426
- ontimeout(): void;
427
- poll(): void;
428
- send(body: any): void;
429
- close(code: any, reason: any): void;
430
- }
431
- export declare class Ajax {
432
- static request(method: any, endPoint: any, accept: any, body: any, timeout: any, ontimeout: any, callback: any): void;
433
- static xdomainRequest(req: any, method: any, endPoint: any, body: any, timeout: any, ontimeout: any, callback: any): void;
434
- static xhrRequest(req: any, method: any, endPoint: any, accept: any, body: any, timeout: any, ontimeout: any, callback: any): void;
435
- static parseJSON(resp: any): any;
436
- static serialize(obj: any, parentKey: any): any;
437
- static appendParams(url: any, params: any): any;
438
- }
439
- /**
440
- * Initializes the Presence
441
- * @param {Channel} channel - The Channel
442
- * @param {Object} opts - The options,
443
- * for example `{events: {state: "state", diff: "diff"}}`
444
- */
445
- export declare class Presence {
446
- constructor(channel: any, opts?: {});
447
- onJoin(callback: any): void;
448
- onLeave(callback: any): void;
449
- onSync(callback: any): void;
450
- list(by: any): any[];
451
- inPendingSyncState(): boolean;
452
- /**
453
- * Used to sync the list of presences on the server
454
- * with the client's state. An optional `onJoin` and `onLeave` callback can
455
- * be provided to react to changes in the client's local presences across
456
- * disconnects and reconnects with the server.
457
- *
458
- * @returns {Presence}
459
- */
460
- static syncState(currentState: any, newState: any, onJoin: any, onLeave: any): any;
461
- /**
462
- *
463
- * Used to sync a diff of presence join and leave
464
- * events from the server, as they happen. Like `syncState`, `syncDiff`
465
- * accepts optional `onJoin` and `onLeave` callbacks to react to a user
466
- * joining or leaving from a device.
467
- *
468
- * @returns {Presence}
469
- */
470
- static syncDiff(currentState: any, { joins, leaves }: {
471
- joins: any;
472
- leaves: any;
473
- }, onJoin: any, onLeave: any): any;
474
- /**
475
- * Returns the array of presences, with selected metadata.
476
- *
477
- * @param {Object} presences
478
- * @param {Function} chooser
479
- *
480
- * @returns {Presence}
481
- */
482
- static list(presences: any, chooser: any): any[];
483
- static map(obj: any, func: any): any[];
484
- static clone(obj: any): any;
485
- }
486
- export {};