@koine/next 2.0.0-beta.1 → 2.0.0-beta.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/12/AnalyticsGoogle.mjs +41 -15
- package/12/DisableErrorOverlay.mjs +8 -5
- package/12/DynamicNamespaces.d.ts +1 -1
- package/12/DynamicNamespaces.mjs +1 -2
- package/12/Favicon.mjs +6 -2
- package/12/Link.d.ts +1 -1
- package/12/Link.mjs +14 -6
- package/12/NextProgress.mjs +26 -17
- package/12/Seo.d.ts +1 -1
- package/12/Seo.mjs +5 -4
- package/12/SeoDefaults.d.ts +1 -1
- package/12/SeoDefaults.mjs +5 -3
- package/12/T.d.ts +1 -1
- package/12/T.mjs +20 -6
- package/12/ThemeContext.mjs +3 -3
- package/12/ThemeProvider.mjs +139 -129
- package/12/TransText.mjs +1 -1
- package/12/app/AppHead.mjs +8 -2
- package/12/app/AppMain.d.ts +4 -4
- package/12/app/AppMain.mjs +1 -1
- package/12/app/css/AppMain.mjs +15 -5
- package/12/app/css/AppTheme.d.ts +1 -1
- package/12/app/css/AppTheme.mjs +7 -4
- package/12/app/css/auth/index.d.ts +1 -1
- package/12/app/css/auth/index.mjs +17 -6
- package/12/app/css/index.d.ts +1 -1
- package/12/app/css/index.mjs +14 -6
- package/12/app/sc/AppMain.mjs +46 -13
- package/12/app/sc/AppTheme.d.ts +1 -1
- package/12/app/sc/AppTheme.mjs +9 -4
- package/12/app/sc/auth/index.d.ts +1 -1
- package/12/app/sc/auth/index.mjs +17 -6
- package/12/app/sc/index.d.ts +1 -1
- package/12/app/sc/index.mjs +14 -6
- package/12/document/Document.mjs +24 -14
- package/12/document/css/index.mjs +26 -18
- package/12/document/sc/index.mjs +46 -45
- package/12/getT.mjs +2 -4
- package/12/index.mjs +2 -2
- package/12/seoBuildTags.mjs +59 -55
- package/12/to.mjs +4 -10
- package/12/translationAsOptions.mjs +6 -6
- package/12/types-i18n.mjs +1 -2
- package/12/types-seo.mjs +1 -1
- package/12/useBackUrl.mjs +8 -8
- package/12/useDateFormat.mjs +15 -28
- package/12/useForm.d.ts +1 -1
- package/12/useForm.mjs +25 -13
- package/12/useT.d.ts +1 -1
- package/12/useT.mjs +32 -14
- package/12/useTheme.mjs +1 -2
- package/12/useTo.mjs +3 -10
- package/README.md +1 -1
- package/config/index.mjs +187 -204
- package/getSiteUrl.mjs +2 -4
- package/load.mjs +3 -4
- package/package.json +25 -18
- package/typings.d.ts +60 -0
- package/12/AnalyticsGoogle.js +0 -39
- package/12/DisableErrorOverlay.js +0 -18
- package/12/DynamicNamespaces.js +0 -13
- package/12/Favicon.js +0 -10
- package/12/Link.js +0 -15
- package/12/NextProgress.js +0 -46
- package/12/Seo.js +0 -34
- package/12/SeoDefaults.js +0 -17
- package/12/T.js +0 -17
- package/12/ThemeContext.js +0 -10
- package/12/ThemeProvider.js +0 -239
- package/12/TransText.js +0 -8
- package/12/app/AppHead.js +0 -11
- package/12/app/AppMain.js +0 -2
- package/12/app/css/AppMain.js +0 -18
- package/12/app/css/AppTheme.js +0 -18
- package/12/app/css/auth/index.js +0 -17
- package/12/app/css/auth/package.json +0 -6
- package/12/app/css/index.js +0 -61
- package/12/app/css/package.json +0 -6
- package/12/app/index.js +0 -5
- package/12/app/package.json +0 -6
- package/12/app/sc/AppMain.js +0 -29
- package/12/app/sc/AppTheme.js +0 -15
- package/12/app/sc/auth/index.js +0 -17
- package/12/app/sc/auth/package.json +0 -6
- package/12/app/sc/index.js +0 -63
- package/12/app/sc/package.json +0 -6
- package/12/document/Document.js +0 -31
- package/12/document/css/index.js +0 -45
- package/12/document/css/package.json +0 -6
- package/12/document/index.js +0 -7
- package/12/document/package.json +0 -6
- package/12/document/sc/index.js +0 -67
- package/12/document/sc/package.json +0 -6
- package/12/getT.js +0 -14
- package/12/index.js +0 -52
- package/12/package.json +0 -6
- package/12/seoBuildTags.js +0 -121
- package/12/to.js +0 -29
- package/12/translationAsOptions.js +0 -13
- package/12/types-i18n.js +0 -14
- package/12/types-seo.js +0 -2
- package/12/useBackUrl.js +0 -33
- package/12/useDateFormat.js +0 -43
- package/12/useForm.js +0 -39
- package/12/useLocale.js +0 -11
- package/12/useT.js +0 -44
- package/12/useTheme.js +0 -12
- package/12/useTo.js +0 -19
- package/config/index.js +0 -343
- package/config/package.json +0 -6
- package/getSiteUrl.js +0 -17
- package/index.js +0 -7
- package/load.js +0 -18
package/12/ThemeProvider.mjs
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { __spreadArray } from "tslib";
|
|
3
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { useCallback, useEffect, useState, memo } from "react";
|
|
5
3
|
import NextScript from "next/script";
|
|
4
|
+
import { memo, useCallback, useEffect, useState } from "react";
|
|
6
5
|
import isServer from "@koine/utils/isServer";
|
|
7
6
|
import { ThemeContext } from "./ThemeContext";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const colorSchemes = [
|
|
8
|
+
"light",
|
|
9
|
+
"dark"
|
|
10
|
+
];
|
|
11
|
+
const MEDIA = "(prefers-color-scheme: dark)";
|
|
12
|
+
const THEME_STORAGE_KEY = "theme";
|
|
11
13
|
/**
|
|
12
14
|
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
13
15
|
*
|
|
@@ -16,51 +18,39 @@ var THEME_STORAGE_KEY = "theme";
|
|
|
16
18
|
* - enableColorScheme: `false` by default (instead of `true`), this plays more
|
|
17
19
|
* nicely with tailwind `dark` class mode as dark theme is supposed to be only
|
|
18
20
|
* controlled by tailwind modifiers
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var applyTheme = useCallback(function (theme) {
|
|
30
|
-
var _a;
|
|
31
|
-
var resolved = theme;
|
|
32
|
-
if (isServer || !resolved)
|
|
33
|
-
return;
|
|
21
|
+
*/ export const ThemeProvider = ({ forcedTheme, disableTransitionOnChange = false, enableSystem = true, enableColorScheme, themes = [
|
|
22
|
+
"light",
|
|
23
|
+
"dark"
|
|
24
|
+
], defaultTheme = enableSystem ? "system" : "light", attribute = "data-theme", value, children, nonce })=>{
|
|
25
|
+
const [theme, setThemeState] = useState(()=>getTheme(THEME_STORAGE_KEY, defaultTheme));
|
|
26
|
+
const [resolvedTheme, setResolvedTheme] = useState(()=>getTheme(THEME_STORAGE_KEY));
|
|
27
|
+
const attrs = !value ? themes : Object.values(value);
|
|
28
|
+
const applyTheme = useCallback((theme)=>{
|
|
29
|
+
let resolved = theme;
|
|
30
|
+
if (isServer || !resolved) return;
|
|
34
31
|
// If theme is system, resolve it before setting theme
|
|
35
32
|
if (theme === "system" && enableSystem) {
|
|
36
33
|
resolved = getSystemTheme();
|
|
37
34
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
const name = value ? value[resolved] : resolved;
|
|
36
|
+
const enable = disableTransitionOnChange ? disableAnimation() : null;
|
|
37
|
+
const d = document.documentElement;
|
|
41
38
|
if (attribute === "class") {
|
|
42
|
-
|
|
43
|
-
if (name)
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
39
|
+
d.classList.remove(...attrs);
|
|
40
|
+
if (name) d.classList.add(name);
|
|
41
|
+
} else {
|
|
47
42
|
if (name) {
|
|
48
43
|
d.setAttribute(attribute, name);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
44
|
+
} else {
|
|
51
45
|
d.removeAttribute(attribute);
|
|
52
46
|
}
|
|
53
47
|
}
|
|
54
48
|
if (enableColorScheme) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
: "";
|
|
58
|
-
var colorScheme = colorSchemes.includes(resolved)
|
|
59
|
-
? resolved
|
|
60
|
-
: fallback;
|
|
49
|
+
const fallback = colorSchemes.includes(defaultTheme) ? defaultTheme : "";
|
|
50
|
+
const colorScheme = colorSchemes.includes(resolved) ? resolved : fallback;
|
|
61
51
|
d.style.colorScheme = colorScheme;
|
|
62
52
|
}
|
|
63
|
-
enable
|
|
53
|
+
enable?.();
|
|
64
54
|
}, [
|
|
65
55
|
attribute,
|
|
66
56
|
attrs,
|
|
@@ -68,168 +58,188 @@ export var ThemeProvider = function (_a) {
|
|
|
68
58
|
disableTransitionOnChange,
|
|
69
59
|
enableColorScheme,
|
|
70
60
|
enableSystem,
|
|
71
|
-
value
|
|
61
|
+
value
|
|
72
62
|
]);
|
|
73
|
-
|
|
63
|
+
const setTheme = useCallback((theme)=>{
|
|
74
64
|
setThemeState(theme);
|
|
75
65
|
// Save to storage
|
|
76
66
|
try {
|
|
77
67
|
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Unsupported
|
|
68
|
+
} catch (e) {
|
|
69
|
+
// Unsupported
|
|
81
70
|
}
|
|
82
71
|
}, []);
|
|
83
|
-
|
|
84
|
-
|
|
72
|
+
const handleMediaQuery = useCallback((e)=>{
|
|
73
|
+
const resolved = getSystemTheme(e);
|
|
85
74
|
setResolvedTheme(resolved);
|
|
86
75
|
if (theme === "system" && enableSystem && !forcedTheme) {
|
|
87
76
|
applyTheme("system");
|
|
88
77
|
}
|
|
89
|
-
}, [
|
|
78
|
+
}, [
|
|
79
|
+
theme,
|
|
80
|
+
enableSystem,
|
|
81
|
+
forcedTheme,
|
|
82
|
+
applyTheme
|
|
83
|
+
]);
|
|
90
84
|
// Always listen to System preference
|
|
91
|
-
useEffect(
|
|
92
|
-
|
|
85
|
+
useEffect(()=>{
|
|
86
|
+
const media = window.matchMedia(MEDIA);
|
|
93
87
|
// Intentionally use deprecated listener methods to support iOS & old browsers
|
|
94
88
|
media.addListener(handleMediaQuery);
|
|
95
89
|
handleMediaQuery(media);
|
|
96
|
-
return
|
|
97
|
-
}, [
|
|
90
|
+
return ()=>media.removeListener(handleMediaQuery);
|
|
91
|
+
}, [
|
|
92
|
+
handleMediaQuery
|
|
93
|
+
]);
|
|
98
94
|
// localStorage event handling
|
|
99
|
-
useEffect(
|
|
100
|
-
|
|
95
|
+
useEffect(()=>{
|
|
96
|
+
const handleStorage = (e)=>{
|
|
101
97
|
if (e.key !== THEME_STORAGE_KEY) {
|
|
102
98
|
return;
|
|
103
99
|
}
|
|
104
100
|
// If default theme set, use it if localstorage === null (happens on local storage manual deletion)
|
|
105
|
-
|
|
101
|
+
const theme = e.newValue || defaultTheme;
|
|
106
102
|
setTheme(theme);
|
|
107
103
|
};
|
|
108
104
|
window.addEventListener("storage", handleStorage);
|
|
109
|
-
return
|
|
110
|
-
}, [
|
|
105
|
+
return ()=>window.removeEventListener("storage", handleStorage);
|
|
106
|
+
}, [
|
|
107
|
+
defaultTheme,
|
|
108
|
+
setTheme
|
|
109
|
+
]);
|
|
111
110
|
// Whenever theme or forcedTheme changes, apply it
|
|
112
|
-
useEffect(
|
|
113
|
-
applyTheme(forcedTheme
|
|
114
|
-
}, [
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
useEffect(()=>{
|
|
112
|
+
applyTheme(forcedTheme ?? theme);
|
|
113
|
+
}, [
|
|
114
|
+
applyTheme,
|
|
115
|
+
forcedTheme,
|
|
116
|
+
theme
|
|
117
|
+
]);
|
|
118
|
+
return /*#__PURE__*/ _jsxs(ThemeContext.Provider, {
|
|
119
|
+
value: {
|
|
120
|
+
theme,
|
|
121
|
+
setTheme,
|
|
122
|
+
forcedTheme,
|
|
119
123
|
resolvedTheme: theme === "system" ? resolvedTheme : theme,
|
|
120
|
-
themes: enableSystem ?
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
themes: enableSystem ? [
|
|
125
|
+
...themes,
|
|
126
|
+
"system"
|
|
127
|
+
] : themes,
|
|
128
|
+
systemTheme: enableSystem ? resolvedTheme : undefined
|
|
129
|
+
},
|
|
130
|
+
children: [
|
|
131
|
+
/*#__PURE__*/ _jsx(ThemeScript, {
|
|
132
|
+
forcedTheme,
|
|
133
|
+
disableTransitionOnChange,
|
|
134
|
+
enableSystem,
|
|
135
|
+
enableColorScheme,
|
|
136
|
+
themes,
|
|
137
|
+
defaultTheme,
|
|
138
|
+
attribute,
|
|
139
|
+
value,
|
|
140
|
+
children,
|
|
141
|
+
attrs,
|
|
142
|
+
nonce
|
|
143
|
+
}),
|
|
144
|
+
children
|
|
145
|
+
]
|
|
146
|
+
});
|
|
123
147
|
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
var defaultSystem = defaultTheme === "system";
|
|
148
|
+
const ThemeScript = /*#__PURE__*/ memo(({ forcedTheme, attribute, enableSystem, enableColorScheme, defaultTheme, value, attrs, nonce })=>{
|
|
149
|
+
const defaultSystem = defaultTheme === "system";
|
|
127
150
|
// Code-golfing the amount of characters in the script
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
.join(","), ")");
|
|
132
|
-
return "var d=document.documentElement.classList;".concat(removeClasses, ";");
|
|
151
|
+
const optimization = (()=>{
|
|
152
|
+
const removeClasses = `d.remove(${attrs.map((t)=>`'${t}'`).join(",")})`;
|
|
153
|
+
return `var d=document.documentElement.classList;${removeClasses};`;
|
|
133
154
|
})();
|
|
134
|
-
|
|
155
|
+
const fallbackColorScheme = (()=>{
|
|
135
156
|
if (!enableColorScheme) {
|
|
136
157
|
return "";
|
|
137
158
|
}
|
|
138
|
-
|
|
139
|
-
? defaultTheme
|
|
140
|
-
: null;
|
|
159
|
+
const fallback = colorSchemes.includes(defaultTheme) ? defaultTheme : null;
|
|
141
160
|
if (fallback) {
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return "if(e==='light'||e==='dark')d.style.colorScheme=e";
|
|
161
|
+
return `if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${defaultTheme}'`;
|
|
162
|
+
} else {
|
|
163
|
+
return `if(e==='light'||e==='dark')d.style.colorScheme=e`;
|
|
146
164
|
}
|
|
147
165
|
})();
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
var val = literal ? name + "|| ''" : "'".concat(resolvedName, "'");
|
|
153
|
-
var text = "";
|
|
166
|
+
const updateDOM = (name, literal = false, setColorScheme = true)=>{
|
|
167
|
+
const resolvedName = value ? value[name] : name;
|
|
168
|
+
const val = literal ? name + `|| ''` : `'${resolvedName}'`;
|
|
169
|
+
let text = "";
|
|
154
170
|
// MUCH faster to set colorScheme alongside HTML attribute/class
|
|
155
171
|
// as it only incurs 1 style recalculation rather than 2
|
|
156
172
|
// This can save over 250ms of work for pages with big DOM
|
|
157
|
-
if (enableColorScheme &&
|
|
158
|
-
|
|
159
|
-
!literal &&
|
|
160
|
-
colorSchemes.includes(name)) {
|
|
161
|
-
text += "d.style.colorScheme = '".concat(name, "';");
|
|
173
|
+
if (enableColorScheme && setColorScheme && !literal && colorSchemes.includes(name)) {
|
|
174
|
+
text += `d.style.colorScheme = '${name}';`;
|
|
162
175
|
}
|
|
163
176
|
if (attribute === "class") {
|
|
164
177
|
if (literal || resolvedName) {
|
|
165
|
-
text +=
|
|
178
|
+
text += `d.add(${val})`;
|
|
179
|
+
} else {
|
|
180
|
+
text += `null`;
|
|
166
181
|
}
|
|
167
|
-
|
|
168
|
-
text += "null";
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
182
|
+
} else {
|
|
172
183
|
if (resolvedName) {
|
|
173
|
-
text +=
|
|
184
|
+
text += `d[s](n, ${val})`;
|
|
174
185
|
}
|
|
175
186
|
}
|
|
176
187
|
return text;
|
|
177
188
|
};
|
|
178
|
-
|
|
189
|
+
const scriptSrc = (()=>{
|
|
179
190
|
if (forcedTheme) {
|
|
180
|
-
return
|
|
191
|
+
return `!function(){${optimization}${updateDOM(forcedTheme)}}()`;
|
|
181
192
|
}
|
|
182
193
|
if (enableSystem) {
|
|
183
|
-
return
|
|
184
|
-
? "else{" + updateDOM(defaultTheme, false, false) + "}"
|
|
185
|
-
: "").concat(fallbackColorScheme, "}catch(e){}}()");
|
|
194
|
+
return `!function(){try {${optimization}var e=localStorage.getItem('${THEME_STORAGE_KEY}');if("system"===e||(!e&&${defaultSystem})){var t="${MEDIA}",m=window.matchMedia(t);if(m.media!==t||m.matches){${updateDOM("dark")}}else{${updateDOM("light")}}}else if(e){${value ? `var x=${JSON.stringify(value)};` : ""}${updateDOM(value ? `x[e]` : "e", true)}}${!defaultSystem ? `else{` + updateDOM(defaultTheme, false, false) + "}" : ""}${fallbackColorScheme}}catch(e){}}()`;
|
|
186
195
|
}
|
|
187
|
-
return
|
|
196
|
+
return `!function(){try{${optimization}var e=localStorage.getItem("${THEME_STORAGE_KEY}");if(e){${value ? `var x=${JSON.stringify(value)};` : ""}${updateDOM(value ? `x[e]` : "e", true)}}else{${updateDOM(defaultTheme, false, false)};}${fallbackColorScheme}}catch(t){}}();`;
|
|
188
197
|
})();
|
|
189
198
|
// We MUST use next/script's `beforeInteractive` strategy to avoid flashing on load.
|
|
190
199
|
// However, it only accepts the `src` prop, not `dangerouslySetInnerHTML` or `children`
|
|
191
200
|
// But our script cannot be external because it changes at runtime based on React props
|
|
192
201
|
// so we trick next/script by passing `src` as a base64 JS script
|
|
193
|
-
|
|
194
|
-
return
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
202
|
+
const encodedScript = `data:text/javascript;base64,${encodeBase64(scriptSrc)}`;
|
|
203
|
+
return /*#__PURE__*/ _jsx(NextScript, {
|
|
204
|
+
id: "next-theme-script",
|
|
205
|
+
strategy: "beforeInteractive",
|
|
206
|
+
src: encodedScript,
|
|
207
|
+
nonce: nonce
|
|
208
|
+
});
|
|
209
|
+
}, // Never re-render this component
|
|
210
|
+
()=>true);
|
|
198
211
|
// Helpers
|
|
199
|
-
|
|
200
|
-
if (isServer)
|
|
201
|
-
|
|
202
|
-
var theme;
|
|
212
|
+
const getTheme = (key, fallback)=>{
|
|
213
|
+
if (isServer) return undefined;
|
|
214
|
+
let theme;
|
|
203
215
|
try {
|
|
204
216
|
theme = localStorage.getItem(key) || undefined;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Unsupported
|
|
217
|
+
} catch (e) {
|
|
218
|
+
// Unsupported
|
|
208
219
|
}
|
|
209
220
|
return theme || fallback;
|
|
210
221
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
css.appendChild(d.createTextNode(
|
|
222
|
+
const disableAnimation = ()=>{
|
|
223
|
+
const d = document;
|
|
224
|
+
const css = d.createElement("style");
|
|
225
|
+
css.appendChild(d.createTextNode(`*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`));
|
|
215
226
|
d.head.appendChild(css);
|
|
216
|
-
return
|
|
227
|
+
return ()=>{
|
|
217
228
|
// Force restyle
|
|
218
|
-
(
|
|
229
|
+
(()=>window.getComputedStyle(d.body))();
|
|
219
230
|
// Wait for next tick before removing
|
|
220
|
-
setTimeout(
|
|
231
|
+
setTimeout(()=>{
|
|
221
232
|
d.head.removeChild(css);
|
|
222
233
|
}, 1);
|
|
223
234
|
};
|
|
224
235
|
};
|
|
225
|
-
|
|
226
|
-
if (!e)
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
var systemTheme = isDark ? "dark" : "light";
|
|
236
|
+
const getSystemTheme = (e)=>{
|
|
237
|
+
if (!e) e = window.matchMedia(MEDIA);
|
|
238
|
+
const isDark = e.matches;
|
|
239
|
+
const systemTheme = isDark ? "dark" : "light";
|
|
230
240
|
return systemTheme;
|
|
231
241
|
};
|
|
232
|
-
|
|
242
|
+
const encodeBase64 = (str)=>{
|
|
233
243
|
return isServer ? Buffer.from(str).toString("base64") : btoa(str);
|
|
234
244
|
};
|
|
235
245
|
export default ThemeProvider;
|
package/12/TransText.mjs
CHANGED
package/12/app/AppHead.mjs
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import Head from "next/head";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import React from "react";
|
|
4
|
+
export const AppHead = ()=>{
|
|
5
|
+
return /*#__PURE__*/ _jsx(Head, {
|
|
6
|
+
children: /*#__PURE__*/ _jsx("meta", {
|
|
7
|
+
name: "viewport",
|
|
8
|
+
content: "width=device-width"
|
|
9
|
+
})
|
|
10
|
+
});
|
|
5
11
|
};
|
|
6
12
|
export default AppHead;
|
package/12/app/AppMain.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { AppProps as NextAppProps } from "next/app";
|
|
3
1
|
import type { HTMLMotionProps } from "framer-motion";
|
|
4
|
-
import type {
|
|
5
|
-
import
|
|
2
|
+
import type { AppProps as NextAppProps } from "next/app";
|
|
3
|
+
import React from "react";
|
|
6
4
|
import type { MotionProviderFeatures } from "@koine/react/m";
|
|
5
|
+
import type { NextProgressProps } from "../NextProgress";
|
|
6
|
+
import type { SeoDefaultsProps } from "../SeoDefaults";
|
|
7
7
|
export type AppMainBaseProps = NextAppProps & {
|
|
8
8
|
/**
|
|
9
9
|
* A wrapping layout component
|
package/12/app/AppMain.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
package/12/app/css/AppMain.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import React from "react";
|
|
4
3
|
import { SeoDefaults } from "../../SeoDefaults";
|
|
@@ -6,9 +5,20 @@ import { SeoDefaults } from "../../SeoDefaults";
|
|
|
6
5
|
* App main
|
|
7
6
|
*
|
|
8
7
|
* It does not imply any specific styling or animation solution
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
*/ export const AppMain = ({ Component, pageProps, Layout, seo, pre, post })=>{
|
|
9
|
+
return /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ _jsx(SeoDefaults, {
|
|
12
|
+
...seo
|
|
13
|
+
}),
|
|
14
|
+
pre,
|
|
15
|
+
/*#__PURE__*/ _jsx(Layout, {
|
|
16
|
+
children: /*#__PURE__*/ _jsx(Component, {
|
|
17
|
+
...pageProps
|
|
18
|
+
})
|
|
19
|
+
}),
|
|
20
|
+
post
|
|
21
|
+
]
|
|
22
|
+
});
|
|
13
23
|
};
|
|
14
24
|
export default AppMain;
|
package/12/app/css/AppTheme.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { type AppProps as NextAppProps } from "next/app";
|
|
2
|
+
import React from "react";
|
|
3
3
|
import { type ThemeProviderProps } from "../../ThemeProvider";
|
|
4
4
|
export type AppThemeProps = React.PropsWithChildren<NextAppProps & {
|
|
5
5
|
theme: ThemeProviderProps["defaultTheme"];
|
package/12/app/css/AppTheme.mjs
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
2
3
|
// import { ThemeVanillaProvider, ThemeVanillaValue } from "@koine/react/styles";
|
|
3
4
|
import { ThemeProvider } from "../../ThemeProvider";
|
|
4
5
|
/**
|
|
5
6
|
* App theme with vanilla class based theme (good for `tailwindcss`)
|
|
6
|
-
*/
|
|
7
|
-
export var AppTheme = function (_a) {
|
|
8
|
-
var theme = _a.theme, children = _a.children;
|
|
7
|
+
*/ export const AppTheme = ({ theme, children })=>{
|
|
9
8
|
// return (
|
|
10
9
|
// <ThemeVanillaProvider initialTheme={theme}>{children}</ThemeVanillaProvider>
|
|
11
10
|
// );
|
|
12
|
-
return
|
|
11
|
+
return /*#__PURE__*/ _jsx(ThemeProvider, {
|
|
12
|
+
defaultTheme: theme,
|
|
13
|
+
attribute: "class",
|
|
14
|
+
children: children
|
|
15
|
+
});
|
|
13
16
|
};
|
|
14
17
|
export default AppTheme;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AppProps } from "next/app";
|
|
2
|
-
import { type AppThemeProps } from "../AppTheme";
|
|
3
2
|
import { type AppMainProps } from "../AppMain";
|
|
3
|
+
import { type AppThemeProps } from "../AppTheme";
|
|
4
4
|
export type NextAppProps = AppProps<{
|
|
5
5
|
session: any;
|
|
6
6
|
}> & AppThemeProps & AppMainProps;
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
2
|
import { SessionProvider } from "next-auth/react";
|
|
4
3
|
import { AppHead } from "../../AppHead";
|
|
5
|
-
import { AppTheme } from "../AppTheme";
|
|
6
4
|
import { AppMain } from "../AppMain";
|
|
5
|
+
import { AppTheme } from "../AppTheme";
|
|
7
6
|
/**
|
|
8
7
|
* App with authentication provided by `next-auth`
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
*/ export const NextApp = (props)=>{
|
|
9
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ _jsx(AppHead, {}),
|
|
12
|
+
/*#__PURE__*/ _jsx(SessionProvider, {
|
|
13
|
+
session: props.pageProps.session,
|
|
14
|
+
children: /*#__PURE__*/ _jsx(AppTheme, {
|
|
15
|
+
...props,
|
|
16
|
+
children: /*#__PURE__*/ _jsx(AppMain, {
|
|
17
|
+
...props
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
]
|
|
22
|
+
});
|
|
12
23
|
};
|
|
13
24
|
export default NextApp;
|
package/12/app/css/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AppProps } from "next/app";
|
|
2
|
-
import { type AppThemeProps } from "./AppTheme";
|
|
3
2
|
import { type AppMainProps } from "./AppMain";
|
|
3
|
+
import { type AppThemeProps } from "./AppTheme";
|
|
4
4
|
export type NextAppProps = AppProps & AppThemeProps & AppMainProps;
|
|
5
5
|
/**
|
|
6
6
|
* App
|
package/12/app/css/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
2
|
import { AppHead } from "../AppHead";
|
|
4
|
-
import { AppTheme } from "./AppTheme";
|
|
5
3
|
import { AppMain } from "./AppMain";
|
|
4
|
+
import { AppTheme } from "./AppTheme";
|
|
6
5
|
/**
|
|
7
6
|
* App
|
|
8
7
|
*
|
|
@@ -50,8 +49,17 @@ import { AppMain } from "./AppMain";
|
|
|
50
49
|
* }
|
|
51
50
|
*
|
|
52
51
|
* ```
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
*/ export const NextApp = (props)=>{
|
|
53
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
54
|
+
children: [
|
|
55
|
+
/*#__PURE__*/ _jsx(AppHead, {}),
|
|
56
|
+
/*#__PURE__*/ _jsx(AppTheme, {
|
|
57
|
+
...props,
|
|
58
|
+
children: /*#__PURE__*/ _jsx(AppMain, {
|
|
59
|
+
...props
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
]
|
|
63
|
+
});
|
|
56
64
|
};
|
|
57
65
|
export default NextApp;
|
package/12/app/sc/AppMain.mjs
CHANGED
|
@@ -1,25 +1,58 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
|
-
import { createElement as _createElement } from "react";
|
|
3
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
|
-
import {
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
5
3
|
import { AnimatePresence, m } from "framer-motion";
|
|
4
|
+
import { useRouter } from "next/router";
|
|
5
|
+
import React from "react";
|
|
6
6
|
import { MotionProvider } from "@koine/react/m";
|
|
7
|
-
import { SeoDefaults } from "../../SeoDefaults";
|
|
8
7
|
import { NextProgress } from "../../NextProgress";
|
|
8
|
+
import { SeoDefaults } from "../../SeoDefaults";
|
|
9
9
|
/**
|
|
10
10
|
* App main
|
|
11
11
|
*
|
|
12
12
|
* It implies a setup for `styled-components` and `framer-motion` libraries.
|
|
13
13
|
*
|
|
14
14
|
* About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
*/ export const AppMain = ({ Component, pageProps, Layout, ProgressOverlay, seo, motion, transition = {
|
|
16
|
+
initial: {
|
|
17
|
+
opacity: 0
|
|
18
|
+
},
|
|
19
|
+
animate: {
|
|
20
|
+
opacity: 1
|
|
21
|
+
},
|
|
22
|
+
exit: {
|
|
23
|
+
opacity: 0
|
|
24
|
+
}
|
|
25
|
+
}, pre, post })=>{
|
|
26
|
+
const { pathname } = useRouter();
|
|
27
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
28
|
+
children: [
|
|
29
|
+
/*#__PURE__*/ _jsx(SeoDefaults, {
|
|
30
|
+
...seo
|
|
31
|
+
}),
|
|
32
|
+
pre,
|
|
33
|
+
/*#__PURE__*/ _jsxs(MotionProvider, {
|
|
34
|
+
features: motion,
|
|
35
|
+
children: [
|
|
36
|
+
ProgressOverlay && /*#__PURE__*/ _jsx(NextProgress, {
|
|
37
|
+
Overlay: ProgressOverlay
|
|
38
|
+
}),
|
|
39
|
+
/*#__PURE__*/ _jsx(Layout, {
|
|
40
|
+
children: /*#__PURE__*/ _jsx(AnimatePresence, {
|
|
41
|
+
exitBeforeEnter: true,
|
|
42
|
+
initial: false,
|
|
43
|
+
children: /*#__PURE__*/ _jsx(m.div, {
|
|
44
|
+
...transition,
|
|
45
|
+
children: /*#__PURE__*/ _createElement(Component, {
|
|
46
|
+
...pageProps,
|
|
47
|
+
key: pathname
|
|
48
|
+
})
|
|
49
|
+
}, pathname)
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
}),
|
|
54
|
+
post
|
|
55
|
+
]
|
|
56
|
+
});
|
|
24
57
|
};
|
|
25
58
|
export default AppMain;
|
package/12/app/sc/AppTheme.d.ts
CHANGED