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.
@@ -140,6 +140,12 @@ export class IOCore extends EventEmitter<string | symbol, any> {
140
140
  * @type {Map<string, Set<string>>}
141
141
  */
142
142
  linkMap: Map<string, Set<string>>;
143
+ /** @private @type {Map<string, Map<string, Set<Function>>>} */
144
+ private _linkHandlers;
145
+ /** @private @type {Set<string>} */
146
+ private _listenTags;
147
+ /** @private @type {Set<string>} */
148
+ private _manualSubscriptions;
143
149
  /**
144
150
  * Indicates if auto-reconnect is enabled.
145
151
  * @type {boolean}
@@ -166,7 +172,9 @@ export class IOCore extends EventEmitter<string | symbol, any> {
166
172
  stop(): void;
167
173
  /**
168
174
  * Permanently destroys the instance, cleaning up all resources.
169
- * The instance will not be usable after this.
175
+ * The instance will not be usable after this. Later signal()/publish()/subscribe()
176
+ * calls are silently dropped, the same as sends while disconnected, and call()
177
+ * rejects with code 'CONNECTION_CLOSED'.
170
178
  */
171
179
  destroy(): void;
172
180
  /**
@@ -249,6 +257,7 @@ export class IOCore extends EventEmitter<string | symbol, any> {
249
257
  getEncryptionMode(): boolean;
250
258
  /**
251
259
  * Sends data with encryption based on the encryption mode.
260
+ * Like an unconnected socket, a destroyed instance silently drops the data.
252
261
  * @param {Buffer} data - The data buffer to send.
253
262
  * @param {boolean} [useEncryption] - Optional. Force encryption or not. If undefined, uses default policy.
254
263
  */
@@ -317,7 +326,7 @@ export class IOCore extends EventEmitter<string | symbol, any> {
317
326
  /**
318
327
  * Subscribes to a channel or channels.
319
328
  * @param {string} tag - The tag(s) of the channel(s) to subscribe to (comma-separated).
320
- * @throws {TypeError} If tag is not a string or exceeds length limit.
329
+ * @throws {TypeError} If tag is invalid, exceeds the length limit, or contains a direct-receive subscription.
321
330
  */
322
331
  subscribe(tag: string): void;
323
332
  /**
@@ -328,41 +337,49 @@ export class IOCore extends EventEmitter<string | symbol, any> {
328
337
  /**
329
338
  * Unsubscribes from a channel or channels.
330
339
  * @param {string} [tag=""] - The tag(s) of the channel(s) to unsubscribe from (comma-separated). If empty, unsubscribes from all.
331
- * @throws {TypeError} If tag is not a string or exceeds length limit.
340
+ * @throws {TypeError} If tag is invalid, exceeds the length limit, or contains a direct-receive subscription.
332
341
  */
333
342
  unsubscribe(tag?: string): void;
334
343
  /**
335
344
  * Convenience API for simple clients (for example, CLI tools): register a
336
- * tag handler once and remember its subscription in channels. Register before
337
- * connection readiness; the CID-ready flow subscribes on initial connection
345
+ * tag handler once and remember its subscription in channels. For subscription
346
+ * tags, register before connection readiness; the CID-ready flow subscribes on initial connection
338
347
  * and again after reconnect, without application-level ready/subscribe code.
339
348
  * This does not send a subscription immediately, even if already ready.
340
349
  * For precise subscription/send ordering or dynamic subscriptions, use
341
- * on() with subscribe() in a ready handler instead. Direct signals use on('@').
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.
354
+ * Dispatch is synchronous: '@' first, then '@topic' when tag is not '@'.
355
+ * Returning false does not cancel dispatch; a thrown error interrupts it.
342
356
  * @param {string} tag - The tag to listen on.
343
357
  * @param {Function} handler - The callback function to handle the signal.
344
358
  * @throws {TypeError} If tag is not a string, handler is not a function, or tag length is invalid.
345
359
  */
346
360
  listen(tag: string, handler: Function): void;
347
361
  /**
348
- * Links a local target to a remote tag and sets up a handler.
349
- * @param {string} to - The local link target.
350
- * @param {string} tag - The remote tag.
351
- * @param {Function} handler - The callback function to handle the signal.
352
- * @throws {TypeError} If 'to' or 'tag' are not strings, handler is not a function, or tag length is invalid.
362
+ * 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.
365
+ * @param {string} to - The local component identifier, not a server target.
366
+ * @param {string} tag - The exact event tag.
367
+ * @param {Function} handler - The callback receiving (tag, ...args).
368
+ * @throws {TypeError} If the arguments or subscription tags are invalid.
353
369
  */
354
370
  link(to: string, tag: string, handler: Function): void;
355
371
  /**
356
- * Unlinks a specific tag from a local target.
357
- * @param {string} to - The local link target.
358
- * @param {string} tag - The tag to unlink.
359
- * @throws {TypeError} If 'to' or 'tag' are not strings or tag length is invalid.
372
+ * Removes only one local component's handlers for a tag. Direct tags never
373
+ * send an unsubscribe. Shared subscriptions and explicit subscriptions remain.
374
+ * @param {string} to - The local component identifier.
375
+ * @param {string} tag - The exact linked tag.
376
+ * @throws {TypeError} If the arguments are invalid.
360
377
  */
361
378
  unlink(to: string, tag: string): void;
362
379
  /**
363
- * Unlinks all tags from a local target.
364
- * @param {string} to - The local link target.
365
- * @throws {TypeError} If 'to' is not a string.
380
+ * Removes this local component's links without removing other listeners.
381
+ * @param {string} to - The local component identifier.
382
+ * @throws {TypeError} If the component identifier is not a string.
366
383
  */
367
384
  unlinkAll(to: string): void;
368
385
  /**
@@ -68,7 +68,7 @@ export default class IO extends IOCore {
68
68
  */
69
69
  onWebSocketMessageBlob(event: MessageEvent): Promise<void>;
70
70
  /**
71
- * Sends data over the WebSocket.
71
+ * Sends data over the WebSocket. Data is dropped while the socket is not open.
72
72
  * @param {BufferSource} data - The data to send.
73
73
  */
74
74
  socket_send(data: BufferSource): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iosignal",
3
- "version": "7.1.0",
3
+ "version": "8.0.0",
4
4
  "description": "iosignal",
5
5
  "type": "module",
6
6
  "exports": {