react-instantsearch-nextjs 1.0.16 → 1.1.1

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,34 +1,29 @@
1
- "use strict";
2
- 'use client';
1
+ 'use strict';
3
2
 
4
3
  Object.defineProperty(exports, "__esModule", {
5
- value: true
4
+ value: true
6
5
  });
7
- exports.useDynamicRouteWarning = useDynamicRouteWarning;
6
+ Object.defineProperty(exports, "useDynamicRouteWarning", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return useDynamicRouteWarning;
10
+ }
11
+ });
12
+ var _sliced_to_array = require("@swc/helpers/_/_sliced_to_array");
8
13
  var _navigation = require("next/navigation");
9
14
  var _warn = require("./warn");
10
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
11
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
13
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
16
15
  var lastParams = null;
17
- function useDynamicRouteWarning(_ref) {
18
- var isServer = _ref.isServer,
19
- isMounting = _ref.isMounting,
20
- instance = _ref.instance;
21
- var params = (0, _navigation.useParams)();
22
- if (!isServer && isMounting.current && !instance) {
23
- // Warn if lastParams and current params have the same keys but different values
24
- if (lastParams && Object.keys(lastParams).length === Object.keys(params).length && Object.entries(lastParams).some(function (_ref2) {
25
- var _ref3 = _slicedToArray(_ref2, 2),
26
- key = _ref3[0],
27
- value = _ref3[1];
28
- return params[key] !== value;
29
- })) {
30
- process.env.NODE_ENV === 'development' ? (0, _warn.warn)(false, "\nWe detected you may be using `<InstantSearchNext>` on a dynamic route.\n\nThis can lead to unexpected behavior, we recommend passing an `instance` prop to <InstantSearchNext>, created from the `createInstantSearchNextInstance` function.\n\nThis message can be safely ignored if you are not using dynamic routes.\n\nFor more information, see https://www.algolia.com/doc/guides/building-search-ui/going-further/server-side-rendering/react/#dynamic-routes\n") : void 0;
16
+ function useDynamicRouteWarning(param) {
17
+ var isServer = param.isServer, isMounting = param.isMounting, instance = param.instance;
18
+ var params = (0, _navigation.useParams)();
19
+ if (!isServer && isMounting.current && !instance) {
20
+ // Warn if lastParams and current params have the same keys but different values
21
+ if (lastParams && Object.keys(lastParams).length === Object.keys(params).length && Object.entries(lastParams).some(function(param) {
22
+ var _param = _sliced_to_array._(param, 2), key = _param[0], value = _param[1];
23
+ return params[key] !== value;
24
+ })) {
25
+ (0, _warn.warn)(false, "\nWe detected you may be using `<InstantSearchNext>` on a dynamic route.\n\nThis can lead to unexpected behavior, we recommend passing an `instance` prop to <InstantSearchNext>, created from the `createInstantSearchNextInstance` function.\n\nThis message can be safely ignored if you are not using dynamic routes.\n\nFor more information, see https://www.algolia.com/doc/guides/building-search-ui/going-further/server-side-rendering/react/#dynamic-routes\n");
26
+ }
27
+ lastParams = params;
31
28
  }
32
- lastParams = params;
33
- }
34
- }
29
+ }
@@ -1,67 +1,71 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
- value: true
4
+ value: true
5
5
  });
6
- exports.useInstantSearchRouting = useInstantSearchRouting;
7
- var _history = _interopRequireDefault(require("instantsearch.js/cjs/lib/routers/history"));
6
+ Object.defineProperty(exports, "useInstantSearchRouting", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return useInstantSearchRouting;
10
+ }
11
+ });
12
+ var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
13
+ var _object_spread = require("@swc/helpers/_/_object_spread");
14
+ var _type_of = require("@swc/helpers/_/_type_of");
15
+ var _history = /*#__PURE__*/ _interop_require_default._(require("instantsearch.js/cjs/lib/routers/history"));
8
16
  var _navigation = require("next/navigation");
9
17
  var _react = require("react");
10
18
  var _useNextHeaders = require("./useNextHeaders");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
