express-intlayer 5.0.2 → 5.0.4

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { createModuleAugmentation } from '@intlayer/chokidar';\nimport { type Locales, getConfiguration } from '@intlayer/config';\nimport { getTranslation, localeDetector } from '@intlayer/core';\nimport { createNamespace } from 'cls-hooked';\nimport type { NextFunction, RequestHandler, Request, Response } from 'express';\nimport { type IConfigLocales } from 'intlayer';\n\nconst { middleware, internationalization } = getConfiguration({\n verbose: true,\n});\nconst { headerName, cookieName } = middleware;\n\nconst appNamespace = createNamespace('app');\n\ncreateModuleAugmentation();\n\nexport const translateFunction =\n (_req: Request, res: Response, _next?: NextFunction) =>\n <T extends string>(\n content: IConfigLocales<T> | string,\n locale?: Locales\n ): T => {\n const { locale: currentLocale, defaultLocale } = res.locals as {\n locale: Locales;\n defaultLocale: Locales;\n };\n\n const targetLocale = locale ?? currentLocale;\n\n if (typeof content === 'undefined') {\n return '' as unknown as T;\n }\n\n if (typeof content === 'string') {\n return content as unknown as T;\n }\n\n if (\n typeof content?.[targetLocale as unknown as keyof IConfigLocales<T>] ===\n 'undefined'\n ) {\n if (\n typeof content?.[\n defaultLocale as unknown as keyof IConfigLocales<T>\n ] === 'undefined'\n ) {\n return content as unknown as T;\n } else {\n return getTranslation(content, defaultLocale);\n }\n }\n\n return getTranslation(content, targetLocale);\n };\n\n/**\n * Detect locale used by the user and load it into res locale storage\n *\n * @returns\n */\nexport const intlayer = (): RequestHandler => (req, res, next) => {\n // Detect if locale is set by intlayer frontend lib in the cookies\n const localeCookie = req.cookies?.[cookieName];\n // Detect if locale is set by intlayer frontend lib in the headers\n const localeHeader = req.headers?.[headerName];\n // Interpret browser locale\n\n const negotiatorHeaders: Record<string, string> = {};\n\n // // Check if req.headers exists and is an object\n if (req && typeof req.headers === 'object') {\n // Copy all headers from the request to negotiatorHeaders\n for (const key in req.headers) {\n if (typeof req.headers[key] === 'string') {\n negotiatorHeaders[key] = req.headers[key];\n }\n }\n }\n\n const localeDetected = localeDetector(\n negotiatorHeaders,\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n res.locals.locale_header = localeHeader;\n res.locals.locale_cookie = localeCookie;\n res.locals.locale_detected = localeDetected;\n res.locals.locale = localeCookie ?? localeHeader ?? localeDetected;\n res.locals.defaultLocale = internationalization.defaultLocale;\n\n const t = translateFunction(req, res, next);\n res.locals.t = t;\n\n appNamespace.run(() => {\n appNamespace.set('t', t);\n\n next();\n });\n};\n\ntype LanguageContent<Content = string> = IConfigLocales<Content>;\n\nexport const t = <Content = string>(\n content: LanguageContent<Content>,\n locale?: Locales\n): Content => appNamespace.get('t')(content, locale);\n\nexport { LanguageContent };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyC;AACzC,oBAA+C;AAC/C,kBAA+C;AAC/C,wBAAgC;AAIhC,MAAM,EAAE,YAAY,qBAAqB,QAAI,gCAAiB;AAAA,EAC5D,SAAS;AACX,CAAC;AACD,MAAM,EAAE,YAAY,WAAW,IAAI;AAEnC,MAAM,mBAAe,mCAAgB,KAAK;AAAA,IAE1C,0CAAyB;AAElB,MAAM,oBACX,CAAC,MAAe,KAAe,UAC/B,CACE,SACA,WACM;AACN,QAAM,EAAE,QAAQ,eAAe,cAAc,IAAI,IAAI;AAKrD,QAAM,eAAe,UAAU;AAE/B,MAAI,OAAO,YAAY,aAAa;AAClC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO;AAAA,EACT;AAEA,MACE,OAAO,UAAU,YAAkD,MACnE,aACA;AACA,QACE,OAAO,UACL,aACF,MAAM,aACN;AACA,aAAO;AAAA,IACT,OAAO;AACL,iBAAO,4BAAe,SAAS,aAAa;AAAA,IAC9C;AAAA,EACF;AAEA,aAAO,4BAAe,SAAS,YAAY;AAC7C;AAOK,MAAM,WAAW,MAAsB,CAAC,KAAK,KAAK,SAAS;AAEhE,QAAM,eAAe,IAAI,UAAU,UAAU;AAE7C,QAAM,eAAe,IAAI,UAAU,UAAU;AAG7C,QAAM,oBAA4C,CAAC;AAGnD,MAAI,OAAO,OAAO,IAAI,YAAY,UAAU;AAE1C,eAAW,OAAO,IAAI,SAAS;AAC7B,UAAI,OAAO,IAAI,QAAQ,GAAG,MAAM,UAAU;AACxC,0BAAkB,GAAG,IAAI,IAAI,QAAQ,GAAG;AAAA,MAC1C;AAAA,IACF;AAAA,EACF;AAEA,QAAM,qBAAiB;AAAA,IACrB;AAAA,IACA,qBAAqB;AAAA,IACrB,qBAAqB;AAAA,EACvB;AAEA,MAAI,OAAO,gBAAgB;AAC3B,MAAI,OAAO,gBAAgB;AAC3B,MAAI,OAAO,kBAAkB;AAC7B,MAAI,OAAO,SAAS,gBAAgB,gBAAgB;AACpD,MAAI,OAAO,gBAAgB,qBAAqB;AAEhD,QAAMA,KAAI,kBAAkB,KAAK,KAAK,IAAI;AAC1C,MAAI,OAAO,IAAIA;AAEf,eAAa,IAAI,MAAM;AACrB,iBAAa,IAAI,KAAKA,EAAC;AAEvB,SAAK;AAAA,EACP,CAAC;AACH;AAIO,MAAM,IAAI,CACf,SACA,WACY,aAAa,IAAI,GAAG,EAAE,SAAS,MAAM;","names":["t"]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { createModuleAugmentation } from '@intlayer/chokidar';\nimport { type Locales, getConfiguration } from '@intlayer/config';\nimport {\n getTranslation,\n localeDetector,\n type LanguageContent,\n} from '@intlayer/core';\nimport { createNamespace } from 'cls-hooked';\nimport type { NextFunction, RequestHandler, Request, Response } from 'express';\n\nconst { middleware, internationalization } = getConfiguration({\n verbose: true,\n});\nconst { headerName, cookieName } = middleware;\n\nconst appNamespace = createNamespace('app');\n\ncreateModuleAugmentation();\n\nexport const translateFunction =\n (_req: Request, res: Response, _next?: NextFunction) =>\n <T extends string>(\n content: LanguageContent<T> | string,\n locale?: Locales\n ): T => {\n const { locale: currentLocale, defaultLocale } = res.locals as {\n locale: Locales;\n defaultLocale: Locales;\n };\n\n const targetLocale = locale ?? currentLocale;\n\n if (typeof content === 'undefined') {\n return '' as unknown as T;\n }\n\n if (typeof content === 'string') {\n return content as unknown as T;\n }\n\n if (\n typeof content?.[targetLocale as unknown as keyof LanguageContent<T>] ===\n 'undefined'\n ) {\n if (\n typeof content?.[\n defaultLocale as unknown as keyof LanguageContent<T>\n ] === 'undefined'\n ) {\n return content as unknown as T;\n } else {\n return getTranslation(content, defaultLocale);\n }\n }\n\n return getTranslation(content, targetLocale);\n };\n\n/**\n * Detect locale used by the user and load it into res locale storage\n *\n * @returns\n */\nexport const intlayer = (): RequestHandler => (req, res, next) => {\n // Detect if locale is set by intlayer frontend lib in the cookies\n const localeCookie = req.cookies?.[cookieName];\n // Detect if locale is set by intlayer frontend lib in the headers\n const localeHeader = req.headers?.[headerName];\n // Interpret browser locale\n\n const negotiatorHeaders: Record<string, string> = {};\n\n // // Check if req.headers exists and is an object\n if (req && typeof req.headers === 'object') {\n // Copy all headers from the request to negotiatorHeaders\n for (const key in req.headers) {\n if (typeof req.headers[key] === 'string') {\n negotiatorHeaders[key] = req.headers[key];\n }\n }\n }\n\n const localeDetected = localeDetector(\n negotiatorHeaders,\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n res.locals.locale_header = localeHeader;\n res.locals.locale_cookie = localeCookie;\n res.locals.locale_detected = localeDetected;\n res.locals.locale = localeCookie ?? localeHeader ?? localeDetected;\n res.locals.defaultLocale = internationalization.defaultLocale;\n\n const t = translateFunction(req, res, next);\n res.locals.t = t;\n\n appNamespace.run(() => {\n appNamespace.set('t', t);\n\n next();\n });\n};\n\nexport const t = <Content = string>(\n content: LanguageContent<Content>,\n locale?: Locales\n): Content => appNamespace.get('t')(content, locale);\n\nexport { LanguageContent };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAA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,gBAAgB,gBAAgB;AACpD,MAAI,OAAO,gBAAgB,qBAAqB;AAEhD,QAAMA,KAAI,kBAAkB,KAAK,KAAK,IAAI;AAC1C,MAAI,OAAO,IAAIA;AAEf,eAAa,IAAI,MAAM;AACrB,iBAAa,IAAI,KAAKA,EAAC;AAEvB,SAAK;AAAA,EACP,CAAC;AACH;AAEO,MAAM,IAAI,CACf,SACA,WACY,aAAa,IAAI,GAAG,EAAE,SAAS,MAAM;","names":["t"]}
@@ -1,6 +1,9 @@
1
1
  import { createModuleAugmentation } from "@intlayer/chokidar";
2
2
  import { getConfiguration } from "@intlayer/config";
3
- import { getTranslation, localeDetector } from "@intlayer/core";
3
+ import {
4
+ getTranslation,
5
+ localeDetector
6
+ } from "@intlayer/core";
4
7
  import { createNamespace } from "cls-hooked";
5
8
  const { middleware, internationalization } = getConfiguration({
6
9
  verbose: true
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { createModuleAugmentation } from '@intlayer/chokidar';\nimport { type Locales, getConfiguration } from '@intlayer/config';\nimport { getTranslation, localeDetector } from '@intlayer/core';\nimport { createNamespace } from 'cls-hooked';\nimport type { NextFunction, RequestHandler, Request, Response } from 'express';\nimport { type IConfigLocales } from 'intlayer';\n\nconst { middleware, internationalization } = getConfiguration({\n verbose: true,\n});\nconst { headerName, cookieName } = middleware;\n\nconst appNamespace = createNamespace('app');\n\ncreateModuleAugmentation();\n\nexport const translateFunction =\n (_req: Request, res: Response, _next?: NextFunction) =>\n <T extends string>(\n content: IConfigLocales<T> | string,\n locale?: Locales\n ): T => {\n const { locale: currentLocale, defaultLocale } = res.locals as {\n locale: Locales;\n defaultLocale: Locales;\n };\n\n const targetLocale = locale ?? currentLocale;\n\n if (typeof content === 'undefined') {\n return '' as unknown as T;\n }\n\n if (typeof content === 'string') {\n return content as unknown as T;\n }\n\n if (\n typeof content?.[targetLocale as unknown as keyof IConfigLocales<T>] ===\n 'undefined'\n ) {\n if (\n typeof content?.[\n defaultLocale as unknown as keyof IConfigLocales<T>\n ] === 'undefined'\n ) {\n return content as unknown as T;\n } else {\n return getTranslation(content, defaultLocale);\n }\n }\n\n return getTranslation(content, targetLocale);\n };\n\n/**\n * Detect locale used by the user and load it into res locale storage\n *\n * @returns\n */\nexport const intlayer = (): RequestHandler => (req, res, next) => {\n // Detect if locale is set by intlayer frontend lib in the cookies\n const localeCookie = req.cookies?.[cookieName];\n // Detect if locale is set by intlayer frontend lib in the headers\n const localeHeader = req.headers?.[headerName];\n // Interpret browser locale\n\n const negotiatorHeaders: Record<string, string> = {};\n\n // // Check if req.headers exists and is an object\n if (req && typeof req.headers === 'object') {\n // Copy all headers from the request to negotiatorHeaders\n for (const key in req.headers) {\n if (typeof req.headers[key] === 'string') {\n negotiatorHeaders[key] = req.headers[key];\n }\n }\n }\n\n const localeDetected = localeDetector(\n negotiatorHeaders,\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n res.locals.locale_header = localeHeader;\n res.locals.locale_cookie = localeCookie;\n res.locals.locale_detected = localeDetected;\n res.locals.locale = localeCookie ?? localeHeader ?? localeDetected;\n res.locals.defaultLocale = internationalization.defaultLocale;\n\n const t = translateFunction(req, res, next);\n res.locals.t = t;\n\n appNamespace.run(() => {\n appNamespace.set('t', t);\n\n next();\n });\n};\n\ntype LanguageContent<Content = string> = IConfigLocales<Content>;\n\nexport const t = <Content = string>(\n content: LanguageContent<Content>,\n locale?: Locales\n): Content => appNamespace.get('t')(content, locale);\n\nexport { LanguageContent };\n"],"mappings":"AAAA,SAAS,gCAAgC;AACzC,SAAuB,wBAAwB;AAC/C,SAAS,gBAAgB,sBAAsB;AAC/C,SAAS,uBAAuB;AAIhC,MAAM,EAAE,YAAY,qBAAqB,IAAI,iBAAiB;AAAA,EAC5D,SAAS;AACX,CAAC;AACD,MAAM,EAAE,YAAY,WAAW,IAAI;AAEnC,MAAM,eAAe,gBAAgB,KAAK;AAE1C,yBAAyB;AAElB,MAAM,oBACX,CAAC,MAAe,KAAe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;","names":["t"]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { createModuleAugmentation } from '@intlayer/chokidar';\nimport { type Locales, getConfiguration } from '@intlayer/config';\nimport {\n getTranslation,\n localeDetector,\n type LanguageContent,\n} from '@intlayer/core';\nimport { createNamespace } from 'cls-hooked';\nimport type { NextFunction, RequestHandler, Request, Response } from 'express';\n\nconst { middleware, internationalization } = getConfiguration({\n verbose: true,\n});\nconst { headerName, cookieName } = middleware;\n\nconst appNamespace = createNamespace('app');\n\ncreateModuleAugmentation();\n\nexport const translateFunction =\n (_req: Request, res: Response, _next?: NextFunction) =>\n <T extends string>(\n content: LanguageContent<T> | string,\n locale?: Locales\n ): T => {\n const { locale: currentLocale, defaultLocale } = res.locals as {\n locale: Locales;\n defaultLocale: Locales;\n };\n\n const targetLocale = locale ?? currentLocale;\n\n if (typeof content === 'undefined') {\n return '' as unknown as T;\n }\n\n if (typeof content === 'string') {\n return content as unknown as T;\n }\n\n if (\n typeof content?.[targetLocale as unknown as keyof LanguageContent<T>] ===\n 'undefined'\n ) {\n if (\n typeof content?.[\n defaultLocale as unknown as keyof LanguageContent<T>\n ] === 'undefined'\n ) {\n return content as unknown as T;\n } else {\n return getTranslation(content, defaultLocale);\n }\n }\n\n return getTranslation(content, targetLocale);\n };\n\n/**\n * Detect locale used by the user and load it into res locale storage\n *\n * @returns\n */\nexport const intlayer = (): RequestHandler => (req, res, next) => {\n // Detect if locale is set by intlayer frontend lib in the cookies\n const localeCookie = req.cookies?.[cookieName];\n // Detect if locale is set by intlayer frontend lib in the headers\n const localeHeader = req.headers?.[headerName];\n // Interpret browser locale\n\n const negotiatorHeaders: Record<string, string> = {};\n\n // // Check if req.headers exists and is an object\n if (req && typeof req.headers === 'object') {\n // Copy all headers from the request to negotiatorHeaders\n for (const key in req.headers) {\n if (typeof req.headers[key] === 'string') {\n negotiatorHeaders[key] = req.headers[key];\n }\n }\n }\n\n const localeDetected = localeDetector(\n negotiatorHeaders,\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n res.locals.locale_header = localeHeader;\n res.locals.locale_cookie = localeCookie;\n res.locals.locale_detected = localeDetected;\n res.locals.locale = localeCookie ?? localeHeader ?? localeDetected;\n res.locals.defaultLocale = internationalization.defaultLocale;\n\n const t = translateFunction(req, res, next);\n res.locals.t = t;\n\n appNamespace.run(() => {\n appNamespace.set('t', t);\n\n next();\n });\n};\n\nexport const t = <Content = string>(\n content: LanguageContent<Content>,\n locale?: Locales\n): Content => appNamespace.get('t')(content, locale);\n\nexport { LanguageContent };\n"],"mappings":"AAAA,SAAS,gCAAgC;AACzC,SAAuB,wBAAwB;AAC/C;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,uBAAuB;AAGhC,MAAM,EAAE,YAAY,qBAAqB,IAAI,iBAAiB;AAAA,EAC5D,SAAS;AACX,CAAC;AACD,MAAM,EAAE,YAAY,WAAW,IAAI;AAEnC,MAAM,eAAe,gBAAgB,KAAK;AAE1C,yBAAyB;AAElB,MAAM,oBACX,CAAC,MAAe,KAAe,UAC/B,CACE,SACA,WACM;AACN,QAAM,EAAE,QAAQ,eAAe,cAAc,IAAI,IAAI;AAKrD,QAAM,eAAe,UAAU;AAE/B,MAAI,OAAO,YAAY,aAAa;AAClC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO;AAAA,EACT;AAEA,MACE,OAAO,UAAU,YAAmD,MACpE,aACA;AACA,QACE,OAAO,UACL,aACF,MAAM,aACN;AACA,aAAO;AAAA,IACT,OAAO;AACL,aAAO,eAAe,SAAS,aAAa;AAAA,IAC9C;AAAA,EACF;AAEA,SAAO,eAAe,SAAS,YAAY;AAC7C;AAOK,MAAM,WAAW,MAAsB,CAAC,KAAK,KAAK,SAAS;AAEhE,QAAM,eAAe,IAAI,UAAU,UAAU;AAE7C,QAAM,eAAe,IAAI,UAAU,UAAU;AAG7C,QAAM,oBAA4C,CAAC;AAGnD,MAAI,OAAO,OAAO,IAAI,YAAY,UAAU;AAE1C,eAAW,OAAO,IAAI,SAAS;AAC7B,UAAI,OAAO,IAAI,QAAQ,GAAG,MAAM,UAAU;AACxC,0BAAkB,GAAG,IAAI,IAAI,QAAQ,GAAG;AAAA,MAC1C;AAAA,IACF;AAAA,EACF;AAEA,QAAM,iBAAiB;AAAA,IACrB;AAAA,IACA,qBAAqB;AAAA,IACrB,qBAAqB;AAAA,EACvB;AAEA,MAAI,OAAO,gBAAgB;AAC3B,MAAI,OAAO,gBAAgB;AAC3B,MAAI,OAAO,kBAAkB;AAC7B,MAAI,OAAO,SAAS,gBAAgB,gBAAgB;AACpD,MAAI,OAAO,gBAAgB,qBAAqB;AAEhD,QAAMA,KAAI,kBAAkB,KAAK,KAAK,IAAI;AAC1C,MAAI,OAAO,IAAIA;AAEf,eAAa,IAAI,MAAM;AACrB,iBAAa,IAAI,KAAKA,EAAC;AAEvB,SAAK;AAAA,EACP,CAAC;AACH;AAEO,MAAM,IAAI,CACf,SACA,WACY,aAAa,IAAI,GAAG,EAAE,SAAS,MAAM;","names":["t"]}
@@ -1,14 +1,13 @@
1
1
  import { type Locales } from '@intlayer/config';
2
+ import { type LanguageContent } from '@intlayer/core';
2
3
  import type { NextFunction, RequestHandler, Request, Response } from 'express';
3
- import { type IConfigLocales } from 'intlayer';
4
- export declare const translateFunction: (_req: Request, res: Response, _next?: NextFunction) => <T extends string>(content: IConfigLocales<T> | string, locale?: Locales) => T;
4
+ export declare const translateFunction: (_req: Request, res: Response, _next?: NextFunction) => <T extends string>(content: LanguageContent<T> | string, locale?: Locales) => T;
5
5
  /**
6
6
  * Detect locale used by the user and load it into res locale storage
7
7
  *
8
8
  * @returns
9
9
  */
10
10
  export declare const intlayer: () => RequestHandler;
11
- type LanguageContent<Content = string> = IConfigLocales<Content>;
12
11
  export declare const t: <Content = string>(content: LanguageContent<Content>, locale?: Locales) => Content;
13
12
  export { LanguageContent };
14
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAoB,MAAM,kBAAkB,CAAC;AAGlE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAW/C,eAAO,MAAM,iBAAiB,SACrB,OAAO,OAAO,QAAQ,UAAU,YAAY,MAClD,CAAC,SAAS,MAAM,WACN,cAAc,CAAC,CAAC,CAAC,GAAG,MAAM,WAC1B,OAAO,KACf,CAgCF,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,QAAQ,QAAO,cAuC3B,CAAC;AAEF,KAAK,eAAe,CAAC,OAAO,GAAG,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AAEjE,eAAO,MAAM,CAAC,GAAI,OAAO,oBACd,eAAe,CAAC,OAAO,CAAC,WACxB,OAAO,KACf,OAAiD,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAoB,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAW/E,eAAO,MAAM,iBAAiB,SACrB,OAAO,OAAO,QAAQ,UAAU,YAAY,MAClD,CAAC,SAAS,MAAM,WACN,eAAe,CAAC,CAAC,CAAC,GAAG,MAAM,WAC3B,OAAO,KACf,CAgCF,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,QAAQ,QAAO,cAuC3B,CAAC;AAEF,eAAO,MAAM,CAAC,GAAI,OAAO,oBACd,eAAe,CAAC,OAAO,CAAC,WACxB,OAAO,KACf,OAAiD,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-intlayer",
3
- "version": "5.0.2",
3
+ "version": "5.0.4",
4
4
  "private": false,
5
5
  "description": "Manage internationalization i18n in a simple way for express application.",
6
6
  "keywords": [
@@ -61,10 +61,10 @@
61
61
  ],
62
62
  "dependencies": {
63
63
  "cls-hooked": "^4.2.2",
64
- "@intlayer/config": "5.0.2",
65
- "@intlayer/core": "5.0.2",
66
- "@intlayer/chokidar": "5.0.2",
67
- "intlayer": "5.0.2"
64
+ "@intlayer/chokidar": "5.0.4",
65
+ "@intlayer/config": "5.0.4",
66
+ "@intlayer/core": "5.0.4",
67
+ "intlayer": "5.0.4"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@changesets/changelog-github": "0.5.0",
@@ -81,16 +81,16 @@
81
81
  "tsc-alias": "^1.8.10",
82
82
  "tsup": "^8.3.5",
83
83
  "typescript": "^5.7.3",
84
+ "@utils/eslint-config": "1.0.4",
84
85
  "@utils/ts-config": "1.0.4",
85
86
  "@utils/ts-config-types": "1.0.4",
86
- "@utils/tsup-config": "1.0.4",
87
- "@utils/eslint-config": "1.0.4"
87
+ "@utils/tsup-config": "1.0.4"
88
88
  },
89
89
  "peerDependencies": {
90
- "@intlayer/chokidar": "5.0.2",
91
- "@intlayer/core": "5.0.2",
92
- "@intlayer/config": "5.0.2",
93
- "intlayer": "^5.0.2"
90
+ "@intlayer/chokidar": "5.0.4",
91
+ "@intlayer/config": "5.0.4",
92
+ "@intlayer/core": "5.0.4",
93
+ "intlayer": "^5.0.4"
94
94
  },
95
95
  "engines": {
96
96
  "node": ">=14.18"