@intlayer/lingui 9.0.0-canary.1 → 9.0.0-canary.2

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.
@@ -12,15 +12,41 @@ let vite_intlayer = require("vite-intlayer");
12
12
  /**
13
13
  * Caller configurations for lingui.
14
14
  *
15
- * Lingui's `i18n._(id)` / `i18n.t` and `useLingui()`'s `_()` all resolve
16
- * translations at runtime through the intlayer `messages` dictionary. Since the
17
- * mapping is 1:1 (one catalog one `messages` dict) there is no namespace
18
- * splitting needed at the analyser level, so the caller list is empty for now.
15
+ * After `@lingui/babel-plugin-lingui-macro` / `@lingui/swc-plugin` compiles
16
+ * macros (`` t`Hello ${name}` `` `i18n._(id, values)`) the intlayer field
17
+ * usage analyser sees these method calls and records which top-level fields of
18
+ * the `messages` dictionary are consumed, enabling accurate pruning.
19
19
  *
20
- * Future: once `namespace: { from: 'self' }` is supported in the babel/swc
21
- * analyser, we can add callers for `useLingui()._(id)`.
20
+ * Two call forms are tracked:
21
+ * - `i18n._('home.title', values)` string id
22
+ * - `i18n._({ id: 'home.title', message: '...' }, values)` — descriptor
23
+ * - `i18n.t('home.title', values)` — alias for `_`
24
+ *
25
+ * Because lingui projects may also use hashed IDs (generated from the default
26
+ * message string) that cannot be statically mapped to dictionary keys, a
27
+ * separate `'all'`-mode caller is not needed here: when the first argument is
28
+ * not a static string or descriptor, the `'self'` handler falls back to `'all'`
29
+ * automatically.
22
30
  */
