iosignal 7.1.0 → 8.0.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.
@@ -146,6 +146,12 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
146
146
  * @type {Map<string, Set<string>>}
147
147
  */
148
148
  linkMap: Map<string, Set<string>>;
149
+ /** @private @type {Map<string, Map<string, Set<Function>>>} */
150
+ private _linkHandlers;
151
+ /** @private @type {Set<string>} */
152
+ private _listenTags;
153
+ /** @private @type {Set<string>} */
154
+ private _manualSubscriptions;
149
155
  /**
150
156
  * Indicates if auto-reconnect is enabled.
151
157
  * @type {boolean}
@@ -172,7 +178,9 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
172
178
  stop(): void;
173
179
  /**
174
180
  * Permanently destroys the instance, cleaning up all resources.
175
- * The instance will not be usable after this.
181
+ * The instance will not be usable after this. Later signal()/publish()/subscribe()
182
+ * calls are silently dropped, the same as sends while disconnected, and call()
183
+ * rejects with code 'CONNECTION_CLOSED'.
176
184
  */
177
185
  destroy(): void;
178
186
  /**
@@ -255,6 +263,7 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
255
263
  getEncryptionMode(): boolean;
256
264
  /**
257
265
  * Sends data with encryption based on the encryption mode.
266
+ * Like an unconnected socket, a destroyed instance silently drops the data.
258
267
  * @param {Buffer} data - The data buffer to send.
259
268
  * @param {boolean} [useEncryption] - Optional. Force encryption or not. If undefined, uses default policy.
260
269
  */
@@ -323,7 +332,7 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
323
332
  /**
324
333
  * Subscribes to a channel or channels.
325
334
  * @param {string} tag - The tag(s) of the channel(s) to subscribe to (comma-separated).
326
- * @throws {TypeError} If tag is not a string or exceeds length limit.
335
+ * @throws {TypeError} If tag is invalid, exceeds the length limit, or contains a direct-receive subscription.
327
336
  */
328
337
  subscribe(tag: string): void;
329
338
  /**
@@ -334,41 +343,49 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
334
343
  /**
335
344
  * Unsubscribes from a channel or channels.
336
345
  * @param {string} [tag=""] - The tag(s) of the channel(s) to unsubscribe from (comma-separated). If empty, unsubscribes from all.
337
- * @throws {TypeError} If tag is not a string or exceeds length limit.
346
+ * @throws {TypeError} If tag is invalid, exceeds the length limit, or contains a direct-receive subscription.
338
347
  */
339
348
  unsubscribe(tag?: string): void;
340
349
  /**
341
350
  * Convenience API for simple clients (for example, CLI tools): register a
342
- * tag handler once and remember its subscription in channels. Register before
343
- * connection readiness; the CID-ready flow subscribes on initial connection
351
+ * tag handler once and remember its subscription in channels. For subscription
352
+ * tags, register before connection readiness; the CID-ready flow subscribes on initial connection
344
353
  * and again after reconnect, without application-level ready/subscribe code.
345
354
  * This does not send a subscription immediately, even if already ready.
346
355
  * For precise subscription/send ordering or dynamic subscriptions, use
347
- * on() with subscribe() in a ready handler instead. Direct signals use on('@').
356
+ * on() with subscribe() in a ready handler instead.
357
+ * Direct signals need no subscription: use on/listen('@') for all direct
358
+ * signals, or on/listen('@topic') for an exact topic. Direct handlers can be
359
+ * registered before or after readiness, before the message arrives.
360
+ * Dispatch is synchronous: '@' first, then '@topic' when tag is not '@'.
361
+ * Returning false does not cancel dispatch; a thrown error interrupts it.
348
362
  * @param {string} tag - The tag to listen on.
349
363
  * @param {Function} handler - The callback function to handle the signal.
350
364
  * @throws {TypeError} If tag is not a string, handler is not a function, or tag length is invalid.
351
365
  */
352
366
  listen(tag: string, handler: Function): void;
353
367
  /**
354
- * Links a local target to a remote tag and sets up a handler.
355
- * @param {string} to - The local link target.
356
- * @param {string} tag - The remote tag.
357
- * @param {Function} handler - The callback function to handle the signal.
358
- * @throws {TypeError} If 'to' or 'tag' are not strings, handler is not a function, or tag length is invalid.
368
+ * Associates handlers with a local component for scoped teardown.
369
+ * Direct tags (@ or @topic) only register local handlers. Other tags also
370
+ * subscribe now and are remembered for reconnection.
371
+ * @param {string} to - The local component identifier, not a server target.
372
+ * @param {string} tag - The exact event tag.
373
+ * @param {Function} handler - The callback receiving (tag, ...args).
374
+ * @throws {TypeError} If the arguments or subscription tags are invalid.
359
375
  */
360
376
  link(to: string, tag: string, handler: Function): void;
361
377
  /**
362
- * Unlinks a specific tag from a local target.
363
- * @param {string} to - The local link target.
364
- * @param {string} tag - The tag to unlink.
365
- * @throws {TypeError} If 'to' or 'tag' are not strings or tag length is invalid.
378
+ * Removes only one local component's handlers for a tag. Direct tags never
379
+ * send an unsubscribe. Shared subscriptions and explicit subscriptions remain.
380
+ * @param {string} to - The local component identifier.
381
+ * @param {string} tag - The exact linked tag.
382
+ * @throws {TypeError} If the arguments are invalid.
366
383
  */
367
384
  unlink(to: string, tag: string): void;
368
385
  /**
369
- * Unlinks all tags from a local target.
370
- * @param {string} to - The local link target.
371
- * @throws {TypeError} If 'to' is not a string.
386
+ * Removes this local component's links without removing other listeners.
387
+ * @param {string} to - The local component identifier.
388
+ * @throws {TypeError} If the component identifier is not a string.
372
389
  */
373
390
  unlinkAll(to: string): void;
374
391
  /**
@@ -490,7 +507,7 @@ declare class IO extends IOCore {
490
507
  */
491
508
  onWebSocketMessageBlob(event: MessageEvent): Promise<void>;
492
509
  /**
493
- * Sends data over the WebSocket.
510
+ * Sends data over the WebSocket. Data is dropped while the socket is not open.
494
511
  * @param {BufferSource} data - The data to send.
495
512
  */
496
513
  socket_send(data: BufferSource): void;