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
@@ -1,4 +1,6 @@
1
- export declare type InsightsClientMethod = 'viewedObjectIDs' | 'clickedFilters' | 'clickedObjectIDsAfterSearch' | 'convertedObjectIDsAfterSearch';
1
+ import type { InsightsMethodMap, InsightsClient as _InsightsClient } from 'search-insights';
2
+ export type { Init as InsightsInit, AddAlgoliaAgent as InsightsAddAlgoliaAgent, SetUserToken as InsightsSetUserToken, GetUserToken as InsightsGetUserToken, OnUserTokenChange as InsightsOnUserTokenChange, } from 'search-insights';
3
+ export declare type InsightsClientMethod = keyof InsightsMethodMap;
2
4
  export declare type InsightsClientPayload = {
3
5
  eventName: string;
4
6
  queryID: string;
@@ -6,18 +8,13 @@ export declare type InsightsClientPayload = {
6
8
  objectIDs: string[];
7
9
  positions?: number[];
8
10
  };
9
- export declare type InsightsSetUserToken = (method: 'setUserToken', userToken: string) => void;
10
- export declare type InsightsSendEvent = (method: InsightsClientMethod, payload: InsightsClientPayload) => void;
11
- export declare type InsightsOnUserTokenChange = (method: 'onUserTokenChange', callback?: (userToken: string) => void, options?: {
12
- immediate?: boolean;
13
- }) => void;
14
- export declare type InsightsGetUserToken = (method: 'getUserToken', options?: any, callback?: (error: any, userToken: string) => void) => void;
15
- export declare type InsightsInit = (method: 'init', options: {
16
- appId: string;
17
- apiKey: string;
18
- }) => void;
19
- export declare type InsightsAddAlgoliaAgent = (method: 'addAlgoliaAgent', algoliaAgent: string) => void;
20
- export declare type InsightsClient = InsightsAddAlgoliaAgent & InsightsSendEvent & InsightsOnUserTokenChange & InsightsInit & InsightsSetUserToken & InsightsGetUserToken & {
21
- queue?: Array<[string, any]>;
11
+ declare type QueueItemMap = {
12
+ [MethodName in keyof InsightsMethodMap]: [
13
+ methodName: MethodName,
14
+ ...args: InsightsMethodMap[MethodName]
15
+ ];
16
+ };
17
+ declare type QueueItem = QueueItemMap[keyof QueueItemMap];
18
+ export declare type InsightsClient = _InsightsClient & {
19
+ queue?: QueueItem[];
22
20
  };
23
- export declare type InsightsClientWrapper = (method: InsightsClientMethod, payload: Partial<InsightsClientPayload>) => void;
@@ -1,8 +1,8 @@
1
- import type { Widget, WidgetDescription } from './widget';
1
+ import type { UnknownWidgetParams, Widget, WidgetDescription } from './widget';
2
2
  /**
3
3
  * The function that creates a new widget.
4
4
  */
5
- export declare type WidgetFactory<TWidgetDescription extends WidgetDescription, TConnectorParams, TWidgetParams> = (
5
+ export declare type WidgetFactory<TWidgetDescription extends WidgetDescription, TConnectorParams extends UnknownWidgetParams, TWidgetParams extends UnknownWidgetParams> = (
6
6
  /**
7
7
  * The params of the widget.
8
8
  */
@@ -36,8 +36,9 @@ export declare type DisposeOptions = {
36
36
  };
37
37
  export declare type BuiltinTypes = 'ais.analytics' | 'ais.answers' | 'ais.autocomplete' | 'ais.breadcrumb' | 'ais.clearRefinements' | 'ais.configure' | 'ais.configureRelatedItems' | 'ais.currentRefinements' | 'ais.dynamicWidgets' | 'ais.geoSearch' | 'ais.hierarchicalMenu' | 'ais.hits' | 'ais.hitsPerPage' | 'ais.index' | 'ais.infiniteHits' | 'ais.menu' | 'ais.numericMenu' | 'ais.pagination' | 'ais.places' | 'ais.poweredBy' | 'ais.queryRules' | 'ais.range' | 'ais.rangeSlider' | 'ais.rangeInput' | 'ais.ratingMenu' | 'ais.refinementList' | 'ais.searchBox' | 'ais.relevantSort' | 'ais.sortBy' | 'ais.stats' | 'ais.toggleRefinement' | 'ais.voiceSearch';
38
38
  export declare type BuiltinWidgetTypes = 'ais.analytics' | 'ais.answers' | 'ais.autocomplete' | 'ais.breadcrumb' | 'ais.clearRefinements' | 'ais.configure' | 'ais.configureRelatedItems' | 'ais.currentRefinements' | 'ais.dynamicWidgets' | 'ais.geoSearch' | 'ais.hierarchicalMenu' | 'ais.hits' | 'ais.hitsPerPage' | 'ais.index' | 'ais.infiniteHits' | 'ais.menu' | 'ais.menuSelect' | 'ais.numericMenu' | 'ais.pagination' | 'ais.places' | 'ais.poweredBy' | 'ais.queryRuleCustomData' | 'ais.queryRuleContext' | 'ais.rangeInput' | 'ais.rangeSlider' | 'ais.ratingMenu' | 'ais.refinementList' | 'ais.searchBox' | 'ais.relevantSort' | 'ais.sortBy' | 'ais.stats' | 'ais.toggleRefinement' | 'ais.voiceSearch';
39
+ export declare type UnknownWidgetParams = NonNullable<object>;
39
40
  export declare type WidgetParams = {
40
- widgetParams: NonNullable<unknown>;
41
+ widgetParams?: UnknownWidgetParams;
41
42
  };
42
43
  export declare type WidgetDescription = {
43
44
  $$type: string;
@@ -127,7 +128,6 @@ declare type RequiredRenderStateLifeCycle<TWidgetDescription extends WidgetDescr
127
128
  declare type RenderStateLifeCycle<TWidgetDescription extends WidgetDescription & WidgetParams> = TWidgetDescription extends RequiredKeys<WidgetDescription, 'renderState' | 'indexRenderState'> & WidgetParams ? RequiredRenderStateLifeCycle<TWidgetDescription> : Partial<RequiredRenderStateLifeCycle<TWidgetDescription>>;
128
129
  export declare type Widget<TWidgetDescription extends WidgetDescription & WidgetParams = {
129
130
  $$type: string;
130
- widgetParams: unknown;
131
131
  }> = Expand<RequiredWidgetLifeCycle<TWidgetDescription> & WidgetType<TWidgetDescription> & UiStateLifeCycle<TWidgetDescription> & RenderStateLifeCycle<TWidgetDescription>>;
132
132
  /**
133
133
  * Transforms the given items.
@@ -541,7 +541,7 @@ var index = function index(widgetParams) {
541
541
  localUiState = getLocalWidgetsUiState(localWidgets, {
542
542
  searchParameters: this.getHelper().state,
543
543
  helper: this.getHelper()
544
- });
544
+ }, localUiState);
545
545
  }
546
546
  };
547
547
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instantsearch.js",
3
- "version": "4.31.0",
3
+ "version": "4.33.1",
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",
@@ -55,12 +55,13 @@
55
55
  "@types/google.maps": "^3.45.3",
56
56
  "@types/hogan.js": "^3.0.0",
57
57
  "@types/qs": "^6.5.3",
58
- "algoliasearch-helper": "^3.5.5",
58
+ "algoliasearch-helper": "^3.6.2",
59
59
  "classnames": "^2.2.5",
60
60
  "events": "^1.1.0",
61
61
  "hogan.js": "^3.0.2",
62
62
  "preact": "^10.0.0",
63
- "qs": "^6.5.1 < 6.10"
63
+ "qs": "^6.5.1 < 6.10",
64
+ "search-insights": "^2.0.5"
64
65
  },
65
66
  "devDependencies": {
66
67
  "@algolia/client-search": "4.10.3",
@@ -137,7 +138,6 @@
137
138
  "rollup-plugin-replace": "2.2.0",
138
139
  "rollup-plugin-uglify": "6.0.4",
139
140
  "scriptjs": "2.5.9",
140
- "search-insights": "1.7.2",
141
141
  "semver": "6.3.0",
142
142
  "shelljs": "0.8.3",
143
143
  "shipjs": "0.21.0",
@@ -150,7 +150,7 @@
150
150
  "bundlesize": [
151
151
  {
152
152
  "path": "./dist/instantsearch.production.min.js",
153
- "maxSize": "69 kB"
153
+ "maxSize": "69.25 kB"
154
154
  },
155
155
  {
156
156
  "path": "./dist/instantsearch.development.js",