15
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
16
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
18
19
  function useInstantSearchRouting(passedRouting, isMounting) {
19
- var isServer = typeof window === 'undefined';
20
- var pathname = (0, _navigation.usePathname)();
21
- var searchParams = (0, _navigation.useSearchParams)();
22
- var routingRef = (0, _react.useRef)(null);
23
- var onUpdateRef = (0, _react.useRef)(null);
24
- var isUnmounting = (0, _react.useRef)(false);
25
- (0, _react.useEffect)(function () {
26
- if (onUpdateRef.current) {
27
- onUpdateRef.current();
28
- }
29
- }, [pathname, searchParams]);
30
- (0, _react.useEffect)(function () {
31
- isUnmounting.current = false;
32
- return function () {
33
- isUnmounting.current = true;
34
- };
35
- });
36
- var headers = (0, _useNextHeaders.useNextHeaders)();
37
- if (passedRouting && !routingRef.current) {
38
- var browserHistoryOptions = {};
39
- browserHistoryOptions.getLocation = function () {
40
- if (isServer) {
41
- var url = "".concat((headers === null || headers === void 0 ? void 0 : headers.get('x-forwarded-proto')) || 'http', "://").concat(headers === null || headers === void 0 ? void 0 : headers.get('host')).concat(pathname, "?").concat(searchParams);
42
- return new URL(url);
43
- }
44
- if (isMounting.current) {
45
- return new URL("".concat(window.location.protocol, "//").concat(window.location.host).concat(pathname, "?").concat(searchParams));
46
- }
47
- return window.location;
48
- };
49
- browserHistoryOptions.push = function push(url) {
50
- // This is to skip the push with empty routeState on dispose as it would clear params set on a <Link>
51
- if (this.isDisposed && isUnmounting.current) {
52
- return;
53
- }
54
- history.pushState({}, '', url);
55
- };
56
- browserHistoryOptions.start = function start(onUpdate) {
57
- onUpdateRef.current = onUpdate;
58
- };
59
- routingRef.current = {};
60
- if (_typeof(passedRouting) === 'object') {
61
- browserHistoryOptions = _objectSpread(_objectSpread({}, browserHistoryOptions), passedRouting.router);
62
- routingRef.current.stateMapping = passedRouting.stateMapping;
20
+ var isServer = typeof window === 'undefined';
21
+ var pathname = (0, _navigation.usePathname)();
22
+ var searchParams = (0, _navigation.useSearchParams)();
23
+ var routingRef = (0, _react.useRef)(null);
24
+ var onUpdateRef = (0, _react.useRef)(null);
25
+ var isUnmounting = (0, _react.useRef)(false);
26
+ (0, _react.useEffect)(function() {
27
+ if (onUpdateRef.current) {
28
+ onUpdateRef.current();
29
+ }
30
+ }, [
31
+ pathname,
32
+ searchParams
33
+ ]);
34
+ (0, _react.useEffect)(function() {
35
+ isUnmounting.current = false;
36
+ return function() {
37
+ isUnmounting.current = true;
38
+ };
39
+ });
40
+ var headers = (0, _useNextHeaders.useNextHeaders)();
41
+ if (passedRouting && !routingRef.current) {
42
+ var browserHistoryOptions = {};
43
+ browserHistoryOptions.getLocation = function() {
44
+ if (isServer) {
45
+ var url = "".concat((headers === null || headers === void 0 ? void 0 : headers.get('x-forwarded-proto')) || 'http', "://").concat(headers === null || headers === void 0 ? void 0 : headers.get('host')).concat(pathname, "?").concat(searchParams);
46
+ return new URL(url);
47
+ }
48
+ if (isMounting.current) {
49
+ return new URL("".concat(window.location.protocol, "//").concat(window.location.host).concat(pathname, "?").concat(searchParams));
50
+ }
51
+ return window.location;
52
+ };
53
+ browserHistoryOptions.push = function push(url) {
54
+ // This is to skip the push with empty routeState on dispose as it would clear params set on a <Link>
55
+ if (this.isDisposed && isUnmounting.current) {
56
+ return;
57
+ }
58
+ history.pushState({}, '', url);
59
+ };
60
+ browserHistoryOptions.start = function start(onUpdate) {
61
+ onUpdateRef.current = onUpdate;
62
+ };
63
+ routingRef.current = {};
64
+ if ((typeof passedRouting === "undefined" ? "undefined" : _type_of._(passedRouting)) === 'object') {
65
+ browserHistoryOptions = _object_spread._({}, browserHistoryOptions, passedRouting.router);
66
+ routingRef.current.stateMapping = passedRouting.stateMapping;
67
+ }
68
+ routingRef.current.router = (0, _history.default)(browserHistoryOptions);
63
69
  }
64
- routingRef.current.router = (0, _history.default)(browserHistoryOptions);
65
- }
66
- return routingRef.current;
67
- }
70
+ return routingRef.current;
71
+ }
@@ -1,25 +1,26 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
- value: true
4
+ value: true
5
5
  });
