@koine/next 2.0.0-beta.124 → 2.0.0-beta.126

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.
@@ -0,0 +1,22 @@
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
+
11
+ /** Falls back to `.env` variable `NEXT_PUBLIC_GTM_ID` */let AnalyticsGoogle=({id:s})=>{let l=s||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 (// const [url, setUrl] = useState("");
12
+ react.useEffect(()=>{let e=()=>{u(!0);};return m.on("routeChangeComplete",e),()=>{m.off("routeChangeComplete",e);}},[m]),react.useEffect(()=>{w&&p&&c&&// const search = query;
13
+ browser.gtagPageview(c);},[c,d,w,p]),l)?/*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[/*#__PURE__*/jsxRuntime.jsx(o,{id:"google-tagmanager",src:`https://www.googletagmanager.com/gtag/js?id=${s}`,strategy:"afterInteractive",onLoad:()=>f(!0)}),/*#__PURE__*/jsxRuntime.jsx(o,{id:"google-analytics",strategy:"afterInteractive",children:`
14
+ window.dataLayer = window.dataLayer || [];
15
+ function gtag(){window.dataLayer.push(arguments);}
16
+ gtag('js', new Date());
17
+
18
+ gtag('config', '${s}', { 'send_page_view': false });
19
+ `})]}):null};
20
+
21
+ exports.AnalyticsGoogle = AnalyticsGoogle;
22
+ exports.default = AnalyticsGoogle;
@@ -0,0 +1,17 @@
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
+
7
+ /** Falls back to `.env` variable `NEXT_PUBLIC_GTM_ID` */let AnalyticsGoogle=({id:s})=>{let l=s||process.env.NEXT_PUBLIC_GTM_ID,{events:m,asPath:c,query:d}=useRouter(),[p,f]=useState(!1),[w,u]=useState(!1);return (// const [url, setUrl] = useState("");
8
+ useEffect(()=>{let e=()=>{u(!0);};return m.on("routeChangeComplete",e),()=>{m.off("routeChangeComplete",e);}},[m]),useEffect(()=>{w&&p&&c&&// const search = query;
9
+ gtagPageview(c);},[c,d,w,p]),l)?/*#__PURE__*/jsxs(Fragment,{children:[/*#__PURE__*/jsx(o,{id:"google-tagmanager",src:`https://www.googletagmanager.com/gtag/js?id=${s}`,strategy:"afterInteractive",onLoad:()=>f(!0)}),/*#__PURE__*/jsx(o,{id:"google-analytics",strategy:"afterInteractive",children:`
10
+ window.dataLayer = window.dataLayer || [];
11
+ function gtag(){window.dataLayer.push(arguments);}
12
+ gtag('js', new Date());
13
+
14
+ gtag('config', '${s}', { 'send_page_view': false });
15
+ `})]}):null};
16
+
17
+ export { AnalyticsGoogle, AnalyticsGoogle as default };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var r = require('next/head');
7
+
8
+ /**
9
+ * Disable error overlay during `dev`
10
+ *
11
+ * @see https://github.com/vercel/next.js/discussions/13387#discussioncomment-101564
12
+ */let DisableErrorOverlay=()=>/*#__PURE__*/jsxRuntime.jsx(r,{children:"development"===process.env.NODE_ENV&&/*#__PURE__*/jsxRuntime.jsx("script",{dangerouslySetInnerHTML:{__html:"window.addEventListener('error',event =>{event.stopImmediatePropagation()});window.addEventListener('unhandledrejection',event =>{event.stopImmediatePropagation()});"}})});
13
+
14
+ exports.DisableErrorOverlay = DisableErrorOverlay;
15
+ exports.default = DisableErrorOverlay;
@@ -0,0 +1,10 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import r from 'next/head';
3
+
4
+ /**
5
+ * Disable error overlay during `dev`
6
+ *
7
+ * @see https://github.com/vercel/next.js/discussions/13387#discussioncomment-101564
8
+ */let DisableErrorOverlay=()=>/*#__PURE__*/jsx(r,{children:"development"===process.env.NODE_ENV&&/*#__PURE__*/jsx("script",{dangerouslySetInnerHTML:{__html:"window.addEventListener('error',event =>{event.stopImmediatePropagation()});window.addEventListener('unhandledrejection',event =>{event.stopImmediatePropagation()});"}})});
9
+
10
+ export { DisableErrorOverlay, DisableErrorOverlay as default };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { SeoProps } from "./Seo";
3
2
  import type { SeoDefaultsProps } from "./SeoDefaults";
