react-instantsearch-nextjs 1.0.16 → 1.1.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,67 +1,64 @@
1
- "use strict";
1
+ 'use strict';
2
+
3
+ var _object_spread = require('@swc/helpers/_/_object_spread');
4
+ var _type_of = require('@swc/helpers/_/_type_of');
5
+ var historyRouter = require('instantsearch.js/cjs/lib/routers/history');
6
+ var navigation = require('next/navigation');
7
+ var React = require('react');
8
+ var useNextHeaders = require('./useNextHeaders.js');
2
9
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useInstantSearchRouting = useInstantSearchRouting;
7
- var _history = _interopRequireDefault(require("instantsearch.js/cjs/lib/routers/history"));
8
- var _navigation = require("next/navigation");
9
- var _react = require("react");
10
- 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
10
  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;
11
+ var isServer = typeof window === 'undefined';
12
+ var pathname = navigation.usePathname();
13
+ var searchParams = navigation.useSearchParams();
14
+ var routingRef = React.useRef(null);
15
+ var onUpdateRef = React.useRef(null);
16
+ var isUnmounting = React.useRef(false);
17
+ React.useEffect(function() {
18
+ if (onUpdateRef.current) {
19
+ onUpdateRef.current();
20
+ }
21
+ }, [
22
+ pathname,
23
+ searchParams
24
+ ]);
25
+ React.useEffect(function() {
26
+ isUnmounting.current = false;
27
+ return function() {
28
+ isUnmounting.current = true;
29
+ };
30
+ });
31
+ var headers = useNextHeaders.useNextHeaders();
32
+ if (passedRouting && !routingRef.current) {
33
+ var browserHistoryOptions = {};
34
+ browserHistoryOptions.getLocation = function() {
35
+ if (isServer) {
36
+ 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);
37
+ return new URL(url);
38
+ }
39
+ if (isMounting.current) {
40
+ return new URL("".concat(window.location.protocol, "//").concat(window.location.host).concat(pathname, "?").concat(searchParams));
41
+ }
42
+ return window.location;
43
+ };
44
+ browserHistoryOptions.push = function push(url) {
45
+ // This is to skip the push with empty routeState on dispose as it would clear params set on a <Link>
46
+ if (this.isDisposed && isUnmounting.current) {
47
+ return;
48
+ }
49
+ history.pushState({}, '', url);
50
+ };
51
+ browserHistoryOptions.start = function start(onUpdate) {
52
+ onUpdateRef.current = onUpdate;
53
+ };
54
+ routingRef.current = {};
55
+ if ((typeof passedRouting === "undefined" ? "undefined" : _type_of._(passedRouting)) === 'object') {
56
+ browserHistoryOptions = _object_spread._({}, browserHistoryOptions, passedRouting.router);
57
+ routingRef.current.stateMapping = passedRouting.stateMapping;
58
+ }
59
+ routingRef.current.router = historyRouter(browserHistoryOptions);
63
60
  }
64
- routingRef.current.router = (0, _history.default)(browserHistoryOptions);
65
- }
66
- return routingRef.current;
67
- }
61
+ return routingRef.current;
62
+ }
63
+
64
+ exports.useInstantSearchRouting = useInstantSearchRouting;
@@ -1,25 +1,20 @@
1
- "use strict";
1
+ 'use strict';
2
+
3
+ var _type_of = require('@swc/helpers/_/_type_of');
4
+ var React = require('react');
2
5
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useNextHeaders = void 0;
7
- var _headers = require("next/headers");
8
- 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
6
  function isPromise(obj) {
11
- return obj && (_typeof(obj) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
7
+ return obj !== null && ((typeof obj === "undefined" ? "undefined" : _type_of._(obj)) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
12
8
  }
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
9
+ var useNextHeaders = function useNextHeaders() {
10
+ var isServer = typeof window === 'undefined';
11
+ if (isServer) {
12
+ // Dynamic require to avoid bundling next/headers in client components
13
+ var nextHeadersModule = require('next/headers');
14
+ var nextHeaders = nextHeadersModule.headers();
15
+ return isPromise(nextHeaders) ? React.use(nextHeaders) : nextHeaders;
22
16
  }
23
- }
24
- return h;
25
- };
17
+ return undefined;
18
+ };
19
+
20
+ exports.useNextHeaders = useNextHeaders;
@@ -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 };
@@ -1,79 +1,78 @@
1
- var _excluded = ["children", "routing", "instance", "ignoreMultipleHooksWarning"];
2
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
4
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
5
- import { safelyRunOnBrowser } from "instantsearch.js/es/lib/utils/index.js";
6
- import React, { useEffect, useRef } from 'react';
1
+ import { _ as _$2 } from '@swc/helpers/cjs/_object_spread.cjs';
2
+ import { _ as _$1 } from '@swc/helpers/cjs/_object_spread_props.cjs';
3
+ import { _ } from '@swc/helpers/cjs/_object_without_properties.cjs';
4
+ import { safelyRunOnBrowser } from 'instantsearch.js/es/lib/utils/index.js';
5
+ import React, { useRef, useEffect } from 'react';
7
6
  import { InstantSearch, InstantSearchRSCContext, InstantSearchSSRContext } from 'react-instantsearch-core';