6
- exports.useNextHeaders = void 0;
7
- var _headers = require("next/headers");
6
+ Object.defineProperty(exports, "useNextHeaders", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return useNextHeaders;
10
+ }
11
+ });
12
+ var _type_of = require("@swc/helpers/_/_type_of");
8
13
  var _react = require("react");
9
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
14
  function isPromise(obj) {
11
- return obj && (_typeof(obj) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
15
+ return obj !== null && ((typeof obj === "undefined" ? "undefined" : _type_of._(obj)) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
12
16
  }
13
- var useNextHeaders = exports.useNextHeaders = function useNextHeaders() {
14
- var isServer = typeof window === 'undefined';
15
- var h;
16
- if (isServer) {
17
- var nextHeaders = (0, _headers.headers)();
18
- if (isPromise((0, _headers.headers)())) {
19
- h = (0, _react.use)(nextHeaders);
20
- } else {
21
- h = nextHeaders; // assert that headers come from the synchronous nextjs function
17
+ var useNextHeaders = function useNextHeaders() {
18
+ var isServer = typeof window === 'undefined';
19
+ if (isServer) {
20
+ // Dynamic require to avoid bundling next/headers in client components
21
+ var nextHeadersModule = require('next/headers');
22
+ var nextHeaders = nextHeadersModule.headers();
23
+ return isPromise(nextHeaders) ? (0, _react.use)(nextHeaders) : nextHeaders;
22
24
  }
23
- }
24
- return h;
25
- };
25
+ return undefined;
26
+ };
package/dist/cjs/warn.js CHANGED
@@ -1,40 +1,27 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
- value: true
4
+ value: true
5
5
  });
6
- exports.warn = warn;
7
- exports.warnCache = void 0;
8
- /* eslint-disable no-console, no-empty */
9
-
10
- var warnCache = exports.warnCache = {
11
- current: {}
6
+ function _export(target, all) {
7
+ for(var name in all)Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: Object.getOwnPropertyDescriptor(all, name).get
10
+ });
11
+ }
12
+ _export(exports, {
13
+ get warn () {
14
+ return warn;
15
+ },
16
+ get warnCache () {
17
+ return warnCache;
18
+ }
19
+ });
20
+ var warnCache = {
21
+ current: {}
12
22
  };
