instantsearch.js 4.41.0 → 4.42.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 +34 -0
- package/cjs/lib/InstantSearch.js +3 -4
- package/cjs/lib/utils/createSendEventForHits.js +10 -3
- package/cjs/lib/version.js +1 -1
- package/dist/instantsearch.development.d.ts +11 -9
- package/dist/instantsearch.development.js +130 -64
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +11 -9
- package/dist/instantsearch.production.min.d.ts +11 -9
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/lib/InstantSearch.d.ts +10 -9
- package/es/lib/InstantSearch.js +3 -4
- package/es/lib/utils/createSendEventForHits.js +10 -3
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
# [4.42.0](https://github.com/algolia/instantsearch.js/compare/v4.41.2...v4.42.0) (2022-06-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **es:** update import path for `infiniteHitsCache` in depreciation message ([#5068](https://github.com/algolia/instantsearch.js/issues/5068)) ([545cbaf](https://github.com/algolia/instantsearch.js/commit/545cbafd748bb8be32bff66ac60b5f3f9133a5b4))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **core:** sort parameters & support client.search for sffv ([#5069](https://github.com/algolia/instantsearch.js/issues/5069)) ([34e2b00](https://github.com/algolia/instantsearch.js/commit/34e2b00cbc93f1bc86ee0abaec6b6e132bd18354))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [4.41.2](https://github.com/algolia/instantsearch.js/compare/v4.41.1...v4.41.2) (2022-06-15)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **hierarchicalMenu:** show full hierarchical parent values ([#5063](https://github.com/algolia/instantsearch.js/issues/5063)) ([cd1db34](https://github.com/algolia/instantsearch.js/commit/cd1db34815f92acb3d2d0cec6c1ae7865d14fb13))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## [4.41.1](https://github.com/algolia/instantsearch.js/compare/v4.41.0...v4.41.1) (2022-06-14)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
* **insights:** don't send view event if search is stalled ([#5058](https://github.com/algolia/instantsearch.js/issues/5058)) ([1686dfb](https://github.com/algolia/instantsearch.js/commit/1686dfb096cfce062e268feda7956e3b160bf2da)), closes [/github.com/algolia/instantsearch.js/blob/99f6fe1dc51e4815e5b9efcfb30e3e2f3127e763/src/lib/utils/createSendEventForHits.ts#L168](https://github.com//github.com/algolia/instantsearch.js/blob/99f6fe1dc51e4815e5b9efcfb30e3e2f3127e763/src/lib/utils/createSendEventForHits.ts/issues/L168) [/github.com/algolia/instantsearch.js/blob/55313e4ea4105b777f3f102e9f48a7e440496d25/src/middlewares/createInsightsMiddleware.ts#L144](https://github.com//github.com/algolia/instantsearch.js/blob/55313e4ea4105b777f3f102e9f48a7e440496d25/src/middlewares/createInsightsMiddleware.ts/issues/L144)
|
|
30
|
+
* **types:** avoid inferring UiState type from initialUiState ([#5061](https://github.com/algolia/instantsearch.js/issues/5061)) ([80ca07e](https://github.com/algolia/instantsearch.js/commit/80ca07e29064357343ee997be94ef10beadba637)), closes [/github.com/Microsoft/TypeScript/issues/14829#issuecomment-504042546](https://github.com//github.com/Microsoft/TypeScript/issues/14829/issues/issuecomment-504042546) [#5060](https://github.com/algolia/instantsearch.js/issues/5060)
|
|
31
|
+
* **types:** make all usages of UiState in InstantSearch generic ([#5060](https://github.com/algolia/instantsearch.js/issues/5060)) ([2b9e76b](https://github.com/algolia/instantsearch.js/commit/2b9e76b568fb4d4cc5bd49c384ee583d84d6f39a))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
1
35
|
# [4.41.0](https://github.com/algolia/instantsearch.js/compare/v4.40.6...v4.41.0) (2022-06-01)
|
|
2
36
|
|
|
3
37
|
|
package/cjs/lib/InstantSearch.js
CHANGED
|
@@ -61,10 +61,9 @@ var withUsage = (0, _index2.createDocumentationMessageGenerator)({
|
|
|
61
61
|
|
|
62
62
|
function defaultCreateURL() {
|
|
63
63
|
return '#';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*/
|
|
64
|
+
} // this purposely breaks typescript's type inference to ensure it's not used
|
|
65
|
+
// as it's used for a default parameter for example
|
|
66
|
+
// source: https://github.com/Microsoft/TypeScript/issues/14829#issuecomment-504042546
|
|
68
67
|
|
|
69
68
|
|
|
70
69
|
/**
|
|
@@ -25,7 +25,8 @@ var buildPayloads = function buildPayloads(_ref) {
|
|
|
25
25
|
var index = _ref.index,
|
|
26
26
|
widgetType = _ref.widgetType,
|
|
27
27
|
methodName = _ref.methodName,
|
|
28
|
-
args = _ref.args
|
|
28
|
+
args = _ref.args,
|
|
29
|
+
isSearchStalled = _ref.isSearchStalled;
|
|
29
30
|
|
|
30
31
|
// when there's only one argument, that means it's custom
|
|
31
32
|
if (args.length === 1 && _typeof(args[0]) === 'object') {
|
|
@@ -72,6 +73,10 @@ var buildPayloads = function buildPayloads(_ref) {
|
|
|
72
73
|
});
|
|
73
74
|
|
|
74
75
|
if (eventType === 'view') {
|
|
76
|
+
if (isSearchStalled) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
|
|
75
80
|
return hitsChunks.map(function (batch, i) {
|
|
76
81
|
return {
|
|
77
82
|
insightsMethod: 'viewedObjectIDs',
|
|
@@ -142,7 +147,8 @@ function createSendEventForHits(_ref2) {
|
|
|
142
147
|
widgetType: widgetType,
|
|
143
148
|
index: index,
|
|
144
149
|
methodName: 'sendEvent',
|
|
145
|
-
args: args
|
|
150
|
+
args: args,
|
|
151
|
+
isSearchStalled: instantSearchInstance._isSearchStalled
|
|
146
152
|
});
|
|
147
153
|
payloads.forEach(function (payload) {
|
|
148
154
|
return instantSearchInstance.sendEventToInsights(payload);
|
|
@@ -165,7 +171,8 @@ function createBindEventForHits(_ref3) {
|
|
|
165
171
|
widgetType: widgetType,
|
|
166
172
|
index: index,
|
|
167
173
|
methodName: 'bindEvent',
|
|
168
|
-
args: args
|
|
174
|
+
args: args,
|
|
175
|
+
isSearchStalled: false
|
|
169
176
|
});
|
|
170
177
|
return payloads.length ? "data-insights-event=".concat((0, _serializer.serializePayload)(payloads)) : '';
|
|
171
178
|
};
|
package/cjs/lib/version.js
CHANGED
|
@@ -2286,7 +2286,7 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2286
2286
|
client: InstantSearchOptions['searchClient'];
|
|
2287
2287
|
indexName: string;
|
|
2288
2288
|
insightsClient: InsightsClient | null;
|
|
2289
|
-
onStateChange: InstantSearchOptions['onStateChange'] | null;
|
|
2289
|
+
onStateChange: InstantSearchOptions<TUiState>['onStateChange'] | null;
|
|
2290
2290
|
helper: AlgoliaSearchHelper | null;
|
|
2291
2291
|
mainHelper: AlgoliaSearchHelper | null;
|
|
2292
2292
|
mainIndex: IndexWidget;
|
|
@@ -2296,9 +2296,9 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2296
2296
|
_stalledSearchDelay: number;
|
|
2297
2297
|
_searchStalledTimer: any;
|
|
2298
2298
|
_isSearchStalled: boolean;
|
|
2299
|
-
_initialUiState:
|
|
2299
|
+
_initialUiState: TUiState;
|
|
2300
2300
|
_initialResults: InitialResults | null;
|
|
2301
|
-
_createURL: CreateURL<
|
|
2301
|
+
_createURL: CreateURL<TUiState>;
|
|
2302
2302
|
_searchFunction?: InstantSearchOptions['searchFunction'];
|
|
2303
2303
|
_mainHelperSearch?: AlgoliaSearchHelper['search'];
|
|
2304
2304
|
middleware: Array<{
|
|
@@ -2368,13 +2368,13 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2368
2368
|
cancel(): void;
|
|
2369
2369
|
};
|
|
2370
2370
|
scheduleStalledRender(): void;
|
|
2371
|
-
setUiState(uiState:
|
|
2372
|
-
getUiState():
|
|
2371
|
+
setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState)): void;
|
|
2372
|
+
getUiState(): TUiState;
|
|
2373
2373
|
onInternalStateChange: ((...args: any[]) => void) & {
|
|
2374
2374
|
wait(): Promise<void>;
|
|
2375
2375
|
cancel(): void;
|
|
2376
2376
|
};
|
|
2377
|
-
createURL(nextState?:
|
|
2377
|
+
createURL(nextState?: TUiState): string;
|
|
2378
2378
|
refresh(): void;
|
|
2379
2379
|
}
|
|
2380
2380
|
|
|
@@ -2466,8 +2466,8 @@ declare type InstantSearchOptions<TUiState extends UiState = UiState, TRouteStat
|
|
|
2466
2466
|
* become in charge of updating the UI state with the `setUiState` function.
|
|
2467
2467
|
*/
|
|
2468
2468
|
onStateChange?: (params: {
|
|
2469
|
-
uiState:
|
|
2470
|
-
setUiState(uiState:
|
|
2469
|
+
uiState: TUiState;
|
|
2470
|
+
setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState)): void;
|
|
2471
2471
|
}) => void;
|
|
2472
2472
|
/**
|
|
2473
2473
|
* Injects a `uiState` to the `instantsearch` instance. You can use this option
|
|
@@ -2475,7 +2475,7 @@ declare type InstantSearchOptions<TUiState extends UiState = UiState, TRouteStat
|
|
|
2475
2475
|
* for the first search. To unconditionally pass additional parameters to the
|
|
2476
2476
|
* Algolia API, take a look at the `configure` widget.
|
|
2477
2477
|
*/
|
|
2478
|
-
initialUiState?: TUiState
|
|
2478
|
+
initialUiState?: NoInfer<TUiState>;
|
|
2479
2479
|
/**
|
|
2480
2480
|
* Time before a search is considered stalled. The default is 200ms
|
|
2481
2481
|
*/
|
|
@@ -2779,6 +2779,8 @@ declare namespace middlewares {
|
|
|
2779
2779
|
}
|
|
2780
2780
|
}
|
|
2781
2781
|
|
|
2782
|
+
declare type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
2783
|
+
|
|
2782
2784
|
declare const numericMenu: NumericMenuWidget;
|
|
2783
2785
|
|
|
2784
2786
|
declare type NumericMenuComponentCSSClasses = ComponentCSSClasses<NumericMenuCSSClasses>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! InstantSearch.js 4.
|
|
1
|
+
/*! InstantSearch.js 4.42.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch.js */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -2989,7 +2989,7 @@
|
|
|
2989
2989
|
nextDisjunctiveResult++;
|
|
2990
2990
|
});
|
|
2991
2991
|
|
|
2992
|
-
// if we have some
|
|
2992
|
+
// if we have some parent level values for hierarchical facets, merge them
|
|
2993
2993
|
state.getRefinedHierarchicalFacets().forEach(function(refinedFacet) {
|
|
2994
2994
|
var hierarchicalFacet = state.getHierarchicalFacetByName(refinedFacet);
|
|
2995
2995
|
var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);
|
|
@@ -3001,47 +3001,49 @@
|
|
|
3001
3001
|
return;
|
|
3002
3002
|
}
|
|
3003
3003
|
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
Object.keys(facets).forEach(function(dfacet) {
|
|
3009
|
-
var facetResults = facets[dfacet];
|
|
3010
|
-
var position = findIndex(state.hierarchicalFacets, function(f) {
|
|
3011
|
-
return f.name === hierarchicalFacet.name;
|
|
3012
|
-
});
|
|
3013
|
-
var attributeIndex = findIndex(self.hierarchicalFacets[position], function(f) {
|
|
3014
|
-
return f.attribute === dfacet;
|
|
3015
|
-
});
|
|
3004
|
+
results.slice(nextDisjunctiveResult).forEach(function(result) {
|
|
3005
|
+
var facets = result && result.facets
|
|
3006
|
+
? result.facets
|
|
3007
|
+
: {};
|
|
3016
3008
|
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3009
|
+
Object.keys(facets).forEach(function(dfacet) {
|
|
3010
|
+
var facetResults = facets[dfacet];
|
|
3011
|
+
var position = findIndex(state.hierarchicalFacets, function(f) {
|
|
3012
|
+
return f.name === hierarchicalFacet.name;
|
|
3013
|
+
});
|
|
3014
|
+
var attributeIndex = findIndex(self.hierarchicalFacets[position], function(f) {
|
|
3015
|
+
return f.attribute === dfacet;
|
|
3016
|
+
});
|
|
3021
3017
|
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
// > IPA (5)
|
|
3027
|
-
// We want
|
|
3028
|
-
// | beers (5)
|
|
3029
|
-
// > IPA (5)
|
|
3030
|
-
var defaultData = {};
|
|
3031
|
-
|
|
3032
|
-
if (currentRefinement.length > 0) {
|
|
3033
|
-
var root = currentRefinement[0].split(separator)[0];
|
|
3034
|
-
defaultData[root] = self.hierarchicalFacets[position][attributeIndex].data[root];
|
|
3035
|
-
}
|
|
3018
|
+
// previous refinements and no results so not able to find it
|
|
3019
|
+
if (attributeIndex === -1) {
|
|
3020
|
+
return;
|
|
3021
|
+
}
|
|
3036
3022
|
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3023
|
+
// when we always get root levels, if the hits refinement is `beers > IPA` (count: 5),
|
|
3024
|
+
// then the disjunctive values will be `beers` (count: 100),
|
|
3025
|
+
// but we do not want to display
|
|
3026
|
+
// | beers (100)
|
|
3027
|
+
// > IPA (5)
|
|
3028
|
+
// We want
|
|
3029
|
+
// | beers (5)
|
|
3030
|
+
// > IPA (5)
|
|
3031
|
+
var defaultData = {};
|
|
3032
|
+
|
|
3033
|
+
if (currentRefinement.length > 0) {
|
|
3034
|
+
var root = currentRefinement[0].split(separator)[0];
|
|
3035
|
+
defaultData[root] = self.hierarchicalFacets[position][attributeIndex].data[root];
|
|
3036
|
+
}
|
|
3043
3037
|
|
|
3044
|
-
|
|
3038
|
+
self.hierarchicalFacets[position][attributeIndex].data = defaultsPure(
|
|
3039
|
+
defaultData,
|
|
3040
|
+
facetResults,
|
|
3041
|
+
self.hierarchicalFacets[position][attributeIndex].data
|
|
3042
|
+
);
|
|
3043
|
+
});
|
|
3044
|
+
|
|
3045
|
+
nextDisjunctiveResult++;
|
|
3046
|
+
});
|
|
3045
3047
|
});
|
|
3046
3048
|
|
|
3047
3049
|
// add the excludes
|
|
@@ -3845,6 +3847,17 @@
|
|
|
3845
3847
|
|
|
3846
3848
|
var DerivedHelper_1 = DerivedHelper;
|
|
3847
3849
|
|
|
3850
|
+
function sortObject(obj) {
|
|
3851
|
+
return Object.keys(obj)
|
|
3852
|
+
.sort(function(a, b) {
|
|
3853
|
+
return a.localeCompare(b);
|
|
3854
|
+
})
|
|
3855
|
+
.reduce(function(acc, curr) {
|
|
3856
|
+
acc[curr] = obj[curr];
|
|
3857
|
+
return acc;
|
|
3858
|
+
}, {});
|
|
3859
|
+
}
|
|
3860
|
+
|
|
3848
3861
|
var requestBuilder = {
|
|
3849
3862
|
/**
|
|
3850
3863
|
* Get all the queries to send to the client, those queries can used directly
|
|
@@ -3869,18 +3882,38 @@
|
|
|
3869
3882
|
});
|
|
3870
3883
|
});
|
|
3871
3884
|
|
|
3872
|
-
//
|
|
3885
|
+
// More to get the parent levels of the hierarchical facets when refined
|
|
3873
3886
|
state.getRefinedHierarchicalFacets().forEach(function(refinedFacet) {
|
|
3874
3887
|
var hierarchicalFacet = state.getHierarchicalFacetByName(refinedFacet);
|
|
3875
|
-
|
|
3876
3888
|
var currentRefinement = state.getHierarchicalRefinement(refinedFacet);
|
|
3877
|
-
// if we are deeper than level 0 (starting from `beer > IPA`)
|
|
3878
|
-
// we want to get the root values
|
|
3879
3889
|
var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);
|
|
3890
|
+
|
|
3891
|
+
// If we are deeper than level 0 (starting from `beer > IPA`)
|
|
3892
|
+
// we want to get all parent values
|
|
3880
3893
|
if (currentRefinement.length > 0 && currentRefinement[0].split(separator).length > 1) {
|
|
3881
|
-
queries
|
|
3882
|
-
|
|
3883
|
-
|
|
3894
|
+
// We generate a map of the filters we will use for our facet values queries
|
|
3895
|
+
var filtersMap = currentRefinement[0].split(separator).slice(0, -1).reduce(
|
|
3896
|
+
function createFiltersMap(map, segment, level) {
|
|
3897
|
+
return map.concat({
|
|
3898
|
+
attribute: hierarchicalFacet.attributes[level],
|
|
3899
|
+
value: level === 0
|
|
3900
|
+
? segment
|
|
3901
|
+
: [map[map.length - 1].value, segment].join(separator)
|
|
3902
|
+
});
|
|
3903
|
+
}
|
|
3904
|
+
, []);
|
|
3905
|
+
|
|
3906
|
+
filtersMap.forEach(function(filter, level) {
|
|
3907
|
+
var params = requestBuilder._getDisjunctiveFacetSearchParams(
|
|
3908
|
+
state,
|
|
3909
|
+
filter.attribute,
|
|
3910
|
+
level === 0
|
|
3911
|
+
);
|
|
3912
|
+
|
|
3913
|
+
var parent = filtersMap[level - 1];
|
|
3914
|
+
params.facetFilters = level > 0 ? [parent.attribute + ':' + parent.value] : undefined;
|
|
3915
|
+
|
|
3916
|
+
queries.push({indexName: index, params: params});
|
|
3884
3917
|
});
|
|
3885
3918
|
}
|
|
3886
3919
|
});
|
|
@@ -3915,7 +3948,7 @@
|
|
|
3915
3948
|
additionalParams.numericFilters = numericFilters;
|
|
3916
3949
|
}
|
|
3917
3950
|
|
|
3918
|
-
return merge_1({}, state.getQueryParams(), additionalParams);
|
|
3951
|
+
return sortObject(merge_1({}, state.getQueryParams(), additionalParams));
|
|
3919
3952
|
},
|
|
3920
3953
|
|
|
3921
3954
|
/**
|
|
@@ -3960,7 +3993,7 @@
|
|
|
3960
3993
|
additionalParams.facetFilters = facetFilters;
|
|
3961
3994
|
}
|
|
3962
3995
|
|
|
3963
|
-
return merge_1({}, state.getQueryParams(), additionalParams);
|
|
3996
|
+
return sortObject(merge_1({}, state.getQueryParams(), additionalParams));
|
|
3964
3997
|
},
|
|
3965
3998
|
|
|
3966
3999
|
/**
|
|
@@ -4153,17 +4186,17 @@
|
|
|
4153
4186
|
if (typeof maxFacetHits === 'number') {
|
|
4154
4187
|
searchForFacetSearchParameters.maxFacetHits = maxFacetHits;
|
|
4155
4188
|
}
|
|
4156
|
-
return merge_1(
|
|
4189
|
+
return sortObject(merge_1(
|
|
4157
4190
|
{},
|
|
4158
4191
|
requestBuilder._getHitsSearchParams(stateForSearchForFacetValues),
|
|
4159
4192
|
searchForFacetSearchParameters
|
|
4160
|
-
);
|
|
4193
|
+
));
|
|
4161
4194
|
}
|
|
4162
4195
|
};
|
|
4163
4196
|
|
|
4164
4197
|
var requestBuilder_1 = requestBuilder;
|
|
4165
4198
|
|
|
4166
|
-
var version = '3.
|
|
4199
|
+
var version = '3.9.0';
|
|
4167
4200
|
|
|
4168
4201
|
var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
|
|
4169
4202
|
|
|
@@ -4483,20 +4516,51 @@
|
|
|
4483
4516
|
*/
|
|
4484
4517
|
AlgoliaSearchHelper.prototype.searchForFacetValues = function(facet, query, maxFacetHits, userState) {
|
|
4485
4518
|
var clientHasSFFV = typeof this.client.searchForFacetValues === 'function';
|
|
4519
|
+
var clientHasInitIndex = typeof this.client.initIndex === 'function';
|
|
4486
4520
|
if (
|
|
4487
4521
|
!clientHasSFFV &&
|
|
4488
|
-
|
|
4522
|
+
!clientHasInitIndex &&
|
|
4523
|
+
typeof this.client.search !== 'function'
|
|
4489
4524
|
) {
|
|
4490
4525
|
throw new Error(
|
|
4491
4526
|
'search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues'
|
|
4492
4527
|
);
|
|
4493
4528
|
}
|
|
4529
|
+
|
|
4494
4530
|
var state = this.state.setQueryParameters(userState || {});
|
|
4495
4531
|
var isDisjunctive = state.isDisjunctiveFacet(facet);
|
|
4496
4532
|
var algoliaQuery = requestBuilder_1.getSearchForFacetQuery(facet, query, maxFacetHits, state);
|
|
4497
4533
|
|
|
4498
4534
|
this._currentNbQueries++;
|
|
4499
4535
|
var self = this;
|
|
4536
|
+
var searchForFacetValuesPromise;
|
|
4537
|
+
// newer algoliasearch ^3.27.1 - ~4.0.0
|
|
4538
|
+
if (clientHasSFFV) {
|
|
4539
|
+
searchForFacetValuesPromise = this.client.searchForFacetValues([
|
|
4540
|
+
{indexName: state.index, params: algoliaQuery}
|
|
4541
|
+
]);
|
|
4542
|
+
// algoliasearch < 3.27.1
|
|
4543
|
+
} else if (clientHasInitIndex) {
|
|
4544
|
+
searchForFacetValuesPromise = this.client
|
|
4545
|
+
.initIndex(state.index)
|
|
4546
|
+
.searchForFacetValues(algoliaQuery);
|
|
4547
|
+
// algoliasearch ~5.0.0
|
|
4548
|
+
} else {
|
|
4549
|
+
// @MAJOR only use client.search
|
|
4550
|
+
delete algoliaQuery.facetName;
|
|
4551
|
+
searchForFacetValuesPromise = this.client
|
|
4552
|
+
.search([
|
|
4553
|
+
{
|
|
4554
|
+
type: 'facet',
|
|
4555
|
+
facet: facet,
|
|
4556
|
+
indexName: state.index,
|
|
4557
|
+
params: algoliaQuery
|
|
4558
|
+
}
|
|
4559
|
+
])
|
|
4560
|
+
.then(function processResponse(response) {
|
|
4561
|
+
return response.results[0];
|
|
4562
|
+
});
|
|
4563
|
+
}
|
|
4500
4564
|
|
|
4501
4565
|
this.emit('searchForFacetValues', {
|
|
4502
4566
|
state: state,
|
|
@@ -4504,10 +4568,6 @@
|
|
|
4504
4568
|
query: query
|
|
4505
4569
|
});
|
|
4506
4570
|
|
|
4507
|
-
var searchForFacetValuesPromise = clientHasSFFV
|
|
4508
|
-
? this.client.searchForFacetValues([{indexName: state.index, params: algoliaQuery}])
|
|
4509
|
-
: this.client.initIndex(state.index).searchForFacetValues(algoliaQuery);
|
|
4510
|
-
|
|
4511
4571
|
return searchForFacetValuesPromise.then(function addIsRefined(content) {
|
|
4512
4572
|
self._currentNbQueries--;
|
|
4513
4573
|
if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');
|
|
@@ -7692,7 +7752,8 @@
|
|
|
7692
7752
|
var index = _ref.index,
|
|
7693
7753
|
widgetType = _ref.widgetType,
|
|
7694
7754
|
methodName = _ref.methodName,
|
|
7695
|
-
args = _ref.args
|
|
7755
|
+
args = _ref.args,
|
|
7756
|
+
isSearchStalled = _ref.isSearchStalled;
|
|
7696
7757
|
|
|
7697
7758
|
// when there's only one argument, that means it's custom
|
|
7698
7759
|
if (args.length === 1 && _typeof(args[0]) === 'object') {
|
|
@@ -7735,6 +7796,10 @@
|
|
|
7735
7796
|
});
|
|
7736
7797
|
|
|
7737
7798
|
if (eventType === 'view') {
|
|
7799
|
+
if (isSearchStalled) {
|
|
7800
|
+
return [];
|
|
7801
|
+
}
|
|
7802
|
+
|
|
7738
7803
|
return hitsChunks.map(function (batch, i) {
|
|
7739
7804
|
return {
|
|
7740
7805
|
insightsMethod: 'viewedObjectIDs',
|
|
@@ -7803,7 +7868,8 @@
|
|
|
7803
7868
|
widgetType: widgetType,
|
|
7804
7869
|
index: index,
|
|
7805
7870
|
methodName: 'sendEvent',
|
|
7806
|
-
args: args
|
|
7871
|
+
args: args,
|
|
7872
|
+
isSearchStalled: instantSearchInstance._isSearchStalled
|
|
7807
7873
|
});
|
|
7808
7874
|
payloads.forEach(function (payload) {
|
|
7809
7875
|
return instantSearchInstance.sendEventToInsights(payload);
|
|
@@ -7825,7 +7891,8 @@
|
|
|
7825
7891
|
widgetType: widgetType,
|
|
7826
7892
|
index: index,
|
|
7827
7893
|
methodName: 'bindEvent',
|
|
7828
|
-
args: args
|
|
7894
|
+
args: args,
|
|
7895
|
+
isSearchStalled: false
|
|
7829
7896
|
});
|
|
7830
7897
|
return payloads.length ? "data-insights-event=".concat(serializePayload(payloads)) : '';
|
|
7831
7898
|
};
|
|
@@ -8536,7 +8603,7 @@
|
|
|
8536
8603
|
instantSearchInstance.renderState = _objectSpread2(_objectSpread2({}, instantSearchInstance.renderState), {}, _defineProperty({}, parentIndexName, _objectSpread2(_objectSpread2({}, instantSearchInstance.renderState[parentIndexName]), renderState)));
|
|
8537
8604
|
}
|
|
8538
8605
|
|
|
8539
|
-
var version$1 = '4.
|
|
8606
|
+
var version$1 = '4.42.0';
|
|
8540
8607
|
|
|
8541
8608
|
var NAMESPACE = 'ais';
|
|
8542
8609
|
var component = function component(componentName) {
|
|
@@ -10026,10 +10093,9 @@
|
|
|
10026
10093
|
|
|
10027
10094
|
function defaultCreateURL() {
|
|
10028
10095
|
return '#';
|
|
10029
|
-
}
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
*/
|
|
10096
|
+
} // this purposely breaks typescript's type inference to ensure it's not used
|
|
10097
|
+
// as it's used for a default parameter for example
|
|
10098
|
+
// source: https://github.com/Microsoft/TypeScript/issues/14829#issuecomment-504042546
|
|
10033
10099
|
|
|
10034
10100
|
|
|
10035
10101
|
/**
|