iosignal 8.1.0 → 9.6.0

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.
@@ -121,15 +121,13 @@ export class IOCore extends EventEmitter<string | symbol, any> {
121
121
  */
122
122
  mid: number;
123
123
  /**
124
- * Quota level.
125
- * @type {number}
124
+ * This connection's quota as told by the server (QUOTA). maxMessageBytes: largest message
125
+ * send() passes on; null: no limit (also until the server tells).
126
+ * @type {{ maxMessageBytes: number | null }}
126
127
  */
127
- level: number;
128
- /**
129
- * Quota table for current level.
130
- * @type {object}
131
- */
132
- quota: object;
128
+ quota: {
129
+ maxMessageBytes: number | null;
130
+ };
133
131
  /**
134
132
  * Server settings.
135
133
  * @type {object}
@@ -144,6 +142,7 @@ export class IOCore extends EventEmitter<string | symbol, any> {
144
142
  private _linkHandlers;
145
143
  /** @private @type {Set<string>} */
146
144
  private _listenTags;
145
+ _readyDispatch: boolean;
147
146
  /** @private @type {Set<string>} */
148
147
  private _manualSubscriptions;
149
148
  /**
@@ -324,9 +323,13 @@ export class IOCore extends EventEmitter<string | symbol, any> {
324
323
  */
325
324
  call(target: string, topic: string, ...args: any[]): Promise<any>;
326
325
  /**
327
- * Subscribes to a channel or channels.
326
+ * Subscribes to a channel or channels on the current, ready connection, at once.
327
+ * Call it from a ready handler (it runs on every connect) or later while ready; it is not
328
+ * repeated after a reconnect. To subscribe before connecting, or for every connection
329
+ * without a ready handler, use listen() or link().
328
330
  * @param {string} tag - The tag(s) of the channel(s) to subscribe to (comma-separated).
329
331
  * @throws {TypeError} If tag is invalid, exceeds the length limit, or contains a direct-receive subscription.
332
+ * @throws {Error} If the connection is not ready (after destroy() it is a no-op instead).
330
333
  */
331
334
  subscribe(tag: string): void;
332
335
  /**
@@ -344,24 +347,26 @@ export class IOCore extends EventEmitter<string | symbol, any> {
344
347
  * Convenience API for simple clients (for example, CLI tools): register a
345
348
  * tag handler once and remember its subscription in channels. For subscription
346
349
  * tags, register before connection readiness; the CID-ready flow subscribes on initial connection
347
- * and again after reconnect, without application-level ready/subscribe code.
350
+ * and again after reconnect, before 'ready' is emitted, so a ready handler may signal at once.
348
351
  * This does not send a subscription immediately, even if already ready.
349
- * For precise subscription/send ordering or dynamic subscriptions, use
350
- * on() with subscribe() in a ready handler instead.
351
- * Direct signals need no subscription: use on/listen('@') for all direct
352
- * signals, or on/listen('@topic') for an exact topic. Direct handlers can be
353
- * registered before or after readiness, before the message arrives.
352
+ * Do not call listen() inside a ready handler; it throws there, for any tag: a subscription tag
353
+ * would be subscribed only after the next reconnect, and a handler registered on every
354
+ * connect runs once more after each reconnect. In a ready handler use on() and subscribe();
355
+ * for dynamic subscriptions use link().
356
+ * Direct signals need no subscription: use listen('@') during setup, or on('@'), for all
357
+ * direct signals, or '@topic' for an exact topic.
354
358
  * Dispatch is synchronous: '@' first, then '@topic' when tag is not '@'.
355
359
  * Returning false does not cancel dispatch; a thrown error interrupts it.
356
360
  * @param {string} tag - The tag to listen on.
357
361
  * @param {Function} handler - The callback function to handle the signal.
358
362
  * @throws {TypeError} If tag is not a string, handler is not a function, or tag length is invalid.
363
+ * @throws {Error} If called inside a ready handler.
359
364
  */
360
365
  listen(tag: string, handler: Function): void;
361
366
  /**
362
367
  * Associates handlers with a local component for scoped teardown.
363
- * Direct tags (@ or @topic) only register local handlers. Other tags also
364
- * subscribe now and are remembered for reconnection.
368
+ * Direct tags (@ or @topic) only register local handlers. Other tags are remembered for
369
+ * reconnection and subscribed at once on a ready connection; before that, when it becomes ready.
365
370
  * @param {string} to - The local component identifier, not a server target.
366
371
  * @param {string} tag - The exact event tag.
367
372
  * @param {Function} handler - The callback receiving (tag, ...args).
@@ -434,7 +439,6 @@ export type PAYLOAD_TYPE = import("../common/constants.js").PAYLOAD_TYPE;
434
439
  export type SIZE_LIMIT = import("../common/constants.js").SIZE_LIMIT;
435
440
  export type ENC_MODE = import("../common/constants.js").ENC_MODE;
436
441
  export type STATE = import("../common/constants.js").STATE;
437
- export type quotaTable = any;
438
442
  export type Buffer = import("boho").Buffer;
439
443
  import { EventEmitter } from "eventemitter3";
440
444
  import Boho from "boho";
@@ -78,7 +78,7 @@ export type IOMsg = {
78
78
  SERVER_READY: number;
79
79
  CID_REQ: number;
80
80
  CID_RES: number;
81
- QUOTA_LEVEL: number;
81
+ QUOTA: number;
82
82
  AUTH_CLEAR: number;
83
83
  SERVER_REDIRECT: number;
84
84
  LOOP: number;
@@ -114,10 +114,10 @@ export namespace IOMsg {
114
114
  export { CID_REQ_1 as CID_REQ };
115
115
  let CID_RES_1: number;
116
116
  export { CID_RES_1 as CID_RES };
117
- export let QUOTA_LEVEL: number;
118
117
  let AUTH_CLEAR_1: number;
119
118
  export { AUTH_CLEAR_1 as AUTH_CLEAR };
120
119
  export let SERVER_REDIRECT: number;
120
+ export let QUOTA: number;
121
121
  export let LOOP: number;
122
122
  export let ECHO: number;
123
123
  export let PING: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iosignal",
3
- "version": "8.1.0",
3
+ "version": "9.6.0",
4
4
  "description": "iosignal",
5
5
  "type": "module",
6
6
  "exports": {
@@ -92,7 +92,6 @@
92
92
  "dist/types/client/IOCore.d.ts",
93
93
  "dist/types/client/browser/IOWebSocket.d.ts",
94
94
  "dist/types/common/constants.d.ts",
95
- "dist/types/common/payload.d.ts",
96
- "dist/types/common/quotaTable.d.ts"
95
+ "dist/types/common/payload.d.ts"
97
96
  ]
98
97
  }
@@ -1,47 +0,0 @@
1
- export let quotaTable: {
2
- 0: {
3
- signalSize: number;
4
- publishCounter: number;
5
- trafficRate: number;
6
- };
7
- 1: {
8
- signalSize: number;
9
- publishCounter: number;
10
- trafficRate: number;
11
- };
12
- 2: {
13
- signalSize: number;
14
- publishCounter: number;
15
- trafficRate: number;
16
- };
17
- 3: {
18
- signalSize: number;
19
- publishCounter: number;
20
- trafficRate: number;
21
- };
22
- 10: {
23
- signalSize: number;
24
- publishCounter: number;
25
- trafficRate: number;
26
- };
27
- 11: {
28
- signalSize: number;
29
- publishCounter: number;
30
- trafficRate: number;
31
- };
32
- 12: {
33
- signalSize: number;
34
- publishCounter: number;
35
- trafficRate: number;
36
- };
37
- 200: {
38
- signalSize: number;
39
- publishCounter: number;
40
- trafficRate: number;
41
- };
42
- 255: {
43
- signalSize: number;
44
- publishCounter: number;
45
- trafficRate: number;
46
- };
47
- };