@koine/next 2.0.0-beta.39 → 2.0.0-beta.41

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/config.cjs.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
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}
5
+ var nextConfig = require('@koine/i18n/next-config');
6
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};
7
+ let withKoine=(r={})=>o=>{let{nx:t=!0,svg:i=!0,i18n:n}=r,s={eslint:{ignoreDuringBuilds:!0},typescript:{ignoreBuildErrors:!0},poweredByHeader:!1,experimental:{scrollRestoration:!0,...o.experimental||{}},...o};return (i&&(t?s.nx={svgr:!0}:(delete s.nx,s.webpack=(e,r)=>{let o="function"==typeof s.webpack?s.webpack(e,r):e;return o.module.rules.push({test:/\.svg$/,use:[{loader:"@svgr/webpack",options:{svgoConfig:{plugins:[{name:"removeViewBox",active:!1}]}}}]}),o})),n)?nextConfig.withI18nNext({...r,i18n:n})(s):s};
8
8
 
9
9
  exports.withKoine = withKoine;
package/config.d.ts CHANGED
@@ -1,37 +1,29 @@
1
1
  import type { NextConfig } from "next";
2
- import { type ConfigI18nOptions, type Routes } from "./config-i18n.js";
3
- interface KoineNextConfig {
2
+ import { type WithI18nNextConfig } from "@koine/i18n/next-config";
3
+ type WithKoineConfig = {
4
4
  nx?: boolean;
5
5
  svg?: boolean;
6
- routes?: Routes;
7
- permanent?: boolean;
8
- debug?: boolean;
9
- i18n: ConfigI18nOptions & {
10
- loader?: any;
11
- };
12
- }
13
- interface MergedConfig extends KoineNextConfig, Omit<NextConfig, "i18n"> {
14
- }
15
- export declare let withKoine: ({ nx, svg, page, routes, permanent, debug, ...custom }?: MergedConfig) => NextConfig | {
16
- redirects(): Promise<import("./config-i18n.js").Redirect[]>;
6
+ } & Partial<WithI18nNextConfig>;
7
+ export declare let withKoine: (config?: WithKoineConfig) => (customNextConfig: NextConfig) => NextConfig | {
8
+ redirects(): Promise<import("@koine/i18n/client/adapter-next/config").Redirect[]>;
17
9
  rewrites(): Promise<{
18
- beforeFiles: import("./config-i18n.js").Rewrite[];
19
- afterFiles: import("next/dist/lib/load-custom-routes.js").Rewrite[];
20
- fallback: import("next/dist/lib/load-custom-routes.js").Rewrite[];
10
+ beforeFiles: import("@koine/i18n/client/adapter-next/config").Rewrite[];
11
+ afterFiles: import("next/dist/lib/load-custom-routes").Rewrite[];
12
+ fallback: import("next/dist/lib/load-custom-routes").Rewrite[];
21
13
  }>;
22
- exportPathMap?: ((defaultMap: import("next/dist/server/config-shared.js").ExportPathMap, ctx: {
14
+ exportPathMap?: ((defaultMap: import("next/dist/server/config-shared").ExportPathMap, ctx: {
23
15
  dev: boolean;
24
16
  dir: string;
25
17
  outDir: string | null;
26
18
  distDir: string;
27
19
  buildId: string;
28
- }) => import("next/dist/server/config-shared.js").ExportPathMap | Promise<import("next/dist/server/config-shared.js").ExportPathMap>) | undefined;
29
- i18n?: import("next/dist/server/config-shared.js").I18NConfig | null | undefined;
30
- eslint?: import("next/dist/server/config-shared.js").ESLintConfig | undefined;
31
- typescript?: import("next/dist/server/config-shared.js").TypeScriptConfig | undefined;
32
- headers?: (() => Promise<import("next/dist/lib/load-custom-routes.js").Header[]>) | undefined;
20
+ }) => import("next/dist/server/config-shared").ExportPathMap | Promise<import("next/dist/server/config-shared").ExportPathMap>) | undefined;
21
+ i18n?: import("next/dist/server/config-shared").I18NConfig | null | undefined;
22
+ eslint?: import("next/dist/server/config-shared").ESLintConfig | undefined;
23
+ typescript?: import("next/dist/server/config-shared").TypeScriptConfig | undefined;
24
+ headers?: (() => Promise<import("next/dist/lib/load-custom-routes").Header[]>) | undefined;
33
25
  excludeDefaultMomentLocales?: boolean | undefined;
34
- webpack?: import("next/dist/server/config-shared.js").NextJsWebpackConfig | null | undefined;
26
+ webpack?: import("next/dist/server/config-shared").NextJsWebpackConfig | null | undefined;
35
27
  trailingSlash?: boolean | undefined;
36
28
  env?: Record<string, string | undefined> | undefined;
37
29
  distDir?: string | undefined;
@@ -46,7 +38,7 @@ export declare let withKoine: ({ nx, svg, page, routes, permanent, debug, ...cus
46
38
  compress?: boolean | undefined;
47
39
  analyticsId?: string | undefined;
48
40
  poweredByHeader?: boolean | undefined;
49
- images?: Partial<import("next/dist/shared/lib/image-config.js").ImageConfigComplete> | undefined;
41
+ images?: Partial<import("next/dist/shared/lib/image-config").ImageConfigComplete> | undefined;
50
42
  devIndicators?: {
51
43
  buildActivity?: boolean | undefined;
52
44
  buildActivityPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left" | undefined;
@@ -92,8 +84,8 @@ export declare let withKoine: ({ nx, svg, page, routes, permanent, debug, ...cus
92
84
  removeConsole?: boolean | {
93
85
  exclude?: string[] | undefined;
94
86
  } | 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;
87
+ styledComponents?: boolean | import("next/dist/server/config-shared").StyledComponentsConfig | undefined;
88
+ emotion?: boolean | import("next/dist/server/config-shared").EmotionConfig | undefined;
97
89
  } | undefined;
98
90
  output?: "standalone" | "export" | undefined;
99
91
  transpilePackages?: string[] | undefined;
@@ -109,6 +101,6 @@ export declare let withKoine: ({ nx, svg, page, routes, permanent, debug, ...cus
109
101
  fullUrl?: boolean | undefined;
110
102
  } | undefined;
111
103
  } | undefined;
112
- experimental?: import("next/dist/server/config-shared.js").ExperimentalConfig | undefined;
104
+ experimental?: import("next/dist/server/config-shared").ExperimentalConfig | undefined;
113
105
  };
114
106
  export {};
package/config.esm.js CHANGED
@@ -1,5 +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}
1
+ import { withI18nNext } from '@koine/i18n/next-config';
2
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};
3
+ let withKoine=(r={})=>o=>{let{nx:t=!0,svg:i=!0,i18n:n}=r,s={eslint:{ignoreDuringBuilds:!0},typescript:{ignoreBuildErrors:!0},poweredByHeader:!1,experimental:{scrollRestoration:!0,...o.experimental||{}},...o};return (i&&(t?s.nx={svgr:!0}:(delete s.nx,s.webpack=(e,r)=>{let o="function"==typeof s.webpack?s.webpack(e,r):e;return o.module.rules.push({test:/\.svg$/,use:[{loader:"@svgr/webpack",options:{svgoConfig:{plugins:[{name:"removeViewBox",active:!1}]}}}]}),o})),n)?withI18nNext({...r,i18n:n})(s):s};
4
4
 
5
5
  export { withKoine };
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.39",
6
- "@koine/react": "2.0.0-beta.39",
7
- "@koine/utils": "2.0.0-beta.39"
5
+ "@koine/browser": "2.0.0-beta.41",
6
+ "@koine/react": "2.0.0-beta.41",
7
+ "@koine/utils": "2.0.0-beta.41"
8
8
  },
9
9
  "peerDependencies": {
10
10
  "next": "^14.0.4",
@@ -45,5 +45,5 @@
45
45
  },
46
46
  "module": "./index.esm.js",
47
47
  "main": "./index.cjs.js",
48
- "version": "2.0.0-beta.39"
48
+ "version": "2.0.0-beta.41"
49
49
  }
package/config-i18n.d.ts DELETED
@@ -1,29 +0,0 @@
1
- import type { Redirect as _Redirect, Rewrite as _Rewrite } from "next/dist/lib/load-custom-routes";
2
- export type Redirect = Omit<_Redirect, "locale"> & {
3
- locale?: boolean;
4
- };
5
- export type Rewrite = Omit<_Rewrite, "locale"> & {
6
- locale?: boolean;
7
- };
8
- type Route = string | {
9
- [key: string]: Route | string;
10
- };
11
- type RoutesByLocale = Record<string, Route>;
12
- export type Locale = string;
13
- export type Routes = Record<Locale, RoutesByLocale>;
14
- export type ConfigI18nOptions = {
15
- locales: Locale[];
16
- defaultLocale: Locale;
17
- hideDefaultLocaleInUrl?: boolean;
18
- localeParam?: string;
19
- };
20
- type Options = ConfigI18nOptions & {
21
- routes: Routes;
22
- debug?: boolean;
23
- permanent?: boolean;
24
- };
25
- type GetRedirectsOptions = Options;
26
- export declare function getRedirects(arg: GetRedirectsOptions): Redirect[];
27
- type GetRewritesOptions = Options;
28
- export declare function getRewrites(arg: GetRewritesOptions): Rewrite[];
29
- export {};