iosignal 7.1.0 → 7.2.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}
@@ -323,7 +329,7 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
323
329
  /**
324
330
  * Subscribes to a channel or channels.
325
331
  * @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.
332
+ * @throws {TypeError} If tag is invalid, exceeds the length limit, or contains a direct-receive subscription.
327
333
  */
328
334
  subscribe(tag: string): void;
329
335
  /**
@@ -334,41 +340,49 @@ declare class IOCore extends EventEmitter<string | symbol, any> {
334
340
  /**
335
341
  * Unsubscribes from a channel or channels.
336
342
  * @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.
343
+ * @throws {TypeError} If tag is invalid, exceeds the length limit, or contains a direct-receive subscription.
338
344
  */
339
345
  unsubscribe(tag?: string): void;
340
346
  /**
341
347
  * 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
348
+ * tag handler once and remember its subscription in channels. For subscription
349
+ * tags, register before connection readiness; the CID-ready flow subscribes on initial connection
344
350
  * and again after reconnect, without application-level ready/subscribe code.
345
351
  * This does not send a subscription immediately, even if already ready.
346
352
  * For precise subscription/send ordering or dynamic subscriptions, use
347
- * on() with subscribe() in a ready handler instead. Direct signals use on('@').
353
+ * on() with subscribe() in a ready handler instead.
354
+ * Direct signals need no subscription: use on/listen('@') for all direct
355
+ * signals, or on/listen('@topic') for an exact topic. Direct handlers can be
356
+ * registered before or after readiness, before the message arrives.
357
+ * Dispatch is synchronous: '@' first, then '@topic' when tag is not '@'.
358
+ * Returning false does not cancel dispatch; a thrown error interrupts it.
348
359
  * @param {string} tag - The tag to listen on.
349
360
  * @param {Function} handler - The callback function to handle the signal.
350
361
  * @throws {TypeError} If tag is not a string, handler is not a function, or tag length is invalid.
351
362
  */
352
363
  listen(tag: string, handler: Function): void;
353
364
  /**
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.
365
+ * Associates handlers with a local component for scoped teardown.
366
+ * Direct tags (@ or @topic) only register local handlers. Other tags also
367
+ * subscribe now and are remembered for reconnection.
368
+ * @param {string} to - The local component identifier, not a server target.
369
+ * @param {string} tag - The exact event tag.
370
+ * @param {Function} handler - The callback receiving (tag, ...args).
371
+ * @throws {TypeError} If the arguments or subscription tags are invalid.
359
372
  */
360
373
  link(to: string, tag: string, handler: Function): void;
361
374
  /**
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.
375
+ * Removes only one local component's handlers for a tag. Direct tags never
376
+ * send an unsubscribe. Shared subscriptions and explicit subscriptions remain.
377
+ * @param {string} to - The local component identifier.
378
+ * @param {string} tag - The exact linked tag.
379
+ * @throws {TypeError} If the arguments are invalid.
366
380
  */
367
381
  unlink(to: string, tag: string): void;
368
382
  /**
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.
383
+ * Removes this local component's links without removing other listeners.
384
+ * @param {string} to - The local component identifier.
385
+ * @throws {TypeError} If the component identifier is not a string.
372
386
  */
373
387
  unlinkAll(to: string): void;
374
388
  /**