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

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