@koine/next 2.0.0-beta.5 → 2.0.0-beta.50
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.d.ts +0 -1
- package/12/DisableErrorOverlay.d.ts +0 -5
- package/12/NextProgress.d.ts +1 -4
- package/12/Seo.d.ts +0 -24
- package/12/SeoDefaults.d.ts +0 -3
- package/12/seoBuildTags.d.ts +0 -15
- package/12/types-seo.d.ts +0 -0
- package/12/types.d.ts +1 -0
- 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/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 +109 -0
- 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 -2
- package/index.esm.js +14 -0
- package/package.json +29 -83
- package/theme/ThemeContext.d.ts +11 -0
- package/theme/ThemeProvider.d.ts +17 -0
- package/theme/useTheme.d.ts +4 -0
- package/utils/load.d.ts +1 -0
- package/12/AnalyticsGoogle.js +0 -79
- package/12/AnalyticsGoogle.mjs +0 -60
- package/12/DisableErrorOverlay.js +0 -31
- package/12/DisableErrorOverlay.mjs +0 -16
- package/12/DynamicNamespaces.d.ts +0 -13
- package/12/DynamicNamespaces.js +0 -23
- package/12/DynamicNamespaces.mjs +0 -8
- package/12/Favicon.d.ts +0 -4
- package/12/Favicon.js +0 -29
- package/12/Favicon.mjs +0 -10
- package/12/Link.d.ts +0 -10
- package/12/Link.js +0 -38
- package/12/Link.mjs +0 -20
- package/12/NextProgress.js +0 -69
- package/12/NextProgress.mjs +0 -51
- package/12/Seo.js +0 -29
- package/12/Seo.mjs +0 -30
- package/12/SeoDefaults.js +0 -31
- package/12/SeoDefaults.mjs +0 -14
- package/12/T.d.ts +0 -16
- package/12/T.js +0 -43
- package/12/T.mjs +0 -27
- package/12/ThemeContext.d.ts +0 -17
- package/12/ThemeContext.js +0 -25
- package/12/ThemeContext.mjs +0 -7
- package/12/ThemeProvider.d.ts +0 -35
- package/12/ThemeProvider.js +0 -256
- package/12/ThemeProvider.mjs +0 -245
- package/12/TransText.d.ts +0 -3
- package/12/TransText.js +0 -23
- package/12/TransText.mjs +0 -4
- package/12/app/AppHead.d.ts +0 -3
- package/12/app/AppHead.js +0 -31
- package/12/app/AppHead.mjs +0 -12
- package/12/app/AppMain.d.ts +0 -35
- package/12/app/AppMain.js +0 -6
- package/12/app/AppMain.mjs +0 -1
- package/12/app/css/AppMain.d.ts +0 -9
- package/12/app/css/AppMain.js +0 -39
- package/12/app/css/AppMain.mjs +0 -24
- package/12/app/css/AppTheme.d.ts +0 -11
- package/12/app/css/AppTheme.js +0 -33
- package/12/app/css/AppTheme.mjs +0 -17
- package/12/app/css/auth/index.d.ts +0 -11
- package/12/app/css/auth/index.js +0 -40
- package/12/app/css/auth/index.mjs +0 -24
- package/12/app/css/index.d.ts +0 -54
- package/12/app/css/index.js +0 -36
- package/12/app/css/index.mjs +0 -65
- package/12/app/index.d.ts +0 -2
- package/12/app/index.js +0 -7
- package/12/app/index.mjs +0 -2
- package/12/app/sc/AppMain.d.ts +0 -11
- package/12/app/sc/AppMain.js +0 -70
- package/12/app/sc/AppMain.mjs +0 -58
- package/12/app/sc/AppTheme.d.ts +0 -14
- package/12/app/sc/AppTheme.js +0 -33
- package/12/app/sc/AppTheme.mjs +0 -16
- package/12/app/sc/auth/index.d.ts +0 -11
- package/12/app/sc/auth/index.js +0 -40
- package/12/app/sc/auth/index.mjs +0 -24
- package/12/app/sc/index.d.ts +0 -56
- package/12/app/sc/index.js +0 -36
- package/12/app/sc/index.mjs +0 -67
- package/12/document/Document.d.ts +0 -15
- package/12/document/Document.js +0 -49
- package/12/document/Document.mjs +0 -38
- package/12/document/css/index.d.ts +0 -17
- package/12/document/css/index.js +0 -60
- package/12/document/css/index.mjs +0 -53
- package/12/document/index.d.ts +0 -2
- package/12/document/index.js +0 -19
- package/12/document/index.mjs +0 -2
- package/12/document/sc/index.d.ts +0 -19
- package/12/document/sc/index.js +0 -73
- package/12/document/sc/index.mjs +0 -65
- package/12/getT.d.ts +0 -9
- package/12/getT.js +0 -23
- package/12/getT.mjs +0 -8
- package/12/index.d.ts +0 -24
- package/12/index.js +0 -100
- package/12/index.mjs +0 -27
- package/12/seoBuildTags.js +0 -126
- package/12/seoBuildTags.mjs +0 -121
- package/12/to.d.ts +0 -24
- package/12/to.js +0 -31
- package/12/to.mjs +0 -19
- package/12/translationAsOptions.d.ts +0 -3
- package/12/translationAsOptions.js +0 -19
- package/12/translationAsOptions.mjs +0 -9
- package/12/types-i18n.d.ts +0 -118
- package/12/types-i18n.js +0 -15
- package/12/types-i18n.mjs +0 -12
- package/12/types-seo.js +0 -4
- package/12/types-seo.mjs +0 -1
- package/12/useBackUrl.d.ts +0 -2
- package/12/useBackUrl.js +0 -47
- package/12/useBackUrl.mjs +0 -28
- package/12/useDateFormat.d.ts +0 -7
- package/12/useDateFormat.js +0 -42
- package/12/useDateFormat.mjs +0 -26
- package/12/useForm.d.ts +0 -27
- package/12/useForm.js +0 -65
- package/12/useForm.mjs +0 -47
- package/12/useLocale.d.ts +0 -2
- package/12/useLocale.js +0 -25
- package/12/useLocale.mjs +0 -6
- package/12/useT.d.ts +0 -4
- package/12/useT.js +0 -58
- package/12/useT.mjs +0 -39
- package/12/useTheme.d.ts +0 -7
- package/12/useTheme.js +0 -23
- package/12/useTheme.mjs +0 -7
- package/12/useTo.d.ts +0 -3
- package/12/useTo.js +0 -26
- package/12/useTo.mjs +0 -8
- package/config/index.d.ts +0 -160
- package/config/index.js +0 -317
- package/config/index.mjs +0 -315
- package/getSiteUrl.d.ts +0 -8
- package/getSiteUrl.js +0 -24
- package/getSiteUrl.mjs +0 -10
- package/index.js +0 -20
- package/index.mjs +0 -2
- package/load.d.ts +0 -10
- package/load.js +0 -31
- package/load.mjs +0 -13
- package/typings.d.ts +0 -72
package/12/AnalyticsGoogle.d.ts
CHANGED
package/12/NextProgress.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { Simplify } from "@koine/utils";
|
|
2
|
-
import type { WithComponents } from "@koine/react
|
|
2
|
+
import type { WithComponents } from "@koine/react";
|
|
3
3
|
type OwnProps = {
|
|
4
|
-
/** @default 0.3 */
|
|
5
4
|
startAt?: number;
|
|
6
|
-
/** @default true */
|
|
7
5
|
showOnShallow?: boolean;
|
|
8
|
-
/** @default 200 */
|
|
9
6
|
stopDelayMs?: number;
|
|
10
7
|
};
|
|
11
8
|
export type Components = {
|
package/12/Seo.d.ts
CHANGED
|
@@ -4,9 +4,6 @@ import type { SeoData } from "./types-seo";
|
|
|
4
4
|
type SeoPropsOpenGraph = NextSeoProps["openGraph"] & {
|
|
5
5
|
image?: string;
|
|
6
6
|
};
|
|
7
|
-
/**
|
|
8
|
-
* @see https://github.com/garmeeh/next-seo/blob/master/src/types.ts#L395
|
|
9
|
-
*/
|
|
10
7
|
export type SeoProps = Omit<NextSeoProps, "additionalMetaTags" | "additionalLinkTags" | "mobileAlternate" | "robotsProps"> & {
|
|
11
8
|
metaTags?: ReadonlyArray<MetaTag>;
|
|
12
9
|
linkTags?: ReadonlyArray<LinkTag>;
|
|
@@ -16,26 +13,5 @@ export type SeoProps = Omit<NextSeoProps, "additionalMetaTags" | "additionalLink
|
|
|
16
13
|
openGraph?: SeoPropsOpenGraph;
|
|
17
14
|
og?: SeoPropsOpenGraph;
|
|
18
15
|
};
|
|
19
|
-
/**
|
|
20
|
-
* Adapted from [garmeeh/next-seo](https://github.com/garmeeh/next-seo)
|
|
21
|
-
*
|
|
22
|
-
* See also:
|
|
23
|
-
* - https://github.com/catnose99/next-head-seo
|
|
24
|
-
* - https://nextjs.org/docs/api-reference/next/head
|
|
25
|
-
*
|
|
26
|
-
* NB: on the homepage you usually want to customize the `titleTemplate` to avoid
|
|
27
|
-
* doubled app name. Assuming your default seo configuration is something like:
|
|
28
|
-
*
|
|
29
|
-
* ```js
|
|
30
|
-
* {
|
|
31
|
-
* titleTemplate: "%s | MyApp"
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* On the homepage you migh want to override it, e.g.:
|
|
36
|
-
* ```js
|
|
37
|
-
* <Seo title="MyApp | Some description" titleTemplate="%s" />
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
16
|
export declare const Seo: (props: SeoProps) => import("react/jsx-runtime").JSX.Element;
|
|
41
17
|
export default Seo;
|
package/12/SeoDefaults.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { DefaultSeoProps } from "next-seo/lib/types";
|
|
2
2
|
import { type LinkTag, type MetaTag } from "./seoBuildTags";
|
|
3
|
-
/**
|
|
4
|
-
* @see https://github.com/garmeeh/next-seo/blob/master/src/types.ts#L413
|
|
5
|
-
*/
|
|
6
3
|
export type SeoDefaultsProps = Omit<DefaultSeoProps, "additionalMetaTags" | "additionalLinkTags" | "dangerouslySetAllPagesToNoIndex" | "dangerouslySetAllPagesToNoFollow" | "defaultOpenGraphImageWidth" | "defaultOpenGraphImageHeight" | "defaultOpenGraphVideoWidth" | "defaultOpenGraphVideoHeight" | "mobileAlternate" | "robotsProps"> & {
|
|
7
4
|
metaTags?: ReadonlyArray<MetaTag>;
|
|
8
5
|
linkTags?: ReadonlyArray<LinkTag>;
|
package/12/seoBuildTags.d.ts
CHANGED
|
@@ -4,20 +4,5 @@ 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
|
-
/**
|
|
8
|
-
* Comparing to `next-seo` we do a couple of things in addition while many
|
|
9
|
-
* others are removed.
|
|
10
|
-
*
|
|
11
|
-
* - Add `seo` meta object coming from a CMS probably
|
|
12
|
-
* - Add `ogimage` and `openGraph.image` as single image source
|
|
13
|
-
* - Add `og` alias to define `openGraph`
|
|
14
|
-
* - Add check for `title` equal to `templateTitle` to avoid meta titles like
|
|
15
|
-
* "My site | My site" often happening in homepages
|
|
16
|
-
* - Remove the open graph videos and images
|
|
17
|
-
*
|
|
18
|
-
* - Shorter code
|
|
19
|
-
*
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
7
|
export declare const seoBuildTags: ({ seo, hidden, keywords, title, titleTemplate, defaultTitle, noindex, nofollow, description, languageAlternates, twitter, facebook, openGraph, og: ogAlias, canonical, metaTags, linkTags, }?: BuildTagsParams) => React.ReactNode[];
|
|
23
8
|
export default seoBuildTags;
|
package/12/types-seo.d.ts
CHANGED
|
File without changes
|
package/12/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
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/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
|
+
var next = require('@koine/i18n/next');
|
|
6
|
+
|
|
7
|
+
let withKoine=(r={})=>{let{nx:t=!0,svg:o=!0,i18n:i,...n}=r,s={eslint:{ignoreDuringBuilds:!0},typescript:{ignoreBuildErrors:!0},poweredByHeader:!1,experimental:{scrollRestoration:!0,...n.experimental||{}},...n};return (o&&(t?s.nx={svgr:!0}:(delete s.nx,s.webpack=(e,r)=>{let t="function"==typeof s.webpack?s.webpack(e,r):e;return t.module.rules.push({test:/\.svg$/,use:[{loader:"@svgr/webpack",options:{svgoConfig:{plugins:[{name:"removeViewBox",active:!1}]}}}]}),t})),i)?next.withI18nLegacy({...r,...s,i18n:i}):s};
|
|
8
|
+
|
|
9
|
+
exports.withKoine = withKoine;
|
package/config.cjs.mjs
ADDED
package/config.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
} & Partial<WithI18nLegacyOptions> & WithI18nAsyncOptions;
|
|
7
|
+
export declare let withKoine: (options?: WithKoineOptions) => NextConfig | {
|
|
8
|
+
redirects(): Promise<(Omit<import("next/dist/lib/load-custom-routes").Redirect, "locale"> & {
|
|
9
|
+
locale?: boolean | undefined;
|
|
10
|
+
})[]>;
|
|
11
|
+
rewrites(): Promise<{
|
|
12
|
+
beforeFiles: (Omit<import("next/dist/lib/load-custom-routes").Rewrite, "locale"> & {
|
|
13
|
+
locale?: boolean | undefined;
|
|
14
|
+
})[];
|
|
15
|
+
afterFiles: import("next/dist/lib/load-custom-routes").Rewrite[];
|
|
16
|
+
fallback: import("next/dist/lib/load-custom-routes").Rewrite[];
|
|
17
|
+
}>;
|
|
18
|
+
exportPathMap?: ((defaultMap: import("next/dist/server/config-shared").ExportPathMap, ctx: {
|
|
19
|
+
dev: boolean;
|
|
20
|
+
dir: string;
|
|
21
|
+
outDir: string | null;
|
|
22
|
+
distDir: string;
|
|
23
|
+
buildId: string;
|
|
24
|
+
}) => import("next/dist/server/config-shared").ExportPathMap | Promise<import("next/dist/server/config-shared").ExportPathMap>) | undefined;
|
|
25
|
+
i18n?: import("next/dist/server/config-shared").I18NConfig | null | undefined;
|
|
26
|
+
eslint?: import("next/dist/server/config-shared").ESLintConfig | undefined;
|
|
27
|
+
typescript?: import("next/dist/server/config-shared").TypeScriptConfig | undefined;
|
|
28
|
+
headers?: (() => Promise<import("next/dist/lib/load-custom-routes").Header[]>) | undefined;
|
|
29
|
+
excludeDefaultMomentLocales?: boolean | undefined;
|
|
30
|
+
webpack?: import("next/dist/server/config-shared").NextJsWebpackConfig | null | undefined;
|
|
31
|
+
trailingSlash?: boolean | undefined;
|
|
32
|
+
env?: Record<string, string | undefined> | undefined;
|
|
33
|
+
distDir?: string | undefined;
|
|
34
|
+
cleanDistDir?: boolean | undefined;
|
|
35
|
+
assetPrefix?: string | undefined;
|
|
36
|
+
cacheHandler?: string | undefined;
|
|
37
|
+
cacheMaxMemorySize?: number | undefined;
|
|
38
|
+
useFileSystemPublicRoutes?: boolean | undefined;
|
|
39
|
+
generateBuildId?: (() => string | Promise<string | null> | null) | undefined;
|
|
40
|
+
generateEtags?: boolean | undefined;
|
|
41
|
+
pageExtensions?: string[] | undefined;
|
|
42
|
+
compress?: boolean | undefined;
|
|
43
|
+
analyticsId?: string | undefined;
|
|
44
|
+
poweredByHeader?: boolean | undefined;
|
|
45
|
+
images?: Partial<import("next/dist/shared/lib/image-config").ImageConfigComplete> | undefined;
|
|
46
|
+
devIndicators?: {
|
|
47
|
+
buildActivity?: boolean | undefined;
|
|
48
|
+
buildActivityPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left" | undefined;
|
|
49
|
+
} | undefined;
|
|
50
|
+
onDemandEntries?: {
|
|
51
|
+
maxInactiveAge?: number | undefined;
|
|
52
|
+
pagesBufferLength?: number | undefined;
|
|
53
|
+
} | undefined;
|
|
54
|
+
amp?: {
|
|
55
|
+
canonicalBase?: string | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
basePath?: string | undefined;
|
|
58
|
+
sassOptions?: {
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
} | undefined;
|
|
61
|
+
productionBrowserSourceMaps?: boolean | undefined;
|
|
62
|
+
optimizeFonts?: boolean | undefined;
|
|
63
|
+
reactProductionProfiling?: boolean | undefined;
|
|
64
|
+
reactStrictMode?: boolean | null | undefined;
|
|
65
|
+
publicRuntimeConfig?: {
|
|
66
|
+
[key: string]: any;
|
|
67
|
+
} | undefined;
|
|
68
|
+
serverRuntimeConfig?: {
|
|
69
|
+
[key: string]: any;
|
|
70
|
+
} | undefined;
|
|
71
|
+
httpAgentOptions?: {
|
|
72
|
+
keepAlive?: boolean | undefined;
|
|
73
|
+
} | undefined;
|
|
74
|
+
outputFileTracing?: boolean | undefined;
|
|
75
|
+
staticPageGenerationTimeout?: number | undefined;
|
|
76
|
+
crossOrigin?: false | "anonymous" | "use-credentials" | undefined;
|
|
77
|
+
swcMinify?: boolean | undefined;
|
|
78
|
+
compiler?: {
|
|
79
|
+
reactRemoveProperties?: boolean | {
|
|
80
|
+
properties?: string[] | undefined;
|
|
81
|
+
} | undefined;
|
|
82
|
+
relay?: {
|
|
83
|
+
src: string;
|
|
84
|
+
artifactDirectory?: string | undefined;
|
|
85
|
+
language?: "typescript" | "javascript" | "flow" | undefined;
|
|
86
|
+
eagerEsModules?: boolean | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
removeConsole?: boolean | {
|
|
89
|
+
exclude?: string[] | undefined;
|
|
90
|
+
} | undefined;
|
|
91
|
+
styledComponents?: boolean | import("next/dist/server/config-shared").StyledComponentsConfig | undefined;
|
|
92
|
+
emotion?: boolean | import("next/dist/server/config-shared").EmotionConfig | undefined;
|
|
93
|
+
} | undefined;
|
|
94
|
+
output?: "standalone" | "export" | undefined;
|
|
95
|
+
transpilePackages?: string[] | undefined;
|
|
96
|
+
skipMiddlewareUrlNormalize?: boolean | undefined;
|
|
97
|
+
skipTrailingSlashRedirect?: boolean | undefined;
|
|
98
|
+
modularizeImports?: Record<string, {
|
|
99
|
+
transform: string | Record<string, string>;
|
|
100
|
+
preventFullImport?: boolean | undefined;
|
|
101
|
+
skipDefaultConversion?: boolean | undefined;
|
|
102
|
+
}> | undefined;
|
|
103
|
+
logging?: {
|
|
104
|
+
fetches?: {
|
|
105
|
+
fullUrl?: boolean | undefined;
|
|
106
|
+
} | undefined;
|
|
107
|
+
} | undefined;
|
|
108
|
+
experimental?: import("next/dist/server/config-shared").ExperimentalConfig | undefined;
|
|
109
|
+
};
|
package/config.esm.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { withI18nLegacy } from '@koine/i18n/next';
|
|
2
|
+
|
|
3
|
+
let withKoine=(r={})=>{let{nx:t=!0,svg:o=!0,i18n:i,...n}=r,s={eslint:{ignoreDuringBuilds:!0},typescript:{ignoreBuildErrors:!0},poweredByHeader:!1,experimental:{scrollRestoration:!0,...n.experimental||{}},...n};return (o&&(t?s.nx={svgr:!0}:(delete s.nx,s.webpack=(e,r)=>{let t="function"==typeof s.webpack?s.webpack(e,r):e;return t.module.rules.push({test:/\.svg$/,use:[{loader:"@svgr/webpack",options:{svgoConfig:{plugins:[{name:"removeViewBox",active:!1}]}}}]}),t})),i)?withI18nLegacy({...r,...s,i18n:i}):s};
|
|
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,2 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
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
|
@@ -1,104 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koine/next",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@koine/browser": "2.0.0-beta.50",
|
|
6
|
+
"@koine/react": "2.0.0-beta.50",
|
|
7
|
+
"@koine/utils": "2.0.0-beta.50",
|
|
8
|
+
"@koine/i18n": "2.0.0-beta.50"
|
|
9
|
+
},
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"next": "^14.0.4",
|
|
12
|
+
"next-seo": "^6.4.0",
|
|
13
|
+
"react": "^18.2.0"
|
|
14
|
+
},
|
|
4
15
|
"peerDependenciesMeta": {
|
|
5
|
-
"@emotion/react": {
|
|
6
|
-
"optional": true
|
|
7
|
-
},
|
|
8
|
-
"@emotion/server": {
|
|
9
|
-
"optional": true
|
|
10
|
-
},
|
|
11
|
-
"@emotion/styled": {
|
|
12
|
-
"optional": true
|
|
13
|
-
},
|
|
14
|
-
"@hookform/resolvers": {
|
|
15
|
-
"optional": true
|
|
16
|
-
},
|
|
17
16
|
"@kuus/yup": {
|
|
18
17
|
"optional": true
|
|
19
18
|
},
|
|
20
|
-
"@mui/base": {
|
|
21
|
-
"optional": true
|
|
22
|
-
},
|
|
23
|
-
"@mui/material": {
|
|
24
|
-
"optional": true
|
|
25
|
-
},
|
|
26
|
-
"@tiptap/react": {
|
|
27
|
-
"optional": true
|
|
28
|
-
},
|
|
29
|
-
"@tiptap/starter-kit": {
|
|
30
|
-
"optional": true
|
|
31
|
-
},
|
|
32
|
-
"date-fns": {
|
|
33
|
-
"optional": true
|
|
34
|
-
},
|
|
35
|
-
"framer-motion": {
|
|
36
|
-
"optional": true
|
|
37
|
-
},
|
|
38
|
-
"next-auth": {
|
|
39
|
-
"optional": true
|
|
40
|
-
},
|
|
41
19
|
"next-seo": {
|
|
42
20
|
"optional": true
|
|
43
21
|
},
|
|
44
|
-
"next-translate": {
|
|
45
|
-
"optional": true
|
|
46
|
-
},
|
|
47
|
-
"react-hook-form": {
|
|
48
|
-
"optional": true
|
|
49
|
-
},
|
|
50
|
-
"react-icons": {
|
|
51
|
-
"optional": true
|
|
52
|
-
},
|
|
53
|
-
"react-is": {
|
|
54
|
-
"optional": true
|
|
55
|
-
},
|
|
56
|
-
"react-popper": {
|
|
57
|
-
"optional": true
|
|
58
|
-
},
|
|
59
22
|
"react-swipeable": {
|
|
60
23
|
"optional": true
|
|
61
24
|
},
|
|
62
|
-
"styled-components": {
|
|
63
|
-
"optional": true
|
|
64
|
-
},
|
|
65
25
|
"tailwindcss": {
|
|
66
26
|
"optional": true
|
|
67
27
|
}
|
|
68
28
|
},
|
|
69
|
-
"dependencies": {
|
|
70
|
-
"@hookform/resolvers": "^3.1.0",
|
|
71
|
-
"@kuus/yup": "1.0.0-beta.7",
|
|
72
|
-
"@mui/base": "5.0.0-beta.4",
|
|
73
|
-
"@mui/utils": "^5.13.6",
|
|
74
|
-
"@tiptap/react": "2.0.3",
|
|
75
|
-
"@tiptap/starter-kit": "2.0.3",
|
|
76
|
-
"clsx": "^1.2.1",
|
|
77
|
-
"date-fns": "^2.30.0",
|
|
78
|
-
"date-fns-tz": "^2.0.0",
|
|
79
|
-
"framer-motion": "^10.12.17",
|
|
80
|
-
"next": "^13.4.7",
|
|
81
|
-
"next-auth": "^4.22.1",
|
|
82
|
-
"next-seo": "^6.1.0",
|
|
83
|
-
"next-translate": "^2.4.2",
|
|
84
|
-
"react": "^18.2.0",
|
|
85
|
-
"react-hook-form": "^7.45.0",
|
|
86
|
-
"react-icons": "^4.10.1",
|
|
87
|
-
"react-swipeable": "^7.0.1",
|
|
88
|
-
"styled-components": "^5.3.11",
|
|
89
|
-
"ts-debounce": "^4.0.0",
|
|
90
|
-
"tslib": "^2.5.3",
|
|
91
|
-
"type-fest": "^3.12.0"
|
|
92
|
-
},
|
|
93
|
-
"peerDependencies": {},
|
|
94
|
-
"module": "./index.mjs",
|
|
95
|
-
"main": "./index.js",
|
|
96
29
|
"exports": {
|
|
30
|
+
"./package.json": "./package.json",
|
|
97
31
|
".": {
|
|
98
|
-
"
|
|
99
|
-
"
|
|
32
|
+
"module": "./index.esm.js",
|
|
33
|
+
"import": "./index.cjs.mjs",
|
|
34
|
+
"default": "./index.cjs.js"
|
|
35
|
+
},
|
|
36
|
+
"./12": {
|
|
37
|
+
"module": "./12.esm.js",
|
|
38
|
+
"import": "./12.cjs.mjs",
|
|
39
|
+
"default": "./12.cjs.js"
|
|
40
|
+
},
|
|
41
|
+
"./config": {
|
|
42
|
+
"module": "./config.esm.js",
|
|
43
|
+
"import": "./config.cjs.mjs",
|
|
44
|
+
"default": "./config.cjs.js"
|
|
100
45
|
}
|
|
101
46
|
},
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
|
|
47
|
+
"module": "./index.esm.js",
|
|
48
|
+
"main": "./index.cjs.js",
|
|
49
|
+
"version": "2.0.0-beta.50"
|
|
50
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type ThemeContextProps = {
|
|
3
|
+
themes: string[];
|
|
4
|
+
forcedTheme?: string;
|
|
5
|
+
setTheme: (theme: string) => void;
|
|
6
|
+
theme?: string;
|
|
7
|
+
resolvedTheme?: string;
|
|
8
|
+
systemTheme?: "dark" | "light";
|
|
9
|
+
};
|
|
10
|
+
export declare const ThemeContext: import("react").Context<ThemeContextProps>;
|
|
11
|
+
export default ThemeContext;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type ValueObject = {
|
|
3
|
+
[themeName: string]: string;
|
|
4
|
+
};
|
|
5
|
+
export type ThemeProviderProps = React.PropsWithChildren<{
|
|
6
|
+
themes?: string[];
|
|
7
|
+
forcedTheme?: string;
|
|
8
|
+
enableSystem?: boolean;
|
|
9
|
+
disableTransitionOnChange?: boolean;
|
|
10
|
+
enableColorScheme?: boolean;
|
|
11
|
+
defaultTheme?: string;
|
|
12
|
+
attribute?: string | "class";
|
|
13
|
+
value?: ValueObject;
|
|
14
|
+
nonce?: string;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const ThemeProvider: ({ forcedTheme, disableTransitionOnChange, enableSystem, enableColorScheme, themes, defaultTheme, attribute, value, children, nonce, }: ThemeProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export default ThemeProvider;
|
package/utils/load.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function load<T>(component: T, milliseconds: number): Promise<T>;
|
package/12/AnalyticsGoogle.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
function _export(target, all) {
|
|
7
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: all[name]
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
13
|
-
AnalyticsGoogle: function() {
|
|
14
|
-
return AnalyticsGoogle;
|
|
15
|
-
},
|
|
16
|
-
default: function() {
|
|
17
|
-
return _default;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
21
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
22
|
-
const _router = require("next/router");
|
|
23
|
-
const _script = /*#__PURE__*/ _interop_require_default._(require("next/script"));
|
|
24
|
-
const _react = require("react");
|
|
25
|
-
const _gtagPageview = /*#__PURE__*/ _interop_require_default._(require("@koine/browser/gtagPageview"));
|
|
26
|
-
const AnalyticsGoogle = ({ id })=>{
|
|
27
|
-
const uid = id || process.env["NEXT_PUBLIC_GTM_ID"];
|
|
28
|
-
const { events, asPath, query } = (0, _router.useRouter)();
|
|
29
|
-
const [ready, setReady] = (0, _react.useState)(false);
|
|
30
|
-
const [routed, setRouted] = (0, _react.useState)(false);
|
|
31
|
-
// const [url, setUrl] = useState("");
|
|
32
|
-
(0, _react.useEffect)(()=>{
|
|
33
|
-
const handleRouteChange = ()=>{
|
|
34
|
-
setRouted(true);
|
|
35
|
-
};
|
|
36
|
-
events.on("routeChangeComplete", handleRouteChange);
|
|
37
|
-
return ()=>{
|
|
38
|
-
events.off("routeChangeComplete", handleRouteChange);
|
|
39
|
-
};
|
|
40
|
-
}, [
|
|
41
|
-
events
|
|
42
|
-
]);
|
|
43
|
-
(0, _react.useEffect)(()=>{
|
|
44
|
-
if (routed && ready && asPath) {
|
|
45
|
-
// const search = query;
|
|
46
|
-
(0, _gtagPageview.default)(asPath);
|
|
47
|
-
}
|
|
48
|
-
}, [
|
|
49
|
-
asPath,
|
|
50
|
-
query,
|
|
51
|
-
routed,
|
|
52
|
-
ready
|
|
53
|
-
]);
|
|
54
|
-
if (!uid) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
58
|
-
children: [
|
|
59
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_script.default, {
|
|
60
|
-
id: "google-tagmanager",
|
|
61
|
-
src: `https://www.googletagmanager.com/gtag/js?id=${id}`,
|
|
62
|
-
strategy: "afterInteractive",
|
|
63
|
-
onLoad: ()=>setReady(true)
|
|
64
|
-
}),
|
|
65
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_script.default, {
|
|
66
|
-
id: "google-analytics",
|
|
67
|
-
strategy: "afterInteractive",
|
|
68
|
-
children: `
|
|
69
|
-
window.dataLayer = window.dataLayer || [];
|
|
70
|
-
function gtag(){window.dataLayer.push(arguments);}
|
|
71
|
-
gtag('js', new Date());
|
|
72
|
-
|
|
73
|
-
gtag('config', '${id}', { 'send_page_view': false });
|
|
74
|
-
`
|
|
75
|
-
})
|
|
76
|
-
]
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
const _default = AnalyticsGoogle;
|