@arch-cadre/intl 0.0.32 → 0.0.34

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.
Files changed (48) hide show
  1. package/dist/client/index.mjs +1 -2
  2. package/dist/server/index.mjs +1 -2
  3. package/dist/server/module-loader.mjs +1 -2
  4. package/dist/shared/constants.mjs +1 -2
  5. package/dist/shared/utils.mjs +1 -2
  6. package/package.json +5 -16
  7. package/dist/_virtual/_rolldown/runtime.cjs +0 -1
  8. package/dist/client/index.cjs +0 -1
  9. package/dist/client/index.d.cts +0 -35
  10. package/dist/client/index.d.cts.map +0 -1
  11. package/dist/client/index.d.mts +0 -35
  12. package/dist/client/index.d.mts.map +0 -1
  13. package/dist/client/index.mjs.map +0 -1
  14. package/dist/index.cjs +0 -1
  15. package/dist/index.d.cts +0 -5
  16. package/dist/index.d.mts +0 -5
  17. package/dist/locales/en/global.json.d.cts +0 -10
  18. package/dist/locales/en/global.json.d.cts.map +0 -1
  19. package/dist/locales/en/global.json.d.mts +0 -10
  20. package/dist/locales/en/global.json.d.mts.map +0 -1
  21. package/dist/server/index.cjs +0 -1
  22. package/dist/server/index.d.cts +0 -27
  23. package/dist/server/index.d.cts.map +0 -1
  24. package/dist/server/index.d.mts +0 -27
  25. package/dist/server/index.d.mts.map +0 -1
  26. package/dist/server/index.mjs.map +0 -1
  27. package/dist/server/module-loader.cjs +0 -1
  28. package/dist/server/module-loader.d.cts +0 -9
  29. package/dist/server/module-loader.d.cts.map +0 -1
  30. package/dist/server/module-loader.d.mts +0 -11
  31. package/dist/server/module-loader.d.mts.map +0 -1
  32. package/dist/server/module-loader.mjs.map +0 -1
  33. package/dist/shared/constants.cjs +0 -1
  34. package/dist/shared/constants.d.cts +0 -7
  35. package/dist/shared/constants.d.cts.map +0 -1
  36. package/dist/shared/constants.d.mts +0 -7
  37. package/dist/shared/constants.d.mts.map +0 -1
  38. package/dist/shared/constants.mjs.map +0 -1
  39. package/dist/shared/utils.cjs +0 -1
  40. package/dist/shared/utils.d.cts +0 -13
  41. package/dist/shared/utils.d.cts.map +0 -1
  42. package/dist/shared/utils.d.mts +0 -13
  43. package/dist/shared/utils.d.mts.map +0 -1
  44. package/dist/shared/utils.mjs.map +0 -1
  45. package/dist/types.d.cts +0 -23
  46. package/dist/types.d.cts.map +0 -1
  47. package/dist/types.d.mts +0 -23
  48. package/dist/types.d.mts.map +0 -1
