@koine/next 1.0.11 → 1.0.14
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/Analytics/AnalyticsGoogle.js +12 -16
- package/Auth/helpers.js +6 -5
- package/Auth/useLogin.js +17 -18
- package/Auth/useLoginUrl.js +5 -5
- package/Auth/useLogout.js +19 -19
- package/Favicon/Favicon.js +2 -1
- package/Forms/useForm.js +10 -12
- package/Forms/useSubmit.js +23 -18
- package/I18n/I18n.js +35 -14
- package/Img/Img.js +22 -20
- package/Link/Link.js +4 -2
- package/NextProgress/NextProgress.js +12 -9
- package/Seo/Seo.js +2 -2
- package/Seo/SeoDefaults.js +2 -2
- package/Seo/helpers.js +34 -30
- package/Theme/Theme.js +98 -88
- package/app/AppHead.js +1 -1
- package/app/css/AppMain.js +4 -2
- package/app/css/AppTheme.js +4 -2
- package/app/css/auth/index.js +3 -2
- package/app/css/index.js +3 -2
- package/app/em/AppMain.js +9 -7
- package/app/em/AppTheme.js +6 -5
- package/app/em/auth/index.js +3 -2
- package/app/em/index.js +3 -2
- package/app/sc/AppMain.js +9 -7
- package/app/sc/AppTheme.js +4 -2
- package/app/sc/auth/index.js +3 -2
- package/app/sc/index.js +3 -2
- package/config/index.d.ts +13 -0
- package/config/index.js +87 -71
- package/document/Document.js +12 -5
- package/document/css/index.js +26 -12
- package/document/em/index.js +39 -48
- package/document/sc/index.js +44 -23
- package/package.json +13 -11
- package/utils/api.js +40 -31
- package/utils/index.js +7 -6
- package/node/Analytics/AnalyticsGoogle.js +0 -42
- package/node/Analytics/index.js +0 -4
- package/node/Auth/helpers.js +0 -26
- package/node/Auth/index.js +0 -7
- package/node/Auth/useLogin.js +0 -54
- package/node/Auth/useLoginUrl.js +0 -15
- package/node/Auth/useLogout.js +0 -56
- package/node/Favicon/Favicon.js +0 -9
- package/node/Favicon/index.js +0 -4
- package/node/Forms/index.js +0 -5
- package/node/Forms/useForm.js +0 -41
- package/node/Forms/useSubmit.js +0 -27
- package/node/Head/Head.js +0 -8
- package/node/Head/index.js +0 -4
- package/node/I18n/I18n.js +0 -82
- package/node/I18n/index.js +0 -4
- package/node/Img/Img.js +0 -34
- package/node/Img/index.js +0 -4
- package/node/Link/Link.js +0 -13
- package/node/Link/index.js +0 -4
- package/node/NextProgress/NextProgress.js +0 -41
- package/node/NextProgress/index.js +0 -5
- package/node/Seo/Seo.js +0 -12
- package/node/Seo/SeoDefaults.js +0 -16
- package/node/Seo/helpers.js +0 -115
- package/node/Seo/index.js +0 -15
- package/node/Theme/Theme.js +0 -241
- package/node/Theme/index.js +0 -4
- package/node/app/AppHead.js +0 -10
- package/node/app/AppMain.js +0 -2
- package/node/app/css/AppMain.js +0 -16
- package/node/app/css/AppTheme.js +0 -16
- package/node/app/css/auth/index.js +0 -18
- package/node/app/css/index.js +0 -62
- package/node/app/em/AppMain.js +0 -26
- package/node/app/em/AppTheme.js +0 -22
- package/node/app/em/auth/index.js +0 -18
- package/node/app/em/index.js +0 -17
- package/node/app/index.js +0 -5
- package/node/app/sc/AppMain.js +0 -26
- package/node/app/sc/AppTheme.js +0 -13
- package/node/app/sc/auth/index.js +0 -18
- package/node/app/sc/index.js +0 -64
- package/node/config/index.js +0 -184
- package/node/document/Document.js +0 -24
- package/node/document/css/index.js +0 -35
- package/node/document/em/index.js +0 -73
- package/node/document/index.js +0 -7
- package/node/document/sc/index.js +0 -49
- package/node/index.js +0 -15
- package/node/utils/api.js +0 -38
- package/node/utils/emotion-cache.js +0 -13
- package/node/utils/index.js +0 -32
package/Seo/helpers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import { isArray } from "@koine/utils";
|
|
3
|
-
|
|
4
|
+
var defaults = {
|
|
4
5
|
tplTitle: "",
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
@@ -17,14 +18,15 @@ const defaults = {
|
|
|
17
18
|
*
|
|
18
19
|
* @returns
|
|
19
20
|
*/
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
export var buildTags = function (_a) {
|
|
22
|
+
var _b = _a === void 0 ? {} : _a, seo = _b.seo, hidden = _b.hidden, keywords = _b.keywords, _c = _b.title, title = _c === void 0 ? "" : _c, titleTemplate = _b.titleTemplate, defaultTitle = _b.defaultTitle, noindex = _b.noindex, nofollow = _b.nofollow, description = _b.description, _d = _b.languageAlternates, languageAlternates = _d === void 0 ? [] : _d, twitter = _b.twitter, facebook = _b.facebook, openGraph = _b.openGraph, ogAlias = _b.og, canonical = _b.canonical, metaTags = _b.metaTags, linkTags = _b.linkTags;
|
|
23
|
+
var render = [];
|
|
24
|
+
var $names = {};
|
|
25
|
+
var $properties = {};
|
|
24
26
|
if (titleTemplate) {
|
|
25
27
|
defaults.tplTitle = titleTemplate;
|
|
26
28
|
}
|
|
27
|
-
title = title || seo
|
|
29
|
+
title = title || (seo === null || seo === void 0 ? void 0 : seo.title) || "";
|
|
28
30
|
if (title) {
|
|
29
31
|
if (defaults.tplTitle && defaults.tplTitle !== title) {
|
|
30
32
|
title = defaults.tplTitle.replace(/%s/g, title);
|
|
@@ -37,26 +39,26 @@ export const buildTags = ({ seo, hidden, keywords, title = "", titleTemplate, de
|
|
|
37
39
|
render.push(_jsx("title", { children: title }, "title"));
|
|
38
40
|
$properties["og:title"] = title; // overridden later...
|
|
39
41
|
}
|
|
40
|
-
$names["robots"] =
|
|
41
|
-
description = description || seo
|
|
42
|
+
$names["robots"] = "".concat(noindex || hidden ? "noindex" : "index", ",").concat(nofollow || hidden ? "nofollow" : "follow");
|
|
43
|
+
description = description || (seo === null || seo === void 0 ? void 0 : seo.description);
|
|
42
44
|
if (description) {
|
|
43
45
|
$names["description"] = description;
|
|
44
46
|
$properties["og:description"] = description; // overridden later...
|
|
45
47
|
}
|
|
46
|
-
keywords = keywords || seo
|
|
48
|
+
keywords = keywords || (seo === null || seo === void 0 ? void 0 : seo.keywords);
|
|
47
49
|
if (keywords) {
|
|
48
50
|
$names["keywords"] = isArray(keywords) ? keywords.join(", ") : keywords;
|
|
49
51
|
}
|
|
50
|
-
if (languageAlternates
|
|
51
|
-
languageAlternates.forEach((languageAlternate)
|
|
52
|
-
render.push(_jsx("link", { rel: "alternate", hrefLang: languageAlternate.hrefLang, href: languageAlternate.href },
|
|
52
|
+
if ((languageAlternates === null || languageAlternates === void 0 ? void 0 : languageAlternates.length) > 0) {
|
|
53
|
+
languageAlternates.forEach(function (languageAlternate) {
|
|
54
|
+
render.push(_jsx("link", { rel: "alternate", hrefLang: languageAlternate.hrefLang, href: languageAlternate.href }, "languageAlternate-".concat(languageAlternate.hrefLang)));
|
|
53
55
|
});
|
|
54
56
|
}
|
|
55
57
|
if (canonical) {
|
|
56
58
|
render.push(_jsx("link", { rel: "canonical", href: canonical }, "canonical"));
|
|
57
59
|
$properties["og:url"] = canonical;
|
|
58
60
|
}
|
|
59
|
-
if (facebook
|
|
61
|
+
if (facebook === null || facebook === void 0 ? void 0 : facebook.appId)
|
|
60
62
|
$properties["fb:app_id"] = facebook.appId;
|
|
61
63
|
if (twitter) {
|
|
62
64
|
if (twitter.cardType)
|
|
@@ -66,36 +68,38 @@ export const buildTags = ({ seo, hidden, keywords, title = "", titleTemplate, de
|
|
|
66
68
|
if (twitter.handle)
|
|
67
69
|
$names["twitter:creator"] = twitter.handle;
|
|
68
70
|
}
|
|
69
|
-
|
|
70
|
-
if (og
|
|
71
|
-
$properties["og:title"] = og
|
|
72
|
-
if (og
|
|
73
|
-
$properties["og:description"] = og
|
|
74
|
-
if (og
|
|
71
|
+
var og = ogAlias || openGraph;
|
|
72
|
+
if (og === null || og === void 0 ? void 0 : og.title)
|
|
73
|
+
$properties["og:title"] = og === null || og === void 0 ? void 0 : og.title;
|
|
74
|
+
if (og === null || og === void 0 ? void 0 : og.description)
|
|
75
|
+
$properties["og:description"] = og === null || og === void 0 ? void 0 : og.description;
|
|
76
|
+
if (og === null || og === void 0 ? void 0 : og.url)
|
|
75
77
|
$properties["og:url"] = og.url;
|
|
76
|
-
if (og
|
|
78
|
+
if (og === null || og === void 0 ? void 0 : og.type)
|
|
77
79
|
$properties["og:type"] = og.type.toLowerCase();
|
|
78
|
-
if (og
|
|
80
|
+
if (og === null || og === void 0 ? void 0 : og.locale)
|
|
79
81
|
$properties["og:locale"] = og.locale;
|
|
80
|
-
if (og
|
|
82
|
+
if (og === null || og === void 0 ? void 0 : og.site_name)
|
|
81
83
|
$properties["og:site_name"] = og.site_name;
|
|
82
|
-
|
|
84
|
+
var ogimage = (og === null || og === void 0 ? void 0 : og.image) || (seo === null || seo === void 0 ? void 0 : seo.ogimage);
|
|
83
85
|
if (ogimage)
|
|
84
86
|
$properties["og:image"] = ogimage;
|
|
85
|
-
Object.keys($names).forEach((key)
|
|
87
|
+
Object.keys($names).forEach(function (key) {
|
|
86
88
|
render.push(_jsx("meta", { name: key, content: $names[key] }, key));
|
|
87
89
|
});
|
|
88
|
-
Object.keys($properties).forEach((key)
|
|
90
|
+
Object.keys($properties).forEach(function (key) {
|
|
89
91
|
render.push(_jsx("meta", { property: key, content: $properties[key] }, key));
|
|
90
92
|
});
|
|
91
93
|
if (metaTags && metaTags.length > 0) {
|
|
92
|
-
metaTags.forEach((tag)
|
|
93
|
-
|
|
94
|
+
metaTags.forEach(function (tag) {
|
|
95
|
+
var _a, _b, _c;
|
|
96
|
+
render.push(_jsx("meta", __assign({}, tag), "meta:".concat((_c = (_b = (_a = tag.keyOverride) !== null && _a !== void 0 ? _a : tag.name) !== null && _b !== void 0 ? _b : tag.property) !== null && _c !== void 0 ? _c : tag.httpEquiv)));
|
|
94
97
|
});
|
|
95
98
|
}
|
|
96
|
-
if (linkTags
|
|
97
|
-
linkTags.forEach((tag)
|
|
98
|
-
|
|
99
|
+
if (linkTags === null || linkTags === void 0 ? void 0 : linkTags.length) {
|
|
100
|
+
linkTags.forEach(function (tag) {
|
|
101
|
+
var _a;
|
|
102
|
+
render.push(_jsx("link", __assign({}, tag), "link".concat((_a = tag.keyOverride) !== null && _a !== void 0 ? _a : tag.href).concat(tag.rel)));
|
|
99
103
|
});
|
|
100
104
|
}
|
|
101
105
|
// TODO: alternates and canonical
|
package/Theme/Theme.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign, __spreadArray } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
/**
|
|
3
4
|
* @file
|
|
@@ -7,32 +8,38 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
7
8
|
import { createContext, useCallback, useContext, useEffect, useState, memo, } from "react";
|
|
8
9
|
import NextScript from "next/script";
|
|
9
10
|
import { isServer } from "@koine/utils";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
var THEME_STORAGE_KEY = "theme";
|
|
12
|
+
var colorSchemes = ["light", "dark"];
|
|
13
|
+
var MEDIA = "(prefers-color-scheme: dark)";
|
|
14
|
+
var ThemeContext = createContext({
|
|
14
15
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
15
|
-
setTheme: (_)
|
|
16
|
+
setTheme: function (_) { },
|
|
16
17
|
themes: [],
|
|
17
18
|
});
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
export var useTheme = function () { return useContext(ThemeContext); };
|
|
20
|
+
export var ThemeProvider = function (_a) {
|
|
21
|
+
var forcedTheme = _a.forcedTheme, _b = _a.disableTransitionOnChange, disableTransitionOnChange = _b === void 0 ? false : _b, _c = _a.enableSystem, enableSystem = _c === void 0 ? true : _c, _d = _a.enableColorScheme, enableColorScheme = _d === void 0 ? true : _d, _e = _a.themes, themes = _e === void 0 ? ["light", "dark"] : _e, _f = _a.defaultTheme, defaultTheme = _f === void 0 ? enableSystem ? "system" : "light" : _f, _g = _a.attribute, attribute = _g === void 0 ? "data-theme" : _g, value = _a.value, children = _a.children, nonce = _a.nonce;
|
|
22
|
+
var _h = useState(function () {
|
|
23
|
+
return getTheme(THEME_STORAGE_KEY, defaultTheme);
|
|
24
|
+
}), theme = _h[0], setThemeState = _h[1];
|
|
25
|
+
var _j = useState(function () {
|
|
26
|
+
return getTheme(THEME_STORAGE_KEY);
|
|
27
|
+
}), resolvedTheme = _j[0], setResolvedTheme = _j[1];
|
|
28
|
+
var attrs = !value ? themes : Object.values(value);
|
|
29
|
+
var applyTheme = useCallback(function (theme) {
|
|
30
|
+
var _a;
|
|
31
|
+
var resolved = theme;
|
|
25
32
|
if (isServer || !resolved)
|
|
26
33
|
return;
|
|
27
34
|
// If theme is system, resolve it before setting theme
|
|
28
35
|
if (theme === "system" && enableSystem) {
|
|
29
36
|
resolved = getSystemTheme();
|
|
30
37
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
var name = value ? value[resolved] : resolved;
|
|
39
|
+
var enable = disableTransitionOnChange ? disableAnimation() : null;
|
|
40
|
+
var d = document.documentElement;
|
|
34
41
|
if (attribute === "class") {
|
|
35
|
-
d.classList.remove(
|
|
42
|
+
(_a = d.classList).remove.apply(_a, attrs);
|
|
36
43
|
if (name)
|
|
37
44
|
d.classList.add(name);
|
|
38
45
|
}
|
|
@@ -45,15 +52,15 @@ export const ThemeProvider = ({ forcedTheme, disableTransitionOnChange = false,
|
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
54
|
if (enableColorScheme) {
|
|
48
|
-
|
|
55
|
+
var fallback = colorSchemes.includes(defaultTheme)
|
|
49
56
|
? defaultTheme
|
|
50
57
|
: "";
|
|
51
|
-
|
|
58
|
+
var colorScheme = colorSchemes.includes(resolved)
|
|
52
59
|
? resolved
|
|
53
60
|
: fallback;
|
|
54
61
|
d.style.colorScheme = colorScheme;
|
|
55
62
|
}
|
|
56
|
-
enable
|
|
63
|
+
enable === null || enable === void 0 ? void 0 : enable();
|
|
57
64
|
}, [
|
|
58
65
|
attribute,
|
|
59
66
|
attrs,
|
|
@@ -63,7 +70,7 @@ export const ThemeProvider = ({ forcedTheme, disableTransitionOnChange = false,
|
|
|
63
70
|
enableSystem,
|
|
64
71
|
value,
|
|
65
72
|
]);
|
|
66
|
-
|
|
73
|
+
var setTheme = useCallback(function (theme) {
|
|
67
74
|
setThemeState(theme);
|
|
68
75
|
// Save to storage
|
|
69
76
|
try {
|
|
@@ -73,86 +80,89 @@ export const ThemeProvider = ({ forcedTheme, disableTransitionOnChange = false,
|
|
|
73
80
|
// Unsupported
|
|
74
81
|
}
|
|
75
82
|
}, []);
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
var handleMediaQuery = useCallback(function (e) {
|
|
84
|
+
var resolved = getSystemTheme(e);
|
|
78
85
|
setResolvedTheme(resolved);
|
|
79
86
|
if (theme === "system" && enableSystem && !forcedTheme) {
|
|
80
87
|
applyTheme("system");
|
|
81
88
|
}
|
|
82
89
|
}, [theme, enableSystem, forcedTheme, applyTheme]);
|
|
83
90
|
// Always listen to System preference
|
|
84
|
-
useEffect(()
|
|
85
|
-
|
|
91
|
+
useEffect(function () {
|
|
92
|
+
var media = window.matchMedia(MEDIA);
|
|
86
93
|
// Intentionally use deprecated listener methods to support iOS & old browsers
|
|
87
94
|
media.addListener(handleMediaQuery);
|
|
88
95
|
handleMediaQuery(media);
|
|
89
|
-
return ()
|
|
96
|
+
return function () { return media.removeListener(handleMediaQuery); };
|
|
90
97
|
}, [handleMediaQuery]);
|
|
91
98
|
// localStorage event handling
|
|
92
|
-
useEffect(()
|
|
93
|
-
|
|
99
|
+
useEffect(function () {
|
|
100
|
+
var handleStorage = function (e) {
|
|
94
101
|
if (e.key !== THEME_STORAGE_KEY) {
|
|
95
102
|
return;
|
|
96
103
|
}
|
|
97
104
|
// If default theme set, use it if localstorage === null (happens on local storage manual deletion)
|
|
98
|
-
|
|
105
|
+
var theme = e.newValue || defaultTheme;
|
|
99
106
|
setTheme(theme);
|
|
100
107
|
};
|
|
101
108
|
window.addEventListener("storage", handleStorage);
|
|
102
|
-
return ()
|
|
109
|
+
return function () { return window.removeEventListener("storage", handleStorage); };
|
|
103
110
|
}, [defaultTheme, setTheme]);
|
|
104
111
|
// Whenever theme or forcedTheme changes, apply it
|
|
105
|
-
useEffect(()
|
|
106
|
-
applyTheme(forcedTheme
|
|
112
|
+
useEffect(function () {
|
|
113
|
+
applyTheme(forcedTheme !== null && forcedTheme !== void 0 ? forcedTheme : theme);
|
|
107
114
|
}, [applyTheme, forcedTheme, theme]);
|
|
108
|
-
return (_jsxs(ThemeContext.Provider, { value: {
|
|
109
|
-
theme,
|
|
110
|
-
setTheme,
|
|
111
|
-
forcedTheme,
|
|
115
|
+
return (_jsxs(ThemeContext.Provider, __assign({ value: {
|
|
116
|
+
theme: theme,
|
|
117
|
+
setTheme: setTheme,
|
|
118
|
+
forcedTheme: forcedTheme,
|
|
112
119
|
resolvedTheme: theme === "system" ? resolvedTheme : theme,
|
|
113
|
-
themes: enableSystem ? [
|
|
120
|
+
themes: enableSystem ? __spreadArray(__spreadArray([], themes, true), ["system"], false) : themes,
|
|
114
121
|
systemTheme: (enableSystem ? resolvedTheme : undefined),
|
|
115
|
-
}, children: [_jsx(ThemeScript, {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
} }, { children: [_jsx(ThemeScript, __assign({}, {
|
|
123
|
+
forcedTheme: forcedTheme,
|
|
124
|
+
disableTransitionOnChange: disableTransitionOnChange,
|
|
125
|
+
enableSystem: enableSystem,
|
|
126
|
+
enableColorScheme: enableColorScheme,
|
|
127
|
+
themes: themes,
|
|
128
|
+
defaultTheme: defaultTheme,
|
|
129
|
+
attribute: attribute,
|
|
130
|
+
value: value,
|
|
131
|
+
children: children,
|
|
132
|
+
attrs: attrs,
|
|
133
|
+
nonce: nonce,
|
|
134
|
+
})), children] })));
|
|
128
135
|
};
|
|
129
|
-
|
|
130
|
-
|
|
136
|
+
var ThemeScript = memo(function (_a) {
|
|
137
|
+
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;
|
|
138
|
+
var defaultSystem = defaultTheme === "system";
|
|
131
139
|
// Code-golfing the amount of characters in the script
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
.map((t)
|
|
135
|
-
.join(",")
|
|
136
|
-
return
|
|
140
|
+
var optimization = (function () {
|
|
141
|
+
var removeClasses = "d.remove(".concat(attrs
|
|
142
|
+
.map(function (t) { return "'".concat(t, "'"); })
|
|
143
|
+
.join(","), ")");
|
|
144
|
+
return "var d=document.documentElement.classList;".concat(removeClasses, ";");
|
|
137
145
|
})();
|
|
138
|
-
|
|
146
|
+
var fallbackColorScheme = (function () {
|
|
139
147
|
if (!enableColorScheme) {
|
|
140
148
|
return "";
|
|
141
149
|
}
|
|
142
|
-
|
|
150
|
+
var fallback = colorSchemes.includes(defaultTheme)
|
|
143
151
|
? defaultTheme
|
|
144
152
|
: null;
|
|
145
153
|
if (fallback) {
|
|
146
|
-
return
|
|
154
|
+
return "if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'".concat(defaultTheme, "'");
|
|
147
155
|
}
|
|
148
156
|
else {
|
|
149
|
-
return
|
|
157
|
+
return "if(e==='light'||e==='dark')d.style.colorScheme=e";
|
|
150
158
|
}
|
|
151
159
|
})();
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
160
|
+
var updateDOM = function (name, literal, setColorScheme) {
|
|
161
|
+
if (literal === void 0) { literal = false; }
|
|
162
|
+
if (setColorScheme === void 0) { setColorScheme = true; }
|
|
163
|
+
var resolvedName = value ? value[name] : name;
|
|
164
|
+
var val = literal ? name + "|| ''" : "'".concat(resolvedName, "'");
|
|
165
|
+
var text = "";
|
|
156
166
|
// MUCH faster to set colorScheme alongside HTML attribute/class
|
|
157
167
|
// as it only incurs 1 style recalculation rather than 2
|
|
158
168
|
// This can save over 250ms of work for pages with big DOM
|
|
@@ -160,48 +170,48 @@ const ThemeScript = memo(({ forcedTheme, attribute, enableSystem, enableColorSch
|
|
|
160
170
|
setColorScheme &&
|
|
161
171
|
!literal &&
|
|
162
172
|
colorSchemes.includes(name)) {
|
|
163
|
-
text +=
|
|
173
|
+
text += "d.style.colorScheme = '".concat(name, "';");
|
|
164
174
|
}
|
|
165
175
|
if (attribute === "class") {
|
|
166
176
|
if (literal || resolvedName) {
|
|
167
|
-
text +=
|
|
177
|
+
text += "d.add(".concat(val, ")");
|
|
168
178
|
}
|
|
169
179
|
else {
|
|
170
|
-
text +=
|
|
180
|
+
text += "null";
|
|
171
181
|
}
|
|
172
182
|
}
|
|
173
183
|
else {
|
|
174
184
|
if (resolvedName) {
|
|
175
|
-
text +=
|
|
185
|
+
text += "d[s](n, ".concat(val, ")");
|
|
176
186
|
}
|
|
177
187
|
}
|
|
178
188
|
return text;
|
|
179
189
|
};
|
|
180
|
-
|
|
190
|
+
var scriptSrc = (function () {
|
|
181
191
|
if (forcedTheme) {
|
|
182
|
-
return
|
|
192
|
+
return "!function(){".concat(optimization).concat(updateDOM(forcedTheme), "}()");
|
|
183
193
|
}
|
|
184
194
|
if (enableSystem) {
|
|
185
|
-
return
|
|
186
|
-
?
|
|
187
|
-
: ""
|
|
195
|
+
return "!function(){try {".concat(optimization, "var e=localStorage.getItem('").concat(THEME_STORAGE_KEY, "');if(\"system\"===e||(!e&&").concat(defaultSystem, ")){var t=\"").concat(MEDIA, "\",m=window.matchMedia(t);if(m.media!==t||m.matches){").concat(updateDOM("dark"), "}else{").concat(updateDOM("light"), "}}else if(e){").concat(value ? "var x=".concat(JSON.stringify(value), ";") : "").concat(updateDOM(value ? "x[e]" : "e", true), "}").concat(!defaultSystem
|
|
196
|
+
? "else{" + updateDOM(defaultTheme, false, false) + "}"
|
|
197
|
+
: "").concat(fallbackColorScheme, "}catch(e){}}()");
|
|
188
198
|
}
|
|
189
|
-
return
|
|
199
|
+
return "!function(){try{".concat(optimization, "var e=localStorage.getItem(\"").concat(THEME_STORAGE_KEY, "\");if(e){").concat(value ? "var x=".concat(JSON.stringify(value), ";") : "").concat(updateDOM(value ? "x[e]" : "e", true), "}else{").concat(updateDOM(defaultTheme, false, false), ";}").concat(fallbackColorScheme, "}catch(t){}}();");
|
|
190
200
|
})();
|
|
191
201
|
// We MUST use next/script's `beforeInteractive` strategy to avoid flashing on load.
|
|
192
202
|
// However, it only accepts the `src` prop, not `dangerouslySetInnerHTML` or `children`
|
|
193
203
|
// But our script cannot be external because it changes at runtime based on React props
|
|
194
204
|
// so we trick next/script by passing `src` as a base64 JS script
|
|
195
|
-
|
|
205
|
+
var encodedScript = "data:text/javascript;base64,".concat(encodeBase64(scriptSrc));
|
|
196
206
|
return (_jsx(NextScript, { id: "next-theme-script", strategy: "beforeInteractive", src: encodedScript, nonce: nonce }));
|
|
197
207
|
},
|
|
198
208
|
// Never re-render this component
|
|
199
|
-
()
|
|
209
|
+
function () { return true; });
|
|
200
210
|
// Helpers
|
|
201
|
-
|
|
211
|
+
var getTheme = function (key, fallback) {
|
|
202
212
|
if (isServer)
|
|
203
213
|
return undefined;
|
|
204
|
-
|
|
214
|
+
var theme;
|
|
205
215
|
try {
|
|
206
216
|
theme = localStorage.getItem(key) || undefined;
|
|
207
217
|
}
|
|
@@ -210,26 +220,26 @@ const getTheme = (key, fallback) => {
|
|
|
210
220
|
}
|
|
211
221
|
return theme || fallback;
|
|
212
222
|
};
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
css.appendChild(document.createTextNode(
|
|
223
|
+
var disableAnimation = function () {
|
|
224
|
+
var css = document.createElement("style");
|
|
225
|
+
css.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"));
|
|
216
226
|
document.head.appendChild(css);
|
|
217
|
-
return ()
|
|
227
|
+
return function () {
|
|
218
228
|
// Force restyle
|
|
219
|
-
(()
|
|
229
|
+
(function () { return window.getComputedStyle(document.body); })();
|
|
220
230
|
// Wait for next tick before removing
|
|
221
|
-
setTimeout(()
|
|
231
|
+
setTimeout(function () {
|
|
222
232
|
document.head.removeChild(css);
|
|
223
233
|
}, 1);
|
|
224
234
|
};
|
|
225
235
|
};
|
|
226
|
-
|
|
236
|
+
var getSystemTheme = function (e) {
|
|
227
237
|
if (!e)
|
|
228
238
|
e = window.matchMedia(MEDIA);
|
|
229
|
-
|
|
230
|
-
|
|
239
|
+
var isDark = e.matches;
|
|
240
|
+
var systemTheme = isDark ? "dark" : "light";
|
|
231
241
|
return systemTheme;
|
|
232
242
|
};
|
|
233
|
-
|
|
243
|
+
var encodeBase64 = function (str) {
|
|
234
244
|
return isServer ? Buffer.from(str).toString("base64") : btoa(str);
|
|
235
245
|
};
|
package/app/AppHead.js
CHANGED
package/app/css/AppMain.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { SeoDefaults } from "../../Seo";
|
|
@@ -6,6 +7,7 @@ import { SeoDefaults } from "../../Seo";
|
|
|
6
7
|
*
|
|
7
8
|
* It does not imply any specific styling or animation solution
|
|
8
9
|
*/
|
|
9
|
-
export
|
|
10
|
-
|
|
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] }));
|
|
11
13
|
};
|
package/app/css/AppTheme.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
// import { ThemeVanillaProvider, ThemeVanillaValue } from "@koine/react";
|
|
3
4
|
import { ThemeProvider } from "../../Theme";
|
|
4
5
|
/**
|
|
5
6
|
* App theme with vanilla class based theme (good for `tailwindcss`)
|
|
6
7
|
*/
|
|
7
|
-
export
|
|
8
|
+
export var AppTheme = function (_a) {
|
|
9
|
+
var theme = _a.theme, children = _a.children;
|
|
8
10
|
// return (
|
|
9
11
|
// <ThemeVanillaProvider initialTheme={theme}>{children}</ThemeVanillaProvider>
|
|
10
12
|
// );
|
|
11
|
-
return (_jsx(ThemeProvider, { defaultTheme: theme, attribute: "class", children: children }));
|
|
13
|
+
return (_jsx(ThemeProvider, __assign({ defaultTheme: theme, attribute: "class" }, { children: children })));
|
|
12
14
|
};
|
package/app/css/auth/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { SessionProvider } from "next-auth/react";
|
|
@@ -7,7 +8,7 @@ import { AppMain } from "../AppMain";
|
|
|
7
8
|
/**
|
|
8
9
|
* App with authentication provided by `next-auth`
|
|
9
10
|
*/
|
|
10
|
-
export
|
|
11
|
-
return (_jsxs(React.StrictMode, { children: [_jsx(AppHead, {}), _jsx(SessionProvider, { session: props.pageProps.session, children: _jsx(AppTheme, {
|
|
11
|
+
export var NextApp = function (props) {
|
|
12
|
+
return (_jsxs(React.StrictMode, { children: [_jsx(AppHead, {}), _jsx(SessionProvider, __assign({ session: props.pageProps.session }, { children: _jsx(AppTheme, __assign({}, props, { children: _jsx(AppMain, __assign({}, props)) })) }))] }));
|
|
12
13
|
};
|
|
13
14
|
export default NextApp;
|
package/app/css/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { AppHead } from "../AppHead";
|
|
@@ -51,7 +52,7 @@ import { AppMain } from "./AppMain";
|
|
|
51
52
|
*
|
|
52
53
|
* ```
|
|
53
54
|
*/
|
|
54
|
-
export
|
|
55
|
-
return (_jsxs(React.StrictMode, { children: [_jsx(AppHead, {}), _jsx(AppTheme, {
|
|
55
|
+
export var NextApp = function (props) {
|
|
56
|
+
return (_jsxs(React.StrictMode, { children: [_jsx(AppHead, {}), _jsx(AppTheme, __assign({}, props, { children: _jsx(AppMain, __assign({}, props)) }))] }));
|
|
56
57
|
};
|
|
57
58
|
export default NextApp;
|
package/app/em/AppMain.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { createElement as _createElement } from "react";
|
|
2
3
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
4
|
import { useRouter } from "next/router";
|
|
@@ -12,11 +13,12 @@ import { NextProgress } from "../../NextProgress";
|
|
|
12
13
|
*
|
|
13
14
|
* About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
|
|
14
15
|
*/
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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] }));
|
|
22
24
|
};
|
package/app/em/AppTheme.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign, __makeTemplateObject } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { ThemeProvider } from "@mui/material/styles";
|
|
3
4
|
import { CacheProvider } from "@emotion/react";
|
|
@@ -6,12 +7,12 @@ import { Global, css } from "@emotion/react";
|
|
|
6
7
|
import { stylesGlobal } from "@koine/react/sc";
|
|
7
8
|
import { createEmotionCache } from "../../utils/emotion-cache";
|
|
8
9
|
// client-side cache, shared for the whole session of the user in the browser.
|
|
9
|
-
|
|
10
|
+
var clientSideEmotionCache = createEmotionCache();
|
|
10
11
|
/**
|
|
11
12
|
* App theme with `emotion` (good for `@mui`)s
|
|
12
13
|
*/
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
` }), children] }) }));
|
|
14
|
+
export var AppTheme = function (_a) {
|
|
15
|
+
var _b = _a.emotionCache, emotionCache = _b === void 0 ? clientSideEmotionCache : _b, theme = _a.theme, children = _a.children;
|
|
16
|
+
return (_jsx(CacheProvider, __assign({ value: emotionCache }, { children: _jsxs(ThemeProvider, __assign({ theme: theme }, { children: [_jsx(CssBaseline, {}), _jsx(Global, { styles: css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), stylesGlobal) }), children] })) })));
|
|
17
17
|
};
|
|
18
|
+
var templateObject_1;
|
package/app/em/auth/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { SessionProvider } from "next-auth/react";
|
|
@@ -7,7 +8,7 @@ import { AppMain } from "../AppMain";
|
|
|
7
8
|
/**
|
|
8
9
|
* App with authentication provided by `next-auth`
|
|
9
10
|
*/
|
|
10
|
-
export
|
|
11
|
-
return (_jsxs(React.StrictMode, { children: [_jsx(AppHead, {}), _jsx(SessionProvider, { session: props.pageProps.session, children: _jsx(AppTheme, {
|
|
11
|
+
export var NextApp = function (props) {
|
|
12
|
+
return (_jsxs(React.StrictMode, { children: [_jsx(AppHead, {}), _jsx(SessionProvider, __assign({ session: props.pageProps.session }, { children: _jsx(AppTheme, __assign({}, props, { children: _jsx(AppMain, __assign({}, props)) })) }))] }));
|
|
12
13
|
};
|
|
13
14
|
export default NextApp;
|
package/app/em/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { AppHead } from "../AppHead";
|
|
@@ -6,7 +7,7 @@ import { AppMain } from "./AppMain";
|
|
|
6
7
|
/**
|
|
7
8
|
* App
|
|
8
9
|
*/
|
|
9
|
-
export
|
|
10
|
-
return (_jsxs(React.StrictMode, { children: [_jsx(AppHead, {}), _jsx(AppTheme, {
|
|
10
|
+
export var NextApp = function (props) {
|
|
11
|
+
return (_jsxs(React.StrictMode, { children: [_jsx(AppHead, {}), _jsx(AppTheme, __assign({}, props, { children: _jsx(AppMain, __assign({}, props)) }))] }));
|
|
11
12
|
};
|
|
12
13
|
export default NextApp;
|
package/app/sc/AppMain.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { createElement as _createElement } from "react";
|
|
2
3
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
4
|
import { useRouter } from "next/router";
|
|
@@ -12,11 +13,12 @@ import { NextProgress } from "../../NextProgress";
|
|
|
12
13
|
*
|
|
13
14
|
* About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
|
|
14
15
|
*/
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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] }));
|
|
22
24
|
};
|