react-instantsearch-nextjs 0.2.4 → 0.3.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.
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -13,6 +12,12 @@ var _reactInstantsearchCore = require("react-instantsearch-core");
|
|
|
13
12
|
var _htmlEscape = require("./htmlEscape");
|
|
14
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
20
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
21
|
var _ref2 = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
17
22
|
function InitializePromise() {
|
|
18
23
|
var _search = (0, _reactInstantsearchCore.useInstantSearchContext)();
|
|
@@ -24,7 +29,7 @@ function InitializePromise() {
|
|
|
24
29
|
// Extract search parameters from the search client to use them
|
|
25
30
|
// later during hydration.
|
|
26
31
|
var requestParamsList;
|
|
27
|
-
_search.mainHelper.setClient({
|
|
32
|
+
_search.mainHelper.setClient(_objectSpread(_objectSpread({}, _search.mainHelper.getClient()), {}, {
|
|
28
33
|
search: function search(queries) {
|
|
29
34
|
requestParamsList = queries.map(function (_ref) {
|
|
30
35
|
var params = _ref.params;
|
|
@@ -32,11 +37,23 @@ function InitializePromise() {
|
|
|
32
37
|
});
|
|
33
38
|
return _search.client.search(queries);
|
|
34
39
|
}
|
|
35
|
-
});
|
|
40
|
+
}));
|
|
41
|
+
(0, _utils.resetWidgetId)();
|
|
36
42
|
var waitForResults = function waitForResults() {
|
|
37
43
|
return new Promise(function (resolve) {
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
var searchReceived = false;
|
|
45
|
+
var recommendReceived = false;
|
|
46
|
+
_search.mainHelper.derivedHelpers[0].once('result', function () {
|
|
47
|
+
searchReceived = true;
|
|
48
|
+
if (!_search._hasRecommendWidget || recommendReceived) {
|
|
49
|
+
resolve();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
_search.mainHelper.derivedHelpers[0].once('recommend:result', function () {
|
|
53
|
+
recommendReceived = true;
|
|
54
|
+
if (!_search._hasSearchWidget || searchReceived) {
|
|
55
|
+
resolve();
|
|
56
|
+
}
|
|
40
57
|
});
|
|
41
58
|
});
|
|
42
59
|
};
|
|
@@ -10,8 +10,9 @@ function TriggerSearch() {
|
|
|
10
10
|
var instantsearch = (0, _reactInstantsearchCore.useInstantSearchContext)();
|
|
11
11
|
var waitForResultsRef = (0, _reactInstantsearchCore.useRSCContext)();
|
|
12
12
|
if ((waitForResultsRef === null || waitForResultsRef === void 0 ? void 0 : (_waitForResultsRef$cu = waitForResultsRef.current) === null || _waitForResultsRef$cu === void 0 ? void 0 : _waitForResultsRef$cu.status) === 'pending') {
|
|
13
|
-
var _instantsearch$mainHe;
|
|
14
|
-
(_instantsearch$mainHe = instantsearch.mainHelper) === null || _instantsearch$mainHe === void 0 ? void 0 : _instantsearch$mainHe.searchOnlyWithDerivedHelpers();
|
|
13
|
+
var _instantsearch$mainHe, _instantsearch$mainHe2;
|
|
14
|
+
instantsearch._hasSearchWidget && ((_instantsearch$mainHe = instantsearch.mainHelper) === null || _instantsearch$mainHe === void 0 ? void 0 : _instantsearch$mainHe.searchOnlyWithDerivedHelpers());
|
|
15
|
+
instantsearch._hasRecommendWidget && ((_instantsearch$mainHe2 = instantsearch.mainHelper) === null || _instantsearch$mainHe2 === void 0 ? void 0 : _instantsearch$mainHe2.recommend());
|
|
15
16
|
}
|
|
16
17
|
return null;
|
|
17
18
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
1
7
|
import { getInitialResults } from "instantsearch.js/es/lib/server.js";
|
|
2
|
-
import { walkIndex } from "instantsearch.js/es/lib/utils/index.js";
|
|
8
|
+
import { resetWidgetId, walkIndex } from "instantsearch.js/es/lib/utils/index.js";
|
|
3
9
|
import { ServerInsertedHTMLContext } from "next/navigation.js";
|
|
4
10
|
import React, { useContext } from 'react';
|
|
5
11
|
import { useInstantSearchContext, useRSCContext, wrapPromiseWithState } from 'react-instantsearch-core';
|
|
@@ -15,7 +21,7 @@ export function InitializePromise() {
|
|
|
15
21
|
// Extract search parameters from the search client to use them
|
|
16
22
|
// later during hydration.
|
|
17
23
|
var requestParamsList;
|
|
18
|
-
_search.mainHelper.setClient({
|
|
24
|
+
_search.mainHelper.setClient(_objectSpread(_objectSpread({}, _search.mainHelper.getClient()), {}, {
|
|
19
25
|
search: function search(queries) {
|
|
20
26
|
requestParamsList = queries.map(function (_ref) {
|
|
21
27
|
var params = _ref.params;
|
|
@@ -23,11 +29,23 @@ export function InitializePromise() {
|
|
|
23
29
|
});
|
|
24
30
|
return _search.client.search(queries);
|
|
25
31
|
}
|
|
26
|
-
});
|
|
32
|
+
}));
|
|
33
|
+
resetWidgetId();
|
|
27
34
|
var waitForResults = function waitForResults() {
|
|
28
35
|
return new Promise(function (resolve) {
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
var searchReceived = false;
|
|
37
|
+
var recommendReceived = false;
|
|
38
|
+
_search.mainHelper.derivedHelpers[0].once('result', function () {
|
|
39
|
+
searchReceived = true;
|
|
40
|
+
if (!_search._hasRecommendWidget || recommendReceived) {
|
|
41
|
+
resolve();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
_search.mainHelper.derivedHelpers[0].once('recommend:result', function () {
|
|
45
|
+
recommendReceived = true;
|
|
46
|
+
if (!_search._hasSearchWidget || searchReceived) {
|
|
47
|
+
resolve();
|
|
48
|
+
}
|
|
31
49
|
});
|
|
32
50
|
});
|
|
33
51
|
};
|
package/dist/es/TriggerSearch.js
CHANGED
|
@@ -4,8 +4,9 @@ export function TriggerSearch() {
|
|
|
4
4
|
var instantsearch = useInstantSearchContext();
|
|
5
5
|
var waitForResultsRef = useRSCContext();
|
|
6
6
|
if ((waitForResultsRef === null || waitForResultsRef === void 0 ? void 0 : (_waitForResultsRef$cu = waitForResultsRef.current) === null || _waitForResultsRef$cu === void 0 ? void 0 : _waitForResultsRef$cu.status) === 'pending') {
|
|
7
|
-
var _instantsearch$mainHe;
|
|
8
|
-
(_instantsearch$mainHe = instantsearch.mainHelper) === null || _instantsearch$mainHe === void 0 ? void 0 : _instantsearch$mainHe.searchOnlyWithDerivedHelpers();
|
|
7
|
+
var _instantsearch$mainHe, _instantsearch$mainHe2;
|
|
8
|
+
instantsearch._hasSearchWidget && ((_instantsearch$mainHe = instantsearch.mainHelper) === null || _instantsearch$mainHe === void 0 ? void 0 : _instantsearch$mainHe.searchOnlyWithDerivedHelpers());
|
|
9
|
+
instantsearch._hasRecommendWidget && ((_instantsearch$mainHe2 = instantsearch.mainHelper) === null || _instantsearch$mainHe2 === void 0 ? void 0 : _instantsearch$mainHe2.recommend());
|
|
9
10
|
}
|
|
10
11
|
return null;
|
|
11
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-instantsearch-nextjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "React InstantSearch SSR utilities for Next.js",
|
|
5
5
|
"types": "dist/es/index.d.ts",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"watch:es": "yarn --silent build:es:base --watch"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"instantsearch.js": "4.
|
|
52
|
+
"instantsearch.js": "4.70.0",
|
|
53
53
|
"next": "13.5.1",
|
|
54
|
-
"react-instantsearch-core": "7.
|
|
54
|
+
"react-instantsearch-core": "7.10.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"next": ">= 13.4 && < 15",
|
|
58
58
|
"react-instantsearch": ">= 7.1.0 && < 8"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "5bf02d0f65e6e1fc70265319dbad660696d8ba81"
|
|
61
61
|
}
|