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/es/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { createInfiniteHitsSessionStorageCache } from './lib/infiniteHitsCache';
|
|
|
6
6
|
declare type InstantSearchModule = {
|
|
7
7
|
<TUiState = Record<string, unknown>, TRouteState = TUiState>(options: InstantSearchOptions<Expand<UiState & TUiState>, TRouteState>): InstantSearch<Expand<UiState & TUiState>, TRouteState>;
|
|
8
8
|
version: string;
|
|
9
|
-
/** @deprecated import { createInfiniteHitsSessionStorageCache } from 'instantsearch.js/es/
|
|
9
|
+
/** @deprecated import { createInfiniteHitsSessionStorageCache } from 'instantsearch.js/es/lib/infiniteHitsCache' */
|
|
10
10
|
createInfiniteHitsSessionStorageCache: typeof createInfiniteHitsSessionStorageCache;
|
|
11
11
|
/** @deprecated import { highlight } from 'instantsearch.js/es/helpers' */
|
|
12
12
|
highlight: typeof highlight;
|
package/es/index.js
CHANGED
|
@@ -24,7 +24,7 @@ var instantsearch = function instantsearch(options) {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
instantsearch.version = version;
|
|
27
|
-
instantsearch.createInfiniteHitsSessionStorageCache = deprecate(createInfiniteHitsSessionStorageCache, "import { createInfiniteHitsSessionStorageCache } from 'instantsearch.js/es/
|
|
27
|
+
instantsearch.createInfiniteHitsSessionStorageCache = deprecate(createInfiniteHitsSessionStorageCache, "import { createInfiniteHitsSessionStorageCache } from 'instantsearch.js/es/lib/infiniteHitsCache'");
|
|
28
28
|
instantsearch.highlight = deprecate(highlight, "import { highlight } from 'instantsearch.js/es/helpers'");
|
|
29
29
|
instantsearch.reverseHighlight = deprecate(reverseHighlight, "import { reverseHighlight } from 'instantsearch.js/es/helpers'");
|
|
30
30
|
instantsearch.snippet = deprecate(snippet, "import { snippet } from 'instantsearch.js/es/helpers'");
|
|
@@ -4,6 +4,7 @@ import type { IndexWidget } from '../widgets/index/index';
|
|
|
4
4
|
import type { InsightsClient as AlgoliaInsightsClient, SearchClient, Widget, UiState, CreateURL, Middleware, MiddlewareDefinition, RenderState, InitialResults } from '../types';
|
|
5
5
|
import type { RouterProps } from '../middlewares/createRouterMiddleware';
|
|
6
6
|
import type { InsightsEvent } from '../middlewares/createInsightsMiddleware';
|
|
7
|
+
declare type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
7
8
|
/**
|
|
8
9
|
* Global options for an InstantSearch instance.
|
|
9
10
|
*/
|
|
@@ -58,8 +59,8 @@ export declare type InstantSearchOptions<TUiState extends UiState = UiState, TRo
|
|
|
58
59
|
* become in charge of updating the UI state with the `setUiState` function.
|
|
59
60
|
*/
|
|
60
61
|
onStateChange?: (params: {
|
|
61
|
-
uiState:
|
|
62
|
-
setUiState(uiState:
|
|
62
|
+
uiState: TUiState;
|
|
63
|
+
setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState)): void;
|
|
63
64
|
}) => void;
|
|
64
65
|
/**
|
|
65
66
|
* Injects a `uiState` to the `instantsearch` instance. You can use this option
|
|
@@ -67,7 +68,7 @@ export declare type InstantSearchOptions<TUiState extends UiState = UiState, TRo
|
|
|
67
68
|
* for the first search. To unconditionally pass additional parameters to the
|
|
68
69
|
* Algolia API, take a look at the `configure` widget.
|
|
69
70
|
*/
|
|
70
|
-
initialUiState?: TUiState
|
|
71
|
+
initialUiState?: NoInfer<TUiState>;
|
|
71
72
|
/**
|
|
72
73
|
* Time before a search is considered stalled. The default is 200ms
|
|
73
74
|
*/
|
|
@@ -94,7 +95,7 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
94
95
|
client: InstantSearchOptions['searchClient'];
|
|
95
96
|
indexName: string;
|
|
96
97
|
insightsClient: AlgoliaInsightsClient | null;
|
|
97
|
-
onStateChange: InstantSearchOptions['onStateChange'] | null;
|
|
98
|
+
onStateChange: InstantSearchOptions<TUiState>['onStateChange'] | null;
|
|
98
99
|
helper: AlgoliaSearchHelper | null;
|
|
99
100
|
mainHelper: AlgoliaSearchHelper | null;
|
|
100
101
|
mainIndex: IndexWidget;
|
|
@@ -104,9 +105,9 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
104
105
|
_stalledSearchDelay: number;
|
|
105
106
|
_searchStalledTimer: any;
|
|
106
107
|
_isSearchStalled: boolean;
|
|
107
|
-
_initialUiState:
|
|
108
|
+
_initialUiState: TUiState;
|
|
108
109
|
_initialResults: InitialResults | null;
|
|
109
|
-
_createURL: CreateURL<
|
|
110
|
+
_createURL: CreateURL<TUiState>;
|
|
110
111
|
_searchFunction?: InstantSearchOptions['searchFunction'];
|
|
111
112
|
_mainHelperSearch?: AlgoliaSearchHelper['search'];
|
|
112
113
|
middleware: Array<{
|
|
@@ -176,13 +177,13 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
176
177
|
cancel(): void;
|
|
177
178
|
};
|
|
178
179
|
scheduleStalledRender(): void;
|
|
179
|
-
setUiState(uiState:
|
|
180
|
-
getUiState():
|
|
180
|
+
setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState)): void;
|
|
181
|
+
getUiState(): TUiState;
|
|
181
182
|
onInternalStateChange: ((...args: any[]) => void) & {
|
|
182
183
|
wait(): Promise<void>;
|
|
183
184
|
cancel(): void;
|
|
184
185
|
};
|
|
185
|
-
createURL(nextState?:
|
|
186
|
+
createURL(nextState?: TUiState): string;
|
|
186
187
|
refresh(): void;
|
|
187
188
|
}
|
|
188
189
|
export default InstantSearch;
|
package/es/lib/InstantSearch.js
CHANGED
|
@@ -40,10 +40,9 @@ var withUsage = createDocumentationMessageGenerator({
|
|
|
40
40
|
|
|
41
41
|
function defaultCreateURL() {
|
|
42
42
|
return '#';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*/
|
|
43
|
+
} // this purposely breaks typescript's type inference to ensure it's not used
|
|
44
|
+
// as it's used for a default parameter for example
|
|
45
|
+
// source: https://github.com/Microsoft/TypeScript/issues/14829#issuecomment-504042546
|
|
47
46
|
|
|
48
47
|
|
|
49
48
|
/**
|
|
@@ -20,7 +20,8 @@ var buildPayloads = function buildPayloads(_ref) {
|
|
|
20
20
|
var index = _ref.index,
|
|
21
21
|
widgetType = _ref.widgetType,
|
|
22
22
|
methodName = _ref.methodName,
|
|
23
|
-
args = _ref.args
|
|
23
|
+
args = _ref.args,
|
|
24
|
+
isSearchStalled = _ref.isSearchStalled;
|
|
24
25
|
|
|
25
26
|
// when there's only one argument, that means it's custom
|
|
26
27
|
if (args.length === 1 && _typeof(args[0]) === 'object') {
|
|
@@ -67,6 +68,10 @@ var buildPayloads = function buildPayloads(_ref) {
|
|
|
67
68
|
});
|
|
68
69
|
|
|
69
70
|
if (eventType === 'view') {
|
|
71
|
+
if (isSearchStalled) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
|
|
70
75
|
return hitsChunks.map(function (batch, i) {
|
|
71
76
|
return {
|
|
72
77
|
insightsMethod: 'viewedObjectIDs',
|
|
@@ -137,7 +142,8 @@ export function createSendEventForHits(_ref2) {
|
|
|
137
142
|
widgetType: widgetType,
|
|
138
143
|
index: index,
|
|
139
144
|
methodName: 'sendEvent',
|
|
140
|
-
args: args
|
|
145
|
+
args: args,
|
|
146
|
+
isSearchStalled: instantSearchInstance._isSearchStalled
|
|
141
147
|
});
|
|
142
148
|
payloads.forEach(function (payload) {
|
|
143
149
|
return instantSearchInstance.sendEventToInsights(payload);
|
|
@@ -159,7 +165,8 @@ export function createBindEventForHits(_ref3) {
|
|
|
159
165
|
widgetType: widgetType,
|
|
160
166
|
index: index,
|
|
161
167
|
methodName: 'bindEvent',
|
|
162
|
-
args: args
|
|
168
|
+
args: args,
|
|
169
|
+
isSearchStalled: false
|
|
163
170
|
});
|
|
164
171
|
return payloads.length ? "data-insights-event=".concat(serializePayload(payloads)) : '';
|
|
165
172
|
};
|
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.
|
|
1
|
+
declare const _default: "4.42.0";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.
|
|
1
|
+
export default '4.42.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instantsearch.js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.42.0",
|
|
4
4
|
"description": "InstantSearch.js is a JavaScript library for building performant and instant search experiences with Algolia.",
|
|
5
5
|
"homepage": "https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/",
|
|
6
6
|
"types": "es/index.d.ts",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"scripts/transforms"
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
|
+
"@algolia/events": "^4.0.1",
|
|
56
57
|
"@types/google.maps": "^3.45.3",
|
|
57
58
|
"@types/hogan.js": "^3.0.0",
|
|
58
59
|
"@types/qs": "^6.5.3",
|
|
59
|
-
"algoliasearch-helper": "^3.
|
|
60
|
+
"algoliasearch-helper": "^3.9.0",
|
|
60
61
|
"classnames": "^2.2.5",
|
|
61
|
-
"@algolia/events": "^4.0.1",
|
|
62
62
|
"hogan.js": "^3.0.2",
|
|
63
63
|
"preact": "^10.6.0",
|
|
64
64
|
"qs": "^6.5.1 < 6.10",
|