@prezly/theme-kit-nextjs 8.0.0 → 8.0.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.
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.DEFAULT_REQUEST_ORIGIN_HEADER = exports.DEFAULT_LOCALE_CODE_HEADER = void 0;
7
7
  exports.getLocaleCodeFromHeader = getLocaleCodeFromHeader;
8
- exports.getRequestOriginFromHeader = getRequestOriginFromHeader;
9
8
  exports.handle = handle;
10
9
  var _themeKitCore = require("@prezly/theme-kit-core");
11
10
  var _themeKitIntl = require("@prezly/theme-kit-intl");
@@ -33,14 +32,12 @@ function _handle() {
33
32
  var {
34
33
  router,
35
34
  localeCodeHeader = DEFAULT_LOCALE_CODE_HEADER,
36
- requestOriginHeader = DEFAULT_REQUEST_ORIGIN_HEADER,
37
35
  toLocaleSlug = _themeKitCore.Routing.getShortestLocaleSlug
38
36
  } = config;
39
37
  var [defaultLocale, locales] = yield _themeKitCore.AsyncResolvable.resolve(config.defaultLocale, config.locales);
40
38
  var {
41
39
  pathname,
42
- searchParams,
43
- origin
40
+ searchParams
44
41
  } = request.nextUrl;
45
42
  var match = router.match(pathname, searchParams, {
46
43
  isSupportedLocale(localeSlug) {
@@ -58,8 +55,7 @@ function _handle() {
58
55
  defaultLocale;
59
56
  return _server.NextResponse.rewrite(new URL("/".concat(_localeCode, "/_error404"), request.nextUrl), {
60
57
  headers: {
61
- [localeCodeHeader]: _localeCode,
62
- [requestOriginHeader]: origin
58
+ [localeCodeHeader]: _localeCode
63
59
  }
64
60
  });
65
61
  }
@@ -86,8 +82,7 @@ function _handle() {
86
82
  }, match.params));
87
83
  return _server.NextResponse.rewrite(new URL(rewrite, request.nextUrl), {
88
84
  headers: {
89
- [localeCodeHeader]: localeCode,
90
- [requestOriginHeader]: origin
85
+ [localeCodeHeader]: localeCode
91
86
  }
92
87
  });
93
88
  });
@@ -113,22 +108,6 @@ function getLocaleCodeFromHeader() {
113
108
  }
114
109
  return _themeKitIntl.Locale.from(code).code || undefined; // convert empty string to `undefined`
115
110
  }
116
-
117
- /**
118
- * Get the request `origin` attached to the request headers.
119
- *
120
- * WARNING: Calling this function will opt out of Next.js optimizations.
121
- * Only call it when absolutely necessary.
122
- * See https://nextjs.org/docs/app/building-your-application/rendering/server-components#dynamic-functions
123
- */
124
- function getRequestOriginFromHeader() {
125
- var requestOriginHeader = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_REQUEST_ORIGIN_HEADER;
126
- var origin = (0, _headers.headers)().get(requestOriginHeader);
127
- if (origin === null) {
128
- throw new Error("Request origin header (".concat(requestOriginHeader, ") is not set. Please check if the middleware is configured properly."));
129
- }
130
- return origin;
131
- }
132
111
  function isTheoreticallySupportedLocaleSlug(localeSlug) {
133
112
  return _slugs.slugs.includes(localeSlug);
134
113
  }
@@ -28,12 +28,6 @@ export type Configuration = {
28
28
  * "not-found" pages, which do not have access to request path.
29
29
  */
30
30
  localeCodeHeader?: string;
31
- /**
32
- * The middleware will attach the request URL `origin` value to the
33
- * rewritten request headers. This helps to get the request origin
34
- * (protocol + host) anywhere in the app.
35
- */
36
- requestOriginHeader?: string;
37
31
  };
38
32
  type Awaitable<T> = T | Promise<T> | PromiseLike<T>;
