@koine/next 2.0.0-beta.2 → 2.0.0-beta.4

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.
Files changed (112) hide show
  1. package/12/AnalyticsGoogle.js +65 -25
  2. package/12/AnalyticsGoogle.mjs +41 -15
  3. package/12/DisableErrorOverlay.js +29 -16
  4. package/12/DisableErrorOverlay.mjs +8 -5
  5. package/12/DynamicNamespaces.d.ts +1 -1
  6. package/12/DynamicNamespaces.js +22 -12
  7. package/12/DynamicNamespaces.mjs +1 -2
  8. package/12/Favicon.js +28 -9
  9. package/12/Favicon.mjs +6 -2
  10. package/12/Link.d.ts +1 -1
  11. package/12/Link.js +36 -13
  12. package/12/Link.mjs +14 -6
  13. package/12/NextProgress.js +47 -24
  14. package/12/NextProgress.mjs +26 -17
  15. package/12/Seo.d.ts +1 -1
  16. package/12/Seo.js +27 -32
  17. package/12/Seo.mjs +5 -4
  18. package/12/SeoDefaults.d.ts +1 -1
  19. package/12/SeoDefaults.js +27 -13
  20. package/12/SeoDefaults.mjs +5 -3
  21. package/12/T.d.ts +1 -1
  22. package/12/T.js +42 -16
  23. package/12/T.mjs +20 -6
  24. package/12/ThemeContext.js +22 -7
  25. package/12/ThemeContext.mjs +3 -3
  26. package/12/ThemeProvider.js +164 -147
  27. package/12/ThemeProvider.mjs +139 -129
  28. package/12/TransText.js +22 -7
  29. package/12/TransText.mjs +1 -1
  30. package/12/app/AppHead.js +29 -9
  31. package/12/app/AppHead.mjs +8 -2
  32. package/12/app/AppMain.d.ts +4 -4
  33. package/12/app/AppMain.js +5 -1
  34. package/12/app/AppMain.mjs +1 -1
  35. package/12/app/css/AppMain.js +37 -16
  36. package/12/app/css/AppMain.mjs +15 -5
  37. package/12/app/css/AppTheme.d.ts +1 -1
  38. package/12/app/css/AppTheme.js +28 -13
  39. package/12/app/css/AppTheme.mjs +7 -4
  40. package/12/app/css/auth/index.d.ts +1 -1
  41. package/12/app/css/auth/index.js +38 -15
  42. package/12/app/css/auth/index.mjs +17 -6
  43. package/12/app/css/index.d.ts +1 -1
  44. package/12/app/css/index.js +34 -59
  45. package/12/app/css/index.mjs +14 -6
  46. package/12/app/index.js +6 -4
  47. package/12/app/sc/AppMain.js +68 -27
  48. package/12/app/sc/AppMain.mjs +46 -13
  49. package/12/app/sc/AppTheme.d.ts +1 -1
  50. package/12/app/sc/AppTheme.js +31 -13
  51. package/12/app/sc/AppTheme.mjs +9 -4
  52. package/12/app/sc/auth/index.d.ts +1 -1
  53. package/12/app/sc/auth/index.js +38 -15
  54. package/12/app/sc/auth/index.mjs +17 -6
  55. package/12/app/sc/index.d.ts +1 -1
  56. package/12/app/sc/index.js +34 -61
  57. package/12/app/sc/index.mjs +14 -6
  58. package/12/document/Document.js +47 -29
  59. package/12/document/Document.mjs +24 -14
  60. package/12/document/css/index.js +47 -32
  61. package/12/document/css/index.mjs +26 -18
  62. package/12/document/index.js +18 -6
  63. package/12/document/sc/index.js +71 -65
  64. package/12/document/sc/index.mjs +46 -45
  65. package/12/getT.js +22 -13
  66. package/12/getT.mjs +2 -4
  67. package/12/index.js +99 -51
  68. package/12/index.mjs +2 -2
  69. package/12/seoBuildTags.js +81 -76
  70. package/12/seoBuildTags.mjs +59 -55
  71. package/12/to.js +21 -19
  72. package/12/to.mjs +4 -10
  73. package/12/translationAsOptions.js +15 -9
  74. package/12/translationAsOptions.mjs +6 -6
  75. package/12/types-i18n.js +4 -3
  76. package/12/types-i18n.mjs +1 -2
  77. package/12/types-seo.js +3 -1
  78. package/12/types-seo.mjs +1 -1
  79. package/12/useBackUrl.js +30 -16
  80. package/12/useBackUrl.mjs +8 -8
  81. package/12/useDateFormat.js +37 -38
  82. package/12/useDateFormat.mjs +15 -28
  83. package/12/useForm.d.ts +1 -1
  84. package/12/useForm.js +46 -20
  85. package/12/useForm.mjs +25 -13
  86. package/12/useLocale.js +22 -8
  87. package/12/useT.d.ts +1 -1
  88. package/12/useT.js +53 -39
  89. package/12/useT.mjs +32 -14
  90. package/12/useTheme.js +22 -11
  91. package/12/useTheme.mjs +1 -2
  92. package/12/useTo.js +23 -16
  93. package/12/useTo.mjs +3 -10
  94. package/README.md +1 -1
  95. package/config/index.js +225 -251
  96. package/config/index.mjs +187 -204
  97. package/getSiteUrl.js +22 -15
  98. package/getSiteUrl.mjs +2 -4
  99. package/index.js +19 -6
  100. package/load.js +21 -8
  101. package/load.mjs +3 -4
  102. package/package.json +19 -17
  103. package/12/app/css/auth/package.json +0 -6
  104. package/12/app/css/package.json +0 -6
  105. package/12/app/package.json +0 -6
  106. package/12/app/sc/auth/package.json +0 -6
  107. package/12/app/sc/package.json +0 -6
  108. package/12/document/css/package.json +0 -6
  109. package/12/document/package.json +0 -6
  110. package/12/document/sc/package.json +0 -6
  111. package/12/package.json +0 -6
  112. package/config/package.json +0 -6