4
3
  export type MetaTag = React.DetailedHTMLProps<React.MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>;
package/12.cjs.js CHANGED
@@ -1,27 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var router = require('next/router');
5
- var o = require('next/script');
6
- var react = require('react');
7
- var browser = require('@koine/browser');
8
- var r = require('next/head');
3
+ var AnalyticsGoogle = require('./12/AnalyticsGoogle.cjs.js');
4
+ var DisableErrorOverlay = require('./12/DisableErrorOverlay.cjs.js');
9
5
 
10
- /** Falls back to `.env` variable `NEXT_PUBLIC_GTM_ID` */let AnalyticsGoogle=({id:s})=>{let l=s||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 (// const [url, setUrl] = useState("");
11
- react.useEffect(()=>{let e=()=>{u(!0);};return m.on("routeChangeComplete",e),()=>{m.off("routeChangeComplete",e);}},[m]),react.useEffect(()=>{w&&p&&c&&// const search = query;
12
- browser.gtagPageview(c);},[c,d,w,p]),l)?/*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[/*#__PURE__*/jsxRuntime.jsx(o,{id:"google-tagmanager",src:`https://www.googletagmanager.com/gtag/js?id=${s}`,strategy:"afterInteractive",onLoad:()=>f(!0)}),/*#__PURE__*/jsxRuntime.jsx(o,{id:"google-analytics",strategy:"afterInteractive",children:`
13
- window.dataLayer = window.dataLayer || [];
14
- function gtag(){window.dataLayer.push(arguments);}
15
- gtag('js', new Date());
16
6
 
17
- gtag('config', '${s}', { 'send_page_view': false });
18
- `})]}):null};
19
7
 