@@ -1,2 +1 @@
1
- "use client";import{formatMessage as e,getNestedMessage as t}from"../shared/utils.mjs";import*as n from"react";import{createContext as r,useContext as i}from"react";const a=Symbol.for(`kryo-intl-context`),o=globalThis[a]||r(null);globalThis[a]||(globalThis[a]=o);function s({children:e,locale:t,messages:r}){return n.createElement(o.Provider,{value:{locale:t,messages:r}},e)}function c(){let e=i(o);if(!e)throw Error(`useLocale must be used within I18nProvider`);return e.locale}function l(){let n=i(o);if(!n)throw Error(`useTranslation must be used within I18nProvider`);let{messages:r,locale:a}=n;return{t:(n,i)=>{let a=t(r,String(n));return typeof a==`string`?e(a,i):String(n)},locale:a}}const u=l;export{s as I18nProvider,c as useLocale,l as useTranslation,u as useTranslations};
2
- //# sourceMappingURL=index.mjs.map
1
+ "use client";import{formatMessage as e,getNestedMessage as t}from"../shared/utils.mjs";import*as n from"react";import{createContext as r,useContext as i}from"react";const a=Symbol.for(`kryo-intl-context`),o=globalThis[a]||r(null);globalThis[a]||(globalThis[a]=o);function s({children:e,locale:t,messages:r}){return n.createElement(o.Provider,{value:{locale:t,messages:r}},e)}function c(){let e=i(o);if(!e)throw Error(`useLocale must be used within I18nProvider`);return e.locale}function l(){let n=i(o);if(!n)throw Error(`useTranslation must be used within I18nProvider`);let{messages:r,locale:a}=n;return{t:(n,i)=>{let a=t(r,String(n));return typeof a==`string`?e(a,i):String(n)},locale:a}}const u=l;export{s as I18nProvider,c as useLocale,l as useTranslation,u as useTranslations};
@@ -1,2 +1 @@
1
- import{formatMessage as e,getNestedMessage as t}from"../shared/utils.mjs";import{I18nProvider as n}from"../client/index.mjs";import{COOKIE_NAME as r,DEFAULT_LOCALE as i}from"../shared/constants.mjs";import{discoverLocalePaths as a,getModuleLocalePaths as o}from"./module-loader.mjs";import s from"react";import c from"node:fs/promises";import l from"node:path";import{match as u}from"@formatjs/intl-localematcher";import d from"negotiator";import{cookies as f,headers as p}from"next/headers";function m(e,t){let n={...e};for(let r of Object.keys(t))t[r]instanceof Object&&r in e&&e[r]instanceof Object?n[r]=m(e[r],t[r]):n[r]=t[r];return n}let h=null;function g(e){h=Array.from(new Set([...h||[],...e]))}async function _(e,t){(h===null||h.length===0)&&g(await a());let n={},r=l.join(process.cwd(),`locales`),i=new Set;if(h)for(let e of h)i.add(e);if(t)for(let e of t)i.add(e);i.add(r);for(let t of Array.from(i)){let r=l.join(t,e);try{await c.access(r);let e=await c.readdir(r);for(let t of e)if(t.endsWith(`on`)){let e=l.join(r,t),i=await c.readFile(e,`utf-8`),a=JSON.parse(i);n=m(n,a)}}catch{}}return n}function v(e,t){let n=p();return u(new d({headers:Object.fromEntries(n.entries())}).languages(),e,t)}async function y({children:e}){let t=(await f()).get(r)?.value||i,a=await _(t);return s.createElement(n,{locale:t,messages:a},e)}async function b(){let n=(await f()).get(r)?.value||i,a=await _(n);return{t:(n,r)=>{let i=t(a,String(n));return typeof i==`string`?e(i,r):String(n)},locale:n}}export{y as I18nProvider,v as detectLocale,a as discoverLocalePaths,_ as getMessages,o as getModuleLocalePaths,b as getTranslation,g as registerLocalePaths};
2
- //# sourceMappingURL=index.mjs.map
1
+ import{formatMessage as e,getNestedMessage as t}from"../shared/utils.mjs";import{I18nProvider as n}from"../client/index.mjs";import{COOKIE_NAME as r,DEFAULT_LOCALE as i}from"../shared/constants.mjs";import{discoverLocalePaths as a,getModuleLocalePaths as o}from"./module-loader.mjs";import s from"react";import c from"node:fs/promises";import l from"node:path";import{match as u}from"@formatjs/intl-localematcher";import d from"negotiator";import{cookies as f,headers as p}from"next/headers";function m(e,t){let n={...e};for(let r of Object.keys(t))t[r]instanceof Object&&r in e&&e[r]instanceof Object?n[r]=m(e[r],t[r]):n[r]=t[r];return n}let h=null;function g(e){h=Array.from(new Set([...h||[],...e]))}async function _(e,t){(h===null||h.length===0)&&g(await a());let n={},r=l.join(process.cwd(),`locales`),i=new Set;if(h)for(let e of h)i.add(e);if(t)for(let e of t)i.add(e);i.add(r);for(let t of Array.from(i)){let r=l.join(t,e);try{await c.access(r);let e=await c.readdir(r);for(let t of e)if(t.endsWith(`on`)){let e=l.join(r,t),i=await c.readFile(e,`utf-8`),a=JSON.parse(i);n=m(n,a)}}catch{}}return n}function v(e,t){let n=p();return u(new d({headers:Object.fromEntries(n.entries())}).languages(),e,t)}async function y({children:e}){let t=(await f()).get(r)?.value||i,a=await _(t);return s.createElement(n,{locale:t,messages:a},e)}async function b(){let n=(await f()).get(r)?.value||i,a=await _(n);return{t:(n,r)=>{let i=t(a,String(n));return typeof i==`string`?e(i,r):String(n)},locale:n}}export{y as I18nProvider,v as detectLocale,a as discoverLocalePaths,_ as getMessages,o as getModuleLocalePaths,b as getTranslation,g as registerLocalePaths};
@@ -1,2 +1 @@
1
- import e from"node:fs/promises";import t from"node:path";import"server-only";async function n(){let n=[],r=process.cwd(),i=await(async n=>{let r=[`pnpm-workspace.yaml`,`packageon`],i=n;for(console.log(`[intl]: Searching for monorepo root starting from: ${n}`);i!==t.parse(i).root;){for(let n of r)try{if(await e.access(t.join(i,n)),n===`pnpm-workspace.yaml`)return i}catch{}i=t.dirname(i)}return null})(r);if(i){let r=t.join(i,`packages`);try{let i=await e.readdir(r,{withFileTypes:!0});for(let a of i)if(a.isDirectory()){let i=t.join(r,a.name,`locales`);try{await e.access(i),n.push(i)}catch{}}}catch{}}let a=t.join(r,`node_modules`,`@arch-cadre`);try{let r=await e.readdir(a,{withFileTypes:!0});for(let i of r){let r=t.join(a,i.name,`locales`);try{await e.access(r),n.push(r)}catch{}}}catch{}let o=t.join(r,`modules`);try{let r=await e.readdir(o,{withFileTypes:!0});for(let i of r)if(i.isDirectory()){let r=t.join(o,i.name,`locales`);try{await e.access(r),n.push(r)}catch{}}}catch{}return Array.from(new Set(n))}async function r(e=[],t=`modules`){return n()}export{n as discoverLocalePaths,r as getModuleLocalePaths};
2
- //# sourceMappingURL=module-loader.mjs.map
1
+ import e from"node:fs/promises";import t from"node:path";import"server-only";async function n(){let n=[],r=process.cwd(),i=await(async n=>{let r=[`pnpm-workspace.yaml`,`packageon`],i=n;for(console.log(`[intl]: Searching for monorepo root starting from: ${n}`);i!==t.parse(i).root;){for(let n of r)try{if(await e.access(t.join(i,n)),n===`pnpm-workspace.yaml`)return i}catch{}i=t.dirname(i)}return null})(r);if(i){let r=t.join(i,`packages`);try{let i=await e.readdir(r,{withFileTypes:!0});for(let a of i)if(a.isDirectory()){let i=t.join(r,a.name,`locales`);try{await e.access(i),n.push(i)}catch{}}}catch{}}let a=t.join(r,`node_modules`,`@arch-cadre`);try{let r=await e.readdir(a,{withFileTypes:!0});for(let i of r){let r=t.join(a,i.name,`locales`);try{await e.access(r),n.push(r)}catch{}}}catch{}let o=t.join(r,`modules`);try{let r=await e.readdir(o,{withFileTypes:!0});for(let i of r)if(i.isDirectory()){let r=t.join(o,i.name,`locales`);try{await e.access(r),n.push(r)}catch{}}}catch{}return Array.from(new Set(n))}async function r(e=[],t=`modules`){return n()}export{n as discoverLocalePaths,r as getModuleLocalePaths};
@@ -1,2 +1 @@
1
- const e=`NEXT_LOCALE`,t=`en`,n=[`en`,`pl`];export{e as COOKIE_NAME,t as DEFAULT_LOCALE,n as LOCALES};
2
- //# sourceMappingURL=constants.mjs.map
1
+ const e=`NEXT_LOCALE`,t=`en`,n=[`en`,`pl`];export{e as COOKIE_NAME,t as DEFAULT_LOCALE,n as LOCALES};
@@ -1,2 +1 @@
1
- function e(e,t){if(!e)return;if(t in e)return e[t];let n=t.split(`.`),r=e,i=0;for(;i<n.length;){if(typeof r!=`object`||!r)return;let e=!1;for(let t=n.length;t>i;t--){let a=n.slice(i,t).join(`.`);if(a in r){r=r[a],i=t,e=!0;break}}if(!e)return}return r}function t(e,t){return t?e.replace(/{(\w+)}/g,(e,n)=>t[n]===void 0?e:String(t[n])):e}const n=e=>e;export{t as formatMessage,e as getNestedMessage,n as i18n};
2
- //# sourceMappingURL=utils.mjs.map
1
+ function e(e,t){if(!e)return;if(t in e)return e[t];let n=t.split(`.`),r=e,i=0;for(;i<n.length;){if(typeof r!=`object`||!r)return;let e=!1;for(let t=n.length;t>i;t--){let a=n.slice(i,t).join(`.`);if(a in r){r=r[a],i=t,e=!0;break}}if(!e)return}return r}function t(e,t){return t?e.replace(/{(\w+)}/g,(e,n)=>t[n]===void 0?e:String(t[n])):e}const n=e=>e;export{t as formatMessage,e as getNestedMessage,n as i18n};
package/package.json CHANGED
@@ -1,21 +1,12 @@
1
1
  {
2
2
  "name": "@arch-cadre/intl",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "type": "module",
5
5
  "description": "Core Intl for Kryo framework",
6
6
  "exports": {
7
- ".": {
8
- "import": "./dist/index.mjs",
9
- "require": "./dist/index.cjs"
10
- },
11
- "./client": {
12
- "import": "./dist/client/index.mjs",
13
- "require": "./dist/client/index.cjs"
14
- },
15
- "./server": {
16
- "import": "./dist/server/index.mjs",
17
- "require": "./dist/server/index.cjs"
18
- },
7
+ ".": "./dist/index.mjs",
8
+ "./client": "./dist/client/index.mjs",
9
+ "./server": "./dist/server/index.mjs",
19
10
  "./package.json": "./package.json"
20
11
  },
21
12
  "files": [
@@ -48,7 +39,5 @@
48
39
  "tsdown": "^0.20.3",
49
40
  "typescript": "^5"
50
41
  },
51
- "types": "./dist/index.d.cts",
52
- "main": "./dist/index.cjs",
53
- "module": "./dist/index.mjs"
42
+ "types": "./dist/index.d.cts"
54
43
  }
