@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
package/build/dist/lib/index.js
CHANGED
|
@@ -7332,7 +7332,7 @@ function createAction(type, identityReducer = payload => ({
|
|
|
7332
7332
|
|
|
7333
7333
|
action.toString = () => String(type);
|
|
7334
7334
|
|
|
7335
|
-
action.match = obj => obj
|
|
7335
|
+
action.match = obj => (obj === null || obj === void 0 ? void 0 : obj.type) === String(type);
|
|
7336
7336
|
|
|
7337
7337
|
return action;
|
|
7338
7338
|
}
|
|
@@ -7422,7 +7422,7 @@ function createThunk(type, payloadCreator) {
|
|
|
7422
7422
|
}
|
|
7423
7423
|
function createReducer(domain, handlers = {}, defaultState) {
|
|
7424
7424
|
const reducer = (state = defaultState, action) => {
|
|
7425
|
-
const typeReducer = handlers
|
|
7425
|
+
const typeReducer = handlers === null || handlers === void 0 ? void 0 : handlers[action === null || action === void 0 ? void 0 : action.type];
|
|
7426
7426
|
return typeReducer ? typeReducer(state, action) : state;
|
|
7427
7427
|
};
|
|
7428
7428
|
|
|
@@ -7757,7 +7757,7 @@ function selectors_defineProperty(obj, key, value) { if (key in obj) { Object.de
|
|
|
7757
7757
|
|
|
7758
7758
|
const selectConfig = createSelector(selectState, config => {
|
|
7759
7759
|
let newConfig = selectors_objectSpread({
|
|
7760
|
-
visible: config
|
|
7760
|
+
visible: (config === null || config === void 0 ? void 0 : config.layoutMode) === 'inline' ? visibilityStates.open : visibilityStates.minimized,
|
|
7761
7761
|
appContainerClassNames: config.appContainerClassNames || []
|
|
7762
7762
|
}, config);
|
|
7763
7763
|
|
|
@@ -8594,6 +8594,8 @@ function hooks_useSelector(selector, deps = []) {
|
|
|
8594
8594
|
(0,hooks_namespaceObject.useLayoutEffect)(() => {
|
|
8595
8595
|
// we subscribe to the store changes
|
|
8596
8596
|
return store.subscribe(() => {
|
|
8597
|
+
var _selectorRef$current;
|
|
8598
|
+
|
|
8597
8599
|
const newState = store.getState(); // prevent recalculating if the state hasn't changed
|
|
8598
8600
|
// if the selector changed, it was already handled synchronously
|
|
8599
8601
|
|
|
@@ -8602,7 +8604,7 @@ function hooks_useSelector(selector, deps = []) {
|
|
|
8602
8604
|
} // calculate the new value based on selector+state
|
|
8603
8605
|
|
|
8604
8606
|
|
|
8605
|
-
const newValue = selectorRef.current
|
|
8607
|
+
const newValue = (_selectorRef$current = selectorRef.current) === null || _selectorRef$current === void 0 ? void 0 : _selectorRef$current.call(selectorRef, store.getState()); // only if the value changed we update. this saves heaps of re-rendering
|
|
8606
8608
|
|
|
8607
8609
|
if (newValue !== valueRef.current) {
|
|
8608
8610
|
valueRef.current = newValue;
|
|
@@ -8877,6 +8879,7 @@ function seamly_utils_objectSpread(target) { for (var i = 1; i < arguments.lengt
|
|
|
8877
8879
|
function seamly_utils_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8878
8880
|
|
|
8879
8881
|
|
|
8882
|
+
|
|
8880
8883
|
const eventTypes = {
|
|
8881
8884
|
info: 'info',
|
|
8882
8885
|
message: 'message',
|
|
@@ -9168,9 +9171,9 @@ const seamlyStateReducer = (state, action) => {
|
|
|
9168
9171
|
|
|
9169
9172
|
|
|
9170
9173
|
if (accountHasUploads && (eventType === eventTypes.message || eventType === eventTypes.participant) && !payload.fromClient) {
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
+
var _payload$entry;
|
|
9175
|
+
|
|
9176
|
+
const entryType = payload === null || payload === void 0 ? void 0 : (_payload$entry = payload.entry) === null || _payload$entry === void 0 ? void 0 : _payload$entry.type;
|
|
9174
9177
|
newOptions = seamly_utils_objectSpread(seamly_utils_objectSpread({}, newOptions), {}, {
|
|
9175
9178
|
features: seamly_utils_objectSpread(seamly_utils_objectSpread({}, newOptions.features), {}, {
|
|
9176
9179
|
uploads: seamly_utils_objectSpread(seamly_utils_objectSpread({}, newOptions.features.uploads), {}, {
|
|
@@ -9200,7 +9203,10 @@ const seamlyStateReducer = (state, action) => {
|
|
|
9200
9203
|
// event optimistically.
|
|
9201
9204
|
payload: seamly_utils_objectSpread(seamly_utils_objectSpread({}, incrementUnread && {
|
|
9202
9205
|
messageStatus: payload.fromClient ? readStates.read : readStates.received
|
|
9203
|
-
}),
|
|
9206
|
+
}), {}, {
|
|
9207
|
+
// We add a randomid to use as key for mapping of Events to avoid rerendering
|
|
9208
|
+
key: randomId()
|
|
9209
|
+
}, payload)
|
|
9204
9210
|
})]
|
|
9205
9211
|
});
|
|
9206
9212
|
|
|
@@ -9294,12 +9300,9 @@ const seamlyStateReducer = (state, action) => {
|
|
|
9294
9300
|
const newFeaturesHasUpload = newFeatures.hasOwnProperty(featureKeys.uploads); // Only set uploads if it was initialised by the account config.
|
|
9295
9301
|
|
|
9296
9302
|
if (newFeaturesHasUpload) {
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
const {
|
|
9301
|
-
type: entryType
|
|
9302
|
-
} = lastParticipantEventPayload.entry || {};
|
|
9303
|
+
var _lastParticipantEvent, _lastParticipantEvent2;
|
|
9304
|
+
|
|
9305
|
+
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;
|
|
9303
9306
|
newFeatures = seamly_utils_objectSpread(seamly_utils_objectSpread({}, newFeatures), {}, {
|
|
9304
9307
|
uploads: {
|
|
9305
9308
|
enabled: !!(uploads && uploads.enabled),
|
|
@@ -9755,7 +9758,9 @@ const selectEventsWithSuggestion = createSelector(seamly_state_hooks_selectState
|
|
|
9755
9758
|
events,
|
|
9756
9759
|
serviceData
|
|
9757
9760
|
}, config, userHasResponded) => {
|
|
9758
|
-
|
|
9761
|
+
var _serviceData$suggesti;
|
|
9762
|
+
|
|
9763
|
+
if (userHasResponded || config.layoutMode === 'inline' || !serviceData.suggestion || !((_serviceData$suggesti = serviceData.suggestion) !== null && _serviceData$suggesti !== void 0 && _serviceData$suggesti.body.length)) {
|
|
9759
9764
|
return events;
|
|
9760
9765
|
}
|
|
9761
9766
|
|
|
@@ -9766,10 +9771,12 @@ const selectEventsWithSuggestion = createSelector(seamly_state_hooks_selectState
|
|
|
9766
9771
|
return [...events, suggestionsEvent];
|
|
9767
9772
|
});
|
|
9768
9773
|
const selectEvents = createSelector(selectEventsWithSuggestion, selectConfig, (events, config) => {
|
|
9774
|
+
var _config$messages;
|
|
9775
|
+
|
|
9769
9776
|
const {
|
|
9770
9777
|
enabled,
|
|
9771
9778
|
threshold
|
|
9772
|
-
} = config
|
|
9779
|
+
} = (config === null || config === void 0 ? void 0 : (_config$messages = config.messages) === null || _config$messages === void 0 ? void 0 : _config$messages.timeIndicator) ?? {};
|
|
9773
9780
|
|
|
9774
9781
|
if (!enabled) {
|
|
9775
9782
|
return events;
|
|
@@ -9803,8 +9810,10 @@ const useSkiplink = () => useSeamlyStateContext().skiplinkTargetId;
|
|
|
9803
9810
|
const useSeamlyParticipant = participantId => useSeamlyStateContext().participantInfo.participants[participantId];
|
|
9804
9811
|
const useSeamlyServiceInfo = () => useSeamlyStateContext().serviceInfo;
|
|
9805
9812
|
const selectLastMessageEventId = createSelector(selectEvents, events => {
|
|
9813
|
+
var _filteredEvents;
|
|
9814
|
+
|
|
9806
9815
|
const filteredEvents = events.filter(event => event.type === 'message');
|
|
9807
|
-
return filteredEvents[filteredEvents.length - 1]
|
|
9816
|
+
return (_filteredEvents = filteredEvents[filteredEvents.length - 1]) === null || _filteredEvents === void 0 ? void 0 : _filteredEvents.payload.id;
|
|
9808
9817
|
});
|
|
9809
9818
|
const useLastMessageEventId = () => hooks_useSelector(selectLastMessageEventId);
|
|
9810
9819
|
const useSeamlyIsHistoryLoaded = () => useSeamlyStateContext().historyLoaded;
|
|
@@ -9973,11 +9982,13 @@ const actions_initialize = visibility_utils_createThunk('initialize', async (loc
|
|
|
9973
9982
|
api
|
|
9974
9983
|
}
|
|
9975
9984
|
}) => {
|
|
9985
|
+
var _api$store$get;
|
|
9986
|
+
|
|
9976
9987
|
// initialize stored visibility
|
|
9977
9988
|
const {
|
|
9978
9989
|
layoutMode
|
|
9979
9990
|
} = selectConfig(getState());
|
|
9980
|
-
const storedVisibility = api.store.get(StoreKey)
|
|
9991
|
+
const storedVisibility = (_api$store$get = api.store.get(StoreKey)) === null || _api$store$get === void 0 ? void 0 : _api$store$get[layoutMode];
|
|
9981
9992
|
|
|
9982
9993
|
if (storedVisibility) {
|
|
9983
9994
|
dispatch(setFromStorage(storedVisibility));
|
|
@@ -10015,13 +10026,13 @@ class SeamlyBaseError extends Error {
|
|
|
10015
10026
|
|
|
10016
10027
|
this.originalError = originalError;
|
|
10017
10028
|
|
|
10018
|
-
if (originalError
|
|
10029
|
+
if (originalError !== null && originalError !== void 0 && originalError.payload) {
|
|
10019
10030
|
this.originalEvent = originalError;
|
|
10020
10031
|
this.originalError = originalError.payload.error;
|
|
10021
10032
|
this.message = `Event of type ${originalError.payload.type} encountered`;
|
|
10022
10033
|
}
|
|
10023
10034
|
|
|
10024
|
-
if (originalError
|
|
10035
|
+
if (originalError !== null && originalError !== void 0 && originalError.error) {
|
|
10025
10036
|
this.originalError = originalError.error;
|
|
10026
10037
|
}
|
|
10027
10038
|
}
|
|
@@ -10070,8 +10081,10 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
10070
10081
|
config
|
|
10071
10082
|
}
|
|
10072
10083
|
}) => {
|
|
10084
|
+
var _config$context;
|
|
10085
|
+
|
|
10073
10086
|
dispatch(initialize(config));
|
|
10074
|
-
let locale = config
|
|
10087
|
+
let locale = config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale;
|
|
10075
10088
|
|
|
10076
10089
|
try {
|
|
10077
10090
|
const {
|
|
@@ -10098,7 +10111,7 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
10098
10111
|
startChatIcon
|
|
10099
10112
|
}));
|
|
10100
10113
|
|
|
10101
|
-
if (agentParticipant
|
|
10114
|
+
if (agentParticipant !== null && agentParticipant !== void 0 && agentParticipant.name) {
|
|
10102
10115
|
dispatch({
|
|
10103
10116
|
type: seamlyActions.SET_HEADER_SUB_TITLE,
|
|
10104
10117
|
title: agentParticipant.name
|
|
@@ -10110,18 +10123,22 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
10110
10123
|
|
|
10111
10124
|
try {
|
|
10112
10125
|
if (api.hasConversation()) {
|
|
10126
|
+
var _initialState$transla;
|
|
10127
|
+
|
|
10113
10128
|
const initialState = await api.getConversationIntitialState();
|
|
10114
10129
|
dispatch({
|
|
10115
10130
|
type: seamlyActions.SET_INITIAL_STATE,
|
|
10116
10131
|
initialState
|
|
10117
10132
|
});
|
|
10118
|
-
locale = initialState.translation
|
|
10133
|
+
locale = ((_initialState$transla = initialState.translation) === null || _initialState$transla === void 0 ? void 0 : _initialState$transla.locale) || locale;
|
|
10119
10134
|
|
|
10120
10135
|
if ('userResponded' in initialState) {
|
|
10121
10136
|
dispatch(setHasResponded(initialState.userResponded));
|
|
10122
10137
|
}
|
|
10123
10138
|
} else {
|
|
10124
|
-
|
|
10139
|
+
var _config$context2, _config$context3;
|
|
10140
|
+
|
|
10141
|
+
if (config !== null && config !== void 0 && (_config$context2 = config.context) !== null && _config$context2 !== void 0 && _config$context2.topic) {
|
|
10125
10142
|
api.send('action', {
|
|
10126
10143
|
type: actionTypes.setTopic,
|
|
10127
10144
|
body: {
|
|
@@ -10133,7 +10150,7 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
10133
10150
|
});
|
|
10134
10151
|
}
|
|
10135
10152
|
|
|
10136
|
-
if (config
|
|
10153
|
+
if (config !== null && config !== void 0 && (_config$context3 = config.context) !== null && _config$context3 !== void 0 && _config$context3.translationLocale) {
|
|
10137
10154
|
locale = config.context.translationLocale;
|
|
10138
10155
|
api.send('action', {
|
|
10139
10156
|
type: actionTypes.setTranslation,
|
|
@@ -11537,13 +11554,13 @@ const useIntersect = ({
|
|
|
11537
11554
|
}) => {
|
|
11538
11555
|
const [entry, setEntry] = (0,hooks_namespaceObject.useState)(null);
|
|
11539
11556
|
const containerRef = (0,hooks_namespaceObject.useRef)(null);
|
|
11540
|
-
const isVisible = !!entry
|
|
11557
|
+
const isVisible = !!(entry !== null && entry !== void 0 && entry.isIntersecting) || !enabled;
|
|
11541
11558
|
const frozen = isVisible && freezeOnceVisible;
|
|
11542
11559
|
|
|
11543
11560
|
const observerCallback = ([updatedEntry]) => setEntry(updatedEntry);
|
|
11544
11561
|
|
|
11545
11562
|
(0,hooks_namespaceObject.useEffect)(() => {
|
|
11546
|
-
const node = containerRef
|
|
11563
|
+
const node = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
|
|
11547
11564
|
const hasIOSupport = !!window.IntersectionObserver;
|
|
11548
11565
|
|
|
11549
11566
|
if (!node && "production" === 'development') {} // Return an arrow function to have a consistent return value
|
|
@@ -11802,20 +11819,6 @@ const useSeamlyCommands = () => {
|
|
|
11802
11819
|
}
|
|
11803
11820
|
});
|
|
11804
11821
|
}, [dispatch]);
|
|
11805
|
-
const sendInfo = (0,hooks_namespaceObject.useCallback)(({
|
|
11806
|
-
type,
|
|
11807
|
-
subtype
|
|
11808
|
-
}) => {
|
|
11809
|
-
const info = {
|
|
11810
|
-
type,
|
|
11811
|
-
subtype,
|
|
11812
|
-
id: randomId(),
|
|
11813
|
-
transactionId: randomId(),
|
|
11814
|
-
participant: userParticipantId,
|
|
11815
|
-
fromClient: true
|
|
11816
|
-
};
|
|
11817
|
-
api.send('info', info);
|
|
11818
|
-
}, [api]);
|
|
11819
11822
|
const sendAction = (0,hooks_namespaceObject.useCallback)(body => {
|
|
11820
11823
|
if (!body) {
|
|
11821
11824
|
return;
|
|
@@ -11858,7 +11861,6 @@ const useSeamlyCommands = () => {
|
|
|
11858
11861
|
connect,
|
|
11859
11862
|
start,
|
|
11860
11863
|
sendMessage,
|
|
11861
|
-
sendInfo,
|
|
11862
11864
|
sendAction,
|
|
11863
11865
|
sendContext,
|
|
11864
11866
|
reset,
|
|
@@ -12530,19 +12532,21 @@ function useTranslations() {
|
|
|
12530
12532
|
function useTranslatedEventData({
|
|
12531
12533
|
payload
|
|
12532
12534
|
} = {}) {
|
|
12533
|
-
|
|
12535
|
+
var _translatedBody, _translatedBody2, _translatedBody3;
|
|
12536
|
+
|
|
12537
|
+
const payloadId = payload === null || payload === void 0 ? void 0 : payload.id;
|
|
12534
12538
|
let body;
|
|
12535
12539
|
let translatedBody;
|
|
12536
12540
|
|
|
12537
|
-
switch (payload
|
|
12541
|
+
switch (payload === null || payload === void 0 ? void 0 : payload.type) {
|
|
12538
12542
|
case 'participant':
|
|
12539
12543
|
body = payload.participant.introduction;
|
|
12540
12544
|
translatedBody = payload.participant.translatedIntroduction;
|
|
12541
12545
|
break;
|
|
12542
12546
|
|
|
12543
12547
|
default:
|
|
12544
|
-
body = payload
|
|
12545
|
-
translatedBody = payload
|
|
12548
|
+
body = payload === null || payload === void 0 ? void 0 : payload.body;
|
|
12549
|
+
translatedBody = payload === null || payload === void 0 ? void 0 : payload.translatedBody;
|
|
12546
12550
|
}
|
|
12547
12551
|
|
|
12548
12552
|
const hasTranslation = !!translatedBody;
|
|
@@ -12557,12 +12561,12 @@ function useTranslatedEventData({
|
|
|
12557
12561
|
dispatch(enableEvent(payloadId));
|
|
12558
12562
|
}
|
|
12559
12563
|
}, [isTranslated, payloadId, dispatch]);
|
|
12560
|
-
return [hasTranslation && isTranslated ? translatedBody
|
|
12564
|
+
return [hasTranslation && isTranslated ? (_translatedBody = translatedBody) === null || _translatedBody === void 0 ? void 0 : _translatedBody.data : body, {
|
|
12561
12565
|
hasTranslation,
|
|
12562
12566
|
isTranslated: isTranslated && hasTranslation,
|
|
12563
12567
|
toggleTranslation,
|
|
12564
|
-
translatedBy: translatedBody
|
|
12565
|
-
locale: translatedBody
|
|
12568
|
+
translatedBy: (_translatedBody2 = translatedBody) === null || _translatedBody2 === void 0 ? void 0 : _translatedBody2.translatedBy,
|
|
12569
|
+
locale: (_translatedBody3 = translatedBody) === null || _translatedBody3 === void 0 ? void 0 : _translatedBody3.locale
|
|
12566
12570
|
}];
|
|
12567
12571
|
}
|
|
12568
12572
|
function useTranslationsContainer() {
|
|
@@ -12577,49 +12581,58 @@ function useLocaleNativeName(locale) {
|
|
|
12577
12581
|
const {
|
|
12578
12582
|
languages
|
|
12579
12583
|
} = useTranslations();
|
|
12580
|
-
return (0,hooks_namespaceObject.useMemo)(() =>
|
|
12584
|
+
return (0,hooks_namespaceObject.useMemo)(() => {
|
|
12585
|
+
var _languages$find;
|
|
12586
|
+
|
|
12587
|
+
return languages === null || languages === void 0 ? void 0 : (_languages$find = languages.find(lang => lang.locale === locale)) === null || _languages$find === void 0 ? void 0 : _languages$find.nativeName;
|
|
12588
|
+
}, [locale, languages]);
|
|
12581
12589
|
}
|
|
12582
12590
|
;// CONCATENATED MODULE: ./src/javascripts/domains/translations/middleware.js
|
|
12583
12591
|
|
|
12584
12592
|
|
|
12585
12593
|
|
|
12586
|
-
function middleware_createMiddleware(
|
|
12587
|
-
|
|
12588
|
-
|
|
12589
|
-
|
|
12590
|
-
|
|
12591
|
-
|
|
12594
|
+
function middleware_createMiddleware({
|
|
12595
|
+
dispatch,
|
|
12596
|
+
getState
|
|
12597
|
+
}) {
|
|
12598
|
+
return next => {
|
|
12599
|
+
return action => {
|
|
12600
|
+
var _action$history, _action$history$trans, _action$initialState, _action$initialState$, _action$event, _action$event$payload, _action$event$payload2;
|
|
12592
12601
|
|
|
12593
|
-
|
|
12594
|
-
case String(seamlyActions.SET_HISTORY):
|
|
12595
|
-
if (action.history?.translation?.enabled) {
|
|
12596
|
-
dispatch(enable(action.history.translation.locale));
|
|
12597
|
-
}
|
|
12602
|
+
const result = next(action);
|
|
12598
12603
|
|
|
12599
|
-
|
|
12604
|
+
switch (action.type) {
|
|
12605
|
+
case String(seamlyActions.SET_HISTORY):
|
|
12606
|
+
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) {
|
|
12607
|
+
dispatch(enable(action.history.translation.locale));
|
|
12608
|
+
dispatch(setLocale(action.history.translation.locale));
|
|
12609
|
+
}
|
|
12600
12610
|
|
|
12601
|
-
|
|
12602
|
-
if (action.initialState?.translation?.enabled) {
|
|
12603
|
-
dispatch(enable(action.initialState.translation.locale));
|
|
12604
|
-
dispatch(setLocale(action.locale));
|
|
12605
|
-
}
|
|
12611
|
+
break;
|
|
12606
12612
|
|
|
12607
|
-
|
|
12613
|
+
case String(seamlyActions.SET_INITIAL_STATE):
|
|
12614
|
+
if ((_action$initialState = action.initialState) !== null && _action$initialState !== void 0 && (_action$initialState$ = _action$initialState.translation) !== null && _action$initialState$ !== void 0 && _action$initialState$.enabled) {
|
|
12615
|
+
dispatch(enable(action.initialState.translation.locale));
|
|
12616
|
+
dispatch(setLocale(action.locale));
|
|
12617
|
+
}
|
|
12608
12618
|
|
|
12609
|
-
|
|
12610
|
-
if (action.event.type === 'info' && action.event?.payload?.body?.subtype === 'new_translation' && action.event.payload.body.translationEnabled) {
|
|
12611
|
-
dispatch(setLocale(action.event.payload.body.translationLocale));
|
|
12612
|
-
}
|
|
12619
|
+
break;
|
|
12613
12620
|
|
|
12614
|
-
|
|
12621
|
+
case String(seamlyActions.ADD_EVENT):
|
|
12622
|
+
if (action.event.type === 'info' && ((_action$event = action.event) === null || _action$event === void 0 ? void 0 : (_action$event$payload = _action$event.payload) === null || _action$event$payload === void 0 ? void 0 : (_action$event$payload2 = _action$event$payload.body) === null || _action$event$payload2 === void 0 ? void 0 : _action$event$payload2.subtype) === 'new_translation' && action.event.payload.body.translationEnabled) {
|
|
12623
|
+
dispatch(setLocale(action.event.payload.body.translationLocale));
|
|
12624
|
+
}
|
|
12615
12625
|
|
|
12616
|
-
|
|
12617
|
-
const initialLocale = selectInitialLocale(getState());
|
|
12618
|
-
dispatch(setLocale(initialLocale));
|
|
12619
|
-
break;
|
|
12620
|
-
}
|
|
12626
|
+
break;
|
|
12621
12627
|
|
|
12622
|
-
|
|
12628
|
+
case String(disable):
|
|
12629
|
+
const initialLocale = selectInitialLocale(getState());
|
|
12630
|
+
dispatch(setLocale(initialLocale));
|
|
12631
|
+
break;
|
|
12632
|
+
}
|
|
12633
|
+
|
|
12634
|
+
return result;
|
|
12635
|
+
};
|
|
12623
12636
|
};
|
|
12624
12637
|
}
|
|
12625
12638
|
;// CONCATENATED MODULE: ./src/javascripts/domains/translations/reducer.js
|
|
@@ -12644,7 +12657,9 @@ const translations_reducer_initialState = {
|
|
|
12644
12657
|
};
|
|
12645
12658
|
/* harmony default export */ const translations_reducer = (translations_utils_createReducer({
|
|
12646
12659
|
[seamlyActions.SET_FEATURES]: (state, action) => {
|
|
12647
|
-
|
|
12660
|
+
var _action$features;
|
|
12661
|
+
|
|
12662
|
+
const feature = action === null || action === void 0 ? void 0 : (_action$features = action.features) === null || _action$features === void 0 ? void 0 : _action$features.translation;
|
|
12648
12663
|
|
|
12649
12664
|
if (!feature) {
|
|
12650
12665
|
return state;
|
|
@@ -12997,7 +13012,9 @@ function validate(values, schema = {}) {
|
|
|
12997
13012
|
validations = [validations];
|
|
12998
13013
|
}
|
|
12999
13014
|
|
|
13000
|
-
for (let i = 0; i < validations
|
|
13015
|
+
for (let i = 0; i < ((_validations = validations) === null || _validations === void 0 ? void 0 : _validations.length) ?? 0; i++) {
|
|
13016
|
+
var _validations;
|
|
13017
|
+
|
|
13001
13018
|
if (!validations[i].fn(values[key], validations[i].compareValue)) {
|
|
13002
13019
|
errors[key] = validations[i].errorText;
|
|
13003
13020
|
break;
|
|
@@ -13044,7 +13061,7 @@ const [registerControl, deregisterControl, actions_updateControlValue, actions_u
|
|
|
13044
13061
|
|
|
13045
13062
|
const selectors_getState = forms_utils_selectState;
|
|
13046
13063
|
const getFormById = createSelector(selectors_getState, getPropSelector('formId'), (forms, formId) => forms[formId]);
|
|
13047
|
-
const getFormControlsByFormId = createSelector(getFormById, form => form
|
|
13064
|
+
const getFormControlsByFormId = createSelector(getFormById, form => (form === null || form === void 0 ? void 0 : form.controls) || {});
|
|
13048
13065
|
const getFormValuesByFormId = createSelector(getFormControlsByFormId, controls => {
|
|
13049
13066
|
const valuesObj = {};
|
|
13050
13067
|
Object.entries(controls).forEach(([key, {
|
|
@@ -13054,8 +13071,16 @@ const getFormValuesByFormId = createSelector(getFormControlsByFormId, controls =
|
|
|
13054
13071
|
});
|
|
13055
13072
|
return valuesObj;
|
|
13056
13073
|
});
|
|
13057
|
-
const getControlValueByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) =>
|
|
13058
|
-
|
|
13074
|
+
const getControlValueByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => {
|
|
13075
|
+
var _controls$name;
|
|
13076
|
+
|
|
13077
|
+
return (_controls$name = controls[name]) === null || _controls$name === void 0 ? void 0 : _controls$name.value;
|
|
13078
|
+
});
|
|
13079
|
+
const getControlTouchedByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => {
|
|
13080
|
+
var _controls$name2;
|
|
13081
|
+
|
|
13082
|
+
return (_controls$name2 = controls[name]) === null || _controls$name2 === void 0 ? void 0 : _controls$name2.touched;
|
|
13083
|
+
});
|
|
13059
13084
|
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/context.js
|
|
13060
13085
|
|
|
13061
13086
|
const FormContext = (0,external_preact_namespaceObject.createContext)({});
|
|
@@ -13115,7 +13140,7 @@ function useFormControl(name) {
|
|
|
13115
13140
|
formId,
|
|
13116
13141
|
name
|
|
13117
13142
|
}, [formId, name]);
|
|
13118
|
-
const error = errors
|
|
13143
|
+
const error = errors === null || errors === void 0 ? void 0 : errors[name];
|
|
13119
13144
|
const isValid = !error;
|
|
13120
13145
|
(0,hooks_namespaceObject.useEffect)(() => {
|
|
13121
13146
|
// Make sure the form is registered
|
|
@@ -13217,9 +13242,11 @@ function FormProvider(_ref) {
|
|
|
13217
13242
|
});
|
|
13218
13243
|
}, [setExternalErrors]);
|
|
13219
13244
|
const handleSubmit = (0,hooks_namespaceObject.useCallback)(e => {
|
|
13245
|
+
var _e$submitter;
|
|
13246
|
+
|
|
13220
13247
|
e.preventDefault(); // If the submitter is set to being aria-disabled, block the submit action
|
|
13221
13248
|
|
|
13222
|
-
const ariaDisabled = e.submitter
|
|
13249
|
+
const ariaDisabled = ((_e$submitter = e.submitter) === null || _e$submitter === void 0 ? void 0 : _e$submitter.ariaDisabled) === 'true';
|
|
13223
13250
|
setIsSubmitted(!ariaDisabled);
|
|
13224
13251
|
|
|
13225
13252
|
if (!ariaDisabled && validationIsValid) {
|
|
@@ -13286,7 +13313,9 @@ const initialControlState = {
|
|
|
13286
13313
|
};
|
|
13287
13314
|
|
|
13288
13315
|
function updateFormControl(state, formId, name, controlState) {
|
|
13289
|
-
|
|
13316
|
+
var _state$formId;
|
|
13317
|
+
|
|
13318
|
+
const currentControlState = ((_state$formId = state[formId]) === null || _state$formId === void 0 ? void 0 : _state$formId.controls[name]) || initialControlState;
|
|
13290
13319
|
return forms_reducer_objectSpread(forms_reducer_objectSpread({}, state), {}, {
|
|
13291
13320
|
[formId]: forms_reducer_objectSpread(forms_reducer_objectSpread({}, state[formId]), {}, {
|
|
13292
13321
|
controls: forms_reducer_objectSpread(forms_reducer_objectSpread({}, state[formId].controls), {}, {
|
|
@@ -13314,9 +13343,11 @@ function updateFormControl(state, formId, name, controlState) {
|
|
|
13314
13343
|
[deregisterForm]: (state, {
|
|
13315
13344
|
formId
|
|
13316
13345
|
}) => {
|
|
13346
|
+
var _newState$formId;
|
|
13347
|
+
|
|
13317
13348
|
const newState = forms_reducer_objectSpread({}, state);
|
|
13318
13349
|
|
|
13319
|
-
if (!newState[formId]
|
|
13350
|
+
if (!((_newState$formId = newState[formId]) !== null && _newState$formId !== void 0 && _newState$formId.persistData)) {
|
|
13320
13351
|
delete newState[formId];
|
|
13321
13352
|
}
|
|
13322
13353
|
|
|
@@ -13547,7 +13578,7 @@ const validateFileSize = (fileList, maxSize) => {
|
|
|
13547
13578
|
|
|
13548
13579
|
return isValid;
|
|
13549
13580
|
};
|
|
13550
|
-
const fileListObjectIsNotEmpty = fileListObj => !!fileListObj
|
|
13581
|
+
const fileListObjectIsNotEmpty = fileListObj => !!(fileListObj !== null && fileListObj !== void 0 && fileListObj.length) > 0;
|
|
13551
13582
|
/* eslint-disable no-control-regex */
|
|
13552
13583
|
|
|
13553
13584
|
const isEmailString = val => {
|
|
@@ -14156,16 +14187,15 @@ const SuggestionsList = ({
|
|
|
14156
14187
|
|
|
14157
14188
|
|
|
14158
14189
|
|
|
14159
|
-
|
|
14160
14190
|
|
|
14161
14191
|
|
|
14162
14192
|
const Suggestions = ({
|
|
14163
|
-
isAside
|
|
14193
|
+
isAside = false
|
|
14164
14194
|
}) => {
|
|
14165
14195
|
// generic hooks
|
|
14166
14196
|
const {
|
|
14167
|
-
|
|
14168
|
-
} =
|
|
14197
|
+
isInline
|
|
14198
|
+
} = useSeamlyLayoutMode();
|
|
14169
14199
|
const {
|
|
14170
14200
|
t
|
|
14171
14201
|
} = useI18n();
|
|
@@ -14207,11 +14237,20 @@ const Suggestions = ({
|
|
|
14207
14237
|
const prevHasSuggestions = (0,hooks_namespaceObject.useRef)(false);
|
|
14208
14238
|
const previousRenderedSuggestions = (0,hooks_namespaceObject.useRef)([]);
|
|
14209
14239
|
const hasSuggestions = !!suggestions.length;
|
|
14210
|
-
const hideSuggestions =
|
|
14240
|
+
const hideSuggestions = isInline ? (hasResponded || isOpen) && !isAside : hasResponded;
|
|
14211
14241
|
const prevHideSuggestions = (0,hooks_namespaceObject.useRef)(hideSuggestions);
|
|
14212
14242
|
const showSuggestionsContainer = hasSuggestions && !hideSuggestions;
|
|
14213
14243
|
const renderedSuggestions = hasSuggestions ? suggestions : previousRenderedSuggestions.current;
|
|
14214
|
-
previousRenderedSuggestions.current = renderedSuggestions;
|
|
14244
|
+
previousRenderedSuggestions.current = renderedSuggestions;
|
|
14245
|
+
const suggestionsClassNames = (0,hooks_namespaceObject.useMemo)(() => {
|
|
14246
|
+
const classNames = ['suggestions'];
|
|
14247
|
+
|
|
14248
|
+
if (isAside) {
|
|
14249
|
+
classNames.push('suggestions--aside');
|
|
14250
|
+
}
|
|
14251
|
+
|
|
14252
|
+
return css_className(classNames);
|
|
14253
|
+
}, [isAside]); // click handler
|
|
14215
14254
|
|
|
14216
14255
|
const handleClick = (0,hooks_namespaceObject.useCallback)(({
|
|
14217
14256
|
id,
|
|
@@ -14276,7 +14315,7 @@ const Suggestions = ({
|
|
|
14276
14315
|
isActive: showSuggestionsContainer,
|
|
14277
14316
|
transitionStartState: transitionStartStates.notRendered,
|
|
14278
14317
|
children: (0,jsx_runtime_namespaceObject.jsxs)(ContainerElement, {
|
|
14279
|
-
className:
|
|
14318
|
+
className: suggestionsClassNames,
|
|
14280
14319
|
"aria-labelledby": headingText ? sectionId : null,
|
|
14281
14320
|
ref: containerRef,
|
|
14282
14321
|
children: [headingText && (0,jsx_runtime_namespaceObject.jsx)("p", {
|
|
@@ -14544,11 +14583,13 @@ const timeFormatOptions = {
|
|
|
14544
14583
|
minute: 'numeric'
|
|
14545
14584
|
};
|
|
14546
14585
|
const useFormattedDate = date => {
|
|
14586
|
+
var _config$context;
|
|
14587
|
+
|
|
14547
14588
|
const {
|
|
14548
14589
|
t
|
|
14549
14590
|
} = useI18n();
|
|
14550
14591
|
const config = useConfig();
|
|
14551
|
-
const locale = config
|
|
14592
|
+
const locale = (config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale) ?? [];
|
|
14552
14593
|
const eventDate = new Date(date);
|
|
14553
14594
|
const currentDate = new Date();
|
|
14554
14595
|
const midnight = new Date(currentDate);
|
|
@@ -14920,9 +14961,11 @@ const useChoicePrompt = event => {
|
|
|
14920
14961
|
service
|
|
14921
14962
|
} = payload;
|
|
14922
14963
|
const subEvent = (0,hooks_namespaceObject.useMemo)(() => {
|
|
14964
|
+
var _event$payload$body;
|
|
14965
|
+
|
|
14923
14966
|
return choice_prompt_objectSpread(choice_prompt_objectSpread({}, event), {}, {
|
|
14924
14967
|
payload: choice_prompt_objectSpread(choice_prompt_objectSpread({}, event.payload), {}, {
|
|
14925
|
-
body: event.payload.body
|
|
14968
|
+
body: (_event$payload$body = event.payload.body) === null || _event$payload$body === void 0 ? void 0 : _event$payload$body.prompt,
|
|
14926
14969
|
translatedBody: event.payload.translatedBody && choice_prompt_objectSpread(choice_prompt_objectSpread({}, event.payload.translatedBody), {}, {
|
|
14927
14970
|
data: event.payload.translatedBody.data.prompt
|
|
14928
14971
|
})
|
|
@@ -17535,7 +17578,7 @@ const ConversationSuggestions = _ref => {
|
|
|
17535
17578
|
|
|
17536
17579
|
const hasLastTransactionEvent = (0,hooks_namespaceObject.useMemo)(() => events.some(({
|
|
17537
17580
|
payload: eventPayload
|
|
17538
|
-
}) => eventPayload
|
|
17581
|
+
}) => eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.transactionLast), [events]);
|
|
17539
17582
|
const handleClick = (0,hooks_namespaceObject.useCallback)(({
|
|
17540
17583
|
id,
|
|
17541
17584
|
question
|
|
@@ -17674,6 +17717,37 @@ const ComponentFilter = ({
|
|
|
17674
17717
|
|
|
17675
17718
|
|
|
17676
17719
|
|
|
17720
|
+
const Events = () => {
|
|
17721
|
+
const events = useEvents();
|
|
17722
|
+
let prevParticipant = null;
|
|
17723
|
+
return events.map(event => {
|
|
17724
|
+
const {
|
|
17725
|
+
type,
|
|
17726
|
+
payload
|
|
17727
|
+
} = event;
|
|
17728
|
+
const {
|
|
17729
|
+
participant,
|
|
17730
|
+
fromClient
|
|
17731
|
+
} = payload;
|
|
17732
|
+
let participantChanged = false;
|
|
17733
|
+
|
|
17734
|
+
if (type !== 'participant') {
|
|
17735
|
+
const currentParticipant = fromClient ? 'seamly-client-participant' : participant;
|
|
17736
|
+
|
|
17737
|
+
if (event.type !== 'info' && prevParticipant !== currentParticipant) {
|
|
17738
|
+
participantChanged = true;
|
|
17739
|
+
}
|
|
17740
|
+
|
|
17741
|
+
prevParticipant = currentParticipant;
|
|
17742
|
+
}
|
|
17743
|
+
|
|
17744
|
+
return (0,jsx_runtime_namespaceObject.jsx)(event_event, {
|
|
17745
|
+
event: event,
|
|
17746
|
+
newParticipant: participantChanged
|
|
17747
|
+
}, event.payload.key || event.payload.id);
|
|
17748
|
+
});
|
|
17749
|
+
};
|
|
17750
|
+
|
|
17677
17751
|
const Conversation = () => {
|
|
17678
17752
|
const {
|
|
17679
17753
|
t
|
|
@@ -17695,36 +17769,6 @@ const Conversation = () => {
|
|
|
17695
17769
|
}
|
|
17696
17770
|
}, [events, isLoading, isOpen, loadedImageEventIds]);
|
|
17697
17771
|
|
|
17698
|
-
const renderEvents = () => {
|
|
17699
|
-
let prevParticipant = null;
|
|
17700
|
-
return events.map(event => {
|
|
17701
|
-
const {
|
|
17702
|
-
type,
|
|
17703
|
-
payload
|
|
17704
|
-
} = event;
|
|
17705
|
-
const {
|
|
17706
|
-
participant,
|
|
17707
|
-
fromClient
|
|
17708
|
-
} = payload;
|
|
17709
|
-
let participantChanged = false;
|
|
17710
|
-
|
|
17711
|
-
if (type !== 'participant') {
|
|
17712
|
-
const currentParticipant = fromClient ? 'seamly-client-participant' : participant;
|
|
17713
|
-
|
|
17714
|
-
if (event.type !== 'info' && prevParticipant !== currentParticipant) {
|
|
17715
|
-
participantChanged = true;
|
|
17716
|
-
}
|
|
17717
|
-
|
|
17718
|
-
prevParticipant = currentParticipant;
|
|
17719
|
-
}
|
|
17720
|
-
|
|
17721
|
-
return (0,jsx_runtime_namespaceObject.jsx)(event_event, {
|
|
17722
|
-
event: event,
|
|
17723
|
-
newParticipant: participantChanged
|
|
17724
|
-
}, event.payload.id);
|
|
17725
|
-
});
|
|
17726
|
-
};
|
|
17727
|
-
|
|
17728
17772
|
const onClickHandler = e => {
|
|
17729
17773
|
e.preventDefault();
|
|
17730
17774
|
focusSkiplinkTarget();
|
|
@@ -17744,7 +17788,7 @@ const Conversation = () => {
|
|
|
17744
17788
|
children: [(0,jsx_runtime_namespaceObject.jsx)(privacy_disclaimer, {}), (0,jsx_runtime_namespaceObject.jsxs)("ol", {
|
|
17745
17789
|
className: css_className('conversation'),
|
|
17746
17790
|
children: [(0,jsx_runtime_namespaceObject.jsx)(component_filter, {
|
|
17747
|
-
children:
|
|
17791
|
+
children: (0,jsx_runtime_namespaceObject.jsx)(Events, {})
|
|
17748
17792
|
}), isLoading && (0,jsx_runtime_namespaceObject.jsx)(loader, {})]
|
|
17749
17793
|
})]
|
|
17750
17794
|
})
|
|
@@ -18952,7 +18996,11 @@ const OptionsButton = () => {
|
|
|
18952
18996
|
const prevMenuIsOpen = (0,hooks_namespaceObject.useRef)(false);
|
|
18953
18997
|
const multiMenu = optionsLength > 1;
|
|
18954
18998
|
const firstOption = menuOptions[0];
|
|
18955
|
-
const firstOptionName = (0,hooks_namespaceObject.useMemo)(() =>
|
|
18999
|
+
const firstOptionName = (0,hooks_namespaceObject.useMemo)(() => {
|
|
19000
|
+
var _firstOption$name;
|
|
19001
|
+
|
|
19002
|
+
return firstOption === null || firstOption === void 0 ? void 0 : (_firstOption$name = firstOption.name) === null || _firstOption$name === void 0 ? void 0 : _firstOption$name.trim().replace(/\s+/g, '');
|
|
19003
|
+
}, [firstOption]);
|
|
18956
19004
|
(0,hooks_namespaceObject.useEffect)(() => {
|
|
18957
19005
|
return () => {
|
|
18958
19006
|
clearTimeout(focusOutDelayTimeoutID.current);
|
|
@@ -19621,7 +19669,7 @@ function errors_createMiddleware({
|
|
|
19621
19669
|
api,
|
|
19622
19670
|
layoutMode
|
|
19623
19671
|
} = selectConfig(getState());
|
|
19624
|
-
errorCallback
|
|
19672
|
+
errorCallback === null || errorCallback === void 0 ? void 0 : errorCallback(action.error, {
|
|
19625
19673
|
namespace,
|
|
19626
19674
|
api,
|
|
19627
19675
|
layoutMode,
|
|
@@ -19665,7 +19713,11 @@ function useSeamlyInstanceFunction(functionName, fn, deps = []) {
|
|
|
19665
19713
|
return undefined;
|
|
19666
19714
|
}
|
|
19667
19715
|
|
|
19668
|
-
const callback = (...args) =>
|
|
19716
|
+
const callback = (...args) => {
|
|
19717
|
+
var _callbackRef$current;
|
|
19718
|
+
|
|
19719
|
+
return (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, ...args);
|
|
19720
|
+
};
|
|
19669
19721
|
|
|
19670
19722
|
eventBus.emit('function.register', functionName, callback);
|
|
19671
19723
|
return () => eventBus.emit('function.unregister', functionName, callback); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -19710,12 +19762,12 @@ const SeamlyInstanceFunctionsLoader = () => {
|
|
|
19710
19762
|
sendMessage({
|
|
19711
19763
|
body: text
|
|
19712
19764
|
});
|
|
19713
|
-
}, [api
|
|
19765
|
+
}, [api === null || api === void 0 ? void 0 : api.send]);
|
|
19714
19766
|
useSeamlyInstanceFunction('setVariables', variables => {
|
|
19715
19767
|
sendContext({
|
|
19716
19768
|
variables
|
|
19717
19769
|
});
|
|
19718
|
-
}, [api
|
|
19770
|
+
}, [api === null || api === void 0 ? void 0 : api.send]);
|
|
19719
19771
|
useSeamlyInstanceFunction('getVisibility', callback => {
|
|
19720
19772
|
if (callback) {
|
|
19721
19773
|
callback(currentVisibility.current);
|
|
@@ -19731,7 +19783,7 @@ const SeamlyInstanceFunctionsLoader = () => {
|
|
|
19731
19783
|
|
|
19732
19784
|
onActivityHandler();
|
|
19733
19785
|
setVisibility(visibilityState);
|
|
19734
|
-
}, [config
|
|
19786
|
+
}, [config === null || config === void 0 ? void 0 : config.api]);
|
|
19735
19787
|
useSeamlyInstanceFunction('sendCustomAction', (actionType, body) => {
|
|
19736
19788
|
sendAction({
|
|
19737
19789
|
type: 'custom',
|
|
@@ -20649,31 +20701,25 @@ function store(key) {
|
|
|
20649
20701
|
// EXTERNAL MODULE: ./src/javascripts/lib/debug.js
|
|
20650
20702
|
var debug = __webpack_require__(905);
|
|
20651
20703
|
var debug_default = /*#__PURE__*/__webpack_require__.n(debug);
|
|
20652
|
-
;// CONCATENATED MODULE: ./node_modules/phoenix/priv/static/phoenix.
|
|
20704
|
+
;// CONCATENATED MODULE: ./node_modules/phoenix/priv/static/phoenix.mjs
|
|
20653
20705
|
// js/phoenix/utils.js
|
|
20654
|
-
var closure = value => {
|
|
20706
|
+
var closure = (value) => {
|
|
20655
20707
|
if (typeof value === "function") {
|
|
20656
20708
|
return value;
|
|
20657
20709
|
} else {
|
|
20658
|
-
let closure2 = function
|
|
20710
|
+
let closure2 = function() {
|
|
20659
20711
|
return value;
|
|
20660
20712
|
};
|
|
20661
|
-
|
|
20662
20713
|
return closure2;
|
|
20663
20714
|
}
|
|
20664
|
-
};
|
|
20665
|
-
|
|
20715
|
+
};
|
|
20666
20716
|
|
|
20717
|
+
// js/phoenix/constants.js
|
|
20667
20718
|
var globalSelf = typeof self !== "undefined" ? self : null;
|
|
20668
20719
|
var phxWindow = typeof window !== "undefined" ? window : null;
|
|
20669
|
-
var global = globalSelf || phxWindow ||
|
|
20720
|
+
var global = globalSelf || phxWindow || global;
|
|
20670
20721
|
var DEFAULT_VSN = "2.0.0";
|
|
20671
|
-
var SOCKET_STATES = {
|
|
20672
|
-
connecting: 0,
|
|
20673
|
-
open: 1,
|
|
20674
|
-
closing: 2,
|
|
20675
|
-
closed: 3
|
|
20676
|
-
};
|
|
20722
|
+
var SOCKET_STATES = { connecting: 0, open: 1, closing: 2, closed: 3 };
|
|
20677
20723
|
var DEFAULT_TIMEOUT = 1e4;
|
|
20678
20724
|
var WS_CLOSE_NORMAL = 1e3;
|
|
20679
20725
|
var CHANNEL_STATES = {
|
|
@@ -20696,35 +20742,31 @@ var TRANSPORTS = {
|
|
|
20696
20742
|
};
|
|
20697
20743
|
var XHR_STATES = {
|
|
20698
20744
|
complete: 4
|
|
20699
|
-
};
|
|
20745
|
+
};
|
|
20700
20746
|
|
|
20747
|
+
// js/phoenix/push.js
|
|
20701
20748
|
var Push = class {
|
|
20702
20749
|
constructor(channel, event, payload, timeout) {
|
|
20703
20750
|
this.channel = channel;
|
|
20704
20751
|
this.event = event;
|
|
20705
|
-
|
|
20706
|
-
this.payload = payload || function () {
|
|
20752
|
+
this.payload = payload || function() {
|
|
20707
20753
|
return {};
|
|
20708
20754
|
};
|
|
20709
|
-
|
|
20710
20755
|
this.receivedResp = null;
|
|
20711
20756
|
this.timeout = timeout;
|
|
20712
20757
|
this.timeoutTimer = null;
|
|
20713
20758
|
this.recHooks = [];
|
|
20714
20759
|
this.sent = false;
|
|
20715
20760
|
}
|
|
20716
|
-
|
|
20717
20761
|
resend(timeout) {
|
|
20718
20762
|
this.timeout = timeout;
|
|
20719
20763
|
this.reset();
|
|
20720
20764
|
this.send();
|
|
20721
20765
|
}
|
|
20722
|
-
|
|
20723
20766
|
send() {
|
|
20724
20767
|
if (this.hasReceived("timeout")) {
|
|
20725
20768
|
return;
|
|
20726
20769
|
}
|
|
20727
|
-
|
|
20728
20770
|
this.startTimeout();
|
|
20729
20771
|
this.sent = true;
|
|
20730
20772
|
this.channel.socket.push({
|
|
@@ -20735,19 +20777,13 @@ var Push = class {
|
|
|
20735
20777
|
join_ref: this.channel.joinRef()
|
|
20736
20778
|
});
|
|
20737
20779
|
}
|
|
20738
|
-
|
|
20739
20780
|
receive(status, callback) {
|
|
20740
20781
|
if (this.hasReceived(status)) {
|
|
20741
20782
|
callback(this.receivedResp.response);
|
|
20742
20783
|
}
|
|
20743
|
-
|
|
20744
|
-
this.recHooks.push({
|
|
20745
|
-
status,
|
|
20746
|
-
callback
|
|
20747
|
-
});
|
|
20784
|
+
this.recHooks.push({ status, callback });
|
|
20748
20785
|
return this;
|
|
20749
20786
|
}
|
|
20750
|
-
|
|
20751
20787
|
reset() {
|
|
20752
20788
|
this.cancelRefEvent();
|
|
20753
20789
|
this.ref = null;
|
|
@@ -20755,36 +20791,26 @@ var Push = class {
|
|
|
20755
20791
|
this.receivedResp = null;
|
|
20756
20792
|
this.sent = false;
|
|
20757
20793
|
}
|
|
20758
|
-
|
|
20759
|
-
|
|
20760
|
-
status,
|
|
20761
|
-
response,
|
|
20762
|
-
_ref
|
|
20763
|
-
}) {
|
|
20764
|
-
this.recHooks.filter(h => h.status === status).forEach(h => h.callback(response));
|
|
20794
|
+
matchReceive({ status, response, _ref }) {
|
|
20795
|
+
this.recHooks.filter((h) => h.status === status).forEach((h) => h.callback(response));
|
|
20765
20796
|
}
|
|
20766
|
-
|
|
20767
20797
|
cancelRefEvent() {
|
|
20768
20798
|
if (!this.refEvent) {
|
|
20769
20799
|
return;
|
|
20770
20800
|
}
|
|
20771
|
-
|
|
20772
20801
|
this.channel.off(this.refEvent);
|
|
20773
20802
|
}
|
|
20774
|
-
|
|
20775
20803
|
cancelTimeout() {
|
|
20776
20804
|
clearTimeout(this.timeoutTimer);
|
|
20777
20805
|
this.timeoutTimer = null;
|
|
20778
20806
|
}
|
|
20779
|
-
|
|
20780
20807
|
startTimeout() {
|
|
20781
20808
|
if (this.timeoutTimer) {
|
|
20782
20809
|
this.cancelTimeout();
|
|
20783
20810
|
}
|
|
20784
|
-
|
|
20785
20811
|
this.ref = this.channel.socket.makeRef();
|
|
20786
20812
|
this.refEvent = this.channel.replyEventName(this.ref);
|
|
20787
|
-
this.channel.on(this.refEvent, payload => {
|
|
20813
|
+
this.channel.on(this.refEvent, (payload) => {
|
|
20788
20814
|
this.cancelRefEvent();
|
|
20789
20815
|
this.cancelTimeout();
|
|
20790
20816
|
this.receivedResp = payload;
|
|
@@ -20794,20 +20820,15 @@ var Push = class {
|
|
|
20794
20820
|
this.trigger("timeout", {});
|
|
20795
20821
|
}, this.timeout);
|
|
20796
20822
|
}
|
|
20797
|
-
|
|
20798
20823
|
hasReceived(status) {
|
|
20799
20824
|
return this.receivedResp && this.receivedResp.status === status;
|
|
20800
20825
|
}
|
|
20801
|
-
|
|
20802
20826
|
trigger(status, response) {
|
|
20803
|
-
this.channel.trigger(this.refEvent, {
|
|
20804
|
-
status,
|
|
20805
|
-
response
|
|
20806
|
-
});
|
|
20827
|
+
this.channel.trigger(this.refEvent, { status, response });
|
|
20807
20828
|
}
|
|
20829
|
+
};
|
|
20808
20830
|
|
|
20809
|
-
|
|
20810
|
-
|
|
20831
|
+
// js/phoenix/timer.js
|
|
20811
20832
|
var Timer = class {
|
|
20812
20833
|
constructor(callback, timerCalc) {
|
|
20813
20834
|
this.callback = callback;
|
|
@@ -20815,12 +20836,10 @@ var Timer = class {
|
|
|
20815
20836
|
this.timer = null;
|
|
20816
20837
|
this.tries = 0;
|
|
20817
20838
|
}
|
|
20818
|
-
|
|
20819
20839
|
reset() {
|
|
20820
20840
|
this.tries = 0;
|
|
20821
20841
|
clearTimeout(this.timer);
|
|
20822
20842
|
}
|
|
20823
|
-
|
|
20824
20843
|
scheduleTimeout() {
|
|
20825
20844
|
clearTimeout(this.timer);
|
|
20826
20845
|
this.timer = setTimeout(() => {
|
|
@@ -20828,9 +20847,9 @@ var Timer = class {
|
|
|
20828
20847
|
this.callback();
|
|
20829
20848
|
}, this.timerCalc(this.tries + 1));
|
|
20830
20849
|
}
|
|
20850
|
+
};
|
|
20831
20851
|
|
|
20832
|
-
|
|
20833
|
-
|
|
20852
|
+
// js/phoenix/channel.js
|
|
20834
20853
|
var Channel = class {
|
|
20835
20854
|
constructor(topic, params, socket) {
|
|
20836
20855
|
this.state = CHANNEL_STATES.closed;
|
|
@@ -20852,7 +20871,6 @@ var Channel = class {
|
|
|
20852
20871
|
this.stateChangeRefs.push(this.socket.onError(() => this.rejoinTimer.reset()));
|
|
20853
20872
|
this.stateChangeRefs.push(this.socket.onOpen(() => {
|
|
20854
20873
|
this.rejoinTimer.reset();
|
|
20855
|
-
|
|
20856
20874
|
if (this.isErrored()) {
|
|
20857
20875
|
this.rejoin();
|
|
20858
20876
|
}
|
|
@@ -20860,42 +20878,40 @@ var Channel = class {
|
|
|
20860
20878
|
this.joinPush.receive("ok", () => {
|
|
20861
20879
|
this.state = CHANNEL_STATES.joined;
|
|
20862
20880
|
this.rejoinTimer.reset();
|
|
20863
|
-
this.pushBuffer.forEach(pushEvent => pushEvent.send());
|
|
20881
|
+
this.pushBuffer.forEach((pushEvent) => pushEvent.send());
|
|
20864
20882
|
this.pushBuffer = [];
|
|
20865
20883
|
});
|
|
20866
20884
|
this.joinPush.receive("error", () => {
|
|
20867
20885
|
this.state = CHANNEL_STATES.errored;
|
|
20868
|
-
|
|
20869
20886
|
if (this.socket.isConnected()) {
|
|
20870
20887
|
this.rejoinTimer.scheduleTimeout();
|
|
20871
20888
|
}
|
|
20872
20889
|
});
|
|
20873
20890
|
this.onClose(() => {
|
|
20874
20891
|
this.rejoinTimer.reset();
|
|
20875
|
-
if (this.socket.hasLogger())
|
|
20892
|
+
if (this.socket.hasLogger())
|
|
20893
|
+
this.socket.log("channel", `close ${this.topic} ${this.joinRef()}`);
|
|
20876
20894
|
this.state = CHANNEL_STATES.closed;
|
|
20877
20895
|
this.socket.remove(this);
|
|
20878
20896
|
});
|
|
20879
|
-
this.onError(reason => {
|
|
20880
|
-
if (this.socket.hasLogger())
|
|
20881
|
-
|
|
20897
|
+
this.onError((reason) => {
|
|
20898
|
+
if (this.socket.hasLogger())
|
|
20899
|
+
this.socket.log("channel", `error ${this.topic}`, reason);
|
|
20882
20900
|
if (this.isJoining()) {
|
|
20883
20901
|
this.joinPush.reset();
|
|
20884
20902
|
}
|
|
20885
|
-
|
|
20886
20903
|
this.state = CHANNEL_STATES.errored;
|
|
20887
|
-
|
|
20888
20904
|
if (this.socket.isConnected()) {
|
|
20889
20905
|
this.rejoinTimer.scheduleTimeout();
|
|
20890
20906
|
}
|
|
20891
20907
|
});
|
|
20892
20908
|
this.joinPush.receive("timeout", () => {
|
|
20893
|
-
if (this.socket.hasLogger())
|
|
20909
|
+
if (this.socket.hasLogger())
|
|
20910
|
+
this.socket.log("channel", `timeout ${this.topic} (${this.joinRef()})`, this.joinPush.timeout);
|
|
20894
20911
|
let leavePush = new Push(this, CHANNEL_EVENTS.leave, closure({}), this.timeout);
|
|
20895
20912
|
leavePush.send();
|
|
20896
20913
|
this.state = CHANNEL_STATES.errored;
|
|
20897
20914
|
this.joinPush.reset();
|
|
20898
|
-
|
|
20899
20915
|
if (this.socket.isConnected()) {
|
|
20900
20916
|
this.rejoinTimer.scheduleTimeout();
|
|
20901
20917
|
}
|
|
@@ -20904,7 +20920,6 @@ var Channel = class {
|
|
|
20904
20920
|
this.trigger(this.replyEventName(ref), payload);
|
|
20905
20921
|
});
|
|
20906
20922
|
}
|
|
20907
|
-
|
|
20908
20923
|
join(timeout = this.timeout) {
|
|
20909
20924
|
if (this.joinedOnce) {
|
|
20910
20925
|
throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");
|
|
@@ -20915,211 +20930,162 @@ var Channel = class {
|
|
|
20915
20930
|
return this.joinPush;
|
|
20916
20931
|
}
|
|
20917
20932
|
}
|
|
20918
|
-
|
|
20919
20933
|
onClose(callback) {
|
|
20920
20934
|
this.on(CHANNEL_EVENTS.close, callback);
|
|
20921
20935
|
}
|
|
20922
|
-
|
|
20923
20936
|
onError(callback) {
|
|
20924
|
-
return this.on(CHANNEL_EVENTS.error, reason => callback(reason));
|
|
20937
|
+
return this.on(CHANNEL_EVENTS.error, (reason) => callback(reason));
|
|
20925
20938
|
}
|
|
20926
|
-
|
|
20927
20939
|
on(event, callback) {
|
|
20928
20940
|
let ref = this.bindingRef++;
|
|
20929
|
-
this.bindings.push({
|
|
20930
|
-
event,
|
|
20931
|
-
ref,
|
|
20932
|
-
callback
|
|
20933
|
-
});
|
|
20941
|
+
this.bindings.push({ event, ref, callback });
|
|
20934
20942
|
return ref;
|
|
20935
20943
|
}
|
|
20936
|
-
|
|
20937
20944
|
off(event, ref) {
|
|
20938
|
-
this.bindings = this.bindings.filter(bind => {
|
|
20945
|
+
this.bindings = this.bindings.filter((bind) => {
|
|
20939
20946
|
return !(bind.event === event && (typeof ref === "undefined" || ref === bind.ref));
|
|
20940
20947
|
});
|
|
20941
20948
|
}
|
|
20942
|
-
|
|
20943
20949
|
canPush() {
|
|
20944
20950
|
return this.socket.isConnected() && this.isJoined();
|
|
20945
20951
|
}
|
|
20946
|
-
|
|
20947
20952
|
push(event, payload, timeout = this.timeout) {
|
|
20948
20953
|
payload = payload || {};
|
|
20949
|
-
|
|
20950
20954
|
if (!this.joinedOnce) {
|
|
20951
20955
|
throw new Error(`tried to push '${event}' to '${this.topic}' before joining. Use channel.join() before pushing events`);
|
|
20952
20956
|
}
|
|
20953
|
-
|
|
20954
|
-
let pushEvent = new Push(this, event, function () {
|
|
20957
|
+
let pushEvent = new Push(this, event, function() {
|
|
20955
20958
|
return payload;
|
|
20956
20959
|
}, timeout);
|
|
20957
|
-
|
|
20958
20960
|
if (this.canPush()) {
|
|
20959
20961
|
pushEvent.send();
|
|
20960
20962
|
} else {
|
|
20961
20963
|
pushEvent.startTimeout();
|
|
20962
20964
|
this.pushBuffer.push(pushEvent);
|
|
20963
20965
|
}
|
|
20964
|
-
|
|
20965
20966
|
return pushEvent;
|
|
20966
20967
|
}
|
|
20967
|
-
|
|
20968
20968
|
leave(timeout = this.timeout) {
|
|
20969
20969
|
this.rejoinTimer.reset();
|
|
20970
20970
|
this.joinPush.cancelTimeout();
|
|
20971
20971
|
this.state = CHANNEL_STATES.leaving;
|
|
20972
|
-
|
|
20973
20972
|
let onClose = () => {
|
|
20974
|
-
if (this.socket.hasLogger())
|
|
20973
|
+
if (this.socket.hasLogger())
|
|
20974
|
+
this.socket.log("channel", `leave ${this.topic}`);
|
|
20975
20975
|
this.trigger(CHANNEL_EVENTS.close, "leave");
|
|
20976
20976
|
};
|
|
20977
|
-
|
|
20978
20977
|
let leavePush = new Push(this, CHANNEL_EVENTS.leave, closure({}), timeout);
|
|
20979
20978
|
leavePush.receive("ok", () => onClose()).receive("timeout", () => onClose());
|
|
20980
20979
|
leavePush.send();
|
|
20981
|
-
|
|
20982
20980
|
if (!this.canPush()) {
|
|
20983
20981
|
leavePush.trigger("ok", {});
|
|
20984
20982
|
}
|
|
20985
|
-
|
|
20986
20983
|
return leavePush;
|
|
20987
20984
|
}
|
|
20988
|
-
|
|
20989
20985
|
onMessage(_event, payload, _ref) {
|
|
20990
20986
|
return payload;
|
|
20991
20987
|
}
|
|
20992
|
-
|
|
20993
20988
|
isMember(topic, event, payload, joinRef) {
|
|
20994
20989
|
if (this.topic !== topic) {
|
|
20995
20990
|
return false;
|
|
20996
20991
|
}
|
|
20997
|
-
|
|
20998
20992
|
if (joinRef && joinRef !== this.joinRef()) {
|
|
20999
|
-
if (this.socket.hasLogger())
|
|
21000
|
-
topic,
|
|
21001
|
-
event,
|
|
21002
|
-
payload,
|
|
21003
|
-
joinRef
|
|
21004
|
-
});
|
|
20993
|
+
if (this.socket.hasLogger())
|
|
20994
|
+
this.socket.log("channel", "dropping outdated message", { topic, event, payload, joinRef });
|
|
21005
20995
|
return false;
|
|
21006
20996
|
} else {
|
|
21007
20997
|
return true;
|
|
21008
20998
|
}
|
|
21009
20999
|
}
|
|
21010
|
-
|
|
21011
21000
|
joinRef() {
|
|
21012
21001
|
return this.joinPush.ref;
|
|
21013
21002
|
}
|
|
21014
|
-
|
|
21015
21003
|
rejoin(timeout = this.timeout) {
|
|
21016
21004
|
if (this.isLeaving()) {
|
|
21017
21005
|
return;
|
|
21018
21006
|
}
|
|
21019
|
-
|
|
21020
21007
|
this.socket.leaveOpenTopic(this.topic);
|
|
21021
21008
|
this.state = CHANNEL_STATES.joining;
|
|
21022
21009
|
this.joinPush.resend(timeout);
|
|
21023
21010
|
}
|
|
21024
|
-
|
|
21025
21011
|
trigger(event, payload, ref, joinRef) {
|
|
21026
21012
|
let handledPayload = this.onMessage(event, payload, ref, joinRef);
|
|
21027
|
-
|
|
21028
21013
|
if (payload && !handledPayload) {
|
|
21029
21014
|
throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");
|
|
21030
21015
|
}
|
|
21031
|
-
|
|
21032
|
-
let eventBindings = this.bindings.filter(bind => bind.event === event);
|
|
21033
|
-
|
|
21016
|
+
let eventBindings = this.bindings.filter((bind) => bind.event === event);
|
|
21034
21017
|
for (let i = 0; i < eventBindings.length; i++) {
|
|
21035
21018
|
let bind = eventBindings[i];
|
|
21036
21019
|
bind.callback(handledPayload, ref, joinRef || this.joinRef());
|
|
21037
21020
|
}
|
|
21038
21021
|
}
|
|
21039
|
-
|
|
21040
21022
|
replyEventName(ref) {
|
|
21041
21023
|
return `chan_reply_${ref}`;
|
|
21042
21024
|
}
|
|
21043
|
-
|
|
21044
21025
|
isClosed() {
|
|
21045
21026
|
return this.state === CHANNEL_STATES.closed;
|
|
21046
21027
|
}
|
|
21047
|
-
|
|
21048
21028
|
isErrored() {
|
|
21049
21029
|
return this.state === CHANNEL_STATES.errored;
|
|
21050
21030
|
}
|
|
21051
|
-
|
|
21052
21031
|
isJoined() {
|
|
21053
21032
|
return this.state === CHANNEL_STATES.joined;
|
|
21054
21033
|
}
|
|
21055
|
-
|
|
21056
21034
|
isJoining() {
|
|
21057
21035
|
return this.state === CHANNEL_STATES.joining;
|
|
21058
21036
|
}
|
|
21059
|
-
|
|
21060
21037
|
isLeaving() {
|
|
21061
21038
|
return this.state === CHANNEL_STATES.leaving;
|
|
21062
21039
|
}
|
|
21040
|
+
};
|
|
21063
21041
|
|
|
21064
|
-
|
|
21065
|
-
|
|
21042
|
+
// js/phoenix/ajax.js
|
|
21066
21043
|
var Ajax = class {
|
|
21067
21044
|
static request(method, endPoint, accept, body, timeout, ontimeout, callback) {
|
|
21068
21045
|
if (global.XDomainRequest) {
|
|
21069
21046
|
let req = new global.XDomainRequest();
|
|
21070
|
-
this.xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback);
|
|
21047
|
+
return this.xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback);
|
|
21071
21048
|
} else {
|
|
21072
21049
|
let req = new global.XMLHttpRequest();
|
|
21073
|
-
this.xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback);
|
|
21050
|
+
return this.xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback);
|
|
21074
21051
|
}
|
|
21075
21052
|
}
|
|
21076
|
-
|
|
21077
21053
|
static xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback) {
|
|
21078
21054
|
req.timeout = timeout;
|
|
21079
21055
|
req.open(method, endPoint);
|
|
21080
|
-
|
|
21081
21056
|
req.onload = () => {
|
|
21082
21057
|
let response = this.parseJSON(req.responseText);
|
|
21083
21058
|
callback && callback(response);
|
|
21084
21059
|
};
|
|
21085
|
-
|
|
21086
21060
|
if (ontimeout) {
|
|
21087
21061
|
req.ontimeout = ontimeout;
|
|
21088
21062
|
}
|
|
21089
|
-
|
|
21090
|
-
|
|
21091
|
-
|
|
21063
|
+
req.onprogress = () => {
|
|
21064
|
+
};
|
|
21092
21065
|
req.send(body);
|
|
21066
|
+
return req;
|
|
21093
21067
|
}
|
|
21094
|
-
|
|
21095
21068
|
static xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback) {
|
|
21096
21069
|
req.open(method, endPoint, true);
|
|
21097
21070
|
req.timeout = timeout;
|
|
21098
21071
|
req.setRequestHeader("Content-Type", accept);
|
|
21099
|
-
|
|
21100
|
-
req.onerror = () => {
|
|
21101
|
-
callback && callback(null);
|
|
21102
|
-
};
|
|
21103
|
-
|
|
21072
|
+
req.onerror = () => callback && callback(null);
|
|
21104
21073
|
req.onreadystatechange = () => {
|
|
21105
21074
|
if (req.readyState === XHR_STATES.complete && callback) {
|
|
21106
21075
|
let response = this.parseJSON(req.responseText);
|
|
21107
21076
|
callback(response);
|
|
21108
21077
|
}
|
|
21109
21078
|
};
|
|
21110
|
-
|
|
21111
21079
|
if (ontimeout) {
|
|
21112
21080
|
req.ontimeout = ontimeout;
|
|
21113
21081
|
}
|
|
21114
|
-
|
|
21115
21082
|
req.send(body);
|
|
21083
|
+
return req;
|
|
21116
21084
|
}
|
|
21117
|
-
|
|
21118
21085
|
static parseJSON(resp) {
|
|
21119
21086
|
if (!resp || resp === "") {
|
|
21120
21087
|
return null;
|
|
21121
21088
|
}
|
|
21122
|
-
|
|
21123
21089
|
try {
|
|
21124
21090
|
return JSON.parse(resp);
|
|
21125
21091
|
} catch (e) {
|
|
@@ -21127,186 +21093,168 @@ var Ajax = class {
|
|
|
21127
21093
|
return null;
|
|
21128
21094
|
}
|
|
21129
21095
|
}
|
|
21130
|
-
|
|
21131
21096
|
static serialize(obj, parentKey) {
|
|
21132
21097
|
let queryStr = [];
|
|
21133
|
-
|
|
21134
21098
|
for (var key in obj) {
|
|
21135
21099
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
21136
21100
|
continue;
|
|
21137
21101
|
}
|
|
21138
|
-
|
|
21139
21102
|
let paramKey = parentKey ? `${parentKey}[${key}]` : key;
|
|
21140
21103
|
let paramVal = obj[key];
|
|
21141
|
-
|
|
21142
21104
|
if (typeof paramVal === "object") {
|
|
21143
21105
|
queryStr.push(this.serialize(paramVal, paramKey));
|
|
21144
21106
|
} else {
|
|
21145
21107
|
queryStr.push(encodeURIComponent(paramKey) + "=" + encodeURIComponent(paramVal));
|
|
21146
21108
|
}
|
|
21147
21109
|
}
|
|
21148
|
-
|
|
21149
21110
|
return queryStr.join("&");
|
|
21150
21111
|
}
|
|
21151
|
-
|
|
21152
21112
|
static appendParams(url, params) {
|
|
21153
21113
|
if (Object.keys(params).length === 0) {
|
|
21154
21114
|
return url;
|
|
21155
21115
|
}
|
|
21156
|
-
|
|
21157
21116
|
let prefix = url.match(/\?/) ? "&" : "?";
|
|
21158
21117
|
return `${url}${prefix}${this.serialize(params)}`;
|
|
21159
21118
|
}
|
|
21119
|
+
};
|
|
21160
21120
|
|
|
21161
|
-
|
|
21162
|
-
|
|
21121
|
+
// js/phoenix/longpoll.js
|
|
21163
21122
|
var LongPoll = class {
|
|
21164
21123
|
constructor(endPoint) {
|
|
21165
21124
|
this.endPoint = null;
|
|
21166
21125
|
this.token = null;
|
|
21167
21126
|
this.skipHeartbeat = true;
|
|
21168
|
-
|
|
21169
|
-
this.onopen = function
|
|
21170
|
-
|
|
21171
|
-
this.onerror = function
|
|
21172
|
-
|
|
21173
|
-
this.onmessage = function
|
|
21174
|
-
|
|
21175
|
-
this.onclose = function
|
|
21176
|
-
|
|
21127
|
+
this.reqs = /* @__PURE__ */ new Set();
|
|
21128
|
+
this.onopen = function() {
|
|
21129
|
+
};
|
|
21130
|
+
this.onerror = function() {
|
|
21131
|
+
};
|
|
21132
|
+
this.onmessage = function() {
|
|
21133
|
+
};
|
|
21134
|
+
this.onclose = function() {
|
|
21135
|
+
};
|
|
21177
21136
|
this.pollEndpoint = this.normalizeEndpoint(endPoint);
|
|
21178
21137
|
this.readyState = SOCKET_STATES.connecting;
|
|
21179
21138
|
this.poll();
|
|
21180
21139
|
}
|
|
21181
|
-
|
|
21182
21140
|
normalizeEndpoint(endPoint) {
|
|
21183
21141
|
return endPoint.replace("ws://", "http://").replace("wss://", "https://").replace(new RegExp("(.*)/" + TRANSPORTS.websocket), "$1/" + TRANSPORTS.longpoll);
|
|
21184
21142
|
}
|
|
21185
|
-
|
|
21186
21143
|
endpointURL() {
|
|
21187
|
-
return Ajax.appendParams(this.pollEndpoint, {
|
|
21188
|
-
token: this.token
|
|
21189
|
-
});
|
|
21144
|
+
return Ajax.appendParams(this.pollEndpoint, { token: this.token });
|
|
21190
21145
|
}
|
|
21191
|
-
|
|
21192
|
-
|
|
21193
|
-
this.close();
|
|
21146
|
+
closeAndRetry(code, reason, wasClean) {
|
|
21147
|
+
this.close(code, reason, wasClean);
|
|
21194
21148
|
this.readyState = SOCKET_STATES.connecting;
|
|
21195
21149
|
}
|
|
21196
|
-
|
|
21197
21150
|
ontimeout() {
|
|
21198
21151
|
this.onerror("timeout");
|
|
21199
|
-
this.closeAndRetry();
|
|
21152
|
+
this.closeAndRetry(1005, "timeout", false);
|
|
21153
|
+
}
|
|
21154
|
+
isActive() {
|
|
21155
|
+
return this.readyState === SOCKET_STATES.open || this.readyState === SOCKET_STATES.connecting;
|
|
21200
21156
|
}
|
|
21201
|
-
|
|
21202
21157
|
poll() {
|
|
21203
|
-
|
|
21204
|
-
return;
|
|
21205
|
-
}
|
|
21206
|
-
|
|
21207
|
-
Ajax.request("GET", this.endpointURL(), "application/json", null, this.timeout, this.ontimeout.bind(this), resp => {
|
|
21158
|
+
this.ajax("GET", null, () => this.ontimeout(), (resp) => {
|
|
21208
21159
|
if (resp) {
|
|
21209
|
-
var {
|
|
21210
|
-
status,
|
|
21211
|
-
token,
|
|
21212
|
-
messages
|
|
21213
|
-
} = resp;
|
|
21160
|
+
var { status, token, messages } = resp;
|
|
21214
21161
|
this.token = token;
|
|
21215
21162
|
} else {
|
|
21216
21163
|
status = 0;
|
|
21217
21164
|
}
|
|
21218
|
-
|
|
21219
21165
|
switch (status) {
|
|
21220
21166
|
case 200:
|
|
21221
|
-
messages.forEach(msg => {
|
|
21222
|
-
setTimeout(() => {
|
|
21223
|
-
this.onmessage({
|
|
21224
|
-
data: msg
|
|
21225
|
-
});
|
|
21226
|
-
}, 0);
|
|
21167
|
+
messages.forEach((msg) => {
|
|
21168
|
+
setTimeout(() => this.onmessage({ data: msg }), 0);
|
|
21227
21169
|
});
|
|
21228
21170
|
this.poll();
|
|
21229
21171
|
break;
|
|
21230
|
-
|
|
21231
21172
|
case 204:
|
|
21232
21173
|
this.poll();
|
|
21233
21174
|
break;
|
|
21234
|
-
|
|
21235
21175
|
case 410:
|
|
21236
21176
|
this.readyState = SOCKET_STATES.open;
|
|
21237
|
-
this.onopen();
|
|
21177
|
+
this.onopen({});
|
|
21238
21178
|
this.poll();
|
|
21239
21179
|
break;
|
|
21240
|
-
|
|
21241
21180
|
case 403:
|
|
21242
|
-
this.onerror();
|
|
21243
|
-
this.close();
|
|
21181
|
+
this.onerror(403);
|
|
21182
|
+
this.close(1008, "forbidden", false);
|
|
21244
21183
|
break;
|
|
21245
|
-
|
|
21246
21184
|
case 0:
|
|
21247
21185
|
case 500:
|
|
21248
|
-
this.onerror();
|
|
21249
|
-
this.closeAndRetry();
|
|
21186
|
+
this.onerror(500);
|
|
21187
|
+
this.closeAndRetry(1011, "internal server error", 500);
|
|
21250
21188
|
break;
|
|
21251
|
-
|
|
21252
21189
|
default:
|
|
21253
21190
|
throw new Error(`unhandled poll status ${status}`);
|
|
21254
21191
|
}
|
|
21255
21192
|
});
|
|
21256
21193
|
}
|
|
21257
|
-
|
|
21258
21194
|
send(body) {
|
|
21259
|
-
|
|
21195
|
+
this.ajax("POST", body, () => this.onerror("timeout"), (resp) => {
|
|
21260
21196
|
if (!resp || resp.status !== 200) {
|
|
21261
21197
|
this.onerror(resp && resp.status);
|
|
21262
|
-
this.closeAndRetry();
|
|
21198
|
+
this.closeAndRetry(1011, "internal server error", false);
|
|
21263
21199
|
}
|
|
21264
21200
|
});
|
|
21265
21201
|
}
|
|
21266
|
-
|
|
21267
|
-
|
|
21202
|
+
close(code, reason, wasClean) {
|
|
21203
|
+
for (let req of this.reqs) {
|
|
21204
|
+
req.abort();
|
|
21205
|
+
}
|
|
21268
21206
|
this.readyState = SOCKET_STATES.closed;
|
|
21269
|
-
|
|
21207
|
+
let opts = Object.assign({ code: 1e3, reason: void 0, wasClean: true }, { code, reason, wasClean });
|
|
21208
|
+
if (typeof CloseEvent !== "undefined") {
|
|
21209
|
+
this.onclose(new CloseEvent("close", opts));
|
|
21210
|
+
} else {
|
|
21211
|
+
this.onclose(opts);
|
|
21212
|
+
}
|
|
21270
21213
|
}
|
|
21214
|
+
ajax(method, body, onCallerTimeout, callback) {
|
|
21215
|
+
let req;
|
|
21216
|
+
let ontimeout = () => {
|
|
21217
|
+
this.reqs.delete(req);
|
|
21218
|
+
onCallerTimeout();
|
|
21219
|
+
};
|
|
21220
|
+
req = Ajax.request(method, this.endpointURL(), "application/json", body, this.timeout, ontimeout, (resp) => {
|
|
21221
|
+
this.reqs.delete(req);
|
|
21222
|
+
if (this.isActive()) {
|
|
21223
|
+
callback(resp);
|
|
21224
|
+
}
|
|
21225
|
+
});
|
|
21226
|
+
this.reqs.add(req);
|
|
21227
|
+
}
|
|
21228
|
+
};
|
|
21271
21229
|
|
|
21272
|
-
|
|
21273
|
-
|
|
21230
|
+
// js/phoenix/presence.js
|
|
21274
21231
|
var Presence = class {
|
|
21275
21232
|
constructor(channel, opts = {}) {
|
|
21276
|
-
let events = opts.events || {
|
|
21277
|
-
state: "presence_state",
|
|
21278
|
-
diff: "presence_diff"
|
|
21279
|
-
};
|
|
21233
|
+
let events = opts.events || { state: "presence_state", diff: "presence_diff" };
|
|
21280
21234
|
this.state = {};
|
|
21281
21235
|
this.pendingDiffs = [];
|
|
21282
21236
|
this.channel = channel;
|
|
21283
21237
|
this.joinRef = null;
|
|
21284
21238
|
this.caller = {
|
|
21285
|
-
onJoin: function
|
|
21286
|
-
|
|
21287
|
-
|
|
21239
|
+
onJoin: function() {
|
|
21240
|
+
},
|
|
21241
|
+
onLeave: function() {
|
|
21242
|
+
},
|
|
21243
|
+
onSync: function() {
|
|
21244
|
+
}
|
|
21288
21245
|
};
|
|
21289
|
-
this.channel.on(events.state, newState => {
|
|
21290
|
-
let {
|
|
21291
|
-
onJoin,
|
|
21292
|
-
onLeave,
|
|
21293
|
-
onSync
|
|
21294
|
-
} = this.caller;
|
|
21246
|
+
this.channel.on(events.state, (newState) => {
|
|
21247
|
+
let { onJoin, onLeave, onSync } = this.caller;
|
|
21295
21248
|
this.joinRef = this.channel.joinRef();
|
|
21296
21249
|
this.state = Presence.syncState(this.state, newState, onJoin, onLeave);
|
|
21297
|
-
this.pendingDiffs.forEach(diff => {
|
|
21250
|
+
this.pendingDiffs.forEach((diff) => {
|
|
21298
21251
|
this.state = Presence.syncDiff(this.state, diff, onJoin, onLeave);
|
|
21299
21252
|
});
|
|
21300
21253
|
this.pendingDiffs = [];
|
|
21301
21254
|
onSync();
|
|
21302
21255
|
});
|
|
21303
|
-
this.channel.on(events.diff, diff => {
|
|
21304
|
-
let {
|
|
21305
|
-
onJoin,
|
|
21306
|
-
onLeave,
|
|
21307
|
-
onSync
|
|
21308
|
-
} = this.caller;
|
|
21309
|
-
|
|
21256
|
+
this.channel.on(events.diff, (diff) => {
|
|
21257
|
+
let { onJoin, onLeave, onSync } = this.caller;
|
|
21310
21258
|
if (this.inPendingSyncState()) {
|
|
21311
21259
|
this.pendingDiffs.push(diff);
|
|
21312
21260
|
} else {
|
|
@@ -21315,27 +21263,21 @@ var Presence = class {
|
|
|
21315
21263
|
}
|
|
21316
21264
|
});
|
|
21317
21265
|
}
|
|
21318
|
-
|
|
21319
21266
|
onJoin(callback) {
|
|
21320
21267
|
this.caller.onJoin = callback;
|
|
21321
21268
|
}
|
|
21322
|
-
|
|
21323
21269
|
onLeave(callback) {
|
|
21324
21270
|
this.caller.onLeave = callback;
|
|
21325
21271
|
}
|
|
21326
|
-
|
|
21327
21272
|
onSync(callback) {
|
|
21328
21273
|
this.caller.onSync = callback;
|
|
21329
21274
|
}
|
|
21330
|
-
|
|
21331
21275
|
list(by) {
|
|
21332
21276
|
return Presence.list(this.state, by);
|
|
21333
21277
|
}
|
|
21334
|
-
|
|
21335
21278
|
inPendingSyncState() {
|
|
21336
21279
|
return !this.joinRef || this.joinRef !== this.channel.joinRef();
|
|
21337
21280
|
}
|
|
21338
|
-
|
|
21339
21281
|
static syncState(currentState, newState, onJoin, onLeave) {
|
|
21340
21282
|
let state = this.clone(currentState);
|
|
21341
21283
|
let joins = {};
|
|
@@ -21347,18 +21289,15 @@ var Presence = class {
|
|
|
21347
21289
|
});
|
|
21348
21290
|
this.map(newState, (key, newPresence) => {
|
|
21349
21291
|
let currentPresence = state[key];
|
|
21350
|
-
|
|
21351
21292
|
if (currentPresence) {
|
|
21352
|
-
let newRefs = newPresence.metas.map(m => m.phx_ref);
|
|
21353
|
-
let curRefs = currentPresence.metas.map(m => m.phx_ref);
|
|
21354
|
-
let joinedMetas = newPresence.metas.filter(m => curRefs.indexOf(m.phx_ref) < 0);
|
|
21355
|
-
let leftMetas = currentPresence.metas.filter(m => newRefs.indexOf(m.phx_ref) < 0);
|
|
21356
|
-
|
|
21293
|
+
let newRefs = newPresence.metas.map((m) => m.phx_ref);
|
|
21294
|
+
let curRefs = currentPresence.metas.map((m) => m.phx_ref);
|
|
21295
|
+
let joinedMetas = newPresence.metas.filter((m) => curRefs.indexOf(m.phx_ref) < 0);
|
|
21296
|
+
let leftMetas = currentPresence.metas.filter((m) => newRefs.indexOf(m.phx_ref) < 0);
|
|
21357
21297
|
if (joinedMetas.length > 0) {
|
|
21358
21298
|
joins[key] = newPresence;
|
|
21359
21299
|
joins[key].metas = joinedMetas;
|
|
21360
21300
|
}
|
|
21361
|
-
|
|
21362
21301
|
if (leftMetas.length > 0) {
|
|
21363
21302
|
leaves[key] = this.clone(currentPresence);
|
|
21364
21303
|
leaves[key].metas = leftMetas;
|
|
@@ -21367,89 +21306,67 @@ var Presence = class {
|
|
|
21367
21306
|
joins[key] = newPresence;
|
|
21368
21307
|
}
|
|
21369
21308
|
});
|
|
21370
|
-
return this.syncDiff(state, {
|
|
21371
|
-
joins,
|
|
21372
|
-
leaves
|
|
21373
|
-
}, onJoin, onLeave);
|
|
21309
|
+
return this.syncDiff(state, { joins, leaves }, onJoin, onLeave);
|
|
21374
21310
|
}
|
|
21375
|
-
|
|
21376
21311
|
static syncDiff(state, diff, onJoin, onLeave) {
|
|
21377
|
-
let {
|
|
21378
|
-
joins,
|
|
21379
|
-
leaves
|
|
21380
|
-
} = this.clone(diff);
|
|
21381
|
-
|
|
21312
|
+
let { joins, leaves } = this.clone(diff);
|
|
21382
21313
|
if (!onJoin) {
|
|
21383
|
-
onJoin = function
|
|
21314
|
+
onJoin = function() {
|
|
21315
|
+
};
|
|
21384
21316
|
}
|
|
21385
|
-
|
|
21386
21317
|
if (!onLeave) {
|
|
21387
|
-
onLeave = function
|
|
21318
|
+
onLeave = function() {
|
|
21319
|
+
};
|
|
21388
21320
|
}
|
|
21389
|
-
|
|
21390
21321
|
this.map(joins, (key, newPresence) => {
|
|
21391
21322
|
let currentPresence = state[key];
|
|
21392
21323
|
state[key] = this.clone(newPresence);
|
|
21393
|
-
|
|
21394
21324
|
if (currentPresence) {
|
|
21395
|
-
let joinedRefs = state[key].metas.map(m => m.phx_ref);
|
|
21396
|
-
let curMetas = currentPresence.metas.filter(m => joinedRefs.indexOf(m.phx_ref) < 0);
|
|
21325
|
+
let joinedRefs = state[key].metas.map((m) => m.phx_ref);
|
|
21326
|
+
let curMetas = currentPresence.metas.filter((m) => joinedRefs.indexOf(m.phx_ref) < 0);
|
|
21397
21327
|
state[key].metas.unshift(...curMetas);
|
|
21398
21328
|
}
|
|
21399
|
-
|
|
21400
21329
|
onJoin(key, currentPresence, newPresence);
|
|
21401
21330
|
});
|
|
21402
21331
|
this.map(leaves, (key, leftPresence) => {
|
|
21403
21332
|
let currentPresence = state[key];
|
|
21404
|
-
|
|
21405
21333
|
if (!currentPresence) {
|
|
21406
21334
|
return;
|
|
21407
21335
|
}
|
|
21408
|
-
|
|
21409
|
-
|
|
21410
|
-
currentPresence.metas = currentPresence.metas.filter(p => {
|
|
21336
|
+
let refsToRemove = leftPresence.metas.map((m) => m.phx_ref);
|
|
21337
|
+
currentPresence.metas = currentPresence.metas.filter((p) => {
|
|
21411
21338
|
return refsToRemove.indexOf(p.phx_ref) < 0;
|
|
21412
21339
|
});
|
|
21413
21340
|
onLeave(key, currentPresence, leftPresence);
|
|
21414
|
-
|
|
21415
21341
|
if (currentPresence.metas.length === 0) {
|
|
21416
21342
|
delete state[key];
|
|
21417
21343
|
}
|
|
21418
21344
|
});
|
|
21419
21345
|
return state;
|
|
21420
21346
|
}
|
|
21421
|
-
|
|
21422
21347
|
static list(presences, chooser) {
|
|
21423
21348
|
if (!chooser) {
|
|
21424
|
-
chooser = function
|
|
21349
|
+
chooser = function(key, pres) {
|
|
21425
21350
|
return pres;
|
|
21426
21351
|
};
|
|
21427
21352
|
}
|
|
21428
|
-
|
|
21429
21353
|
return this.map(presences, (key, presence) => {
|
|
21430
21354
|
return chooser(key, presence);
|
|
21431
21355
|
});
|
|
21432
21356
|
}
|
|
21433
|
-
|
|
21434
21357
|
static map(obj, func) {
|
|
21435
|
-
return Object.getOwnPropertyNames(obj).map(key => func(key, obj[key]));
|
|
21358
|
+
return Object.getOwnPropertyNames(obj).map((key) => func(key, obj[key]));
|
|
21436
21359
|
}
|
|
21437
|
-
|
|
21438
21360
|
static clone(obj) {
|
|
21439
21361
|
return JSON.parse(JSON.stringify(obj));
|
|
21440
21362
|
}
|
|
21363
|
+
};
|
|
21441
21364
|
|
|
21442
|
-
|
|
21443
|
-
|
|
21365
|
+
// js/phoenix/serializer.js
|
|
21444
21366
|
var serializer_default = {
|
|
21445
21367
|
HEADER_LENGTH: 1,
|
|
21446
21368
|
META_LENGTH: 4,
|
|
21447
|
-
KINDS: {
|
|
21448
|
-
push: 0,
|
|
21449
|
-
reply: 1,
|
|
21450
|
-
broadcast: 2
|
|
21451
|
-
},
|
|
21452
|
-
|
|
21369
|
+
KINDS: { push: 0, reply: 1, broadcast: 2 },
|
|
21453
21370
|
encode(msg, callback) {
|
|
21454
21371
|
if (msg.payload.constructor === ArrayBuffer) {
|
|
21455
21372
|
return callback(this.binaryEncode(msg));
|
|
@@ -21458,30 +21375,16 @@ var serializer_default = {
|
|
|
21458
21375
|
return callback(JSON.stringify(payload));
|
|
21459
21376
|
}
|
|
21460
21377
|
},
|
|
21461
|
-
|
|
21462
21378
|
decode(rawPayload, callback) {
|
|
21463
21379
|
if (rawPayload.constructor === ArrayBuffer) {
|
|
21464
21380
|
return callback(this.binaryDecode(rawPayload));
|
|
21465
21381
|
} else {
|
|
21466
21382
|
let [join_ref, ref, topic, event, payload] = JSON.parse(rawPayload);
|
|
21467
|
-
return callback({
|
|
21468
|
-
join_ref,
|
|
21469
|
-
ref,
|
|
21470
|
-
topic,
|
|
21471
|
-
event,
|
|
21472
|
-
payload
|
|
21473
|
-
});
|
|
21383
|
+
return callback({ join_ref, ref, topic, event, payload });
|
|
21474
21384
|
}
|
|
21475
21385
|
},
|
|
21476
|
-
|
|
21477
21386
|
binaryEncode(message) {
|
|
21478
|
-
let {
|
|
21479
|
-
join_ref,
|
|
21480
|
-
ref,
|
|
21481
|
-
event,
|
|
21482
|
-
topic,
|
|
21483
|
-
payload
|
|
21484
|
-
} = message;
|
|
21387
|
+
let { join_ref, ref, event, topic, payload } = message;
|
|
21485
21388
|
let metaLength = this.META_LENGTH + join_ref.length + ref.length + topic.length + event.length;
|
|
21486
21389
|
let header = new ArrayBuffer(this.HEADER_LENGTH + metaLength);
|
|
21487
21390
|
let view = new DataView(header);
|
|
@@ -21491,33 +21394,28 @@ var serializer_default = {
|
|
|
21491
21394
|
view.setUint8(offset++, ref.length);
|
|
21492
21395
|
view.setUint8(offset++, topic.length);
|
|
21493
21396
|
view.setUint8(offset++, event.length);
|
|
21494
|
-
Array.from(join_ref, char => view.setUint8(offset++, char.charCodeAt(0)));
|
|
21495
|
-
Array.from(ref, char => view.setUint8(offset++, char.charCodeAt(0)));
|
|
21496
|
-
Array.from(topic, char => view.setUint8(offset++, char.charCodeAt(0)));
|
|
21497
|
-
Array.from(event, char => view.setUint8(offset++, char.charCodeAt(0)));
|
|
21397
|
+
Array.from(join_ref, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
21398
|
+
Array.from(ref, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
21399
|
+
Array.from(topic, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
21400
|
+
Array.from(event, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
21498
21401
|
var combined = new Uint8Array(header.byteLength + payload.byteLength);
|
|
21499
21402
|
combined.set(new Uint8Array(header), 0);
|
|
21500
21403
|
combined.set(new Uint8Array(payload), header.byteLength);
|
|
21501
21404
|
return combined.buffer;
|
|
21502
21405
|
},
|
|
21503
|
-
|
|
21504
21406
|
binaryDecode(buffer) {
|
|
21505
21407
|
let view = new DataView(buffer);
|
|
21506
21408
|
let kind = view.getUint8(0);
|
|
21507
21409
|
let decoder = new TextDecoder();
|
|
21508
|
-
|
|
21509
21410
|
switch (kind) {
|
|
21510
21411
|
case this.KINDS.push:
|
|
21511
21412
|
return this.decodePush(buffer, view, decoder);
|
|
21512
|
-
|
|
21513
21413
|
case this.KINDS.reply:
|
|
21514
21414
|
return this.decodeReply(buffer, view, decoder);
|
|
21515
|
-
|
|
21516
21415
|
case this.KINDS.broadcast:
|
|
21517
21416
|
return this.decodeBroadcast(buffer, view, decoder);
|
|
21518
21417
|
}
|
|
21519
21418
|
},
|
|
21520
|
-
|
|
21521
21419
|
decodePush(buffer, view, decoder) {
|
|
21522
21420
|
let joinRefSize = view.getUint8(1);
|
|
21523
21421
|
let topicSize = view.getUint8(2);
|
|
@@ -21530,15 +21428,8 @@ var serializer_default = {
|
|
|
21530
21428
|
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
21531
21429
|
offset = offset + eventSize;
|
|
21532
21430
|
let data = buffer.slice(offset, buffer.byteLength);
|
|
21533
|
-
return {
|
|
21534
|
-
join_ref: joinRef,
|
|
21535
|
-
ref: null,
|
|
21536
|
-
topic,
|
|
21537
|
-
event,
|
|
21538
|
-
payload: data
|
|
21539
|
-
};
|
|
21431
|
+
return { join_ref: joinRef, ref: null, topic, event, payload: data };
|
|
21540
21432
|
},
|
|
21541
|
-
|
|
21542
21433
|
decodeReply(buffer, view, decoder) {
|
|
21543
21434
|
let joinRefSize = view.getUint8(1);
|
|
21544
21435
|
let refSize = view.getUint8(2);
|
|
@@ -21554,19 +21445,9 @@ var serializer_default = {
|
|
|
21554
21445
|
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
21555
21446
|
offset = offset + eventSize;
|
|
21556
21447
|
let data = buffer.slice(offset, buffer.byteLength);
|
|
21557
|
-
let payload = {
|
|
21558
|
-
|
|
21559
|
-
response: data
|
|
21560
|
-
};
|
|
21561
|
-
return {
|
|
21562
|
-
join_ref: joinRef,
|
|
21563
|
-
ref,
|
|
21564
|
-
topic,
|
|
21565
|
-
event: CHANNEL_EVENTS.reply,
|
|
21566
|
-
payload
|
|
21567
|
-
};
|
|
21448
|
+
let payload = { status: event, response: data };
|
|
21449
|
+
return { join_ref: joinRef, ref, topic, event: CHANNEL_EVENTS.reply, payload };
|
|
21568
21450
|
},
|
|
21569
|
-
|
|
21570
21451
|
decodeBroadcast(buffer, view, decoder) {
|
|
21571
21452
|
let topicSize = view.getUint8(1);
|
|
21572
21453
|
let eventSize = view.getUint8(2);
|
|
@@ -21576,25 +21457,14 @@ var serializer_default = {
|
|
|
21576
21457
|
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
21577
21458
|
offset = offset + eventSize;
|
|
21578
21459
|
let data = buffer.slice(offset, buffer.byteLength);
|
|
21579
|
-
return {
|
|
21580
|
-
join_ref: null,
|
|
21581
|
-
ref: null,
|
|
21582
|
-
topic,
|
|
21583
|
-
event,
|
|
21584
|
-
payload: data
|
|
21585
|
-
};
|
|
21460
|
+
return { join_ref: null, ref: null, topic, event, payload: data };
|
|
21586
21461
|
}
|
|
21462
|
+
};
|
|
21587
21463
|
|
|
21588
|
-
|
|
21589
|
-
|
|
21464
|
+
// js/phoenix/socket.js
|
|
21590
21465
|
var Socket = class {
|
|
21591
21466
|
constructor(endPoint, opts = {}) {
|
|
21592
|
-
this.stateChangeCallbacks = {
|
|
21593
|
-
open: [],
|
|
21594
|
-
close: [],
|
|
21595
|
-
error: [],
|
|
21596
|
-
message: []
|
|
21597
|
-
};
|
|
21467
|
+
this.stateChangeCallbacks = { open: [], close: [], error: [], message: [] };
|
|
21598
21468
|
this.channels = [];
|
|
21599
21469
|
this.sendBuffer = [];
|
|
21600
21470
|
this.ref = 0;
|
|
@@ -21606,7 +21476,6 @@ var Socket = class {
|
|
|
21606
21476
|
this.closeWasClean = false;
|
|
21607
21477
|
this.binaryType = opts.binaryType || "arraybuffer";
|
|
21608
21478
|
this.connectClock = 1;
|
|
21609
|
-
|
|
21610
21479
|
if (this.transport !== LongPoll) {
|
|
21611
21480
|
this.encode = opts.encode || this.defaultEncoder;
|
|
21612
21481
|
this.decode = opts.decode || this.defaultDecoder;
|
|
@@ -21614,42 +21483,36 @@ var Socket = class {
|
|
|
21614
21483
|
this.encode = this.defaultEncoder;
|
|
21615
21484
|
this.decode = this.defaultDecoder;
|
|
21616
21485
|
}
|
|
21617
|
-
|
|
21618
21486
|
let awaitingConnectionOnPageShow = null;
|
|
21619
|
-
|
|
21620
21487
|
if (phxWindow && phxWindow.addEventListener) {
|
|
21621
|
-
phxWindow.addEventListener("pagehide", _e => {
|
|
21488
|
+
phxWindow.addEventListener("pagehide", (_e) => {
|
|
21622
21489
|
if (this.conn) {
|
|
21623
21490
|
this.disconnect();
|
|
21624
21491
|
awaitingConnectionOnPageShow = this.connectClock;
|
|
21625
21492
|
}
|
|
21626
21493
|
});
|
|
21627
|
-
phxWindow.addEventListener("pageshow", _e => {
|
|
21494
|
+
phxWindow.addEventListener("pageshow", (_e) => {
|
|
21628
21495
|
if (awaitingConnectionOnPageShow === this.connectClock) {
|
|
21629
21496
|
awaitingConnectionOnPageShow = null;
|
|
21630
21497
|
this.connect();
|
|
21631
21498
|
}
|
|
21632
21499
|
});
|
|
21633
21500
|
}
|
|
21634
|
-
|
|
21635
21501
|
this.heartbeatIntervalMs = opts.heartbeatIntervalMs || 3e4;
|
|
21636
|
-
|
|
21637
|
-
this.rejoinAfterMs = tries => {
|
|
21502
|
+
this.rejoinAfterMs = (tries) => {
|
|
21638
21503
|
if (opts.rejoinAfterMs) {
|
|
21639
21504
|
return opts.rejoinAfterMs(tries);
|
|
21640
21505
|
} else {
|
|
21641
21506
|
return [1e3, 2e3, 5e3][tries - 1] || 1e4;
|
|
21642
21507
|
}
|
|
21643
21508
|
};
|
|
21644
|
-
|
|
21645
|
-
this.reconnectAfterMs = tries => {
|
|
21509
|
+
this.reconnectAfterMs = (tries) => {
|
|
21646
21510
|
if (opts.reconnectAfterMs) {
|
|
21647
21511
|
return opts.reconnectAfterMs(tries);
|
|
21648
21512
|
} else {
|
|
21649
21513
|
return [10, 50, 100, 150, 200, 250, 500, 1e3, 2e3][tries - 1] || 5e3;
|
|
21650
21514
|
}
|
|
21651
21515
|
};
|
|
21652
|
-
|
|
21653
21516
|
this.logger = opts.logger || null;
|
|
21654
21517
|
this.longpollerTimeout = opts.longpollerTimeout || 2e4;
|
|
21655
21518
|
this.params = closure(opts.params || {});
|
|
@@ -21661,99 +21524,101 @@ var Socket = class {
|
|
|
21661
21524
|
this.teardown(() => this.connect());
|
|
21662
21525
|
}, this.reconnectAfterMs);
|
|
21663
21526
|
}
|
|
21664
|
-
|
|
21527
|
+
getLongPollTransport() {
|
|
21528
|
+
return LongPoll;
|
|
21529
|
+
}
|
|
21665
21530
|
replaceTransport(newTransport) {
|
|
21666
|
-
this.
|
|
21531
|
+
this.connectClock++;
|
|
21532
|
+
this.closeWasClean = true;
|
|
21533
|
+
this.reconnectTimer.reset();
|
|
21534
|
+
this.sendBuffer = [];
|
|
21535
|
+
if (this.conn) {
|
|
21536
|
+
this.conn.close();
|
|
21537
|
+
this.conn = null;
|
|
21538
|
+
}
|
|
21667
21539
|
this.transport = newTransport;
|
|
21668
21540
|
}
|
|
21669
|
-
|
|
21670
21541
|
protocol() {
|
|
21671
21542
|
return location.protocol.match(/^https/) ? "wss" : "ws";
|
|
21672
21543
|
}
|
|
21673
|
-
|
|
21674
21544
|
endPointURL() {
|
|
21675
|
-
let uri = Ajax.appendParams(Ajax.appendParams(this.endPoint, this.params()), {
|
|
21676
|
-
vsn: this.vsn
|
|
21677
|
-
});
|
|
21678
|
-
|
|
21545
|
+
let uri = Ajax.appendParams(Ajax.appendParams(this.endPoint, this.params()), { vsn: this.vsn });
|
|
21679
21546
|
if (uri.charAt(0) !== "/") {
|
|
21680
21547
|
return uri;
|
|
21681
21548
|
}
|
|
21682
|
-
|
|
21683
21549
|
if (uri.charAt(1) === "/") {
|
|
21684
21550
|
return `${this.protocol()}:${uri}`;
|
|
21685
21551
|
}
|
|
21686
|
-
|
|
21687
21552
|
return `${this.protocol()}://${location.host}${uri}`;
|
|
21688
21553
|
}
|
|
21689
|
-
|
|
21690
21554
|
disconnect(callback, code, reason) {
|
|
21691
21555
|
this.connectClock++;
|
|
21692
21556
|
this.closeWasClean = true;
|
|
21693
21557
|
this.reconnectTimer.reset();
|
|
21694
21558
|
this.teardown(callback, code, reason);
|
|
21695
21559
|
}
|
|
21696
|
-
|
|
21697
21560
|
connect(params) {
|
|
21698
|
-
this.connectClock++;
|
|
21699
|
-
|
|
21700
21561
|
if (params) {
|
|
21701
21562
|
console && console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor");
|
|
21702
21563
|
this.params = closure(params);
|
|
21703
21564
|
}
|
|
21704
|
-
|
|
21705
21565
|
if (this.conn) {
|
|
21706
21566
|
return;
|
|
21707
21567
|
}
|
|
21708
|
-
|
|
21568
|
+
this.connectClock++;
|
|
21709
21569
|
this.closeWasClean = false;
|
|
21710
21570
|
this.conn = new this.transport(this.endPointURL());
|
|
21711
21571
|
this.conn.binaryType = this.binaryType;
|
|
21712
21572
|
this.conn.timeout = this.longpollerTimeout;
|
|
21713
|
-
|
|
21714
21573
|
this.conn.onopen = () => this.onConnOpen();
|
|
21715
|
-
|
|
21716
|
-
this.conn.
|
|
21717
|
-
|
|
21718
|
-
this.conn.onmessage = event => this.onConnMessage(event);
|
|
21719
|
-
|
|
21720
|
-
this.conn.onclose = event => this.onConnClose(event);
|
|
21574
|
+
this.conn.onerror = (error) => this.onConnError(error);
|
|
21575
|
+
this.conn.onmessage = (event) => this.onConnMessage(event);
|
|
21576
|
+
this.conn.onclose = (event) => this.onConnClose(event);
|
|
21721
21577
|
}
|
|
21722
|
-
|
|
21723
21578
|
log(kind, msg, data) {
|
|
21724
21579
|
this.logger(kind, msg, data);
|
|
21725
21580
|
}
|
|
21726
|
-
|
|
21727
21581
|
hasLogger() {
|
|
21728
21582
|
return this.logger !== null;
|
|
21729
21583
|
}
|
|
21730
|
-
|
|
21731
21584
|
onOpen(callback) {
|
|
21732
21585
|
let ref = this.makeRef();
|
|
21733
21586
|
this.stateChangeCallbacks.open.push([ref, callback]);
|
|
21734
21587
|
return ref;
|
|
21735
21588
|
}
|
|
21736
|
-
|
|
21737
21589
|
onClose(callback) {
|
|
21738
21590
|
let ref = this.makeRef();
|
|
21739
21591
|
this.stateChangeCallbacks.close.push([ref, callback]);
|
|
21740
21592
|
return ref;
|
|
21741
21593
|
}
|
|
21742
|
-
|
|
21743
21594
|
onError(callback) {
|
|
21744
21595
|
let ref = this.makeRef();
|
|
21745
21596
|
this.stateChangeCallbacks.error.push([ref, callback]);
|
|
21746
21597
|
return ref;
|
|
21747
21598
|
}
|
|
21748
|
-
|
|
21749
21599
|
onMessage(callback) {
|
|
21750
21600
|
let ref = this.makeRef();
|
|
21751
21601
|
this.stateChangeCallbacks.message.push([ref, callback]);
|
|
21752
21602
|
return ref;
|
|
21753
21603
|
}
|
|
21754
|
-
|
|
21604
|
+
ping(callback) {
|
|
21605
|
+
if (!this.isConnected()) {
|
|
21606
|
+
return false;
|
|
21607
|
+
}
|
|
21608
|
+
let ref = this.makeRef();
|
|
21609
|
+
let startTime = Date.now();
|
|
21610
|
+
this.push({ topic: "phoenix", event: "heartbeat", payload: {}, ref });
|
|
21611
|
+
let onMsgRef = this.onMessage((msg) => {
|
|
21612
|
+
if (msg.ref === ref) {
|
|
21613
|
+
this.off([onMsgRef]);
|
|
21614
|
+
callback(Date.now() - startTime);
|
|
21615
|
+
}
|
|
21616
|
+
});
|
|
21617
|
+
return true;
|
|
21618
|
+
}
|
|
21755
21619
|
onConnOpen() {
|
|
21756
|
-
if (this.hasLogger())
|
|
21620
|
+
if (this.hasLogger())
|
|
21621
|
+
this.log("transport", `connected to ${this.endPointURL()}`);
|
|
21757
21622
|
this.closeWasClean = false;
|
|
21758
21623
|
this.establishedConnections++;
|
|
21759
21624
|
this.flushSendBuffer();
|
|
@@ -21761,34 +21626,27 @@ var Socket = class {
|
|
|
21761
21626
|
this.resetHeartbeat();
|
|
21762
21627
|
this.stateChangeCallbacks.open.forEach(([, callback]) => callback());
|
|
21763
21628
|
}
|
|
21764
|
-
|
|
21765
21629
|
heartbeatTimeout() {
|
|
21766
21630
|
if (this.pendingHeartbeatRef) {
|
|
21767
21631
|
this.pendingHeartbeatRef = null;
|
|
21768
|
-
|
|
21769
21632
|
if (this.hasLogger()) {
|
|
21770
21633
|
this.log("transport", "heartbeat timeout. Attempting to re-establish connection");
|
|
21771
21634
|
}
|
|
21772
|
-
|
|
21773
21635
|
this.abnormalClose("heartbeat timeout");
|
|
21774
21636
|
}
|
|
21775
21637
|
}
|
|
21776
|
-
|
|
21777
21638
|
resetHeartbeat() {
|
|
21778
21639
|
if (this.conn && this.conn.skipHeartbeat) {
|
|
21779
21640
|
return;
|
|
21780
21641
|
}
|
|
21781
|
-
|
|
21782
21642
|
this.pendingHeartbeatRef = null;
|
|
21783
21643
|
clearTimeout(this.heartbeatTimer);
|
|
21784
21644
|
setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
|
21785
21645
|
}
|
|
21786
|
-
|
|
21787
21646
|
teardown(callback, code, reason) {
|
|
21788
21647
|
if (!this.conn) {
|
|
21789
21648
|
return callback && callback();
|
|
21790
21649
|
}
|
|
21791
|
-
|
|
21792
21650
|
this.waitForBufferDone(() => {
|
|
21793
21651
|
if (this.conn) {
|
|
21794
21652
|
if (code) {
|
|
@@ -21797,100 +21655,83 @@ var Socket = class {
|
|
|
21797
21655
|
this.conn.close();
|
|
21798
21656
|
}
|
|
21799
21657
|
}
|
|
21800
|
-
|
|
21801
21658
|
this.waitForSocketClosed(() => {
|
|
21802
21659
|
if (this.conn) {
|
|
21803
|
-
this.conn.onclose = function
|
|
21804
|
-
|
|
21660
|
+
this.conn.onclose = function() {
|
|
21661
|
+
};
|
|
21805
21662
|
this.conn = null;
|
|
21806
21663
|
}
|
|
21807
|
-
|
|
21808
21664
|
callback && callback();
|
|
21809
21665
|
});
|
|
21810
21666
|
});
|
|
21811
21667
|
}
|
|
21812
|
-
|
|
21813
21668
|
waitForBufferDone(callback, tries = 1) {
|
|
21814
21669
|
if (tries === 5 || !this.conn || !this.conn.bufferedAmount) {
|
|
21815
21670
|
callback();
|
|
21816
21671
|
return;
|
|
21817
21672
|
}
|
|
21818
|
-
|
|
21819
21673
|
setTimeout(() => {
|
|
21820
21674
|
this.waitForBufferDone(callback, tries + 1);
|
|
21821
21675
|
}, 150 * tries);
|
|
21822
21676
|
}
|
|
21823
|
-
|
|
21824
21677
|
waitForSocketClosed(callback, tries = 1) {
|
|
21825
21678
|
if (tries === 5 || !this.conn || this.conn.readyState === SOCKET_STATES.closed) {
|
|
21826
21679
|
callback();
|
|
21827
21680
|
return;
|
|
21828
21681
|
}
|
|
21829
|
-
|
|
21830
21682
|
setTimeout(() => {
|
|
21831
21683
|
this.waitForSocketClosed(callback, tries + 1);
|
|
21832
21684
|
}, 150 * tries);
|
|
21833
21685
|
}
|
|
21834
|
-
|
|
21835
21686
|
onConnClose(event) {
|
|
21836
21687
|
let closeCode = event && event.code;
|
|
21837
|
-
if (this.hasLogger())
|
|
21688
|
+
if (this.hasLogger())
|
|
21689
|
+
this.log("transport", "close", event);
|
|
21838
21690
|
this.triggerChanError();
|
|
21839
21691
|
clearTimeout(this.heartbeatTimer);
|
|
21840
|
-
|
|
21841
21692
|
if (!this.closeWasClean && closeCode !== 1e3) {
|
|
21842
21693
|
this.reconnectTimer.scheduleTimeout();
|
|
21843
21694
|
}
|
|
21844
|
-
|
|
21845
21695
|
this.stateChangeCallbacks.close.forEach(([, callback]) => callback(event));
|
|
21846
21696
|
}
|
|
21847
|
-
|
|
21848
21697
|
onConnError(error) {
|
|
21849
|
-
if (this.hasLogger())
|
|
21698
|
+
if (this.hasLogger())
|
|
21699
|
+
this.log("transport", error);
|
|
21850
21700
|
let transportBefore = this.transport;
|
|
21851
21701
|
let establishedBefore = this.establishedConnections;
|
|
21852
21702
|
this.stateChangeCallbacks.error.forEach(([, callback]) => {
|
|
21853
21703
|
callback(error, transportBefore, establishedBefore);
|
|
21854
21704
|
});
|
|
21855
|
-
|
|
21856
21705
|
if (transportBefore === this.transport || establishedBefore > 0) {
|
|
21857
21706
|
this.triggerChanError();
|
|
21858
21707
|
}
|
|
21859
21708
|
}
|
|
21860
|
-
|
|
21861
21709
|
triggerChanError() {
|
|
21862
|
-
this.channels.forEach(channel => {
|
|
21710
|
+
this.channels.forEach((channel) => {
|
|
21863
21711
|
if (!(channel.isErrored() || channel.isLeaving() || channel.isClosed())) {
|
|
21864
21712
|
channel.trigger(CHANNEL_EVENTS.error);
|
|
21865
21713
|
}
|
|
21866
21714
|
});
|
|
21867
21715
|
}
|
|
21868
|
-
|
|
21869
21716
|
connectionState() {
|
|
21870
21717
|
switch (this.conn && this.conn.readyState) {
|
|
21871
21718
|
case SOCKET_STATES.connecting:
|
|
21872
21719
|
return "connecting";
|
|
21873
|
-
|
|
21874
21720
|
case SOCKET_STATES.open:
|
|
21875
21721
|
return "open";
|
|
21876
|
-
|
|
21877
21722
|
case SOCKET_STATES.closing:
|
|
21878
21723
|
return "closing";
|
|
21879
|
-
|
|
21880
21724
|
default:
|
|
21881
21725
|
return "closed";
|
|
21882
21726
|
}
|
|
21883
21727
|
}
|
|
21884
|
-
|
|
21885
21728
|
isConnected() {
|
|
21886
21729
|
return this.connectionState() === "open";
|
|
21887
21730
|
}
|
|
21888
|
-
|
|
21889
21731
|
remove(channel) {
|
|
21890
21732
|
this.off(channel.stateChangeRefs);
|
|
21891
|
-
this.channels = this.channels.filter(c => c.joinRef() !== channel.joinRef());
|
|
21733
|
+
this.channels = this.channels.filter((c) => c.joinRef() !== channel.joinRef());
|
|
21892
21734
|
}
|
|
21893
|
-
|
|
21894
21735
|
off(refs) {
|
|
21895
21736
|
for (let key in this.stateChangeCallbacks) {
|
|
21896
21737
|
this.stateChangeCallbacks[key] = this.stateChangeCallbacks[key].filter(([ref]) => {
|
|
@@ -21898,120 +21739,86 @@ var Socket = class {
|
|
|
21898
21739
|
});
|
|
21899
21740
|
}
|
|
21900
21741
|
}
|
|
21901
|
-
|
|
21902
21742
|
channel(topic, chanParams = {}) {
|
|
21903
21743
|
let chan = new Channel(topic, chanParams, this);
|
|
21904
21744
|
this.channels.push(chan);
|
|
21905
21745
|
return chan;
|
|
21906
21746
|
}
|
|
21907
|
-
|
|
21908
21747
|
push(data) {
|
|
21909
21748
|
if (this.hasLogger()) {
|
|
21910
|
-
let {
|
|
21911
|
-
topic,
|
|
21912
|
-
event,
|
|
21913
|
-
payload,
|
|
21914
|
-
ref,
|
|
21915
|
-
join_ref
|
|
21916
|
-
} = data;
|
|
21749
|
+
let { topic, event, payload, ref, join_ref } = data;
|
|
21917
21750
|
this.log("push", `${topic} ${event} (${join_ref}, ${ref})`, payload);
|
|
21918
21751
|
}
|
|
21919
|
-
|
|
21920
21752
|
if (this.isConnected()) {
|
|
21921
|
-
this.encode(data, result => this.conn.send(result));
|
|
21753
|
+
this.encode(data, (result) => this.conn.send(result));
|
|
21922
21754
|
} else {
|
|
21923
|
-
this.sendBuffer.push(() => this.encode(data, result => this.conn.send(result)));
|
|
21755
|
+
this.sendBuffer.push(() => this.encode(data, (result) => this.conn.send(result)));
|
|
21924
21756
|
}
|
|
21925
21757
|
}
|
|
21926
|
-
|
|
21927
21758
|
makeRef() {
|
|
21928
21759
|
let newRef = this.ref + 1;
|
|
21929
|
-
|
|
21930
21760
|
if (newRef === this.ref) {
|
|
21931
21761
|
this.ref = 0;
|
|
21932
21762
|
} else {
|
|
21933
21763
|
this.ref = newRef;
|
|
21934
21764
|
}
|
|
21935
|
-
|
|
21936
21765
|
return this.ref.toString();
|
|
21937
21766
|
}
|
|
21938
|
-
|
|
21939
21767
|
sendHeartbeat() {
|
|
21940
21768
|
if (this.pendingHeartbeatRef && !this.isConnected()) {
|
|
21941
21769
|
return;
|
|
21942
21770
|
}
|
|
21943
|
-
|
|
21944
21771
|
this.pendingHeartbeatRef = this.makeRef();
|
|
21945
|
-
this.push({
|
|
21946
|
-
topic: "phoenix",
|
|
21947
|
-
event: "heartbeat",
|
|
21948
|
-
payload: {},
|
|
21949
|
-
ref: this.pendingHeartbeatRef
|
|
21950
|
-
});
|
|
21772
|
+
this.push({ topic: "phoenix", event: "heartbeat", payload: {}, ref: this.pendingHeartbeatRef });
|
|
21951
21773
|
this.heartbeatTimer = setTimeout(() => this.heartbeatTimeout(), this.heartbeatIntervalMs);
|
|
21952
21774
|
}
|
|
21953
|
-
|
|
21954
21775
|
abnormalClose(reason) {
|
|
21955
21776
|
this.closeWasClean = false;
|
|
21956
|
-
|
|
21957
21777
|
if (this.isConnected()) {
|
|
21958
21778
|
this.conn.close(WS_CLOSE_NORMAL, reason);
|
|
21959
21779
|
}
|
|
21960
21780
|
}
|
|
21961
|
-
|
|
21962
21781
|
flushSendBuffer() {
|
|
21963
21782
|
if (this.isConnected() && this.sendBuffer.length > 0) {
|
|
21964
|
-
this.sendBuffer.forEach(callback => callback());
|
|
21783
|
+
this.sendBuffer.forEach((callback) => callback());
|
|
21965
21784
|
this.sendBuffer = [];
|
|
21966
21785
|
}
|
|
21967
21786
|
}
|
|
21968
|
-
|
|
21969
21787
|
onConnMessage(rawMessage) {
|
|
21970
|
-
this.decode(rawMessage.data, msg => {
|
|
21971
|
-
let {
|
|
21972
|
-
topic,
|
|
21973
|
-
event,
|
|
21974
|
-
payload,
|
|
21975
|
-
ref,
|
|
21976
|
-
join_ref
|
|
21977
|
-
} = msg;
|
|
21978
|
-
|
|
21788
|
+
this.decode(rawMessage.data, (msg) => {
|
|
21789
|
+
let { topic, event, payload, ref, join_ref } = msg;
|
|
21979
21790
|
if (ref && ref === this.pendingHeartbeatRef) {
|
|
21980
21791
|
clearTimeout(this.heartbeatTimer);
|
|
21981
21792
|
this.pendingHeartbeatRef = null;
|
|
21982
21793
|
setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
|
21983
21794
|
}
|
|
21984
|
-
|
|
21985
|
-
|
|
21986
|
-
|
|
21795
|
+
if (this.hasLogger())
|
|
21796
|
+
this.log("receive", `${payload.status || ""} ${topic} ${event} ${ref && "(" + ref + ")" || ""}`, payload);
|
|
21987
21797
|
for (let i = 0; i < this.channels.length; i++) {
|
|
21988
21798
|
const channel = this.channels[i];
|
|
21989
|
-
|
|
21990
21799
|
if (!channel.isMember(topic, event, payload, join_ref)) {
|
|
21991
21800
|
continue;
|
|
21992
21801
|
}
|
|
21993
|
-
|
|
21994
21802
|
channel.trigger(event, payload, ref, join_ref);
|
|
21995
21803
|
}
|
|
21996
|
-
|
|
21997
21804
|
for (let i = 0; i < this.stateChangeCallbacks.message.length; i++) {
|
|
21998
21805
|
let [, callback] = this.stateChangeCallbacks.message[i];
|
|
21999
21806
|
callback(msg);
|
|
22000
21807
|
}
|
|
22001
21808
|
});
|
|
22002
21809
|
}
|
|
22003
|
-
|
|
22004
21810
|
leaveOpenTopic(topic) {
|
|
22005
|
-
let dupChannel = this.channels.find(c => c.topic === topic && (c.isJoined() || c.isJoining()));
|
|
22006
|
-
|
|
21811
|
+
let dupChannel = this.channels.find((c) => c.topic === topic && (c.isJoined() || c.isJoining()));
|
|
22007
21812
|
if (dupChannel) {
|
|
22008
|
-
if (this.hasLogger())
|
|
21813
|
+
if (this.hasLogger())
|
|
21814
|
+
this.log("transport", `leaving duplicate topic "${topic}"`);
|
|
22009
21815
|
dupChannel.leave();
|
|
22010
21816
|
}
|
|
22011
21817
|
}
|
|
22012
|
-
|
|
22013
21818
|
};
|
|
22014
21819
|
|
|
21820
|
+
//# sourceMappingURL=phoenix.mjs.map
|
|
21821
|
+
|
|
22015
21822
|
;// CONCATENATED MODULE: ./src/javascripts/lib/split-url-params.js
|
|
22016
21823
|
function split_url_params_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
22017
21824
|
|
|
@@ -22442,6 +22249,8 @@ class API {
|
|
|
22442
22249
|
|
|
22443
22250
|
async createConversation() {
|
|
22444
22251
|
try {
|
|
22252
|
+
var _conversation$transla;
|
|
22253
|
+
|
|
22445
22254
|
const request = client_default().post(`${this.getUrlPrefix('http')}${this.URLS.conversations}`).set('Content-Type', 'application/json').query({
|
|
22446
22255
|
v: apiVersion
|
|
22447
22256
|
}) // withCredentials() is necessary to allow browsers to save received
|
|
@@ -22464,7 +22273,7 @@ class API {
|
|
|
22464
22273
|
this.setChannelTopic(conversation.channelTopic);
|
|
22465
22274
|
this.updateUrls(body);
|
|
22466
22275
|
this.setConversationUrl(this.URLS.conversation);
|
|
22467
|
-
this.locale = conversation.translation
|
|
22276
|
+
this.locale = (_conversation$transla = conversation.translation) === null || _conversation$transla === void 0 ? void 0 : _conversation$transla.locale;
|
|
22468
22277
|
this.userResponded = conversation.userResponded;
|
|
22469
22278
|
return initialState;
|
|
22470
22279
|
} catch (error) {
|
|
@@ -22699,7 +22508,7 @@ class API {
|
|
|
22699
22508
|
return {
|
|
22700
22509
|
clientName: "@seamly/web-ui",
|
|
22701
22510
|
clientVariant: this.layoutMode,
|
|
22702
|
-
clientVersion: "20.
|
|
22511
|
+
clientVersion: "20.7.0",
|
|
22703
22512
|
currentUrl: window.location.toString(),
|
|
22704
22513
|
screenResolution: `${window.screen.width}x${window.screen.height}`,
|
|
22705
22514
|
timezone: getTimeZone(),
|
|
@@ -22708,6 +22517,37 @@ class API {
|
|
|
22708
22517
|
}
|
|
22709
22518
|
|
|
22710
22519
|
}
|
|
22520
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/options/middleware.js
|
|
22521
|
+
function middleware_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
22522
|
+
|
|
22523
|
+
function middleware_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? middleware_ownKeys(Object(source), !0).forEach(function (key) { middleware_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : middleware_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22524
|
+
|
|
22525
|
+
function middleware_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22526
|
+
|
|
22527
|
+
|
|
22528
|
+
function options_middleware_createMiddleware({
|
|
22529
|
+
api
|
|
22530
|
+
}) {
|
|
22531
|
+
return () => next => action => {
|
|
22532
|
+
const result = next(action);
|
|
22533
|
+
|
|
22534
|
+
switch (action.type) {
|
|
22535
|
+
case seamlyActions.SET_USER_SELECTED_OPTIONS:
|
|
22536
|
+
api.store.set('options', action.options);
|
|
22537
|
+
break;
|
|
22538
|
+
|
|
22539
|
+
case seamlyActions.SET_USER_SELECTED_OPTION:
|
|
22540
|
+
api.store.set('options', middleware_objectSpread(middleware_objectSpread({}, api.store.get('options') || {}), {}, {
|
|
22541
|
+
[action.option]: action.value
|
|
22542
|
+
}));
|
|
22543
|
+
break;
|
|
22544
|
+
}
|
|
22545
|
+
|
|
22546
|
+
return result;
|
|
22547
|
+
};
|
|
22548
|
+
}
|
|
22549
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/options/index.js
|
|
22550
|
+
|
|
22711
22551
|
;// CONCATENATED MODULE: ./node_modules/redux-thunk/es/index.js
|
|
22712
22552
|
/** A function that accepts a potential "extra argument" value to be injected later,
|
|
22713
22553
|
* and returns an instance of the thunk middleware that uses that value
|
|
@@ -22741,37 +22581,6 @@ var thunk = createThunkMiddleware(); // Attach the factory function so users can
|
|
|
22741
22581
|
|
|
22742
22582
|
thunk.withExtraArgument = createThunkMiddleware;
|
|
22743
22583
|
/* harmony default export */ const es = (thunk);
|
|
22744
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/options/middleware.js
|
|
22745
|
-
function middleware_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
22746
|
-
|
|
22747
|
-
function middleware_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? middleware_ownKeys(Object(source), !0).forEach(function (key) { middleware_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : middleware_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22748
|
-
|
|
22749
|
-
function middleware_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22750
|
-
|
|
22751
|
-
|
|
22752
|
-
function options_middleware_createMiddleware({
|
|
22753
|
-
api
|
|
22754
|
-
}) {
|
|
22755
|
-
return () => next => action => {
|
|
22756
|
-
const result = next(action);
|
|
22757
|
-
|
|
22758
|
-
switch (action.type) {
|
|
22759
|
-
case seamlyActions.SET_USER_SELECTED_OPTIONS:
|
|
22760
|
-
api.store.set('options', action.options);
|
|
22761
|
-
break;
|
|
22762
|
-
|
|
22763
|
-
case seamlyActions.SET_USER_SELECTED_OPTION:
|
|
22764
|
-
api.store.set('options', middleware_objectSpread(middleware_objectSpread({}, api.store.get('options') || {}), {}, {
|
|
22765
|
-
[action.option]: action.value
|
|
22766
|
-
}));
|
|
22767
|
-
break;
|
|
22768
|
-
}
|
|
22769
|
-
|
|
22770
|
-
return result;
|
|
22771
|
-
};
|
|
22772
|
-
}
|
|
22773
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/options/index.js
|
|
22774
|
-
|
|
22775
22584
|
;// CONCATENATED MODULE: ./src/javascripts/domains/store/state-reducer.js
|
|
22776
22585
|
// Legacy state reducer. Do not add new features here but extract/create new reducers as needed
|
|
22777
22586
|
|
|
@@ -22870,7 +22679,7 @@ function store_createStore({
|
|
|
22870
22679
|
api
|
|
22871
22680
|
}), options_middleware_createMiddleware({
|
|
22872
22681
|
api
|
|
22873
|
-
}), middleware_createMiddleware
|
|
22682
|
+
}), middleware_createMiddleware]
|
|
22874
22683
|
});
|
|
22875
22684
|
return store;
|
|
22876
22685
|
}
|
|
@@ -23208,7 +23017,9 @@ class ExternalApi {
|
|
|
23208
23017
|
}
|
|
23209
23018
|
|
|
23210
23019
|
getMergedVariables(userConfig) {
|
|
23211
|
-
|
|
23020
|
+
var _this$appConfig$conte, _userConfig$context;
|
|
23021
|
+
|
|
23022
|
+
return external_api_objectSpread(external_api_objectSpread(external_api_objectSpread({}, ((_this$appConfig$conte = this.appConfig.context) === null || _this$appConfig$conte === void 0 ? void 0 : _this$appConfig$conte.variables) || {}), ((_userConfig$context = userConfig.context) === null || _userConfig$context === void 0 ? void 0 : _userConfig$context.variables) || {}), this.context.variables || {});
|
|
23212
23023
|
}
|
|
23213
23024
|
|
|
23214
23025
|
}
|
|
@@ -23256,7 +23067,7 @@ const AgentInfo = () => {
|
|
|
23256
23067
|
hasInterrupt
|
|
23257
23068
|
} = useInterrupt();
|
|
23258
23069
|
const startChatIcon = useStartChatIcon();
|
|
23259
|
-
const src = currentAgent
|
|
23070
|
+
const src = (currentAgent === null || currentAgent === void 0 ? void 0 : currentAgent.avatar) ?? startChatIcon;
|
|
23260
23071
|
const displaySubtitle = hasInterrupt ? '' : subTitle;
|
|
23261
23072
|
const classNames = ['message-count'];
|
|
23262
23073
|
|
|
@@ -23273,7 +23084,7 @@ const AgentInfo = () => {
|
|
|
23273
23084
|
children: [(0,jsx_runtime_namespaceObject.jsxs)("div", {
|
|
23274
23085
|
className: css_className('agent-info__graphic'),
|
|
23275
23086
|
children: [src ? (0,jsx_runtime_namespaceObject.jsx)("img", {
|
|
23276
|
-
className: css_className(currentAgent
|
|
23087
|
+
className: css_className(currentAgent !== null && currentAgent !== void 0 && currentAgent.avatar ? 'avatar' : 'icon'),
|
|
23277
23088
|
src: src,
|
|
23278
23089
|
alt: ""
|
|
23279
23090
|
}) : (0,jsx_runtime_namespaceObject.jsx)(icon, {
|