package/config/index.js CHANGED
@@ -1,62 +1,63 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withKoine = exports.getRewrites = exports.getRedirects = exports.getPathRedirect = exports.getPathRewrite = exports.encodePathname = exports.toPath = exports.normaliseUrlPathname = void 0;
4
- var tslib_1 = require("tslib");
5
- /**
6
- * Normalise pathname
7
- *
8
- * From a path like `/some//malformed/path///` it returns `some/malformed/path`
9
- *
10
- * - Removes subsequent slashes
11
- * - Removing initial and ending slashes
12
- * - Returns an empty string `"""` if only slashes are given
13
- */
14
- function normaliseUrlPathname(pathname) {
15
- if (pathname === void 0) { pathname = ""; }
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ normaliseUrlPathname: function() {
13
+ return normaliseUrlPathname;
14
+ },
15
+ toPath: function() {
16
+ return toPath;
17
+ },
18
+ encodePathname: function() {
19
+ return encodePathname;
20
+ },
21
+ getPathRewrite: function() {
22
+ return getPathRewrite;
23
+ },
24
+ getPathRedirect: function() {
25
+ return getPathRedirect;
26
+ },
27
+ getRedirects: function() {
28
+ return getRedirects;
29
+ },
30
+ getRewrites: function() {
31
+ return getRewrites;
32
+ },
33
+ withKoine: function() {
34
+ return withKoine;
35
+ },
36
+ default: function() {
37
+ return _default;
38
+ }
39
+ });
40
+ function normaliseUrlPathname(pathname = "") {
16
41
  // with return pathname.replace(/\/+\//g, "/").replace(/^\/+(.*?)\/+$/, "$1");
17
42
  // we would instead return a single slash if only slashes are given
18
43
  return pathname.replace(/\/+\//g, "/").replace(/^\/*(.*?)\/*$/, "$1");
19
44
  }
20
- exports.normaliseUrlPathname = normaliseUrlPathname;
21
- /**
22
- * Transform to path any absolute or relative URL
23
- *
24
- * Useful when setting up `rewrites` and `redirects` especally in a [multi-zones
25
- * setup](https://nextjs.org/docs/advanced-features/multi-zones).
26
- *
27
- * From a path like `http://localhost/some//malformed/path///` it returns `/some/malformed/path`
28
- *
29
- * @see {@link normaliseUrlPathname}
30
- */
31
- function toPath(urlOrPathname) {
32
- if (urlOrPathname === void 0) { urlOrPathname = ""; }
33
- var pathname = "";
45
+ function toPath(urlOrPathname = "") {
46
+ let pathname = "";
34
47
  try {
35
- var parsed = new URL(urlOrPathname);
48
+ const parsed = new URL(urlOrPathname);
36
49
  pathname = parsed.pathname;
37
- }
38
- catch (e) {
50
+ } catch (e) {
39
51
  pathname = urlOrPathname;
40
52
  }
41
53
  // with return pathname.replace(/\/+\//g, "/").replace(/^\/+(.*?)\/+$/, "$1");
42
54
  // we would instead return a single slash if only slashes are given
43
55
  return pathname.replace(/\/+\//g, "/").replace(/^\/*(.*?)\/*$/, "$1");
44
56
  }
45
- exports.toPath = toPath;
46
- /**
47
- * Clean a pathname and encode each part
48
- *
49
- * @see {@link normaliseUrlPathname}
50
- */
51
- function encodePathname(pathname) {
52
- if (pathname === void 0) { pathname = ""; }
53
- var parts = normaliseUrlPathname(pathname).split("/");
54
- return parts
55
- .filter(function (part) { return !!part; })
56
- .map(function (part) { return encodeURIComponent(part); })
57
- .join("/");
57
+ function encodePathname(pathname = "") {
58
+ const parts = normaliseUrlPathname(pathname).split("/");
59
+ return parts.filter((part)=>!!part).map((part)=>encodeURIComponent(part)).join("/");
58
60
  }
59
- exports.encodePathname = encodePathname;
60
61
  /**
61
62
  * Transform the route translated defintion into a `pathname` and a `template`.
62
63
  *
@@ -66,61 +67,48 @@ exports.encodePathname = encodePathname;
66
67
  * having asterisks there is a bit cumbersome.
67
68
  *
68
69
  * @see https://nextjs.org/docs/messages/invalid-multi-match
69
- */
70
- function transformRoute(route) {
71
- var rawPathname = route.pathname, rawTemplate = route.template;
72
- var pathnameParts = rawPathname.split("/").filter(function (part) { return !!part; });
73
- var templateParts = rawTemplate.split("/").filter(function (part) { return !!part; });
74
- var mapPartsByIdx = {};
75
- var pathname = pathnameParts
76
- .map(function (part) {
77
- var _a, _b;
78
- var hasWildcard = part.endsWith("*");
70
+ */ function transformRoute(route) {
71
+ const { pathname: rawPathname, template: rawTemplate } = route;
72
+ const pathnameParts = rawPathname.split("/").filter((part)=>!!part);
73
+ const templateParts = rawTemplate.split("/").filter((part)=>!!part);
74
+ const mapPartsByIdx = {};
75
+ const pathname = pathnameParts.map((part)=>{
76
+ const hasWildcard = part.endsWith("*");
79
77
  part = part.replace("*", "");
80
- var isDynamic = part.startsWith("{{") && part.endsWith("}}");
81
- var asValue = isDynamic
82
- ? (_b = (_a = part.match(/{{(.+)}}/)) === null || _a === void 0 ? void 0 : _a[1].trim()) !== null && _b !== void 0 ? _b : ""
83
- : part.trim();
84
- var asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
78
+ const isDynamic = part.startsWith("{{") && part.endsWith("}}");
79
+ const asValue = isDynamic ? part.match(/{{(.+)}}/)?.[1].trim() ?? "" : part.trim();
80
+ const asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
85
81
  mapPartsByIdx[asValue] = {
86
- isDynamic: isDynamic,
87
- hasWildcard: hasWildcard,
82
+ isDynamic,
83
+ hasWildcard
88
84
  };
89
- return isDynamic ? ":".concat(asPath) : asPath;
90
- })
91
- .join("/");
92
- var template = templateParts
93
- .map(function (part) {
94
- var _a, _b, _c;
95
- var isDynamic = part.startsWith("[") && part.endsWith("]");
96
- var asValue = isDynamic
97
- ? (_b = (_a = part.match(/\[(.+)\]/)) === null || _a === void 0 ? void 0 : _a[1].trim()) !== null && _b !== void 0 ? _b : ""
98
- : part.trim();
99
- var hasWildcard = (_c = mapPartsByIdx[asValue]) === null || _c === void 0 ? void 0 : _c.hasWildcard;
100
- var asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
101
- return isDynamic ? ":".concat(asPath) : asPath;
102
- })
103
- .join("/");
104
- return { pathname: pathname, template: template };
85
+ return isDynamic ? `:${asPath}` : asPath;
86
+ }).join("/");
87
+ const template = templateParts.map((part)=>{
88
+ const isDynamic = part.startsWith("[") && part.endsWith("]");
89
+ const asValue = isDynamic ? part.match(/\[(.+)\]/)?.[1].trim() ?? "" : part.trim();
90
+ const hasWildcard = mapPartsByIdx[asValue]?.hasWildcard;
91
+ const asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
92
+ return isDynamic ? `:${asPath}` : asPath;
93
+ }).join("/");
94
+ return {
95
+ pathname,
96
+ template
97
+ };
105
98
  }
106
99
  /**
107
100
  * Get routes map dictionary
108
- */
109
- function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
110
- if (map === void 0) { map = {}; }
111
- if (pathnameBuffer === void 0) { pathnameBuffer = ""; }
112
- if (templateBuffer === void 0) { templateBuffer = ""; }
113
- for (var key in routes) {
114
- var pathOrNestedRoutes = routes[key];
115
- var template = "".concat(templateBuffer, "/").concat(key);
101
+ */ function getRoutesMap(map = {}, routes, pathnameBuffer = "", templateBuffer = "") {
102
+ for(const key in routes){
103
+ const pathOrNestedRoutes = routes[key];
104
+ const template = `${templateBuffer}/${key}`;
116
105
  if (typeof pathOrNestedRoutes === "string") {
117
106
  map[template] = {
118
- template: template,
107
+ template,
119
108
  pathname: pathOrNestedRoutes,
120
- wildcard: pathOrNestedRoutes.includes("*"),
109
+ wildcard: pathOrNestedRoutes.includes("*")
121
110
  };
122
- }
123
- else {
111
+ } else {
124
112
  getRoutesMap(map, pathOrNestedRoutes, pathnameBuffer, template);
125
113
  }
126
114
  }
@@ -128,137 +116,131 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
128
116
  }
129
117
  /**
130
118
  * Removes `/index` from a template/url path
131
- */
132
- function getWithoutIndex(template) {
119
+ */ function getWithoutIndex(template) {
133
120
  return template.replace(/\/index$/, "");
134
121
  }
135
- /**
136
- * Get path rewrite
137
- */
138
122
  function getPathRewrite(route) {
139
- var _a = transformRoute(route), pathname = _a.pathname, template = _a.template;
140
- var source = "/".concat(normaliseUrlPathname(pathname));
141
- var destination = "/".concat(normaliseUrlPathname(template));
123
+ const { pathname, template } = transformRoute(route);
124
+ const source = `/${normaliseUrlPathname(pathname)}`;
125
+ const destination = `/${normaliseUrlPathname(template)}`;
142
126
  // console.log(`rewrite pathname "${source}" to template "${destination}"`);
143
127
  return {
144
- source: source,
145
- destination: getWithoutIndex(destination),
128
+ source,
129
+ destination: getWithoutIndex(destination)
146
130
  };
147
131
  }
148
- exports.getPathRewrite = getPathRewrite;
149
- /**
150
- * Get path redirect
151
- */
152
- function getPathRedirect(locale, route, permanent) {
153
- if (locale === void 0) { locale = ""; }
154
- var _a = transformRoute(route), template = _a.template, pathname = _a.pathname;
155
- var source = "/".concat(normaliseUrlPathname((locale ? "/".concat(locale, "/") : "/") + template));
156
- var destination = "/".concat(normaliseUrlPathname(pathname));
132
+ function getPathRedirect(locale = "", route, permanent) {
133
+ const { template, pathname } = transformRoute(route);
134
+ const source = `/${normaliseUrlPathname((locale ? `/${locale}/` : "/") + template)}`;
135
+ const destination = `/${normaliseUrlPathname(pathname)}`;
157
136
  // console.log(`redirect template "${source}" to pathname "${destination}"`);
158
137
  return {
159
138
  source: getWithoutIndex(source),
160
- destination: destination,
139
+ destination,
161
140
  permanent: Boolean(permanent),
162
- locale: false,
141
+ locale: false
163
142
  };
164
143
  }
165
- exports.getPathRedirect = getPathRedirect;
166
- /**
167
- */
168
- function getRedirects(defaultLocale, routes, permanent, debug) {
169
- return tslib_1.__awaiter(this, void 0, void 0, function () {
170
- var redirects, routesMap;
171
- return tslib_1.__generator(this, function (_a) {
172
- redirects = [];
173
- routesMap = getRoutesMap({}, routes);
174
- Object.keys(routesMap).forEach(function (template) {
175
- var route = routesMap[template];
176
- // TODO: add option hideDefaultLocaleInUrl?
177
- // this is meant to redirect the URL with the default locale to the same
178
- // url without locale prefix, e.g.: /en/about -> /about (assuming en is the
179
- // defualt locale).
180
- // Actually this redirect seem not to be necessary, probably the i18n routing
181
- // mechanism of next 12 already does this, enabling causes infinite redirects
182
- // if (hideDefaultLocaleInUrl) {
183
- // redirects.push(getPathRedirect(defaultLocale, route, permanent));
184
- // }
185
- if (route.pathname !== getWithoutIndex(template)) {
186
- redirects.push(getPathRedirect("", route, permanent));
187
- }
188
- });
189
- if (debug)
190
- console.info("[@koine/next/config:getRedirects]", redirects);
191
- return [2 /*return*/, redirects];
192
- });
144
+ async function getRedirects(defaultLocale, routes, permanent, debug) {
145
+ const redirects = [];
146
+ const routesMap = getRoutesMap({}, routes);
147
+ Object.keys(routesMap).forEach((template)=>{
148
+ const route = routesMap[template];
149
+ // TODO: add option hideDefaultLocaleInUrl?
150
+ // this is meant to redirect the URL with the default locale to the same
151
+ // url without locale prefix, e.g.: /en/about -> /about (assuming en is the
152
+ // defualt locale).
153
+ // Actually this redirect seem not to be necessary, probably the i18n routing
154
+ // mechanism of next 12 already does this, enabling causes infinite redirects
155
+ // if (hideDefaultLocaleInUrl) {
156
+ // redirects.push(getPathRedirect(defaultLocale, route, permanent));
157
+ // }
158
+ if (route.pathname !== getWithoutIndex(template)) {
159
+ redirects.push(getPathRedirect("", route, permanent));
160
+ }
193
161
  });
162
+ if (debug) console.info("[@koine/next/config:getRedirects]", redirects);
163
+ return redirects;
194
164
  }
195
- exports.getRedirects = getRedirects;
196
- /**
197
- */
198
- function getRewrites(routes, debug) {
199
- return tslib_1.__awaiter(this, void 0, void 0, function () {
200
- var rewrites, routesMap;
201
- return tslib_1.__generator(this, function (_a) {
202
- rewrites = [];
203
- routesMap = getRoutesMap({}, routes);
204
- Object.keys(routesMap).forEach(function (template) {
205
- var route = routesMap[template];
206
- if (route.pathname !== getWithoutIndex(template)) {
207
- rewrites.push(getPathRewrite(route));
208
- }
209
- });
210
- if (debug)
211
- console.info("[@koine/next/config:getRewrites]", rewrites);
212
- return [2 /*return*/, rewrites];
213
- });
165
+ async function getRewrites(routes, debug) {
166
+ const rewrites = [];
167
+ const routesMap = getRoutesMap({}, routes);
168
+ Object.keys(routesMap).forEach((template)=>{
169
+ const route = routesMap[template];
170
+ if (route.pathname !== getWithoutIndex(template)) {
171
+ rewrites.push(getPathRewrite(route));
172
+ }
214
173
  });
174
+ if (debug) console.info("[@koine/next/config:getRewrites]", rewrites);
175
+ return rewrites;
215
176
  }
216
- exports.getRewrites = getRewrites;
217
- /**
218
- * Get Next.js config with some basic opinionated defaults
219
- *
220
- * @param {object} options
221
- * @property {boolean} [options.nx=false] Nx monorepo setup
222
- * @property {boolean} [options.svg=false] Svg to react components
223
- * @property {boolean} [options.sc=false] Styled components enabled
224
- * @property {boolean} [options.page=false] When `true` uses `*.page.ts` or `*.page.tsx`
225
- * extension for next.js config option [`pageExtensions`](https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory)
226
- * and it enables the same for `next-translate`.
227
- */
228
- function withKoine(_a) {
229
- var _b;
230
- if (_a === void 0) { _a = {
231
- i18n: { locales: ["en"], defaultLocale: "en" },
232
- }; }
233
- var _c = _a.nx, nx = _c === void 0 ? true : _c, _d = _a.svg, svg = _d === void 0 ? true : _d, _e = _a.sc, sc = _e === void 0 ? true : _e, page = _a.page, routes = _a.routes, permanent = _a.permanent, debug = _a.debug, custom = tslib_1.__rest(_a, ["nx", "svg", "sc", "page", "routes", "permanent", "debug"]);
234
- var nextConfig = tslib_1.__assign({
177
+ function withKoine({ nx = true, svg = true, sc = true, page, routes, permanent, debug, ...custom } = {
178
+ i18n: {
179
+ locales: [
180
+ "en"
181
+ ],
182
+ defaultLocale: "en"
183
+ }
184
+ }) {
185
+ const nextConfig = {
235
186
  // @see https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory
236
- pageExtensions: page ? ["page.tsx", "page.ts"] : undefined, eslint: {
237
- ignoreDuringBuilds: true, // we have this strict check on each commit
238
- }, typescript: {
239
- ignoreBuildErrors: true, // we have this strict check on each commit
240
- }, poweredByHeader: false, swcMinify: true, modularizeImports: tslib_1.__assign({ "@koine/api": { transform: "@koine/api/{{member}}" }, "@koine/browser": { transform: "@koine/browser/{{member}}" }, "@koine/dom": { transform: "@koine/dom/{{member}}" }, "@koine/next/?(((\\w*)?/?)*)": {
241
- transform: "@koine/next/{{ matches.[1] }}/{{member}}",
242
- }, "@koine/react/?(((\\w*)?/?)*)": {
243
- transform: "@koine/react/{{ matches.[1] }}/{{member}}",
244
- }, "@koine/utils": { transform: "@koine/utils/{{member}}" } }, (custom["modularizeImports"] || {})), experimental: tslib_1.__assign({
187
+ pageExtensions: page ? [
188
+ "page.tsx",
189
+ "page.ts"
190
+ ] : undefined,
191
+ eslint: {
192
+ ignoreDuringBuilds: true
193
+ },
194
+ typescript: {
195
+ ignoreBuildErrors: true
196
+ },
197
+ poweredByHeader: false,
198
+ swcMinify: true,
199
+ modularizeImports: {
200
+ "@koine/api": {
201
+ transform: "@koine/api/{{member}}"
202
+ },
203
+ "@koine/browser": {
204
+ transform: "@koine/browser/{{member}}"
205
+ },
206
+ "@koine/dom": {
207
+ transform: "@koine/dom/{{member}}"
208
+ },
209
+ "@koine/next/?(((\\w*)?/?)*)": {
210
+ transform: "@koine/next/{{ matches.[1] }}/{{member}}"
211
+ },
212
+ "@koine/react/?(((\\w*)?/?)*)": {
213
+ transform: "@koine/react/{{ matches.[1] }}/{{member}}"
214
+ },
215
+ "@koine/utils": {
216
+ transform: "@koine/utils/{{member}}"
217
+ },
218
+ ...custom["modularizeImports"] || {}
219
+ },
220
+ experimental: {
245
221
  // @see https://github.com/vercel/vercel/discussions/5973#discussioncomment-472618
246
222
  // @see critters error https://github.com/vercel/next.js/issues/20742
247
223
  // optimizeCss: true,
248
224
  // @see https://github.com/vercel/next.js/discussions/30174#discussion-3643870
249
- scrollRestoration: true }, (custom["experimental"] || {})) }, custom);
225
+ scrollRestoration: true,
226
+ // concurrentFeatures: true,
227
+ // serverComponents: true,
228
+ // reactRoot: true,
229
+ ...custom["experimental"] || {}
230
+ },
231
+ // @see https://github.com/vercel/next.js/issues/7322#issuecomment-887330111
232
+ // reactStrictMode: true,
233
+ ...custom
234
+ };
250
235
  if (svg) {
251
236
  if (nx) {
252
237
  // @see https://github.com/gregberge/svgr
253
238
  nextConfig["nx"] = {
254
- svgr: true,
239
+ svgr: true
255
240
  };
256
- }
257
- else {
258
- nextConfig.webpack = function (_config, options) {
259
- var webpackConfig = typeof nextConfig.webpack === "function"
260
- ? nextConfig.webpack(_config, options)
261
- : _config;
241
+ } else {
242
+ nextConfig.webpack = (_config, options)=>{
243
+ const webpackConfig = typeof nextConfig.webpack === "function" ? nextConfig.webpack(_config, options) : _config;
262
244
  // @see https://dev.to/dolearning/importing-svgs-to-next-js-nna#svgr
263
245
  webpackConfig.module.rules.push({
264
246
  test: /\.svg$/,
@@ -270,13 +252,13 @@ function withKoine(_a) {
270
252
  plugins: [
271
253
  {
272
254
  name: "removeViewBox",
273
- active: false,
274
- },
275
- ],
276
- },
277
- },
278
- },
279
- ],
255
+ active: false
256
+ }
257
+ ]
258
+ }
259
+ }
260
+ }
261
+ ]
280
262
  });
281
263
  return webpackConfig;
282
264
  };
@@ -284,60 +266,52 @@ function withKoine(_a) {
284
266
  }
285
267
  if (sc) {
286
268
  nextConfig.compiler = {
287
- styledComponents: true,
269
+ styledComponents: true
288
270
  };
289
271
  }
290
272
  if (routes) {
291
273
  // we pass the default values, so we can assert I guess
292
- var defaultLocale_1 = (_b = nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.i18n) === null || _b === void 0 ? void 0 : _b.defaultLocale;
293
- return tslib_1.__assign(tslib_1.__assign({}, nextConfig), { redirects: function () {
294
- return tslib_1.__awaiter(this, void 0, void 0, function () {
295
- var defaults, customs;
296
- return tslib_1.__generator(this, function (_a) {
297
- switch (_a.label) {
298
- case 0: return [4 /*yield*/, getRedirects(defaultLocale_1, routes, permanent, debug)];
299
- case 1:
300
- defaults = _a.sent();
301
- if (!nextConfig.redirects) return [3 /*break*/, 3];
302
- return [4 /*yield*/, nextConfig.redirects()];
303
- case 2:
304
- customs = _a.sent();
305
- return [2 /*return*/, tslib_1.__spreadArray(tslib_1.__spreadArray([], defaults, true), customs, true)];
306
- case 3: return [2 /*return*/, defaults];
307
- }
308
- });
309
- });
310
- }, rewrites: function () {
311
- return tslib_1.__awaiter(this, void 0, void 0, function () {
312
- var defaults, customs;
313
- return tslib_1.__generator(this, function (_a) {
314
- switch (_a.label) {
315
- case 0: return [4 /*yield*/, getRewrites(routes, debug)];
316
- case 1:
317
- defaults = _a.sent();
318
- if (!nextConfig.rewrites) return [3 /*break*/, 3];
319
- return [4 /*yield*/, nextConfig.rewrites()];
320
- case 2:
321
- customs = _a.sent();
322
- if (Array.isArray(customs)) {
323
- return [2 /*return*/, {
324
- beforeFiles: defaults,
325
- afterFiles: customs,
326
- fallback: [],
327
- }];
328
- }
329
- return [2 /*return*/, tslib_1.__assign(tslib_1.__assign({}, customs), { beforeFiles: tslib_1.__spreadArray(tslib_1.__spreadArray([], defaults, true), (customs.beforeFiles || []), true) })];
330
- case 3: return [2 /*return*/, {
331
- afterFiles: [],
332
- beforeFiles: defaults,
333
- fallback: [],
334
- }];
335
- }
336
- });
337
- });
338
- } });
274
+ const defaultLocale = nextConfig?.i18n?.defaultLocale;
275
+ return {
276
+ ...nextConfig,
277
+ async redirects () {
278
+ const defaults = await getRedirects(defaultLocale, routes, permanent, debug);
279
+ if (nextConfig.redirects) {
280
+ const customs = await nextConfig.redirects();
281
+ return [
282
+ ...defaults,
283
+ ...customs
284
+ ];
285
+ }
286
+ return defaults;
287
+ },
288
+ async rewrites () {
289
+ const defaults = await getRewrites(routes, debug);
290
+ if (nextConfig.rewrites) {
291
+ const customs = await nextConfig.rewrites();
292
+ if (Array.isArray(customs)) {
293
+ return {
294
+ beforeFiles: defaults,
295
+ afterFiles: customs,
296
+ fallback: []
297
+ };
298
+ }
299
+ return {
300
+ ...customs,
301
+ beforeFiles: [
302
+ ...defaults,
303
+ ...customs.beforeFiles || []
304
+ ]
305
+ };
306
+ }
307
+ return {
308
+ afterFiles: [],
309
+ beforeFiles: defaults,
310
+ fallback: []
311
+ };
312
+ }
313
+ };
339
314
  }
340
315
  return nextConfig;
341
316
  }
342
- exports.withKoine = withKoine;
343
- exports.default = withKoine;
317
+ const _default = withKoine;