54365436 return base.PubNubFile;
54375437 },
54385438 get version() {
5439- return '10.0 .0';
5439+ return '10.1 .0';
54405440 },
54415441 getVersion() {
54425442 return this.version;
89238923 this.engine.transition(joined(this.channels.slice(0), this.groups.slice(0)));
89248924 }
89258925 leave({ channels, groups }) {
8926+ // Update internal channel tracking to prevent stale heartbeat requests
8927+ if (channels)
8928+ this.channels = this.channels.filter((channel) => !channels.includes(channel));
8929+ if (groups)
8930+ this.groups = this.groups.filter((group) => !groups.includes(group));
89268931 if (this.dependencies.presenceState) {
89278932 channels === null || channels === void 0 ? void 0 : channels.forEach((c) => delete this.dependencies.presenceState[c]);
89288933 groups === null || groups === void 0 ? void 0 : groups.forEach((g) => delete this.dependencies.presenceState[g]);
89298934 }
89308935 this.engine.transition(left(channels !== null && channels !== void 0 ? channels : [], groups !== null && groups !== void 0 ? groups : []));
89318936 }
89328937 leaveAll(isOffline = false) {
8938+ // Clear presence state for all current channels and groups
8939+ if (this.dependencies.presenceState) {
8940+ this.channels.forEach((c) => delete this.dependencies.presenceState[c]);
8941+ this.groups.forEach((g) => delete this.dependencies.presenceState[g]);
8942+ }
8943+ // Reset internal channel and group tracking
8944+ this.channels = [];
8945+ this.groups = [];
89338946 this.engine.transition(leftAll(isOffline));
89348947 }
89358948 reconnect() {
@@ -11432,19 +11445,18 @@
1143211445 */
1143311446 class HereNowRequest extends AbstractRequest {
1143411447 constructor(parameters) {
11435- var _a, _b, _c, _d ;
11436- var _e, _f, _g, _h ;
11448+ var _a, _b, _c;
11449+ var _d, _e, _f ;
1143711450 super();
1143811451 this.parameters = parameters;
1143911452 // Apply defaults.
11440- (_a = (_e = this.parameters).queryParameters) !== null && _a !== void 0 ? _a : (_e .queryParameters = {});
11441- (_b = (_f = this.parameters).includeUUIDs) !== null && _b !== void 0 ? _b : (_f .includeUUIDs = INCLUDE_UUID$1);
11442- (_c = (_g = this.parameters).includeState) !== null && _c !== void 0 ? _c : (_g .includeState = INCLUDE_STATE);
11453+ (_a = (_d = this.parameters).queryParameters) !== null && _a !== void 0 ? _a : (_d .queryParameters = {});
11454+ (_b = (_e = this.parameters).includeUUIDs) !== null && _b !== void 0 ? _b : (_e .includeUUIDs = INCLUDE_UUID$1);
11455+ (_c = (_f = this.parameters).includeState) !== null && _c !== void 0 ? _c : (_f .includeState = INCLUDE_STATE);
1144311456 if (this.parameters.limit)
1144411457 this.parameters.limit = Math.min(this.parameters.limit, MAXIMUM_COUNT);
1144511458 else
1144611459 this.parameters.limit = MAXIMUM_COUNT;
11447- (_d = (_h = this.parameters).offset) !== null && _d !== void 0 ? _d : (_h.offset = 0);
1144811460 }
1144911461 operation() {
1145011462 const { channels = [], channelGroups = [] } = this.parameters;
1146511477 const totalOccupancy = 'occupancy' in serviceResponse ? serviceResponse.occupancy : serviceResponse.payload.total_occupancy;
1146611478 const channelsPresence = {};
1146711479 let channels = {};
11480+ const limit = this.parameters.limit;
11481+ let occupancyMatchLimit = false;
1146811482 // Remap single channel presence to multiple channels presence response.
1146911483 if ('occupancy' in serviceResponse) {
1147011484 const channel = this.parameters.channels[0];
@@ -11485,11 +11499,12 @@
1148511499 name: channel,
1148611500 occupancy: channelEntry.occupancy,
1148711501 };
11502+ if (!occupancyMatchLimit && channelEntry.occupancy === limit)
11503+ occupancyMatchLimit = true;
1148811504 });
1148911505 return {
1149011506 totalChannels,
1149111507 totalOccupancy,
11492- next: 0,
1149311508 channels: channelsPresence,
1149411509 };
1149511510 });
1150211517 return path;
1150311518 }
1150411519 get queryParameters() {
11505- const { channelGroups, includeUUIDs, includeState, limit, offset, queryParameters } = this.parameters;
11506- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign( {}, (this.operation() === RequestOperation$1.PNHereNowOperation ? { limit } : {})), (this.operation() === RequestOperation$1.PNHereNowOperation && offset > 0 ? { offset } : {})), (!includeUUIDs ? { disable_uuids: '1' } : {})), ((includeState !== null && includeState !== void 0 ? includeState : false) ? { state: '1' } : {})), (channelGroups && channelGroups.length > 0 ? { 'channel-group': channelGroups.join(',') } : {})), queryParameters);
11520+ const { channelGroups, includeUUIDs, includeState, limit, queryParameters } = this.parameters;
11521+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (this.operation() === RequestOperation$1.PNHereNowOperation ? { limit } : {})), (!includeUUIDs ? { disable_uuids: '1' } : {})), ((includeState !== null && includeState !== void 0 ? includeState : false) ? { state: '1' } : {})), (channelGroups && channelGroups.length > 0 ? { 'channel-group': channelGroups.join(',') } : {})), queryParameters);
1150711522 }
1150811523 }
1150911524
@@ -16778,16 +16793,10 @@
1677816793 };
1677916794 if (callback)
1678016795 return this.sendRequest(request, (status, response) => {
16781- var _a;
16782- if (response && response.totalOccupancy === parameters.limit)
16783- response.next = ((_a = parameters.offset) !== null && _a !== void 0 ? _a : 0) + 1;
1678416796 logResponse(response);
1678516797 callback(status, response);
1678616798 });
1678716799 return this.sendRequest(request).then((response) => {
16788- var _a;
16789- if (response && response.totalOccupancy === parameters.limit)
16790- response.next = ((_a = parameters.offset) !== null && _a !== void 0 ? _a : 0) + 1;
1679116800 logResponse(response);
1679216801 return response;
1679316802 });
0 commit comments