algolia-experiences 1.8.23 → 1.8.25
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! algolia-experiences 1.8.
|
|
1
|
+
/*! algolia-experiences 1.8.25 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
|
|
2
2
|
(function (factory) {
|
|
3
3
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
4
|
factory();
|
|
@@ -1118,6 +1118,43 @@
|
|
|
1118
1118
|
return target;
|
|
1119
1119
|
}
|
|
1120
1120
|
|
|
1121
|
+
function _array_with_holes(arr) {
|
|
1122
|
+
if (Array.isArray(arr)) return arr;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
function _iterable_to_array_limit(arr, i) {
|
|
1126
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1127
|
+
|
|
1128
|
+
if (_i == null) return;
|
|
1129
|
+
|
|
1130
|
+
var _arr = [];
|
|
1131
|
+
var _n = true;
|
|
1132
|
+
var _d = false;
|
|
1133
|
+
var _s, _e;
|
|
1134
|
+
|
|
1135
|
+
try {
|
|
1136
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
1137
|
+
_arr.push(_s.value);
|
|
1138
|
+
if (i && _arr.length === i) break;
|
|
1139
|
+
}
|
|
1140
|
+
} catch (err) {
|
|
1141
|
+
_d = true;
|
|
1142
|
+
_e = err;
|
|
1143
|
+
} finally {
|
|
1144
|
+
try {
|
|
1145
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
1146
|
+
} finally {
|
|
1147
|
+
if (_d) throw _e;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
return _arr;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
function _non_iterable_rest() {
|
|
1155
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1121
1158
|
function _array_like_to_array(arr, len) {
|
|
1122
1159
|
if (len == null || len > arr.length) len = arr.length;
|
|
1123
1160
|
|
|
@@ -1126,6 +1163,21 @@
|
|
|
1126
1163
|
return arr2;
|
|
1127
1164
|
}
|
|
1128
1165
|
|
|
1166
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
1167
|
+
if (!o) return;
|
|
1168
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
1169
|
+
|
|
1170
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1171
|
+
|
|
1172
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1173
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1174
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
function _sliced_to_array(arr, i) {
|
|
1178
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1129
1181
|
function _array_without_holes(arr) {
|
|
1130
1182
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1131
1183
|
}
|
|
@@ -1140,17 +1192,6 @@
|
|
|
1140
1192
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1141
1193
|
}
|
|
1142
1194
|
|
|
1143
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
1144
|
-
if (!o) return;
|
|
1145
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
1146
|
-
|
|
1147
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1148
|
-
|
|
1149
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1150
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1151
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
1195
|
function _to_consumable_array(arr) {
|
|
1155
1196
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
1156
1197
|
}
|
|
@@ -6832,47 +6873,6 @@
|
|
|
6832
6873
|
return target;
|
|
6833
6874
|
}
|
|
6834
6875
|
|
|
6835
|
-
function _array_with_holes(arr) {
|
|
6836
|
-
if (Array.isArray(arr)) return arr;
|
|
6837
|
-
}
|
|
6838
|
-
|
|
6839
|
-
function _iterable_to_array_limit(arr, i) {
|
|
6840
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
6841
|
-
|
|
6842
|
-
if (_i == null) return;
|
|
6843
|
-
|
|
6844
|
-
var _arr = [];
|
|
6845
|
-
var _n = true;
|
|
6846
|
-
var _d = false;
|
|
6847
|
-
var _s, _e;
|
|
6848
|
-
|
|
6849
|
-
try {
|
|
6850
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
6851
|
-
_arr.push(_s.value);
|
|
6852
|
-
if (i && _arr.length === i) break;
|
|
6853
|
-
}
|
|
6854
|
-
} catch (err) {
|
|
6855
|
-
_d = true;
|
|
6856
|
-
_e = err;
|
|
6857
|
-
} finally {
|
|
6858
|
-
try {
|
|
6859
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
6860
|
-
} finally {
|
|
6861
|
-
if (_d) throw _e;
|
|
6862
|
-
}
|
|
6863
|
-
}
|
|
6864
|
-
|
|
6865
|
-
return _arr;
|
|
6866
|
-
}
|
|
6867
|
-
|
|
6868
|
-
function _non_iterable_rest() {
|
|
6869
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
6870
|
-
}
|
|
6871
|
-
|
|
6872
|
-
function _sliced_to_array(arr, i) {
|
|
6873
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
6874
|
-
}
|
|
6875
|
-
|
|
6876
6876
|
/**
|
|
6877
6877
|
* Create UUID according to
|
|
6878
6878
|
* https://www.ietf.org/rfc/rfc4122.txt.
|
|
@@ -6886,7 +6886,7 @@
|
|
|
6886
6886
|
});
|
|
6887
6887
|
}
|
|
6888
6888
|
|
|
6889
|
-
var version = '4.
|
|
6889
|
+
var version = '4.115.0';
|
|
6890
6890
|
|
|
6891
6891
|
var ANONYMOUS_TOKEN_COOKIE_KEY = '_ALGOLIA';
|
|
6892
6892
|
function getCookie(name) {
|
|
@@ -8996,23 +8996,33 @@
|
|
|
8996
8996
|
}
|
|
8997
8997
|
|
|
8998
8998
|
var nextMicroTask = Promise.resolve();
|
|
8999
|
-
function defer(callback
|
|
8999
|
+
function defer(callback, // arguments: the first caller of the window decides what the single run
|
|
9000
|
+
// receives. Pass this to fold every later argument into the pending ones
|
|
9001
|
+
// instead.
|
|
9002
|
+
mergeArguments) {
|
|
9000
9003
|
var progress = null;
|
|
9001
9004
|
var cancelled = false;
|
|
9005
|
+
var pendingArgs = null;
|
|
9002
9006
|
var fn = function fn() {
|
|
9003
9007
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
9004
9008
|
args[_key] = arguments[_key];
|
|
9005
9009
|
}
|
|
9006
9010
|
if (progress !== null) {
|
|
9011
|
+
if (mergeArguments && pendingArgs !== null) {
|
|
9012
|
+
pendingArgs = mergeArguments(pendingArgs, args);
|
|
9013
|
+
}
|
|
9007
9014
|
return;
|
|
9008
9015
|
}
|
|
9016
|
+
pendingArgs = args;
|
|
9009
9017
|
progress = nextMicroTask.then(function() {
|
|
9010
9018
|
progress = null;
|
|
9019
|
+
var runArgs = pendingArgs;
|
|
9020
|
+
pendingArgs = null;
|
|
9011
9021
|
if (cancelled) {
|
|
9012
9022
|
cancelled = false;
|
|
9013
9023
|
return;
|
|
9014
9024
|
}
|
|
9015
|
-
callback.apply(void 0, _to_consumable_array(
|
|
9025
|
+
callback.apply(void 0, _to_consumable_array(runArgs));
|
|
9016
9026
|
});
|
|
9017
9027
|
};
|
|
9018
9028
|
fn.wait = function() {
|
|
@@ -9381,6 +9391,11 @@
|
|
|
9381
9391
|
var helper = null;
|
|
9382
9392
|
var derivedHelper = null;
|
|
9383
9393
|
var lastValidSearchParameters = null;
|
|
9394
|
+
// The error this index has already rolled back for. Renders also happen for
|
|
9395
|
+
// reasons unrelated to a search (a chat panel opening, a recommend result,
|
|
9396
|
+
// the stalled timer), and rolling back on every one of them would discard
|
|
9397
|
+
// state written after the failed search.
|
|
9398
|
+
var restoredForError;
|
|
9384
9399
|
var recomputeLocalRequestDependencies = function recomputeLocalRequestDependencies() {
|
|
9385
9400
|
if (localInstantSearchInstance) {
|
|
9386
9401
|
recomputeInstantSearchRequestDependencies(localInstantSearchInstance);
|
|
@@ -9520,6 +9535,92 @@
|
|
|
9520
9535
|
}
|
|
9521
9536
|
return this;
|
|
9522
9537
|
},
|
|
9538
|
+
updateWidget: function updateWidget(previousWidget, nextWidget) {
|
|
9539
|
+
if (typeof previousWidget.dispose !== 'function') {
|
|
9540
|
+
throw new Error(withUsage$K('The widget definition expects a `dispose` method.'));
|
|
9541
|
+
}
|
|
9542
|
+
if (typeof nextWidget.init !== 'function' && typeof nextWidget.render !== 'function') {
|
|
9543
|
+
throw new Error(withUsage$K('The widget definition expects a `render` and/or an `init` method.'));
|
|
9544
|
+
}
|
|
9545
|
+
// The `uiState` as it is before the previous widget is detached, so that
|
|
9546
|
+
// the state it owns can be handed over to the next widget.
|
|
9547
|
+
var previousUiState = localUiState;
|
|
9548
|
+
previousWidget.parent = undefined;
|
|
9549
|
+
nextWidget.parent = this;
|
|
9550
|
+
if (!isIndexWidget(nextWidget)) {
|
|
9551
|
+
addWidgetId(nextWidget);
|
|
9552
|
+
}
|
|
9553
|
+
// The next widget takes the place of the previous one, so that the order
|
|
9554
|
+
// in which widgets contribute to the search parameters is unchanged.
|
|
9555
|
+
var nextWidgets = localWidgets.slice();
|
|
9556
|
+
var position = nextWidgets.indexOf(previousWidget);
|
|
9557
|
+
if (position === -1) {
|
|
9558
|
+
nextWidgets.push(nextWidget);
|
|
9559
|
+
} else {
|
|
9560
|
+
nextWidgets[position] = nextWidget;
|
|
9561
|
+
}
|
|
9562
|
+
localWidgets = nextWidgets;
|
|
9563
|
+
recomputeLocalRequestDependencies();
|
|
9564
|
+
if (!localInstantSearchInstance) {
|
|
9565
|
+
return this;
|
|
9566
|
+
}
|
|
9567
|
+
// We still dispose the previous widget, for its side effects. The search
|
|
9568
|
+
// state it returns is only used as a base when shared state isn't preserved
|
|
9569
|
+
// on unmount, like in `removeWidgets`.
|
|
9570
|
+
var disposedState = previousWidget.dispose({
|
|
9571
|
+
helper: helper,
|
|
9572
|
+
state: helper.state,
|
|
9573
|
+
recommendState: helper.recommendState,
|
|
9574
|
+
parent: this
|
|
9575
|
+
});
|
|
9576
|
+
var cleanedRecommendState = _instanceof(disposedState, algoliasearchHelper.RecommendParameters) ? disposedState : helper.recommendState;
|
|
9577
|
+
var cleanedSearchState = disposedState && !_instanceof(disposedState, algoliasearchHelper.RecommendParameters) ? disposedState : helper.state;
|
|
9578
|
+
var initialSearchParameters = localInstantSearchInstance.future.preserveSharedStateOnUnmount ? new algoliasearchHelper.SearchParameters({
|
|
9579
|
+
index: this.getIndexName()
|
|
9580
|
+
}) : cleanedSearchState;
|
|
9581
|
+
// We hand the previous `uiState` over to the next widgets, then read the
|
|
9582
|
+
// `uiState` back from them. Widgets only pick up the state they claim, so
|
|
9583
|
+
// this drops state that no mounted widget owns anymore (an attribute that
|
|
9584
|
+
// changed, for instance) instead of seeding it with `previousUiState`.
|
|
9585
|
+
localUiState = getLocalWidgetsUiState(localWidgets, {
|
|
9586
|
+
searchParameters: getLocalWidgetsSearchParameters(localWidgets, {
|
|
9587
|
+
uiState: previousUiState,
|
|
9588
|
+
initialSearchParameters: initialSearchParameters
|
|
9589
|
+
}),
|
|
9590
|
+
helper: helper
|
|
9591
|
+
});
|
|
9592
|
+
// The search parameters are then computed again from that narrowed
|
|
9593
|
+
// `uiState`, so that they can't hold state the `uiState` doesn't describe.
|
|
9594
|
+
var newState = getLocalWidgetsSearchParameters(localWidgets, {
|
|
9595
|
+
uiState: localUiState,
|
|
9596
|
+
initialSearchParameters: initialSearchParameters
|
|
9597
|
+
});
|
|
9598
|
+
privateHelperSetState(helper, {
|
|
9599
|
+
state: newState,
|
|
9600
|
+
recommendState: getLocalWidgetsRecommendParameters(localWidgets, {
|
|
9601
|
+
uiState: localUiState,
|
|
9602
|
+
initialRecommendParameters: cleanedRecommendState
|
|
9603
|
+
}),
|
|
9604
|
+
_uiState: localUiState
|
|
9605
|
+
});
|
|
9606
|
+
if (nextWidget.getRenderState) {
|
|
9607
|
+
var renderState = nextWidget.getRenderState(localInstantSearchInstance.renderState[this.getIndexId()] || {}, createInitArgs(localInstantSearchInstance, this, localInstantSearchInstance._initialUiState));
|
|
9608
|
+
storeRenderState({
|
|
9609
|
+
renderState: renderState,
|
|
9610
|
+
instantSearchInstance: localInstantSearchInstance,
|
|
9611
|
+
parent: this
|
|
9612
|
+
});
|
|
9613
|
+
}
|
|
9614
|
+
if (nextWidget.init) {
|
|
9615
|
+
nextWidget.init(createInitArgs(localInstantSearchInstance, this, localInstantSearchInstance._initialUiState));
|
|
9616
|
+
}
|
|
9617
|
+
if (isolated) {
|
|
9618
|
+
this.scheduleLocalSearch();
|
|
9619
|
+
} else {
|
|
9620
|
+
localInstantSearchInstance.scheduleSearch();
|
|
9621
|
+
}
|
|
9622
|
+
return this;
|
|
9623
|
+
},
|
|
9523
9624
|
removeWidgets: function removeWidgets(widgets) {
|
|
9524
9625
|
var _this = this;
|
|
9525
9626
|
if (!Array.isArray(widgets)) {
|
|
@@ -9771,7 +9872,10 @@
|
|
|
9771
9872
|
var instantSearchInstance = param.instantSearchInstance;
|
|
9772
9873
|
// we can't attach a listener to the error event of search, as the error
|
|
9773
9874
|
// then would no longer be thrown for global handlers.
|
|
9774
|
-
if (instantSearchInstance.status
|
|
9875
|
+
if (instantSearchInstance.status !== 'error') {
|
|
9876
|
+
restoredForError = undefined;
|
|
9877
|
+
} else if (instantSearchInstance.error !== restoredForError && !instantSearchInstance.mainHelper.hasPendingRequests() && lastValidSearchParameters) {
|
|
9878
|
+
restoredForError = instantSearchInstance.error;
|
|
9775
9879
|
helper.setState(lastValidSearchParameters);
|
|
9776
9880
|
}
|
|
9777
9881
|
// We only render index widgets if there are no results.
|
|
@@ -10422,6 +10526,14 @@
|
|
|
10422
10526
|
instantSearchInstance: _this
|
|
10423
10527
|
});
|
|
10424
10528
|
_this.emit('render');
|
|
10529
|
+
}, // status reset accumulates instead of letting the first caller decide: a
|
|
10530
|
+
// render scheduled for a reason unrelated to the search must not cancel the
|
|
10531
|
+
// one a search result asks for, or it would strand the status on `loading`.
|
|
10532
|
+
function(param, param1) {
|
|
10533
|
+
var _param = _sliced_to_array(param, 1), tmp = _param[0], shouldResetStatus = tmp === void 0 ? true : tmp, _param1 = _sliced_to_array(param1, 1), tmp1 = _param1[0], nextShouldResetStatus = tmp1 === void 0 ? true : tmp1;
|
|
10534
|
+
return [
|
|
10535
|
+
shouldResetStatus || nextShouldResetStatus
|
|
10536
|
+
];
|
|
10425
10537
|
})), _define_property(_this, "onInternalStateChange", defer(function() {
|
|
10426
10538
|
var nextUiState = _this.mainIndex.getWidgetUiState({});
|
|
10427
10539
|
_this.middleware.forEach(function(param) {
|