@naylence/runtime 0.3.5-test.937 → 0.3.5-test.939

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.
@@ -98,12 +98,12 @@ installProcessEnvShim();
98
98
  // --- END ENV SHIM ---
99
99
 
100
100
  // This file is auto-generated during build - do not edit manually
101
- // Generated from package.json version: 0.3.5-test.937
101
+ // Generated from package.json version: 0.3.5-test.939
102
102
  /**
103
103
  * The package version, injected at build time.
104
104
  * @internal
105
105
  */
106
- const VERSION = '0.3.5-test.937';
106
+ const VERSION = '0.3.5-test.939';
107
107
 
108
108
  /**
109
109
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -9993,11 +9993,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9993
9993
  if (typeof document !== 'undefined') {
9994
9994
  document.addEventListener('visibilitychange', this.visibilityChangeHandler);
9995
9995
  this.visibilityChangeListenerRegistered = true;
9996
- // Log initial state
9996
+ // Log initial state with detailed visibility info
9997
9997
  logger$_.debug('broadcast_channel_initial_visibility', {
9998
9998
  channel: this.channelName,
9999
9999
  connector_id: this.connectorId,
10000
10000
  visibility: document.hidden ? 'hidden' : 'visible',
10001
+ document_hidden: document.hidden,
10002
+ visibility_state: document.visibilityState,
10003
+ has_focus: document.hasFocus(),
10001
10004
  });
10002
10005
  }
10003
10006
  }
@@ -10178,6 +10181,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10178
10181
  logger$_.debug('broadcast_channel_start_in_hidden_tab', {
10179
10182
  channel: this.channelName,
10180
10183
  connector_id: this.connectorId,
10184
+ document_hidden: document.hidden,
10185
+ visibility_state: document.visibilityState,
10186
+ has_focus: document.hasFocus(),
10181
10187
  timestamp: new Date().toISOString(),
10182
10188
  });
10183
10189
  // Immediately pause if tab is hidden at start time
@@ -10476,6 +10482,7 @@ class UpstreamSessionManager extends TaskSpawner {
10476
10482
  this.lastHeartbeatAckTime = null;
10477
10483
  this.lastSeenEpoch = null;
10478
10484
  this.hadSuccessfulAttach = false;
10485
+ this.lastConnectorState = null;
10479
10486
  this.connectEpoch = 0;
10480
10487
  const options = normalizeOptions$k(optionsInput);
10481
10488
  this.node = options.node;
@@ -10900,15 +10907,26 @@ class UpstreamSessionManager extends TaskSpawner {
10900
10907
  if (stopEvt.isSet() || signal?.aborted) {
10901
10908
  break;
10902
10909
  }
10910
+ const currentState = connector.state;
10911
+ const previousState = this.lastConnectorState;
10912
+ this.lastConnectorState = currentState;
10903
10913
  // Skip heartbeat if connector is paused (e.g., tab is hidden)
10904
10914
  // Keep ack time current so we don't timeout immediately after resuming
10905
- if (connector.state === core.ConnectorState.PAUSED) {
10915
+ if (currentState === core.ConnectorState.PAUSED) {
10906
10916
  logger$Z.debug('skipping_heartbeat_connector_paused', {
10907
- connector_state: connector.state,
10917
+ connector_state: currentState,
10908
10918
  });
10909
10919
  this.lastHeartbeatAckTime = Date.now();
10910
10920
  continue;
10911
10921
  }
10922
+ // Reset ack time if just resumed from pause (prevents immediate timeout)
10923
+ if (previousState === core.ConnectorState.PAUSED && currentState === core.ConnectorState.STARTED) {
10924
+ logger$Z.debug('connector_just_resumed_resetting_ack_time', {
10925
+ previous_state: previousState,
10926
+ current_state: currentState,
10927
+ });
10928
+ this.lastHeartbeatAckTime = Date.now();
10929
+ }
10912
10930
  const envelope = await this.makeHeartbeatEnvelope();
10913
10931
  logger$Z.debug('sending_heartbeat', {
10914
10932
  hb_corr_id: envelope.corrId,
@@ -12643,7 +12661,8 @@ class DefaultNodeAttachClient {
12643
12661
  async awaitAck(connector) {
12644
12662
  const deadline = Date.now() + this.timeoutMs;
12645
12663
  while (Date.now() < deadline) {
12646
- if (connector.state !== core.ConnectorState.STARTED) {
12664
+ // Allow both STARTED and PAUSED states (PAUSED = tab hidden but connection alive)
12665
+ if (connector.state !== core.ConnectorState.STARTED && connector.state !== core.ConnectorState.PAUSED) {
12647
12666
  let errorMessage = 'Connector closed while waiting for NodeAttachAck';
12648
12667
  if (connector.closeCode !== undefined) {
12649
12668
  errorMessage += ` (code=${connector.closeCode}`;
@@ -96,12 +96,12 @@ installProcessEnvShim();
96
96
  // --- END ENV SHIM ---
97
97
 
98
98
  // This file is auto-generated during build - do not edit manually
99
- // Generated from package.json version: 0.3.5-test.937
99
+ // Generated from package.json version: 0.3.5-test.939
100
100
  /**
101
101
  * The package version, injected at build time.
102
102
  * @internal
103
103
  */
