Skip to content

Commit 0fa1f3e

Browse files
committed
lib/dist updates for structural split changes
1 parent 3d738a0 commit 0fa1f3e

20 files changed

Lines changed: 472 additions & 378 deletions

dist/web/pubnub.js

Lines changed: 250 additions & 220 deletions
Large diffs are not rendered by default.

dist/web/pubnub.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/event-engine/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4242
};
4343
Object.defineProperty(exports, "__esModule", { value: true });
4444
exports.EventEngine = void 0;
45-
const receiving_1 = require("./states/receiving");
45+
const states_1 = require("./states");
4646
const dispatcher_1 = require("./dispatcher");
4747
const utils_1 = require("../core/utils");
48-
const unsubscribed_1 = require("./states/unsubscribed");
4948
const core_1 = require("./core");
5049
const categories_1 = __importDefault(require("../core/constants/categories"));
5150
const utils = __importStar(require("../core/utils"));
@@ -71,7 +70,7 @@ class EventEngine {
7170
this.dispatcher.dispatch(change.invocation);
7271
}
7372
});
74-
this.engine.start(unsubscribed_1.UnsubscribedState, undefined);
73+
this.engine.start(states_1.UnsubscribedState, undefined);
7574
}
7675
/**
7776
* Subscription-based current timetoken.
@@ -84,7 +83,7 @@ class EventEngine {
8483
return undefined;
8584
let referenceTimetoken;
8685
let currentTimetoken = '0';
87-
if (currentState.label === receiving_1.ReceivingState.label) {
86+
if (currentState.label === states_1.ReceivingState.label) {
8887
const context = this.engine.currentContext;
8988
currentTimetoken = context.cursor.timetoken;
9089
referenceTimetoken = context.referenceTimetoken;
@@ -118,7 +117,7 @@ class EventEngine {
118117
const currentState = this.engine.currentState;
119118
const currentContext = this.engine.currentContext;
120119
let currentTimetoken = '0';
121-
if ((currentState === null || currentState === void 0 ? void 0 : currentState.label) === receiving_1.ReceivingState.label && currentContext) {
120+
if ((currentState === null || currentState === void 0 ? void 0 : currentState.label) === states_1.ReceivingState.label && currentContext) {
122121
const receivingContext = currentContext;
123122
currentTimetoken = (_a = receivingContext.cursor) === null || _a === void 0 ? void 0 : _a.timetoken;
124123
}

lib/event-engine/presence/presence.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var __importStar = (this && this.__importStar) || (function () {
4040
Object.defineProperty(exports, "__esModule", { value: true });
4141
exports.PresenceEventEngine = void 0;
4242
const dispatcher_1 = require("./dispatcher");
43-
const heartbeat_inactive_1 = require("./states/heartbeat_inactive");
43+
const states_1 = require("./states");
4444
const core_1 = require("../core");
4545
const events = __importStar(require("./events"));
4646
/**
@@ -64,7 +64,7 @@ class PresenceEventEngine {
6464
this.dispatcher.dispatch(change.invocation);
6565
}
6666
});
67-
this.engine.start(heartbeat_inactive_1.HeartbeatInactiveState, undefined);
67+
this.engine.start(states_1.HeartbeatInactiveState, undefined);
6868
}
6969
join({ channels, groups }) {
7070
this.channels = [...this.channels, ...(channels !== null && channels !== void 0 ? channels : []).filter((channel) => !this.channels.includes(channel))];

lib/event-engine/presence/states/heartbeat_cooldown.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,34 @@
66
*/
77
Object.defineProperty(exports, "__esModule", { value: true });
88
exports.HeartbeatCooldownState = void 0;
9-
const state_1 = require("../../core/state");
109
const events_1 = require("../events");
1110
const effects_1 = require("../effects");
12-
const heartbeating_1 = require("./heartbeating");
13-
const heartbeat_stopped_1 = require("./heartbeat_stopped");
14-
const heartbeat_inactive_1 = require("./heartbeat_inactive");
11+
const instances_1 = require("./instances");
12+
Object.defineProperty(exports, "HeartbeatCooldownState", { enumerable: true, get: function () { return instances_1.HeartbeatCooldownState; } });
1513
/**
1614
* Waiting next heartbeat state.
1715
*
1816
* State in which Presence Event Engine is waiting when delay will run out and next heartbeat call should be done.
1917
*
2018
* @internal
2119
*/
22-
exports.HeartbeatCooldownState = new state_1.State('HEARTBEAT_COOLDOWN');
23-
exports.HeartbeatCooldownState.onEnter(() => (0, effects_1.wait)());
24-
exports.HeartbeatCooldownState.onExit(() => effects_1.wait.cancel);
25-
exports.HeartbeatCooldownState.on(events_1.timesUp.type, (context, _) => heartbeating_1.HeartbeatingState.with({
20+
instances_1.HeartbeatCooldownState.onEnter(() => (0, effects_1.wait)());
21+
instances_1.HeartbeatCooldownState.onExit(() => effects_1.wait.cancel);
22+
instances_1.HeartbeatCooldownState.on(events_1.timesUp.type, (context, _) => instances_1.HeartbeatingState.with({
2623
channels: context.channels,
2724
groups: context.groups,
2825
}));
29-
exports.HeartbeatCooldownState.on(events_1.joined.type, (context, event) => heartbeating_1.HeartbeatingState.with({
26+
instances_1.HeartbeatCooldownState.on(events_1.joined.type, (context, event) => instances_1.HeartbeatingState.with({
3027
channels: [...context.channels, ...event.payload.channels.filter((channel) => !context.channels.includes(channel))],
3128
groups: [...context.groups, ...event.payload.groups.filter((group) => !context.groups.includes(group))],
3229
}));
33-
exports.HeartbeatCooldownState.on(events_1.left.type, (context, event) => heartbeating_1.HeartbeatingState.with({
30+
instances_1.HeartbeatCooldownState.on(events_1.left.type, (context, event) => instances_1.HeartbeatingState.with({
3431
channels: context.channels.filter((channel) => !event.payload.channels.includes(channel)),
3532
groups: context.groups.filter((group) => !event.payload.groups.includes(group)),
3633
}, [(0, effects_1.leave)(event.payload.channels, event.payload.groups)]));
37-
exports.HeartbeatCooldownState.on(events_1.disconnect.type, (context, event) => heartbeat_stopped_1.HeartbeatStoppedState.with({ channels: context.channels, groups: context.groups }, [
34+
instances_1.HeartbeatCooldownState.on(events_1.disconnect.type, (context, event) => instances_1.HeartbeatStoppedState.with({ channels: context.channels, groups: context.groups }, [
3835
...(!event.payload.isOffline ? [(0, effects_1.leave)(context.channels, context.groups)] : []),
3936
]));
40-
exports.HeartbeatCooldownState.on(events_1.leftAll.type, (context, event) => heartbeat_inactive_1.HeartbeatInactiveState.with(undefined, [
37+
instances_1.HeartbeatCooldownState.on(events_1.leftAll.type, (context, event) => instances_1.HeartbeatInactiveState.with(undefined, [
4138
...(!event.payload.isOffline ? [(0, effects_1.leave)(context.channels, context.groups)] : []),
4239
]));

lib/event-engine/presence/states/heartbeat_failed.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
*/
77
Object.defineProperty(exports, "__esModule", { value: true });
88
exports.HeartbeatFailedState = void 0;
9-
const state_1 = require("../../core/state");
109
const events_1 = require("../events");
1110
const effects_1 = require("../effects");
12-
const heartbeating_1 = require("./heartbeating");
13-
const heartbeat_stopped_1 = require("./heartbeat_stopped");
14-
const heartbeat_inactive_1 = require("./heartbeat_inactive");
11+
const instances_1 = require("./instances");
12+
Object.defineProperty(exports, "HeartbeatFailedState", { enumerable: true, get: function () { return instances_1.HeartbeatFailedState; } });
1513
/**
1614
* Failed to heartbeat state.
1715
*
@@ -20,22 +18,21 @@ const heartbeat_inactive_1 = require("./heartbeat_inactive");
2018
*
2119
* @internal
2220
*/
23-
exports.HeartbeatFailedState = new state_1.State('HEARTBEAT_FAILED');
24-
exports.HeartbeatFailedState.on(events_1.joined.type, (context, event) => heartbeating_1.HeartbeatingState.with({
21+
instances_1.HeartbeatFailedState.on(events_1.joined.type, (context, event) => instances_1.HeartbeatingState.with({
2522
channels: [...context.channels, ...event.payload.channels.filter((channel) => !context.channels.includes(channel))],
2623
groups: [...context.groups, ...event.payload.groups.filter((group) => !context.groups.includes(group))],
2724
}));
28-
exports.HeartbeatFailedState.on(events_1.left.type, (context, event) => heartbeating_1.HeartbeatingState.with({
25+
instances_1.HeartbeatFailedState.on(events_1.left.type, (context, event) => instances_1.HeartbeatingState.with({
2926
channels: context.channels.filter((channel) => !event.payload.channels.includes(channel)),
3027
groups: context.groups.filter((group) => !event.payload.groups.includes(group)),
3128
}, [(0, effects_1.leave)(event.payload.channels, event.payload.groups)]));
32-
exports.HeartbeatFailedState.on(events_1.reconnect.type, (context, _) => heartbeating_1.HeartbeatingState.with({
29+
instances_1.HeartbeatFailedState.on(events_1.reconnect.type, (context, _) => instances_1.HeartbeatingState.with({
3330
channels: context.channels,
3431
groups: context.groups,
3532
}));
36-
exports.HeartbeatFailedState.on(events_1.disconnect.type, (context, event) => heartbeat_stopped_1.HeartbeatStoppedState.with({ channels: context.channels, groups: context.groups }, [
33+
instances_1.HeartbeatFailedState.on(events_1.disconnect.type, (context, event) => instances_1.HeartbeatStoppedState.with({ channels: context.channels, groups: context.groups }, [
3734
...(!event.payload.isOffline ? [(0, effects_1.leave)(context.channels, context.groups)] : []),
3835
]));
39-
exports.HeartbeatFailedState.on(events_1.leftAll.type, (context, event) => heartbeat_inactive_1.HeartbeatInactiveState.with(undefined, [
36+
instances_1.HeartbeatFailedState.on(events_1.leftAll.type, (context, event) => instances_1.HeartbeatInactiveState.with(undefined, [
4037
...(!event.payload.isOffline ? [(0, effects_1.leave)(context.channels, context.groups)] : []),
4138
]));

lib/event-engine/presence/states/heartbeat_inactive.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@
66
*/
77
Object.defineProperty(exports, "__esModule", { value: true });
88
exports.HeartbeatInactiveState = void 0;
9-
const state_1 = require("../../core/state");
109
const events_1 = require("../events");
11-
const heartbeating_1 = require("./heartbeating");
10+
const instances_1 = require("./instances");
11+
Object.defineProperty(exports, "HeartbeatInactiveState", { enumerable: true, get: function () { return instances_1.HeartbeatInactiveState; } });
1212
/**
1313
* Inactive heratbeating state
1414
*
1515
* State in which Presence Event Engine doesn't process any heartbeat requests (initial state).
1616
*
1717
* @internal
1818
*/
19-
exports.HeartbeatInactiveState = new state_1.State('HEARTBEAT_INACTIVE');
20-
exports.HeartbeatInactiveState.on(events_1.joined.type, (_, event) => heartbeating_1.HeartbeatingState.with({
19+
instances_1.HeartbeatInactiveState.on(events_1.joined.type, (_, event) => instances_1.HeartbeatingState.with({
2120
channels: event.payload.channels,
2221
groups: event.payload.groups,
2322
}));

lib/event-engine/presence/states/heartbeat_stopped.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
*/
77
Object.defineProperty(exports, "__esModule", { value: true });
88
exports.HeartbeatStoppedState = void 0;
9-
const state_1 = require("../../core/state");
109
const events_1 = require("../events");
11-
const heartbeat_inactive_1 = require("./heartbeat_inactive");
12-
const heartbeating_1 = require("./heartbeating");
10+
const instances_1 = require("./instances");
11+
Object.defineProperty(exports, "HeartbeatStoppedState", { enumerable: true, get: function () { return instances_1.HeartbeatStoppedState; } });
1312
/**
1413
* Heartbeat stopped state.
1514
*
@@ -18,17 +17,16 @@ const heartbeating_1 = require("./heartbeating");
1817
*
1918
* @internal
2019
*/
21-
exports.HeartbeatStoppedState = new state_1.State('HEARTBEAT_STOPPED');
22-
exports.HeartbeatStoppedState.on(events_1.joined.type, (context, event) => exports.HeartbeatStoppedState.with({
20+
instances_1.HeartbeatStoppedState.on(events_1.joined.type, (context, event) => instances_1.HeartbeatStoppedState.with({
2321
channels: [...context.channels, ...event.payload.channels.filter((channel) => !context.channels.includes(channel))],
2422
groups: [...context.groups, ...event.payload.groups.filter((group) => !context.groups.includes(group))],
2523
}));
26-
exports.HeartbeatStoppedState.on(events_1.left.type, (context, event) => exports.HeartbeatStoppedState.with({
24+
instances_1.HeartbeatStoppedState.on(events_1.left.type, (context, event) => instances_1.HeartbeatStoppedState.with({
2725
channels: context.channels.filter((channel) => !event.payload.channels.includes(channel)),
2826
groups: context.groups.filter((group) => !event.payload.groups.includes(group)),
2927
}));
30-
exports.HeartbeatStoppedState.on(events_1.reconnect.type, (context, _) => heartbeating_1.HeartbeatingState.with({
28+
instances_1.HeartbeatStoppedState.on(events_1.reconnect.type, (context, _) => instances_1.HeartbeatingState.with({
3129
channels: context.channels,
3230
groups: context.groups,
3331
}));
34-
exports.HeartbeatStoppedState.on(events_1.leftAll.type, (context, _) => heartbeat_inactive_1.HeartbeatInactiveState.with(undefined));
32+
instances_1.HeartbeatStoppedState.on(events_1.leftAll.type, (context, _) => instances_1.HeartbeatInactiveState.with(undefined));

lib/event-engine/presence/states/heartbeating.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,37 @@
77
Object.defineProperty(exports, "__esModule", { value: true });
88
exports.HeartbeatingState = void 0;
99
const events_1 = require("../events");
10-
const heartbeat_inactive_1 = require("./heartbeat_inactive");
11-
const heartbeat_cooldown_1 = require("./heartbeat_cooldown");
12-
const heartbeat_stopped_1 = require("./heartbeat_stopped");
13-
const heartbeat_failed_1 = require("./heartbeat_failed");
1410
const effects_1 = require("../effects");
15-
const state_1 = require("../../core/state");
11+
const instances_1 = require("./instances");
12+
Object.defineProperty(exports, "HeartbeatingState", { enumerable: true, get: function () { return instances_1.HeartbeatingState; } });
1613
/**
1714
* Heartbeating state module.
1815
*
1916
* State in which Presence Event Engine send heartbeat REST API call.
2017
*
2118
* @internal
2219
*/
23-
exports.HeartbeatingState = new state_1.State('HEARTBEATING');
24-
exports.HeartbeatingState.onEnter((context) => (0, effects_1.heartbeat)(context.channels, context.groups));
25-
exports.HeartbeatingState.onExit(() => effects_1.heartbeat.cancel);
26-
exports.HeartbeatingState.on(events_1.heartbeatSuccess.type, (context, event) => heartbeat_cooldown_1.HeartbeatCooldownState.with({ channels: context.channels, groups: context.groups }, [
20+
instances_1.HeartbeatingState.onEnter((context) => (0, effects_1.heartbeat)(context.channels, context.groups));
21+
instances_1.HeartbeatingState.onExit(() => effects_1.heartbeat.cancel);
22+
instances_1.HeartbeatingState.on(events_1.heartbeatSuccess.type, (context, event) => instances_1.HeartbeatCooldownState.with({ channels: context.channels, groups: context.groups }, [
2723
(0, effects_1.emitStatus)(Object.assign({}, event.payload)),
2824
]));
29-
exports.HeartbeatingState.on(events_1.joined.type, (context, event) => exports.HeartbeatingState.with({
25+
instances_1.HeartbeatingState.on(events_1.joined.type, (context, event) => instances_1.HeartbeatingState.with({
3026
channels: [...context.channels, ...event.payload.channels.filter((channel) => !context.channels.includes(channel))],
3127
groups: [...context.groups, ...event.payload.groups.filter((group) => !context.groups.includes(group))],
3228
}));
33-
exports.HeartbeatingState.on(events_1.left.type, (context, event) => {
34-
return exports.HeartbeatingState.with({
29+
instances_1.HeartbeatingState.on(events_1.left.type, (context, event) => {
30+
return instances_1.HeartbeatingState.with({
3531
channels: context.channels.filter((channel) => !event.payload.channels.includes(channel)),
3632
groups: context.groups.filter((group) => !event.payload.groups.includes(group)),
3733
}, [(0, effects_1.leave)(event.payload.channels, event.payload.groups)]);
3834
});
39-
exports.HeartbeatingState.on(events_1.heartbeatFailure.type, (context, event) => heartbeat_failed_1.HeartbeatFailedState.with(Object.assign({}, context), [
35+
instances_1.HeartbeatingState.on(events_1.heartbeatFailure.type, (context, event) => instances_1.HeartbeatFailedState.with(Object.assign({}, context), [
4036
...(event.payload.status ? [(0, effects_1.emitStatus)(Object.assign({}, event.payload.status))] : []),
4137
]));
42-
exports.HeartbeatingState.on(events_1.disconnect.type, (context, event) => heartbeat_stopped_1.HeartbeatStoppedState.with({ channels: context.channels, groups: context.groups }, [
38+
instances_1.HeartbeatingState.on(events_1.disconnect.type, (context, event) => instances_1.HeartbeatStoppedState.with({ channels: context.channels, groups: context.groups }, [
4339
...(!event.payload.isOffline ? [(0, effects_1.leave)(context.channels, context.groups)] : []),
4440
]));
45-
exports.HeartbeatingState.on(events_1.leftAll.type, (context, event) => heartbeat_inactive_1.HeartbeatInactiveState.with(undefined, [
41+
instances_1.HeartbeatingState.on(events_1.leftAll.type, (context, event) => instances_1.HeartbeatInactiveState.with(undefined, [
4642
...(!event.payload.isOffline ? [(0, effects_1.leave)(context.channels, context.groups)] : []),
4743
]));
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"use strict";
2+
/**
3+
* Presence Event Engine states.
4+
*
5+
* Side-effect imports register transition handlers on the shared state instances.
6+
*
7+
* @internal
8+
*/
9+
Object.defineProperty(exports, "__esModule", { value: true });
10+
exports.HeartbeatFailedState = exports.HeartbeatStoppedState = exports.HeartbeatCooldownState = exports.HeartbeatingState = exports.HeartbeatInactiveState = void 0;
11+
require("./heartbeat_inactive");
12+
require("./heartbeating");
13+
require("./heartbeat_cooldown");
14+
require("./heartbeat_stopped");
15+
require("./heartbeat_failed");
16+
var instances_1 = require("./instances");
17+
Object.defineProperty(exports, "HeartbeatInactiveState", { enumerable: true, get: function () { return instances_1.HeartbeatInactiveState; } });
18+
Object.defineProperty(exports, "HeartbeatingState", { enumerable: true, get: function () { return instances_1.HeartbeatingState; } });
19+
Object.defineProperty(exports, "HeartbeatCooldownState", { enumerable: true, get: function () { return instances_1.HeartbeatCooldownState; } });
20+
Object.defineProperty(exports, "HeartbeatStoppedState", { enumerable: true, get: function () { return instances_1.HeartbeatStoppedState; } });
21+
Object.defineProperty(exports, "HeartbeatFailedState", { enumerable: true, get: function () { return instances_1.HeartbeatFailedState; } });

0 commit comments

Comments
 (0)