39
33
  export type Router = {
@@ -90,12 +84,4 @@ export interface LocaleMatchContext {
90
84
  * See https://nextjs.org/docs/app/api-reference/file-conventions/not-found#props
91
85
  */
92
86
  export declare function getLocaleCodeFromHeader(localeCodeHeader?: string): Locale.Code | undefined;
93
- /**
94
- * Get the request `origin` attached to the request headers.
95
- *
96
- * WARNING: Calling this function will opt out of Next.js optimizations.
97
- * Only call it when absolutely necessary.
98
- * See https://nextjs.org/docs/app/building-your-application/rendering/server-components#dynamic-functions
99
- */
100
- export declare function getRequestOriginFromHeader(requestOriginHeader?: string): `http://${string}` | `https://${string}`;
101
87
  export {};
@@ -26,14 +26,12 @@ function _handle() {
26
26
  var {
27
27
  router,
28
28
  localeCodeHeader = DEFAULT_LOCALE_CODE_HEADER,
29
- requestOriginHeader = DEFAULT_REQUEST_ORIGIN_HEADER,
30
29
  toLocaleSlug = Routing.getShortestLocaleSlug
31
30
  } = config;
32
31
  var [defaultLocale, locales] = yield AsyncResolvable.resolve(config.defaultLocale, config.locales);
33
32
  var {
34
33
  pathname,
35
- searchParams,
36
- origin
34
+ searchParams
37
35
  } = request.nextUrl;
38
36
  var match = router.match(pathname, searchParams, {
39
37
  isSupportedLocale(localeSlug) {
@@ -51,8 +49,7 @@ function _handle() {
51
49
  defaultLocale;
52
50
  return NextResponse.rewrite(new URL("/".concat(_localeCode, "/_error404"), request.nextUrl), {
53
51
  headers: {
54
- [localeCodeHeader]: _localeCode,
55
- [requestOriginHeader]: origin
52
+ [localeCodeHeader]: _localeCode
56
53
  }
57
54
  });
58
55
  }
@@ -79,8 +76,7 @@ function _handle() {
79
76
  }, match.params));
80
77
  return NextResponse.rewrite(new URL(rewrite, request.nextUrl), {
81
78
  headers: {
82
- [localeCodeHeader]: localeCode,
83
- [requestOriginHeader]: origin
79
+ [localeCodeHeader]: localeCode
84
80
  }
85
81
  });
86
82
  });
@@ -106,22 +102,6 @@ export function getLocaleCodeFromHeader() {
106
102
  }
107
103
  return Locale.from(code).code || undefined; // convert empty string to `undefined`
108
104
  }
109
-
110
- /**
111
- * Get the request `origin` attached to the request headers.
112
- *
113
- * WARNING: Calling this function will opt out of Next.js optimizations.
114
- * Only call it when absolutely necessary.
115
- * See https://nextjs.org/docs/app/building-your-application/rendering/server-components#dynamic-functions
116
- */
117
- export function getRequestOriginFromHeader() {
118
- var requestOriginHeader = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_REQUEST_ORIGIN_HEADER;
119
- var origin = headers().get(requestOriginHeader);
120
- if (origin === null) {
121
- throw new Error("Request origin header (".concat(requestOriginHeader, ") is not set. Please check if the middleware is configured properly."));
122
- }
123
- return origin;
124
- }
125
105
  function isTheoreticallySupportedLocaleSlug(localeSlug) {
126
106
  return slugs.includes(localeSlug);
127
107
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prezly/theme-kit-nextjs",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "description": "Data layer and utility library for developing Prezly themes with NextJS",
5
5
  "type": "module",
6
6
  "main": "build/index.mjs",
@@ -92,7 +92,7 @@
92
92
  }
93
93
  },
94
94
  "dependencies": {
95
- "@prezly/theme-kit-core": "^8.0.0",
95
+ "@prezly/theme-kit-core": "^8.0.1",
96
96
  "@prezly/theme-kit-intl": "^8.0.0",
97
97
  "@prezly/theme-kit-react": "^8.0.0",
98
98
  "@technically/is-not-undefined": "^1.0.0",
@@ -107,5 +107,5 @@
107
107
  "access": "public"
108
108
  },
109
109
  "sideEffects": false,
110
- "gitHead": "2561eeb2181adf7e01783ac5bddaafab70a04b44"
110
+ "gitHead": "3068afdd286035a4d0cf106ca25070114a779b25"
111
111
  }