@@ -1 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
@@ -1 +0,0 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../shared/utils.cjs`);let n=require(`react`);n=e.__toESM(n);const r=Symbol.for(`kryo-intl-context`),i=globalThis[r]||(0,n.createContext)(null);globalThis[r]||(globalThis[r]=i);function a({children:e,locale:t,messages:r}){return n.createElement(i.Provider,{value:{locale:t,messages:r}},e)}function o(){let e=(0,n.useContext)(i);if(!e)throw Error(`useLocale must be used within I18nProvider`);return e.locale}function s(){let e=(0,n.useContext)(i);if(!e)throw Error(`useTranslation must be used within I18nProvider`);let{messages:r,locale:a}=e;return{t:(e,n)=>{let i=t.getNestedMessage(r,String(e));return typeof i==`string`?t.formatMessage(i,n):String(e)},locale:a}}const c=s;exports.I18nProvider=a,exports.useLocale=o,exports.useTranslation=s,exports.useTranslations=c;
@@ -1,35 +0,0 @@
1
- import { AbstractIntlMessages, TranslationKeys } from "../types.cjs";
2
- import * as React$1 from "react";
3
-
4
- //#region src/client/index.d.ts
5
- declare function I18nProvider({
6
- children,
7
- locale,
8
- messages
9
- }: {
10
- children: React$1.ReactNode;
11
- locale: string;
12
- messages: AbstractIntlMessages;
13
- }): React$1.CElement<{
14
- value: {
15
- locale: string;
16
- messages: AbstractIntlMessages;
17
- };
18
- }, React$1.Component<{
19
- value: {
20
- locale: string;
21
- messages: AbstractIntlMessages;
22
- };
23
- }, any, any>>;
24
- declare function useLocale(): string;
25
- /**
26
- * Client-side hook for translations with IntelliSense support.
27
- */
28
- declare function useTranslation(): {
29
- t: (key: TranslationKeys, values?: Record<string, any>) => string;
30
- locale: string;
31
- };
32
- declare const useTranslations: typeof useTranslation;
33
- //#endregion
34
- export { I18nProvider, useLocale, useTranslation, useTranslations };
35
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/client/index.ts"],"mappings":";;;;iBAqBgB,YAAA,CAAA;EACd,QAAA;EACA,MAAA;EACA;AAAA;EAEA,QAAA,EAAU,OAAA,CAAM,SAAA;EAChB,MAAA;EACA,QAAA,EAAU,oBAAA;AAAA,IACX,OAAA,CAAA,QAAA;;;;;;;;;;;iBAQe,SAAA,CAAA;;;;iBAWA,cAAA,CAAA;WAQE,eAAA,EAAe,MAAA,GAAW,MAAA;;;cAa/B,eAAA,SAAe,cAAA"}
@@ -1,35 +0,0 @@
1
- import { AbstractIntlMessages, TranslationKeys } from "../types.mjs";
2
- import * as React$1 from "react";
3
-
4
- //#region src/client/index.d.ts
5
- declare function I18nProvider({
6
- children,
7
- locale,
8
- messages
9
- }: {
10
- children: React$1.ReactNode;
11
- locale: string;
12
- messages: AbstractIntlMessages;
13
- }): React$1.CElement<{
14
- value: {
15
- locale: string;
16
- messages: AbstractIntlMessages;
17
- };
18
- }, React$1.Component<{
19
- value: {
20
- locale: string;
21
- messages: AbstractIntlMessages;
22
- };
23
- }, any, any>>;
24
- declare function useLocale(): string;
25
- /**
26
- * Client-side hook for translations with IntelliSense support.
27
- */
28
- declare function useTranslation(): {
29
- t: (key: TranslationKeys, values?: Record<string, any>) => string;
30
- locale: string;
31
- };
32
- declare const useTranslations: typeof useTranslation;
33
- //#endregion
34
- export { I18nProvider, useLocale, useTranslation, useTranslations };
35
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/client/index.ts"],"mappings":";;;;iBAqBgB,YAAA,CAAA;EACd,QAAA;EACA,MAAA;EACA;AAAA;EAEA,QAAA,EAAU,OAAA,CAAM,SAAA;EAChB,MAAA;EACA,QAAA,EAAU,oBAAA;AAAA,IACX,OAAA,CAAA,QAAA;;;;;;;;;;;iBAQe,SAAA,CAAA;;;;iBAWA,cAAA,CAAA;WAQE,eAAA,EAAe,MAAA,GAAW,MAAA;;;cAa/B,eAAA,SAAe,cAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":["React"],"sources":["../../src/client/index.ts"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { createContext, useContext } from \"react\";\nimport { formatMessage, getNestedMessage } from \"../shared/utils\";\nimport type { AbstractIntlMessages, TranslationKeys } from \"../types\";\n\ntype ContextType = {\n locale: string;\n messages: AbstractIntlMessages;\n};\n\nconst CONTEXT_SYMBOL = Symbol.for(\"kryo-intl-context\");\nconst IntlContext =\n (globalThis as any)[CONTEXT_SYMBOL] ||\n createContext<ContextType | null>(null);\n\nif (!(globalThis as any)[CONTEXT_SYMBOL]) {\n (globalThis as any)[CONTEXT_SYMBOL] = IntlContext;\n}\n\nexport function I18nProvider({\n children,\n locale,\n messages,\n}: {\n children: React.ReactNode;\n locale: string;\n messages: AbstractIntlMessages;\n}) {\n return React.createElement(\n IntlContext.Provider,\n { value: { locale, messages } },\n children,\n );\n}\n\nexport function useLocale() {\n const context = useContext(IntlContext) as ContextType | null;\n if (!context) {\n throw new Error(\"useLocale must be used within I18nProvider\");\n }\n return context.locale;\n}\n\n/**\n * Client-side hook for translations with IntelliSense support.\n */\nexport function useTranslation() {\n const context = useContext(IntlContext) as ContextType | null;\n if (!context) {\n throw new Error(\"useTranslation must be used within I18nProvider\");\n }\n\n const { messages, locale } = context;\n\n const t = (key: TranslationKeys, values?: Record<string, any>) => {\n const message = getNestedMessage(messages, String(key));\n\n if (typeof message !== \"string\") {\n return String(key);\n }\n\n return formatMessage(message, values);\n };\n\n return { t, locale };\n}\n\nexport const useTranslations = useTranslation;\n"],"mappings":"qKAYA,MAAM,EAAiB,OAAO,IAAI,oBAAoB,CAChD,EACH,WAAmB,IACpB,EAAkC,KAAK,CAEnC,WAAmB,KACtB,WAAmB,GAAkB,GAGxC,SAAgB,EAAa,CAC3B,WACA,SACA,YAKC,CACD,OAAOA,EAAM,cACX,EAAY,SACZ,CAAE,MAAO,CAAE,SAAQ,WAAU,CAAE,CAC/B,EACD,CAGH,SAAgB,GAAY,CAC1B,IAAM,EAAU,EAAW,EAAY,CACvC,GAAI,CAAC,EACH,MAAU,MAAM,6CAA6C,CAE/D,OAAO,EAAQ,OAMjB,SAAgB,GAAiB,CAC/B,IAAM,EAAU,EAAW,EAAY,CACvC,GAAI,CAAC,EACH,MAAU,MAAM,kDAAkD,CAGpE,GAAM,CAAE,WAAU,UAAW,EAY7B,MAAO,CAAE,GAVE,EAAsB,IAAiC,CAChE,IAAM,EAAU,EAAiB,EAAU,OAAO,EAAI,CAAC,CAMvD,OAJI,OAAO,GAAY,SAIhB,EAAc,EAAS,EAAO,CAH5B,OAAO,EAAI,EAMV,SAAQ,CAGtB,MAAa,EAAkB"}
package/dist/index.cjs DELETED
@@ -1 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./shared/utils.cjs`),t=require(`./client/index.cjs`),n=require(`./shared/constants.cjs`);exports.COOKIE_NAME=n.COOKIE_NAME,exports.DEFAULT_LOCALE=n.DEFAULT_LOCALE,exports.I18nProvider=t.I18nProvider,exports.LOCALES=n.LOCALES,exports.formatMessage=e.formatMessage,exports.getNestedMessage=e.getNestedMessage,exports.i18n=e.i18n,exports.useLocale=t.useLocale,exports.useTranslation=t.useTranslation,exports.useTranslations=t.useTranslations;
package/dist/index.d.cts DELETED
@@ -1,5 +0,0 @@
1
- import { AbstractIntlMessages, IntlMessages, NestedKeyOf, TranslationKeys } from "./types.cjs";
2
- import { I18nProvider, useLocale, useTranslation, useTranslations } from "./client/index.cjs";
3
- import { COOKIE_NAME, DEFAULT_LOCALE, LOCALES } from "./shared/constants.cjs";
4
- import { formatMessage, getNestedMessage, i18n } from "./shared/utils.cjs";
5
- export { AbstractIntlMessages, COOKIE_NAME, DEFAULT_LOCALE, I18nProvider, IntlMessages, LOCALES, NestedKeyOf, TranslationKeys, formatMessage, getNestedMessage, i18n, useLocale, useTranslation, useTranslations };
package/dist/index.d.mts DELETED
@@ -1,5 +0,0 @@
1
- import { AbstractIntlMessages, IntlMessages, NestedKeyOf, TranslationKeys } from "./types.mjs";
2
- import { I18nProvider, useLocale, useTranslation, useTranslations } from "./client/index.mjs";
3
- import { COOKIE_NAME, DEFAULT_LOCALE, LOCALES } from "./shared/constants.mjs";
4
- import { formatMessage, getNestedMessage, i18n } from "./shared/utils.mjs";
5
- export { AbstractIntlMessages, COOKIE_NAME, DEFAULT_LOCALE, I18nProvider, IntlMessages, LOCALES, NestedKeyOf, TranslationKeys, formatMessage, getNestedMessage, i18n, useLocale, useTranslation, useTranslations };
@@ -1,10 +0,0 @@
1
- //#region locales/en/global.json.d.ts
2
- declare const _exports: {
3
- "Loading...": string;
4
- "Please wait...": string;
5
- "Please wait while we load the application.": string;
6
- UnexpectedError: string;
7
- };
8
- //#endregion
9
- export { _exports };
10
- //# sourceMappingURL=global.json.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"global.json.d.cts","names":["_exports","UnexpectedError","default","_Loading___0","_Please_wait___1","_Please_wait_while_we_load_the_application_2","_UnexpectedError3"],"sources":["../../../locales/en/global.json.d.ts"],"mappings":";cAAcA,QAAAA;EACV,YAAA;EACA,gBAAA;EACA,4CAAA;EACAC,eAAAA;AAAAA"}
@@ -1,10 +0,0 @@
1
- //#region locales/en/global.json.d.ts
2
- declare const _exports: {
3
- "Loading...": string;
4
- "Please wait...": string;
5
- "Please wait while we load the application.": string;
6
- UnexpectedError: string;
7
- };
8
- //#endregion
9
- export { _exports };
10
- //# sourceMappingURL=global.json.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"global.json.d.mts","names":["_exports","UnexpectedError","default","_Loading___0","_Please_wait___1","_Please_wait_while_we_load_the_application_2","_UnexpectedError3"],"sources":["../../../locales/en/global.json.d.ts"],"mappings":";cAAcA,QAAAA;EACV,YAAA;EACA,gBAAA;EACA,4CAAA;EACAC,eAAAA;AAAAA"}
@@ -1 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../shared/utils.cjs`),n=require(`../client/index.cjs`),r=require(`../shared/constants.cjs`),i=require(`./module-loader.cjs`);let a=require(`react`);a=e.__toESM(a);let o=require(`node:fs/promises`);o=e.__toESM(o);let s=require(`node:path`);s=e.__toESM(s);let c=require(`@formatjs/intl-localematcher`),l=require(`negotiator`);l=e.__toESM(l);let u=require(`next/headers`);function d(e,t){let n={...e};for(let r of Object.keys(t))t[r]instanceof Object&&r in e&&e[r]instanceof Object?n[r]=d(e[r],t[r]):n[r]=t[r];return n}let f=null;function p(e){f=Array.from(new Set([...f||[],...e]))}async function m(e,t){(f===null||f.length===0)&&p(await i.discoverLocalePaths());let n={},r=s.default.join(process.cwd(),`locales`),a=new Set;if(f)for(let e of f)a.add(e);if(t)for(let e of t)a.add(e);a.add(r);for(let t of Array.from(a)){let r=s.default.join(t,e);try{await o.default.access(r);let e=await o.default.readdir(r);for(let t of e)if(t.endsWith(`on`)){let e=s.default.join(r,t),i=await o.default.readFile(e,`utf-8`),a=JSON.parse(i);n=d(n,a)}}catch{}}return n}function h(e,t){let n=(0,u.headers)();return(0,c.match)(new l.default({headers:Object.fromEntries(n.entries())}).languages(),e,t)}async function g({children:e}){let t=(await(0,u.cookies)()).get(r.COOKIE_NAME)?.value||r.DEFAULT_LOCALE,i=await m(t);return a.default.createElement(n.I18nProvider,{locale:t,messages:i},e)}async function _(){let e=(await(0,u.cookies)()).get(r.COOKIE_NAME)?.value||r.DEFAULT_LOCALE,n=await m(e);return{t:(e,r)=>{let i=t.getNestedMessage(n,String(e));return typeof i==`string`?t.formatMessage(i,r):String(e)},locale:e}}exports.I18nProvider=g,exports.detectLocale=h,exports.discoverLocalePaths=i.discoverLocalePaths,exports.getMessages=m,exports.getModuleLocalePaths=i.getModuleLocalePaths,exports.getTranslation=_,exports.registerLocalePaths=p;
@@ -1,27 +0,0 @@
1
- import { AbstractIntlMessages, TranslationKeys } from "../types.cjs";
2
- import { discoverLocalePaths, getModuleLocalePaths } from "./module-loader.cjs";
3
- import React from "react";
4
-
5
- //#region src/server/index.d.ts
6
- /**
7
- * Register additional directories to search for locales.
8
- * Can be called multiple times, but usually called once in RootLayout.
9
- */
10
- declare function registerLocalePaths(paths: string[]): void;
11
- declare function getMessages(locale: string, searchDirectories?: string[]): Promise<AbstractIntlMessages>;
12
- declare function detectLocale(supportedLocales: string[], defaultLocale: string): string;
13
- /**
14
- * Smart Server Component that handles locale detection and message loading automatically.
15
- */
16
- declare function I18nProvider({
17
- children
18
- }: {
19
- children: React.ReactNode;
20
- }): Promise<React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>>;
21
- declare function getTranslation(): Promise<{
22
- t: (key: TranslationKeys, values?: Record<string, any>) => string;
23
- locale: string;
24
- }>;
25
- //#endregion
26
- export { I18nProvider, detectLocale, discoverLocalePaths, getMessages, getModuleLocalePaths, getTranslation, registerLocalePaths };
27
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/server/index.ts"],"mappings":";;;;;;;;AAuCA;iBAAgB,mBAAA,CAAoB,KAAA;AAAA,iBAId,WAAA,CACpB,MAAA,UACA,iBAAA,cAA4B,OAAA,CAAA,oBAAA;AAAA,iBA8Cd,YAAA,CACd,gBAAA,YACA,aAAA;;AAlDF;;iBA+DsB,YAAA,CAAA;EACpB;AAAA;EAEA,QAAA,EAAU,KAAA,CAAM,SAAA;AAAA,IACjB,OAAA,CAAA,KAAA,CAAA,wBAAA,CAAA,KAAA,CAAA,mBAAA,CAAA,gBAAA,GAAA,gBAAA;AAAA,iBAWqB,cAAA,CAAA,GAAc,OAAA;WAQlB,eAAA,EAAe,MAAA,GAAW,MAAA"}
@@ -1,27 +0,0 @@
1
- import { AbstractIntlMessages, TranslationKeys } from "../types.mjs";
2
- import { discoverLocalePaths, getModuleLocalePaths } from "./module-loader.mjs";
3
- import React from "react";
4
-
5
- //#region src/server/index.d.ts
6
- /**
7
- * Register additional directories to search for locales.
8
- * Can be called multiple times, but usually called once in RootLayout.
9
- */
10
- declare function registerLocalePaths(paths: string[]): void;
11
- declare function getMessages(locale: string, searchDirectories?: string[]): Promise<AbstractIntlMessages>;
12
- declare function detectLocale(supportedLocales: string[], defaultLocale: string): string;
13
- /**
14
- * Smart Server Component that handles locale detection and message loading automatically.
15
- */
16
- declare function I18nProvider({
17
- children
18
- }: {
19
- children: React.ReactNode;
20
- }): Promise<React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>>;
21
- declare function getTranslation(): Promise<{
22
- t: (key: TranslationKeys, values?: Record<string, any>) => string;
23
- locale: string;
24
- }>;
25
- //#endregion
26
- export { I18nProvider, detectLocale, discoverLocalePaths, getMessages, getModuleLocalePaths, getTranslation, registerLocalePaths };
27
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/server/index.ts"],"mappings":";;;;;;;;AAuCA;iBAAgB,mBAAA,CAAoB,KAAA;AAAA,iBAId,WAAA,CACpB,MAAA,UACA,iBAAA,cAA4B,OAAA,CAAA,oBAAA;AAAA,iBA8Cd,YAAA,CACd,gBAAA,YACA,aAAA;;AAlDF;;iBA+DsB,YAAA,CAAA;EACpB;AAAA;EAEA,QAAA,EAAU,KAAA,CAAM,SAAA;AAAA,IACjB,OAAA,CAAA,KAAA,CAAA,wBAAA,CAAA,KAAA,CAAA,mBAAA,CAAA,gBAAA,GAAA,gBAAA;AAAA,iBAWqB,cAAA,CAAA,GAAc,OAAA;WAQlB,eAAA,EAAe,MAAA,GAAW,MAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":["ClientProvider"],"sources":["../../src/server/index.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { match } from \"@formatjs/intl-localematcher\";\nimport Negotiator from \"negotiator\";\nimport { cookies, headers } from \"next/headers\";\nimport React from \"react\";\nimport { I18nProvider as ClientProvider } from \"../client/index\";\nimport { COOKIE_NAME, DEFAULT_LOCALE } from \"../shared/constants\";\nimport { formatMessage, getNestedMessage } from \"../shared/utils\";\nimport type {\n AbstractIntlMessages,\n NestedKeyOf,\n TranslationKeys,\n} from \"../types\";\nimport { discoverLocalePaths } from \"./module-loader\";\n\nfunction deepMerge(target: any, source: any) {\n const result = { ...target };\n for (const key of Object.keys(source)) {\n if (\n source[key] instanceof Object &&\n key in target &&\n target[key] instanceof Object\n ) {\n result[key] = deepMerge(target[key], source[key]);\n } else {\n result[key] = source[key];\n }\n }\n return result;\n}\n\n// Internal state for locale paths\nlet registeredPaths: string[] | null = null;\n\n/**\n * Register additional directories to search for locales.\n * Can be called multiple times, but usually called once in RootLayout.\n */\nexport function registerLocalePaths(paths: string[]) {\n registeredPaths = Array.from(new Set([...(registeredPaths || []), ...paths]));\n}\n\nexport async function getMessages(\n locale: string,\n searchDirectories?: string[],\n) {\n // Auto-discovery if no paths registered\n if (registeredPaths === null || registeredPaths.length === 0) {\n const discovered = await discoverLocalePaths();\n registerLocalePaths(discovered);\n }\n\n let messages: AbstractIntlMessages = {};\n\n const defaultDir = path.join(process.cwd(), \"locales\");\n\n // Use provided paths, or registered paths, or just default\n const directoriesToScan = new Set<string>();\n\n if (registeredPaths) {\n for (const p of registeredPaths) directoriesToScan.add(p);\n }\n if (searchDirectories) {\n for (const p of searchDirectories) directoriesToScan.add(p);\n }\n directoriesToScan.add(defaultDir);\n\n for (const dir of Array.from(directoriesToScan)) {\n const localeDir = path.join(dir, locale);\n try {\n await fs.access(localeDir);\n const files = await fs.readdir(localeDir);\n\n for (const file of files) {\n if (file.endsWith(\"on\")) {\n const filePath = path.join(localeDir, file);\n const fileContent = await fs.readFile(filePath, \"utf-8\");\n const jsonContent = JSON.parse(fileContent);\n\n messages = deepMerge(messages, jsonContent);\n }\n }\n } catch (error) {\n // Ignore missing directories\n }\n }\n\n return messages;\n}\n\nexport function detectLocale(\n supportedLocales: string[],\n defaultLocale: string,\n) {\n const headerList = headers();\n const languages = new Negotiator({\n headers: Object.fromEntries((headerList as any).entries()),\n }).languages();\n\n return match(languages, supportedLocales, defaultLocale);\n}\n\n/**\n * Smart Server Component that handles locale detection and message loading automatically.\n */\nexport async function I18nProvider({\n children,\n}: {\n children: React.ReactNode;\n}) {\n const cookieStore = await cookies();\n const locale = cookieStore.get(COOKIE_NAME)?.value || DEFAULT_LOCALE;\n const messages = await getMessages(locale);\n\n // @ts-expect-error\n return React.createElement(ClientProvider, { locale, messages }, children);\n}\n\nexport * from \"./module-loader\";\n\nexport async function getTranslation() {\n const cookieStore = await cookies();\n const locale = cookieStore.get(COOKIE_NAME)?.value || DEFAULT_LOCALE;\n\n // If paths haven't been registered yet, we might be in a race condition.\n // In a real production app, we might want to have a deterministic way to load these.\n const messages = await getMessages(locale);\n\n const t = (key: TranslationKeys, values?: Record<string, any>) => {\n const message = getNestedMessage(messages, String(key));\n\n if (typeof message !== \"string\") {\n return String(key);\n }\n\n return formatMessage(message, values);\n };\n\n return { t, locale };\n}\n"],"mappings":"4eAgBA,SAAS,EAAU,EAAa,EAAa,CAC3C,IAAM,EAAS,CAAE,GAAG,EAAQ,CAC5B,IAAK,IAAM,KAAO,OAAO,KAAK,EAAO,CAEjC,EAAO,aAAgB,QACvB,KAAO,GACP,EAAO,aAAgB,OAEvB,EAAO,GAAO,EAAU,EAAO,GAAM,EAAO,GAAK,CAEjD,EAAO,GAAO,EAAO,GAGzB,OAAO,EAIT,IAAI,EAAmC,KAMvC,SAAgB,EAAoB,EAAiB,CACnD,EAAkB,MAAM,KAAK,IAAI,IAAI,CAAC,GAAI,GAAmB,EAAE,CAAG,GAAG,EAAM,CAAC,CAAC,CAG/E,eAAsB,EACpB,EACA,EACA,EAEI,IAAoB,MAAQ,EAAgB,SAAW,IAEzD,EADmB,MAAM,GAAqB,CACf,CAGjC,IAAI,EAAiC,EAAE,CAEjC,EAAa,EAAK,KAAK,QAAQ,KAAK,CAAE,UAAU,CAGhD,EAAoB,IAAI,IAE9B,GAAI,EACF,IAAK,IAAM,KAAK,EAAiB,EAAkB,IAAI,EAAE,CAE3D,GAAI,EACF,IAAK,IAAM,KAAK,EAAmB,EAAkB,IAAI,EAAE,CAE7D,EAAkB,IAAI,EAAW,CAEjC,IAAK,IAAM,KAAO,MAAM,KAAK,EAAkB,CAAE,CAC/C,IAAM,EAAY,EAAK,KAAK,EAAK,EAAO,CACxC,GAAI,CACF,MAAM,EAAG,OAAO,EAAU,CAC1B,IAAM,EAAQ,MAAM,EAAG,QAAQ,EAAU,CAEzC,IAAK,IAAM,KAAQ,EACjB,GAAI,EAAK,SAAS,KAAK,CAAE,CACvB,IAAM,EAAW,EAAK,KAAK,EAAW,EAAK,CACrC,EAAc,MAAM,EAAG,SAAS,EAAU,QAAQ,CAClD,EAAc,KAAK,MAAM,EAAY,CAE3C,EAAW,EAAU,EAAU,EAAY,OAGjC,GAKlB,OAAO,EAGT,SAAgB,EACd,EACA,EACA,CACA,IAAM,EAAa,GAAS,CAK5B,OAAO,EAJW,IAAI,EAAW,CAC/B,QAAS,OAAO,YAAa,EAAmB,SAAS,CAAC,CAC3D,CAAC,CAAC,WAAW,CAEU,EAAkB,EAAc,CAM1D,eAAsB,EAAa,CACjC,YAGC,CAED,IAAM,GADc,MAAM,GAAS,EACR,IAAI,EAAY,EAAE,OAAS,EAChD,EAAW,MAAM,EAAY,EAAO,CAG1C,OAAO,EAAM,cAAcA,EAAgB,CAAE,SAAQ,WAAU,CAAE,EAAS,CAK5E,eAAsB,GAAiB,CAErC,IAAM,GADc,MAAM,GAAS,EACR,IAAI,EAAY,EAAE,OAAS,EAIhD,EAAW,MAAM,EAAY,EAAO,CAY1C,MAAO,CAAE,GAVE,EAAsB,IAAiC,CAChE,IAAM,EAAU,EAAiB,EAAU,OAAO,EAAI,CAAC,CAMvD,OAJI,OAAO,GAAY,SAIhB,EAAc,EAAS,EAAO,CAH5B,OAAO,EAAI,EAMV,SAAQ"}
@@ -1 +0,0 @@
1
- const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`node:fs/promises`);t=e.__toESM(t);let n=require(`node:path`);n=e.__toESM(n),require(`server-only`);async function r(){let e=[],r=process.cwd(),i=await(async e=>{let r=[`pnpm-workspace.yaml`,`packageon`],i=e;for(console.log(`[intl]: Searching for monorepo root starting from: ${e}`);i!==n.default.parse(i).root;){for(let e of r)try{if(await t.default.access(n.default.join(i,e)),e===`pnpm-workspace.yaml`)return i}catch{}i=n.default.dirname(i)}return null})(r);if(i){let r=n.default.join(i,`packages`);try{let i=await t.default.readdir(r,{withFileTypes:!0});for(let a of i)if(a.isDirectory()){let i=n.default.join(r,a.name,`locales`);try{await t.default.access(i),e.push(i)}catch{}}}catch{}}let a=n.default.join(r,`node_modules`,`@arch-cadre`);try{let r=await t.default.readdir(a,{withFileTypes:!0});for(let i of r){let r=n.default.join(a,i.name,`locales`);try{await t.default.access(r),e.push(r)}catch{}}}catch{}let o=n.default.join(r,`modules`);try{let r=await t.default.readdir(o,{withFileTypes:!0});for(let i of r)if(i.isDirectory()){let r=n.default.join(o,i.name,`locales`);try{await t.default.access(r),e.push(r)}catch{}}}catch{}return Array.from(new Set(e))}async function i(e=[],t=`modules`){return r()}exports.discoverLocalePaths=r,exports.getModuleLocalePaths=i;
@@ -1,9 +0,0 @@
1
- //#region src/server/module-loader.d.ts
2
- declare function discoverLocalePaths(): Promise<string[]>;
3
- /**
4
- * Legacy support or manual overrides
5
- */
6
- declare function getModuleLocalePaths(packageModules?: string[], localModulesDir?: string): Promise<string[]>;
7
- //#endregion
8
- export { discoverLocalePaths, getModuleLocalePaths };
9
- //# sourceMappingURL=module-loader.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-loader.d.cts","names":[],"sources":["../../src/server/module-loader.ts"],"mappings":";iBAIsB,mBAAA,CAAA,GAAuB,OAAA;;;;iBAgFvB,oBAAA,CACpB,cAAA,aACA,eAAA,YACC,OAAA"}
@@ -1,11 +0,0 @@
1
- import "server-only";
2
-
3
- //#region src/server/module-loader.d.ts
4
- declare function discoverLocalePaths(): Promise<string[]>;
5
- /**
6
- * Legacy support or manual overrides
7
- */
8
- declare function getModuleLocalePaths(packageModules?: string[], localModulesDir?: string): Promise<string[]>;
9
- //#endregion
10
- export { discoverLocalePaths, getModuleLocalePaths };
11
- //# sourceMappingURL=module-loader.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-loader.d.mts","names":[],"sources":["../../src/server/module-loader.ts"],"mappings":";;;iBAIsB,mBAAA,CAAA,GAAuB,OAAA;;AAA7C;;iBAgFsB,oBAAA,CACpB,cAAA,aACA,eAAA,YACC,OAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-loader.mjs","names":[],"sources":["../../src/server/module-loader.ts"],"sourcesContent":["import \"server-only\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport async function discoverLocalePaths(): Promise<string[]> {\n const paths: string[] = [];\n const root = process.cwd();\n\n // Helper to find monorepo root (looking for pnpm-workspace.yaml or turboon)\n const findMonorepoRoot = async (current: string): Promise<string | null> => {\n const indicators = [\"pnpm-workspace.yaml\", \"packageon\"];\n let dir = current;\n\n console.log(\n `[intl]: Searching for monorepo root starting from: ${current}`,\n );\n\n while (dir !== path.parse(dir).root) {\n for (const indicator of indicators) {\n try {\n await fs.access(path.join(dir, indicator));\n // If we find pnpm-workspace.yaml, this is definitely it\n if (indicator === \"pnpm-workspace.yaml\") return dir;\n } catch { }\n }\n dir = path.dirname(dir);\n }\n return null;\n };\n\n const monorepoRoot = await findMonorepoRoot(root);\n\n // 1. Monorepo 'packages' scan\n if (monorepoRoot) {\n const packagesDir = path.join(monorepoRoot, \"packages\");\n try {\n const entries = await fs.readdir(packagesDir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const localePath = path.join(packagesDir, entry.name, \"locales\");\n try {\n await fs.access(localePath);\n\n paths.push(localePath);\n } catch { }\n }\n }\n } catch (e) { }\n }\n\n // 2. node_modules/@arch-cadre scan (relative to app root)\n const nodeModulesKryo = path.join(root, \"node_modules\", \"@arch-cadre\");\n try {\n const entries = await fs.readdir(nodeModulesKryo, { withFileTypes: true });\n for (const entry of entries) {\n const localePath = path.join(nodeModulesKryo, entry.name, \"locales\");\n try {\n await fs.access(localePath);\n paths.push(localePath);\n } catch { }\n }\n } catch (e) { }\n\n // 3. Local 'modules' scan (relative to app root)\n const localModulesDir = path.join(root, \"modules\");\n try {\n const entries = await fs.readdir(localModulesDir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const localePath = path.join(localModulesDir, entry.name, \"locales\");\n try {\n await fs.access(localePath);\n paths.push(localePath);\n } catch { }\n }\n }\n } catch (e) { }\n\n return Array.from(new Set(paths));\n}\n\n/**\n * Legacy support or manual overrides\n */\nexport async function getModuleLocalePaths(\n packageModules: string[] = [],\n localModulesDir: string = \"modules\",\n): Promise<string[]> {\n // ... rest of the existing function if we want to keep it,\n // but we'll probably favor discoverLocalePaths\n return discoverLocalePaths();\n}\n"],"mappings":"6EAIA,eAAsB,GAAyC,CAC7D,IAAM,EAAkB,EAAE,CACpB,EAAO,QAAQ,KAAK,CAwBpB,EAAe,MArBI,KAAO,IAA4C,CAC1E,IAAM,EAAa,CAAC,sBAAuB,YAAY,CACnD,EAAM,EAMV,IAJA,QAAQ,IACN,sDAAsD,IACvD,CAEM,IAAQ,EAAK,MAAM,EAAI,CAAC,MAAM,CACnC,IAAK,IAAM,KAAa,EACtB,GAAI,CAGF,GAFA,MAAM,EAAG,OAAO,EAAK,KAAK,EAAK,EAAU,CAAC,CAEtC,IAAc,sBAAuB,OAAO,OAC1C,EAEV,EAAM,EAAK,QAAQ,EAAI,CAEzB,OAAO,OAGmC,EAAK,CAGjD,GAAI,EAAc,CAChB,IAAM,EAAc,EAAK,KAAK,EAAc,WAAW,CACvD,GAAI,CACF,IAAM,EAAU,MAAM,EAAG,QAAQ,EAAa,CAAE,cAAe,GAAM,CAAC,CACtE,IAAK,IAAM,KAAS,EAClB,GAAI,EAAM,aAAa,CAAE,CACvB,IAAM,EAAa,EAAK,KAAK,EAAa,EAAM,KAAM,UAAU,CAChE,GAAI,CACF,MAAM,EAAG,OAAO,EAAW,CAE3B,EAAM,KAAK,EAAW,MAChB,SAGF,GAId,IAAM,EAAkB,EAAK,KAAK,EAAM,eAAgB,cAAc,CACtE,GAAI,CACF,IAAM,EAAU,MAAM,EAAG,QAAQ,EAAiB,CAAE,cAAe,GAAM,CAAC,CAC1E,IAAK,IAAM,KAAS,EAAS,CAC3B,IAAM,EAAa,EAAK,KAAK,EAAiB,EAAM,KAAM,UAAU,CACpE,GAAI,CACF,MAAM,EAAG,OAAO,EAAW,CAC3B,EAAM,KAAK,EAAW,MAChB,SAEA,EAGZ,IAAM,EAAkB,EAAK,KAAK,EAAM,UAAU,CAClD,GAAI,CACF,IAAM,EAAU,MAAM,EAAG,QAAQ,EAAiB,CAAE,cAAe,GAAM,CAAC,CAC1E,IAAK,IAAM,KAAS,EAClB,GAAI,EAAM,aAAa,CAAE,CACvB,IAAM,EAAa,EAAK,KAAK,EAAiB,EAAM,KAAM,UAAU,CACpE,GAAI,CACF,MAAM,EAAG,OAAO,EAAW,CAC3B,EAAM,KAAK,EAAW,MAChB,SAGF,EAEZ,OAAO,MAAM,KAAK,IAAI,IAAI,EAAM,CAAC,CAMnC,eAAsB,EACpB,EAA2B,EAAE,CAC7B,EAA0B,UACP,CAGnB,OAAO,GAAqB"}
@@ -1 +0,0 @@
1
- const e=[`en`,`pl`];exports.COOKIE_NAME=`NEXT_LOCALE`,exports.DEFAULT_LOCALE=`en`,exports.LOCALES=e;
@@ -1,7 +0,0 @@
1
- //#region src/shared/constants.d.ts
2
- declare const COOKIE_NAME = "NEXT_LOCALE";
3
- declare const DEFAULT_LOCALE = "en";
4
- declare const LOCALES: string[];
5
- //#endregion
6
- export { COOKIE_NAME, DEFAULT_LOCALE, LOCALES };
7
- //# sourceMappingURL=constants.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.cts","names":[],"sources":["../../src/shared/constants.ts"],"mappings":";cAAa,WAAA;AAAA,cACA,cAAA;AAAA,cACA,OAAA"}
@@ -1,7 +0,0 @@
1
- //#region src/shared/constants.d.ts
2
- declare const COOKIE_NAME = "NEXT_LOCALE";
3
- declare const DEFAULT_LOCALE = "en";
4
- declare const LOCALES: string[];
5
- //#endregion
6
- export { COOKIE_NAME, DEFAULT_LOCALE, LOCALES };
7
- //# sourceMappingURL=constants.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.mts","names":[],"sources":["../../src/shared/constants.ts"],"mappings":";cAAa,WAAA;AAAA,cACA,cAAA;AAAA,cACA,OAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.mjs","names":[],"sources":["../../src/shared/constants.ts"],"sourcesContent":["export const COOKIE_NAME = \"NEXT_LOCALE\";\nexport const DEFAULT_LOCALE = \"en\";\nexport const LOCALES = [\"en\", \"pl\"];\n"],"mappings":"AAAA,MAAa,EAAc,cACd,EAAiB,KACjB,EAAU,CAAC,KAAM,KAAK"}
@@ -1 +0,0 @@
1
- function e(e,t){if(!e)return;if(t in e)return e[t];let n=t.split(`.`),r=e,i=0;for(;i<n.length;){if(typeof r!=`object`||!r)return;let e=!1;for(let t=n.length;t>i;t--){let a=n.slice(i,t).join(`.`);if(a in r){r=r[a],i=t,e=!0;break}}if(!e)return}return r}function t(e,t){return t?e.replace(/{(\w+)}/g,(e,n)=>t[n]===void 0?e:String(t[n])):e}const n=e=>e;exports.formatMessage=t,exports.getNestedMessage=e,exports.i18n=n;
@@ -1,13 +0,0 @@
1
- import { AbstractIntlMessages } from "../types.cjs";
2
-
3
- //#region src/shared/utils.d.ts
4
- declare function getNestedMessage(messages: AbstractIntlMessages | undefined, path: string): string | AbstractIntlMessages | undefined;
5
- declare function formatMessage(message: string, values?: Record<string, any>): string;
6
- /**
7
- * Identity function used as a marker for static analysis tools to extract
8
- * translation keys that are defined as plain strings but translated later.
9
- */
10
- declare const i18n: (key: string) => string;
11
- //#endregion
12
- export { formatMessage, getNestedMessage, i18n };
13
- //# sourceMappingURL=utils.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.cts","names":[],"sources":["../../src/shared/utils.ts"],"mappings":";;;iBAEgB,gBAAA,CACd,QAAA,EAAU,oBAAA,cACV,IAAA,oBACU,oBAAA;AAAA,iBAmCI,aAAA,CACd,OAAA,UACA,MAAA,GAAS,MAAA;AAxCX;;;;AAAA,cAqDa,IAAA,GAAQ,GAAA"}
@@ -1,13 +0,0 @@
1
- import { AbstractIntlMessages } from "../types.mjs";
2
-
3
- //#region src/shared/utils.d.ts
4
- declare function getNestedMessage(messages: AbstractIntlMessages | undefined, path: string): string | AbstractIntlMessages | undefined;
5
- declare function formatMessage(message: string, values?: Record<string, any>): string;
6
- /**
7
- * Identity function used as a marker for static analysis tools to extract
8
- * translation keys that are defined as plain strings but translated later.
9
- */
10
- declare const i18n: (key: string) => string;
11
- //#endregion
12
- export { formatMessage, getNestedMessage, i18n };
13
- //# sourceMappingURL=utils.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.mts","names":[],"sources":["../../src/shared/utils.ts"],"mappings":";;;iBAEgB,gBAAA,CACd,QAAA,EAAU,oBAAA,cACV,IAAA,oBACU,oBAAA;AAAA,iBAmCI,aAAA,CACd,OAAA,UACA,MAAA,GAAS,MAAA;AAxCX;;;;AAAA,cAqDa,IAAA,GAAQ,GAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.mjs","names":[],"sources":["../../src/shared/utils.ts"],"sourcesContent":["import type { AbstractIntlMessages } from \"../types\";\n\nexport function getNestedMessage(\n messages: AbstractIntlMessages | undefined,\n path: string,\n): string | AbstractIntlMessages | undefined {\n if (!messages) return undefined;\n\n // Try direct match first (optimization + exact match with dots)\n if (path in messages) return messages[path];\n\n const parts = path.split(\".\");\n let current: any = messages;\n\n let i = 0;\n while (i < parts.length) {\n if (typeof current !== \"object\" || current === null) return undefined;\n\n // Try to match longest possible key from current position\n let found = false;\n for (let j = parts.length; j > i; j--) {\n const keyAttempt = parts.slice(i, j).join(\".\");\n if (keyAttempt in current) {\n current = current[keyAttempt];\n i = j;\n found = true;\n break;\n }\n }\n\n if (!found) {\n // If we can't match anything, check if we are at the end and looking for a partial key?\n // But strictly, we failed to traverse.\n return undefined;\n }\n }\n\n return current;\n}\n\nexport function formatMessage(\n message: string,\n values?: Record<string, any>,\n): string {\n if (!values) return message;\n\n return message.replace(/{(\\w+)}/g, (match, key) => {\n return values[key] !== undefined ? String(values[key]) : match;\n });\n}\n\n/**\n * Identity function used as a marker for static analysis tools to extract\n * translation keys that are defined as plain strings but translated later.\n */\nexport const i18n = (key: string): string => key;\n"],"mappings":"AAEA,SAAgB,EACd,EACA,EAC2C,CAC3C,GAAI,CAAC,EAAU,OAGf,GAAI,KAAQ,EAAU,OAAO,EAAS,GAEtC,IAAM,EAAQ,EAAK,MAAM,IAAI,CACzB,EAAe,EAEf,EAAI,EACR,KAAO,EAAI,EAAM,QAAQ,CACvB,GAAI,OAAO,GAAY,WAAY,EAAkB,OAGrD,IAAI,EAAQ,GACZ,IAAK,IAAI,EAAI,EAAM,OAAQ,EAAI,EAAG,IAAK,CACrC,IAAM,EAAa,EAAM,MAAM,EAAG,EAAE,CAAC,KAAK,IAAI,CAC9C,GAAI,KAAc,EAAS,CACzB,EAAU,EAAQ,GAClB,EAAI,EACJ,EAAQ,GACR,OAIJ,GAAI,CAAC,EAGH,OAIJ,OAAO,EAGT,SAAgB,EACd,EACA,EACQ,CAGR,OAFK,EAEE,EAAQ,QAAQ,YAAa,EAAO,IAClC,EAAO,KAAS,IAAA,GAAkC,EAAtB,OAAO,EAAO,GAAK,CACtD,CAJkB,EAWtB,MAAa,EAAQ,GAAwB"}
package/dist/types.d.cts DELETED
@@ -1,23 +0,0 @@
1
- import { _exports } from "./locales/en/global.json.cjs";
2
-
3
- //#region src/types.d.ts
4
- type JsonDataType = typeof _exports;
5
- interface IntlMessages extends JsonDataType {}
6
- /**
7
- * Global namespace augmentation for translation messages.
8
- */
9
- declare global {
10
- interface IntlMessages {}
11
- }
12
- type AbstractIntlMessages = Record<string, any>;
13
- /**
14
- * Recursive type to get all nested keys joined by dots.
15
- */
16
- type NestedKeyOf<ObjectType> = { [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}` | `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}` }[keyof ObjectType & (string | number)];
17
- /**
18
- * Gets translation keys for a specific namespace or all keys if none is provided.
19
- */
20
- type TranslationKeys<N = undefined> = N extends keyof IntlMessages ? NestedKeyOf<IntlMessages[N]> | (string & {}) : NestedKeyOf<IntlMessages> | (string & {});
21
- //#endregion
22
- export { AbstractIntlMessages, IntlMessages, NestedKeyOf, TranslationKeys };
23
- //# sourceMappingURL=types.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;KAEK,YAAA,UAAsB,QAAA;AAAA,UAEV,YAAA,SAAqB,YAAA;;;;QAK9B,MAAA;EAAA,UACI,YAAA;AAAA;AAAA,KAGA,oBAAA,GAAuB,MAAA;;AATmB;;KAc1C,WAAA,+BACI,UAAA,uBAAiC,UAAA,CAAW,GAAA,sBACrD,GAAA,QAAW,GAAA,IAAO,WAAA,CAAY,UAAA,CAAW,GAAA,UACzC,GAAA,WACC,UAAA;;AATR;;KAcY,eAAA,kBAAiC,CAAA,eAAgB,YAAA,GACzD,WAAA,CAAY,YAAA,CAAa,CAAA,qBACzB,WAAA,CAAY,YAAA"}
package/dist/types.d.mts DELETED
@@ -1,23 +0,0 @@
1
- import { _exports } from "./locales/en/global.json.mjs";
2
-
3
- //#region src/types.d.ts
4
- type JsonDataType = typeof _exports;
5
- interface IntlMessages extends JsonDataType {}
6
- /**
7
- * Global namespace augmentation for translation messages.
8
- */
9
- declare global {
10
- interface IntlMessages {}
11
- }
12
- type AbstractIntlMessages = Record<string, any>;
13
- /**
14
- * Recursive type to get all nested keys joined by dots.
15
- */
16
- type NestedKeyOf<ObjectType> = { [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}` | `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}` }[keyof ObjectType & (string | number)];
17
- /**
18
- * Gets translation keys for a specific namespace or all keys if none is provided.
19
- */
20
- type TranslationKeys<N = undefined> = N extends keyof IntlMessages ? NestedKeyOf<IntlMessages[N]> | (string & {}) : NestedKeyOf<IntlMessages> | (string & {});
21
- //#endregion
22
- export { AbstractIntlMessages, IntlMessages, NestedKeyOf, TranslationKeys };
23
- //# sourceMappingURL=types.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;KAEK,YAAA,UAAsB,QAAA;AAAA,UAEV,YAAA,SAAqB,YAAA;;;;QAK9B,MAAA;EAAA,UACI,YAAA;AAAA;AAAA,KAGA,oBAAA,GAAuB,MAAA;;AATmB;;KAc1C,WAAA,+BACI,UAAA,uBAAiC,UAAA,CAAW,GAAA,sBACrD,GAAA,QAAW,GAAA,IAAO,WAAA,CAAY,UAAA,CAAW,GAAA,UACzC,GAAA,WACC,UAAA;;AATR;;KAcY,eAAA,kBAAiC,CAAA,eAAgB,YAAA,GACzD,WAAA,CAAY,YAAA,CAAa,CAAA,qBACzB,WAAA,CAAY,YAAA"}