instantsearch.js 4.54.1 → 4.55.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/cjs/components/Hits/Hits.js +16 -7
- package/cjs/components/InfiniteHits/InfiniteHits.js +13 -2
- package/cjs/connectors/autocomplete/connectAutocomplete.js +1 -1
- package/cjs/connectors/geo-search/connectGeoSearch.js +1 -1
- package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +1 -1
- package/cjs/connectors/hits/connectHits.js +1 -1
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +39 -31
- package/cjs/connectors/menu/connectMenu.js +1 -1
- package/cjs/connectors/numeric-menu/connectNumericMenu.js +1 -1
- package/cjs/connectors/rating-menu/connectRatingMenu.js +7 -3
- package/cjs/connectors/refinement-list/connectRefinementList.js +1 -1
- package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +14 -4
- package/cjs/helpers/insights.js +3 -4
- package/cjs/lib/InstantSearch.js +18 -2
- package/cjs/lib/insights/listener.js +43 -36
- package/cjs/lib/routers/history.js +1 -0
- package/cjs/lib/stateMappings/simple.js +1 -0
- package/cjs/lib/stateMappings/singleIndex.js +1 -0
- package/cjs/lib/utils/createSendEventForFacet.js +12 -2
- package/cjs/lib/utils/createSendEventForHits.js +34 -11
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createInsightsMiddleware.js +135 -33
- package/cjs/middlewares/createMetadataMiddleware.js +17 -5
- package/cjs/middlewares/createRouterMiddleware.js +5 -1
- package/cjs/widgets/hits/hits.js +1 -2
- package/cjs/widgets/infinite-hits/infinite-hits.js +1 -2
- package/dist/instantsearch.development.d.ts +67 -8
- package/dist/instantsearch.development.js +433 -251
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +67 -8
- package/dist/instantsearch.production.min.d.ts +67 -8
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Hits/Hits.d.ts +5 -5
- package/es/components/Hits/Hits.js +15 -5
- package/es/components/InfiniteHits/InfiniteHits.d.ts +3 -2
- package/es/components/InfiniteHits/InfiniteHits.js +13 -2
- package/es/connectors/autocomplete/connectAutocomplete.js +1 -1
- package/es/connectors/geo-search/connectGeoSearch.js +1 -1
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +1 -1
- package/es/connectors/hits/connectHits.js +1 -1
- package/es/connectors/infinite-hits/connectInfiniteHits.js +39 -31
- package/es/connectors/menu/connectMenu.js +1 -1
- package/es/connectors/numeric-menu/connectNumericMenu.js +1 -1
- package/es/connectors/rating-menu/connectRatingMenu.js +7 -3
- package/es/connectors/refinement-list/connectRefinementList.js +1 -1
- package/es/connectors/toggle-refinement/connectToggleRefinement.js +13 -3
- package/es/helpers/insights.d.ts +2 -1
- package/es/helpers/insights.js +3 -3
- package/es/lib/InstantSearch.d.ts +11 -1
- package/es/lib/InstantSearch.js +18 -2
- package/es/lib/insights/listener.d.ts +10 -6
- package/es/lib/insights/listener.js +42 -36
- package/es/lib/routers/history.d.ts +1 -0
- package/es/lib/routers/history.js +1 -0
- package/es/lib/stateMappings/simple.js +1 -0
- package/es/lib/stateMappings/singleIndex.js +1 -0
- package/es/lib/utils/createSendEventForFacet.js +12 -2
- package/es/lib/utils/createSendEventForHits.d.ts +8 -0
- package/es/lib/utils/createSendEventForHits.js +33 -11
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createInsightsMiddleware.d.ts +12 -12
- package/es/middlewares/createInsightsMiddleware.js +136 -34
- package/es/middlewares/createMetadataMiddleware.d.ts +3 -1
- package/es/middlewares/createMetadataMiddleware.js +17 -5
- package/es/middlewares/createRouterMiddleware.js +5 -1
- package/es/types/insights.d.ts +19 -1
- package/es/types/middleware.d.ts +16 -0
- package/es/types/router.d.ts +8 -0
- package/es/widgets/hits/hits.js +2 -3
- package/es/widgets/infinite-hits/infinite-hits.js +2 -3
- package/package.json +6 -6
|
@@ -10,7 +10,7 @@ import type { HighlightProps as HighlightProps_3 } from '@algolia/ui-components-
|
|
|
10
10
|
import type { HoganOptions } from 'hogan.js';
|
|
11
11
|
import type { html } from 'htm/preact';
|
|
12
12
|
import type { InsightsClient as InsightsClient_2 } from 'search-insights';
|
|
13
|
-
import type { InsightsMethodMap } from 'search-insights';
|
|
13
|
+
import type { InsightsMethodMap as InsightsMethodMap_2 } from 'search-insights';
|
|
14
14
|
import type * as Places from 'places.js';
|
|
15
15
|
import type { PlainSearchParameters } from 'algoliasearch-helper';
|
|
16
16
|
import { default as qs_2 } from 'qs';
|
|
@@ -438,6 +438,7 @@ declare type BreadcrumbWidgetParams = {
|
|
|
438
438
|
};
|
|
439
439
|
|
|
440
440
|
declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
|
|
441
|
+
$$type: string;
|
|
441
442
|
/**
|
|
442
443
|
* Transforms a UI state into a title for the page.
|
|
443
444
|
*/
|
|
@@ -901,7 +902,7 @@ declare function createInfiniteHitsSessionStorageCache(): InfiniteHitsCache;
|
|
|
901
902
|
|
|
902
903
|
declare type CreateInsightsMiddleware = typeof createInsightsMiddleware;
|
|
903
904
|
|
|
904
|
-
declare function createInsightsMiddleware<TInsightsClient extends
|
|
905
|
+
declare function createInsightsMiddleware<TInsightsClient extends ProvidedInsightsClient>(props?: InsightsProps<TInsightsClient>): InternalMiddleware;
|
|
905
906
|
|
|
906
907
|
/**
|
|
907
908
|
* Exposes the metadata of mounted widgets in a custom
|
|
@@ -910,7 +911,9 @@ declare function createInsightsMiddleware<TInsightsClient extends null | Insight
|
|
|
910
911
|
* - widget name
|
|
911
912
|
* - connector name
|
|
912
913
|
*/
|
|
913
|
-
declare function createMetadataMiddleware(
|
|
914
|
+
declare function createMetadataMiddleware({ $$internal, }?: {
|
|
915
|
+
$$internal?: boolean;
|
|
916
|
+
}): InternalMiddleware;
|
|
914
917
|
|
|
915
918
|
declare const createRouterMiddleware: <TUiState extends UiState = UiState, TRouteState = TUiState>(props?: RouterProps<TUiState, TRouteState>) => InternalMiddleware<TUiState>;
|
|
916
919
|
|
|
@@ -2313,20 +2316,39 @@ declare type InsightsClientPayload = {
|
|
|
2313
2316
|
positions?: number[];
|
|
2314
2317
|
};
|
|
2315
2318
|
|
|
2316
|
-
declare type
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
+
declare type InsightsClientWithGlobals = InsightsClient & {
|
|
2320
|
+
shouldAddScript?: boolean;
|
|
2321
|
+
version?: string;
|
|
2322
|
+
};
|
|
2323
|
+
|
|
2324
|
+
declare type InsightsEvent<TMethod extends InsightsMethod = InsightsMethod> = InsightsEvent_2<TMethod>;
|
|
2325
|
+
|
|
2326
|
+
/**
|
|
2327
|
+
* The event sent to the insights middleware.
|
|
2328
|
+
*/
|
|
2329
|
+
declare type InsightsEvent_2<TMethod extends InsightsMethod = InsightsMethod> = {
|
|
2330
|
+
insightsMethod?: TMethod;
|
|
2331
|
+
payload: InsightsMethodMap[TMethod][0];
|
|
2319
2332
|
widgetType: string;
|
|
2320
2333
|
eventType: string;
|
|
2334
|
+
eventModifier?: string;
|
|
2321
2335
|
hits?: Hit[];
|
|
2322
2336
|
attribute?: string;
|
|
2323
2337
|
};
|
|
2324
2338
|
|
|
2325
|
-
|
|
2326
|
-
|
|
2339
|
+
/**
|
|
2340
|
+
* Method allowed by the insights middleware.
|
|
2341
|
+
*/
|
|
2342
|
+
declare type InsightsMethod = 'clickedObjectIDsAfterSearch' | 'clickedObjectIDs' | 'clickedFilters' | 'convertedObjectIDsAfterSearch' | 'convertedObjectIDs' | 'convertedFilters' | 'viewedObjectIDs' | 'viewedFilters';
|
|
2343
|
+
|
|
2344
|
+
declare type InsightsMethodMap = InsightsMethodMap_2;
|
|
2345
|
+
|
|
2346
|
+
declare type InsightsProps<TInsightsClient extends ProvidedInsightsClient = ProvidedInsightsClient> = {
|
|
2347
|
+
insightsClient?: TInsightsClient;
|
|
2327
2348
|
insightsInitParams?: {
|
|
2328
2349
|
userHasOptedOut?: boolean;
|
|
2329
2350
|
useCookie?: boolean;
|
|
2351
|
+
anonymousUserToken?: boolean;
|
|
2330
2352
|
cookieDuration?: number;
|
|
2331
2353
|
region?: 'de' | 'us';
|
|
2332
2354
|
};
|
|
@@ -2567,6 +2589,16 @@ declare type InstantSearchOptions<TUiState extends UiState = UiState, TRouteStat
|
|
|
2567
2589
|
* client side persistence. Passing `true` will use the default URL options.
|
|
2568
2590
|
*/
|
|
2569
2591
|
routing?: RouterProps<TUiState, TRouteState> | boolean;
|
|
2592
|
+
/**
|
|
2593
|
+
* Enables the Insights middleware and loads the Insights library
|
|
2594
|
+
* if not already loaded.
|
|
2595
|
+
*
|
|
2596
|
+
* The Insights middleware sends view and click events automatically, and lets
|
|
2597
|
+
* you set up your own events.
|
|
2598
|
+
*
|
|
2599
|
+
* @default false
|
|
2600
|
+
*/
|
|
2601
|
+
insights?: InsightsProps | boolean;
|
|
2570
2602
|
/**
|
|
2571
2603
|
* the instance of search-insights to use for sending insights events inside
|
|
2572
2604
|
* widgets like `hits`.
|
|
@@ -2839,11 +2871,27 @@ declare type MenuWidgetParams = {
|
|
|
2839
2871
|
declare type Middleware = (options: MiddlewareOptions) => AtLeastOne<MiddlewareDefinition>;
|
|
2840
2872
|
|
|
2841
2873
|
declare type MiddlewareDefinition<TUiState extends UiState = UiState> = {
|
|
2874
|
+
/**
|
|
2875
|
+
* string to identify the middleware
|
|
2876
|
+
*/
|
|
2877
|
+
$$type: string;
|
|
2878
|
+
/**
|
|
2879
|
+
* Change handler called on every UiState change
|
|
2880
|
+
*/
|
|
2842
2881
|
onStateChange(options: {
|
|
2843
2882
|
uiState: TUiState;
|
|
2844
2883
|
}): void;
|
|
2884
|
+
/**
|
|
2885
|
+
* Called when the middleware is added to InstantSearch
|
|
2886
|
+
*/
|
|
2845
2887
|
subscribe(): void;
|
|
2888
|
+
/**
|
|
2889
|
+
* Called when InstantSearch is started
|
|
2890
|
+
*/
|
|
2846
2891
|
started(): void;
|
|
2892
|
+
/**
|
|
2893
|
+
* Called when the middleware is removed from InstantSearch
|
|
2894
|
+
*/
|
|
2847
2895
|
unsubscribe(): void;
|
|
2848
2896
|
};
|
|
2849
2897
|
|
|
@@ -2856,6 +2904,7 @@ declare namespace middlewares {
|
|
|
2856
2904
|
createInsightsMiddleware,
|
|
2857
2905
|
InsightsEvent,
|
|
2858
2906
|
InsightsProps,
|
|
2907
|
+
InsightsClientWithGlobals,
|
|
2859
2908
|
CreateInsightsMiddleware,
|
|
2860
2909
|
RouterProps,
|
|
2861
2910
|
createRouterMiddleware,
|
|
@@ -3431,6 +3480,8 @@ declare type PoweredByWidgetParams = {
|
|
|
3431
3480
|
cssClasses?: PoweredByCSSClasses;
|
|
3432
3481
|
};
|
|
3433
3482
|
|
|
3483
|
+
declare type ProvidedInsightsClient = InsightsClient | null | undefined;
|
|
3484
|
+
|
|
3434
3485
|
declare const queryRuleContext: QueryRuleContextWidget;
|
|
3435
3486
|
|
|
3436
3487
|
declare type QueryRuleContextWidget = WidgetFactory<QueryRulesWidgetDescription & {
|
|
@@ -4562,6 +4613,10 @@ declare type Router<TRouteState = UiState> = {
|
|
|
4562
4613
|
* Called when InstantSearch is started.
|
|
4563
4614
|
*/
|
|
4564
4615
|
start?: () => void;
|
|
4616
|
+
/**
|
|
4617
|
+
* Identifier for this router. Used to differentiate between routers.
|
|
4618
|
+
*/
|
|
4619
|
+
$$type?: string;
|
|
4565
4620
|
};
|
|
4566
4621
|
|
|
4567
4622
|
declare type RouterProps<TUiState extends UiState = UiState, TRouteState = TUiState> = {
|
|
@@ -4993,6 +5048,10 @@ declare type StateMapping<TUiState = UiState, TRouteState = TUiState> = {
|
|
|
4993
5048
|
* The format is the output of `stateToRoute`.
|
|
4994
5049
|
*/
|
|
4995
5050
|
routeToState(routeState: TRouteState): TUiState;
|
|
5051
|
+
/**
|
|
5052
|
+
* Identifier for this stateMapping. Used to differentiate between stateMappings.
|
|
5053
|
+
*/
|
|
5054
|
+
$$type?: string;
|
|
4996
5055
|
};
|
|
4997
5056
|
|
|
4998
5057
|
declare namespace stateMappings {
|