@koine/next 2.0.0-beta.21 → 2.0.0-beta.210
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/README.md +1 -0
- package/ThemeContext.cjs.default.js +1 -0
- package/ThemeContext.cjs.js +10 -0
- package/ThemeContext.cjs.mjs +2 -0
- package/ThemeContext.d.ts +6 -1
- package/ThemeContext.esm.js +5 -0
- package/ThemeProvider.cjs.default.js +1 -0
- package/ThemeProvider.cjs.js +14 -0
- package/ThemeProvider.cjs.mjs +2 -0
- package/ThemeProvider.d.ts +18 -1
- package/ThemeProvider.esm.js +9 -0
- package/config.cjs.default.js +1 -0
- package/config.cjs.js +9 -0
- package/config.cjs.mjs +2 -0
- package/config.d.ts +42 -107
- package/config.esm.js +7 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +13 -0
- package/index.cjs.mjs +2 -0
- package/index.d.ts +4 -5
- package/index.esm.js +4 -0
- package/load.cjs.default.js +1 -0
- package/load.cjs.js +8 -0
- package/load.cjs.mjs +2 -0
- package/load.d.ts +8 -0
- package/load.esm.js +3 -0
- package/package.json +43 -206
- package/typings.d.ts +39 -50
- package/useTheme.cjs.default.js +1 -0
- package/useTheme.cjs.js +11 -0
- package/useTheme.cjs.mjs +2 -0
- package/useTheme.d.ts +4 -1
- package/useTheme.esm.js +6 -0
- package/vite.config.d.ts +2 -0
- package/12/AnalyticsGoogle.d.ts +0 -5
- package/12/AnalyticsGoogle.js +0 -33
- package/12/DisableErrorOverlay.d.ts +0 -2
- package/12/DisableErrorOverlay.js +0 -8
- package/12/DynamicNamespaces.d.ts +0 -8
- package/12/DynamicNamespaces.js +0 -4
- package/12/Favicon.d.ts +0 -4
- package/12/Favicon.js +0 -6
- package/12/Link.d.ts +0 -7
- package/12/Link.js +0 -9
- package/12/NextProgress.d.ts +0 -22
- package/12/NextProgress.js +0 -40
- package/12/Seo.d.ts +0 -17
- package/12/Seo.js +0 -7
- package/12/SeoDefaults.d.ts +0 -8
- package/12/SeoDefaults.js +0 -7
- package/12/T.d.ts +0 -10
- package/12/T.js +0 -8
- package/12/TransText.d.ts +0 -3
- package/12/TransText.js +0 -4
- package/12/app/AppHead.d.ts +0 -3
- package/12/app/AppHead.js +0 -6
- package/12/app/AppMain.d.ts +0 -17
- package/12/app/AppMain.js +0 -1
- package/12/app/css/AppMain.d.ts +0 -4
- package/12/app/css/AppMain.js +0 -9
- package/12/app/css/AppTheme.d.ts +0 -8
- package/12/app/css/AppTheme.js +0 -7
- package/12/app/css/auth/index.d.ts +0 -8
- package/12/app/css/auth/index.js +0 -10
- package/12/app/css/index.d.ts +0 -6
- package/12/app/css/index.js +0 -9
- package/12/app/index.d.ts +0 -2
- package/12/app/index.js +0 -2
- package/12/app/sc/AppMain.d.ts +0 -4
- package/12/app/sc/AppMain.js +0 -18
- package/12/app/sc/AppTheme.d.ts +0 -8
- package/12/app/sc/AppTheme.js +0 -8
- package/12/app/sc/auth/index.d.ts +0 -8
- package/12/app/sc/auth/index.js +0 -10
- package/12/app/sc/index.d.ts +0 -6
- package/12/app/sc/index.js +0 -9
- package/12/document/Document.d.ts +0 -5
- package/12/document/Document.js +0 -18
- package/12/document/css/index.d.ts +0 -5
- package/12/document/css/index.js +0 -18
- package/12/document/index.d.ts +0 -2
- package/12/document/index.js +0 -2
- package/12/document/sc/index.d.ts +0 -6
- package/12/document/sc/index.js +0 -50
- package/12/getT.d.ts +0 -4
- package/12/getT.js +0 -4
- package/12/index.d.ts +0 -3
- package/12/index.js +0 -3
- package/12/seoBuildTags.d.ts +0 -8
- package/12/seoBuildTags.js +0 -93
- package/12/to.d.ts +0 -14
- package/12/to.js +0 -19
- package/12/translationAsOptions.d.ts +0 -4
- package/12/translationAsOptions.js +0 -10
- package/12/types-i18n.d.ts +0 -31
- package/12/types-i18n.js +0 -1
- package/12/types-seo.d.ts +0 -7
- package/12/types-seo.js +0 -1
- package/12/types.d.ts +0 -7
- package/12/types.js +0 -2
- package/12/useBackUrl.d.ts +0 -2
- package/12/useBackUrl.js +0 -24
- package/12/useDateFormat.d.ts +0 -3
- package/12/useDateFormat.js +0 -35
- package/12/useForm.d.ts +0 -27
- package/12/useForm.js +0 -15
- package/12/useLocale.d.ts +0 -2
- package/12/useLocale.js +0 -6
- package/12/useT.d.ts +0 -4
- package/12/useT.js +0 -17
- package/12/useTo.d.ts +0 -3
- package/12/useTo.js +0 -15
- package/ThemeContext.js +0 -6
- package/ThemeProvider.js +0 -204
- package/config-i18n.d.ts +0 -52
- package/config-i18n.js +0 -251
- package/config.js +0 -118
- package/getSiteUrl.d.ts +0 -2
- package/getSiteUrl.js +0 -6
- package/index.js +0 -5
- package/load.js +0 -6
- package/useTheme.js +0 -5
package/12/useDateFormat.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { __assign, __read, __spreadArray } from "tslib";
|
|
3
|
-
import format from "date-fns/format";
|
|
4
|
-
import { useRouter } from "next/router";
|
|
5
|
-
import { useEffect, useState } from "react";
|
|
6
|
-
import { useDateLocale } from "@koine/react";
|
|
7
|
-
export var useDateFormat = function () {
|
|
8
|
-
var _a = __read(useState(function () {
|
|
9
|
-
return function () {
|
|
10
|
-
var args = [];
|
|
11
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
12
|
-
args[_i] = arguments[_i];
|
|
13
|
-
}
|
|
14
|
-
return format.apply(void 0, __spreadArray([], __read(args), false));
|
|
15
|
-
};
|
|
16
|
-
}), 2), formatter = _a[0], setFormatter = _a[1];
|
|
17
|
-
var router = useRouter();
|
|
18
|
-
var locale = useDateLocale(router.locale);
|
|
19
|
-
useEffect(function () {
|
|
20
|
-
if (locale) {
|
|
21
|
-
var newFormatter_1 = function (date, _format, options) { return format(date, _format, __assign(__assign({}, (options || {})), { locale: locale })); };
|
|
22
|
-
setFormatter(function () {
|
|
23
|
-
return function () {
|
|
24
|
-
var args = [];
|
|
25
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
26
|
-
args[_i] = arguments[_i];
|
|
27
|
-
}
|
|
28
|
-
return newFormatter_1.apply(void 0, __spreadArray([], __read(args), false));
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}, [locale]);
|
|
33
|
-
return formatter;
|
|
34
|
-
};
|
|
35
|
-
export default useDateFormat;
|
package/12/useForm.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { ObjectSchema } from "@kuus/yup";
|
|
2
|
-
import type { FieldValues, UseFormProps } from "react-hook-form";
|
|
3
|
-
import { type TranslateLoose } from "./types-i18n.js";
|
|
4
|
-
export declare function useForm<T extends FieldValues>(schema: ObjectSchema<any>, t: TranslateLoose, formProps?: UseFormProps, debug?: boolean): {
|
|
5
|
-
watch: import("react-hook-form").UseFormWatch<T>;
|
|
6
|
-
getValues: import("react-hook-form").UseFormGetValues<T>;
|
|
7
|
-
getFieldState: import("react-hook-form").UseFormGetFieldState<T>;
|
|
8
|
-
setError: import("react-hook-form").UseFormSetError<T>;
|
|
9
|
-
clearErrors: import("react-hook-form").UseFormClearErrors<T>;
|
|
10
|
-
setValue: import("react-hook-form").UseFormSetValue<T>;
|
|
11
|
-
trigger: import("react-hook-form").UseFormTrigger<T>;
|
|
12
|
-
formState: import("react-hook-form").FormState<T>;
|
|
13
|
-
resetField: import("react-hook-form").UseFormResetField<T>;
|
|
14
|
-
reset: import("react-hook-form").UseFormReset<T>;
|
|
15
|
-
handleSubmit: import("react-hook-form").UseFormHandleSubmit<T, undefined>;
|
|
16
|
-
unregister: import("react-hook-form").UseFormUnregister<T>;
|
|
17
|
-
control: import("react-hook-form").Control<T, any>;
|
|
18
|
-
register: import("react-hook-form").UseFormRegister<T>;
|
|
19
|
-
setFocus: import("react-hook-form").UseFormSetFocus<T>;
|
|
20
|
-
field: {
|
|
21
|
-
control: import("react-hook-form").Control<T, any>;
|
|
22
|
-
register: import("react-hook-form").UseFormRegister<T>;
|
|
23
|
-
setValue: import("react-hook-form").UseFormSetValue<T>;
|
|
24
|
-
t: TranslateLoose;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export default useForm;
|
package/12/useForm.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { __assign } from "tslib";
|
|
3
|
-
import { yupResolver as resolver } from "@hookform/resolvers/yup";
|
|
4
|
-
import { useMemo } from "react";
|
|
5
|
-
import { useForm as _useForm } from "react-hook-form";
|
|
6
|
-
export function useForm(schema, t, formProps, debug) {
|
|
7
|
-
if (formProps === void 0) { formProps = {}; }
|
|
8
|
-
var form = _useForm(__assign({ resolver: resolver(schema) }, formProps));
|
|
9
|
-
return useMemo(function () {
|
|
10
|
-
var control = form.control, register = form.register, setValue = form.setValue;
|
|
11
|
-
var field = { control: control, register: register, setValue: setValue, t: t };
|
|
12
|
-
return __assign({ field: field }, form);
|
|
13
|
-
}, [t, form]);
|
|
14
|
-
}
|
|
15
|
-
export default useForm;
|
package/12/useLocale.d.ts
DELETED
package/12/useLocale.js
DELETED
package/12/useT.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { TranslateDefault, TranslateNamespace, TranslateNamespaced } from "./types-i18n.js";
|
|
2
|
-
export declare function useT(): TranslateDefault;
|
|
3
|
-
export declare function useT<TNamespace extends TranslateNamespace>(namespace: TNamespace): TranslateNamespaced<TNamespace>;
|
|
4
|
-
export default useT;
|
package/12/useT.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import I18nContext from "next-translate/context";
|
|
3
|
-
import { useContext, useMemo } from "react";
|
|
4
|
-
export function useT(namespace) {
|
|
5
|
-
var t = useContext(I18nContext).t;
|
|
6
|
-
var tMemoized = useMemo(function () {
|
|
7
|
-
return function (s, q, o) {
|
|
8
|
-
return t(namespace ? "".concat(namespace, ":").concat(s) : "".concat(s), q === "obj" || q === "" ? null : q, q === "obj" || o === "obj"
|
|
9
|
-
? { returnObjects: true }
|
|
10
|
-
: q === "" || o === ""
|
|
11
|
-
? { fallback: "" }
|
|
12
|
-
: o);
|
|
13
|
-
};
|
|
14
|
-
}, [t, namespace]);
|
|
15
|
-
return tMemoized;
|
|
16
|
-
}
|
|
17
|
-
export default useT;
|
package/12/useTo.d.ts
DELETED
package/12/useTo.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { __read, __spreadArray } from "tslib";
|
|
3
|
-
import { to } from "./to.js";
|
|
4
|
-
import { useT } from "./useT.js";
|
|
5
|
-
export function useTo() {
|
|
6
|
-
var t = useT("~");
|
|
7
|
-
return function () {
|
|
8
|
-
var args = [];
|
|
9
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10
|
-
args[_i] = arguments[_i];
|
|
11
|
-
}
|
|
12
|
-
return to.apply(void 0, __spreadArray([t], __read(args), false));
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export default useTo;
|
package/ThemeContext.js
DELETED
package/ThemeProvider.js
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { __read, __spreadArray } from "tslib";
|
|
3
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
import NextScript from "next/script";
|
|
5
|
-
import { memo, useCallback, useEffect, useState } from "react";
|
|
6
|
-
import { isServer } from "@koine/utils";
|
|
7
|
-
import { ThemeContext } from "./ThemeContext.js";
|
|
8
|
-
var colorSchemes = ["light", "dark"];
|
|
9
|
-
var MEDIA = "(prefers-color-scheme: dark)";
|
|
10
|
-
var THEME_STORAGE_KEY = "theme";
|
|
11
|
-
export var ThemeProvider = function (_a) {
|
|
12
|
-
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;
|
|
13
|
-
var _g = __read(useState(function () {
|
|
14
|
-
return getTheme(THEME_STORAGE_KEY, defaultTheme);
|
|
15
|
-
}), 2), theme = _g[0], setThemeState = _g[1];
|
|
16
|
-
var _h = __read(useState(function () {
|
|
17
|
-
return getTheme(THEME_STORAGE_KEY);
|
|
18
|
-
}), 2), resolvedTheme = _h[0], setResolvedTheme = _h[1];
|
|
19
|
-
var attrs = !value ? themes : Object.values(value);
|
|
20
|
-
var applyTheme = useCallback(function (theme) {
|
|
21
|
-
var _a;
|
|
22
|
-
var resolved = theme;
|
|
23
|
-
if (isServer || !resolved)
|
|
24
|
-
return;
|
|
25
|
-
if (theme === "system" && enableSystem) {
|
|
26
|
-
resolved = getSystemTheme();
|
|
27
|
-
}
|
|
28
|
-
var name = value ? value[resolved] : resolved;
|
|
29
|
-
var enable = disableTransitionOnChange ? disableAnimation() : null;
|
|
30
|
-
var d = document.documentElement;
|
|
31
|
-
if (attribute === "class") {
|
|
32
|
-
(_a = d.classList).remove.apply(_a, __spreadArray([], __read(attrs), false));
|
|
33
|
-
if (name)
|
|
34
|
-
d.classList.add(name);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
if (name) {
|
|
38
|
-
d.setAttribute(attribute, name);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
d.removeAttribute(attribute);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (enableColorScheme) {
|
|
45
|
-
var fallback = colorSchemes.includes(defaultTheme)
|
|
46
|
-
? defaultTheme
|
|
47
|
-
: "";
|
|
48
|
-
var colorScheme = colorSchemes.includes(resolved)
|
|
49
|
-
? resolved
|
|
50
|
-
: fallback;
|
|
51
|
-
d.style.colorScheme = colorScheme;
|
|
52
|
-
}
|
|
53
|
-
enable === null || enable === void 0 ? void 0 : enable();
|
|
54
|
-
}, [
|
|
55
|
-
attribute,
|
|
56
|
-
attrs,
|
|
57
|
-
defaultTheme,
|
|
58
|
-
disableTransitionOnChange,
|
|
59
|
-
enableColorScheme,
|
|
60
|
-
enableSystem,
|
|
61
|
-
value,
|
|
62
|
-
]);
|
|
63
|
-
var setTheme = useCallback(function (theme) {
|
|
64
|
-
setThemeState(theme);
|
|
65
|
-
try {
|
|
66
|
-
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
}
|
|
70
|
-
}, []);
|
|
71
|
-
var handleMediaQuery = useCallback(function (e) {
|
|
72
|
-
var resolved = getSystemTheme(e);
|
|
73
|
-
setResolvedTheme(resolved);
|
|
74
|
-
if (theme === "system" && enableSystem && !forcedTheme) {
|
|
75
|
-
applyTheme("system");
|
|
76
|
-
}
|
|
77
|
-
}, [theme, enableSystem, forcedTheme, applyTheme]);
|
|
78
|
-
useEffect(function () {
|
|
79
|
-
var media = window.matchMedia(MEDIA);
|
|
80
|
-
media.addListener(handleMediaQuery);
|
|
81
|
-
handleMediaQuery(media);
|
|
82
|
-
return function () { return media.removeListener(handleMediaQuery); };
|
|
83
|
-
}, [handleMediaQuery]);
|
|
84
|
-
useEffect(function () {
|
|
85
|
-
var handleStorage = function (e) {
|
|
86
|
-
if (e.key !== THEME_STORAGE_KEY) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
var theme = e.newValue || defaultTheme;
|
|
90
|
-
setTheme(theme);
|
|
91
|
-
};
|
|
92
|
-
window.addEventListener("storage", handleStorage);
|
|
93
|
-
return function () { return window.removeEventListener("storage", handleStorage); };
|
|
94
|
-
}, [defaultTheme, setTheme]);
|
|
95
|
-
useEffect(function () {
|
|
96
|
-
applyTheme(forcedTheme !== null && forcedTheme !== void 0 ? forcedTheme : theme);
|
|
97
|
-
}, [applyTheme, forcedTheme, theme]);
|
|
98
|
-
return (_jsxs(ThemeContext.Provider, { value: {
|
|
99
|
-
theme: theme,
|
|
100
|
-
setTheme: setTheme,
|
|
101
|
-
forcedTheme: forcedTheme,
|
|
102
|
-
resolvedTheme: theme === "system" ? resolvedTheme : theme,
|
|
103
|
-
themes: enableSystem ? __spreadArray(__spreadArray([], __read(themes), false), ["system"], false) : themes,
|
|
104
|
-
systemTheme: (enableSystem ? resolvedTheme : undefined),
|
|
105
|
-
}, children: [_jsx(ThemeScript, { forcedTheme: forcedTheme, disableTransitionOnChange: disableTransitionOnChange, enableSystem: enableSystem, enableColorScheme: enableColorScheme, themes: themes, defaultTheme: defaultTheme, attribute: attribute, value: value, children: children, attrs: attrs, nonce: nonce }), children] }));
|
|
106
|
-
};
|
|
107
|
-
var ThemeScript = memo(function (_a) {
|
|
108
|
-
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;
|
|
109
|
-
var defaultSystem = defaultTheme === "system";
|
|
110
|
-
var optimization = (function () {
|
|
111
|
-
var removeClasses = "d.remove(".concat(attrs
|
|
112
|
-
.map(function (t) { return "'".concat(t, "'"); })
|
|
113
|
-
.join(","), ")");
|
|
114
|
-
return "var d=document.documentElement.classList;".concat(removeClasses, ";");
|
|
115
|
-
})();
|
|
116
|
-
var fallbackColorScheme = (function () {
|
|
117
|
-
if (!enableColorScheme) {
|
|
118
|
-
return "";
|
|
119
|
-
}
|
|
120
|
-
var fallback = colorSchemes.includes(defaultTheme)
|
|
121
|
-
? defaultTheme
|
|
122
|
-
: null;
|
|
123
|
-
if (fallback) {
|
|
124
|
-
return "if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'".concat(defaultTheme, "'");
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
return "if(e==='light'||e==='dark')d.style.colorScheme=e";
|
|
128
|
-
}
|
|
129
|
-
})();
|
|
130
|
-
var updateDOM = function (name, literal, setColorScheme) {
|
|
131
|
-
if (literal === void 0) { literal = false; }
|
|
132
|
-
if (setColorScheme === void 0) { setColorScheme = true; }
|
|
133
|
-
var resolvedName = value ? value[name] : name;
|
|
134
|
-
var val = literal ? name + "|| ''" : "'".concat(resolvedName, "'");
|
|
135
|
-
var text = "";
|
|
136
|
-
if (enableColorScheme &&
|
|
137
|
-
setColorScheme &&
|
|
138
|
-
!literal &&
|
|
139
|
-
colorSchemes.includes(name)) {
|
|
140
|
-
text += "d.style.colorScheme = '".concat(name, "';");
|
|
141
|
-
}
|
|
142
|
-
if (attribute === "class") {
|
|
143
|
-
if (literal || resolvedName) {
|
|
144
|
-
text += "d.add(".concat(val, ")");
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
text += "null";
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
if (resolvedName) {
|
|
152
|
-
text += "d[s](n, ".concat(val, ")");
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return text;
|
|
156
|
-
};
|
|
157
|
-
var scriptSrc = (function () {
|
|
158
|
-
if (forcedTheme) {
|
|
159
|
-
return "!function(){".concat(optimization).concat(updateDOM(forcedTheme), "}()");
|
|
160
|
-
}
|
|
161
|
-
if (enableSystem) {
|
|
162
|
-
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
|
|
163
|
-
? "else{" + updateDOM(defaultTheme, false, false) + "}"
|
|
164
|
-
: "").concat(fallbackColorScheme, "}catch(e){}}()");
|
|
165
|
-
}
|
|
166
|
-
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){}}();");
|
|
167
|
-
})();
|
|
168
|
-
var encodedScript = "data:text/javascript;base64,".concat(encodeBase64(scriptSrc));
|
|
169
|
-
return (_jsx(NextScript, { id: "next-theme-script", strategy: "beforeInteractive", src: encodedScript, nonce: nonce }));
|
|
170
|
-
}, function () { return true; });
|
|
171
|
-
var getTheme = function (key, fallback) {
|
|
172
|
-
if (isServer)
|
|
173
|
-
return undefined;
|
|
174
|
-
var theme;
|
|
175
|
-
try {
|
|
176
|
-
theme = localStorage.getItem(key) || undefined;
|
|
177
|
-
}
|
|
178
|
-
catch (e) {
|
|
179
|
-
}
|
|
180
|
-
return theme || fallback;
|
|
181
|
-
};
|
|
182
|
-
var disableAnimation = function () {
|
|
183
|
-
var d = document;
|
|
184
|
-
var css = d.createElement("style");
|
|
185
|
-
css.appendChild(d.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"));
|
|
186
|
-
d.head.appendChild(css);
|
|
187
|
-
return function () {
|
|
188
|
-
(function () { return window.getComputedStyle(d.body); })();
|
|
189
|
-
setTimeout(function () {
|
|
190
|
-
d.head.removeChild(css);
|
|
191
|
-
}, 1);
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
var getSystemTheme = function (e) {
|
|
195
|
-
if (!e)
|
|
196
|
-
e = window.matchMedia(MEDIA);
|
|
197
|
-
var isDark = e.matches;
|
|
198
|
-
var systemTheme = isDark ? "dark" : "light";
|
|
199
|
-
return systemTheme;
|
|
200
|
-
};
|
|
201
|
-
var encodeBase64 = function (str) {
|
|
202
|
-
return isServer ? Buffer.from(str).toString("base64") : btoa(str);
|
|
203
|
-
};
|
|
204
|
-
export default ThemeProvider;
|
package/config-i18n.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { Redirect as _Redirect, Rewrite as _Rewrite } from "next/dist/lib/load-custom-routes";
|
|
2
|
-
export type Redirect = Omit<_Redirect, "locale"> & {
|
|
3
|
-
locale?: boolean;
|
|
4
|
-
};
|
|
5
|
-
export type Rewrite = Omit<_Rewrite, "locale"> & {
|
|
6
|
-
locale?: boolean;
|
|
7
|
-
};
|
|
8
|
-
type Route = string | {
|
|
9
|
-
[key: string]: Route | string;
|
|
10
|
-
};
|
|
11
|
-
type RoutesByLocale = Record<string, Route>;
|
|
12
|
-
export type Locale = string;
|
|
13
|
-
export type Routes = Record<Locale, RoutesByLocale>;
|
|
14
|
-
type RoutesMapRoute = {
|
|
15
|
-
template: string;
|
|
16
|
-
pathname: string;
|
|
17
|
-
wildcard?: boolean;
|
|
18
|
-
};
|
|
19
|
-
export declare function normaliseUrlPathname(pathname?: string): string;
|
|
20
|
-
export declare function toPath(urlOrPathname?: string): string;
|
|
21
|
-
export declare function encodePathname(pathname?: string): string;
|
|
22
|
-
export declare function getRoutesOfDefaultLocale(routes: Routes | RoutesByLocale, defaultLocale?: Locale): RoutesByLocale;
|
|
23
|
-
export type ConfigI18nOptions = {
|
|
24
|
-
locales: Locale[];
|
|
25
|
-
defaultLocale: Locale;
|
|
26
|
-
hideDefaultLocaleInUrl?: boolean;
|
|
27
|
-
localeParam?: string;
|
|
28
|
-
};
|
|
29
|
-
type Options = ConfigI18nOptions & {
|
|
30
|
-
routes: Routes;
|
|
31
|
-
debug?: boolean;
|
|
32
|
-
permanent?: boolean;
|
|
33
|
-
};
|
|
34
|
-
export declare function getPathRedirect(arg: Pick<GetRedirectsOptions, "localeParam" | "permanent"> & {
|
|
35
|
-
localeSource?: Locale;
|
|
36
|
-
localeDestination?: Locale;
|
|
37
|
-
route: RoutesMapRoute;
|
|
38
|
-
usePathnameAsSource?: boolean;
|
|
39
|
-
}): Redirect | undefined;
|
|
40
|
-
type GetRedirectsOptions = Options;
|
|
41
|
-
export declare function getRedirects(arg: GetRedirectsOptions): Promise<Redirect[]>;
|
|
42
|
-
export declare function getPathRewrite(arg: Pick<GetRewritesOptions, "localeParam"> & {
|
|
43
|
-
localeSource?: Locale;
|
|
44
|
-
localeDestination?: Locale;
|
|
45
|
-
route: RoutesMapRoute;
|
|
46
|
-
}): {
|
|
47
|
-
source: string;
|
|
48
|
-
destination: string;
|
|
49
|
-
} | undefined;
|
|
50
|
-
type GetRewritesOptions = Options;
|
|
51
|
-
export declare function getRewrites(arg: GetRewritesOptions): Promise<Rewrite[]>;
|
|
52
|
-
export {};
|
package/config-i18n.js
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
|
-
var arrayUniqueByProperties = function (array, keys) {
|
|
3
|
-
return array.filter(function (item, idx, arr) {
|
|
4
|
-
return arr.findIndex(function (itemWith) {
|
|
5
|
-
return keys.every(function (k) { return itemWith[k] === item[k]; });
|
|
6
|
-
}) === idx;
|
|
7
|
-
});
|
|
8
|
-
};
|
|
9
|
-
export function normaliseUrlPathname(pathname) {
|
|
10
|
-
if (pathname === void 0) { pathname = ""; }
|
|
11
|
-
return pathname.replace(/\/+\//g, "/").replace(/^\/*(.*?)\/*$/, "$1");
|
|
12
|
-
}
|
|
13
|
-
export function toPath(urlOrPathname) {
|
|
14
|
-
if (urlOrPathname === void 0) { urlOrPathname = ""; }
|
|
15
|
-
var pathname = "";
|
|
16
|
-
try {
|
|
17
|
-
var parsed = new URL(urlOrPathname);
|
|
18
|
-
pathname = parsed.pathname;
|
|
19
|
-
}
|
|
20
|
-
catch (e) {
|
|
21
|
-
pathname = urlOrPathname;
|
|
22
|
-
}
|
|
23
|
-
return pathname.replace(/\/+\//g, "/").replace(/^\/*(.*?)\/*$/, "$1");
|
|
24
|
-
}
|
|
25
|
-
export function encodePathname(pathname) {
|
|
26
|
-
if (pathname === void 0) { pathname = ""; }
|
|
27
|
-
var parts = normaliseUrlPathname(pathname).split("/");
|
|
28
|
-
return parts
|
|
29
|
-
.filter(function (part) { return !!part; })
|
|
30
|
-
.map(function (part) { return encodeURIComponent(part); })
|
|
31
|
-
.join("/");
|
|
32
|
-
}
|
|
33
|
-
function transformRoute(route) {
|
|
34
|
-
var rawPathname = route.pathname, rawTemplate = route.template;
|
|
35
|
-
var pathnameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
36
|
-
var templateParts = rawTemplate.split("/").filter(function (part) { return !!part; });
|
|
37
|
-
var mapPartsByIdx = {};
|
|
38
|
-
var pathname = pathnameParts
|
|
39
|
-
.map(function (part) {
|
|
40
|
-
var _a, _b;
|
|
41
|
-
var hasWildcard = part.endsWith("*");
|
|
42
|
-
part = part.replace("*", "");
|
|
43
|
-
var isDynamic = part.startsWith("{{") && part.endsWith("}}");
|
|
44
|
-
var asValue = isDynamic
|
|
45
|
-
? (_b = (_a = part.match(/{{(.+)}}/)) === null || _a === void 0 ? void 0 : _a[1].trim()) !== null && _b !== void 0 ? _b : ""
|
|
46
|
-
: part.trim();
|
|
47
|
-
var asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
|
|
48
|
-
mapPartsByIdx[asValue] = {
|
|
49
|
-
isDynamic: isDynamic,
|
|
50
|
-
hasWildcard: hasWildcard,
|
|
51
|
-
};
|
|
52
|
-
return isDynamic ? ":".concat(asPath) : asPath;
|
|
53
|
-
})
|
|
54
|
-
.join("/");
|
|
55
|
-
var template = templateParts
|
|
56
|
-
.map(function (part) {
|
|
57
|
-
var _a, _b, _c;
|
|
58
|
-
var isDynamic = part.startsWith("[") && part.endsWith("]");
|
|
59
|
-
var asValue = isDynamic
|
|
60
|
-
? (_b = (_a = part.match(/\[(.+)\]/)) === null || _a === void 0 ? void 0 : _a[1].trim()) !== null && _b !== void 0 ? _b : ""
|
|
61
|
-
: part.trim();
|
|
62
|
-
var hasWildcard = (_c = mapPartsByIdx[asValue]) === null || _c === void 0 ? void 0 : _c.hasWildcard;
|
|
63
|
-
var asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
|
|
64
|
-
return isDynamic ? ":".concat(asPath) : asPath;
|
|
65
|
-
})
|
|
66
|
-
.join("/");
|
|
67
|
-
return { pathname: pathname, template: template };
|
|
68
|
-
}
|
|
69
|
-
function getRoutesMap(map, routesByLocale, pathnameBuffer, templateBuffer) {
|
|
70
|
-
if (map === void 0) { map = {}; }
|
|
71
|
-
if (pathnameBuffer === void 0) { pathnameBuffer = ""; }
|
|
72
|
-
if (templateBuffer === void 0) { templateBuffer = ""; }
|
|
73
|
-
var isSpaRoute = Object.keys(routesByLocale).includes("[spa]");
|
|
74
|
-
for (var key in routesByLocale) {
|
|
75
|
-
var pathOrNestedRoutes = routesByLocale[key];
|
|
76
|
-
var template = "".concat(templateBuffer, "/").concat(key);
|
|
77
|
-
if (typeof pathOrNestedRoutes === "string") {
|
|
78
|
-
if (!isSpaRoute || (isSpaRoute && ["[spa]", "index"].includes(key))) {
|
|
79
|
-
map[template] = {
|
|
80
|
-
template: template,
|
|
81
|
-
pathname: pathOrNestedRoutes,
|
|
82
|
-
wildcard: pathOrNestedRoutes.includes("*"),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
if (!isSpaRoute) {
|
|
88
|
-
getRoutesMap(map, pathOrNestedRoutes, pathnameBuffer, template);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return map;
|
|
93
|
-
}
|
|
94
|
-
function getWithoutIndex(template) {
|
|
95
|
-
return template.replace(/\/index$/, "");
|
|
96
|
-
}
|
|
97
|
-
export function getRoutesOfDefaultLocale(routes, defaultLocale) {
|
|
98
|
-
var routesByLocale = routes;
|
|
99
|
-
if (defaultLocale &&
|
|
100
|
-
routesByLocale[defaultLocale]) {
|
|
101
|
-
return routesByLocale[defaultLocale];
|
|
102
|
-
}
|
|
103
|
-
if (Object.keys(routes).length === 1) {
|
|
104
|
-
var routesWithOneLocale = routes;
|
|
105
|
-
var output = {};
|
|
106
|
-
for (var onlyLocale in routesWithOneLocale) {
|
|
107
|
-
output =
|
|
108
|
-
routesWithOneLocale[onlyLocale];
|
|
109
|
-
}
|
|
110
|
-
return output;
|
|
111
|
-
}
|
|
112
|
-
return routes;
|
|
113
|
-
}
|
|
114
|
-
export function getPathRedirect(arg) {
|
|
115
|
-
var localeSource = arg.localeSource, localeDestination = arg.localeDestination, route = arg.route, usePathnameAsSource = arg.usePathnameAsSource, permanent = arg.permanent;
|
|
116
|
-
var _a = transformRoute(route), routeTemplate = _a.template, pathname = _a.pathname;
|
|
117
|
-
var template = usePathnameAsSource ? pathname : routeTemplate;
|
|
118
|
-
var sourcePrefix = localeSource ? "".concat(localeSource, "/") : "";
|
|
119
|
-
var source = getWithoutIndex("/".concat(normaliseUrlPathname(sourcePrefix + template)));
|
|
120
|
-
var destinationPrefix = localeDestination ? "".concat(localeDestination, "/") : "";
|
|
121
|
-
var destination = "/".concat(normaliseUrlPathname(destinationPrefix + pathname));
|
|
122
|
-
if (source === destination)
|
|
123
|
-
return;
|
|
124
|
-
var redirect = {
|
|
125
|
-
source: source,
|
|
126
|
-
destination: destination,
|
|
127
|
-
permanent: Boolean(permanent),
|
|
128
|
-
};
|
|
129
|
-
return redirect;
|
|
130
|
-
}
|
|
131
|
-
export function getRedirects(arg) {
|
|
132
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
133
|
-
var routes, defaultLocale, hideDefaultLocaleInUrl, localeParam, permanent, debug, redirects, locale, routesByLocale, routesMap, template, route, isVisibleDefaultLocale, isHiddenDefaultLocale, cleaned;
|
|
134
|
-
return __generator(this, function (_a) {
|
|
135
|
-
routes = arg.routes, defaultLocale = arg.defaultLocale, hideDefaultLocaleInUrl = arg.hideDefaultLocaleInUrl, localeParam = arg.localeParam, permanent = arg.permanent, debug = arg.debug;
|
|
136
|
-
redirects = [];
|
|
137
|
-
for (locale in routes) {
|
|
138
|
-
routesByLocale = routes[locale];
|
|
139
|
-
routesMap = getRoutesMap({}, routesByLocale);
|
|
140
|
-
for (template in routesMap) {
|
|
141
|
-
route = routesMap[template];
|
|
142
|
-
if (route.pathname !== getWithoutIndex(template)) {
|
|
143
|
-
isVisibleDefaultLocale = locale === defaultLocale && !hideDefaultLocaleInUrl;
|
|
144
|
-
isHiddenDefaultLocale = locale === defaultLocale && hideDefaultLocaleInUrl;
|
|
145
|
-
if (localeParam) {
|
|
146
|
-
if (isVisibleDefaultLocale) {
|
|
147
|
-
redirects.push(getPathRedirect({ localeDestination: locale, route: route, permanent: permanent }));
|
|
148
|
-
}
|
|
149
|
-
else if (isHiddenDefaultLocale) {
|
|
150
|
-
redirects.push(getPathRedirect({ localeSource: locale, route: route, permanent: permanent }));
|
|
151
|
-
}
|
|
152
|
-
else if (locale !== defaultLocale) {
|
|
153
|
-
redirects.push(getPathRedirect({
|
|
154
|
-
localeSource: locale,
|
|
155
|
-
localeDestination: locale,
|
|
156
|
-
route: route,
|
|
157
|
-
permanent: permanent,
|
|
158
|
-
}));
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
redirects.push(getPathRedirect({ route: route, permanent: permanent }));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
if (isVisibleDefaultLocale) {
|
|
166
|
-
redirects.push(getPathRedirect({ localeDestination: locale, route: route, permanent: permanent }));
|
|
167
|
-
}
|
|
168
|
-
else if (locale !== defaultLocale) {
|
|
169
|
-
redirects.push(getPathRedirect({
|
|
170
|
-
localeSource: locale,
|
|
171
|
-
localeDestination: locale,
|
|
172
|
-
route: route,
|
|
173
|
-
permanent: permanent,
|
|
174
|
-
}));
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
redirects.push(getPathRedirect({ route: route, permanent: permanent }));
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
cleaned = arrayUniqueByProperties(redirects.filter(Boolean), ["source", "destination"]).map(function (rewrite) { return (localeParam ? rewrite : __assign(__assign({}, rewrite), { locale: false })); });
|
|
184
|
-
if (debug)
|
|
185
|
-
console.info("[@koine/next/config:getRedirects]", cleaned);
|
|
186
|
-
return [2, cleaned];
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
export function getPathRewrite(arg) {
|
|
191
|
-
var localeSource = arg.localeSource, localeDestination = arg.localeDestination, localeParam = arg.localeParam, route = arg.route;
|
|
192
|
-
var _a = transformRoute(route), pathname = _a.pathname, template = _a.template;
|
|
193
|
-
var sourcePrefix = "";
|
|
194
|
-
if (localeSource)
|
|
195
|
-
sourcePrefix = "".concat(localeSource, "/");
|
|
196
|
-
else if (localeParam)
|
|
197
|
-
sourcePrefix = ":".concat(localeParam, "/");
|
|
198
|
-
var source = "/".concat(normaliseUrlPathname(sourcePrefix + pathname));
|
|
199
|
-
var destinationPrefix = "";
|
|
200
|
-
if (localeDestination)
|
|
201
|
-
destinationPrefix = "".concat(localeDestination, "/");
|
|
202
|
-
else if (localeParam)
|
|
203
|
-
destinationPrefix = ":".concat(localeParam, "/");
|
|
204
|
-
var destination = getWithoutIndex("/".concat(normaliseUrlPathname(destinationPrefix + template)));
|
|
205
|
-
if (source === destination)
|
|
206
|
-
return;
|
|
207
|
-
return {
|
|
208
|
-
source: source,
|
|
209
|
-
destination: destination,
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
export function getRewrites(arg) {
|
|
213
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
214
|
-
var routes, defaultLocale, hideDefaultLocaleInUrl, localeParam, debug, rewrites, locale, routesByLocale, routesMap, template, route, isVisibleDefaultLocale, isHiddenDefaultLocale, cleaned;
|
|
215
|
-
return __generator(this, function (_a) {
|
|
216
|
-
routes = arg.routes, defaultLocale = arg.defaultLocale, hideDefaultLocaleInUrl = arg.hideDefaultLocaleInUrl, localeParam = arg.localeParam, debug = arg.debug;
|
|
217
|
-
rewrites = [];
|
|
218
|
-
for (locale in routes) {
|
|
219
|
-
routesByLocale = routes[locale];
|
|
220
|
-
routesMap = getRoutesMap({}, routesByLocale);
|
|
221
|
-
for (template in routesMap) {
|
|
222
|
-
route = routesMap[template];
|
|
223
|
-
isVisibleDefaultLocale = locale === defaultLocale && !hideDefaultLocaleInUrl;
|
|
224
|
-
isHiddenDefaultLocale = locale === defaultLocale && hideDefaultLocaleInUrl;
|
|
225
|
-
if (localeParam) {
|
|
226
|
-
if (isHiddenDefaultLocale) {
|
|
227
|
-
rewrites.push(getPathRewrite({ localeDestination: locale, route: route }));
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
rewrites.push(getPathRewrite({ localeParam: localeParam, route: route }));
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
if (route.pathname !== getWithoutIndex(template)) {
|
|
235
|
-
if (locale !== defaultLocale || isVisibleDefaultLocale) {
|
|
236
|
-
rewrites.push(getPathRewrite({ localeSource: locale, route: route }));
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
rewrites.push(getPathRewrite({ route: route }));
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
cleaned = arrayUniqueByProperties(rewrites.filter(Boolean), ["source", "destination"]);
|
|
246
|
-
if (debug)
|
|
247
|
-
console.info("[@koine/next/config:getRewrites]", cleaned);
|
|
248
|
-
return [2, cleaned];
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
}
|