instantsearch.js 4.57.0 → 4.58.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/README.md +0 -1
- package/cjs/lib/InstantSearch.js +18 -2
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createInsightsMiddleware.js +1 -1
- package/cjs/widgets/index/index.js +16 -7
- package/dist/instantsearch.development.d.ts +13 -0
- package/dist/instantsearch.development.js +49 -24
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +13 -0
- package/dist/instantsearch.production.min.d.ts +13 -0
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/InternalHighlight/InternalHighlight.d.ts +1 -1
- package/es/lib/InstantSearch.d.ts +14 -0
- package/es/lib/InstantSearch.js +16 -1
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createInsightsMiddleware.js +1 -1
- package/es/widgets/index/index.js +16 -7
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const InternalHighlight: (
|
|
1
|
+
export declare const InternalHighlight: (userProps: import("@algolia/ui-components-highlight-vdom").HighlightProps) => JSX.Element;
|
|
@@ -96,8 +96,21 @@ export type InstantSearchOptions<TUiState extends UiState = UiState, TRouteState
|
|
|
96
96
|
* @deprecated This property will be still supported in 4.x releases, but not further. It is replaced by the `insights` middleware. For more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/
|
|
97
97
|
*/
|
|
98
98
|
insightsClient?: AlgoliaInsightsClient;
|
|
99
|
+
future?: {
|
|
100
|
+
/**
|
|
101
|
+
* Changes the way `dispose` is used in InstantSearch lifecycle.
|
|
102
|
+
*
|
|
103
|
+
* If `false` (by default), each widget unmounting will remove its state as well, even if there are multiple widgets reading that UI State.
|
|
104
|
+
*
|
|
105
|
+
* If `true`, each widget unmounting will only remove its own state if it's the last of its type. This allows for dynamically adding and removing widgets without losing their state.
|
|
106
|
+
*
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
preserveSharedStateOnUnmount?: boolean;
|
|
110
|
+
};
|
|
99
111
|
};
|
|
100
112
|
export type InstantSearchStatus = 'idle' | 'loading' | 'stalled' | 'error';
|
|
113
|
+
export declare const INSTANTSEARCH_FUTURE_DEFAULTS: Required<InstantSearchOptions['future']>;
|
|
101
114
|
/**
|
|
102
115
|
* The actual implementation of the InstantSearch. This is
|
|
103
116
|
* created using the `instantsearch` factory function.
|
|
@@ -108,6 +121,7 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
108
121
|
indexName: string;
|
|
109
122
|
insightsClient: AlgoliaInsightsClient | null;
|
|
110
123
|
onStateChange: InstantSearchOptions<TUiState>['onStateChange'] | null;
|
|
124
|
+
future: NonNullable<InstantSearchOptions<TUiState>['future']>;
|
|
111
125
|
helper: AlgoliaSearchHelper | null;
|
|
112
126
|
mainHelper: AlgoliaSearchHelper | null;
|
|
113
127
|
mainIndex: IndexWidget;
|
package/es/lib/InstantSearch.js
CHANGED
|
@@ -36,6 +36,10 @@ function defaultCreateURL() {
|
|
|
36
36
|
/**
|
|
37
37
|
* Global options for an InstantSearch instance.
|
|
38
38
|
*/
|
|
39
|
+
export var INSTANTSEARCH_FUTURE_DEFAULTS = {
|
|
40
|
+
preserveSharedStateOnUnmount: false
|
|
41
|
+
};
|
|
42
|
+
|
|
39
43
|
/**
|
|
40
44
|
* The actual implementation of the InstantSearch. This is
|
|
41
45
|
* created using the `instantsearch` factory function.
|
|
@@ -45,6 +49,7 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
45
49
|
_inherits(InstantSearch, _EventEmitter);
|
|
46
50
|
var _super = _createSuper(InstantSearch);
|
|
47
51
|
function InstantSearch(options) {
|
|
52
|
+
var _options$future2;
|
|
48
53
|
var _this;
|
|
49
54
|
_classCallCheck(this, InstantSearch);
|
|
50
55
|
_this = _super.call(this);
|
|
@@ -54,6 +59,7 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
54
59
|
_defineProperty(_assertThisInitialized(_this), "indexName", void 0);
|
|
55
60
|
_defineProperty(_assertThisInitialized(_this), "insightsClient", void 0);
|
|
56
61
|
_defineProperty(_assertThisInitialized(_this), "onStateChange", null);
|
|
62
|
+
_defineProperty(_assertThisInitialized(_this), "future", void 0);
|
|
57
63
|
_defineProperty(_assertThisInitialized(_this), "helper", void 0);
|
|
58
64
|
_defineProperty(_assertThisInitialized(_this), "mainHelper", void 0);
|
|
59
65
|
_defineProperty(_assertThisInitialized(_this), "mainIndex", void 0);
|
|
@@ -126,7 +132,9 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
126
132
|
_options$insightsClie = options.insightsClient,
|
|
127
133
|
insightsClient = _options$insightsClie === void 0 ? null : _options$insightsClie,
|
|
128
134
|
_options$onStateChang = options.onStateChange,
|
|
129
|
-
onStateChange = _options$onStateChang === void 0 ? null : _options$onStateChang
|
|
135
|
+
onStateChange = _options$onStateChang === void 0 ? null : _options$onStateChang,
|
|
136
|
+
_options$future = options.future,
|
|
137
|
+
future = _options$future === void 0 ? _objectSpread(_objectSpread({}, INSTANTSEARCH_FUTURE_DEFAULTS), options.future || {}) : _options$future;
|
|
130
138
|
if (searchClient === null) {
|
|
131
139
|
throw new Error(withUsage('The `searchClient` option is required.'));
|
|
132
140
|
}
|
|
@@ -143,7 +151,14 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
143
151
|
process.env.NODE_ENV === 'development' ? warning(!options.searchParameters, "The `searchParameters` option is deprecated and will not be supported in InstantSearch.js 4.x.\n\nYou can replace it with the `configure` widget:\n\n```\nsearch.addWidgets([\n configure(".concat(JSON.stringify(options.searchParameters, null, 2), ")\n]);\n```\n\nSee ").concat(createDocumentationLink({
|
|
144
152
|
name: 'configure'
|
|
145
153
|
}))) : void 0;
|
|
154
|
+
if (process.env.NODE_ENV === 'development' && ((_options$future2 = options.future) === null || _options$future2 === void 0 ? void 0 : _options$future2.preserveSharedStateOnUnmount) === undefined) {
|
|
155
|
+
// eslint-disable-next-line no-console
|
|
156
|
+
console.info("Starting from the next major version, InstantSearch will change how widgets state is preserved when they are removed. InstantSearch will keep the state of unmounted widgets to be usable by other widgets with the same attribute.\n\nWe recommend setting `future.preserveSharedStateOnUnmount` to true to adopt this change today.\nTo stay with the current behaviour and remove this warning, set the option to false.\n\nSee documentation: ".concat(createDocumentationLink({
|
|
157
|
+
name: 'instantsearch'
|
|
158
|
+
}), "#widget-param-future\n "));
|
|
159
|
+
}
|
|
146
160
|
_this.client = searchClient;
|
|
161
|
+
_this.future = future;
|
|
147
162
|
_this.insightsClient = insightsClient;
|
|
148
163
|
_this.indexName = indexName;
|
|
149
164
|
_this.helper = null;
|
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.
|
|
1
|
+
declare const _default: "4.58.0";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.
|
|
1
|
+
export default '4.58.0';
|
|
@@ -135,7 +135,7 @@ export function createInsightsMiddleware() {
|
|
|
135
135
|
},
|
|
136
136
|
started: function started() {
|
|
137
137
|
insightsClient('addAlgoliaAgent', 'insights-middleware');
|
|
138
|
-
helper = instantSearchInstance.
|
|
138
|
+
helper = instantSearchInstance.mainHelper;
|
|
139
139
|
initialParameters = {
|
|
140
140
|
userToken: helper.state.userToken,
|
|
141
141
|
clickAnalytics: helper.state.clickAnalytics
|
|
@@ -207,7 +207,7 @@ var index = function index(widgetParams) {
|
|
|
207
207
|
return widgets.indexOf(widget) === -1;
|
|
208
208
|
});
|
|
209
209
|
if (localInstantSearchInstance && Boolean(widgets.length)) {
|
|
210
|
-
var
|
|
210
|
+
var cleanedState = widgets.reduce(function (state, widget) {
|
|
211
211
|
// the `dispose` method exists at this point we already assert it
|
|
212
212
|
var next = widget.dispose({
|
|
213
213
|
helper: helper,
|
|
@@ -216,14 +216,23 @@ var index = function index(widgetParams) {
|
|
|
216
216
|
});
|
|
217
217
|
return next || state;
|
|
218
218
|
}, helper.state);
|
|
219
|
+
var newState = localInstantSearchInstance.future.preserveSharedStateOnUnmount ? getLocalWidgetsSearchParameters(localWidgets, {
|
|
220
|
+
uiState: localUiState,
|
|
221
|
+
initialSearchParameters: new algoliasearchHelper.SearchParameters({
|
|
222
|
+
index: this.getIndexName()
|
|
223
|
+
})
|
|
224
|
+
}) : getLocalWidgetsSearchParameters(localWidgets, {
|
|
225
|
+
uiState: getLocalWidgetsUiState(localWidgets, {
|
|
226
|
+
searchParameters: cleanedState,
|
|
227
|
+
helper: helper
|
|
228
|
+
}),
|
|
229
|
+
initialSearchParameters: cleanedState
|
|
230
|
+
});
|
|
219
231
|
localUiState = getLocalWidgetsUiState(localWidgets, {
|
|
220
|
-
searchParameters:
|
|
232
|
+
searchParameters: newState,
|
|
221
233
|
helper: helper
|
|
222
234
|
});
|
|
223
|
-
helper.setState(
|
|
224
|
-
uiState: localUiState,
|
|
225
|
-
initialSearchParameters: _nextState
|
|
226
|
-
}));
|
|
235
|
+
helper.setState(newState);
|
|
227
236
|
if (localWidgets.length) {
|
|
228
237
|
localInstantSearchInstance.scheduleSearch();
|
|
229
238
|
}
|
|
@@ -289,7 +298,7 @@ var index = function index(widgetParams) {
|
|
|
289
298
|
return mainHelper.searchForFacetValues(facetName, facetValue, maxFacetHits, state);
|
|
290
299
|
};
|
|
291
300
|
derivedHelper = mainHelper.derive(function () {
|
|
292
|
-
return mergeSearchParameters.apply(void 0, _toConsumableArray(resolveSearchParameters(_this3)));
|
|
301
|
+
return mergeSearchParameters.apply(void 0, [mainHelper.state].concat(_toConsumableArray(resolveSearchParameters(_this3))));
|
|
293
302
|
});
|
|
294
303
|
var indexInitialResults = (_instantSearchInstanc = instantSearchInstance._initialResults) === null || _instantSearchInstanc === void 0 ? void 0 : _instantSearchInstanc[this.getIndexId()];
|
|
295
304
|
if (indexInitialResults) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instantsearch.js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.58.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",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@algolia/events": "^4.0.1",
|
|
30
|
-
"@algolia/ui-components-highlight-vdom": "^1.2.
|
|
31
|
-
"@algolia/ui-components-shared": "^1.2.
|
|
30
|
+
"@algolia/ui-components-highlight-vdom": "^1.2.2",
|
|
31
|
+
"@algolia/ui-components-shared": "^1.2.2",
|
|
32
32
|
"@types/dom-speech-recognition": "^0.0.1",
|
|
33
33
|
"@types/google.maps": "^3.45.3",
|
|
34
34
|
"@types/hogan.js": "^3.0.0",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"version": "./scripts/version/update-version.js"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@instantsearch/mocks": "1.
|
|
59
|
-
"@instantsearch/tests": "1.
|
|
60
|
-
"@instantsearch/testutils": "1.
|
|
58
|
+
"@instantsearch/mocks": "1.27.0",
|
|
59
|
+
"@instantsearch/tests": "1.27.0",
|
|
60
|
+
"@instantsearch/testutils": "1.16.0",
|
|
61
61
|
"@storybook/html": "5.3.9",
|
|
62
62
|
"@types/scriptjs": "0.0.2",
|
|
63
63
|
"algoliasearch": "4.14.3",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"scriptjs": "2.5.9",
|
|
66
66
|
"webpack": "4.41.5"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "d21e0ed006139e5635df70d7a4caf0c99ab85f5a"
|
|
69
69
|
}
|