20
- /**
21
- * Disable error overlay during `dev`
22
- *
23
- * @see https://github.com/vercel/next.js/discussions/13387#discussioncomment-101564
24
- */let DisableErrorOverlay=()=>/*#__PURE__*/jsxRuntime.jsx(r,{children:"development"===process.env.NODE_ENV&&/*#__PURE__*/jsxRuntime.jsx("script",{dangerouslySetInnerHTML:{__html:"window.addEventListener('error',event =>{event.stopImmediatePropagation()});window.addEventListener('unhandledrejection',event =>{event.stopImmediatePropagation()});"}})});
25
-
26
- exports.AnalyticsGoogle = AnalyticsGoogle;
27
- exports.DisableErrorOverlay = DisableErrorOverlay;
8
+ exports.AnalyticsGoogle = AnalyticsGoogle.AnalyticsGoogle;
9
+ exports.DisableErrorOverlay = DisableErrorOverlay.DisableErrorOverlay;
package/12.esm.js CHANGED
@@ -1,24 +1,2 @@
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
- /** Falls back to `.env` variable `NEXT_PUBLIC_GTM_ID` */let AnalyticsGoogle=({id:s})=>{let l=s||process.env.NEXT_PUBLIC_GTM_ID,{events:m,asPath:c,query:d}=useRouter(),[p,f]=useState(!1),[w,u]=useState(!1);return (// const [url, setUrl] = useState("");
9
- useEffect(()=>{let e=()=>{u(!0);};return m.on("routeChangeComplete",e),()=>{m.off("routeChangeComplete",e);}},[m]),useEffect(()=>{w&&p&&c&&// const search = query;
10
- gtagPageview(c);},[c,d,w,p]),l)?/*#__PURE__*/jsxs(Fragment,{children:[/*#__PURE__*/jsx(o,{id:"google-tagmanager",src:`https://www.googletagmanager.com/gtag/js?id=${s}`,strategy:"afterInteractive",onLoad:()=>f(!0)}),/*#__PURE__*/jsx(o,{id:"google-analytics",strategy:"afterInteractive",children:`
11
- window.dataLayer = window.dataLayer || [];
12
- function gtag(){window.dataLayer.push(arguments);}
13
- gtag('js', new Date());
14
-
15
- gtag('config', '${s}', { 'send_page_view': false });
16
- `})]}):null};
17
-
18
- /**
19
- * Disable error overlay during `dev`
20
- *
21
- * @see https://github.com/vercel/next.js/discussions/13387#discussioncomment-101564
22
- */let DisableErrorOverlay=()=>/*#__PURE__*/jsx(r,{children:"development"===process.env.NODE_ENV&&/*#__PURE__*/jsx("script",{dangerouslySetInnerHTML:{__html:"window.addEventListener('error',event =>{event.stopImmediatePropagation()});window.addEventListener('unhandledrejection',event =>{event.stopImmediatePropagation()});"}})});
23
-
24
- export { AnalyticsGoogle, DisableErrorOverlay };
1
+ export { AnalyticsGoogle } from './12/AnalyticsGoogle.esm.js';
2
+ export { DisableErrorOverlay } from './12/DisableErrorOverlay.esm.js';
package/ThemeContext.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export type ThemeContextProps = {
3
2
  themes: string[];
4
3
  forcedTheme?: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  type ValueObject = {
3
2
  [themeName: string]: string;
4
3
  };
package/config.cjs.js CHANGED
@@ -6,22 +6,33 @@ var next = require('@koine/i18n/next');
6
6
  /**
7
7
  * @legacy
8
8
  *//**
9
+ * A list of the packages to modularize, if a `scope` is given that will be
10
+ * automatically prepended before a slash e.g. `{scope}/@{lib}`.
11
+ * @example ["components", "utils"]
12
+ *//**
13
+ * The scope of the packages to modularize, if given a slash is automatically
14
+ * appended between the scope and the lib name
15
+ * @example "@"
16
+ *//**
17
+ * Shortcut option to automatically create swc transforms to feed into
18
+ * _Next.js_' `modularizeImports`
19
+ *//**
9
20
  * Get Next.js config with some basic opinionated defaults
10
21
  *
11
22
  * @param {object} options
12
23
  * @property {boolean} [options.nx=false] Nx monorepo setup
13
24
  * @property {boolean} [options.svg=false] SVG to react components
14
- */let withKoine=(i={})=>{let{nx:n,svg:s,i18nRoutes:p,i18nCompiler:l,...a}=i,m={eslint:{ignoreDuringBuilds:!0},// we have this strict check on each commit
25
+ */let withKoine=(s={})=>{let{nx:n,svg:p,i18nRoutes:l,i18nCompiler:a,modularize:u,...m}=s,c={eslint:{ignoreDuringBuilds:!0},// we have this strict check on each commit
15
26
  typescript:{ignoreBuildErrors:!0},// we have this strict check on each commit
16
27
  poweredByHeader:!1,experimental:{// @see https://github.com/vercel/vercel/discussions/5973#discussioncomment-472618
17
28
  // @see critters error https://github.com/vercel/next.js/issues/20742
18
29
  // optimizeCss: true,
19
30
  // @see https://github.com/vercel/next.js/discussions/30174#discussion-3643870
20
- scrollRestoration:!0,...a.experimental||{}},// @see https://www.zhoulujun.net/nextjs/advanced-features/compiler.html#modularize-imports
21
- modularizeImports:{...a.modularizeImports||{},...swc.swcTransformsKoine},...a};return (s&&(n?// @see https://github.com/gregberge/svgr
22
- m.nx={svgr:!0}:(// if falsy just remove the key
23
- delete m.nx,m.webpack=(e,r)=>// ...[_config, options]: Parameters<NonNullable<NextConfig['webpack']>>
31
+ scrollRestoration:!0,...m.experimental||{}},// @see https://www.zhoulujun.net/nextjs/advanced-features/compiler.html#modularize-imports
32
+ modularizeImports:{...u?Array.isArray(u)?u.reduce((r,o)=>({...r,...swc.swcCreateTransforms(o.libs,o.scope)}),{}):swc.swcCreateTransforms(u.libs,u.scope):{},...m.modularizeImports||{},...swc.swcTransformsKoine},...m};return (p&&(n?// @see https://github.com/gregberge/svgr
33
+ c.nx={svgr:!0}:(// if falsy just remove the key
34
+ delete c.nx,c.webpack=(e,r)=>// ...[_config, options]: Parameters<NonNullable<NextConfig['webpack']>>
24
35
  {let o="function"==typeof m.webpack?m.webpack(e,r):e;return(// @see https://dev.to/dolearning/importing-svgs-to-next-js-nna#svgr
25
- o.module.rules.push({test:/\.svg$/,use:[{loader:"@svgr/webpack",options:{svgoConfig:{plugins:[{name:"removeViewBox",active:!1}]}}}]}),o)})),p)?next.withI18nLegacy({...m,i18nRoutes:p}):l?n?next.withI18nAsync({...m,i18nCompiler:l}):next.withI18n({...m,i18nCompiler:l}):m};
36
+ o.module.rules.push({test:/\.svg$/,use:[{loader:"@svgr/webpack",options:{svgoConfig:{plugins:[{name:"removeViewBox",active:!1}]}}}]}),o)})),l)?next.withI18nLegacy({...c,i18nRoutes:l}):a?n?next.withI18nAsync({...c,i18nCompiler:a}):next.withI18n({...c,i18nCompiler:a}):c};
26
37
 
