@seamly/web-ui 20.5.0 → 20.7.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 +791 -0
- package/build/dist/lib/index.debug.js +43 -43
- 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 +432 -621
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/standalone.js +349 -766
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/style-guide.js +151 -92
- package/build/dist/lib/style-guide.min.js +1 -1
- package/build/dist/lib/styles.css +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/components/suggestions/index.js +37 -26
- package/src/javascripts/ui/hooks/use-seamly-commands.js +0 -17
- package/src/javascripts/ui/utils/seamly-utils.js +5 -3
- package/src/stylesheets/5-components/_suggestions.scss +3 -3
- 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',
|
|
@@ -18314,9 +18264,9 @@ const seamlyStateReducer = (state, action) => {
|
|
|
18314
18264
|
|
|
18315
18265
|
|
|
18316
18266
|
if (accountHasUploads && (eventType === eventTypes.message || eventType === eventTypes.participant) && !payload.fromClient) {
|
|
18317
|
-
|
|
18318
|
-
|
|
18319
|
-
|
|
18267
|
+
var _payload$entry;
|
|
18268
|
+
|
|
18269
|
+
const entryType = payload === null || payload === void 0 ? void 0 : (_payload$entry = payload.entry) === null || _payload$entry === void 0 ? void 0 : _payload$entry.type;
|
|
18320
18270
|
newOptions = seamly_utils_objectSpread(seamly_utils_objectSpread({}, newOptions), {}, {
|
|
18321
18271
|
features: seamly_utils_objectSpread(seamly_utils_objectSpread({}, newOptions.features), {}, {
|
|
18322
18272
|
uploads: seamly_utils_objectSpread(seamly_utils_objectSpread({}, newOptions.features.uploads), {}, {
|
|
@@ -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
|
|
|
@@ -18444,12 +18397,9 @@ const seamlyStateReducer = (state, action) => {
|
|
|
18444
18397
|
const newFeaturesHasUpload = newFeatures.hasOwnProperty(featureKeys.uploads); // Only set uploads if it was initialised by the account config.
|
|
18445
18398
|
|
|
18446
18399
|
if (newFeaturesHasUpload) {
|
|
18447
|
-
|
|
18448
|
-
|
|
18449
|
-
|
|
18450
|
-
const {
|
|
18451
|
-
type: entryType
|
|
18452
|
-
} = lastParticipantEventPayload.entry || {};
|
|
18400
|
+
var _lastParticipantEvent, _lastParticipantEvent2;
|
|
18401
|
+
|
|
18402
|
+
const entryType = lastParticipantEvent === null || lastParticipantEvent === void 0 ? void 0 : (_lastParticipantEvent = lastParticipantEvent.payload) === null || _lastParticipantEvent === void 0 ? void 0 : (_lastParticipantEvent2 = _lastParticipantEvent.entry) === null || _lastParticipantEvent2 === void 0 ? void 0 : _lastParticipantEvent2.type;
|
|
18453
18403
|
newFeatures = seamly_utils_objectSpread(seamly_utils_objectSpread({}, newFeatures), {}, {
|
|
18454
18404
|
uploads: {
|
|
18455
18405
|
enabled: !!(uploads && uploads.enabled),
|
|
@@ -21163,21 +21113,6 @@ const useSeamlyCommands = () => {
|
|
|
21163
21113
|
}
|
|
21164
21114
|
});
|
|
21165
21115
|
}, [dispatch]);
|
|
21166
|
-
const sendInfo = hooks_module_A(_ref2 => {
|
|
21167
|
-
let {
|
|
21168
|
-
type,
|
|
21169
|
-
subtype
|
|
21170
|
-
} = _ref2;
|
|
21171
|
-
const info = {
|
|
21172
|
-
type,
|
|
21173
|
-
subtype,
|
|
21174
|
-
id: randomId(),
|
|
21175
|
-
transactionId: randomId(),
|
|
21176
|
-
participant: userParticipantId,
|
|
21177
|
-
fromClient: true
|
|
21178
|
-
};
|
|
21179
|
-
api.send('info', info);
|
|
21180
|
-
}, [api]);
|
|
21181
21116
|
const sendAction = hooks_module_A(body => {
|
|
21182
21117
|
if (!body) {
|
|
21183
21118
|
return;
|
|
@@ -21220,7 +21155,6 @@ const useSeamlyCommands = () => {
|
|
|
21220
21155
|
connect,
|
|
21221
21156
|
start,
|
|
21222
21157
|
sendMessage,
|
|
21223
|
-
sendInfo,
|
|
21224
21158
|
sendAction,
|
|
21225
21159
|
sendContext,
|
|
21226
21160
|
reset,
|
|
@@ -21992,13 +21926,13 @@ function useLocaleNativeName(locale) {
|
|
|
21992
21926
|
|
|
21993
21927
|
|
|
21994
21928
|
|
|
21995
|
-
function middleware_createMiddleware() {
|
|
21996
|
-
|
|
21997
|
-
|
|
21998
|
-
|
|
21999
|
-
|
|
22000
|
-
|
|
22001
|
-
return
|
|
21929
|
+
function middleware_createMiddleware(_ref) {
|
|
21930
|
+
let {
|
|
21931
|
+
dispatch,
|
|
21932
|
+
getState
|
|
21933
|
+
} = _ref;
|
|
21934
|
+
return next => {
|
|
21935
|
+
return action => {
|
|
22002
21936
|
var _action$history, _action$history$trans, _action$initialState, _action$initialState$, _action$event, _action$event$payload, _action$event$payload2;
|
|
22003
21937
|
|
|
22004
21938
|
const result = next(action);
|
|
@@ -22007,6 +21941,7 @@ function middleware_createMiddleware() {
|
|
|
22007
21941
|
case String(seamlyActions.SET_HISTORY):
|
|
22008
21942
|
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
21943
|
dispatch(enable(action.history.translation.locale));
|
|
21944
|
+
dispatch(setLocale(action.history.translation.locale));
|
|
22010
21945
|
}
|
|
22011
21946
|
|
|
22012
21947
|
break;
|
|
@@ -23719,17 +23654,16 @@ const SuggestionsList = _ref => {
|
|
|
23719
23654
|
|
|
23720
23655
|
|
|
23721
23656
|
|
|
23722
|
-
|
|
23723
23657
|
|
|
23724
23658
|
|
|
23725
23659
|
const Suggestions = _ref => {
|
|
23726
23660
|
let {
|
|
23727
|
-
isAside
|
|
23661
|
+
isAside = false
|
|
23728
23662
|
} = _ref;
|
|
23729
23663
|
// generic hooks
|
|
23730
23664
|
const {
|
|
23731
|
-
|
|
23732
|
-
} =
|
|
23665
|
+
isInline
|
|
23666
|
+
} = useSeamlyLayoutMode();
|
|
23733
23667
|
const {
|
|
23734
23668
|
t
|
|
23735
23669
|
} = useI18n();
|
|
@@ -23771,11 +23705,20 @@ const Suggestions = _ref => {
|
|
|
23771
23705
|
const prevHasSuggestions = hooks_module_h(false);
|
|
23772
23706
|
const previousRenderedSuggestions = hooks_module_h([]);
|
|
23773
23707
|
const hasSuggestions = !!suggestions.length;
|
|
23774
|
-
const hideSuggestions =
|
|
23708
|
+
const hideSuggestions = isInline ? (hasResponded || isOpen) && !isAside : hasResponded;
|
|
23775
23709
|
const prevHideSuggestions = hooks_module_h(hideSuggestions);
|
|
23776
23710
|
const showSuggestionsContainer = hasSuggestions && !hideSuggestions;
|
|
23777
23711
|
const renderedSuggestions = hasSuggestions ? suggestions : previousRenderedSuggestions.current;
|
|
23778
|
-
previousRenderedSuggestions.current = renderedSuggestions;
|
|
23712
|
+
previousRenderedSuggestions.current = renderedSuggestions;
|
|
23713
|
+
const suggestionsClassNames = hooks_module_(() => {
|
|
23714
|
+
const classNames = ['suggestions'];
|
|
23715
|
+
|
|
23716
|
+
if (isAside) {
|
|
23717
|
+
classNames.push('suggestions--aside');
|
|
23718
|
+
}
|
|
23719
|
+
|
|
23720
|
+
return css_className(classNames);
|
|
23721
|
+
}, [isAside]); // click handler
|
|
23779
23722
|
|
|
23780
23723
|
const handleClick = hooks_module_A(_ref2 => {
|
|
23781
23724
|
let {
|
|
@@ -23843,7 +23786,7 @@ const Suggestions = _ref => {
|
|
|
23843
23786
|
isActive: showSuggestionsContainer,
|
|
23844
23787
|
transitionStartState: transitionStartStates.notRendered,
|
|
23845
23788
|
children: jsxRuntime_module_e(ContainerElement, {
|
|
23846
|
-
className:
|
|
23789
|
+
className: suggestionsClassNames,
|
|
23847
23790
|
"aria-labelledby": headingText ? sectionId : null,
|
|
23848
23791
|
ref: containerRef,
|
|
23849
23792
|
children: [headingText && jsxRuntime_module_e("p", {
|
|
@@ -27392,6 +27335,37 @@ const ComponentFilter = _ref => {
|
|
|
27392
27335
|
|
|
27393
27336
|
|
|
27394
27337
|
|
|
27338
|
+
const Events = () => {
|
|
27339
|
+
const events = useEvents();
|
|
27340
|
+
let prevParticipant = null;
|
|
27341
|
+
return map_default()(events).call(events, event => {
|
|
27342
|
+
const {
|
|
27343
|
+
type,
|
|
27344
|
+
payload
|
|
27345
|
+
} = event;
|
|
27346
|
+
const {
|
|
27347
|
+
participant,
|
|
27348
|
+
fromClient
|
|
27349
|
+
} = payload;
|
|
27350
|
+
let participantChanged = false;
|
|
27351
|
+
|
|
27352
|
+
if (type !== 'participant') {
|
|
27353
|
+
const currentParticipant = fromClient ? 'seamly-client-participant' : participant;
|
|
27354
|
+
|
|
27355
|
+
if (event.type !== 'info' && prevParticipant !== currentParticipant) {
|
|
27356
|
+
participantChanged = true;
|
|
27357
|
+
}
|
|
27358
|
+
|
|
27359
|
+
prevParticipant = currentParticipant;
|
|
27360
|
+
}
|
|
27361
|
+
|
|
27362
|
+
return jsxRuntime_module_e(event_event, {
|
|
27363
|
+
event: event,
|
|
27364
|
+
newParticipant: participantChanged
|
|
27365
|
+
}, event.payload.key || event.payload.id);
|
|
27366
|
+
});
|
|
27367
|
+
};
|
|
27368
|
+
|
|
27395
27369
|
const Conversation = () => {
|
|
27396
27370
|
const {
|
|
27397
27371
|
t
|
|
@@ -27413,36 +27387,6 @@ const Conversation = () => {
|
|
|
27413
27387
|
}
|
|
27414
27388
|
}, [events, isLoading, isOpen, loadedImageEventIds]);
|
|
27415
27389
|
|
|
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
27390
|
const onClickHandler = e => {
|
|
27447
27391
|
e.preventDefault();
|
|
27448
27392
|
focusSkiplinkTarget();
|
|
@@ -27462,7 +27406,7 @@ const Conversation = () => {
|
|
|
27462
27406
|
children: [jsxRuntime_module_e(privacy_disclaimer, {}), jsxRuntime_module_e("ol", {
|
|
27463
27407
|
className: css_className('conversation'),
|
|
27464
27408
|
children: [jsxRuntime_module_e(component_filter, {
|
|
27465
|
-
children:
|
|
27409
|
+
children: jsxRuntime_module_e(Events, {})
|
|
27466
27410
|
}), isLoading && jsxRuntime_module_e(loader, {})]
|
|
27467
27411
|
})]
|
|
27468
27412
|
})
|
|
@@ -30530,46 +30474,25 @@ function store(key) {
|
|
|
30530
30474
|
// EXTERNAL MODULE: ./src/javascripts/lib/debug.js
|
|
30531
30475
|
var debug = __webpack_require__(1905);
|
|
30532
30476
|
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
|
-
|
|
30477
|
+
;// CONCATENATED MODULE: ./node_modules/phoenix/priv/static/phoenix.mjs
|
|
30549
30478
|
// js/phoenix/utils.js
|
|
30550
|
-
var closure = value => {
|
|
30479
|
+
var closure = (value) => {
|
|
30551
30480
|
if (typeof value === "function") {
|
|
30552
30481
|
return value;
|
|
30553
30482
|
} else {
|
|
30554
|
-
let closure2 = function
|
|
30483
|
+
let closure2 = function() {
|
|
30555
30484
|
return value;
|
|
30556
30485
|
};
|
|
30557
|
-
|
|
30558
30486
|
return closure2;
|
|
30559
30487
|
}
|
|
30560
|
-
};
|
|
30561
|
-
|
|
30488
|
+
};
|
|
30562
30489
|
|
|
30490
|
+
// js/phoenix/constants.js
|
|
30563
30491
|
var globalSelf = typeof self !== "undefined" ? self : null;
|
|
30564
30492
|
var phxWindow = typeof window !== "undefined" ? window : null;
|
|
30565
|
-
var global = globalSelf || phxWindow ||
|
|
30493
|
+
var global = globalSelf || phxWindow || global;
|
|
30566
30494
|
var DEFAULT_VSN = "2.0.0";
|
|
30567
|
-
var SOCKET_STATES = {
|
|
30568
|
-
connecting: 0,
|
|
30569
|
-
open: 1,
|
|
30570
|
-
closing: 2,
|
|
30571
|
-
closed: 3
|
|
30572
|
-
};
|
|
30495
|
+
var SOCKET_STATES = { connecting: 0, open: 1, closing: 2, closed: 3 };
|
|
30573
30496
|
var DEFAULT_TIMEOUT = 1e4;
|
|
30574
30497
|
var WS_CLOSE_NORMAL = 1e3;
|
|
30575
30498
|
var CHANNEL_STATES = {
|
|
@@ -30592,35 +30515,31 @@ var TRANSPORTS = {
|
|
|
30592
30515
|
};
|
|
30593
30516
|
var XHR_STATES = {
|
|
30594
30517
|
complete: 4
|
|
30595
|
-
};
|
|
30518
|
+
};
|
|
30596
30519
|
|
|
30520
|
+
// js/phoenix/push.js
|
|
30597
30521
|
var Push = class {
|
|
30598
30522
|
constructor(channel, event, payload, timeout) {
|
|
30599
30523
|
this.channel = channel;
|
|
30600
30524
|
this.event = event;
|
|
30601
|
-
|
|
30602
|
-
this.payload = payload || function () {
|
|
30525
|
+
this.payload = payload || function() {
|
|
30603
30526
|
return {};
|
|
30604
30527
|
};
|
|
30605
|
-
|
|
30606
30528
|
this.receivedResp = null;
|
|
30607
30529
|
this.timeout = timeout;
|
|
30608
30530
|
this.timeoutTimer = null;
|
|
30609
30531
|
this.recHooks = [];
|
|
30610
30532
|
this.sent = false;
|
|
30611
30533
|
}
|
|
30612
|
-
|
|
30613
30534
|
resend(timeout) {
|
|
30614
30535
|
this.timeout = timeout;
|
|
30615
30536
|
this.reset();
|
|
30616
30537
|
this.send();
|
|
30617
30538
|
}
|
|
30618
|
-
|
|
30619
30539
|
send() {
|
|
30620
30540
|
if (this.hasReceived("timeout")) {
|
|
30621
30541
|
return;
|
|
30622
30542
|
}
|
|
30623
|
-
|
|
30624
30543
|
this.startTimeout();
|
|
30625
30544
|
this.sent = true;
|
|
30626
30545
|
this.channel.socket.push({
|
|
@@ -30631,19 +30550,13 @@ var Push = class {
|
|
|
30631
30550
|
join_ref: this.channel.joinRef()
|
|
30632
30551
|
});
|
|
30633
30552
|
}
|
|
30634
|
-
|
|
30635
30553
|
receive(status, callback) {
|
|
30636
30554
|
if (this.hasReceived(status)) {
|
|
30637
30555
|
callback(this.receivedResp.response);
|
|
30638
30556
|
}
|
|
30639
|
-
|
|
30640
|
-
this.recHooks.push({
|
|
30641
|
-
status,
|
|
30642
|
-
callback
|
|
30643
|
-
});
|
|
30557
|
+
this.recHooks.push({ status, callback });
|
|
30644
30558
|
return this;
|
|
30645
30559
|
}
|
|
30646
|
-
|
|
30647
30560
|
reset() {
|
|
30648
30561
|
this.cancelRefEvent();
|
|
30649
30562
|
this.ref = null;
|
|
@@ -30651,63 +30564,44 @@ var Push = class {
|
|
|
30651
30564
|
this.receivedResp = null;
|
|
30652
30565
|
this.sent = false;
|
|
30653
30566
|
}
|
|
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));
|
|
30567
|
+
matchReceive({ status, response, _ref }) {
|
|
30568
|
+
this.recHooks.filter((h) => h.status === status).forEach((h) => h.callback(response));
|
|
30665
30569
|
}
|
|
30666
|
-
|
|
30667
30570
|
cancelRefEvent() {
|
|
30668
30571
|
if (!this.refEvent) {
|
|
30669
30572
|
return;
|
|
30670
30573
|
}
|
|
30671
|
-
|
|
30672
30574
|
this.channel.off(this.refEvent);
|
|
30673
30575
|
}
|
|
30674
|
-
|
|
30675
30576
|
cancelTimeout() {
|
|
30676
30577
|
clearTimeout(this.timeoutTimer);
|
|
30677
30578
|
this.timeoutTimer = null;
|
|
30678
30579
|
}
|
|
30679
|
-
|
|
30680
30580
|
startTimeout() {
|
|
30681
30581
|
if (this.timeoutTimer) {
|
|
30682
30582
|
this.cancelTimeout();
|
|
30683
30583
|
}
|
|
30684
|
-
|
|
30685
30584
|
this.ref = this.channel.socket.makeRef();
|
|
30686
30585
|
this.refEvent = this.channel.replyEventName(this.ref);
|
|
30687
|
-
this.channel.on(this.refEvent, payload => {
|
|
30586
|
+
this.channel.on(this.refEvent, (payload) => {
|
|
30688
30587
|
this.cancelRefEvent();
|
|
30689
30588
|
this.cancelTimeout();
|
|
30690
30589
|
this.receivedResp = payload;
|
|
30691
30590
|
this.matchReceive(payload);
|
|
30692
30591
|
});
|
|
30693
|
-
this.timeoutTimer =
|
|
30592
|
+
this.timeoutTimer = setTimeout(() => {
|
|
30694
30593
|
this.trigger("timeout", {});
|
|
30695
30594
|
}, this.timeout);
|
|
30696
30595
|
}
|
|
30697
|
-
|
|
30698
30596
|
hasReceived(status) {
|
|
30699
30597
|
return this.receivedResp && this.receivedResp.status === status;
|
|
30700
30598
|
}
|
|
30701
|
-
|
|
30702
30599
|
trigger(status, response) {
|
|
30703
|
-
this.channel.trigger(this.refEvent, {
|
|
30704
|
-
status,
|
|
30705
|
-
response
|
|
30706
|
-
});
|
|
30600
|
+
this.channel.trigger(this.refEvent, { status, response });
|
|
30707
30601
|
}
|
|
30602
|
+
};
|
|
30708
30603
|
|
|
30709
|
-
|
|
30710
|
-
|
|
30604
|
+
// js/phoenix/timer.js
|
|
30711
30605
|
var Timer = class {
|
|
30712
30606
|
constructor(callback, timerCalc) {
|
|
30713
30607
|
this.callback = callback;
|
|
@@ -30715,22 +30609,20 @@ var Timer = class {
|
|
|
30715
30609
|
this.timer = null;
|
|
30716
30610
|
this.tries = 0;
|
|
30717
30611
|
}
|
|
30718
|
-
|
|
30719
30612
|
reset() {
|
|
30720
30613
|
this.tries = 0;
|
|
30721
30614
|
clearTimeout(this.timer);
|
|
30722
30615
|
}
|
|
30723
|
-
|
|
30724
30616
|
scheduleTimeout() {
|
|
30725
30617
|
clearTimeout(this.timer);
|
|
30726
|
-
this.timer =
|
|
30618
|
+
this.timer = setTimeout(() => {
|
|
30727
30619
|
this.tries = this.tries + 1;
|
|
30728
30620
|
this.callback();
|
|
30729
30621
|
}, this.timerCalc(this.tries + 1));
|
|
30730
30622
|
}
|
|
30623
|
+
};
|
|
30731
30624
|
|
|
30732
|
-
|
|
30733
|
-
|
|
30625
|
+
// js/phoenix/channel.js
|
|
30734
30626
|
var Channel = class {
|
|
30735
30627
|
constructor(topic, params, socket) {
|
|
30736
30628
|
this.state = CHANNEL_STATES.closed;
|
|
@@ -30752,54 +30644,47 @@ var Channel = class {
|
|
|
30752
30644
|
this.stateChangeRefs.push(this.socket.onError(() => this.rejoinTimer.reset()));
|
|
30753
30645
|
this.stateChangeRefs.push(this.socket.onOpen(() => {
|
|
30754
30646
|
this.rejoinTimer.reset();
|
|
30755
|
-
|
|
30756
30647
|
if (this.isErrored()) {
|
|
30757
30648
|
this.rejoin();
|
|
30758
30649
|
}
|
|
30759
30650
|
}));
|
|
30760
30651
|
this.joinPush.receive("ok", () => {
|
|
30761
|
-
var _context3;
|
|
30762
|
-
|
|
30763
30652
|
this.state = CHANNEL_STATES.joined;
|
|
30764
30653
|
this.rejoinTimer.reset();
|
|
30765
|
-
|
|
30766
|
-
for_each_default()(_context3 = this.pushBuffer).call(_context3, pushEvent => pushEvent.send());
|
|
30767
|
-
|
|
30654
|
+
this.pushBuffer.forEach((pushEvent) => pushEvent.send());
|
|
30768
30655
|
this.pushBuffer = [];
|
|
30769
30656
|
});
|
|
30770
30657
|
this.joinPush.receive("error", () => {
|
|
30771
30658
|
this.state = CHANNEL_STATES.errored;
|
|
30772
|
-
|
|
30773
30659
|
if (this.socket.isConnected()) {
|
|
30774
30660
|
this.rejoinTimer.scheduleTimeout();
|
|
30775
30661
|
}
|
|
30776
30662
|
});
|
|
30777
30663
|
this.onClose(() => {
|
|
30778
30664
|
this.rejoinTimer.reset();
|
|
30779
|
-
if (this.socket.hasLogger())
|
|
30665
|
+
if (this.socket.hasLogger())
|
|
30666
|
+
this.socket.log("channel", `close ${this.topic} ${this.joinRef()}`);
|
|
30780
30667
|
this.state = CHANNEL_STATES.closed;
|
|
30781
30668
|
this.socket.remove(this);
|
|
30782
30669
|
});
|
|
30783
|
-
this.onError(reason => {
|
|
30784
|
-
if (this.socket.hasLogger())
|
|
30785
|
-
|
|
30670
|
+
this.onError((reason) => {
|
|
30671
|
+
if (this.socket.hasLogger())
|
|
30672
|
+
this.socket.log("channel", `error ${this.topic}`, reason);
|
|
30786
30673
|
if (this.isJoining()) {
|
|
30787
30674
|
this.joinPush.reset();
|
|
30788
30675
|
}
|
|
30789
|
-
|
|
30790
30676
|
this.state = CHANNEL_STATES.errored;
|
|
30791
|
-
|
|
30792
30677
|
if (this.socket.isConnected()) {
|
|
30793
30678
|
this.rejoinTimer.scheduleTimeout();
|
|
30794
30679
|
}
|
|
30795
30680
|
});
|
|
30796
30681
|
this.joinPush.receive("timeout", () => {
|
|
30797
|
-
if (this.socket.hasLogger())
|
|
30682
|
+
if (this.socket.hasLogger())
|
|
30683
|
+
this.socket.log("channel", `timeout ${this.topic} (${this.joinRef()})`, this.joinPush.timeout);
|
|
30798
30684
|
let leavePush = new Push(this, CHANNEL_EVENTS.leave, closure({}), this.timeout);
|
|
30799
30685
|
leavePush.send();
|
|
30800
30686
|
this.state = CHANNEL_STATES.errored;
|
|
30801
30687
|
this.joinPush.reset();
|
|
30802
|
-
|
|
30803
30688
|
if (this.socket.isConnected()) {
|
|
30804
30689
|
this.rejoinTimer.scheduleTimeout();
|
|
30805
30690
|
}
|
|
@@ -30808,10 +30693,7 @@ var Channel = class {
|
|
|
30808
30693
|
this.trigger(this.replyEventName(ref), payload);
|
|
30809
30694
|
});
|
|
30810
30695
|
}
|
|
30811
|
-
|
|
30812
|
-
join() {
|
|
30813
|
-
let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.timeout;
|
|
30814
|
-
|
|
30696
|
+
join(timeout = this.timeout) {
|
|
30815
30697
|
if (this.joinedOnce) {
|
|
30816
30698
|
throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");
|
|
30817
30699
|
} else {
|
|
@@ -30821,219 +30703,162 @@ var Channel = class {
|
|
|
30821
30703
|
return this.joinPush;
|
|
30822
30704
|
}
|
|
30823
30705
|
}
|
|
30824
|
-
|
|
30825
30706
|
onClose(callback) {
|
|
30826
30707
|
this.on(CHANNEL_EVENTS.close, callback);
|
|
30827
30708
|
}
|
|
30828
|
-
|
|
30829
30709
|
onError(callback) {
|
|
30830
|
-
return this.on(CHANNEL_EVENTS.error, reason => callback(reason));
|
|
30710
|
+
return this.on(CHANNEL_EVENTS.error, (reason) => callback(reason));
|
|
30831
30711
|
}
|
|
30832
|
-
|
|
30833
30712
|
on(event, callback) {
|
|
30834
30713
|
let ref = this.bindingRef++;
|
|
30835
|
-
this.bindings.push({
|
|
30836
|
-
event,
|
|
30837
|
-
ref,
|
|
30838
|
-
callback
|
|
30839
|
-
});
|
|
30714
|
+
this.bindings.push({ event, ref, callback });
|
|
30840
30715
|
return ref;
|
|
30841
30716
|
}
|
|
30842
|
-
|
|
30843
30717
|
off(event, ref) {
|
|
30844
|
-
|
|
30845
|
-
|
|
30846
|
-
this.bindings = filter_default()(_context4 = this.bindings).call(_context4, bind => {
|
|
30718
|
+
this.bindings = this.bindings.filter((bind) => {
|
|
30847
30719
|
return !(bind.event === event && (typeof ref === "undefined" || ref === bind.ref));
|
|
30848
30720
|
});
|
|
30849
30721
|
}
|
|
30850
|
-
|
|
30851
30722
|
canPush() {
|
|
30852
30723
|
return this.socket.isConnected() && this.isJoined();
|
|
30853
30724
|
}
|
|
30854
|
-
|
|
30855
|
-
push(event, payload) {
|
|
30856
|
-
let timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.timeout;
|
|
30725
|
+
push(event, payload, timeout = this.timeout) {
|
|
30857
30726
|
payload = payload || {};
|
|
30858
|
-
|
|
30859
30727
|
if (!this.joinedOnce) {
|
|
30860
30728
|
throw new Error(`tried to push '${event}' to '${this.topic}' before joining. Use channel.join() before pushing events`);
|
|
30861
30729
|
}
|
|
30862
|
-
|
|
30863
|
-
let pushEvent = new Push(this, event, function () {
|
|
30730
|
+
let pushEvent = new Push(this, event, function() {
|
|
30864
30731
|
return payload;
|
|
30865
30732
|
}, timeout);
|
|
30866
|
-
|
|
30867
30733
|
if (this.canPush()) {
|
|
30868
30734
|
pushEvent.send();
|
|
30869
30735
|
} else {
|
|
30870
30736
|
pushEvent.startTimeout();
|
|
30871
30737
|
this.pushBuffer.push(pushEvent);
|
|
30872
30738
|
}
|
|
30873
|
-
|
|
30874
30739
|
return pushEvent;
|
|
30875
30740
|
}
|
|
30876
|
-
|
|
30877
|
-
leave() {
|
|
30878
|
-
let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.timeout;
|
|
30741
|
+
leave(timeout = this.timeout) {
|
|
30879
30742
|
this.rejoinTimer.reset();
|
|
30880
30743
|
this.joinPush.cancelTimeout();
|
|
30881
30744
|
this.state = CHANNEL_STATES.leaving;
|
|
30882
|
-
|
|
30883
30745
|
let onClose = () => {
|
|
30884
|
-
if (this.socket.hasLogger())
|
|
30746
|
+
if (this.socket.hasLogger())
|
|
30747
|
+
this.socket.log("channel", `leave ${this.topic}`);
|
|
30885
30748
|
this.trigger(CHANNEL_EVENTS.close, "leave");
|
|
30886
30749
|
};
|
|
30887
|
-
|
|
30888
30750
|
let leavePush = new Push(this, CHANNEL_EVENTS.leave, closure({}), timeout);
|
|
30889
30751
|
leavePush.receive("ok", () => onClose()).receive("timeout", () => onClose());
|
|
30890
30752
|
leavePush.send();
|
|
30891
|
-
|
|
30892
30753
|
if (!this.canPush()) {
|
|
30893
30754
|
leavePush.trigger("ok", {});
|
|
30894
30755
|
}
|
|
30895
|
-
|
|
30896
30756
|
return leavePush;
|
|
30897
30757
|
}
|
|
30898
|
-
|
|
30899
30758
|
onMessage(_event, payload, _ref) {
|
|
30900
30759
|
return payload;
|
|
30901
30760
|
}
|
|
30902
|
-
|
|
30903
30761
|
isMember(topic, event, payload, joinRef) {
|
|
30904
30762
|
if (this.topic !== topic) {
|
|
30905
30763
|
return false;
|
|
30906
30764
|
}
|
|
30907
|
-
|
|
30908
30765
|
if (joinRef && joinRef !== this.joinRef()) {
|
|
30909
|
-
if (this.socket.hasLogger())
|
|
30910
|
-
topic,
|
|
30911
|
-
event,
|
|
30912
|
-
payload,
|
|
30913
|
-
joinRef
|
|
30914
|
-
});
|
|
30766
|
+
if (this.socket.hasLogger())
|
|
30767
|
+
this.socket.log("channel", "dropping outdated message", { topic, event, payload, joinRef });
|
|
30915
30768
|
return false;
|
|
30916
30769
|
} else {
|
|
30917
30770
|
return true;
|
|
30918
30771
|
}
|
|
30919
30772
|
}
|
|
30920
|
-
|
|
30921
30773
|
joinRef() {
|
|
30922
30774
|
return this.joinPush.ref;
|
|
30923
30775
|
}
|
|
30924
|
-
|
|
30925
|
-
rejoin() {
|
|
30926
|
-
let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.timeout;
|
|
30927
|
-
|
|
30776
|
+
rejoin(timeout = this.timeout) {
|
|
30928
30777
|
if (this.isLeaving()) {
|
|
30929
30778
|
return;
|
|
30930
30779
|
}
|
|
30931
|
-
|
|
30932
30780
|
this.socket.leaveOpenTopic(this.topic);
|
|
30933
30781
|
this.state = CHANNEL_STATES.joining;
|
|
30934
30782
|
this.joinPush.resend(timeout);
|
|
30935
30783
|
}
|
|
30936
|
-
|
|
30937
30784
|
trigger(event, payload, ref, joinRef) {
|
|
30938
|
-
var _context5;
|
|
30939
|
-
|
|
30940
30785
|
let handledPayload = this.onMessage(event, payload, ref, joinRef);
|
|
30941
|
-
|
|
30942
30786
|
if (payload && !handledPayload) {
|
|
30943
30787
|
throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");
|
|
30944
30788
|
}
|
|
30945
|
-
|
|
30946
|
-
let eventBindings = filter_default()(_context5 = this.bindings).call(_context5, bind => bind.event === event);
|
|
30947
|
-
|
|
30789
|
+
let eventBindings = this.bindings.filter((bind) => bind.event === event);
|
|
30948
30790
|
for (let i = 0; i < eventBindings.length; i++) {
|
|
30949
30791
|
let bind = eventBindings[i];
|
|
30950
30792
|
bind.callback(handledPayload, ref, joinRef || this.joinRef());
|
|
30951
30793
|
}
|
|
30952
30794
|
}
|
|
30953
|
-
|
|
30954
30795
|
replyEventName(ref) {
|
|
30955
30796
|
return `chan_reply_${ref}`;
|
|
30956
30797
|
}
|
|
30957
|
-
|
|
30958
30798
|
isClosed() {
|
|
30959
30799
|
return this.state === CHANNEL_STATES.closed;
|
|
30960
30800
|
}
|
|
30961
|
-
|
|
30962
30801
|
isErrored() {
|
|
30963
30802
|
return this.state === CHANNEL_STATES.errored;
|
|
30964
30803
|
}
|
|
30965
|
-
|
|
30966
30804
|
isJoined() {
|
|
30967
30805
|
return this.state === CHANNEL_STATES.joined;
|
|
30968
30806
|
}
|
|
30969
|
-
|
|
30970
30807
|
isJoining() {
|
|
30971
30808
|
return this.state === CHANNEL_STATES.joining;
|
|
30972
30809
|
}
|
|
30973
|
-
|
|
30974
30810
|
isLeaving() {
|
|
30975
30811
|
return this.state === CHANNEL_STATES.leaving;
|
|
30976
30812
|
}
|
|
30813
|
+
};
|
|
30977
30814
|
|
|
30978
|
-
|
|
30979
|
-
|
|
30815
|
+
// js/phoenix/ajax.js
|
|
30980
30816
|
var Ajax = class {
|
|
30981
30817
|
static request(method, endPoint, accept, body, timeout, ontimeout, callback) {
|
|
30982
30818
|
if (global.XDomainRequest) {
|
|
30983
30819
|
let req = new global.XDomainRequest();
|
|
30984
|
-
this.xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback);
|
|
30820
|
+
return this.xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback);
|
|
30985
30821
|
} else {
|
|
30986
30822
|
let req = new global.XMLHttpRequest();
|
|
30987
|
-
this.xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback);
|
|
30823
|
+
return this.xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback);
|
|
30988
30824
|
}
|
|
30989
30825
|
}
|
|
30990
|
-
|
|
30991
30826
|
static xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback) {
|
|
30992
30827
|
req.timeout = timeout;
|
|
30993
30828
|
req.open(method, endPoint);
|
|
30994
|
-
|
|
30995
30829
|
req.onload = () => {
|
|
30996
30830
|
let response = this.parseJSON(req.responseText);
|
|
30997
30831
|
callback && callback(response);
|
|
30998
30832
|
};
|
|
30999
|
-
|
|
31000
30833
|
if (ontimeout) {
|
|
31001
30834
|
req.ontimeout = ontimeout;
|
|
31002
30835
|
}
|
|
31003
|
-
|
|
31004
|
-
|
|
31005
|
-
|
|
30836
|
+
req.onprogress = () => {
|
|
30837
|
+
};
|
|
31006
30838
|
req.send(body);
|
|
30839
|
+
return req;
|
|
31007
30840
|
}
|
|
31008
|
-
|
|
31009
30841
|
static xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback) {
|
|
31010
30842
|
req.open(method, endPoint, true);
|
|
31011
30843
|
req.timeout = timeout;
|
|
31012
30844
|
req.setRequestHeader("Content-Type", accept);
|
|
31013
|
-
|
|
31014
|
-
req.onerror = () => {
|
|
31015
|
-
callback && callback(null);
|
|
31016
|
-
};
|
|
31017
|
-
|
|
30845
|
+
req.onerror = () => callback && callback(null);
|
|
31018
30846
|
req.onreadystatechange = () => {
|
|
31019
30847
|
if (req.readyState === XHR_STATES.complete && callback) {
|
|
31020
30848
|
let response = this.parseJSON(req.responseText);
|
|
31021
30849
|
callback(response);
|
|
31022
30850
|
}
|
|
31023
30851
|
};
|
|
31024
|
-
|
|
31025
30852
|
if (ontimeout) {
|
|
31026
30853
|
req.ontimeout = ontimeout;
|
|
31027
30854
|
}
|
|
31028
|
-
|
|
31029
30855
|
req.send(body);
|
|
30856
|
+
return req;
|
|
31030
30857
|
}
|
|
31031
|
-
|
|
31032
30858
|
static parseJSON(resp) {
|
|
31033
30859
|
if (!resp || resp === "") {
|
|
31034
30860
|
return null;
|
|
31035
30861
|
}
|
|
31036
|
-
|
|
31037
30862
|
try {
|
|
31038
30863
|
return JSON.parse(resp);
|
|
31039
30864
|
} catch (e) {
|
|
@@ -31041,196 +30866,168 @@ var Ajax = class {
|
|
|
31041
30866
|
return null;
|
|
31042
30867
|
}
|
|
31043
30868
|
}
|
|
31044
|
-
|
|
31045
30869
|
static serialize(obj, parentKey) {
|
|
31046
30870
|
let queryStr = [];
|
|
31047
|
-
|
|
31048
30871
|
for (var key in obj) {
|
|
31049
30872
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
31050
30873
|
continue;
|
|
31051
30874
|
}
|
|
31052
|
-
|
|
31053
30875
|
let paramKey = parentKey ? `${parentKey}[${key}]` : key;
|
|
31054
30876
|
let paramVal = obj[key];
|
|
31055
|
-
|
|
31056
30877
|
if (typeof paramVal === "object") {
|
|
31057
30878
|
queryStr.push(this.serialize(paramVal, paramKey));
|
|
31058
30879
|
} else {
|
|
31059
30880
|
queryStr.push(encodeURIComponent(paramKey) + "=" + encodeURIComponent(paramVal));
|
|
31060
30881
|
}
|
|
31061
30882
|
}
|
|
31062
|
-
|
|
31063
30883
|
return queryStr.join("&");
|
|
31064
30884
|
}
|
|
31065
|
-
|
|
31066
30885
|
static appendParams(url, params) {
|
|
31067
|
-
if (
|
|
30886
|
+
if (Object.keys(params).length === 0) {
|
|
31068
30887
|
return url;
|
|
31069
30888
|
}
|
|
31070
|
-
|
|
31071
30889
|
let prefix = url.match(/\?/) ? "&" : "?";
|
|
31072
30890
|
return `${url}${prefix}${this.serialize(params)}`;
|
|
31073
30891
|
}
|
|
30892
|
+
};
|
|
31074
30893
|
|
|
31075
|
-
|
|
31076
|
-
|
|
30894
|
+
// js/phoenix/longpoll.js
|
|
31077
30895
|
var LongPoll = class {
|
|
31078
30896
|
constructor(endPoint) {
|
|
31079
30897
|
this.endPoint = null;
|
|
31080
30898
|
this.token = null;
|
|
31081
30899
|
this.skipHeartbeat = true;
|
|
31082
|
-
|
|
31083
|
-
this.onopen = function
|
|
31084
|
-
|
|
31085
|
-
this.onerror = function
|
|
31086
|
-
|
|
31087
|
-
this.onmessage = function
|
|
31088
|
-
|
|
31089
|
-
this.onclose = function
|
|
31090
|
-
|
|
30900
|
+
this.reqs = /* @__PURE__ */ new Set();
|
|
30901
|
+
this.onopen = function() {
|
|
30902
|
+
};
|
|
30903
|
+
this.onerror = function() {
|
|
30904
|
+
};
|
|
30905
|
+
this.onmessage = function() {
|
|
30906
|
+
};
|
|
30907
|
+
this.onclose = function() {
|
|
30908
|
+
};
|
|
31091
30909
|
this.pollEndpoint = this.normalizeEndpoint(endPoint);
|
|
31092
30910
|
this.readyState = SOCKET_STATES.connecting;
|
|
31093
30911
|
this.poll();
|
|
31094
30912
|
}
|
|
31095
|
-
|
|
31096
30913
|
normalizeEndpoint(endPoint) {
|
|
31097
30914
|
return endPoint.replace("ws://", "http://").replace("wss://", "https://").replace(new RegExp("(.*)/" + TRANSPORTS.websocket), "$1/" + TRANSPORTS.longpoll);
|
|
31098
30915
|
}
|
|
31099
|
-
|
|
31100
30916
|
endpointURL() {
|
|
31101
|
-
return Ajax.appendParams(this.pollEndpoint, {
|
|
31102
|
-
token: this.token
|
|
31103
|
-
});
|
|
30917
|
+
return Ajax.appendParams(this.pollEndpoint, { token: this.token });
|
|
31104
30918
|
}
|
|
31105
|
-
|
|
31106
|
-
|
|
31107
|
-
this.close();
|
|
30919
|
+
closeAndRetry(code, reason, wasClean) {
|
|
30920
|
+
this.close(code, reason, wasClean);
|
|
31108
30921
|
this.readyState = SOCKET_STATES.connecting;
|
|
31109
30922
|
}
|
|
31110
|
-
|
|
31111
30923
|
ontimeout() {
|
|
31112
30924
|
this.onerror("timeout");
|
|
31113
|
-
this.closeAndRetry();
|
|
30925
|
+
this.closeAndRetry(1005, "timeout", false);
|
|
30926
|
+
}
|
|
30927
|
+
isActive() {
|
|
30928
|
+
return this.readyState === SOCKET_STATES.open || this.readyState === SOCKET_STATES.connecting;
|
|
31114
30929
|
}
|
|
31115
|
-
|
|
31116
30930
|
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 => {
|
|
30931
|
+
this.ajax("GET", null, () => this.ontimeout(), (resp) => {
|
|
31124
30932
|
if (resp) {
|
|
31125
|
-
var {
|
|
31126
|
-
status,
|
|
31127
|
-
token,
|
|
31128
|
-
messages
|
|
31129
|
-
} = resp;
|
|
30933
|
+
var { status, token, messages } = resp;
|
|
31130
30934
|
this.token = token;
|
|
31131
30935
|
} else {
|
|
31132
30936
|
status = 0;
|
|
31133
30937
|
}
|
|
31134
|
-
|
|
31135
30938
|
switch (status) {
|
|
31136
30939
|
case 200:
|
|
31137
|
-
|
|
31138
|
-
|
|
31139
|
-
this.onmessage({
|
|
31140
|
-
data: msg
|
|
31141
|
-
});
|
|
31142
|
-
}, 0);
|
|
30940
|
+
messages.forEach((msg) => {
|
|
30941
|
+
setTimeout(() => this.onmessage({ data: msg }), 0);
|
|
31143
30942
|
});
|
|
31144
|
-
|
|
31145
30943
|
this.poll();
|
|
31146
30944
|
break;
|
|
31147
|
-
|
|
31148
30945
|
case 204:
|
|
31149
30946
|
this.poll();
|
|
31150
30947
|
break;
|
|
31151
|
-
|
|
31152
30948
|
case 410:
|
|
31153
30949
|
this.readyState = SOCKET_STATES.open;
|
|
31154
|
-
this.onopen();
|
|
30950
|
+
this.onopen({});
|
|
31155
30951
|
this.poll();
|
|
31156
30952
|
break;
|
|
31157
|
-
|
|
31158
30953
|
case 403:
|
|
31159
|
-
this.onerror();
|
|
31160
|
-
this.close();
|
|
30954
|
+
this.onerror(403);
|
|
30955
|
+
this.close(1008, "forbidden", false);
|
|
31161
30956
|
break;
|
|
31162
|
-
|
|
31163
30957
|
case 0:
|
|
31164
30958
|
case 500:
|
|
31165
|
-
this.onerror();
|
|
31166
|
-
this.closeAndRetry();
|
|
30959
|
+
this.onerror(500);
|
|
30960
|
+
this.closeAndRetry(1011, "internal server error", 500);
|
|
31167
30961
|
break;
|
|
31168
|
-
|
|
31169
30962
|
default:
|
|
31170
30963
|
throw new Error(`unhandled poll status ${status}`);
|
|
31171
30964
|
}
|
|
31172
30965
|
});
|
|
31173
30966
|
}
|
|
31174
|
-
|
|
31175
30967
|
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 => {
|
|
30968
|
+
this.ajax("POST", body, () => this.onerror("timeout"), (resp) => {
|
|
31179
30969
|
if (!resp || resp.status !== 200) {
|
|
31180
30970
|
this.onerror(resp && resp.status);
|
|
31181
|
-
this.closeAndRetry();
|
|
30971
|
+
this.closeAndRetry(1011, "internal server error", false);
|
|
31182
30972
|
}
|
|
31183
30973
|
});
|
|
31184
30974
|
}
|
|
31185
|
-
|
|
31186
|
-
|
|
30975
|
+
close(code, reason, wasClean) {
|
|
30976
|
+
for (let req of this.reqs) {
|
|
30977
|
+
req.abort();
|
|
30978
|
+
}
|
|
31187
30979
|
this.readyState = SOCKET_STATES.closed;
|
|
31188
|
-
|
|
30980
|
+
let opts = Object.assign({ code: 1e3, reason: void 0, wasClean: true }, { code, reason, wasClean });
|
|
30981
|
+
if (typeof CloseEvent !== "undefined") {
|
|
30982
|
+
this.onclose(new CloseEvent("close", opts));
|
|
30983
|
+
} else {
|
|
30984
|
+
this.onclose(opts);
|
|
30985
|
+
}
|
|
31189
30986
|
}
|
|
31190
|
-
|
|
31191
|
-
|
|
31192
|
-
|
|
31193
|
-
|
|
31194
|
-
|
|
31195
|
-
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
31196
|
-
let events = opts.events || {
|
|
31197
|
-
state: "presence_state",
|
|
31198
|
-
diff: "presence_diff"
|
|
30987
|
+
ajax(method, body, onCallerTimeout, callback) {
|
|
30988
|
+
let req;
|
|
30989
|
+
let ontimeout = () => {
|
|
30990
|
+
this.reqs.delete(req);
|
|
30991
|
+
onCallerTimeout();
|
|
31199
30992
|
};
|
|
30993
|
+
req = Ajax.request(method, this.endpointURL(), "application/json", body, this.timeout, ontimeout, (resp) => {
|
|
30994
|
+
this.reqs.delete(req);
|
|
30995
|
+
if (this.isActive()) {
|
|
30996
|
+
callback(resp);
|
|
30997
|
+
}
|
|
30998
|
+
});
|
|
30999
|
+
this.reqs.add(req);
|
|
31000
|
+
}
|
|
31001
|
+
};
|
|
31002
|
+
|
|
31003
|
+
// js/phoenix/presence.js
|
|
31004
|
+
var Presence = class {
|
|
31005
|
+
constructor(channel, opts = {}) {
|
|
31006
|
+
let events = opts.events || { state: "presence_state", diff: "presence_diff" };
|
|
31200
31007
|
this.state = {};
|
|
31201
31008
|
this.pendingDiffs = [];
|
|
31202
31009
|
this.channel = channel;
|
|
31203
31010
|
this.joinRef = null;
|
|
31204
31011
|
this.caller = {
|
|
31205
|
-
onJoin: function
|
|
31206
|
-
|
|
31207
|
-
|
|
31012
|
+
onJoin: function() {
|
|
31013
|
+
},
|
|
31014
|
+
onLeave: function() {
|
|
31015
|
+
},
|
|
31016
|
+
onSync: function() {
|
|
31017
|
+
}
|
|
31208
31018
|
};
|
|
31209
|
-
this.channel.on(events.state, newState => {
|
|
31210
|
-
|
|
31211
|
-
|
|
31212
|
-
let {
|
|
31213
|
-
onJoin,
|
|
31214
|
-
onLeave,
|
|
31215
|
-
onSync
|
|
31216
|
-
} = this.caller;
|
|
31019
|
+
this.channel.on(events.state, (newState) => {
|
|
31020
|
+
let { onJoin, onLeave, onSync } = this.caller;
|
|
31217
31021
|
this.joinRef = this.channel.joinRef();
|
|
31218
31022
|
this.state = Presence.syncState(this.state, newState, onJoin, onLeave);
|
|
31219
|
-
|
|
31220
|
-
_forEachInstanceProperty(_context8 = this.pendingDiffs).call(_context8, diff => {
|
|
31023
|
+
this.pendingDiffs.forEach((diff) => {
|
|
31221
31024
|
this.state = Presence.syncDiff(this.state, diff, onJoin, onLeave);
|
|
31222
31025
|
});
|
|
31223
|
-
|
|
31224
31026
|
this.pendingDiffs = [];
|
|
31225
31027
|
onSync();
|
|
31226
31028
|
});
|
|
31227
|
-
this.channel.on(events.diff, diff => {
|
|
31228
|
-
let {
|
|
31229
|
-
onJoin,
|
|
31230
|
-
onLeave,
|
|
31231
|
-
onSync
|
|
31232
|
-
} = this.caller;
|
|
31233
|
-
|
|
31029
|
+
this.channel.on(events.diff, (diff) => {
|
|
31030
|
+
let { onJoin, onLeave, onSync } = this.caller;
|
|
31234
31031
|
if (this.inPendingSyncState()) {
|
|
31235
31032
|
this.pendingDiffs.push(diff);
|
|
31236
31033
|
} else {
|
|
@@ -31239,59 +31036,41 @@ var Presence = class {
|
|
|
31239
31036
|
}
|
|
31240
31037
|
});
|
|
31241
31038
|
}
|
|
31242
|
-
|
|
31243
31039
|
onJoin(callback) {
|
|
31244
31040
|
this.caller.onJoin = callback;
|
|
31245
31041
|
}
|
|
31246
|
-
|
|
31247
31042
|
onLeave(callback) {
|
|
31248
31043
|
this.caller.onLeave = callback;
|
|
31249
31044
|
}
|
|
31250
|
-
|
|
31251
31045
|
onSync(callback) {
|
|
31252
31046
|
this.caller.onSync = callback;
|
|
31253
31047
|
}
|
|
31254
|
-
|
|
31255
31048
|
list(by) {
|
|
31256
31049
|
return Presence.list(this.state, by);
|
|
31257
31050
|
}
|
|
31258
|
-
|
|
31259
31051
|
inPendingSyncState() {
|
|
31260
31052
|
return !this.joinRef || this.joinRef !== this.channel.joinRef();
|
|
31261
31053
|
}
|
|
31262
|
-
|
|
31263
31054
|
static syncState(currentState, newState, onJoin, onLeave) {
|
|
31264
|
-
var _context9, _context10;
|
|
31265
|
-
|
|
31266
31055
|
let state = this.clone(currentState);
|
|
31267
31056
|
let joins = {};
|
|
31268
31057
|
let leaves = {};
|
|
31269
|
-
|
|
31270
|
-
_mapInstanceProperty(_context9 = this).call(_context9, state, (key, presence) => {
|
|
31058
|
+
this.map(state, (key, presence) => {
|
|
31271
31059
|
if (!newState[key]) {
|
|
31272
31060
|
leaves[key] = presence;
|
|
31273
31061
|
}
|
|
31274
31062
|
});
|
|
31275
|
-
|
|
31276
|
-
_mapInstanceProperty(_context10 = this).call(_context10, newState, (key, newPresence) => {
|
|
31063
|
+
this.map(newState, (key, newPresence) => {
|
|
31277
31064
|
let currentPresence = state[key];
|
|
31278
|
-
|
|
31279
31065
|
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
|
-
|
|
31066
|
+
let newRefs = newPresence.metas.map((m) => m.phx_ref);
|
|
31067
|
+
let curRefs = currentPresence.metas.map((m) => m.phx_ref);
|
|
31068
|
+
let joinedMetas = newPresence.metas.filter((m) => curRefs.indexOf(m.phx_ref) < 0);
|
|
31069
|
+
let leftMetas = currentPresence.metas.filter((m) => newRefs.indexOf(m.phx_ref) < 0);
|
|
31290
31070
|
if (joinedMetas.length > 0) {
|
|
31291
31071
|
joins[key] = newPresence;
|
|
31292
31072
|
joins[key].metas = joinedMetas;
|
|
31293
31073
|
}
|
|
31294
|
-
|
|
31295
31074
|
if (leftMetas.length > 0) {
|
|
31296
31075
|
leaves[key] = this.clone(currentPresence);
|
|
31297
31076
|
leaves[key].metas = leftMetas;
|
|
@@ -31300,137 +31079,85 @@ var Presence = class {
|
|
|
31300
31079
|
joins[key] = newPresence;
|
|
31301
31080
|
}
|
|
31302
31081
|
});
|
|
31303
|
-
|
|
31304
|
-
return this.syncDiff(state, {
|
|
31305
|
-
joins,
|
|
31306
|
-
leaves
|
|
31307
|
-
}, onJoin, onLeave);
|
|
31082
|
+
return this.syncDiff(state, { joins, leaves }, onJoin, onLeave);
|
|
31308
31083
|
}
|
|
31309
|
-
|
|
31310
31084
|
static syncDiff(state, diff, onJoin, onLeave) {
|
|
31311
|
-
|
|
31312
|
-
|
|
31313
|
-
let {
|
|
31314
|
-
joins,
|
|
31315
|
-
leaves
|
|
31316
|
-
} = this.clone(diff);
|
|
31317
|
-
|
|
31085
|
+
let { joins, leaves } = this.clone(diff);
|
|
31318
31086
|
if (!onJoin) {
|
|
31319
|
-
onJoin = function
|
|
31087
|
+
onJoin = function() {
|
|
31088
|
+
};
|
|
31320
31089
|
}
|
|
31321
|
-
|
|
31322
31090
|
if (!onLeave) {
|
|
31323
|
-
onLeave = function
|
|
31091
|
+
onLeave = function() {
|
|
31092
|
+
};
|
|
31324
31093
|
}
|
|
31325
|
-
|
|
31326
|
-
_mapInstanceProperty(_context15 = this).call(_context15, joins, (key, newPresence) => {
|
|
31094
|
+
this.map(joins, (key, newPresence) => {
|
|
31327
31095
|
let currentPresence = state[key];
|
|
31328
31096
|
state[key] = this.clone(newPresence);
|
|
31329
|
-
|
|
31330
31097
|
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
|
-
|
|
31098
|
+
let joinedRefs = state[key].metas.map((m) => m.phx_ref);
|
|
31099
|
+
let curMetas = currentPresence.metas.filter((m) => joinedRefs.indexOf(m.phx_ref) < 0);
|
|
31337
31100
|
state[key].metas.unshift(...curMetas);
|
|
31338
31101
|
}
|
|
31339
|
-
|
|
31340
31102
|
onJoin(key, currentPresence, newPresence);
|
|
31341
31103
|
});
|
|
31342
|
-
|
|
31343
|
-
_mapInstanceProperty(_context18 = this).call(_context18, leaves, (key, leftPresence) => {
|
|
31344
|
-
var _context19, _context20;
|
|
31345
|
-
|
|
31104
|
+
this.map(leaves, (key, leftPresence) => {
|
|
31346
31105
|
let currentPresence = state[key];
|
|
31347
|
-
|
|
31348
31106
|
if (!currentPresence) {
|
|
31349
31107
|
return;
|
|
31350
31108
|
}
|
|
31351
|
-
|
|
31352
|
-
|
|
31353
|
-
|
|
31354
|
-
currentPresence.metas = _filterInstanceProperty(_context20 = currentPresence.metas).call(_context20, p => {
|
|
31355
|
-
return _indexOfInstanceProperty(refsToRemove).call(refsToRemove, p.phx_ref) < 0;
|
|
31109
|
+
let refsToRemove = leftPresence.metas.map((m) => m.phx_ref);
|
|
31110
|
+
currentPresence.metas = currentPresence.metas.filter((p) => {
|
|
31111
|
+
return refsToRemove.indexOf(p.phx_ref) < 0;
|
|
31356
31112
|
});
|
|
31357
31113
|
onLeave(key, currentPresence, leftPresence);
|
|
31358
|
-
|
|
31359
31114
|
if (currentPresence.metas.length === 0) {
|
|
31360
31115
|
delete state[key];
|
|
31361
31116
|
}
|
|
31362
31117
|
});
|
|
31363
|
-
|
|
31364
31118
|
return state;
|
|
31365
31119
|
}
|
|
31366
|
-
|
|
31367
31120
|
static list(presences, chooser) {
|
|
31368
|
-
var _context21;
|
|
31369
|
-
|
|
31370
31121
|
if (!chooser) {
|
|
31371
|
-
chooser = function
|
|
31122
|
+
chooser = function(key, pres) {
|
|
31372
31123
|
return pres;
|
|
31373
31124
|
};
|
|
31374
31125
|
}
|
|
31375
|
-
|
|
31376
|
-
return _mapInstanceProperty(_context21 = this).call(_context21, presences, (key, presence) => {
|
|
31126
|
+
return this.map(presences, (key, presence) => {
|
|
31377
31127
|
return chooser(key, presence);
|
|
31378
31128
|
});
|
|
31379
31129
|
}
|
|
31380
|
-
|
|
31381
31130
|
static map(obj, func) {
|
|
31382
|
-
|
|
31383
|
-
|
|
31384
|
-
return _mapInstanceProperty(_context22 = _Object$getOwnPropertyNames(obj)).call(_context22, key => func(key, obj[key]));
|
|
31131
|
+
return Object.getOwnPropertyNames(obj).map((key) => func(key, obj[key]));
|
|
31385
31132
|
}
|
|
31386
|
-
|
|
31387
31133
|
static clone(obj) {
|
|
31388
|
-
return JSON.parse(
|
|
31134
|
+
return JSON.parse(JSON.stringify(obj));
|
|
31389
31135
|
}
|
|
31136
|
+
};
|
|
31390
31137
|
|
|
31391
|
-
|
|
31392
|
-
|
|
31138
|
+
// js/phoenix/serializer.js
|
|
31393
31139
|
var serializer_default = {
|
|
31394
31140
|
HEADER_LENGTH: 1,
|
|
31395
31141
|
META_LENGTH: 4,
|
|
31396
|
-
KINDS: {
|
|
31397
|
-
push: 0,
|
|
31398
|
-
reply: 1,
|
|
31399
|
-
broadcast: 2
|
|
31400
|
-
},
|
|
31401
|
-
|
|
31142
|
+
KINDS: { push: 0, reply: 1, broadcast: 2 },
|
|
31402
31143
|
encode(msg, callback) {
|
|
31403
31144
|
if (msg.payload.constructor === ArrayBuffer) {
|
|
31404
31145
|
return callback(this.binaryEncode(msg));
|
|
31405
31146
|
} else {
|
|
31406
31147
|
let payload = [msg.join_ref, msg.ref, msg.topic, msg.event, msg.payload];
|
|
31407
|
-
return callback(
|
|
31148
|
+
return callback(JSON.stringify(payload));
|
|
31408
31149
|
}
|
|
31409
31150
|
},
|
|
31410
|
-
|
|
31411
31151
|
decode(rawPayload, callback) {
|
|
31412
31152
|
if (rawPayload.constructor === ArrayBuffer) {
|
|
31413
31153
|
return callback(this.binaryDecode(rawPayload));
|
|
31414
31154
|
} else {
|
|
31415
31155
|
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
|
-
});
|
|
31156
|
+
return callback({ join_ref, ref, topic, event, payload });
|
|
31423
31157
|
}
|
|
31424
31158
|
},
|
|
31425
|
-
|
|
31426
31159
|
binaryEncode(message) {
|
|
31427
|
-
let {
|
|
31428
|
-
join_ref,
|
|
31429
|
-
ref,
|
|
31430
|
-
event,
|
|
31431
|
-
topic,
|
|
31432
|
-
payload
|
|
31433
|
-
} = message;
|
|
31160
|
+
let { join_ref, ref, event, topic, payload } = message;
|
|
31434
31161
|
let metaLength = this.META_LENGTH + join_ref.length + ref.length + topic.length + event.length;
|
|
31435
31162
|
let header = new ArrayBuffer(this.HEADER_LENGTH + metaLength);
|
|
31436
31163
|
let view = new DataView(header);
|
|
@@ -31440,136 +31167,88 @@ var serializer_default = {
|
|
|
31440
31167
|
view.setUint8(offset++, ref.length);
|
|
31441
31168
|
view.setUint8(offset++, topic.length);
|
|
31442
31169
|
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
|
-
|
|
31170
|
+
Array.from(join_ref, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
31171
|
+
Array.from(ref, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
31172
|
+
Array.from(topic, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
31173
|
+
Array.from(event, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
31452
31174
|
var combined = new Uint8Array(header.byteLength + payload.byteLength);
|
|
31453
31175
|
combined.set(new Uint8Array(header), 0);
|
|
31454
31176
|
combined.set(new Uint8Array(payload), header.byteLength);
|
|
31455
31177
|
return combined.buffer;
|
|
31456
31178
|
},
|
|
31457
|
-
|
|
31458
31179
|
binaryDecode(buffer) {
|
|
31459
31180
|
let view = new DataView(buffer);
|
|
31460
31181
|
let kind = view.getUint8(0);
|
|
31461
31182
|
let decoder = new TextDecoder();
|
|
31462
|
-
|
|
31463
31183
|
switch (kind) {
|
|
31464
31184
|
case this.KINDS.push:
|
|
31465
31185
|
return this.decodePush(buffer, view, decoder);
|
|
31466
|
-
|
|
31467
31186
|
case this.KINDS.reply:
|
|
31468
31187
|
return this.decodeReply(buffer, view, decoder);
|
|
31469
|
-
|
|
31470
31188
|
case this.KINDS.broadcast:
|
|
31471
31189
|
return this.decodeBroadcast(buffer, view, decoder);
|
|
31472
31190
|
}
|
|
31473
31191
|
},
|
|
31474
|
-
|
|
31475
31192
|
decodePush(buffer, view, decoder) {
|
|
31476
31193
|
let joinRefSize = view.getUint8(1);
|
|
31477
31194
|
let topicSize = view.getUint8(2);
|
|
31478
31195
|
let eventSize = view.getUint8(3);
|
|
31479
31196
|
let offset = this.HEADER_LENGTH + this.META_LENGTH - 1;
|
|
31480
|
-
let joinRef = decoder.decode(
|
|
31197
|
+
let joinRef = decoder.decode(buffer.slice(offset, offset + joinRefSize));
|
|
31481
31198
|
offset = offset + joinRefSize;
|
|
31482
|
-
let topic = decoder.decode(
|
|
31199
|
+
let topic = decoder.decode(buffer.slice(offset, offset + topicSize));
|
|
31483
31200
|
offset = offset + topicSize;
|
|
31484
|
-
let event = decoder.decode(
|
|
31201
|
+
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
31485
31202
|
offset = offset + eventSize;
|
|
31486
|
-
|
|
31487
|
-
|
|
31488
|
-
|
|
31489
|
-
return {
|
|
31490
|
-
join_ref: joinRef,
|
|
31491
|
-
ref: null,
|
|
31492
|
-
topic,
|
|
31493
|
-
event,
|
|
31494
|
-
payload: data
|
|
31495
|
-
};
|
|
31203
|
+
let data = buffer.slice(offset, buffer.byteLength);
|
|
31204
|
+
return { join_ref: joinRef, ref: null, topic, event, payload: data };
|
|
31496
31205
|
},
|
|
31497
|
-
|
|
31498
31206
|
decodeReply(buffer, view, decoder) {
|
|
31499
31207
|
let joinRefSize = view.getUint8(1);
|
|
31500
31208
|
let refSize = view.getUint8(2);
|
|
31501
31209
|
let topicSize = view.getUint8(3);
|
|
31502
31210
|
let eventSize = view.getUint8(4);
|
|
31503
31211
|
let offset = this.HEADER_LENGTH + this.META_LENGTH;
|
|
31504
|
-
let joinRef = decoder.decode(
|
|
31212
|
+
let joinRef = decoder.decode(buffer.slice(offset, offset + joinRefSize));
|
|
31505
31213
|
offset = offset + joinRefSize;
|
|
31506
|
-
let ref = decoder.decode(
|
|
31214
|
+
let ref = decoder.decode(buffer.slice(offset, offset + refSize));
|
|
31507
31215
|
offset = offset + refSize;
|
|
31508
|
-
let topic = decoder.decode(
|
|
31216
|
+
let topic = decoder.decode(buffer.slice(offset, offset + topicSize));
|
|
31509
31217
|
offset = offset + topicSize;
|
|
31510
|
-
let event = decoder.decode(
|
|
31218
|
+
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
31511
31219
|
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
|
-
};
|
|
31220
|
+
let data = buffer.slice(offset, buffer.byteLength);
|
|
31221
|
+
let payload = { status: event, response: data };
|
|
31222
|
+
return { join_ref: joinRef, ref, topic, event: CHANNEL_EVENTS.reply, payload };
|
|
31526
31223
|
},
|
|
31527
|
-
|
|
31528
31224
|
decodeBroadcast(buffer, view, decoder) {
|
|
31529
31225
|
let topicSize = view.getUint8(1);
|
|
31530
31226
|
let eventSize = view.getUint8(2);
|
|
31531
31227
|
let offset = this.HEADER_LENGTH + 2;
|
|
31532
|
-
let topic = decoder.decode(
|
|
31228
|
+
let topic = decoder.decode(buffer.slice(offset, offset + topicSize));
|
|
31533
31229
|
offset = offset + topicSize;
|
|
31534
|
-
let event = decoder.decode(
|
|
31230
|
+
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
31535
31231
|
offset = offset + eventSize;
|
|
31536
|
-
|
|
31537
|
-
|
|
31538
|
-
|
|
31539
|
-
return {
|
|
31540
|
-
join_ref: null,
|
|
31541
|
-
ref: null,
|
|
31542
|
-
topic,
|
|
31543
|
-
event,
|
|
31544
|
-
payload: data
|
|
31545
|
-
};
|
|
31232
|
+
let data = buffer.slice(offset, buffer.byteLength);
|
|
31233
|
+
return { join_ref: null, ref: null, topic, event, payload: data };
|
|
31546
31234
|
}
|
|
31235
|
+
};
|
|
31547
31236
|
|
|
31548
|
-
|
|
31549
|
-
|
|
31237
|
+
// js/phoenix/socket.js
|
|
31550
31238
|
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
|
-
};
|
|
31239
|
+
constructor(endPoint, opts = {}) {
|
|
31240
|
+
this.stateChangeCallbacks = { open: [], close: [], error: [], message: [] };
|
|
31561
31241
|
this.channels = [];
|
|
31562
31242
|
this.sendBuffer = [];
|
|
31563
31243
|
this.ref = 0;
|
|
31564
31244
|
this.timeout = opts.timeout || DEFAULT_TIMEOUT;
|
|
31565
31245
|
this.transport = opts.transport || global.WebSocket || LongPoll;
|
|
31566
31246
|
this.establishedConnections = 0;
|
|
31567
|
-
this.defaultEncoder =
|
|
31568
|
-
this.defaultDecoder =
|
|
31247
|
+
this.defaultEncoder = serializer_default.encode.bind(serializer_default);
|
|
31248
|
+
this.defaultDecoder = serializer_default.decode.bind(serializer_default);
|
|
31569
31249
|
this.closeWasClean = false;
|
|
31570
31250
|
this.binaryType = opts.binaryType || "arraybuffer";
|
|
31571
31251
|
this.connectClock = 1;
|
|
31572
|
-
|
|
31573
31252
|
if (this.transport !== LongPoll) {
|
|
31574
31253
|
this.encode = opts.encode || this.defaultEncoder;
|
|
31575
31254
|
this.decode = opts.decode || this.defaultDecoder;
|
|
@@ -31577,42 +31256,36 @@ var Socket = class {
|
|
|
31577
31256
|
this.encode = this.defaultEncoder;
|
|
31578
31257
|
this.decode = this.defaultDecoder;
|
|
31579
31258
|
}
|
|
31580
|
-
|
|
31581
31259
|
let awaitingConnectionOnPageShow = null;
|
|
31582
|
-
|
|
31583
31260
|
if (phxWindow && phxWindow.addEventListener) {
|
|
31584
|
-
phxWindow.addEventListener("pagehide", _e => {
|
|
31261
|
+
phxWindow.addEventListener("pagehide", (_e) => {
|
|
31585
31262
|
if (this.conn) {
|
|
31586
31263
|
this.disconnect();
|
|
31587
31264
|
awaitingConnectionOnPageShow = this.connectClock;
|
|
31588
31265
|
}
|
|
31589
31266
|
});
|
|
31590
|
-
phxWindow.addEventListener("pageshow", _e => {
|
|
31267
|
+
phxWindow.addEventListener("pageshow", (_e) => {
|
|
31591
31268
|
if (awaitingConnectionOnPageShow === this.connectClock) {
|
|
31592
31269
|
awaitingConnectionOnPageShow = null;
|
|
31593
31270
|
this.connect();
|
|
31594
31271
|
}
|
|
31595
31272
|
});
|
|
31596
31273
|
}
|
|
31597
|
-
|
|
31598
31274
|
this.heartbeatIntervalMs = opts.heartbeatIntervalMs || 3e4;
|
|
31599
|
-
|
|
31600
|
-
this.rejoinAfterMs = tries => {
|
|
31275
|
+
this.rejoinAfterMs = (tries) => {
|
|
31601
31276
|
if (opts.rejoinAfterMs) {
|
|
31602
31277
|
return opts.rejoinAfterMs(tries);
|
|
31603
31278
|
} else {
|
|
31604
31279
|
return [1e3, 2e3, 5e3][tries - 1] || 1e4;
|
|
31605
31280
|
}
|
|
31606
31281
|
};
|
|
31607
|
-
|
|
31608
|
-
this.reconnectAfterMs = tries => {
|
|
31282
|
+
this.reconnectAfterMs = (tries) => {
|
|
31609
31283
|
if (opts.reconnectAfterMs) {
|
|
31610
31284
|
return opts.reconnectAfterMs(tries);
|
|
31611
31285
|
} else {
|
|
31612
31286
|
return [10, 50, 100, 150, 200, 250, 500, 1e3, 2e3][tries - 1] || 5e3;
|
|
31613
31287
|
}
|
|
31614
31288
|
};
|
|
31615
|
-
|
|
31616
31289
|
this.logger = opts.logger || null;
|
|
31617
31290
|
this.longpollerTimeout = opts.longpollerTimeout || 2e4;
|
|
31618
31291
|
this.params = closure(opts.params || {});
|
|
@@ -31624,141 +31297,129 @@ var Socket = class {
|
|
|
31624
31297
|
this.teardown(() => this.connect());
|
|
31625
31298
|
}, this.reconnectAfterMs);
|
|
31626
31299
|
}
|
|
31627
|
-
|
|
31300
|
+
getLongPollTransport() {
|
|
31301
|
+
return LongPoll;
|
|
31302
|
+
}
|
|
31628
31303
|
replaceTransport(newTransport) {
|
|
31629
|
-
this.
|
|
31304
|
+
this.connectClock++;
|
|
31305
|
+
this.closeWasClean = true;
|
|
31306
|
+
this.reconnectTimer.reset();
|
|
31307
|
+
this.sendBuffer = [];
|
|
31308
|
+
if (this.conn) {
|
|
31309
|
+
this.conn.close();
|
|
31310
|
+
this.conn = null;
|
|
31311
|
+
}
|
|
31630
31312
|
this.transport = newTransport;
|
|
31631
31313
|
}
|
|
31632
|
-
|
|
31633
31314
|
protocol() {
|
|
31634
31315
|
return location.protocol.match(/^https/) ? "wss" : "ws";
|
|
31635
31316
|
}
|
|
31636
|
-
|
|
31637
31317
|
endPointURL() {
|
|
31638
|
-
let uri = Ajax.appendParams(Ajax.appendParams(this.endPoint, this.params()), {
|
|
31639
|
-
vsn: this.vsn
|
|
31640
|
-
});
|
|
31641
|
-
|
|
31318
|
+
let uri = Ajax.appendParams(Ajax.appendParams(this.endPoint, this.params()), { vsn: this.vsn });
|
|
31642
31319
|
if (uri.charAt(0) !== "/") {
|
|
31643
31320
|
return uri;
|
|
31644
31321
|
}
|
|
31645
|
-
|
|
31646
31322
|
if (uri.charAt(1) === "/") {
|
|
31647
31323
|
return `${this.protocol()}:${uri}`;
|
|
31648
31324
|
}
|
|
31649
|
-
|
|
31650
31325
|
return `${this.protocol()}://${location.host}${uri}`;
|
|
31651
31326
|
}
|
|
31652
|
-
|
|
31653
31327
|
disconnect(callback, code, reason) {
|
|
31654
31328
|
this.connectClock++;
|
|
31655
31329
|
this.closeWasClean = true;
|
|
31656
31330
|
this.reconnectTimer.reset();
|
|
31657
31331
|
this.teardown(callback, code, reason);
|
|
31658
31332
|
}
|
|
31659
|
-
|
|
31660
31333
|
connect(params) {
|
|
31661
|
-
this.connectClock++;
|
|
31662
|
-
|
|
31663
31334
|
if (params) {
|
|
31664
31335
|
console && console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor");
|
|
31665
31336
|
this.params = closure(params);
|
|
31666
31337
|
}
|
|
31667
|
-
|
|
31668
31338
|
if (this.conn) {
|
|
31669
31339
|
return;
|
|
31670
31340
|
}
|
|
31671
|
-
|
|
31341
|
+
this.connectClock++;
|
|
31672
31342
|
this.closeWasClean = false;
|
|
31673
31343
|
this.conn = new this.transport(this.endPointURL());
|
|
31674
31344
|
this.conn.binaryType = this.binaryType;
|
|
31675
31345
|
this.conn.timeout = this.longpollerTimeout;
|
|
31676
|
-
|
|
31677
31346
|
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);
|
|
31347
|
+
this.conn.onerror = (error) => this.onConnError(error);
|
|
31348
|
+
this.conn.onmessage = (event) => this.onConnMessage(event);
|
|
31349
|
+
this.conn.onclose = (event) => this.onConnClose(event);
|
|
31684
31350
|
}
|
|
31685
|
-
|
|
31686
31351
|
log(kind, msg, data) {
|
|
31687
31352
|
this.logger(kind, msg, data);
|
|
31688
31353
|
}
|
|
31689
|
-
|
|
31690
31354
|
hasLogger() {
|
|
31691
31355
|
return this.logger !== null;
|
|
31692
31356
|
}
|
|
31693
|
-
|
|
31694
31357
|
onOpen(callback) {
|
|
31695
31358
|
let ref = this.makeRef();
|
|
31696
31359
|
this.stateChangeCallbacks.open.push([ref, callback]);
|
|
31697
31360
|
return ref;
|
|
31698
31361
|
}
|
|
31699
|
-
|
|
31700
31362
|
onClose(callback) {
|
|
31701
31363
|
let ref = this.makeRef();
|
|
31702
31364
|
this.stateChangeCallbacks.close.push([ref, callback]);
|
|
31703
31365
|
return ref;
|
|
31704
31366
|
}
|
|
31705
|
-
|
|
31706
31367
|
onError(callback) {
|
|
31707
31368
|
let ref = this.makeRef();
|
|
31708
31369
|
this.stateChangeCallbacks.error.push([ref, callback]);
|
|
31709
31370
|
return ref;
|
|
31710
31371
|
}
|
|
31711
|
-
|
|
31712
31372
|
onMessage(callback) {
|
|
31713
31373
|
let ref = this.makeRef();
|
|
31714
31374
|
this.stateChangeCallbacks.message.push([ref, callback]);
|
|
31715
31375
|
return ref;
|
|
31716
31376
|
}
|
|
31717
|
-
|
|
31377
|
+
ping(callback) {
|
|
31378
|
+
if (!this.isConnected()) {
|
|
31379
|
+
return false;
|
|
31380
|
+
}
|
|
31381
|
+
let ref = this.makeRef();
|
|
31382
|
+
let startTime = Date.now();
|
|
31383
|
+
this.push({ topic: "phoenix", event: "heartbeat", payload: {}, ref });
|
|
31384
|
+
let onMsgRef = this.onMessage((msg) => {
|
|
31385
|
+
if (msg.ref === ref) {
|
|
31386
|
+
this.off([onMsgRef]);
|
|
31387
|
+
callback(Date.now() - startTime);
|
|
31388
|
+
}
|
|
31389
|
+
});
|
|
31390
|
+
return true;
|
|
31391
|
+
}
|
|
31718
31392
|
onConnOpen() {
|
|
31719
|
-
|
|
31720
|
-
|
|
31721
|
-
if (this.hasLogger()) this.log("transport", `connected to ${this.endPointURL()}`);
|
|
31393
|
+
if (this.hasLogger())
|
|
31394
|
+
this.log("transport", `connected to ${this.endPointURL()}`);
|
|
31722
31395
|
this.closeWasClean = false;
|
|
31723
31396
|
this.establishedConnections++;
|
|
31724
31397
|
this.flushSendBuffer();
|
|
31725
31398
|
this.reconnectTimer.reset();
|
|
31726
31399
|
this.resetHeartbeat();
|
|
31727
|
-
|
|
31728
|
-
for_each_default()(_context25 = this.stateChangeCallbacks.open).call(_context25, _ref3 => {
|
|
31729
|
-
let [, callback] = _ref3;
|
|
31730
|
-
return callback();
|
|
31731
|
-
});
|
|
31400
|
+
this.stateChangeCallbacks.open.forEach(([, callback]) => callback());
|
|
31732
31401
|
}
|
|
31733
|
-
|
|
31734
31402
|
heartbeatTimeout() {
|
|
31735
31403
|
if (this.pendingHeartbeatRef) {
|
|
31736
31404
|
this.pendingHeartbeatRef = null;
|
|
31737
|
-
|
|
31738
31405
|
if (this.hasLogger()) {
|
|
31739
31406
|
this.log("transport", "heartbeat timeout. Attempting to re-establish connection");
|
|
31740
31407
|
}
|
|
31741
|
-
|
|
31742
31408
|
this.abnormalClose("heartbeat timeout");
|
|
31743
31409
|
}
|
|
31744
31410
|
}
|
|
31745
|
-
|
|
31746
31411
|
resetHeartbeat() {
|
|
31747
31412
|
if (this.conn && this.conn.skipHeartbeat) {
|
|
31748
31413
|
return;
|
|
31749
31414
|
}
|
|
31750
|
-
|
|
31751
31415
|
this.pendingHeartbeatRef = null;
|
|
31752
31416
|
clearTimeout(this.heartbeatTimer);
|
|
31753
|
-
|
|
31754
|
-
set_timeout_default()(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
|
31417
|
+
setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
|
31755
31418
|
}
|
|
31756
|
-
|
|
31757
31419
|
teardown(callback, code, reason) {
|
|
31758
31420
|
if (!this.conn) {
|
|
31759
31421
|
return callback && callback();
|
|
31760
31422
|
}
|
|
31761
|
-
|
|
31762
31423
|
this.waitForBufferDone(() => {
|
|
31763
31424
|
if (this.conn) {
|
|
31764
31425
|
if (code) {
|
|
@@ -31767,248 +31428,170 @@ var Socket = class {
|
|
|
31767
31428
|
this.conn.close();
|
|
31768
31429
|
}
|
|
31769
31430
|
}
|
|
31770
|
-
|
|
31771
31431
|
this.waitForSocketClosed(() => {
|
|
31772
31432
|
if (this.conn) {
|
|
31773
|
-
this.conn.onclose = function
|
|
31774
|
-
|
|
31433
|
+
this.conn.onclose = function() {
|
|
31434
|
+
};
|
|
31775
31435
|
this.conn = null;
|
|
31776
31436
|
}
|
|
31777
|
-
|
|
31778
31437
|
callback && callback();
|
|
31779
31438
|
});
|
|
31780
31439
|
});
|
|
31781
31440
|
}
|
|
31782
|
-
|
|
31783
|
-
waitForBufferDone(callback) {
|
|
31784
|
-
let tries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
31785
|
-
|
|
31441
|
+
waitForBufferDone(callback, tries = 1) {
|
|
31786
31442
|
if (tries === 5 || !this.conn || !this.conn.bufferedAmount) {
|
|
31787
31443
|
callback();
|
|
31788
31444
|
return;
|
|
31789
31445
|
}
|
|
31790
|
-
|
|
31791
|
-
set_timeout_default()(() => {
|
|
31446
|
+
setTimeout(() => {
|
|
31792
31447
|
this.waitForBufferDone(callback, tries + 1);
|
|
31793
31448
|
}, 150 * tries);
|
|
31794
31449
|
}
|
|
31795
|
-
|
|
31796
|
-
waitForSocketClosed(callback) {
|
|
31797
|
-
let tries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
31798
|
-
|
|
31450
|
+
waitForSocketClosed(callback, tries = 1) {
|
|
31799
31451
|
if (tries === 5 || !this.conn || this.conn.readyState === SOCKET_STATES.closed) {
|
|
31800
31452
|
callback();
|
|
31801
31453
|
return;
|
|
31802
31454
|
}
|
|
31803
|
-
|
|
31804
|
-
set_timeout_default()(() => {
|
|
31455
|
+
setTimeout(() => {
|
|
31805
31456
|
this.waitForSocketClosed(callback, tries + 1);
|
|
31806
31457
|
}, 150 * tries);
|
|
31807
31458
|
}
|
|
31808
|
-
|
|
31809
31459
|
onConnClose(event) {
|
|
31810
|
-
var _context26;
|
|
31811
|
-
|
|
31812
31460
|
let closeCode = event && event.code;
|
|
31813
|
-
if (this.hasLogger())
|
|
31461
|
+
if (this.hasLogger())
|
|
31462
|
+
this.log("transport", "close", event);
|
|
31814
31463
|
this.triggerChanError();
|
|
31815
31464
|
clearTimeout(this.heartbeatTimer);
|
|
31816
|
-
|
|
31817
31465
|
if (!this.closeWasClean && closeCode !== 1e3) {
|
|
31818
31466
|
this.reconnectTimer.scheduleTimeout();
|
|
31819
31467
|
}
|
|
31820
|
-
|
|
31821
|
-
for_each_default()(_context26 = this.stateChangeCallbacks.close).call(_context26, _ref4 => {
|
|
31822
|
-
let [, callback] = _ref4;
|
|
31823
|
-
return callback(event);
|
|
31824
|
-
});
|
|
31468
|
+
this.stateChangeCallbacks.close.forEach(([, callback]) => callback(event));
|
|
31825
31469
|
}
|
|
31826
|
-
|
|
31827
31470
|
onConnError(error) {
|
|
31828
|
-
|
|
31829
|
-
|
|
31830
|
-
if (this.hasLogger()) this.log("transport", error);
|
|
31471
|
+
if (this.hasLogger())
|
|
31472
|
+
this.log("transport", error);
|
|
31831
31473
|
let transportBefore = this.transport;
|
|
31832
31474
|
let establishedBefore = this.establishedConnections;
|
|
31833
|
-
|
|
31834
|
-
for_each_default()(_context27 = this.stateChangeCallbacks.error).call(_context27, _ref5 => {
|
|
31835
|
-
let [, callback] = _ref5;
|
|
31475
|
+
this.stateChangeCallbacks.error.forEach(([, callback]) => {
|
|
31836
31476
|
callback(error, transportBefore, establishedBefore);
|
|
31837
31477
|
});
|
|
31838
|
-
|
|
31839
31478
|
if (transportBefore === this.transport || establishedBefore > 0) {
|
|
31840
31479
|
this.triggerChanError();
|
|
31841
31480
|
}
|
|
31842
31481
|
}
|
|
31843
|
-
|
|
31844
31482
|
triggerChanError() {
|
|
31845
|
-
|
|
31846
|
-
|
|
31847
|
-
for_each_default()(_context28 = this.channels).call(_context28, channel => {
|
|
31483
|
+
this.channels.forEach((channel) => {
|
|
31848
31484
|
if (!(channel.isErrored() || channel.isLeaving() || channel.isClosed())) {
|
|
31849
31485
|
channel.trigger(CHANNEL_EVENTS.error);
|
|
31850
31486
|
}
|
|
31851
31487
|
});
|
|
31852
31488
|
}
|
|
31853
|
-
|
|
31854
31489
|
connectionState() {
|
|
31855
31490
|
switch (this.conn && this.conn.readyState) {
|
|
31856
31491
|
case SOCKET_STATES.connecting:
|
|
31857
31492
|
return "connecting";
|
|
31858
|
-
|
|
31859
31493
|
case SOCKET_STATES.open:
|
|
31860
31494
|
return "open";
|
|
31861
|
-
|
|
31862
31495
|
case SOCKET_STATES.closing:
|
|
31863
31496
|
return "closing";
|
|
31864
|
-
|
|
31865
31497
|
default:
|
|
31866
31498
|
return "closed";
|
|
31867
31499
|
}
|
|
31868
31500
|
}
|
|
31869
|
-
|
|
31870
31501
|
isConnected() {
|
|
31871
31502
|
return this.connectionState() === "open";
|
|
31872
31503
|
}
|
|
31873
|
-
|
|
31874
31504
|
remove(channel) {
|
|
31875
|
-
var _context29;
|
|
31876
|
-
|
|
31877
31505
|
this.off(channel.stateChangeRefs);
|
|
31878
|
-
this.channels =
|
|
31506
|
+
this.channels = this.channels.filter((c) => c.joinRef() !== channel.joinRef());
|
|
31879
31507
|
}
|
|
31880
|
-
|
|
31881
31508
|
off(refs) {
|
|
31882
31509
|
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;
|
|
31510
|
+
this.stateChangeCallbacks[key] = this.stateChangeCallbacks[key].filter(([ref]) => {
|
|
31511
|
+
return refs.indexOf(ref) === -1;
|
|
31888
31512
|
});
|
|
31889
31513
|
}
|
|
31890
31514
|
}
|
|
31891
|
-
|
|
31892
|
-
channel(topic) {
|
|
31893
|
-
let chanParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
31515
|
+
channel(topic, chanParams = {}) {
|
|
31894
31516
|
let chan = new Channel(topic, chanParams, this);
|
|
31895
31517
|
this.channels.push(chan);
|
|
31896
31518
|
return chan;
|
|
31897
31519
|
}
|
|
31898
|
-
|
|
31899
31520
|
push(data) {
|
|
31900
31521
|
if (this.hasLogger()) {
|
|
31901
|
-
let {
|
|
31902
|
-
topic,
|
|
31903
|
-
event,
|
|
31904
|
-
payload,
|
|
31905
|
-
ref,
|
|
31906
|
-
join_ref
|
|
31907
|
-
} = data;
|
|
31522
|
+
let { topic, event, payload, ref, join_ref } = data;
|
|
31908
31523
|
this.log("push", `${topic} ${event} (${join_ref}, ${ref})`, payload);
|
|
31909
31524
|
}
|
|
31910
|
-
|
|
31911
31525
|
if (this.isConnected()) {
|
|
31912
|
-
this.encode(data, result => this.conn.send(result));
|
|
31526
|
+
this.encode(data, (result) => this.conn.send(result));
|
|
31913
31527
|
} else {
|
|
31914
|
-
this.sendBuffer.push(() => this.encode(data, result => this.conn.send(result)));
|
|
31528
|
+
this.sendBuffer.push(() => this.encode(data, (result) => this.conn.send(result)));
|
|
31915
31529
|
}
|
|
31916
31530
|
}
|
|
31917
|
-
|
|
31918
31531
|
makeRef() {
|
|
31919
31532
|
let newRef = this.ref + 1;
|
|
31920
|
-
|
|
31921
31533
|
if (newRef === this.ref) {
|
|
31922
31534
|
this.ref = 0;
|
|
31923
31535
|
} else {
|
|
31924
31536
|
this.ref = newRef;
|
|
31925
31537
|
}
|
|
31926
|
-
|
|
31927
31538
|
return this.ref.toString();
|
|
31928
31539
|
}
|
|
31929
|
-
|
|
31930
31540
|
sendHeartbeat() {
|
|
31931
31541
|
if (this.pendingHeartbeatRef && !this.isConnected()) {
|
|
31932
31542
|
return;
|
|
31933
31543
|
}
|
|
31934
|
-
|
|
31935
31544
|
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);
|
|
31545
|
+
this.push({ topic: "phoenix", event: "heartbeat", payload: {}, ref: this.pendingHeartbeatRef });
|
|
31546
|
+
this.heartbeatTimer = setTimeout(() => this.heartbeatTimeout(), this.heartbeatIntervalMs);
|
|
31943
31547
|
}
|
|
31944
|
-
|
|
31945
31548
|
abnormalClose(reason) {
|
|
31946
31549
|
this.closeWasClean = false;
|
|
31947
|
-
|
|
31948
31550
|
if (this.isConnected()) {
|
|
31949
31551
|
this.conn.close(WS_CLOSE_NORMAL, reason);
|
|
31950
31552
|
}
|
|
31951
31553
|
}
|
|
31952
|
-
|
|
31953
31554
|
flushSendBuffer() {
|
|
31954
31555
|
if (this.isConnected() && this.sendBuffer.length > 0) {
|
|
31955
|
-
|
|
31956
|
-
|
|
31957
|
-
for_each_default()(_context31 = this.sendBuffer).call(_context31, callback => callback());
|
|
31958
|
-
|
|
31556
|
+
this.sendBuffer.forEach((callback) => callback());
|
|
31959
31557
|
this.sendBuffer = [];
|
|
31960
31558
|
}
|
|
31961
31559
|
}
|
|
31962
|
-
|
|
31963
31560
|
onConnMessage(rawMessage) {
|
|
31964
|
-
this.decode(rawMessage.data, msg => {
|
|
31965
|
-
let {
|
|
31966
|
-
topic,
|
|
31967
|
-
event,
|
|
31968
|
-
payload,
|
|
31969
|
-
ref,
|
|
31970
|
-
join_ref
|
|
31971
|
-
} = msg;
|
|
31972
|
-
|
|
31561
|
+
this.decode(rawMessage.data, (msg) => {
|
|
31562
|
+
let { topic, event, payload, ref, join_ref } = msg;
|
|
31973
31563
|
if (ref && ref === this.pendingHeartbeatRef) {
|
|
31974
31564
|
clearTimeout(this.heartbeatTimer);
|
|
31975
31565
|
this.pendingHeartbeatRef = null;
|
|
31976
|
-
|
|
31977
|
-
set_timeout_default()(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
|
31566
|
+
setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
|
31978
31567
|
}
|
|
31979
|
-
|
|
31980
|
-
|
|
31981
|
-
|
|
31568
|
+
if (this.hasLogger())
|
|
31569
|
+
this.log("receive", `${payload.status || ""} ${topic} ${event} ${ref && "(" + ref + ")" || ""}`, payload);
|
|
31982
31570
|
for (let i = 0; i < this.channels.length; i++) {
|
|
31983
31571
|
const channel = this.channels[i];
|
|
31984
|
-
|
|
31985
31572
|
if (!channel.isMember(topic, event, payload, join_ref)) {
|
|
31986
31573
|
continue;
|
|
31987
31574
|
}
|
|
31988
|
-
|
|
31989
31575
|
channel.trigger(event, payload, ref, join_ref);
|
|
31990
31576
|
}
|
|
31991
|
-
|
|
31992
31577
|
for (let i = 0; i < this.stateChangeCallbacks.message.length; i++) {
|
|
31993
31578
|
let [, callback] = this.stateChangeCallbacks.message[i];
|
|
31994
31579
|
callback(msg);
|
|
31995
31580
|
}
|
|
31996
31581
|
});
|
|
31997
31582
|
}
|
|
31998
|
-
|
|
31999
31583
|
leaveOpenTopic(topic) {
|
|
32000
|
-
|
|
32001
|
-
|
|
32002
|
-
let dupChannel = find_default()(_context32 = this.channels).call(_context32, c => c.topic === topic && (c.isJoined() || c.isJoining()));
|
|
32003
|
-
|
|
31584
|
+
let dupChannel = this.channels.find((c) => c.topic === topic && (c.isJoined() || c.isJoining()));
|
|
32004
31585
|
if (dupChannel) {
|
|
32005
|
-
if (this.hasLogger())
|
|
31586
|
+
if (this.hasLogger())
|
|
31587
|
+
this.log("transport", `leaving duplicate topic "${topic}"`);
|
|
32006
31588
|
dupChannel.leave();
|
|
32007
31589
|
}
|
|
32008
31590
|
}
|
|
32009
|
-
|
|
32010
31591
|
};
|
|
32011
31592
|
|
|
31593
|
+
//# sourceMappingURL=phoenix.mjs.map
|
|
31594
|
+
|
|
32012
31595
|
;// CONCATENATED MODULE: ./src/javascripts/lib/split-url-params.js
|
|
32013
31596
|
|
|
32014
31597
|
|
|
@@ -32759,7 +32342,7 @@ class API {
|
|
|
32759
32342
|
return {
|
|
32760
32343
|
clientName: "@seamly/web-ui",
|
|
32761
32344
|
clientVariant: this.layoutMode,
|
|
32762
|
-
clientVersion: "20.
|
|
32345
|
+
clientVersion: "20.7.0",
|
|
32763
32346
|
currentUrl: window.location.toString(),
|
|
32764
32347
|
screenResolution: `${window.screen.width}x${window.screen.height}`,
|
|
32765
32348
|
timezone: getTimeZone(),
|
|
@@ -32768,39 +32351,6 @@ class API {
|
|
|
32768
32351
|
}
|
|
32769
32352
|
|
|
32770
32353
|
}
|
|
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
32354
|
;// CONCATENATED MODULE: ./src/javascripts/domains/options/middleware.js
|
|
32805
32355
|
|
|
32806
32356
|
|
|
@@ -32841,6 +32391,39 @@ function options_middleware_createMiddleware(_ref) {
|
|
|
32841
32391
|
}
|
|
32842
32392
|
;// CONCATENATED MODULE: ./src/javascripts/domains/options/index.js
|
|
32843
32393
|
|
|
32394
|
+
;// CONCATENATED MODULE: ./node_modules/redux-thunk/es/index.js
|
|
32395
|
+
/** A function that accepts a potential "extra argument" value to be injected later,
|
|
32396
|
+
* and returns an instance of the thunk middleware that uses that value
|
|
32397
|
+
*/
|
|
32398
|
+
function createThunkMiddleware(extraArgument) {
|
|
32399
|
+
// Standard Redux middleware definition pattern:
|
|
32400
|
+
// See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
|
|
32401
|
+
var middleware = function middleware(_ref) {
|
|
32402
|
+
var dispatch = _ref.dispatch,
|
|
32403
|
+
getState = _ref.getState;
|
|
32404
|
+
return function (next) {
|
|
32405
|
+
return function (action) {
|
|
32406
|
+
// The thunk middleware looks for any functions that were passed to `store.dispatch`.
|
|
32407
|
+
// If this "action" is really a function, call it and return the result.
|
|
32408
|
+
if (typeof action === 'function') {
|
|
32409
|
+
// Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
|
|
32410
|
+
return action(dispatch, getState, extraArgument);
|
|
32411
|
+
} // Otherwise, pass the action down the middleware chain as usual
|
|
32412
|
+
|
|
32413
|
+
|
|
32414
|
+
return next(action);
|
|
32415
|
+
};
|
|
32416
|
+
};
|
|
32417
|
+
};
|
|
32418
|
+
|
|
32419
|
+
return middleware;
|
|
32420
|
+
}
|
|
32421
|
+
|
|
32422
|
+
var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
|
|
32423
|
+
// with whatever "extra arg" they want to inject into their thunks
|
|
32424
|
+
|
|
32425
|
+
thunk.withExtraArgument = createThunkMiddleware;
|
|
32426
|
+
/* harmony default export */ var es = (thunk);
|
|
32844
32427
|
;// CONCATENATED MODULE: ./src/javascripts/domains/store/state-reducer.js
|
|
32845
32428
|
// Legacy state reducer. Do not add new features here but extract/create new reducers as needed
|
|
32846
32429
|
|
|
@@ -32943,7 +32526,7 @@ function store_createStore() {
|
|
|
32943
32526
|
api
|
|
32944
32527
|
}), options_middleware_createMiddleware({
|
|
32945
32528
|
api
|
|
32946
|
-
}), middleware_createMiddleware
|
|
32529
|
+
}), middleware_createMiddleware]
|
|
32947
32530
|
});
|
|
32948
32531
|
return store;
|
|
32949
32532
|
}
|