instantsearch.js 4.31.0 → 4.33.1

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/cjs/connectors/powered-by/connectPoweredBy.js +13 -4
  3. package/cjs/lib/InstantSearch.js +4 -2
  4. package/cjs/lib/infiniteHitsCache/sessionStorage.js +16 -12
  5. package/cjs/lib/insights/client.js +6 -1
  6. package/cjs/lib/routers/history.js +89 -42
  7. package/cjs/lib/utils/detect-insights-client.js +10 -1
  8. package/cjs/lib/utils/getWidgetAttribute.js +18 -8
  9. package/cjs/lib/utils/index.js +10 -1
  10. package/cjs/lib/utils/safelyRunOnBrowser.js +30 -0
  11. package/cjs/lib/version.js +1 -1
  12. package/cjs/lib/voiceSearchHelper/index.js +5 -0
  13. package/cjs/middlewares/createMetadataMiddleware.js +13 -5
  14. package/cjs/widgets/index/index.js +1 -1
  15. package/dist/instantsearch.development.d.ts +32 -26
  16. package/dist/instantsearch.development.js +213 -84
  17. package/dist/instantsearch.development.js.map +1 -1
  18. package/dist/instantsearch.development.min.d.ts +32 -26
  19. package/dist/instantsearch.production.d.ts +32 -26
  20. package/dist/instantsearch.production.min.d.ts +32 -26
  21. package/dist/instantsearch.production.min.js +2 -2
  22. package/dist/instantsearch.production.min.js.map +1 -1
  23. package/es/connectors/powered-by/connectPoweredBy.js +14 -5
  24. package/es/lib/InstantSearch.js +4 -2
  25. package/es/lib/infiniteHitsCache/sessionStorage.js +17 -14
  26. package/es/lib/insights/client.js +6 -1
  27. package/es/lib/insights/listener.d.ts +2 -2
  28. package/es/lib/routers/history.d.ts +13 -2
  29. package/es/lib/routers/history.js +88 -42
  30. package/es/lib/utils/detect-insights-client.js +9 -1
  31. package/es/lib/utils/getWidgetAttribute.js +19 -9
  32. package/es/lib/utils/index.d.ts +1 -0
  33. package/es/lib/utils/index.js +2 -1
  34. package/es/lib/utils/safelyRunOnBrowser.d.ts +14 -0
  35. package/es/lib/utils/safelyRunOnBrowser.js +23 -0
  36. package/es/lib/version.d.ts +1 -1
  37. package/es/lib/version.js +1 -1
  38. package/es/lib/voiceSearchHelper/index.js +5 -0
  39. package/es/middlewares/createMetadataMiddleware.js +13 -5
  40. package/es/types/connector.d.ts +2 -2
  41. package/es/types/insights.d.ts +12 -15
  42. package/es/types/widget-factory.d.ts +2 -2
  43. package/es/types/widget.d.ts +2 -2
  44. package/es/widgets/index/index.js +1 -1
  45. package/package.json +5 -5
@@ -5,6 +5,8 @@ import type algoliasearch from 'algoliasearch/lite';
5
5
  import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
6
6
  import type * as ClientSearch from '@algolia/client-search';
7
7
  import EventEmitter from 'events';
8
+ import type { InsightsClient as InsightsClient_2 } from 'search-insights';
9
+ import type { InsightsMethodMap } from 'search-insights';
8
10
  import type * as Places from 'places.js';
9
11
  import type { PlainSearchParameters } from 'algoliasearch-helper';
10
12
  import { default as qs_2 } from 'qs';
@@ -453,13 +455,23 @@ declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
453
455
  * It should be symmetrical to `createURL`.
454
456
  */
455
457
  private readonly parseURL;
458
+ /**
459
+ * Returns the location to store in the history.
460
+ * @default () => window.location
461
+ */
462
+ private readonly getLocation;
456
463
  private writeTimer?;
457
464
  private _onPopState;
465
+ /**
466
+ * Indicates if history.pushState should be executed.
467
+ * It needs to avoid pushing state to history in case of back/forward in browser
468
+ */
469
+ private shouldPushState;
458
470
  /**
459
471
  * Initializes a new storage provider that syncs the search state to the URL
460
472
  * using web APIs (`window.location.pushState` and `onpopstate` event).
461
473
  */
