1
- import { Expand , InstantSearchOptions , UiState } from './types' ;
2
- import InstantSearch from './lib/InstantSearch' ;
1
+ import { Expand , UiState } from './types' ;
2
+ import InstantSearch , { InstantSearchOptions } from './lib/InstantSearch' ;
3
3
import version from './lib/version' ;
4
4
import {
5
5
snippet ,
@@ -10,22 +10,73 @@ import {
10
10
getInsightsAnonymousUserToken ,
11
11
} from './helpers' ;
12
12
import { createInfiniteHitsSessionStorageCache } from './lib/infiniteHitsCache' ;
13
+ import { deprecate } from './lib/utils' ;
13
14
14
- const instantsearch = <
15
- TUiState = Record < string , unknown > ,
16
- TRouteState = TUiState
17
- > (
18
- options : InstantSearchOptions < Expand < UiState & TUiState > , TRouteState >
19
- ) => new InstantSearch ( options ) ;
15
+ type InstantSearchModule = {
16
+ < TUiState = Record < string , unknown > , TRouteState = TUiState > (
17
+ options : InstantSearchOptions < Expand < UiState & TUiState > , TRouteState >
18
+ ) : InstantSearch < Expand < UiState & TUiState > , TRouteState > ;
19
+ version : string ;
20
+
21
+ // @major remove these in favour of the exports
22
+ /** @deprecated */
23
+ createInfiniteHitsSessionStorageCache : typeof createInfiniteHitsSessionStorageCache ;
24
+ /** @deprecated */
25
+ highlight : typeof highlight ;
26
+ /** @deprecated */
27
+ reverseHighlight : typeof reverseHighlight ;
28
+ /** @deprecated */
29
+ snippet : typeof snippet ;
30
+ /** @deprecated */
31
+ reverseSnippet : typeof reverseSnippet ;
32
+ /** @deprecated */
33
+ insights : typeof insights ;
34
+ /** @deprecated */
35
+ getInsightsAnonymousUserToken : typeof getInsightsAnonymousUserToken ;
36
+ } ;
37
+
38
+ /**
39
+ * InstantSearch is the main component of InstantSearch.js. This object
40
+ * manages the widget and lets you add new ones.
41
+ *
42
+ * Two parameters are required to get you started with InstantSearch.js:
43
+ * - `indexName`: the main index that you will use for your new search UI
44
+ * - `searchClient`: the search client to plug to InstantSearch.js
45
+ *
46
+ * The [search client provided by Algolia](algolia.com/doc/api-client/getting-started/what-is-the-api-client/javascript/)
47
+ * needs an `appId` and an `apiKey`. Those parameters can be found in your
48
+ * [Algolia dashboard](https://www.algolia.com/api-keys).
49
+ *
50
+ * If you want to get up and running quickly with InstantSearch.js, have a
51
+ * look at the [getting started](https://www.algolia.com/doc/guides/building-search-ui/getting-started/js/).
52
+ */
53
+ const instantsearch : InstantSearchModule = options =>
54
+ new InstantSearch ( options ) ;
20
55
21
56
instantsearch . version = version ;
22
- instantsearch . snippet = snippet ;
23
- instantsearch . reverseSnippet = reverseSnippet ;
24
- instantsearch . highlight = highlight ;
25
- instantsearch . reverseHighlight = reverseHighlight ;
57
+
58
+ instantsearch . createInfiniteHitsSessionStorageCache = deprecate (
59
+ createInfiniteHitsSessionStorageCache ,
60
+ "import { createInfiniteHitsSessionStorageCache } from 'instantsearch.js/es/helpers'"
61
+ ) ;
62
+ instantsearch . highlight = deprecate (
63
+ highlight ,
64
+ "import { highlight } from 'instantsearch.js/es/helpers'"
65
+ ) ;
66
+ instantsearch . reverseHighlight = deprecate (
67
+ reverseHighlight ,
68
+ "import { reverseHighlight } from 'instantsearch.js/es/helpers'"
69
+ ) ;
70
+ instantsearch . snippet = deprecate (
71
+ snippet ,
72
+ "import { snippet } from 'instantsearch.js/es/helpers'"
73
+ ) ;
74
+ instantsearch . reverseSnippet = deprecate (
75
+ reverseSnippet ,
76
+ "import { reverseSnippet } from 'instantsearch.js/es/helpers'"
77
+ ) ;
26
78
instantsearch . insights = insights ;
27
79
instantsearch . getInsightsAnonymousUserToken = getInsightsAnonymousUserToken ;
28
- instantsearch . createInfiniteHitsSessionStorageCache = createInfiniteHitsSessionStorageCache ;
29
80
30
81
Object . defineProperty ( instantsearch , 'widgets' , {
31
82
get ( ) {
0 commit comments