@koine/next 2.0.0-beta.75 → 2.0.0-beta.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/12/AnalyticsGoogle.js +3 -33
- package/12/DisableErrorOverlay.js +1 -6
- package/12/Seo.js +1 -5
- package/12/SeoDefaults.js +1 -5
- package/12/seoBuildTags.d.ts +2 -2
- package/12/seoBuildTags.js +1 -94
- package/12/types.js +1 -1
- package/12.js +1 -3
- package/ThemeContext.js +1 -6
- package/ThemeProvider.js +1 -204
- package/cjs/12/AnalyticsGoogle.d.ts +5 -0
- package/cjs/12/AnalyticsGoogle.js +7 -0
- package/cjs/12/DisableErrorOverlay.d.ts +2 -0
- package/cjs/12/DisableErrorOverlay.js +1 -0
- package/cjs/12/Seo.d.ts +23 -0
- package/cjs/12/Seo.js +1 -0
- package/cjs/12/SeoDefaults.d.ts +10 -0
- package/cjs/12/SeoDefaults.js +1 -0
- package/cjs/12/seoBuildTags.d.ts +8 -0
- package/cjs/12/seoBuildTags.js +1 -0
- package/cjs/12/types.d.ts +2 -0
- package/cjs/12/types.js +1 -0
- package/cjs/12.d.ts +3 -0
- package/cjs/12.js +1 -0
- package/cjs/ThemeContext.js +1 -0
- package/cjs/ThemeProvider.js +1 -0
- package/cjs/config.d.ts +7 -0
- package/cjs/config.js +1 -0
- package/cjs/index.d.ts +4 -0
- package/cjs/index.js +1 -0
- package/{utils → cjs}/load.d.ts +1 -0
- package/cjs/load.js +1 -0
- package/cjs/package.json +22 -0
- package/cjs/useTheme.js +1 -0
- package/config.js +1 -77
- package/index.js +1 -4
- package/load.js +1 -6
- package/package.json +24 -56
- package/useTheme.js +1 -5
- package/12.cjs.d.ts +0 -1
- package/12.cjs.default.js +0 -1
- package/12.cjs.js +0 -28
- package/12.cjs.mjs +0 -2
- package/12.esm.js +0 -18
- package/README.md +0 -1
- package/config.cjs.d.ts +0 -1
- package/config.cjs.default.js +0 -1
- package/config.cjs.js +0 -9
- package/config.cjs.mjs +0 -2
- package/config.esm.js +0 -5
- package/index.cjs.d.ts +0 -1
- package/index.cjs.default.js +0 -1
- package/index.cjs.js +0 -25
- package/index.cjs.mjs +0 -2
- package/index.esm.js +0 -14
- package/theme/ThemeContext.js +0 -6
- package/theme/ThemeProvider.js +0 -204
- package/theme/useTheme.js +0 -5
- package/typings.d.ts +0 -61
- package/utils/load.js +0 -5
- /package/{theme → cjs}/ThemeContext.d.ts +0 -0
- /package/{theme → cjs}/ThemeProvider.d.ts +0 -0
- /package/{theme → cjs}/useTheme.d.ts +0 -0
package/12/AnalyticsGoogle.js
CHANGED
|
@@ -1,37 +1,7 @@
|
|
|
1
|
-
"
|
|
2
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useRouter } from "next/router";
|
|
4
|
-
import Script from "next/script";
|
|
5
|
-
import { useEffect, useState } from "react";
|
|
6
|
-
import { gtagPageview } from "@koine/browser";
|
|
7
|
-
export let AnalyticsGoogle = ({ id }) => {
|
|
8
|
-
const uid = id || process.env["NEXT_PUBLIC_GTM_ID"];
|
|
9
|
-
const { events, asPath, query } = useRouter();
|
|
10
|
-
const [ready, setReady] = useState(false);
|
|
11
|
-
const [routed, setRouted] = useState(false);
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const handleRouteChange = () => {
|
|
14
|
-
setRouted(true);
|
|
15
|
-
};
|
|
16
|
-
events.on("routeChangeComplete", handleRouteChange);
|
|
17
|
-
return () => {
|
|
18
|
-
events.off("routeChangeComplete", handleRouteChange);
|
|
19
|
-
};
|
|
20
|
-
}, [events]);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (routed && ready && asPath) {
|
|
23
|
-
gtagPageview(asPath);
|
|
24
|
-
}
|
|
25
|
-
}, [asPath, query, routed, ready]);
|
|
26
|
-
if (!uid) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
return (_jsxs(_Fragment, { children: [_jsx(Script, { id: "google-tagmanager", src: `https://www.googletagmanager.com/gtag/js?id=${id}`, strategy: "afterInteractive", onLoad: () => setReady(true) }), _jsx(Script, { id: "google-analytics", strategy: "afterInteractive", children: `
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import{useRouter as r}from"next/router";import o from"next/script";import{useEffect as n,useState as g}from"react";import{gtagPageview as i}from"@koine/browser";export let AnalyticsGoogle=({id:s})=>{let l=s||process.env.NEXT_PUBLIC_GTM_ID,{events:m,asPath:c,query:d}=r(),[p,f]=g(!1),[w,u]=g(!1);return(n(()=>{let e=()=>{u(!0)};return m.on("routeChangeComplete",e),()=>{m.off("routeChangeComplete",e)}},[m]),n(()=>{w&&p&&c&&i(c)},[c,d,w,p]),l)?t(a,{children:[e(o,{id:"google-tagmanager",src:`https://www.googletagmanager.com/gtag/js?id=${s}`,strategy:"afterInteractive",onLoad:()=>f(!0)}),e(o,{id:"google-analytics",strategy:"afterInteractive",children:`
|
|
30
2
|
window.dataLayer = window.dataLayer || [];
|
|
31
3
|
function gtag(){window.dataLayer.push(arguments);}
|
|
32
4
|
gtag('js', new Date());
|
|
33
5
|
|
|
34
|
-
gtag('config', '${
|
|
35
|
-
`
|
|
36
|
-
};
|
|
37
|
-
export default AnalyticsGoogle;
|
|
6
|
+
gtag('config', '${s}', { 'send_page_view': false });
|
|
7
|
+
`})]}):null};export default AnalyticsGoogle;
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Head from "next/head";
|
|
3
|
-
export let DisableErrorOverlay = () => (_jsx(Head, { children: process.env["NODE_ENV"] === "development" && (_jsx("script", { dangerouslySetInnerHTML: {
|
|
4
|
-
__html: `window.addEventListener('error',event =>{event.stopImmediatePropagation()});window.addEventListener('unhandledrejection',event =>{event.stopImmediatePropagation()});`,
|
|
5
|
-
} })) }));
|
|
6
|
-
export default DisableErrorOverlay;
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import r from"next/head";export let DisableErrorOverlay=()=>e(r,{children:"development"===process.env.NODE_ENV&&e("script",{dangerouslySetInnerHTML:{__html:"window.addEventListener('error',event =>{event.stopImmediatePropagation()});window.addEventListener('unhandledrejection',event =>{event.stopImmediatePropagation()});"}})});export default DisableErrorOverlay;
|
package/12/Seo.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Head from "next/head";
|
|
3
|
-
import { seoBuildTags } from "./seoBuildTags";
|
|
4
|
-
export let Seo = (props) => _jsx(Head, { children: seoBuildTags(props) });
|
|
5
|
-
export default Seo;
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import o from"next/head";import{seoBuildTags as r}from"./seoBuildTags";export let Seo=t=>e(o,{children:r(t)});export default Seo;
|
package/12/SeoDefaults.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Head from "next/head";
|
|
3
|
-
import { seoBuildTags } from "./seoBuildTags";
|
|
4
|
-
export let SeoDefaults = (props) => (_jsx(Head, { children: seoBuildTags(props) }));
|
|
5
|
-
export default SeoDefaults;
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import t from"next/head";import{seoBuildTags as o}from"./seoBuildTags";export let SeoDefaults=r=>e(t,{children:o(r)});export default SeoDefaults;
|
package/12/seoBuildTags.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import type { SeoProps } from "./Seo";
|
|
3
3
|
import type { SeoDefaultsProps } from "./SeoDefaults";
|
|
4
4
|
export type MetaTag = React.DetailedHTMLProps<React.MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>;
|
|
5
5
|
export type LinkTag = React.DetailedHTMLProps<React.LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>;
|
|
6
6
|
type BuildTagsParams = SeoProps & SeoDefaultsProps;
|
|
7
|
-
export declare const seoBuildTags: ({ seo, hidden, keywords, title, titleTemplate, defaultTitle, noindex, nofollow, description, languageAlternates, twitter, facebook, openGraph, og: ogAlias, canonical, metaTags, linkTags, schema, }?: BuildTagsParams) =>
|
|
7
|
+
export declare const seoBuildTags: ({ seo, hidden, keywords, title, titleTemplate, defaultTitle, noindex, nofollow, description, languageAlternates, twitter, facebook, openGraph, og: ogAlias, canonical, metaTags, linkTags, schema, }?: BuildTagsParams) => import("react").ReactNode[];
|
|
8
8
|
export default seoBuildTags;
|
package/12/seoBuildTags.js
CHANGED
|
@@ -1,94 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { isArray } from "@koine/utils";
|
|
4
|
-
const defaults = {
|
|
5
|
-
tplTitle: "",
|
|
6
|
-
};
|
|
7
|
-
export const seoBuildTags = ({ seo, hidden, keywords, title = "", titleTemplate, defaultTitle, noindex, nofollow, description, languageAlternates = [], twitter, facebook, openGraph, og: ogAlias, canonical, metaTags, linkTags, schema, } = {}) => {
|
|
8
|
-
const id = "seo-";
|
|
9
|
-
const render = [];
|
|
10
|
-
const $names = {};
|
|
11
|
-
const $properties = {};
|
|
12
|
-
if (titleTemplate) {
|
|
13
|
-
defaults.tplTitle = titleTemplate;
|
|
14
|
-
}
|
|
15
|
-
title = title || seo?.title || "";
|
|
16
|
-
if (title) {
|
|
17
|
-
if (defaults.tplTitle && defaults.tplTitle !== title) {
|
|
18
|
-
title = defaults.tplTitle.replace(/%s/g, title);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
else if (defaultTitle) {
|
|
22
|
-
title = defaultTitle;
|
|
23
|
-
}
|
|
24
|
-
if (title) {
|
|
25
|
-
render.push(_jsx("title", { children: title }, id + "title"));
|
|
26
|
-
$properties["og:title"] = title;
|
|
27
|
-
}
|
|
28
|
-
$names["robots"] = `${noindex || hidden ? "noindex" : "index"},${nofollow || hidden ? "nofollow" : "follow"}`;
|
|
29
|
-
description = description || seo?.description;
|
|
30
|
-
if (description) {
|
|
31
|
-
$names["description"] = description;
|
|
32
|
-
$properties["og:description"] = description;
|
|
33
|
-
}
|
|
34
|
-
keywords = keywords || seo?.keywords;
|
|
35
|
-
if (keywords) {
|
|
36
|
-
$names["keywords"] = isArray(keywords) ? keywords.join(", ") : keywords;
|
|
37
|
-
}
|
|
38
|
-
if (languageAlternates?.length > 0) {
|
|
39
|
-
languageAlternates.forEach(({ href, hrefLang }) => {
|
|
40
|
-
render.push(_jsx("link", { rel: "alternate", hrefLang: hrefLang, href: href }, id + "languageAlternate-" + hrefLang));
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
if (canonical) {
|
|
44
|
-
render.push(_jsx("link", { rel: "canonical", href: canonical }, id + "canonical"));
|
|
45
|
-
$properties["og:url"] = canonical;
|
|
46
|
-
}
|
|
47
|
-
if (facebook?.appId)
|
|
48
|
-
$properties["fb:app_id"] = facebook.appId;
|
|
49
|
-
if (twitter) {
|
|
50
|
-
if (twitter.cardType)
|
|
51
|
-
$names["twitter:card"] = twitter.cardType;
|
|
52
|
-
if (twitter.site)
|
|
53
|
-
$names["twitter:site"] = twitter.site;
|
|
54
|
-
if (twitter.handle)
|
|
55
|
-
$names["twitter:creator"] = twitter.handle;
|
|
56
|
-
}
|
|
57
|
-
const og = ogAlias || openGraph;
|
|
58
|
-
if (og?.title)
|
|
59
|
-
$properties["og:title"] = og?.title;
|
|
60
|
-
if (og?.description)
|
|
61
|
-
$properties["og:description"] = og?.description;
|
|
62
|
-
if (og?.url)
|
|
63
|
-
$properties["og:url"] = og.url;
|
|
64
|
-
if (og?.type)
|
|
65
|
-
$properties["og:type"] = og.type.toLowerCase();
|
|
66
|
-
if (og?.locale)
|
|
67
|
-
$properties["og:locale"] = og.locale;
|
|
68
|
-
if (og?.siteName)
|
|
69
|
-
$properties["og:siteName"] = og.siteName;
|
|
70
|
-
const ogimage = og?.image || seo?.ogimage;
|
|
71
|
-
if (ogimage)
|
|
72
|
-
$properties["og:image"] = ogimage;
|
|
73
|
-
Object.keys($names).forEach((key) => {
|
|
74
|
-
render.push(_jsx("meta", { name: key, content: $names[key] }, id + "name-" + key));
|
|
75
|
-
});
|
|
76
|
-
Object.keys($properties).forEach((key) => {
|
|
77
|
-
render.push(_jsx("meta", { property: key, content: $properties[key] }, id + "prop-" + +key));
|
|
78
|
-
});
|
|
79
|
-
if (metaTags && metaTags.length > 0) {
|
|
80
|
-
metaTags.forEach((tag) => {
|
|
81
|
-
render.push(_jsx("meta", { ...tag }, id + "meta-" + (tag.name || tag.property || tag.httpEquiv)));
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
if (linkTags?.length) {
|
|
85
|
-
linkTags.forEach((tag) => {
|
|
86
|
-
render.push(_jsx("link", { ...tag }, id + "link-" + (tag.href || tag.rel)));
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
if (schema) {
|
|
90
|
-
render.push(_jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: JSON.stringify(schema) } }, id + "schema"));
|
|
91
|
-
}
|
|
92
|
-
return render;
|
|
93
|
-
};
|
|
94
|
-
export default seoBuildTags;
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{isArray as t}from"@koine/utils";let l={tplTitle:""};export const seoBuildTags=({seo:o,hidden:i,keywords:r,title:a="",titleTemplate:n,defaultTitle:p,noindex:s,nofollow:c,description:g,languageAlternates:h=[],twitter:d,facebook:u,openGraph:m,og:f,canonical:y,metaTags:T,linkTags:k,schema:w}={})=>{let j="seo-",x=[],E={},b={};n&&(l.tplTitle=n),(a=a||o?.title||"")?l.tplTitle&&l.tplTitle!==a&&(a=l.tplTitle.replace(/%s/g,a)):p&&(a=p),a&&(x.push(e("title",{children:a},j+"title")),b["og:title"]=a),E.robots=`${s||i?"noindex":"index"},${c||i?"nofollow":"follow"}`,(g=g||o?.description)&&(E.description=g,b["og:description"]=g),(r=r||o?.keywords)&&(E.keywords=t(r)?r.join(", "):r),h?.length>0&&h.forEach(({href:t,hrefLang:l})=>{x.push(e("link",{rel:"alternate",hrefLang:l,href:t},j+"languageAlternate-"+l))}),y&&(x.push(e("link",{rel:"canonical",href:y},j+"canonical")),b["og:url"]=y),u?.appId&&(b["fb:app_id"]=u.appId),d&&(d.cardType&&(E["twitter:card"]=d.cardType),d.site&&(E["twitter:site"]=d.site),d.handle&&(E["twitter:creator"]=d.handle));let N=f||m;N?.title&&(b["og:title"]=N?.title),N?.description&&(b["og:description"]=N?.description),N?.url&&(b["og:url"]=N.url),N?.type&&(b["og:type"]=N.type.toLowerCase()),N?.locale&&(b["og:locale"]=N.locale),N?.siteName&&(b["og:siteName"]=N.siteName);let I=N?.image||o?.ogimage;return I&&(b["og:image"]=I),Object.keys(E).forEach(t=>{x.push(e("meta",{name:t,content:E[t]},j+"name-"+t))}),Object.keys(b).forEach(t=>{x.push(e("meta",{property:t,content:b[t]},j+"prop-"+ +t))}),T&&T.length>0&&T.forEach(t=>{x.push(e("meta",{...t},j+"meta-"+(t.name||t.property||t.httpEquiv)))}),k?.length&&k.forEach(t=>{x.push(e("link",{...t},j+"link-"+(t.href||t.rel)))}),w&&x.push(e("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(w)}},j+"schema")),x};export default seoBuildTags;
|
package/12/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
package/12.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { DisableErrorOverlay } from "./12/DisableErrorOverlay";
|
|
3
|
-
export * from "./12/types";
|
|
1
|
+
export{AnalyticsGoogle}from"./12/AnalyticsGoogle";export{DisableErrorOverlay}from"./12/DisableErrorOverlay";export*from"./12/types";
|
package/ThemeContext.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export const ThemeContext = createContext({
|
|
3
|
-
setTheme: (_) => { },
|
|
4
|
-
themes: [],
|
|
5
|
-
});
|
|
6
|
-
export default ThemeContext;
|
|
1
|
+
import{createContext as e}from"react";export const ThemeContext=e({setTheme:e=>{},themes:[]});export default ThemeContext;
|
package/ThemeProvider.js
CHANGED
|
@@ -1,204 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import NextScript from "next/script";
|
|
4
|
-
import { memo, useCallback, useEffect, useState } from "react";
|
|
5
|
-
import { isServer } from "@koine/utils";
|
|
6
|
-
import { ThemeContext } from "./ThemeContext";
|
|
7
|
-
const colorSchemes = ["light", "dark"];
|
|
8
|
-
const MEDIA = "(prefers-color-scheme: dark)";
|
|
9
|
-
const THEME_STORAGE_KEY = "theme";
|
|
10
|
-
export const ThemeProvider = ({ forcedTheme, disableTransitionOnChange = false, enableSystem = true, enableColorScheme, themes = ["light", "dark"], defaultTheme = enableSystem ? "system" : "light", attribute = "data-theme", value, children, nonce, }) => {
|
|
11
|
-
const [theme, setThemeState] = useState(() => getTheme(THEME_STORAGE_KEY, defaultTheme));
|
|
12
|
-
const [resolvedTheme, setResolvedTheme] = useState(() => getTheme(THEME_STORAGE_KEY));
|
|
13
|
-
const attrs = !value ? themes : Object.values(value);
|
|
14
|
-
const applyTheme = useCallback((theme) => {
|
|
15
|
-
let resolved = theme;
|
|
16
|
-
if (isServer || !resolved)
|
|
17
|
-
return;
|
|
18
|
-
if (theme === "system" && enableSystem) {
|
|
19
|
-
resolved = getSystemTheme();
|
|
20
|
-
}
|
|
21
|
-
const name = value ? value[resolved] : resolved;
|
|
22
|
-
const enable = disableTransitionOnChange ? disableAnimation() : null;
|
|
23
|
-
const d = document.documentElement;
|
|
24
|
-
if (attribute === "class") {
|
|
25
|
-
d.classList.remove(...attrs);
|
|
26
|
-
if (name)
|
|
27
|
-
d.classList.add(name);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
if (name) {
|
|
31
|
-
d.setAttribute(attribute, name);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
d.removeAttribute(attribute);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (enableColorScheme) {
|
|
38
|
-
const fallback = colorSchemes.includes(defaultTheme)
|
|
39
|
-
? defaultTheme
|
|
40
|
-
: "";
|
|
41
|
-
const colorScheme = colorSchemes.includes(resolved)
|
|
42
|
-
? resolved
|
|
43
|
-
: fallback;
|
|
44
|
-
d.style.colorScheme = colorScheme;
|
|
45
|
-
}
|
|
46
|
-
enable?.();
|
|
47
|
-
}, [
|
|
48
|
-
attribute,
|
|
49
|
-
attrs,
|
|
50
|
-
defaultTheme,
|
|
51
|
-
disableTransitionOnChange,
|
|
52
|
-
enableColorScheme,
|
|
53
|
-
enableSystem,
|
|
54
|
-
value,
|
|
55
|
-
]);
|
|
56
|
-
const setTheme = useCallback((theme) => {
|
|
57
|
-
setThemeState(theme);
|
|
58
|
-
try {
|
|
59
|
-
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
|
60
|
-
}
|
|
61
|
-
catch (e) {
|
|
62
|
-
}
|
|
63
|
-
}, []);
|
|
64
|
-
const handleMediaQuery = useCallback((e) => {
|
|
65
|
-
const resolved = getSystemTheme(e);
|
|
66
|
-
setResolvedTheme(resolved);
|
|
67
|
-
if (theme === "system" && enableSystem && !forcedTheme) {
|
|
68
|
-
applyTheme("system");
|
|
69
|
-
}
|
|
70
|
-
}, [theme, enableSystem, forcedTheme, applyTheme]);
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
const media = window.matchMedia(MEDIA);
|
|
73
|
-
media.addListener(handleMediaQuery);
|
|
74
|
-
handleMediaQuery(media);
|
|
75
|
-
return () => media.removeListener(handleMediaQuery);
|
|
76
|
-
}, [handleMediaQuery]);
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
const handleStorage = (e) => {
|
|
79
|
-
if (e.key !== THEME_STORAGE_KEY) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const theme = e.newValue || defaultTheme;
|
|
83
|
-
setTheme(theme);
|
|
84
|
-
};
|
|
85
|
-
window.addEventListener("storage", handleStorage);
|
|
86
|
-
return () => window.removeEventListener("storage", handleStorage);
|
|
87
|
-
}, [defaultTheme, setTheme]);
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
applyTheme(forcedTheme ?? theme);
|
|
90
|
-
}, [applyTheme, forcedTheme, theme]);
|
|
91
|
-
return (_jsxs(ThemeContext.Provider, { value: {
|
|
92
|
-
theme,
|
|
93
|
-
setTheme,
|
|
94
|
-
forcedTheme,
|
|
95
|
-
resolvedTheme: theme === "system" ? resolvedTheme : theme,
|
|
96
|
-
themes: enableSystem ? [...themes, "system"] : themes,
|
|
97
|
-
systemTheme: (enableSystem ? resolvedTheme : undefined),
|
|
98
|
-
}, children: [_jsx(ThemeScript, { forcedTheme,
|
|
99
|
-
disableTransitionOnChange,
|
|
100
|
-
enableSystem,
|
|
101
|
-
enableColorScheme,
|
|
102
|
-
themes,
|
|
103
|
-
defaultTheme,
|
|
104
|
-
attribute,
|
|
105
|
-
value,
|
|
106
|
-
children,
|
|
107
|
-
attrs,
|
|
108
|
-
nonce }), children] }));
|
|
109
|
-
};
|
|
110
|
-
const ThemeScript = memo(({ forcedTheme, attribute, enableSystem, enableColorScheme, defaultTheme, value, attrs, nonce, }) => {
|
|
111
|
-
const defaultSystem = defaultTheme === "system";
|
|
112
|
-
const optimization = (() => {
|
|
113
|
-
const removeClasses = `d.remove(${attrs
|
|
114
|
-
.map((t) => `'${t}'`)
|
|
115
|
-
.join(",")})`;
|
|
116
|
-
return `var d=document.documentElement.classList;${removeClasses};`;
|
|
117
|
-
})();
|
|
118
|
-
const fallbackColorScheme = (() => {
|
|
119
|
-
if (!enableColorScheme) {
|
|
120
|
-
return "";
|
|
121
|
-
}
|
|
122
|
-
const fallback = colorSchemes.includes(defaultTheme)
|
|
123
|
-
? defaultTheme
|
|
124
|
-
: null;
|
|
125
|
-
if (fallback) {
|
|
126
|
-
return `if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${defaultTheme}'`;
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
return `if(e==='light'||e==='dark')d.style.colorScheme=e`;
|
|
130
|
-
}
|
|
131
|
-
})();
|
|
132
|
-
const updateDOM = (name, literal = false, setColorScheme = true) => {
|
|
133
|
-
const resolvedName = value ? value[name] : name;
|
|
134
|
-
const val = literal ? name + `|| ''` : `'${resolvedName}'`;
|
|
135
|
-
let text = "";
|
|
136
|
-
if (enableColorScheme &&
|
|
137
|
-
setColorScheme &&
|
|
138
|
-
!literal &&
|
|
139
|
-
colorSchemes.includes(name)) {
|
|
140
|
-
text += `d.style.colorScheme = '${name}';`;
|
|
141
|
-
}
|
|
142
|
-
if (attribute === "class") {
|
|
143
|
-
if (literal || resolvedName) {
|
|
144
|
-
text += `d.add(${val})`;
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
text += `null`;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
if (resolvedName) {
|
|
152
|
-
text += `d[s](n, ${val})`;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return text;
|
|
156
|
-
};
|
|
157
|
-
const scriptSrc = (() => {
|
|
158
|
-
if (forcedTheme) {
|
|
159
|
-
return `!function(){${optimization}${updateDOM(forcedTheme)}}()`;
|
|
160
|
-
}
|
|
161
|
-
if (enableSystem) {
|
|
162
|
-
return `!function(){try {${optimization}var e=localStorage.getItem('${THEME_STORAGE_KEY}');if("system"===e||(!e&&${defaultSystem})){var t="${MEDIA}",m=window.matchMedia(t);if(m.media!==t||m.matches){${updateDOM("dark")}}else{${updateDOM("light")}}}else if(e){${value ? `var x=${JSON.stringify(value)};` : ""}${updateDOM(value ? `x[e]` : "e", true)}}${!defaultSystem
|
|
163
|
-
? `else{` + updateDOM(defaultTheme, false, false) + "}"
|
|
164
|
-
: ""}${fallbackColorScheme}}catch(e){}}()`;
|
|
165
|
-
}
|
|
166
|
-
return `!function(){try{${optimization}var e=localStorage.getItem("${THEME_STORAGE_KEY}");if(e){${value ? `var x=${JSON.stringify(value)};` : ""}${updateDOM(value ? `x[e]` : "e", true)}}else{${updateDOM(defaultTheme, false, false)};}${fallbackColorScheme}}catch(t){}}();`;
|
|
167
|
-
})();
|
|
168
|
-
const encodedScript = `data:text/javascript;base64,${encodeBase64(scriptSrc)}`;
|
|
169
|
-
return (_jsx(NextScript, { id: "next-theme-script", strategy: "beforeInteractive", src: encodedScript, nonce: nonce }));
|
|
170
|
-
}, () => true);
|
|
171
|
-
const getTheme = (key, fallback) => {
|
|
172
|
-
if (isServer)
|
|
173
|
-
return undefined;
|
|
174
|
-
let theme;
|
|
175
|
-
try {
|
|
176
|
-
theme = localStorage.getItem(key) || undefined;
|
|
177
|
-
}
|
|
178
|
-
catch (e) {
|
|
179
|
-
}
|
|
180
|
-
return theme || fallback;
|
|
181
|
-
};
|
|
182
|
-
const disableAnimation = () => {
|
|
183
|
-
const d = document;
|
|
184
|
-
const 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 () => {
|
|
188
|
-
(() => window.getComputedStyle(d.body))();
|
|
189
|
-
setTimeout(() => {
|
|
190
|
-
d.head.removeChild(css);
|
|
191
|
-
}, 1);
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
const getSystemTheme = (e) => {
|
|
195
|
-
if (!e)
|
|
196
|
-
e = window.matchMedia(MEDIA);
|
|
197
|
-
const isDark = e.matches;
|
|
198
|
-
const systemTheme = isDark ? "dark" : "light";
|
|
199
|
-
return systemTheme;
|
|
200
|
-
};
|
|
201
|
-
const encodeBase64 = (str) => {
|
|
202
|
-
return isServer ? Buffer.from(str).toString("base64") : btoa(str);
|
|
203
|
-
};
|
|
204
|
-
export default ThemeProvider;
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import r from"next/script";import{memo as o,useCallback as i,useEffect as n,useState as s}from"react";import{isServer as a}from"@koine/utils";import{ThemeContext as m}from"./ThemeContext";let l=["light","dark"],d="(prefers-color-scheme: dark)",c="theme";export const ThemeProvider=({forcedTheme:r,disableTransitionOnChange:o=!1,enableSystem:v=!0,enableColorScheme:y,themes:p=["light","dark"],defaultTheme:g=v?"system":"light",attribute:w="data-theme",value:x,children:S,nonce:k})=>{let[b,L]=s(()=>u(c,g)),[T,j]=s(()=>u(c)),C=x?Object.values(x):p,E=i(e=>{let t=e;if(a||!t)return;"system"===e&&v&&(t=f());let r=x?x[t]:t,i=o?$():null,n=document.documentElement;if("class"===w?(n.classList.remove(...C),r&&n.classList.add(r)):r?n.setAttribute(w,r):n.removeAttribute(w),y){let e=l.includes(g)?g:"",r=l.includes(t)?t:e;n.style.colorScheme=r}i?.()},[w,C,g,o,y,v,x]),I=i(e=>{L(e);try{localStorage.setItem(c,e)}catch(e){}},[]),M=i(e=>{j(f(e)),"system"===b&&v&&!r&&E("system")},[b,v,r,E]);return n(()=>{let e=window.matchMedia(d);return e.addListener(M),M(e),()=>e.removeListener(M)},[M]),n(()=>{let e=e=>{e.key===c&&I(e.newValue||g)};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[g,I]),n(()=>{E(r??b)},[E,r,b]),t(m.Provider,{value:{theme:b,setTheme:I,forcedTheme:r,resolvedTheme:"system"===b?T:b,themes:v?[...p,"system"]:p,systemTheme:v?T:void 0},children:[e(h,{forcedTheme:r,disableTransitionOnChange:o,enableSystem:v,enableColorScheme:y,themes:p,defaultTheme:g,attribute:w,value:x,children:S,attrs:C,nonce:k}),S]})};let h=o(({forcedTheme:t,attribute:o,enableSystem:i,enableColorScheme:n,defaultTheme:s,value:a,attrs:m,nonce:h})=>{let u="system"===s,$=(()=>{let e=`d.remove(${m.map(e=>`'${e}'`).join(",")})`;return`var d=document.documentElement.classList;${e};`})(),f=n?(l.includes(s)?s:null)?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${s}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",y=(e,t=!1,r=!0)=>{let i=a?a[e]:e,s=t?e+"|| ''":`'${i}'`,m="";return n&&r&&!t&&l.includes(e)&&(m+=`d.style.colorScheme = '${e}';`),"class"===o?t||i?m+=`d.add(${s})`:m+="null":i&&(m+=`d[s](n, ${s})`),m},p=t?`!function(){${$}${y(t)}}()`:i?`!function(){try {${$}var e=localStorage.getItem('${c}');if("system"===e||(!e&&${u})){var t="${d}",m=window.matchMedia(t);if(m.media!==t||m.matches){${y("dark")}}else{${y("light")}}}else if(e){${a?`var x=${JSON.stringify(a)};`:""}${y(a?"x[e]":"e",!0)}}${u?"":"else{"+y(s,!1,!1)+"}"}${f}}catch(e){}}()`:`!function(){try{${$}var e=localStorage.getItem("${c}");if(e){${a?`var x=${JSON.stringify(a)};`:""}${y(a?"x[e]":"e",!0)}}else{${y(s,!1,!1)};}${f}}catch(t){}}();`;return e(r,{id:"next-theme-script",strategy:"beforeInteractive",src:`data:text/javascript;base64,${v(p)}`,nonce:h})},()=>!0),u=(e,t)=>{let r;if(!a){try{r=localStorage.getItem(e)||void 0}catch(e){}return r||t}},$=()=>{let e=document,t=e.createElement("style");return t.appendChild(e.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),e.head.appendChild(t),()=>{window.getComputedStyle(e.body),setTimeout(()=>{e.head.removeChild(t)},1)}},f=e=>(e||(e=window.matchMedia(d)),e.matches?"dark":"light"),v=e=>a?Buffer.from(e).toString("base64"):btoa(e);export default ThemeProvider;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import{useRouter as r}from"next/router";import o from"next/script";import{useEffect as n,useState as g}from"react";import{gtagPageview as i}from"@koine/browser";export let AnalyticsGoogle=({id:s})=>{let l=s||process.env.NEXT_PUBLIC_GTM_ID,{events:m,asPath:c,query:d}=r(),[p,f]=g(!1),[w,u]=g(!1);return(n(()=>{let e=()=>{u(!0)};return m.on("routeChangeComplete",e),()=>{m.off("routeChangeComplete",e)}},[m]),n(()=>{w&&p&&c&&i(c)},[c,d,w,p]),l)?t(a,{children:[e(o,{id:"google-tagmanager",src:`https://www.googletagmanager.com/gtag/js?id=${s}`,strategy:"afterInteractive",onLoad:()=>f(!0)}),e(o,{id:"google-analytics",strategy:"afterInteractive",children:`
|
|
2
|
+
window.dataLayer = window.dataLayer || [];
|
|
3
|
+
function gtag(){window.dataLayer.push(arguments);}
|
|
4
|
+
gtag('js', new Date());
|
|
5
|
+
|
|
6
|
+
gtag('config', '${s}', { 'send_page_view': false });
|
|
7
|
+
`})]}):null};export default AnalyticsGoogle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import r from"next/head";export let DisableErrorOverlay=()=>e(r,{children:"development"===process.env.NODE_ENV&&e("script",{dangerouslySetInnerHTML:{__html:"window.addEventListener('error',event =>{event.stopImmediatePropagation()});window.addEventListener('unhandledrejection',event =>{event.stopImmediatePropagation()});"}})});export default DisableErrorOverlay;
|
package/cjs/12/Seo.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { NextSeoProps } from "next-seo/lib/types";
|
|
2
|
+
import { type LinkTag, type MetaTag } from "./seoBuildTags";
|
|
3
|
+
export type SeoData = {
|
|
4
|
+
hidden?: boolean;
|
|
5
|
+
title?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
keywords?: string | string[];
|
|
8
|
+
ogimage?: string;
|
|
9
|
+
};
|
|
10
|
+
type SeoPropsOpenGraph = NextSeoProps["openGraph"] & {
|
|
11
|
+
image?: string;
|
|
12
|
+
};
|
|
13
|
+
export type SeoProps = Omit<NextSeoProps, "additionalMetaTags" | "additionalLinkTags" | "mobileAlternate" | "robotsProps"> & {
|
|
14
|
+
metaTags?: ReadonlyArray<MetaTag>;
|
|
15
|
+
linkTags?: ReadonlyArray<LinkTag>;
|
|
16
|
+
seo?: SeoData;
|
|
17
|
+
hidden?: SeoData["hidden"];
|
|
18
|
+
keywords?: SeoData["keywords"];
|
|
19
|
+
openGraph?: SeoPropsOpenGraph;
|
|
20
|
+
og?: SeoPropsOpenGraph;
|
|
21
|
+
};
|
|
22
|
+
export declare let Seo: (props: SeoProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export default Seo;
|
package/cjs/12/Seo.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import o from"next/head";import{seoBuildTags as r}from"./seoBuildTags";export let Seo=t=>e(o,{children:r(t)});export default Seo;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DefaultSeoProps } from "next-seo/lib/types";
|
|
2
|
+
import type { JsonObject } from "@koine/utils";
|
|
3
|
+
import { type LinkTag, type MetaTag } from "./seoBuildTags";
|
|
4
|
+
export type SeoDefaultsProps = Omit<DefaultSeoProps, "additionalMetaTags" | "additionalLinkTags" | "dangerouslySetAllPagesToNoIndex" | "dangerouslySetAllPagesToNoFollow" | "defaultOpenGraphImageWidth" | "defaultOpenGraphImageHeight" | "defaultOpenGraphVideoWidth" | "defaultOpenGraphVideoHeight" | "mobileAlternate" | "robotsProps"> & {
|
|
5
|
+
metaTags?: ReadonlyArray<MetaTag>;
|
|
6
|
+
linkTags?: ReadonlyArray<LinkTag>;
|
|
7
|
+
schema?: JsonObject;
|
|
8
|
+
};
|
|
9
|
+
export declare let SeoDefaults: (props: SeoDefaultsProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default SeoDefaults;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import t from"next/head";import{seoBuildTags as o}from"./seoBuildTags";export let SeoDefaults=r=>e(t,{children:o(r)});export default SeoDefaults;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { SeoProps } from "./Seo";
|
|
3
|
+
import type { SeoDefaultsProps } from "./SeoDefaults";
|
|
4
|
+
export type MetaTag = React.DetailedHTMLProps<React.MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>;
|
|
5
|
+
export type LinkTag = React.DetailedHTMLProps<React.LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>;
|
|
6
|
+
type BuildTagsParams = SeoProps & SeoDefaultsProps;
|
|
7
|
+
export declare const seoBuildTags: ({ seo, hidden, keywords, title, titleTemplate, defaultTitle, noindex, nofollow, description, languageAlternates, twitter, facebook, openGraph, og: ogAlias, canonical, metaTags, linkTags, schema, }?: BuildTagsParams) => import("react").ReactNode[];
|
|
8
|
+
export default seoBuildTags;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{isArray as t}from"@koine/utils";let l={tplTitle:""};export const seoBuildTags=({seo:o,hidden:i,keywords:r,title:a="",titleTemplate:n,defaultTitle:p,noindex:s,nofollow:c,description:g,languageAlternates:h=[],twitter:d,facebook:u,openGraph:m,og:f,canonical:y,metaTags:T,linkTags:k,schema:w}={})=>{let j="seo-",x=[],E={},b={};n&&(l.tplTitle=n),(a=a||o?.title||"")?l.tplTitle&&l.tplTitle!==a&&(a=l.tplTitle.replace(/%s/g,a)):p&&(a=p),a&&(x.push(e("title",{children:a},j+"title")),b["og:title"]=a),E.robots=`${s||i?"noindex":"index"},${c||i?"nofollow":"follow"}`,(g=g||o?.description)&&(E.description=g,b["og:description"]=g),(r=r||o?.keywords)&&(E.keywords=t(r)?r.join(", "):r),h?.length>0&&h.forEach(({href:t,hrefLang:l})=>{x.push(e("link",{rel:"alternate",hrefLang:l,href:t},j+"languageAlternate-"+l))}),y&&(x.push(e("link",{rel:"canonical",href:y},j+"canonical")),b["og:url"]=y),u?.appId&&(b["fb:app_id"]=u.appId),d&&(d.cardType&&(E["twitter:card"]=d.cardType),d.site&&(E["twitter:site"]=d.site),d.handle&&(E["twitter:creator"]=d.handle));let N=f||m;N?.title&&(b["og:title"]=N?.title),N?.description&&(b["og:description"]=N?.description),N?.url&&(b["og:url"]=N.url),N?.type&&(b["og:type"]=N.type.toLowerCase()),N?.locale&&(b["og:locale"]=N.locale),N?.siteName&&(b["og:siteName"]=N.siteName);let I=N?.image||o?.ogimage;return I&&(b["og:image"]=I),Object.keys(E).forEach(t=>{x.push(e("meta",{name:t,content:E[t]},j+"name-"+t))}),Object.keys(b).forEach(t=>{x.push(e("meta",{property:t,content:b[t]},j+"prop-"+ +t))}),T&&T.length>0&&T.forEach(t=>{x.push(e("meta",{...t},j+"meta-"+(t.name||t.property||t.httpEquiv)))}),k?.length&&k.forEach(t=>{x.push(e("link",{...t},j+"link-"+(t.href||t.rel)))}),w&&x.push(e("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(w)}},j+"schema")),x};export default seoBuildTags;
|
package/cjs/12/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
package/cjs/12.d.ts
ADDED
package/cjs/12.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{AnalyticsGoogle}from"./12/AnalyticsGoogle";export{DisableErrorOverlay}from"./12/DisableErrorOverlay";export*from"./12/types";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext as e}from"react";export const ThemeContext=e({setTheme:e=>{},themes:[]});export default ThemeContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import r from"next/script";import{memo as o,useCallback as i,useEffect as n,useState as s}from"react";import{isServer as a}from"@koine/utils";import{ThemeContext as m}from"./ThemeContext";let l=["light","dark"],d="(prefers-color-scheme: dark)",c="theme";export const ThemeProvider=({forcedTheme:r,disableTransitionOnChange:o=!1,enableSystem:v=!0,enableColorScheme:y,themes:p=["light","dark"],defaultTheme:g=v?"system":"light",attribute:w="data-theme",value:x,children:S,nonce:k})=>{let[b,L]=s(()=>u(c,g)),[T,j]=s(()=>u(c)),C=x?Object.values(x):p,E=i(e=>{let t=e;if(a||!t)return;"system"===e&&v&&(t=f());let r=x?x[t]:t,i=o?$():null,n=document.documentElement;if("class"===w?(n.classList.remove(...C),r&&n.classList.add(r)):r?n.setAttribute(w,r):n.removeAttribute(w),y){let e=l.includes(g)?g:"",r=l.includes(t)?t:e;n.style.colorScheme=r}i?.()},[w,C,g,o,y,v,x]),I=i(e=>{L(e);try{localStorage.setItem(c,e)}catch(e){}},[]),M=i(e=>{j(f(e)),"system"===b&&v&&!r&&E("system")},[b,v,r,E]);return n(()=>{let e=window.matchMedia(d);return e.addListener(M),M(e),()=>e.removeListener(M)},[M]),n(()=>{let e=e=>{e.key===c&&I(e.newValue||g)};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[g,I]),n(()=>{E(r??b)},[E,r,b]),t(m.Provider,{value:{theme:b,setTheme:I,forcedTheme:r,resolvedTheme:"system"===b?T:b,themes:v?[...p,"system"]:p,systemTheme:v?T:void 0},children:[e(h,{forcedTheme:r,disableTransitionOnChange:o,enableSystem:v,enableColorScheme:y,themes:p,defaultTheme:g,attribute:w,value:x,children:S,attrs:C,nonce:k}),S]})};let h=o(({forcedTheme:t,attribute:o,enableSystem:i,enableColorScheme:n,defaultTheme:s,value:a,attrs:m,nonce:h})=>{let u="system"===s,$=(()=>{let e=`d.remove(${m.map(e=>`'${e}'`).join(",")})`;return`var d=document.documentElement.classList;${e};`})(),f=n?(l.includes(s)?s:null)?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${s}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",y=(e,t=!1,r=!0)=>{let i=a?a[e]:e,s=t?e+"|| ''":`'${i}'`,m="";return n&&r&&!t&&l.includes(e)&&(m+=`d.style.colorScheme = '${e}';`),"class"===o?t||i?m+=`d.add(${s})`:m+="null":i&&(m+=`d[s](n, ${s})`),m},p=t?`!function(){${$}${y(t)}}()`:i?`!function(){try {${$}var e=localStorage.getItem('${c}');if("system"===e||(!e&&${u})){var t="${d}",m=window.matchMedia(t);if(m.media!==t||m.matches){${y("dark")}}else{${y("light")}}}else if(e){${a?`var x=${JSON.stringify(a)};`:""}${y(a?"x[e]":"e",!0)}}${u?"":"else{"+y(s,!1,!1)+"}"}${f}}catch(e){}}()`:`!function(){try{${$}var e=localStorage.getItem("${c}");if(e){${a?`var x=${JSON.stringify(a)};`:""}${y(a?"x[e]":"e",!0)}}else{${y(s,!1,!1)};}${f}}catch(t){}}();`;return e(r,{id:"next-theme-script",strategy:"beforeInteractive",src:`data:text/javascript;base64,${v(p)}`,nonce:h})},()=>!0),u=(e,t)=>{let r;if(!a){try{r=localStorage.getItem(e)||void 0}catch(e){}return r||t}},$=()=>{let e=document,t=e.createElement("style");return t.appendChild(e.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),e.head.appendChild(t),()=>{window.getComputedStyle(e.body),setTimeout(()=>{e.head.removeChild(t)},1)}},f=e=>(e||(e=window.matchMedia(d)),e.matches?"dark":"light"),v=e=>a?Buffer.from(e).toString("base64"):btoa(e);export default ThemeProvider;
|
package/cjs/config.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NextConfig } from "next";
|
|
2
|
+
import { type WithI18nAsyncOptions, type WithI18nLegacyOptions } from "@koine/i18n/next";
|
|
3
|
+
export type WithKoineOptions = NextConfig & {
|
|
4
|
+
nx?: boolean;
|
|
5
|
+
svg?: boolean;
|
|
6
|
+
} & WithI18nLegacyOptions & WithI18nAsyncOptions;
|
|
7
|
+
export declare let withKoine: (options?: WithKoineOptions) => NextConfig;
|
package/cjs/config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{withI18n as e,withI18nAsync as r,withI18nLegacy as o}from"@koine/i18n/next";export let withKoine=(n={})=>{let{nx:i,svg:t,i18nRoutes:m,i18nCompiler:s,...a}=n,k={eslint:{ignoreDuringBuilds:!0},typescript:{ignoreBuildErrors:!0},poweredByHeader:!1,experimental:{scrollRestoration:!0,...a.experimental||{}},modularizeImports:{...a.modularizeImports||{},"@koine/api":{transform:"@koine/api/{{member}}"},"@koine/browser":{transform:"@koine/browser/{{member}}"},"@koine/dom":{transform:"@koine/dom/{{member}}"},"@koine/node":{transform:"@koine/node/{{member}}"},"@koine/i18n/?(((\\w*)?/?)*)":{transform:"@koine/i18n/{{ matches.[1] }}/{{member}}"},"@koine/react/?(((\\w*)?/?)*)":{transform:"@koine/react/{{ matches.[1] }}/{{member}}"},"@koine/next/?(((\\w*)?/?)*)":{transform:"@koine/next/{{ matches.[1] }}/{{member}}"},"@koine/utils":{transform:"@koine/utils/{{member}}"}},...a};return(t&&(i?k.nx={svgr:!0}:(delete k.nx,k.webpack=(e,r)=>{let o="function"==typeof k.webpack?k.webpack(e,r):e;return o.module.rules.push({test:/\.svg$/,use:[{loader:"@svgr/webpack",options:{svgoConfig:{plugins:[{name:"removeViewBox",active:!1}]}}}]}),o})),m)?o({...k,i18nRoutes:m}):s?i?r({...k,i18nCompiler:s}):e({...k,i18nCompiler:s}):k};
|
package/cjs/index.d.ts
ADDED
package/cjs/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{load}from"./load";export{ThemeContext}from"./ThemeContext";export{ThemeProvider}from"./ThemeProvider";export{useTheme}from"./useTheme";
|
package/{utils → cjs}/load.d.ts
RENAMED
package/cjs/load.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function load(e,o){return new Promise(t=>{setTimeout(()=>t(e),o)})}export default load;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@koine/next",
|
|
3
|
+
"sideEffects": false,
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@koine/browser": "*",
|
|
6
|
+
"@koine/utils": "*",
|
|
7
|
+
"@koine/i18n": "*"
|
|
8
|
+
},
|
|
9
|
+
"peerDependencies": {
|
|
10
|
+
"next": "^14.0.4",
|
|
11
|
+
"next-seo": "^6.4.0",
|
|
12
|
+
"react": "^18.2.0"
|
|
13
|
+
},
|
|
14
|
+
"peerDependenciesMeta": {
|
|
15
|
+
"next-seo": {
|
|
16
|
+
"optional": true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"module": "./index.js",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "./index.js"
|
|
22
|
+
}
|
package/cjs/useTheme.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useContext as e}from"react";import{ThemeContext as t}from"./ThemeContext";export const useTheme=()=>e(t);export default useTheme;
|