adonis-intlayer 8.7.2 → 8.7.7

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,"file":"middleware.cjs","names":["getStorageLocale","translateFunction","appNamespace"],"sources":["../../src/middleware.ts"],"sourcesContent":["import type { HttpContext } from '@adonisjs/core/http';\nimport type { NextFn } from '@adonisjs/core/types/http';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {\n getDictionary as getDictionaryFunction,\n getIntlayer as getIntlayerFunction,\n} from '@intlayer/core/interpreter';\nimport { appNamespace, getStorageLocale, translateFunction } from './index';\n\nconst configuration = getConfiguration();\nconst { internationalization } = configuration;\n\n/**\n * AdonisJS middleware that detects the user's locale and populates the context with Intlayer data.\n */\nexport default class IntlayerMiddleware {\n async handle(ctx: HttpContext, next: NextFn) {\n // Detect if locale is set by intlayer frontend lib in the headers or cookies\n const localeFromStorage = getStorageLocale(ctx);\n\n const negotiatorHeaders: Record<string, string> = {};\n\n // Copy all headers from the request to negotiatorHeaders\n const headers = ctx.request.headers();\n for (const key in headers) {\n const val = headers[key];\n if (typeof val === 'string') {\n negotiatorHeaders[key] = val;\n } else if (Array.isArray(val)) {\n negotiatorHeaders[key] = val.join(',');\n }\n }\n\n const localeDetected = localeDetector(\n negotiatorHeaders,\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n const locale = localeFromStorage ?? localeDetected;\n\n // Decorate context\n (ctx as any).locale = locale;\n (ctx as any).defaultLocale = internationalization.defaultLocale;\n\n const t = translateFunction(ctx);\n\n const getIntlayer: typeof getIntlayerFunction = (\n key,\n localeArg = locale as Parameters<typeof getIntlayerFunction>[1],\n ...props\n ) => getIntlayerFunction(key, localeArg, ...props);\n\n const getDictionary: typeof getDictionaryFunction = (\n key,\n localeArg = locale as Parameters<typeof getDictionaryFunction>[1],\n ...props\n ) => getDictionaryFunction(key, localeArg, ...props);\n\n // Make functions available via CLS\n await appNamespace.runPromise(async () => {\n appNamespace.set('locale', locale);\n appNamespace.set('t', t);\n appNamespace.set('getIntlayer', getIntlayer);\n appNamespace.set('getDictionary', getDictionary);\n\n await next();\n });\n }\n}\n"],"mappings":";;;;;AAUA,MAAM,EAAE,sEADgC;;;;AAMxC,IAAqB,qBAArB,MAAwC;CACtC,MAAM,OAAO,KAAkB,MAAc;EAE3C,MAAM,oBAAoBA,+BAAiB,IAAI;EAE/C,MAAM,oBAA4C,EAAE;EAGpD,MAAM,UAAU,IAAI,QAAQ,SAAS;AACrC,OAAK,MAAM,OAAO,SAAS;GACzB,MAAM,MAAM,QAAQ;AACpB,OAAI,OAAO,QAAQ,SACjB,mBAAkB,OAAO;YAChB,MAAM,QAAQ,IAAI,CAC3B,mBAAkB,OAAO,IAAI,KAAK,IAAI;;EAI1C,MAAM,iBAAiB,eACrB,mBACA,qBAAqB,SACrB,qBAAqB,cACtB;EAED,MAAM,SAAS,qBAAqB;AAGpC,EAAC,IAAY,SAAS;AACtB,EAAC,IAAY,gBAAgB,qBAAqB;EAElD,MAAM,IAAIC,gCAAkB,IAAI;EAEhC,MAAM,eACJ,KACA,YAAY,QACZ,GAAG,sDACoB,KAAK,WAAW,GAAG,MAAM;EAElD,MAAM,iBACJ,KACA,YAAY,QACZ,GAAG,wDACsB,KAAK,WAAW,GAAG,MAAM;AAGpD,QAAMC,2BAAa,WAAW,YAAY;AACxC,8BAAa,IAAI,UAAU,OAAO;AAClC,8BAAa,IAAI,KAAK,EAAE;AACxB,8BAAa,IAAI,eAAe,YAAY;AAC5C,8BAAa,IAAI,iBAAiB,cAAc;AAEhD,SAAM,MAAM;IACZ"}
1
+ {"version":3,"file":"middleware.cjs","names":["getStorageLocale","translateFunction","appNamespace"],"sources":["../../src/middleware.ts"],"sourcesContent":["import type { HttpContext } from '@adonisjs/core/http';\nimport type { NextFn } from '@adonisjs/core/types/http';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {\n getDictionary as getDictionaryFunction,\n getIntlayer as getIntlayerFunction,\n} from '@intlayer/core/interpreter';\nimport { appNamespace, getStorageLocale, translateFunction } from './index';\n\nconst configuration = getConfiguration();\nconst { internationalization } = configuration;\n\n/**\n * AdonisJS middleware that detects the user's locale and populates the context with Intlayer data.\n */\nexport default class IntlayerMiddleware {\n async handle(ctx: HttpContext, next: NextFn) {\n // Detect if locale is set by intlayer frontend lib in the headers or cookies\n const localeFromStorage = getStorageLocale(ctx);\n\n const negotiatorHeaders: Record<string, string> = {};\n\n // Copy all headers from the request to negotiatorHeaders\n const headers = ctx.request.headers();\n for (const key in headers) {\n const val = headers[key];\n if (typeof val === 'string') {\n negotiatorHeaders[key] = val;\n } else if (Array.isArray(val)) {\n negotiatorHeaders[key] = val.join(',');\n }\n }\n\n const localeDetected = localeDetector(\n negotiatorHeaders,\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n const locale = localeFromStorage ?? localeDetected;\n\n // Decorate context\n (ctx as any).locale = locale;\n (ctx as any).defaultLocale = internationalization.defaultLocale;\n\n const t = translateFunction(ctx);\n\n const getIntlayer: typeof getIntlayerFunction = (\n key,\n localeArg = locale as Parameters<typeof getIntlayerFunction>[1],\n ...props\n ) => getIntlayerFunction(key, localeArg, ...props);\n\n const getDictionary: typeof getDictionaryFunction = (\n key,\n localeArg = locale as Parameters<typeof getDictionaryFunction>[1],\n ...props\n ) => getDictionaryFunction(key, localeArg, ...props);\n\n // Make functions available via CLS\n await appNamespace.runPromise(async () => {\n appNamespace.set('locale', locale);\n appNamespace.set('t', t);\n appNamespace.set('getIntlayer', getIntlayer);\n appNamespace.set('getDictionary', getDictionary);\n\n await next();\n });\n }\n}\n"],"mappings":";;;;;AAUA,MAAM,EAAE,sEAAsC;;;;AAK9C,IAAqB,qBAArB,MAAwC;CACtC,MAAM,OAAO,KAAkB,MAAc;EAE3C,MAAM,oBAAoBA,+BAAiB,IAAI;EAE/C,MAAM,oBAA4C,EAAE;EAGpD,MAAM,UAAU,IAAI,QAAQ,SAAS;AACrC,OAAK,MAAM,OAAO,SAAS;GACzB,MAAM,MAAM,QAAQ;AACpB,OAAI,OAAO,QAAQ,SACjB,mBAAkB,OAAO;YAChB,MAAM,QAAQ,IAAI,CAC3B,mBAAkB,OAAO,IAAI,KAAK,IAAI;;EAI1C,MAAM,iBAAiB,eACrB,mBACA,qBAAqB,SACrB,qBAAqB,cACtB;EAED,MAAM,SAAS,qBAAqB;AAGpC,EAAC,IAAY,SAAS;AACtB,EAAC,IAAY,gBAAgB,qBAAqB;EAElD,MAAM,IAAIC,gCAAkB,IAAI;EAEhC,MAAM,eACJ,KACA,YAAY,QACZ,GAAG,sDACoB,KAAK,WAAW,GAAG,MAAM;EAElD,MAAM,iBACJ,KACA,YAAY,QACZ,GAAG,wDACsB,KAAK,WAAW,GAAG,MAAM;AAGpD,QAAMC,2BAAa,WAAW,YAAY;AACxC,8BAAa,IAAI,UAAU,OAAO;AAClC,8BAAa,IAAI,KAAK,EAAE;AACxB,8BAAa,IAAI,eAAe,YAAY;AAC5C,8BAAa,IAAI,iBAAiB,cAAc;AAEhD,SAAM,MAAM;IACZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.mjs","names":["getIntlayer","getIntlayerFunction","getDictionary","getDictionaryFunction"],"sources":["../../src/middleware.ts"],"sourcesContent":["import type { HttpContext } from '@adonisjs/core/http';\nimport type { NextFn } from '@adonisjs/core/types/http';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {\n getDictionary as getDictionaryFunction,\n getIntlayer as getIntlayerFunction,\n} from '@intlayer/core/interpreter';\nimport { appNamespace, getStorageLocale, translateFunction } from './index';\n\nconst configuration = getConfiguration();\nconst { internationalization } = configuration;\n\n/**\n * AdonisJS middleware that detects the user's locale and populates the context with Intlayer data.\n */\nexport default class IntlayerMiddleware {\n async handle(ctx: HttpContext, next: NextFn) {\n // Detect if locale is set by intlayer frontend lib in the headers or cookies\n const localeFromStorage = getStorageLocale(ctx);\n\n const negotiatorHeaders: Record<string, string> = {};\n\n // Copy all headers from the request to negotiatorHeaders\n const headers = ctx.request.headers();\n for (const key in headers) {\n const val = headers[key];\n if (typeof val === 'string') {\n negotiatorHeaders[key] = val;\n } else if (Array.isArray(val)) {\n negotiatorHeaders[key] = val.join(',');\n }\n }\n\n const localeDetected = localeDetector(\n negotiatorHeaders,\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n const locale = localeFromStorage ?? localeDetected;\n\n // Decorate context\n (ctx as any).locale = locale;\n (ctx as any).defaultLocale = internationalization.defaultLocale;\n\n const t = translateFunction(ctx);\n\n const getIntlayer: typeof getIntlayerFunction = (\n key,\n localeArg = locale as Parameters<typeof getIntlayerFunction>[1],\n ...props\n ) => getIntlayerFunction(key, localeArg, ...props);\n\n const getDictionary: typeof getDictionaryFunction = (\n key,\n localeArg = locale as Parameters<typeof getDictionaryFunction>[1],\n ...props\n ) => getDictionaryFunction(key, localeArg, ...props);\n\n // Make functions available via CLS\n await appNamespace.runPromise(async () => {\n appNamespace.set('locale', locale);\n appNamespace.set('t', t);\n appNamespace.set('getIntlayer', getIntlayer);\n appNamespace.set('getDictionary', getDictionary);\n\n await next();\n });\n }\n}\n"],"mappings":";;;;;AAUA,MAAM,EAAE,yBADc,kBAAkB;;;;AAMxC,IAAqB,qBAArB,MAAwC;CACtC,MAAM,OAAO,KAAkB,MAAc;EAE3C,MAAM,oBAAoB,iBAAiB,IAAI;EAE/C,MAAM,oBAA4C,EAAE;EAGpD,MAAM,UAAU,IAAI,QAAQ,SAAS;AACrC,OAAK,MAAM,OAAO,SAAS;GACzB,MAAM,MAAM,QAAQ;AACpB,OAAI,OAAO,QAAQ,SACjB,mBAAkB,OAAO;YAChB,MAAM,QAAQ,IAAI,CAC3B,mBAAkB,OAAO,IAAI,KAAK,IAAI;;EAI1C,MAAM,iBAAiB,eACrB,mBACA,qBAAqB,SACrB,qBAAqB,cACtB;EAED,MAAM,SAAS,qBAAqB;AAGpC,EAAC,IAAY,SAAS;AACtB,EAAC,IAAY,gBAAgB,qBAAqB;EAElD,MAAM,IAAI,kBAAkB,IAAI;EAEhC,MAAMA,iBACJ,KACA,YAAY,QACZ,GAAG,UACAC,YAAoB,KAAK,WAAW,GAAG,MAAM;EAElD,MAAMC,mBACJ,KACA,YAAY,QACZ,GAAG,UACAC,cAAsB,KAAK,WAAW,GAAG,MAAM;AAGpD,QAAM,aAAa,WAAW,YAAY;AACxC,gBAAa,IAAI,UAAU,OAAO;AAClC,gBAAa,IAAI,KAAK,EAAE;AACxB,gBAAa,IAAI,eAAeH,cAAY;AAC5C,gBAAa,IAAI,iBAAiBE,gBAAc;AAEhD,SAAM,MAAM;IACZ"}
1
+ {"version":3,"file":"middleware.mjs","names":["getIntlayer","getIntlayerFunction","getDictionary","getDictionaryFunction"],"sources":["../../src/middleware.ts"],"sourcesContent":["import type { HttpContext } from '@adonisjs/core/http';\nimport type { NextFn } from '@adonisjs/core/types/http';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {\n getDictionary as getDictionaryFunction,\n getIntlayer as getIntlayerFunction,\n} from '@intlayer/core/interpreter';\nimport { appNamespace, getStorageLocale, translateFunction } from './index';\n\nconst configuration = getConfiguration();\nconst { internationalization } = configuration;\n\n/**\n * AdonisJS middleware that detects the user's locale and populates the context with Intlayer data.\n */\nexport default class IntlayerMiddleware {\n async handle(ctx: HttpContext, next: NextFn) {\n // Detect if locale is set by intlayer frontend lib in the headers or cookies\n const localeFromStorage = getStorageLocale(ctx);\n\n const negotiatorHeaders: Record<string, string> = {};\n\n // Copy all headers from the request to negotiatorHeaders\n const headers = ctx.request.headers();\n for (const key in headers) {\n const val = headers[key];\n if (typeof val === 'string') {\n negotiatorHeaders[key] = val;\n } else if (Array.isArray(val)) {\n negotiatorHeaders[key] = val.join(',');\n }\n }\n\n const localeDetected = localeDetector(\n negotiatorHeaders,\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n const locale = localeFromStorage ?? localeDetected;\n\n // Decorate context\n (ctx as any).locale = locale;\n (ctx as any).defaultLocale = internationalization.defaultLocale;\n\n const t = translateFunction(ctx);\n\n const getIntlayer: typeof getIntlayerFunction = (\n key,\n localeArg = locale as Parameters<typeof getIntlayerFunction>[1],\n ...props\n ) => getIntlayerFunction(key, localeArg, ...props);\n\n const getDictionary: typeof getDictionaryFunction = (\n key,\n localeArg = locale as Parameters<typeof getDictionaryFunction>[1],\n ...props\n ) => getDictionaryFunction(key, localeArg, ...props);\n\n // Make functions available via CLS\n await appNamespace.runPromise(async () => {\n appNamespace.set('locale', locale);\n appNamespace.set('t', t);\n appNamespace.set('getIntlayer', getIntlayer);\n appNamespace.set('getDictionary', getDictionary);\n\n await next();\n });\n }\n}\n"],"mappings":";;;;;AAUA,MAAM,EAAE,yBADc,kBACwB;;;;AAK9C,IAAqB,qBAArB,MAAwC;CACtC,MAAM,OAAO,KAAkB,MAAc;EAE3C,MAAM,oBAAoB,iBAAiB,IAAI;EAE/C,MAAM,oBAA4C,EAAE;EAGpD,MAAM,UAAU,IAAI,QAAQ,SAAS;AACrC,OAAK,MAAM,OAAO,SAAS;GACzB,MAAM,MAAM,QAAQ;AACpB,OAAI,OAAO,QAAQ,SACjB,mBAAkB,OAAO;YAChB,MAAM,QAAQ,IAAI,CAC3B,mBAAkB,OAAO,IAAI,KAAK,IAAI;;EAI1C,MAAM,iBAAiB,eACrB,mBACA,qBAAqB,SACrB,qBAAqB,cACtB;EAED,MAAM,SAAS,qBAAqB;AAGpC,EAAC,IAAY,SAAS;AACtB,EAAC,IAAY,gBAAgB,qBAAqB;EAElD,MAAM,IAAI,kBAAkB,IAAI;EAEhC,MAAMA,iBACJ,KACA,YAAY,QACZ,GAAG,UACAC,YAAoB,KAAK,WAAW,GAAG,MAAM;EAElD,MAAMC,mBACJ,KACA,YAAY,QACZ,GAAG,UACAC,cAAsB,KAAK,WAAW,GAAG,MAAM;AAGpD,QAAM,aAAa,WAAW,YAAY;AACxC,gBAAa,IAAI,UAAU,OAAO;AAClC,gBAAa,IAAI,KAAK,EAAE;AACxB,gBAAa,IAAI,eAAeH,cAAY;AAC5C,gBAAa,IAAI,iBAAiBE,gBAAc;AAEhD,SAAM,MAAM;IACZ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adonis-intlayer",
3
- "version": "8.7.2",
3
+ "version": "8.7.7",
4
4
  "private": false,
5
5
  "description": "Manage internationalization i18n in a simple way for AdonisJS application.",
6
6
  "keywords": [
@@ -80,22 +80,22 @@
80
80
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
81
81
  },
82
82
  "dependencies": {
83
- "@intlayer/chokidar": "8.7.2",
84
- "@intlayer/config": "8.7.2",
85
- "@intlayer/core": "8.7.2",
86
- "@intlayer/types": "8.7.2",
83
+ "@intlayer/chokidar": "8.7.7",
84
+ "@intlayer/config": "8.7.7",
85
+ "@intlayer/core": "8.7.7",
86
+ "@intlayer/types": "8.7.7",
87
87
  "cls-hooked": "4.2.2"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@types/cls-hooked": "4.3.9",
91
- "@types/node": "25.5.2",
91
+ "@types/node": "25.6.0",
92
92
  "@utils/ts-config": "1.0.4",
93
93
  "@utils/ts-config-types": "1.0.4",
94
94
  "@utils/tsdown-config": "1.0.4",
95
95
  "rimraf": "6.1.3",
96
- "tsdown": "0.21.8",
97
- "typescript": "6.0.2",
98
- "vitest": "4.1.4"
96
+ "tsdown": "0.21.10",
97
+ "typescript": "6.0.3",
98
+ "vitest": "4.1.5"
99
99
  },
100
100
  "peerDependencies": {
101
101
  "@adonisjs/core": ">=6.0.0"