27
38
  exports.withKoine = withKoine;
package/config.d.ts CHANGED
@@ -1,8 +1,14 @@
1
1
  import type { NextConfig } from "next";
2
2
  import { type WithI18nAsyncOptions, type WithI18nLegacyOptions } from "@koine/i18n/next";
3
3
  export type Routes = NonNullable<WithI18nLegacyOptions["i18nRoutes"]>["routes"];
4
+ type ModularizeShortcut = {
5
+ libs: string[];
6
+ scope?: string;
7
+ };
4
8
  export type WithKoineOptions = NextConfig & {
5
9
  nx?: boolean;
6
10
  svg?: boolean;
11
+ modularize?: ModularizeShortcut[] | ModularizeShortcut;
7
12
  } & WithI18nLegacyOptions & WithI18nAsyncOptions;
8
13
  export declare let withKoine: (options?: WithKoineOptions) => NextConfig;
14
+ export {};
package/config.esm.js CHANGED
@@ -1,25 +1,36 @@
1
- import { swcTransformsKoine } from '@koine/node/swc';
1
+ import { swcCreateTransforms, swcTransformsKoine } from '@koine/node/swc';
2
2
  import { withI18nLegacy, withI18nAsync, withI18n } from '@koine/i18n/next';
3
3
 
4
4
  /**
5
5
  * @legacy
6
6
  *//**
7
+ * A list of the packages to modularize, if a `scope` is given that will be
8
+ * automatically prepended before a slash e.g. `{scope}/@{lib}`.
9
+ * @example ["components", "utils"]
10
+ *//**
11
+ * The scope of the packages to modularize, if given a slash is automatically
12
+ * appended between the scope and the lib name
13
+ * @example "@"
14
+ *//**
15
+ * Shortcut option to automatically create swc transforms to feed into
16
+ * _Next.js_' `modularizeImports`
17
+ *//**
7
18
  * Get Next.js config with some basic opinionated defaults
8
19
  *
9
20
  * @param {object} options
10
21
  * @property {boolean} [options.nx=false] Nx monorepo setup
11
22
  * @property {boolean} [options.svg=false] SVG to react components
12
- */let withKoine=(i={})=>{let{nx:n,svg:s,i18nRoutes:p,i18nCompiler:l,...a}=i,m={eslint:{ignoreDuringBuilds:!0},// we have this strict check on each commit
23
+ */let withKoine=(s={})=>{let{nx:n,svg:p,i18nRoutes:l,i18nCompiler:a,modularize:u,...m}=s,c={eslint:{ignoreDuringBuilds:!0},// we have this strict check on each commit
13
24
  typescript:{ignoreBuildErrors:!0},// we have this strict check on each commit
14
25
  poweredByHeader:!1,experimental:{// @see https://github.com/vercel/vercel/discussions/5973#discussioncomment-472618
15
26
  // @see critters error https://github.com/vercel/next.js/issues/20742
16
27
  // optimizeCss: true,
17
28
  // @see https://github.com/vercel/next.js/discussions/30174#discussion-3643870
18
- scrollRestoration:!0,...a.experimental||{}},// @see https://www.zhoulujun.net/nextjs/advanced-features/compiler.html#modularize-imports
19
- modularizeImports:{...a.modularizeImports||{},...swcTransformsKoine},...a};return (s&&(n?// @see https://github.com/gregberge/svgr
20
- m.nx={svgr:!0}:(// if falsy just remove the key
21
- delete m.nx,m.webpack=(e,r)=>// ...[_config, options]: Parameters<NonNullable<NextConfig['webpack']>>
29
+ scrollRestoration:!0,...m.experimental||{}},// @see https://www.zhoulujun.net/nextjs/advanced-features/compiler.html#modularize-imports
30
+ modularizeImports:{...u?Array.isArray(u)?u.reduce((r,o)=>({...r,...swcCreateTransforms(o.libs,o.scope)}),{}):swcCreateTransforms(u.libs,u.scope):{},...m.modularizeImports||{},...swcTransformsKoine},...m};return (p&&(n?// @see https://github.com/gregberge/svgr
31
+ c.nx={svgr:!0}:(// if falsy just remove the key
32
+ delete c.nx,c.webpack=(e,r)=>// ...[_config, options]: Parameters<NonNullable<NextConfig['webpack']>>
22
33
  {let o="function"==typeof m.webpack?m.webpack(e,r):e;return(// @see https://dev.to/dolearning/importing-svgs-to-next-js-nna#svgr
23
- o.module.rules.push({test:/\.svg$/,use:[{loader:"@svgr/webpack",options:{svgoConfig:{plugins:[{name:"removeViewBox",active:!1}]}}}]}),o)})),p)?withI18nLegacy({...m,i18nRoutes:p}):l?n?withI18nAsync({...m,i18nCompiler:l}):withI18n({...m,i18nCompiler:l}):m};
34
+ o.module.rules.push({test:/\.svg$/,use:[{loader:"@svgr/webpack",options:{svgoConfig:{plugins:[{name:"removeViewBox",active:!1}]}}}]}),o)})),l)?withI18nLegacy({...c,i18nRoutes:l}):a?n?withI18nAsync({...c,i18nCompiler:a}):withI18n({...c,i18nCompiler:a}):c};
24
35
 