104
- const VERSION = '0.3.5-test.937';
104
+ const VERSION = '0.3.5-test.939';
105
105
 
106
106
  /**
107
107
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -9991,11 +9991,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9991
9991
  if (typeof document !== 'undefined') {
9992
9992
  document.addEventListener('visibilitychange', this.visibilityChangeHandler);
9993
9993
  this.visibilityChangeListenerRegistered = true;
9994
- // Log initial state
9994
+ // Log initial state with detailed visibility info
9995
9995
  logger$_.debug('broadcast_channel_initial_visibility', {
9996
9996
  channel: this.channelName,
9997
9997
  connector_id: this.connectorId,
9998
9998
  visibility: document.hidden ? 'hidden' : 'visible',
9999
+ document_hidden: document.hidden,
10000
+ visibility_state: document.visibilityState,
10001
+ has_focus: document.hasFocus(),
9999
10002
  });
10000
10003
  }
10001
10004
  }
@@ -10176,6 +10179,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10176
10179
  logger$_.debug('broadcast_channel_start_in_hidden_tab', {
10177
10180
  channel: this.channelName,
10178
10181
  connector_id: this.connectorId,
10182
+ document_hidden: document.hidden,
10183
+ visibility_state: document.visibilityState,
10184
+ has_focus: document.hasFocus(),
10179
10185
  timestamp: new Date().toISOString(),
10180
10186
  });
10181
10187
  // Immediately pause if tab is hidden at start time
@@ -10474,6 +10480,7 @@ class UpstreamSessionManager extends TaskSpawner {
10474
10480
  this.lastHeartbeatAckTime = null;
10475
10481
  this.lastSeenEpoch = null;
10476
10482
  this.hadSuccessfulAttach = false;
10483
+ this.lastConnectorState = null;
10477
10484
  this.connectEpoch = 0;
10478
10485
  const options = normalizeOptions$k(optionsInput);
10479
10486
  this.node = options.node;
@@ -10898,15 +10905,26 @@ class UpstreamSessionManager extends TaskSpawner {
10898
10905
  if (stopEvt.isSet() || signal?.aborted) {
10899
10906
  break;
10900
10907
  }
10908
+ const currentState = connector.state;
10909
+ const previousState = this.lastConnectorState;
10910
+ this.lastConnectorState = currentState;
10901
10911
  // Skip heartbeat if connector is paused (e.g., tab is hidden)
10902
10912
  // Keep ack time current so we don't timeout immediately after resuming
10903
- if (connector.state === ConnectorState.PAUSED) {
10913
+ if (currentState === ConnectorState.PAUSED) {
10904
10914
  logger$Z.debug('skipping_heartbeat_connector_paused', {
10905
- connector_state: connector.state,
10915
+ connector_state: currentState,
10906
10916
  });
10907
10917
  this.lastHeartbeatAckTime = Date.now();
10908
10918
  continue;
10909
10919
  }
10920
+ // Reset ack time if just resumed from pause (prevents immediate timeout)
10921
+ if (previousState === ConnectorState.PAUSED && currentState === ConnectorState.STARTED) {
10922
+ logger$Z.debug('connector_just_resumed_resetting_ack_time', {
10923
+ previous_state: previousState,
10924
+ current_state: currentState,
10925
+ });
10926
+ this.lastHeartbeatAckTime = Date.now();
10927
+ }
10910
10928
  const envelope = await this.makeHeartbeatEnvelope();
10911
10929
  logger$Z.debug('sending_heartbeat', {
10912
10930
  hb_corr_id: envelope.corrId,
@@ -12641,7 +12659,8 @@ class DefaultNodeAttachClient {
12641
12659
  async awaitAck(connector) {
12642
12660
  const deadline = Date.now() + this.timeoutMs;
12643
12661
  while (Date.now() < deadline) {
12644
- if (connector.state !== ConnectorState.STARTED) {
12662
+ // Allow both STARTED and PAUSED states (PAUSED = tab hidden but connection alive)
12663
+ if (connector.state !== ConnectorState.STARTED && connector.state !== ConnectorState.PAUSED) {
12645
12664
  let errorMessage = 'Connector closed while waiting for NodeAttachAck';
12646
12665
  if (connector.closeCode !== undefined) {
12647
12666
  errorMessage += ` (code=${connector.closeCode}`;
@@ -181,11 +181,14 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
181
181
  if (typeof document !== 'undefined') {
182
182
  document.addEventListener('visibilitychange', this.visibilityChangeHandler);
183
183
  this.visibilityChangeListenerRegistered = true;
184
- // Log initial state
184
+ // Log initial state with detailed visibility info
185
185
  logger.debug('broadcast_channel_initial_visibility', {
186
186
  channel: this.channelName,
187
187
  connector_id: this.connectorId,
188
188
  visibility: document.hidden ? 'hidden' : 'visible',
189
+ document_hidden: document.hidden,
190
+ visibility_state: document.visibilityState,
191
+ has_focus: document.hasFocus(),
189
192
  });
190
193
  }
191
194
  }
@@ -366,6 +369,9 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
366
369
  logger.debug('broadcast_channel_start_in_hidden_tab', {
367
370
  channel: this.channelName,
368
371
  connector_id: this.connectorId,
372
+ document_hidden: document.hidden,
373
+ visibility_state: document.visibilityState,
374
+ has_focus: document.hasFocus(),
369
375
  timestamp: new Date().toISOString(),
370
376
  });
371
377
  // Immediately pause if tab is hidden at start time
@@ -202,7 +202,8 @@ class DefaultNodeAttachClient {
202
202
  async awaitAck(connector) {
203
203
  const deadline = Date.now() + this.timeoutMs;
204
204
  while (Date.now() < deadline) {
205
- if (connector.state !== core_1.ConnectorState.STARTED) {
205
+ // Allow both STARTED and PAUSED states (PAUSED = tab hidden but connection alive)
206
+ if (connector.state !== core_1.ConnectorState.STARTED && connector.state !== core_1.ConnectorState.PAUSED) {
206
207
  let errorMessage = 'Connector closed while waiting for NodeAttachAck';
207
208
  if (connector.closeCode !== undefined) {
208
209
  errorMessage += ` (code=${connector.closeCode}`;
@@ -112,6 +112,7 @@ class UpstreamSessionManager extends task_spawner_js_1.TaskSpawner {
112
112
  this.lastHeartbeatAckTime = null;
113
113
  this.lastSeenEpoch = null;
114
114
  this.hadSuccessfulAttach = false;
115
+ this.lastConnectorState = null;
115
116
  this.connectEpoch = 0;
116
117
  const options = normalizeOptions(optionsInput);
117
118
  this.node = options.node;
@@ -536,15 +537,26 @@ class UpstreamSessionManager extends task_spawner_js_1.TaskSpawner {
536
537
  if (stopEvt.isSet() || signal?.aborted) {
537
538
  break;
538
539
  }
540
+ const currentState = connector.state;
541
+ const previousState = this.lastConnectorState;
542
+ this.lastConnectorState = currentState;
539
543
  // Skip heartbeat if connector is paused (e.g., tab is hidden)
540
544
  // Keep ack time current so we don't timeout immediately after resuming
541
- if (connector.state === core_1.ConnectorState.PAUSED) {
545
+ if (currentState === core_1.ConnectorState.PAUSED) {
542
546
  logger.debug('skipping_heartbeat_connector_paused', {
543
- connector_state: connector.state,
547
+ connector_state: currentState,
544
548
  });
545
549
  this.lastHeartbeatAckTime = Date.now();
546
550
  continue;
547
551
  }
552
+ // Reset ack time if just resumed from pause (prevents immediate timeout)
553
+ if (previousState === core_1.ConnectorState.PAUSED && currentState === core_1.ConnectorState.STARTED) {
554
+ logger.debug('connector_just_resumed_resetting_ack_time', {
555
+ previous_state: previousState,
556
+ current_state: currentState,
557
+ });
558
+ this.lastHeartbeatAckTime = Date.now();
559
+ }
548
560
  const envelope = await this.makeHeartbeatEnvelope();
549
561
  logger.debug('sending_heartbeat', {
550
562
  hb_corr_id: envelope.corrId,
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  // This file is auto-generated during build - do not edit manually
3
- // Generated from package.json version: 0.3.5-test.937
3
+ // Generated from package.json version: 0.3.5-test.939
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.VERSION = void 0;
6
6
  /**
7
7
  * The package version, injected at build time.
8
8
  * @internal
9
9
  */
