@koine/next 2.0.0-beta.38 → 2.0.0-beta.39
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/Seo.d.ts +2 -2
- package/12/SeoDefaults.d.ts +1 -1
- package/12/seoBuildTags.d.ts +2 -2
- package/12/types.d.ts +1 -1
- package/12.cjs.d.ts +1 -0
- package/12.cjs.default.js +1 -0
- package/12.cjs.js +28 -0
- package/12.cjs.mjs +2 -0
- package/12.d.ts +3 -0
- package/12.esm.js +18 -0
- package/README.md +13 -0
- package/config-i18n.d.ts +2 -28
- package/config.cjs.d.ts +1 -0
- package/config.cjs.default.js +1 -0
- package/config.cjs.js +9 -0
- package/config.cjs.mjs +2 -0
- package/config.d.ts +2 -2
- package/config.esm.js +5 -0
- package/index.cjs.d.ts +1 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +25 -0
- package/index.cjs.mjs +2 -0
- package/index.d.ts +4 -4
- package/index.esm.js +14 -0
- package/package.json +21 -119
- package/{useTheme.d.ts → theme/useTheme.d.ts} +1 -1
- package/{load.d.ts → utils/load.d.ts} +0 -1
- package/12/AnalyticsGoogle.js +0 -33
- 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/NextProgress.js +0 -40
- package/12/Seo.js +0 -7
- package/12/SeoDefaults.js +0 -7
- package/12/T.d.ts +0 -11
- 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 -11
- 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/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/createUseLocale.d.ts +0 -2
- package/12/createUseLocale.js +0 -7
- package/12/createUseT.d.ts +0 -6
- package/12/createUseT.js +0 -18
- package/12/createUseTo.d.ts +0 -3
- package/12/createUseTo.js +0 -21
- 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/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.js +0 -93
- package/12/translationAsOptions.d.ts +0 -4
- package/12/translationAsOptions.js +0 -10
- package/12/types-seo.js +0 -1
- package/12/types.js +0 -1
- package/12/typings.d.ts +0 -48
- 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/useLocale.d.ts +0 -2
- package/12/useLocale.js +0 -6
- package/12/useT.d.ts +0 -0
- package/12/useT.js +0 -1
- package/ThemeContext.js +0 -6
- package/ThemeProvider.js +0 -204
- package/config-i18n.js +0 -258
- package/config.js +0 -114
- package/index.js +0 -4
- package/load.js +0 -6
- package/typings.d.ts +0 -33
- package/useTheme.js +0 -5
- /package/{ThemeContext.d.ts → theme/ThemeContext.d.ts} +0 -0
- /package/{ThemeProvider.d.ts → theme/ThemeProvider.d.ts} +0 -0
package/12/Seo.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NextSeoProps } from "next-seo/lib/types";
|
|
2
|
-
import { type LinkTag, type MetaTag } from "./seoBuildTags
|
|
3
|
-
import type { SeoData } from "./types-seo
|
|
2
|
+
import { type LinkTag, type MetaTag } from "./seoBuildTags";
|
|
3
|
+
import type { SeoData } from "./types-seo";
|
|
4
4
|
type SeoPropsOpenGraph = NextSeoProps["openGraph"] & {
|
|
5
5
|
image?: string;
|
|
6
6
|
};
|
package/12/SeoDefaults.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DefaultSeoProps } from "next-seo/lib/types";
|
|
2
|
-
import { type LinkTag, type MetaTag } from "./seoBuildTags
|
|
2
|
+
import { type LinkTag, type MetaTag } from "./seoBuildTags";
|
|
3
3
|
export type SeoDefaultsProps = Omit<DefaultSeoProps, "additionalMetaTags" | "additionalLinkTags" | "dangerouslySetAllPagesToNoIndex" | "dangerouslySetAllPagesToNoFollow" | "defaultOpenGraphImageWidth" | "defaultOpenGraphImageHeight" | "defaultOpenGraphVideoWidth" | "defaultOpenGraphVideoHeight" | "mobileAlternate" | "robotsProps"> & {
|
|
4
4
|
metaTags?: ReadonlyArray<MetaTag>;
|
|
5
5
|
linkTags?: ReadonlyArray<LinkTag>;
|
package/12/seoBuildTags.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { SeoProps } from "./Seo
|
|
3
|
-
import type { SeoDefaultsProps } from "./SeoDefaults
|
|
2
|
+
import type { SeoProps } from "./Seo";
|
|
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;
|
package/12/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { SeoDefaultsProps } from "./SeoDefaults
|
|
1
|
+
export type { SeoDefaultsProps } from "./SeoDefaults";
|
package/12.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./12";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./12.cjs.js').default;
|
package/12.cjs.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var router = require('next/router');
|
|
7
|
+
var o = require('next/script');
|
|
8
|
+
var react = require('react');
|
|
9
|
+
var browser = require('@koine/browser');
|
|
10
|
+
var r = require('next/head');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
+
|
|
14
|
+
var o__default = /*#__PURE__*/_interopDefaultLegacy(o);
|
|
15
|
+
var r__default = /*#__PURE__*/_interopDefaultLegacy(r);
|
|
16
|
+
|
|
17
|
+
const AnalyticsGoogle=({id:i})=>{let l=i||process.env.NEXT_PUBLIC_GTM_ID,{events:m,asPath:c,query:d}=router.useRouter(),[p,f]=react.useState(!1),[w,u]=react.useState(!1);return (react.useEffect(()=>{let e=()=>{u(!0);};return m.on("routeChangeComplete",e),()=>{m.off("routeChangeComplete",e);}},[m]),react.useEffect(()=>{w&&p&&c&&browser.gtagPageview(c);},[c,d,w,p]),l)?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(o__default["default"],{id:"google-tagmanager",src:`https://www.googletagmanager.com/gtag/js?id=${i}`,strategy:"afterInteractive",onLoad:()=>f(!0)}),jsxRuntime.jsx(o__default["default"],{id:"google-analytics",strategy:"afterInteractive",children:`
|
|
18
|
+
window.dataLayer = window.dataLayer || [];
|
|
19
|
+
function gtag(){window.dataLayer.push(arguments);}
|
|
20
|
+
gtag('js', new Date());
|
|
21
|
+
|
|
22
|
+
gtag('config', '${i}', { 'send_page_view': false });
|
|
23
|
+
`})]}):null};
|
|
24
|
+
|
|
25
|
+
const DisableErrorOverlay=()=>jsxRuntime.jsx(r__default["default"],{children:"development"===process.env.NODE_ENV&&jsxRuntime.jsx("script",{dangerouslySetInnerHTML:{__html:"window.addEventListener('error',event =>{event.stopImmediatePropagation()});window.addEventListener('unhandledrejection',event =>{event.stopImmediatePropagation()});"}})});
|
|
26
|
+
|
|
27
|
+
exports.AnalyticsGoogle = AnalyticsGoogle;
|
|
28
|
+
exports.DisableErrorOverlay = DisableErrorOverlay;
|
package/12.cjs.mjs
ADDED
package/12.d.ts
ADDED
package/12.esm.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useRouter } from 'next/router';
|
|
3
|
+
import o from 'next/script';
|
|
4
|
+
import { useState, useEffect } from 'react';
|
|
5
|
+
import { gtagPageview } from '@koine/browser';
|
|
6
|
+
import r from 'next/head';
|
|
7
|
+
|
|
8
|
+
const AnalyticsGoogle=({id:i})=>{let l=i||process.env.NEXT_PUBLIC_GTM_ID,{events:m,asPath:c,query:d}=useRouter(),[p,f]=useState(!1),[w,u]=useState(!1);return (useEffect(()=>{let e=()=>{u(!0);};return m.on("routeChangeComplete",e),()=>{m.off("routeChangeComplete",e);}},[m]),useEffect(()=>{w&&p&&c&>agPageview(c);},[c,d,w,p]),l)?jsxs(Fragment,{children:[jsx(o,{id:"google-tagmanager",src:`https://www.googletagmanager.com/gtag/js?id=${i}`,strategy:"afterInteractive",onLoad:()=>f(!0)}),jsx(o,{id:"google-analytics",strategy:"afterInteractive",children:`
|
|
9
|
+
window.dataLayer = window.dataLayer || [];
|
|
10
|
+
function gtag(){window.dataLayer.push(arguments);}
|
|
11
|
+
gtag('js', new Date());
|
|
12
|
+
|
|
13
|
+
gtag('config', '${i}', { 'send_page_view': false });
|
|
14
|
+
`})]}):null};
|
|
15
|
+
|
|
16
|
+
const DisableErrorOverlay=()=>jsx(r,{children:"development"===process.env.NODE_ENV&&jsx("script",{dangerouslySetInnerHTML:{__html:"window.addEventListener('error',event =>{event.stopImmediatePropagation()});window.addEventListener('unhandledrejection',event =>{event.stopImmediatePropagation()});"}})});
|
|
17
|
+
|
|
18
|
+
export { AnalyticsGoogle, DisableErrorOverlay };
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @koine/next
|
|
2
|
+
|
|
3
|
+
## i18n
|
|
4
|
+
|
|
5
|
+
To make typescript work nicely with `useT`, `getT` and `T` make sure to enable [`resolveJsonModule`](https://www.typescriptlang.org/tsconfig#resolveJsonModule) in your `tsconfig.json` file:
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"compilerOptions": {
|
|
10
|
+
"resolveJsonModule": true
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
```
|
package/config-i18n.d.ts
CHANGED
|
@@ -11,18 +11,6 @@ type Route = string | {
|
|
|
11
11
|
type RoutesByLocale = Record<string, Route>;
|
|
12
12
|
export type Locale = string;
|
|
13
13
|
export type Routes = Record<Locale, RoutesByLocale>;
|
|
14
|
-
type RoutesMapRoute = {
|
|
15
|
-
template: string;
|
|
16
|
-
pathname: string;
|
|
17
|
-
wildcard?: boolean;
|
|
18
|
-
};
|
|
19
|
-
export declare function orderRoutes(routes: Routes, defaultLocale: Locale): {
|
|
20
|
-
[x: string]: RoutesByLocale;
|
|
21
|
-
};
|
|
22
|
-
export declare function normaliseUrlPathname(pathname?: string): string;
|
|
23
|
-
export declare function toPath(urlOrPathname?: string): string;
|
|
24
|
-
export declare function encodePathname(pathname?: string): string;
|
|
25
|
-
export declare function getRoutesOfDefaultLocale(routes: Routes | RoutesByLocale, defaultLocale?: Locale): RoutesByLocale;
|
|
26
14
|
export type ConfigI18nOptions = {
|
|
27
15
|
locales: Locale[];
|
|
28
16
|
defaultLocale: Locale;
|
|
@@ -34,22 +22,8 @@ type Options = ConfigI18nOptions & {
|
|
|
34
22
|
debug?: boolean;
|
|
35
23
|
permanent?: boolean;
|
|
36
24
|
};
|
|
37
|
-
export declare function getPathRedirect(arg: Pick<GetRedirectsOptions, "localeParam" | "permanent"> & {
|
|
38
|
-
localeSource?: Locale;
|
|
39
|
-
localeDestination?: Locale;
|
|
40
|
-
route: RoutesMapRoute;
|
|
41
|
-
usePathnameAsSource?: boolean;
|
|
42
|
-
}): Redirect | undefined;
|
|
43
25
|
type GetRedirectsOptions = Options;
|
|
44
|
-
export declare function getRedirects(arg: GetRedirectsOptions):
|
|
45
|
-
export declare function getPathRewrite(arg: Pick<GetRewritesOptions, "localeParam"> & {
|
|
46
|
-
localeSource?: Locale;
|
|
47
|
-
localeDestination?: Locale;
|
|
48
|
-
route: RoutesMapRoute;
|
|
49
|
-
}): {
|
|
50
|
-
source: string;
|
|
51
|
-
destination: string;
|
|
52
|
-
} | undefined;
|
|
26
|
+
export declare function getRedirects(arg: GetRedirectsOptions): Redirect[];
|
|
53
27
|
type GetRewritesOptions = Options;
|
|
54
|
-
export declare function getRewrites(arg: GetRewritesOptions):
|
|
28
|
+
export declare function getRewrites(arg: GetRewritesOptions): Rewrite[];
|
|
55
29
|
export {};
|
package/config.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./config";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./config.cjs.js').default;
|
package/config.cjs.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
let e=(e,t)=>e.filter((e,n,i)=>i.findIndex(n=>t.every(t=>n[t]===e[t]))===n);function t(e,t){let{[t]:n,...i}=e;return {[t]:n,...i}}function n(e=""){return e.replace(/\/+\//g,"/").replace(/^\/*(.*?)\/*$/,"$1")}function i(e){let{pathname:t,template:n}=e,i=t.split("/").filter(e=>!!e),l=n.split("/").filter(e=>!!e),o={};return {pathname:i.map(e=>{let t=e.endsWith("*"),n=(e=e.replace("*","")).startsWith("{{")&&e.endsWith("}}"),i=n?e.match(/{{(.+)}}/)?.[1].trim()??"":e.trim(),l=encodeURIComponent(i)+(t?"*":"");return o[i]={isDynamic:n,hasWildcard:t},n?`:${l}`:l}).join("/"),template:l.map(e=>{let t=e.startsWith("[")&&e.endsWith("]"),n=t?e.match(/\[(.+)\]/)?.[1].trim()??"":e.trim(),i=o[n]?.hasWildcard,l=encodeURIComponent(n)+(i?"*":"");return t?`:${l}`:l}).join("/")}}function l(e={},t,n="",i=""){let o=Object.keys(t).includes("[spa]");for(let r in t){let a=t[r],c=`${i}/${r}`;"string"==typeof a?(!o||o&&["[spa]","index"].includes(r))&&(e[c]={template:c,pathname:a,wildcard:a.includes("*")}):o||l(e,a,n,c);}return e}function o(e){return e.replace(/\/index$/,"")}function r(e){let{localeSource:t,localeDestination:l,route:r,usePathnameAsSource:a,permanent:c}=e,{template:s,pathname:u}=i(r),p=t?`${t}/`:"",f=o(`/${n(p+(a?u:s))}`),h=l?`${l}/`:"",d=`/${n(h+u)}`;if(f!==d)return {source:f,destination:d,permanent:!!c}}function getRedirects(n){let{routes:i,defaultLocale:a,hideDefaultLocaleInUrl:c,localeParam:s,permanent:u,debug:p}=n,f=t(i,a),h=[];for(let e in f){let t=l({},i[e]);for(let n in t){let i=t[n];if(i.pathname!==o(n)){let t=e===a&&!c,n=e===a&&c;s?t?h.push(r({localeDestination:e,route:i,permanent:u})):n?h.push(r({localeSource:e,route:i,permanent:u})):e!==a?h.push(r({localeSource:e,localeDestination:e,route:i,permanent:u})):h.push(r({route:i,permanent:u})):t?h.push(r({localeDestination:e,route:i,permanent:u})):e!==a?h.push(r({localeSource:e,localeDestination:e,route:i,permanent:u})):h.push(r({route:i,permanent:u}));}}}let d=e(h.filter(Boolean),["source","destination"]).map(e=>s?e:{...e,locale:!1});return p&&console.info("[@koine/next/config:getRedirects]",d),d}function a(e){let{localeSource:t,localeDestination:l,localeParam:r,route:a}=e,{pathname:c,template:s}=i(a),u="";t?u=`${t}/`:r&&(u=`:${r}/`);let p=`/${n(u+c)}`,f="";l?f=`${l}/`:r&&(f=`:${r}/`);let h=o(`/${n(f+s)}`);if(p!==h)return {source:p,destination:h}}function getRewrites(n){let{routes:i,defaultLocale:r,hideDefaultLocaleInUrl:c,localeParam:s,debug:u}=n,p=t(i,r),f=[];for(let e in p){let t=l({},i[e]);for(let n in t){let i=t[n],l=e===r&&!c,u=e===r&&c;s?u?f.push(a({localeDestination:e,route:i})):f.push(a({localeParam:s,route:i})):i.pathname!==o(n)&&(e!==r||l?f.push(a({localeSource:e,route:i})):f.push(a({route:i})));}}let h=e(f.filter(Boolean),["source","destination"]);return u&&console.info("[@koine/next/config:getRewrites]",h),h}
|
|
6
|
+
|
|
7
|
+
let withKoine=({nx:i=!0,svg:t=!0,page:n,routes:l,permanent:o,debug:s,...a}={i18n:{locales:["en"],defaultLocale:"en",hideDefaultLocaleInUrl:!1}})=>{let c={eslint:{ignoreDuringBuilds:!0},typescript:{ignoreBuildErrors:!0},poweredByHeader:!1,modularizeImports:{"@koine/i18n":{transform:"@koine/i18n/{{member}}"},"@koine/next/?(((\\w*)?/?)*)":{transform:"@koine/next/{{ matches.[1] }}/{{member}}"},...a.modularizeImports||{}},experimental:{scrollRestoration:!0,...a.experimental||{}},...a};if(t&&(i?c.nx={svgr:!0}:(delete c.nx,c.webpack=(e,r)=>{let i="function"==typeof c.webpack?c.webpack(e,r):e;return i.module.rules.push({test:/\.svg$/,use:[{loader:"@svgr/webpack",options:{svgoConfig:{plugins:[{name:"removeViewBox",active:!1}]}}}]}),i})),a.i18n){let{locales:e,defaultLocale:r,localeParam:i}=a.i18n;i?delete c.i18n:c.i18n={locales:e,defaultLocale:r};}return l?{...c,async redirects(){let r=getRedirects({routes:l,permanent:o,debug:s,...a.i18n});return c.redirects?[...r,...await c.redirects()]:r},async rewrites(){let e=getRewrites({routes:l,debug:s,...a.i18n});if(c.rewrites){let r=await c.rewrites();return Array.isArray(r)?{beforeFiles:e,afterFiles:r,fallback:[]}:{...r,beforeFiles:[...e,...r.beforeFiles||[]]}}return {beforeFiles:e,afterFiles:[],fallback:[]}}}:c};
|
|
8
|
+
|
|
9
|
+
exports.withKoine = withKoine;
|
package/config.cjs.mjs
ADDED
package/config.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ interface KoineNextConfig {
|
|
|
12
12
|
}
|
|
13
13
|
interface MergedConfig extends KoineNextConfig, Omit<NextConfig, "i18n"> {
|
|
14
14
|
}
|
|
15
|
-
export declare
|
|
15
|
+
export declare let withKoine: ({ nx, svg, page, routes, permanent, debug, ...custom }?: MergedConfig) => NextConfig | {
|
|
16
16
|
redirects(): Promise<import("./config-i18n.js").Redirect[]>;
|
|
17
17
|
rewrites(): Promise<{
|
|
18
18
|
beforeFiles: import("./config-i18n.js").Rewrite[];
|
|
@@ -111,4 +111,4 @@ export declare function withKoine({ nx, svg, page, routes, permanent, debug, ...
|
|
|
111
111
|
} | undefined;
|
|
112
112
|
experimental?: import("next/dist/server/config-shared.js").ExperimentalConfig | undefined;
|
|
113
113
|
};
|
|
114
|
-
export
|
|
114
|
+
export {};
|
package/config.esm.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
let e=(e,t)=>e.filter((e,n,i)=>i.findIndex(n=>t.every(t=>n[t]===e[t]))===n);function t(e,t){let{[t]:n,...i}=e;return {[t]:n,...i}}function n(e=""){return e.replace(/\/+\//g,"/").replace(/^\/*(.*?)\/*$/,"$1")}function i(e){let{pathname:t,template:n}=e,i=t.split("/").filter(e=>!!e),l=n.split("/").filter(e=>!!e),o={};return {pathname:i.map(e=>{let t=e.endsWith("*"),n=(e=e.replace("*","")).startsWith("{{")&&e.endsWith("}}"),i=n?e.match(/{{(.+)}}/)?.[1].trim()??"":e.trim(),l=encodeURIComponent(i)+(t?"*":"");return o[i]={isDynamic:n,hasWildcard:t},n?`:${l}`:l}).join("/"),template:l.map(e=>{let t=e.startsWith("[")&&e.endsWith("]"),n=t?e.match(/\[(.+)\]/)?.[1].trim()??"":e.trim(),i=o[n]?.hasWildcard,l=encodeURIComponent(n)+(i?"*":"");return t?`:${l}`:l}).join("/")}}function l(e={},t,n="",i=""){let o=Object.keys(t).includes("[spa]");for(let r in t){let a=t[r],c=`${i}/${r}`;"string"==typeof a?(!o||o&&["[spa]","index"].includes(r))&&(e[c]={template:c,pathname:a,wildcard:a.includes("*")}):o||l(e,a,n,c);}return e}function o(e){return e.replace(/\/index$/,"")}function r(e){let{localeSource:t,localeDestination:l,route:r,usePathnameAsSource:a,permanent:c}=e,{template:s,pathname:u}=i(r),p=t?`${t}/`:"",f=o(`/${n(p+(a?u:s))}`),h=l?`${l}/`:"",d=`/${n(h+u)}`;if(f!==d)return {source:f,destination:d,permanent:!!c}}function getRedirects(n){let{routes:i,defaultLocale:a,hideDefaultLocaleInUrl:c,localeParam:s,permanent:u,debug:p}=n,f=t(i,a),h=[];for(let e in f){let t=l({},i[e]);for(let n in t){let i=t[n];if(i.pathname!==o(n)){let t=e===a&&!c,n=e===a&&c;s?t?h.push(r({localeDestination:e,route:i,permanent:u})):n?h.push(r({localeSource:e,route:i,permanent:u})):e!==a?h.push(r({localeSource:e,localeDestination:e,route:i,permanent:u})):h.push(r({route:i,permanent:u})):t?h.push(r({localeDestination:e,route:i,permanent:u})):e!==a?h.push(r({localeSource:e,localeDestination:e,route:i,permanent:u})):h.push(r({route:i,permanent:u}));}}}let d=e(h.filter(Boolean),["source","destination"]).map(e=>s?e:{...e,locale:!1});return p&&console.info("[@koine/next/config:getRedirects]",d),d}function a(e){let{localeSource:t,localeDestination:l,localeParam:r,route:a}=e,{pathname:c,template:s}=i(a),u="";t?u=`${t}/`:r&&(u=`:${r}/`);let p=`/${n(u+c)}`,f="";l?f=`${l}/`:r&&(f=`:${r}/`);let h=o(`/${n(f+s)}`);if(p!==h)return {source:p,destination:h}}function getRewrites(n){let{routes:i,defaultLocale:r,hideDefaultLocaleInUrl:c,localeParam:s,debug:u}=n,p=t(i,r),f=[];for(let e in p){let t=l({},i[e]);for(let n in t){let i=t[n],l=e===r&&!c,u=e===r&&c;s?u?f.push(a({localeDestination:e,route:i})):f.push(a({localeParam:s,route:i})):i.pathname!==o(n)&&(e!==r||l?f.push(a({localeSource:e,route:i})):f.push(a({route:i})));}}let h=e(f.filter(Boolean),["source","destination"]);return u&&console.info("[@koine/next/config:getRewrites]",h),h}
|
|
2
|
+
|
|
3
|
+
let withKoine=({nx:i=!0,svg:t=!0,page:n,routes:l,permanent:o,debug:s,...a}={i18n:{locales:["en"],defaultLocale:"en",hideDefaultLocaleInUrl:!1}})=>{let c={eslint:{ignoreDuringBuilds:!0},typescript:{ignoreBuildErrors:!0},poweredByHeader:!1,modularizeImports:{"@koine/i18n":{transform:"@koine/i18n/{{member}}"},"@koine/next/?(((\\w*)?/?)*)":{transform:"@koine/next/{{ matches.[1] }}/{{member}}"},...a.modularizeImports||{}},experimental:{scrollRestoration:!0,...a.experimental||{}},...a};if(t&&(i?c.nx={svgr:!0}:(delete c.nx,c.webpack=(e,r)=>{let i="function"==typeof c.webpack?c.webpack(e,r):e;return i.module.rules.push({test:/\.svg$/,use:[{loader:"@svgr/webpack",options:{svgoConfig:{plugins:[{name:"removeViewBox",active:!1}]}}}]}),i})),a.i18n){let{locales:e,defaultLocale:r,localeParam:i}=a.i18n;i?delete c.i18n:c.i18n={locales:e,defaultLocale:r};}return l?{...c,async redirects(){let r=getRedirects({routes:l,permanent:o,debug:s,...a.i18n});return c.redirects?[...r,...await c.redirects()]:r},async rewrites(){let e=getRewrites({routes:l,debug:s,...a.i18n});if(c.rewrites){let r=await c.rewrites();return Array.isArray(r)?{beforeFiles:e,afterFiles:r,fallback:[]}:{...r,beforeFiles:[...e,...r.beforeFiles||[]]}}return {beforeFiles:e,afterFiles:[],fallback:[]}}}:c};
|
|
4
|
+
|
|
5
|
+
export { withKoine };
|
package/index.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./index";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./index.cjs.js').default;
|
package/index.cjs.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var o = require('next/script');
|
|
8
|
+
var utils = require('@koine/utils');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var o__default = /*#__PURE__*/_interopDefaultLegacy(o);
|
|
13
|
+
|
|
14
|
+
function load(e,o){return new Promise(t=>{setTimeout(()=>t(e),o);})}
|
|
15
|
+
|
|
16
|
+
const ThemeContext=react.createContext({setTheme:e=>{},themes:[]});
|
|
17
|
+
|
|
18
|
+
let l=["light","dark"],d="(prefers-color-scheme: dark)",c="theme";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]=react.useState(()=>u(c,g)),[T,j]=react.useState(()=>u(c)),C=x?Object.values(x):p,E=react.useCallback(e=>{let t=e;if(utils.isServer||!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=react.useCallback(e=>{L(e);try{localStorage.setItem(c,e);}catch(e){}},[]),M=react.useCallback(e=>{j(f(e)),"system"===b&&v&&!r&&E("system");},[b,v,r,E]);return react.useEffect(()=>{let e=window.matchMedia(d);return e.addListener(M),M(e),()=>e.removeListener(M)},[M]),react.useEffect(()=>{let e=e=>{e.key===c&&I(e.newValue||g);};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[g,I]),react.useEffect(()=>{E(r??b);},[E,r,b]),jsxRuntime.jsxs(ThemeContext.Provider,{value:{theme:b,setTheme:I,forcedTheme:r,resolvedTheme:"system"===b?T:b,themes:v?[...p,"system"]:p,systemTheme:v?T:void 0},children:[jsxRuntime.jsx(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=react.memo(({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 jsxRuntime.jsx(o__default["default"],{id:"next-theme-script",strategy:"beforeInteractive",src:`data:text/javascript;base64,${v(p)}`,nonce:h})},()=>!0),u=(e,t)=>{let r;if(!utils.isServer){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=>utils.isServer?Buffer.from(e).toString("base64"):btoa(e);
|
|
19
|
+
|
|
20
|
+
const useTheme=()=>react.useContext(ThemeContext);
|
|
21
|
+
|
|
22
|
+
exports.ThemeContext = ThemeContext;
|
|
23
|
+
exports.ThemeProvider = ThemeProvider;
|
|
24
|
+
exports.load = load;
|
|
25
|
+
exports.useTheme = useTheme;
|
package/index.cjs.mjs
ADDED
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { load } from "./load
|
|
2
|
-
export { ThemeContext, type ThemeContextProps } from "./ThemeContext
|
|
3
|
-
export { ThemeProvider, type ThemeProviderProps } from "./ThemeProvider
|
|
4
|
-
export { useTheme, type UseThemeProps } from "./useTheme
|
|
1
|
+
export { load } from "./utils/load";
|
|
2
|
+
export { ThemeContext, type ThemeContextProps } from "./theme/ThemeContext";
|
|
3
|
+
export { ThemeProvider, type ThemeProviderProps } from "./theme/ThemeProvider";
|
|
4
|
+
export { useTheme, type UseThemeProps } from "./theme/useTheme";
|
package/index.esm.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext, useState, useCallback, useEffect, memo, useContext } from 'react';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import o from 'next/script';
|
|
4
|
+
import { isServer } from '@koine/utils';
|
|
5
|
+
|
|
6
|
+
function load(e,o){return new Promise(t=>{setTimeout(()=>t(e),o);})}
|
|
7
|
+
|
|
8
|
+
const ThemeContext=createContext({setTheme:e=>{},themes:[]});
|
|
9
|
+
|
|
10
|
+
let l=["light","dark"],d="(prefers-color-scheme: dark)",c="theme";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]=useState(()=>u(c,g)),[T,j]=useState(()=>u(c)),C=x?Object.values(x):p,E=useCallback(e=>{let t=e;if(isServer||!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=useCallback(e=>{L(e);try{localStorage.setItem(c,e);}catch(e){}},[]),M=useCallback(e=>{j(f(e)),"system"===b&&v&&!r&&E("system");},[b,v,r,E]);return useEffect(()=>{let e=window.matchMedia(d);return e.addListener(M),M(e),()=>e.removeListener(M)},[M]),useEffect(()=>{let e=e=>{e.key===c&&I(e.newValue||g);};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[g,I]),useEffect(()=>{E(r??b);},[E,r,b]),jsxs(ThemeContext.Provider,{value:{theme:b,setTheme:I,forcedTheme:r,resolvedTheme:"system"===b?T:b,themes:v?[...p,"system"]:p,systemTheme:v?T:void 0},children:[jsx(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=memo(({forcedTheme:t,attribute:o$1,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$1?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 jsx(o,{id:"next-theme-script",strategy:"beforeInteractive",src:`data:text/javascript;base64,${v(p)}`,nonce:h})},()=>!0),u=(e,t)=>{let r;if(!isServer){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=>isServer?Buffer.from(e).toString("base64"):btoa(e);
|
|
11
|
+
|
|
12
|
+
const useTheme=()=>useContext(ThemeContext);
|
|
13
|
+
|
|
14
|
+
export { ThemeContext, ThemeProvider, load, useTheme };
|
package/package.json
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
"name": "@koine/next",
|
|
3
3
|
"sideEffects": false,
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@koine/browser": "2.0.0-beta.
|
|
6
|
-
"@koine/
|
|
7
|
-
"@koine/
|
|
8
|
-
|
|
5
|
+
"@koine/browser": "2.0.0-beta.39",
|
|
6
|
+
"@koine/react": "2.0.0-beta.39",
|
|
7
|
+
"@koine/utils": "2.0.0-beta.39"
|
|
8
|
+
},
|
|
9
|
+
"peerDependencies": {
|
|
10
|
+
"next": "^14.0.4",
|
|
11
|
+
"next-seo": "^6.4.0",
|
|
12
|
+
"react": "^18.2.0"
|
|
9
13
|
},
|
|
10
|
-
"peerDependencies": {},
|
|
11
14
|
"peerDependenciesMeta": {
|
|
12
15
|
"@kuus/yup": {
|
|
13
16
|
"optional": true
|
|
14
17
|
},
|
|
15
|
-
"date-fns": {
|
|
16
|
-
"optional": true
|
|
17
|
-
},
|
|
18
18
|
"next-seo": {
|
|
19
19
|
"optional": true
|
|
20
20
|
},
|
|
@@ -25,123 +25,25 @@
|
|
|
25
25
|
"optional": true
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
|
-
"module": "./index.js",
|
|
29
|
-
"type": "module",
|
|
30
28
|
"exports": {
|
|
29
|
+
"./package.json": "./package.json",
|
|
31
30
|
".": {
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"import": "./12/AnalyticsGoogle.js"
|
|
36
|
-
},
|
|
37
|
-
"./12/DisableErrorOverlay": {
|
|
38
|
-
"import": "./12/DisableErrorOverlay.js"
|
|
39
|
-
},
|
|
40
|
-
"./12/DynamicNamespaces": {
|
|
41
|
-
"import": "./12/DynamicNamespaces.js"
|
|
42
|
-
},
|
|
43
|
-
"./12/Favicon": {
|
|
44
|
-
"import": "./12/Favicon.js"
|
|
45
|
-
},
|
|
46
|
-
"./12/NextProgress": {
|
|
47
|
-
"import": "./12/NextProgress.js"
|
|
48
|
-
},
|
|
49
|
-
"./12/Seo": {
|
|
50
|
-
"import": "./12/Seo.js"
|
|
51
|
-
},
|
|
52
|
-
"./12/SeoDefaults": {
|
|
53
|
-
"import": "./12/SeoDefaults.js"
|
|
54
|
-
},
|
|
55
|
-
"./12/T": {
|
|
56
|
-
"import": "./12/T.js"
|
|
57
|
-
},
|
|
58
|
-
"./12/TransText": {
|
|
59
|
-
"import": "./12/TransText.js"
|
|
60
|
-
},
|
|
61
|
-
"./12/app/AppHead": {
|
|
62
|
-
"import": "./12/app/AppHead.js"
|
|
63
|
-
},
|
|
64
|
-
"./12/app/AppMain": {
|
|
65
|
-
"import": "./12/app/AppMain.js"
|
|
66
|
-
},
|
|
67
|
-
"./12/app/css/AppMain": {
|
|
68
|
-
"import": "./12/app/css/AppMain.js"
|
|
69
|
-
},
|
|
70
|
-
"./12/app/css/AppTheme": {
|
|
71
|
-
"import": "./12/app/css/AppTheme.js"
|
|
72
|
-
},
|
|
73
|
-
"./12/app/css": {
|
|
74
|
-
"import": "./12/app/css/index.js"
|
|
75
|
-
},
|
|
76
|
-
"./12/app": {
|
|
77
|
-
"import": "./12/app/index.js"
|
|
78
|
-
},
|
|
79
|
-
"./12/createUseLocale": {
|
|
80
|
-
"import": "./12/createUseLocale.js"
|
|
81
|
-
},
|
|
82
|
-
"./12/createUseT": {
|
|
83
|
-
"import": "./12/createUseT.js"
|
|
84
|
-
},
|
|
85
|
-
"./12/createUseTo": {
|
|
86
|
-
"import": "./12/createUseTo.js"
|
|
87
|
-
},
|
|
88
|
-
"./12/document/Document": {
|
|
89
|
-
"import": "./12/document/Document.js"
|
|
90
|
-
},
|
|
91
|
-
"./12/document/css": {
|
|
92
|
-
"import": "./12/document/css/index.js"
|
|
93
|
-
},
|
|
94
|
-
"./12/document": {
|
|
95
|
-
"import": "./12/document/index.js"
|
|
96
|
-
},
|
|
97
|
-
"./12/getT": {
|
|
98
|
-
"import": "./12/getT.js"
|
|
31
|
+
"module": "./index.esm.js",
|
|
32
|
+
"import": "./index.cjs.mjs",
|
|
33
|
+
"default": "./index.cjs.js"
|
|
99
34
|
},
|
|
100
35
|
"./12": {
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
"import": "./12/seoBuildTags.js"
|
|
105
|
-
},
|
|
106
|
-
"./12/translationAsOptions": {
|
|
107
|
-
"import": "./12/translationAsOptions.js"
|
|
108
|
-
},
|
|
109
|
-
"./12/types-seo": {
|
|
110
|
-
"import": "./12/types-seo.js"
|
|
111
|
-
},
|
|
112
|
-
"./12/types": {
|
|
113
|
-
"import": "./12/types.js"
|
|
114
|
-
},
|
|
115
|
-
"./12/useBackUrl": {
|
|
116
|
-
"import": "./12/useBackUrl.js"
|
|
117
|
-
},
|
|
118
|
-
"./12/useDateFormat": {
|
|
119
|
-
"import": "./12/useDateFormat.js"
|
|
120
|
-
},
|
|
121
|
-
"./12/useLocale": {
|
|
122
|
-
"import": "./12/useLocale.js"
|
|
123
|
-
},
|
|
124
|
-
"./12/useT": {
|
|
125
|
-
"import": "./12/useT.js"
|
|
126
|
-
},
|
|
127
|
-
"./ThemeContext": {
|
|
128
|
-
"import": "./ThemeContext.js"
|
|
129
|
-
},
|
|
130
|
-
"./ThemeProvider": {
|
|
131
|
-
"import": "./ThemeProvider.js"
|
|
132
|
-
},
|
|
133
|
-
"./config-i18n": {
|
|
134
|
-
"import": "./config-i18n.js"
|
|
36
|
+
"module": "./12.esm.js",
|
|
37
|
+
"import": "./12.cjs.mjs",
|
|
38
|
+
"default": "./12.cjs.js"
|
|
135
39
|
},
|
|
136
40
|
"./config": {
|
|
137
|
-
"
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
"import": "./load.js"
|
|
141
|
-
},
|
|
142
|
-
"./useTheme": {
|
|
143
|
-
"import": "./useTheme.js"
|
|
41
|
+
"module": "./config.esm.js",
|
|
42
|
+
"import": "./config.cjs.mjs",
|
|
43
|
+
"default": "./config.cjs.js"
|
|
144
44
|
}
|
|
145
45
|
},
|
|
146
|
-
"
|
|
46
|
+
"module": "./index.esm.js",
|
|
47
|
+
"main": "./index.cjs.js",
|
|
48
|
+
"version": "2.0.0-beta.39"
|
|
147
49
|
}
|
package/12/AnalyticsGoogle.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { __read } from "tslib";
|
|
3
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { useRouter } from "next/router";
|
|
5
|
-
import Script from "next/script";
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
7
|
-
import { gtagPageview } from "@koine/browser";
|
|
8
|
-
export var AnalyticsGoogle = function (_a) {
|
|
9
|
-
var id = _a.id;
|
|
10
|
-
var uid = id || process.env["NEXT_PUBLIC_GTM_ID"];
|
|
11
|
-
var _b = useRouter(), events = _b.events, asPath = _b.asPath, query = _b.query;
|
|
12
|
-
var _c = __read(useState(false), 2), ready = _c[0], setReady = _c[1];
|
|
13
|
-
var _d = __read(useState(false), 2), routed = _d[0], setRouted = _d[1];
|
|
14
|
-
useEffect(function () {
|
|
15
|
-
var handleRouteChange = function () {
|
|
16
|
-
setRouted(true);
|
|
17
|
-
};
|
|
18
|
-
events.on("routeChangeComplete", handleRouteChange);
|
|
19
|
-
return function () {
|
|
20
|
-
events.off("routeChangeComplete", handleRouteChange);
|
|
21
|
-
};
|
|
22
|
-
}, [events]);
|
|
23
|
-
useEffect(function () {
|
|
24
|
-
if (routed && ready && asPath) {
|
|
25
|
-
gtagPageview(asPath);
|
|
26
|
-
}
|
|
27
|
-
}, [asPath, query, routed, ready]);
|
|
28
|
-
if (!uid) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
return (_jsxs(_Fragment, { children: [_jsx(Script, { id: "google-tagmanager", src: "https://www.googletagmanager.com/gtag/js?id=".concat(id), strategy: "afterInteractive", onLoad: function () { return setReady(true); } }), _jsx(Script, { id: "google-analytics", strategy: "afterInteractive", children: "\n window.dataLayer = window.dataLayer || [];\n function gtag(){window.dataLayer.push(arguments);}\n gtag('js', new Date());\n\n gtag('config', '".concat(id, "', { 'send_page_view': false });\n ") })] }));
|
|
32
|
-
};
|
|
33
|
-
export default AnalyticsGoogle;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import Head from "next/head";
|
|
3
|
-
export var DisableErrorOverlay = function () {
|
|
4
|
-
return (_jsx(Head, { children: process.env["NODE_ENV"] === "development" && (_jsx("script", { dangerouslySetInnerHTML: {
|
|
5
|
-
__html: "window.addEventListener('error',event =>{event.stopImmediatePropagation()});window.addEventListener('unhandledrejection',event =>{event.stopImmediatePropagation()});",
|
|
6
|
-
} })) }));
|
|
7
|
-
};
|
|
8
|
-
export default DisableErrorOverlay;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { DynamicNamespacesProps as BaseDynamicNamespacesProps } from "next-translate";
|
|
2
|
-
import BaseDynamicNamespaces from "next-translate/DynamicNamespaces";
|
|
3
|
-
import type { TranslateNamespace } from "@koine/i18n";
|
|
4
|
-
export type DynamicNamespacesProps = Omit<BaseDynamicNamespacesProps, "namespaces"> & {
|
|
5
|
-
namespaces: TranslateNamespace[];
|
|
6
|
-
};
|
|
7
|
-
export declare const DynamicNamespaces: (props: DynamicNamespacesProps) => ReturnType<typeof BaseDynamicNamespaces>;
|
|
8
|
-
export default DynamicNamespaces;
|
package/12/DynamicNamespaces.js
DELETED
package/12/Favicon.d.ts
DELETED
package/12/Favicon.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import Head from "next/head";
|
|
4
|
-
import FaviconTags from "@koine/react/FaviconTags";
|
|
5
|
-
export var Favicon = function (props) { return (_jsx(Head, { children: _jsx(FaviconTags, __assign({}, props)) })); };
|
|
6
|
-
export default Favicon;
|
package/12/NextProgress.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { __read } from "tslib";
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import { useRouter } from "next/router";
|
|
5
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
6
|
-
export var NextProgress = function (_a) {
|
|
7
|
-
var _b = _a.startAt, startAt = _b === void 0 ? 0.3 : _b, _c = _a.showOnShallow, showOnShallow = _c === void 0 ? true : _c, _d = _a.stopDelayMs, stopDelayMs = _d === void 0 ? 200 : _d, _e = _a.Overlay, Overlay = _e === void 0 ? "div" : _e;
|
|
8
|
-
var events = useRouter().events;
|
|
9
|
-
var _f = __read(useState(false), 2), running = _f[0], setRunning = _f[1];
|
|
10
|
-
var timer = useRef(null);
|
|
11
|
-
var routeChangeStart = useCallback(function (_, _a) {
|
|
12
|
-
var shallow = _a.shallow;
|
|
13
|
-
if (!shallow || showOnShallow) {
|
|
14
|
-
setRunning(true);
|
|
15
|
-
}
|
|
16
|
-
}, [showOnShallow]);
|
|
17
|
-
var routeChangeEnd = useCallback(function (_, _a) {
|
|
18
|
-
var shallow = _a.shallow;
|
|
19
|
-
if (!shallow || showOnShallow) {
|
|
20
|
-
if (timer.current) {
|
|
21
|
-
clearTimeout(timer.current);
|
|
22
|
-
}
|
|
23
|
-
timer.current = setTimeout(function () {
|
|
24
|
-
setRunning(false);
|
|
25
|
-
}, stopDelayMs);
|
|
26
|
-
}
|
|
27
|
-
}, [showOnShallow, stopDelayMs, timer]);
|
|
28
|
-
useEffect(function () {
|
|
29
|
-
events.on("routeChangeStart", routeChangeStart);
|
|
30
|
-
events.on("routeChangeComplete", routeChangeEnd);
|
|
31
|
-
events.on("routeChangeError", routeChangeEnd);
|
|
32
|
-
return function () {
|
|
33
|
-
events.off("routeChangeStart", routeChangeStart);
|
|
34
|
-
events.off("routeChangeComplete", routeChangeEnd);
|
|
35
|
-
events.off("routeChangeError", routeChangeEnd);
|
|
36
|
-
};
|
|
37
|
-
}, [events, routeChangeStart, routeChangeEnd]);
|
|
38
|
-
return _jsx(Overlay, { running: running });
|
|
39
|
-
};
|
|
40
|
-
export default NextProgress;
|
package/12/Seo.js
DELETED
package/12/SeoDefaults.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import Head from "next/head";
|
|
3
|
-
import { seoBuildTags } from "./seoBuildTags.js";
|
|
4
|
-
export var SeoDefaults = function (props) {
|
|
5
|
-
return _jsx(Head, { children: seoBuildTags(props) });
|
|
6
|
-
};
|
|
7
|
-
export default SeoDefaults;
|
package/12/T.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { TransProps } from "next-translate";
|
|
3
|
-
import type { TranslateNamespace, TranslationsAllPaths, TranslationsPaths } from "@koine/i18n";
|
|
4
|
-
export type TProps<TNamespace extends TranslateNamespace | undefined = undefined> = (Omit<TransProps, "i18nKey" | "ns"> & {
|
|
5
|
-
i18nKey: TranslationsAllPaths;
|
|
6
|
-
}) | (Omit<TransProps, "i18nKey" | "ns"> & {
|
|
7
|
-
ns: TNamespace;
|
|
8
|
-
i18nKey: TranslationsPaths<TNamespace>;
|
|
9
|
-
});
|
|
10
|
-
export declare const T: <TNamespace extends TranslateNamespace | undefined = undefined>(props: TProps<TNamespace>) => import("react").ReactElement<TProps<TNamespace>, string | import("react").JSXElementConstructor<any>>;
|
|
11
|
-
export default T;
|
package/12/T.js
DELETED