25
36
  export { withKoine };
package/index.cjs.js CHANGED
@@ -4,10 +4,6 @@ var load = require('./load.cjs.js');
4
4
  var ThemeContext = require('./ThemeContext.cjs.js');
5
5
  var ThemeProvider = require('./ThemeProvider.cjs.js');
6
6
  var useTheme = require('./useTheme.cjs.js');
7
- require('react');
8
- require('react/jsx-runtime');
9
- require('next/script');
10
- require('@koine/utils');
11
7
 
12
8
 
13
9
 
package/index.esm.js CHANGED
@@ -2,7 +2,3 @@ export { load } from './load.esm.js';
2
2
  export { ThemeContext } from './ThemeContext.esm.js';
3
3
  export { ThemeProvider } from './ThemeProvider.esm.js';
4
4
  export { useTheme } from './useTheme.esm.js';
5
- import 'react';
6
- import 'react/jsx-runtime';
7
- import 'next/script';
8
- import '@koine/utils';
package/package.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@koine/next",
3
3
  "sideEffects": false,
4
4
  "dependencies": {
5
- "@koine/browser": "2.0.0-beta.124",
6
- "@koine/utils": "2.0.0-beta.124",
7
- "@koine/i18n": "2.0.0-beta.124"
5
+ "@koine/browser": "2.0.0-beta.126",
6
+ "@koine/utils": "2.0.0-beta.126",
7
+ "@koine/i18n": "2.0.0-beta.126"
8
8
  },
9
9
  "peerDependencies": {
10
10
  "next": "^14.0.4",
@@ -20,41 +20,49 @@
20
20
  "./package.json": "./package.json",
21
21
  ".": {
22
22
  "module": "./index.esm.js",
23
+ "types": "./index.esm.d.ts",
23
24
  "import": "./index.cjs.mjs",
24
25
  "default": "./index.cjs.js"
25
26
  },
26
27
  "./12": {
27
28
  "module": "./12.esm.js",
29
+ "types": "./12.esm.d.ts",
28
30
  "import": "./12.cjs.mjs",
29
31
  "default": "./12.cjs.js"
30
32
  },
31
33
  "./config": {
32
34
  "module": "./config.esm.js",
35
+ "types": "./config.esm.d.ts",
33
36
  "import": "./config.cjs.mjs",
34
37
  "default": "./config.cjs.js"
35
38
  },
36
39
  "./load": {
37
40
  "module": "./load.esm.js",
41
+ "types": "./load.esm.d.ts",
38
42
  "import": "./load.cjs.mjs",
39
43
  "default": "./load.cjs.js"
40
44
  },
41
45
  "./ThemeContext": {
42
46
  "module": "./ThemeContext.esm.js",
47
+ "types": "./ThemeContext.esm.d.ts",
43
48
  "import": "./ThemeContext.cjs.mjs",
44
49
  "default": "./ThemeContext.cjs.js"
45
50
  },
46
51
  "./ThemeProvider": {
47
52
  "module": "./ThemeProvider.esm.js",
53
+ "types": "./ThemeProvider.esm.d.ts",
48
54
  "import": "./ThemeProvider.cjs.mjs",
49
55
  "default": "./ThemeProvider.cjs.js"
50
56
  },
51
57
  "./useTheme": {
52
58
  "module": "./useTheme.esm.js",
59
+ "types": "./useTheme.esm.d.ts",
53
60
  "import": "./useTheme.cjs.mjs",
54
61
  "default": "./useTheme.cjs.js"
55
62
  }
56
63
  },
57
64
  "module": "./index.esm.js",
58
65
  "main": "./index.cjs.js",
59
- "version": "2.0.0-beta.124"
66
+ "types": "./index.esm.d.ts",
67
+ "version": "2.0.0-beta.126"
60
68
  }