8
- import { InitializePromise } from "./InitializePromise.js";
9
- import { TriggerSearch } from "./TriggerSearch.js";
10
- import { useDynamicRouteWarning } from "./useDynamicRouteWarning.js";
11
- import { useInstantSearchRouting } from "./useInstantSearchRouting.js";
12
- import { useNextHeaders } from "./useNextHeaders.js";
7
+ import { InitializePromise } from './InitializePromise.js';
8
+ import { TriggerSearch } from './TriggerSearch.js';
9
+ import { useDynamicRouteWarning } from './useDynamicRouteWarning.js';
10
+ import { useInstantSearchRouting } from './useInstantSearchRouting.js';
11
+ import { useNextHeaders } from './useNextHeaders.js';
12
+
13
13
  var InstantSearchInitialResults = Symbol.for('InstantSearchInitialResults');
14
- export function createInstantSearchNextInstance() {
15
- return {
16
- current: null
17
- };
14
+ function createInstantSearchNextInstance() {
15
+ return {
16
+ current: null
17
+ };
18
18
  }
19
- export function InstantSearchNext(_ref) {
20
- var children = _ref.children,
21
- passedRouting = _ref.routing,
22
- instance = _ref.instance,
23
- _ref$ignoreMultipleHo = _ref.ignoreMultipleHooksWarning,
24
- ignoreMultipleHooksWarning = _ref$ignoreMultipleHo === void 0 ? false : _ref$ignoreMultipleHo,
25
- instantSearchProps = _objectWithoutProperties(_ref, _excluded);
26
- var isMounting = useRef(true);
27
- var isServer = typeof window === 'undefined';
28
- useEffect(function () {
29
- isMounting.current = false;
30
- }, []);
31
- var headers = useNextHeaders();
32
- var nonce = safelyRunOnBrowser(function () {
33
- return undefined;
34
- }, {
35
- fallback: function fallback() {
36
- return (headers === null || headers === void 0 ? void 0 : headers.get('x-nonce')) || undefined;
37
- }
38
- });
39
- useDynamicRouteWarning({
40
- isServer: isServer,
41
- isMounting: isMounting,
42
- instance: instance
43
- });
44
- var routing = useInstantSearchRouting(passedRouting, isMounting);
45
- return /*#__PURE__*/React.createElement(ServerOrHydrationProvider, {
46
- isServer: isServer,
47
- instance: instance,
48
- ignoreMultipleHooksWarning: ignoreMultipleHooksWarning
49
- }, /*#__PURE__*/React.createElement(InstantSearch, _extends({}, instantSearchProps, {
50
- routing: routing
51
- }), isServer && /*#__PURE__*/React.createElement(InitializePromise, {
52
- nonce: nonce
53
- }), children, isServer && /*#__PURE__*/React.createElement(TriggerSearch, {
54
- nonce: nonce
55
- })));
19
+ function InstantSearchNext(_0) {
20
+ var children = _0.children, passedRouting = _0.routing, instance = _0.instance, _0_ignoreMultipleHooksWarning = _0.ignoreMultipleHooksWarning, ignoreMultipleHooksWarning = _0_ignoreMultipleHooksWarning === void 0 ? false : _0_ignoreMultipleHooksWarning, instantSearchProps = _(_0, [
21
+ "children",
22
+ "routing",
23
+ "instance",
24
+ "ignoreMultipleHooksWarning"
25
+ ]);
26
+ var isMounting = useRef(true);
27
+ var isServer = typeof window === 'undefined';
28
+ useEffect(function() {
29
+ isMounting.current = false;
30
+ }, []);
31
+ var headers = useNextHeaders();
32
+ var nonce = safelyRunOnBrowser(function() {
33
+ return undefined;
34
+ }, {
35
+ fallback: function fallback() {
36
+ return (headers === null || headers === void 0 ? void 0 : headers.get('x-nonce')) || undefined;
37
+ }
38
+ });
39
+ useDynamicRouteWarning({
40
+ isServer: isServer,
41
+ isMounting: isMounting,
42
+ instance: instance
43
+ });
44
+ var routing = useInstantSearchRouting(passedRouting, isMounting);
45
+ return /*#__PURE__*/ React.createElement(ServerOrHydrationProvider, {
46
+ isServer: isServer,
47
+ instance: instance,
48
+ ignoreMultipleHooksWarning: ignoreMultipleHooksWarning
49
+ }, /*#__PURE__*/ React.createElement(InstantSearch, _$1(_$2({}, instantSearchProps), {
50
+ routing: routing
51
+ }), isServer && /*#__PURE__*/ React.createElement(InitializePromise, {
52
+ nonce: nonce
53
+ }), children, isServer && /*#__PURE__*/ React.createElement(TriggerSearch, {
54
+ nonce: nonce
55
+ })));
56
56
  }
57
- function ServerOrHydrationProvider(_ref2) {
58
- var isServer = _ref2.isServer,
59
- children = _ref2.children,
60
- instance = _ref2.instance,
61
- ignoreMultipleHooksWarning = _ref2.ignoreMultipleHooksWarning;
62
- var promiseRef = useRef(null);
63
- var countRef = useRef(0);
64
- var initialResults = safelyRunOnBrowser(function () {
65
- return window[InstantSearchInitialResults];
66
- });
67
- return /*#__PURE__*/React.createElement(InstantSearchRSCContext.Provider, {
68
- value: {
69
- waitForResultsRef: promiseRef,
70
- countRef: countRef,
71
- ignoreMultipleHooksWarning: ignoreMultipleHooksWarning
72
- }
73
- }, /*#__PURE__*/React.createElement(InstantSearchSSRContext.Provider, {
74
- value: {
75
- initialResults: initialResults,
76
- ssrSearchRef: isServer ? undefined : instance
77
- }
78
- }, children));
79
- }
57
+ function ServerOrHydrationProvider(param) {
58
+ var isServer = param.isServer, children = param.children, instance = param.instance, ignoreMultipleHooksWarning = param.ignoreMultipleHooksWarning;
59
+ var promiseRef = useRef(null);
60
+ var countRef = useRef(0);
61
+ var initialResults = safelyRunOnBrowser(function() {
62
+ return window[InstantSearchInitialResults];
63
+ });
64
+ return /*#__PURE__*/ React.createElement(InstantSearchRSCContext.Provider, {
65
+ value: {
66
+ waitForResultsRef: promiseRef,
67
+ countRef: countRef,
68
+ ignoreMultipleHooksWarning: ignoreMultipleHooksWarning
69
+ }
70
+ }, /*#__PURE__*/ React.createElement(InstantSearchSSRContext.Provider, {
71
+ value: {
72
+ initialResults: initialResults,
73
+ ssrSearchRef: isServer ? undefined : instance
74
+ }
75
+ }, children));
76
+ }
77
+
78
+ export { InstantSearchNext, createInstantSearchNextInstance };
@@ -1,40 +1,41 @@
1
- import { ServerInsertedHTMLContext } from "next/navigation.js";
1
+ import { ServerInsertedHTMLContext } from 'next/navigation.js';
2
2
  import { useContext } from 'react';
3
3
  import { useInstantSearchContext, useRSCContext } from 'react-instantsearch-core';
4
- import { createInsertHTML } from "./createInsertHTML.js";
5
- export function TriggerSearch(_ref) {
6
- var _waitForResultsRef$cu;
7
- var nonce = _ref.nonce;
8
- var instantsearch = useInstantSearchContext();
9
- var _useRSCContext = useRSCContext(),
10
- waitForResultsRef = _useRSCContext.waitForResultsRef;
11
- var insertHTML = useContext(ServerInsertedHTMLContext) || function () {
12
- throw new Error('Missing ServerInsertedHTMLContext');
13
- };
14
- if ((waitForResultsRef === null || waitForResultsRef === void 0 ? void 0 : (_waitForResultsRef$cu = waitForResultsRef.current) === null || _waitForResultsRef$cu === void 0 ? void 0 : _waitForResultsRef$cu.status) === 'pending') {
15
- var _instantsearch$mainHe3;
16
- if (instantsearch._hasSearchWidget) {
17
- if (instantsearch.compositionID) {
18
- var _instantsearch$mainHe;
19
- (_instantsearch$mainHe = instantsearch.mainHelper) === null || _instantsearch$mainHe === void 0 ? void 0 : _instantsearch$mainHe.searchWithComposition();
20
- } else {
21
- var _instantsearch$mainHe2;
22
- (_instantsearch$mainHe2 = instantsearch.mainHelper) === null || _instantsearch$mainHe2 === void 0 ? void 0 : _instantsearch$mainHe2.searchOnlyWithDerivedHelpers();
23
- }
24
- }
25
- instantsearch._hasRecommendWidget && ((_instantsearch$mainHe3 = instantsearch.mainHelper) === null || _instantsearch$mainHe3 === void 0 ? void 0 : _instantsearch$mainHe3.recommend());
4
+ import { createInsertHTML } from './createInsertHTML.js';
26
5
 
27
- // If there are no widgets, we inject empty initial results instantly
28
- if (!instantsearch._hasSearchWidget && !instantsearch._hasRecommendWidget) {
29
- var options = {
30
- inserted: false
31
- };
32
- insertHTML(createInsertHTML({
33
- options: options,
34
- results: {},
35
- nonce: nonce
36
- }));
6
+ function TriggerSearch(param) {
7
+ var nonce = param.nonce;
8
+ var _waitForResultsRef_current;
9
+ var instantsearch = useInstantSearchContext();
10
+ var waitForResultsRef = useRSCContext().waitForResultsRef;
11
+ var insertHTML = useContext(ServerInsertedHTMLContext) || function() {
12
+ throw new Error('Missing ServerInsertedHTMLContext');
13
+ };
14
+ if ((waitForResultsRef === null || waitForResultsRef === void 0 ? void 0 : (_waitForResultsRef_current = waitForResultsRef.current) === null || _waitForResultsRef_current === void 0 ? void 0 : _waitForResultsRef_current.status) === 'pending') {
15
+ var _instantsearch_mainHelper;
16
+ if (instantsearch._hasSearchWidget) {
17
+ if (instantsearch.compositionID) {
18
+ var _instantsearch_mainHelper1;
19
+ (_instantsearch_mainHelper1 = instantsearch.mainHelper) === null || _instantsearch_mainHelper1 === void 0 ? void 0 : _instantsearch_mainHelper1.searchWithComposition();
20
+ } else {
21
+ var _instantsearch_mainHelper2;
22
+ (_instantsearch_mainHelper2 = instantsearch.mainHelper) === null || _instantsearch_mainHelper2 === void 0 ? void 0 : _instantsearch_mainHelper2.searchOnlyWithDerivedHelpers();
23
+ }
24
+ }
25
+ instantsearch._hasRecommendWidget && ((_instantsearch_mainHelper = instantsearch.mainHelper) === null || _instantsearch_mainHelper === void 0 ? void 0 : _instantsearch_mainHelper.recommend());
26
+ // If there are no widgets, we inject empty initial results instantly
27
+ if (!instantsearch._hasSearchWidget && !instantsearch._hasRecommendWidget) {
28
+ var options = {
29
+ inserted: false
30
+ };
31
+ insertHTML(createInsertHTML({
32
+ options: options,
33
+ results: {},
34
+ nonce: nonce
35
+ }));
36
+ }
37
37
  }
38
- }
39
- return null;
40
- }
38
+ return null;
39
+ }
40
+
41
+ export { TriggerSearch };
@@ -1,19 +1,20 @@
1
1
  import React from 'react';
2
- import { htmlEscapeJsonString } from "./htmlEscape.js";
3
- export var createInsertHTML = function createInsertHTML(_ref) {
4
- var options = _ref.options,
5
- results = _ref.results,
6
- nonce = _ref.nonce;
7
- return function () {
8
- if (options.inserted) {
9
- return /*#__PURE__*/React.createElement(React.Fragment, null);
10
- }
11
- options.inserted = true;
12
- return /*#__PURE__*/React.createElement("script", {
13
- nonce: nonce,
14
- dangerouslySetInnerHTML: {
15
- __html: "window[Symbol.for(\"InstantSearchInitialResults\")] = ".concat(htmlEscapeJsonString(JSON.stringify(results)))
16
- }
17
- });
18
- };
19
- };
2
+ import { htmlEscapeJsonString } from './htmlEscape.js';
3
+
4
+ var createInsertHTML = function createInsertHTML(param) {
5
+ var options = param.options, results = param.results, nonce = param.nonce;
6
+ return function() {
7
+ if (options.inserted) {
8
+ return /*#__PURE__*/ React.createElement(React.Fragment, null);
9
+ }
10
+ options.inserted = true;
11
+ return /*#__PURE__*/ React.createElement("script", {
12
+ nonce: nonce,
13
+ dangerouslySetInnerHTML: {
14
+ __html: 'window[Symbol.for("InstantSearchInitialResults")] = '.concat(htmlEscapeJsonString(JSON.stringify(results)))
15
+ }
16
+ });
17
+ };
18
+ };
19
+
20
+ export { createInsertHTML };