algolia-experiences 1.8.0 → 1.8.2
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.2 | © 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();
|
|
@@ -2575,6 +2575,12 @@
|
|
|
2575
2575
|
* This doesn't contain any beta/hidden features.
|
|
2576
2576
|
* @private
|
|
2577
2577
|
*/ SearchParameters.PARAMETERS = Object.keys(new SearchParameters());
|
|
2578
|
+
// Returns a finite number or null. Used to reject Infinity/-Infinity from parseFloat.
|
|
2579
|
+
function parseFiniteFloat(value) {
|
|
2580
|
+
var n = parseFloat(value);
|
|
2581
|
+
// global isFinite is safe here: n is always a number type (no string coercion risk)
|
|
2582
|
+
return isFinite(n) ? n : null;
|
|
2583
|
+
}
|
|
2578
2584
|
/**
|
|
2579
2585
|
* @private
|
|
2580
2586
|
* @param {object} partialState full or part of a state
|
|
@@ -2600,8 +2606,18 @@
|
|
|
2600
2606
|
var value = partialState[k];
|
|
2601
2607
|
if (typeof value === 'string') {
|
|
2602
2608
|
var parsedValue = parseFloat(value);
|
|
2603
|
-
|
|
2604
|
-
|
|
2609
|
+
if (isNaN(parsedValue)) {
|
|
2610
|
+
// originally an unparseable string like "all", keep NaN
|
|
2611
|
+
numbers[k] = value;
|
|
2612
|
+
} else if (!isFinite(parsedValue)) {
|
|
2613
|
+
// Infinity/-Infinity — convert to null
|
|
2614
|
+
numbers[k] = null;
|
|
2615
|
+
} else {
|
|
2616
|
+
numbers[k] = parsedValue;
|
|
2617
|
+
}
|
|
2618
|
+
} else if (typeof value === 'number' && !isFinite(value)) {
|
|
2619
|
+
// Already-numeric Infinity — convert to null
|
|
2620
|
+
numbers[k] = null;
|
|
2605
2621
|
}
|
|
2606
2622
|
});
|
|
2607
2623
|
// there's two formats of insideBoundingBox, we need to parse
|
|
@@ -2610,7 +2626,13 @@
|
|
|
2610
2626
|
numbers.insideBoundingBox = partialState.insideBoundingBox.map(function(geoRect) {
|
|
2611
2627
|
if (Array.isArray(geoRect)) {
|
|
2612
2628
|
return geoRect.map(function(value) {
|
|
2613
|
-
|
|
2629
|
+
if (typeof value === 'string') {
|
|
2630
|
+
return parseFiniteFloat(value);
|
|
2631
|
+
}
|
|
2632
|
+
if (typeof value === 'number' && !isFinite(value)) {
|
|
2633
|
+
return null;
|
|
2634
|
+
}
|
|
2635
|
+
return value;
|
|
2614
2636
|
});
|
|
2615
2637
|
}
|
|
2616
2638
|
return geoRect;
|
|
@@ -2627,12 +2649,17 @@
|
|
|
2627
2649
|
if (Array.isArray(v)) {
|
|
2628
2650
|
return v.map(function(vPrime) {
|
|
2629
2651
|
if (typeof vPrime === 'string') {
|
|
2630
|
-
return
|
|
2652
|
+
return parseFiniteFloat(vPrime);
|
|
2653
|
+
}
|
|
2654
|
+
if (typeof vPrime === 'number' && !isFinite(vPrime)) {
|
|
2655
|
+
return null;
|
|
2631
2656
|
}
|
|
2632
2657
|
return vPrime;
|
|
2633
2658
|
});
|
|
2634
2659
|
} else if (typeof v === 'string') {
|
|
2635
|
-
return
|
|
2660
|
+
return parseFiniteFloat(v);
|
|
2661
|
+
} else if (typeof v === 'number' && !isFinite(v)) {
|
|
2662
|
+
return null;
|
|
2636
2663
|
}
|
|
2637
2664
|
return v;
|
|
2638
2665
|
});
|
|
@@ -4960,7 +4987,7 @@
|
|
|
4960
4987
|
function requireVersion() {
|
|
4961
4988
|
if (hasRequiredVersion) return version$1;
|
|
4962
4989
|
hasRequiredVersion = 1;
|
|
4963
|
-
version$1 = '3.
|
|
4990
|
+
version$1 = '3.29.0';
|
|
4964
4991
|
return version$1;
|
|
4965
4992
|
}
|
|
4966
4993
|
|
|
@@ -6334,7 +6361,6 @@
|
|
|
6334
6361
|
var derivedStateQueries = requestBuilder._getCompositionQueries(derivedState);
|
|
6335
6362
|
states.push({
|
|
6336
6363
|
state: derivedState,
|
|
6337
|
-
queriesCount: derivedStateQueries.length,
|
|
6338
6364
|
helper: derivedHelper
|
|
6339
6365
|
});
|
|
6340
6366
|
derivedHelper.emit('search', {
|
|
@@ -6464,7 +6490,7 @@
|
|
|
6464
6490
|
var state = s.state;
|
|
6465
6491
|
var queriesCount = s.queriesCount;
|
|
6466
6492
|
var helper = s.helper;
|
|
6467
|
-
var specificResults = results.splice(0, queriesCount);
|
|
6493
|
+
var specificResults = queriesCount !== undefined ? results.splice(0, queriesCount) : results;
|
|
6468
6494
|
if (!state.index) {
|
|
6469
6495
|
helper.emit('result', {
|
|
6470
6496
|
results: null,
|
|
@@ -6472,8 +6498,24 @@
|
|
|
6472
6498
|
});
|
|
6473
6499
|
return;
|
|
6474
6500
|
}
|
|
6475
|
-
|
|
6476
|
-
if (
|
|
6501
|
+
// Multifeed composition: build ordered SearchResults array on lastResults
|
|
6502
|
+
if (specificResults.length > 0 && specificResults[0].feedID) {
|
|
6503
|
+
var feeds = specificResults.map(function(r) {
|
|
6504
|
+
var sr = new SearchResults(state, [
|
|
6505
|
+
r
|
|
6506
|
+
], self._searchResultsOptions);
|
|
6507
|
+
if (rawContent !== undefined) sr._rawContent = rawContent;
|
|
6508
|
+
return sr;
|
|
6509
|
+
});
|
|
6510
|
+
helper.lastResults = new SearchResults(state, [
|
|
6511
|
+
specificResults[0]
|
|
6512
|
+
], self._searchResultsOptions);
|
|
6513
|
+
helper.lastResults.feeds = feeds;
|
|
6514
|
+
if (rawContent !== undefined) helper.lastResults._rawContent = rawContent;
|
|
6515
|
+
} else {
|
|
6516
|
+
helper.lastResults = new SearchResults(state, specificResults, self._searchResultsOptions);
|
|
6517
|
+
if (rawContent !== undefined) helper.lastResults._rawContent = rawContent;
|
|
6518
|
+
}
|
|
6477
6519
|
helper.emit('result', {
|
|
6478
6520
|
results: helper.lastResults,
|
|
6479
6521
|
state: state
|
|
@@ -7253,6 +7295,20 @@
|
|
|
7253
7295
|
return typeof userToken === 'number' ? userToken.toString() : userToken;
|
|
7254
7296
|
}
|
|
7255
7297
|
|
|
7298
|
+
var indexWidgetTypes = [
|
|
7299
|
+
'ais.index',
|
|
7300
|
+
'ais.feedContainer'
|
|
7301
|
+
];
|
|
7302
|
+
|
|
7303
|
+
function isIndexWidget(widget) {
|
|
7304
|
+
return indexWidgetTypes.includes(widget.$$type);
|
|
7305
|
+
}
|
|
7306
|
+
|
|
7307
|
+
function getAlgoliaAgent(client) {
|
|
7308
|
+
var clientTyped = client;
|
|
7309
|
+
return clientTyped.transporter && clientTyped.transporter.userAgent ? clientTyped.transporter.userAgent.value : clientTyped._ua;
|
|
7310
|
+
}
|
|
7311
|
+
|
|
7256
7312
|
function createInitArgs(instantSearchInstance, parent, uiState) {
|
|
7257
7313
|
var helper = parent.getHelper();
|
|
7258
7314
|
return {
|
|
@@ -7292,10 +7348,10 @@
|
|
|
7292
7348
|
error: instantSearchInstance.error
|
|
7293
7349
|
};
|
|
7294
7350
|
}
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
var
|
|
7298
|
-
|
|
7351
|
+
function storeRenderState(param) {
|
|
7352
|
+
var renderState = param.renderState, instantSearchInstance = param.instantSearchInstance, parent = param.parent;
|
|
7353
|
+
var parentIndexName = parent ? parent.getIndexId() : instantSearchInstance.mainIndex.getIndexId();
|
|
7354
|
+
instantSearchInstance.renderState = _object_spread_props(_object_spread({}, instantSearchInstance.renderState), _define_property({}, parentIndexName, _object_spread({}, instantSearchInstance.renderState[parentIndexName], renderState)));
|
|
7299
7355
|
}
|
|
7300
7356
|
|
|
7301
7357
|
function extractWidgetPayload(widgets, instantSearchInstance, payload) {
|
|
@@ -7318,7 +7374,7 @@
|
|
|
7318
7374
|
widgetType: widget.$$widgetType,
|
|
7319
7375
|
params: params
|
|
7320
7376
|
});
|
|
7321
|
-
if (widget
|
|
7377
|
+
if (isIndexWidget(widget)) {
|
|
7322
7378
|
extractWidgetPayload(widget.getWidgets(), instantSearchInstance, payload);
|
|
7323
7379
|
}
|
|
7324
7380
|
});
|
|
@@ -8577,7 +8633,11 @@
|
|
|
8577
8633
|
routeToState: function routeToState() {
|
|
8578
8634
|
var routeState = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
8579
8635
|
return Object.keys(routeState).reduce(function(state, indexId) {
|
|
8580
|
-
|
|
8636
|
+
var indexState = routeState[indexId];
|
|
8637
|
+
if ((typeof indexState === "undefined" ? "undefined" : _type_of(indexState)) !== 'object' || indexState === null) {
|
|
8638
|
+
return state;
|
|
8639
|
+
}
|
|
8640
|
+
return _object_spread_props(_object_spread({}, state), _define_property({}, indexId, getIndexStateWithoutConfigure(indexState)));
|
|
8581
8641
|
}, {});
|
|
8582
8642
|
}
|
|
8583
8643
|
};
|
|
@@ -8690,10 +8750,6 @@
|
|
|
8690
8750
|
widget.$$id = id++;
|
|
8691
8751
|
}
|
|
8692
8752
|
|
|
8693
|
-
function isIndexWidget(widget) {
|
|
8694
|
-
return widget.$$type === 'ais.index';
|
|
8695
|
-
}
|
|
8696
|
-
|
|
8697
8753
|
var nextMicroTask = Promise.resolve();
|
|
8698
8754
|
function defer(callback) {
|
|
8699
8755
|
var progress = null;
|
|
@@ -9518,11 +9574,6 @@
|
|
|
9518
9574
|
}
|
|
9519
9575
|
};
|
|
9520
9576
|
};
|
|
9521
|
-
function storeRenderState(param) {
|
|
9522
|
-
var renderState = param.renderState, instantSearchInstance = param.instantSearchInstance, parent = param.parent;
|
|
9523
|
-
var parentIndexName = parent ? parent.getIndexId() : instantSearchInstance.mainIndex.getIndexId();
|
|
9524
|
-
instantSearchInstance.renderState = _object_spread_props(_object_spread({}, instantSearchInstance.renderState), _define_property({}, parentIndexName, _object_spread({}, instantSearchInstance.renderState[parentIndexName], renderState)));
|
|
9525
|
-
}
|
|
9526
9577
|
/**
|
|
9527
9578
|
* Walk up the parent chain to find the closest isolated index, or fall back to mainHelper
|
|
9528
9579
|
*/ function nearestIsolatedHelper(current, mainHelper) {
|
|
@@ -9930,8 +9981,12 @@
|
|
|
9930
9981
|
};
|
|
9931
9982
|
}
|
|
9932
9983
|
|
|
9933
|
-
var version = '4.
|
|
9984
|
+
var version = '4.96.0';
|
|
9934
9985
|
|
|
9986
|
+
function getServerResults(entry) {
|
|
9987
|
+
var _entry_compositionFeedsResults;
|
|
9988
|
+
return ((_entry_compositionFeedsResults = entry.compositionFeedsResults) === null || _entry_compositionFeedsResults === void 0 ? void 0 : _entry_compositionFeedsResults.length) ? entry.compositionFeedsResults : entry.results || [];
|
|
9989
|
+
}
|
|
9935
9990
|
function hydrateSearchClient(client, results) {
|
|
9936
9991
|
if (!results) {
|
|
9937
9992
|
return;
|
|
@@ -9944,7 +9999,9 @@
|
|
|
9944
9999
|
}
|
|
9945
10000
|
var cachedRequest = [
|
|
9946
10001
|
Object.keys(results).reduce(function(acc, key) {
|
|
9947
|
-
var
|
|
10002
|
+
var entry = results[key];
|
|
10003
|
+
var state = entry.state, requestParams = entry.requestParams;
|
|
10004
|
+
var serverResults = getServerResults(entry);
|
|
9948
10005
|
var mappedResults = serverResults && state ? serverResults.map(function(result, idx) {
|
|
9949
10006
|
return _object_spread({
|
|
9950
10007
|
indexName: state.index || result.index
|
|
@@ -9956,7 +10013,7 @@
|
|
|
9956
10013
|
}, [])
|
|
9957
10014
|
];
|
|
9958
10015
|
var cachedResults = Object.keys(results).reduce(function(acc, key) {
|
|
9959
|
-
var res = results[key]
|
|
10016
|
+
var res = getServerResults(results[key]);
|
|
9960
10017
|
if (!res) {
|
|
9961
10018
|
return acc;
|
|
9962
10019
|
}
|
|
@@ -10011,7 +10068,7 @@
|
|
|
10011
10068
|
}));
|
|
10012
10069
|
client.cache = _object_spread_props(_object_spread({}, client.cache), _define_property({}, cacheKey, JSON.stringify({
|
|
10013
10070
|
results: Object.keys(results).map(function(key) {
|
|
10014
|
-
return results[key]
|
|
10071
|
+
return getServerResults(results[key]);
|
|
10015
10072
|
})
|
|
10016
10073
|
})));
|
|
10017
10074
|
}
|
|
@@ -11078,6 +11135,13 @@
|
|
|
11078
11135
|
});
|
|
11079
11136
|
}
|
|
11080
11137
|
|
|
11138
|
+
/**
|
|
11139
|
+
* Returns true if the widget requires a second SSR pass to discover and
|
|
11140
|
+
* mount child widgets (e.g. DynamicWidgets, Feeds).
|
|
11141
|
+
*/ function isTwoPassWidget(widget) {
|
|
11142
|
+
return widget.$$type === 'ais.dynamicWidgets' || widget.$$type === 'ais.feeds';
|
|
11143
|
+
}
|
|
11144
|
+
|
|
11081
11145
|
/**
|
|
11082
11146
|
* Creates a new object with the same keys as the original object, but without the excluded keys.
|
|
11083
11147
|
* @param source original object
|
|
@@ -15449,19 +15513,16 @@
|
|
|
15449
15513
|
});
|
|
15450
15514
|
/*
|
|
15451
15515
|
With dynamic widgets, facets are not included in the state before their relevant widgets are mounted. Until then, we need to bail out of writing this incomplete state representation in cache.
|
|
15452
|
-
*/ var
|
|
15516
|
+
*/ var hasTwoPassWidgets = false;
|
|
15453
15517
|
walkIndex(instantSearchInstance.mainIndex, function(indexWidget) {
|
|
15454
|
-
if (!
|
|
15455
|
-
|
|
15456
|
-
return $$type === 'ais.dynamicWidgets';
|
|
15457
|
-
})) {
|
|
15458
|
-
hasDynamicWidgets = true;
|
|
15518
|
+
if (!hasTwoPassWidgets && indexWidget.getWidgets().some(isTwoPassWidget)) {
|
|
15519
|
+
hasTwoPassWidgets = true;
|
|
15459
15520
|
}
|
|
15460
15521
|
});
|
|
15461
15522
|
var hasNoFacets = !((_state_disjunctiveFacets = state.disjunctiveFacets) === null || _state_disjunctiveFacets === void 0 ? void 0 : _state_disjunctiveFacets.length) && !(state.facets || []).filter(function(f) {
|
|
15462
15523
|
return f !== '*';
|
|
15463
15524
|
}).length && !((_state_hierarchicalFacets = state.hierarchicalFacets) === null || _state_hierarchicalFacets === void 0 ? void 0 : _state_hierarchicalFacets.length);
|
|
15464
|
-
if (cachedHits[page] === undefined && !results.__isArtificial && instantSearchInstance.status === 'idle' && !(
|
|
15525
|
+
if (cachedHits[page] === undefined && !results.__isArtificial && instantSearchInstance.status === 'idle' && !(hasTwoPassWidgets && hasNoFacets)) {
|
|
15465
15526
|
cachedHits[page] = transformedHits;
|
|
15466
15527
|
cache.write({
|
|
15467
15528
|
state: normalizeState(state),
|
|
@@ -19358,7 +19419,8 @@
|
|
|
19358
19419
|
},
|
|
19359
19420
|
getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, param) {
|
|
19360
19421
|
var uiState = param.uiState;
|
|
19361
|
-
var
|
|
19422
|
+
var isUiStateSortByInItems = !uiState.sortBy || Object.prototype.hasOwnProperty.call(connectorState.itemsLookup, uiState.sortBy);
|
|
19423
|
+
var sortByValue = (isUiStateSortByInItems ? uiState.sortBy : undefined) || connectorState.initialValue || searchParameters.index;
|
|
19362
19424
|
if (isValidStrategy(connectorState.itemsLookup, sortByValue)) {
|
|
19363
19425
|
var item = connectorState.itemsLookup[sortByValue];
|
|
19364
19426
|
// Strategy-based: set the sortBy parameter for composition API
|