@koine/next 1.1.10 → 1.1.11
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/AnalyticsGoogle.js +19 -15
- package/AnalyticsGoogle.mjs +34 -0
- package/DisableErrorOverlay.js +10 -5
- package/DisableErrorOverlay.mjs +13 -0
- package/DynamicNamespaces.js +7 -3
- package/DynamicNamespaces.mjs +8 -0
- package/Favicon.js +10 -6
- package/Favicon.mjs +6 -0
- package/Head.js +7 -3
- package/Head.mjs +3 -0
- package/Link.js +11 -8
- package/Link.mjs +12 -0
- package/NextProgress.js +16 -12
- package/{node/NextProgress.js → NextProgress.mjs} +12 -16
- package/Seo.js +11 -6
- package/{node/Seo.js → Seo.mjs} +6 -11
- package/SeoDefaults.js +11 -6
- package/SeoDefaults.mjs +12 -0
- package/T.js +9 -5
- package/T.mjs +10 -0
- package/ThemeContext.js +6 -3
- package/ThemeContext.mjs +7 -0
- package/ThemeProvider.js +28 -24
- package/{node/ThemeProvider.js → ThemeProvider.mjs} +24 -28
- package/TransText.js +7 -3
- package/TransText.mjs +3 -0
- package/app/AppHead.js +10 -5
- package/app/AppHead.mjs +6 -0
- package/app/AppMain.js +2 -1
- package/app/AppMain.mjs +1 -0
- package/app/css/AppMain.js +11 -7
- package/app/css/AppMain.mjs +14 -0
- package/app/css/AppTheme.js +10 -6
- package/app/css/AppTheme.mjs +15 -0
- package/app/css/auth/index.js +13 -9
- package/app/css/auth/index.mjs +13 -0
- package/app/css/auth/package.json +2 -2
- package/app/css/index.js +12 -8
- package/{node/app/css/index.js → app/css/index.mjs} +8 -12
- package/app/css/package.json +2 -2
- package/app/em/AppMain.js +16 -12
- package/app/em/AppMain.mjs +25 -0
- package/app/em/AppTheme.js +16 -12
- package/app/em/AppTheme.mjs +19 -0
- package/app/em/auth/index.js +13 -9
- package/app/em/auth/index.mjs +13 -0
- package/app/em/auth/package.json +2 -2
- package/app/em/index.js +12 -8
- package/app/em/index.mjs +12 -0
- package/app/em/package.json +2 -2
- package/app/index.js +5 -2
- package/app/index.mjs +2 -0
- package/app/package.json +2 -2
- package/app/sc/AppMain.js +16 -12
- package/app/sc/AppMain.mjs +25 -0
- package/app/sc/AppTheme.js +11 -7
- package/app/sc/AppTheme.mjs +12 -0
- package/app/sc/auth/index.js +13 -9
- package/app/sc/auth/index.mjs +13 -0
- package/app/sc/auth/package.json +2 -2
- package/app/sc/index.js +12 -8
- package/{node/app/sc/index.js → app/sc/index.mjs} +8 -12
- package/app/sc/package.json +2 -2
- package/auth/helpers.js +13 -7
- package/auth/helpers.mjs +22 -0
- package/auth/index.js +7 -4
- package/auth/index.mjs +4 -0
- package/auth/package.json +2 -2
- package/auth/useLogin.js +22 -18
- package/auth/useLogin.mjs +50 -0
- package/auth/useLoginUrl.js +13 -9
- package/auth/useLoginUrl.mjs +12 -0
- package/auth/useLogout.js +23 -18
- package/auth/useLogout.mjs +53 -0
- package/config/index.js +36 -25
- package/{node/config/index.js → config/index.mjs} +25 -36
- package/config/package.json +2 -2
- package/createEmotionCache.js +9 -4
- package/createEmotionCache.mjs +9 -0
- package/document/Document.js +13 -10
- package/document/Document.mjs +28 -0
- package/document/css/index.js +18 -15
- package/document/css/index.mjs +45 -0
- package/document/css/package.json +2 -2
- package/document/em/index.js +22 -19
- package/document/em/index.mjs +60 -0
- package/document/em/package.json +2 -2
- package/document/index.js +7 -2
- package/document/index.mjs +2 -0
- package/document/package.json +2 -2
- package/document/sc/index.js +21 -18
- package/document/sc/index.mjs +64 -0
- package/document/sc/package.json +2 -2
- package/getSiteUrl.js +9 -4
- package/getSiteUrl.mjs +12 -0
- package/getT.js +7 -3
- package/{node/getT.js → getT.mjs} +3 -7
- package/index.js +31 -28
- package/index.mjs +30 -0
- package/load.js +6 -2
- package/{node/load.js → load.mjs} +2 -6
- package/package.json +6 -4
- package/revalidate.js +5 -2
- package/revalidate.mjs +5 -0
- package/seoBuildTags.js +17 -13
- package/{node/seoBuildTags.js → seoBuildTags.mjs} +13 -17
- package/to.js +6 -2
- package/{node/to.js → to.mjs} +2 -6
- package/translationAsOptions.js +5 -1
- package/{node/translationAsOptions.js → translationAsOptions.mjs} +1 -5
- package/types-i18n.js +2 -1
- package/{node/types-i18n.js → types-i18n.mjs} +1 -2
- package/types-seo.js +2 -1
- package/types-seo.mjs +1 -0
- package/useBackUrl.js +15 -10
- package/useBackUrl.mjs +27 -0
- package/useDateFormat.js +17 -13
- package/useDateFormat.mjs +38 -0
- package/useForm.js +14 -10
- package/{node/useForm.js → useForm.mjs} +10 -14
- package/useLocale.js +9 -4
- package/useLocale.mjs +5 -0
- package/useT.js +11 -6
- package/{node/useT.js → useT.mjs} +6 -11
- package/useTheme.js +8 -4
- package/useTheme.mjs +7 -0
- package/useTo.js +11 -7
- package/useTo.mjs +14 -0
- package/NextImg.d.ts +0 -16
- package/NextImg.js +0 -20
- package/NextImgSmart.d.ts +0 -6
- package/NextImgSmart.js +0 -13
- package/node/AnalyticsGoogle.js +0 -38
- package/node/DisableErrorOverlay.js +0 -18
- package/node/DynamicNamespaces.js +0 -12
- package/node/Favicon.js +0 -10
- package/node/Head.js +0 -7
- package/node/Link.js +0 -15
- package/node/SeoDefaults.js +0 -17
- package/node/T.js +0 -14
- package/node/ThemeContext.js +0 -10
- package/node/TransText.js +0 -7
- package/node/app/AppHead.js +0 -11
- package/node/app/AppMain.js +0 -2
- package/node/app/css/AppMain.js +0 -18
- package/node/app/css/AppTheme.js +0 -19
- package/node/app/css/auth/index.js +0 -17
- package/node/app/em/AppMain.js +0 -29
- package/node/app/em/AppTheme.js +0 -23
- package/node/app/em/auth/index.js +0 -17
- package/node/app/em/index.js +0 -16
- package/node/app/index.js +0 -5
- package/node/app/sc/AppMain.js +0 -29
- package/node/app/sc/AppTheme.js +0 -16
- package/node/app/sc/auth/index.js +0 -17
- package/node/auth/helpers.js +0 -28
- package/node/auth/index.js +0 -7
- package/node/auth/useLogin.js +0 -54
- package/node/auth/useLoginUrl.js +0 -16
- package/node/auth/useLogout.js +0 -58
- package/node/createEmotionCache.js +0 -14
- package/node/document/Document.js +0 -31
- package/node/document/css/index.js +0 -48
- package/node/document/em/index.js +0 -63
- package/node/document/index.js +0 -7
- package/node/document/sc/index.js +0 -67
- package/node/getSiteUrl.js +0 -17
- package/node/index.js +0 -33
- package/node/revalidate.js +0 -8
- package/node/types-seo.js +0 -2
- package/node/useBackUrl.js +0 -32
- package/node/useDateFormat.js +0 -42
- package/node/useLocale.js +0 -10
- package/node/useTheme.js +0 -11
- package/node/useTo.js +0 -18
package/config/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withKoine = exports.getRewrites = exports.getRedirects = exports.getPathRedirect = exports.getPathRewrite = exports.encodePathname = exports.toPath = exports.normaliseUrlPathname = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
2
5
|
/**
|
|
3
6
|
* Normalise pathname
|
|
4
7
|
*
|
|
@@ -8,12 +11,13 @@ import { __assign, __awaiter, __generator, __rest, __spreadArray } from "tslib";
|
|
|
8
11
|
* - Removing initial and ending slashes
|
|
9
12
|
* - Returns an empty string `"""` if only slashes are given
|
|
10
13
|
*/
|
|
11
|
-
|
|
14
|
+
function normaliseUrlPathname(pathname) {
|
|
12
15
|
if (pathname === void 0) { pathname = ""; }
|
|
13
16
|
// with return pathname.replace(/\/+\//g, "/").replace(/^\/+(.*?)\/+$/, "$1");
|
|
14
17
|
// we would instead return a single slash if only slashes are given
|
|
15
18
|
return pathname.replace(/\/+\//g, "/").replace(/^\/*(.*?)\/*$/, "$1");
|
|
16
19
|
}
|
|
20
|
+
exports.normaliseUrlPathname = normaliseUrlPathname;
|
|
17
21
|
/**
|
|
18
22
|
* Transform to path any absolute or relative URL
|
|
19
23
|
*
|
|
@@ -24,7 +28,7 @@ export function normaliseUrlPathname(pathname) {
|
|
|
24
28
|
*
|
|
25
29
|
* @see {@link normaliseUrlPathname}
|
|
26
30
|
*/
|
|
27
|
-
|
|
31
|
+
function toPath(urlOrPathname) {
|
|
28
32
|
if (urlOrPathname === void 0) { urlOrPathname = ""; }
|
|
29
33
|
var pathname = "";
|
|
30
34
|
try {
|
|
@@ -38,12 +42,13 @@ export function toPath(urlOrPathname) {
|
|
|
38
42
|
// we would instead return a single slash if only slashes are given
|
|
39
43
|
return pathname.replace(/\/+\//g, "/").replace(/^\/*(.*?)\/*$/, "$1");
|
|
40
44
|
}
|
|
45
|
+
exports.toPath = toPath;
|
|
41
46
|
/**
|
|
42
47
|
* Clean a pathname and encode each part
|
|
43
48
|
*
|
|
44
49
|
* @see {@link normaliseUrlPathname}
|
|
45
50
|
*/
|
|
46
|
-
|
|
51
|
+
function encodePathname(pathname) {
|
|
47
52
|
if (pathname === void 0) { pathname = ""; }
|
|
48
53
|
var parts = normaliseUrlPathname(pathname).split("/");
|
|
49
54
|
return parts
|
|
@@ -51,6 +56,7 @@ export function encodePathname(pathname) {
|
|
|
51
56
|
.map(function (part) { return encodeURIComponent(part); })
|
|
52
57
|
.join("/");
|
|
53
58
|
}
|
|
59
|
+
exports.encodePathname = encodePathname;
|
|
54
60
|
/**
|
|
55
61
|
* Transform the route translated defintion into a `pathname` and a `template`.
|
|
56
62
|
*
|
|
@@ -123,7 +129,7 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
|
|
|
123
129
|
/**
|
|
124
130
|
* Get path rewrite
|
|
125
131
|
*/
|
|
126
|
-
|
|
132
|
+
function getPathRewrite(route) {
|
|
127
133
|
var _a = transformRoute(route), pathname = _a.pathname, template = _a.template;
|
|
128
134
|
var source = "/".concat(normaliseUrlPathname(pathname));
|
|
129
135
|
var destination = "/".concat(normaliseUrlPathname(template));
|
|
@@ -133,10 +139,11 @@ export function getPathRewrite(route) {
|
|
|
133
139
|
destination: destination.replace(/\/index$/, ""),
|
|
134
140
|
};
|
|
135
141
|
}
|
|
142
|
+
exports.getPathRewrite = getPathRewrite;
|
|
136
143
|
/**
|
|
137
144
|
* Get path redirect
|
|
138
145
|
*/
|
|
139
|
-
|
|
146
|
+
function getPathRedirect(locale, route, permanent) {
|
|
140
147
|
if (locale === void 0) { locale = ""; }
|
|
141
148
|
var _a = transformRoute(route), template = _a.template, pathname = _a.pathname;
|
|
142
149
|
var source = "/".concat(normaliseUrlPathname((locale ? "/".concat(locale, "/") : "/") + template));
|
|
@@ -149,12 +156,13 @@ export function getPathRedirect(locale, route, permanent) {
|
|
|
149
156
|
locale: false,
|
|
150
157
|
};
|
|
151
158
|
}
|
|
159
|
+
exports.getPathRedirect = getPathRedirect;
|
|
152
160
|
/**
|
|
153
161
|
*/
|
|
154
|
-
|
|
155
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
162
|
+
function getRedirects(defaultLocale, routes, permanent, debug) {
|
|
163
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
156
164
|
var redirects, routesMap;
|
|
157
|
-
return __generator(this, function (_a) {
|
|
165
|
+
return tslib_1.__generator(this, function (_a) {
|
|
158
166
|
redirects = [];
|
|
159
167
|
routesMap = getRoutesMap({}, routes);
|
|
160
168
|
Object.keys(routesMap).forEach(function (template) {
|
|
@@ -170,12 +178,13 @@ export function getRedirects(defaultLocale, routes, permanent, debug) {
|
|
|
170
178
|
});
|
|
171
179
|
});
|
|
172
180
|
}
|
|
181
|
+
exports.getRedirects = getRedirects;
|
|
173
182
|
/**
|
|
174
183
|
*/
|
|
175
|
-
|
|
176
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
+
function getRewrites(routes, debug) {
|
|
185
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
177
186
|
var rewrites, routesMap;
|
|
178
|
-
return __generator(this, function (_a) {
|
|
187
|
+
return tslib_1.__generator(this, function (_a) {
|
|
179
188
|
rewrites = [];
|
|
180
189
|
routesMap = getRoutesMap({}, routes);
|
|
181
190
|
Object.keys(routesMap).forEach(function (template) {
|
|
@@ -190,6 +199,7 @@ export function getRewrites(routes, debug) {
|
|
|
190
199
|
});
|
|
191
200
|
});
|
|
192
201
|
}
|
|
202
|
+
exports.getRewrites = getRewrites;
|
|
193
203
|
/**
|
|
194
204
|
* Get Next.js config with some basic opinionated defaults
|
|
195
205
|
*
|
|
@@ -201,23 +211,23 @@ export function getRewrites(routes, debug) {
|
|
|
201
211
|
* 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)
|
|
202
212
|
* and it enables the same for `next-translate`.
|
|
203
213
|
*/
|
|
204
|
-
|
|
214
|
+
function withKoine(_a) {
|
|
205
215
|
var _b;
|
|
206
216
|
if (_a === void 0) { _a = {
|
|
207
217
|
i18n: { locales: ["en"], defaultLocale: "en" },
|
|
208
218
|
}; }
|
|
209
|
-
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"]);
|
|
210
|
-
var nextConfig = __assign({
|
|
219
|
+
var _c = _a.nx, nx = _c === void 0 ? true : _c, _d = _a.svg, svg = _d === void 0 ? true : _d, _e = _a.sc, sc = _e === void 0 ? true : _e, page = _a.page, routes = _a.routes, permanent = _a.permanent, debug = _a.debug, custom = tslib_1.__rest(_a, ["nx", "svg", "sc", "page", "routes", "permanent", "debug"]);
|
|
220
|
+
var nextConfig = tslib_1.__assign({
|
|
211
221
|
// @see https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory
|
|
212
222
|
pageExtensions: page ? ["page.tsx", "page.ts"] : undefined, eslint: {
|
|
213
223
|
ignoreDuringBuilds: true, // we have this strict check on each commit
|
|
214
224
|
}, typescript: {
|
|
215
225
|
ignoreBuildErrors: true, // we have this strict check on each commit
|
|
216
|
-
}, 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*)?/?)*)": {
|
|
226
|
+
}, poweredByHeader: false, swcMinify: true, modularizeImports: tslib_1.__assign({ "@koine/api": { transform: "@koine/api/{{member}}" }, "@koine/browser": { transform: "@koine/browser/{{member}}" }, "@koine/dom": { transform: "@koine/dom/{{member}}" }, "@koine/next/?(((\\w*)?/?)*)": {
|
|
217
227
|
transform: "@koine/next/{{ matches.[1] }}/{{member}}",
|
|
218
228
|
}, "@koine/react/?(((\\w*)?/?)*)": {
|
|
219
229
|
transform: "@koine/react/{{ matches.[1] }}/{{member}}",
|
|
220
|
-
}, "@koine/utils": { transform: "@koine/utils/{{member}}" } }, (custom["modularizeImports"] || {})), experimental: __assign({
|
|
230
|
+
}, "@koine/utils": { transform: "@koine/utils/{{member}}" } }, (custom["modularizeImports"] || {})), experimental: tslib_1.__assign({
|
|
221
231
|
// @see https://github.com/vercel/vercel/discussions/5973#discussioncomment-472618
|
|
222
232
|
// @see critters error https://github.com/vercel/next.js/issues/20742
|
|
223
233
|
// optimizeCss: true,
|
|
@@ -266,10 +276,10 @@ export function withKoine(_a) {
|
|
|
266
276
|
if (routes) {
|
|
267
277
|
// we pass the default values, so we can assert I guess
|
|
268
278
|
var defaultLocale_1 = (_b = nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.i18n) === null || _b === void 0 ? void 0 : _b.defaultLocale;
|
|
269
|
-
return __assign(__assign({}, nextConfig), { redirects: function () {
|
|
270
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
279
|
+
return tslib_1.__assign(tslib_1.__assign({}, nextConfig), { redirects: function () {
|
|
280
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
271
281
|
var defaults, customs;
|
|
272
|
-
return __generator(this, function (_a) {
|
|
282
|
+
return tslib_1.__generator(this, function (_a) {
|
|
273
283
|
switch (_a.label) {
|
|
274
284
|
case 0: return [4 /*yield*/, getRedirects(defaultLocale_1, routes, permanent, debug)];
|
|
275
285
|
case 1:
|
|
@@ -278,15 +288,15 @@ export function withKoine(_a) {
|
|
|
278
288
|
return [4 /*yield*/, nextConfig.redirects()];
|
|
279
289
|
case 2:
|
|
280
290
|
customs = _a.sent();
|
|
281
|
-
return [2 /*return*/, __spreadArray(__spreadArray([], defaults, true), customs, true)];
|
|
291
|
+
return [2 /*return*/, tslib_1.__spreadArray(tslib_1.__spreadArray([], defaults, true), customs, true)];
|
|
282
292
|
case 3: return [2 /*return*/, defaults];
|
|
283
293
|
}
|
|
284
294
|
});
|
|
285
295
|
});
|
|
286
296
|
}, rewrites: function () {
|
|
287
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
297
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
288
298
|
var defaults, customs;
|
|
289
|
-
return __generator(this, function (_a) {
|
|
299
|
+
return tslib_1.__generator(this, function (_a) {
|
|
290
300
|
switch (_a.label) {
|
|
291
301
|
case 0: return [4 /*yield*/, getRewrites(routes, debug)];
|
|
292
302
|
case 1:
|
|
@@ -302,7 +312,7 @@ export function withKoine(_a) {
|
|
|
302
312
|
fallback: [],
|
|
303
313
|
}];
|
|
304
314
|
}
|
|
305
|
-
return [2 /*return*/, __assign(__assign({}, customs), { beforeFiles: __spreadArray(__spreadArray([], defaults, true), (customs.beforeFiles || []), true) })];
|
|
315
|
+
return [2 /*return*/, tslib_1.__assign(tslib_1.__assign({}, customs), { beforeFiles: tslib_1.__spreadArray(tslib_1.__spreadArray([], defaults, true), (customs.beforeFiles || []), true) })];
|
|
306
316
|
case 3: return [2 /*return*/, {
|
|
307
317
|
afterFiles: [],
|
|
308
318
|
beforeFiles: defaults,
|
|
@@ -315,4 +325,5 @@ export function withKoine(_a) {
|
|
|
315
325
|
}
|
|
316
326
|
return nextConfig;
|
|
317
327
|
}
|
|
318
|
-
|
|
328
|
+
exports.withKoine = withKoine;
|
|
329
|
+
exports.default = withKoine;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withKoine = exports.getRewrites = exports.getRedirects = exports.getPathRedirect = exports.getPathRewrite = exports.encodePathname = exports.toPath = exports.normaliseUrlPathname = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
1
|
+
import { __assign, __awaiter, __generator, __rest, __spreadArray } from "tslib";
|
|
5
2
|
/**
|
|
6
3
|
* Normalise pathname
|
|
7
4
|
*
|
|
@@ -11,13 +8,12 @@ var tslib_1 = require("tslib");
|
|
|
11
8
|
* - Removing initial and ending slashes
|
|
12
9
|
* - Returns an empty string `"""` if only slashes are given
|
|
13
10
|
*/
|
|
14
|
-
function normaliseUrlPathname(pathname) {
|
|
11
|
+
export function normaliseUrlPathname(pathname) {
|
|
15
12
|
if (pathname === void 0) { pathname = ""; }
|
|
16
13
|
// with return pathname.replace(/\/+\//g, "/").replace(/^\/+(.*?)\/+$/, "$1");
|
|
17
14
|
// we would instead return a single slash if only slashes are given
|
|
18
15
|
return pathname.replace(/\/+\//g, "/").replace(/^\/*(.*?)\/*$/, "$1");
|
|
19
16
|
}
|
|
20
|
-
exports.normaliseUrlPathname = normaliseUrlPathname;
|
|
21
17
|
/**
|
|
22
18
|
* Transform to path any absolute or relative URL
|
|
23
19
|
*
|
|
@@ -28,7 +24,7 @@ exports.normaliseUrlPathname = normaliseUrlPathname;
|
|
|
28
24
|
*
|
|
29
25
|
* @see {@link normaliseUrlPathname}
|
|
30
26
|
*/
|
|
31
|
-
function toPath(urlOrPathname) {
|
|
27
|
+
export function toPath(urlOrPathname) {
|
|
32
28
|
if (urlOrPathname === void 0) { urlOrPathname = ""; }
|
|
33
29
|
var pathname = "";
|
|
34
30
|
try {
|
|
@@ -42,13 +38,12 @@ function toPath(urlOrPathname) {
|
|
|
42
38
|
// we would instead return a single slash if only slashes are given
|
|
43
39
|
return pathname.replace(/\/+\//g, "/").replace(/^\/*(.*?)\/*$/, "$1");
|
|
44
40
|
}
|
|
45
|
-
exports.toPath = toPath;
|
|
46
41
|
/**
|
|
47
42
|
* Clean a pathname and encode each part
|
|
48
43
|
*
|
|
49
44
|
* @see {@link normaliseUrlPathname}
|
|
50
45
|
*/
|
|
51
|
-
function encodePathname(pathname) {
|
|
46
|
+
export function encodePathname(pathname) {
|
|
52
47
|
if (pathname === void 0) { pathname = ""; }
|
|
53
48
|
var parts = normaliseUrlPathname(pathname).split("/");
|
|
54
49
|
return parts
|
|
@@ -56,7 +51,6 @@ function encodePathname(pathname) {
|
|
|
56
51
|
.map(function (part) { return encodeURIComponent(part); })
|
|
57
52
|
.join("/");
|
|
58
53
|
}
|
|
59
|
-
exports.encodePathname = encodePathname;
|
|
60
54
|
/**
|
|
61
55
|
* Transform the route translated defintion into a `pathname` and a `template`.
|
|
62
56
|
*
|
|
@@ -129,7 +123,7 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
|
|
|
129
123
|
/**
|
|
130
124
|
* Get path rewrite
|
|
131
125
|
*/
|
|
132
|
-
function getPathRewrite(route) {
|
|
126
|
+
export function getPathRewrite(route) {
|
|
133
127
|
var _a = transformRoute(route), pathname = _a.pathname, template = _a.template;
|
|
134
128
|
var source = "/".concat(normaliseUrlPathname(pathname));
|
|
135
129
|
var destination = "/".concat(normaliseUrlPathname(template));
|
|
@@ -139,11 +133,10 @@ function getPathRewrite(route) {
|
|
|
139
133
|
destination: destination.replace(/\/index$/, ""),
|
|
140
134
|
};
|
|
141
135
|
}
|
|
142
|
-
exports.getPathRewrite = getPathRewrite;
|
|
143
136
|
/**
|
|
144
137
|
* Get path redirect
|
|
145
138
|
*/
|
|
146
|
-
function getPathRedirect(locale, route, permanent) {
|
|
139
|
+
export function getPathRedirect(locale, route, permanent) {
|
|
147
140
|
if (locale === void 0) { locale = ""; }
|
|
148
141
|
var _a = transformRoute(route), template = _a.template, pathname = _a.pathname;
|
|
149
142
|
var source = "/".concat(normaliseUrlPathname((locale ? "/".concat(locale, "/") : "/") + template));
|
|
@@ -156,13 +149,12 @@ function getPathRedirect(locale, route, permanent) {
|
|
|
156
149
|
locale: false,
|
|
157
150
|
};
|
|
158
151
|
}
|
|
159
|
-
exports.getPathRedirect = getPathRedirect;
|
|
160
152
|
/**
|
|
161
153
|
*/
|
|
162
|
-
function getRedirects(defaultLocale, routes, permanent, debug) {
|
|
163
|
-
return
|
|
154
|
+
export function getRedirects(defaultLocale, routes, permanent, debug) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
164
156
|
var redirects, routesMap;
|
|
165
|
-
return
|
|
157
|
+
return __generator(this, function (_a) {
|
|
166
158
|
redirects = [];
|
|
167
159
|
routesMap = getRoutesMap({}, routes);
|
|
168
160
|
Object.keys(routesMap).forEach(function (template) {
|
|
@@ -178,13 +170,12 @@ function getRedirects(defaultLocale, routes, permanent, debug) {
|
|
|
178
170
|
});
|
|
179
171
|
});
|
|
180
172
|
}
|
|
181
|
-
exports.getRedirects = getRedirects;
|
|
182
173
|
/**
|
|
183
174
|
*/
|
|
184
|
-
function getRewrites(routes, debug) {
|
|
185
|
-
return
|
|
175
|
+
export function getRewrites(routes, debug) {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
186
177
|
var rewrites, routesMap;
|
|
187
|
-
return
|
|
178
|
+
return __generator(this, function (_a) {
|
|
188
179
|
rewrites = [];
|
|
189
180
|
routesMap = getRoutesMap({}, routes);
|
|
190
181
|
Object.keys(routesMap).forEach(function (template) {
|
|
@@ -199,7 +190,6 @@ function getRewrites(routes, debug) {
|
|
|
199
190
|
});
|
|
200
191
|
});
|
|
201
192
|
}
|
|
202
|
-
exports.getRewrites = getRewrites;
|
|
203
193
|
/**
|
|
204
194
|
* Get Next.js config with some basic opinionated defaults
|
|
205
195
|
*
|
|
@@ -211,23 +201,23 @@ exports.getRewrites = getRewrites;
|
|
|
211
201
|
* 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)
|
|
212
202
|
* and it enables the same for `next-translate`.
|
|
213
203
|
*/
|
|
214
|
-
function withKoine(_a) {
|
|
204
|
+
export function withKoine(_a) {
|
|
215
205
|
var _b;
|
|
216
206
|
if (_a === void 0) { _a = {
|
|
217
207
|
i18n: { locales: ["en"], defaultLocale: "en" },
|
|
218
208
|
}; }
|
|
219
|
-
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 =
|
|
220
|
-
var nextConfig =
|
|
209
|
+
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"]);
|
|
210
|
+
var nextConfig = __assign({
|
|
221
211
|
// @see https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory
|
|
222
212
|
pageExtensions: page ? ["page.tsx", "page.ts"] : undefined, eslint: {
|
|
223
213
|
ignoreDuringBuilds: true, // we have this strict check on each commit
|
|
224
214
|
}, typescript: {
|
|
225
215
|
ignoreBuildErrors: true, // we have this strict check on each commit
|
|
226
|
-
}, poweredByHeader: false, swcMinify: true, modularizeImports:
|
|
216
|
+
}, 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*)?/?)*)": {
|
|
227
217
|
transform: "@koine/next/{{ matches.[1] }}/{{member}}",
|
|
228
218
|
}, "@koine/react/?(((\\w*)?/?)*)": {
|
|
229
219
|
transform: "@koine/react/{{ matches.[1] }}/{{member}}",
|
|
230
|
-
}, "@koine/utils": { transform: "@koine/utils/{{member}}" } }, (custom["modularizeImports"] || {})), experimental:
|
|
220
|
+
}, "@koine/utils": { transform: "@koine/utils/{{member}}" } }, (custom["modularizeImports"] || {})), experimental: __assign({
|
|
231
221
|
// @see https://github.com/vercel/vercel/discussions/5973#discussioncomment-472618
|
|
232
222
|
// @see critters error https://github.com/vercel/next.js/issues/20742
|
|
233
223
|
// optimizeCss: true,
|
|
@@ -276,10 +266,10 @@ function withKoine(_a) {
|
|
|
276
266
|
if (routes) {
|
|
277
267
|
// we pass the default values, so we can assert I guess
|
|
278
268
|
var defaultLocale_1 = (_b = nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.i18n) === null || _b === void 0 ? void 0 : _b.defaultLocale;
|
|
279
|
-
return
|
|
280
|
-
return
|
|
269
|
+
return __assign(__assign({}, nextConfig), { redirects: function () {
|
|
270
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
281
271
|
var defaults, customs;
|
|
282
|
-
return
|
|
272
|
+
return __generator(this, function (_a) {
|
|
283
273
|
switch (_a.label) {
|
|
284
274
|
case 0: return [4 /*yield*/, getRedirects(defaultLocale_1, routes, permanent, debug)];
|
|
285
275
|
case 1:
|
|
@@ -288,15 +278,15 @@ function withKoine(_a) {
|
|
|
288
278
|
return [4 /*yield*/, nextConfig.redirects()];
|
|
289
279
|
case 2:
|
|
290
280
|
customs = _a.sent();
|
|
291
|
-
return [2 /*return*/,
|
|
281
|
+
return [2 /*return*/, __spreadArray(__spreadArray([], defaults, true), customs, true)];
|
|
292
282
|
case 3: return [2 /*return*/, defaults];
|
|
293
283
|
}
|
|
294
284
|
});
|
|
295
285
|
});
|
|
296
286
|
}, rewrites: function () {
|
|
297
|
-
return
|
|
287
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
298
288
|
var defaults, customs;
|
|
299
|
-
return
|
|
289
|
+
return __generator(this, function (_a) {
|
|
300
290
|
switch (_a.label) {
|
|
301
291
|
case 0: return [4 /*yield*/, getRewrites(routes, debug)];
|
|
302
292
|
case 1:
|
|
@@ -312,7 +302,7 @@ function withKoine(_a) {
|
|
|
312
302
|
fallback: [],
|
|
313
303
|
}];
|
|
314
304
|
}
|
|
315
|
-
return [2 /*return*/,
|
|
305
|
+
return [2 /*return*/, __assign(__assign({}, customs), { beforeFiles: __spreadArray(__spreadArray([], defaults, true), (customs.beforeFiles || []), true) })];
|
|
316
306
|
case 3: return [2 /*return*/, {
|
|
317
307
|
afterFiles: [],
|
|
318
308
|
beforeFiles: defaults,
|
|
@@ -325,5 +315,4 @@ function withKoine(_a) {
|
|
|
325
315
|
}
|
|
326
316
|
return nextConfig;
|
|
327
317
|
}
|
|
328
|
-
|
|
329
|
-
exports.default = withKoine;
|
|
318
|
+
export default withKoine;
|
package/config/package.json
CHANGED
package/createEmotionCache.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEmotionCache = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var cache_1 = tslib_1.__importDefault(require("@emotion/cache"));
|
|
2
6
|
/**
|
|
3
7
|
* prepend: true moves MUI styles to the top of the <head> so they're loaded first.
|
|
4
8
|
* It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
|
|
5
9
|
*/
|
|
6
|
-
|
|
7
|
-
return
|
|
10
|
+
function createEmotionCache() {
|
|
11
|
+
return (0, cache_1.default)({ key: "css", prepend: true });
|
|
8
12
|
}
|
|
9
|
-
|
|
13
|
+
exports.createEmotionCache = createEmotionCache;
|
|
14
|
+
exports.default = createEmotionCache;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import createCache from "@emotion/cache";
|
|
2
|
+
/**
|
|
3
|
+
* prepend: true moves MUI styles to the top of the <head> so they're loaded first.
|
|
4
|
+
* It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
|
|
5
|
+
*/
|
|
6
|
+
export function createEmotionCache() {
|
|
7
|
+
return createCache({ key: "css", prepend: true });
|
|
8
|
+
}
|
|
9
|
+
export default createEmotionCache;
|
package/document/Document.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Document = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
var document_1 = tslib_1.__importStar(require("next/document"));
|
|
7
|
+
var Meta_1 = tslib_1.__importDefault(require("@koine/react/Meta"));
|
|
8
|
+
var NoJs_1 = tslib_1.__importDefault(require("@koine/react/NoJs"));
|
|
6
9
|
/**
|
|
7
10
|
* Next Document wrapper for bare projects
|
|
8
11
|
*
|
|
@@ -14,15 +17,15 @@ import NoJs from "@koine/react/NoJs";
|
|
|
14
17
|
* ```
|
|
15
18
|
*/
|
|
16
19
|
var Document = /** @class */ (function (_super) {
|
|
17
|
-
__extends(Document, _super);
|
|
20
|
+
tslib_1.__extends(Document, _super);
|
|
18
21
|
function Document() {
|
|
19
22
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
20
23
|
}
|
|
21
24
|
Document.prototype.render = function () {
|
|
22
25
|
var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
|
|
23
|
-
return (
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)(document_1.Html, tslib_1.__assign({ lang: locale || defaultLocale, className: "no-js" }, { children: [(0, jsx_runtime_1.jsxs)(document_1.Head, { children: [(0, jsx_runtime_1.jsx)(Meta_1.default, {}), (0, jsx_runtime_1.jsx)(NoJs_1.default, {})] }), (0, jsx_runtime_1.jsxs)("body", { children: [(0, jsx_runtime_1.jsx)(document_1.Main, {}), (0, jsx_runtime_1.jsx)(document_1.NextScript, {})] })] })));
|
|
24
27
|
};
|
|
25
28
|
return Document;
|
|
26
|
-
}(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
}(document_1.default));
|
|
30
|
+
exports.Document = Document;
|
|
31
|
+
exports.default = Document;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __assign, __extends } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import NextDocument, { Html, Head, Main, NextScript } from "next/document";
|
|
4
|
+
import Meta from "@koine/react/Meta";
|
|
5
|
+
import NoJs from "@koine/react/NoJs";
|
|
6
|
+
/**
|
|
7
|
+
* Next Document wrapper for bare projects
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* in your `myapp/pages/_document.tsx`:
|
|
12
|
+
* ```tsx
|
|
13
|
+
* export { Document as default } from "@koine/next/document";
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
var Document = /** @class */ (function (_super) {
|
|
17
|
+
__extends(Document, _super);
|
|
18
|
+
function Document() {
|
|
19
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
20
|
+
}
|
|
21
|
+
Document.prototype.render = function () {
|
|
22
|
+
var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
|
|
23
|
+
return (_jsxs(Html, __assign({ lang: locale || defaultLocale, className: "no-js" }, { children: [_jsxs(Head, { children: [_jsx(Meta, {}), _jsx(NoJs, {})] }), _jsxs("body", { children: [_jsx(Main, {}), _jsx(NextScript, {})] })] })));
|
|
24
|
+
};
|
|
25
|
+
return Document;
|
|
26
|
+
}(NextDocument));
|
|
27
|
+
export { Document };
|
|
28
|
+
export default Document;
|
package/document/css/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Document = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
var document_1 = tslib_1.__importStar(require("next/document"));
|
|
7
|
+
var Meta_1 = tslib_1.__importDefault(require("@koine/react/Meta"));
|
|
8
|
+
var NoJs_1 = tslib_1.__importDefault(require("@koine/react/NoJs"));
|
|
9
|
+
var sc_1 = require("@koine/react/sc"); // FIXME: this should be imported from another entrypoint
|
|
7
10
|
/**
|
|
8
11
|
* Next Document wrapper for `css/tailwind` based projects
|
|
9
12
|
*
|
|
@@ -17,29 +20,29 @@ import { getInitialThemeFromRequest } from "@koine/react/sc"; // FIXME: this sho
|
|
|
17
20
|
* ```
|
|
18
21
|
*/
|
|
19
22
|
var Document = /** @class */ (function (_super) {
|
|
20
|
-
__extends(Document, _super);
|
|
23
|
+
tslib_1.__extends(Document, _super);
|
|
21
24
|
function Document() {
|
|
22
25
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
26
|
}
|
|
24
27
|
Document.getInitialProps = function (ctx) {
|
|
25
28
|
var _a;
|
|
26
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
29
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
27
30
|
var initialProps;
|
|
28
|
-
return __generator(this, function (_b) {
|
|
31
|
+
return tslib_1.__generator(this, function (_b) {
|
|
29
32
|
switch (_b.label) {
|
|
30
|
-
case 0: return [4 /*yield*/,
|
|
33
|
+
case 0: return [4 /*yield*/, document_1.default.getInitialProps(ctx)];
|
|
31
34
|
case 1:
|
|
32
35
|
initialProps = _b.sent();
|
|
33
|
-
return [2 /*return*/, __assign(__assign({}, initialProps), { theme: getInitialThemeFromRequest(((_a = ctx.req) === null || _a === void 0 ? void 0 : _a.headers.cookie /* || document?.cookie */) || "") })];
|
|
36
|
+
return [2 /*return*/, tslib_1.__assign(tslib_1.__assign({}, initialProps), { theme: (0, sc_1.getInitialThemeFromRequest)(((_a = ctx.req) === null || _a === void 0 ? void 0 : _a.headers.cookie /* || document?.cookie */) || "") })];
|
|
34
37
|
}
|
|
35
38
|
});
|
|
36
39
|
});
|
|
37
40
|
};
|
|
38
41
|
Document.prototype.render = function () {
|
|
39
42
|
var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
|
|
40
|
-
return (
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)(document_1.Html, tslib_1.__assign({ lang: locale || defaultLocale, className: "no-js" }, { children: [(0, jsx_runtime_1.jsxs)(document_1.Head, { children: [(0, jsx_runtime_1.jsx)(Meta_1.default, {}), (0, jsx_runtime_1.jsx)(NoJs_1.default, {})] }), (0, jsx_runtime_1.jsxs)("body", { children: [(0, jsx_runtime_1.jsx)(document_1.Main, {}), (0, jsx_runtime_1.jsx)(document_1.NextScript, {})] })] })));
|
|
41
44
|
};
|
|
42
45
|
return Document;
|
|
43
|
-
}(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
}(document_1.default));
|
|
47
|
+
exports.Document = Document;
|
|
48
|
+
exports.default = Document;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { __assign, __awaiter, __extends, __generator } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import NextDocument, { Html, Head, Main, NextScript, } from "next/document";
|
|
4
|
+
import Meta from "@koine/react/Meta";
|
|
5
|
+
import NoJs from "@koine/react/NoJs";
|
|
6
|
+
import { getInitialThemeFromRequest } from "@koine/react/sc"; // FIXME: this should be imported from another entrypoint
|
|
7
|
+
/**
|
|
8
|
+
* Next Document wrapper for `css/tailwind` based projects
|
|
9
|
+
*
|
|
10
|
+
* Uses cookie to manage the current theme
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*
|
|
14
|
+
* in your `myapp/pages/_document.tsx`:
|
|
15
|
+
* ```tsx
|
|
16
|
+
* export { Document as default } from "@koine/next/document/css";
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
var Document = /** @class */ (function (_super) {
|
|
20
|
+
__extends(Document, _super);
|
|
21
|
+
function Document() {
|
|
22
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
+
}
|
|
24
|
+
Document.getInitialProps = function (ctx) {
|
|
25
|
+
var _a;
|
|
26
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
27
|
+
var initialProps;
|
|
28
|
+
return __generator(this, function (_b) {
|
|
29
|
+
switch (_b.label) {
|
|
30
|
+
case 0: return [4 /*yield*/, NextDocument.getInitialProps(ctx)];
|
|
31
|
+
case 1:
|
|
32
|
+
initialProps = _b.sent();
|
|
33
|
+
return [2 /*return*/, __assign(__assign({}, initialProps), { theme: getInitialThemeFromRequest(((_a = ctx.req) === null || _a === void 0 ? void 0 : _a.headers.cookie /* || document?.cookie */) || "") })];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
Document.prototype.render = function () {
|
|
39
|
+
var _a = this.props.__NEXT_DATA__, locale = _a.locale, defaultLocale = _a.defaultLocale;
|
|
40
|
+
return (_jsxs(Html, __assign({ lang: locale || defaultLocale, className: "no-js" }, { children: [_jsxs(Head, { children: [_jsx(Meta, {}), _jsx(NoJs, {})] }), _jsxs("body", { children: [_jsx(Main, {}), _jsx(NextScript, {})] })] })));
|
|
41
|
+
};
|
|
42
|
+
return Document;
|
|
43
|
+
}(NextDocument));
|
|
44
|
+
export { Document };
|
|
45
|
+
export default Document;
|