462
- constructor({ windowTitle, writeDelay, createURL, parseURL, }: BrowserHistoryArgs<TRouteState>);
474
+ constructor({ windowTitle, writeDelay, createURL, parseURL, getLocation, }: BrowserHistoryArgs<TRouteState>);
463
475
  /**
464
476
  * Reads the URL and returns a syncable UI search state.
465
477
  */
@@ -492,6 +504,7 @@ declare type BrowserHistoryArgs<TRouteState> = {
492
504
  writeDelay: number;
493
505
  createURL: CreateURL_2<TRouteState>;
494
506
  parseURL: ParseURL<TRouteState>;
507
+ getLocation(): Location;
495
508
  };
496
509
 
497
510
  declare type BuiltInBindEventForHits = (eventType: string, hits: Hit | Hits, eventName?: string) => string;
@@ -734,7 +747,7 @@ declare const connectNumericMenu: NumericMenuConnector;
734
747
  * The connector handles the business logic and exposes
735
748
  * a simplified API to the rendering function.
736
749
  */
737
- declare type Connector<TWidgetDescription extends WidgetDescription, TConnectorParams> = <TWidgetParams>(
750
+ declare type Connector<TWidgetDescription extends WidgetDescription, TConnectorParams extends UnknownWidgetParams> = <TWidgetParams extends UnknownWidgetParams>(
738
751
  /**
739
752
  * The render function.
740
753
  */
@@ -1721,7 +1734,7 @@ declare type HighlightOptions = {
1721
1734
  }>;
1722
1735
  };
1723
1736
 
1724
- declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
1737
+ declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
1725
1738
 
1726
1739
  declare type Hit = {
1727
1740
  __position: number;
@@ -2191,13 +2204,11 @@ declare type InitOptions = SharedRenderOptions & {
2191
2204
  */
2192
2205
  declare function insights(method: InsightsClientMethod, payload: Partial<InsightsClientPayload>): string;
2193
2206
 
2194
- declare type InsightsAddAlgoliaAgent = (method: 'addAlgoliaAgent', algoliaAgent: string) => void;
2195
-
2196
- declare type InsightsClient = InsightsAddAlgoliaAgent & InsightsSendEvent & InsightsOnUserTokenChange & InsightsInit & InsightsSetUserToken & InsightsGetUserToken & {
2197
- queue?: Array<[string, any]>;
2207
+ declare type InsightsClient = InsightsClient_2 & {
2208
+ queue?: QueueItem[];
2198
2209
  };
2199
2210
 
2200
- declare type InsightsClientMethod = 'viewedObjectIDs' | 'clickedFilters' | 'clickedObjectIDsAfterSearch' | 'convertedObjectIDsAfterSearch';
2211
+ declare type InsightsClientMethod = keyof InsightsMethodMap;
2201
2212
 
2202
2213
  declare type InsightsClientPayload = {
2203
2214
  eventName: string;
@@ -2216,17 +2227,6 @@ declare type InsightsEvent = {
2216
2227
  attribute?: string;
2217
2228
  };
2218
2229
 
2219
- declare type InsightsGetUserToken = (method: 'getUserToken', options?: any, callback?: (error: any, userToken: string) => void) => void;
2220
-
2221
- declare type InsightsInit = (method: 'init', options: {
2222
- appId: string;
2223
- apiKey: string;
2224
- }) => void;
2225
-
2226
- declare type InsightsOnUserTokenChange = (method: 'onUserTokenChange', callback?: (userToken: string) => void, options?: {
2227
- immediate?: boolean;
2228
- }) => void;
2229
-
2230
2230
  declare type InsightsProps = {
2231
2231
  insightsClient: null | InsightsClient;
2232
2232
  insightsInitParams?: {
@@ -2238,10 +2238,6 @@ declare type InsightsProps = {
2238
2238
  onEvent?: (event: InsightsEvent, insightsClient: null | InsightsClient) => void;
2239
2239
  };
2240
2240
 
2241
- declare type InsightsSendEvent = (method: InsightsClientMethod, payload: InsightsClientPayload) => void;
2242
-
2243
- declare type InsightsSetUserToken = (method: 'setUserToken', userToken: string) => void;
2244
-
2245
2241
  /**
2246
2242
  * The actual implementation of the InstantSearch. This is
2247
2243
  * created using the `instantsearch` factory function.
@@ -3343,6 +3339,15 @@ declare type QueryRulesWidgetDescription = {
3343
3339
  };
3344
3340
  };
3345
3341
 
3342
+ declare type QueueItem = QueueItemMap[keyof QueueItemMap];
3343
+
3344
+ declare type QueueItemMap = {
3345
+ [MethodName in keyof InsightsMethodMap]: [
3346
+ methodName: MethodName,
3347
+ ...args: InsightsMethodMap[MethodName]
3348
+ ];
3349
+ };
3350
+
3346
3351
  declare type Range_2 = {
3347
3352
  min: RangeMin;
3348
3353
  max: RangeMax;
@@ -5005,6 +5010,8 @@ declare type UiState = {
5005
5010
 
5006
5011
  declare type UiStateLifeCycle<TWidgetDescription extends WidgetDescription> = TWidgetDescription extends RequiredKeys<WidgetDescription, 'indexUiState'> ? RequiredUiStateLifeCycle<TWidgetDescription> : Partial<RequiredUiStateLifeCycle<TWidgetDescription>>;
5007
5012
 
5013
+ declare type UnknownWidgetParams = NonNullable<object>;
5014
+
5008
5015
  /**
5009
5016
  * The called function when unmounting a widget.
5010
5017
  */
@@ -5102,7 +5109,6 @@ declare type VoiceSearchWidgetParams = {
5102
5109
 
5103
5110
  declare type Widget<TWidgetDescription extends WidgetDescription & WidgetParams = {
5104
5111
  $$type: string;
5105
- widgetParams: unknown;
5106
5112
  }> = Expand<RequiredWidgetLifeCycle<TWidgetDescription> & WidgetType<TWidgetDescription> & UiStateLifeCycle<TWidgetDescription> & RenderStateLifeCycle<TWidgetDescription>>;
5107
5113
 
5108
5114
  declare type WidgetDescription = {
@@ -5116,7 +5122,7 @@ declare type WidgetDescription = {
5116
5122
  /**
5117
5123
  * The function that creates a new widget.
5118
5124
  */
5119
- declare type WidgetFactory<TWidgetDescription extends WidgetDescription, TConnectorParams, TWidgetParams> = (
5125
+ declare type WidgetFactory<TWidgetDescription extends WidgetDescription, TConnectorParams extends UnknownWidgetParams, TWidgetParams extends UnknownWidgetParams> = (
5120
5126
  /**
5121
5127
  * The params of the widget.
5122
5128
  */
@@ -5125,7 +5131,7 @@ widgetParams: TWidgetParams & TConnectorParams) => Widget<TWidgetDescription & {
5125
5131
  }>;
5126
5132
 
5127
5133
  declare type WidgetParams = {
5128
- widgetParams: NonNullable<unknown>;
5134
+ widgetParams?: UnknownWidgetParams;
5129
5135
  };
5130
5136
 
5131
5137
  declare type WidgetRenderState<TWidgetRenderState, TWidgetParams> = TWidgetRenderState & {
@@ -5,6 +5,8 @@ import type algoliasearch from 'algoliasearch/lite';
5
5
  import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
6
6
  import type * as ClientSearch from '@algolia/client-search';
7
7
  import EventEmitter from 'events';
8
+ import type { InsightsClient as InsightsClient_2 } from 'search-insights';
9
+ import type { InsightsMethodMap } from 'search-insights';
8
10
  import type * as Places from 'places.js';
9
11
  import type { PlainSearchParameters } from 'algoliasearch-helper';
10
12
  import { default as qs_2 } from 'qs';
@@ -453,13 +455,23 @@ declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
453
455
  * It should be symmetrical to `createURL`.
454
456
  */
455
457
  private readonly parseURL;
458
+ /**
459
+ * Returns the location to store in the history.
460
+ * @default () => window.location
461
+ */
462
+ private readonly getLocation;
456
463
  private writeTimer?;
457
464
  private _onPopState;
465
+ /**
466
+ * Indicates if history.pushState should be executed.
467
+ * It needs to avoid pushing state to history in case of back/forward in browser
468
+ */
469
+ private shouldPushState;
458
470
  /**
459
471
  * Initializes a new storage provider that syncs the search state to the URL
460
472
  * using web APIs (`window.location.pushState` and `onpopstate` event).
461
473
  */
462
- constructor({ windowTitle, writeDelay, createURL, parseURL, }: BrowserHistoryArgs<TRouteState>);
474
+ constructor({ windowTitle, writeDelay, createURL, parseURL, getLocation, }: BrowserHistoryArgs<TRouteState>);
463
475
  /**
464
476
  * Reads the URL and returns a syncable UI search state.
465
477
  */
@@ -492,6 +504,7 @@ declare type BrowserHistoryArgs<TRouteState> = {
492
504
  writeDelay: number;
493
505
  createURL: CreateURL_2<TRouteState>;
494
506
  parseURL: ParseURL<TRouteState>;
507
+ getLocation(): Location;
495
508
  };
496
509
 
497
510
  declare type BuiltInBindEventForHits = (eventType: string, hits: Hit | Hits, eventName?: string) => string;
@@ -734,7 +747,7 @@ declare const connectNumericMenu: NumericMenuConnector;
734
747
  * The connector handles the business logic and exposes
735
748
  * a simplified API to the rendering function.
736
749
  */
737
- declare type Connector<TWidgetDescription extends WidgetDescription, TConnectorParams> = <TWidgetParams>(
750
+ declare type Connector<TWidgetDescription extends WidgetDescription, TConnectorParams extends UnknownWidgetParams> = <TWidgetParams extends UnknownWidgetParams>(
738
751
  /**
739
752
  * The render function.
740
753
  */
@@ -1721,7 +1734,7 @@ declare type HighlightOptions = {
1721
1734
  }>;
1722
1735
  };
1723
1736
 
1724
- declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
1737
+ declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
1725
1738
 
1726
1739
  declare type Hit = {
1727
1740
  __position: number;
@@ -2191,13 +2204,11 @@ declare type InitOptions = SharedRenderOptions & {
2191
2204
  */
2192
2205
  declare function insights(method: InsightsClientMethod, payload: Partial<InsightsClientPayload>): string;
2193
2206
 
2194
- declare type InsightsAddAlgoliaAgent = (method: 'addAlgoliaAgent', algoliaAgent: string) => void;
2195
-
2196
- declare type InsightsClient = InsightsAddAlgoliaAgent & InsightsSendEvent & InsightsOnUserTokenChange & InsightsInit & InsightsSetUserToken & InsightsGetUserToken & {
2197
- queue?: Array<[string, any]>;
2207
+ declare type InsightsClient = InsightsClient_2 & {
2208
+ queue?: QueueItem[];
2198
2209
  };
2199
2210
 
2200
- declare type InsightsClientMethod = 'viewedObjectIDs' | 'clickedFilters' | 'clickedObjectIDsAfterSearch' | 'convertedObjectIDsAfterSearch';
2211
+ declare type InsightsClientMethod = keyof InsightsMethodMap;
2201
2212
 
2202
2213
  declare type InsightsClientPayload = {
2203
2214
  eventName: string;
@@ -2216,17 +2227,6 @@ declare type InsightsEvent = {
2216
2227
  attribute?: string;
2217
2228
  };
2218
2229
 
2219
- declare type InsightsGetUserToken = (method: 'getUserToken', options?: any, callback?: (error: any, userToken: string) => void) => void;
2220
-
2221
- declare type InsightsInit = (method: 'init', options: {
2222
- appId: string;
2223
- apiKey: string;
2224
- }) => void;
2225
-
2226
- declare type InsightsOnUserTokenChange = (method: 'onUserTokenChange', callback?: (userToken: string) => void, options?: {
2227
- immediate?: boolean;
2228
- }) => void;
2229
-
2230
2230
  declare type InsightsProps = {
2231
2231
  insightsClient: null | InsightsClient;
2232
2232
  insightsInitParams?: {
@@ -2238,10 +2238,6 @@ declare type InsightsProps = {
2238
2238
  onEvent?: (event: InsightsEvent, insightsClient: null | InsightsClient) => void;
2239
2239
  };
2240
2240
 
2241
- declare type InsightsSendEvent = (method: InsightsClientMethod, payload: InsightsClientPayload) => void;
2242
-
2243
- declare type InsightsSetUserToken = (method: 'setUserToken', userToken: string) => void;
2244
-
2245
2241
  /**
2246
2242
  * The actual implementation of the InstantSearch. This is
2247
2243
  * created using the `instantsearch` factory function.
@@ -3343,6 +3339,15 @@ declare type QueryRulesWidgetDescription = {
3343
3339
  };
3344
3340
  };
3345
3341
 
3342
+ declare type QueueItem = QueueItemMap[keyof QueueItemMap];
3343
+
3344
+ declare type QueueItemMap = {
3345
+ [MethodName in keyof InsightsMethodMap]: [
3346
+ methodName: MethodName,
3347
+ ...args: InsightsMethodMap[MethodName]
3348
+ ];
3349
+ };
3350
+
3346
3351
  declare type Range_2 = {
3347
3352
  min: RangeMin;
3348
3353
  max: RangeMax;
@@ -5005,6 +5010,8 @@ declare type UiState = {
5005
5010
 
5006
5011
  declare type UiStateLifeCycle<TWidgetDescription extends WidgetDescription> = TWidgetDescription extends RequiredKeys<WidgetDescription, 'indexUiState'> ? RequiredUiStateLifeCycle<TWidgetDescription> : Partial<RequiredUiStateLifeCycle<TWidgetDescription>>;
5007
5012
 
5013
+ declare type UnknownWidgetParams = NonNullable<object>;
5014
+
5008
5015
  /**
5009
5016
  * The called function when unmounting a widget.
5010
5017
  */
@@ -5102,7 +5109,6 @@ declare type VoiceSearchWidgetParams = {
5102
5109
 
5103
5110
  declare type Widget<TWidgetDescription extends WidgetDescription & WidgetParams = {
5104
5111
  $$type: string;
5105
- widgetParams: unknown;
5106
5112
  }> = Expand<RequiredWidgetLifeCycle<TWidgetDescription> & WidgetType<TWidgetDescription> & UiStateLifeCycle<TWidgetDescription> & RenderStateLifeCycle<TWidgetDescription>>;
5107
5113
 
5108
5114
  declare type WidgetDescription = {
@@ -5116,7 +5122,7 @@ declare type WidgetDescription = {
5116
5122
  /**
5117
5123
  * The function that creates a new widget.
5118
5124
  */
5119
- declare type WidgetFactory<TWidgetDescription extends WidgetDescription, TConnectorParams, TWidgetParams> = (
5125
+ declare type WidgetFactory<TWidgetDescription extends WidgetDescription, TConnectorParams extends UnknownWidgetParams, TWidgetParams extends UnknownWidgetParams> = (
5120
5126
  /**
5121
5127
  * The params of the widget.
5122
5128
  */
@@ -5125,7 +5131,7 @@ widgetParams: TWidgetParams & TConnectorParams) => Widget<TWidgetDescription & {
5125
5131
  }>;
5126
5132
 
5127
5133
  declare type WidgetParams = {
5128
- widgetParams: NonNullable<unknown>;
5134
+ widgetParams?: UnknownWidgetParams;
5129
5135
  };
5130
5136
 
5131
5137
  declare type WidgetRenderState<TWidgetRenderState, TWidgetParams> = TWidgetRenderState & {
@@ -5,6 +5,8 @@ import type algoliasearch from 'algoliasearch/lite';
5
5
  import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
6
6
  import type * as ClientSearch from '@algolia/client-search';
7
7
  import EventEmitter from 'events';
8
+ import type { InsightsClient as InsightsClient_2 } from 'search-insights';
9
+ import type { InsightsMethodMap } from 'search-insights';
8
10
  import type * as Places from 'places.js';
9
11
  import type { PlainSearchParameters } from 'algoliasearch-helper';
10
12
  import { default as qs_2 } from 'qs';
@@ -453,13 +455,23 @@ declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
453
455
  * It should be symmetrical to `createURL`.
454
456
  */
455
457
  private readonly parseURL;
458
+ /**
459
+ * Returns the location to store in the history.
460
+ * @default () => window.location
461
+ */
462
+ private readonly getLocation;
456
463
  private writeTimer?;
457
464
  private _onPopState;
465
+ /**
466
+ * Indicates if history.pushState should be executed.
467
+ * It needs to avoid pushing state to history in case of back/forward in browser
468
+ */
469
+ private shouldPushState;
458
470
  /**
459
471
  * Initializes a new storage provider that syncs the search state to the URL
460
472
  * using web APIs (`window.location.pushState` and `onpopstate` event).
461
473
  */
462
- constructor({ windowTitle, writeDelay, createURL, parseURL, }: BrowserHistoryArgs<TRouteState>);
474
+ constructor({ windowTitle, writeDelay, createURL, parseURL, getLocation, }: BrowserHistoryArgs<TRouteState>);
463
475
  /**
464
476
  * Reads the URL and returns a syncable UI search state.
465
477
  */
@@ -492,6 +504,7 @@ declare type BrowserHistoryArgs<TRouteState> = {
492
504
  writeDelay: number;
493
505
  createURL: CreateURL_2<TRouteState>;
494
506
  parseURL: ParseURL<TRouteState>;
507
+ getLocation(): Location;
495
508
  };
496
509
 
497
510
  declare type BuiltInBindEventForHits = (eventType: string, hits: Hit | Hits, eventName?: string) => string;
@@ -734,7 +747,7 @@ declare const connectNumericMenu: NumericMenuConnector;
734
747
  * The connector handles the business logic and exposes
735
748
  * a simplified API to the rendering function.
736
749
  */
737
- declare type Connector<TWidgetDescription extends WidgetDescription, TConnectorParams> = <TWidgetParams>(
750
+ declare type Connector<TWidgetDescription extends WidgetDescription, TConnectorParams extends UnknownWidgetParams> = <TWidgetParams extends UnknownWidgetParams>(
738
751
  /**
739
752
  * The render function.
740
753
  */
@@ -1721,7 +1734,7 @@ declare type HighlightOptions = {
1721
1734
  }>;
1722
1735
  };
1723
1736
 
1724
- declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
1737
+ declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
1725
1738
 
1726
1739
  declare type Hit = {
1727
1740
  __position: number;
@@ -2191,13 +2204,11 @@ declare type InitOptions = SharedRenderOptions & {
2191
2204
  */
2192
2205
  declare function insights(method: InsightsClientMethod, payload: Partial<InsightsClientPayload>): string;
2193
2206
 
2194
- declare type InsightsAddAlgoliaAgent = (method: 'addAlgoliaAgent', algoliaAgent: string) => void;
2195
-
2196
- declare type InsightsClient = InsightsAddAlgoliaAgent & InsightsSendEvent & InsightsOnUserTokenChange & InsightsInit & InsightsSetUserToken & InsightsGetUserToken & {
2197
- queue?: Array<[string, any]>;
2207
+ declare type InsightsClient = InsightsClient_2 & {
2208
+ queue?: QueueItem[];
2198
2209
  };
2199
2210
 
2200
- declare type InsightsClientMethod = 'viewedObjectIDs' | 'clickedFilters' | 'clickedObjectIDsAfterSearch' | 'convertedObjectIDsAfterSearch';
2211
+ declare type InsightsClientMethod = keyof InsightsMethodMap;
2201
2212
 
2202
2213
  declare type InsightsClientPayload = {
2203
2214
  eventName: string;
@@ -2216,17 +2227,6 @@ declare type InsightsEvent = {
2216
2227
  attribute?: string;
2217
2228
  };
2218
2229
 
2219
- declare type InsightsGetUserToken = (method: 'getUserToken', options?: any, callback?: (error: any, userToken: string) => void) => void;
2220
-
2221
- declare type InsightsInit = (method: 'init', options: {
2222
- appId: string;
2223
- apiKey: string;
2224
- }) => void;
2225
-
2226
- declare type InsightsOnUserTokenChange = (method: 'onUserTokenChange', callback?: (userToken: string) => void, options?: {
2227
- immediate?: boolean;
2228
- }) => void;
2229
-
2230
2230
  declare type InsightsProps = {
2231
2231
  insightsClient: null | InsightsClient;
2232
2232
  insightsInitParams?: {
@@ -2238,10 +2238,6 @@ declare type InsightsProps = {
2238
2238
  onEvent?: (event: InsightsEvent, insightsClient: null | InsightsClient) => void;
2239
2239
  };
2240
2240
 
2241
- declare type InsightsSendEvent = (method: InsightsClientMethod, payload: InsightsClientPayload) => void;
2242
-
2243
- declare type InsightsSetUserToken = (method: 'setUserToken', userToken: string) => void;
2244
-
2245
2241
  /**
2246
2242
  * The actual implementation of the InstantSearch. This is
2247
2243
  * created using the `instantsearch` factory function.
@@ -3343,6 +3339,15 @@ declare type QueryRulesWidgetDescription = {
3343
3339
  };
3344
3340
  };
3345
3341
 
3342
+ declare type QueueItem = QueueItemMap[keyof QueueItemMap];
3343
+
3344
+ declare type QueueItemMap = {
3345
+ [MethodName in keyof InsightsMethodMap]: [
3346
+ methodName: MethodName,
3347
+ ...args: InsightsMethodMap[MethodName]
3348
+ ];
3349
+ };
3350
+
3346
3351
  declare type Range_2 = {
3347
3352
  min: RangeMin;
3348
3353
  max: RangeMax;
@@ -5005,6 +5010,8 @@ declare type UiState = {
5005
5010
 
5006
5011
  declare type UiStateLifeCycle<TWidgetDescription extends WidgetDescription> = TWidgetDescription extends RequiredKeys<WidgetDescription, 'indexUiState'> ? RequiredUiStateLifeCycle<TWidgetDescription> : Partial<RequiredUiStateLifeCycle<TWidgetDescription>>;
5007
5012
 
5013
+ declare type UnknownWidgetParams = NonNullable<object>;
5014
+
5008
5015
  /**
5009
5016
  * The called function when unmounting a widget.
5010
5017
  */
@@ -5102,7 +5109,6 @@ declare type VoiceSearchWidgetParams = {
5102
5109
 
5103
5110
  declare type Widget<TWidgetDescription extends WidgetDescription & WidgetParams = {
5104
5111
  $$type: string;
5105
- widgetParams: unknown;
5106
5112
  }> = Expand<RequiredWidgetLifeCycle<TWidgetDescription> & WidgetType<TWidgetDescription> & UiStateLifeCycle<TWidgetDescription> & RenderStateLifeCycle<TWidgetDescription>>;
5107
5113
 
5108
5114
  declare type WidgetDescription = {
@@ -5116,7 +5122,7 @@ declare type WidgetDescription = {
5116
5122
  /**
5117
5123
  * The function that creates a new widget.
5118
5124
  */
5119
- declare type WidgetFactory<TWidgetDescription extends WidgetDescription, TConnectorParams, TWidgetParams> = (
5125
+ declare type WidgetFactory<TWidgetDescription extends WidgetDescription, TConnectorParams extends UnknownWidgetParams, TWidgetParams extends UnknownWidgetParams> = (
5120
5126
  /**
5121
5127
  * The params of the widget.
5122
5128
  */
@@ -5125,7 +5131,7 @@ widgetParams: TWidgetParams & TConnectorParams) => Widget<TWidgetDescription & {
5125
5131
  }>;
5126
5132
 
5127
5133
  declare type WidgetParams = {
5128
- widgetParams: NonNullable<unknown>;
5134
+ widgetParams?: UnknownWidgetParams;
5129
5135
  };
5130
5136
 
5131
5137
  declare type WidgetRenderState<TWidgetRenderState, TWidgetParams> = TWidgetRenderState & {