@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.
- package/12/AnalyticsGoogle.js +65 -25
- package/12/AnalyticsGoogle.mjs +41 -15
- package/12/DisableErrorOverlay.js +29 -16
- package/12/DisableErrorOverlay.mjs +8 -5
- package/12/DynamicNamespaces.d.ts +1 -1
- package/12/DynamicNamespaces.js +22 -12
- package/12/DynamicNamespaces.mjs +1 -2
- package/12/Favicon.js +28 -9
- package/12/Favicon.mjs +6 -2
- package/12/Link.d.ts +1 -1
- package/12/Link.js +36 -13
- package/12/Link.mjs +14 -6
- package/12/NextProgress.js +47 -24
- package/12/NextProgress.mjs +26 -17
- package/12/Seo.d.ts +1 -1
- package/12/Seo.js +27 -32
- package/12/Seo.mjs +5 -4
- package/12/SeoDefaults.d.ts +1 -1
- package/12/SeoDefaults.js +27 -13
- package/12/SeoDefaults.mjs +5 -3
- package/12/T.d.ts +1 -1
- package/12/T.js +42 -16
- package/12/T.mjs +20 -6
- package/12/ThemeContext.js +22 -7
- package/12/ThemeContext.mjs +3 -3
- package/12/ThemeProvider.js +164 -147
- package/12/ThemeProvider.mjs +139 -129
- package/12/TransText.js +22 -7
- package/12/TransText.mjs +1 -1
- package/12/app/AppHead.js +29 -9
- package/12/app/AppHead.mjs +8 -2
- package/12/app/AppMain.d.ts +4 -4
- package/12/app/AppMain.js +5 -1
- package/12/app/AppMain.mjs +1 -1
- package/12/app/css/AppMain.js +37 -16
- package/12/app/css/AppMain.mjs +15 -5
- package/12/app/css/AppTheme.d.ts +1 -1
- package/12/app/css/AppTheme.js +28 -13
- package/12/app/css/AppTheme.mjs +7 -4
- package/12/app/css/auth/index.d.ts +1 -1
- package/12/app/css/auth/index.js +38 -15
- package/12/app/css/auth/index.mjs +17 -6
- package/12/app/css/index.d.ts +1 -1
- package/12/app/css/index.js +34 -59
- package/12/app/css/index.mjs +14 -6
- package/12/app/index.js +6 -4
- package/12/app/sc/AppMain.js +68 -27
- package/12/app/sc/AppMain.mjs +46 -13
- package/12/app/sc/AppTheme.d.ts +1 -1
- package/12/app/sc/AppTheme.js +31 -13
- package/12/app/sc/AppTheme.mjs +9 -4
- package/12/app/sc/auth/index.d.ts +1 -1
- package/12/app/sc/auth/index.js +38 -15
- package/12/app/sc/auth/index.mjs +17 -6
- package/12/app/sc/index.d.ts +1 -1
- package/12/app/sc/index.js +34 -61
- package/12/app/sc/index.mjs +14 -6
- package/12/document/Document.js +47 -29
- package/12/document/Document.mjs +24 -14
- package/12/document/css/index.js +47 -32
- package/12/document/css/index.mjs +26 -18
- package/12/document/index.js +18 -6
- package/12/document/sc/index.js +71 -65
- package/12/document/sc/index.mjs +46 -45
- package/12/getT.js +22 -13
- package/12/getT.mjs +2 -4
- package/12/index.js +99 -51
- package/12/index.mjs +2 -2
- package/12/seoBuildTags.js +81 -76
- package/12/seoBuildTags.mjs +59 -55
- package/12/to.js +21 -19
- package/12/to.mjs +4 -10
- package/12/translationAsOptions.js +15 -9
- package/12/translationAsOptions.mjs +6 -6
- package/12/types-i18n.js +4 -3
- package/12/types-i18n.mjs +1 -2
- package/12/types-seo.js +3 -1
- package/12/types-seo.mjs +1 -1
- package/12/useBackUrl.js +30 -16
- package/12/useBackUrl.mjs +8 -8
- package/12/useDateFormat.js +37 -38
- package/12/useDateFormat.mjs +15 -28
- package/12/useForm.d.ts +1 -1
- package/12/useForm.js +46 -20
- package/12/useForm.mjs +25 -13
- package/12/useLocale.js +22 -8
- package/12/useT.d.ts +1 -1
- package/12/useT.js +53 -39
- package/12/useT.mjs +32 -14
- package/12/useTheme.js +22 -11
- package/12/useTheme.mjs +1 -2
- package/12/useTo.js +23 -16
- package/12/useTo.mjs +3 -10
- package/README.md +1 -1
- package/config/index.js +225 -251
- package/config/index.mjs +187 -204
- package/getSiteUrl.js +22 -15
- package/getSiteUrl.mjs +2 -4
- package/index.js +19 -6
- package/load.js +21 -8
- package/load.mjs +3 -4
- package/package.json +19 -17
- package/12/app/css/auth/package.json +0 -6
- package/12/app/css/package.json +0 -6
- package/12/app/package.json +0 -6
- package/12/app/sc/auth/package.json +0 -6
- package/12/app/sc/package.json +0 -6
- package/12/document/css/package.json +0 -6
- package/12/document/package.json +0 -6
- package/12/document/sc/package.json +0 -6
- package/12/package.json +0 -6
- 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
|
-
|
|
28
|
-
if (urlOrPathname === void 0) { urlOrPathname = ""; }
|
|
29
|
-
var pathname = "";
|
|
23
|
+
*/ export function toPath(urlOrPathname = "") {
|
|
24
|
+
let pathname = "";
|
|
30
25
|
try {
|
|
31
|
-
|
|
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
|
-
|
|
47
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
81
|
-
hasWildcard
|
|
64
|
+
isDynamic,
|
|
65
|
+
hasWildcard
|
|
82
66
|
};
|
|
83
|
-
return isDynamic ?
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
|
139
|
-
destination: getWithoutIndex(destination)
|
|
112
|
+
source,
|
|
113
|
+
destination: getWithoutIndex(destination)
|
|
140
114
|
};
|
|
141
115
|
}
|
|
142
116
|
/**
|
|
143
117
|
* Get path redirect
|
|
144
|
-
*/
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
|
125
|
+
destination,
|
|
154
126
|
permanent: Boolean(permanent),
|
|
155
|
-
locale: false
|
|
127
|
+
locale: false
|
|
156
128
|
};
|
|
157
129
|
}
|
|
158
130
|
/**
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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 ? [
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
|
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
|
-
|
|
248
|
-
|
|
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
|
-
|
|
283
|
-
return
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
17
|
-
|
|
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
|
-
|
|
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", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
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(
|
|
14
|
-
setTimeout(
|
|
27
|
+
return new Promise((resolve)=>{
|
|
28
|
+
setTimeout(()=>resolve(component), milliseconds);
|
|
15
29
|
});
|
|
16
30
|
}
|
|
17
|
-
|
|
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
|
-
|
|
10
|
-
|
|
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;
|