13
-
14
- /**
15
- * Logs a warning if the condition is not met.
16
- * This is used to log issues in development environment only.
17
- */
18
23
  function warn(condition, message) {
19
- if (!(process.env.NODE_ENV === 'development')) {
20
- return;
21
- }
22
- if (condition) {
23
- return;
24
- }
25
- var sanitizedMessage = message.trim();
26
- var hasAlreadyPrinted = warnCache.current[sanitizedMessage];
27
- if (!hasAlreadyPrinted) {
28
- warnCache.current[sanitizedMessage] = true;
29
- var warning = "[react-instantsearch-nextjs] ".concat(sanitizedMessage);
30
- console.warn(warning);
31
- try {
32
- // Welcome to debugging InstantSearch.
33
- //
34
- // This error was thrown as a convenience so that you can find the source
35
- // of the warning that appears in the console by enabling "Pause on exceptions"
36
- // in your debugger.
37
- throw new Error(warning);
38
- } catch (error) {}
39
- }
40
- }
24
+ {
25
+ return;
26
+ }
27
+ }
@@ -1,95 +1,94 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- import { getInitialResults } from "instantsearch.js/es/lib/server.js";
8
- import { resetWidgetId, walkIndex } from "instantsearch.js/es/lib/utils/index.js";
9
- import { ServerInsertedHTMLContext } from "next/navigation.js";
1
+ import { _ as _$1 } from '@swc/helpers/cjs/_object_spread.cjs';
2
+ import { _ } from '@swc/helpers/cjs/_object_spread_props.cjs';
3
+ import { getInitialResults } from 'instantsearch.js/es/lib/server.js';
4
+ import { resetWidgetId, walkIndex } from 'instantsearch.js/es/lib/utils/index.js';
5
+ import { ServerInsertedHTMLContext } from 'next/navigation.js';
10
6
  import { useContext } from 'react';
11
7
  import { useInstantSearchContext, useRSCContext, wrapPromiseWithState } from 'react-instantsearch-core';
