@koine/next 1.0.42 → 1.0.45
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/Theme/Theme.d.ts +6 -0
- package/Theme/Theme.js +6 -0
- package/config/index.d.ts +11 -4
- package/config/index.js +23 -7
- package/document/sc/index.js +1 -3
- package/node/Theme/Theme.js +6 -0
- package/node/config/index.js +23 -7
- package/node/document/sc/index.js +1 -3
- package/package.json +5 -5
package/Theme/Theme.d.ts
CHANGED
|
@@ -47,6 +47,12 @@ export declare type ThemeProviderProps = React.PropsWithChildren<{
|
|
|
47
47
|
/** Nonce string to pass to the inline script for CSP headers */
|
|
48
48
|
nonce?: string;
|
|
49
49
|
}>;
|
|
50
|
+
/**
|
|
51
|
+
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
52
|
+
*/
|
|
50
53
|
export declare const useTheme: () => UseThemeProps;
|
|
54
|
+
/**
|
|
55
|
+
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
56
|
+
*/
|
|
51
57
|
export declare const ThemeProvider: ({ forcedTheme, disableTransitionOnChange, enableSystem, enableColorScheme, themes, defaultTheme, attribute, value, children, nonce, }: ThemeProviderProps) => JSX.Element;
|
|
52
58
|
export {};
|
package/Theme/Theme.js
CHANGED
|
@@ -22,7 +22,13 @@ var ThemeContext = createContext({
|
|
|
22
22
|
setTheme: function (_) { },
|
|
23
23
|
themes: [],
|
|
24
24
|
});
|
|
25
|
+
/**
|
|
26
|
+
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
27
|
+
*/
|
|
25
28
|
export var useTheme = function () { return useContext(ThemeContext); };
|
|
29
|
+
/**
|
|
30
|
+
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
31
|
+
*/
|
|
26
32
|
export var ThemeProvider = function (_a) {
|
|
27
33
|
var forcedTheme = _a.forcedTheme, _b = _a.disableTransitionOnChange, disableTransitionOnChange = _b === void 0 ? false : _b, _c = _a.enableSystem, enableSystem = _c === void 0 ? true : _c, enableColorScheme = _a.enableColorScheme, _d = _a.themes, themes = _d === void 0 ? ["light", "dark"] : _d, _e = _a.defaultTheme, defaultTheme = _e === void 0 ? enableSystem ? "system" : "light" : _e, _f = _a.attribute, attribute = _f === void 0 ? "data-theme" : _f, value = _a.value, children = _a.children, nonce = _a.nonce;
|
|
28
34
|
var _g = useState(function () {
|
package/config/index.d.ts
CHANGED
|
@@ -76,10 +76,10 @@ declare type KoineNextConfig = {
|
|
|
76
76
|
* "home": "/",
|
|
77
77
|
* "products": {
|
|
78
78
|
* "list": "/products",
|
|
79
|
-
* "[category]": "/products/
|
|
79
|
+
* "[category]": "/products/{{ category }}",
|
|
80
80
|
* "[tag]": {
|
|
81
|
-
* "view": "/products/
|
|
82
|
-
* "related": "/products/
|
|
81
|
+
* "view": "/products/{{ category }}/{{ tag }}",
|
|
82
|
+
* "related": "/products/{{ category }}/{{ tag }}/related"
|
|
83
83
|
* }
|
|
84
84
|
* },
|
|
85
85
|
* "company": {
|
|
@@ -89,7 +89,14 @@ declare type KoineNextConfig = {
|
|
|
89
89
|
* }
|
|
90
90
|
* ```
|
|
91
91
|
*
|
|
92
|
-
*
|
|
92
|
+
* NOTE1:
|
|
93
|
+
* You cannot name your dynamic template file "index.tsx" when they have nested
|
|
94
|
+
* segments or the rewrites won't work. So while this is allowed:
|
|
95
|
+
* `/pages/cats/[category]/index.tsx` it is not when you also have e.g.:
|
|
96
|
+
* `/pages/cats/[category]/reviews.tsx`
|
|
97
|
+
* TODO: This might be fixable?
|
|
98
|
+
*
|
|
99
|
+
* NOTE2:
|
|
93
100
|
* When `routes` is used be sure to pass before than the `i18n.defaultLocale`
|
|
94
101
|
* configuration. That is used for localised routing. By default we set `i18n`
|
|
95
102
|
* as such:
|
package/config/index.js
CHANGED
|
@@ -52,18 +52,33 @@ export function encodePathname(pathname) {
|
|
|
52
52
|
.join("/");
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
* It replaces `/
|
|
56
|
-
* the end it adds an asterisk
|
|
55
|
+
* It replaces `/{{ slug }}/` with the given replacer.
|
|
57
56
|
*/
|
|
58
57
|
function transformRoutePathname(rawPathname, replacer) {
|
|
59
58
|
var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
60
59
|
return pathNameParts
|
|
61
|
-
.map(function (part,
|
|
60
|
+
.map(function (part, _idx) {
|
|
61
|
+
var isDynamic = part.startsWith("{{") && part.endsWith("}}");
|
|
62
|
+
part = isDynamic ? replacer : part;
|
|
63
|
+
// if (isDynamic && _idx === pathNameParts.length - 1) {
|
|
64
|
+
// part += "*";
|
|
65
|
+
// }
|
|
66
|
+
return isDynamic ? part : encodeURIComponent(part);
|
|
67
|
+
})
|
|
68
|
+
.join("/");
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* It replaces `/[slug]/` with the given replacer.
|
|
72
|
+
*/
|
|
73
|
+
function transformRouteTemplate(rawPathname, replacer) {
|
|
74
|
+
var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
75
|
+
return pathNameParts
|
|
76
|
+
.map(function (part, _idx) {
|
|
62
77
|
var isDynamic = part.startsWith("[") && part.endsWith("]");
|
|
63
78
|
part = isDynamic ? replacer : part;
|
|
64
|
-
if (isDynamic &&
|
|
65
|
-
|
|
66
|
-
}
|
|
79
|
+
// if (isDynamic && _idx === pathNameParts.length - 1) {
|
|
80
|
+
// part += "*";
|
|
81
|
+
// }
|
|
67
82
|
return isDynamic ? part : encodeURIComponent(part);
|
|
68
83
|
})
|
|
69
84
|
.join("/");
|
|
@@ -92,6 +107,7 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
|
|
|
92
107
|
*/
|
|
93
108
|
export function getPathRewrite(pathname, template) {
|
|
94
109
|
pathname = transformRoutePathname(pathname, ":path");
|
|
110
|
+
template = transformRouteTemplate(template, ":path");
|
|
95
111
|
var source = "/".concat(normaliseUrlPathname(pathname));
|
|
96
112
|
var destination = "/".concat(normaliseUrlPathname(template));
|
|
97
113
|
// console.log(`rewrite pathname "${source}" to template "${destination}"`);
|
|
@@ -105,7 +121,7 @@ export function getPathRewrite(pathname, template) {
|
|
|
105
121
|
*/
|
|
106
122
|
export function getPathRedirect(locale, pathname, template, permanent) {
|
|
107
123
|
if (locale === void 0) { locale = ""; }
|
|
108
|
-
template =
|
|
124
|
+
template = transformRouteTemplate(template, ":slug");
|
|
109
125
|
pathname = transformRoutePathname(pathname, ":slug");
|
|
110
126
|
var source = "/".concat(normaliseUrlPathname((locale ? "/".concat(locale, "/") : "/") + template));
|
|
111
127
|
var destination = "/".concat(normaliseUrlPathname(pathname));
|
package/document/sc/index.js
CHANGED
|
@@ -44,9 +44,7 @@ var Document = /** @class */ (function (_super) {
|
|
|
44
44
|
return [4 /*yield*/, NextDocument.getInitialProps(ctx)];
|
|
45
45
|
case 2:
|
|
46
46
|
initialProps = _a.sent();
|
|
47
|
-
return [2 /*return*/, __assign(__assign({}, initialProps), {
|
|
48
|
-
// @ts-expect-error FIXME: have they changed type?
|
|
49
|
-
styles: (_jsxs(React.Fragment, { children: [initialProps.styles, sheet.getStyleElement()] })) })];
|
|
47
|
+
return [2 /*return*/, __assign(__assign({}, initialProps), { styles: (_jsxs(React.Fragment, { children: [initialProps.styles, sheet.getStyleElement()] })) })];
|
|
50
48
|
case 3:
|
|
51
49
|
sheet.seal();
|
|
52
50
|
return [7 /*endfinally*/];
|
package/node/Theme/Theme.js
CHANGED
|
@@ -25,8 +25,14 @@ var ThemeContext = (0, react_1.createContext)({
|
|
|
25
25
|
setTheme: function (_) { },
|
|
26
26
|
themes: [],
|
|
27
27
|
});
|
|
28
|
+
/**
|
|
29
|
+
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
30
|
+
*/
|
|
28
31
|
var useTheme = function () { return (0, react_1.useContext)(ThemeContext); };
|
|
29
32
|
exports.useTheme = useTheme;
|
|
33
|
+
/**
|
|
34
|
+
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
35
|
+
*/
|
|
30
36
|
var ThemeProvider = function (_a) {
|
|
31
37
|
var forcedTheme = _a.forcedTheme, _b = _a.disableTransitionOnChange, disableTransitionOnChange = _b === void 0 ? false : _b, _c = _a.enableSystem, enableSystem = _c === void 0 ? true : _c, enableColorScheme = _a.enableColorScheme, _d = _a.themes, themes = _d === void 0 ? ["light", "dark"] : _d, _e = _a.defaultTheme, defaultTheme = _e === void 0 ? enableSystem ? "system" : "light" : _e, _f = _a.attribute, attribute = _f === void 0 ? "data-theme" : _f, value = _a.value, children = _a.children, nonce = _a.nonce;
|
|
32
38
|
var _g = (0, react_1.useState)(function () {
|
package/node/config/index.js
CHANGED
|
@@ -58,18 +58,33 @@ function encodePathname(pathname) {
|
|
|
58
58
|
}
|
|
59
59
|
exports.encodePathname = encodePathname;
|
|
60
60
|
/**
|
|
61
|
-
* It replaces `/
|
|
62
|
-
* the end it adds an asterisk
|
|
61
|
+
* It replaces `/{{ slug }}/` with the given replacer.
|
|
63
62
|
*/
|
|
64
63
|
function transformRoutePathname(rawPathname, replacer) {
|
|
65
64
|
var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
66
65
|
return pathNameParts
|
|
67
|
-
.map(function (part,
|
|
66
|
+
.map(function (part, _idx) {
|
|
67
|
+
var isDynamic = part.startsWith("{{") && part.endsWith("}}");
|
|
68
|
+
part = isDynamic ? replacer : part;
|
|
69
|
+
// if (isDynamic && _idx === pathNameParts.length - 1) {
|
|
70
|
+
// part += "*";
|
|
71
|
+
// }
|
|
72
|
+
return isDynamic ? part : encodeURIComponent(part);
|
|
73
|
+
})
|
|
74
|
+
.join("/");
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* It replaces `/[slug]/` with the given replacer.
|
|
78
|
+
*/
|
|
79
|
+
function transformRouteTemplate(rawPathname, replacer) {
|
|
80
|
+
var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
81
|
+
return pathNameParts
|
|
82
|
+
.map(function (part, _idx) {
|
|
68
83
|
var isDynamic = part.startsWith("[") && part.endsWith("]");
|
|
69
84
|
part = isDynamic ? replacer : part;
|
|
70
|
-
if (isDynamic &&
|
|
71
|
-
|
|
72
|
-
}
|
|
85
|
+
// if (isDynamic && _idx === pathNameParts.length - 1) {
|
|
86
|
+
// part += "*";
|
|
87
|
+
// }
|
|
73
88
|
return isDynamic ? part : encodeURIComponent(part);
|
|
74
89
|
})
|
|
75
90
|
.join("/");
|
|
@@ -98,6 +113,7 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
|
|
|
98
113
|
*/
|
|
99
114
|
function getPathRewrite(pathname, template) {
|
|
100
115
|
pathname = transformRoutePathname(pathname, ":path");
|
|
116
|
+
template = transformRouteTemplate(template, ":path");
|
|
101
117
|
var source = "/".concat(normaliseUrlPathname(pathname));
|
|
102
118
|
var destination = "/".concat(normaliseUrlPathname(template));
|
|
103
119
|
// console.log(`rewrite pathname "${source}" to template "${destination}"`);
|
|
@@ -112,7 +128,7 @@ exports.getPathRewrite = getPathRewrite;
|
|
|
112
128
|
*/
|
|
113
129
|
function getPathRedirect(locale, pathname, template, permanent) {
|
|
114
130
|
if (locale === void 0) { locale = ""; }
|
|
115
|
-
template =
|
|
131
|
+
template = transformRouteTemplate(template, ":slug");
|
|
116
132
|
pathname = transformRoutePathname(pathname, ":slug");
|
|
117
133
|
var source = "/".concat(normaliseUrlPathname((locale ? "/".concat(locale, "/") : "/") + template));
|
|
118
134
|
var destination = "/".concat(normaliseUrlPathname(pathname));
|
|
@@ -47,9 +47,7 @@ var Document = /** @class */ (function (_super) {
|
|
|
47
47
|
return [4 /*yield*/, document_1.default.getInitialProps(ctx)];
|
|
48
48
|
case 2:
|
|
49
49
|
initialProps = _a.sent();
|
|
50
|
-
return [2 /*return*/, tslib_1.__assign(tslib_1.__assign({}, initialProps), {
|
|
51
|
-
// @ts-expect-error FIXME: have they changed type?
|
|
52
|
-
styles: ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [initialProps.styles, sheet.getStyleElement()] })) })];
|
|
50
|
+
return [2 /*return*/, tslib_1.__assign(tslib_1.__assign({}, initialProps), { styles: ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [initialProps.styles, sheet.getStyleElement()] })) })];
|
|
53
51
|
case 3:
|
|
54
52
|
sheet.seal();
|
|
55
53
|
return [7 /*endfinally*/];
|
package/package.json
CHANGED
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"dependencies": {},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": "^16.8 || ^17 || ^18",
|
|
20
|
-
"next": "^12.
|
|
21
|
-
"@koine/utils": "1.0.
|
|
20
|
+
"next": "^12.2.0",
|
|
21
|
+
"@koine/utils": "1.0.45",
|
|
22
22
|
"framer-motion": "^6.3.16",
|
|
23
|
-
"@koine/react": "1.0.
|
|
23
|
+
"@koine/react": "1.0.45",
|
|
24
24
|
"styled-components": "^5.3.5",
|
|
25
25
|
"@mui/base": "^5.0.0-alpha.87",
|
|
26
26
|
"react-icons": "^4.4.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"type-fest": "^2.14.0",
|
|
34
34
|
"react-popper": "^2.3.0",
|
|
35
35
|
"tslib": "^2.4.0",
|
|
36
|
-
"next-auth": "^4.
|
|
36
|
+
"next-auth": "^4.7.0",
|
|
37
37
|
"@mui/material": "^5.8.6",
|
|
38
38
|
"@emotion/react": "^11.9.3",
|
|
39
39
|
"@emotion/server": "^11.4.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"next-translate": "^1.4.0",
|
|
42
42
|
"next-seo": "^5.4.0"
|
|
43
43
|
},
|
|
44
|
-
"version": "1.0.
|
|
44
|
+
"version": "1.0.45",
|
|
45
45
|
"module": "./index.js",
|
|
46
46
|
"types": "./index.d.ts"
|
|
47
47
|
}
|