@koine/next 2.0.0-beta.2 → 2.0.0-beta.21
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.d.ts +0 -1
- package/12/AnalyticsGoogle.js +15 -21
- package/12/DisableErrorOverlay.d.ts +0 -5
- package/12/DisableErrorOverlay.js +5 -15
- package/12/DynamicNamespaces.d.ts +2 -7
- package/12/DynamicNamespaces.js +3 -12
- package/12/Favicon.d.ts +0 -0
- package/12/Favicon.js +6 -10
- package/12/Link.d.ts +1 -4
- package/12/Link.js +8 -14
- package/12/NextProgress.d.ts +1 -4
- package/12/NextProgress.js +13 -19
- package/12/Seo.d.ts +2 -26
- package/12/Seo.js +6 -33
- package/12/SeoDefaults.d.ts +1 -4
- package/12/SeoDefaults.js +6 -16
- package/12/T.d.ts +1 -7
- package/12/T.js +6 -15
- package/12/TransText.d.ts +0 -0
- package/12/TransText.js +3 -7
- package/12/app/AppHead.d.ts +0 -0
- package/12/app/AppHead.js +5 -10
- package/12/app/AppMain.d.ts +4 -22
- package/12/app/AppMain.js +1 -2
- package/12/app/css/AppMain.d.ts +1 -6
- package/12/app/css/AppMain.js +7 -16
- package/12/app/css/AppTheme.d.ts +2 -5
- package/12/app/css/AppTheme.js +5 -16
- package/12/app/css/auth/index.d.ts +2 -5
- package/12/app/css/auth/index.js +9 -16
- package/12/app/css/index.d.ts +2 -50
- package/12/app/css/index.js +8 -60
- package/12/app/index.d.ts +2 -2
- package/12/app/index.js +2 -5
- package/12/app/sc/AppMain.d.ts +1 -8
- package/12/app/sc/AppMain.js +12 -23
- package/12/app/sc/AppTheme.d.ts +1 -7
- package/12/app/sc/AppTheme.js +6 -13
- package/12/app/sc/auth/index.d.ts +2 -5
- package/12/app/sc/auth/index.js +9 -16
- package/12/app/sc/index.d.ts +2 -52
- package/12/app/sc/index.js +8 -62
- package/12/document/Document.d.ts +0 -10
- package/12/document/Document.js +11 -24
- package/12/document/css/index.d.ts +0 -12
- package/12/document/css/index.js +11 -38
- package/12/document/index.d.ts +2 -2
- package/12/document/index.js +2 -7
- package/12/document/sc/index.d.ts +0 -13
- package/12/document/sc/index.js +21 -38
- package/12/getT.d.ts +1 -6
- package/12/getT.js +3 -13
- package/12/index.d.ts +3 -24
- package/12/index.js +3 -52
- package/12/seoBuildTags.d.ts +2 -17
- package/12/seoBuildTags.js +15 -43
- package/12/to.d.ts +1 -11
- package/12/to.js +4 -14
- package/12/translationAsOptions.d.ts +2 -1
- package/12/translationAsOptions.js +2 -5
- package/12/types-i18n.d.ts +0 -87
- package/12/types-i18n.js +1 -14
- package/12/types-seo.d.ts +0 -0
- package/12/types-seo.js +1 -2
- package/12/types.d.ts +7 -0
- package/12/types.js +2 -0
- package/12/useBackUrl.d.ts +0 -0
- package/12/useBackUrl.js +11 -20
- package/12/useDateFormat.d.ts +0 -4
- package/12/useDateFormat.js +15 -23
- package/12/useForm.d.ts +2 -2
- package/12/useForm.js +9 -33
- package/12/useLocale.d.ts +0 -0
- package/12/useLocale.js +4 -9
- package/12/useT.d.ts +1 -1
- package/12/useT.js +6 -33
- package/12/useTo.d.ts +1 -1
- package/12/useTo.js +7 -11
- package/ThemeContext.d.ts +11 -0
- package/{12/ThemeContext.mjs → ThemeContext.js} +0 -1
- package/ThemeProvider.d.ts +17 -0
- package/{12/ThemeProvider.mjs → ThemeProvider.js} +11 -42
- package/config-i18n.d.ts +52 -0
- package/config-i18n.js +251 -0
- package/config.d.ts +109 -0
- package/config.js +118 -0
- package/getSiteUrl.d.ts +0 -6
- package/getSiteUrl.js +4 -15
- package/index.d.ts +5 -2
- package/index.js +5 -7
- package/load.d.ts +0 -8
- package/load.js +2 -14
- package/package.json +159 -39
- package/useTheme.d.ts +4 -0
- package/{12/useTheme.mjs → useTheme.js} +1 -4
- package/12/AnalyticsGoogle.mjs +0 -34
- package/12/DisableErrorOverlay.mjs +0 -13
- package/12/DynamicNamespaces.mjs +0 -9
- package/12/Favicon.mjs +0 -6
- package/12/Link.mjs +0 -12
- package/12/NextProgress.mjs +0 -42
- package/12/Seo.mjs +0 -29
- package/12/SeoDefaults.mjs +0 -12
- package/12/T.mjs +0 -13
- package/12/ThemeContext.d.ts +0 -17
- package/12/ThemeContext.js +0 -10
- package/12/ThemeProvider.d.ts +0 -35
- package/12/ThemeProvider.js +0 -239
- package/12/TransText.mjs +0 -4
- package/12/app/AppHead.mjs +0 -6
- package/12/app/AppMain.mjs +0 -1
- package/12/app/css/AppMain.mjs +0 -14
- package/12/app/css/AppTheme.mjs +0 -14
- package/12/app/css/auth/index.mjs +0 -13
- package/12/app/css/auth/package.json +0 -6
- package/12/app/css/index.mjs +0 -57
- package/12/app/css/package.json +0 -6
- package/12/app/index.mjs +0 -2
- package/12/app/package.json +0 -6
- package/12/app/sc/AppMain.mjs +0 -25
- package/12/app/sc/AppTheme.mjs +0 -11
- package/12/app/sc/auth/index.mjs +0 -13
- package/12/app/sc/auth/package.json +0 -6
- package/12/app/sc/index.mjs +0 -59
- package/12/app/sc/package.json +0 -6
- package/12/document/Document.mjs +0 -28
- package/12/document/css/index.mjs +0 -45
- package/12/document/css/package.json +0 -6
- package/12/document/index.mjs +0 -2
- package/12/document/package.json +0 -6
- package/12/document/sc/index.mjs +0 -64
- package/12/document/sc/package.json +0 -6
- package/12/getT.mjs +0 -10
- package/12/index.mjs +0 -27
- package/12/package.json +0 -6
- package/12/seoBuildTags.mjs +0 -117
- package/12/to.mjs +0 -25
- package/12/translationAsOptions.mjs +0 -9
- package/12/types-i18n.mjs +0 -13
- package/12/types-seo.mjs +0 -1
- package/12/useBackUrl.mjs +0 -28
- package/12/useDateFormat.mjs +0 -39
- package/12/useForm.mjs +0 -35
- package/12/useLocale.mjs +0 -6
- package/12/useT.mjs +0 -21
- package/12/useTheme.d.ts +0 -7
- package/12/useTheme.js +0 -12
- package/12/useTo.mjs +0 -15
- package/README.md +0 -13
- package/config/index.d.ts +0 -160
- package/config/index.js +0 -343
- package/config/index.mjs +0 -332
- package/config/package.json +0 -6
- package/getSiteUrl.mjs +0 -12
- package/index.mjs +0 -2
- package/load.mjs +0 -14
package/config-i18n.js
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
|
+
var arrayUniqueByProperties = function (array, keys) {
|
|
3
|
+
return array.filter(function (item, idx, arr) {
|
|
4
|
+
return arr.findIndex(function (itemWith) {
|
|
5
|
+
return keys.every(function (k) { return itemWith[k] === item[k]; });
|
|
6
|
+
}) === idx;
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export function normaliseUrlPathname(pathname) {
|
|
10
|
+
if (pathname === void 0) { pathname = ""; }
|
|
11
|
+
return pathname.replace(/\/+\//g, "/").replace(/^\/*(.*?)\/*$/, "$1");
|
|
12
|
+
}
|
|
13
|
+
export function toPath(urlOrPathname) {
|
|
14
|
+
if (urlOrPathname === void 0) { urlOrPathname = ""; }
|
|
15
|
+
var pathname = "";
|
|
16
|
+
try {
|
|
17
|
+
var parsed = new URL(urlOrPathname);
|
|
18
|
+
pathname = parsed.pathname;
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
pathname = urlOrPathname;
|
|
22
|
+
}
|
|
23
|
+
return pathname.replace(/\/+\//g, "/").replace(/^\/*(.*?)\/*$/, "$1");
|
|
24
|
+
}
|
|
25
|
+
export function encodePathname(pathname) {
|
|
26
|
+
if (pathname === void 0) { pathname = ""; }
|
|
27
|
+
var parts = normaliseUrlPathname(pathname).split("/");
|
|
28
|
+
return parts
|
|
29
|
+
.filter(function (part) { return !!part; })
|
|
30
|
+
.map(function (part) { return encodeURIComponent(part); })
|
|
31
|
+
.join("/");
|
|
32
|
+
}
|
|
33
|
+
function transformRoute(route) {
|
|
34
|
+
var rawPathname = route.pathname, rawTemplate = route.template;
|
|
35
|
+
var pathnameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
36
|
+
var templateParts = rawTemplate.split("/").filter(function (part) { return !!part; });
|
|
37
|
+
var mapPartsByIdx = {};
|
|
38
|
+
var pathname = pathnameParts
|
|
39
|
+
.map(function (part) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
var hasWildcard = part.endsWith("*");
|
|
42
|
+
part = part.replace("*", "");
|
|
43
|
+
var isDynamic = part.startsWith("{{") && part.endsWith("}}");
|
|
44
|
+
var asValue = isDynamic
|
|
45
|
+
? (_b = (_a = part.match(/{{(.+)}}/)) === null || _a === void 0 ? void 0 : _a[1].trim()) !== null && _b !== void 0 ? _b : ""
|
|
46
|
+
: part.trim();
|
|
47
|
+
var asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
|
|
48
|
+
mapPartsByIdx[asValue] = {
|
|
49
|
+
isDynamic: isDynamic,
|
|
50
|
+
hasWildcard: hasWildcard,
|
|
51
|
+
};
|
|
52
|
+
return isDynamic ? ":".concat(asPath) : asPath;
|
|
53
|
+
})
|
|
54
|
+
.join("/");
|
|
55
|
+
var template = templateParts
|
|
56
|
+
.map(function (part) {
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
var isDynamic = part.startsWith("[") && part.endsWith("]");
|
|
59
|
+
var asValue = isDynamic
|
|
60
|
+
? (_b = (_a = part.match(/\[(.+)\]/)) === null || _a === void 0 ? void 0 : _a[1].trim()) !== null && _b !== void 0 ? _b : ""
|
|
61
|
+
: part.trim();
|
|
62
|
+
var hasWildcard = (_c = mapPartsByIdx[asValue]) === null || _c === void 0 ? void 0 : _c.hasWildcard;
|
|
63
|
+
var asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
|
|
64
|
+
return isDynamic ? ":".concat(asPath) : asPath;
|
|
65
|
+
})
|
|
66
|
+
.join("/");
|
|
67
|
+
return { pathname: pathname, template: template };
|
|
68
|
+
}
|
|
69
|
+
function getRoutesMap(map, routesByLocale, pathnameBuffer, templateBuffer) {
|
|
70
|
+
if (map === void 0) { map = {}; }
|
|
71
|
+
if (pathnameBuffer === void 0) { pathnameBuffer = ""; }
|
|
72
|
+
if (templateBuffer === void 0) { templateBuffer = ""; }
|
|
73
|
+
var isSpaRoute = Object.keys(routesByLocale).includes("[spa]");
|
|
74
|
+
for (var key in routesByLocale) {
|
|
75
|
+
var pathOrNestedRoutes = routesByLocale[key];
|
|
76
|
+
var template = "".concat(templateBuffer, "/").concat(key);
|
|
77
|
+
if (typeof pathOrNestedRoutes === "string") {
|
|
78
|
+
if (!isSpaRoute || (isSpaRoute && ["[spa]", "index"].includes(key))) {
|
|
79
|
+
map[template] = {
|
|
80
|
+
template: template,
|
|
81
|
+
pathname: pathOrNestedRoutes,
|
|
82
|
+
wildcard: pathOrNestedRoutes.includes("*"),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
if (!isSpaRoute) {
|
|
88
|
+
getRoutesMap(map, pathOrNestedRoutes, pathnameBuffer, template);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return map;
|
|
93
|
+
}
|
|
94
|
+
function getWithoutIndex(template) {
|
|
95
|
+
return template.replace(/\/index$/, "");
|
|
96
|
+
}
|
|
97
|
+
export function getRoutesOfDefaultLocale(routes, defaultLocale) {
|
|
98
|
+
var routesByLocale = routes;
|
|
99
|
+
if (defaultLocale &&
|
|
100
|
+
routesByLocale[defaultLocale]) {
|
|
101
|
+
return routesByLocale[defaultLocale];
|
|
102
|
+
}
|
|
103
|
+
if (Object.keys(routes).length === 1) {
|
|
104
|
+
var routesWithOneLocale = routes;
|
|
105
|
+
var output = {};
|
|
106
|
+
for (var onlyLocale in routesWithOneLocale) {
|
|
107
|
+
output =
|
|
108
|
+
routesWithOneLocale[onlyLocale];
|
|
109
|
+
}
|
|
110
|
+
return output;
|
|
111
|
+
}
|
|
112
|
+
return routes;
|
|
113
|
+
}
|
|
114
|
+
export function getPathRedirect(arg) {
|
|
115
|
+
var localeSource = arg.localeSource, localeDestination = arg.localeDestination, route = arg.route, usePathnameAsSource = arg.usePathnameAsSource, permanent = arg.permanent;
|
|
116
|
+
var _a = transformRoute(route), routeTemplate = _a.template, pathname = _a.pathname;
|
|
117
|
+
var template = usePathnameAsSource ? pathname : routeTemplate;
|
|
118
|
+
var sourcePrefix = localeSource ? "".concat(localeSource, "/") : "";
|
|
119
|
+
var source = getWithoutIndex("/".concat(normaliseUrlPathname(sourcePrefix + template)));
|
|
120
|
+
var destinationPrefix = localeDestination ? "".concat(localeDestination, "/") : "";
|
|
121
|
+
var destination = "/".concat(normaliseUrlPathname(destinationPrefix + pathname));
|
|
122
|
+
if (source === destination)
|
|
123
|
+
return;
|
|
124
|
+
var redirect = {
|
|
125
|
+
source: source,
|
|
126
|
+
destination: destination,
|
|
127
|
+
permanent: Boolean(permanent),
|
|
128
|
+
};
|
|
129
|
+
return redirect;
|
|
130
|
+
}
|
|
131
|
+
export function getRedirects(arg) {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
133
|
+
var routes, defaultLocale, hideDefaultLocaleInUrl, localeParam, permanent, debug, redirects, locale, routesByLocale, routesMap, template, route, isVisibleDefaultLocale, isHiddenDefaultLocale, cleaned;
|
|
134
|
+
return __generator(this, function (_a) {
|
|
135
|
+
routes = arg.routes, defaultLocale = arg.defaultLocale, hideDefaultLocaleInUrl = arg.hideDefaultLocaleInUrl, localeParam = arg.localeParam, permanent = arg.permanent, debug = arg.debug;
|
|
136
|
+
redirects = [];
|
|
137
|
+
for (locale in routes) {
|
|
138
|
+
routesByLocale = routes[locale];
|
|
139
|
+
routesMap = getRoutesMap({}, routesByLocale);
|
|
140
|
+
for (template in routesMap) {
|
|
141
|
+
route = routesMap[template];
|
|
142
|
+
if (route.pathname !== getWithoutIndex(template)) {
|
|
143
|
+
isVisibleDefaultLocale = locale === defaultLocale && !hideDefaultLocaleInUrl;
|
|
144
|
+
isHiddenDefaultLocale = locale === defaultLocale && hideDefaultLocaleInUrl;
|
|
145
|
+
if (localeParam) {
|
|
146
|
+
if (isVisibleDefaultLocale) {
|
|
147
|
+
redirects.push(getPathRedirect({ localeDestination: locale, route: route, permanent: permanent }));
|
|
148
|
+
}
|
|
149
|
+
else if (isHiddenDefaultLocale) {
|
|
150
|
+
redirects.push(getPathRedirect({ localeSource: locale, route: route, permanent: permanent }));
|
|
151
|
+
}
|
|
152
|
+
else if (locale !== defaultLocale) {
|
|
153
|
+
redirects.push(getPathRedirect({
|
|
154
|
+
localeSource: locale,
|
|
155
|
+
localeDestination: locale,
|
|
156
|
+
route: route,
|
|
157
|
+
permanent: permanent,
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
redirects.push(getPathRedirect({ route: route, permanent: permanent }));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
if (isVisibleDefaultLocale) {
|
|
166
|
+
redirects.push(getPathRedirect({ localeDestination: locale, route: route, permanent: permanent }));
|
|
167
|
+
}
|
|
168
|
+
else if (locale !== defaultLocale) {
|
|
169
|
+
redirects.push(getPathRedirect({
|
|
170
|
+
localeSource: locale,
|
|
171
|
+
localeDestination: locale,
|
|
172
|
+
route: route,
|
|
173
|
+
permanent: permanent,
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
redirects.push(getPathRedirect({ route: route, permanent: permanent }));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
cleaned = arrayUniqueByProperties(redirects.filter(Boolean), ["source", "destination"]).map(function (rewrite) { return (localeParam ? rewrite : __assign(__assign({}, rewrite), { locale: false })); });
|
|
184
|
+
if (debug)
|
|
185
|
+
console.info("[@koine/next/config:getRedirects]", cleaned);
|
|
186
|
+
return [2, cleaned];
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
export function getPathRewrite(arg) {
|
|
191
|
+
var localeSource = arg.localeSource, localeDestination = arg.localeDestination, localeParam = arg.localeParam, route = arg.route;
|
|
192
|
+
var _a = transformRoute(route), pathname = _a.pathname, template = _a.template;
|
|
193
|
+
var sourcePrefix = "";
|
|
194
|
+
if (localeSource)
|
|
195
|
+
sourcePrefix = "".concat(localeSource, "/");
|
|
196
|
+
else if (localeParam)
|
|
197
|
+
sourcePrefix = ":".concat(localeParam, "/");
|
|
198
|
+
var source = "/".concat(normaliseUrlPathname(sourcePrefix + pathname));
|
|
199
|
+
var destinationPrefix = "";
|
|
200
|
+
if (localeDestination)
|
|
201
|
+
destinationPrefix = "".concat(localeDestination, "/");
|
|
202
|
+
else if (localeParam)
|
|
203
|
+
destinationPrefix = ":".concat(localeParam, "/");
|
|
204
|
+
var destination = getWithoutIndex("/".concat(normaliseUrlPathname(destinationPrefix + template)));
|
|
205
|
+
if (source === destination)
|
|
206
|
+
return;
|
|
207
|
+
return {
|
|
208
|
+
source: source,
|
|
209
|
+
destination: destination,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
export function getRewrites(arg) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
214
|
+
var routes, defaultLocale, hideDefaultLocaleInUrl, localeParam, debug, rewrites, locale, routesByLocale, routesMap, template, route, isVisibleDefaultLocale, isHiddenDefaultLocale, cleaned;
|
|
215
|
+
return __generator(this, function (_a) {
|
|
216
|
+
routes = arg.routes, defaultLocale = arg.defaultLocale, hideDefaultLocaleInUrl = arg.hideDefaultLocaleInUrl, localeParam = arg.localeParam, debug = arg.debug;
|
|
217
|
+
rewrites = [];
|
|
218
|
+
for (locale in routes) {
|
|
219
|
+
routesByLocale = routes[locale];
|
|
220
|
+
routesMap = getRoutesMap({}, routesByLocale);
|
|
221
|
+
for (template in routesMap) {
|
|
222
|
+
route = routesMap[template];
|
|
223
|
+
isVisibleDefaultLocale = locale === defaultLocale && !hideDefaultLocaleInUrl;
|
|
224
|
+
isHiddenDefaultLocale = locale === defaultLocale && hideDefaultLocaleInUrl;
|
|
225
|
+
if (localeParam) {
|
|
226
|
+
if (isHiddenDefaultLocale) {
|
|
227
|
+
rewrites.push(getPathRewrite({ localeDestination: locale, route: route }));
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
rewrites.push(getPathRewrite({ localeParam: localeParam, route: route }));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
if (route.pathname !== getWithoutIndex(template)) {
|
|
235
|
+
if (locale !== defaultLocale || isVisibleDefaultLocale) {
|
|
236
|
+
rewrites.push(getPathRewrite({ localeSource: locale, route: route }));
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
rewrites.push(getPathRewrite({ route: route }));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
cleaned = arrayUniqueByProperties(rewrites.filter(Boolean), ["source", "destination"]);
|
|
246
|
+
if (debug)
|
|
247
|
+
console.info("[@koine/next/config:getRewrites]", cleaned);
|
|
248
|
+
return [2, cleaned];
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
}
|
package/config.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { NextConfig } from "next";
|
|
2
|
+
import { type ConfigI18nOptions, type Routes } from "./config-i18n.js";
|
|
3
|
+
interface KoineNextConfig {
|
|
4
|
+
nx?: boolean;
|
|
5
|
+
svg?: boolean;
|
|
6
|
+
sc?: boolean;
|
|
7
|
+
page?: boolean;
|
|
8
|
+
routes?: Routes;
|
|
9
|
+
permanent?: boolean;
|
|
10
|
+
debug?: boolean;
|
|
11
|
+
i18n: ConfigI18nOptions & {
|
|
12
|
+
loader?: any;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
interface MergedConfig extends KoineNextConfig, Omit<NextConfig, "i18n"> {
|
|
16
|
+
}
|
|
17
|
+
export declare function withKoine({ nx, svg, sc, page, routes, permanent, debug, ...custom }?: MergedConfig): NextConfig | {
|
|
18
|
+
redirects(): Promise<import("./config-i18n.js").Redirect[]>;
|
|
19
|
+
rewrites(): Promise<{
|
|
20
|
+
beforeFiles: import("./config-i18n.js").Rewrite[];
|
|
21
|
+
afterFiles: import("next/dist/lib/load-custom-routes.js").Rewrite[];
|
|
22
|
+
fallback: import("next/dist/lib/load-custom-routes.js").Rewrite[];
|
|
23
|
+
}>;
|
|
24
|
+
exportPathMap?: ((defaultMap: import("next/dist/server/config-shared.js").ExportPathMap, ctx: {
|
|
25
|
+
dev: boolean;
|
|
26
|
+
dir: string;
|
|
27
|
+
outDir: string | null;
|
|
28
|
+
distDir: string;
|
|
29
|
+
buildId: string;
|
|
30
|
+
}) => import("next/dist/server/config-shared.js").ExportPathMap | Promise<import("next/dist/server/config-shared.js").ExportPathMap>) | undefined;
|
|
31
|
+
i18n?: import("next/dist/server/config-shared.js").I18NConfig | null | undefined;
|
|
32
|
+
eslint?: import("next/dist/server/config-shared.js").ESLintConfig | undefined;
|
|
33
|
+
typescript?: import("next/dist/server/config-shared.js").TypeScriptConfig | undefined;
|
|
34
|
+
headers?: (() => Promise<import("next/dist/lib/load-custom-routes.js").Header[]>) | undefined;
|
|
35
|
+
excludeDefaultMomentLocales?: boolean | undefined;
|
|
36
|
+
webpack?: import("next/dist/server/config-shared.js").NextJsWebpackConfig | null | undefined;
|
|
37
|
+
trailingSlash?: boolean | undefined;
|
|
38
|
+
env?: Record<string, string> | undefined;
|
|
39
|
+
distDir?: string | undefined;
|
|
40
|
+
cleanDistDir?: boolean | undefined;
|
|
41
|
+
assetPrefix?: string | undefined;
|
|
42
|
+
useFileSystemPublicRoutes?: boolean | undefined;
|
|
43
|
+
generateBuildId?: (() => string | Promise<string | null> | null) | undefined;
|
|
44
|
+
generateEtags?: boolean | undefined;
|
|
45
|
+
pageExtensions?: string[] | undefined;
|
|
46
|
+
compress?: boolean | undefined;
|
|
47
|
+
analyticsId?: string | undefined;
|
|
48
|
+
poweredByHeader?: boolean | undefined;
|
|
49
|
+
images?: Partial<import("next/dist/shared/lib/image-config.js").ImageConfigComplete> | undefined;
|
|
50
|
+
devIndicators?: {
|
|
51
|
+
buildActivity?: boolean | undefined;
|
|
52
|
+
buildActivityPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left" | undefined;
|
|
53
|
+
} | undefined;
|
|
54
|
+
onDemandEntries?: {
|
|
55
|
+
maxInactiveAge?: number | undefined;
|
|
56
|
+
pagesBufferLength?: number | undefined;
|
|
57
|
+
} | undefined;
|
|
58
|
+
amp?: {
|
|
59
|
+
canonicalBase?: string | undefined;
|
|
60
|
+
} | undefined;
|
|
61
|
+
basePath?: string | undefined;
|
|
62
|
+
sassOptions?: {
|
|
63
|
+
[key: string]: any;
|
|
64
|
+
} | undefined;
|
|
65
|
+
productionBrowserSourceMaps?: boolean | undefined;
|
|
66
|
+
optimizeFonts?: boolean | undefined;
|
|
67
|
+
reactProductionProfiling?: boolean | undefined;
|
|
68
|
+
reactStrictMode?: boolean | null | undefined;
|
|
69
|
+
publicRuntimeConfig?: {
|
|
70
|
+
[key: string]: any;
|
|
71
|
+
} | undefined;
|
|
72
|
+
serverRuntimeConfig?: {
|
|
73
|
+
[key: string]: any;
|
|
74
|
+
} | undefined;
|
|
75
|
+
httpAgentOptions?: {
|
|
76
|
+
keepAlive?: boolean | undefined;
|
|
77
|
+
} | undefined;
|
|
78
|
+
outputFileTracing?: boolean | undefined;
|
|
79
|
+
staticPageGenerationTimeout?: number | undefined;
|
|
80
|
+
crossOrigin?: false | "anonymous" | "use-credentials" | undefined;
|
|
81
|
+
swcMinify?: boolean | undefined;
|
|
82
|
+
compiler?: {
|
|
83
|
+
reactRemoveProperties?: boolean | {
|
|
84
|
+
properties?: string[] | undefined;
|
|
85
|
+
} | undefined;
|
|
86
|
+
relay?: {
|
|
87
|
+
src: string;
|
|
88
|
+
artifactDirectory?: string | undefined;
|
|
89
|
+
language?: "typescript" | "flow" | "javascript" | undefined;
|
|
90
|
+
eagerEsModules?: boolean | undefined;
|
|
91
|
+
} | undefined;
|
|
92
|
+
removeConsole?: boolean | {
|
|
93
|
+
exclude?: string[] | undefined;
|
|
94
|
+
} | undefined;
|
|
95
|
+
styledComponents?: boolean | import("next/dist/server/config-shared.js").StyledComponentsConfig | undefined;
|
|
96
|
+
emotion?: boolean | import("next/dist/server/config-shared.js").EmotionConfig | undefined;
|
|
97
|
+
} | undefined;
|
|
98
|
+
output?: "standalone" | "export" | undefined;
|
|
99
|
+
transpilePackages?: string[] | undefined;
|
|
100
|
+
skipMiddlewareUrlNormalize?: boolean | undefined;
|
|
101
|
+
skipTrailingSlashRedirect?: boolean | undefined;
|
|
102
|
+
modularizeImports?: Record<string, {
|
|
103
|
+
transform: string | Record<string, string>;
|
|
104
|
+
preventFullImport?: boolean | undefined;
|
|
105
|
+
skipDefaultConversion?: boolean | undefined;
|
|
106
|
+
}> | undefined;
|
|
107
|
+
experimental?: import("next/dist/server/config-shared.js").ExperimentalConfig | undefined;
|
|
108
|
+
};
|
|
109
|
+
export default withKoine;
|
package/config.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { __assign, __awaiter, __generator, __read, __rest, __spreadArray } from "tslib";
|
|
2
|
+
import { getRedirects, getRewrites, } from "./config-i18n.js";
|
|
3
|
+
export function withKoine(_a) {
|
|
4
|
+
if (_a === void 0) { _a = {
|
|
5
|
+
i18n: {
|
|
6
|
+
locales: ["en"],
|
|
7
|
+
defaultLocale: "en",
|
|
8
|
+
hideDefaultLocaleInUrl: false,
|
|
9
|
+
},
|
|
10
|
+
}; }
|
|
11
|
+
var _b = _a.nx, nx = _b === void 0 ? true : _b, _c = _a.svg, svg = _c === void 0 ? true : _c, _d = _a.sc, sc = _d === void 0 ? true : _d, page = _a.page, routes = _a.routes, permanent = _a.permanent, debug = _a.debug, custom = __rest(_a, ["nx", "svg", "sc", "page", "routes", "permanent", "debug"]);
|
|
12
|
+
var nextConfig = __assign({ pageExtensions: page ? ["page.tsx", "page.ts"] : undefined, eslint: {
|
|
13
|
+
ignoreDuringBuilds: true,
|
|
14
|
+
}, typescript: {
|
|
15
|
+
ignoreBuildErrors: true,
|
|
16
|
+
}, 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*)?/?)*)": {
|
|
17
|
+
transform: "@koine/next/{{ matches.[1] }}/{{member}}",
|
|
18
|
+
}, "@koine/react/?(((\\w*)?/?)*)": {
|
|
19
|
+
transform: "@koine/react/{{ matches.[1] }}/{{member}}",
|
|
20
|
+
}, "@koine/utils": { transform: "@koine/utils/{{member}}" } }, (custom["modularizeImports"] || {})), experimental: __assign({ scrollRestoration: true }, (custom["experimental"] || {})) }, custom);
|
|
21
|
+
if (svg) {
|
|
22
|
+
if (nx) {
|
|
23
|
+
nextConfig["nx"] = {
|
|
24
|
+
svgr: true,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
nextConfig.webpack = function (_config, options) {
|
|
29
|
+
var webpackConfig = typeof nextConfig.webpack === "function"
|
|
30
|
+
? nextConfig.webpack(_config, options)
|
|
31
|
+
: _config;
|
|
32
|
+
webpackConfig.module.rules.push({
|
|
33
|
+
test: /\.svg$/,
|
|
34
|
+
use: [
|
|
35
|
+
{
|
|
36
|
+
loader: "@svgr/webpack",
|
|
37
|
+
options: {
|
|
38
|
+
svgoConfig: {
|
|
39
|
+
plugins: [
|
|
40
|
+
{
|
|
41
|
+
name: "removeViewBox",
|
|
42
|
+
active: false,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
return webpackConfig;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (sc) {
|
|
55
|
+
nextConfig.compiler = {
|
|
56
|
+
styledComponents: true,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (custom.i18n) {
|
|
60
|
+
var _e = custom.i18n || {}, hideDefaultLocaleInUrl = _e.hideDefaultLocaleInUrl, localeParam = _e.localeParam, loader = _e.loader, nextI18nConfig = __rest(_e, ["hideDefaultLocaleInUrl", "localeParam", "loader"]);
|
|
61
|
+
if (localeParam) {
|
|
62
|
+
delete nextConfig.i18n;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
nextConfig.i18n = nextI18nConfig;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (routes) {
|
|
69
|
+
return __assign(__assign({}, nextConfig), { redirects: function () {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
+
var defaults, customs;
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
switch (_a.label) {
|
|
74
|
+
case 0: return [4, getRedirects(__assign({ routes: routes, permanent: permanent, debug: debug }, custom.i18n))];
|
|
75
|
+
case 1:
|
|
76
|
+
defaults = _a.sent();
|
|
77
|
+
if (!nextConfig.redirects) return [3, 3];
|
|
78
|
+
return [4, nextConfig.redirects()];
|
|
79
|
+
case 2:
|
|
80
|
+
customs = _a.sent();
|
|
81
|
+
return [2, __spreadArray(__spreadArray([], __read(defaults), false), __read(customs), false)];
|
|
82
|
+
case 3: return [2, defaults];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}, rewrites: function () {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
+
var defaults, customs;
|
|
89
|
+
return __generator(this, function (_a) {
|
|
90
|
+
switch (_a.label) {
|
|
91
|
+
case 0: return [4, getRewrites(__assign({ routes: routes, debug: debug }, custom.i18n))];
|
|
92
|
+
case 1:
|
|
93
|
+
defaults = _a.sent();
|
|
94
|
+
if (!nextConfig.rewrites) return [3, 3];
|
|
95
|
+
return [4, nextConfig.rewrites()];
|
|
96
|
+
case 2:
|
|
97
|
+
customs = _a.sent();
|
|
98
|
+
if (Array.isArray(customs)) {
|
|
99
|
+
return [2, {
|
|
100
|
+
beforeFiles: defaults,
|
|
101
|
+
afterFiles: customs,
|
|
102
|
+
fallback: [],
|
|
103
|
+
}];
|
|
104
|
+
}
|
|
105
|
+
return [2, __assign(__assign({}, customs), { beforeFiles: __spreadArray(__spreadArray([], __read(defaults), false), __read((customs.beforeFiles || [])), false) })];
|
|
106
|
+
case 3: return [2, {
|
|
107
|
+
afterFiles: [],
|
|
108
|
+
beforeFiles: defaults,
|
|
109
|
+
fallback: [],
|
|
110
|
+
}];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
} });
|
|
115
|
+
}
|
|
116
|
+
return nextConfig;
|
|
117
|
+
}
|
|
118
|
+
export default withKoine;
|
package/getSiteUrl.d.ts
CHANGED
package/getSiteUrl.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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) {
|
|
1
|
+
import { normaliseUrl } from "@koine/utils";
|
|
2
|
+
export function getSiteUrl(path) {
|
|
13
3
|
if (path === void 0) { path = ""; }
|
|
14
|
-
return (
|
|
4
|
+
return normaliseUrl("".concat(process.env["NEXT_PUBLIC_APP_URL"], "/").concat(path));
|
|
15
5
|
}
|
|
16
|
-
|
|
17
|
-
exports.default = getSiteUrl;
|
|
6
|
+
export default getSiteUrl;
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export { getSiteUrl } from "./getSiteUrl";
|
|
2
|
-
export { load } from "./load";
|
|
1
|
+
export { getSiteUrl } from "./getSiteUrl.js";
|
|
2
|
+
export { load } from "./load.js";
|
|
3
|
+
export { ThemeContext, type ThemeContextProps } from "./ThemeContext.js";
|
|
4
|
+
export { ThemeProvider, type ThemeProviderProps } from "./ThemeProvider.js";
|
|
5
|
+
export { useTheme, type UseThemeProps } from "./useTheme.js";
|
package/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var load_1 = require("./load");
|
|
7
|
-
Object.defineProperty(exports, "load", { enumerable: true, get: function () { return load_1.load; } });
|
|
1
|
+
export { getSiteUrl } from "./getSiteUrl.js";
|
|
2
|
+
export { load } from "./load.js";
|
|
3
|
+
export { ThemeContext } from "./ThemeContext.js";
|
|
4
|
+
export { ThemeProvider } from "./ThemeProvider.js";
|
|
5
|
+
export { useTheme } from "./useTheme.js";
|
package/load.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility to load a component with an optional pre-determined delay.
|
|
3
|
-
*
|
|
4
|
-
* This was designed to improve anti spam with async form loading.
|
|
5
|
-
*
|
|
6
|
-
* @see https://github.com/vercel/next.js/blob/main/packages/next/next-server/lib/dynamic.tsx
|
|
7
|
-
* @see https://github.com/vercel/next.js/blob/canary/examples/with-dynamic-import/pages/index.js
|
|
8
|
-
*/
|
|
9
1
|
export declare function load<T>(component: T, milliseconds: number): Promise<T>;
|
|
10
2
|
export default load;
|
package/load.js
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.load = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Utility to load a component with an optional pre-determined delay.
|
|
6
|
-
*
|
|
7
|
-
* This was designed to improve anti spam with async form loading.
|
|
8
|
-
*
|
|
9
|
-
* @see https://github.com/vercel/next.js/blob/main/packages/next/next-server/lib/dynamic.tsx
|
|
10
|
-
* @see https://github.com/vercel/next.js/blob/canary/examples/with-dynamic-import/pages/index.js
|
|
11
|
-
*/
|
|
12
|
-
function load(component, milliseconds) {
|
|
1
|
+
export function load(component, milliseconds) {
|
|
13
2
|
return new Promise(function (resolve) {
|
|
14
3
|
setTimeout(function () { return resolve(component); }, milliseconds);
|
|
15
4
|
});
|
|
16
5
|
}
|
|
17
|
-
|
|
18
|
-
exports.default = load;
|
|
6
|
+
export default load;
|