Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
---
changelog:
- date: 2025-03-06
version: v8.10.0
changes:
- type: feature
text: "Add `useSmartHeartbeat` configuration option which allows ignoring implicit heartbeat (with successful subscribe response) and keep sending `heartbeat` calls with fixed intervals."
- type: feature
text: "`subscriptionWorkerOfflineClientsCheckInterval` configuration option can be used to configure the interval at which “offline” PubNub clients (when tab closed) detection will be done."
- type: feature
text: "`subscriptionWorkerUnsubscribeOfflineClients` configuration option can be used to force unsubscribe (presence leave) for “offline” PubNub clients (when tab closed)."
- date: 2025-02-26
version: v8.9.1
changes:
Expand Down Expand Up @@ -1151,7 +1160,7 @@ supported-platforms:
- 'Ubuntu 14.04 and up'
- 'Windows 7 and up'
version: 'Pubnub Javascript for Node'
version: '8.9.1'
version: '8.10.0'
sdks:
- full-name: PubNub Javascript SDK
short-name: Javascript
Expand All @@ -1167,7 +1176,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.9.1.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.10.0.zip
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down Expand Up @@ -1838,7 +1847,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v8.9.1/pubnub.8.9.1.js
location: https://github.com/pubnub/javascript/releases/download/v8.10.0/pubnub.8.10.0.js
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v8.10.0
March 06 2025

#### Added
- Add `useSmartHeartbeat` configuration option which allows ignoring implicit heartbeat (with successful subscribe response) and keep sending `heartbeat` calls with fixed intervals.
- `subscriptionWorkerOfflineClientsCheckInterval` configuration option can be used to configure the interval at which “offline” PubNub clients (when tab closed) detection will be done.
- `subscriptionWorkerUnsubscribeOfflineClients` configuration option can be used to force unsubscribe (presence leave) for “offline” PubNub clients (when tab closed).

