@seamly/web-ui 20.5.0 → 20.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +769 -0
- package/build/dist/lib/index.debug.js +41 -41
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +4 -4
- package/build/dist/lib/index.js +411 -590
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/standalone.js +327 -733
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/style-guide.js +145 -68
- package/build/dist/lib/style-guide.min.js +1 -1
- package/package.json +1 -1
- package/src/javascripts/domains/store/index.js +11 -11
- package/src/javascripts/domains/translations/middleware.js +6 -5
- package/src/javascripts/style-guide/states.js +31 -1
- package/src/javascripts/ui/components/conversation/conversation.js +31 -26
- package/src/javascripts/ui/utils/seamly-utils.js +3 -0
- package/webpack/parts/dev-server.js +10 -1
- package/src/.DS_Store +0 -0
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',
|
|
@@ -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
|
|
|
@@ -9755,7 +9761,9 @@ const selectEventsWithSuggestion = createSelector(seamly_state_hooks_selectState
|
|
|
9755
9761
|
events,
|
|
9756
9762
|
serviceData
|
|
9757
9763
|
}, config, userHasResponded) => {
|
|
9758
|
-
|
|
9764
|
+
var _serviceData$suggesti;
|
|
9765
|
+
|
|
9766
|
+
if (userHasResponded || config.layoutMode === 'inline' || !serviceData.suggestion || !((_serviceData$suggesti = serviceData.suggestion) !== null && _serviceData$suggesti !== void 0 && _serviceData$suggesti.body.length)) {
|
|
9759
9767
|
return events;
|
|
9760
9768
|
}
|
|
9761
9769
|
|
|
@@ -9766,10 +9774,12 @@ const selectEventsWithSuggestion = createSelector(seamly_state_hooks_selectState
|
|
|
9766
9774
|
return [...events, suggestionsEvent];
|
|
9767
9775
|
});
|
|
9768
9776
|
const selectEvents = createSelector(selectEventsWithSuggestion, selectConfig, (events, config) => {
|
|
9777
|
+
var _config$messages;
|
|
9778
|
+
|
|
9769
9779
|
const {
|
|
9770
9780
|
enabled,
|
|
9771
9781
|
threshold
|
|
9772
|
-
} = config
|
|
9782
|
+
} = (config === null || config === void 0 ? void 0 : (_config$messages = config.messages) === null || _config$messages === void 0 ? void 0 : _config$messages.timeIndicator) ?? {};
|
|
9773
9783
|
|
|
9774
9784
|
if (!enabled) {
|
|
9775
9785
|
return events;
|
|
@@ -9803,8 +9813,10 @@ const useSkiplink = () => useSeamlyStateContext().skiplinkTargetId;
|
|
|
9803
9813
|
const useSeamlyParticipant = participantId => useSeamlyStateContext().participantInfo.participants[participantId];
|
|
9804
9814
|
const useSeamlyServiceInfo = () => useSeamlyStateContext().serviceInfo;
|
|
9805
9815
|
const selectLastMessageEventId = createSelector(selectEvents, events => {
|
|
9816
|
+
var _filteredEvents;
|
|
9817
|
+
|
|
9806
9818
|
const filteredEvents = events.filter(event => event.type === 'message');
|
|
9807
|
-
return filteredEvents[filteredEvents.length - 1]
|
|
9819
|
+
return (_filteredEvents = filteredEvents[filteredEvents.length - 1]) === null || _filteredEvents === void 0 ? void 0 : _filteredEvents.payload.id;
|
|
9808
9820
|
});
|
|
9809
9821
|
const useLastMessageEventId = () => hooks_useSelector(selectLastMessageEventId);
|
|
9810
9822
|
const useSeamlyIsHistoryLoaded = () => useSeamlyStateContext().historyLoaded;
|
|
@@ -9973,11 +9985,13 @@ const actions_initialize = visibility_utils_createThunk('initialize', async (loc
|
|
|
9973
9985
|
api
|
|
9974
9986
|
}
|
|
9975
9987
|
}) => {
|
|
9988
|
+
var _api$store$get;
|
|
9989
|
+
|
|
9976
9990
|
// initialize stored visibility
|
|
9977
9991
|
const {
|
|
9978
9992
|
layoutMode
|
|
9979
9993
|
} = selectConfig(getState());
|
|
9980
|
-
const storedVisibility = api.store.get(StoreKey)
|
|
9994
|
+
const storedVisibility = (_api$store$get = api.store.get(StoreKey)) === null || _api$store$get === void 0 ? void 0 : _api$store$get[layoutMode];
|
|
9981
9995
|
|
|
9982
9996
|
if (storedVisibility) {
|
|
9983
9997
|
dispatch(setFromStorage(storedVisibility));
|
|
@@ -10015,13 +10029,13 @@ class SeamlyBaseError extends Error {
|
|
|
10015
10029
|
|
|
10016
10030
|
this.originalError = originalError;
|
|
10017
10031
|
|
|
10018
|
-
if (originalError
|
|
10032
|
+
if (originalError !== null && originalError !== void 0 && originalError.payload) {
|
|
10019
10033
|
this.originalEvent = originalError;
|
|
10020
10034
|
this.originalError = originalError.payload.error;
|
|
10021
10035
|
this.message = `Event of type ${originalError.payload.type} encountered`;
|
|
10022
10036
|
}
|
|
10023
10037
|
|
|
10024
|
-
if (originalError
|
|
10038
|
+
if (originalError !== null && originalError !== void 0 && originalError.error) {
|
|
10025
10039
|
this.originalError = originalError.error;
|
|
10026
10040
|
}
|
|
10027
10041
|
}
|
|
@@ -10070,8 +10084,10 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
10070
10084
|
config
|
|
10071
10085
|
}
|
|
10072
10086
|
}) => {
|
|
10087
|
+
var _config$context;
|
|
10088
|
+
|
|
10073
10089
|
dispatch(initialize(config));
|
|
10074
|
-
let locale = config
|
|
10090
|
+
let locale = config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale;
|
|
10075
10091
|
|
|
10076
10092
|
try {
|
|
10077
10093
|
const {
|
|
@@ -10098,7 +10114,7 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
10098
10114
|
startChatIcon
|
|
10099
10115
|
}));
|
|
10100
10116
|
|
|
10101
|
-
if (agentParticipant
|
|
10117
|
+
if (agentParticipant !== null && agentParticipant !== void 0 && agentParticipant.name) {
|
|
10102
10118
|
dispatch({
|
|
10103
10119
|
type: seamlyActions.SET_HEADER_SUB_TITLE,
|
|
10104
10120
|
title: agentParticipant.name
|
|
@@ -10110,18 +10126,22 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
10110
10126
|
|
|
10111
10127
|
try {
|
|
10112
10128
|
if (api.hasConversation()) {
|
|
10129
|
+
var _initialState$transla;
|
|
10130
|
+
|
|
10113
10131
|
const initialState = await api.getConversationIntitialState();
|
|
10114
10132
|
dispatch({
|
|
10115
10133
|
type: seamlyActions.SET_INITIAL_STATE,
|
|
10116
10134
|
initialState
|
|
10117
10135
|
});
|
|
10118
|
-
locale = initialState.translation
|
|
10136
|
+
locale = ((_initialState$transla = initialState.translation) === null || _initialState$transla === void 0 ? void 0 : _initialState$transla.locale) || locale;
|
|
10119
10137
|
|
|
10120
10138
|
if ('userResponded' in initialState) {
|
|
10121
10139
|
dispatch(setHasResponded(initialState.userResponded));
|
|
10122
10140
|
}
|
|
10123
10141
|
} else {
|
|
10124
|
-
|
|
10142
|
+
var _config$context2, _config$context3;
|
|
10143
|
+
|
|
10144
|
+
if (config !== null && config !== void 0 && (_config$context2 = config.context) !== null && _config$context2 !== void 0 && _config$context2.topic) {
|
|
10125
10145
|
api.send('action', {
|
|
10126
10146
|
type: actionTypes.setTopic,
|
|
10127
10147
|
body: {
|
|
@@ -10133,7 +10153,7 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
10133
10153
|
});
|
|
10134
10154
|
}
|
|
10135
10155
|
|
|
10136
|
-
if (config
|
|
10156
|
+
if (config !== null && config !== void 0 && (_config$context3 = config.context) !== null && _config$context3 !== void 0 && _config$context3.translationLocale) {
|
|
10137
10157
|
locale = config.context.translationLocale;
|
|
10138
10158
|
api.send('action', {
|
|
10139
10159
|
type: actionTypes.setTranslation,
|
|
@@ -11537,13 +11557,13 @@ const useIntersect = ({
|
|
|
11537
11557
|
}) => {
|
|
11538
11558
|
const [entry, setEntry] = (0,hooks_namespaceObject.useState)(null);
|
|
11539
11559
|
const containerRef = (0,hooks_namespaceObject.useRef)(null);
|
|
11540
|
-
const isVisible = !!entry
|
|
11560
|
+
const isVisible = !!(entry !== null && entry !== void 0 && entry.isIntersecting) || !enabled;
|
|
11541
11561
|
const frozen = isVisible && freezeOnceVisible;
|
|
11542
11562
|
|
|
11543
11563
|
const observerCallback = ([updatedEntry]) => setEntry(updatedEntry);
|
|
11544
11564
|
|
|
11545
11565
|
(0,hooks_namespaceObject.useEffect)(() => {
|
|
11546
|
-
const node = containerRef
|
|
11566
|
+
const node = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
|
|
11547
11567
|
const hasIOSupport = !!window.IntersectionObserver;
|
|
11548
11568
|
|
|
11549
11569
|
if (!node && "production" === 'development') {} // Return an arrow function to have a consistent return value
|
|
@@ -12530,19 +12550,21 @@ function useTranslations() {
|
|
|
12530
12550
|
function useTranslatedEventData({
|
|
12531
12551
|
payload
|
|
12532
12552
|
} = {}) {
|
|
12533
|
-
|
|
12553
|
+
var _translatedBody, _translatedBody2, _translatedBody3;
|
|
12554
|
+
|
|
12555
|
+
const payloadId = payload === null || payload === void 0 ? void 0 : payload.id;
|
|
12534
12556
|
let body;
|
|
12535
12557
|
let translatedBody;
|
|
12536
12558
|
|
|
12537
|
-
switch (payload
|
|
12559
|
+
switch (payload === null || payload === void 0 ? void 0 : payload.type) {
|
|
12538
12560
|
case 'participant':
|
|
12539
12561
|
body = payload.participant.introduction;
|
|
12540
12562
|
translatedBody = payload.participant.translatedIntroduction;
|
|
12541
12563
|
break;
|
|
12542
12564
|
|
|
12543
12565
|
default:
|
|
12544
|
-
body = payload
|
|
12545
|
-
translatedBody = payload
|
|
12566
|
+
body = payload === null || payload === void 0 ? void 0 : payload.body;
|
|
12567
|
+
translatedBody = payload === null || payload === void 0 ? void 0 : payload.translatedBody;
|
|
12546
12568
|
}
|
|
12547
12569
|
|
|
12548
12570
|
const hasTranslation = !!translatedBody;
|
|
@@ -12557,12 +12579,12 @@ function useTranslatedEventData({
|
|
|
12557
12579
|
dispatch(enableEvent(payloadId));
|
|
12558
12580
|
}
|
|
12559
12581
|
}, [isTranslated, payloadId, dispatch]);
|
|
12560
|
-
return [hasTranslation && isTranslated ? translatedBody
|
|
12582
|
+
return [hasTranslation && isTranslated ? (_translatedBody = translatedBody) === null || _translatedBody === void 0 ? void 0 : _translatedBody.data : body, {
|
|
12561
12583
|
hasTranslation,
|
|
12562
12584
|
isTranslated: isTranslated && hasTranslation,
|
|
12563
12585
|
toggleTranslation,
|
|
12564
|
-
translatedBy: translatedBody
|
|
12565
|
-
locale: translatedBody
|
|
12586
|
+
translatedBy: (_translatedBody2 = translatedBody) === null || _translatedBody2 === void 0 ? void 0 : _translatedBody2.translatedBy,
|
|
12587
|
+
locale: (_translatedBody3 = translatedBody) === null || _translatedBody3 === void 0 ? void 0 : _translatedBody3.locale
|
|
12566
12588
|
}];
|
|
12567
12589
|
}
|
|
12568
12590
|
function useTranslationsContainer() {
|
|
@@ -12577,49 +12599,58 @@ function useLocaleNativeName(locale) {
|
|
|
12577
12599
|
const {
|
|
12578
12600
|
languages
|
|
12579
12601
|
} = useTranslations();
|
|
12580
|
-
return (0,hooks_namespaceObject.useMemo)(() =>
|
|
12602
|
+
return (0,hooks_namespaceObject.useMemo)(() => {
|
|
12603
|
+
var _languages$find;
|
|
12604
|
+
|
|
12605
|
+
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;
|
|
12606
|
+
}, [locale, languages]);
|
|
12581
12607
|
}
|
|
12582
12608
|
;// CONCATENATED MODULE: ./src/javascripts/domains/translations/middleware.js
|
|
12583
12609
|
|
|
12584
12610
|
|
|
12585
12611
|
|
|
12586
|
-
function middleware_createMiddleware(
|
|
12587
|
-
|
|
12588
|
-
|
|
12589
|
-
|
|
12590
|
-
|
|
12591
|
-
|
|
12612
|
+
function middleware_createMiddleware({
|
|
12613
|
+
dispatch,
|
|
12614
|
+
getState
|
|
12615
|
+
}) {
|
|
12616
|
+
return next => {
|
|
12617
|
+
return action => {
|
|
12618
|
+
var _action$history, _action$history$trans, _action$initialState, _action$initialState$, _action$event, _action$event$payload, _action$event$payload2;
|
|
12592
12619
|
|
|
12593
|
-
|
|
12594
|
-
case String(seamlyActions.SET_HISTORY):
|
|
12595
|
-
if (action.history?.translation?.enabled) {
|
|
12596
|
-
dispatch(enable(action.history.translation.locale));
|
|
12597
|
-
}
|
|
12620
|
+
const result = next(action);
|
|
12598
12621
|
|
|
12599
|
-
|
|
12622
|
+
switch (action.type) {
|
|
12623
|
+
case String(seamlyActions.SET_HISTORY):
|
|
12624
|
+
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) {
|
|
12625
|
+
dispatch(enable(action.history.translation.locale));
|
|
12626
|
+
dispatch(setLocale(action.history.translation.locale));
|
|
12627
|
+
}
|
|
12600
12628
|
|
|
12601
|
-
|
|
12602
|
-
if (action.initialState?.translation?.enabled) {
|
|
12603
|
-
dispatch(enable(action.initialState.translation.locale));
|
|
12604
|
-
dispatch(setLocale(action.locale));
|
|
12605
|
-
}
|
|
12629
|
+
break;
|
|
12606
12630
|
|
|
12607
|
-
|
|
12631
|
+
case String(seamlyActions.SET_INITIAL_STATE):
|
|
12632
|
+
if ((_action$initialState = action.initialState) !== null && _action$initialState !== void 0 && (_action$initialState$ = _action$initialState.translation) !== null && _action$initialState$ !== void 0 && _action$initialState$.enabled) {
|
|
12633
|
+
dispatch(enable(action.initialState.translation.locale));
|
|
12634
|
+
dispatch(setLocale(action.locale));
|
|
12635
|
+
}
|
|
12608
12636
|
|
|
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
|
-
}
|
|
12637
|
+
break;
|
|
12613
12638
|
|
|
12614
|
-
|
|
12639
|
+
case String(seamlyActions.ADD_EVENT):
|
|
12640
|
+
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) {
|
|
12641
|
+
dispatch(setLocale(action.event.payload.body.translationLocale));
|
|
12642
|
+
}
|
|
12615
12643
|
|
|
12616
|
-
|
|
12617
|
-
const initialLocale = selectInitialLocale(getState());
|
|
12618
|
-
dispatch(setLocale(initialLocale));
|
|
12619
|
-
break;
|
|
12620
|
-
}
|
|
12644
|
+
break;
|
|
12621
12645
|
|
|
12622
|
-
|
|
12646
|
+
case String(disable):
|
|
12647
|
+
const initialLocale = selectInitialLocale(getState());
|
|
12648
|
+
dispatch(setLocale(initialLocale));
|
|
12649
|
+
break;
|
|
12650
|
+
}
|
|
12651
|
+
|
|
12652
|
+
return result;
|
|
12653
|
+
};
|
|
12623
12654
|
};
|
|
12624
12655
|
}
|
|
12625
12656
|
;// CONCATENATED MODULE: ./src/javascripts/domains/translations/reducer.js
|
|
@@ -12644,7 +12675,9 @@ const translations_reducer_initialState = {
|
|
|
12644
12675
|
};
|
|
12645
12676
|
/* harmony default export */ const translations_reducer = (translations_utils_createReducer({
|
|
12646
12677
|
[seamlyActions.SET_FEATURES]: (state, action) => {
|
|
12647
|
-
|
|
12678
|
+
var _action$features;
|
|
12679
|
+
|
|
12680
|
+
const feature = action === null || action === void 0 ? void 0 : (_action$features = action.features) === null || _action$features === void 0 ? void 0 : _action$features.translation;
|
|
12648
12681
|
|
|
12649
12682
|
if (!feature) {
|
|
12650
12683
|
return state;
|
|
@@ -12997,7 +13030,9 @@ function validate(values, schema = {}) {
|
|
|
12997
13030
|
validations = [validations];
|
|
12998
13031
|
}
|
|
12999
13032
|
|
|
13000
|
-
for (let i = 0; i < validations
|
|
13033
|
+
for (let i = 0; i < ((_validations = validations) === null || _validations === void 0 ? void 0 : _validations.length) ?? 0; i++) {
|
|
13034
|
+
var _validations;
|
|
13035
|
+
|
|
13001
13036
|
if (!validations[i].fn(values[key], validations[i].compareValue)) {
|
|
13002
13037
|
errors[key] = validations[i].errorText;
|
|
13003
13038
|
break;
|
|
@@ -13044,7 +13079,7 @@ const [registerControl, deregisterControl, actions_updateControlValue, actions_u
|
|
|
13044
13079
|
|
|
13045
13080
|
const selectors_getState = forms_utils_selectState;
|
|
13046
13081
|
const getFormById = createSelector(selectors_getState, getPropSelector('formId'), (forms, formId) => forms[formId]);
|
|
13047
|
-
const getFormControlsByFormId = createSelector(getFormById, form => form
|
|
13082
|
+
const getFormControlsByFormId = createSelector(getFormById, form => (form === null || form === void 0 ? void 0 : form.controls) || {});
|
|
13048
13083
|
const getFormValuesByFormId = createSelector(getFormControlsByFormId, controls => {
|
|
13049
13084
|
const valuesObj = {};
|
|
13050
13085
|
Object.entries(controls).forEach(([key, {
|
|
@@ -13054,8 +13089,16 @@ const getFormValuesByFormId = createSelector(getFormControlsByFormId, controls =
|
|
|
13054
13089
|
});
|
|
13055
13090
|
return valuesObj;
|
|
13056
13091
|
});
|
|
13057
|
-
const getControlValueByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) =>
|
|
13058
|
-
|
|
13092
|
+
const getControlValueByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => {
|
|
13093
|
+
var _controls$name;
|
|
13094
|
+
|
|
13095
|
+
return (_controls$name = controls[name]) === null || _controls$name === void 0 ? void 0 : _controls$name.value;
|
|
13096
|
+
});
|
|
13097
|
+
const getControlTouchedByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => {
|
|
13098
|
+
var _controls$name2;
|
|
13099
|
+
|
|
13100
|
+
return (_controls$name2 = controls[name]) === null || _controls$name2 === void 0 ? void 0 : _controls$name2.touched;
|
|
13101
|
+
});
|
|
13059
13102
|
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/context.js
|
|
13060
13103
|
|
|
13061
13104
|
const FormContext = (0,external_preact_namespaceObject.createContext)({});
|
|
@@ -13115,7 +13158,7 @@ function useFormControl(name) {
|
|
|
13115
13158
|
formId,
|
|
13116
13159
|
name
|
|
13117
13160
|
}, [formId, name]);
|
|
13118
|
-
const error = errors
|
|
13161
|
+
const error = errors === null || errors === void 0 ? void 0 : errors[name];
|
|
13119
13162
|
const isValid = !error;
|
|
13120
13163
|
(0,hooks_namespaceObject.useEffect)(() => {
|
|
13121
13164
|
// Make sure the form is registered
|
|
@@ -13217,9 +13260,11 @@ function FormProvider(_ref) {
|
|
|
13217
13260
|
});
|
|
13218
13261
|
}, [setExternalErrors]);
|
|
13219
13262
|
const handleSubmit = (0,hooks_namespaceObject.useCallback)(e => {
|
|
13263
|
+
var _e$submitter;
|
|
13264
|
+
|
|
13220
13265
|
e.preventDefault(); // If the submitter is set to being aria-disabled, block the submit action
|
|
13221
13266
|
|
|
13222
|
-
const ariaDisabled = e.submitter
|
|
13267
|
+
const ariaDisabled = ((_e$submitter = e.submitter) === null || _e$submitter === void 0 ? void 0 : _e$submitter.ariaDisabled) === 'true';
|
|
13223
13268
|
setIsSubmitted(!ariaDisabled);
|
|
13224
13269
|
|
|
13225
13270
|
if (!ariaDisabled && validationIsValid) {
|
|
@@ -13286,7 +13331,9 @@ const initialControlState = {
|
|
|
13286
13331
|
};
|
|
13287
13332
|
|
|
13288
13333
|
function updateFormControl(state, formId, name, controlState) {
|
|
13289
|
-
|
|
13334
|
+
var _state$formId;
|
|
13335
|
+
|
|
13336
|
+
const currentControlState = ((_state$formId = state[formId]) === null || _state$formId === void 0 ? void 0 : _state$formId.controls[name]) || initialControlState;
|
|
13290
13337
|
return forms_reducer_objectSpread(forms_reducer_objectSpread({}, state), {}, {
|
|
13291
13338
|
[formId]: forms_reducer_objectSpread(forms_reducer_objectSpread({}, state[formId]), {}, {
|
|
13292
13339
|
controls: forms_reducer_objectSpread(forms_reducer_objectSpread({}, state[formId].controls), {}, {
|
|
@@ -13314,9 +13361,11 @@ function updateFormControl(state, formId, name, controlState) {
|
|
|
13314
13361
|
[deregisterForm]: (state, {
|
|
13315
13362
|
formId
|
|
13316
13363
|
}) => {
|
|
13364
|
+
var _newState$formId;
|
|
13365
|
+
|
|
13317
13366
|
const newState = forms_reducer_objectSpread({}, state);
|
|
13318
13367
|
|
|
13319
|
-
if (!newState[formId]
|
|
13368
|
+
if (!((_newState$formId = newState[formId]) !== null && _newState$formId !== void 0 && _newState$formId.persistData)) {
|
|
13320
13369
|
delete newState[formId];
|
|
13321
13370
|
}
|
|
13322
13371
|
|
|
@@ -13547,7 +13596,7 @@ const validateFileSize = (fileList, maxSize) => {
|
|
|
13547
13596
|
|
|
13548
13597
|
return isValid;
|
|
13549
13598
|
};
|
|
13550
|
-
const fileListObjectIsNotEmpty = fileListObj => !!fileListObj
|
|
13599
|
+
const fileListObjectIsNotEmpty = fileListObj => !!(fileListObj !== null && fileListObj !== void 0 && fileListObj.length) > 0;
|
|
13551
13600
|
/* eslint-disable no-control-regex */
|
|
13552
13601
|
|
|
13553
13602
|
const isEmailString = val => {
|
|
@@ -14544,11 +14593,13 @@ const timeFormatOptions = {
|
|
|
14544
14593
|
minute: 'numeric'
|
|
14545
14594
|
};
|
|
14546
14595
|
const useFormattedDate = date => {
|
|
14596
|
+
var _config$context;
|
|
14597
|
+
|
|
14547
14598
|
const {
|
|
14548
14599
|
t
|
|
14549
14600
|
} = useI18n();
|
|
14550
14601
|
const config = useConfig();
|
|
14551
|
-
const locale = config
|
|
14602
|
+
const locale = (config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale) ?? [];
|
|
14552
14603
|
const eventDate = new Date(date);
|
|
14553
14604
|
const currentDate = new Date();
|
|
14554
14605
|
const midnight = new Date(currentDate);
|
|
@@ -14920,9 +14971,11 @@ const useChoicePrompt = event => {
|
|
|
14920
14971
|
service
|
|
14921
14972
|
} = payload;
|
|
14922
14973
|
const subEvent = (0,hooks_namespaceObject.useMemo)(() => {
|
|
14974
|
+
var _event$payload$body;
|
|
14975
|
+
|
|
14923
14976
|
return choice_prompt_objectSpread(choice_prompt_objectSpread({}, event), {}, {
|
|
14924
14977
|
payload: choice_prompt_objectSpread(choice_prompt_objectSpread({}, event.payload), {}, {
|
|
14925
|
-
body: event.payload.body
|
|
14978
|
+
body: (_event$payload$body = event.payload.body) === null || _event$payload$body === void 0 ? void 0 : _event$payload$body.prompt,
|
|
14926
14979
|
translatedBody: event.payload.translatedBody && choice_prompt_objectSpread(choice_prompt_objectSpread({}, event.payload.translatedBody), {}, {
|
|
14927
14980
|
data: event.payload.translatedBody.data.prompt
|
|
14928
14981
|
})
|
|
@@ -17535,7 +17588,7 @@ const ConversationSuggestions = _ref => {
|
|
|
17535
17588
|
|
|
17536
17589
|
const hasLastTransactionEvent = (0,hooks_namespaceObject.useMemo)(() => events.some(({
|
|
17537
17590
|
payload: eventPayload
|
|
17538
|
-
}) => eventPayload
|
|
17591
|
+
}) => eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.transactionLast), [events]);
|
|
17539
17592
|
const handleClick = (0,hooks_namespaceObject.useCallback)(({
|
|
17540
17593
|
id,
|
|
17541
17594
|
question
|
|
@@ -17674,6 +17727,37 @@ const ComponentFilter = ({
|
|
|
17674
17727
|
|
|
17675
17728
|
|
|
17676
17729
|
|
|
17730
|
+
const Events = () => {
|
|
17731
|
+
const events = useEvents();
|
|
17732
|
+
let prevParticipant = null;
|
|
17733
|
+
return events.map(event => {
|
|
17734
|
+
const {
|
|
17735
|
+
type,
|
|
17736
|
+
payload
|
|
17737
|
+
} = event;
|
|
17738
|
+
const {
|
|
17739
|
+
participant,
|
|
17740
|
+
fromClient
|
|
17741
|
+
} = payload;
|
|
17742
|
+
let participantChanged = false;
|
|
17743
|
+
|
|
17744
|
+
if (type !== 'participant') {
|
|
17745
|
+
const currentParticipant = fromClient ? 'seamly-client-participant' : participant;
|
|
17746
|
+
|
|
17747
|
+
if (event.type !== 'info' && prevParticipant !== currentParticipant) {
|
|
17748
|
+
participantChanged = true;
|
|
17749
|
+
}
|
|
17750
|
+
|
|
17751
|
+
prevParticipant = currentParticipant;
|
|
17752
|
+
}
|
|
17753
|
+
|
|
17754
|
+
return (0,jsx_runtime_namespaceObject.jsx)(event_event, {
|
|
17755
|
+
event: event,
|
|
17756
|
+
newParticipant: participantChanged
|
|
17757
|
+
}, event.payload.key || event.payload.id);
|
|
17758
|
+
});
|
|
17759
|
+
};
|
|
17760
|
+
|
|
17677
17761
|
const Conversation = () => {
|
|
17678
17762
|
const {
|
|
17679
17763
|
t
|
|
@@ -17695,36 +17779,6 @@ const Conversation = () => {
|
|
|
17695
17779
|
}
|
|
17696
17780
|
}, [events, isLoading, isOpen, loadedImageEventIds]);
|
|
17697
17781
|
|
|
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
17782
|
const onClickHandler = e => {
|
|
17729
17783
|
e.preventDefault();
|
|
17730
17784
|
focusSkiplinkTarget();
|
|
@@ -17744,7 +17798,7 @@ const Conversation = () => {
|
|
|
17744
17798
|
children: [(0,jsx_runtime_namespaceObject.jsx)(privacy_disclaimer, {}), (0,jsx_runtime_namespaceObject.jsxs)("ol", {
|
|
17745
17799
|
className: css_className('conversation'),
|
|
17746
17800
|
children: [(0,jsx_runtime_namespaceObject.jsx)(component_filter, {
|
|
17747
|
-
children:
|
|
17801
|
+
children: (0,jsx_runtime_namespaceObject.jsx)(Events, {})
|
|
17748
17802
|
}), isLoading && (0,jsx_runtime_namespaceObject.jsx)(loader, {})]
|
|
17749
17803
|
})]
|
|
17750
17804
|
})
|
|
@@ -18952,7 +19006,11 @@ const OptionsButton = () => {
|
|
|
18952
19006
|
const prevMenuIsOpen = (0,hooks_namespaceObject.useRef)(false);
|
|
18953
19007
|
const multiMenu = optionsLength > 1;
|
|
18954
19008
|
const firstOption = menuOptions[0];
|
|
18955
|
-
const firstOptionName = (0,hooks_namespaceObject.useMemo)(() =>
|
|
19009
|
+
const firstOptionName = (0,hooks_namespaceObject.useMemo)(() => {
|
|
19010
|
+
var _firstOption$name;
|
|
19011
|
+
|
|
19012
|
+
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, '');
|
|
19013
|
+
}, [firstOption]);
|
|
18956
19014
|
(0,hooks_namespaceObject.useEffect)(() => {
|
|
18957
19015
|
return () => {
|
|
18958
19016
|
clearTimeout(focusOutDelayTimeoutID.current);
|
|
@@ -19621,7 +19679,7 @@ function errors_createMiddleware({
|
|
|
19621
19679
|
api,
|
|
19622
19680
|
layoutMode
|
|
19623
19681
|
} = selectConfig(getState());
|
|
19624
|
-
errorCallback
|
|
19682
|
+
errorCallback === null || errorCallback === void 0 ? void 0 : errorCallback(action.error, {
|
|
19625
19683
|
namespace,
|
|
19626
19684
|
api,
|
|
19627
19685
|
layoutMode,
|
|
@@ -19665,7 +19723,11 @@ function useSeamlyInstanceFunction(functionName, fn, deps = []) {
|
|
|
19665
19723
|
return undefined;
|
|
19666
19724
|
}
|
|
19667
19725
|
|
|
19668
|
-
const callback = (...args) =>
|
|
19726
|
+
const callback = (...args) => {
|
|
19727
|
+
var _callbackRef$current;
|
|
19728
|
+
|
|
19729
|
+
return (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, ...args);
|
|
19730
|
+
};
|
|
19669
19731
|
|
|
19670
19732
|
eventBus.emit('function.register', functionName, callback);
|
|
19671
19733
|
return () => eventBus.emit('function.unregister', functionName, callback); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -19710,12 +19772,12 @@ const SeamlyInstanceFunctionsLoader = () => {
|
|
|
19710
19772
|
sendMessage({
|
|
19711
19773
|
body: text
|
|
19712
19774
|
});
|
|
19713
|
-
}, [api
|
|
19775
|
+
}, [api === null || api === void 0 ? void 0 : api.send]);
|
|
19714
19776
|
useSeamlyInstanceFunction('setVariables', variables => {
|
|
19715
19777
|
sendContext({
|
|
19716
19778
|
variables
|
|
19717
19779
|
});
|
|
19718
|
-
}, [api
|
|
19780
|
+
}, [api === null || api === void 0 ? void 0 : api.send]);
|
|
19719
19781
|
useSeamlyInstanceFunction('getVisibility', callback => {
|
|
19720
19782
|
if (callback) {
|
|
19721
19783
|
callback(currentVisibility.current);
|
|
@@ -19731,7 +19793,7 @@ const SeamlyInstanceFunctionsLoader = () => {
|
|
|
19731
19793
|
|
|
19732
19794
|
onActivityHandler();
|
|
19733
19795
|
setVisibility(visibilityState);
|
|
19734
|
-
}, [config
|
|
19796
|
+
}, [config === null || config === void 0 ? void 0 : config.api]);
|
|
19735
19797
|
useSeamlyInstanceFunction('sendCustomAction', (actionType, body) => {
|
|
19736
19798
|
sendAction({
|
|
19737
19799
|
type: 'custom',
|
|
@@ -20649,31 +20711,25 @@ function store(key) {
|
|
|
20649
20711
|
// EXTERNAL MODULE: ./src/javascripts/lib/debug.js
|
|
20650
20712
|
var debug = __webpack_require__(905);
|
|
20651
20713
|
var debug_default = /*#__PURE__*/__webpack_require__.n(debug);
|
|
20652
|
-
;// CONCATENATED MODULE: ./node_modules/phoenix/priv/static/phoenix.
|
|
20714
|
+
;// CONCATENATED MODULE: ./node_modules/phoenix/priv/static/phoenix.mjs
|
|
20653
20715
|
// js/phoenix/utils.js
|
|
20654
|
-
var closure = value => {
|
|
20716
|
+
var closure = (value) => {
|
|
20655
20717
|
if (typeof value === "function") {
|
|
20656
20718
|
return value;
|
|
20657
20719
|
} else {
|
|
20658
|
-
let closure2 = function
|
|
20720
|
+
let closure2 = function() {
|
|
20659
20721
|
return value;
|
|
20660
20722
|
};
|
|
20661
|
-
|
|
20662
20723
|
return closure2;
|
|
20663
20724
|
}
|
|
20664
|
-
};
|
|
20665
|
-
|
|
20725
|
+
};
|
|
20666
20726
|
|
|
20727
|
+
// js/phoenix/constants.js
|
|
20667
20728
|
var globalSelf = typeof self !== "undefined" ? self : null;
|
|
20668
20729
|
var phxWindow = typeof window !== "undefined" ? window : null;
|
|
20669
|
-
var global = globalSelf || phxWindow ||
|
|
20730
|
+
var global = globalSelf || phxWindow || global;
|
|
20670
20731
|
var DEFAULT_VSN = "2.0.0";
|
|
20671
|
-
var SOCKET_STATES = {
|
|
20672
|
-
connecting: 0,
|
|
20673
|
-
open: 1,
|
|
20674
|
-
closing: 2,
|
|
20675
|
-
closed: 3
|
|
20676
|
-
};
|
|
20732
|
+
var SOCKET_STATES = { connecting: 0, open: 1, closing: 2, closed: 3 };
|
|
20677
20733
|
var DEFAULT_TIMEOUT = 1e4;
|
|
20678
20734
|
var WS_CLOSE_NORMAL = 1e3;
|
|
20679
20735
|
var CHANNEL_STATES = {
|
|
@@ -20696,35 +20752,31 @@ var TRANSPORTS = {
|
|
|
20696
20752
|
};
|
|
20697
20753
|
var XHR_STATES = {
|
|
20698
20754
|
complete: 4
|
|
20699
|
-
};
|
|
20755
|
+
};
|
|
20700
20756
|
|
|
20757
|
+
// js/phoenix/push.js
|
|
20701
20758
|
var Push = class {
|
|
20702
20759
|
constructor(channel, event, payload, timeout) {
|
|
20703
20760
|
this.channel = channel;
|
|
20704
20761
|
this.event = event;
|
|
20705
|
-
|
|
20706
|
-
this.payload = payload || function () {
|
|
20762
|
+
this.payload = payload || function() {
|
|
20707
20763
|
return {};
|
|
20708
20764
|
};
|
|
20709
|
-
|
|
20710
20765
|
this.receivedResp = null;
|
|
20711
20766
|
this.timeout = timeout;
|
|
20712
20767
|
this.timeoutTimer = null;
|
|
20713
20768
|
this.recHooks = [];
|
|
20714
20769
|
this.sent = false;
|
|
20715
20770
|
}
|
|
20716
|
-
|
|
20717
20771
|
resend(timeout) {
|
|
20718
20772
|
this.timeout = timeout;
|
|
20719
20773
|
this.reset();
|
|
20720
20774
|
this.send();
|
|
20721
20775
|
}
|
|
20722
|
-
|
|
20723
20776
|
send() {
|
|
20724
20777
|
if (this.hasReceived("timeout")) {
|
|
20725
20778
|
return;
|
|
20726
20779
|
}
|
|
20727
|
-
|
|
20728
20780
|
this.startTimeout();
|
|
20729
20781
|
this.sent = true;
|
|
20730
20782
|
this.channel.socket.push({
|
|
@@ -20735,19 +20787,13 @@ var Push = class {
|
|
|
20735
20787
|
join_ref: this.channel.joinRef()
|
|
20736
20788
|
});
|
|
20737
20789
|
}
|
|
20738
|
-
|
|
20739
20790
|
receive(status, callback) {
|
|
20740
20791
|
if (this.hasReceived(status)) {
|
|
20741
20792
|
callback(this.receivedResp.response);
|
|
20742
20793
|
}
|
|
20743
|
-
|
|
20744
|
-
this.recHooks.push({
|
|
20745
|
-
status,
|
|
20746
|
-
callback
|
|
20747
|
-
});
|
|
20794
|
+
this.recHooks.push({ status, callback });
|
|
20748
20795
|
return this;
|
|
20749
20796
|
}
|
|
20750
|
-
|
|
20751
20797
|
reset() {
|
|
20752
20798
|
this.cancelRefEvent();
|
|
20753
20799
|
this.ref = null;
|
|
@@ -20755,36 +20801,26 @@ var Push = class {
|
|
|
20755
20801
|
this.receivedResp = null;
|
|
20756
20802
|
this.sent = false;
|
|
20757
20803
|
}
|
|
20758
|
-
|
|
20759
|
-
|
|
20760
|
-
status,
|
|
20761
|
-
response,
|
|
20762
|
-
_ref
|
|
20763
|
-
}) {
|
|
20764
|
-
this.recHooks.filter(h => h.status === status).forEach(h => h.callback(response));
|
|
20804
|
+
matchReceive({ status, response, _ref }) {
|
|
20805
|
+
this.recHooks.filter((h) => h.status === status).forEach((h) => h.callback(response));
|
|
20765
20806
|
}
|
|
20766
|
-
|
|
20767
20807
|
cancelRefEvent() {
|
|
20768
20808
|
if (!this.refEvent) {
|
|
20769
20809
|
return;
|
|
20770
20810
|
}
|
|
20771
|
-
|
|
20772
20811
|
this.channel.off(this.refEvent);
|
|
20773
20812
|
}
|
|
20774
|
-
|
|
20775
20813
|
cancelTimeout() {
|
|
20776
20814
|
clearTimeout(this.timeoutTimer);
|
|
20777
20815
|
this.timeoutTimer = null;
|
|
20778
20816
|
}
|
|
20779
|
-
|
|
20780
20817
|
startTimeout() {
|
|
20781
20818
|
if (this.timeoutTimer) {
|
|
20782
20819
|
this.cancelTimeout();
|
|
20783
20820
|
}
|
|
20784
|
-
|
|
20785
20821
|
this.ref = this.channel.socket.makeRef();
|
|
20786
20822
|
this.refEvent = this.channel.replyEventName(this.ref);
|
|
20787
|
-
this.channel.on(this.refEvent, payload => {
|
|
20823
|
+
this.channel.on(this.refEvent, (payload) => {
|
|
20788
20824
|
this.cancelRefEvent();
|
|
20789
20825
|
this.cancelTimeout();
|
|
20790
20826
|
this.receivedResp = payload;
|
|
@@ -20794,20 +20830,15 @@ var Push = class {
|
|
|
20794
20830
|
this.trigger("timeout", {});
|
|
20795
20831
|
}, this.timeout);
|
|
20796
20832
|
}
|
|
20797
|
-
|
|
20798
20833
|
hasReceived(status) {
|
|
20799
20834
|
return this.receivedResp && this.receivedResp.status === status;
|
|
20800
20835
|
}
|
|
20801
|
-
|
|
20802
20836
|
trigger(status, response) {
|
|
20803
|
-
this.channel.trigger(this.refEvent, {
|
|
20804
|
-
status,
|
|
20805
|
-
response
|
|
20806
|
-
});
|
|
20837
|
+
this.channel.trigger(this.refEvent, { status, response });
|
|
20807
20838
|
}
|
|
20839
|
+
};
|
|
20808
20840
|
|
|
20809
|
-
|
|
20810
|
-
|
|
20841
|
+
// js/phoenix/timer.js
|
|
20811
20842
|
var Timer = class {
|
|
20812
20843
|
constructor(callback, timerCalc) {
|
|
20813
20844
|
this.callback = callback;
|
|
@@ -20815,12 +20846,10 @@ var Timer = class {
|
|
|
20815
20846
|
this.timer = null;
|
|
20816
20847
|
this.tries = 0;
|
|
20817
20848
|
}
|
|
20818
|
-
|
|
20819
20849
|
reset() {
|
|
20820
20850
|
this.tries = 0;
|
|
20821
20851
|
clearTimeout(this.timer);
|
|
20822
20852
|
}
|
|
20823
|
-
|
|
20824
20853
|
scheduleTimeout() {
|
|
20825
20854
|
clearTimeout(this.timer);
|
|
20826
20855
|
this.timer = setTimeout(() => {
|
|
@@ -20828,9 +20857,9 @@ var Timer = class {
|
|
|
20828
20857
|
this.callback();
|
|
20829
20858
|
}, this.timerCalc(this.tries + 1));
|
|
20830
20859
|
}
|
|
20860
|
+
};
|
|
20831
20861
|
|
|
20832
|
-
|
|
20833
|
-
|
|
20862
|
+
// js/phoenix/channel.js
|
|
20834
20863
|
var Channel = class {
|
|
20835
20864
|
constructor(topic, params, socket) {
|
|
20836
20865
|
this.state = CHANNEL_STATES.closed;
|
|
@@ -20852,7 +20881,6 @@ var Channel = class {
|
|
|
20852
20881
|
this.stateChangeRefs.push(this.socket.onError(() => this.rejoinTimer.reset()));
|
|
20853
20882
|
this.stateChangeRefs.push(this.socket.onOpen(() => {
|
|
20854
20883
|
this.rejoinTimer.reset();
|
|
20855
|
-
|
|
20856
20884
|
if (this.isErrored()) {
|
|
20857
20885
|
this.rejoin();
|
|
20858
20886
|
}
|
|
@@ -20860,42 +20888,40 @@ var Channel = class {
|
|
|
20860
20888
|
this.joinPush.receive("ok", () => {
|
|
20861
20889
|
this.state = CHANNEL_STATES.joined;
|
|
20862
20890
|
this.rejoinTimer.reset();
|
|
20863
|
-
this.pushBuffer.forEach(pushEvent => pushEvent.send());
|
|
20891
|
+
this.pushBuffer.forEach((pushEvent) => pushEvent.send());
|
|
20864
20892
|
this.pushBuffer = [];
|
|
20865
20893
|
});
|
|
20866
20894
|
this.joinPush.receive("error", () => {
|
|
20867
20895
|
this.state = CHANNEL_STATES.errored;
|
|
20868
|
-
|
|
20869
20896
|
if (this.socket.isConnected()) {
|
|
20870
20897
|
this.rejoinTimer.scheduleTimeout();
|
|
20871
20898
|
}
|
|
20872
20899
|
});
|
|
20873
20900
|
this.onClose(() => {
|
|
20874
20901
|
this.rejoinTimer.reset();
|
|
20875
|
-
if (this.socket.hasLogger())
|
|
20902
|
+
if (this.socket.hasLogger())
|
|
20903
|
+
this.socket.log("channel", `close ${this.topic} ${this.joinRef()}`);
|
|
20876
20904
|
this.state = CHANNEL_STATES.closed;
|
|
20877
20905
|
this.socket.remove(this);
|
|
20878
20906
|
});
|
|
20879
|
-
this.onError(reason => {
|
|
20880
|
-
if (this.socket.hasLogger())
|
|
20881
|
-
|
|
20907
|
+
this.onError((reason) => {
|
|
20908
|
+
if (this.socket.hasLogger())
|
|
20909
|
+
this.socket.log("channel", `error ${this.topic}`, reason);
|
|
20882
20910
|
if (this.isJoining()) {
|
|
20883
20911
|
this.joinPush.reset();
|
|
20884
20912
|
}
|
|
20885
|
-
|
|
20886
20913
|
this.state = CHANNEL_STATES.errored;
|
|
20887
|
-
|
|
20888
20914
|
if (this.socket.isConnected()) {
|
|
20889
20915
|
this.rejoinTimer.scheduleTimeout();
|
|
20890
20916
|
}
|
|
20891
20917
|
});
|
|
20892
20918
|
this.joinPush.receive("timeout", () => {
|
|
20893
|
-
if (this.socket.hasLogger())
|
|
20919
|
+
if (this.socket.hasLogger())
|
|
20920
|
+
this.socket.log("channel", `timeout ${this.topic} (${this.joinRef()})`, this.joinPush.timeout);
|
|
20894
20921
|
let leavePush = new Push(this, CHANNEL_EVENTS.leave, closure({}), this.timeout);
|
|
20895
20922
|
leavePush.send();
|
|
20896
20923
|
this.state = CHANNEL_STATES.errored;
|
|
20897
20924
|
this.joinPush.reset();
|
|
20898
|
-
|
|
20899
20925
|
if (this.socket.isConnected()) {
|
|
20900
20926
|
this.rejoinTimer.scheduleTimeout();
|
|
20901
20927
|
}
|
|
@@ -20904,7 +20930,6 @@ var Channel = class {
|
|
|
20904
20930
|
this.trigger(this.replyEventName(ref), payload);
|
|
20905
20931
|
});
|
|
20906
20932
|
}
|
|
20907
|
-
|
|
20908
20933
|
join(timeout = this.timeout) {
|
|
20909
20934
|
if (this.joinedOnce) {
|
|
20910
20935
|
throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");
|
|
@@ -20915,211 +20940,162 @@ var Channel = class {
|
|
|
20915
20940
|
return this.joinPush;
|
|
20916
20941
|
}
|
|
20917
20942
|
}
|
|
20918
|
-
|
|
20919
20943
|
onClose(callback) {
|
|
20920
20944
|
this.on(CHANNEL_EVENTS.close, callback);
|
|
20921
20945
|
}
|
|
20922
|
-
|
|
20923
20946
|
onError(callback) {
|
|
20924
|
-
return this.on(CHANNEL_EVENTS.error, reason => callback(reason));
|
|
20947
|
+
return this.on(CHANNEL_EVENTS.error, (reason) => callback(reason));
|
|
20925
20948
|
}
|
|
20926
|
-
|
|
20927
20949
|
on(event, callback) {
|
|
20928
20950
|
let ref = this.bindingRef++;
|
|
20929
|
-
this.bindings.push({
|
|
20930
|
-
event,
|
|
20931
|
-
ref,
|
|
20932
|
-
callback
|
|
20933
|
-
});
|
|
20951
|
+
this.bindings.push({ event, ref, callback });
|
|
20934
20952
|
return ref;
|
|
20935
20953
|
}
|
|
20936
|
-
|
|
20937
20954
|
off(event, ref) {
|
|
20938
|
-
this.bindings = this.bindings.filter(bind => {
|
|
20955
|
+
this.bindings = this.bindings.filter((bind) => {
|
|
20939
20956
|
return !(bind.event === event && (typeof ref === "undefined" || ref === bind.ref));
|
|
20940
20957
|
});
|
|
20941
20958
|
}
|
|
20942
|
-
|
|
20943
20959
|
canPush() {
|
|
20944
20960
|
return this.socket.isConnected() && this.isJoined();
|
|
20945
20961
|
}
|
|
20946
|
-
|
|
20947
20962
|
push(event, payload, timeout = this.timeout) {
|
|
20948
20963
|
payload = payload || {};
|
|
20949
|
-
|
|
20950
20964
|
if (!this.joinedOnce) {
|
|
20951
20965
|
throw new Error(`tried to push '${event}' to '${this.topic}' before joining. Use channel.join() before pushing events`);
|
|
20952
20966
|
}
|
|
20953
|
-
|
|
20954
|
-
let pushEvent = new Push(this, event, function () {
|
|
20967
|
+
let pushEvent = new Push(this, event, function() {
|
|
20955
20968
|
return payload;
|
|
20956
20969
|
}, timeout);
|
|
20957
|
-
|
|
20958
20970
|
if (this.canPush()) {
|
|
20959
20971
|
pushEvent.send();
|
|
20960
20972
|
} else {
|
|
20961
20973
|
pushEvent.startTimeout();
|
|
20962
20974
|
this.pushBuffer.push(pushEvent);
|
|
20963
20975
|
}
|
|
20964
|
-
|
|
20965
20976
|
return pushEvent;
|
|
20966
20977
|
}
|
|
20967
|
-
|
|
20968
20978
|
leave(timeout = this.timeout) {
|
|
20969
20979
|
this.rejoinTimer.reset();
|
|
20970
20980
|
this.joinPush.cancelTimeout();
|
|
20971
20981
|
this.state = CHANNEL_STATES.leaving;
|
|
20972
|
-
|
|
20973
20982
|
let onClose = () => {
|
|
20974
|
-
if (this.socket.hasLogger())
|
|
20983
|
+
if (this.socket.hasLogger())
|
|
20984
|
+
this.socket.log("channel", `leave ${this.topic}`);
|
|
20975
20985
|
this.trigger(CHANNEL_EVENTS.close, "leave");
|
|
20976
20986
|
};
|
|
20977
|
-
|
|
20978
20987
|
let leavePush = new Push(this, CHANNEL_EVENTS.leave, closure({}), timeout);
|
|
20979
20988
|
leavePush.receive("ok", () => onClose()).receive("timeout", () => onClose());
|
|
20980
20989
|
leavePush.send();
|
|
20981
|
-
|
|
20982
20990
|
if (!this.canPush()) {
|
|
20983
20991
|
leavePush.trigger("ok", {});
|
|
20984
20992
|
}
|
|
20985
|
-
|
|
20986
20993
|
return leavePush;
|
|
20987
20994
|
}
|
|
20988
|
-
|
|
20989
20995
|
onMessage(_event, payload, _ref) {
|
|
20990
20996
|
return payload;
|
|
20991
20997
|
}
|
|
20992
|
-
|
|
20993
20998
|
isMember(topic, event, payload, joinRef) {
|
|
20994
20999
|
if (this.topic !== topic) {
|
|
20995
21000
|
return false;
|
|
20996
21001
|
}
|
|
20997
|
-
|
|
20998
21002
|
if (joinRef && joinRef !== this.joinRef()) {
|
|
20999
|
-
if (this.socket.hasLogger())
|
|
21000
|
-
topic,
|
|
21001
|
-
event,
|
|
21002
|
-
payload,
|
|
21003
|
-
joinRef
|
|
21004
|
-
});
|
|
21003
|
+
if (this.socket.hasLogger())
|
|
21004
|
+
this.socket.log("channel", "dropping outdated message", { topic, event, payload, joinRef });
|
|
21005
21005
|
return false;
|
|
21006
21006
|
} else {
|
|
21007
21007
|
return true;
|
|
21008
21008
|
}
|
|
21009
21009
|
}
|
|
21010
|
-
|
|
21011
21010
|
joinRef() {
|
|
21012
21011
|
return this.joinPush.ref;
|
|
21013
21012
|
}
|
|
21014
|
-
|
|
21015
21013
|
rejoin(timeout = this.timeout) {
|
|
21016
21014
|
if (this.isLeaving()) {
|
|
21017
21015
|
return;
|
|
21018
21016
|
}
|
|
21019
|
-
|
|
21020
21017
|
this.socket.leaveOpenTopic(this.topic);
|
|
21021
21018
|
this.state = CHANNEL_STATES.joining;
|
|
21022
21019
|
this.joinPush.resend(timeout);
|
|
21023
21020
|
}
|
|
21024
|
-
|
|
21025
21021
|
trigger(event, payload, ref, joinRef) {
|
|
21026
21022
|
let handledPayload = this.onMessage(event, payload, ref, joinRef);
|
|
21027
|
-
|
|
21028
21023
|
if (payload && !handledPayload) {
|
|
21029
21024
|
throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");
|
|
21030
21025
|
}
|
|
21031
|
-
|
|
21032
|
-
let eventBindings = this.bindings.filter(bind => bind.event === event);
|
|
21033
|
-
|
|
21026
|
+
let eventBindings = this.bindings.filter((bind) => bind.event === event);
|
|
21034
21027
|
for (let i = 0; i < eventBindings.length; i++) {
|
|
21035
21028
|
let bind = eventBindings[i];
|
|
21036
21029
|
bind.callback(handledPayload, ref, joinRef || this.joinRef());
|
|
21037
21030
|
}
|
|
21038
21031
|
}
|
|
21039
|
-
|
|
21040
21032
|
replyEventName(ref) {
|
|
21041
21033
|
return `chan_reply_${ref}`;
|
|
21042
21034
|
}
|
|
21043
|
-
|
|
21044
21035
|
isClosed() {
|
|
21045
21036
|
return this.state === CHANNEL_STATES.closed;
|
|
21046
21037
|
}
|
|
21047
|
-
|
|
21048
21038
|
isErrored() {
|
|
21049
21039
|
return this.state === CHANNEL_STATES.errored;
|
|
21050
21040
|
}
|
|
21051
|
-
|
|
21052
21041
|
isJoined() {
|
|
21053
21042
|
return this.state === CHANNEL_STATES.joined;
|
|
21054
21043
|
}
|
|
21055
|
-
|
|
21056
21044
|
isJoining() {
|
|
21057
21045
|
return this.state === CHANNEL_STATES.joining;
|
|
21058
21046
|
}
|
|
21059
|
-
|
|
21060
21047
|
isLeaving() {
|
|
21061
21048
|
return this.state === CHANNEL_STATES.leaving;
|
|
21062
21049
|
}
|
|
21050
|
+
};
|
|
21063
21051
|
|
|
21064
|
-
|
|
21065
|
-
|
|
21052
|
+
// js/phoenix/ajax.js
|
|
21066
21053
|
var Ajax = class {
|
|
21067
21054
|
static request(method, endPoint, accept, body, timeout, ontimeout, callback) {
|
|
21068
21055
|
if (global.XDomainRequest) {
|
|
21069
21056
|
let req = new global.XDomainRequest();
|
|
21070
|
-
this.xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback);
|
|
21057
|
+
return this.xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback);
|
|
21071
21058
|
} else {
|
|
21072
21059
|
let req = new global.XMLHttpRequest();
|
|
21073
|
-
this.xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback);
|
|
21060
|
+
return this.xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback);
|
|
21074
21061
|
}
|
|
21075
21062
|
}
|
|
21076
|
-
|
|
21077
21063
|
static xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback) {
|
|
21078
21064
|
req.timeout = timeout;
|
|
21079
21065
|
req.open(method, endPoint);
|
|
21080
|
-
|
|
21081
21066
|
req.onload = () => {
|
|
21082
21067
|
let response = this.parseJSON(req.responseText);
|
|
21083
21068
|
callback && callback(response);
|
|
21084
21069
|
};
|
|
21085
|
-
|
|
21086
21070
|
if (ontimeout) {
|
|
21087
21071
|
req.ontimeout = ontimeout;
|
|
21088
21072
|
}
|
|
21089
|
-
|
|
21090
|
-
|
|
21091
|
-
|
|
21073
|
+
req.onprogress = () => {
|
|
21074
|
+
};
|
|
21092
21075
|
req.send(body);
|
|
21076
|
+
return req;
|
|
21093
21077
|
}
|
|
21094
|
-
|
|
21095
21078
|
static xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback) {
|
|
21096
21079
|
req.open(method, endPoint, true);
|
|
21097
21080
|
req.timeout = timeout;
|
|
21098
21081
|
req.setRequestHeader("Content-Type", accept);
|
|
21099
|
-
|
|
21100
|
-
req.onerror = () => {
|
|
21101
|
-
callback && callback(null);
|
|
21102
|
-
};
|
|
21103
|
-
|
|
21082
|
+
req.onerror = () => callback && callback(null);
|
|
21104
21083
|
req.onreadystatechange = () => {
|
|
21105
21084
|
if (req.readyState === XHR_STATES.complete && callback) {
|
|
21106
21085
|
let response = this.parseJSON(req.responseText);
|
|
21107
21086
|
callback(response);
|
|
21108
21087
|
}
|
|
21109
21088
|
};
|
|
21110
|
-
|
|
21111
21089
|
if (ontimeout) {
|
|
21112
21090
|
req.ontimeout = ontimeout;
|
|
21113
21091
|
}
|
|
21114
|
-
|
|
21115
21092
|
req.send(body);
|
|
21093
|
+
return req;
|
|
21116
21094
|
}
|
|
21117
|
-
|
|
21118
21095
|
static parseJSON(resp) {
|
|
21119
21096
|
if (!resp || resp === "") {
|
|
21120
21097
|
return null;
|
|
21121
21098
|
}
|
|
21122
|
-
|
|
21123
21099
|
try {
|
|
21124
21100
|
return JSON.parse(resp);
|
|
21125
21101
|
} catch (e) {
|
|
@@ -21127,186 +21103,168 @@ var Ajax = class {
|
|
|
21127
21103
|
return null;
|
|
21128
21104
|
}
|
|
21129
21105
|
}
|
|
21130
|
-
|
|
21131
21106
|
static serialize(obj, parentKey) {
|
|
21132
21107
|
let queryStr = [];
|
|
21133
|
-
|
|
21134
21108
|
for (var key in obj) {
|
|
21135
21109
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
21136
21110
|
continue;
|
|
21137
21111
|
}
|
|
21138
|
-
|
|
21139
21112
|
let paramKey = parentKey ? `${parentKey}[${key}]` : key;
|
|
21140
21113
|
let paramVal = obj[key];
|
|
21141
|
-
|
|
21142
21114
|
if (typeof paramVal === "object") {
|
|
21143
21115
|
queryStr.push(this.serialize(paramVal, paramKey));
|
|
21144
21116
|
} else {
|
|
21145
21117
|
queryStr.push(encodeURIComponent(paramKey) + "=" + encodeURIComponent(paramVal));
|
|
21146
21118
|
}
|
|
21147
21119
|
}
|
|
21148
|
-
|
|
21149
21120
|
return queryStr.join("&");
|
|
21150
21121
|
}
|
|
21151
|
-
|
|
21152
21122
|
static appendParams(url, params) {
|
|
21153
21123
|
if (Object.keys(params).length === 0) {
|
|
21154
21124
|
return url;
|
|
21155
21125
|
}
|
|
21156
|
-
|
|
21157
21126
|
let prefix = url.match(/\?/) ? "&" : "?";
|
|
21158
21127
|
return `${url}${prefix}${this.serialize(params)}`;
|
|
21159
21128
|
}
|
|
21129
|
+
};
|
|
21160
21130
|
|
|
21161
|
-
|
|
21162
|
-
|
|
21131
|
+
// js/phoenix/longpoll.js
|
|
21163
21132
|
var LongPoll = class {
|
|
21164
21133
|
constructor(endPoint) {
|
|
21165
21134
|
this.endPoint = null;
|
|
21166
21135
|
this.token = null;
|
|
21167
21136
|
this.skipHeartbeat = true;
|
|
21168
|
-
|
|
21169
|
-
this.onopen = function
|
|
21170
|
-
|
|
21171
|
-
this.onerror = function
|
|
21172
|
-
|
|
21173
|
-
this.onmessage = function
|
|
21174
|
-
|
|
21175
|
-
this.onclose = function
|
|
21176
|
-
|
|
21137
|
+
this.reqs = /* @__PURE__ */ new Set();
|
|
21138
|
+
this.onopen = function() {
|
|
21139
|
+
};
|
|
21140
|
+
this.onerror = function() {
|
|
21141
|
+
};
|
|
21142
|
+
this.onmessage = function() {
|
|
21143
|
+
};
|
|
21144
|
+
this.onclose = function() {
|
|
21145
|
+
};
|
|
21177
21146
|
this.pollEndpoint = this.normalizeEndpoint(endPoint);
|
|
21178
21147
|
this.readyState = SOCKET_STATES.connecting;
|
|
21179
21148
|
this.poll();
|
|
21180
21149
|
}
|
|
21181
|
-
|
|
21182
21150
|
normalizeEndpoint(endPoint) {
|
|
21183
21151
|
return endPoint.replace("ws://", "http://").replace("wss://", "https://").replace(new RegExp("(.*)/" + TRANSPORTS.websocket), "$1/" + TRANSPORTS.longpoll);
|
|
21184
21152
|
}
|
|
21185
|
-
|
|
21186
21153
|
endpointURL() {
|
|
21187
|
-
return Ajax.appendParams(this.pollEndpoint, {
|
|
21188
|
-
token: this.token
|
|
21189
|
-
});
|
|
21154
|
+
return Ajax.appendParams(this.pollEndpoint, { token: this.token });
|
|
21190
21155
|
}
|
|
21191
|
-
|
|
21192
|
-
|
|
21193
|
-
this.close();
|
|
21156
|
+
closeAndRetry(code, reason, wasClean) {
|
|
21157
|
+
this.close(code, reason, wasClean);
|
|
21194
21158
|
this.readyState = SOCKET_STATES.connecting;
|
|
21195
21159
|
}
|
|
21196
|
-
|
|
21197
21160
|
ontimeout() {
|
|
21198
21161
|
this.onerror("timeout");
|
|
21199
|
-
this.closeAndRetry();
|
|
21162
|
+
this.closeAndRetry(1005, "timeout", false);
|
|
21163
|
+
}
|
|
21164
|
+
isActive() {
|
|
21165
|
+
return this.readyState === SOCKET_STATES.open || this.readyState === SOCKET_STATES.connecting;
|
|
21200
21166
|
}
|
|
21201
|
-
|
|
21202
21167
|
poll() {
|
|
21203
|
-
|
|
21204
|
-
return;
|
|
21205
|
-
}
|
|
21206
|
-
|
|
21207
|
-
Ajax.request("GET", this.endpointURL(), "application/json", null, this.timeout, this.ontimeout.bind(this), resp => {
|
|
21168
|
+
this.ajax("GET", null, () => this.ontimeout(), (resp) => {
|
|
21208
21169
|
if (resp) {
|
|
21209
|
-
var {
|
|
21210
|
-
status,
|
|
21211
|
-
token,
|
|
21212
|
-
messages
|
|
21213
|
-
} = resp;
|
|
21170
|
+
var { status, token, messages } = resp;
|
|
21214
21171
|
this.token = token;
|
|
21215
21172
|
} else {
|
|
21216
21173
|
status = 0;
|
|
21217
21174
|
}
|
|
21218
|
-
|
|
21219
21175
|
switch (status) {
|
|
21220
21176
|
case 200:
|
|
21221
|
-
messages.forEach(msg => {
|
|
21222
|
-
setTimeout(() => {
|
|
21223
|
-
this.onmessage({
|
|
21224
|
-
data: msg
|
|
21225
|
-
});
|
|
21226
|
-
}, 0);
|
|
21177
|
+
messages.forEach((msg) => {
|
|
21178
|
+
setTimeout(() => this.onmessage({ data: msg }), 0);
|
|
21227
21179
|
});
|
|
21228
21180
|
this.poll();
|
|
21229
21181
|
break;
|
|
21230
|
-
|
|
21231
21182
|
case 204:
|
|
21232
21183
|
this.poll();
|
|
21233
21184
|
break;
|
|
21234
|
-
|
|
21235
21185
|
case 410:
|
|
21236
21186
|
this.readyState = SOCKET_STATES.open;
|
|
21237
|
-
this.onopen();
|
|
21187
|
+
this.onopen({});
|
|
21238
21188
|
this.poll();
|
|
21239
21189
|
break;
|
|
21240
|
-
|
|
21241
21190
|
case 403:
|
|
21242
|
-
this.onerror();
|
|
21243
|
-
this.close();
|
|
21191
|
+
this.onerror(403);
|
|
21192
|
+
this.close(1008, "forbidden", false);
|
|
21244
21193
|
break;
|
|
21245
|
-
|
|
21246
21194
|
case 0:
|
|
21247
21195
|
case 500:
|
|
21248
|
-
this.onerror();
|
|
21249
|
-
this.closeAndRetry();
|
|
21196
|
+
this.onerror(500);
|
|
21197
|
+
this.closeAndRetry(1011, "internal server error", 500);
|
|
21250
21198
|
break;
|
|
21251
|
-
|
|
21252
21199
|
default:
|
|
21253
21200
|
throw new Error(`unhandled poll status ${status}`);
|
|
21254
21201
|
}
|
|
21255
21202
|
});
|
|
21256
21203
|
}
|
|
21257
|
-
|
|
21258
21204
|
send(body) {
|
|
21259
|
-
|
|
21205
|
+
this.ajax("POST", body, () => this.onerror("timeout"), (resp) => {
|
|
21260
21206
|
if (!resp || resp.status !== 200) {
|
|
21261
21207
|
this.onerror(resp && resp.status);
|
|
21262
|
-
this.closeAndRetry();
|
|
21208
|
+
this.closeAndRetry(1011, "internal server error", false);
|
|
21263
21209
|
}
|
|
21264
21210
|
});
|
|
21265
21211
|
}
|
|
21266
|
-
|
|
21267
|
-
|
|
21212
|
+
close(code, reason, wasClean) {
|
|
21213
|
+
for (let req of this.reqs) {
|
|
21214
|
+
req.abort();
|
|
21215
|
+
}
|
|
21268
21216
|
this.readyState = SOCKET_STATES.closed;
|
|
21269
|
-
|
|
21217
|
+
let opts = Object.assign({ code: 1e3, reason: void 0, wasClean: true }, { code, reason, wasClean });
|
|
21218
|
+
if (typeof CloseEvent !== "undefined") {
|
|
21219
|
+
this.onclose(new CloseEvent("close", opts));
|
|
21220
|
+
} else {
|
|
21221
|
+
this.onclose(opts);
|
|
21222
|
+
}
|
|
21270
21223
|
}
|
|
21224
|
+
ajax(method, body, onCallerTimeout, callback) {
|
|
21225
|
+
let req;
|
|
21226
|
+
let ontimeout = () => {
|
|
21227
|
+
this.reqs.delete(req);
|
|
21228
|
+
onCallerTimeout();
|
|
21229
|
+
};
|
|
21230
|
+
req = Ajax.request(method, this.endpointURL(), "application/json", body, this.timeout, ontimeout, (resp) => {
|
|
21231
|
+
this.reqs.delete(req);
|
|
21232
|
+
if (this.isActive()) {
|
|
21233
|
+
callback(resp);
|
|
21234
|
+
}
|
|
21235
|
+
});
|
|
21236
|
+
this.reqs.add(req);
|
|
21237
|
+
}
|
|
21238
|
+
};
|
|
21271
21239
|
|
|
21272
|
-
|
|
21273
|
-
|
|
21240
|
+
// js/phoenix/presence.js
|
|
21274
21241
|
var Presence = class {
|
|
21275
21242
|
constructor(channel, opts = {}) {
|
|
21276
|
-
let events = opts.events || {
|
|
21277
|
-
state: "presence_state",
|
|
21278
|
-
diff: "presence_diff"
|
|
21279
|
-
};
|
|
21243
|
+
let events = opts.events || { state: "presence_state", diff: "presence_diff" };
|
|
21280
21244
|
this.state = {};
|
|
21281
21245
|
this.pendingDiffs = [];
|
|
21282
21246
|
this.channel = channel;
|
|
21283
21247
|
this.joinRef = null;
|
|
21284
21248
|
this.caller = {
|
|
21285
|
-
onJoin: function
|
|
21286
|
-
|
|
21287
|
-
|
|
21249
|
+
onJoin: function() {
|
|
21250
|
+
},
|
|
21251
|
+
onLeave: function() {
|
|
21252
|
+
},
|
|
21253
|
+
onSync: function() {
|
|
21254
|
+
}
|
|
21288
21255
|
};
|
|
21289
|
-
this.channel.on(events.state, newState => {
|
|
21290
|
-
let {
|
|
21291
|
-
onJoin,
|
|
21292
|
-
onLeave,
|
|
21293
|
-
onSync
|
|
21294
|
-
} = this.caller;
|
|
21256
|
+
this.channel.on(events.state, (newState) => {
|
|
21257
|
+
let { onJoin, onLeave, onSync } = this.caller;
|
|
21295
21258
|
this.joinRef = this.channel.joinRef();
|
|
21296
21259
|
this.state = Presence.syncState(this.state, newState, onJoin, onLeave);
|
|
21297
|
-
this.pendingDiffs.forEach(diff => {
|
|
21260
|
+
this.pendingDiffs.forEach((diff) => {
|
|
21298
21261
|
this.state = Presence.syncDiff(this.state, diff, onJoin, onLeave);
|
|
21299
21262
|
});
|
|
21300
21263
|
this.pendingDiffs = [];
|
|
21301
21264
|
onSync();
|
|
21302
21265
|
});
|
|
21303
|
-
this.channel.on(events.diff, diff => {
|
|
21304
|
-
let {
|
|
21305
|
-
onJoin,
|
|
21306
|
-
onLeave,
|
|
21307
|
-
onSync
|
|
21308
|
-
} = this.caller;
|
|
21309
|
-
|
|
21266
|
+
this.channel.on(events.diff, (diff) => {
|
|
21267
|
+
let { onJoin, onLeave, onSync } = this.caller;
|
|
21310
21268
|
if (this.inPendingSyncState()) {
|
|
21311
21269
|
this.pendingDiffs.push(diff);
|
|
21312
21270
|
} else {
|
|
@@ -21315,27 +21273,21 @@ var Presence = class {
|
|
|
21315
21273
|
}
|
|
21316
21274
|
});
|
|
21317
21275
|
}
|
|
21318
|
-
|
|
21319
21276
|
onJoin(callback) {
|
|
21320
21277
|
this.caller.onJoin = callback;
|
|
21321
21278
|
}
|
|
21322
|
-
|
|
21323
21279
|
onLeave(callback) {
|
|
21324
21280
|
this.caller.onLeave = callback;
|
|
21325
21281
|
}
|
|
21326
|
-
|
|
21327
21282
|
onSync(callback) {
|
|
21328
21283
|
this.caller.onSync = callback;
|
|
21329
21284
|
}
|
|
21330
|
-
|
|
21331
21285
|
list(by) {
|
|
21332
21286
|
return Presence.list(this.state, by);
|
|
21333
21287
|
}
|
|
21334
|
-
|
|
21335
21288
|
inPendingSyncState() {
|
|
21336
21289
|
return !this.joinRef || this.joinRef !== this.channel.joinRef();
|
|
21337
21290
|
}
|
|
21338
|
-
|
|
21339
21291
|
static syncState(currentState, newState, onJoin, onLeave) {
|
|
21340
21292
|
let state = this.clone(currentState);
|
|
21341
21293
|
let joins = {};
|
|
@@ -21347,18 +21299,15 @@ var Presence = class {
|
|
|
21347
21299
|
});
|
|
21348
21300
|
this.map(newState, (key, newPresence) => {
|
|
21349
21301
|
let currentPresence = state[key];
|
|
21350
|
-
|
|
21351
21302
|
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
|
-
|
|
21303
|
+
let newRefs = newPresence.metas.map((m) => m.phx_ref);
|
|
21304
|
+
let curRefs = currentPresence.metas.map((m) => m.phx_ref);
|
|
21305
|
+
let joinedMetas = newPresence.metas.filter((m) => curRefs.indexOf(m.phx_ref) < 0);
|
|
21306
|
+
let leftMetas = currentPresence.metas.filter((m) => newRefs.indexOf(m.phx_ref) < 0);
|
|
21357
21307
|
if (joinedMetas.length > 0) {
|
|
21358
21308
|
joins[key] = newPresence;
|
|
21359
21309
|
joins[key].metas = joinedMetas;
|
|
21360
21310
|
}
|
|
21361
|
-
|
|
21362
21311
|
if (leftMetas.length > 0) {
|
|
21363
21312
|
leaves[key] = this.clone(currentPresence);
|
|
21364
21313
|
leaves[key].metas = leftMetas;
|
|
@@ -21367,89 +21316,67 @@ var Presence = class {
|
|
|
21367
21316
|
joins[key] = newPresence;
|
|
21368
21317
|
}
|
|
21369
21318
|
});
|
|
21370
|
-
return this.syncDiff(state, {
|
|
21371
|
-
joins,
|
|
21372
|
-
leaves
|
|
21373
|
-
}, onJoin, onLeave);
|
|
21319
|
+
return this.syncDiff(state, { joins, leaves }, onJoin, onLeave);
|
|
21374
21320
|
}
|
|
21375
|
-
|
|
21376
21321
|
static syncDiff(state, diff, onJoin, onLeave) {
|
|
21377
|
-
let {
|
|
21378
|
-
joins,
|
|
21379
|
-
leaves
|
|
21380
|
-
} = this.clone(diff);
|
|
21381
|
-
|
|
21322
|
+
let { joins, leaves } = this.clone(diff);
|
|
21382
21323
|
if (!onJoin) {
|
|
21383
|
-
onJoin = function
|
|
21324
|
+
onJoin = function() {
|
|
21325
|
+
};
|
|
21384
21326
|
}
|
|
21385
|
-
|
|
21386
21327
|
if (!onLeave) {
|
|
21387
|
-
onLeave = function
|
|
21328
|
+
onLeave = function() {
|
|
21329
|
+
};
|
|
21388
21330
|
}
|
|
21389
|
-
|
|
21390
21331
|
this.map(joins, (key, newPresence) => {
|
|
21391
21332
|
let currentPresence = state[key];
|
|
21392
21333
|
state[key] = this.clone(newPresence);
|
|
21393
|
-
|
|
21394
21334
|
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);
|
|
21335
|
+
let joinedRefs = state[key].metas.map((m) => m.phx_ref);
|
|
21336
|
+
let curMetas = currentPresence.metas.filter((m) => joinedRefs.indexOf(m.phx_ref) < 0);
|
|
21397
21337
|
state[key].metas.unshift(...curMetas);
|
|
21398
21338
|
}
|
|
21399
|
-
|
|
21400
21339
|
onJoin(key, currentPresence, newPresence);
|
|
21401
21340
|
});
|
|
21402
21341
|
this.map(leaves, (key, leftPresence) => {
|
|
21403
21342
|
let currentPresence = state[key];
|
|
21404
|
-
|
|
21405
21343
|
if (!currentPresence) {
|
|
21406
21344
|
return;
|
|
21407
21345
|
}
|
|
21408
|
-
|
|
21409
|
-
|
|
21410
|
-
currentPresence.metas = currentPresence.metas.filter(p => {
|
|
21346
|
+
let refsToRemove = leftPresence.metas.map((m) => m.phx_ref);
|
|
21347
|
+
currentPresence.metas = currentPresence.metas.filter((p) => {
|
|
21411
21348
|
return refsToRemove.indexOf(p.phx_ref) < 0;
|
|
21412
21349
|
});
|
|
21413
21350
|
onLeave(key, currentPresence, leftPresence);
|
|
21414
|
-
|
|
21415
21351
|
if (currentPresence.metas.length === 0) {
|
|
21416
21352
|
delete state[key];
|
|
21417
21353
|
}
|
|
21418
21354
|
});
|
|
21419
21355
|
return state;
|
|
21420
21356
|
}
|
|
21421
|
-
|
|
21422
21357
|
static list(presences, chooser) {
|
|
21423
21358
|
if (!chooser) {
|
|
21424
|
-
chooser = function
|
|
21359
|
+
chooser = function(key, pres) {
|
|
21425
21360
|
return pres;
|
|
21426
21361
|
};
|
|
21427
21362
|
}
|
|
21428
|
-
|
|
21429
21363
|
return this.map(presences, (key, presence) => {
|
|
21430
21364
|
return chooser(key, presence);
|
|
21431
21365
|
});
|
|
21432
21366
|
}
|
|
21433
|
-
|
|
21434
21367
|
static map(obj, func) {
|
|
21435
|
-
return Object.getOwnPropertyNames(obj).map(key => func(key, obj[key]));
|
|
21368
|
+
return Object.getOwnPropertyNames(obj).map((key) => func(key, obj[key]));
|
|
21436
21369
|
}
|
|
21437
|
-
|
|
21438
21370
|
static clone(obj) {
|
|
21439
21371
|
return JSON.parse(JSON.stringify(obj));
|
|
21440
21372
|
}
|
|
21373
|
+
};
|
|
21441
21374
|
|
|
21442
|
-
|
|
21443
|
-
|
|
21375
|
+
// js/phoenix/serializer.js
|
|
21444
21376
|
var serializer_default = {
|
|
21445
21377
|
HEADER_LENGTH: 1,
|
|
21446
21378
|
META_LENGTH: 4,
|
|
21447
|
-
KINDS: {
|
|
21448
|
-
push: 0,
|
|
21449
|
-
reply: 1,
|
|
21450
|
-
broadcast: 2
|
|
21451
|
-
},
|
|
21452
|
-
|
|
21379
|
+
KINDS: { push: 0, reply: 1, broadcast: 2 },
|
|
21453
21380
|
encode(msg, callback) {
|
|
21454
21381
|
if (msg.payload.constructor === ArrayBuffer) {
|
|
21455
21382
|
return callback(this.binaryEncode(msg));
|
|
@@ -21458,30 +21385,16 @@ var serializer_default = {
|
|
|
21458
21385
|
return callback(JSON.stringify(payload));
|
|
21459
21386
|
}
|
|
21460
21387
|
},
|
|
21461
|
-
|
|
21462
21388
|
decode(rawPayload, callback) {
|
|
21463
21389
|
if (rawPayload.constructor === ArrayBuffer) {
|
|
21464
21390
|
return callback(this.binaryDecode(rawPayload));
|
|
21465
21391
|
} else {
|
|
21466
21392
|
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
|
-
});
|
|
21393
|
+
return callback({ join_ref, ref, topic, event, payload });
|
|
21474
21394
|
}
|
|
21475
21395
|
},
|
|
21476
|
-
|
|
21477
21396
|
binaryEncode(message) {
|
|
21478
|
-
let {
|
|
21479
|
-
join_ref,
|
|
21480
|
-
ref,
|
|
21481
|
-
event,
|
|
21482
|
-
topic,
|
|
21483
|
-
payload
|
|
21484
|
-
} = message;
|
|
21397
|
+
let { join_ref, ref, event, topic, payload } = message;
|
|
21485
21398
|
let metaLength = this.META_LENGTH + join_ref.length + ref.length + topic.length + event.length;
|
|
21486
21399
|
let header = new ArrayBuffer(this.HEADER_LENGTH + metaLength);
|
|
21487
21400
|
let view = new DataView(header);
|
|
@@ -21491,33 +21404,28 @@ var serializer_default = {
|
|
|
21491
21404
|
view.setUint8(offset++, ref.length);
|
|
21492
21405
|
view.setUint8(offset++, topic.length);
|
|
21493
21406
|
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)));
|
|
21407
|
+
Array.from(join_ref, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
21408
|
+
Array.from(ref, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
21409
|
+
Array.from(topic, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
21410
|
+
Array.from(event, (char) => view.setUint8(offset++, char.charCodeAt(0)));
|
|
21498
21411
|
var combined = new Uint8Array(header.byteLength + payload.byteLength);
|
|
21499
21412
|
combined.set(new Uint8Array(header), 0);
|
|
21500
21413
|
combined.set(new Uint8Array(payload), header.byteLength);
|
|
21501
21414
|
return combined.buffer;
|
|
21502
21415
|
},
|
|
21503
|
-
|
|
21504
21416
|
binaryDecode(buffer) {
|
|
21505
21417
|
let view = new DataView(buffer);
|
|
21506
21418
|
let kind = view.getUint8(0);
|
|
21507
21419
|
let decoder = new TextDecoder();
|
|
21508
|
-
|
|
21509
21420
|
switch (kind) {
|
|
21510
21421
|
case this.KINDS.push:
|
|
21511
21422
|
return this.decodePush(buffer, view, decoder);
|
|
21512
|
-
|
|
21513
21423
|
case this.KINDS.reply:
|
|
21514
21424
|
return this.decodeReply(buffer, view, decoder);
|
|
21515
|
-
|
|
21516
21425
|
case this.KINDS.broadcast:
|
|
21517
21426
|
return this.decodeBroadcast(buffer, view, decoder);
|
|
21518
21427
|
}
|
|
21519
21428
|
},
|
|
21520
|
-
|
|
21521
21429
|
decodePush(buffer, view, decoder) {
|
|
21522
21430
|
let joinRefSize = view.getUint8(1);
|
|
21523
21431
|
let topicSize = view.getUint8(2);
|
|
@@ -21530,15 +21438,8 @@ var serializer_default = {
|
|
|
21530
21438
|
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
21531
21439
|
offset = offset + eventSize;
|
|
21532
21440
|
let data = buffer.slice(offset, buffer.byteLength);
|
|
21533
|
-
return {
|
|
21534
|
-
join_ref: joinRef,
|
|
21535
|
-
ref: null,
|
|
21536
|
-
topic,
|
|
21537
|
-
event,
|
|
21538
|
-
payload: data
|
|
21539
|
-
};
|
|
21441
|
+
return { join_ref: joinRef, ref: null, topic, event, payload: data };
|
|
21540
21442
|
},
|
|
21541
|
-
|
|
21542
21443
|
decodeReply(buffer, view, decoder) {
|
|
21543
21444
|
let joinRefSize = view.getUint8(1);
|
|
21544
21445
|
let refSize = view.getUint8(2);
|
|
@@ -21554,19 +21455,9 @@ var serializer_default = {
|
|
|
21554
21455
|
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
21555
21456
|
offset = offset + eventSize;
|
|
21556
21457
|
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
|
-
};
|
|
21458
|
+
let payload = { status: event, response: data };
|
|
21459
|
+
return { join_ref: joinRef, ref, topic, event: CHANNEL_EVENTS.reply, payload };
|
|
21568
21460
|
},
|
|
21569
|
-
|
|
21570
21461
|
decodeBroadcast(buffer, view, decoder) {
|
|
21571
21462
|
let topicSize = view.getUint8(1);
|
|
21572
21463
|
let eventSize = view.getUint8(2);
|
|
@@ -21576,25 +21467,14 @@ var serializer_default = {
|
|
|
21576
21467
|
let event = decoder.decode(buffer.slice(offset, offset + eventSize));
|
|
21577
21468
|
offset = offset + eventSize;
|
|
21578
21469
|
let data = buffer.slice(offset, buffer.byteLength);
|
|
21579
|
-
return {
|
|
21580
|
-
join_ref: null,
|
|
21581
|
-
ref: null,
|
|
21582
|
-
topic,
|
|
21583
|
-
event,
|
|
21584
|
-
payload: data
|
|
21585
|
-
};
|
|
21470
|
+
return { join_ref: null, ref: null, topic, event, payload: data };
|
|
21586
21471
|
}
|
|
21472
|
+
};
|
|
21587
21473
|
|
|
21588
|
-
|
|
21589
|
-
|
|
21474
|
+
// js/phoenix/socket.js
|
|
21590
21475
|
var Socket = class {
|
|
21591
21476
|
constructor(endPoint, opts = {}) {
|
|
21592
|
-
this.stateChangeCallbacks = {
|
|
21593
|
-
open: [],
|
|
21594
|
-
close: [],
|
|
21595
|
-
error: [],
|
|
21596
|
-
message: []
|
|
21597
|
-
};
|
|
21477
|
+
this.stateChangeCallbacks = { open: [], close: [], error: [], message: [] };
|
|
21598
21478
|
this.channels = [];
|
|
21599
21479
|
this.sendBuffer = [];
|
|
21600
21480
|
this.ref = 0;
|
|
@@ -21606,7 +21486,6 @@ var Socket = class {
|
|
|
21606
21486
|
this.closeWasClean = false;
|
|
21607
21487
|
this.binaryType = opts.binaryType || "arraybuffer";
|
|
21608
21488
|
this.connectClock = 1;
|
|
21609
|
-
|
|
21610
21489
|
if (this.transport !== LongPoll) {
|
|
21611
21490
|
this.encode = opts.encode || this.defaultEncoder;
|
|
21612
21491
|
this.decode = opts.decode || this.defaultDecoder;
|
|
@@ -21614,42 +21493,36 @@ var Socket = class {
|
|
|
21614
21493
|
this.encode = this.defaultEncoder;
|
|
21615
21494
|
this.decode = this.defaultDecoder;
|
|
21616
21495
|
}
|
|
21617
|
-
|
|
21618
21496
|
let awaitingConnectionOnPageShow = null;
|
|
21619
|
-
|
|
21620
21497
|
if (phxWindow && phxWindow.addEventListener) {
|
|
21621
|
-
phxWindow.addEventListener("pagehide", _e => {
|
|
21498
|
+
phxWindow.addEventListener("pagehide", (_e) => {
|
|
21622
21499
|
if (this.conn) {
|
|
21623
21500
|
this.disconnect();
|
|
21624
21501
|
awaitingConnectionOnPageShow = this.connectClock;
|
|
21625
21502
|
}
|
|
21626
21503
|
});
|
|
21627
|
-
phxWindow.addEventListener("pageshow", _e => {
|
|
21504
|
+
phxWindow.addEventListener("pageshow", (_e) => {
|
|
21628
21505
|
if (awaitingConnectionOnPageShow === this.connectClock) {
|
|
21629
21506
|
awaitingConnectionOnPageShow = null;
|
|
21630
21507
|
this.connect();
|
|
21631
21508
|
}
|
|
21632
21509
|
});
|
|
21633
21510
|
}
|
|
21634
|
-
|
|
21635
21511
|
this.heartbeatIntervalMs = opts.heartbeatIntervalMs || 3e4;
|
|
21636
|
-
|
|
21637
|
-
this.rejoinAfterMs = tries => {
|
|
21512
|
+
this.rejoinAfterMs = (tries) => {
|
|
21638
21513
|
if (opts.rejoinAfterMs) {
|
|
21639
21514
|
return opts.rejoinAfterMs(tries);
|
|
21640
21515
|
} else {
|
|
21641
21516
|
return [1e3, 2e3, 5e3][tries - 1] || 1e4;
|
|
21642
21517
|
}
|
|
21643
21518
|
};
|
|
21644
|
-
|
|
21645
|
-
this.reconnectAfterMs = tries => {
|
|
21519
|
+
this.reconnectAfterMs = (tries) => {
|
|
21646
21520
|
if (opts.reconnectAfterMs) {
|
|
21647
21521
|
return opts.reconnectAfterMs(tries);
|
|
21648
21522
|
} else {
|
|
21649
21523
|
return [10, 50, 100, 150, 200, 250, 500, 1e3, 2e3][tries - 1] || 5e3;
|
|
21650
21524
|
}
|
|
21651
21525
|
};
|
|
21652
|
-
|
|
21653
21526
|
this.logger = opts.logger || null;
|
|
21654
21527
|
this.longpollerTimeout = opts.longpollerTimeout || 2e4;
|
|
21655
21528
|
this.params = closure(opts.params || {});
|
|
@@ -21661,99 +21534,101 @@ var Socket = class {
|
|
|
21661
21534
|
this.teardown(() => this.connect());
|
|
21662
21535
|
}, this.reconnectAfterMs);
|
|
21663
21536
|
}
|
|
21664
|
-
|
|
21537
|
+
getLongPollTransport() {
|
|
21538
|
+
return LongPoll;
|
|
21539
|
+
}
|
|
21665
21540
|
replaceTransport(newTransport) {
|
|
21666
|
-
this.
|
|
21541
|
+
this.connectClock++;
|
|
21542
|
+
this.closeWasClean = true;
|
|
21543
|
+
this.reconnectTimer.reset();
|
|
21544
|
+
this.sendBuffer = [];
|
|
21545
|
+
if (this.conn) {
|
|
21546
|
+
this.conn.close();
|
|
21547
|
+
this.conn = null;
|
|
21548
|
+
}
|
|
21667
21549
|
this.transport = newTransport;
|
|
21668
21550
|
}
|
|
21669
|
-
|
|
21670
21551
|
protocol() {
|
|
21671
21552
|
return location.protocol.match(/^https/) ? "wss" : "ws";
|
|
21672
21553
|
}
|
|
21673
|
-
|
|
21674
21554
|
endPointURL() {
|
|
21675
|
-
let uri = Ajax.appendParams(Ajax.appendParams(this.endPoint, this.params()), {
|
|
21676
|
-
vsn: this.vsn
|
|
21677
|
-
});
|
|
21678
|
-
|
|
21555
|
+
let uri = Ajax.appendParams(Ajax.appendParams(this.endPoint, this.params()), { vsn: this.vsn });
|
|
21679
21556
|
if (uri.charAt(0) !== "/") {
|
|
21680
21557
|
return uri;
|
|
21681
21558
|
}
|
|
21682
|
-
|
|
21683
21559
|
if (uri.charAt(1) === "/") {
|
|
21684
21560
|
return `${this.protocol()}:${uri}`;
|
|
21685
21561
|
}
|
|
21686
|
-
|
|
21687
21562
|
return `${this.protocol()}://${location.host}${uri}`;
|
|
21688
21563
|
}
|
|
21689
|
-
|
|
21690
21564
|
disconnect(callback, code, reason) {
|
|
21691
21565
|
this.connectClock++;
|
|
21692
21566
|
this.closeWasClean = true;
|
|
21693
21567
|
this.reconnectTimer.reset();
|
|
21694
21568
|
this.teardown(callback, code, reason);
|
|
21695
21569
|
}
|
|
21696
|
-
|
|
21697
21570
|
connect(params) {
|
|
21698
|
-
this.connectClock++;
|
|
21699
|
-
|
|
21700
21571
|
if (params) {
|
|
21701
21572
|
console && console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor");
|
|
21702
21573
|
this.params = closure(params);
|
|
21703
21574
|
}
|
|
21704
|
-
|
|
21705
21575
|
if (this.conn) {
|
|
21706
21576
|
return;
|
|
21707
21577
|
}
|
|
21708
|
-
|
|
21578
|
+
this.connectClock++;
|
|
21709
21579
|
this.closeWasClean = false;
|
|
21710
21580
|
this.conn = new this.transport(this.endPointURL());
|
|
21711
21581
|
this.conn.binaryType = this.binaryType;
|
|
21712
21582
|
this.conn.timeout = this.longpollerTimeout;
|
|
21713
|
-
|
|
21714
21583
|
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);
|
|
21584
|
+
this.conn.onerror = (error) => this.onConnError(error);
|
|
21585
|
+
this.conn.onmessage = (event) => this.onConnMessage(event);
|
|
21586
|
+
this.conn.onclose = (event) => this.onConnClose(event);
|
|
21721
21587
|
}
|
|
21722
|
-
|
|
21723
21588
|
log(kind, msg, data) {
|
|
21724
21589
|
this.logger(kind, msg, data);
|
|
21725
21590
|
}
|
|
21726
|
-
|
|
21727
21591
|
hasLogger() {
|
|
21728
21592
|
return this.logger !== null;
|
|
21729
21593
|
}
|
|
21730
|
-
|
|
21731
21594
|
onOpen(callback) {
|
|
21732
21595
|
let ref = this.makeRef();
|
|
21733
21596
|
this.stateChangeCallbacks.open.push([ref, callback]);
|
|
21734
21597
|
return ref;
|
|
21735
21598
|
}
|
|
21736
|
-
|
|
21737
21599
|
onClose(callback) {
|
|
21738
21600
|
let ref = this.makeRef();
|
|
21739
21601
|
this.stateChangeCallbacks.close.push([ref, callback]);
|
|
21740
21602
|
return ref;
|
|
21741
21603
|
}
|
|
21742
|
-
|
|
21743
21604
|
onError(callback) {
|
|
21744
21605
|
let ref = this.makeRef();
|
|
21745
21606
|
this.stateChangeCallbacks.error.push([ref, callback]);
|
|
21746
21607
|
return ref;
|
|
21747
21608
|
}
|
|
21748
|
-
|
|
21749
21609
|
onMessage(callback) {
|
|
21750
21610
|
let ref = this.makeRef();
|
|
21751
21611
|
this.stateChangeCallbacks.message.push([ref, callback]);
|
|
21752
21612
|
return ref;
|
|
21753
21613
|
}
|
|
21754
|
-
|
|
21614
|
+
ping(callback) {
|
|
21615
|
+
if (!this.isConnected()) {
|
|
21616
|
+
return false;
|
|
21617
|
+
}
|
|
21618
|
+
let ref = this.makeRef();
|
|
21619
|
+
let startTime = Date.now();
|
|
21620
|
+
this.push({ topic: "phoenix", event: "heartbeat", payload: {}, ref });
|
|
21621
|
+
let onMsgRef = this.onMessage((msg) => {
|
|
21622
|
+
if (msg.ref === ref) {
|
|
21623
|
+
this.off([onMsgRef]);
|
|
21624
|
+
callback(Date.now() - startTime);
|
|
21625
|
+
}
|
|
21626
|
+
});
|
|
21627
|
+
return true;
|
|
21628
|
+
}
|
|
21755
21629
|
onConnOpen() {
|
|
21756
|
-
if (this.hasLogger())
|
|
21630
|
+
if (this.hasLogger())
|
|
21631
|
+
this.log("transport", `connected to ${this.endPointURL()}`);
|
|
21757
21632
|
this.closeWasClean = false;
|
|
21758
21633
|
this.establishedConnections++;
|
|
21759
21634
|
this.flushSendBuffer();
|
|
@@ -21761,34 +21636,27 @@ var Socket = class {
|
|
|
21761
21636
|
this.resetHeartbeat();
|
|
21762
21637
|
this.stateChangeCallbacks.open.forEach(([, callback]) => callback());
|
|
21763
21638
|
}
|
|
21764
|
-
|
|
21765
21639
|
heartbeatTimeout() {
|
|
21766
21640
|
if (this.pendingHeartbeatRef) {
|
|
21767
21641
|
this.pendingHeartbeatRef = null;
|
|
21768
|
-
|
|
21769
21642
|
if (this.hasLogger()) {
|
|
21770
21643
|
this.log("transport", "heartbeat timeout. Attempting to re-establish connection");
|
|
21771
21644
|
}
|
|
21772
|
-
|
|
21773
21645
|
this.abnormalClose("heartbeat timeout");
|
|
21774
21646
|
}
|
|
21775
21647
|
}
|
|
21776
|
-
|
|
21777
21648
|
resetHeartbeat() {
|
|
21778
21649
|
if (this.conn && this.conn.skipHeartbeat) {
|
|
21779
21650
|
return;
|
|
21780
21651
|
}
|
|
21781
|
-
|
|
21782
21652
|
this.pendingHeartbeatRef = null;
|
|
21783
21653
|
clearTimeout(this.heartbeatTimer);
|
|
21784
21654
|
setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
|
21785
21655
|
}
|
|
21786
|
-
|
|
21787
21656
|
teardown(callback, code, reason) {
|
|
21788
21657
|
if (!this.conn) {
|
|
21789
21658
|
return callback && callback();
|
|
21790
21659
|
}
|
|
21791
|
-
|
|
21792
21660
|
this.waitForBufferDone(() => {
|
|
21793
21661
|
if (this.conn) {
|
|
21794
21662
|
if (code) {
|
|
@@ -21797,100 +21665,83 @@ var Socket = class {
|
|
|
21797
21665
|
this.conn.close();
|
|
21798
21666
|
}
|
|
21799
21667
|
}
|
|
21800
|
-
|
|
21801
21668
|
this.waitForSocketClosed(() => {
|
|
21802
21669
|
if (this.conn) {
|
|
21803
|
-
this.conn.onclose = function
|
|
21804
|
-
|
|
21670
|
+
this.conn.onclose = function() {
|
|
21671
|
+
};
|
|
21805
21672
|
this.conn = null;
|
|
21806
21673
|
}
|
|
21807
|
-
|
|
21808
21674
|
callback && callback();
|
|
21809
21675
|
});
|
|
21810
21676
|
});
|
|
21811
21677
|
}
|
|
21812
|
-
|
|
21813
21678
|
waitForBufferDone(callback, tries = 1) {
|
|
21814
21679
|
if (tries === 5 || !this.conn || !this.conn.bufferedAmount) {
|
|
21815
21680
|
callback();
|
|
21816
21681
|
return;
|
|
21817
21682
|
}
|
|
21818
|
-
|
|
21819
21683
|
setTimeout(() => {
|
|
21820
21684
|
this.waitForBufferDone(callback, tries + 1);
|
|
21821
21685
|
}, 150 * tries);
|
|
21822
21686
|
}
|
|
21823
|
-
|
|
21824
21687
|
waitForSocketClosed(callback, tries = 1) {
|
|
21825
21688
|
if (tries === 5 || !this.conn || this.conn.readyState === SOCKET_STATES.closed) {
|
|
21826
21689
|
callback();
|
|
21827
21690
|
return;
|
|
21828
21691
|
}
|
|
21829
|
-
|
|
21830
21692
|
setTimeout(() => {
|
|
21831
21693
|
this.waitForSocketClosed(callback, tries + 1);
|
|
21832
21694
|
}, 150 * tries);
|
|
21833
21695
|
}
|
|
21834
|
-
|
|
21835
21696
|
onConnClose(event) {
|
|
21836
21697
|
let closeCode = event && event.code;
|
|
21837
|
-
if (this.hasLogger())
|
|
21698
|
+
if (this.hasLogger())
|
|
21699
|
+
this.log("transport", "close", event);
|
|
21838
21700
|
this.triggerChanError();
|
|
21839
21701
|
clearTimeout(this.heartbeatTimer);
|
|
21840
|
-
|
|
21841
21702
|
if (!this.closeWasClean && closeCode !== 1e3) {
|
|
21842
21703
|
this.reconnectTimer.scheduleTimeout();
|
|
21843
21704
|
}
|
|
21844
|
-
|
|
21845
21705
|
this.stateChangeCallbacks.close.forEach(([, callback]) => callback(event));
|
|
21846
21706
|
}
|
|
21847
|
-
|
|
21848
21707
|
onConnError(error) {
|
|
21849
|
-
if (this.hasLogger())
|
|
21708
|
+
if (this.hasLogger())
|
|
21709
|
+
this.log("transport", error);
|
|
21850
21710
|
let transportBefore = this.transport;
|
|
21851
21711
|
let establishedBefore = this.establishedConnections;
|
|
21852
21712
|
this.stateChangeCallbacks.error.forEach(([, callback]) => {
|
|
21853
21713
|
callback(error, transportBefore, establishedBefore);
|
|
21854
21714
|
});
|
|
21855
|
-
|
|
21856
21715
|
if (transportBefore === this.transport || establishedBefore > 0) {
|
|
21857
21716
|
this.triggerChanError();
|
|
21858
21717
|
}
|
|
21859
21718
|
}
|
|
21860
|
-
|
|
21861
21719
|
triggerChanError() {
|
|
21862
|
-
this.channels.forEach(channel => {
|
|
21720
|
+
this.channels.forEach((channel) => {
|
|
21863
21721
|
if (!(channel.isErrored() || channel.isLeaving() || channel.isClosed())) {
|
|
21864
21722
|
channel.trigger(CHANNEL_EVENTS.error);
|
|
21865
21723
|
}
|
|
21866
21724
|
});
|
|
21867
21725
|
}
|
|
21868
|
-
|
|
21869
21726
|
connectionState() {
|
|
21870
21727
|
switch (this.conn && this.conn.readyState) {
|
|
21871
21728
|
case SOCKET_STATES.connecting:
|
|
21872
21729
|
return "connecting";
|
|
21873
|
-
|
|
21874
21730
|
case SOCKET_STATES.open:
|
|
21875
21731
|
return "open";
|
|
21876
|
-
|
|
21877
21732
|
case SOCKET_STATES.closing:
|
|
21878
21733
|
return "closing";
|
|
21879
|
-
|
|
21880
21734
|
default:
|
|
21881
21735
|
return "closed";
|
|
21882
21736
|
}
|
|
21883
21737
|
}
|
|
21884
|
-
|
|
21885
21738
|
isConnected() {
|
|
21886
21739
|
return this.connectionState() === "open";
|
|
21887
21740
|
}
|
|
21888
|
-
|
|
21889
21741
|
remove(channel) {
|
|
21890
21742
|
this.off(channel.stateChangeRefs);
|
|
21891
|
-
this.channels = this.channels.filter(c => c.joinRef() !== channel.joinRef());
|
|
21743
|
+
this.channels = this.channels.filter((c) => c.joinRef() !== channel.joinRef());
|
|
21892
21744
|
}
|
|
21893
|
-
|
|
21894
21745
|
off(refs) {
|
|
21895
21746
|
for (let key in this.stateChangeCallbacks) {
|
|
21896
21747
|
this.stateChangeCallbacks[key] = this.stateChangeCallbacks[key].filter(([ref]) => {
|
|
@@ -21898,120 +21749,86 @@ var Socket = class {
|
|
|
21898
21749
|
});
|
|
21899
21750
|
}
|
|
21900
21751
|
}
|
|
21901
|
-
|
|
21902
21752
|
channel(topic, chanParams = {}) {
|
|
21903
21753
|
let chan = new Channel(topic, chanParams, this);
|
|
21904
21754
|
this.channels.push(chan);
|
|
21905
21755
|
return chan;
|
|
21906
21756
|
}
|
|
21907
|
-
|
|
21908
21757
|
push(data) {
|
|
21909
21758
|
if (this.hasLogger()) {
|
|
21910
|
-
let {
|
|
21911
|
-
topic,
|
|
21912
|
-
event,
|
|
21913
|
-
payload,
|
|
21914
|
-
ref,
|
|
21915
|
-
join_ref
|
|
21916
|
-
} = data;
|
|
21759
|
+
let { topic, event, payload, ref, join_ref } = data;
|
|
21917
21760
|
this.log("push", `${topic} ${event} (${join_ref}, ${ref})`, payload);
|
|
21918
21761
|
}
|
|
21919
|
-
|
|
21920
21762
|
if (this.isConnected()) {
|
|
21921
|
-
this.encode(data, result => this.conn.send(result));
|
|
21763
|
+
this.encode(data, (result) => this.conn.send(result));
|
|
21922
21764
|
} else {
|
|
21923
|
-
this.sendBuffer.push(() => this.encode(data, result => this.conn.send(result)));
|
|
21765
|
+
this.sendBuffer.push(() => this.encode(data, (result) => this.conn.send(result)));
|
|
21924
21766
|
}
|
|
21925
21767
|
}
|
|
21926
|
-
|
|
21927
21768
|
makeRef() {
|
|
21928
21769
|
let newRef = this.ref + 1;
|
|
21929
|
-
|
|
21930
21770
|
if (newRef === this.ref) {
|
|
21931
21771
|
this.ref = 0;
|
|
21932
21772
|
} else {
|
|
21933
21773
|
this.ref = newRef;
|
|
21934
21774
|
}
|
|
21935
|
-
|
|
21936
21775
|
return this.ref.toString();
|
|
21937
21776
|
}
|
|
21938
|
-
|
|
21939
21777
|
sendHeartbeat() {
|
|
21940
21778
|
if (this.pendingHeartbeatRef && !this.isConnected()) {
|
|
21941
21779
|
return;
|
|
21942
21780
|
}
|
|
21943
|
-
|
|
21944
21781
|
this.pendingHeartbeatRef = this.makeRef();
|
|
21945
|
-
this.push({
|
|
21946
|
-
topic: "phoenix",
|
|
21947
|
-
event: "heartbeat",
|
|
21948
|
-
payload: {},
|
|
21949
|
-
ref: this.pendingHeartbeatRef
|
|
21950
|
-
});
|
|
21782
|
+
this.push({ topic: "phoenix", event: "heartbeat", payload: {}, ref: this.pendingHeartbeatRef });
|
|
21951
21783
|
this.heartbeatTimer = setTimeout(() => this.heartbeatTimeout(), this.heartbeatIntervalMs);
|
|
21952
21784
|
}
|
|
21953
|
-
|
|
21954
21785
|
abnormalClose(reason) {
|
|
21955
21786
|
this.closeWasClean = false;
|
|
21956
|
-
|
|
21957
21787
|
if (this.isConnected()) {
|
|
21958
21788
|
this.conn.close(WS_CLOSE_NORMAL, reason);
|
|
21959
21789
|
}
|
|
21960
21790
|
}
|
|
21961
|
-
|
|
21962
21791
|
flushSendBuffer() {
|
|
21963
21792
|
if (this.isConnected() && this.sendBuffer.length > 0) {
|
|
21964
|
-
this.sendBuffer.forEach(callback => callback());
|
|
21793
|
+
this.sendBuffer.forEach((callback) => callback());
|
|
21965
21794
|
this.sendBuffer = [];
|
|
21966
21795
|
}
|
|
21967
21796
|
}
|
|
21968
|
-
|
|
21969
21797
|
onConnMessage(rawMessage) {
|
|
21970
|
-
this.decode(rawMessage.data, msg => {
|
|
21971
|
-
let {
|
|
21972
|
-
topic,
|
|
21973
|
-
event,
|
|
21974
|
-
payload,
|
|
21975
|
-
ref,
|
|
21976
|
-
join_ref
|
|
21977
|
-
} = msg;
|
|
21978
|
-
|
|
21798
|
+
this.decode(rawMessage.data, (msg) => {
|
|
21799
|
+
let { topic, event, payload, ref, join_ref } = msg;
|
|
21979
21800
|
if (ref && ref === this.pendingHeartbeatRef) {
|
|
21980
21801
|
clearTimeout(this.heartbeatTimer);
|
|
21981
21802
|
this.pendingHeartbeatRef = null;
|
|
21982
21803
|
setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
|
21983
21804
|
}
|
|
21984
|
-
|
|
21985
|
-
|
|
21986
|
-
|
|
21805
|
+
if (this.hasLogger())
|
|
21806
|
+
this.log("receive", `${payload.status || ""} ${topic} ${event} ${ref && "(" + ref + ")" || ""}`, payload);
|
|
21987
21807
|
for (let i = 0; i < this.channels.length; i++) {
|
|
21988
21808
|
const channel = this.channels[i];
|
|
21989
|
-
|
|
21990
21809
|
if (!channel.isMember(topic, event, payload, join_ref)) {
|
|
21991
21810
|
continue;
|
|
21992
21811
|
}
|
|
21993
|
-
|
|
21994
21812
|
channel.trigger(event, payload, ref, join_ref);
|
|
21995
21813
|
}
|
|
21996
|
-
|
|
21997
21814
|
for (let i = 0; i < this.stateChangeCallbacks.message.length; i++) {
|
|
21998
21815
|
let [, callback] = this.stateChangeCallbacks.message[i];
|
|
21999
21816
|
callback(msg);
|
|
22000
21817
|
}
|
|
22001
21818
|
});
|
|
22002
21819
|
}
|
|
22003
|
-
|
|
22004
21820
|
leaveOpenTopic(topic) {
|
|
22005
|
-
let dupChannel = this.channels.find(c => c.topic === topic && (c.isJoined() || c.isJoining()));
|
|
22006
|
-
|
|
21821
|
+
let dupChannel = this.channels.find((c) => c.topic === topic && (c.isJoined() || c.isJoining()));
|
|
22007
21822
|
if (dupChannel) {
|
|
22008
|
-
if (this.hasLogger())
|
|
21823
|
+
if (this.hasLogger())
|
|
21824
|
+
this.log("transport", `leaving duplicate topic "${topic}"`);
|
|
22009
21825
|
dupChannel.leave();
|
|
22010
21826
|
}
|
|
22011
21827
|
}
|
|
22012
|
-
|
|
22013
21828
|
};
|
|
22014
21829
|
|
|
21830
|
+
//# sourceMappingURL=phoenix.mjs.map
|
|
21831
|
+
|
|
22015
21832
|
;// CONCATENATED MODULE: ./src/javascripts/lib/split-url-params.js
|
|
22016
21833
|
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
21834
|
|
|
@@ -22442,6 +22259,8 @@ class API {
|
|
|
22442
22259
|
|
|
22443
22260
|
async createConversation() {
|
|
22444
22261
|
try {
|
|
22262
|
+
var _conversation$transla;
|
|
22263
|
+
|
|
22445
22264
|
const request = client_default().post(`${this.getUrlPrefix('http')}${this.URLS.conversations}`).set('Content-Type', 'application/json').query({
|
|
22446
22265
|
v: apiVersion
|
|
22447
22266
|
}) // withCredentials() is necessary to allow browsers to save received
|
|
@@ -22464,7 +22283,7 @@ class API {
|
|
|
22464
22283
|
this.setChannelTopic(conversation.channelTopic);
|
|
22465
22284
|
this.updateUrls(body);
|
|
22466
22285
|
this.setConversationUrl(this.URLS.conversation);
|
|
22467
|
-
this.locale = conversation.translation
|
|
22286
|
+
this.locale = (_conversation$transla = conversation.translation) === null || _conversation$transla === void 0 ? void 0 : _conversation$transla.locale;
|
|
22468
22287
|
this.userResponded = conversation.userResponded;
|
|
22469
22288
|
return initialState;
|
|
22470
22289
|
} catch (error) {
|
|
@@ -22699,7 +22518,7 @@ class API {
|
|
|
22699
22518
|
return {
|
|
22700
22519
|
clientName: "@seamly/web-ui",
|
|
22701
22520
|
clientVariant: this.layoutMode,
|
|
22702
|
-
clientVersion: "20.
|
|
22521
|
+
clientVersion: "20.6.0",
|
|
22703
22522
|
currentUrl: window.location.toString(),
|
|
22704
22523
|
screenResolution: `${window.screen.width}x${window.screen.height}`,
|
|
22705
22524
|
timezone: getTimeZone(),
|
|
@@ -22708,6 +22527,37 @@ class API {
|
|
|
22708
22527
|
}
|
|
22709
22528
|
|
|
22710
22529
|
}
|
|
22530
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/options/middleware.js
|
|
22531
|
+
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; }
|
|
22532
|
+
|
|
22533
|
+
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; }
|
|
22534
|
+
|
|
22535
|
+
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; }
|
|
22536
|
+
|
|
22537
|
+
|
|
22538
|
+
function options_middleware_createMiddleware({
|
|
22539
|
+
api
|
|
22540
|
+
}) {
|
|
22541
|
+
return () => next => action => {
|
|
22542
|
+
const result = next(action);
|
|
22543
|
+
|
|
22544
|
+
switch (action.type) {
|
|
22545
|
+
case seamlyActions.SET_USER_SELECTED_OPTIONS:
|
|
22546
|
+
api.store.set('options', action.options);
|
|
22547
|
+
break;
|
|
22548
|
+
|
|
22549
|
+
case seamlyActions.SET_USER_SELECTED_OPTION:
|
|
22550
|
+
api.store.set('options', middleware_objectSpread(middleware_objectSpread({}, api.store.get('options') || {}), {}, {
|
|
22551
|
+
[action.option]: action.value
|
|
22552
|
+
}));
|
|
22553
|
+
break;
|
|
22554
|
+
}
|
|
22555
|
+
|
|
22556
|
+
return result;
|
|
22557
|
+
};
|
|
22558
|
+
}
|
|
22559
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/options/index.js
|
|
22560
|
+
|
|
22711
22561
|
;// CONCATENATED MODULE: ./node_modules/redux-thunk/es/index.js
|
|
22712
22562
|
/** A function that accepts a potential "extra argument" value to be injected later,
|
|
22713
22563
|
* and returns an instance of the thunk middleware that uses that value
|
|
@@ -22741,37 +22591,6 @@ var thunk = createThunkMiddleware(); // Attach the factory function so users can
|
|
|
22741
22591
|
|
|
22742
22592
|
thunk.withExtraArgument = createThunkMiddleware;
|
|
22743
22593
|
/* 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
22594
|
;// CONCATENATED MODULE: ./src/javascripts/domains/store/state-reducer.js
|
|
22776
22595
|
// Legacy state reducer. Do not add new features here but extract/create new reducers as needed
|
|
22777
22596
|
|
|
@@ -22870,7 +22689,7 @@ function store_createStore({
|
|
|
22870
22689
|
api
|
|
22871
22690
|
}), options_middleware_createMiddleware({
|
|
22872
22691
|
api
|
|
22873
|
-
}), middleware_createMiddleware
|
|
22692
|
+
}), middleware_createMiddleware]
|
|
22874
22693
|
});
|
|
22875
22694
|
return store;
|
|
22876
22695
|
}
|
|
@@ -23208,7 +23027,9 @@ class ExternalApi {
|
|
|
23208
23027
|
}
|
|
23209
23028
|
|
|
23210
23029
|
getMergedVariables(userConfig) {
|
|
23211
|
-
|
|
23030
|
+
var _this$appConfig$conte, _userConfig$context;
|
|
23031
|
+
|
|
23032
|
+
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
23033
|
}
|
|
23213
23034
|
|
|
23214
23035
|
}
|
|
@@ -23256,7 +23077,7 @@ const AgentInfo = () => {
|
|
|
23256
23077
|
hasInterrupt
|
|
23257
23078
|
} = useInterrupt();
|
|
23258
23079
|
const startChatIcon = useStartChatIcon();
|
|
23259
|
-
const src = currentAgent
|
|
23080
|
+
const src = (currentAgent === null || currentAgent === void 0 ? void 0 : currentAgent.avatar) ?? startChatIcon;
|
|
23260
23081
|
const displaySubtitle = hasInterrupt ? '' : subTitle;
|
|
23261
23082
|
const classNames = ['message-count'];
|
|
23262
23083
|
|
|
@@ -23273,7 +23094,7 @@ const AgentInfo = () => {
|
|
|
23273
23094
|
children: [(0,jsx_runtime_namespaceObject.jsxs)("div", {
|
|
23274
23095
|
className: css_className('agent-info__graphic'),
|
|
23275
23096
|
children: [src ? (0,jsx_runtime_namespaceObject.jsx)("img", {
|
|
23276
|
-
className: css_className(currentAgent
|
|
23097
|
+
className: css_className(currentAgent !== null && currentAgent !== void 0 && currentAgent.avatar ? 'avatar' : 'icon'),
|
|
23277
23098
|
src: src,
|
|
23278
23099
|
alt: ""
|
|
23279
23100
|
}) : (0,jsx_runtime_namespaceObject.jsx)(icon, {
|