vue-instantsearch 4.8.8 → 4.8.10
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/package.json +3 -3
- package/src/components/__tests__/InstantSearch.js +32 -0
- package/src/util/createInstantSearchComponent.js +6 -0
- package/src/util/createServerRootMixin.js +6 -44
- package/vue2/cjs/index.js +1 -1
- package/vue2/cjs/index.js.map +1 -1
- package/vue2/es/package.json.js +1 -1
- package/vue2/es/src/util/createInstantSearchComponent.js +1 -1
- package/vue2/es/src/util/createInstantSearchComponent.js.map +1 -1
- package/vue2/es/src/util/createServerRootMixin.js +1 -1
- package/vue2/es/src/util/createServerRootMixin.js.map +1 -1
- package/vue2/umd/index.js +1 -1
- package/vue2/umd/index.js.map +1 -1
- package/vue3/cjs/index.js +1 -1
- package/vue3/cjs/index.js.map +1 -1
- package/vue3/es/package.json.js +1 -1
- package/vue3/es/src/util/createInstantSearchComponent.js +1 -1
- package/vue3/es/src/util/createInstantSearchComponent.js.map +1 -1
- package/vue3/es/src/util/createServerRootMixin.js +1 -1
- package/vue3/es/src/util/createServerRootMixin.js.map +1 -1
- package/vue3/umd/index.js +1 -1
- package/vue3/umd/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"autocomplete"
|
|
17
17
|
],
|
|
18
18
|
"license": "MIT",
|
|
19
|
-
"version": "4.8.
|
|
19
|
+
"version": "4.8.10",
|
|
20
20
|
"files": [
|
|
21
21
|
"vue2",
|
|
22
22
|
"vue3",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"test:exports:vue3": "node ./test/module/vue3/is-es-module.mjs && node ./test/module/vue3/is-cjs-module.cjs"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"instantsearch.js": "4.
|
|
38
|
+
"instantsearch.js": "4.54.1",
|
|
39
39
|
"mitt": "^2.1.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"vuex": "3.5.1",
|
|
86
86
|
"vuex4": "npm:vuex@4.0.0"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "1f81b61cf0e78aeb7022d5e9eca0d49de727dc64"
|
|
89
89
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @jest-environment jsdom
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { createAlgoliaSearchClient } from '@instantsearch/mocks';
|
|
5
6
|
import { isVue3, version as vueVersion } from '../../util/vue-compat';
|
|
6
7
|
import { mount, nextTick } from '../../../test/utils';
|
|
7
8
|
import instantsearch from 'instantsearch.js/es';
|
|
@@ -177,6 +178,37 @@ it('Allows a change in `search-client`', async () => {
|
|
|
177
178
|
expect(helper.search).toHaveBeenCalledTimes(1);
|
|
178
179
|
});
|
|
179
180
|
|
|
181
|
+
it('warns when the `search-client` changes', async () => {
|
|
182
|
+
const wrapper = mount(InstantSearch, {
|
|
183
|
+
propsData: {
|
|
184
|
+
searchClient: createAlgoliaSearchClient({}),
|
|
185
|
+
indexName: 'indexName',
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const newClient = createAlgoliaSearchClient({});
|
|
190
|
+
|
|
191
|
+
await wrapper.setProps({ searchClient: newClient });
|
|
192
|
+
|
|
193
|
+
expect(warn).toHaveBeenCalledWith(
|
|
194
|
+
false,
|
|
195
|
+
'The `search-client` prop of `<ais-instant-search>` changed between renders, which may cause more search requests than necessary. If this is an unwanted behavior, please provide a stable reference: https://www.algolia.com/doc/api-reference/widgets/instantsearch/vue/#widget-param-search-client'
|
|
196
|
+
);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('does not warn when the `search-client` does not change', async () => {
|
|
200
|
+
const wrapper = mount(InstantSearch, {
|
|
201
|
+
propsData: {
|
|
202
|
+
searchClient: createAlgoliaSearchClient({}),
|
|
203
|
+
indexName: 'indexName',
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
await wrapper.setProps({ indexName: 'indexName2' });
|
|
208
|
+
|
|
209
|
+
expect(warn).not.toHaveBeenCalled();
|
|
210
|
+
});
|
|
211
|
+
|
|
180
212
|
it('Allows a change in `search-function`', async () => {
|
|
181
213
|
const oldValue = () => {};
|
|
182
214
|
const newValue = () => {};
|
|
@@ -2,6 +2,7 @@ import { createSuitMixin } from '../mixins/suit';
|
|
|
2
2
|
import { version } from '../../package.json'; // rollup does pick only what needed from json
|
|
3
3
|
import { _objectSpread } from './polyfills';
|
|
4
4
|
import { isVue3, version as vueVersion } from './vue-compat';
|
|
5
|
+
import { warn } from './warn';
|
|
5
6
|
|
|
6
7
|
export const createInstantSearchComponent = (component) =>
|
|
7
8
|
_objectSpread(
|
|
@@ -14,6 +15,11 @@ export const createInstantSearchComponent = (component) =>
|
|
|
14
15
|
},
|
|
15
16
|
watch: {
|
|
16
17
|
searchClient(searchClient) {
|
|
18
|
+
warn(
|
|
19
|
+
false,
|
|
20
|
+
'The `search-client` prop of `<ais-instant-search>` changed between renders, which may cause more search requests than necessary. If this is an unwanted behavior, please provide a stable reference: https://www.algolia.com/doc/api-reference/widgets/instantsearch/vue/#widget-param-search-client'
|
|
21
|
+
);
|
|
22
|
+
|
|
17
23
|
this.instantSearchInstance.helper.setClient(searchClient).search();
|
|
18
24
|
},
|
|
19
25
|
indexName(indexName) {
|
|
@@ -1,34 +1,11 @@
|
|
|
1
1
|
import instantsearch from 'instantsearch.js/es';
|
|
2
|
+
import {
|
|
3
|
+
waitForResults,
|
|
4
|
+
getInitialResults,
|
|
5
|
+
} from 'instantsearch.js/es/lib/server';
|
|
2
6
|
import { isVue3, isVue2, Vue2, createSSRApp } from './vue-compat';
|
|
3
7
|
import { warn } from './warn';
|
|
4
8
|
|
|
5
|
-
function walkIndex(indexWidget, visit) {
|
|
6
|
-
visit(indexWidget);
|
|
7
|
-
|
|
8
|
-
return indexWidget.getWidgets().forEach((widget) => {
|
|
9
|
-
if (widget.$$type !== 'ais.index') return;
|
|
10
|
-
visit(widget);
|
|
11
|
-
walkIndex(widget, visit);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function searchOnlyWithDerivedHelpers(helper) {
|
|
16
|
-
return new Promise((resolve, reject) => {
|
|
17
|
-
helper.searchOnlyWithDerivedHelpers();
|
|
18
|
-
|
|
19
|
-
// we assume all derived helpers resolve at least in the same tick
|
|
20
|
-
helper.derivedHelpers[0].on('result', () => {
|
|
21
|
-
resolve();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
helper.derivedHelpers.forEach((derivedHelper) =>
|
|
25
|
-
derivedHelper.on('error', (e) => {
|
|
26
|
-
reject(e);
|
|
27
|
-
})
|
|
28
|
-
);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
9
|
function defaultCloneComponent(componentInstance, { mixins = [] } = {}) {
|
|
33
10
|
const options = {
|
|
34
11
|
serverPrefetch: undefined,
|
|
@@ -133,24 +110,9 @@ function augmentInstantSearch(instantSearchOptions, cloneComponent) {
|
|
|
133
110
|
});
|
|
134
111
|
})
|
|
135
112
|
.then(() => renderToString(app))
|
|
136
|
-
.then(() =>
|
|
113
|
+
.then(() => waitForResults(instance))
|
|
137
114
|
.then(() => {
|
|
138
|
-
initialResults =
|
|
139
|
-
walkIndex(instance.mainIndex, (widget) => {
|
|
140
|
-
initialResults[widget.getIndexId()] = {
|
|
141
|
-
// copy just the values of SearchParameters, not the functions
|
|
142
|
-
state: Object.entries(widget.getHelper().state).reduce(
|
|
143
|
-
(acc, [key, value]) => {
|
|
144
|
-
// eslint-disable-next-line no-param-reassign
|
|
145
|
-
acc[key] = value;
|
|
146
|
-
return acc;
|
|
147
|
-
},
|
|
148
|
-
{}
|
|
149
|
-
),
|
|
150
|
-
results: widget.getResults()._rawResults,
|
|
151
|
-
};
|
|
152
|
-
});
|
|
153
|
-
|
|
115
|
+
initialResults = getInitialResults(instance.mainIndex);
|
|
154
116
|
search.hydrate(initialResults);
|
|
155
117
|
return search.getState();
|
|
156
118
|
});
|