@seamly/web-ui 20.5.0 → 20.6.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.
- package/CHANGELOG.md +769 -0
- package/build/dist/lib/index.debug.js +41 -41
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +4 -4
- package/build/dist/lib/index.js +411 -590
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/standalone.js +327 -733
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/style-guide.js +145 -68
- package/build/dist/lib/style-guide.min.js +1 -1
- package/package.json +1 -1
- package/src/javascripts/domains/store/index.js +11 -11
- package/src/javascripts/domains/translations/middleware.js +6 -5
- package/src/javascripts/style-guide/states.js +31 -1
- package/src/javascripts/ui/components/conversation/conversation.js +31 -26
- package/src/javascripts/ui/utils/seamly-utils.js +3 -0
- package/webpack/parts/dev-server.js +10 -1
- package/src/.DS_Store +0 -0
|
@@ -221,13 +221,6 @@ module.exports = __webpack_require__(2857);
|
|
|
221
221
|
|
|
222
222
|
/***/ }),
|
|
223
223
|
|
|
224
|
-
/***/ 8604:
|
|
225
|
-
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
226
|
-
|
|
227
|
-
/* unused reexport */ __webpack_require__(4477);
|
|
228
|
-
|
|
229
|
-
/***/ }),
|
|
230
|
-
|
|
231
224
|
/***/ 4310:
|
|
232
225
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
233
226
|
|
|
@@ -4799,21 +4792,6 @@ var path = __webpack_require__(4058);
|
|
|
4799
4792
|
module.exports = path.Object.getOwnPropertyDescriptors;
|
|
4800
4793
|
|
|
4801
4794
|
|
|
4802
|
-
/***/ }),
|
|
4803
|
-
|
|
4804
|
-
/***/ 3288:
|
|
4805
|
-
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
4806
|
-
|
|
4807
|
-
__webpack_require__(9816);
|
|
4808
|
-
var path = __webpack_require__(4058);
|
|
4809
|
-
|
|
4810
|
-
var Object = path.Object;
|
|
4811
|
-
|
|
4812
|
-
module.exports = function getOwnPropertyNames(it) {
|
|
4813
|
-
return Object.getOwnPropertyNames(it);
|
|
4814
|
-
};
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
4795
|
/***/ }),
|
|
4818
4796
|
|
|
4819
4797
|
/***/ 498:
|
|
@@ -10517,25 +10495,6 @@ $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
|
|
|
10517
10495
|
});
|
|
10518
10496
|
|
|
10519
10497
|
|
|
10520
|
-
/***/ }),
|
|
10521
|
-
|
|
10522
|
-
/***/ 9816:
|
|
10523
|
-
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
|
10524
|
-
|
|
10525
|
-
var $ = __webpack_require__(6887);
|
|
10526
|
-
var fails = __webpack_require__(5981);
|
|
10527
|
-
var getOwnPropertyNames = (__webpack_require__(684).f);
|
|
10528
|
-
|
|
10529
|
-
// eslint-disable-next-line es-x/no-object-getownpropertynames -- required for testing
|
|
10530
|
-
var FAILS_ON_PRIMITIVES = fails(function () { return !Object.getOwnPropertyNames(1); });
|
|
10531
|
-
|
|
10532
|
-
// `Object.getOwnPropertyNames` method
|
|
10533
|
-
// https://tc39.es/ecma262/#sec-object.getownpropertynames
|
|
10534
|
-
$({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
|
|
10535
|
-
getOwnPropertyNames: getOwnPropertyNames
|
|
10536
|
-
});
|
|
10537
|
-
|
|
10538
|
-
|
|
10539
10498
|
/***/ }),
|
|
10540
10499
|
|
|
10541
10500
|
/***/ 7144:
|
|
@@ -12316,16 +12275,6 @@ var parent = __webpack_require__(2766);
|
|
|
12316
12275
|
module.exports = parent;
|
|
12317
12276
|
|
|
12318
12277
|
|
|
12319
|
-
/***/ }),
|
|
12320
|
-
|
|
12321
|
-
/***/ 4477:
|
|
12322
|
-
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
12323
|
-
|
|
12324
|
-
var parent = __webpack_require__(3288);
|
|
12325
|
-
|
|
12326
|
-
module.exports = parent;
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
12278
|
/***/ }),
|
|
12330
12279
|
|
|
12331
12280
|
/***/ 9534:
|
|
@@ -18010,6 +17959,7 @@ function seamly_utils_objectSpread(target) { for (var i = 1; i < arguments.lengt
|
|
|
18010
17959
|
|
|
18011
17960
|
|
|
18012
17961
|
|
|
17962
|
+
|
|
18013
17963
|
const eventTypes = {
|
|
18014
17964
|
info: 'info',
|
|
18015
17965
|
message: 'message',
|
|
@@ -18346,7 +18296,10 @@ const seamlyStateReducer = (state, action) => {
|
|
|
18346
18296
|
// event optimistically.
|
|
18347
18297
|
payload: seamly_utils_objectSpread(seamly_utils_objectSpread({}, incrementUnread && {
|
|
18348
18298
|
messageStatus: payload.fromClient ? readStates.read : readStates.received
|
|
18349
|
-
}),
|
|
18299
|
+
}), {}, {
|
|
18300
|
+
// We add a randomid to use as key for mapping of Events to avoid rerendering
|
|
18301
|
+
key: randomId()
|
|
18302
|
+
}, payload)
|
|
18350
18303
|
})]
|
|
18351
18304
|
});
|
|
18352
18305
|
|
|
@@ -21992,13 +21945,13 @@ function useLocaleNativeName(locale) {
|
|
|
21992
21945
|
|
|
21993
21946
|
|
|
21994
21947
|
|
|
21995
|
-
function middleware_createMiddleware() {
|
|
21996
|
-
|
|
21997
|
-
|
|
21998
|
-
|
|
21999
|
-
|
|
22000
|
-
|
|
22001
|
-
return
|
|
21948
|
+
function middleware_createMiddleware(_ref) {
|
|
21949
|
+
let {
|
|
21950
|
+
dispatch,
|
|
21951
|
+
getState
|
|
21952
|
+
} = _ref;
|
|
21953
|
+
return next => {
|
|
21954
|
+
return action => {
|
|
22002
21955
|
var _action$history, _action$history$trans, _action$initialState, _action$initialState$, _action$event, _action$event$payload, _action$event$payload2;
|
|
22003
21956
|
|
|
22004
21957
|
const result = next(action);
|
|
@@ -22007,6 +21960,7 @@ function middleware_createMiddleware() {
|
|
|
22007
21960
|
case String(seamlyActions.SET_HISTORY):
|
|
22008
21961
|
if ((_action$history = action.history) !== null && _action$history !== void 0 && (_action$history$trans = _action$history.translation) !== null && _action$history$trans !== void 0 && _action$history$trans.enabled) {
|
|
22009
21962
|
dispatch(enable(action.history.translation.locale));
|
|
21963
|
+
dispatch(setLocale(action.history.translation.locale));
|
|
22010
21964
|
}
|
|
22011
21965
|
|
|
22012
21966
|
break;
|
|
@@ -27392,6 +27346,37 @@ const ComponentFilter = _ref => {
|
|
|
27392
27346
|
|
|
27393
27347
|
|
|
27394
27348
|
|
|
27349
|
+
const Events = () => {
|
|
27350
|
+
const events = useEvents();
|
|
27351
|
+
let prevParticipant = null;
|
|
27352
|
+
return map_default()(events).call(events, event => {
|
|
27353
|
+
const {
|
|
27354
|
+
type,
|
|
27355
|
+
payload
|
|
27356
|
+
} = event;
|
|
27357
|
+
const {
|
|
27358
|
+
participant,
|
|
27359
|
+
fromClient
|
|
27360
|
+
} = payload;
|
|
27361
|
+
let participantChanged = false;
|
|
27362
|
+
|
|
27363
|
+
if (type !== 'participant') {
|
|
27364
|
+
const currentParticipant = fromClient ? 'seamly-client-participant' : participant;
|
|
27365
|
+
|
|
27366
|
+
if (event.type !== 'info' && prevParticipant !== currentParticipant) {
|
|
27367
|
+
participantChanged = true;
|
|
27368
|
+
}
|
|
27369
|
+
|
|
27370
|
+
prevParticipant = currentParticipant;
|
|
27371
|
+
}
|
|
27372
|
+
|
|
27373
|
+
return jsxRuntime_module_e(event_event, {
|
|
27374
|
+
event: event,
|
|
27375
|
+
newParticipant: participantChanged
|
|
27376
|
+
}, event.payload.key || event.payload.id);
|
|
27377
|
+
});
|
|
27378
|
+
};
|
|
27379
|
+
|
|
27395
27380
|
const Conversation = () => {
|
|
27396
27381
|
const {
|
|
27397
27382
|
t
|
|
@@ -27413,36 +27398,6 @@ const Conversation = () => {
|
|
|
27413
27398
|
}
|
|
27414
27399
|
}, [events, isLoading, isOpen, loadedImageEventIds]);
|
|
27415
27400
|
|
|
27416
|
-
const renderEvents = () => {
|
|
27417
|
-
let prevParticipant = null;
|
|
27418
|
-
return map_default()(events).call(events, event => {
|
|
27419
|
-
const {
|
|
27420
|
-
type,
|
|
27421
|
-
payload
|
|
27422
|
-
} = event;
|
|
27423
|
-
const {
|
|
27424
|
-
participant,
|
|
27425
|
-
fromClient
|
|
27426
|
-
} = payload;
|
|
27427
|
-
let participantChanged = false;
|
|
27428
|
-
|
|
27429
|
-
if (type !== 'participant') {
|
|
27430
|
-
const currentParticipant = fromClient ? 'seamly-client-participant' : participant;
|
|
27431
|
-
|
|
27432
|
-
if (event.type !== 'info' && prevParticipant !== currentParticipant) {
|
|
27433
|
-
participantChanged = true;
|
|
27434
|
-
}
|
|
27435
|
-
|
|
27436
|
-
prevParticipant = currentParticipant;
|
|
27437
|
-
}
|
|
27438
|
-
|
|
27439
|
-
return jsxRuntime_module_e(event_event, {
|
|
27440
|
-
event: event,
|
|
27441
|
-
newParticipant: participantChanged
|
|
27442
|
-
}, event.payload.id);
|
|
27443
|
-
});
|
|
27444
|
-
};
|
|
27445
|
-
|
|
27446
27401
|
const onClickHandler = e => {
|
|
27447
27402
|
e.preventDefault();
|
|
27448
27403
|
focusSkiplinkTarget();
|
|
@@ -27462,7 +27417,7 @@ const Conversation = () => {
|
|
|
27462
27417
|
children: [jsxRuntime_module_e(privacy_disclaimer, {}), jsxRuntime_module_e("ol", {
|
|
27463
27418
|
className: css_className('conversation'),
|
|
27464
27419
|
children: [jsxRuntime_module_e(component_filter, {
|
|
27465
|
-
children:
|
|
27420
|
+
children: jsxRuntime_module_e(Events, {})
|
|
27466
27421
|
}), isLoading && jsxRuntime_module_e(loader, {})]
|
|
27467
27422
|
})]
|
|
27468
27423
|
})
|
|
@@ -30530,46 +30485,25 @@ function store(key) {
|
|
|
30530
30485
|
// EXTERNAL MODULE: ./src/javascripts/lib/debug.js
|
|
30531
30486
|
var debug = __webpack_require__(1905);
|
|
30532
30487
|
var debug_default = /*#__PURE__*/__webpack_require__.n(debug);
|
|
30533
|
-
|
|
30534
|
-
var get_own_property_names = __webpack_require__(8604);
|
|
30535
|
-
;// CONCATENATED MODULE: ./node_modules/phoenix/priv/static/phoenix.esm.js
|
|
30536
|
-
|
|
30537
|
-
|
|
30538
|
-
|
|
30539
|
-
|
|
30540
|
-
|
|
30541
|
-
|
|
30542
|
-
|
|
30543
|
-
|
|
30544
|
-
|
|
30545
|
-
|
|
30546
|
-
|
|
30547
|
-
|
|
30548
|
-
|
|
30488
|
+
;// CONCATENATED MODULE: ./node_modules/phoenix/priv/static/phoenix.mjs
|
|
30549
30489
|
// js/phoenix/utils.js
|
|
30550
|
-
var closure = value => {
|
|
30490
|
+
var closure = (value) => {
|
|
30551
30491
|
if (typeof value === "function") {
|
|
30552
30492
|
return value;
|
|
30553
30493
|
} else {
|
|
30554
|
-
let closure2 = function
|
|
30494
|
+
let closure2 = function() {
|
|
30555
30495
|
return value;
|
|
30556
30496
|
};
|
|
30557
|
-
|
|
30558
30497
|
return closure2;
|
|
30559
30498
|
}
|
|
30560
|
-
};
|
|
30561
|
-
|
|
30499
|
+
};
|
|
30562
30500
|
|
|
30501
|
+
// js/phoenix/constants.js
|
|
30563
30502
|
var globalSelf = typeof self !== "undefined" ? self : null;
|
|
30564
30503
|
var phxWindow = typeof window !== "undefined" ? window : null;
|
|
30565
|
-
var global = globalSelf || phxWindow ||
|
|
30504
|
+
var global = globalSelf || phxWindow || global;
|
|
30566
30505
|
var DEFAULT_VSN = "2.0.0";
|
|
30567
|
-
var SOCKET_STATES = {
|
|
30568
|
-
connecting: 0,
|
|
30569
|
-
open: 1,
|
|
30570
|
-
closing: 2,
|
|
30571
|
-
closed: 3
|
|
30572
|
-
};
|
|
30506
|
+
var SOCKET_STATES = { connecting: 0, open: 1, closing: 2, closed: 3 };
|
|
30573
30507
|
var DEFAULT_TIMEOUT = 1e4;
|
|
30574
30508
|
var WS_CLOSE_NORMAL = 1e3;
|
|
30575
30509
|
var CHANNEL_STATES = {
|
|
@@ -30592,35 +30526,31 @@ var TRANSPORTS = {
|
|
|
30592
30526
|
};
|
|
30593
30527
|
var XHR_STATES = {
|
|
30594
30528
|
complete: 4
|
|
30595
|
-
};
|
|
30529
|
+
};
|
|
30596
30530
|
|
|
30531
|
+
// js/phoenix/push.js
|
|
30597
30532
|
var Push = class {
|
|
30598
30533
|
constructor(channel, event, payload, timeout) {
|
|
30599
30534
|
this.channel = channel;
|
|
30600
30535
|
this.event = event;
|
|
30601
|
-
|
|
30602
|
-
this.payload = payload || function () {
|
|
30536
|
+
this.payload = payload || function() {
|
|
30603
30537
|
return {};
|
|
30604
30538
|
};
|
|
30605
|
-
|
|
30606
30539
|
this.receivedResp = null;
|
|
30607
30540
|
this.timeout = timeout;
|
|
30608
30541
|
this.timeoutTimer = null;
|
|
30609
30542
|
this.recHooks = [];
|
|
30610
30543
|
this.sent = false;
|
|
30611
30544
|
}
|
|
30612
|
-
|
|
30613
30545
|
resend(timeout) {
|
|
30614
30546
|
this.timeout = timeout;
|
|
30615
30547
|
this.reset();
|
|
30616
30548
|
this.send();
|
|
30617
30549
|
}
|
|
30618
|
-
|
|
30619
30550
|
send() {
|
|
30620
30551
|
if (this.hasReceived("timeout")) {
|
|
30621
30552
|
return;
|
|
30622
30553
|
}
|
|
30623
|
-
|
|
30624
30554
|
this.startTimeout();
|
|
30625
30555
|
this.sent = true;
|
|
30626
30556
|
this.channel.socket.push({
|
|
@@ -30631,19 +30561,13 @@ var Push = class {
|
|
|
30631
30561
|
join_ref: this.channel.joinRef()
|
|
30632
30562
|
});
|
|
30633
30563
|
}
|
|
30634
|
-
|
|
30635
30564
|
receive(status, callback) {
|
|
30636
30565
|
if (this.hasReceived(status)) {
|
|
30637
30566
|
callback(this.receivedResp.response);
|
|
30638
30567
|
}
|
|
30639
|
-
|
|
30640
|
-
this.recHooks.push({
|
|
30641
|
-
status,
|
|
30642
|
-
callback
|
|
30643
|
-
});
|
|
30568
|
+
this.recHooks.push({ status, callback });
|
|
30644
30569
|
return this;
|
|
30645
30570
|
}
|
|
30646
|
-
|
|
30647
30571
|
reset() {
|
|
30648
30572
|
this.cancelRefEvent();
|
|
30649
30573
|
this.ref = null;
|
|
@@ -30651,63 +30575,44 @@ var Push = class {
|
|
|
30651
30575
|
this.receivedResp = null;
|
|
30652
30576
|
this.sent = false;
|
|
30653
30577
|
}
|
|
30654
|
-
|
|
30655
|
-
|
|
30656
|
-
var _context, _context2;
|
|
30657
|
-
|
|
30658
|
-
let {
|
|
30659
|
-
status,
|
|
30660
|
-
response,
|
|
30661
|
-
_ref
|
|
30662
|
-
} = _ref2;
|
|
30663
|
-
|
|
30664
|
-
for_each_default()(_context = filter_default()(_context2 = this.recHooks).call(_context2, h => h.status === status)).call(_context, h => h.callback(response));
|
|
30578
|
+
matchReceive({ status, response, _ref }) {
|
|
30579
|
+
this.recHooks.filter((h) => h.status === status).forEach((h) => h.callback(response));
|
|
30665
30580
|
}
|
|
30666
|
-
|
|
30667
30581
|
cancelRefEvent() {
|
|
30668
30582
|
if (!this.refEvent) {
|
|
30669
30583
|
return;
|
|
30670
30584
|
}
|
|
30671
|
-
|
|
30672
30585
|
this.channel.off(this.refEvent);
|
|
30673
30586
|
}
|
|
30674
|
-
|
|
30675
30587
|
cancelTimeout() {
|
|
30676
30588
|
clearTimeout(this.timeoutTimer);
|
|
30677
30589
|
this.timeoutTimer = null;
|
|
30678
30590
|
}
|
|
30679
|
-
|
|
30680
30591
|
startTimeout() {
|
|
30681
30592
|
if (this.timeoutTimer) {
|
|
30682
30593
|
this.cancelTimeout();
|
|
30683
30594
|
}
|
|
30684
|
-
|
|
30685
30595
|
this.ref = this.channel.socket.makeRef();
|
|
30686
30596
|
this.refEvent = this.channel.replyEventName(this.ref);
|
|
30687
|
-
this.channel.on(this.refEvent, payload => {
|
|
30597
|
+
this.channel.on(this.refEvent, (payload) => {
|
|
30688
30598
|
this.cancelRefEvent();
|
|
30689
30599
|
this.cancelTimeout();
|
|
30690
30600
|
this.receivedResp = payload;
|
|
30691
30601
|
this.matchReceive(payload);
|
|
30692
30602
|
});
|
|
30693
|
-
this.timeoutTimer =
|
|
30603
|
+
this.timeoutTimer = setTimeout(() => {
|
|
30694
30604
|
this.trigger("timeout", {});
|
|
30695
30605
|
}, this.timeout);
|
|
30696
30606
|
}
|
|
30697
|
-
|
|
30698
30607
|
hasReceived(status) {
|
|
30699
30608
|
return this.receivedResp && this.receivedResp.status === status;
|
|
30700
30609
|
}
|
|
30701
|
-
|
|
30702
30610
|
trigger(status, response) {
|
|
30703
|
-
this.channel.trigger(this.refEvent, {
|
|
30704
|
-
status,
|
|
30705
|
-
response
|
|
30706
|
-
});
|
|
30611
|
+
this.channel.trigger(this.refEvent, { status, response });
|
|
30707
30612
|
}
|
|
30613
|
+
};
|
|
30708
30614
|
|
|
30709
|
-
|
|
30710
|
-
|
|
30615
|
+
// js/phoenix/timer.js
|
|
30711
30616
|
var Timer = class {
|
|
30712
30617
|
constructor(callback, timerCalc) {
|
|
30713
30618
|
this.callback = callback;
|
|
@@ -30715,22 +30620,20 @@ var Timer = class {
|
|
|
30715
30620
|
this.timer = null;
|
|
30716
30621
|
this.tries = 0;
|
|
30717
30622
|
}
|
|
30718
|
-
|
|
30719
30623
|
reset() {
|
|
30720
30624
|
this.tries = 0;
|
|
30721
30625
|
clearTimeout(this.timer);
|
|
30722
30626
|
}
|
|
30723
|
-
|
|
30724
30627
|
scheduleTimeout() {
|
|
30725
30628
|
clearTimeout(this.timer);
|
|
30726
|
-
this.timer =
|
|
30629
|
+
this.timer = setTimeout(() => {
|
|
30727
30630
|
this.tries = this.tries + 1;
|
|
30728
30631
|
this.callback();
|
|
30729
30632
|
}, this.timerCalc(this.tries + 1));
|
|
30730
30633
|
}
|
|
30634
|
+
};
|
|
30731
30635
|
|
|
30732
|
-
|
|
30733
|
-
|
|
30636
|
+
// js/phoenix/channel.js
|
|
30734
30637
|
var Channel = class {
|
|
30735
30638
|
constructor(topic, params, socket) {
|
|
30736
30639
|
this.state = CHANNEL_STATES.closed;
|
|
@@ -30752,54 +30655,47 @@ var Channel = class {
|
|
|
30752
30655
|
this.stateChangeRefs.push(this.socket.onError(() => this.rejoinTimer.reset()));
|
|
30753
30656
|
this.stateChangeRefs.push(this.socket.onOpen(() => {
|
|
30754
30657
|
this.rejoinTimer.reset();
|
|
30755
|
-
|
|
30756
30658
|
if (this.isErrored()) {
|
|
30757
30659
|
this.rejoin();
|
|
30758
30660
|
}
|
|
30759
30661
|
}));
|
|
30760
30662
|
this.joinPush.receive("ok", () => {
|
|
30761
|
-
var _context3;
|
|
30762
|
-
|
|
30763
30663
|
this.state = CHANNEL_STATES.joined;
|
|
30764
30664
|
this.rejoinTimer.reset();
|
|
30765
|
-
|
|
30766
|
-
for_each_default()(_context3 = this.pushBuffer).call(_context3, pushEvent => pushEvent.send());
|
|
30767
|
-
|
|
30665
|
+
this.pushBuffer.forEach((pushEvent) => pushEvent.send());
|
|
30768
30666
|
this.pushBuffer = [];
|
|
30769
30667
|
});
|
|
30770
30668
|
this.joinPush.receive("error", () => {
|
|
30771
30669
|
this.state = CHANNEL_STATES.errored;
|
|
30772
|
-
|
|
30773
30670
|
if (this.socket.isConnected()) {
|
|
30774
30671
|
this.rejoinTimer.scheduleTimeout();
|
|
30775
30672
|
}
|
|
30776
30673
|
});
|
|
30777
30674
|
this.onClose(() => {
|
|
30778
30675
|
this.rejoinTimer.reset();
|
|
30779
|
-
if (this.socket.hasLogger())
|
|
30676
|
+
if (this.socket.hasLogger())
|
|
30677
|
+
this.socket.log("channel", `close ${this.topic} ${this.joinRef()}`);
|
|
30780
30678
|
this.state = CHANNEL_STATES.closed;
|
|
30781
30679
|
this.socket.remove(this);
|
|
30782
30680
|
});
|
|
30783
|
-
this.onError(reason => {
|
|
30784
|
-
if (this.socket.hasLogger())
|
|
30785
|
-
|
|
30681
|
+
this.onError((reason) => {
|
|
30682
|
+
if (this.socket.hasLogger())
|
|
30683
|
+
this.socket.log("channel", `error ${this.topic}`, reason);
|
|
30786
30684
|
if (this.isJoining()) {
|
|
30787
30685
|
this.joinPush.reset();
|
|
30788
30686
|
}
|
|
30789
|
-
|
|
30790
30687
|
this.state = CHANNEL_STATES.errored;
|
|
30791
|
-
|
|
30792
30688
|
if (this.socket.isConnected()) {
|
|
30793
30689
|
this.rejoinTimer.scheduleTimeout();
|
|
30794
30690
|
}
|
|
30795
30691
|
});
|
|
30796
30692
|
this.joinPush.receive("timeout", () => {
|
|
30797
|
-
if (this.socket.hasLogger())
|
|
30693
|
+
if (this.socket.hasLogger())
|
|
30694
|
+
this.socket.log("channel", `timeout ${this.topic} (${this.joinRef()})`, this.joinPush.timeout);
|
|
30798
30695
|
let leavePush = new Push(this, CHANNEL_EVENTS.leave, closure({}), this.timeout);
|
|
30799
30696
|
leavePush.send();
|
|
30800
30697
|
this.state = CHANNEL_STATES.errored;
|
|
30801
30698
|
this.joinPush.reset();
|
|
30802
|
-
|
|
30803
30699
|
if (this.socket.isConnected()) {
|
|
30804
30700
|
this.rejoinTimer.scheduleTimeout();
|
|
30805
30701
|
}
|
|
@@ -30808,10 +30704,7 @@ var Channel = class {
|
|
|
30808
30704
|
this.trigger(this.replyEventName(ref), payload);
|
|
30809
30705
|
});
|
|
30810
30706
|
}
|
|
30811
|
-
|
|
30812
|
-
join() {
|
|
30813
|
-
let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.timeout;
|
|
30814
|
-
|
|
30707
|
+
join(timeout = this.timeout) {
|
|
30815
30708
|
if (this.joinedOnce) {
|
|
30816
30709
|
throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");
|
|
30817
30710
|
} else {
|
|
@@ -30821,219 +30714,162 @@ var Channel = class {
|
|
|
30821
30714
|
return this.joinPush;
|
|
30822
30715
|
}
|
|
30823
30716
|
}
|
|
30824
|
-
|
|
30825
30717
|
onClose(callback) {
|
|
30826
30718
|
this.on(CHANNEL_EVENTS.close, callback);
|
|
30827
30719
|
}
|
|
30828
|
-
|
|
30829
30720
|
onError(callback) {
|
|
30830
|
-
return this.on(CHANNEL_EVENTS.error, reason => callback(reason));
|
|
30721
|
+
return this.on(CHANNEL_EVENTS.error, (reason) => callback(reason));
|
|
30831
30722
|
}
|
|
30832
|
-
|
|
30833
30723
|
on(event, callback) {
|
|
30834
30724
|
let ref = this.bindingRef++;
|
|
30835
|
-
this.bindings.push({
|
|
30836
|
-
event,
|
|
30837
|
-
ref,
|
|
30838
|
-
callback
|
|
30839
|
-
});
|
|
30725
|
+
this.bindings.push({ event, ref, callback });
|
|
30840
30726
|
return ref;
|
|
30841
30727
|
}
|
|
30842
|
-
|
|
30843
30728
|
off(event, ref) {
|
|
30844
|
-
|
|
30845
|
-
|
|
30846
|
-
this.bindings = filter_default()(_context4 = this.bindings).call(_context4, bind => {
|
|
30729
|
+
this.bindings = this.bindings.filter((bind) => {
|
|
30847
30730
|
return !(bind.event === event && (typeof ref === "undefined" || ref === bind.ref));
|
|
30848
30731
|
});
|
|
30849
30732
|
}
|
|
30850
|
-
|
|
30851
30733
|
canPush() {
|
|
30852
30734
|
return this.socket.isConnected() && this.isJoined();
|
|
30853
30735
|
}
|
|
30854
|
-
|
|
30855
|
-
push(event, payload) {
|
|
30856
|
-
let timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.timeout;
|
|
30736
|
+
push(event, payload, timeout = this.timeout) {
|
|
30857
30737
|
payload = payload || {};
|
|
30858
|
-
|
|
30859
30738
|
if (!this.joinedOnce) {
|
|
30860
30739
|
throw new Error(`tried to push '${event}' to '${this.topic}' before joining. Use channel.join() before pushing events`);
|
|
30861
30740
|
}
|
|
30862
|
-
|
|
30863
|
-
let pushEvent = new Push(this, event, function () {
|
|
30741
|
+
let pushEvent = new Push(this, event, function() {
|
|
30864
30742
|
return payload;
|
|
30865
30743
|
}, timeout);
|
|
30866
|
-
|
|
30867
30744
|
if (this.canPush()) {
|
|
30868
30745
|
pushEvent.send();
|
|
30869
30746
|
} else {
|
|
30870
30747
|
pushEvent.startTimeout();
|
|
30871
30748
|
this.pushBuffer.push(pushEvent);
|
|
30872
30749
|
}
|
|
30873
|
-
|
|
30874
30750
|
return pushEvent;
|
|
30875
30751
|
}
|
|
30876
|
-
|
|
30877
|
-
leave() {
|
|
30878
|
-
let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.timeout;
|
|
30752
|
+
leave(timeout = this.timeout) {
|
|
30879
30753
|
this.rejoinTimer.reset();
|
|
30880
30754
|
this.joinPush.cancelTimeout();
|
|
30881
30755
|
this.state = CHANNEL_STATES.leaving;
|
|
30882
|
-
|
|
30883
30756
|
let onClose = () => {
|
|
30884
|
-
if (this.socket.hasLogger())
|
|
30757
|
+
if (this.socket.hasLogger())
|
|
30758
|
+
this.socket.log("channel", `leave ${this.topic}`);
|
|
30885
30759
|
this.trigger(CHANNEL_EVENTS.close, "leave");
|
|
30886
30760
|
};
|
|
30887
|
-
|
|
30888
30761
|
let leavePush = new Push(this, CHANNEL_EVENTS.leave, closure({}), timeout);
|
|
30889
30762
|
leavePush.receive("ok", () => onClose()).receive("timeout", () => onClose());
|
|
30890
30763
|
leavePush.send();
|
|
30891
|
-
|
|
30892
30764
|
if (!this.canPush()) {
|
|
30893
30765
|
leavePush.trigger("ok", {});
|
|
30894
30766
|
}
|
|
30895
|
-
|
|
30896
30767
|
return leavePush;
|
|
30897
30768
|
}
|
|
30898
|
-
|
|
30899
30769
|
onMessage(_event, payload, _ref) {
|
|
30900
30770
|
return payload;
|
|
30901
30771
|
}
|
|
30902
|
-
|
|
30903
30772
|
isMember(topic, event, payload, joinRef) {
|
|
30904
30773
|
if (this.topic !== topic) {
|
|
30905
30774
|
return false;
|
|
30906
30775
|
}
|
|
30907
|
-
|
|
30908
30776
|
if (joinRef && joinRef !== this.joinRef()) {
|
|
30909
|
-
if (this.socket.hasLogger())
|
|
30910
|
-
topic,
|
|
30911
|
-
event,
|
|
30912
|
-
payload,
|
|
30913
|
-
joinRef
|
|
30914
|
-
});
|
|
30777
|
+
if (this.socket.hasLogger())
|
|
30778
|
+
this.socket.log("channel", "dropping outdated message", { topic, event, payload, joinRef });
|
|
30915
30779
|
return false;
|
|
30916
30780
|
} else {
|
|
30917
30781
|
return true;
|
|
30918
30782
|
}
|
|
30919
30783
|
}
|
|
30920
|
-
|
|
30921
30784
|
joinRef() {
|
|
30922
30785
|
return this.joinPush.ref;
|
|
30923
30786
|
}
|
|
30924
|
-
|
|
30925
|
-
rejoin() {
|
|
30926
|
-
let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.timeout;
|
|
30927
|
-
|
|
30787
|
+
rejoin(timeout = this.timeout) {
|
|
30928
30788
|
if (this.isLeaving()) {
|
|
30929
30789
|
return;
|
|
30930
30790
|
}
|
|
30931
|
-
|
|
30932
30791
|
this.socket.leaveOpenTopic(this.topic);
|
|
30933
30792
|
this.state = CHANNEL_STATES.joining;
|
|
30934
30793
|
this.joinPush.resend(timeout);
|
|
30935
30794
|
}
|
|
30936
|
-
|
|
30937
30795
|
trigger(event, payload, ref, joinRef) {
|
|
30938
|
-
var _context5;
|
|
30939
|
-
|
|
30940
30796
|
let handledPayload = this.onMessage(event, payload, ref, joinRef);
|
|
30941
|
-
|
|
30942
30797
|
if (payload && !handledPayload) {
|
|
30943
30798
|
throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");
|
|
30944
30799
|
}
|
|
30945
|
-
|
|
30946
|
-
let eventBindings = filter_default()(_context5 = this.bindings).call(_context5, bind => bind.event === event);
|
|
30947
|
-
|
|
30800
|
+
let eventBindings = this.bindings.filter((bind) => bind.event === event);
|
|
30948
30801
|
for (let i = 0; i < eventBindings.length; i++) {
|
|
30949
30802
|
let bind = eventBindings[i];
|
|
30950
30803
|
bind.callback(handledPayload, ref, joinRef || this.joinRef());
|
|
30951
30804
|
}
|
|
30952
30805
|
}
|
|
30953
|
-
|
|
30954
30806
|
replyEventName(ref) {
|
|
30955
30807
|
return `chan_reply_${ref}`;
|
|
30956
30808
|
}
|
|
30957
|
-
|
|
30958
30809
|
isClosed() {
|
|
30959
30810
|
return this.state === CHANNEL_STATES.closed;
|
|
30960
30811
|
}
|
|
30961
|
-
|
|
30962
30812
|
isErrored() {
|
|
30963
30813
|
return this.state === CHANNEL_STATES.errored;
|
|
30964
30814
|
}
|
|
30965
|
-
|
|
30966
30815
|
isJoined() {
|
|
30967
30816
|
return this.state === CHANNEL_STATES.joined;
|
|
30968
30817
|
}
|
|
30969
|
-
|
|
30970
30818
|
isJoining() {
|
|
30971
30819
|
return this.state === CHANNEL_STATES.joining;
|
|
30972
30820
|
}
|
|
30973
|
-
|
|
30974
30821
|
isLeaving() {
|
|
30975
30822
|
return this.state === CHANNEL_STATES.leaving;
|
|
30976
30823
|
}
|
|
30824
|
+
};
|
|
30977
30825
|
|
|
30978
|
-
|
|
30979
|
-
|
|
30826
|
+
// js/phoenix/ajax.js
|
|
30980
30827
|
var Ajax = class {
|
|
30981
30828
|
static request(method, endPoint, accept, body, timeout, ontimeout, callback) {
|
|
30982
30829
|
if (global.XDomainRequest) {
|
|
30983
30830
|
let req = new global.XDomainRequest();
|
|
30984
|
-
this.xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback);
|
|
30831
|
+
return this.xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback);
|
|
30985
30832
|
} else {
|
|
30986
30833
|
let req = new global.XMLHttpRequest();
|
|
30987
|
-
this.xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback);
|
|
30834
|
+
return this.xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback);
|
|
30988
30835
|
}
|
|
30989
30836
|
}
|
|
30990
|
-
|
|
30991
30837
|
static xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback) {
|
|
30992
30838
|
req.timeout = timeout;
|
|
30993
30839
|
req.open(method, endPoint);
|
|
30994
|
-
|
|
30995
30840
|
req.onload = () => {
|
|
30996
30841
|
let response = this.parseJSON(req.responseText);
|
|
30997
30842
|
callback && callback(response);
|
|
30998
30843
|
};
|
|
30999
|
-
|
|
31000
30844
|
if (ontimeout) {
|
|
31001
30845
|
req.ontimeout = ontimeout;
|
|
31002
30846
|
}
|
|
31003
|
-
|
|
31004
|
-
|
|
31005
|
-
|
|
30847
|
+
req.onprogress = () => {
|
|
30848
|
+
};
|
|
31006
30849
|
req.send(body);
|
|
30850
|
+
return req;
|
|
31007
30851
|
}
|
|
31008
|
-
|
|
31009
30852
|
static xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback) {
|
|
31010
30853
|
req.open(method, endPoint, true);
|
|
31011
30854
|
req.timeout = timeout;
|
|
31012
30855
|
req.setRequestHeader("Content-Type", accept);
|
|
31013
|
-
|
|
31014
|
-
req.onerror = () => {
|
|
31015
|
-
callback && callback(null);
|
|
31016
|
-
};
|
|
31017
|
-
|
|
30856
|
+
req.onerror = () => callback && callback(null);
|
|
31018
30857
|
req.onreadystatechange = () => {
|
|
31019
30858
|
if (req.readyState === XHR_STATES.complete && callback) {
|
|
31020
30859
|
let response = this.parseJSON(req.responseText);
|
|
31021
30860
|
callback(response);
|
|
31022
30861
|
}
|
|
31023
30862
|
};
|
|
31024
|
-
|
|
31025
30863
|
if (ontimeout) {
|
|
31026
30864
|
req.ontimeout = ontimeout;
|
|
31027
30865
|
}
|
|
31028
|
-
|
|
31029
30866
|
req.send(body);
|
|
30867
|
+
return req;
|
|
31030
30868
|
}
|
|
31031
|
-
|
|
31032
30869
|
static parseJSON(resp) {
|
|
31033
30870
|
if (!resp || resp === "") {
|
|
31034
30871
|
return null;
|
|
31035
30872
|
}
|
|
31036
|
-
|
|
31037
30873
|
try {
|
|
31038
30874
|
return JSON.parse(resp);
|
|
31039
30875
|
} catch (e) {
|
|
@@ -31041,196 +30877,168 @@ var Ajax = class {
|
|
|
31041
30877
|
return null;
|
|
31042
30878
|
}
|
|
31043
30879
|
}
|
|
31044
|
-
|
|
31045
30880
|
static serialize(obj, parentKey) {
|
|
31046
30881
|
let queryStr = [];
|
|
31047
|
-
|
|
31048
30882
|
for (var key in obj) {
|
|
31049
30883
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
31050
30884
|
continue;
|
|
31051
30885
|
}
|
|
31052
|
-
|
|
31053
30886
|
let paramKey = parentKey ? `${parentKey}[${key}]` : key;
|
|
31054
30887
|
let paramVal = obj[key];
|
|
31055
|
-
|
|
31056
30888
|
if (typeof paramVal === "object") {
|
|
31057
30889
|
queryStr.push(this.serialize(paramVal, paramKey));
|
|
31058
30890
|
} else {
|
|
31059
30891
|
queryStr.push(encodeURIComponent(paramKey) + "=" + encodeURIComponent(paramVal));
|
|
31060
30892
|
}
|
|
31061
30893
|
}
|
|
31062
|
-
|
|
31063
30894
|
return queryStr.join("&");
|
|
31064
30895
|
}
|
|
31065
|
-
|
|
31066
30896
|
static appendParams(url, params) {
|
|
31067
|
-
if (
|
|
30897
|
+
if (Object.keys(params).length === 0) {
|
|
31068
30898
|
return url;
|
|
31069
30899
|
}
|
|
31070
|
-
|
|
31071
30900
|
let prefix = url.match(/\?/) ? "&" : "?";
|
|
31072
30901
|
return `${url}${prefix}${this.serialize(params)}`;
|
|
31073
30902
|
}
|
|
30903
|
+
};
|
|
31074
30904
|
|
|
31075
|
-
|
|
31076
|
-
|
|
30905
|
+
// js/phoenix/longpoll.js
|
|
31077
30906
|
var LongPoll = class {
|
|
31078
30907
|
constructor(endPoint) {
|
|
31079
30908
|
this.endPoint = null;
|
|
31080
30909
|
this.token = null;
|
|
31081
30910
|
this.skipHeartbeat = true;
|
|
31082
|
-
|
|
31083
|
-
this.onopen = function
|
|
31084
|
-
|
|
31085
|
-
this.onerror = function
|
|
31086
|
-
|
|
31087
|
-
this.onmessage = function
|
|
31088
|
-
|
|
31089
|
-
this.onclose = function
|
|
31090
|
-
|
|
30911
|
+
this.reqs = /* @__PURE__ */ new Set();
|
|
30912
|
+
this.onopen = function() {
|
|
30913
|
+
};
|
|
30914
|
+
this.onerror = function() {
|
|
30915
|
+
};
|
|
30916
|
+
this.onmessage = function() {
|
|
30917
|
+
};
|
|
30918
|
+
this.onclose = function() {
|
|
30919
|
+
};
|
|
31091
30920
|
this.pollEndpoint = this.normalizeEndpoint(endPoint);
|
|
31092
30921
|
this.readyState = SOCKET_STATES.connecting;
|
|
31093
30922
|
this.poll();
|
|
31094
30923
|
}
|
|
31095
|
-
|
|
31096
30924
|
normalizeEndpoint(endPoint) {
|
|
31097
30925
|
return endPoint.replace("ws://", "http://").replace("wss://", "https://").replace(new RegExp("(.*)/" + TRANSPORTS.websocket), "$1/" + TRANSPORTS.longpoll);
|
|
31098
30926
|
}
|
|
31099
|
-
|
|
31100
30927
|
endpointURL() {
|
|
31101
|
-
return Ajax.appendParams(this.pollEndpoint, {
|
|
31102
|
-
token: this.token
|
|
31103
|
-
});
|
|
30928
|
+
return Ajax.appendParams(this.pollEndpoint, { token: this.token });
|
|
31104
30929
|
}
|
|
31105
|
-
|
|
31106
|
-
|
|
31107
|
-
this.close();
|
|
30930
|
+
closeAndRetry(code, reason, wasClean) {
|
|
30931
|
+
this.close(code, reason, wasClean);
|
|
31108
30932
|
this.readyState = SOCKET_STATES.connecting;
|
|
31109
30933
|
}
|
|
31110
|
-
|
|
31111
30934
|
ontimeout() {
|
|
31112
30935
|
this.onerror("timeout");
|
|
31113
|
-
this.closeAndRetry();
|
|
30936
|
+
this.closeAndRetry(1005, "timeout", false);
|
|
30937
|
+
}
|
|
30938
|
+
isActive() {
|
|
30939
|
+
return this.readyState === SOCKET_STATES.open || this.readyState === SOCKET_STATES.connecting;
|
|
31114
30940
|
}
|
|
31115
|
-
|
|
31116
30941
|
poll() {
|
|
31117
|
-
|
|
31118
|
-
|
|
31119
|
-
if (!(this.readyState === SOCKET_STATES.open || this.readyState === SOCKET_STATES.connecting)) {
|
|
31120
|
-
return;
|
|
31121
|
-
}
|
|
31122
|
-
|
|
31123
|
-
Ajax.request("GET", this.endpointURL(), "application/json", null, this.timeout, bind_default()(_context6 = this.ontimeout).call(_context6, this), resp => {
|
|
30942
|
+
this.ajax("GET", null, () => this.ontimeout(), (resp) => {
|
|
31124
30943
|
if (resp) {
|
|
31125
|
-
var {
|
|
31126
|
-
status,
|
|
31127
|
-
token,
|
|
31128
|
-
messages
|
|
31129
|
-
} = resp;
|
|
30944
|
+
var { status, token, messages } = resp;
|
|
31130
30945
|
this.token = token;
|
|
31131
30946
|
} else {
|
|
31132
30947
|
status = 0;
|
|
31133
30948
|
}
|
|
31134
|
-
|
|
31135
30949
|
switch (status) {
|
|
31136
30950
|
case 200:
|
|
31137
|
-
|
|
31138
|
-
|
|
31139
|
-
this.onmessage({
|
|
31140
|
-
data: msg
|
|
31141
|
-
});
|
|
31142
|
-
}, 0);
|
|
30951
|
+
messages.forEach((msg) => {
|
|
30952
|
+
setTimeout(() => this.onmessage({ data: msg }), 0);
|
|
31143
30953
|
});
|
|
31144
|
-
|
|
31145
30954
|
this.poll();
|
|
31146
30955
|
break;
|
|
31147
|
-
|
|
31148
30956
|
case 204:
|
|
31149
30957
|
this.poll();
|
|
31150
30958
|
break;
|
|
31151
|
-
|
|
31152
30959
|
case 410:
|
|
31153
30960
|
this.readyState = SOCKET_STATES.open;
|
|
31154
|
-
this.onopen();
|
|
30961
|
+
this.onopen({});
|
|
31155
30962
|
this.poll();
|
|
31156
30963
|
break;
|
|
31157
|
-
|
|
31158
30964
|
case 403:
|
|
31159
|
-
this.onerror();
|
|
31160
|
-
this.close();
|
|
30965
|
+
this.onerror(403);
|
|
30966
|
+
this.close(1008, "forbidden", false);
|
|
31161
30967
|
break;
|
|
31162
|
-
|
|
31163
30968
|
case 0:
|
|
31164
30969
|
case 500:
|
|
31165
|
-
this.onerror();
|
|
31166
|
-
this.closeAndRetry();
|
|
30970
|
+
this.onerror(500);
|
|
30971
|
+
this.closeAndRetry(1011, "internal server error", 500);
|
|
31167
30972
|
break;
|
|
31168
|
-
|
|
31169
30973
|
default:
|
|
31170
30974
|
throw new Error(`unhandled poll status ${status}`);
|
|
31171
30975
|
}
|
|
31172
30976
|
});
|
|
31173
30977
|
}
|
|
31174
|
-
|
|
31175
30978
|
send(body) {
|
|
31176
|
-
|
|
31177
|
-
|
|
31178
|
-
Ajax.request("POST", this.endpointURL(), "application/json", body, this.timeout, bind_default()(_context7 = this.onerror).call(_context7, this, "timeout"), resp => {
|
|
30979
|
+
this.ajax("POST", body, () => this.onerror("timeout"), (resp) => {
|
|
31179
30980
|
if (!resp || resp.status !== 200) {
|
|
31180
30981
|
this.onerror(resp && resp.status);
|
|
31181
|
-
this.closeAndRetry();
|
|
30982
|
+
this.closeAndRetry(1011, "internal server error", false);
|
|
31182
30983
|
}
|
|
31183
30984
|
});
|
|
31184
30985
|
}
|
|
31185
|
-
|
|
31186
|
-
|
|
30986
|
+
close(code, reason, wasClean) {
|
|
30987
|
+
for (let req of this.reqs) {
|
|
30988
|
+
req.abort();
|
|
30989
|
+
}
|
|
31187
30990
|
this.readyState = SOCKET_STATES.closed;
|
|
31188
|
-
|
|
30991
|
+
let opts = Object.assign({ code: 1e3, reason: void 0, wasClean: true }, { code, reason, wasClean });
|
|
30992
|
+
if (typeof CloseEvent !== "undefined") {
|
|
30993
|
+
this.onclose(new CloseEvent("close", opts));
|
|
30994
|
+
} else {
|
|
30995
|
+
this.onclose(opts);
|
|
30996
|
+
}
|
|
31189
30997
|
}
|
|
30998
|
+
ajax(method, body, onCallerTimeout, callback) {
|
|
30999
|
+
let req;
|
|
31000
|
+
let ontimeout = () => {
|
|
31001
|
+
this.reqs.delete(req);
|
|
31002
|
+
onCallerTimeout();
|
|
31003
|
+
};
|
|
31004
|
+
req = Ajax.request(method, this.endpointURL(), "application/json", body, this.timeout, ontimeout, (resp) => {
|
|
31005
|
+
this.reqs.delete(req);
|
|
31006
|
+
if (this.isActive()) {
|
|
31007
|
+
callback(resp);
|
|
31008
|
+
}
|
|
31009
|
+
});
|
|
31010
|
+
this.reqs.add(req);
|
|
31011
|
+
}
|
|
31012
|
+
};
|
|
31190
31013
|
|
|
31191
|
-
|
|
31192
|
-
|
|
31014
|
+
// js/phoenix/presence.js
|
|
31193
31015
|
var Presence = class {
|
|
31194
|
-
constructor(channel) {
|
|
31195
|
-
let
|
|
31196
|
-
let events = opts.events || {
|
|
31197
|
-
state: "presence_state",
|
|
31198
|
-
diff: "presence_diff"
|
|
31199
|
-
};
|
|
31016
|
+
constructor(channel, opts = {}) {
|
|
31017
|
+
let events = opts.events || { state: "presence_state", diff: "presence_diff" };
|
|
31200
31018
|
this.state = {};
|
|
31201
31019
|
this.pendingDiffs = [];
|
|
31202
31020
|
this.channel = channel;
|
|
31203
31021
|
this.joinRef = null;
|
|
31204
31022
|
this.caller = {
|
|
31205
|
-
onJoin: function
|
|
31206
|
-
|
|
31207
|
-
|
|
31023
|
+
onJoin: function() {
|
|
31024
|
+
},
|
|
31025
|
+
onLeave: function() {
|
|
31026
|
+
},
|
|
31027
|
+
onSync: function() {
|
|
31028
|
+
}
|
|
31208
31029
|
};
|
|
31209
|
-
this.channel.on(events.state, newState => {
|
|
31210
|
-
|
|
31211
|
-
|
|
31212
|
-
let {
|
|
31213
|
-
onJoin,
|
|
31214
|
-
onLeave,
|
|
31215
|
-
onSync
|
|
31216
|
-
} = this.caller;
|
|
31030
|
+
this.channel.on(events.state, (newState) => {
|
|
31031
|
+
let { onJoin, onLeave, onSync } = this.caller;
|
|
31217
31032
|
this.joinRef = this.channel.joinRef();
|
|
31218
31033
|
this.state = Presence.syncState(this.state, newState, onJoin, onLeave);
|
|
31219
|
-
|
|
31220
|
-
_forEachInstanceProperty(_context8 = this.pendingDiffs).call(_context8, diff => {
|
|
31034
|
+
this.pendingDiffs.forEach((diff) => {
|
|
31221
31035
|
this.state = Presence.syncDiff(this.state, diff, onJoin, onLeave);
|
|
31222
31036
|
});
|
|
31223
|
-
|
|
31224
31037
|
this.pendingDiffs = [];
|
|
31225
31038
|
onSync();
|
|
31226
31039
|
});
|
|
31227
|
-
this.channel.on(events.diff, diff => {
|
|
31228
|
-
let {
|
|
31229
|
-
onJoin,
|
|
31230
|
-
onLeave,
|
|
31231
|
-
onSync
|
|
31232
|
-
} = this.caller;
|
|
31233
|
-
|
|
31040
|
+
this.channel.on(events.diff, (diff) => {
|
|
31041
|
+
let { onJoin, onLeave, onSync } = this.caller;
|
|
31234
31042
|
if (this.inPendingSyncState()) {
|
|
31235
31043
|
this.pendingDiffs.push(diff);
|
|
31236
31044
|
} else {
|
|
@@ -31239,59 +31047,41 @@ var Presence = class {
|
|
|
31239
31047
|
}
|
|
31240
31048
|
});
|
|
31241
31049
|
}
|
|
31242
|
-
|
|
31243
31050
|
onJoin(callback) {
|
|
31244
31051
|
this.caller.onJoin = callback;
|
|
31245
31052
|
}
|
|
31246
|
-
|
|
31247
31053
|
onLeave(callback) {
|
|
31248
31054
|
this.caller.onLeave = callback;
|
|
31249
31055
|
}
|
|
31250
|
-
|
|
31251
31056
|
onSync(callback) {
|
|
31252
31057
|
this.caller.onSync = callback;
|
|
31253
31058
|
}
|
|
31254
|
-
|
|
31255
31059
|
list(by) {
|
|
31256
31060
|
return Presence.list(this.state, by);
|
|
31257
31061
|
}
|
|
31258
|
-
|
|
31259
31062
|
inPendingSyncState() {
|
|
31260
31063
|
return !this.joinRef || this.joinRef !== this.channel.joinRef();
|
|
31261
31064
|
}
|
|
31262
|
-
|
|
31263
31065
|
static syncState(currentState, newState, onJoin, onLeave) {
|
|
31264
|
-
var _context9, _context10;
|
|
31265
|
-
|
|
31266
31066
|
let state = this.clone(currentState);
|
|
31267
31067
|
let joins = {};
|
|
31268
31068
|
let leaves = {};
|
|
31269
|
-
|
|
31270
|
-
_mapInstanceProperty(_context9 = this).call(_context9, state, (key, presence) => {
|
|
31069
|
+
this.map(state, (key, presence) => {
|
|
31271
31070
|
if (!newState[key]) {
|
|
31272
31071
|
leaves[key] = presence;
|
|
31273
31072
|
}
|
|
31274
31073
|
});
|
|
31275
|
-
|
|
31276
|
-
_mapInstanceProperty(_context10 = this).call(_context10, newState, (key, newPresence) => {
|
|
31074
|
+
this.map(newState, (key, newPresence) => {
|
|
31277
31075
|
let currentPresence = state[key];
|
|
31278
|
-
|
|
31279
31076
|
if (currentPresence) {
|
|
31280
|
-
|
|
31281
|
-
|
|
31282
|
-
let
|
|
31283
|
-
|
|
31284
|
-
let curRefs = _mapInstanceProperty(_context12 = currentPresence.metas).call(_context12, m => m.phx_ref);
|
|
31285
|
-
|
|
31286
|
-
let joinedMetas = _filterInstanceProperty(_context13 = newPresence.metas).call(_context13, m => _indexOfInstanceProperty(curRefs).call(curRefs, m.phx_ref) < 0);
|
|
31287
|
-
|
|
31288
|
-
let leftMetas = _filterInstanceProperty(_context14 = currentPresence.metas).call(_context14, m => _indexOfInstanceProperty(newRefs).call(newRefs, m.phx_ref) < 0);
|
|
31289
|
-
|
|
31077
|
+
let newRefs = newPresence.metas.map((m) => m.phx_ref);
|
|
31078
|
+
let curRefs = currentPresence.metas.map((m) => m.phx_ref);
|
|
31079
|
+
let joinedMetas = newPresence.metas.filter((m) => curRefs.indexOf(m.phx_ref) < 0);
|
|
31080
|
+
let leftMetas = currentPresence.metas.filter((m) => newRefs.indexOf(m.phx_ref) < 0);
|
|
31290
31081
|
if (joinedMetas.length > 0) {
|
|
31291
31082
|
joins[key] = newPresence;
|
|
31292
31083
|
joins[key].metas = joinedMetas;
|
|
31293
31084
|
}
|
|
31294
|
-
|
|
31295
31085
|
if (leftMetas.length > 0) {
|
|
31296
31086
|
leaves[key] = this.clone(currentPresence);
|
|
31297
31087
|
leaves[key].metas = leftMetas;
|
|
@@ -31300,137 +31090,85 @@ var Presence = class {
|
|
|
31300
31090
|
joins[key] = newPresence;
|
|
31301
31091
|
}
|
|
31302
31092
|
});
|
|
31303
|
-
|
|
31304
|
-
return this.syncDiff(state, {
|
|
31305
|
-
joins,
|
|
31306
|
-
leaves
|
|
31307
|
-
}, onJoin, onLeave);
|
|
31093
|
+
return this.syncDiff(state, { joins, leaves }, onJoin, onLeave);
|
|
31308
31094
|
}
|
|
31309
|
-
|
|
31310
31095
|
static syncDiff(state, diff, onJoin, onLeave) {
|
|
31311
|
-
|
|
31312
|
-
|
|
31313
|
-
let {
|
|
31314
|
-
joins,
|
|
31315
|
-
leaves
|
|
31316
|
-
} = this.clone(diff);
|
|
31317
|
-
|
|
31096
|
+
let { joins, leaves } = this.clone(diff);
|
|
31318
31097
|
if (!onJoin) {
|
|
31319
|
-
onJoin = function
|
|
31098
|
+
onJoin = function() {
|
|
31099
|
+
};
|
|
31320
31100
|
}
|
|
31321
|
-
|
|
31322
31101
|
if (!onLeave) {
|
|
31323
|
-
onLeave = function
|
|
31102
|
+
onLeave = function() {
|
|
31103
|
+
};
|
|
31324
31104
|
}
|
|
31325
|
-
|
|
31326
|
-
_mapInstanceProperty(_context15 = this).call(_context15, joins, (key, newPresence) => {
|
|
31105
|
+
this.map(joins, (key, newPresence) => {
|
|
31327
31106
|
let currentPresence = state[key];
|
|
31328
31107
|
state[key] = this.clone(newPresence);
|
|
31329
|
-
|
|
31330
31108
|
if (currentPresence) {
|
|
31331
|
-
|
|
31332
|
-
|
|
31333
|
-
let joinedRefs = _mapInstanceProperty(_context16 = state[key].metas).call(_context16, m => m.phx_ref);
|
|
31334
|
-
|
|
31335
|
-
let curMetas = _filterInstanceProperty(_context17 = currentPresence.metas).call(_context17, m => _indexOfInstanceProperty(joinedRefs).call(joinedRefs, m.phx_ref) < 0);
|
|
31336
|
-
|
|
31109
|
+
let joinedRefs = state[key].metas.map((m) => m.phx_ref);
|
|
31110
|
+
let curMetas = currentPresence.metas.filter((m) => joinedRefs.indexOf(m.phx_ref) < 0);
|
|
31337
31111
|
state[key].metas.unshift(...curMetas);
|
|
31338
31112
|
}
|
|
31339
|
-
|
|
31340
31113
|
onJoin(key, currentPresence, newPresence);
|
|
31341
31114
|
});
|
|
31342
|
-
|
|
31343
|
-
_mapInstanceProperty(_context18 = this).call(_context18, leaves, (key, leftPresence) => {
|
|
31344
|
-
var _context19, _context20;
|
|
31345
|
-
|
|
31115
|
+
this.map(leaves, (key, leftPresence) => {
|
|
31346
31116
|
let currentPresence = state[key];
|
|
31347
|
-
|
|
31348
31117
|
if (!currentPresence) {
|
|
31349
31118
|
return;
|
|
31350
31119
|
}
|
|
31351
|
-
|
|
31352
|
-
|
|
31353
|
-
|
|
31354
|
-
currentPresence.metas = _filterInstanceProperty(_context20 = currentPresence.metas).call(_context20, p => {
|
|
31355
|
-
return _indexOfInstanceProperty(refsToRemove).call(refsToRemove, p.phx_ref) < 0;
|
|
31120
|
+
let refsToRemove = leftPresence.metas.map((m) => m.phx_ref);
|
|
31121
|
+
currentPresence.metas = currentPresence.metas.filter((p) => {
|
|
31122
|
+
return refsToRemove.indexOf(p.phx_ref) < 0;
|
|
31356
31123
|
});
|
|
31357
31124
|
onLeave(key, currentPresence, leftPresence);
|
|
31358
|
-
|
|
31359
31125
|
if (currentPresence.metas.length === 0) {
|
|
31360
31126
|
delete state[key];
|
|
31361
31127
|
}
|
|
31362
31128
|
});
|
|
31363
|
-
|
|
31364
31129
|
return state;
|
|
31365
31130
|
}
|
|
31366
|
-
|
|
31367
31131
|
static list(presences, chooser) {
|
|
31368
|
-
var _context21;
|
|
31369
|
-
|
|
31370
31132
|
if (!chooser) {
|
|
31371
|
-
chooser = function
|
|
31133
|
+
chooser = function(key, pres) {
|
|
31372
31134
|
return pres;
|
|
31373
31135
|
};
|
|
31374
31136
|
}
|
|
31375
|
-
|
|
31376
|
-
return _mapInstanceProperty(_context21 = this).call(_context21, presences, (key, presence) => {
|
|
31137
|
+
return this.map(presences, (key, presence) => {
|
|
31377
31138
|
return chooser(key, presence);
|
|
31378
31139
|
});
|
|
31379
31140
|
}
|
|
31380
|
-
|
|
31381
31141
|
static map(obj, func) {
|
|
31382
|
-
|
|
31383
|
-
|
|
31384
|
-
return _mapInstanceProperty(_context22 = _Object$getOwnPropertyNames(obj)).call(_context22, key => func(key, obj[key]));
|
|
31142
|
+
return Object.getOwnPropertyNames(obj).map((key) => func(key, obj[key]));
|
|
31385
31143
|
}
|
|
31386
|
-
|
|
31387
31144
|
static clone(obj) {
|
|
31388
|
-
return JSON.parse(
|
|
31145
|
+
return JSON.parse(JSON.stringify(obj));
|
|
31389
31146
|
}
|
|
31147
|
+
};
|
|
31390
31148
|
|
|
31391
|
-
|
|
31392
|
-
|
|
31149
|
+
// js/phoenix/serializer.js
|
|
31393
31150
|
var serializer_default = {
|
|
31394
31151
|
HEADER_LENGTH: 1,
|
|
31395
31152
|
META_LENGTH: 4,
|
|
31396
|
-
KINDS: {
|
|
31397
|
-
push: 0,
|
|
31398
|
-
reply: 1,
|
|
31399
|
-
broadcast: 2
|
|
31400
|
-
},
|
|
31401
|
-
|
|
31153
|
+
KINDS: { push: 0, reply: 1, broadcast: 2 },
|
|
31402
31154
|
encode(msg, callback) {
|
|
31403
31155
|
if (msg.payload.constructor === ArrayBuffer) {
|
|
31404
31156
|
return callback(this.binaryEncode(msg));
|
|
31405
31157
|
} else {
|
|
31406
31158
|
let payload = [msg.join_ref, msg.ref, msg.topic, msg.event, msg.payload];
|
|
31407
|
-
return callback(
|
|
31159
|
+
return callback(JSON.stringify(payload));
|
|
31408
31160
|
}
|
|
31409
31161
|
},
|
|
31410
|
-
|
|
31411
31162
|
decode(rawPayload, callback) {
|
|
31412
31163
|
if (rawPayload.constructor === ArrayBuffer) {
|
|
31413
31164
|
return callback(this.binaryDecode(rawPayload));
|
|
31414
31165
|
} else {
|
|
31415
31166
|
let [join_ref, ref, topic, event, payload] = JSON.parse(rawPayload);
|
|
31416
|
-
return callback({
|
|
31417
|
-
join_ref,
|
|
31418
|
-
ref,
|
|
31419
|
-
topic,
|
|
31420
|
-
event,
|
|
31421
|
-
payload
|
|
31422
|
-
});
|
|
31167
|
+
return callback({ join_ref, ref, topic, event, payload });
|
|
31423
31168
|
}
|
|
31424
31169
|
},
|
|
31425
|
-
|
|
31426
31170
|
binaryEncode(message) {
|
|
31427
|
-
let {
|
|
31428
|
-
join_ref,
|
|
31429
|
-
ref,
|
|
31430
|
-
event,
|
|
31431
|
-
topic,
|
|
31432
|
-
payload
|
|
31433
|
-
} = message;
|
|
31171
|
+
let { join_ref, ref, event, topic, payload } = message;
|
|
31434
31172
|
let metaLength = this.META_LENGTH + join_ref.length + ref.length + topic.length + event.length;
|
|
31435
31173
|
let header = new ArrayBuffer(this.HEADER_LENGTH + metaLength);
|
|
31436
31174
|
let view = new DataView(header);
|
|
@@ -31440,136 +31178,88 @@ var serializer_default = {
|
|
|
31440
31178
|
view.setUint8(offset++, ref.length);
|
|
31441
31179
|
view.setUint8(offset++, topic.length);
|
|
31442
31180
|
view.setUint8(offset++, event.length);
|
|
31443
|
-
|
|
31444
|
-
|
|
31445
|
-
|
|
31446
|
-
|
|
31447
|
-
|
|
31448
|
-
from_default()(topic, char => view.setUint8(offset++, char.charCodeAt(0)));
|
|
31449
|
-
|
|
31450
|
-
from_default()(event, char => view.setUint8(offset++, char.charCodeAt(0)));
|
|
31451
|
-
|
|
31181
|
+
Array.from(join_ref, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
31182
|
+
Array.from(ref, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
31183
|
+
Array.from(topic, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
31184
|
+
Array.from(event, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
31452
31185
|
var combined = new Uint8Array(header.byteLength + payload.byteLength);
|
|
31453
31186
|
combined.set(new Uint8Array(header), 0);
|
|
31454
31187
|
combined.set(new Uint8Array(payload), header.byteLength);
|
|
31455
31188
|
return combined.buffer;
|
|
31456
31189
|
},
|
|
31457
|
-
|
|
31458
31190
|
binaryDecode(buffer) {
|
|
31459
31191
|
let view = new DataView(buffer);
|
|
31460
31192
|
let kind = view.getUint8(0);
|
|
31461
31193
|
let decoder = new TextDecoder();
|
|
31462
|
-
|
|
31463
31194
|
switch (kind) {
|
|
31464
31195
|
case this.KINDS.push:
|
|
31465
31196
|
return this.decodePush(buffer, view, decoder);
|
|
31466
|
-
|
|
31467
31197
|
case this.KINDS.reply:
|
|
31468
31198
|
return this.decodeReply(buffer, view, decoder);
|
|
31469
|
-
|
|
31470
31199
|
case this.KINDS.broadcast:
|
|
31471
31200
|
return this.decodeBroadcast(buffer, view, decoder);
|
|
31472
31201
|
}
|
|
31473
31202
|
},
|
|
31474
|
-
|
|
31475
31203
|
decodePush(buffer, view, decoder) {
|
|
31476
31204
|
let joinRefSize = view.getUint8(1);
|
|
31477
31205
|
let topicSize = view.getUint8(2);
|
|
31478
31206
|
let eventSize = view.getUint8(3);
|
|
31479
31207
|
let offset = this.HEADER_LENGTH + this.META_LENGTH - 1;
|
|
31480
|
-
let joinRef = decoder.decode(
|
|
31208
|
+
let joinRef = decoder.decode(buffer.slice(offset, offset + joinRefSize));
|
|
31481
31209
|
offset = offset + joinRefSize;
|
|
31482
|
-
let topic = decoder.decode(
|
|
31210
|
+
let topic = decoder.decode(buffer.slice(offset, offset + topicSize));
|
|
31483
31211
|
offset = offset + topicSize;
|
|
31484
|
-
let event = decoder.decode(
|
|
31212
|
+
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
31485
31213
|
offset = offset + eventSize;
|
|
31486
|
-
|
|
31487
|
-
|
|
31488
|
-
|
|
31489
|
-
return {
|
|
31490
|
-
join_ref: joinRef,
|
|
31491
|
-
ref: null,
|
|
31492
|
-
topic,
|
|
31493
|
-
event,
|
|
31494
|
-
payload: data
|
|
31495
|
-
};
|
|
31214
|
+
let data = buffer.slice(offset, buffer.byteLength);
|
|
31215
|
+
return { join_ref: joinRef, ref: null, topic, event, payload: data };
|
|
31496
31216
|
},
|
|
31497
|
-
|
|
31498
31217
|
decodeReply(buffer, view, decoder) {
|
|
31499
31218
|
let joinRefSize = view.getUint8(1);
|
|
31500
31219
|
let refSize = view.getUint8(2);
|
|
31501
31220
|
let topicSize = view.getUint8(3);
|
|
31502
31221
|
let eventSize = view.getUint8(4);
|
|
31503
31222
|
let offset = this.HEADER_LENGTH + this.META_LENGTH;
|
|
31504
|
-
let joinRef = decoder.decode(
|
|
31223
|
+
let joinRef = decoder.decode(buffer.slice(offset, offset + joinRefSize));
|
|
31505
31224
|
offset = offset + joinRefSize;
|
|
31506
|
-
let ref = decoder.decode(
|
|
31225
|
+
let ref = decoder.decode(buffer.slice(offset, offset + refSize));
|
|
31507
31226
|
offset = offset + refSize;
|
|
31508
|
-
let topic = decoder.decode(
|
|
31227
|
+
let topic = decoder.decode(buffer.slice(offset, offset + topicSize));
|
|
31509
31228
|
offset = offset + topicSize;
|
|
31510
|
-
let event = decoder.decode(
|
|
31229
|
+
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
31511
31230
|
offset = offset + eventSize;
|
|
31512
|
-
|
|
31513
|
-
let
|
|
31514
|
-
|
|
31515
|
-
let payload = {
|
|
31516
|
-
status: event,
|
|
31517
|
-
response: data
|
|
31518
|
-
};
|
|
31519
|
-
return {
|
|
31520
|
-
join_ref: joinRef,
|
|
31521
|
-
ref,
|
|
31522
|
-
topic,
|
|
31523
|
-
event: CHANNEL_EVENTS.reply,
|
|
31524
|
-
payload
|
|
31525
|
-
};
|
|
31231
|
+
let data = buffer.slice(offset, buffer.byteLength);
|
|
31232
|
+
let payload = { status: event, response: data };
|
|
31233
|
+
return { join_ref: joinRef, ref, topic, event: CHANNEL_EVENTS.reply, payload };
|
|
31526
31234
|
},
|
|
31527
|
-
|
|
31528
31235
|
decodeBroadcast(buffer, view, decoder) {
|
|
31529
31236
|
let topicSize = view.getUint8(1);
|
|
31530
31237
|
let eventSize = view.getUint8(2);
|
|
31531
31238
|
let offset = this.HEADER_LENGTH + 2;
|
|
31532
|
-
let topic = decoder.decode(
|
|
31239
|
+
let topic = decoder.decode(buffer.slice(offset, offset + topicSize));
|
|
31533
31240
|
offset = offset + topicSize;
|
|
31534
|
-
let event = decoder.decode(
|
|
31241
|
+
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
31535
31242
|
offset = offset + eventSize;
|
|
31536
|
-
|
|
31537
|
-
|
|
31538
|
-
|
|
31539
|
-
return {
|
|
31540
|
-
join_ref: null,
|
|
31541
|
-
ref: null,
|
|
31542
|
-
topic,
|
|
31543
|
-
event,
|
|
31544
|
-
payload: data
|
|
31545
|
-
};
|
|
31243
|
+
let data = buffer.slice(offset, buffer.byteLength);
|
|
31244
|
+
return { join_ref: null, ref: null, topic, event, payload: data };
|
|
31546
31245
|
}
|
|
31246
|
+
};
|
|
31547
31247
|
|
|
31548
|
-
|
|
31549
|
-
|
|
31248
|
+
// js/phoenix/socket.js
|
|
31550
31249
|
var Socket = class {
|
|
31551
|
-
constructor(endPoint) {
|
|
31552
|
-
|
|
31553
|
-
|
|
31554
|
-
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
31555
|
-
this.stateChangeCallbacks = {
|
|
31556
|
-
open: [],
|
|
31557
|
-
close: [],
|
|
31558
|
-
error: [],
|
|
31559
|
-
message: []
|
|
31560
|
-
};
|
|
31250
|
+
constructor(endPoint, opts = {}) {
|
|
31251
|
+
this.stateChangeCallbacks = { open: [], close: [], error: [], message: [] };
|
|
31561
31252
|
this.channels = [];
|
|
31562
31253
|
this.sendBuffer = [];
|
|
31563
31254
|
this.ref = 0;
|
|
31564
31255
|
this.timeout = opts.timeout || DEFAULT_TIMEOUT;
|
|
31565
31256
|
this.transport = opts.transport || global.WebSocket || LongPoll;
|
|
31566
31257
|
this.establishedConnections = 0;
|
|
31567
|
-
this.defaultEncoder =
|
|
31568
|
-
this.defaultDecoder =
|
|
31258
|
+
this.defaultEncoder = serializer_default.encode.bind(serializer_default);
|
|
31259
|
+
this.defaultDecoder = serializer_default.decode.bind(serializer_default);
|
|
31569
31260
|
this.closeWasClean = false;
|
|
31570
31261
|
this.binaryType = opts.binaryType || "arraybuffer";
|
|
31571
31262
|
this.connectClock = 1;
|
|
31572
|
-
|
|
31573
31263
|
if (this.transport !== LongPoll) {
|
|
31574
31264
|
this.encode = opts.encode || this.defaultEncoder;
|
|
31575
31265
|
this.decode = opts.decode || this.defaultDecoder;
|
|
@@ -31577,42 +31267,36 @@ var Socket = class {
|
|
|
31577
31267
|
this.encode = this.defaultEncoder;
|
|
31578
31268
|
this.decode = this.defaultDecoder;
|
|
31579
31269
|
}
|
|
31580
|
-
|
|
31581
31270
|
let awaitingConnectionOnPageShow = null;
|
|
31582
|
-
|
|
31583
31271
|
if (phxWindow && phxWindow.addEventListener) {
|
|
31584
|
-
phxWindow.addEventListener("pagehide", _e => {
|
|
31272
|
+
phxWindow.addEventListener("pagehide", (_e) => {
|
|
31585
31273
|
if (this.conn) {
|
|
31586
31274
|
this.disconnect();
|
|
31587
31275
|
awaitingConnectionOnPageShow = this.connectClock;
|
|
31588
31276
|
}
|
|
31589
31277
|
});
|
|
31590
|
-
phxWindow.addEventListener("pageshow", _e => {
|
|
31278
|
+
phxWindow.addEventListener("pageshow", (_e) => {
|
|
31591
31279
|
if (awaitingConnectionOnPageShow === this.connectClock) {
|
|
31592
31280
|
awaitingConnectionOnPageShow = null;
|
|
31593
31281
|
this.connect();
|
|
31594
31282
|
}
|
|
31595
31283
|
});
|
|
31596
31284
|
}
|
|
31597
|
-
|
|
31598
31285
|
this.heartbeatIntervalMs = opts.heartbeatIntervalMs || 3e4;
|
|
31599
|
-
|
|
31600
|
-
this.rejoinAfterMs = tries => {
|
|
31286
|
+
this.rejoinAfterMs = (tries) => {
|
|
31601
31287
|
if (opts.rejoinAfterMs) {
|
|
31602
31288
|
return opts.rejoinAfterMs(tries);
|
|
31603
31289
|
} else {
|
|
31604
31290
|
return [1e3, 2e3, 5e3][tries - 1] || 1e4;
|
|
31605
31291
|
}
|
|
31606
31292
|
};
|
|
31607
|
-
|
|
31608
|
-
this.reconnectAfterMs = tries => {
|
|
31293
|
+
this.reconnectAfterMs = (tries) => {
|
|
31609
31294
|
if (opts.reconnectAfterMs) {
|
|
31610
31295
|
return opts.reconnectAfterMs(tries);
|
|
31611
31296
|
} else {
|
|
31612
31297
|
return [10, 50, 100, 150, 200, 250, 500, 1e3, 2e3][tries - 1] || 5e3;
|
|
31613
31298
|
}
|
|
31614
31299
|
};
|
|
31615
|
-
|
|
31616
31300
|
this.logger = opts.logger || null;
|
|
31617
31301
|
this.longpollerTimeout = opts.longpollerTimeout || 2e4;
|
|
31618
31302
|
this.params = closure(opts.params || {});
|
|
@@ -31624,141 +31308,129 @@ var Socket = class {
|
|
|
31624
31308
|
this.teardown(() => this.connect());
|
|
31625
31309
|
}, this.reconnectAfterMs);
|
|
31626
31310
|
}
|
|
31627
|
-
|
|
31311
|
+
getLongPollTransport() {
|
|
31312
|
+
return LongPoll;
|
|
31313
|
+
}
|
|
31628
31314
|
replaceTransport(newTransport) {
|
|
31629
|
-
this.
|
|
31315
|
+
this.connectClock++;
|
|
31316
|
+
this.closeWasClean = true;
|
|
31317
|
+
this.reconnectTimer.reset();
|
|
31318
|
+
this.sendBuffer = [];
|
|
31319
|
+
if (this.conn) {
|
|
31320
|
+
this.conn.close();
|
|
31321
|
+
this.conn = null;
|
|
31322
|
+
}
|
|
31630
31323
|
this.transport = newTransport;
|
|
31631
31324
|
}
|
|
31632
|
-
|
|
31633
31325
|
protocol() {
|
|
31634
31326
|
return location.protocol.match(/^https/) ? "wss" : "ws";
|
|
31635
31327
|
}
|
|
31636
|
-
|
|
31637
31328
|
endPointURL() {
|
|
31638
|
-
let uri = Ajax.appendParams(Ajax.appendParams(this.endPoint, this.params()), {
|
|
31639
|
-
vsn: this.vsn
|
|
31640
|
-
});
|
|
31641
|
-
|
|
31329
|
+
let uri = Ajax.appendParams(Ajax.appendParams(this.endPoint, this.params()), { vsn: this.vsn });
|
|
31642
31330
|
if (uri.charAt(0) !== "/") {
|
|
31643
31331
|
return uri;
|
|
31644
31332
|
}
|
|
31645
|
-
|
|
31646
31333
|
if (uri.charAt(1) === "/") {
|
|
31647
31334
|
return `${this.protocol()}:${uri}`;
|
|
31648
31335
|
}
|
|
31649
|
-
|
|
31650
31336
|
return `${this.protocol()}://${location.host}${uri}`;
|
|
31651
31337
|
}
|
|
31652
|
-
|
|
31653
31338
|
disconnect(callback, code, reason) {
|
|
31654
31339
|
this.connectClock++;
|
|
31655
31340
|
this.closeWasClean = true;
|
|
31656
31341
|
this.reconnectTimer.reset();
|
|
31657
31342
|
this.teardown(callback, code, reason);
|
|
31658
31343
|
}
|
|
31659
|
-
|
|
31660
31344
|
connect(params) {
|
|
31661
|
-
this.connectClock++;
|
|
31662
|
-
|
|
31663
31345
|
if (params) {
|
|
31664
31346
|
console && console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor");
|
|
31665
31347
|
this.params = closure(params);
|
|
31666
31348
|
}
|
|
31667
|
-
|
|
31668
31349
|
if (this.conn) {
|
|
31669
31350
|
return;
|
|
31670
31351
|
}
|
|
31671
|
-
|
|
31352
|
+
this.connectClock++;
|
|
31672
31353
|
this.closeWasClean = false;
|
|
31673
31354
|
this.conn = new this.transport(this.endPointURL());
|
|
31674
31355
|
this.conn.binaryType = this.binaryType;
|
|
31675
31356
|
this.conn.timeout = this.longpollerTimeout;
|
|
31676
|
-
|
|
31677
31357
|
this.conn.onopen = () => this.onConnOpen();
|
|
31678
|
-
|
|
31679
|
-
this.conn.
|
|
31680
|
-
|
|
31681
|
-
this.conn.onmessage = event => this.onConnMessage(event);
|
|
31682
|
-
|
|
31683
|
-
this.conn.onclose = event => this.onConnClose(event);
|
|
31358
|
+
this.conn.onerror = (error) => this.onConnError(error);
|
|
31359
|
+
this.conn.onmessage = (event) => this.onConnMessage(event);
|
|
31360
|
+
this.conn.onclose = (event) => this.onConnClose(event);
|
|
31684
31361
|
}
|
|
31685
|
-
|
|
31686
31362
|
log(kind, msg, data) {
|
|
31687
31363
|
this.logger(kind, msg, data);
|
|
31688
31364
|
}
|
|
31689
|
-
|
|
31690
31365
|
hasLogger() {
|
|
31691
31366
|
return this.logger !== null;
|
|
31692
31367
|
}
|
|
31693
|
-
|
|
31694
31368
|
onOpen(callback) {
|
|
31695
31369
|
let ref = this.makeRef();
|
|
31696
31370
|
this.stateChangeCallbacks.open.push([ref, callback]);
|
|
31697
31371
|
return ref;
|
|
31698
31372
|
}
|
|
31699
|
-
|
|
31700
31373
|
onClose(callback) {
|
|
31701
31374
|
let ref = this.makeRef();
|
|
31702
31375
|
this.stateChangeCallbacks.close.push([ref, callback]);
|
|
31703
31376
|
return ref;
|
|
31704
31377
|
}
|
|
31705
|
-
|
|
31706
31378
|
onError(callback) {
|
|
31707
31379
|
let ref = this.makeRef();
|
|
31708
31380
|
this.stateChangeCallbacks.error.push([ref, callback]);
|
|
31709
31381
|
return ref;
|
|
31710
31382
|
}
|
|
31711
|
-
|
|
31712
31383
|
onMessage(callback) {
|
|
31713
31384
|
let ref = this.makeRef();
|
|
31714
31385
|
this.stateChangeCallbacks.message.push([ref, callback]);
|
|
31715
31386
|
return ref;
|
|
31716
31387
|
}
|
|
31717
|
-
|
|
31388
|
+
ping(callback) {
|
|
31389
|
+
if (!this.isConnected()) {
|
|
31390
|
+
return false;
|
|
31391
|
+
}
|
|
31392
|
+
let ref = this.makeRef();
|
|
31393
|
+
let startTime = Date.now();
|
|
31394
|
+
this.push({ topic: "phoenix", event: "heartbeat", payload: {}, ref });
|
|
31395
|
+
let onMsgRef = this.onMessage((msg) => {
|
|
31396
|
+
if (msg.ref === ref) {
|
|
31397
|
+
this.off([onMsgRef]);
|
|
31398
|
+
callback(Date.now() - startTime);
|
|
31399
|
+
}
|
|
31400
|
+
});
|
|
31401
|
+
return true;
|
|
31402
|
+
}
|
|
31718
31403
|
onConnOpen() {
|
|
31719
|
-
|
|
31720
|
-
|
|
31721
|
-
if (this.hasLogger()) this.log("transport", `connected to ${this.endPointURL()}`);
|
|
31404
|
+
if (this.hasLogger())
|
|
31405
|
+
this.log("transport", `connected to ${this.endPointURL()}`);
|
|
31722
31406
|
this.closeWasClean = false;
|
|
31723
31407
|
this.establishedConnections++;
|
|
31724
31408
|
this.flushSendBuffer();
|
|
31725
31409
|
this.reconnectTimer.reset();
|
|
31726
31410
|
this.resetHeartbeat();
|
|
31727
|
-
|
|
31728
|
-
for_each_default()(_context25 = this.stateChangeCallbacks.open).call(_context25, _ref3 => {
|
|
31729
|
-
let [, callback] = _ref3;
|
|
31730
|
-
return callback();
|
|
31731
|
-
});
|
|
31411
|
+
this.stateChangeCallbacks.open.forEach(([, callback]) => callback());
|
|
31732
31412
|
}
|
|
31733
|
-
|
|
31734
31413
|
heartbeatTimeout() {
|
|
31735
31414
|
if (this.pendingHeartbeatRef) {
|
|
31736
31415
|
this.pendingHeartbeatRef = null;
|
|
31737
|
-
|
|
31738
31416
|
if (this.hasLogger()) {
|
|
31739
31417
|
this.log("transport", "heartbeat timeout. Attempting to re-establish connection");
|
|
31740
31418
|
}
|
|
31741
|
-
|
|
31742
31419
|
this.abnormalClose("heartbeat timeout");
|
|
31743
31420
|
}
|
|
31744
31421
|
}
|
|
31745
|
-
|
|
31746
31422
|
resetHeartbeat() {
|
|
31747
31423
|
if (this.conn && this.conn.skipHeartbeat) {
|
|
31748
31424
|
return;
|
|
31749
31425
|
}
|
|
31750
|
-
|
|
31751
31426
|
this.pendingHeartbeatRef = null;
|
|
31752
31427
|
clearTimeout(this.heartbeatTimer);
|
|
31753
|
-
|
|
31754
|
-
set_timeout_default()(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
|
31428
|
+
setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
|
31755
31429
|
}
|
|
31756
|
-
|
|
31757
31430
|
teardown(callback, code, reason) {
|
|
31758
31431
|
if (!this.conn) {
|
|
31759
31432
|
return callback && callback();
|
|
31760
31433
|
}
|
|
31761
|
-
|
|
31762
31434
|
this.waitForBufferDone(() => {
|
|
31763
31435
|
if (this.conn) {
|
|
31764
31436
|
if (code) {
|
|
@@ -31767,248 +31439,170 @@ var Socket = class {
|
|
|
31767
31439
|
this.conn.close();
|
|
31768
31440
|
}
|
|
31769
31441
|
}
|
|
31770
|
-
|
|
31771
31442
|
this.waitForSocketClosed(() => {
|
|
31772
31443
|
if (this.conn) {
|
|
31773
|
-
this.conn.onclose = function
|
|
31774
|
-
|
|
31444
|
+
this.conn.onclose = function() {
|
|
31445
|
+
};
|
|
31775
31446
|
this.conn = null;
|
|
31776
31447
|
}
|
|
31777
|
-
|
|
31778
31448
|
callback && callback();
|
|
31779
31449
|
});
|
|
31780
31450
|
});
|
|
31781
31451
|
}
|
|
31782
|
-
|
|
31783
|
-
waitForBufferDone(callback) {
|
|
31784
|
-
let tries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
31785
|
-
|
|
31452
|
+
waitForBufferDone(callback, tries = 1) {
|
|
31786
31453
|
if (tries === 5 || !this.conn || !this.conn.bufferedAmount) {
|
|
31787
31454
|
callback();
|
|
31788
31455
|
return;
|
|
31789
31456
|
}
|
|
31790
|
-
|
|
31791
|
-
set_timeout_default()(() => {
|
|
31457
|
+
setTimeout(() => {
|
|
31792
31458
|
this.waitForBufferDone(callback, tries + 1);
|
|
31793
31459
|
}, 150 * tries);
|
|
31794
31460
|
}
|
|
31795
|
-
|
|
31796
|
-
waitForSocketClosed(callback) {
|
|
31797
|
-
let tries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
31798
|
-
|
|
31461
|
+
waitForSocketClosed(callback, tries = 1) {
|
|
31799
31462
|
if (tries === 5 || !this.conn || this.conn.readyState === SOCKET_STATES.closed) {
|
|
31800
31463
|
callback();
|
|
31801
31464
|
return;
|
|
31802
31465
|
}
|
|
31803
|
-
|
|
31804
|
-
set_timeout_default()(() => {
|
|
31466
|
+
setTimeout(() => {
|
|
31805
31467
|
this.waitForSocketClosed(callback, tries + 1);
|
|
31806
31468
|
}, 150 * tries);
|
|
31807
31469
|
}
|
|
31808
|
-
|
|
31809
31470
|
onConnClose(event) {
|
|
31810
|
-
var _context26;
|
|
31811
|
-
|
|
31812
31471
|
let closeCode = event && event.code;
|
|
31813
|
-
if (this.hasLogger())
|
|
31472
|
+
if (this.hasLogger())
|
|
31473
|
+
this.log("transport", "close", event);
|
|
31814
31474
|
this.triggerChanError();
|
|
31815
31475
|
clearTimeout(this.heartbeatTimer);
|
|
31816
|
-
|
|
31817
31476
|
if (!this.closeWasClean && closeCode !== 1e3) {
|
|
31818
31477
|
this.reconnectTimer.scheduleTimeout();
|
|
31819
31478
|
}
|
|
31820
|
-
|
|
31821
|
-
for_each_default()(_context26 = this.stateChangeCallbacks.close).call(_context26, _ref4 => {
|
|
31822
|
-
let [, callback] = _ref4;
|
|
31823
|
-
return callback(event);
|
|
31824
|
-
});
|
|
31479
|
+
this.stateChangeCallbacks.close.forEach(([, callback]) => callback(event));
|
|
31825
31480
|
}
|
|
31826
|
-
|
|
31827
31481
|
onConnError(error) {
|
|
31828
|
-
|
|
31829
|
-
|
|
31830
|
-
if (this.hasLogger()) this.log("transport", error);
|
|
31482
|
+
if (this.hasLogger())
|
|
31483
|
+
this.log("transport", error);
|
|
31831
31484
|
let transportBefore = this.transport;
|
|
31832
31485
|
let establishedBefore = this.establishedConnections;
|
|
31833
|
-
|
|
31834
|
-
for_each_default()(_context27 = this.stateChangeCallbacks.error).call(_context27, _ref5 => {
|
|
31835
|
-
let [, callback] = _ref5;
|
|
31486
|
+
this.stateChangeCallbacks.error.forEach(([, callback]) => {
|
|
31836
31487
|
callback(error, transportBefore, establishedBefore);
|
|
31837
31488
|
});
|
|
31838
|
-
|
|
31839
31489
|
if (transportBefore === this.transport || establishedBefore > 0) {
|
|
31840
31490
|
this.triggerChanError();
|
|
31841
31491
|
}
|
|
31842
31492
|
}
|
|
31843
|
-
|
|
31844
31493
|
triggerChanError() {
|
|
31845
|
-
|
|
31846
|
-
|
|
31847
|
-
for_each_default()(_context28 = this.channels).call(_context28, channel => {
|
|
31494
|
+
this.channels.forEach((channel) => {
|
|
31848
31495
|
if (!(channel.isErrored() || channel.isLeaving() || channel.isClosed())) {
|
|
31849
31496
|
channel.trigger(CHANNEL_EVENTS.error);
|
|
31850
31497
|
}
|
|
31851
31498
|
});
|
|
31852
31499
|
}
|
|
31853
|
-
|
|
31854
31500
|
connectionState() {
|
|
31855
31501
|
switch (this.conn && this.conn.readyState) {
|
|
31856
31502
|
case SOCKET_STATES.connecting:
|
|
31857
31503
|
return "connecting";
|
|
31858
|
-
|
|
31859
31504
|
case SOCKET_STATES.open:
|
|
31860
31505
|
return "open";
|
|
31861
|
-
|
|
31862
31506
|
case SOCKET_STATES.closing:
|
|
31863
31507
|
return "closing";
|
|
31864
|
-
|
|
31865
31508
|
default:
|
|
31866
31509
|
return "closed";
|
|
31867
31510
|
}
|
|
31868
31511
|
}
|
|
31869
|
-
|
|
31870
31512
|
isConnected() {
|
|
31871
31513
|
return this.connectionState() === "open";
|
|
31872
31514
|
}
|
|
31873
|
-
|
|
31874
31515
|
remove(channel) {
|
|
31875
|
-
var _context29;
|
|
31876
|
-
|
|
31877
31516
|
this.off(channel.stateChangeRefs);
|
|
31878
|
-
this.channels =
|
|
31517
|
+
this.channels = this.channels.filter((c) => c.joinRef() !== channel.joinRef());
|
|
31879
31518
|
}
|
|
31880
|
-
|
|
31881
31519
|
off(refs) {
|
|
31882
31520
|
for (let key in this.stateChangeCallbacks) {
|
|
31883
|
-
|
|
31884
|
-
|
|
31885
|
-
this.stateChangeCallbacks[key] = filter_default()(_context30 = this.stateChangeCallbacks[key]).call(_context30, _ref6 => {
|
|
31886
|
-
let [ref] = _ref6;
|
|
31887
|
-
return instance_index_of_default()(refs).call(refs, ref) === -1;
|
|
31521
|
+
this.stateChangeCallbacks[key] = this.stateChangeCallbacks[key].filter(([ref]) => {
|
|
31522
|
+
return refs.indexOf(ref) === -1;
|
|
31888
31523
|
});
|
|
31889
31524
|
}
|
|
31890
31525
|
}
|
|
31891
|
-
|
|
31892
|
-
channel(topic) {
|
|
31893
|
-
let chanParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
31526
|
+
channel(topic, chanParams = {}) {
|
|
31894
31527
|
let chan = new Channel(topic, chanParams, this);
|
|
31895
31528
|
this.channels.push(chan);
|
|
31896
31529
|
return chan;
|
|
31897
31530
|
}
|
|
31898
|
-
|
|
31899
31531
|
push(data) {
|
|
31900
31532
|
if (this.hasLogger()) {
|
|
31901
|
-
let {
|
|
31902
|
-
topic,
|
|
31903
|
-
event,
|
|
31904
|
-
payload,
|
|
31905
|
-
ref,
|
|
31906
|
-
join_ref
|
|
31907
|
-
} = data;
|
|
31533
|
+
let { topic, event, payload, ref, join_ref } = data;
|
|
31908
31534
|
this.log("push", `${topic} ${event} (${join_ref}, ${ref})`, payload);
|
|
31909
31535
|
}
|
|
31910
|
-
|
|
31911
31536
|
if (this.isConnected()) {
|
|
31912
|
-
this.encode(data, result => this.conn.send(result));
|
|
31537
|
+
this.encode(data, (result) => this.conn.send(result));
|
|
31913
31538
|
} else {
|
|
31914
|
-
this.sendBuffer.push(() => this.encode(data, result => this.conn.send(result)));
|
|
31539
|
+
this.sendBuffer.push(() => this.encode(data, (result) => this.conn.send(result)));
|
|
31915
31540
|
}
|
|
31916
31541
|
}
|
|
31917
|
-
|
|
31918
31542
|
makeRef() {
|
|
31919
31543
|
let newRef = this.ref + 1;
|
|
31920
|
-
|
|
31921
31544
|
if (newRef === this.ref) {
|
|
31922
31545
|
this.ref = 0;
|
|
31923
31546
|
} else {
|
|
31924
31547
|
this.ref = newRef;
|
|
31925
31548
|
}
|
|
31926
|
-
|
|
31927
31549
|
return this.ref.toString();
|
|
31928
31550
|
}
|
|
31929
|
-
|
|
31930
31551
|
sendHeartbeat() {
|
|
31931
31552
|
if (this.pendingHeartbeatRef && !this.isConnected()) {
|
|
31932
31553
|
return;
|
|
31933
31554
|
}
|
|
31934
|
-
|
|
31935
31555
|
this.pendingHeartbeatRef = this.makeRef();
|
|
31936
|
-
this.push({
|
|
31937
|
-
|
|
31938
|
-
event: "heartbeat",
|
|
31939
|
-
payload: {},
|
|
31940
|
-
ref: this.pendingHeartbeatRef
|
|
31941
|
-
});
|
|
31942
|
-
this.heartbeatTimer = set_timeout_default()(() => this.heartbeatTimeout(), this.heartbeatIntervalMs);
|
|
31556
|
+
this.push({ topic: "phoenix", event: "heartbeat", payload: {}, ref: this.pendingHeartbeatRef });
|
|
31557
|
+
this.heartbeatTimer = setTimeout(() => this.heartbeatTimeout(), this.heartbeatIntervalMs);
|
|
31943
31558
|
}
|
|
31944
|
-
|
|
31945
31559
|
abnormalClose(reason) {
|
|
31946
31560
|
this.closeWasClean = false;
|
|
31947
|
-
|
|
31948
31561
|
if (this.isConnected()) {
|
|
31949
31562
|
this.conn.close(WS_CLOSE_NORMAL, reason);
|
|
31950
31563
|
}
|
|
31951
31564
|
}
|
|
31952
|
-
|
|
31953
31565
|
flushSendBuffer() {
|
|
31954
31566
|
if (this.isConnected() && this.sendBuffer.length > 0) {
|
|
31955
|
-
|
|
31956
|
-
|
|
31957
|
-
for_each_default()(_context31 = this.sendBuffer).call(_context31, callback => callback());
|
|
31958
|
-
|
|
31567
|
+
this.sendBuffer.forEach((callback) => callback());
|
|
31959
31568
|
this.sendBuffer = [];
|
|
31960
31569
|
}
|
|
31961
31570
|
}
|
|
31962
|
-
|
|
31963
31571
|
onConnMessage(rawMessage) {
|
|
31964
|
-
this.decode(rawMessage.data, msg => {
|
|
31965
|
-
let {
|
|
31966
|
-
topic,
|
|
31967
|
-
event,
|
|
31968
|
-
payload,
|
|
31969
|
-
ref,
|
|
31970
|
-
join_ref
|
|
31971
|
-
} = msg;
|
|
31972
|
-
|
|
31572
|
+
this.decode(rawMessage.data, (msg) => {
|
|
31573
|
+
let { topic, event, payload, ref, join_ref } = msg;
|
|
31973
31574
|
if (ref && ref === this.pendingHeartbeatRef) {
|
|
31974
31575
|
clearTimeout(this.heartbeatTimer);
|
|
31975
31576
|
this.pendingHeartbeatRef = null;
|
|
31976
|
-
|
|
31977
|
-
set_timeout_default()(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
|
31577
|
+
setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
|
31978
31578
|
}
|
|
31979
|
-
|
|
31980
|
-
|
|
31981
|
-
|
|
31579
|
+
if (this.hasLogger())
|
|
31580
|
+
this.log("receive", `${payload.status || ""} ${topic} ${event} ${ref && "(" + ref + ")" || ""}`, payload);
|
|
31982
31581
|
for (let i = 0; i < this.channels.length; i++) {
|
|
31983
31582
|
const channel = this.channels[i];
|
|
31984
|
-
|
|
31985
31583
|
if (!channel.isMember(topic, event, payload, join_ref)) {
|
|
31986
31584
|
continue;
|
|
31987
31585
|
}
|
|
31988
|
-
|
|
31989
31586
|
channel.trigger(event, payload, ref, join_ref);
|
|
31990
31587
|
}
|
|
31991
|
-
|
|
31992
31588
|
for (let i = 0; i < this.stateChangeCallbacks.message.length; i++) {
|
|
31993
31589
|
let [, callback] = this.stateChangeCallbacks.message[i];
|
|
31994
31590
|
callback(msg);
|
|
31995
31591
|
}
|
|
31996
31592
|
});
|
|
31997
31593
|
}
|
|
31998
|
-
|
|
31999
31594
|
leaveOpenTopic(topic) {
|
|
32000
|
-
|
|
32001
|
-
|
|
32002
|
-
let dupChannel = find_default()(_context32 = this.channels).call(_context32, c => c.topic === topic && (c.isJoined() || c.isJoining()));
|
|
32003
|
-
|
|
31595
|
+
let dupChannel = this.channels.find((c) => c.topic === topic && (c.isJoined() || c.isJoining()));
|
|
32004
31596
|
if (dupChannel) {
|
|
32005
|
-
if (this.hasLogger())
|
|
31597
|
+
if (this.hasLogger())
|
|
31598
|
+
this.log("transport", `leaving duplicate topic "${topic}"`);
|
|
32006
31599
|
dupChannel.leave();
|
|
32007
31600
|
}
|
|
32008
31601
|
}
|
|
32009
|
-
|
|
32010
31602
|
};
|
|
32011
31603
|
|
|
31604
|
+
//# sourceMappingURL=phoenix.mjs.map
|
|
31605
|
+
|
|
32012
31606
|
;// CONCATENATED MODULE: ./src/javascripts/lib/split-url-params.js
|
|
32013
31607
|
|
|
32014
31608
|
|
|
@@ -32759,7 +32353,7 @@ class API {
|
|
|
32759
32353
|
return {
|
|
32760
32354
|
clientName: "@seamly/web-ui",
|
|
32761
32355
|
clientVariant: this.layoutMode,
|
|
32762
|
-
clientVersion: "20.
|
|
32356
|
+
clientVersion: "20.6.0",
|
|
32763
32357
|
currentUrl: window.location.toString(),
|
|
32764
32358
|
screenResolution: `${window.screen.width}x${window.screen.height}`,
|
|
32765
32359
|
timezone: getTimeZone(),
|
|
@@ -32768,39 +32362,6 @@ class API {
|
|
|
32768
32362
|
}
|
|
32769
32363
|
|
|
32770
32364
|
}
|
|
32771
|
-
;// CONCATENATED MODULE: ./node_modules/redux-thunk/es/index.js
|
|
32772
|
-
/** A function that accepts a potential "extra argument" value to be injected later,
|
|
32773
|
-
* and returns an instance of the thunk middleware that uses that value
|
|
32774
|
-
*/
|
|
32775
|
-
function createThunkMiddleware(extraArgument) {
|
|
32776
|
-
// Standard Redux middleware definition pattern:
|
|
32777
|
-
// See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
|
|
32778
|
-
var middleware = function middleware(_ref) {
|
|
32779
|
-
var dispatch = _ref.dispatch,
|
|
32780
|
-
getState = _ref.getState;
|
|
32781
|
-
return function (next) {
|
|
32782
|
-
return function (action) {
|
|
32783
|
-
// The thunk middleware looks for any functions that were passed to `store.dispatch`.
|
|
32784
|
-
// If this "action" is really a function, call it and return the result.
|
|
32785
|
-
if (typeof action === 'function') {
|
|
32786
|
-
// Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
|
|
32787
|
-
return action(dispatch, getState, extraArgument);
|
|
32788
|
-
} // Otherwise, pass the action down the middleware chain as usual
|
|
32789
|
-
|
|
32790
|
-
|
|
32791
|
-
return next(action);
|
|
32792
|
-
};
|
|
32793
|
-
};
|
|
32794
|
-
};
|
|
32795
|
-
|
|
32796
|
-
return middleware;
|
|
32797
|
-
}
|
|
32798
|
-
|
|
32799
|
-
var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
|
|
32800
|
-
// with whatever "extra arg" they want to inject into their thunks
|
|
32801
|
-
|
|
32802
|
-
thunk.withExtraArgument = createThunkMiddleware;
|
|
32803
|
-
/* harmony default export */ var es = (thunk);
|
|
32804
32365
|
;// CONCATENATED MODULE: ./src/javascripts/domains/options/middleware.js
|
|
32805
32366
|
|
|
32806
32367
|
|
|
@@ -32841,6 +32402,39 @@ function options_middleware_createMiddleware(_ref) {
|
|
|
32841
32402
|
}
|
|
32842
32403
|
;// CONCATENATED MODULE: ./src/javascripts/domains/options/index.js
|
|
32843
32404
|
|
|
32405
|
+
;// CONCATENATED MODULE: ./node_modules/redux-thunk/es/index.js
|
|
32406
|
+
/** A function that accepts a potential "extra argument" value to be injected later,
|
|
32407
|
+
* and returns an instance of the thunk middleware that uses that value
|
|
32408
|
+
*/
|
|
32409
|
+
function createThunkMiddleware(extraArgument) {
|
|
32410
|
+
// Standard Redux middleware definition pattern:
|
|
32411
|
+
// See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
|
|
32412
|
+
var middleware = function middleware(_ref) {
|
|
32413
|
+
var dispatch = _ref.dispatch,
|
|
32414
|
+
getState = _ref.getState;
|
|
32415
|
+
return function (next) {
|
|
32416
|
+
return function (action) {
|
|
32417
|
+
// The thunk middleware looks for any functions that were passed to `store.dispatch`.
|
|
32418
|
+
// If this "action" is really a function, call it and return the result.
|
|
32419
|
+
if (typeof action === 'function') {
|
|
32420
|
+
// Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
|
|
32421
|
+
return action(dispatch, getState, extraArgument);
|
|
32422
|
+
} // Otherwise, pass the action down the middleware chain as usual
|
|
32423
|
+
|
|
32424
|
+
|
|
32425
|
+
return next(action);
|
|
32426
|
+
};
|
|
32427
|
+
};
|
|
32428
|
+
};
|
|
32429
|
+
|
|
32430
|
+
return middleware;
|
|
32431
|
+
}
|
|
32432
|
+
|
|
32433
|
+
var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
|
|
32434
|
+
// with whatever "extra arg" they want to inject into their thunks
|
|
32435
|
+
|
|
32436
|
+
thunk.withExtraArgument = createThunkMiddleware;
|
|
32437
|
+
/* harmony default export */ var es = (thunk);
|
|
32844
32438
|
;// CONCATENATED MODULE: ./src/javascripts/domains/store/state-reducer.js
|
|
32845
32439
|
// Legacy state reducer. Do not add new features here but extract/create new reducers as needed
|
|
32846
32440
|
|
|
@@ -32943,7 +32537,7 @@ function store_createStore() {
|
|
|
32943
32537
|
api
|
|
32944
32538
|
}), options_middleware_createMiddleware({
|
|
32945
32539
|
api
|
|
32946
|
-
}), middleware_createMiddleware
|
|
32540
|
+
}), middleware_createMiddleware]
|
|
32947
32541
|
});
|
|
32948
32542
|
return store;
|
|
32949
32543
|
}
|