@koine/next 2.0.0-beta.21 → 2.0.0-beta.210
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/ThemeContext.cjs.default.js +1 -0
- package/ThemeContext.cjs.js +10 -0
- package/ThemeContext.cjs.mjs +2 -0
- package/ThemeContext.d.ts +6 -1
- package/ThemeContext.esm.js +5 -0
- package/ThemeProvider.cjs.default.js +1 -0
- package/ThemeProvider.cjs.js +14 -0
- package/ThemeProvider.cjs.mjs +2 -0
- package/ThemeProvider.d.ts +18 -1
- package/ThemeProvider.esm.js +9 -0
- package/config.cjs.default.js +1 -0
- package/config.cjs.js +9 -0
- package/config.cjs.mjs +2 -0
- package/config.d.ts +42 -107
- package/config.esm.js +7 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +13 -0
- package/index.cjs.mjs +2 -0
- package/index.d.ts +4 -5
- package/index.esm.js +4 -0
- package/load.cjs.default.js +1 -0
- package/load.cjs.js +8 -0
- package/load.cjs.mjs +2 -0
- package/load.d.ts +8 -0
- package/load.esm.js +3 -0
- package/package.json +43 -206
- package/typings.d.ts +39 -50
- package/useTheme.cjs.default.js +1 -0
- package/useTheme.cjs.js +11 -0
- package/useTheme.cjs.mjs +2 -0
- package/useTheme.d.ts +4 -1
- package/useTheme.esm.js +6 -0
- package/vite.config.d.ts +2 -0
- package/12/AnalyticsGoogle.d.ts +0 -5
- package/12/AnalyticsGoogle.js +0 -33
- package/12/DisableErrorOverlay.d.ts +0 -2
- package/12/DisableErrorOverlay.js +0 -8
- package/12/DynamicNamespaces.d.ts +0 -8
- package/12/DynamicNamespaces.js +0 -4
- package/12/Favicon.d.ts +0 -4
- package/12/Favicon.js +0 -6
- package/12/Link.d.ts +0 -7
- package/12/Link.js +0 -9
- package/12/NextProgress.d.ts +0 -22
- package/12/NextProgress.js +0 -40
- package/12/Seo.d.ts +0 -17
- package/12/Seo.js +0 -7
- package/12/SeoDefaults.d.ts +0 -8
- package/12/SeoDefaults.js +0 -7
- package/12/T.d.ts +0 -10
- package/12/T.js +0 -8
- package/12/TransText.d.ts +0 -3
- package/12/TransText.js +0 -4
- package/12/app/AppHead.d.ts +0 -3
- package/12/app/AppHead.js +0 -6
- package/12/app/AppMain.d.ts +0 -17
- package/12/app/AppMain.js +0 -1
- package/12/app/css/AppMain.d.ts +0 -4
- package/12/app/css/AppMain.js +0 -9
- package/12/app/css/AppTheme.d.ts +0 -8
- package/12/app/css/AppTheme.js +0 -7
- package/12/app/css/auth/index.d.ts +0 -8
- package/12/app/css/auth/index.js +0 -10
- package/12/app/css/index.d.ts +0 -6
- package/12/app/css/index.js +0 -9
- package/12/app/index.d.ts +0 -2
- package/12/app/index.js +0 -2
- package/12/app/sc/AppMain.d.ts +0 -4
- package/12/app/sc/AppMain.js +0 -18
- package/12/app/sc/AppTheme.d.ts +0 -8
- package/12/app/sc/AppTheme.js +0 -8
- package/12/app/sc/auth/index.d.ts +0 -8
- package/12/app/sc/auth/index.js +0 -10
- package/12/app/sc/index.d.ts +0 -6
- package/12/app/sc/index.js +0 -9
- package/12/document/Document.d.ts +0 -5
- package/12/document/Document.js +0 -18
- package/12/document/css/index.d.ts +0 -5
- package/12/document/css/index.js +0 -18
- package/12/document/index.d.ts +0 -2
- package/12/document/index.js +0 -2
- package/12/document/sc/index.d.ts +0 -6
- package/12/document/sc/index.js +0 -50
- package/12/getT.d.ts +0 -4
- package/12/getT.js +0 -4
- package/12/index.d.ts +0 -3
- package/12/index.js +0 -3
- package/12/seoBuildTags.d.ts +0 -8
- package/12/seoBuildTags.js +0 -93
- package/12/to.d.ts +0 -14
- package/12/to.js +0 -19
- package/12/translationAsOptions.d.ts +0 -4
- package/12/translationAsOptions.js +0 -10
- package/12/types-i18n.d.ts +0 -31
- package/12/types-i18n.js +0 -1
- package/12/types-seo.d.ts +0 -7
- package/12/types-seo.js +0 -1
- package/12/types.d.ts +0 -7
- package/12/types.js +0 -2
- package/12/useBackUrl.d.ts +0 -2
- package/12/useBackUrl.js +0 -24
- package/12/useDateFormat.d.ts +0 -3
- package/12/useDateFormat.js +0 -35
- package/12/useForm.d.ts +0 -27
- package/12/useForm.js +0 -15
- package/12/useLocale.d.ts +0 -2
- package/12/useLocale.js +0 -6
- package/12/useT.d.ts +0 -4
- package/12/useT.js +0 -17
- package/12/useTo.d.ts +0 -3
- package/12/useTo.js +0 -15
- package/ThemeContext.js +0 -6
- package/ThemeProvider.js +0 -204
- package/config-i18n.d.ts +0 -52
- package/config-i18n.js +0 -251
- package/config.js +0 -118
- package/getSiteUrl.d.ts +0 -2
- package/getSiteUrl.js +0 -6
- package/index.js +0 -5
- package/load.js +0 -6
- package/useTheme.js +0 -5
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @koine/next
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./ThemeContext.cjs.js').default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
|
|
7
|
+
const ThemeContext=react.createContext({setTheme:e=>{},themes:[]});
|
|
8
|
+
|
|
9
|
+
exports.ThemeContext = ThemeContext;
|
|
10
|
+
exports.default = ThemeContext;
|
package/ThemeContext.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
export type ThemeContextProps = {
|
|
2
|
+
/** List of all available theme names */
|
|
3
3
|
themes: string[];
|
|
4
|
+
/** Forced theme name for the current page */
|
|
4
5
|
forcedTheme?: string;
|
|
6
|
+
/** Update the theme */
|
|
5
7
|
setTheme: (theme: string) => void;
|
|
8
|
+
/** Active theme name */
|
|
6
9
|
theme?: string;
|
|
10
|
+
/** If `enableSystem` is true and the active theme is "system", this returns whether the system preference resolved to "dark" or "light". Otherwise, identical to `theme` */
|
|
7
11
|
resolvedTheme?: string;
|
|
12
|
+
/** If enableSystem is true, returns the System theme preference ("dark" or "light"), regardless what the active theme is */
|
|
8
13
|
systemTheme?: "dark" | "light";
|
|
9
14
|
};
|
|
10
15
|
export declare const ThemeContext: import("react").Context<ThemeContextProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./ThemeProvider.cjs.js').default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var r = require('next/script');
|
|
7
|
+
var react = require('react');
|
|
8
|
+
var utils = require('@koine/utils');
|
|
9
|
+
var ThemeContext = require('./ThemeContext.cjs.js');
|
|
10
|
+
|
|
11
|
+
let l=["light","dark"],d="(prefers-color-scheme: dark)",c="theme";const ThemeProvider=({forcedTheme:r,disableTransitionOnChange:o=false,enableSystem:v=true,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.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,f=(u=`d.remove(${m.map(e=>`'${e}'`).join(",")})`,`var d=document.documentElement.classList;${u};`),y=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":"",p=(e,t=false,r=true)=>{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},g=t?`!function(){${f}${p(t)}}()`:i?`!function(){try {${f}var e=localStorage.getItem('${c}');if("system"===e||(!e&&${$})){var t="${d}",m=window.matchMedia(t);if(m.media!==t||m.matches){${p("dark")}}else{${p("light")}}}else if(e){${a?`var x=${JSON.stringify(a)};`:""}${p(a?"x[e]":"e",true)}}${!$?"else{"+p(s,false,false)+"}":""}${y}}catch(e){}}()`:`!function(){try{${f}var e=localStorage.getItem("${c}");if(e){${a?`var x=${JSON.stringify(a)};`:""}${p(a?"x[e]":"e",true)}}else{${p(s,false,false)};}${y}}catch(t){}}();`;return jsxRuntime.jsx(r,{id:"next-theme-script",strategy:"beforeInteractive",src:`data:text/javascript;base64,${v(g)}`,nonce:h})},()=>true),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);
|
|
12
|
+
|
|
13
|
+
exports.ThemeProvider = ThemeProvider;
|
|
14
|
+
exports.default = ThemeProvider;
|
package/ThemeProvider.d.ts
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
type ValueObject = {
|
|
3
2
|
[themeName: string]: string;
|
|
4
3
|
};
|
|
5
4
|
export type ThemeProviderProps = React.PropsWithChildren<{
|
|
5
|
+
/** List of all available theme names */
|
|
6
6
|
themes?: string[];
|
|
7
|
+
/** Forced theme name for the current page */
|
|
7
8
|
forcedTheme?: string;
|
|
9
|
+
/** Whether to switch between dark and light themes based on prefers-color-scheme */
|
|
8
10
|
enableSystem?: boolean;
|
|
11
|
+
/** Disable all CSS transitions when switching themes */
|
|
9
12
|
disableTransitionOnChange?: boolean;
|
|
13
|
+
/** Whether to indicate to browsers which color scheme is used (dark or light) for built-in UI like inputs and buttons */
|
|
10
14
|
enableColorScheme?: boolean;
|
|
15
|
+
/** Default theme name (for v0.0.12 and lower the default was light). If `enableSystem` is false, the default theme is light */
|
|
11
16
|
defaultTheme?: string;
|
|
17
|
+
/** HTML attribute modified based on the active theme. Accepts `class` and `data-*` (meaning any data attribute, `data-mode`, `data-color`, etc.) */
|
|
12
18
|
attribute?: string | "class";
|
|
19
|
+
/** Mapping of theme name to HTML attribute value. Object where key is the theme name and value is the attribute value */
|
|
13
20
|
value?: ValueObject;
|
|
21
|
+
/** Nonce string to pass to the inline script for CSP headers */
|
|
14
22
|
nonce?: string;
|
|
15
23
|
}>;
|
|
24
|
+
/**
|
|
25
|
+
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
26
|
+
*
|
|
27
|
+
* Differences:
|
|
28
|
+
*
|
|
29
|
+
* - enableColorScheme: `false` by default (instead of `true`), this plays more
|
|
30
|
+
* nicely with tailwind `dark` class mode as dark theme is supposed to be only
|
|
31
|
+
* controlled by tailwind modifiers
|
|
32
|
+
*/
|
|
16
33
|
export declare const ThemeProvider: ({ forcedTheme, disableTransitionOnChange, enableSystem, enableColorScheme, themes, defaultTheme, attribute, value, children, nonce, }: ThemeProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
34
|
export default ThemeProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import r from 'next/script';
|
|
3
|
+
import { memo, useState, useCallback, useEffect } from 'react';
|
|
4
|
+
import { isServer } from '@koine/utils';
|
|
5
|
+
import { ThemeContext } from './ThemeContext.esm.js';
|
|
6
|
+
|
|
7
|
+
let l=["light","dark"],d="(prefers-color-scheme: dark)",c="theme";const ThemeProvider=({forcedTheme:r,disableTransitionOnChange:o=false,enableSystem:v=true,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,enableSystem:i,enableColorScheme:n,defaultTheme:s,value:a,attrs:m,nonce:h})=>{let u,$="system"===s,f=(u=`d.remove(${m.map(e=>`'${e}'`).join(",")})`,`var d=document.documentElement.classList;${u};`),y=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":"",p=(e,t=false,r=true)=>{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},g=t?`!function(){${f}${p(t)}}()`:i?`!function(){try {${f}var e=localStorage.getItem('${c}');if("system"===e||(!e&&${$})){var t="${d}",m=window.matchMedia(t);if(m.media!==t||m.matches){${p("dark")}}else{${p("light")}}}else if(e){${a?`var x=${JSON.stringify(a)};`:""}${p(a?"x[e]":"e",true)}}${!$?"else{"+p(s,false,false)+"}":""}${y}}catch(e){}}()`:`!function(){try{${f}var e=localStorage.getItem("${c}");if(e){${a?`var x=${JSON.stringify(a)};`:""}${p(a?"x[e]":"e",true)}}else{${p(s,false,false)};}${y}}catch(t){}}();`;return jsx(r,{id:"next-theme-script",strategy:"beforeInteractive",src:`data:text/javascript;base64,${v(g)}`,nonce:h})},()=>true),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);
|
|
8
|
+
|
|
9
|
+
export { ThemeProvider, ThemeProvider as default };
|
|
@@ -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
|
+
var swc = require('@koine/node/swc');
|
|
4
|
+
var next = require('@koine/i18n/next');
|
|
5
|
+
var utils = require('@koine/utils');
|
|
6
|
+
|
|
7
|
+
function withKoine(i={}){let{nx:n,svg:l,i18nRoutes:m,i18nCompiler:p,modularize:u,...c}=i,f={modularizeImports:{...u?Array.isArray(u)?swc.swcCreateTransforms(u):swc.swcCreateTransform(u):{},...c.modularizeImports||{},...swc.swcTransformsKoine},...c};return (l&&(n?f.nx={svgr:true}:(delete f.nx,true===l||"turbopack"===l?f.turbopack={...c.turbopack,rules:{...c.turbopack?.rules,"*.svg":{loaders:[{loader:"@svgr/webpack",options:{memo:true,dimensions:false,svgoConfig:{multipass:true,plugins:["removeDimensions","removeOffCanvasPaths","reusePaths","removeElementsByAttr","removeStyleElement","removeScriptElement","prefixIds","cleanupIds",{name:"cleanupNumericValues",params:{floatPrecision:1}},{name:"convertPathData",params:{floatPrecision:1}},{name:"convertTransform",params:{floatPrecision:1}},{name:"cleanupListOfValues",params:{floatPrecision:1}}]}}}],as:"*.js"}}}:"webpack"===l&&(f.webpack=(e,r)=>{let a="function"==typeof c.webpack?c.webpack(e,r):e;return a.module.rules.push({test:/\.svg$/,use:[{loader:"@svgr/webpack",options:{svgoConfig:{plugins:[{name:"removeViewBox",active:false}]}}}]}),a}))),m)?next.withI18nLegacy({...f,i18nRoutes:m}):p?n?next.withI18nAsync({...f,i18nCompiler:p}):next.withI18n({...f,i18nCompiler:p}):f}function n(e,r,a){return [...Array.isArray(r)?r:r?.[e]||[],...Array.isArray(a)?a:a?.[e]||[]]}async function l(e,r){let a=utils.isFunction(e)?await e?.():e,o=await r?.(),s=n("beforeFiles",a,o);return {beforeFiles:s,afterFiles:n("afterFiles",a,o),fallback:n("fallback",a,o)}}withKoine.mergeRewrites=l;
|
|
8
|
+
|
|
9
|
+
exports.withKoine = withKoine;
|
package/config.cjs.mjs
ADDED
package/config.d.ts
CHANGED
|
@@ -1,109 +1,44 @@
|
|
|
1
1
|
import type { NextConfig } from "next";
|
|
2
|
-
import { type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
import { type SwcTransformingLib } from "@koine/node/swc";
|
|
3
|
+
import { type WithI18nAsyncOptions, type WithI18nLegacyOptions } from "@koine/i18n/next";
|
|
4
|
+
/**
|
|
5
|
+
* @legacy
|
|
6
|
+
*/
|
|
7
|
+
export type Routes = NonNullable<WithI18nLegacyOptions["i18nRoutes"]>["routes"];
|
|
8
|
+
export type WithKoineOptions<Nx extends boolean | undefined = undefined> = NextConfig & {
|
|
9
|
+
/**
|
|
10
|
+
* Set it to `true` when your _Next.js_ app is built inside a Nx monorepo
|
|
11
|
+
*/
|
|
12
|
+
nx?: Nx;
|
|
13
|
+
/**
|
|
14
|
+
* Set it to `true` in order to be able importing React components directly
|
|
15
|
+
* from `.svg` files.
|
|
16
|
+
*
|
|
17
|
+
* It configures turbopack/webpack taking into account `nx` option.
|
|
18
|
+
*/
|
|
19
|
+
svg?: boolean | "turbopack" | "webpack";
|
|
20
|
+
/**
|
|
21
|
+
* Shortcut option to automatically create swc transforms to feed into
|
|
22
|
+
* _Next.js_' `modularizeImports`.
|
|
23
|
+
*
|
|
24
|
+
* Pass _one_ or an _array_ of {@link SwcTransformingLib lib transform object}.
|
|
25
|
+
*/
|
|
26
|
+
modularize?: SwcTransformingLib[] | SwcTransformingLib;
|
|
27
|
+
} & WithI18nLegacyOptions & WithI18nAsyncOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Get _Next.js_ config with some extra {@link WithKoineOptions options}
|
|
30
|
+
*
|
|
31
|
+
* @param options
|
|
32
|
+
*/
|
|
33
|
+
export declare function withKoine(options: WithKoineOptions<undefined | false>): NextConfig;
|
|
34
|
+
export declare function withKoine(options: WithKoineOptions<true>): NextConfigFn;
|
|
35
|
+
export declare namespace withKoine {
|
|
36
|
+
var mergeRewrites: typeof nextjsConfigMergeRewrites;
|
|
14
37
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
fallback: import("next/dist/lib/load-custom-routes.js").Rewrite[];
|
|
23
|
-
}>;
|
|
24
|
-
exportPathMap?: ((defaultMap: import("next/dist/server/config-shared.js").ExportPathMap, ctx: {
|
|
25
|
-
dev: boolean;
|
|
26
|
-
dir: string;
|
|
27
|
-
outDir: string | null;
|
|
28
|
-
distDir: string;
|
|
29
|
-
buildId: string;
|
|
30
|
-
}) => import("next/dist/server/config-shared.js").ExportPathMap | Promise<import("next/dist/server/config-shared.js").ExportPathMap>) | undefined;
|
|
31
|
-
i18n?: import("next/dist/server/config-shared.js").I18NConfig | null | undefined;
|
|
32
|
-
eslint?: import("next/dist/server/config-shared.js").ESLintConfig | undefined;
|
|
33
|
-
typescript?: import("next/dist/server/config-shared.js").TypeScriptConfig | undefined;
|
|
34
|
-
headers?: (() => Promise<import("next/dist/lib/load-custom-routes.js").Header[]>) | undefined;
|
|
35
|
-
excludeDefaultMomentLocales?: boolean | undefined;
|
|
36
|
-
webpack?: import("next/dist/server/config-shared.js").NextJsWebpackConfig | null | undefined;
|
|
37
|
-
trailingSlash?: boolean | undefined;
|
|
38
|
-
env?: Record<string, string> | undefined;
|
|
39
|
-
distDir?: string | undefined;
|
|
40
|
-
cleanDistDir?: boolean | undefined;
|
|
41
|
-
assetPrefix?: string | undefined;
|
|
42
|
-
useFileSystemPublicRoutes?: boolean | undefined;
|
|
43
|
-
generateBuildId?: (() => string | Promise<string | null> | null) | undefined;
|
|
44
|
-
generateEtags?: boolean | undefined;
|
|
45
|
-
pageExtensions?: string[] | undefined;
|
|
46
|
-
compress?: boolean | undefined;
|
|
47
|
-
analyticsId?: string | undefined;
|
|
48
|
-
poweredByHeader?: boolean | undefined;
|
|
49
|
-
images?: Partial<import("next/dist/shared/lib/image-config.js").ImageConfigComplete> | undefined;
|
|
50
|
-
devIndicators?: {
|
|
51
|
-
buildActivity?: boolean | undefined;
|
|
52
|
-
buildActivityPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left" | undefined;
|
|
53
|
-
} | undefined;
|
|
54
|
-
onDemandEntries?: {
|
|
55
|
-
maxInactiveAge?: number | undefined;
|
|
56
|
-
pagesBufferLength?: number | undefined;
|
|
57
|
-
} | undefined;
|
|
58
|
-
amp?: {
|
|
59
|
-
canonicalBase?: string | undefined;
|
|
60
|
-
} | undefined;
|
|
61
|
-
basePath?: string | undefined;
|
|
62
|
-
sassOptions?: {
|
|
63
|
-
[key: string]: any;
|
|
64
|
-
} | undefined;
|
|
65
|
-
productionBrowserSourceMaps?: boolean | undefined;
|
|
66
|
-
optimizeFonts?: boolean | undefined;
|
|
67
|
-
reactProductionProfiling?: boolean | undefined;
|
|
68
|
-
reactStrictMode?: boolean | null | undefined;
|
|
69
|
-
publicRuntimeConfig?: {
|
|
70
|
-
[key: string]: any;
|
|
71
|
-
} | undefined;
|
|
72
|
-
serverRuntimeConfig?: {
|
|
73
|
-
[key: string]: any;
|
|
74
|
-
} | undefined;
|
|
75
|
-
httpAgentOptions?: {
|
|
76
|
-
keepAlive?: boolean | undefined;
|
|
77
|
-
} | undefined;
|
|
78
|
-
outputFileTracing?: boolean | undefined;
|
|
79
|
-
staticPageGenerationTimeout?: number | undefined;
|
|
80
|
-
crossOrigin?: false | "anonymous" | "use-credentials" | undefined;
|
|
81
|
-
swcMinify?: boolean | undefined;
|
|
82
|
-
compiler?: {
|
|
83
|
-
reactRemoveProperties?: boolean | {
|
|
84
|
-
properties?: string[] | undefined;
|
|
85
|
-
} | undefined;
|
|
86
|
-
relay?: {
|
|
87
|
-
src: string;
|
|
88
|
-
artifactDirectory?: string | undefined;
|
|
89
|
-
language?: "typescript" | "flow" | "javascript" | undefined;
|
|
90
|
-
eagerEsModules?: boolean | undefined;
|
|
91
|
-
} | undefined;
|
|
92
|
-
removeConsole?: boolean | {
|
|
93
|
-
exclude?: string[] | undefined;
|
|
94
|
-
} | undefined;
|
|
95
|
-
styledComponents?: boolean | import("next/dist/server/config-shared.js").StyledComponentsConfig | undefined;
|
|
96
|
-
emotion?: boolean | import("next/dist/server/config-shared.js").EmotionConfig | undefined;
|
|
97
|
-
} | undefined;
|
|
98
|
-
output?: "standalone" | "export" | undefined;
|
|
99
|
-
transpilePackages?: string[] | undefined;
|
|
100
|
-
skipMiddlewareUrlNormalize?: boolean | undefined;
|
|
101
|
-
skipTrailingSlashRedirect?: boolean | undefined;
|
|
102
|
-
modularizeImports?: Record<string, {
|
|
103
|
-
transform: string | Record<string, string>;
|
|
104
|
-
preventFullImport?: boolean | undefined;
|
|
105
|
-
skipDefaultConversion?: boolean | undefined;
|
|
106
|
-
}> | undefined;
|
|
107
|
-
experimental?: import("next/dist/server/config-shared.js").ExperimentalConfig | undefined;
|
|
108
|
-
};
|
|
109
|
-
export default withKoine;
|
|
38
|
+
type NextConfigFn = (phase: string, context?: any) => Promise<NextConfig> | NextConfig;
|
|
39
|
+
declare function nextjsConfigMergeRewrites(defaultRewrites?: NextConfig["rewrites"] | Awaited<ReturnType<NonNullable<NextConfig["rewrites"]>>>, customRewrites?: NextConfig["rewrites"]): Promise<{
|
|
40
|
+
beforeFiles: any[];
|
|
41
|
+
afterFiles: any[];
|
|
42
|
+
fallback: any[];
|
|
43
|
+
}>;
|
|
44
|
+
export {};
|
package/config.esm.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { swcTransformsKoine, swcCreateTransforms, swcCreateTransform } from '@koine/node/swc';
|
|
2
|
+
import { withI18nLegacy, withI18nAsync, withI18n } from '@koine/i18n/next';
|
|
3
|
+
import { isFunction } from '@koine/utils';
|
|
4
|
+
|
|
5
|
+
function withKoine(i={}){let{nx:n,svg:l,i18nRoutes:m,i18nCompiler:p,modularize:u,...c}=i,f={modularizeImports:{...u?Array.isArray(u)?swcCreateTransforms(u):swcCreateTransform(u):{},...c.modularizeImports||{},...swcTransformsKoine},...c};return (l&&(n?f.nx={svgr:true}:(delete f.nx,true===l||"turbopack"===l?f.turbopack={...c.turbopack,rules:{...c.turbopack?.rules,"*.svg":{loaders:[{loader:"@svgr/webpack",options:{memo:true,dimensions:false,svgoConfig:{multipass:true,plugins:["removeDimensions","removeOffCanvasPaths","reusePaths","removeElementsByAttr","removeStyleElement","removeScriptElement","prefixIds","cleanupIds",{name:"cleanupNumericValues",params:{floatPrecision:1}},{name:"convertPathData",params:{floatPrecision:1}},{name:"convertTransform",params:{floatPrecision:1}},{name:"cleanupListOfValues",params:{floatPrecision:1}}]}}}],as:"*.js"}}}:"webpack"===l&&(f.webpack=(e,r)=>{let a="function"==typeof c.webpack?c.webpack(e,r):e;return a.module.rules.push({test:/\.svg$/,use:[{loader:"@svgr/webpack",options:{svgoConfig:{plugins:[{name:"removeViewBox",active:false}]}}}]}),a}))),m)?withI18nLegacy({...f,i18nRoutes:m}):p?n?withI18nAsync({...f,i18nCompiler:p}):withI18n({...f,i18nCompiler:p}):f}function n(e,r,a){return [...Array.isArray(r)?r:r?.[e]||[],...Array.isArray(a)?a:a?.[e]||[]]}async function l(e,r){let a=isFunction(e)?await e?.():e,o=await r?.(),s=n("beforeFiles",a,o);return {beforeFiles:s,afterFiles:n("afterFiles",a,o),fallback:n("fallback",a,o)}}withKoine.mergeRewrites=l;
|
|
6
|
+
|
|
7
|
+
export { withKoine };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./index.cjs.js').default;
|
package/index.cjs.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var load = require('./load.cjs.js');
|
|
4
|
+
var ThemeContext = require('./ThemeContext.cjs.js');
|
|
5
|
+
var ThemeProvider = require('./ThemeProvider.cjs.js');
|
|
6
|
+
var useTheme = require('./useTheme.cjs.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.load = load.load;
|
|
11
|
+
exports.ThemeContext = ThemeContext.ThemeContext;
|
|
12
|
+
exports.ThemeProvider = ThemeProvider.ThemeProvider;
|
|
13
|
+
exports.useTheme = useTheme.useTheme;
|
package/index.cjs.mjs
ADDED
package/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { useTheme, type UseThemeProps } from "./useTheme.js";
|
|
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";
|
package/index.esm.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./load.cjs.js').default;
|
package/load.cjs.js
ADDED
package/load.cjs.mjs
ADDED
package/load.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility to load a component with an optional pre-determined delay.
|
|
3
|
+
*
|
|
4
|
+
* This was designed to improve anti spam with async form loading.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/vercel/next.js/blob/main/packages/next/next-server/lib/dynamic.tsx
|
|
7
|
+
* @see https://github.com/vercel/next.js/blob/canary/examples/with-dynamic-import/pages/index.js
|
|
8
|
+
*/
|
|
1
9
|
export declare function load<T>(component: T, milliseconds: number): Promise<T>;
|
|
2
10
|
export default load;
|
package/load.esm.js
ADDED