react-instantsearch-nextjs 0.0.1 → 0.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.
- package/LICENSE +21 -0
- package/README.md +147 -0
- package/dist/cjs/InitializePromise.js +64 -0
- package/dist/cjs/InstantSearchNext.js +81 -0
- package/dist/cjs/TriggerSearch.js +17 -0
- package/dist/cjs/index.js +16 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/warn.js +41 -0
- package/dist/es/InitializePromise.d.ts +1 -0
- package/dist/es/InitializePromise.js +55 -0
- package/dist/es/InstantSearchNext.d.ts +18 -0
- package/dist/es/InstantSearchNext.js +72 -0
- package/dist/es/TriggerSearch.d.ts +1 -0
- package/dist/es/TriggerSearch.js +11 -0
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.js +1 -0
- package/dist/es/warn.d.ts +10 -0
- package/dist/es/warn.js +33 -0
- package/package.json +57 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-present Algolia, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
2
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
- [react-instantsearch-nextjs](#react-instantsearch-nextjs)
|
|
6
|
+
- [Installation](#installation)
|
|
7
|
+
- [Usage](#usage)
|
|
8
|
+
- [API](#api)
|
|
9
|
+
- [`<InstantSearchNext>`](#instantsearchnext)
|
|
10
|
+
- [`routing` prop](#routing-prop)
|
|
11
|
+
- [Troubleshooting](#troubleshooting)
|
|
12
|
+
- [Contributing](#contributing)
|
|
13
|
+
- [License](#license)
|
|
14
|
+
|
|
15
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
16
|
+
|
|
17
|
+
# react-instantsearch-nextjs
|
|
18
|
+
|
|
19
|
+
This package provides server-side rendering for [React InstantSearch](https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/) that is compatible with [Next.js 13 App Router](https://nextjs.org/docs/app).
|
|
20
|
+
|
|
21
|
+
> [!WARNING]
|
|
22
|
+
> **This package is experimental.**
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
yarn add react-instantsearch-nextjs
|
|
28
|
+
# or with npm
|
|
29
|
+
npm install react-instantsearch-nextjs
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
> [!NOTE]
|
|
35
|
+
> You can check this documentation on [Algolia's Documentation website](https://www.algolia.com/doc/guides/building-search-ui/going-further/server-side-rendering/react/#app-router-experimental).
|
|
36
|
+
|
|
37
|
+
Your search component must be in its own file, and it shouldn't be named `page.js` or `page.tsx`.
|
|
38
|
+
|
|
39
|
+
To render the component in the browser and allow users to interact with it, include the "use client" directive at the top of your code.
|
|
40
|
+
|
|
41
|
+
```diff
|
|
42
|
+
+'use client';
|
|
43
|
+
import algoliasearch from 'algoliasearch/lite';
|
|
44
|
+
import {
|
|
45
|
+
InstantSearch,
|
|
46
|
+
SearchBox,
|
|
47
|
+
} from 'react-instantsearch';
|
|
48
|
+
|
|
49
|
+
const searchClient = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey');
|
|
50
|
+
|
|
51
|
+
export function Search() {
|
|
52
|
+
return (
|
|
53
|
+
<InstantSearch indexName="YourIndexName" searchClient={searchClient}>
|
|
54
|
+
<SearchBox />
|
|
55
|
+
{/* other widgets */}
|
|
56
|
+
</InstantSearch>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Import the `<InstantSearchNext>` component from the `react-instantsearch-nextjs` package, and replace the <%= widget_link('instantsearch', 'react') %> component with it, without changing the props.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
```diff
|
|
65
|
+
'use client';
|
|
66
|
+
import algoliasearch from 'algoliasearch/lite';
|
|
67
|
+
import {
|
|
68
|
+
- InstantSearch,
|
|
69
|
+
SearchBox,
|
|
70
|
+
} from 'react-instantsearch';
|
|
71
|
+
+import { InstantSearchNext } from 'react-instantsearch-nextjs';
|
|
72
|
+
|
|
73
|
+
const searchClient = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey');
|
|
74
|
+
|
|
75
|
+
export function Search() {
|
|
76
|
+
return (
|
|
77
|
+
- <InstantSearch indexName="YourIndexName" searchClient={searchClient}>
|
|
78
|
+
+ <InstantSearchSSRNext indexName="YourIndexName" searchClient={searchClient}>
|
|
79
|
+
<SearchBox />
|
|
80
|
+
{/* other widgets */}
|
|
81
|
+
</InstantSearch>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
To serve your search page at `/search`, create an `app/search` directory. Inside it, create a `page.js` file (or `page.tsx` if you're using TypeScript).
|
|
87
|
+
|
|
88
|
+
Make sure to [configure your route segment to be dynamic](https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamic) so that Next.js generates a new page for each request.
|
|
89
|
+
|
|
90
|
+
```jsx
|
|
91
|
+
// app/search/page.js or app/search/page.tsx
|
|
92
|
+
import { Search } from './Search'; // change this with the path to your <Search> component
|
|
93
|
+
|
|
94
|
+
export const dynamic = 'force-dynamic';
|
|
95
|
+
|
|
96
|
+
export default function Page() {
|
|
97
|
+
return <Search />;
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
You can now visit `/search` to see your server-side rendered search page.
|
|
102
|
+
|
|
103
|
+
## API
|
|
104
|
+
|
|
105
|
+
### `<InstantSearchNext>`
|
|
106
|
+
|
|
107
|
+
The `<InstantSearchNext>` component is a drop-in replacement for the `<InstantSearch>` component. It accepts the same props, and it renders the same UI.
|
|
108
|
+
|
|
109
|
+
You can check the [InstantSearch API reference](https://www.algolia.com/doc/api-reference/widgets/instantsearch/react/) for more information.
|
|
110
|
+
|
|
111
|
+
### `routing` prop
|
|
112
|
+
|
|
113
|
+
As with the `<InstantSearch>` component, you can pass a `routing` prop to the `<InstantSearchNext>` component to customize the routing behavior. The difference here is that `routing.router` takes [the same options as the `historyRouter`](https://www.algolia.com/doc/api-reference/widgets/history-router/react/).
|
|
114
|
+
|
|
115
|
+
## Troubleshooting
|
|
116
|
+
|
|
117
|
+
If you're experiencing issues, please refer to the [**Need help?**](https://algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/#need-help) section of the docs, or [open a new issue](https://github.com/algolia/instantsearch.js/issues/new?assignees=&labels=triage&template=BUG_REPORT.yml).
|
|
118
|
+
|
|
119
|
+
## Contributing
|
|
120
|
+
|
|
121
|
+
We welcome all contributors, from casual to regular 💙
|
|
122
|
+
|
|
123
|
+
- **Bug report**. Is something not working as expected? [Send a bug report][contributing-bugreport].
|
|
124
|
+
- **Feature request**. Would you like to add something to the library? [Send a feature request][contributing-featurerequest].
|
|
125
|
+
- **Documentation**. Did you find a typo in the doc? [Open an issue][contributing-newissue] and we'll take care of it.
|
|
126
|
+
- **Development**. If you don't know where to start, you can check the open issues that are [tagged easy][contributing-label-easy], the [bugs][contributing-label-bug] or [chores][contributing-label-chore].
|
|
127
|
+
|
|
128
|
+
To start contributing to code, you need to:
|
|
129
|
+
|
|
130
|
+
1. [Fork the project](https://help.github.com/articles/fork-a-repo/)
|
|
131
|
+
1. [Clone the repository](https://help.github.com/articles/cloning-a-repository/)
|
|
132
|
+
1. Install the dependencies: `yarn`
|
|
133
|
+
|
|
134
|
+
Please read [our contribution process](https://github.com/algolia/instantsearch/blob/master/CONTRIBUTING.md) to learn more.
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
React InstantSearch is [MIT licensed](../../LICENSE).
|
|
139
|
+
|
|
140
|
+
<!-- Links -->
|
|
141
|
+
|
|
142
|
+
[contributing-bugreport]: https://github.com/algolia/instantsearch/issues/new?template=BUG_REPORT.yml&labels=triage,Library%3A%20React+InstantSearch
|
|
143
|
+
[contributing-featurerequest]: https://github.com/algolia/instantsearch/discussions/new?category=ideas&labels=triage,Library%3A%20React+InstantSearch&title=Feature%20request%3A%20
|
|
144
|
+
[contributing-newissue]: https://github.com/algolia/instantsearch/issues/new?labels=triage,Library%3A%20React+InstantSearch
|
|
145
|
+
[contributing-label-easy]: https://github.com/algolia/instantsearch/issues?q=is%3Aopen+is%3Aissue+label%3A%22Difficulty%3A+Easy%22+label%3A%22Library%3A%20React+InstantSearch%22
|
|
146
|
+
[contributing-label-bug]: https://github.com/algolia/instantsearch/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Bug%22+label%3A%22Library%3A%20React+InstantSearch%22
|
|
147
|
+
[contributing-label-chore]: https://github.com/algolia/instantsearch/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Chore%22+label%3A%22Library%3A%20React+InstantSearch%22
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.InitializePromise = InitializePromise;
|
|
8
|
+
var _server = require("instantsearch.js/cjs/lib/server");
|
|
9
|
+
var _utils = require("instantsearch.js/cjs/lib/utils");
|
|
10
|
+
var _navigation = require("next/navigation");
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _reactInstantsearchCore = require("react-instantsearch-core");
|
|
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); }
|
|
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
|
+
var _ref = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
16
|
+
function InitializePromise() {
|
|
17
|
+
var search = (0, _reactInstantsearchCore.useInstantSearchContext)();
|
|
18
|
+
var waitForResultsRef = (0, _reactInstantsearchCore.useRSCContext)();
|
|
19
|
+
var insertHTML = (0, _react.useContext)(_navigation.ServerInsertedHTMLContext) || function () {
|
|
20
|
+
throw new Error('Missing ServerInsertedHTMLContext');
|
|
21
|
+
};
|
|
22
|
+
var waitForResults = function waitForResults() {
|
|
23
|
+
return new Promise(function (resolve) {
|
|
24
|
+
search.mainHelper.derivedHelpers[0].on('result', function () {
|
|
25
|
+
resolve();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var injectInitialResults = function injectInitialResults() {
|
|
30
|
+
var inserted = false;
|
|
31
|
+
var results = (0, _server.getInitialResults)(search.mainIndex);
|
|
32
|
+
insertHTML(function () {
|
|
33
|
+
if (inserted) {
|
|
34
|
+
return _ref;
|
|
35
|
+
}
|
|
36
|
+
inserted = true;
|
|
37
|
+
return /*#__PURE__*/_react.default.createElement("script", {
|
|
38
|
+
dangerouslySetInnerHTML: {
|
|
39
|
+
__html: "window[Symbol.for(\"InstantSearchInitialResults\")] = ".concat(JSON.stringify(results))
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
if ((waitForResultsRef === null || waitForResultsRef === void 0 ? void 0 : waitForResultsRef.current) === null) {
|
|
45
|
+
waitForResultsRef.current = (0, _reactInstantsearchCore.wrapPromiseWithState)(waitForResults().then(function () {
|
|
46
|
+
var shouldRefetch = false;
|
|
47
|
+
(0, _utils.walkIndex)(search.mainIndex, function (index) {
|
|
48
|
+
shouldRefetch = index.getWidgets().some(function (widget) {
|
|
49
|
+
return widget.$$type === 'ais.dynamicWidgets';
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
if (shouldRefetch) {
|
|
53
|
+
waitForResultsRef.current = (0, _reactInstantsearchCore.wrapPromiseWithState)(waitForResults().then(injectInitialResults));
|
|
54
|
+
}
|
|
55
|
+
return shouldRefetch;
|
|
56
|
+
}).then(function (shouldRefetch) {
|
|
57
|
+
if (shouldRefetch) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
injectInitialResults();
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InstantSearchNext = InstantSearchNext;
|
|
7
|
+
var _history = _interopRequireDefault(require("instantsearch.js/cjs/lib/routers/history"));
|
|
8
|
+
var _utils = require("instantsearch.js/cjs/lib/utils");
|
|
9
|
+
var _headers = require("next/headers");
|
|
10
|
+
var _navigation = require("next/navigation");
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _reactInstantsearchCore = require("react-instantsearch-core");
|
|
13
|
+
var _InitializePromise = require("./InitializePromise");
|
|
14
|
+
var _TriggerSearch = require("./TriggerSearch");
|
|
15
|
+
var _warn = require("./warn");
|
|
16
|
+
var _excluded = ["children", "routing"];
|
|
17
|
+
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); }
|
|
18
|
+
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; }
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
25
|
+
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); }
|
|
26
|
+
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); }
|
|
27
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
28
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
29
|
+
var InstantSearchInitialResults = Symbol.for('InstantSearchInitialResults');
|
|
30
|
+
var _ref2 = /*#__PURE__*/_react.default.createElement(_InitializePromise.InitializePromise, null);
|
|
31
|
+
var _ref3 = /*#__PURE__*/_react.default.createElement(_TriggerSearch.TriggerSearch, null);
|
|
32
|
+
function InstantSearchNext(_ref) {
|
|
33
|
+
var children = _ref.children,
|
|
34
|
+
passedRouting = _ref.routing,
|
|
35
|
+
instantSearchProps = _objectWithoutProperties(_ref, _excluded);
|
|
36
|
+
var pathname = (0, _navigation.usePathname)();
|
|
37
|
+
var searchParams = (0, _navigation.useSearchParams)();
|
|
38
|
+
var router = (0, _navigation.useRouter)();
|
|
39
|
+
var isMounting = (0, _react.useRef)(true);
|
|
40
|
+
(0, _react.useEffect)(function () {
|
|
41
|
+
isMounting.current = false;
|
|
42
|
+
}, []);
|
|
43
|
+
var promiseRef = (0, _react.useRef)(null);
|
|
44
|
+
var initialResults = (0, _utils.safelyRunOnBrowser)(function () {
|
|
45
|
+
return window[InstantSearchInitialResults];
|
|
46
|
+
});
|
|
47
|
+
var routing = passedRouting && {};
|
|
48
|
+
if (routing) {
|
|
49
|
+
var browserHistoryOptions = {};
|
|
50
|
+
browserHistoryOptions.getLocation = function () {
|
|
51
|
+
if (typeof window === 'undefined') {
|
|
52
|
+
var url = "".concat((0, _headers.headers)().get('x-forwarded-proto') || 'http', "://").concat((0, _headers.headers)().get('host')).concat(pathname, "?").concat(searchParams);
|
|
53
|
+
return new URL(url);
|
|
54
|
+
}
|
|
55
|
+
if (isMounting.current) {
|
|
56
|
+
return new URL("".concat(window.location.protocol, "//").concat(window.location.host).concat(pathname, "?").concat(searchParams));
|
|
57
|
+
}
|
|
58
|
+
return window.location;
|
|
59
|
+
};
|
|
60
|
+
browserHistoryOptions.push = function push(url) {
|
|
61
|
+
// This is to skip the push with empty routeState on dispose as it would clear params set on a <Link>
|
|
62
|
+
if (this.isDisposed) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
router.push(url);
|
|
66
|
+
};
|
|
67
|
+
if (_typeof(passedRouting) === 'object') {
|
|
68
|
+
browserHistoryOptions = _objectSpread(_objectSpread({}, browserHistoryOptions), passedRouting.router);
|
|
69
|
+
routing.stateMapping = passedRouting.stateMapping;
|
|
70
|
+
}
|
|
71
|
+
routing.router = (0, _history.default)(browserHistoryOptions);
|
|
72
|
+
}
|
|
73
|
+
process.env.NODE_ENV === 'development' ? (0, _warn.warn)(false, "InstantSearchNext relies on experimental APIs and may break in the future.\nThis message will only be displayed in development mode.") : void 0;
|
|
74
|
+
return /*#__PURE__*/_react.default.createElement(_reactInstantsearchCore.InstantSearchRSCContext.Provider, {
|
|
75
|
+
value: promiseRef
|
|
76
|
+
}, /*#__PURE__*/_react.default.createElement(_reactInstantsearchCore.InstantSearchSSRProvider, {
|
|
77
|
+
initialResults: initialResults
|
|
78
|
+
}, /*#__PURE__*/_react.default.createElement(_reactInstantsearchCore.InstantSearch, _extends({}, instantSearchProps, {
|
|
79
|
+
routing: routing
|
|
80
|
+
}), !initialResults && _ref2, children, !initialResults && _ref3)));
|
|
81
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TriggerSearch = TriggerSearch;
|
|
7
|
+
var _reactInstantsearchCore = require("react-instantsearch-core");
|
|
8
|
+
function TriggerSearch() {
|
|
9
|
+
var _waitForResultsRef$cu;
|
|
10
|
+
var instantsearch = (0, _reactInstantsearchCore.useInstantSearchContext)();
|
|
11
|
+
var waitForResultsRef = (0, _reactInstantsearchCore.useRSCContext)();
|
|
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();
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _InstantSearchNext = require("./InstantSearchNext");
|
|
7
|
+
Object.keys(_InstantSearchNext).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _InstantSearchNext[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _InstantSearchNext[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "commonjs", "sideEffects": false }
|
package/dist/cjs/warn.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.warn = warn;
|
|
7
|
+
exports.warnCache = void 0;
|
|
8
|
+
/* eslint-disable no-console, no-empty */
|
|
9
|
+
|
|
10
|
+
var warnCache = {
|
|
11
|
+
current: {}
|
|
12
|
+
};
|
|
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
|
+
exports.warnCache = warnCache;
|
|
19
|
+
function warn(condition, message) {
|
|
20
|
+
if (!(process.env.NODE_ENV === 'development')) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (condition) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
var sanitizedMessage = message.trim();
|
|
27
|
+
var hasAlreadyPrinted = warnCache.current[sanitizedMessage];
|
|
28
|
+
if (!hasAlreadyPrinted) {
|
|
29
|
+
warnCache.current[sanitizedMessage] = true;
|
|
30
|
+
var warning = "[react-instantsearch-nextjs] ".concat(sanitizedMessage);
|
|
31
|
+
console.warn(warning);
|
|
32
|
+
try {
|
|
33
|
+
// Welcome to debugging InstantSearch.
|
|
34
|
+
//
|
|
35
|
+
// This error was thrown as a convenience so that you can find the source
|
|
36
|
+
// of the warning that appears in the console by enabling "Pause on exceptions"
|
|
37
|
+
// in your debugger.
|
|
38
|
+
throw new Error(warning);
|
|
39
|
+
} catch (error) {}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function InitializePromise(): null;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getInitialResults } from "instantsearch.js/es/lib/server.js";
|
|
2
|
+
import { walkIndex } from "instantsearch.js/es/lib/utils/index.js";
|
|
3
|
+
import { ServerInsertedHTMLContext } from "next/navigation.js";
|
|
4
|
+
import React, { useContext } from 'react';
|
|
5
|
+
import { useInstantSearchContext, useRSCContext, wrapPromiseWithState } from 'react-instantsearch-core';
|
|
6
|
+
var _ref = /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
7
|
+
export function InitializePromise() {
|
|
8
|
+
var search = useInstantSearchContext();
|
|
9
|
+
var waitForResultsRef = useRSCContext();
|
|
10
|
+
var insertHTML = useContext(ServerInsertedHTMLContext) || function () {
|
|
11
|
+
throw new Error('Missing ServerInsertedHTMLContext');
|
|
12
|
+
};
|
|
13
|
+
var waitForResults = function waitForResults() {
|
|
14
|
+
return new Promise(function (resolve) {
|
|
15
|
+
search.mainHelper.derivedHelpers[0].on('result', function () {
|
|
16
|
+
resolve();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var injectInitialResults = function injectInitialResults() {
|
|
21
|
+
var inserted = false;
|
|
22
|
+
var results = getInitialResults(search.mainIndex);
|
|
23
|
+
insertHTML(function () {
|
|
24
|
+
if (inserted) {
|
|
25
|
+
return _ref;
|
|
26
|
+
}
|
|
27
|
+
inserted = true;
|
|
28
|
+
return /*#__PURE__*/React.createElement("script", {
|
|
29
|
+
dangerouslySetInnerHTML: {
|
|
30
|
+
__html: "window[Symbol.for(\"InstantSearchInitialResults\")] = ".concat(JSON.stringify(results))
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
if ((waitForResultsRef === null || waitForResultsRef === void 0 ? void 0 : waitForResultsRef.current) === null) {
|
|
36
|
+
waitForResultsRef.current = wrapPromiseWithState(waitForResults().then(function () {
|
|
37
|
+
var shouldRefetch = false;
|
|
38
|
+
walkIndex(search.mainIndex, function (index) {
|
|
39
|
+
shouldRefetch = index.getWidgets().some(function (widget) {
|
|
40
|
+
return widget.$$type === 'ais.dynamicWidgets';
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
if (shouldRefetch) {
|
|
44
|
+
waitForResultsRef.current = wrapPromiseWithState(waitForResults().then(injectInitialResults));
|
|
45
|
+
}
|
|
46
|
+
return shouldRefetch;
|
|
47
|
+
}).then(function (shouldRefetch) {
|
|
48
|
+
if (shouldRefetch) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
injectInitialResults();
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { InitialResults, StateMapping, UiState } from 'instantsearch.js';
|
|
2
|
+
import type { BrowserHistoryArgs } from 'instantsearch.js/es/lib/routers/history';
|
|
3
|
+
import type { InstantSearchProps } from 'react-instantsearch-core';
|
|
4
|
+
declare const InstantSearchInitialResults: unique symbol;
|
|
5
|
+
declare global {
|
|
6
|
+
interface Window {
|
|
7
|
+
[InstantSearchInitialResults]?: InitialResults;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export type InstantSearchNextRouting<TUiState, TRouteState> = {
|
|
11
|
+
router?: Partial<BrowserHistoryArgs<TRouteState>>;
|
|
12
|
+
stateMapping?: StateMapping<TUiState, TRouteState>;
|
|
13
|
+
};
|
|
14
|
+
export type InstantSearchNextProps<TUiState extends UiState = UiState, TRouteState = TUiState> = Omit<InstantSearchProps<TUiState, TRouteState>, 'routing'> & {
|
|
15
|
+
routing?: InstantSearchNextRouting<TUiState, TRouteState> | boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function InstantSearchNext<TUiState extends UiState = UiState, TRouteState = TUiState>({ children, routing: passedRouting, ...instantSearchProps }: InstantSearchNextProps<TUiState, TRouteState>): JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var _excluded = ["children", "routing"];
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
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); }
|
|
8
|
+
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); }
|
|
9
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
11
|
+
import historyRouter from "instantsearch.js/es/lib/routers/history.js";
|
|
12
|
+
import { safelyRunOnBrowser } from "instantsearch.js/es/lib/utils/index.js";
|
|
13
|
+
import { headers } from "next/headers.js";
|
|
14
|
+
import { usePathname, useSearchParams, useRouter } from "next/navigation.js";
|
|
15
|
+
import React, { useEffect, useRef } from 'react';
|
|
16
|
+
import { InstantSearch, InstantSearchRSCContext, InstantSearchSSRProvider } from 'react-instantsearch-core';
|
|
17
|
+
import { InitializePromise } from "./InitializePromise.js";
|
|
18
|
+
import { TriggerSearch } from "./TriggerSearch.js";
|
|
19
|
+
import { warn } from "./warn.js";
|
|
20
|
+
var InstantSearchInitialResults = Symbol.for('InstantSearchInitialResults');
|
|
21
|
+
var _ref2 = /*#__PURE__*/React.createElement(InitializePromise, null);
|
|
22
|
+
var _ref3 = /*#__PURE__*/React.createElement(TriggerSearch, null);
|
|
23
|
+
export function InstantSearchNext(_ref) {
|
|
24
|
+
var children = _ref.children,
|
|
25
|
+
passedRouting = _ref.routing,
|
|
26
|
+
instantSearchProps = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
var pathname = usePathname();
|
|
28
|
+
var searchParams = useSearchParams();
|
|
29
|
+
var router = useRouter();
|
|
30
|
+
var isMounting = useRef(true);
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
isMounting.current = false;
|
|
33
|
+
}, []);
|
|
34
|
+
var promiseRef = useRef(null);
|
|
35
|
+
var initialResults = safelyRunOnBrowser(function () {
|
|
36
|
+
return window[InstantSearchInitialResults];
|
|
37
|
+
});
|
|
38
|
+
var routing = passedRouting && {};
|
|
39
|
+
if (routing) {
|
|
40
|
+
var browserHistoryOptions = {};
|
|
41
|
+
browserHistoryOptions.getLocation = function () {
|
|
42
|
+
if (typeof window === 'undefined') {
|
|
43
|
+
var url = "".concat(headers().get('x-forwarded-proto') || 'http', "://").concat(headers().get('host')).concat(pathname, "?").concat(searchParams);
|
|
44
|
+
return new URL(url);
|
|
45
|
+
}
|
|
46
|
+
if (isMounting.current) {
|
|
47
|
+
return new URL("".concat(window.location.protocol, "//").concat(window.location.host).concat(pathname, "?").concat(searchParams));
|
|
48
|
+
}
|
|
49
|
+
return window.location;
|
|
50
|
+
};
|
|
51
|
+
browserHistoryOptions.push = function push(url) {
|
|
52
|
+
// This is to skip the push with empty routeState on dispose as it would clear params set on a <Link>
|
|
53
|
+
if (this.isDisposed) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
router.push(url);
|
|
57
|
+
};
|
|
58
|
+
if (_typeof(passedRouting) === 'object') {
|
|
59
|
+
browserHistoryOptions = _objectSpread(_objectSpread({}, browserHistoryOptions), passedRouting.router);
|
|
60
|
+
routing.stateMapping = passedRouting.stateMapping;
|
|
61
|
+
}
|
|
62
|
+
routing.router = historyRouter(browserHistoryOptions);
|
|
63
|
+
}
|
|
64
|
+
process.env.NODE_ENV === 'development' ? warn(false, "InstantSearchNext relies on experimental APIs and may break in the future.\nThis message will only be displayed in development mode.") : void 0;
|
|
65
|
+
return /*#__PURE__*/React.createElement(InstantSearchRSCContext.Provider, {
|
|
66
|
+
value: promiseRef
|
|
67
|
+
}, /*#__PURE__*/React.createElement(InstantSearchSSRProvider, {
|
|
68
|
+
initialResults: initialResults
|
|
69
|
+
}, /*#__PURE__*/React.createElement(InstantSearch, _extends({}, instantSearchProps, {
|
|
70
|
+
routing: routing
|
|
71
|
+
}), !initialResults && _ref2, children, !initialResults && _ref3)));
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function TriggerSearch(): null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useInstantSearchContext, useRSCContext } from 'react-instantsearch-core';
|
|
2
|
+
export function TriggerSearch() {
|
|
3
|
+
var _waitForResultsRef$cu;
|
|
4
|
+
var instantsearch = useInstantSearchContext();
|
|
5
|
+
var waitForResultsRef = useRSCContext();
|
|
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();
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InstantSearchNext';
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./InstantSearchNext.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type WarnCache = {
|
|
2
|
+
current: Record<string, boolean>;
|
|
3
|
+
};
|
|
4
|
+
export declare const warnCache: WarnCache;
|
|
5
|
+
/**
|
|
6
|
+
* Logs a warning if the condition is not met.
|
|
7
|
+
* This is used to log issues in development environment only.
|
|
8
|
+
*/
|
|
9
|
+
export declare function warn(condition: boolean, message: string): void;
|
|
10
|
+
export {};
|
package/dist/es/warn.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* eslint-disable no-console, no-empty */
|
|
2
|
+
|
|
3
|
+
export var warnCache = {
|
|
4
|
+
current: {}
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Logs a warning if the condition is not met.
|
|
9
|
+
* This is used to log issues in development environment only.
|
|
10
|
+
*/
|
|
11
|
+
export function warn(condition, message) {
|
|
12
|
+
if (!(process.env.NODE_ENV === 'development')) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (condition) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
var sanitizedMessage = message.trim();
|
|
19
|
+
var hasAlreadyPrinted = warnCache.current[sanitizedMessage];
|
|
20
|
+
if (!hasAlreadyPrinted) {
|
|
21
|
+
warnCache.current[sanitizedMessage] = true;
|
|
22
|
+
var warning = "[react-instantsearch-nextjs] ".concat(sanitizedMessage);
|
|
23
|
+
console.warn(warning);
|
|
24
|
+
try {
|
|
25
|
+
// Welcome to debugging InstantSearch.
|
|
26
|
+
//
|
|
27
|
+
// This error was thrown as a convenience so that you can find the source
|
|
28
|
+
// of the warning that appears in the console by enabling "Pause on exceptions"
|
|
29
|
+
// in your debugger.
|
|
30
|
+
throw new Error(warning);
|
|
31
|
+
} catch (error) {}
|
|
32
|
+
}
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-instantsearch-nextjs",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React InstantSearch SSR utilities for Next.js",
|
|
5
|
+
"source": "src/index.ts",
|
|
6
|
+
"types": "dist/es/index.d.ts",
|
|
7
|
+
"main": "dist/cjs/index.js",
|
|
8
|
+
"module": "dist/es/index.js",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": {
|
|
11
|
+
"types": "./dist/es/index.d.ts",
|
|
12
|
+
"require": "./dist/cjs/index.js",
|
|
13
|
+
"default": "./dist/es/index.js"
|
|
14
|
+
},
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"homepage": "https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/algolia/instantsearch"
|
|
21
|
+
},
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "Algolia, Inc.",
|
|
24
|
+
"url": "https://www.algolia.com"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"algolia",
|
|
28
|
+
"ssr",
|
|
29
|
+
"app",
|
|
30
|
+
"app router",
|
|
31
|
+
"fast",
|
|
32
|
+
"instantsearch",
|
|
33
|
+
"react",
|
|
34
|
+
"search",
|
|
35
|
+
"next",
|
|
36
|
+
"nextjs"
|
|
37
|
+
],
|
|
38
|
+
"files": [
|
|
39
|
+
"README.md",
|
|
40
|
+
"dist"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"clean": "rm -rf dist",
|
|
44
|
+
"build": "yarn build:cjs && yarn build:es && yarn build:types",
|
|
45
|
+
"build:cjs": "BABEL_ENV=cjs babel src --root-mode upward --extensions '.js,.ts,.tsx' --out-dir dist/cjs --ignore '**/__tests__/**/*','**/__mocks__/**/*' --quiet && ../../scripts/prepare-cjs.sh",
|
|
46
|
+
"build:es": "BABEL_ENV=es babel src --root-mode upward --extensions '.js,.ts,.tsx' --out-dir dist/es --ignore '**/__tests__/**/*','**/__mocks__/**/*' --quiet",
|
|
47
|
+
"build:types": "tsc -p ./tsconfig.declaration.json --outDir ./dist/es",
|
|
48
|
+
"test:exports": "node ./__tests__/module/is-es-module.mjs && node ./__tests__/module/is-cjs-module.cjs"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"instantsearch.js": "4.57.0",
|
|
52
|
+
"next": "13.5.1",
|
|
53
|
+
"react-instantsearch-core": "7.1.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"next": ">= 13.4 && < 14",
|
|
57
|
+
"react-instantsearch": ">= 7.1.0 && < 8"
|
|
58
|
+
},
|
|
59
|
+
"gitHead": "b2196f01f03c6bea37a3aa048e4e5b45a9bbf33d"
|
|
5
60
|
}
|