## v8.9.1
February 26 2025

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Watch [Getting Started with PubNub JS SDK](https://app.dashcam.io/replay/64ee0d2
npm install pubnub
```
* or download one of our builds from our CDN:
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.9.1.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.9.1.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.10.0.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.10.0.min.js

2. Configure your keys:

Expand Down
33 changes: 25 additions & 8 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -3261,6 +3261,8 @@
userId: this.configuration.userId,
heartbeatInterval: this.configuration.heartbeatInterval,
logVerbosity: this.configuration.logVerbosity,
workerOfflineClientsCheckInterval: this.configuration.workerOfflineClientsCheckInterval,
workerUnsubscribeOfflineClients: this.configuration.workerUnsubscribeOfflineClients,
workerLogVerbosity: this.configuration.workerLogVerbosity,
}, true);
this.subscriptionWorker.port.onmessage = (event) => this.handleWorkerEvent(event);
Expand Down Expand Up @@ -3433,6 +3435,10 @@
* Whether configured user presence state should be maintained by the PubNub client or not.
*/
const MAINTAIN_PRESENCE_STATE = true;
/**
* Whether heartbeat should be postponed on successful subscribe response or not.
*/
const USE_SMART_HEARTBEAT = true;
/**
* Whether PubNub client should try to utilize existing TCP connection for new requests or not.
*/
Expand Down Expand Up @@ -3489,7 +3495,7 @@
* @internal
*/
const setDefaults$1 = (configuration) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
// Copy configuration.
const configurationCopy = Object.assign({}, configuration);
(_a = configurationCopy.logVerbosity) !== null && _a !== void 0 ? _a : (configurationCopy.logVerbosity = USE_VERBOSE_LOGGING);
Expand All @@ -3504,13 +3510,14 @@
(_k = configurationCopy.autoNetworkDetection) !== null && _k !== void 0 ? _k : (configurationCopy.autoNetworkDetection = AUTO_NETWORK_DETECTION);
(_l = configurationCopy.enableEventEngine) !== null && _l !== void 0 ? _l : (configurationCopy.enableEventEngine = ENABLE_EVENT_ENGINE);
(_m = configurationCopy.maintainPresenceState) !== null && _m !== void 0 ? _m : (configurationCopy.maintainPresenceState = MAINTAIN_PRESENCE_STATE);
(_o = configurationCopy.keepAlive) !== null && _o !== void 0 ? _o : (configurationCopy.keepAlive = KEEP_ALIVE$1);
(_o = configurationCopy.useSmartHeartbeat) !== null && _o !== void 0 ? _o : (configurationCopy.useSmartHeartbeat = USE_SMART_HEARTBEAT);
(_p = configurationCopy.keepAlive) !== null && _p !== void 0 ? _p : (configurationCopy.keepAlive = KEEP_ALIVE$1);
if (configurationCopy.userId && configurationCopy.uuid)
throw new PubNubError("PubNub client configuration error: use only 'userId'");
(_p = configurationCopy.userId) !== null && _p !== void 0 ? _p : (configurationCopy.userId = configurationCopy.uuid);
(_q = configurationCopy.userId) !== null && _q !== void 0 ? _q : (configurationCopy.userId = configurationCopy.uuid);
if (!configurationCopy.userId)
throw new PubNubError("PubNub client configuration error: 'userId' not set");
else if (((_q = configurationCopy.userId) === null || _q === void 0 ? void 0 : _q.trim().length) === 0)
else if (((_r = configurationCopy.userId) === null || _r === void 0 ? void 0 : _r.trim().length) === 0)
throw new PubNubError("PubNub client configuration error: 'userId' is empty");
// Generate default origin subdomains.
if (!configurationCopy.origin)
Expand Down Expand Up @@ -3599,6 +3606,14 @@
* Whether verbose logging should be enabled for `Subscription` worker to print debug messages or not.
*/
const SUBSCRIPTION_WORKER_LOG_VERBOSITY = false;
/**
* Interval at which Shared Worker should check whether PubNub instances which used it still active or not.
*/
const SUBSCRIPTION_WORKER_OFFLINE_CLIENTS_CHECK_INTERVAL = 10;
/**
* Whether `leave` request should be sent for _offline_ PubNub client or not.
*/
const SUBSCRIPTION_WORKER_UNSUBSCRIBE_OFFLINE_CLIENTS = false;
/**
* Use modern Web Fetch API for network requests by default.
*/
Expand All @@ -3615,13 +3630,13 @@
* @internal
*/
const setDefaults = (configuration) => {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e, _f;
// Force disable service workers if environment doesn't support them.
if (configuration.subscriptionWorkerUrl && typeof SharedWorker === 'undefined')
configuration.subscriptionWorkerUrl = null;
return Object.assign(Object.assign({}, setDefaults$1(configuration)), {
// Set platform-specific options.
listenToBrowserNetworkEvents: (_a = configuration.listenToBrowserNetworkEvents) !== null && _a !== void 0 ? _a : LISTEN_TO_BROWSER_NETWORK_EVENTS, subscriptionWorkerUrl: configuration.subscriptionWorkerUrl, subscriptionWorkerLogVerbosity: (_b = configuration.subscriptionWorkerLogVerbosity) !== null && _b !== void 0 ? _b : SUBSCRIPTION_WORKER_LOG_VERBOSITY, transport: (_c = configuration.transport) !== null && _c !== void 0 ? _c : TRANSPORT, keepAlive: (_d = configuration.keepAlive) !== null && _d !== void 0 ? _d : KEEP_ALIVE });
listenToBrowserNetworkEvents: (_a = configuration.listenToBrowserNetworkEvents) !== null && _a !== void 0 ? _a : LISTEN_TO_BROWSER_NETWORK_EVENTS, subscriptionWorkerUrl: configuration.subscriptionWorkerUrl, subscriptionWorkerOfflineClientsCheckInterval: (_b = configuration.subscriptionWorkerOfflineClientsCheckInterval) !== null && _b !== void 0 ? _b : SUBSCRIPTION_WORKER_OFFLINE_CLIENTS_CHECK_INTERVAL, subscriptionWorkerUnsubscribeOfflineClients: (_c = configuration.subscriptionWorkerUnsubscribeOfflineClients) !== null && _c !== void 0 ? _c : SUBSCRIPTION_WORKER_UNSUBSCRIBE_OFFLINE_CLIENTS, subscriptionWorkerLogVerbosity: (_d = configuration.subscriptionWorkerLogVerbosity) !== null && _d !== void 0 ? _d : SUBSCRIPTION_WORKER_LOG_VERBOSITY, transport: (_e = configuration.transport) !== null && _e !== void 0 ? _e : TRANSPORT, keepAlive: (_f = configuration.keepAlive) !== null && _f !== void 0 ? _f : KEEP_ALIVE });
};

var uuid = {exports: {}};
Expand Down Expand Up @@ -3803,7 +3818,7 @@
return base.PubNubFile;
},
get version() {
return '8.9.1';
return '8.10.0';
},
getVersion() {
return this.version;
Expand Down Expand Up @@ -4930,7 +4945,7 @@
*/
reconnect(forUnsubscribe = false) {
this.startSubscribeLoop();
if (!forUnsubscribe)
if (!forUnsubscribe && this.configuration.useSmartHeartbeat)
this.startHeartbeatTimer();
}
/**
Expand Down Expand Up @@ -14565,6 +14580,8 @@
workerUrl: configurationCopy.subscriptionWorkerUrl,
sdkVersion: clientConfiguration.getVersion(),
heartbeatInterval: clientConfiguration.getHeartbeatInterval(),
workerOfflineClientsCheckInterval: platformConfiguration.subscriptionWorkerOfflineClientsCheckInterval,
workerUnsubscribeOfflineClients: platformConfiguration.subscriptionWorkerUnsubscribeOfflineClients,
logVerbosity: clientConfiguration.logVerbosity,
workerLogVerbosity: platformConfiguration.subscriptionWorkerLogVerbosity,
transport,
Expand Down
4 changes: 2 additions & 2 deletions dist/web/pubnub.min.js

Large diffs are not rendered by default.

Loading
Loading