react-instantsearch-router-nextjs 7.26.0 → 7.27.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/dist/cjs/index.js CHANGED
@@ -1,16 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var _object_spread = require('@swc/helpers/_/_object_spread');
4
- var history = require('instantsearch.js/cjs/lib/routers/history');
5
-
6
- function stripLocaleFromUrl(url, locale) {
7
- var includePrefixSeparator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
8
- if (!locale) {
9
- return url;
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "createInstantSearchRouterNext", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return createInstantSearchRouterNext;
10
10
  }
11
- return url.replace(new RegExp("".concat(includePrefixSeparator ? '/' : '').concat(locale, "(\\/|\\?|$)")), '$1');
12
- }
13
-
11
+ });
12
+ var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
13
+ var _object_spread = require("@swc/helpers/_/_object_spread");
14
+ var _history = /*#__PURE__*/ _interop_require_default._(require("instantsearch.js/cjs/lib/routers/history"));
15
+ var _stripLocaleFromUrl = require("./utils/stripLocaleFromUrl");
14
16
  function createInstantSearchRouterNext(options) {
15
17
  var _ref = options || {}, beforePopState = _ref.beforePopState, singletonRouter = _ref.singletonRouter, serverUrl = _ref.serverUrl, beforeStart = _ref.beforeStart, beforeDispose = _ref.beforeDispose, routerOptions = _ref.routerOptions;
16
18
  var handler;
@@ -19,7 +21,7 @@ function createInstantSearchRouterNext(options) {
19
21
  };
20
22
  // If we're rendering on the server, we create a simpler router
21
23
  if (typeof window === 'undefined') {
22
- return history(_object_spread._({
24
+ return (0, _history.default)(_object_spread._({
23
25
  getLocation: function getLocation() {
24
26
  return new URL(serverUrl);
25
27
  }
@@ -28,7 +30,7 @@ function createInstantSearchRouterNext(options) {
28
30
  /**
29
31
  * Marker to skip `routeChangeComplete` event when the push comes from the router itself.
30
32
  */ var lastPushFromThis = false;
31
- var router = history(_object_spread._({
33
+ var router = (0, _history.default)(_object_spread._({
32
34
  start: function start(onUpdate) {
33
35
  var _singletonRouter_router;
34
36
  if (beforeStart) {
@@ -51,7 +53,7 @@ function createInstantSearchRouterNext(options) {
51
53
  var previousPathname = singletonRouter.asPath.split('?')[0];
52
54
  var nextPathname = new URL(window.location.href).pathname;
53
55
  // We strip the locale from the pathname if it's present
54
- nextPathname = stripLocaleFromUrl(nextPathname, singletonRouter.locale, previousPathname !== '/');
56
+ nextPathname = (0, _stripLocaleFromUrl.stripLocaleFromUrl)(nextPathname, singletonRouter.locale, previousPathname !== '/');
55
57
  // We only want to trigger a server request when going back/forward to a different page
56
58
  return previousPathname !== nextPathname;
57
59
  }
@@ -76,7 +78,7 @@ function createInstantSearchRouterNext(options) {
76
78
  push: function push(newUrl) {
77
79
  // We need to do this because there's an error when using i18n on the
78
80
  // root path it says for example `pages/fr.js` doesn't exist
79
- var url = stripLocaleFromUrl(newUrl, singletonRouter.locale);
81
+ var url = (0, _stripLocaleFromUrl.stripLocaleFromUrl)(newUrl, singletonRouter.locale);
80
82
  // No need to provide the second argument, Next.js will know what to do
81
83
  singletonRouter.push(url, undefined, {
82
84
  shallow: true
@@ -88,5 +90,3 @@ function createInstantSearchRouterNext(options) {
88
90
  router.$$type = 'ais.nextjs';
89
91
  return router;
90
92
  }
91
-
92
- exports.createInstantSearchRouterNext = createInstantSearchRouterNext;
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "stripLocaleFromUrl", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return stripLocaleFromUrl;
10
+ }
11
+ });
12
+ function stripLocaleFromUrl(url, locale) {
13
+ var includePrefixSeparator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
14
+ if (!locale) {
15
+ return url;
16
+ }
17
+ return url.replace(new RegExp("".concat(includePrefixSeparator ? '/' : '').concat(locale, "(\\/|\\?|$)")), '$1');
18
+ }
package/dist/es/index.js CHANGED
@@ -1,13 +1,6 @@
1
1
  import { _ } from '@swc/helpers/cjs/_object_spread.cjs';
2
2
  import history from 'instantsearch.js/es/lib/routers/history.js';
3
-
4
- function stripLocaleFromUrl(url, locale) {
5
- var includePrefixSeparator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
6
- if (!locale) {
7
- return url;
8
- }
9
- return url.replace(new RegExp("".concat(includePrefixSeparator ? '/' : '').concat(locale, "(\\/|\\?|$)")), '$1');
10
- }
3
+ import { stripLocaleFromUrl } from './utils/stripLocaleFromUrl.js';
11
4
 
12
5
  function createInstantSearchRouterNext(options) {
13
6
  var _ref = options || {}, beforePopState = _ref.beforePopState, singletonRouter = _ref.singletonRouter, serverUrl = _ref.serverUrl, beforeStart = _ref.beforeStart, beforeDispose = _ref.beforeDispose, routerOptions = _ref.routerOptions;
@@ -0,0 +1,9 @@
1
+ function stripLocaleFromUrl(url, locale) {
2
+ var includePrefixSeparator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
3
+ if (!locale) {
4
+ return url;
5
+ }
6
+ return url.replace(new RegExp("".concat(includePrefixSeparator ? '/' : '').concat(locale, "(\\/|\\?|$)")), '$1');
7
+ }
8
+
9
+ export { stripLocaleFromUrl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-instantsearch-router-nextjs",
3
- "version": "7.26.0",
3
+ "version": "7.27.0",
4
4
  "description": "React InstantSearch Router for Next.js",
5
5
  "types": "dist/es/index.d.ts",
6
6
  "main": "dist/cjs/index.js",
@@ -47,8 +47,8 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@swc/helpers": "0.5.18",
50
- "instantsearch.js": "4.90.0",
51
- "react-instantsearch-core": "7.26.0"
50
+ "instantsearch.js": "4.91.0",
51
+ "react-instantsearch-core": "7.27.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@playwright/test": "1.49.1"
@@ -56,5 +56,5 @@
56
56
  "peerDependencies": {
57
57
  "next": ">= 9 && < 17"
58
58
  },
59
- "gitHead": "47788afa47a402d506f94f72ec0836fb36085b57"
59
+ "gitHead": "8bc5d6c5e9ba36ac208fe63f177cf48c5ab4e180"
60
60
  }