@koine/next 2.0.0-beta.26 → 2.0.0-beta.27
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/config-i18n.d.ts +3 -0
- package/config-i18n.js +12 -5
- package/config.d.ts +1 -3
- package/config.js +8 -12
- package/package.json +4 -4
package/config-i18n.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ type RoutesMapRoute = {
|
|
|
16
16
|
pathname: string;
|
|
17
17
|
wildcard?: boolean;
|
|
18
18
|
};
|
|
19
|
+
export declare function orderRoutes(routes: Routes, defaultLocale: Locale): {
|
|
20
|
+
[x: string]: RoutesByLocale;
|
|
21
|
+
};
|
|
19
22
|
export declare function normaliseUrlPathname(pathname?: string): string;
|
|
20
23
|
export declare function toPath(urlOrPathname?: string): string;
|
|
21
24
|
export declare function encodePathname(pathname?: string): string;
|
package/config-i18n.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __assign, __awaiter, __generator } from "tslib";
|
|
1
|
+
import { __assign, __awaiter, __generator, __rest } from "tslib";
|
|
2
2
|
var arrayUniqueByProperties = function (array, keys) {
|
|
3
3
|
return array.filter(function (item, idx, arr) {
|
|
4
4
|
return arr.findIndex(function (itemWith) {
|
|
@@ -6,6 +6,11 @@ var arrayUniqueByProperties = function (array, keys) {
|
|
|
6
6
|
}) === idx;
|
|
7
7
|
});
|
|
8
8
|
};
|
|
9
|
+
export function orderRoutes(routes, defaultLocale) {
|
|
10
|
+
var _a;
|
|
11
|
+
var _b = routes, _c = defaultLocale, routesForDefaultLocale = _b[_c], restRoutes = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]);
|
|
12
|
+
return __assign((_a = {}, _a[defaultLocale] = routesForDefaultLocale, _a), restRoutes);
|
|
13
|
+
}
|
|
9
14
|
export function normaliseUrlPathname(pathname) {
|
|
10
15
|
if (pathname === void 0) { pathname = ""; }
|
|
11
16
|
return pathname.replace(/\/+\//g, "/").replace(/^\/*(.*?)\/*$/, "$1");
|
|
@@ -130,11 +135,12 @@ export function getPathRedirect(arg) {
|
|
|
130
135
|
}
|
|
131
136
|
export function getRedirects(arg) {
|
|
132
137
|
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;
|
|
138
|
+
var routes, defaultLocale, hideDefaultLocaleInUrl, localeParam, permanent, debug, orderedRoutes, redirects, locale, routesByLocale, routesMap, template, route, isVisibleDefaultLocale, isHiddenDefaultLocale, cleaned;
|
|
134
139
|
return __generator(this, function (_a) {
|
|
135
140
|
routes = arg.routes, defaultLocale = arg.defaultLocale, hideDefaultLocaleInUrl = arg.hideDefaultLocaleInUrl, localeParam = arg.localeParam, permanent = arg.permanent, debug = arg.debug;
|
|
141
|
+
orderedRoutes = orderRoutes(routes, defaultLocale);
|
|
136
142
|
redirects = [];
|
|
137
|
-
for (locale in
|
|
143
|
+
for (locale in orderedRoutes) {
|
|
138
144
|
routesByLocale = routes[locale];
|
|
139
145
|
routesMap = getRoutesMap({}, routesByLocale);
|
|
140
146
|
for (template in routesMap) {
|
|
@@ -211,11 +217,12 @@ export function getPathRewrite(arg) {
|
|
|
211
217
|
}
|
|
212
218
|
export function getRewrites(arg) {
|
|
213
219
|
return __awaiter(this, void 0, void 0, function () {
|
|
214
|
-
var routes, defaultLocale, hideDefaultLocaleInUrl, localeParam, debug, rewrites, locale, routesByLocale, routesMap, template, route, isVisibleDefaultLocale, isHiddenDefaultLocale, cleaned;
|
|
220
|
+
var routes, defaultLocale, hideDefaultLocaleInUrl, localeParam, debug, orderedRoutes, rewrites, locale, routesByLocale, routesMap, template, route, isVisibleDefaultLocale, isHiddenDefaultLocale, cleaned;
|
|
215
221
|
return __generator(this, function (_a) {
|
|
216
222
|
routes = arg.routes, defaultLocale = arg.defaultLocale, hideDefaultLocaleInUrl = arg.hideDefaultLocaleInUrl, localeParam = arg.localeParam, debug = arg.debug;
|
|
223
|
+
orderedRoutes = orderRoutes(routes, defaultLocale);
|
|
217
224
|
rewrites = [];
|
|
218
|
-
for (locale in
|
|
225
|
+
for (locale in orderedRoutes) {
|
|
219
226
|
routesByLocale = routes[locale];
|
|
220
227
|
routesMap = getRoutesMap({}, routesByLocale);
|
|
221
228
|
for (template in routesMap) {
|
package/config.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ import { type ConfigI18nOptions, type Routes } from "./config-i18n.js";
|
|
|
3
3
|
interface KoineNextConfig {
|
|
4
4
|
nx?: boolean;
|
|
5
5
|
svg?: boolean;
|
|
6
|
-
sc?: boolean;
|
|
7
|
-
page?: boolean;
|
|
8
6
|
routes?: Routes;
|
|
9
7
|
permanent?: boolean;
|
|
10
8
|
debug?: boolean;
|
|
@@ -14,7 +12,7 @@ interface KoineNextConfig {
|
|
|
14
12
|
}
|
|
15
13
|
interface MergedConfig extends KoineNextConfig, Omit<NextConfig, "i18n"> {
|
|
16
14
|
}
|
|
17
|
-
export declare function withKoine({ nx, svg,
|
|
15
|
+
export declare function withKoine({ nx, svg, page, routes, permanent, debug, ...custom }?: MergedConfig): NextConfig | {
|
|
18
16
|
redirects(): Promise<import("./config-i18n.js").Redirect[]>;
|
|
19
17
|
rewrites(): Promise<{
|
|
20
18
|
beforeFiles: import("./config-i18n.js").Rewrite[];
|
package/config.js
CHANGED
|
@@ -8,14 +8,14 @@ export function withKoine(_a) {
|
|
|
8
8
|
hideDefaultLocaleInUrl: false,
|
|
9
9
|
},
|
|
10
10
|
}; }
|
|
11
|
-
var _b = _a.nx, nx = _b === void 0 ? true : _b, _c = _a.svg, svg = _c === void 0 ? true : _c,
|
|
12
|
-
var nextConfig = __assign({
|
|
11
|
+
var _b = _a.nx, nx = _b === void 0 ? true : _b, _c = _a.svg, svg = _c === void 0 ? true : _c, page = _a.page, routes = _a.routes, permanent = _a.permanent, debug = _a.debug, custom = __rest(_a, ["nx", "svg", "page", "routes", "permanent", "debug"]);
|
|
12
|
+
var nextConfig = __assign({ eslint: {
|
|
13
13
|
ignoreDuringBuilds: true,
|
|
14
14
|
}, typescript: {
|
|
15
15
|
ignoreBuildErrors: true,
|
|
16
|
-
}, poweredByHeader: false,
|
|
16
|
+
}, poweredByHeader: false, modularizeImports: __assign({ "@koine/api": { transform: "@koine/api/{{member}}" }, "@koine/browser": { transform: "@koine/browser/{{member}}" }, "@koine/dom": { transform: "@koine/dom/{{member}}" }, "@koine/i18n": { transform: "@koine/i18n/{{member}}" }, "@koine/next/?(((\\w*)?/?)*)": {
|
|
17
17
|
transform: "@koine/next/{{ matches.[1] }}/{{member}}",
|
|
18
|
-
}, "@koine/react/?(((\\w*)?/?)*)": {
|
|
18
|
+
}, "@koine/node": { transform: "@koine/node/{{member}}" }, "@koine/react/?(((\\w*)?/?)*)": {
|
|
19
19
|
transform: "@koine/react/{{ matches.[1] }}/{{member}}",
|
|
20
20
|
}, "@koine/utils": { transform: "@koine/utils/{{member}}" } }, (custom["modularizeImports"] || {})), experimental: __assign({ scrollRestoration: true }, (custom["experimental"] || {})) }, custom);
|
|
21
21
|
if (svg) {
|
|
@@ -25,6 +25,7 @@ export function withKoine(_a) {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
|
+
delete nextConfig["nx"];
|
|
28
29
|
nextConfig.webpack = function (_config, options) {
|
|
29
30
|
var webpackConfig = typeof nextConfig.webpack === "function"
|
|
30
31
|
? nextConfig.webpack(_config, options)
|
|
@@ -51,18 +52,13 @@ export function withKoine(_a) {
|
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
|
-
if (sc) {
|
|
55
|
-
nextConfig.compiler = {
|
|
56
|
-
styledComponents: true,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
55
|
if (custom.i18n) {
|
|
60
|
-
var
|
|
56
|
+
var _d = custom.i18n, locales = _d.locales, defaultLocale = _d.defaultLocale, localeParam = _d.localeParam;
|
|
61
57
|
if (localeParam) {
|
|
62
58
|
delete nextConfig.i18n;
|
|
63
59
|
}
|
|
64
60
|
else {
|
|
65
|
-
nextConfig.i18n =
|
|
61
|
+
nextConfig.i18n = { locales: locales, defaultLocale: defaultLocale };
|
|
66
62
|
}
|
|
67
63
|
}
|
|
68
64
|
if (routes) {
|
|
@@ -104,8 +100,8 @@ export function withKoine(_a) {
|
|
|
104
100
|
}
|
|
105
101
|
return [2, __assign(__assign({}, customs), { beforeFiles: __spreadArray(__spreadArray([], __read(defaults), false), __read((customs.beforeFiles || [])), false) })];
|
|
106
102
|
case 3: return [2, {
|
|
107
|
-
afterFiles: [],
|
|
108
103
|
beforeFiles: defaults,
|
|
104
|
+
afterFiles: [],
|
|
109
105
|
fallback: [],
|
|
110
106
|
}];
|
|
111
107
|
}
|
package/package.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"name": "@koine/next",
|
|
3
3
|
"sideEffects": false,
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@koine/browser": "2.0.0-beta.
|
|
6
|
-
"@koine/react": "2.0.0-beta.
|
|
7
|
-
"@koine/utils": "2.0.0-beta.
|
|
5
|
+
"@koine/browser": "2.0.0-beta.27",
|
|
6
|
+
"@koine/react": "2.0.0-beta.27",
|
|
7
|
+
"@koine/utils": "2.0.0-beta.27"
|
|
8
8
|
},
|
|
9
9
|
"peerDependenciesMeta": {
|
|
10
10
|
"@kuus/yup": {
|
|
@@ -172,5 +172,5 @@
|
|
|
172
172
|
}
|
|
173
173
|
},
|
|
174
174
|
"peerDependencies": {},
|
|
175
|
-
"version": "2.0.0-beta.
|
|
175
|
+
"version": "2.0.0-beta.27"
|
|
176
176
|
}
|