@koine/next 2.0.0-alpha.1 → 2.0.0-alpha.3
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.d.ts → 12/AnalyticsGoogle.d.ts} +1 -1
- package/{AnalyticsGoogle.js → 12/AnalyticsGoogle.js} +1 -1
- package/{legacy → 12}/AnalyticsGoogle.mjs +1 -2
- package/{legacy → 12}/DisableErrorOverlay.d.ts +1 -1
- package/{Favicon.d.ts → 12/Favicon.d.ts} +1 -1
- package/{legacy → 12}/Link.js +1 -1
- package/{legacy → 12}/Link.mjs +1 -1
- package/{NextProgress.d.ts → 12/NextProgress.d.ts} +1 -1
- package/{legacy → 12}/Seo.d.ts +1 -1
- package/{SeoDefaults.d.ts → 12/SeoDefaults.d.ts} +1 -1
- package/{T.d.ts → 12/T.d.ts} +1 -0
- package/{legacy → 12}/ThemeProvider.d.ts +1 -1
- package/{ThemeProvider.js → 12/ThemeProvider.js} +2 -14
- package/{ThemeProvider.mjs → 12/ThemeProvider.mjs} +3 -15
- package/12/app/AppHead.d.ts +3 -0
- package/{legacy → 12}/app/css/AppMain.d.ts +1 -1
- package/{legacy → 12}/app/css/AppTheme.d.ts +1 -1
- package/{app → 12/app}/css/AppTheme.js +1 -2
- package/{app → 12/app}/css/AppTheme.mjs +1 -2
- package/{legacy/app/sc → 12/app/css}/auth/index.d.ts +1 -1
- package/{app → 12/app}/css/auth/index.js +1 -1
- package/{app → 12/app}/css/auth/index.mjs +1 -1
- package/{app → 12/app}/css/index.d.ts +1 -1
- package/{legacy → 12}/app/sc/AppMain.d.ts +1 -1
- package/{legacy → 12}/app/sc/AppMain.js +1 -1
- package/{app → 12/app}/sc/AppMain.mjs +1 -1
- package/{legacy → 12}/app/sc/AppTheme.d.ts +1 -1
- package/{app → 12/app}/sc/AppTheme.js +1 -2
- package/{app → 12/app}/sc/AppTheme.mjs +1 -2
- package/{legacy/app/css → 12/app/sc}/auth/index.d.ts +1 -1
- package/{app/em → 12/app/sc}/auth/index.js +1 -1
- package/{legacy/app/css → 12/app/sc}/auth/index.mjs +1 -1
- package/{legacy → 12}/app/sc/index.d.ts +1 -1
- package/{document → 12/document}/Document.d.ts +1 -2
- package/{legacy → 12}/document/Document.js +1 -1
- package/{legacy → 12}/document/Document.mjs +2 -2
- package/{legacy → 12}/document/css/index.d.ts +1 -2
- package/{document → 12/document}/css/index.js +1 -1
- package/{legacy → 12}/document/css/index.mjs +2 -2
- package/{legacy → 12}/document/sc/index.d.ts +1 -2
- package/{legacy → 12}/document/sc/index.js +1 -1
- package/{legacy → 12}/document/sc/index.mjs +1 -1
- package/{legacy → 12}/types-i18n.d.ts +1 -1
- package/{legacy → 12}/useForm.d.ts +1 -1
- package/12/useT.d.ts +4 -0
- package/{useT.js → 12/useT.js} +20 -16
- package/{legacy → 12}/useT.mjs +7 -5
- package/package.json +13 -24
- package/AnalyticsGoogle.mjs +0 -35
- package/DisableErrorOverlay.d.ts +0 -7
- package/Head.d.ts +0 -3
- package/Head.js +0 -7
- package/Head.mjs +0 -3
- package/Link.js +0 -15
- package/Link.mjs +0 -12
- package/Seo.d.ts +0 -41
- package/ThemeProvider.d.ts +0 -35
- package/app/AppHead.d.ts +0 -3
- package/app/css/AppMain.d.ts +0 -9
- package/app/css/AppTheme.d.ts +0 -11
- package/app/css/auth/index.d.ts +0 -11
- package/app/em/AppMain.d.ts +0 -11
- package/app/em/AppMain.js +0 -29
- package/app/em/AppMain.mjs +0 -25
- package/app/em/AppTheme.d.ts +0 -16
- package/app/em/AppTheme.js +0 -23
- package/app/em/AppTheme.mjs +0 -19
- package/app/em/auth/index.d.ts +0 -11
- package/app/em/auth/index.mjs +0 -13
- package/app/em/index.d.ts +0 -9
- package/app/em/index.js +0 -16
- package/app/em/index.mjs +0 -12
- package/app/sc/AppMain.d.ts +0 -11
- package/app/sc/AppMain.js +0 -29
- package/app/sc/AppTheme.d.ts +0 -14
- package/app/sc/auth/index.d.ts +0 -11
- package/app/sc/auth/index.js +0 -17
- package/app/sc/auth/index.mjs +0 -13
- package/app/sc/index.d.ts +0 -56
- package/auth/helpers.d.ts +0 -17
- package/auth/helpers.js +0 -28
- package/auth/helpers.mjs +0 -22
- package/auth/index.d.ts +0 -4
- package/auth/index.js +0 -7
- package/auth/index.mjs +0 -4
- package/auth/useLogin.d.ts +0 -8
- package/auth/useLogin.js +0 -54
- package/auth/useLogin.mjs +0 -50
- package/auth/useLoginUrl.d.ts +0 -2
- package/auth/useLoginUrl.js +0 -17
- package/auth/useLoginUrl.mjs +0 -13
- package/auth/useLogout.d.ts +0 -7
- package/auth/useLogout.js +0 -59
- package/auth/useLogout.mjs +0 -54
- package/createEmotionCache.d.ts +0 -6
- package/createEmotionCache.js +0 -14
- package/createEmotionCache.mjs +0 -9
- package/document/Document.js +0 -31
- package/document/Document.mjs +0 -28
- package/document/css/index.d.ts +0 -18
- package/document/css/index.mjs +0 -45
- package/document/em/index.d.ts +0 -16
- package/document/em/index.js +0 -63
- package/document/em/index.mjs +0 -60
- package/document/em/package.json +0 -6
- package/document/package.json +0 -6
- package/document/sc/index.d.ts +0 -20
- package/document/sc/index.js +0 -67
- package/document/sc/index.mjs +0 -64
- package/document/sc/package.json +0 -6
- package/legacy/AnalyticsGoogle.d.ts +0 -6
- package/legacy/AnalyticsGoogle.js +0 -39
- package/legacy/DisableErrorOverlay.js +0 -18
- package/legacy/DisableErrorOverlay.mjs +0 -13
- package/legacy/DynamicNamespaces.d.ts +0 -13
- package/legacy/DynamicNamespaces.js +0 -13
- package/legacy/DynamicNamespaces.mjs +0 -9
- package/legacy/Favicon.d.ts +0 -4
- package/legacy/Favicon.js +0 -10
- package/legacy/Favicon.mjs +0 -6
- package/legacy/Link.d.ts +0 -10
- package/legacy/NextProgress.d.ts +0 -25
- package/legacy/NextProgress.js +0 -46
- package/legacy/NextProgress.mjs +0 -42
- package/legacy/Seo.js +0 -34
- package/legacy/Seo.mjs +0 -29
- package/legacy/SeoDefaults.d.ts +0 -11
- package/legacy/SeoDefaults.js +0 -17
- package/legacy/SeoDefaults.mjs +0 -12
- package/legacy/T.d.ts +0 -15
- package/legacy/T.js +0 -17
- package/legacy/T.mjs +0 -13
- package/legacy/ThemeContext.d.ts +0 -17
- package/legacy/ThemeContext.js +0 -10
- package/legacy/ThemeContext.mjs +0 -7
- package/legacy/ThemeProvider.js +0 -251
- package/legacy/ThemeProvider.mjs +0 -247
- package/legacy/TransText.d.ts +0 -3
- package/legacy/TransText.js +0 -8
- package/legacy/TransText.mjs +0 -4
- package/legacy/app/AppHead.d.ts +0 -3
- package/legacy/app/AppHead.js +0 -11
- package/legacy/app/AppHead.mjs +0 -6
- package/legacy/app/AppMain.d.ts +0 -35
- package/legacy/app/AppMain.js +0 -2
- package/legacy/app/AppMain.mjs +0 -1
- package/legacy/app/css/AppMain.js +0 -18
- package/legacy/app/css/AppMain.mjs +0 -14
- package/legacy/app/css/AppTheme.js +0 -19
- package/legacy/app/css/AppTheme.mjs +0 -15
- package/legacy/app/css/auth/index.js +0 -17
- package/legacy/app/css/auth/package.json +0 -6
- package/legacy/app/css/index.d.ts +0 -54
- package/legacy/app/css/index.js +0 -61
- package/legacy/app/css/index.mjs +0 -57
- package/legacy/app/css/package.json +0 -6
- package/legacy/app/index.d.ts +0 -2
- package/legacy/app/index.js +0 -5
- package/legacy/app/index.mjs +0 -2
- package/legacy/app/package.json +0 -6
- package/legacy/app/sc/AppMain.mjs +0 -25
- package/legacy/app/sc/AppTheme.js +0 -16
- package/legacy/app/sc/AppTheme.mjs +0 -12
- package/legacy/app/sc/auth/index.js +0 -17
- package/legacy/app/sc/auth/index.mjs +0 -13
- package/legacy/app/sc/auth/package.json +0 -6
- package/legacy/app/sc/index.js +0 -63
- package/legacy/app/sc/index.mjs +0 -59
- package/legacy/app/sc/package.json +0 -6
- package/legacy/document/Document.d.ts +0 -16
- package/legacy/document/css/index.js +0 -45
- package/legacy/document/css/package.json +0 -6
- package/legacy/document/index.d.ts +0 -2
- package/legacy/document/index.js +0 -7
- package/legacy/document/index.mjs +0 -2
- package/legacy/document/package.json +0 -6
- package/legacy/document/sc/package.json +0 -6
- package/legacy/getT.d.ts +0 -9
- package/legacy/getT.js +0 -14
- package/legacy/getT.mjs +0 -10
- package/legacy/package.json +0 -6
- package/legacy/useT.d.ts +0 -17
- package/legacy/useT.js +0 -40
- package/revalidate.d.ts +0 -5
- package/revalidate.js +0 -8
- package/revalidate.mjs +0 -5
- package/seoBuildTags.d.ts +0 -23
- package/seoBuildTags.js +0 -121
- package/seoBuildTags.mjs +0 -117
- package/to.d.ts +0 -24
- package/to.js +0 -29
- package/to.mjs +0 -25
- package/translationAsOptions.d.ts +0 -3
- package/translationAsOptions.js +0 -13
- package/translationAsOptions.mjs +0 -9
- package/types-i18n.d.ts +0 -118
- package/types-i18n.js +0 -14
- package/types-i18n.mjs +0 -13
- package/types-seo.d.ts +0 -7
- package/types-seo.js +0 -2
- package/types-seo.mjs +0 -1
- package/useBackUrl.d.ts +0 -2
- package/useBackUrl.js +0 -33
- package/useBackUrl.mjs +0 -28
- package/useDateFormat.d.ts +0 -7
- package/useDateFormat.js +0 -43
- package/useDateFormat.mjs +0 -39
- package/useForm.d.ts +0 -27
- package/useForm.js +0 -39
- package/useForm.mjs +0 -35
- package/useLocale.d.ts +0 -2
- package/useLocale.js +0 -11
- package/useLocale.mjs +0 -6
- package/useT.d.ts +0 -17
- package/useT.mjs +0 -19
- package/useTheme.d.ts +0 -7
- package/useTheme.js +0 -12
- package/useTheme.mjs +0 -8
- package/useTo.d.ts +0 -3
- package/useTo.js +0 -19
- package/useTo.mjs +0 -15
- /package/{DisableErrorOverlay.js → 12/DisableErrorOverlay.js} +0 -0
- /package/{DisableErrorOverlay.mjs → 12/DisableErrorOverlay.mjs} +0 -0
- /package/{DynamicNamespaces.d.ts → 12/DynamicNamespaces.d.ts} +0 -0
- /package/{DynamicNamespaces.js → 12/DynamicNamespaces.js} +0 -0
- /package/{DynamicNamespaces.mjs → 12/DynamicNamespaces.mjs} +0 -0
- /package/{Favicon.js → 12/Favicon.js} +0 -0
- /package/{Favicon.mjs → 12/Favicon.mjs} +0 -0
- /package/{Link.d.ts → 12/Link.d.ts} +0 -0
- /package/{NextProgress.js → 12/NextProgress.js} +0 -0
- /package/{NextProgress.mjs → 12/NextProgress.mjs} +0 -0
- /package/{Seo.js → 12/Seo.js} +0 -0
- /package/{Seo.mjs → 12/Seo.mjs} +0 -0
- /package/{SeoDefaults.js → 12/SeoDefaults.js} +0 -0
- /package/{SeoDefaults.mjs → 12/SeoDefaults.mjs} +0 -0
- /package/{T.js → 12/T.js} +0 -0
- /package/{T.mjs → 12/T.mjs} +0 -0
- /package/{ThemeContext.d.ts → 12/ThemeContext.d.ts} +0 -0
- /package/{ThemeContext.js → 12/ThemeContext.js} +0 -0
- /package/{ThemeContext.mjs → 12/ThemeContext.mjs} +0 -0
- /package/{TransText.d.ts → 12/TransText.d.ts} +0 -0
- /package/{TransText.js → 12/TransText.js} +0 -0
- /package/{TransText.mjs → 12/TransText.mjs} +0 -0
- /package/{app → 12/app}/AppHead.js +0 -0
- /package/{app → 12/app}/AppHead.mjs +0 -0
- /package/{app → 12/app}/AppMain.d.ts +0 -0
- /package/{app → 12/app}/AppMain.js +0 -0
- /package/{app → 12/app}/AppMain.mjs +0 -0
- /package/{app → 12/app}/css/AppMain.js +0 -0
- /package/{app → 12/app}/css/AppMain.mjs +0 -0
- /package/{app → 12/app}/css/auth/package.json +0 -0
- /package/{app → 12/app}/css/index.js +0 -0
- /package/{app → 12/app}/css/index.mjs +0 -0
- /package/{app → 12/app}/css/package.json +0 -0
- /package/{app → 12/app}/index.d.ts +0 -0
- /package/{app → 12/app}/index.js +0 -0
- /package/{app → 12/app}/index.mjs +0 -0
- /package/{app/em/auth → 12/app}/package.json +0 -0
- /package/{app/em → 12/app/sc/auth}/package.json +0 -0
- /package/{app → 12/app}/sc/index.js +0 -0
- /package/{app → 12/app}/sc/index.mjs +0 -0
- /package/{app → 12/app/sc}/package.json +0 -0
- /package/{app/sc/auth → 12/document/css}/package.json +0 -0
- /package/{document → 12/document}/index.d.ts +0 -0
- /package/{document → 12/document}/index.js +0 -0
- /package/{document → 12/document}/index.mjs +0 -0
- /package/{app/sc → 12/document}/package.json +0 -0
- /package/{auth → 12/document/sc}/package.json +0 -0
- /package/{getT.d.ts → 12/getT.d.ts} +0 -0
- /package/{getT.js → 12/getT.js} +0 -0
- /package/{getT.mjs → 12/getT.mjs} +0 -0
- /package/{legacy → 12}/index.d.ts +0 -0
- /package/{legacy → 12}/index.js +0 -0
- /package/{legacy → 12}/index.mjs +0 -0
- /package/{document/css → 12}/package.json +0 -0
- /package/{legacy → 12}/seoBuildTags.d.ts +0 -0
- /package/{legacy → 12}/seoBuildTags.js +0 -0
- /package/{legacy → 12}/seoBuildTags.mjs +0 -0
- /package/{legacy → 12}/to.d.ts +0 -0
- /package/{legacy → 12}/to.js +0 -0
- /package/{legacy → 12}/to.mjs +0 -0
- /package/{legacy → 12}/translationAsOptions.d.ts +0 -0
- /package/{legacy → 12}/translationAsOptions.js +0 -0
- /package/{legacy → 12}/translationAsOptions.mjs +0 -0
- /package/{legacy → 12}/types-i18n.js +0 -0
- /package/{legacy → 12}/types-i18n.mjs +0 -0
- /package/{legacy → 12}/types-seo.d.ts +0 -0
- /package/{legacy → 12}/types-seo.js +0 -0
- /package/{legacy → 12}/types-seo.mjs +0 -0
- /package/{legacy → 12}/useBackUrl.d.ts +0 -0
- /package/{legacy → 12}/useBackUrl.js +0 -0
- /package/{legacy → 12}/useBackUrl.mjs +0 -0
- /package/{legacy → 12}/useDateFormat.d.ts +0 -0
- /package/{legacy → 12}/useDateFormat.js +0 -0
- /package/{legacy → 12}/useDateFormat.mjs +0 -0
- /package/{legacy → 12}/useForm.js +0 -0
- /package/{legacy → 12}/useForm.mjs +0 -0
- /package/{legacy → 12}/useLocale.d.ts +0 -0
- /package/{legacy → 12}/useLocale.js +0 -0
- /package/{legacy → 12}/useLocale.mjs +0 -0
- /package/{legacy → 12}/useTheme.d.ts +0 -0
- /package/{legacy → 12}/useTheme.js +0 -0
- /package/{legacy → 12}/useTheme.mjs +0 -0
- /package/{legacy → 12}/useTo.d.ts +0 -0
- /package/{legacy → 12}/useTo.js +0 -0
- /package/{legacy → 12}/useTo.mjs +0 -0
package/legacy/T.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.T = void 0;
|
|
5
|
-
var tslib_1 = require("tslib");
|
|
6
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
var Trans_1 = tslib_1.__importDefault(require("next-translate/Trans"));
|
|
8
|
-
/**
|
|
9
|
-
* **NOTE**: To make typescript work nicely here make sure to enable
|
|
10
|
-
* [`resolveJsonModule`](https://www.typescriptlang.org/tsconfig#resolveJsonModule)
|
|
11
|
-
* in your `tsconfig.json` file.
|
|
12
|
-
*/
|
|
13
|
-
var T = function (props) {
|
|
14
|
-
return ((0, jsx_runtime_1.jsx)(Trans_1.default, tslib_1.__assign({}, props)));
|
|
15
|
-
};
|
|
16
|
-
exports.T = T;
|
|
17
|
-
exports.default = exports.T;
|
package/legacy/T.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { __assign } from "tslib";
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import Trans from "next-translate/Trans";
|
|
5
|
-
/**
|
|
6
|
-
* **NOTE**: To make typescript work nicely here make sure to enable
|
|
7
|
-
* [`resolveJsonModule`](https://www.typescriptlang.org/tsconfig#resolveJsonModule)
|
|
8
|
-
* in your `tsconfig.json` file.
|
|
9
|
-
*/
|
|
10
|
-
export var T = function (props) {
|
|
11
|
-
return (_jsx(Trans, __assign({}, props)));
|
|
12
|
-
};
|
|
13
|
-
export default T;
|
package/legacy/ThemeContext.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export type ThemeContextProps = {
|
|
3
|
-
/** List of all available theme names */
|
|
4
|
-
themes: string[];
|
|
5
|
-
/** Forced theme name for the current page */
|
|
6
|
-
forcedTheme?: string;
|
|
7
|
-
/** Update the theme */
|
|
8
|
-
setTheme: (theme: string) => void;
|
|
9
|
-
/** Active theme name */
|
|
10
|
-
theme?: string;
|
|
11
|
-
/** If `enableSystem` is true and the active theme is "system", this returns whether the system preference resolved to "dark" or "light". Otherwise, identical to `theme` */
|
|
12
|
-
resolvedTheme?: string;
|
|
13
|
-
/** If enableSystem is true, returns the System theme preference ("dark" or "light"), regardless what the active theme is */
|
|
14
|
-
systemTheme?: "dark" | "light";
|
|
15
|
-
};
|
|
16
|
-
export declare const ThemeContext: import("react").Context<ThemeContextProps>;
|
|
17
|
-
export default ThemeContext;
|
package/legacy/ThemeContext.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ThemeContext = void 0;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
exports.ThemeContext = (0, react_1.createContext)({
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
7
|
-
setTheme: function (_) { },
|
|
8
|
-
themes: [],
|
|
9
|
-
});
|
|
10
|
-
exports.default = exports.ThemeContext;
|
package/legacy/ThemeContext.mjs
DELETED
package/legacy/ThemeProvider.js
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ThemeProvider = void 0;
|
|
5
|
-
var tslib_1 = require("tslib");
|
|
6
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
var react_1 = require("react");
|
|
8
|
-
var script_1 = tslib_1.__importDefault(require("next/script"));
|
|
9
|
-
var isServer_1 = tslib_1.__importDefault(require("@koine/utils/isServer"));
|
|
10
|
-
var ThemeContext_1 = require("./ThemeContext");
|
|
11
|
-
var colorSchemes = ["light", "dark"];
|
|
12
|
-
var MEDIA = "(prefers-color-scheme: dark)";
|
|
13
|
-
var THEME_STORAGE_KEY = "theme";
|
|
14
|
-
/**
|
|
15
|
-
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
16
|
-
*
|
|
17
|
-
* Differences:
|
|
18
|
-
*
|
|
19
|
-
* - enableColorScheme: `false` by default (instead of `true`), this plays more
|
|
20
|
-
* nicely with tailwind `dark` class mode as dark theme is supposed to be only
|
|
21
|
-
* controlled by tailwind modifiers
|
|
22
|
-
*/
|
|
23
|
-
var ThemeProvider = function (_a) {
|
|
24
|
-
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;
|
|
25
|
-
var _g = (0, react_1.useState)(function () {
|
|
26
|
-
return getTheme(THEME_STORAGE_KEY, defaultTheme);
|
|
27
|
-
}), theme = _g[0], setThemeState = _g[1];
|
|
28
|
-
var _h = (0, react_1.useState)(function () {
|
|
29
|
-
return getTheme(THEME_STORAGE_KEY);
|
|
30
|
-
}), resolvedTheme = _h[0], setResolvedTheme = _h[1];
|
|
31
|
-
var attrs = !value ? themes : Object.values(value);
|
|
32
|
-
var applyTheme = (0, react_1.useCallback)(function (theme) {
|
|
33
|
-
var _a;
|
|
34
|
-
var resolved = theme;
|
|
35
|
-
if (isServer_1.default || !resolved)
|
|
36
|
-
return;
|
|
37
|
-
// If theme is system, resolve it before setting theme
|
|
38
|
-
if (theme === "system" && enableSystem) {
|
|
39
|
-
resolved = getSystemTheme();
|
|
40
|
-
}
|
|
41
|
-
var name = value ? value[resolved] : resolved;
|
|
42
|
-
var enable = disableTransitionOnChange ? disableAnimation() : null;
|
|
43
|
-
var d = document.documentElement;
|
|
44
|
-
if (attribute === "class") {
|
|
45
|
-
(_a = d.classList).remove.apply(_a, attrs);
|
|
46
|
-
if (name)
|
|
47
|
-
d.classList.add(name);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
if (name) {
|
|
51
|
-
d.setAttribute(attribute, name);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
d.removeAttribute(attribute);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (enableColorScheme) {
|
|
58
|
-
var fallback = colorSchemes.includes(defaultTheme)
|
|
59
|
-
? defaultTheme
|
|
60
|
-
: "";
|
|
61
|
-
var colorScheme = colorSchemes.includes(resolved)
|
|
62
|
-
? resolved
|
|
63
|
-
: fallback;
|
|
64
|
-
d.style.colorScheme = colorScheme;
|
|
65
|
-
}
|
|
66
|
-
enable === null || enable === void 0 ? void 0 : enable();
|
|
67
|
-
}, [
|
|
68
|
-
attribute,
|
|
69
|
-
attrs,
|
|
70
|
-
defaultTheme,
|
|
71
|
-
disableTransitionOnChange,
|
|
72
|
-
enableColorScheme,
|
|
73
|
-
enableSystem,
|
|
74
|
-
value,
|
|
75
|
-
]);
|
|
76
|
-
var setTheme = (0, react_1.useCallback)(function (theme) {
|
|
77
|
-
setThemeState(theme);
|
|
78
|
-
// Save to storage
|
|
79
|
-
try {
|
|
80
|
-
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
// Unsupported
|
|
84
|
-
}
|
|
85
|
-
}, []);
|
|
86
|
-
var handleMediaQuery = (0, react_1.useCallback)(function (e) {
|
|
87
|
-
var resolved = getSystemTheme(e);
|
|
88
|
-
setResolvedTheme(resolved);
|
|
89
|
-
if (theme === "system" && enableSystem && !forcedTheme) {
|
|
90
|
-
applyTheme("system");
|
|
91
|
-
}
|
|
92
|
-
}, [theme, enableSystem, forcedTheme, applyTheme]);
|
|
93
|
-
// Always listen to System preference
|
|
94
|
-
(0, react_1.useEffect)(function () {
|
|
95
|
-
var media = window.matchMedia(MEDIA);
|
|
96
|
-
// Intentionally use deprecated listener methods to support iOS & old browsers
|
|
97
|
-
media.addListener(handleMediaQuery);
|
|
98
|
-
handleMediaQuery(media);
|
|
99
|
-
return function () { return media.removeListener(handleMediaQuery); };
|
|
100
|
-
}, [handleMediaQuery]);
|
|
101
|
-
// localStorage event handling
|
|
102
|
-
(0, react_1.useEffect)(function () {
|
|
103
|
-
var handleStorage = function (e) {
|
|
104
|
-
if (e.key !== THEME_STORAGE_KEY) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
// If default theme set, use it if localstorage === null (happens on local storage manual deletion)
|
|
108
|
-
var theme = e.newValue || defaultTheme;
|
|
109
|
-
setTheme(theme);
|
|
110
|
-
};
|
|
111
|
-
window.addEventListener("storage", handleStorage);
|
|
112
|
-
return function () { return window.removeEventListener("storage", handleStorage); };
|
|
113
|
-
}, [defaultTheme, setTheme]);
|
|
114
|
-
// Whenever theme or forcedTheme changes, apply it
|
|
115
|
-
(0, react_1.useEffect)(function () {
|
|
116
|
-
applyTheme(forcedTheme !== null && forcedTheme !== void 0 ? forcedTheme : theme);
|
|
117
|
-
}, [applyTheme, forcedTheme, theme]);
|
|
118
|
-
return ((0, jsx_runtime_1.jsxs)(ThemeContext_1.ThemeContext.Provider, tslib_1.__assign({ value: {
|
|
119
|
-
theme: theme,
|
|
120
|
-
setTheme: setTheme,
|
|
121
|
-
forcedTheme: forcedTheme,
|
|
122
|
-
resolvedTheme: theme === "system" ? resolvedTheme : theme,
|
|
123
|
-
themes: enableSystem ? tslib_1.__spreadArray(tslib_1.__spreadArray([], themes, true), ["system"], false) : themes,
|
|
124
|
-
systemTheme: (enableSystem ? resolvedTheme : undefined),
|
|
125
|
-
} }, { children: [(0, jsx_runtime_1.jsx)(ThemeScript, tslib_1.__assign({}, {
|
|
126
|
-
forcedTheme: forcedTheme,
|
|
127
|
-
disableTransitionOnChange: disableTransitionOnChange,
|
|
128
|
-
enableSystem: enableSystem,
|
|
129
|
-
enableColorScheme: enableColorScheme,
|
|
130
|
-
themes: themes,
|
|
131
|
-
defaultTheme: defaultTheme,
|
|
132
|
-
attribute: attribute,
|
|
133
|
-
value: value,
|
|
134
|
-
children: children,
|
|
135
|
-
attrs: attrs,
|
|
136
|
-
nonce: nonce,
|
|
137
|
-
})), children] })));
|
|
138
|
-
};
|
|
139
|
-
exports.ThemeProvider = ThemeProvider;
|
|
140
|
-
var ThemeScript = (0, react_1.memo)(function (_a) {
|
|
141
|
-
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;
|
|
142
|
-
var defaultSystem = defaultTheme === "system";
|
|
143
|
-
// Code-golfing the amount of characters in the script
|
|
144
|
-
var optimization = (function () {
|
|
145
|
-
var removeClasses = "d.remove(".concat(attrs
|
|
146
|
-
.map(function (t) { return "'".concat(t, "'"); })
|
|
147
|
-
.join(","), ")");
|
|
148
|
-
return "var d=document.documentElement.classList;".concat(removeClasses, ";");
|
|
149
|
-
})();
|
|
150
|
-
var fallbackColorScheme = (function () {
|
|
151
|
-
if (!enableColorScheme) {
|
|
152
|
-
return "";
|
|
153
|
-
}
|
|
154
|
-
var fallback = colorSchemes.includes(defaultTheme)
|
|
155
|
-
? defaultTheme
|
|
156
|
-
: null;
|
|
157
|
-
if (fallback) {
|
|
158
|
-
return "if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'".concat(defaultTheme, "'");
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
return "if(e==='light'||e==='dark')d.style.colorScheme=e";
|
|
162
|
-
}
|
|
163
|
-
})();
|
|
164
|
-
var updateDOM = function (name, literal, setColorScheme) {
|
|
165
|
-
if (literal === void 0) { literal = false; }
|
|
166
|
-
if (setColorScheme === void 0) { setColorScheme = true; }
|
|
167
|
-
var resolvedName = value ? value[name] : name;
|
|
168
|
-
var val = literal ? name + "|| ''" : "'".concat(resolvedName, "'");
|
|
169
|
-
var text = "";
|
|
170
|
-
// MUCH faster to set colorScheme alongside HTML attribute/class
|
|
171
|
-
// as it only incurs 1 style recalculation rather than 2
|
|
172
|
-
// This can save over 250ms of work for pages with big DOM
|
|
173
|
-
if (enableColorScheme &&
|
|
174
|
-
setColorScheme &&
|
|
175
|
-
!literal &&
|
|
176
|
-
colorSchemes.includes(name)) {
|
|
177
|
-
text += "d.style.colorScheme = '".concat(name, "';");
|
|
178
|
-
}
|
|
179
|
-
if (attribute === "class") {
|
|
180
|
-
if (literal || resolvedName) {
|
|
181
|
-
text += "d.add(".concat(val, ")");
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
text += "null";
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
if (resolvedName) {
|
|
189
|
-
text += "d[s](n, ".concat(val, ")");
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return text;
|
|
193
|
-
};
|
|
194
|
-
var scriptSrc = (function () {
|
|
195
|
-
if (forcedTheme) {
|
|
196
|
-
return "!function(){".concat(optimization).concat(updateDOM(forcedTheme), "}()");
|
|
197
|
-
}
|
|
198
|
-
if (enableSystem) {
|
|
199
|
-
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
|
|
200
|
-
? "else{" + updateDOM(defaultTheme, false, false) + "}"
|
|
201
|
-
: "").concat(fallbackColorScheme, "}catch(e){}}()");
|
|
202
|
-
}
|
|
203
|
-
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){}}();");
|
|
204
|
-
})();
|
|
205
|
-
// We MUST use next/script's `beforeInteractive` strategy to avoid flashing on load.
|
|
206
|
-
// However, it only accepts the `src` prop, not `dangerouslySetInnerHTML` or `children`
|
|
207
|
-
// But our script cannot be external because it changes at runtime based on React props
|
|
208
|
-
// so we trick next/script by passing `src` as a base64 JS script
|
|
209
|
-
var encodedScript = "data:text/javascript;base64,".concat(encodeBase64(scriptSrc));
|
|
210
|
-
return ((0, jsx_runtime_1.jsx)(script_1.default, { id: "next-theme-script", strategy: "beforeInteractive", src: encodedScript, nonce: nonce }));
|
|
211
|
-
},
|
|
212
|
-
// Never re-render this component
|
|
213
|
-
function () { return true; });
|
|
214
|
-
// Helpers
|
|
215
|
-
var getTheme = function (key, fallback) {
|
|
216
|
-
if (isServer_1.default)
|
|
217
|
-
return undefined;
|
|
218
|
-
var theme;
|
|
219
|
-
try {
|
|
220
|
-
theme = localStorage.getItem(key) || undefined;
|
|
221
|
-
}
|
|
222
|
-
catch (e) {
|
|
223
|
-
// Unsupported
|
|
224
|
-
}
|
|
225
|
-
return theme || fallback;
|
|
226
|
-
};
|
|
227
|
-
var disableAnimation = function () {
|
|
228
|
-
var d = document;
|
|
229
|
-
var css = d.createElement("style");
|
|
230
|
-
css.appendChild(d.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"));
|
|
231
|
-
d.head.appendChild(css);
|
|
232
|
-
return function () {
|
|
233
|
-
// Force restyle
|
|
234
|
-
(function () { return window.getComputedStyle(d.body); })();
|
|
235
|
-
// Wait for next tick before removing
|
|
236
|
-
setTimeout(function () {
|
|
237
|
-
d.head.removeChild(css);
|
|
238
|
-
}, 1);
|
|
239
|
-
};
|
|
240
|
-
};
|
|
241
|
-
var getSystemTheme = function (e) {
|
|
242
|
-
if (!e)
|
|
243
|
-
e = window.matchMedia(MEDIA);
|
|
244
|
-
var isDark = e.matches;
|
|
245
|
-
var systemTheme = isDark ? "dark" : "light";
|
|
246
|
-
return systemTheme;
|
|
247
|
-
};
|
|
248
|
-
var encodeBase64 = function (str) {
|
|
249
|
-
return isServer_1.default ? Buffer.from(str).toString("base64") : btoa(str);
|
|
250
|
-
};
|
|
251
|
-
exports.default = exports.ThemeProvider;
|
package/legacy/ThemeProvider.mjs
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { __assign, __spreadArray } from "tslib";
|
|
3
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { useCallback, useEffect, useState, memo } from "react";
|
|
5
|
-
import NextScript from "next/script";
|
|
6
|
-
import isServer from "@koine/utils/isServer";
|
|
7
|
-
import { ThemeContext } from "./ThemeContext";
|
|
8
|
-
var colorSchemes = ["light", "dark"];
|
|
9
|
-
var MEDIA = "(prefers-color-scheme: dark)";
|
|
10
|
-
var THEME_STORAGE_KEY = "theme";
|
|
11
|
-
/**
|
|
12
|
-
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
13
|
-
*
|
|
14
|
-
* Differences:
|
|
15
|
-
*
|
|
16
|
-
* - enableColorScheme: `false` by default (instead of `true`), this plays more
|
|
17
|
-
* nicely with tailwind `dark` class mode as dark theme is supposed to be only
|
|
18
|
-
* controlled by tailwind modifiers
|
|
19
|
-
*/
|
|
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, 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;
|
|
22
|
-
var _g = useState(function () {
|
|
23
|
-
return getTheme(THEME_STORAGE_KEY, defaultTheme);
|
|
24
|
-
}), theme = _g[0], setThemeState = _g[1];
|
|
25
|
-
var _h = useState(function () {
|
|
26
|
-
return getTheme(THEME_STORAGE_KEY);
|
|
27
|
-
}), resolvedTheme = _h[0], setResolvedTheme = _h[1];
|
|
28
|
-
var attrs = !value ? themes : Object.values(value);
|
|
29
|
-
var applyTheme = useCallback(function (theme) {
|
|
30
|
-
var _a;
|
|
31
|
-
var resolved = theme;
|
|
32
|
-
if (isServer || !resolved)
|
|
33
|
-
return;
|
|
34
|
-
// If theme is system, resolve it before setting theme
|
|
35
|
-
if (theme === "system" && enableSystem) {
|
|
36
|
-
resolved = getSystemTheme();
|
|
37
|
-
}
|
|
38
|
-
var name = value ? value[resolved] : resolved;
|
|
39
|
-
var enable = disableTransitionOnChange ? disableAnimation() : null;
|
|
40
|
-
var d = document.documentElement;
|
|
41
|
-
if (attribute === "class") {
|
|
42
|
-
(_a = d.classList).remove.apply(_a, attrs);
|
|
43
|
-
if (name)
|
|
44
|
-
d.classList.add(name);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
if (name) {
|
|
48
|
-
d.setAttribute(attribute, name);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
d.removeAttribute(attribute);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (enableColorScheme) {
|
|
55
|
-
var fallback = colorSchemes.includes(defaultTheme)
|
|
56
|
-
? defaultTheme
|
|
57
|
-
: "";
|
|
58
|
-
var colorScheme = colorSchemes.includes(resolved)
|
|
59
|
-
? resolved
|
|
60
|
-
: fallback;
|
|
61
|
-
d.style.colorScheme = colorScheme;
|
|
62
|
-
}
|
|
63
|
-
enable === null || enable === void 0 ? void 0 : enable();
|
|
64
|
-
}, [
|
|
65
|
-
attribute,
|
|
66
|
-
attrs,
|
|
67
|
-
defaultTheme,
|
|
68
|
-
disableTransitionOnChange,
|
|
69
|
-
enableColorScheme,
|
|
70
|
-
enableSystem,
|
|
71
|
-
value,
|
|
72
|
-
]);
|
|
73
|
-
var setTheme = useCallback(function (theme) {
|
|
74
|
-
setThemeState(theme);
|
|
75
|
-
// Save to storage
|
|
76
|
-
try {
|
|
77
|
-
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
// Unsupported
|
|
81
|
-
}
|
|
82
|
-
}, []);
|
|
83
|
-
var handleMediaQuery = useCallback(function (e) {
|
|
84
|
-
var resolved = getSystemTheme(e);
|
|
85
|
-
setResolvedTheme(resolved);
|
|
86
|
-
if (theme === "system" && enableSystem && !forcedTheme) {
|
|
87
|
-
applyTheme("system");
|
|
88
|
-
}
|
|
89
|
-
}, [theme, enableSystem, forcedTheme, applyTheme]);
|
|
90
|
-
// Always listen to System preference
|
|
91
|
-
useEffect(function () {
|
|
92
|
-
var media = window.matchMedia(MEDIA);
|
|
93
|
-
// Intentionally use deprecated listener methods to support iOS & old browsers
|
|
94
|
-
media.addListener(handleMediaQuery);
|
|
95
|
-
handleMediaQuery(media);
|
|
96
|
-
return function () { return media.removeListener(handleMediaQuery); };
|
|
97
|
-
}, [handleMediaQuery]);
|
|
98
|
-
// localStorage event handling
|
|
99
|
-
useEffect(function () {
|
|
100
|
-
var handleStorage = function (e) {
|
|
101
|
-
if (e.key !== THEME_STORAGE_KEY) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
// If default theme set, use it if localstorage === null (happens on local storage manual deletion)
|
|
105
|
-
var theme = e.newValue || defaultTheme;
|
|
106
|
-
setTheme(theme);
|
|
107
|
-
};
|
|
108
|
-
window.addEventListener("storage", handleStorage);
|
|
109
|
-
return function () { return window.removeEventListener("storage", handleStorage); };
|
|
110
|
-
}, [defaultTheme, setTheme]);
|
|
111
|
-
// Whenever theme or forcedTheme changes, apply it
|
|
112
|
-
useEffect(function () {
|
|
113
|
-
applyTheme(forcedTheme !== null && forcedTheme !== void 0 ? forcedTheme : theme);
|
|
114
|
-
}, [applyTheme, forcedTheme, theme]);
|
|
115
|
-
return (_jsxs(ThemeContext.Provider, __assign({ value: {
|
|
116
|
-
theme: theme,
|
|
117
|
-
setTheme: setTheme,
|
|
118
|
-
forcedTheme: forcedTheme,
|
|
119
|
-
resolvedTheme: theme === "system" ? resolvedTheme : theme,
|
|
120
|
-
themes: enableSystem ? __spreadArray(__spreadArray([], themes, true), ["system"], false) : themes,
|
|
121
|
-
systemTheme: (enableSystem ? resolvedTheme : undefined),
|
|
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] })));
|
|
135
|
-
};
|
|
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";
|
|
139
|
-
// Code-golfing the amount of characters in the script
|
|
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, ";");
|
|
145
|
-
})();
|
|
146
|
-
var fallbackColorScheme = (function () {
|
|
147
|
-
if (!enableColorScheme) {
|
|
148
|
-
return "";
|
|
149
|
-
}
|
|
150
|
-
var fallback = colorSchemes.includes(defaultTheme)
|
|
151
|
-
? defaultTheme
|
|
152
|
-
: null;
|
|
153
|
-
if (fallback) {
|
|
154
|
-
return "if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'".concat(defaultTheme, "'");
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
return "if(e==='light'||e==='dark')d.style.colorScheme=e";
|
|
158
|
-
}
|
|
159
|
-
})();
|
|
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 = "";
|
|
166
|
-
// MUCH faster to set colorScheme alongside HTML attribute/class
|
|
167
|
-
// as it only incurs 1 style recalculation rather than 2
|
|
168
|
-
// This can save over 250ms of work for pages with big DOM
|
|
169
|
-
if (enableColorScheme &&
|
|
170
|
-
setColorScheme &&
|
|
171
|
-
!literal &&
|
|
172
|
-
colorSchemes.includes(name)) {
|
|
173
|
-
text += "d.style.colorScheme = '".concat(name, "';");
|
|
174
|
-
}
|
|
175
|
-
if (attribute === "class") {
|
|
176
|
-
if (literal || resolvedName) {
|
|
177
|
-
text += "d.add(".concat(val, ")");
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
text += "null";
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
if (resolvedName) {
|
|
185
|
-
text += "d[s](n, ".concat(val, ")");
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return text;
|
|
189
|
-
};
|
|
190
|
-
var scriptSrc = (function () {
|
|
191
|
-
if (forcedTheme) {
|
|
192
|
-
return "!function(){".concat(optimization).concat(updateDOM(forcedTheme), "}()");
|
|
193
|
-
}
|
|
194
|
-
if (enableSystem) {
|
|
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){}}()");
|
|
198
|
-
}
|
|
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){}}();");
|
|
200
|
-
})();
|
|
201
|
-
// We MUST use next/script's `beforeInteractive` strategy to avoid flashing on load.
|
|
202
|
-
// However, it only accepts the `src` prop, not `dangerouslySetInnerHTML` or `children`
|
|
203
|
-
// But our script cannot be external because it changes at runtime based on React props
|
|
204
|
-
// so we trick next/script by passing `src` as a base64 JS script
|
|
205
|
-
var encodedScript = "data:text/javascript;base64,".concat(encodeBase64(scriptSrc));
|
|
206
|
-
return (_jsx(NextScript, { id: "next-theme-script", strategy: "beforeInteractive", src: encodedScript, nonce: nonce }));
|
|
207
|
-
},
|
|
208
|
-
// Never re-render this component
|
|
209
|
-
function () { return true; });
|
|
210
|
-
// Helpers
|
|
211
|
-
var getTheme = function (key, fallback) {
|
|
212
|
-
if (isServer)
|
|
213
|
-
return undefined;
|
|
214
|
-
var theme;
|
|
215
|
-
try {
|
|
216
|
-
theme = localStorage.getItem(key) || undefined;
|
|
217
|
-
}
|
|
218
|
-
catch (e) {
|
|
219
|
-
// Unsupported
|
|
220
|
-
}
|
|
221
|
-
return theme || fallback;
|
|
222
|
-
};
|
|
223
|
-
var disableAnimation = function () {
|
|
224
|
-
var d = document;
|
|
225
|
-
var css = d.createElement("style");
|
|
226
|
-
css.appendChild(d.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"));
|
|
227
|
-
d.head.appendChild(css);
|
|
228
|
-
return function () {
|
|
229
|
-
// Force restyle
|
|
230
|
-
(function () { return window.getComputedStyle(d.body); })();
|
|
231
|
-
// Wait for next tick before removing
|
|
232
|
-
setTimeout(function () {
|
|
233
|
-
d.head.removeChild(css);
|
|
234
|
-
}, 1);
|
|
235
|
-
};
|
|
236
|
-
};
|
|
237
|
-
var getSystemTheme = function (e) {
|
|
238
|
-
if (!e)
|
|
239
|
-
e = window.matchMedia(MEDIA);
|
|
240
|
-
var isDark = e.matches;
|
|
241
|
-
var systemTheme = isDark ? "dark" : "light";
|
|
242
|
-
return systemTheme;
|
|
243
|
-
};
|
|
244
|
-
var encodeBase64 = function (str) {
|
|
245
|
-
return isServer ? Buffer.from(str).toString("base64") : btoa(str);
|
|
246
|
-
};
|
|
247
|
-
export default ThemeProvider;
|
package/legacy/TransText.d.ts
DELETED
package/legacy/TransText.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.TransText = void 0;
|
|
5
|
-
var tslib_1 = require("tslib");
|
|
6
|
-
var TransText_1 = tslib_1.__importDefault(require("next-translate/TransText"));
|
|
7
|
-
exports.TransText = TransText_1.default;
|
|
8
|
-
exports.default = exports.TransText;
|
package/legacy/TransText.mjs
DELETED
package/legacy/app/AppHead.d.ts
DELETED
package/legacy/app/AppHead.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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" }) }));
|
|
9
|
-
};
|
|
10
|
-
exports.AppHead = AppHead;
|
|
11
|
-
exports.default = exports.AppHead;
|
package/legacy/app/AppHead.mjs
DELETED
package/legacy/app/AppMain.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { AppProps as NextAppProps } from "next/app";
|
|
3
|
-
import type { HTMLMotionProps } from "framer-motion";
|
|
4
|
-
import type { SeoDefaultsProps } from "../SeoDefaults";
|
|
5
|
-
import type { NextProgressProps } from "../NextProgress";
|
|
6
|
-
import type { MotionProviderFeatures } from "@koine/react/m";
|
|
7
|
-
export type AppMainBaseProps = NextAppProps & {
|
|
8
|
-
/**
|
|
9
|
-
* A wrapping layout component
|
|
10
|
-
*/
|
|
11
|
-
Layout: React.FC<Record<string, unknown>>;
|
|
12
|
-
/**
|
|
13
|
-
* A Progress' Overlay component
|
|
14
|
-
*/
|
|
15
|
-
ProgressOverlay?: NextProgressProps["Overlay"];
|
|
16
|
-
/**
|
|
17
|
-
* Seo site wide default configuration
|
|
18
|
-
*/
|
|
19
|
-
seo?: SeoDefaultsProps;
|
|
20
|
-
/**
|
|
21
|
-
* JSX to render just after SEO
|
|
22
|
-
*/
|
|
23
|
-
pre?: React.ReactNode;
|
|
24
|
-
/**
|
|
25
|
-
* JSX to render just at the end of the markup
|
|
26
|
-
*/
|
|
27
|
-
post?: React.ReactNode;
|
|
28
|
-
};
|
|
29
|
-
export type AppMainFramerProps = {
|
|
30
|
-
motion: MotionProviderFeatures;
|
|
31
|
-
/**
|
|
32
|
-
* Default layout transition, by default it is a simple fade in/out
|
|
33
|
-
*/
|
|
34
|
-
transition?: Omit<HTMLMotionProps<"div">, "key">;
|
|
35
|
-
};
|
package/legacy/app/AppMain.js
DELETED
package/legacy/app/AppMain.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|