12
- import { createInsertHTML } from "./createInsertHTML.js";
13
- export function InitializePromise(_ref) {
14
- var nonce = _ref.nonce;
15
- var _search = useInstantSearchContext();
16
- var _useRSCContext = useRSCContext(),
17
- waitForResultsRef = _useRSCContext.waitForResultsRef;
18
- var insertHTML = useContext(ServerInsertedHTMLContext) || function () {
19
- throw new Error('Missing ServerInsertedHTMLContext');
20
- };
8
+ import { createInsertHTML } from './createInsertHTML.js';
21
9
 
22
- // Extract search parameters from the search client to use them
23
- // later during hydration.
24
- var requestParamsList;
25
- if (_search.compositionID) {
26
- _search.mainHelper.setClient(_objectSpread(_objectSpread({}, _search.mainHelper.getClient()), {}, {
27
- search: function search(query) {
28
- requestParamsList = [query.requestBody.params];
29
- return _search.client.search(query);
30
- }
31
- }));
32
- } else {
33
- _search.mainHelper.setClient(_objectSpread(_objectSpread({}, _search.mainHelper.getClient()), {}, {
34
- search: function search(queries) {
35
- requestParamsList = queries.map(function (_ref2) {
36
- var params = _ref2.params;
37
- return params;
38
- });
39
- return _search.client.search(queries);
40
- }
41
- }));
42
- }
43
- resetWidgetId();
44
- var waitForResults = function waitForResults() {
45
- return new Promise(function (resolve) {
46
- var searchReceived = false;
47
- var recommendReceived = false;
48
- _search.mainHelper.derivedHelpers[0].once('result', function () {
49
- searchReceived = true;
50
- if (!_search._hasRecommendWidget || recommendReceived) {
51
- resolve();
52
- }
53
- });
54
- _search.mainHelper.derivedHelpers[0].once('recommend:result', function () {
55
- recommendReceived = true;
56
- if (!_search._hasSearchWidget || searchReceived) {
57
- resolve();
58
- }
59
- });
60
- });
61
- };
62
- var injectInitialResults = function injectInitialResults() {
63
- var options = {
64
- inserted: false
10
+ function InitializePromise(param) {
11
+ var nonce = param.nonce;
12
+ var search = useInstantSearchContext();
13
+ var waitForResultsRef = useRSCContext().waitForResultsRef;
14
+ var insertHTML = useContext(ServerInsertedHTMLContext) || function() {
15
+ throw new Error('Missing ServerInsertedHTMLContext');
65
16
  };
66
- var results = getInitialResults(_search.mainIndex, requestParamsList);
67
- insertHTML(createInsertHTML({
68
- options: options,
69
- results: results,
70
- nonce: nonce
71
- }));
72
- };
73
- if ((waitForResultsRef === null || waitForResultsRef === void 0 ? void 0 : waitForResultsRef.current) === null) {
74
- waitForResultsRef.current = wrapPromiseWithState(waitForResults().then(function () {
75
- var shouldRefetch = false;
76
- walkIndex(_search.mainIndex, function (index) {
77
- shouldRefetch = index.getWidgets().some(function (widget) {
78
- return widget.$$type === 'ais.dynamicWidgets';
17
+ // Extract search parameters from the search client to use them
18
+ // later during hydration.
19
+ var requestParamsList;
20
+ if (search.compositionID) {
21
+ search.mainHelper.setClient(_(_$1({}, search.mainHelper.getClient()), {
22
+ search: function search1(query) {
23
+ requestParamsList = [
24
+ query.requestBody.params
25
+ ];
26
+ return search.client.search(query);
27
+ }
28
+ }));
29
+ } else {
30
+ search.mainHelper.setClient(_(_$1({}, search.mainHelper.getClient()), {
31
+ search: function search1(queries) {
32
+ requestParamsList = queries.map(function(param) {
33
+ var params = param.params;
34
+ return params;
35
+ });
36
+ return search.client.search(queries);
37
+ }
38
+ }));
39
+ }
40
+ resetWidgetId();
41
+ var waitForResults = function waitForResults() {
42
+ return new Promise(function(resolve) {
43
+ var searchReceived = false;
44
+ var recommendReceived = false;
45
+ search.mainHelper.derivedHelpers[0].once('result', function() {
46
+ searchReceived = true;
47
+ if (!search._hasRecommendWidget || recommendReceived) {
48
+ resolve();
49
+ }
50
+ });
51
+ search.mainHelper.derivedHelpers[0].once('recommend:result', function() {
52
+ recommendReceived = true;
53
+ if (!search._hasSearchWidget || searchReceived) {
54
+ resolve();
55
+ }
56
+ });
79
57
  });
80
- });
81
- if (shouldRefetch) {
82
- var _search$_resetSchedul;
83
- (_search$_resetSchedul = _search._resetScheduleSearch) === null || _search$_resetSchedul === void 0 ? void 0 : _search$_resetSchedul.call(_search);
84
- waitForResultsRef.current = wrapPromiseWithState(waitForResults().then(injectInitialResults));
85
- }
86
- return shouldRefetch;
87
- }).then(function (shouldRefetch) {
88
- if (shouldRefetch) {
89
- return;
90
- }
91
- injectInitialResults();
92
- }));
93
- }
94
- return null;
95
- }
58
+ };
59
+ var injectInitialResults = function injectInitialResults() {
60
+ var options = {
61
+ inserted: false
62
+ };
63
+ var results = getInitialResults(search.mainIndex, requestParamsList);
64
+ insertHTML(createInsertHTML({
65
+ options: options,
66
+ results: results,
67
+ nonce: nonce
68
+ }));
69
+ };
70
+ if ((waitForResultsRef === null || waitForResultsRef === void 0 ? void 0 : waitForResultsRef.current) === null) {
71
+ waitForResultsRef.current = wrapPromiseWithState(waitForResults().then(function() {
72
+ var shouldRefetch = false;
73
+ walkIndex(search.mainIndex, function(index) {
74
+ shouldRefetch = index.getWidgets().some(function(widget) {
75
+ return widget.$$type === 'ais.dynamicWidgets';
76
+ });
77
+ });
78
+ if (shouldRefetch) {
79
+ var _search__resetScheduleSearch;
80
+ (_search__resetScheduleSearch = search._resetScheduleSearch) === null || _search__resetScheduleSearch === void 0 ? void 0 : _search__resetScheduleSearch.call(search);
81
+ waitForResultsRef.current = wrapPromiseWithState(waitForResults().then(injectInitialResults));
82
+ }
83
+ return shouldRefetch;
84
+ }).then(function(shouldRefetch) {
85
+ if (shouldRefetch) {
86
+ return;
87
+ }
88
+ injectInitialResults();
89
+ }));
90
+ }
91
+ return null;
92
+ }
93
+
94
+ export { InitializePromise };