@koine/next 1.1.10 → 1.1.12
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.d.ts +1 -1
- 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 +36 -30
- 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/ThemeProvider.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThemeProvider = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
var react_1 = require("react");
|
|
7
|
+
var script_1 = tslib_1.__importDefault(require("next/script"));
|
|
8
|
+
var isServer_1 = tslib_1.__importDefault(require("@koine/utils/isServer"));
|
|
9
|
+
var ThemeContext_1 = require("./ThemeContext");
|
|
7
10
|
var colorSchemes = ["light", "dark"];
|
|
8
11
|
var MEDIA = "(prefers-color-scheme: dark)";
|
|
9
12
|
var THEME_STORAGE_KEY = "theme";
|
|
@@ -16,19 +19,19 @@ var THEME_STORAGE_KEY = "theme";
|
|
|
16
19
|
* nicely with tailwind `dark` class mode as dark theme is supposed to be only
|
|
17
20
|
* controlled by tailwind modifiers
|
|
18
21
|
*/
|
|
19
|
-
|
|
22
|
+
var ThemeProvider = function (_a) {
|
|
20
23
|
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;
|
|
21
|
-
var _g = useState(function () {
|
|
24
|
+
var _g = (0, react_1.useState)(function () {
|
|
22
25
|
return getTheme(THEME_STORAGE_KEY, defaultTheme);
|
|
23
26
|
}), theme = _g[0], setThemeState = _g[1];
|
|
24
|
-
var _h = useState(function () {
|
|
27
|
+
var _h = (0, react_1.useState)(function () {
|
|
25
28
|
return getTheme(THEME_STORAGE_KEY);
|
|
26
29
|
}), resolvedTheme = _h[0], setResolvedTheme = _h[1];
|
|
27
30
|
var attrs = !value ? themes : Object.values(value);
|
|
28
|
-
var applyTheme = useCallback(function (theme) {
|
|
31
|
+
var applyTheme = (0, react_1.useCallback)(function (theme) {
|
|
29
32
|
var _a;
|
|
30
33
|
var resolved = theme;
|
|
31
|
-
if (
|
|
34
|
+
if (isServer_1.default || !resolved)
|
|
32
35
|
return;
|
|
33
36
|
// If theme is system, resolve it before setting theme
|
|
34
37
|
if (theme === "system" && enableSystem) {
|
|
@@ -69,7 +72,7 @@ export var ThemeProvider = function (_a) {
|
|
|
69
72
|
enableSystem,
|
|
70
73
|
value,
|
|
71
74
|
]);
|
|
72
|
-
var setTheme = useCallback(function (theme) {
|
|
75
|
+
var setTheme = (0, react_1.useCallback)(function (theme) {
|
|
73
76
|
setThemeState(theme);
|
|
74
77
|
// Save to storage
|
|
75
78
|
try {
|
|
@@ -79,7 +82,7 @@ export var ThemeProvider = function (_a) {
|
|
|
79
82
|
// Unsupported
|
|
80
83
|
}
|
|
81
84
|
}, []);
|
|
82
|
-
var handleMediaQuery = useCallback(function (e) {
|
|
85
|
+
var handleMediaQuery = (0, react_1.useCallback)(function (e) {
|
|
83
86
|
var resolved = getSystemTheme(e);
|
|
84
87
|
setResolvedTheme(resolved);
|
|
85
88
|
if (theme === "system" && enableSystem && !forcedTheme) {
|
|
@@ -87,7 +90,7 @@ export var ThemeProvider = function (_a) {
|
|
|
87
90
|
}
|
|
88
91
|
}, [theme, enableSystem, forcedTheme, applyTheme]);
|
|
89
92
|
// Always listen to System preference
|
|
90
|
-
useEffect(function () {
|
|
93
|
+
(0, react_1.useEffect)(function () {
|
|
91
94
|
var media = window.matchMedia(MEDIA);
|
|
92
95
|
// Intentionally use deprecated listener methods to support iOS & old browsers
|
|
93
96
|
media.addListener(handleMediaQuery);
|
|
@@ -95,7 +98,7 @@ export var ThemeProvider = function (_a) {
|
|
|
95
98
|
return function () { return media.removeListener(handleMediaQuery); };
|
|
96
99
|
}, [handleMediaQuery]);
|
|
97
100
|
// localStorage event handling
|
|
98
|
-
useEffect(function () {
|
|
101
|
+
(0, react_1.useEffect)(function () {
|
|
99
102
|
var handleStorage = function (e) {
|
|
100
103
|
if (e.key !== THEME_STORAGE_KEY) {
|
|
101
104
|
return;
|
|
@@ -108,17 +111,17 @@ export var ThemeProvider = function (_a) {
|
|
|
108
111
|
return function () { return window.removeEventListener("storage", handleStorage); };
|
|
109
112
|
}, [defaultTheme, setTheme]);
|
|
110
113
|
// Whenever theme or forcedTheme changes, apply it
|
|
111
|
-
useEffect(function () {
|
|
114
|
+
(0, react_1.useEffect)(function () {
|
|
112
115
|
applyTheme(forcedTheme !== null && forcedTheme !== void 0 ? forcedTheme : theme);
|
|
113
116
|
}, [applyTheme, forcedTheme, theme]);
|
|
114
|
-
return (
|
|
117
|
+
return ((0, jsx_runtime_1.jsxs)(ThemeContext_1.ThemeContext.Provider, tslib_1.__assign({ value: {
|
|
115
118
|
theme: theme,
|
|
116
119
|
setTheme: setTheme,
|
|
117
120
|
forcedTheme: forcedTheme,
|
|
118
121
|
resolvedTheme: theme === "system" ? resolvedTheme : theme,
|
|
119
|
-
themes: enableSystem ? __spreadArray(__spreadArray([], themes, true), ["system"], false) : themes,
|
|
122
|
+
themes: enableSystem ? tslib_1.__spreadArray(tslib_1.__spreadArray([], themes, true), ["system"], false) : themes,
|
|
120
123
|
systemTheme: (enableSystem ? resolvedTheme : undefined),
|
|
121
|
-
} }, { children: [
|
|
124
|
+
} }, { children: [(0, jsx_runtime_1.jsx)(ThemeScript, tslib_1.__assign({}, {
|
|
122
125
|
forcedTheme: forcedTheme,
|
|
123
126
|
disableTransitionOnChange: disableTransitionOnChange,
|
|
124
127
|
enableSystem: enableSystem,
|
|
@@ -132,7 +135,8 @@ export var ThemeProvider = function (_a) {
|
|
|
132
135
|
nonce: nonce,
|
|
133
136
|
})), children] })));
|
|
134
137
|
};
|
|
135
|
-
|
|
138
|
+
exports.ThemeProvider = ThemeProvider;
|
|
139
|
+
var ThemeScript = (0, react_1.memo)(function (_a) {
|
|
136
140
|
var forcedTheme = _a.forcedTheme, attribute = _a.attribute, enableSystem = _a.enableSystem, enableColorScheme = _a.enableColorScheme, defaultTheme = _a.defaultTheme, value = _a.value, attrs = _a.attrs, nonce = _a.nonce;
|
|
137
141
|
var defaultSystem = defaultTheme === "system";
|
|
138
142
|
// Code-golfing the amount of characters in the script
|
|
@@ -202,13 +206,13 @@ var ThemeScript = memo(function (_a) {
|
|
|
202
206
|
// But our script cannot be external because it changes at runtime based on React props
|
|
203
207
|
// so we trick next/script by passing `src` as a base64 JS script
|
|
204
208
|
var encodedScript = "data:text/javascript;base64,".concat(encodeBase64(scriptSrc));
|
|
205
|
-
return (
|
|
209
|
+
return ((0, jsx_runtime_1.jsx)(script_1.default, { id: "next-theme-script", strategy: "beforeInteractive", src: encodedScript, nonce: nonce }));
|
|
206
210
|
},
|
|
207
211
|
// Never re-render this component
|
|
208
212
|
function () { return true; });
|
|
209
213
|
// Helpers
|
|
210
214
|
var getTheme = function (key, fallback) {
|
|
211
|
-
if (
|
|
215
|
+
if (isServer_1.default)
|
|
212
216
|
return undefined;
|
|
213
217
|
var theme;
|
|
214
218
|
try {
|
|
@@ -241,6 +245,6 @@ var getSystemTheme = function (e) {
|
|
|
241
245
|
return systemTheme;
|
|
242
246
|
};
|
|
243
247
|
var encodeBase64 = function (str) {
|
|
244
|
-
return
|
|
248
|
+
return isServer_1.default ? Buffer.from(str).toString("base64") : btoa(str);
|
|
245
249
|
};
|
|
246
|
-
|
|
250
|
+
exports.default = exports.ThemeProvider;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var script_1 = tslib_1.__importDefault(require("next/script"));
|
|
8
|
-
var isServer_1 = tslib_1.__importDefault(require("@koine/utils/isServer"));
|
|
9
|
-
var ThemeContext_1 = require("./ThemeContext");
|
|
1
|
+
import { __assign, __spreadArray } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useState, memo } from "react";
|
|
4
|
+
import NextScript from "next/script";
|
|
5
|
+
import isServer from "@koine/utils/isServer";
|
|
6
|
+
import { ThemeContext } from "./ThemeContext";
|
|
10
7
|
var colorSchemes = ["light", "dark"];
|
|
11
8
|
var MEDIA = "(prefers-color-scheme: dark)";
|
|
12
9
|
var THEME_STORAGE_KEY = "theme";
|
|
@@ -19,19 +16,19 @@ var THEME_STORAGE_KEY = "theme";
|
|
|
19
16
|
* nicely with tailwind `dark` class mode as dark theme is supposed to be only
|
|
20
17
|
* controlled by tailwind modifiers
|
|
21
18
|
*/
|
|
22
|
-
var ThemeProvider = function (_a) {
|
|
19
|
+
export var ThemeProvider = function (_a) {
|
|
23
20
|
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;
|
|
24
|
-
var _g =
|
|
21
|
+
var _g = useState(function () {
|
|
25
22
|
return getTheme(THEME_STORAGE_KEY, defaultTheme);
|
|
26
23
|
}), theme = _g[0], setThemeState = _g[1];
|
|
27
|
-
var _h =
|
|
24
|
+
var _h = useState(function () {
|
|
28
25
|
return getTheme(THEME_STORAGE_KEY);
|
|
29
26
|
}), resolvedTheme = _h[0], setResolvedTheme = _h[1];
|
|
30
27
|
var attrs = !value ? themes : Object.values(value);
|
|
31
|
-
var applyTheme =
|
|
28
|
+
var applyTheme = useCallback(function (theme) {
|
|
32
29
|
var _a;
|
|
33
30
|
var resolved = theme;
|
|
34
|
-
if (
|
|
31
|
+
if (isServer || !resolved)
|
|
35
32
|
return;
|
|
36
33
|
// If theme is system, resolve it before setting theme
|
|
37
34
|
if (theme === "system" && enableSystem) {
|
|
@@ -72,7 +69,7 @@ var ThemeProvider = function (_a) {
|
|
|
72
69
|
enableSystem,
|
|
73
70
|
value,
|
|
74
71
|
]);
|
|
75
|
-
var setTheme =
|
|
72
|
+
var setTheme = useCallback(function (theme) {
|
|
76
73
|
setThemeState(theme);
|
|
77
74
|
// Save to storage
|
|
78
75
|
try {
|
|
@@ -82,7 +79,7 @@ var ThemeProvider = function (_a) {
|
|
|
82
79
|
// Unsupported
|
|
83
80
|
}
|
|
84
81
|
}, []);
|
|
85
|
-
var handleMediaQuery =
|
|
82
|
+
var handleMediaQuery = useCallback(function (e) {
|
|
86
83
|
var resolved = getSystemTheme(e);
|
|
87
84
|
setResolvedTheme(resolved);
|
|
88
85
|
if (theme === "system" && enableSystem && !forcedTheme) {
|
|
@@ -90,7 +87,7 @@ var ThemeProvider = function (_a) {
|
|
|
90
87
|
}
|
|
91
88
|
}, [theme, enableSystem, forcedTheme, applyTheme]);
|
|
92
89
|
// Always listen to System preference
|
|
93
|
-
|
|
90
|
+
useEffect(function () {
|
|
94
91
|
var media = window.matchMedia(MEDIA);
|
|
95
92
|
// Intentionally use deprecated listener methods to support iOS & old browsers
|
|
96
93
|
media.addListener(handleMediaQuery);
|
|
@@ -98,7 +95,7 @@ var ThemeProvider = function (_a) {
|
|
|
98
95
|
return function () { return media.removeListener(handleMediaQuery); };
|
|
99
96
|
}, [handleMediaQuery]);
|
|
100
97
|
// localStorage event handling
|
|
101
|
-
|
|
98
|
+
useEffect(function () {
|
|
102
99
|
var handleStorage = function (e) {
|
|
103
100
|
if (e.key !== THEME_STORAGE_KEY) {
|
|
104
101
|
return;
|
|
@@ -111,17 +108,17 @@ var ThemeProvider = function (_a) {
|
|
|
111
108
|
return function () { return window.removeEventListener("storage", handleStorage); };
|
|
112
109
|
}, [defaultTheme, setTheme]);
|
|
113
110
|
// Whenever theme or forcedTheme changes, apply it
|
|
114
|
-
|
|
111
|
+
useEffect(function () {
|
|
115
112
|
applyTheme(forcedTheme !== null && forcedTheme !== void 0 ? forcedTheme : theme);
|
|
116
113
|
}, [applyTheme, forcedTheme, theme]);
|
|
117
|
-
return ((
|
|
114
|
+
return (_jsxs(ThemeContext.Provider, __assign({ value: {
|
|
118
115
|
theme: theme,
|
|
119
116
|
setTheme: setTheme,
|
|
120
117
|
forcedTheme: forcedTheme,
|
|
121
118
|
resolvedTheme: theme === "system" ? resolvedTheme : theme,
|
|
122
|
-
themes: enableSystem ?
|
|
119
|
+
themes: enableSystem ? __spreadArray(__spreadArray([], themes, true), ["system"], false) : themes,
|
|
123
120
|
systemTheme: (enableSystem ? resolvedTheme : undefined),
|
|
124
|
-
} }, { children: [(
|
|
121
|
+
} }, { children: [_jsx(ThemeScript, __assign({}, {
|
|
125
122
|
forcedTheme: forcedTheme,
|
|
126
123
|
disableTransitionOnChange: disableTransitionOnChange,
|
|
127
124
|
enableSystem: enableSystem,
|
|
@@ -135,8 +132,7 @@ var ThemeProvider = function (_a) {
|
|
|
135
132
|
nonce: nonce,
|
|
136
133
|
})), children] })));
|
|
137
134
|
};
|
|
138
|
-
|
|
139
|
-
var ThemeScript = (0, react_1.memo)(function (_a) {
|
|
135
|
+
var ThemeScript = memo(function (_a) {
|
|
140
136
|
var forcedTheme = _a.forcedTheme, attribute = _a.attribute, enableSystem = _a.enableSystem, enableColorScheme = _a.enableColorScheme, defaultTheme = _a.defaultTheme, value = _a.value, attrs = _a.attrs, nonce = _a.nonce;
|
|
141
137
|
var defaultSystem = defaultTheme === "system";
|
|
142
138
|
// Code-golfing the amount of characters in the script
|
|
@@ -206,13 +202,13 @@ var ThemeScript = (0, react_1.memo)(function (_a) {
|
|
|
206
202
|
// But our script cannot be external because it changes at runtime based on React props
|
|
207
203
|
// so we trick next/script by passing `src` as a base64 JS script
|
|
208
204
|
var encodedScript = "data:text/javascript;base64,".concat(encodeBase64(scriptSrc));
|
|
209
|
-
return ((
|
|
205
|
+
return (_jsx(NextScript, { id: "next-theme-script", strategy: "beforeInteractive", src: encodedScript, nonce: nonce }));
|
|
210
206
|
},
|
|
211
207
|
// Never re-render this component
|
|
212
208
|
function () { return true; });
|
|
213
209
|
// Helpers
|
|
214
210
|
var getTheme = function (key, fallback) {
|
|
215
|
-
if (
|
|
211
|
+
if (isServer)
|
|
216
212
|
return undefined;
|
|
217
213
|
var theme;
|
|
218
214
|
try {
|
|
@@ -245,6 +241,6 @@ var getSystemTheme = function (e) {
|
|
|
245
241
|
return systemTheme;
|
|
246
242
|
};
|
|
247
243
|
var encodeBase64 = function (str) {
|
|
248
|
-
return
|
|
244
|
+
return isServer ? Buffer.from(str).toString("base64") : btoa(str);
|
|
249
245
|
};
|
|
250
|
-
|
|
246
|
+
export default ThemeProvider;
|
package/TransText.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransText = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var TransText_1 = tslib_1.__importDefault(require("next-translate/TransText"));
|
|
6
|
+
exports.TransText = TransText_1.default;
|
|
7
|
+
exports.default = exports.TransText;
|
package/TransText.mjs
ADDED
package/app/AppHead.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppHead = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
var head_1 = tslib_1.__importDefault(require("next/head"));
|
|
7
|
+
var AppHead = function () {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(head_1.default, { children: (0, jsx_runtime_1.jsx)("meta", { name: "viewport", content: "width=device-width" }) }));
|
|
5
9
|
};
|
|
6
|
-
|
|
10
|
+
exports.AppHead = AppHead;
|
|
11
|
+
exports.default = exports.AppHead;
|
package/app/AppHead.mjs
ADDED
package/app/AppMain.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/app/AppMain.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/app/css/AppMain.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppMain = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
var react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
+
var SeoDefaults_1 = require("../../SeoDefaults");
|
|
5
8
|
/**
|
|
6
9
|
* App main
|
|
7
10
|
*
|
|
8
11
|
* It does not imply any specific styling or animation solution
|
|
9
12
|
*/
|
|
10
|
-
|
|
13
|
+
var AppMain = function (_a) {
|
|
11
14
|
var Component = _a.Component, pageProps = _a.pageProps, Layout = _a.Layout, seo = _a.seo, pre = _a.pre, post = _a.post;
|
|
12
|
-
return (
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(SeoDefaults_1.SeoDefaults, tslib_1.__assign({}, seo)), pre, (0, jsx_runtime_1.jsx)(Layout, { children: (0, jsx_runtime_1.jsx)(Component, tslib_1.__assign({}, pageProps)) }), post] }));
|
|
13
16
|
};
|
|
14
|
-
|
|
17
|
+
exports.AppMain = AppMain;
|
|
18
|
+
exports.default = exports.AppMain;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { SeoDefaults } from "../../SeoDefaults";
|
|
5
|
+
/**
|
|
6
|
+
* App main
|
|
7
|
+
*
|
|
8
|
+
* It does not imply any specific styling or animation solution
|
|
9
|
+
*/
|
|
10
|
+
export var AppMain = function (_a) {
|
|
11
|
+
var Component = _a.Component, pageProps = _a.pageProps, Layout = _a.Layout, seo = _a.seo, pre = _a.pre, post = _a.post;
|
|
12
|
+
return (_jsxs(React.Fragment, { children: [_jsx(SeoDefaults, __assign({}, seo)), pre, _jsx(Layout, { children: _jsx(Component, __assign({}, pageProps)) }), post] }));
|
|
13
|
+
};
|
|
14
|
+
export default AppMain;
|
package/app/css/AppTheme.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppTheme = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
3
6
|
// import { ThemeVanillaProvider, ThemeVanillaValue } from "@koine/react/styles";
|
|
4
|
-
|
|
7
|
+
var ThemeProvider_1 = require("../../ThemeProvider");
|
|
5
8
|
/**
|
|
6
9
|
* App theme with vanilla class based theme (good for `tailwindcss`)
|
|
7
10
|
*/
|
|
8
|
-
|
|
11
|
+
var AppTheme = function (_a) {
|
|
9
12
|
var theme = _a.theme, children = _a.children;
|
|
10
13
|
// return (
|
|
11
14
|
// <ThemeVanillaProvider initialTheme={theme}>{children}</ThemeVanillaProvider>
|
|
12
15
|
// );
|
|
13
|
-
return (
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(ThemeProvider_1.ThemeProvider, tslib_1.__assign({ defaultTheme: theme, attribute: "class" }, { children: children })));
|
|
14
17
|
};
|
|
15
|
-
|
|
18
|
+
exports.AppTheme = AppTheme;
|
|
19
|
+
exports.default = exports.AppTheme;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
// import { ThemeVanillaProvider, ThemeVanillaValue } from "@koine/react/styles";
|
|
4
|
+
import { ThemeProvider } from "../../ThemeProvider";
|
|
5
|
+
/**
|
|
6
|
+
* App theme with vanilla class based theme (good for `tailwindcss`)
|
|
7
|
+
*/
|
|
8
|
+
export var AppTheme = function (_a) {
|
|
9
|
+
var theme = _a.theme, children = _a.children;
|
|
10
|
+
// return (
|
|
11
|
+
// <ThemeVanillaProvider initialTheme={theme}>{children}</ThemeVanillaProvider>
|
|
12
|
+
// );
|
|
13
|
+
return (_jsx(ThemeProvider, __assign({ defaultTheme: theme, attribute: "class" }, { children: children })));
|
|
14
|
+
};
|
|
15
|
+
export default AppTheme;
|
package/app/css/auth/index.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NextApp = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
var react_1 = require("next-auth/react");
|
|
7
|
+
var AppHead_1 = require("../../AppHead");
|
|
8
|
+
var AppTheme_1 = require("../AppTheme");
|
|
9
|
+
var AppMain_1 = require("../AppMain");
|
|
7
10
|
/**
|
|
8
11
|
* App with authentication provided by `next-auth`
|
|
9
12
|
*/
|
|
10
|
-
|
|
11
|
-
return (
|
|
13
|
+
var NextApp = function (props) {
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(AppHead_1.AppHead, {}), (0, jsx_runtime_1.jsx)(react_1.SessionProvider, tslib_1.__assign({ session: props.pageProps.session }, { children: (0, jsx_runtime_1.jsx)(AppTheme_1.AppTheme, tslib_1.__assign({}, props, { children: (0, jsx_runtime_1.jsx)(AppMain_1.AppMain, tslib_1.__assign({}, props)) })) }))] }));
|
|
12
15
|
};
|
|
13
|
-
|
|
16
|
+
exports.NextApp = NextApp;
|
|
17
|
+
exports.default = exports.NextApp;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { SessionProvider } from "next-auth/react";
|
|
4
|
+
import { AppHead } from "../../AppHead";
|
|
5
|
+
import { AppTheme } from "../AppTheme";
|
|
6
|
+
import { AppMain } from "../AppMain";
|
|
7
|
+
/**
|
|
8
|
+
* App with authentication provided by `next-auth`
|
|
9
|
+
*/
|
|
10
|
+
export var NextApp = function (props) {
|
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsx(AppHead, {}), _jsx(SessionProvider, __assign({ session: props.pageProps.session }, { children: _jsx(AppTheme, __assign({}, props, { children: _jsx(AppMain, __assign({}, props)) })) }))] }));
|
|
12
|
+
};
|
|
13
|
+
export default NextApp;
|
package/app/css/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NextApp = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
var AppHead_1 = require("../AppHead");
|
|
7
|
+
var AppTheme_1 = require("./AppTheme");
|
|
8
|
+
var AppMain_1 = require("./AppMain");
|
|
6
9
|
/**
|
|
7
10
|
* App
|
|
8
11
|
*
|
|
@@ -51,7 +54,8 @@ import { AppMain } from "./AppMain";
|
|
|
51
54
|
*
|
|
52
55
|
* ```
|
|
53
56
|
*/
|
|
54
|
-
|
|
55
|
-
return (
|
|
57
|
+
var NextApp = function (props) {
|
|
58
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(AppHead_1.AppHead, {}), (0, jsx_runtime_1.jsx)(AppTheme_1.AppTheme, tslib_1.__assign({}, props, { children: (0, jsx_runtime_1.jsx)(AppMain_1.AppMain, tslib_1.__assign({}, props)) }))] }));
|
|
56
59
|
};
|
|
57
|
-
|
|
60
|
+
exports.NextApp = NextApp;
|
|
61
|
+
exports.default = exports.NextApp;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var AppHead_1 = require("../AppHead");
|
|
7
|
-
var AppTheme_1 = require("./AppTheme");
|
|
8
|
-
var AppMain_1 = require("./AppMain");
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { AppHead } from "../AppHead";
|
|
4
|
+
import { AppTheme } from "./AppTheme";
|
|
5
|
+
import { AppMain } from "./AppMain";
|
|
9
6
|
/**
|
|
10
7
|
* App
|
|
11
8
|
*
|
|
@@ -54,8 +51,7 @@ var AppMain_1 = require("./AppMain");
|
|
|
54
51
|
*
|
|
55
52
|
* ```
|
|
56
53
|
*/
|
|
57
|
-
var NextApp = function (props) {
|
|
58
|
-
return ((
|
|
54
|
+
export var NextApp = function (props) {
|
|
55
|
+
return (_jsxs(_Fragment, { children: [_jsx(AppHead, {}), _jsx(AppTheme, __assign({}, props, { children: _jsx(AppMain, __assign({}, props)) }))] }));
|
|
59
56
|
};
|
|
60
|
-
|
|
61
|
-
exports.default = exports.NextApp;
|
|
57
|
+
export default NextApp;
|
package/app/css/package.json
CHANGED
package/app/em/AppMain.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppMain = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = require("react");
|
|
6
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
var router_1 = require("next/router");
|
|
8
|
+
var framer_motion_1 = require("framer-motion");
|
|
9
|
+
var MotionProvider_1 = tslib_1.__importDefault(require("@koine/react/m/MotionProvider"));
|
|
10
|
+
var SeoDefaults_1 = require("../../SeoDefaults");
|
|
11
|
+
var NextProgress_1 = require("../../NextProgress");
|
|
9
12
|
/**
|
|
10
13
|
* App main
|
|
11
14
|
*
|
|
@@ -13,13 +16,14 @@ import { NextProgress } from "../../NextProgress";
|
|
|
13
16
|
*
|
|
14
17
|
* About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
|
|
15
18
|
*/
|
|
16
|
-
|
|
19
|
+
var AppMain = function (_a) {
|
|
17
20
|
var Component = _a.Component, pageProps = _a.pageProps, Layout = _a.Layout, ProgressOverlay = _a.ProgressOverlay, seo = _a.seo, motion = _a.motion, _b = _a.transition, transition = _b === void 0 ? {
|
|
18
21
|
initial: { opacity: 0 },
|
|
19
22
|
animate: { opacity: 1 },
|
|
20
23
|
exit: { opacity: 0 },
|
|
21
24
|
} : _b, pre = _a.pre, post = _a.post;
|
|
22
|
-
var pathname = useRouter().pathname;
|
|
23
|
-
return (
|
|
25
|
+
var pathname = (0, router_1.useRouter)().pathname;
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SeoDefaults_1.SeoDefaults, tslib_1.__assign({}, seo)), pre, (0, jsx_runtime_1.jsxs)(MotionProvider_1.default, tslib_1.__assign({ features: motion }, { children: [ProgressOverlay && (0, jsx_runtime_1.jsx)(NextProgress_1.NextProgress, { Overlay: ProgressOverlay }), (0, jsx_runtime_1.jsx)(Layout, { children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, tslib_1.__assign({ exitBeforeEnter: true, initial: false }, { children: (0, jsx_runtime_1.jsx)(framer_motion_1.m.div, tslib_1.__assign({}, transition, { children: (0, react_1.createElement)(Component, tslib_1.__assign({}, pageProps, { key: pathname })) }), pathname) })) })] })), post] }));
|
|
24
27
|
};
|
|
25
|
-
|
|
28
|
+
exports.AppMain = AppMain;
|
|
29
|
+
exports.default = exports.AppMain;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
|
+
import { useRouter } from "next/router";
|
|
5
|
+
import { AnimatePresence, m } from "framer-motion";
|
|
6
|
+
import MotionProvider from "@koine/react/m/MotionProvider";
|
|
7
|
+
import { SeoDefaults } from "../../SeoDefaults";
|
|
8
|
+
import { NextProgress } from "../../NextProgress";
|
|
9
|
+
/**
|
|
10
|
+
* App main
|
|
11
|
+
*
|
|
12
|
+
* It implies a setup for `styled-components` and `framer-motion` libraries.
|
|
13
|
+
*
|
|
14
|
+
* About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
|
|
15
|
+
*/
|
|
16
|
+
export var AppMain = function (_a) {
|
|
17
|
+
var Component = _a.Component, pageProps = _a.pageProps, Layout = _a.Layout, ProgressOverlay = _a.ProgressOverlay, seo = _a.seo, motion = _a.motion, _b = _a.transition, transition = _b === void 0 ? {
|
|
18
|
+
initial: { opacity: 0 },
|
|
19
|
+
animate: { opacity: 1 },
|
|
20
|
+
exit: { opacity: 0 },
|
|
21
|
+
} : _b, pre = _a.pre, post = _a.post;
|
|
22
|
+
var pathname = useRouter().pathname;
|
|
23
|
+
return (_jsxs(_Fragment, { children: [_jsx(SeoDefaults, __assign({}, seo)), pre, _jsxs(MotionProvider, __assign({ features: motion }, { children: [ProgressOverlay && _jsx(NextProgress, { Overlay: ProgressOverlay }), _jsx(Layout, { children: _jsx(AnimatePresence, __assign({ exitBeforeEnter: true, initial: false }, { children: _jsx(m.div, __assign({}, transition, { children: _createElement(Component, __assign({}, pageProps, { key: pathname })) }), pathname) })) })] })), post] }));
|
|
24
|
+
};
|
|
25
|
+
export default AppMain;
|