23
- const LINGUI_COMPAT_CALLERS = [];
31
+ const LINGUI_COMPAT_CALLERS = [{
32
+ callerName: "_",
33
+ importSources: ["@lingui/core", "@intlayer/lingui"],
34
+ matchAsMethod: true,
35
+ namespace: {
36
+ from: "fixed",
37
+ value: "messages"
38
+ },
39
+ translationFunction: "self"
40
+ }, {
41
+ callerName: "t",
42
+ importSources: ["@lingui/core", "@intlayer/lingui"],
43
+ matchAsMethod: true,
44
+ namespace: {
45
+ from: "fixed",
46
+ value: "messages"
47
+ },
48
+ translationFunction: "self"
49
+ }];
24
50
  /**
25
51
  * A Vite plugin for the lingui compat adapter.
26
52
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["ANSIColors"],"sources":["../../../src/plugin/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { runOnce } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { PluginOption } from 'vite';\nimport { type CompatCallerConfig, intlayer } from 'vite-intlayer';\n\n/**\n * Caller configurations for lingui.\n *\n * Lingui's `i18n._(id)` / `i18n.t` and `useLingui()`'s `_()` all resolve\n * translations at runtime through the intlayer `messages` dictionary. Since the\n * mapping is 1:1 (one catalog one `messages` dict) there is no namespace\n * splitting needed at the analyser level, so the caller list is empty for now.\n *\n * Future: once `namespace: { from: 'self' }` is supported in the babel/swc\n * analyser, we can add callers for `useLingui()._(id)`.\n */\nconst LINGUI_COMPAT_CALLERS: CompatCallerConfig[] = [];\n\n/**\n * A Vite plugin for the lingui compat adapter.\n *\n * Wraps `vite-intlayer` and adds resolve aliases so that both\n * `@lingui/core` **and** `@lingui/react` are redirected to\n * `@intlayer/lingui` at bundle time.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { linguiVitePlugin } from '@intlayer/lingui/plugin';\n *\n * export default defineConfig({\n * plugins: [linguiVitePlugin()],\n * });\n * ```\n */\nexport const linguiVitePlugin = (\n options?: Parameters<typeof intlayer>[0]\n): PluginOption[] => {\n const intlayerConfig = getConfiguration();\n const appLogger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(\n intlayerConfig.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-issues-invitation.lock'\n ),\n () => {\n appLogger([\n colorize(\n 'Please report any issues you met on GitHub:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://github.com/aymericzip/intlayer/issues',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n },\n {\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n }\n );\n\n const basePlugins = intlayer({\n ...options,\n compatCallers: [\n ...(options?.compatCallers ?? []),\n ...LINGUI_COMPAT_CALLERS,\n ],\n });\n\n const compatPlugin: PluginOption = {\n name: 'vite-lingui-compat-plugin',\n config: () => ({\n resolve: {\n alias: {\n '@lingui/core': '@intlayer/lingui',\n '@lingui/react': '@intlayer/lingui',\n },\n },\n }),\n };\n\n return [\n ...(Array.isArray(basePlugins) ? basePlugins : [basePlugins]),\n compatPlugin,\n ];\n};\n\nexport default linguiVitePlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,wBAA8C,CAAC;;;;;;;;;;;;;;;;;;AAmBrD,MAAa,oBACX,YACmB;CACnB,MAAM,6DAAkC;CACxC,MAAM,sDAAyB,cAAc;CAE7C,0DAEI,eAAe,OAAO,SACtB,aACA,SACA,iCACF,SACM;EACJ,UAAU,uCAEN,+CACAA,wBAAW,IACb,yCAEE,iDACAA,wBAAW,UACb,CACF,CAAC;CACH,GACA,EACE,gBAAgB,MAAO,KAAK,GAC9B,CACF;CAEA,MAAM,0CAAuB;EAC3B,GAAG;EACH,eAAe,CACb,GAAI,SAAS,iBAAiB,CAAC,GAC/B,GAAG,qBACL;CACF,CAAC;CAED,MAAM,eAA6B;EACjC,MAAM;EACN,eAAe,EACb,SAAS,EACP,OAAO;GACL,gBAAgB;GAChB,iBAAiB;EACnB,EACF,EACF;CACF;CAEA,OAAO,CACL,GAAI,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW,GAC3D,YACF;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["ANSIColors"],"sources":["../../../src/plugin/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { runOnce } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { PluginOption } from 'vite';\nimport { type CompatCallerConfig, intlayer } from 'vite-intlayer';\n\n/**\n * Caller configurations for lingui.\n *\n * After `@lingui/babel-plugin-lingui-macro` / `@lingui/swc-plugin` compiles\n * macros (`` t`Hello ${name}` `` → `i18n._(id, values)`) the intlayer field\n * usage analyser sees these method calls and records which top-level fields of\n * the `messages` dictionary are consumed, enabling accurate pruning.\n *\n * Two call forms are tracked:\n * - `i18n._('home.title', values)` string id\n * - `i18n._({ id: 'home.title', message: '...' }, values)` descriptor\n * - `i18n.t('home.title', values)` — alias for `_`\n *\n * Because lingui projects may also use hashed IDs (generated from the default\n * message string) that cannot be statically mapped to dictionary keys, a\n * separate `'all'`-mode caller is not needed here: when the first argument is\n * not a static string or descriptor, the `'self'` handler falls back to `'all'`\n * automatically.\n */\nconst LINGUI_COMPAT_CALLERS: CompatCallerConfig[] = [\n {\n callerName: '_',\n importSources: ['@lingui/core', '@intlayer/lingui'],\n matchAsMethod: true,\n namespace: { from: 'fixed', value: 'messages' },\n translationFunction: 'self',\n },\n {\n callerName: 't',\n importSources: ['@lingui/core', '@intlayer/lingui'],\n matchAsMethod: true,\n namespace: { from: 'fixed', value: 'messages' },\n translationFunction: 'self',\n },\n];\n\n/**\n * A Vite plugin for the lingui compat adapter.\n *\n * Wraps `vite-intlayer` and adds resolve aliases so that both\n * `@lingui/core` **and** `@lingui/react` are redirected to\n * `@intlayer/lingui` at bundle time.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { linguiVitePlugin } from '@intlayer/lingui/plugin';\n *\n * export default defineConfig({\n * plugins: [linguiVitePlugin()],\n * });\n * ```\n */\nexport const linguiVitePlugin = (\n options?: Parameters<typeof intlayer>[0]\n): PluginOption[] => {\n const intlayerConfig = getConfiguration();\n const appLogger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(\n intlayerConfig.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-issues-invitation.lock'\n ),\n () => {\n appLogger([\n colorize(\n 'Please report any issues you met on GitHub:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://github.com/aymericzip/intlayer/issues',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n },\n {\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n }\n );\n\n const basePlugins = intlayer({\n ...options,\n compatCallers: [\n ...(options?.compatCallers ?? []),\n ...LINGUI_COMPAT_CALLERS,\n ],\n });\n\n const compatPlugin: PluginOption = {\n name: 'vite-lingui-compat-plugin',\n config: () => ({\n resolve: {\n alias: {\n '@lingui/core': '@intlayer/lingui',\n '@lingui/react': '@intlayer/lingui',\n },\n },\n }),\n };\n\n return [\n ...(Array.isArray(basePlugins) ? basePlugins : [basePlugins]),\n compatPlugin,\n ];\n};\n\nexport default linguiVitePlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,wBAA8C,CAClD;CACE,YAAY;CACZ,eAAe,CAAC,gBAAgB,kBAAkB;CAClD,eAAe;CACf,WAAW;EAAE,MAAM;EAAS,OAAO;CAAW;CAC9C,qBAAqB;AACvB,GACA;CACE,YAAY;CACZ,eAAe,CAAC,gBAAgB,kBAAkB;CAClD,eAAe;CACf,WAAW;EAAE,MAAM;EAAS,OAAO;CAAW;CAC9C,qBAAqB;AACvB,CACF;;;;;;;;;;;;;;;;;;AAmBA,MAAa,oBACX,YACmB;CACnB,MAAM,6DAAkC;CACxC,MAAM,sDAAyB,cAAc;CAE7C,0DAEI,eAAe,OAAO,SACtB,aACA,SACA,iCACF,SACM;EACJ,UAAU,uCAEN,+CACAA,wBAAW,IACb,yCAEE,iDACAA,wBAAW,UACb,CACF,CAAC;CACH,GACA,EACE,gBAAgB,MAAO,KAAK,GAC9B,CACF;CAEA,MAAM,0CAAuB;EAC3B,GAAG;EACH,eAAe,CACb,GAAI,SAAS,iBAAiB,CAAC,GAC/B,GAAG,qBACL;CACF,CAAC;CAED,MAAM,eAA6B;EACjC,MAAM;EACN,eAAe,EACb,SAAS,EACP,OAAO;GACL,gBAAgB;GAChB,iBAAiB;EACnB,EACF,EACF;CACF;CAEA,OAAO,CACL,GAAI,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW,GAC3D,YACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLingui.cjs","names":["LinguiContext","I18nClass"],"sources":["../../src/useLingui.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { I18nContext } from '@lingui/react';\nimport { useContext, useMemo } from 'react';\nimport { useLocale } from 'react-intlayer';\nimport { I18nClass } from './I18nClass';\nimport { LinguiContext } from './LinguiContext';\n\n/**\n * Drop-in for `@lingui/react`'s `useLingui`.\n *\n * Returns `{ i18n, _, defaultComponent }` from the nearest `I18nProvider`.\n * When used outside a provider, derives a locale-aware `i18n` instance from\n * `react-intlayer`'s `useLocale()` so that Server Components and test contexts\n * work without an explicit provider.\n *\n * @example\n * ```tsx\n * const { _ } = useLingui();\n * return <h1>{_({ id: 'home.title', message: 'Welcome' })}</h1>;\n * ```\n */\nexport const useLingui = (): I18nContext => {\n const context = useContext(LinguiContext);\n const { locale } = useLocale();\n\n const derivedI18n = useMemo(() => {\n const instance = new I18nClass({ locale: locale as string });\n return {\n i18n: instance as unknown as I18nContext['i18n'],\n _: instance._.bind(instance) as I18nContext['_'],\n };\n }, [locale]);\n\n if (context) {\n return context;\n }\n\n return derivedI18n as I18nContext;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,kBAA+B;CAC1C,MAAM,gCAAqBA,mCAAa;CACxC,MAAM,EAAE,yCAAqB;CAE7B,MAAM,uCAA4B;EAChC,MAAM,WAAW,IAAIC,4BAAU,EAAU,OAAiB,CAAC;EAC3D,OAAO;GACL,MAAM;GACN,GAAG,SAAS,EAAE,KAAK,QAAQ;EAC7B;CACF,GAAG,CAAC,MAAM,CAAC;CAEX,IAAI,SACF,OAAO;CAGT,OAAO;AACT"}
1
+ {"version":3,"file":"useLingui.cjs","names":["LinguiContext","I18nClass"],"sources":["../../src/useLingui.ts"],"sourcesContent":["'use client';\n\nimport type { I18nContext } from '@lingui/react';\nimport { useContext, useMemo } from 'react';\nimport { useLocale } from 'react-intlayer';\nimport { I18nClass } from './I18nClass';\nimport { LinguiContext } from './LinguiContext';\n\n/**\n * Drop-in for `@lingui/react`'s `useLingui`.\n *\n * Returns `{ i18n, _, defaultComponent }` from the nearest `I18nProvider`.\n * When used outside a provider, derives a locale-aware `i18n` instance from\n * `react-intlayer`'s `useLocale()` so that Server Components and test contexts\n * work without an explicit provider.\n *\n * @example\n * ```tsx\n * const { _ } = useLingui();\n * return <h1>{_({ id: 'home.title', message: 'Welcome' })}</h1>;\n * ```\n */\nexport const useLingui = (): I18nContext => {\n const context = useContext(LinguiContext);\n const { locale } = useLocale();\n\n const derivedI18n = useMemo(() => {\n const instance = new I18nClass({ locale: locale as string });\n return {\n i18n: instance as unknown as I18nContext['i18n'],\n _: instance._.bind(instance) as I18nContext['_'],\n };\n }, [locale]);\n\n if (context) {\n return context;\n }\n\n return derivedI18n as I18nContext;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,kBAA+B;CAC1C,MAAM,gCAAqBA,mCAAa;CACxC,MAAM,EAAE,yCAAqB;CAE7B,MAAM,uCAA4B;EAChC,MAAM,WAAW,IAAIC,4BAAU,EAAU,OAAiB,CAAC;EAC3D,OAAO;GACL,MAAM;GACN,GAAG,SAAS,EAAE,KAAK,QAAQ;EAC7B;CACF,GAAG,CAAC,MAAM,CAAC;CAEX,IAAI,SACF,OAAO;CAGT,OAAO;AACT"}
@@ -9,15 +9,41 @@ import { intlayer } from "vite-intlayer";
9
9
  /**
10
10
  * Caller configurations for lingui.
11
11
  *
12
- * Lingui's `i18n._(id)` / `i18n.t` and `useLingui()`'s `_()` all resolve
13
- * translations at runtime through the intlayer `messages` dictionary. Since the
14
- * mapping is 1:1 (one catalog one `messages` dict) there is no namespace
15
- * splitting needed at the analyser level, so the caller list is empty for now.
12
+ * After `@lingui/babel-plugin-lingui-macro` / `@lingui/swc-plugin` compiles
13
+ * macros (`` t`Hello ${name}` `` `i18n._(id, values)`) the intlayer field
14
+ * usage analyser sees these method calls and records which top-level fields of
15
+ * the `messages` dictionary are consumed, enabling accurate pruning.
16
16
  *
17
- * Future: once `namespace: { from: 'self' }` is supported in the babel/swc
18
- * analyser, we can add callers for `useLingui()._(id)`.
17
+ * Two call forms are tracked:
18
+ * - `i18n._('home.title', values)` string id
19
+ * - `i18n._({ id: 'home.title', message: '...' }, values)` — descriptor
20
+ * - `i18n.t('home.title', values)` — alias for `_`
21
+ *
22
+ * Because lingui projects may also use hashed IDs (generated from the default
23
+ * message string) that cannot be statically mapped to dictionary keys, a
24
+ * separate `'all'`-mode caller is not needed here: when the first argument is
25
+ * not a static string or descriptor, the `'self'` handler falls back to `'all'`
26
+ * automatically.
19
27
  */
20
- const LINGUI_COMPAT_CALLERS = [];
28
+ const LINGUI_COMPAT_CALLERS = [{
29
+ callerName: "_",
30
+ importSources: ["@lingui/core", "@intlayer/lingui"],
31
+ matchAsMethod: true,
32
+ namespace: {
33
+ from: "fixed",
34
+ value: "messages"
35
+ },
36
+ translationFunction: "self"
37
+ }, {
38
+ callerName: "t",
39
+ importSources: ["@lingui/core", "@intlayer/lingui"],
40
+ matchAsMethod: true,
41
+ namespace: {
42
+ from: "fixed",
43
+ value: "messages"
44
+ },
45
+ translationFunction: "self"
46
+ }];
21
47
  /**
22
48
  * A Vite plugin for the lingui compat adapter.
23
49
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugin/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { runOnce } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { PluginOption } from 'vite';\nimport { type CompatCallerConfig, intlayer } from 'vite-intlayer';\n\n/**\n * Caller configurations for lingui.\n *\n * Lingui's `i18n._(id)` / `i18n.t` and `useLingui()`'s `_()` all resolve\n * translations at runtime through the intlayer `messages` dictionary. Since the\n * mapping is 1:1 (one catalog one `messages` dict) there is no namespace\n * splitting needed at the analyser level, so the caller list is empty for now.\n *\n * Future: once `namespace: { from: 'self' }` is supported in the babel/swc\n * analyser, we can add callers for `useLingui()._(id)`.\n */\nconst LINGUI_COMPAT_CALLERS: CompatCallerConfig[] = [];\n\n/**\n * A Vite plugin for the lingui compat adapter.\n *\n * Wraps `vite-intlayer` and adds resolve aliases so that both\n * `@lingui/core` **and** `@lingui/react` are redirected to\n * `@intlayer/lingui` at bundle time.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { linguiVitePlugin } from '@intlayer/lingui/plugin';\n *\n * export default defineConfig({\n * plugins: [linguiVitePlugin()],\n * });\n * ```\n */\nexport const linguiVitePlugin = (\n options?: Parameters<typeof intlayer>[0]\n): PluginOption[] => {\n const intlayerConfig = getConfiguration();\n const appLogger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(\n intlayerConfig.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-issues-invitation.lock'\n ),\n () => {\n appLogger([\n colorize(\n 'Please report any issues you met on GitHub:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://github.com/aymericzip/intlayer/issues',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n },\n {\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n }\n );\n\n const basePlugins = intlayer({\n ...options,\n compatCallers: [\n ...(options?.compatCallers ?? []),\n ...LINGUI_COMPAT_CALLERS,\n ],\n });\n\n const compatPlugin: PluginOption = {\n name: 'vite-lingui-compat-plugin',\n config: () => ({\n resolve: {\n alias: {\n '@lingui/core': '@intlayer/lingui',\n '@lingui/react': '@intlayer/lingui',\n },\n },\n }),\n };\n\n return [\n ...(Array.isArray(basePlugins) ? basePlugins : [basePlugins]),\n compatPlugin,\n ];\n};\n\nexport default linguiVitePlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAM,wBAA8C,CAAC;;;;;;;;;;;;;;;;;;AAmBrD,MAAa,oBACX,YACmB;CACnB,MAAM,iBAAiB,iBAAiB;CACxC,MAAM,YAAY,aAAa,cAAc;CAE7C,QACE,KACE,eAAe,OAAO,SACtB,aACA,SACA,iCACF,SACM;EACJ,UAAU,CACR,SACE,+CACA,WAAW,IACb,GACA,SACE,iDACA,WAAW,UACb,CACF,CAAC;CACH,GACA,EACE,gBAAgB,MAAO,KAAK,GAC9B,CACF;CAEA,MAAM,cAAc,SAAS;EAC3B,GAAG;EACH,eAAe,CACb,GAAI,SAAS,iBAAiB,CAAC,GAC/B,GAAG,qBACL;CACF,CAAC;CAED,MAAM,eAA6B;EACjC,MAAM;EACN,eAAe,EACb,SAAS,EACP,OAAO;GACL,gBAAgB;GAChB,iBAAiB;EACnB,EACF,EACF;CACF;CAEA,OAAO,CACL,GAAI,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW,GAC3D,YACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugin/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { runOnce } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { PluginOption } from 'vite';\nimport { type CompatCallerConfig, intlayer } from 'vite-intlayer';\n\n/**\n * Caller configurations for lingui.\n *\n * After `@lingui/babel-plugin-lingui-macro` / `@lingui/swc-plugin` compiles\n * macros (`` t`Hello ${name}` `` → `i18n._(id, values)`) the intlayer field\n * usage analyser sees these method calls and records which top-level fields of\n * the `messages` dictionary are consumed, enabling accurate pruning.\n *\n * Two call forms are tracked:\n * - `i18n._('home.title', values)` string id\n * - `i18n._({ id: 'home.title', message: '...' }, values)` descriptor\n * - `i18n.t('home.title', values)` — alias for `_`\n *\n * Because lingui projects may also use hashed IDs (generated from the default\n * message string) that cannot be statically mapped to dictionary keys, a\n * separate `'all'`-mode caller is not needed here: when the first argument is\n * not a static string or descriptor, the `'self'` handler falls back to `'all'`\n * automatically.\n */\nconst LINGUI_COMPAT_CALLERS: CompatCallerConfig[] = [\n {\n callerName: '_',\n importSources: ['@lingui/core', '@intlayer/lingui'],\n matchAsMethod: true,\n namespace: { from: 'fixed', value: 'messages' },\n translationFunction: 'self',\n },\n {\n callerName: 't',\n importSources: ['@lingui/core', '@intlayer/lingui'],\n matchAsMethod: true,\n namespace: { from: 'fixed', value: 'messages' },\n translationFunction: 'self',\n },\n];\n\n/**\n * A Vite plugin for the lingui compat adapter.\n *\n * Wraps `vite-intlayer` and adds resolve aliases so that both\n * `@lingui/core` **and** `@lingui/react` are redirected to\n * `@intlayer/lingui` at bundle time.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { linguiVitePlugin } from '@intlayer/lingui/plugin';\n *\n * export default defineConfig({\n * plugins: [linguiVitePlugin()],\n * });\n * ```\n */\nexport const linguiVitePlugin = (\n options?: Parameters<typeof intlayer>[0]\n): PluginOption[] => {\n const intlayerConfig = getConfiguration();\n const appLogger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(\n intlayerConfig.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-issues-invitation.lock'\n ),\n () => {\n appLogger([\n colorize(\n 'Please report any issues you met on GitHub:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://github.com/aymericzip/intlayer/issues',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n },\n {\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n }\n );\n\n const basePlugins = intlayer({\n ...options,\n compatCallers: [\n ...(options?.compatCallers ?? []),\n ...LINGUI_COMPAT_CALLERS,\n ],\n });\n\n const compatPlugin: PluginOption = {\n name: 'vite-lingui-compat-plugin',\n config: () => ({\n resolve: {\n alias: {\n '@lingui/core': '@intlayer/lingui',\n '@lingui/react': '@intlayer/lingui',\n },\n },\n }),\n };\n\n return [\n ...(Array.isArray(basePlugins) ? basePlugins : [basePlugins]),\n compatPlugin,\n ];\n};\n\nexport default linguiVitePlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,wBAA8C,CAClD;CACE,YAAY;CACZ,eAAe,CAAC,gBAAgB,kBAAkB;CAClD,eAAe;CACf,WAAW;EAAE,MAAM;EAAS,OAAO;CAAW;CAC9C,qBAAqB;AACvB,GACA;CACE,YAAY;CACZ,eAAe,CAAC,gBAAgB,kBAAkB;CAClD,eAAe;CACf,WAAW;EAAE,MAAM;EAAS,OAAO;CAAW;CAC9C,qBAAqB;AACvB,CACF;;;;;;;;;;;;;;;;;;AAmBA,MAAa,oBACX,YACmB;CACnB,MAAM,iBAAiB,iBAAiB;CACxC,MAAM,YAAY,aAAa,cAAc;CAE7C,QACE,KACE,eAAe,OAAO,SACtB,aACA,SACA,iCACF,SACM;EACJ,UAAU,CACR,SACE,+CACA,WAAW,IACb,GACA,SACE,iDACA,WAAW,UACb,CACF,CAAC;CACH,GACA,EACE,gBAAgB,MAAO,KAAK,GAC9B,CACF;CAEA,MAAM,cAAc,SAAS;EAC3B,GAAG;EACH,eAAe,CACb,GAAI,SAAS,iBAAiB,CAAC,GAC/B,GAAG,qBACL;CACF,CAAC;CAED,MAAM,eAA6B;EACjC,MAAM;EACN,eAAe,EACb,SAAS,EACP,OAAO;GACL,gBAAgB;GAChB,iBAAiB;EACnB,EACF,EACF;CACF;CAEA,OAAO,CACL,GAAI,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW,GAC3D,YACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLingui.mjs","names":[],"sources":["../../src/useLingui.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { I18nContext } from '@lingui/react';\nimport { useContext, useMemo } from 'react';\nimport { useLocale } from 'react-intlayer';\nimport { I18nClass } from './I18nClass';\nimport { LinguiContext } from './LinguiContext';\n\n/**\n * Drop-in for `@lingui/react`'s `useLingui`.\n *\n * Returns `{ i18n, _, defaultComponent }` from the nearest `I18nProvider`.\n * When used outside a provider, derives a locale-aware `i18n` instance from\n * `react-intlayer`'s `useLocale()` so that Server Components and test contexts\n * work without an explicit provider.\n *\n * @example\n * ```tsx\n * const { _ } = useLingui();\n * return <h1>{_({ id: 'home.title', message: 'Welcome' })}</h1>;\n * ```\n */\nexport const useLingui = (): I18nContext => {\n const context = useContext(LinguiContext);\n const { locale } = useLocale();\n\n const derivedI18n = useMemo(() => {\n const instance = new I18nClass({ locale: locale as string });\n return {\n i18n: instance as unknown as I18nContext['i18n'],\n _: instance._.bind(instance) as I18nContext['_'],\n };\n }, [locale]);\n\n if (context) {\n return context;\n }\n\n return derivedI18n as I18nContext;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,kBAA+B;CAC1C,MAAM,UAAU,WAAW,aAAa;CACxC,MAAM,EAAE,WAAW,UAAU;CAE7B,MAAM,cAAc,cAAc;EAChC,MAAM,WAAW,IAAI,UAAU,EAAU,OAAiB,CAAC;EAC3D,OAAO;GACL,MAAM;GACN,GAAG,SAAS,EAAE,KAAK,QAAQ;EAC7B;CACF,GAAG,CAAC,MAAM,CAAC;CAEX,IAAI,SACF,OAAO;CAGT,OAAO;AACT"}
1
+ {"version":3,"file":"useLingui.mjs","names":[],"sources":["../../src/useLingui.ts"],"sourcesContent":["'use client';\n\nimport type { I18nContext } from '@lingui/react';\nimport { useContext, useMemo } from 'react';\nimport { useLocale } from 'react-intlayer';\nimport { I18nClass } from './I18nClass';\nimport { LinguiContext } from './LinguiContext';\n\n/**\n * Drop-in for `@lingui/react`'s `useLingui`.\n *\n * Returns `{ i18n, _, defaultComponent }` from the nearest `I18nProvider`.\n * When used outside a provider, derives a locale-aware `i18n` instance from\n * `react-intlayer`'s `useLocale()` so that Server Components and test contexts\n * work without an explicit provider.\n *\n * @example\n * ```tsx\n * const { _ } = useLingui();\n * return <h1>{_({ id: 'home.title', message: 'Welcome' })}</h1>;\n * ```\n */\nexport const useLingui = (): I18nContext => {\n const context = useContext(LinguiContext);\n const { locale } = useLocale();\n\n const derivedI18n = useMemo(() => {\n const instance = new I18nClass({ locale: locale as string });\n return {\n i18n: instance as unknown as I18nContext['i18n'],\n _: instance._.bind(instance) as I18nContext['_'],\n };\n }, [locale]);\n\n if (context) {\n return context;\n }\n\n return derivedI18n as I18nContext;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,kBAA+B;CAC1C,MAAM,UAAU,WAAW,aAAa;CACxC,MAAM,EAAE,WAAW,UAAU;CAE7B,MAAM,cAAc,cAAc;EAChC,MAAM,WAAW,IAAI,UAAU,EAAU,OAAiB,CAAC;EAC3D,OAAO;GACL,MAAM;GACN,GAAG,SAAS,EAAE,KAAK,QAAQ;EAC7B;CACF,GAAG,CAAC,MAAM,CAAC;CAEX,IAAI,SACF,OAAO;CAGT,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/plugin/index.ts"],"mappings":";;;;;;AAsCA;;;;;;;;;;;;;AAEe;;cAFF,gBAAA,GACX,OAAA,GAAU,UAAA,QAAkB,QAAA,SAC3B,YAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/plugin/index.ts"],"mappings":";;;;;;AA6DA;;;;;;;;;;;;;AAEe;;cAFF,gBAAA,GACX,OAAA,GAAU,UAAA,QAAkB,QAAA,SAC3B,YAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLingui.d.ts","names":[],"sources":["../../src/useLingui.ts"],"mappings":";;;;;AAuBA;;;;AAiBC;;;;;;;;cAjBY,SAAA,QAAgB,WAiB5B"}
1
+ {"version":3,"file":"useLingui.d.ts","names":[],"sources":["../../src/useLingui.ts"],"mappings":";;;;;AAsBA;;;;AAiBC;;;;;;;;cAjBY,SAAA,QAAgB,WAiB5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/lingui",
3
- "version": "9.0.0-canary.1",
3
+ "version": "9.0.0-canary.2",
4
4
  "private": false,
5
5
  "description": "lingui API adapter for intlayer — drop-in compatibility layer",
6
6
  "keywords": [
@@ -76,13 +76,13 @@
76
76
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
77
77
  },
78
78
  "dependencies": {
79
- "@intlayer/chokidar": "9.0.0-canary.1",
80
- "@intlayer/config": "9.0.0-canary.1",
81
- "@intlayer/core": "9.0.0-canary.1",
82
- "@intlayer/dictionaries-entry": "9.0.0-canary.1",
83
- "@intlayer/types": "9.0.0-canary.1",
84
- "react-intlayer": "9.0.0-canary.1",
85
- "vite-intlayer": "9.0.0-canary.1"
79
+ "@intlayer/chokidar": "9.0.0-canary.2",
80
+ "@intlayer/config": "9.0.0-canary.2",
81
+ "@intlayer/core": "9.0.0-canary.2",
82
+ "@intlayer/dictionaries-entry": "9.0.0-canary.2",
83
+ "@intlayer/types": "9.0.0-canary.2",
84
+ "react-intlayer": "9.0.0-canary.2",
85
+ "vite-intlayer": "9.0.0-canary.2"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@lingui/core": "^6.3.0",