10
- exports.VERSION = '0.3.5-test.937';
10
+ exports.VERSION = '0.3.5-test.939';
@@ -178,11 +178,14 @@ export class BroadcastChannelConnector extends BaseAsyncConnector {
178
178
  if (typeof document !== 'undefined') {
179
179
  document.addEventListener('visibilitychange', this.visibilityChangeHandler);
180
180
  this.visibilityChangeListenerRegistered = true;
181
- // Log initial state
181
+ // Log initial state with detailed visibility info
182
182
  logger.debug('broadcast_channel_initial_visibility', {
183
183
  channel: this.channelName,
184
184
  connector_id: this.connectorId,
185
185
  visibility: document.hidden ? 'hidden' : 'visible',
186
+ document_hidden: document.hidden,
187
+ visibility_state: document.visibilityState,
188
+ has_focus: document.hasFocus(),
186
189
  });
187
190
  }
188
191
  }
@@ -363,6 +366,9 @@ export class BroadcastChannelConnector extends BaseAsyncConnector {
363
366
  logger.debug('broadcast_channel_start_in_hidden_tab', {
364
367
  channel: this.channelName,
365
368
  connector_id: this.connectorId,
369
+ document_hidden: document.hidden,
370
+ visibility_state: document.visibilityState,
371
+ has_focus: document.hasFocus(),
366
372
  timestamp: new Date().toISOString(),
367
373
  });
368
374
  // Immediately pause if tab is hidden at start time
@@ -199,7 +199,8 @@ export class DefaultNodeAttachClient {
199
199
  async awaitAck(connector) {
200
200
  const deadline = Date.now() + this.timeoutMs;
201
201
  while (Date.now() < deadline) {
202
- if (connector.state !== ConnectorState.STARTED) {
202
+ // Allow both STARTED and PAUSED states (PAUSED = tab hidden but connection alive)
203
+ if (connector.state !== ConnectorState.STARTED && connector.state !== ConnectorState.PAUSED) {
203
204
  let errorMessage = 'Connector closed while waiting for NodeAttachAck';
204
205
  if (connector.closeCode !== undefined) {
205
206
  errorMessage += ` (code=${connector.closeCode}`;
@@ -109,6 +109,7 @@ export class UpstreamSessionManager extends TaskSpawner {
109
109
  this.lastHeartbeatAckTime = null;
110
110
  this.lastSeenEpoch = null;
111
111
  this.hadSuccessfulAttach = false;
112
+ this.lastConnectorState = null;
112
113
  this.connectEpoch = 0;
113
114
  const options = normalizeOptions(optionsInput);
114
115
  this.node = options.node;
@@ -533,15 +534,26 @@ export class UpstreamSessionManager extends TaskSpawner {
533
534
  if (stopEvt.isSet() || signal?.aborted) {
534
535
  break;
535
536
  }
537
+ const currentState = connector.state;
538
+ const previousState = this.lastConnectorState;
539
+ this.lastConnectorState = currentState;
536
540
  // Skip heartbeat if connector is paused (e.g., tab is hidden)
537
541
  // Keep ack time current so we don't timeout immediately after resuming
538
- if (connector.state === ConnectorState.PAUSED) {
542
+ if (currentState === ConnectorState.PAUSED) {
539
543
  logger.debug('skipping_heartbeat_connector_paused', {
540
- connector_state: connector.state,
544
+ connector_state: currentState,
541
545
  });
542
546
  this.lastHeartbeatAckTime = Date.now();
543
547
  continue;
544
548
  }
549
+ // Reset ack time if just resumed from pause (prevents immediate timeout)
550
+ if (previousState === ConnectorState.PAUSED && currentState === ConnectorState.STARTED) {
551
+ logger.debug('connector_just_resumed_resetting_ack_time', {
552
+ previous_state: previousState,
553
+ current_state: currentState,
554
+ });
555
+ this.lastHeartbeatAckTime = Date.now();
556
+ }
545
557
  const envelope = await this.makeHeartbeatEnvelope();
546
558
  logger.debug('sending_heartbeat', {
547
559
  hb_corr_id: envelope.corrId,
@@ -1,7 +1,7 @@
1
1
  // This file is auto-generated during build - do not edit manually
2
- // Generated from package.json version: 0.3.5-test.937
2
+ // Generated from package.json version: 0.3.5-test.939
3
3
  /**
4
4
  * The package version, injected at build time.
5
5
  * @internal
6
6
  */
7
- export const VERSION = '0.3.5-test.937';
7
+ export const VERSION = '0.3.5-test.939';
@@ -14,12 +14,12 @@ var fastify = require('fastify');
14
14
  var websocketPlugin = require('@fastify/websocket');
15
15
 
16
16
  // This file is auto-generated during build - do not edit manually
17
- // Generated from package.json version: 0.3.5-test.937
17
+ // Generated from package.json version: 0.3.5-test.939
18
18
  /**
19
19
  * The package version, injected at build time.
20
20
  * @internal
21
21
  */
22
- const VERSION = '0.3.5-test.937';
22
+ const VERSION = '0.3.5-test.939';
23
23
 
24
24
  /**
25
25
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -9909,11 +9909,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9909
9909
  if (typeof document !== 'undefined') {
9910
9910
  document.addEventListener('visibilitychange', this.visibilityChangeHandler);
9911
9911
  this.visibilityChangeListenerRegistered = true;
9912
- // Log initial state
9912
+ // Log initial state with detailed visibility info
9913
9913
  logger$_.debug('broadcast_channel_initial_visibility', {
9914
9914
  channel: this.channelName,
9915
9915
  connector_id: this.connectorId,
9916
9916
  visibility: document.hidden ? 'hidden' : 'visible',
9917
+ document_hidden: document.hidden,
9918
+ visibility_state: document.visibilityState,
9919
+ has_focus: document.hasFocus(),
9917
9920
  });
9918
9921
  }
9919
9922
  }
@@ -10094,6 +10097,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10094
10097
  logger$_.debug('broadcast_channel_start_in_hidden_tab', {
10095
10098
  channel: this.channelName,
10096
10099
  connector_id: this.connectorId,
10100
+ document_hidden: document.hidden,
10101
+ visibility_state: document.visibilityState,
10102
+ has_focus: document.hasFocus(),
10097
10103
  timestamp: new Date().toISOString(),
10098
10104
  });
10099
10105
  // Immediately pause if tab is hidden at start time
@@ -10392,6 +10398,7 @@ class UpstreamSessionManager extends TaskSpawner {
10392
10398
  this.lastHeartbeatAckTime = null;
10393
10399
  this.lastSeenEpoch = null;
10394
10400
  this.hadSuccessfulAttach = false;
10401
+ this.lastConnectorState = null;
10395
10402
  this.connectEpoch = 0;
10396
10403
  const options = normalizeOptions$k(optionsInput);
10397
10404
  this.node = options.node;
@@ -10816,15 +10823,26 @@ class UpstreamSessionManager extends TaskSpawner {
10816
10823
  if (stopEvt.isSet() || signal?.aborted) {
10817
10824
  break;
10818
10825
  }
10826
+ const currentState = connector.state;
10827
+ const previousState = this.lastConnectorState;
10828
+ this.lastConnectorState = currentState;
10819
10829
  // Skip heartbeat if connector is paused (e.g., tab is hidden)
10820
10830
  // Keep ack time current so we don't timeout immediately after resuming
10821
- if (connector.state === core.ConnectorState.PAUSED) {
10831
+ if (currentState === core.ConnectorState.PAUSED) {
10822
10832
  logger$Z.debug('skipping_heartbeat_connector_paused', {
10823
- connector_state: connector.state,
10833
+ connector_state: currentState,
10824
10834
  });
10825
10835
  this.lastHeartbeatAckTime = Date.now();
10826
10836
  continue;
10827
10837
  }
10838
+ // Reset ack time if just resumed from pause (prevents immediate timeout)
10839
+ if (previousState === core.ConnectorState.PAUSED && currentState === core.ConnectorState.STARTED) {
10840
+ logger$Z.debug('connector_just_resumed_resetting_ack_time', {
10841
+ previous_state: previousState,
10842
+ current_state: currentState,
10843
+ });
10844
+ this.lastHeartbeatAckTime = Date.now();
10845
+ }
10828
10846
  const envelope = await this.makeHeartbeatEnvelope();
10829
10847
  logger$Z.debug('sending_heartbeat', {
10830
10848
  hb_corr_id: envelope.corrId,
@@ -12559,7 +12577,8 @@ class DefaultNodeAttachClient {
12559
12577
  async awaitAck(connector) {
12560
12578
  const deadline = Date.now() + this.timeoutMs;
12561
12579
  while (Date.now() < deadline) {
12562
- if (connector.state !== core.ConnectorState.STARTED) {
12580
+ // Allow both STARTED and PAUSED states (PAUSED = tab hidden but connection alive)
12581
+ if (connector.state !== core.ConnectorState.STARTED && connector.state !== core.ConnectorState.PAUSED) {
12563
12582
  let errorMessage = 'Connector closed while waiting for NodeAttachAck';
12564
12583
  if (connector.closeCode !== undefined) {
12565
12584
  errorMessage += ` (code=${connector.closeCode}`;
@@ -13,12 +13,12 @@ import fastify from 'fastify';
13
13
  import websocketPlugin from '@fastify/websocket';
14
14
 
15
15
  // This file is auto-generated during build - do not edit manually
16
- // Generated from package.json version: 0.3.5-test.937
16
+ // Generated from package.json version: 0.3.5-test.939
17
17
  /**
18
18
  * The package version, injected at build time.
19
19
  * @internal
20
20
  */
21
- const VERSION = '0.3.5-test.937';
21
+ const VERSION = '0.3.5-test.939';
22
22
 
23
23
  /**
24
24
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -9908,11 +9908,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9908
9908
  if (typeof document !== 'undefined') {
9909
9909
  document.addEventListener('visibilitychange', this.visibilityChangeHandler);
9910
9910
  this.visibilityChangeListenerRegistered = true;
9911
- // Log initial state
9911
+ // Log initial state with detailed visibility info
9912
9912
  logger$_.debug('broadcast_channel_initial_visibility', {
9913
9913
  channel: this.channelName,
9914
9914
  connector_id: this.connectorId,
9915
9915
  visibility: document.hidden ? 'hidden' : 'visible',
9916
+ document_hidden: document.hidden,
9917
+ visibility_state: document.visibilityState,
9918
+ has_focus: document.hasFocus(),
9916
9919
  });
9917
9920
  }
9918
9921
  }
@@ -10093,6 +10096,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10093
10096
  logger$_.debug('broadcast_channel_start_in_hidden_tab', {
10094
10097
  channel: this.channelName,
10095
10098
  connector_id: this.connectorId,
10099
+ document_hidden: document.hidden,
10100
+ visibility_state: document.visibilityState,
10101
+ has_focus: document.hasFocus(),
10096
10102
  timestamp: new Date().toISOString(),
10097
10103
  });
10098
10104
  // Immediately pause if tab is hidden at start time
@@ -10391,6 +10397,7 @@ class UpstreamSessionManager extends TaskSpawner {
10391
10397
  this.lastHeartbeatAckTime = null;
10392
10398
  this.lastSeenEpoch = null;
10393
10399
  this.hadSuccessfulAttach = false;
10400
+ this.lastConnectorState = null;
10394
10401
  this.connectEpoch = 0;
10395
10402
  const options = normalizeOptions$k(optionsInput);
10396
10403
  this.node = options.node;
@@ -10815,15 +10822,26 @@ class UpstreamSessionManager extends TaskSpawner {
10815
10822
  if (stopEvt.isSet() || signal?.aborted) {
10816
10823
  break;
10817
10824
  }
10825
+ const currentState = connector.state;
10826
+ const previousState = this.lastConnectorState;
10827
+ this.lastConnectorState = currentState;
10818
10828
  // Skip heartbeat if connector is paused (e.g., tab is hidden)
10819
10829
  // Keep ack time current so we don't timeout immediately after resuming
10820
- if (connector.state === ConnectorState.PAUSED) {
10830
+ if (currentState === ConnectorState.PAUSED) {
10821
10831
  logger$Z.debug('skipping_heartbeat_connector_paused', {
10822
- connector_state: connector.state,
10832
+ connector_state: currentState,
10823
10833
  });
10824
10834
  this.lastHeartbeatAckTime = Date.now();
10825
10835
  continue;
10826
10836
  }
10837
+ // Reset ack time if just resumed from pause (prevents immediate timeout)
10838
+ if (previousState === ConnectorState.PAUSED && currentState === ConnectorState.STARTED) {
10839
+ logger$Z.debug('connector_just_resumed_resetting_ack_time', {
10840
+ previous_state: previousState,
10841
+ current_state: currentState,
10842
+ });
10843
+ this.lastHeartbeatAckTime = Date.now();
10844
+ }
10827
10845
  const envelope = await this.makeHeartbeatEnvelope();
10828
10846
  logger$Z.debug('sending_heartbeat', {
10829
10847
  hb_corr_id: envelope.corrId,
@@ -12558,7 +12576,8 @@ class DefaultNodeAttachClient {
12558
12576
  async awaitAck(connector) {
12559
12577
  const deadline = Date.now() + this.timeoutMs;
12560
12578
  while (Date.now() < deadline) {
12561
- if (connector.state !== ConnectorState.STARTED) {
12579
+ // Allow both STARTED and PAUSED states (PAUSED = tab hidden but connection alive)
12580
+ if (connector.state !== ConnectorState.STARTED && connector.state !== ConnectorState.PAUSED) {
12562
12581
  let errorMessage = 'Connector closed while waiting for NodeAttachAck';
12563
12582
  if (connector.closeCode !== undefined) {
12564
12583
  errorMessage += ` (code=${connector.closeCode}`;
@@ -5478,12 +5478,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
5478
5478
  }
5479
5479
 
5480
5480
  // This file is auto-generated during build - do not edit manually
5481
- // Generated from package.json version: 0.3.5-test.937
5481
+ // Generated from package.json version: 0.3.5-test.939
5482
5482
  /**
5483
5483
  * The package version, injected at build time.
5484
5484
  * @internal
5485
5485
  */
5486
- const VERSION = '0.3.5-test.937';
5486
+ const VERSION = '0.3.5-test.939';
5487
5487
 
5488
5488
  /**
5489
5489
  * Fame errors module - Fame protocol specific error classes
@@ -11646,11 +11646,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11646
11646
  if (typeof document !== 'undefined') {
11647
11647
  document.addEventListener('visibilitychange', this.visibilityChangeHandler);
11648
11648
  this.visibilityChangeListenerRegistered = true;
11649
- // Log initial state
11649
+ // Log initial state with detailed visibility info
11650
11650
  logger$10.debug('broadcast_channel_initial_visibility', {
11651
11651
  channel: this.channelName,
11652
11652
  connector_id: this.connectorId,
11653
11653
  visibility: document.hidden ? 'hidden' : 'visible',
11654
+ document_hidden: document.hidden,
11655
+ visibility_state: document.visibilityState,
11656
+ has_focus: document.hasFocus(),
11654
11657
  });
11655
11658
  }
11656
11659
  }
@@ -11831,6 +11834,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11831
11834
  logger$10.debug('broadcast_channel_start_in_hidden_tab', {
11832
11835
  channel: this.channelName,
11833
11836
  connector_id: this.connectorId,
11837
+ document_hidden: document.hidden,
11838
+ visibility_state: document.visibilityState,
11839
+ has_focus: document.hasFocus(),
11834
11840
  timestamp: new Date().toISOString(),
11835
11841
  });
11836
11842
  // Immediately pause if tab is hidden at start time
@@ -12084,6 +12090,7 @@ class UpstreamSessionManager extends TaskSpawner {
12084
12090
  this.lastHeartbeatAckTime = null;
12085
12091
  this.lastSeenEpoch = null;
12086
12092
  this.hadSuccessfulAttach = false;
12093
+ this.lastConnectorState = null;
12087
12094
  this.connectEpoch = 0;
12088
12095
  const options = normalizeOptions$k(optionsInput);
12089
12096
  this.node = options.node;
@@ -12508,15 +12515,26 @@ class UpstreamSessionManager extends TaskSpawner {
12508
12515
  if (stopEvt.isSet() || signal?.aborted) {
12509
12516
  break;
12510
12517
  }
12518
+ const currentState = connector.state;
12519
+ const previousState = this.lastConnectorState;
12520
+ this.lastConnectorState = currentState;
12511
12521
  // Skip heartbeat if connector is paused (e.g., tab is hidden)
12512
12522
  // Keep ack time current so we don't timeout immediately after resuming
12513
- if (connector.state === core.ConnectorState.PAUSED) {
12523
+ if (currentState === core.ConnectorState.PAUSED) {
12514
12524
  logger$$.debug('skipping_heartbeat_connector_paused', {
12515
- connector_state: connector.state,
12525
+ connector_state: currentState,
12516
12526
  });
12517
12527
  this.lastHeartbeatAckTime = Date.now();
12518
12528
  continue;
12519
12529
  }
12530
+ // Reset ack time if just resumed from pause (prevents immediate timeout)
12531
+ if (previousState === core.ConnectorState.PAUSED && currentState === core.ConnectorState.STARTED) {
12532
+ logger$$.debug('connector_just_resumed_resetting_ack_time', {
12533
+ previous_state: previousState,
12534
+ current_state: currentState,
12535
+ });
12536
+ this.lastHeartbeatAckTime = Date.now();
12537
+ }
12520
12538
  const envelope = await this.makeHeartbeatEnvelope();
12521
12539
  logger$$.debug('sending_heartbeat', {
12522
12540
  hb_corr_id: envelope.corrId,
@@ -14251,7 +14269,8 @@ class DefaultNodeAttachClient {
14251
14269
  async awaitAck(connector) {
14252
14270
  const deadline = Date.now() + this.timeoutMs;
14253
14271
  while (Date.now() < deadline) {
14254
- if (connector.state !== core.ConnectorState.STARTED) {
14272
+ // Allow both STARTED and PAUSED states (PAUSED = tab hidden but connection alive)
14273
+ if (connector.state !== core.ConnectorState.STARTED && connector.state !== core.ConnectorState.PAUSED) {
14255
14274
  let errorMessage = 'Connector closed while waiting for NodeAttachAck';
14256
14275
  if (connector.closeCode !== undefined) {
14257
14276
  errorMessage += ` (code=${connector.closeCode}`;
@@ -5477,12 +5477,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
5477
5477
  }
5478
5478
 
5479
5479
  // This file is auto-generated during build - do not edit manually
5480
- // Generated from package.json version: 0.3.5-test.937
5480
+ // Generated from package.json version: 0.3.5-test.939
5481
5481
  /**
5482
5482
  * The package version, injected at build time.
5483
5483
  * @internal
5484
5484
  */
5485
- const VERSION = '0.3.5-test.937';
5485
+ const VERSION = '0.3.5-test.939';
5486
5486
 
5487
5487
  /**
5488
5488
  * Fame errors module - Fame protocol specific error classes
@@ -11645,11 +11645,14 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11645
11645
  if (typeof document !== 'undefined') {
11646
11646
  document.addEventListener('visibilitychange', this.visibilityChangeHandler);
11647
11647
  this.visibilityChangeListenerRegistered = true;
11648
- // Log initial state
11648
+ // Log initial state with detailed visibility info
11649
11649
  logger$10.debug('broadcast_channel_initial_visibility', {
11650
11650
  channel: this.channelName,
11651
11651
  connector_id: this.connectorId,
11652
11652
  visibility: document.hidden ? 'hidden' : 'visible',
11653
+ document_hidden: document.hidden,
11654
+ visibility_state: document.visibilityState,
11655
+ has_focus: document.hasFocus(),
11653
11656
  });
11654
11657
  }
11655
11658
  }
@@ -11830,6 +11833,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11830
11833
  logger$10.debug('broadcast_channel_start_in_hidden_tab', {
11831
11834
  channel: this.channelName,
11832
11835
  connector_id: this.connectorId,
11836
+ document_hidden: document.hidden,
11837
+ visibility_state: document.visibilityState,
11838
+ has_focus: document.hasFocus(),
11833
11839
  timestamp: new Date().toISOString(),
11834
11840
  });
11835
11841
  // Immediately pause if tab is hidden at start time
@@ -12083,6 +12089,7 @@ class UpstreamSessionManager extends TaskSpawner {
12083
12089
  this.lastHeartbeatAckTime = null;
12084
12090
  this.lastSeenEpoch = null;
12085
12091
  this.hadSuccessfulAttach = false;
12092
+ this.lastConnectorState = null;
12086
12093
  this.connectEpoch = 0;
12087
12094
  const options = normalizeOptions$k(optionsInput);
12088
12095
  this.node = options.node;
@@ -12507,15 +12514,26 @@ class UpstreamSessionManager extends TaskSpawner {
12507
12514
  if (stopEvt.isSet() || signal?.aborted) {
12508
12515
  break;
12509
12516
  }
12517
+ const currentState = connector.state;
12518
+ const previousState = this.lastConnectorState;
12519
+ this.lastConnectorState = currentState;
12510
12520
  // Skip heartbeat if connector is paused (e.g., tab is hidden)
12511
12521
  // Keep ack time current so we don't timeout immediately after resuming
12512
- if (connector.state === ConnectorState.PAUSED) {
12522
+ if (currentState === ConnectorState.PAUSED) {
12513
12523
  logger$$.debug('skipping_heartbeat_connector_paused', {
12514
- connector_state: connector.state,
12524
+ connector_state: currentState,
12515
12525
  });
12516
12526
  this.lastHeartbeatAckTime = Date.now();
12517
12527
  continue;
12518
12528
  }
12529
+ // Reset ack time if just resumed from pause (prevents immediate timeout)
12530
+ if (previousState === ConnectorState.PAUSED && currentState === ConnectorState.STARTED) {
12531
+ logger$$.debug('connector_just_resumed_resetting_ack_time', {
12532
+ previous_state: previousState,
12533
+ current_state: currentState,
12534
+ });
12535
+ this.lastHeartbeatAckTime = Date.now();
12536
+ }
12519
12537
  const envelope = await this.makeHeartbeatEnvelope();
12520
12538
  logger$$.debug('sending_heartbeat', {
12521
12539
  hb_corr_id: envelope.corrId,
@@ -14250,7 +14268,8 @@ class DefaultNodeAttachClient {
14250
14268
  async awaitAck(connector) {
14251
14269
  const deadline = Date.now() + this.timeoutMs;
14252
14270
  while (Date.now() < deadline) {
14253
- if (connector.state !== ConnectorState.STARTED) {
14271
+ // Allow both STARTED and PAUSED states (PAUSED = tab hidden but connection alive)
14272
+ if (connector.state !== ConnectorState.STARTED && connector.state !== ConnectorState.PAUSED) {
14254
14273
  let errorMessage = 'Connector closed while waiting for NodeAttachAck';
14255
14274
  if (connector.closeCode !== undefined) {
14256
14275
  errorMessage += ` (code=${connector.closeCode}`;
@@ -65,6 +65,7 @@ export declare class UpstreamSessionManager extends TaskSpawner implements Sessi
65
65
  private lastHeartbeatAckTime;
66
66
  private lastSeenEpoch;
67
67
  private hadSuccessfulAttach;
68
+ private lastConnectorState;
68
69
  private connectEpoch;
69
70
  constructor(optionsInput: UpstreamSessionManagerOptionsInput);
70
71
  get systemId(): string | null;
@@ -2,4 +2,4 @@
2
2
  * The package version, injected at build time.
3
3
  * @internal
4
4
  */
5
- export declare const VERSION = "0.3.5-test.937";
5
+ export declare const VERSION = "0.3.5-test.939";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naylence/runtime",
3
- "version": "0.3.5-test.937",
3
+ "version": "0.3.5-test.939",
4
4
  "type": "module",
5
5
  "description": "Naylence Runtime - Complete TypeScript runtime",
6
6
  "author": "Naylence Dev <naylencedev@gmail.com>",