@intlayer/config 9.4.4 → 9.5.1

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 (34) hide show
  1. package/README.md +0 -2
  2. package/dist/cjs/built.cjs.map +1 -1
  3. package/dist/cjs/callers/compat/lingui.cjs +18 -28
  4. package/dist/cjs/callers/compat/lingui.cjs.map +1 -1
  5. package/dist/cjs/callers/compat/reactI18next.cjs +1 -0
  6. package/dist/cjs/callers/compat/reactI18next.cjs.map +1 -1
  7. package/dist/cjs/callers/compat/reactIntl.cjs +26 -15
  8. package/dist/cjs/callers/compat/reactIntl.cjs.map +1 -1
  9. package/dist/cjs/callers/index.cjs +1 -0
  10. package/dist/cjs/callers/index.cjs.map +1 -1
  11. package/dist/cjs/callers/transform.cjs +16 -9
  12. package/dist/cjs/callers/transform.cjs.map +1 -1
  13. package/dist/esm/built.mjs.map +1 -1
  14. package/dist/esm/bundle/index.mjs +1 -1
  15. package/dist/esm/callers/compat/lingui.mjs +18 -28
  16. package/dist/esm/callers/compat/lingui.mjs.map +1 -1
  17. package/dist/esm/callers/compat/reactI18next.mjs +1 -0
  18. package/dist/esm/callers/compat/reactI18next.mjs.map +1 -1
  19. package/dist/esm/callers/compat/reactIntl.mjs +26 -15
  20. package/dist/esm/callers/compat/reactIntl.mjs.map +1 -1
  21. package/dist/esm/callers/index.mjs +2 -2
  22. package/dist/esm/callers/index.mjs.map +1 -1
  23. package/dist/esm/callers/transform.mjs +16 -10
  24. package/dist/esm/callers/transform.mjs.map +1 -1
  25. package/dist/types/built.d.ts +13 -13
  26. package/dist/types/built.d.ts.map +1 -1
  27. package/dist/types/callers/compat/lingui.d.ts.map +1 -1
  28. package/dist/types/callers/index.d.ts +2 -2
  29. package/dist/types/callers/index.d.ts.map +1 -1
  30. package/dist/types/callers/transform.d.ts +14 -8
  31. package/dist/types/callers/transform.d.ts.map +1 -1
  32. package/dist/types/callers/types.d.ts +6 -0
  33. package/dist/types/callers/types.d.ts.map +1 -1
  34. package/package.json +3 -3
package/README.md CHANGED
@@ -69,8 +69,6 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
69
69
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) <br> - [Intlayer compat adapters](https://intlayer.org/doc/compatibility) |
70
70
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
71
71
 
72
- ---
73
-
74
72
  ## 📦 Installation
75
73
 
76
74
  Start your journey with Intlayer today and experience a smoother, more powerful approach to internationalization.
@@ -1 +1 @@
1
- {"version":3,"file":"built.cjs","names":["getConfiguration"],"sources":["../../src/built.ts"],"sourcesContent":["/**\n * @intlayer/config/built is a package that only returns the configuration file as a JSON object.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n */\n\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getConfiguration } from './configFile/getConfiguration';\nimport type { BuiltConfigKey } from './utils/builtConfigKeys';\n\nconst configuration: IntlayerConfig = getConfiguration();\n\nconst parsedJSONConfig = JSON.parse(JSON.stringify(configuration));\n\nexport const internationalization = parsedJSONConfig.internationalization;\nexport const dictionary = parsedJSONConfig.dictionary;\nexport const routing = parsedJSONConfig.routing;\nexport const content = parsedJSONConfig.content;\nexport const system = parsedJSONConfig.system;\nexport const editor = parsedJSONConfig.editor;\nexport const analytics = parsedJSONConfig.analytics;\nexport const log = parsedJSONConfig.log;\nexport const ai = parsedJSONConfig.ai;\nexport const build = parsedJSONConfig.build;\nexport const compiler = parsedJSONConfig.compiler;\nexport const schemas = parsedJSONConfig.schemas;\nexport const plugins = parsedJSONConfig.plugins;\n\n/**\n * Compile-time guard: the named exports above must cover exactly the canonical\n * {@link BuiltConfigKey} list that `generateConfigurationContent` emits into the\n * aliased `configuration.mjs`. Adding a key to `BUILT_CONFIG_KEYS` without\n * exporting it here (or vice versa) is a type error, keeping the runtime and\n * aliased build targets in lockstep.\n */\n({\n internationalization,\n dictionary,\n routing,\n content,\n system,\n editor,\n analytics,\n log,\n ai,\n build,\n compiler,\n schemas,\n plugins,\n}) satisfies Record<BuiltConfigKey, unknown>;\n"],"mappings":";;;;AASA,MAAM,gBAAgCA,qDAAiB;AAEvD,MAAM,mBAAmB,KAAK,MAAM,KAAK,UAAU,aAAa,CAAC;AAEjE,MAAa,uBAAuB,iBAAiB;AACrD,MAAa,aAAa,iBAAiB;AAC3C,MAAa,UAAU,iBAAiB;AACxC,MAAa,UAAU,iBAAiB;AACxC,MAAa,SAAS,iBAAiB;AACvC,MAAa,SAAS,iBAAiB;AACvC,MAAa,YAAY,iBAAiB;AAC1C,MAAa,MAAM,iBAAiB;AACpC,MAAa,KAAK,iBAAiB;AACnC,MAAa,QAAQ,iBAAiB;AACtC,MAAa,WAAW,iBAAiB;AACzC,MAAa,UAAU,iBAAiB;AACxC,MAAa,UAAU,iBAAiB"}
1
+ {"version":3,"file":"built.cjs","names":["getConfiguration"],"sources":["../../src/built.ts"],"sourcesContent":["/**\n * @intlayer/config/built is a package that only returns the configuration file as a JSON object.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n */\n\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getConfiguration } from './configFile/getConfiguration';\nimport type { BuiltConfigKey } from './utils/builtConfigKeys';\n\nconst configuration: IntlayerConfig = getConfiguration();\n\nconst parsedJSONConfig: IntlayerConfig = JSON.parse(\n JSON.stringify(configuration)\n);\n\nexport const internationalization = parsedJSONConfig.internationalization;\nexport const dictionary = parsedJSONConfig.dictionary;\nexport const routing = parsedJSONConfig.routing;\nexport const content = parsedJSONConfig.content;\nexport const system = parsedJSONConfig.system;\nexport const editor = parsedJSONConfig.editor;\nexport const analytics = parsedJSONConfig.analytics;\nexport const log = parsedJSONConfig.log;\nexport const ai = parsedJSONConfig.ai;\nexport const build = parsedJSONConfig.build;\nexport const compiler = parsedJSONConfig.compiler;\nexport const schemas = parsedJSONConfig.schemas;\nexport const plugins = parsedJSONConfig.plugins;\n\n/**\n * Compile-time guard: the named exports above must cover exactly the canonical\n * {@link BuiltConfigKey} list that `generateConfigurationContent` emits into the\n * aliased `configuration.mjs`. Adding a key to `BUILT_CONFIG_KEYS` without\n * exporting it here (or vice versa) is a type error, keeping the runtime and\n * aliased build targets in lockstep.\n */\n({\n internationalization,\n dictionary,\n routing,\n content,\n system,\n editor,\n analytics,\n log,\n ai,\n build,\n compiler,\n schemas,\n plugins,\n}) satisfies Record<BuiltConfigKey, unknown>;\n"],"mappings":";;;;AASA,MAAM,gBAAgCA,qDAAiB;AAEvD,MAAM,mBAAmC,KAAK,MAC5C,KAAK,UAAU,aAAa,CAC9B;AAEA,MAAa,uBAAuB,iBAAiB;AACrD,MAAa,aAAa,iBAAiB;AAC3C,MAAa,UAAU,iBAAiB;AACxC,MAAa,UAAU,iBAAiB;AACxC,MAAa,SAAS,iBAAiB;AACvC,MAAa,SAAS,iBAAiB;AACvC,MAAa,YAAY,iBAAiB;AAC1C,MAAa,MAAM,iBAAiB;AACpC,MAAa,KAAK,iBAAiB;AACnC,MAAa,QAAQ,iBAAiB;AACtC,MAAa,WAAW,iBAAiB;AACzC,MAAa,UAAU,iBAAiB;AACxC,MAAa,UAAU,iBAAiB"}
@@ -3,9 +3,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  /**
4
4
  * Lingui — `@intlayer/lingui` compat adapter.
5
5
  *
6
- * Lingui is a single-catalog library: every message lives in the `messages`
7
- * dictionary and catalog keys are flat (a dotted id such as
8
- * `results-table.bundleSize` is one literal key, not a nested path).
6
+ * Lingui is a single-catalog library: the namespace lives *inside* the message
7
+ * id rather than in the file layout, so `i18n._('footer.github')` names both
8
+ * the group (`footer`) and the field (`github`).
9
+ *
10
+ * The adapter therefore addresses lingui catalogs by the id's first dot-segment,
11
+ * which lets a catalog split with `syncJSON({ splitKeys: 'key-prefix' })` resolve
12
+ * one small dictionary per call site instead of the whole catalog. None of these
13
+ * callers carries a namespace argument, so the optimize passes leave them to the
14
+ * runtime resolver and only the usage analysis reads the ids.
9
15
  *
10
16
  * `t` and `_` are generic names, so all lingui callers require an import from
11
17
  * a lingui module to participate in matching — this avoids false positives on
@@ -26,13 +32,9 @@ const LINGUI_CALLERS = [
26
32
  callerName: "useLingui",
27
33
  library: "lingui",
28
34
  importSources: LINGUI_IMPORT_SOURCES,
29
- namespaceSources: [{
30
- from: "fixed",
31
- value: "messages"
32
- }],
33
- translationFunction: "destructured-t",
34
- staticReplacement: "useDictionary",
35
- dynamicReplacement: "useDictionaryDynamic"
35
+ namespaceSources: [],
36
+ allowRootScope: true,
37
+ translationFunction: "destructured-t"
36
38
  },
37
39
  {
38
40
  callerName: "_",
@@ -40,12 +42,8 @@ const LINGUI_CALLERS = [
40
42
  importSources: LINGUI_IMPORT_SOURCES,
41
43
  requiresImport: true,
42
44
  matchAsMethod: true,
43
- namespaceSources: [{
44
- from: "fixed",
45
- value: "messages"
46
- }],
47
- translationFunction: "self",
48
- flatKey: true
45
+ namespaceSources: [{ from: "path-first-segment" }],
46
+ translationFunction: "self"
49
47
  },
50
48
  {
51
49
  callerName: "t",
@@ -54,12 +52,8 @@ const LINGUI_CALLERS = [
54
52
  requiresImport: true,
55
53
  matchAsMethod: true,
56
54
  matchAsTaggedTemplate: true,
57
- namespaceSources: [{
58
- from: "fixed",
59
- value: "messages"
60
- }],
61
- translationFunction: "self",
62
- flatKey: true
55
+ namespaceSources: [{ from: "path-first-segment" }],
56
+ translationFunction: "self"
63
57
  },
64
58
  {
65
59
  callerName: "Trans",
@@ -67,12 +61,8 @@ const LINGUI_CALLERS = [
67
61
  importSources: LINGUI_IMPORT_SOURCES,
68
62
  requiresImport: true,
69
63
  jsxIdAttribute: "id",
70
- namespaceSources: [{
71
- from: "fixed",
72
- value: "messages"
73
- }],
74
- translationFunction: "self",
75
- flatKey: true
64
+ namespaceSources: [{ from: "path-first-segment" }],
65
+ translationFunction: "self"
76
66
  }
77
67
  ];
78
68
 
@@ -1 +1 @@
1
- {"version":3,"file":"lingui.cjs","names":[],"sources":["../../../../src/callers/compat/lingui.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * Lingui — `@intlayer/lingui` compat adapter.\n *\n * Lingui is a single-catalog library: every message lives in the `messages`\n * dictionary and catalog keys are flat (a dotted id such as\n * `results-table.bundleSize` is one literal key, not a nested path).\n *\n * `t` and `_` are generic names, so all lingui callers require an import from\n * a lingui module to participate in matching — this avoids false positives on\n * unrelated `t()` helpers.\n *\n * Mirrors `compat/lingui/src/plugin/index.ts`.\n */\nconst LINGUI_IMPORT_SOURCES = [\n '@lingui/core',\n '@lingui/react',\n '@lingui/macro',\n '@lingui/core/macro',\n '@lingui/react/macro',\n '@intlayer/lingui',\n];\n\nexport const LINGUI_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useLingui',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n // `const { i18n, t, _ } = useLingui()` single-catalog hook, no\n // namespace argument: every call reads the `messages` dictionary.\n namespaceSources: [{ from: 'fixed', value: 'messages' }],\n translationFunction: 'destructured-t',\n staticReplacement: 'useDictionary',\n dynamicReplacement: 'useDictionaryDynamic',\n },\n {\n callerName: '_',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n requiresImport: true,\n // `i18n._('id')` and the destructured `const { _ } = useLingui()` form.\n matchAsMethod: true,\n namespaceSources: [{ from: 'fixed', value: 'messages' }],\n translationFunction: 'self',\n flatKey: true,\n },\n {\n callerName: 't',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n requiresImport: true,\n // `i18n.t('id')`, `t({ id: 'id' })` and the macro tagged template ``t`…` ``.\n matchAsMethod: true,\n matchAsTaggedTemplate: true,\n namespaceSources: [{ from: 'fixed', value: 'messages' }],\n translationFunction: 'self',\n flatKey: true,\n },\n {\n callerName: 'Trans',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n requiresImport: true,\n // <Trans id=\"home.title\" message=\"Welcome\" />\n jsxIdAttribute: 'id',\n namespaceSources: [{ from: 'fixed', value: 'messages' }],\n translationFunction: 'self',\n flatKey: true,\n },\n];\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,wBAAwB;CAC5B;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,iBAAqC;CAChD;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EAGf,kBAAkB,CAAC;GAAE,MAAM;GAAS,OAAO;EAAW,CAAC;EACvD,qBAAqB;EACrB,mBAAmB;EACnB,oBAAoB;CACtB;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,eAAe;EACf,kBAAkB,CAAC;GAAE,MAAM;GAAS,OAAO;EAAW,CAAC;EACvD,qBAAqB;EACrB,SAAS;CACX;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,eAAe;EACf,uBAAuB;EACvB,kBAAkB,CAAC;GAAE,MAAM;GAAS,OAAO;EAAW,CAAC;EACvD,qBAAqB;EACrB,SAAS;CACX;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,gBAAgB;EAChB,kBAAkB,CAAC;GAAE,MAAM;GAAS,OAAO;EAAW,CAAC;EACvD,qBAAqB;EACrB,SAAS;CACX;AACF"}
1
+ {"version":3,"file":"lingui.cjs","names":[],"sources":["../../../../src/callers/compat/lingui.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * Lingui — `@intlayer/lingui` compat adapter.\n *\n * Lingui is a single-catalog library: the namespace lives *inside* the message\n * id rather than in the file layout, so `i18n._('footer.github')` names both\n * the group (`footer`) and the field (`github`).\n *\n * The adapter therefore addresses lingui catalogs by the id's first dot-segment,\n * which lets a catalog split with `syncJSON({ splitKeys: 'key-prefix' })` resolve\n * one small dictionary per call site instead of the whole catalog. None of these\n * callers carries a namespace argument, so the optimize passes leave them to the\n * runtime resolver and only the usage analysis reads the ids.\n *\n * `t` and `_` are generic names, so all lingui callers require an import from\n * a lingui module to participate in matching — this avoids false positives on\n * unrelated `t()` helpers.\n *\n * Mirrors `compat/lingui/src/plugin/index.ts`.\n */\nconst LINGUI_IMPORT_SOURCES = [\n '@lingui/core',\n '@lingui/react',\n '@lingui/macro',\n '@lingui/core/macro',\n '@lingui/react/macro',\n '@intlayer/lingui',\n];\n\nexport const LINGUI_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useLingui',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n // `const { i18n, t, _ } = useLingui()` takes no namespace argument, so the\n // dictionary is only knowable from the ids passed to the returned\n // functions which the usage analysis reads and the optimize passes do not.\n namespaceSources: [],\n allowRootScope: true,\n translationFunction: 'destructured-t',\n },\n {\n callerName: '_',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n requiresImport: true,\n // `i18n._('id')` and the destructured `const { _ } = useLingui()` form.\n matchAsMethod: true,\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n {\n callerName: 't',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n requiresImport: true,\n // `i18n.t('id')`, `t({ id: 'id' })` and the macro tagged template ``t`…` ``.\n matchAsMethod: true,\n matchAsTaggedTemplate: true,\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n {\n callerName: 'Trans',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n requiresImport: true,\n // <Trans id=\"home.title\" message=\"Welcome\" />\n jsxIdAttribute: 'id',\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,wBAAwB;CAC5B;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,iBAAqC;CAChD;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EAIf,kBAAkB,CAAC;EACnB,gBAAgB;EAChB,qBAAqB;CACvB;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,eAAe;EACf,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;EACjD,qBAAqB;CACvB;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,eAAe;EACf,uBAAuB;EACvB,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;EACjD,qBAAqB;CACvB;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,gBAAgB;EAChB,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;EACjD,qBAAqB;CACvB;AACF"}
@@ -27,6 +27,7 @@ const REACT_I18NEXT_CALLERS = [{
27
27
  property: "keyPrefix"
28
28
  }],
29
29
  translationFunction: "destructured-t",
30
+ allowRootScope: true,
30
31
  staticReplacement: "useDictionary",
31
32
  dynamicReplacement: "useDictionaryDynamic"
32
33
  }, {
@@ -1 +1 @@
1
- {"version":3,"file":"reactI18next.cjs","names":[],"sources":["../../../../src/callers/compat/reactI18next.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * react-i18next / next-i18next — `@intlayer/react-i18next` and\n * `@intlayer/next-i18next` compat adapters (next-i18next re-exports the\n * react-i18next hook, so both libraries share the same callers).\n *\n * Mirrors `compat/react-i18next/src/plugin/index.ts` and\n * `compat/next-i18next/src/plugin/index.ts`.\n */\nexport const REACT_I18NEXT_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useTranslation',\n library: 'react-i18next',\n importSources: [\n 'react-i18next',\n 'next-i18next',\n '@intlayer/react-i18next',\n '@intlayer/next-i18next',\n ],\n namespaceSources: [{ from: 'argument', index: 0 }],\n keyPrefixSources: [\n { from: 'option', argumentIndex: 1, property: 'keyPrefix' },\n ],\n translationFunction: 'destructured-t',\n staticReplacement: 'useDictionary',\n dynamicReplacement: 'useDictionaryDynamic',\n },\n {\n callerName: 'Trans',\n library: 'react-i18next',\n importSources: [\n 'react-i18next',\n 'next-i18next',\n '@intlayer/react-i18next',\n '@intlayer/next-i18next',\n ],\n // <Trans ns=\"home\" i18nKey=\"richText\" /> — the namespace attribute is\n // optional; without it the analyser falls back to the single translator\n // namespace declared in the same file.\n jsxIdAttribute: 'i18nKey',\n jsxNamespaceAttribute: 'ns',\n namespaceSources: [],\n translationFunction: 'self',\n },\n];\n"],"mappings":";;;;;;;;;;AAUA,MAAa,wBAA4C,CACvD;CACE,YAAY;CACZ,SAAS;CACT,eAAe;EACb;EACA;EACA;EACA;CACF;CACA,kBAAkB,CAAC;EAAE,MAAM;EAAY,OAAO;CAAE,CAAC;CACjD,kBAAkB,CAChB;EAAE,MAAM;EAAU,eAAe;EAAG,UAAU;CAAY,CAC5D;CACA,qBAAqB;CACrB,mBAAmB;CACnB,oBAAoB;AACtB,GACA;CACE,YAAY;CACZ,SAAS;CACT,eAAe;EACb;EACA;EACA;EACA;CACF;CAIA,gBAAgB;CAChB,uBAAuB;CACvB,kBAAkB,CAAC;CACnB,qBAAqB;AACvB,CACF"}
1
+ {"version":3,"file":"reactI18next.cjs","names":[],"sources":["../../../../src/callers/compat/reactI18next.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * react-i18next / next-i18next — `@intlayer/react-i18next` and\n * `@intlayer/next-i18next` compat adapters (next-i18next re-exports the\n * react-i18next hook, so both libraries share the same callers).\n *\n * Mirrors `compat/react-i18next/src/plugin/index.ts` and\n * `compat/next-i18next/src/plugin/index.ts`.\n */\nexport const REACT_I18NEXT_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useTranslation',\n library: 'react-i18next',\n importSources: [\n 'react-i18next',\n 'next-i18next',\n '@intlayer/react-i18next',\n '@intlayer/next-i18next',\n ],\n namespaceSources: [{ from: 'argument', index: 0 }],\n keyPrefixSources: [\n { from: 'option', argumentIndex: 1, property: 'keyPrefix' },\n ],\n translationFunction: 'destructured-t',\n allowRootScope: true,\n staticReplacement: 'useDictionary',\n dynamicReplacement: 'useDictionaryDynamic',\n },\n {\n callerName: 'Trans',\n library: 'react-i18next',\n importSources: [\n 'react-i18next',\n 'next-i18next',\n '@intlayer/react-i18next',\n '@intlayer/next-i18next',\n ],\n // <Trans ns=\"home\" i18nKey=\"richText\" /> — the namespace attribute is\n // optional; without it the analyser falls back to the single translator\n // namespace declared in the same file.\n jsxIdAttribute: 'i18nKey',\n jsxNamespaceAttribute: 'ns',\n namespaceSources: [],\n translationFunction: 'self',\n },\n];\n"],"mappings":";;;;;;;;;;AAUA,MAAa,wBAA4C,CACvD;CACE,YAAY;CACZ,SAAS;CACT,eAAe;EACb;EACA;EACA;EACA;CACF;CACA,kBAAkB,CAAC;EAAE,MAAM;EAAY,OAAO;CAAE,CAAC;CACjD,kBAAkB,CAChB;EAAE,MAAM;EAAU,eAAe;EAAG,UAAU;CAAY,CAC5D;CACA,qBAAqB;CACrB,gBAAgB;CAChB,mBAAmB;CACnB,oBAAoB;AACtB,GACA;CACE,YAAY;CACZ,SAAS;CACT,eAAe;EACb;EACA;EACA;EACA;CACF;CAIA,gBAAgB;CAChB,uBAAuB;CACvB,kBAAkB,CAAC;CACnB,qBAAqB;AACvB,CACF"}
@@ -9,21 +9,32 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
9
9
  *
10
10
  * Mirrors `compat/react-intl/src/plugin/index.ts`.
11
11
  */
12
- const REACT_INTL_CALLERS = [{
13
- callerName: "formatMessage",
14
- library: "react-intl",
15
- importSources: ["react-intl", "@intlayer/react-intl"],
16
- matchAsMethod: true,
17
- namespaceSources: [{ from: "path-first-segment" }],
18
- translationFunction: "self"
19
- }, {
20
- callerName: "FormattedMessage",
21
- library: "react-intl",
22
- importSources: ["react-intl", "@intlayer/react-intl"],
23
- jsxIdAttribute: "id",
24
- namespaceSources: [{ from: "path-first-segment" }],
25
- translationFunction: "self"
26
- }];
12
+ const REACT_INTL_CALLERS = [
13
+ {
14
+ callerName: "useIntl",
15
+ library: "react-intl",
16
+ importSources: ["react-intl", "@intlayer/react-intl"],
17
+ namespaceSources: [],
18
+ allowRootScope: true,
19
+ translationFunction: "destructured-t"
20
+ },
21
+ {
22
+ callerName: "formatMessage",
23
+ library: "react-intl",
24
+ importSources: ["react-intl", "@intlayer/react-intl"],
25
+ matchAsMethod: true,
26
+ namespaceSources: [{ from: "path-first-segment" }],
27
+ translationFunction: "self"
28
+ },
29
+ {
30
+ callerName: "FormattedMessage",
31
+ library: "react-intl",
32
+ importSources: ["react-intl", "@intlayer/react-intl"],
33
+ jsxIdAttribute: "id",
34
+ namespaceSources: [{ from: "path-first-segment" }],
35
+ translationFunction: "self"
36
+ }
37
+ ];
27
38
 
28
39
  //#endregion
29
40
  exports.REACT_INTL_CALLERS = REACT_INTL_CALLERS;
@@ -1 +1 @@
1
- {"version":3,"file":"reactIntl.cjs","names":[],"sources":["../../../../src/callers/compat/reactIntl.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * react-intl (FormatJS) — `@intlayer/react-intl` compat adapter.\n *\n * The full dotted message id encodes both the dictionary key and the field\n * path: `formatMessage({ id: 'home.title' })` → dictionary `home`, field\n * `title`.\n *\n * Mirrors `compat/react-intl/src/plugin/index.ts`.\n */\nexport const REACT_INTL_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'formatMessage',\n library: 'react-intl',\n importSources: ['react-intl', '@intlayer/react-intl'],\n // Matches both `intl.formatMessage(...)` and the destructured\n // `const { formatMessage } = useIntl()` identifier form.\n matchAsMethod: true,\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n {\n callerName: 'FormattedMessage',\n library: 'react-intl',\n importSources: ['react-intl', '@intlayer/react-intl'],\n jsxIdAttribute: 'id',\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n];\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,qBAAyC,CACpD;CACE,YAAY;CACZ,SAAS;CACT,eAAe,CAAC,cAAc,sBAAsB;CAGpD,eAAe;CACf,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;CACjD,qBAAqB;AACvB,GACA;CACE,YAAY;CACZ,SAAS;CACT,eAAe,CAAC,cAAc,sBAAsB;CACpD,gBAAgB;CAChB,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;CACjD,qBAAqB;AACvB,CACF"}
1
+ {"version":3,"file":"reactIntl.cjs","names":[],"sources":["../../../../src/callers/compat/reactIntl.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * react-intl (FormatJS) — `@intlayer/react-intl` compat adapter.\n *\n * The full dotted message id encodes both the dictionary key and the field\n * path: `formatMessage({ id: 'home.title' })` → dictionary `home`, field\n * `title`.\n *\n * Mirrors `compat/react-intl/src/plugin/index.ts`.\n */\nexport const REACT_INTL_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useIntl',\n library: 'react-intl',\n importSources: ['react-intl', '@intlayer/react-intl'],\n namespaceSources: [],\n allowRootScope: true,\n translationFunction: 'destructured-t',\n },\n {\n callerName: 'formatMessage',\n library: 'react-intl',\n importSources: ['react-intl', '@intlayer/react-intl'],\n // Matches both `intl.formatMessage(...)` and the destructured\n // `const { formatMessage } = useIntl()` identifier form.\n matchAsMethod: true,\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n {\n callerName: 'FormattedMessage',\n library: 'react-intl',\n importSources: ['react-intl', '@intlayer/react-intl'],\n jsxIdAttribute: 'id',\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n];\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,qBAAyC;CACpD;EACE,YAAY;EACZ,SAAS;EACT,eAAe,CAAC,cAAc,sBAAsB;EACpD,kBAAkB,CAAC;EACnB,gBAAgB;EAChB,qBAAqB;CACvB;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe,CAAC,cAAc,sBAAsB;EAGpD,eAAe;EACf,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;EACjD,qBAAqB;CACvB;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe,CAAC,cAAc,sBAAsB;EACpD,gBAAgB;EAChB,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;EACjD,qBAAqB;CACvB;AACF"}
@@ -83,5 +83,6 @@ exports.VUE_I18N_CALLERS = require_callers_compat_vueI18n.VUE_I18N_CALLERS;
83
83
  exports.getPositionalKeyCallerNames = getPositionalKeyCallerNames;
84
84
  exports.getRewritableCallers = require_callers_transform.getRewritableCallers;
85
85
  exports.isCallerActive = isCallerActive;
86
+ exports.isRewritableCaller = require_callers_transform.isRewritableCaller;
86
87
  exports.toSwcExtraCallers = require_callers_transform.toSwcExtraCallers;
87
88
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["I18NEXT_CALLERS","REACT_I18NEXT_CALLERS","NEXT_INTL_CALLERS","USE_INTL_CALLERS","REACT_INTL_CALLERS","LINGUI_CALLERS","VUE_I18N_CALLERS","BASE_CALLERS"],"sources":["../../../src/callers/index.ts"],"sourcesContent":["import { BASE_CALLERS } from './base';\nimport { I18NEXT_CALLERS } from './compat/i18next';\nimport { LINGUI_CALLERS } from './compat/lingui';\nimport { NEXT_INTL_CALLERS } from './compat/nextIntl';\nimport { REACT_I18NEXT_CALLERS } from './compat/reactI18next';\nimport { REACT_INTL_CALLERS } from './compat/reactIntl';\nimport { USE_INTL_CALLERS } from './compat/useIntl';\nimport { VUE_I18N_CALLERS } from './compat/vueI18n';\nimport type { CallerDescriptor } from './types';\n\nexport { BASE_CALLERS } from './base';\nexport { I18NEXT_CALLERS } from './compat/i18next';\nexport { LINGUI_CALLERS } from './compat/lingui';\nexport { NEXT_INTL_CALLERS } from './compat/nextIntl';\nexport { REACT_I18NEXT_CALLERS } from './compat/reactI18next';\nexport { REACT_INTL_CALLERS } from './compat/reactIntl';\nexport { USE_INTL_CALLERS } from './compat/useIntl';\nexport { VUE_I18N_CALLERS } from './compat/vueI18n';\nexport {\n getRewritableCallers,\n type SwcExtraCallerConfig,\n toSwcExtraCallers,\n} from './transform';\nexport type {\n CallerDescriptor,\n CallerResultShape,\n CallerValueSource,\n} from './types';\n\n/**\n * Compat-adapter callers, grouped in one list. Each compat package's bundler\n * plugin injects its own slice (e.g. `REACT_I18NEXT_CALLERS`) into the build\n * pipeline; this aggregate exists for consumers that need every syntax at\n * once, such as the LSP.\n */\nexport const COMPAT_CALLERS: CallerDescriptor[] = [\n ...I18NEXT_CALLERS,\n ...REACT_I18NEXT_CALLERS,\n ...NEXT_INTL_CALLERS,\n ...USE_INTL_CALLERS,\n ...REACT_INTL_CALLERS,\n ...LINGUI_CALLERS,\n ...VUE_I18N_CALLERS,\n];\n\n/** Base + compat callers — the full registry the matchers run against. */\nexport const ALL_CALLERS: CallerDescriptor[] = [\n ...BASE_CALLERS,\n ...COMPAT_CALLERS,\n];\n\n/**\n * Descriptors indexed by caller name. A name can map to several descriptors\n * (e.g. `Trans` exists in both react-i18next and lingui with different\n * attributes); matchers try them in registry order.\n */\nexport const CALLERS_BY_NAME: Map<string, CallerDescriptor[]> = (() => {\n const byName = new Map<string, CallerDescriptor[]>();\n\n for (const descriptor of ALL_CALLERS) {\n const existing = byName.get(descriptor.callerName);\n\n if (existing) {\n existing.push(descriptor);\n } else {\n byName.set(descriptor.callerName, [descriptor]);\n }\n }\n\n return byName;\n})();\n\n/**\n * Caller names whose dictionary key can appear as a positional string literal\n * argument (`caller('key', …)` / `caller(locale, 'key', …)`). Used to build\n * text-search regexes over project source files (find-references) and the\n * completion trigger pattern. Callers whose key never appears positionally\n * (fixed namespace, options object, JSX-only) are excluded on purpose.\n */\nexport const getPositionalKeyCallerNames = (): string[] => {\n const names = new Set<string>();\n\n for (const descriptor of ALL_CALLERS) {\n const hasPositionalNamespace = descriptor.namespaceSources.some(\n (source) => source.from === 'argument'\n );\n\n if (hasPositionalNamespace) names.add(descriptor.callerName);\n }\n\n return [...names];\n};\n\n/**\n * Returns `true` when the descriptor may participate in matching for a file\n * importing from `importSources`. Descriptors flagged `requiresImport` only\n * activate when the file imports from one of their declared modules;\n * everything else is always active (results are still validated against the\n * project's dictionaries downstream).\n *\n * @param descriptor - The caller descriptor to gate.\n * @param fileImportSources - Module specifiers imported by the analysed file.\n */\nexport const isCallerActive = (\n descriptor: CallerDescriptor,\n fileImportSources: ReadonlySet<string>\n): boolean => {\n if (!descriptor.requiresImport) return true;\n\n return descriptor.importSources.some((source) =>\n fileImportSources.has(source)\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmCA,MAAa,iBAAqC;CAChD,GAAGA;CACH,GAAGC;CACH,GAAGC;CACH,GAAGC;CACH,GAAGC;CACH,GAAGC;CACH,GAAGC;AACL;;AAGA,MAAa,cAAkC,CAC7C,GAAGC,mCACH,GAAG,cACL;;;;;;AAOA,MAAa,yBAA0D;CACrE,MAAM,yBAAS,IAAI,IAAgC;CAEnD,KAAK,MAAM,cAAc,aAAa;EACpC,MAAM,WAAW,OAAO,IAAI,WAAW,UAAU;EAEjD,IAAI,UACF,SAAS,KAAK,UAAU;OAExB,OAAO,IAAI,WAAW,YAAY,CAAC,UAAU,CAAC;CAElD;CAEA,OAAO;AACT,EAAC,CAAE;;;;;;;;AASH,MAAa,oCAA8C;CACzD,MAAM,wBAAQ,IAAI,IAAY;CAE9B,KAAK,MAAM,cAAc,aAKvB,IAJ+B,WAAW,iBAAiB,MACxD,WAAW,OAAO,SAAS,UAGL,GAAG,MAAM,IAAI,WAAW,UAAU;CAG7D,OAAO,CAAC,GAAG,KAAK;AAClB;;;;;;;;;;;AAYA,MAAa,kBACX,YACA,sBACY;CACZ,IAAI,CAAC,WAAW,gBAAgB,OAAO;CAEvC,OAAO,WAAW,cAAc,MAAM,WACpC,kBAAkB,IAAI,MAAM,CAC9B;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["I18NEXT_CALLERS","REACT_I18NEXT_CALLERS","NEXT_INTL_CALLERS","USE_INTL_CALLERS","REACT_INTL_CALLERS","LINGUI_CALLERS","VUE_I18N_CALLERS","BASE_CALLERS"],"sources":["../../../src/callers/index.ts"],"sourcesContent":["import { BASE_CALLERS } from './base';\nimport { I18NEXT_CALLERS } from './compat/i18next';\nimport { LINGUI_CALLERS } from './compat/lingui';\nimport { NEXT_INTL_CALLERS } from './compat/nextIntl';\nimport { REACT_I18NEXT_CALLERS } from './compat/reactI18next';\nimport { REACT_INTL_CALLERS } from './compat/reactIntl';\nimport { USE_INTL_CALLERS } from './compat/useIntl';\nimport { VUE_I18N_CALLERS } from './compat/vueI18n';\nimport type { CallerDescriptor } from './types';\n\nexport { BASE_CALLERS } from './base';\nexport { I18NEXT_CALLERS } from './compat/i18next';\nexport { LINGUI_CALLERS } from './compat/lingui';\nexport { NEXT_INTL_CALLERS } from './compat/nextIntl';\nexport { REACT_I18NEXT_CALLERS } from './compat/reactI18next';\nexport { REACT_INTL_CALLERS } from './compat/reactIntl';\nexport { USE_INTL_CALLERS } from './compat/useIntl';\nexport { VUE_I18N_CALLERS } from './compat/vueI18n';\nexport {\n getRewritableCallers,\n isRewritableCaller,\n type SwcExtraCallerConfig,\n toSwcExtraCallers,\n} from './transform';\nexport type {\n CallerDescriptor,\n CallerResultShape,\n CallerValueSource,\n} from './types';\n\n/**\n * Compat-adapter callers, grouped in one list. Each compat package's bundler\n * plugin injects its own slice (e.g. `REACT_I18NEXT_CALLERS`) into the build\n * pipeline; this aggregate exists for consumers that need every syntax at\n * once, such as the LSP.\n */\nexport const COMPAT_CALLERS: CallerDescriptor[] = [\n ...I18NEXT_CALLERS,\n ...REACT_I18NEXT_CALLERS,\n ...NEXT_INTL_CALLERS,\n ...USE_INTL_CALLERS,\n ...REACT_INTL_CALLERS,\n ...LINGUI_CALLERS,\n ...VUE_I18N_CALLERS,\n];\n\n/** Base + compat callers — the full registry the matchers run against. */\nexport const ALL_CALLERS: CallerDescriptor[] = [\n ...BASE_CALLERS,\n ...COMPAT_CALLERS,\n];\n\n/**\n * Descriptors indexed by caller name. A name can map to several descriptors\n * (e.g. `Trans` exists in both react-i18next and lingui with different\n * attributes); matchers try them in registry order.\n */\nexport const CALLERS_BY_NAME: Map<string, CallerDescriptor[]> = (() => {\n const byName = new Map<string, CallerDescriptor[]>();\n\n for (const descriptor of ALL_CALLERS) {\n const existing = byName.get(descriptor.callerName);\n\n if (existing) {\n existing.push(descriptor);\n } else {\n byName.set(descriptor.callerName, [descriptor]);\n }\n }\n\n return byName;\n})();\n\n/**\n * Caller names whose dictionary key can appear as a positional string literal\n * argument (`caller('key', …)` / `caller(locale, 'key', …)`). Used to build\n * text-search regexes over project source files (find-references) and the\n * completion trigger pattern. Callers whose key never appears positionally\n * (fixed namespace, options object, JSX-only) are excluded on purpose.\n */\nexport const getPositionalKeyCallerNames = (): string[] => {\n const names = new Set<string>();\n\n for (const descriptor of ALL_CALLERS) {\n const hasPositionalNamespace = descriptor.namespaceSources.some(\n (source) => source.from === 'argument'\n );\n\n if (hasPositionalNamespace) names.add(descriptor.callerName);\n }\n\n return [...names];\n};\n\n/**\n * Returns `true` when the descriptor may participate in matching for a file\n * importing from `importSources`. Descriptors flagged `requiresImport` only\n * activate when the file imports from one of their declared modules;\n * everything else is always active (results are still validated against the\n * project's dictionaries downstream).\n *\n * @param descriptor - The caller descriptor to gate.\n * @param fileImportSources - Module specifiers imported by the analysed file.\n */\nexport const isCallerActive = (\n descriptor: CallerDescriptor,\n fileImportSources: ReadonlySet<string>\n): boolean => {\n if (!descriptor.requiresImport) return true;\n\n return descriptor.importSources.some((source) =>\n fileImportSources.has(source)\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,MAAa,iBAAqC;CAChD,GAAGA;CACH,GAAGC;CACH,GAAGC;CACH,GAAGC;CACH,GAAGC;CACH,GAAGC;CACH,GAAGC;AACL;;AAGA,MAAa,cAAkC,CAC7C,GAAGC,mCACH,GAAG,cACL;;;;;;AAOA,MAAa,yBAA0D;CACrE,MAAM,yBAAS,IAAI,IAAgC;CAEnD,KAAK,MAAM,cAAc,aAAa;EACpC,MAAM,WAAW,OAAO,IAAI,WAAW,UAAU;EAEjD,IAAI,UACF,SAAS,KAAK,UAAU;OAExB,OAAO,IAAI,WAAW,YAAY,CAAC,UAAU,CAAC;CAElD;CAEA,OAAO;AACT,EAAC,CAAE;;;;;;;;AASH,MAAa,oCAA8C;CACzD,MAAM,wBAAQ,IAAI,IAAY;CAE9B,KAAK,MAAM,cAAc,aAKvB,IAJ+B,WAAW,iBAAiB,MACxD,WAAW,OAAO,SAAS,UAGL,GAAG,MAAM,IAAI,WAAW,UAAU;CAG7D,OAAO,CAAC,GAAG,KAAK;AAClB;;;;;;;;;;;AAYA,MAAa,kBACX,YACA,sBACY;CACZ,IAAI,CAAC,WAAW,gBAAgB,OAAO;CAEvC,OAAO,WAAW,cAAc,MAAM,WACpC,kBAAkB,IAAI,MAAM,CAC9B;AACF"}
@@ -1,24 +1,30 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  //#region src/callers/transform.ts
3
3
  /**
4
- * Returns the callers of a registry slice that the optimize pass can rewrite
5
- * at build time: plain imported functions carrying both replacement names.
4
+ * Whether the optimize pass can rewrite this caller's call sites at build time.
6
5
  *
7
- * Method-matched callers (`i18n.getFixedT`) and JSX components are excluded
8
- * their call sites cannot be re-pointed through an import specifier rename.
6
+ * Requires both replacement names and a call shape reachable through an import
7
+ * specifier rename. Method-matched callers (`i18n.getFixedT`, `intl.formatMessage`)
8
+ * and JSX components (`<Trans>`, `<FormattedMessage>`) are excluded — their call
9
+ * sites keep resolving through the runtime dictionary registry.
10
+ */
11
+ const isRewritableCaller = (descriptor) => descriptor.staticReplacement !== void 0 && descriptor.dynamicReplacement !== void 0 && descriptor.matchAsMethod !== true && descriptor.jsxIdAttribute === void 0;
12
+ /**
13
+ * Returns the callers of a registry slice that the optimize pass can rewrite
14
+ * at build time. See {@link isRewritableCaller}.
9
15
  */
10
- const getRewritableCallers = (descriptors) => descriptors.filter((descriptor) => descriptor.staticReplacement !== void 0 && descriptor.dynamicReplacement !== void 0 && descriptor.matchAsMethod !== true && descriptor.jsxIdAttribute === void 0);
16
+ const getRewritableCallers = (descriptors) => descriptors.filter(isRewritableCaller);
11
17
  const findSource = (sources, from) => sources.find((source) => source.from === from);
12
18
  /**
13
19
  * Serialises the rewritable callers of a registry slice into the
14
20
  * `@intlayer/swc` plugin wire format (`extraCallers` option).
15
21
  *
16
- * Callers whose namespace can only be derived per-message id
17
- * (`path-first-segment`) are skipped: the transform cannot bind a single
18
- * dictionary to the call site.
22
+ * A caller with no statically readable namespace source is dropped: the plugin
23
+ * binds a dictionary from an argument, an option property or a fixed value
24
+ * only, so forwarding it would emit a descriptor no call site can match.
19
25
  *
20
26
  * @param descriptors - Registry slice, e.g. `REACT_I18NEXT_CALLERS`.
21
- * @returns Configs ready to pass as `swcExtraCallers` / `extraCallers`.
27
+ * @returns Configs ready to pass as the plugin's `extraCallers` option.
22
28
  */
23
29
  const toSwcExtraCallers = (descriptors) => getRewritableCallers(descriptors).flatMap((descriptor) => {
24
30
  const argumentSource = findSource(descriptor.namespaceSources, "argument");
@@ -41,5 +47,6 @@ const toSwcExtraCallers = (descriptors) => getRewritableCallers(descriptors).fla
41
47
 
42
48
  //#endregion
43
49
  exports.getRewritableCallers = getRewritableCallers;
50
+ exports.isRewritableCaller = isRewritableCaller;
44
51
  exports.toSwcExtraCallers = toSwcExtraCallers;
45
52
  //# sourceMappingURL=transform.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform.cjs","names":[],"sources":["../../../src/callers/transform.ts"],"sourcesContent":["import type { CallerDescriptor, CallerValueSource } from './types';\n\n/**\n * Wire format of an extra caller forwarded to the `@intlayer/swc` plugin.\n *\n * Field names mirror the serde attributes of `ExtraCallerConfig` in\n * `packages/@intlayer/swc/src/lib.rs` — both sides must stay in sync.\n */\nexport type SwcExtraCallerConfig = {\n /** The function name the user calls, e.g. `\"useTranslation\"`. */\n callerName: string;\n /** Module specifiers exporting the function (original + `@intlayer/*`). */\n importSources: string[];\n /**\n * Zero-based index of the positional argument holding the namespace string.\n * Omitted for fixed/option namespace callers.\n */\n namespaceArgIndex?: number;\n /**\n * Compile-time constant namespace — the dictionary ident is inserted as a\n * new first argument (lingui's `useLingui()`).\n */\n fixedNamespace?: string;\n /**\n * Namespace read from a property of an options-object argument — the\n * dictionary ident is inserted as a new first argument and the property is\n * rewritten to the key-prefix remainder (vue-i18n's `useI18n({ namespace })`).\n */\n namespaceOption?: { argumentIndex: number; property: string };\n /** Replacement function name for static import mode, e.g. `\"useDictionary\"`. */\n staticReplacement: string;\n /** Replacement function name for dynamic/fetch mode, e.g. `\"useDictionaryDynamic\"`. */\n dynamicReplacement: string;\n};\n\n/**\n * Returns the callers of a registry slice that the optimize pass can rewrite\n * at build time: plain imported functions carrying both replacement names.\n *\n * Method-matched callers (`i18n.getFixedT`) and JSX components are excluded —\n * their call sites cannot be re-pointed through an import specifier rename.\n */\nexport const getRewritableCallers = (\n descriptors: CallerDescriptor[]\n): CallerDescriptor[] =>\n descriptors.filter(\n (descriptor) =>\n descriptor.staticReplacement !== undefined &&\n descriptor.dynamicReplacement !== undefined &&\n descriptor.matchAsMethod !== true &&\n descriptor.jsxIdAttribute === undefined\n );\n\nconst findSource = <F extends CallerValueSource['from']>(\n sources: CallerValueSource[],\n from: F\n): Extract<CallerValueSource, { from: F }> | undefined =>\n sources.find(\n (source): source is Extract<CallerValueSource, { from: F }> =>\n source.from === from\n );\n\n/**\n * Serialises the rewritable callers of a registry slice into the\n * `@intlayer/swc` plugin wire format (`extraCallers` option).\n *\n * Callers whose namespace can only be derived per-message id\n * (`path-first-segment`) are skipped: the transform cannot bind a single\n * dictionary to the call site.\n *\n * @param descriptors - Registry slice, e.g. `REACT_I18NEXT_CALLERS`.\n * @returns Configs ready to pass as `swcExtraCallers` / `extraCallers`.\n */\nexport const toSwcExtraCallers = (\n descriptors: CallerDescriptor[]\n): SwcExtraCallerConfig[] =>\n getRewritableCallers(descriptors).flatMap((descriptor) => {\n const argumentSource = findSource(descriptor.namespaceSources, 'argument');\n const optionSource = findSource(descriptor.namespaceSources, 'option');\n const fixedSource = findSource(descriptor.namespaceSources, 'fixed');\n\n if (!argumentSource && !optionSource && !fixedSource) return [];\n\n return [\n {\n callerName: descriptor.callerName,\n importSources: descriptor.importSources,\n ...(argumentSource ? { namespaceArgIndex: argumentSource.index } : {}),\n ...(fixedSource ? { fixedNamespace: fixedSource.value } : {}),\n ...(optionSource\n ? {\n namespaceOption: {\n argumentIndex: optionSource.argumentIndex,\n property: optionSource.property,\n },\n }\n : {}),\n staticReplacement: descriptor.staticReplacement!,\n dynamicReplacement: descriptor.dynamicReplacement!,\n },\n ];\n });\n"],"mappings":";;;;;;;;;AA0CA,MAAa,wBACX,gBAEA,YAAY,QACT,eACC,WAAW,sBAAsB,UACjC,WAAW,uBAAuB,UAClC,WAAW,kBAAkB,QAC7B,WAAW,mBAAmB,MAClC;AAEF,MAAM,cACJ,SACA,SAEA,QAAQ,MACL,WACC,OAAO,SAAS,IACpB;;;;;;;;;;;;AAaF,MAAa,qBACX,gBAEA,qBAAqB,WAAW,CAAC,CAAC,SAAS,eAAe;CACxD,MAAM,iBAAiB,WAAW,WAAW,kBAAkB,UAAU;CACzE,MAAM,eAAe,WAAW,WAAW,kBAAkB,QAAQ;CACrE,MAAM,cAAc,WAAW,WAAW,kBAAkB,OAAO;CAEnE,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,aAAa,OAAO,CAAC;CAE9D,OAAO,CACL;EACE,YAAY,WAAW;EACvB,eAAe,WAAW;EAC1B,GAAI,iBAAiB,EAAE,mBAAmB,eAAe,MAAM,IAAI,CAAC;EACpE,GAAI,cAAc,EAAE,gBAAgB,YAAY,MAAM,IAAI,CAAC;EAC3D,GAAI,eACA,EACE,iBAAiB;GACf,eAAe,aAAa;GAC5B,UAAU,aAAa;EACzB,EACF,IACA,CAAC;EACL,mBAAmB,WAAW;EAC9B,oBAAoB,WAAW;CACjC,CACF;AACF,CAAC"}
1
+ {"version":3,"file":"transform.cjs","names":[],"sources":["../../../src/callers/transform.ts"],"sourcesContent":["import type { CallerDescriptor, CallerValueSource } from './types';\n\n/**\n * Wire format of an extra caller forwarded to the `@intlayer/swc` plugin.\n *\n * Field names mirror the serde attributes of `ExtraCallerConfig` in\n * `packages/@intlayer/swc/src/lib.rs` — both sides must stay in sync.\n */\nexport type SwcExtraCallerConfig = {\n /** The function name the user calls, e.g. `\"useTranslation\"`. */\n callerName: string;\n /** Module specifiers exporting the function (original + `@intlayer/*`). */\n importSources: string[];\n /**\n * Zero-based index of the positional argument holding the namespace string.\n * Omitted for fixed/option namespace callers.\n */\n namespaceArgIndex?: number;\n /**\n * Compile-time constant namespace — the dictionary ident is inserted as a\n * new first argument (lingui's `useLingui()`).\n */\n fixedNamespace?: string;\n /**\n * Namespace read from a property of an options-object argument — the\n * dictionary ident is inserted as a new first argument and the property is\n * rewritten to the key-prefix remainder (vue-i18n's `useI18n({ namespace })`).\n */\n namespaceOption?: { argumentIndex: number; property: string };\n /** Replacement function name for static import mode, e.g. `\"useDictionary\"`. */\n staticReplacement: string;\n /** Replacement function name for dynamic/fetch mode, e.g. `\"useDictionaryDynamic\"`. */\n dynamicReplacement: string;\n};\n\n/**\n * Whether the optimize pass can rewrite this caller's call sites at build time.\n *\n * Requires both replacement names and a call shape reachable through an import\n * specifier rename. Method-matched callers (`i18n.getFixedT`, `intl.formatMessage`)\n * and JSX components (`<Trans>`, `<FormattedMessage>`) are excluded their call\n * sites keep resolving through the runtime dictionary registry.\n */\nexport const isRewritableCaller = (descriptor: CallerDescriptor): boolean =>\n descriptor.staticReplacement !== undefined &&\n descriptor.dynamicReplacement !== undefined &&\n descriptor.matchAsMethod !== true &&\n descriptor.jsxIdAttribute === undefined;\n\n/**\n * Returns the callers of a registry slice that the optimize pass can rewrite\n * at build time. See {@link isRewritableCaller}.\n */\nexport const getRewritableCallers = (\n descriptors: CallerDescriptor[]\n): CallerDescriptor[] => descriptors.filter(isRewritableCaller);\n\nconst findSource = <F extends CallerValueSource['from']>(\n sources: CallerValueSource[],\n from: F\n): Extract<CallerValueSource, { from: F }> | undefined =>\n sources.find(\n (source): source is Extract<CallerValueSource, { from: F }> =>\n source.from === from\n );\n\n/**\n * Serialises the rewritable callers of a registry slice into the\n * `@intlayer/swc` plugin wire format (`extraCallers` option).\n *\n * A caller with no statically readable namespace source is dropped: the plugin\n * binds a dictionary from an argument, an option property or a fixed value\n * only, so forwarding it would emit a descriptor no call site can match.\n *\n * @param descriptors - Registry slice, e.g. `REACT_I18NEXT_CALLERS`.\n * @returns Configs ready to pass as the plugin's `extraCallers` option.\n */\nexport const toSwcExtraCallers = (\n descriptors: CallerDescriptor[]\n): SwcExtraCallerConfig[] =>\n getRewritableCallers(descriptors).flatMap((descriptor) => {\n const argumentSource = findSource(descriptor.namespaceSources, 'argument');\n const optionSource = findSource(descriptor.namespaceSources, 'option');\n const fixedSource = findSource(descriptor.namespaceSources, 'fixed');\n\n if (!argumentSource && !optionSource && !fixedSource) return [];\n\n return [\n {\n callerName: descriptor.callerName,\n importSources: descriptor.importSources,\n ...(argumentSource ? { namespaceArgIndex: argumentSource.index } : {}),\n ...(fixedSource ? { fixedNamespace: fixedSource.value } : {}),\n ...(optionSource\n ? {\n namespaceOption: {\n argumentIndex: optionSource.argumentIndex,\n property: optionSource.property,\n },\n }\n : {}),\n staticReplacement: descriptor.staticReplacement!,\n dynamicReplacement: descriptor.dynamicReplacement!,\n },\n ];\n });\n"],"mappings":";;;;;;;;;;AA2CA,MAAa,sBAAsB,eACjC,WAAW,sBAAsB,UACjC,WAAW,uBAAuB,UAClC,WAAW,kBAAkB,QAC7B,WAAW,mBAAmB;;;;;AAMhC,MAAa,wBACX,gBACuB,YAAY,OAAO,kBAAkB;AAE9D,MAAM,cACJ,SACA,SAEA,QAAQ,MACL,WACC,OAAO,SAAS,IACpB;;;;;;;;;;;;AAaF,MAAa,qBACX,gBAEA,qBAAqB,WAAW,CAAC,CAAC,SAAS,eAAe;CACxD,MAAM,iBAAiB,WAAW,WAAW,kBAAkB,UAAU;CACzE,MAAM,eAAe,WAAW,WAAW,kBAAkB,QAAQ;CACrE,MAAM,cAAc,WAAW,WAAW,kBAAkB,OAAO;CAEnE,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,aAAa,OAAO,CAAC;CAE9D,OAAO,CACL;EACE,YAAY,WAAW;EACvB,eAAe,WAAW;EAC1B,GAAI,iBAAiB,EAAE,mBAAmB,eAAe,MAAM,IAAI,CAAC;EACpE,GAAI,cAAc,EAAE,gBAAgB,YAAY,MAAM,IAAI,CAAC;EAC3D,GAAI,eACA,EACE,iBAAiB;GACf,eAAe,aAAa;GAC5B,UAAU,aAAa;EACzB,EACF,IACA,CAAC;EACL,mBAAmB,WAAW;EAC9B,oBAAoB,WAAW;CACjC,CACF;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"built.mjs","names":[],"sources":["../../src/built.ts"],"sourcesContent":["/**\n * @intlayer/config/built is a package that only returns the configuration file as a JSON object.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n */\n\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getConfiguration } from './configFile/getConfiguration';\nimport type { BuiltConfigKey } from './utils/builtConfigKeys';\n\nconst configuration: IntlayerConfig = getConfiguration();\n\nconst parsedJSONConfig = JSON.parse(JSON.stringify(configuration));\n\nexport const internationalization = parsedJSONConfig.internationalization;\nexport const dictionary = parsedJSONConfig.dictionary;\nexport const routing = parsedJSONConfig.routing;\nexport const content = parsedJSONConfig.content;\nexport const system = parsedJSONConfig.system;\nexport const editor = parsedJSONConfig.editor;\nexport const analytics = parsedJSONConfig.analytics;\nexport const log = parsedJSONConfig.log;\nexport const ai = parsedJSONConfig.ai;\nexport const build = parsedJSONConfig.build;\nexport const compiler = parsedJSONConfig.compiler;\nexport const schemas = parsedJSONConfig.schemas;\nexport const plugins = parsedJSONConfig.plugins;\n\n/**\n * Compile-time guard: the named exports above must cover exactly the canonical\n * {@link BuiltConfigKey} list that `generateConfigurationContent` emits into the\n * aliased `configuration.mjs`. Adding a key to `BUILT_CONFIG_KEYS` without\n * exporting it here (or vice versa) is a type error, keeping the runtime and\n * aliased build targets in lockstep.\n */\n({\n internationalization,\n dictionary,\n routing,\n content,\n system,\n editor,\n analytics,\n log,\n ai,\n build,\n compiler,\n schemas,\n plugins,\n}) satisfies Record<BuiltConfigKey, unknown>;\n"],"mappings":";;;AASA,MAAM,gBAAgC,iBAAiB;AAEvD,MAAM,mBAAmB,KAAK,MAAM,KAAK,UAAU,aAAa,CAAC;AAEjE,MAAa,uBAAuB,iBAAiB;AACrD,MAAa,aAAa,iBAAiB;AAC3C,MAAa,UAAU,iBAAiB;AACxC,MAAa,UAAU,iBAAiB;AACxC,MAAa,SAAS,iBAAiB;AACvC,MAAa,SAAS,iBAAiB;AACvC,MAAa,YAAY,iBAAiB;AAC1C,MAAa,MAAM,iBAAiB;AACpC,MAAa,KAAK,iBAAiB;AACnC,MAAa,QAAQ,iBAAiB;AACtC,MAAa,WAAW,iBAAiB;AACzC,MAAa,UAAU,iBAAiB;AACxC,MAAa,UAAU,iBAAiB"}
1
+ {"version":3,"file":"built.mjs","names":[],"sources":["../../src/built.ts"],"sourcesContent":["/**\n * @intlayer/config/built is a package that only returns the configuration file as a JSON object.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n */\n\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getConfiguration } from './configFile/getConfiguration';\nimport type { BuiltConfigKey } from './utils/builtConfigKeys';\n\nconst configuration: IntlayerConfig = getConfiguration();\n\nconst parsedJSONConfig: IntlayerConfig = JSON.parse(\n JSON.stringify(configuration)\n);\n\nexport const internationalization = parsedJSONConfig.internationalization;\nexport const dictionary = parsedJSONConfig.dictionary;\nexport const routing = parsedJSONConfig.routing;\nexport const content = parsedJSONConfig.content;\nexport const system = parsedJSONConfig.system;\nexport const editor = parsedJSONConfig.editor;\nexport const analytics = parsedJSONConfig.analytics;\nexport const log = parsedJSONConfig.log;\nexport const ai = parsedJSONConfig.ai;\nexport const build = parsedJSONConfig.build;\nexport const compiler = parsedJSONConfig.compiler;\nexport const schemas = parsedJSONConfig.schemas;\nexport const plugins = parsedJSONConfig.plugins;\n\n/**\n * Compile-time guard: the named exports above must cover exactly the canonical\n * {@link BuiltConfigKey} list that `generateConfigurationContent` emits into the\n * aliased `configuration.mjs`. Adding a key to `BUILT_CONFIG_KEYS` without\n * exporting it here (or vice versa) is a type error, keeping the runtime and\n * aliased build targets in lockstep.\n */\n({\n internationalization,\n dictionary,\n routing,\n content,\n system,\n editor,\n analytics,\n log,\n ai,\n build,\n compiler,\n schemas,\n plugins,\n}) satisfies Record<BuiltConfigKey, unknown>;\n"],"mappings":";;;AASA,MAAM,gBAAgC,iBAAiB;AAEvD,MAAM,mBAAmC,KAAK,MAC5C,KAAK,UAAU,aAAa,CAC9B;AAEA,MAAa,uBAAuB,iBAAiB;AACrD,MAAa,aAAa,iBAAiB;AAC3C,MAAa,UAAU,iBAAiB;AACxC,MAAa,UAAU,iBAAiB;AACxC,MAAa,SAAS,iBAAiB;AACvC,MAAa,SAAS,iBAAiB;AACvC,MAAa,YAAY,iBAAiB;AAC1C,MAAa,MAAM,iBAAiB;AACpC,MAAa,KAAK,iBAAiB;AACnC,MAAa,QAAQ,iBAAiB;AACtC,MAAa,WAAW,iBAAiB;AACzC,MAAa,UAAU,iBAAiB;AACxC,MAAa,UAAU,iBAAiB"}
@@ -1,7 +1,7 @@
1
1
  import { getAlias } from "../utils/alias.mjs";
2
2
  import { getConfiguration } from "../configFile/getConfiguration.mjs";
3
- import { getConfigEnvVars } from "../envVars/envVars.mjs";
4
3
  import { BundleLogger } from "./logBundle.mjs";
4
+ import { getConfigEnvVars } from "../envVars/envVars.mjs";
5
5
  import { isAbsolute, join, resolve } from "node:path";
6
6
  import { mkdir, rm, writeFile } from "node:fs/promises";
7
7
  import configPackageJson from "@intlayer/types/package.json" with { type: "json" };
@@ -2,9 +2,15 @@
2
2
  /**
3
3
  * Lingui — `@intlayer/lingui` compat adapter.
4
4
  *
5
- * Lingui is a single-catalog library: every message lives in the `messages`
6
- * dictionary and catalog keys are flat (a dotted id such as
7
- * `results-table.bundleSize` is one literal key, not a nested path).
5
+ * Lingui is a single-catalog library: the namespace lives *inside* the message
6
+ * id rather than in the file layout, so `i18n._('footer.github')` names both
7
+ * the group (`footer`) and the field (`github`).
8
+ *
9
+ * The adapter therefore addresses lingui catalogs by the id's first dot-segment,
10
+ * which lets a catalog split with `syncJSON({ splitKeys: 'key-prefix' })` resolve
11
+ * one small dictionary per call site instead of the whole catalog. None of these
12
+ * callers carries a namespace argument, so the optimize passes leave them to the
13
+ * runtime resolver and only the usage analysis reads the ids.
8
14
  *
9
15
  * `t` and `_` are generic names, so all lingui callers require an import from
10
16
  * a lingui module to participate in matching — this avoids false positives on
@@ -25,13 +31,9 @@ const LINGUI_CALLERS = [
25
31
  callerName: "useLingui",
26
32
  library: "lingui",
27
33
  importSources: LINGUI_IMPORT_SOURCES,
28
- namespaceSources: [{
29
- from: "fixed",
30
- value: "messages"
31
- }],
32
- translationFunction: "destructured-t",
33
- staticReplacement: "useDictionary",
34
- dynamicReplacement: "useDictionaryDynamic"
34
+ namespaceSources: [],
35
+ allowRootScope: true,
36
+ translationFunction: "destructured-t"
35
37
  },
36
38
  {
37
39
  callerName: "_",
@@ -39,12 +41,8 @@ const LINGUI_CALLERS = [
39
41
  importSources: LINGUI_IMPORT_SOURCES,
40
42
  requiresImport: true,
41
43
  matchAsMethod: true,
42
- namespaceSources: [{
43
- from: "fixed",
44
- value: "messages"
45
- }],
46
- translationFunction: "self",
47
- flatKey: true
44
+ namespaceSources: [{ from: "path-first-segment" }],
45
+ translationFunction: "self"
48
46
  },
49
47
  {
50
48
  callerName: "t",
@@ -53,12 +51,8 @@ const LINGUI_CALLERS = [
53
51
  requiresImport: true,
54
52
  matchAsMethod: true,
55
53
  matchAsTaggedTemplate: true,
56
- namespaceSources: [{
57
- from: "fixed",
58
- value: "messages"
59
- }],
60
- translationFunction: "self",
61
- flatKey: true
54
+ namespaceSources: [{ from: "path-first-segment" }],
55
+ translationFunction: "self"
62
56
  },
63
57
  {
64
58
  callerName: "Trans",
@@ -66,12 +60,8 @@ const LINGUI_CALLERS = [
66
60
  importSources: LINGUI_IMPORT_SOURCES,
67
61
  requiresImport: true,
68
62
  jsxIdAttribute: "id",
69
- namespaceSources: [{
70
- from: "fixed",
71
- value: "messages"
72
- }],
73
- translationFunction: "self",
74
- flatKey: true
63
+ namespaceSources: [{ from: "path-first-segment" }],
64
+ translationFunction: "self"
75
65
  }
76
66
  ];
77
67
 
@@ -1 +1 @@
1
- {"version":3,"file":"lingui.mjs","names":[],"sources":["../../../../src/callers/compat/lingui.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * Lingui — `@intlayer/lingui` compat adapter.\n *\n * Lingui is a single-catalog library: every message lives in the `messages`\n * dictionary and catalog keys are flat (a dotted id such as\n * `results-table.bundleSize` is one literal key, not a nested path).\n *\n * `t` and `_` are generic names, so all lingui callers require an import from\n * a lingui module to participate in matching — this avoids false positives on\n * unrelated `t()` helpers.\n *\n * Mirrors `compat/lingui/src/plugin/index.ts`.\n */\nconst LINGUI_IMPORT_SOURCES = [\n '@lingui/core',\n '@lingui/react',\n '@lingui/macro',\n '@lingui/core/macro',\n '@lingui/react/macro',\n '@intlayer/lingui',\n];\n\nexport const LINGUI_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useLingui',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n // `const { i18n, t, _ } = useLingui()` single-catalog hook, no\n // namespace argument: every call reads the `messages` dictionary.\n namespaceSources: [{ from: 'fixed', value: 'messages' }],\n translationFunction: 'destructured-t',\n staticReplacement: 'useDictionary',\n dynamicReplacement: 'useDictionaryDynamic',\n },\n {\n callerName: '_',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n requiresImport: true,\n // `i18n._('id')` and the destructured `const { _ } = useLingui()` form.\n matchAsMethod: true,\n namespaceSources: [{ from: 'fixed', value: 'messages' }],\n translationFunction: 'self',\n flatKey: true,\n },\n {\n callerName: 't',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n requiresImport: true,\n // `i18n.t('id')`, `t({ id: 'id' })` and the macro tagged template ``t`…` ``.\n matchAsMethod: true,\n matchAsTaggedTemplate: true,\n namespaceSources: [{ from: 'fixed', value: 'messages' }],\n translationFunction: 'self',\n flatKey: true,\n },\n {\n callerName: 'Trans',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n requiresImport: true,\n // <Trans id=\"home.title\" message=\"Welcome\" />\n jsxIdAttribute: 'id',\n namespaceSources: [{ from: 'fixed', value: 'messages' }],\n translationFunction: 'self',\n flatKey: true,\n },\n];\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,wBAAwB;CAC5B;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,iBAAqC;CAChD;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EAGf,kBAAkB,CAAC;GAAE,MAAM;GAAS,OAAO;EAAW,CAAC;EACvD,qBAAqB;EACrB,mBAAmB;EACnB,oBAAoB;CACtB;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,eAAe;EACf,kBAAkB,CAAC;GAAE,MAAM;GAAS,OAAO;EAAW,CAAC;EACvD,qBAAqB;EACrB,SAAS;CACX;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,eAAe;EACf,uBAAuB;EACvB,kBAAkB,CAAC;GAAE,MAAM;GAAS,OAAO;EAAW,CAAC;EACvD,qBAAqB;EACrB,SAAS;CACX;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,gBAAgB;EAChB,kBAAkB,CAAC;GAAE,MAAM;GAAS,OAAO;EAAW,CAAC;EACvD,qBAAqB;EACrB,SAAS;CACX;AACF"}
1
+ {"version":3,"file":"lingui.mjs","names":[],"sources":["../../../../src/callers/compat/lingui.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * Lingui — `@intlayer/lingui` compat adapter.\n *\n * Lingui is a single-catalog library: the namespace lives *inside* the message\n * id rather than in the file layout, so `i18n._('footer.github')` names both\n * the group (`footer`) and the field (`github`).\n *\n * The adapter therefore addresses lingui catalogs by the id's first dot-segment,\n * which lets a catalog split with `syncJSON({ splitKeys: 'key-prefix' })` resolve\n * one small dictionary per call site instead of the whole catalog. None of these\n * callers carries a namespace argument, so the optimize passes leave them to the\n * runtime resolver and only the usage analysis reads the ids.\n *\n * `t` and `_` are generic names, so all lingui callers require an import from\n * a lingui module to participate in matching — this avoids false positives on\n * unrelated `t()` helpers.\n *\n * Mirrors `compat/lingui/src/plugin/index.ts`.\n */\nconst LINGUI_IMPORT_SOURCES = [\n '@lingui/core',\n '@lingui/react',\n '@lingui/macro',\n '@lingui/core/macro',\n '@lingui/react/macro',\n '@intlayer/lingui',\n];\n\nexport const LINGUI_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useLingui',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n // `const { i18n, t, _ } = useLingui()` takes no namespace argument, so the\n // dictionary is only knowable from the ids passed to the returned\n // functions which the usage analysis reads and the optimize passes do not.\n namespaceSources: [],\n allowRootScope: true,\n translationFunction: 'destructured-t',\n },\n {\n callerName: '_',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n requiresImport: true,\n // `i18n._('id')` and the destructured `const { _ } = useLingui()` form.\n matchAsMethod: true,\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n {\n callerName: 't',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n requiresImport: true,\n // `i18n.t('id')`, `t({ id: 'id' })` and the macro tagged template ``t`…` ``.\n matchAsMethod: true,\n matchAsTaggedTemplate: true,\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n {\n callerName: 'Trans',\n library: 'lingui',\n importSources: LINGUI_IMPORT_SOURCES,\n requiresImport: true,\n // <Trans id=\"home.title\" message=\"Welcome\" />\n jsxIdAttribute: 'id',\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,wBAAwB;CAC5B;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,iBAAqC;CAChD;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EAIf,kBAAkB,CAAC;EACnB,gBAAgB;EAChB,qBAAqB;CACvB;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,eAAe;EACf,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;EACjD,qBAAqB;CACvB;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,eAAe;EACf,uBAAuB;EACvB,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;EACjD,qBAAqB;CACvB;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,gBAAgB;EAChB,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;EACjD,qBAAqB;CACvB;AACF"}
@@ -26,6 +26,7 @@ const REACT_I18NEXT_CALLERS = [{
26
26
  property: "keyPrefix"
27
27
  }],
28
28
  translationFunction: "destructured-t",
29
+ allowRootScope: true,
29
30
  staticReplacement: "useDictionary",
30
31
  dynamicReplacement: "useDictionaryDynamic"
31
32
  }, {
@@ -1 +1 @@
1
- {"version":3,"file":"reactI18next.mjs","names":[],"sources":["../../../../src/callers/compat/reactI18next.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * react-i18next / next-i18next — `@intlayer/react-i18next` and\n * `@intlayer/next-i18next` compat adapters (next-i18next re-exports the\n * react-i18next hook, so both libraries share the same callers).\n *\n * Mirrors `compat/react-i18next/src/plugin/index.ts` and\n * `compat/next-i18next/src/plugin/index.ts`.\n */\nexport const REACT_I18NEXT_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useTranslation',\n library: 'react-i18next',\n importSources: [\n 'react-i18next',\n 'next-i18next',\n '@intlayer/react-i18next',\n '@intlayer/next-i18next',\n ],\n namespaceSources: [{ from: 'argument', index: 0 }],\n keyPrefixSources: [\n { from: 'option', argumentIndex: 1, property: 'keyPrefix' },\n ],\n translationFunction: 'destructured-t',\n staticReplacement: 'useDictionary',\n dynamicReplacement: 'useDictionaryDynamic',\n },\n {\n callerName: 'Trans',\n library: 'react-i18next',\n importSources: [\n 'react-i18next',\n 'next-i18next',\n '@intlayer/react-i18next',\n '@intlayer/next-i18next',\n ],\n // <Trans ns=\"home\" i18nKey=\"richText\" /> — the namespace attribute is\n // optional; without it the analyser falls back to the single translator\n // namespace declared in the same file.\n jsxIdAttribute: 'i18nKey',\n jsxNamespaceAttribute: 'ns',\n namespaceSources: [],\n translationFunction: 'self',\n },\n];\n"],"mappings":";;;;;;;;;AAUA,MAAa,wBAA4C,CACvD;CACE,YAAY;CACZ,SAAS;CACT,eAAe;EACb;EACA;EACA;EACA;CACF;CACA,kBAAkB,CAAC;EAAE,MAAM;EAAY,OAAO;CAAE,CAAC;CACjD,kBAAkB,CAChB;EAAE,MAAM;EAAU,eAAe;EAAG,UAAU;CAAY,CAC5D;CACA,qBAAqB;CACrB,mBAAmB;CACnB,oBAAoB;AACtB,GACA;CACE,YAAY;CACZ,SAAS;CACT,eAAe;EACb;EACA;EACA;EACA;CACF;CAIA,gBAAgB;CAChB,uBAAuB;CACvB,kBAAkB,CAAC;CACnB,qBAAqB;AACvB,CACF"}
1
+ {"version":3,"file":"reactI18next.mjs","names":[],"sources":["../../../../src/callers/compat/reactI18next.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * react-i18next / next-i18next — `@intlayer/react-i18next` and\n * `@intlayer/next-i18next` compat adapters (next-i18next re-exports the\n * react-i18next hook, so both libraries share the same callers).\n *\n * Mirrors `compat/react-i18next/src/plugin/index.ts` and\n * `compat/next-i18next/src/plugin/index.ts`.\n */\nexport const REACT_I18NEXT_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useTranslation',\n library: 'react-i18next',\n importSources: [\n 'react-i18next',\n 'next-i18next',\n '@intlayer/react-i18next',\n '@intlayer/next-i18next',\n ],\n namespaceSources: [{ from: 'argument', index: 0 }],\n keyPrefixSources: [\n { from: 'option', argumentIndex: 1, property: 'keyPrefix' },\n ],\n translationFunction: 'destructured-t',\n allowRootScope: true,\n staticReplacement: 'useDictionary',\n dynamicReplacement: 'useDictionaryDynamic',\n },\n {\n callerName: 'Trans',\n library: 'react-i18next',\n importSources: [\n 'react-i18next',\n 'next-i18next',\n '@intlayer/react-i18next',\n '@intlayer/next-i18next',\n ],\n // <Trans ns=\"home\" i18nKey=\"richText\" /> — the namespace attribute is\n // optional; without it the analyser falls back to the single translator\n // namespace declared in the same file.\n jsxIdAttribute: 'i18nKey',\n jsxNamespaceAttribute: 'ns',\n namespaceSources: [],\n translationFunction: 'self',\n },\n];\n"],"mappings":";;;;;;;;;AAUA,MAAa,wBAA4C,CACvD;CACE,YAAY;CACZ,SAAS;CACT,eAAe;EACb;EACA;EACA;EACA;CACF;CACA,kBAAkB,CAAC;EAAE,MAAM;EAAY,OAAO;CAAE,CAAC;CACjD,kBAAkB,CAChB;EAAE,MAAM;EAAU,eAAe;EAAG,UAAU;CAAY,CAC5D;CACA,qBAAqB;CACrB,gBAAgB;CAChB,mBAAmB;CACnB,oBAAoB;AACtB,GACA;CACE,YAAY;CACZ,SAAS;CACT,eAAe;EACb;EACA;EACA;EACA;CACF;CAIA,gBAAgB;CAChB,uBAAuB;CACvB,kBAAkB,CAAC;CACnB,qBAAqB;AACvB,CACF"}
@@ -8,21 +8,32 @@
8
8
  *
9
9
  * Mirrors `compat/react-intl/src/plugin/index.ts`.
10
10
  */
11
- const REACT_INTL_CALLERS = [{
12
- callerName: "formatMessage",
13
- library: "react-intl",
14
- importSources: ["react-intl", "@intlayer/react-intl"],
15
- matchAsMethod: true,
16
- namespaceSources: [{ from: "path-first-segment" }],
17
- translationFunction: "self"
18
- }, {
19
- callerName: "FormattedMessage",
20
- library: "react-intl",
21
- importSources: ["react-intl", "@intlayer/react-intl"],
22
- jsxIdAttribute: "id",
23
- namespaceSources: [{ from: "path-first-segment" }],
24
- translationFunction: "self"
25
- }];
11
+ const REACT_INTL_CALLERS = [
12
+ {
13
+ callerName: "useIntl",
14
+ library: "react-intl",
15
+ importSources: ["react-intl", "@intlayer/react-intl"],
16
+ namespaceSources: [],
17
+ allowRootScope: true,
18
+ translationFunction: "destructured-t"
19
+ },
20
+ {
21
+ callerName: "formatMessage",
22
+ library: "react-intl",
23
+ importSources: ["react-intl", "@intlayer/react-intl"],
24
+ matchAsMethod: true,
25
+ namespaceSources: [{ from: "path-first-segment" }],
26
+ translationFunction: "self"
27
+ },
28
+ {
29
+ callerName: "FormattedMessage",
30
+ library: "react-intl",
31
+ importSources: ["react-intl", "@intlayer/react-intl"],
32
+ jsxIdAttribute: "id",
33
+ namespaceSources: [{ from: "path-first-segment" }],
34
+ translationFunction: "self"
35
+ }
36
+ ];
26
37
 
27
38
  //#endregion
28
39
  export { REACT_INTL_CALLERS };
@@ -1 +1 @@
1
- {"version":3,"file":"reactIntl.mjs","names":[],"sources":["../../../../src/callers/compat/reactIntl.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * react-intl (FormatJS) — `@intlayer/react-intl` compat adapter.\n *\n * The full dotted message id encodes both the dictionary key and the field\n * path: `formatMessage({ id: 'home.title' })` → dictionary `home`, field\n * `title`.\n *\n * Mirrors `compat/react-intl/src/plugin/index.ts`.\n */\nexport const REACT_INTL_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'formatMessage',\n library: 'react-intl',\n importSources: ['react-intl', '@intlayer/react-intl'],\n // Matches both `intl.formatMessage(...)` and the destructured\n // `const { formatMessage } = useIntl()` identifier form.\n matchAsMethod: true,\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n {\n callerName: 'FormattedMessage',\n library: 'react-intl',\n importSources: ['react-intl', '@intlayer/react-intl'],\n jsxIdAttribute: 'id',\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n];\n"],"mappings":";;;;;;;;;;AAWA,MAAa,qBAAyC,CACpD;CACE,YAAY;CACZ,SAAS;CACT,eAAe,CAAC,cAAc,sBAAsB;CAGpD,eAAe;CACf,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;CACjD,qBAAqB;AACvB,GACA;CACE,YAAY;CACZ,SAAS;CACT,eAAe,CAAC,cAAc,sBAAsB;CACpD,gBAAgB;CAChB,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;CACjD,qBAAqB;AACvB,CACF"}
1
+ {"version":3,"file":"reactIntl.mjs","names":[],"sources":["../../../../src/callers/compat/reactIntl.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * react-intl (FormatJS) — `@intlayer/react-intl` compat adapter.\n *\n * The full dotted message id encodes both the dictionary key and the field\n * path: `formatMessage({ id: 'home.title' })` → dictionary `home`, field\n * `title`.\n *\n * Mirrors `compat/react-intl/src/plugin/index.ts`.\n */\nexport const REACT_INTL_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useIntl',\n library: 'react-intl',\n importSources: ['react-intl', '@intlayer/react-intl'],\n namespaceSources: [],\n allowRootScope: true,\n translationFunction: 'destructured-t',\n },\n {\n callerName: 'formatMessage',\n library: 'react-intl',\n importSources: ['react-intl', '@intlayer/react-intl'],\n // Matches both `intl.formatMessage(...)` and the destructured\n // `const { formatMessage } = useIntl()` identifier form.\n matchAsMethod: true,\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n {\n callerName: 'FormattedMessage',\n library: 'react-intl',\n importSources: ['react-intl', '@intlayer/react-intl'],\n jsxIdAttribute: 'id',\n namespaceSources: [{ from: 'path-first-segment' }],\n translationFunction: 'self',\n },\n];\n"],"mappings":";;;;;;;;;;AAWA,MAAa,qBAAyC;CACpD;EACE,YAAY;EACZ,SAAS;EACT,eAAe,CAAC,cAAc,sBAAsB;EACpD,kBAAkB,CAAC;EACnB,gBAAgB;EAChB,qBAAqB;CACvB;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe,CAAC,cAAc,sBAAsB;EAGpD,eAAe;EACf,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;EACjD,qBAAqB;CACvB;CACA;EACE,YAAY;EACZ,SAAS;EACT,eAAe,CAAC,cAAc,sBAAsB;EACpD,gBAAgB;EAChB,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,CAAC;EACjD,qBAAqB;CACvB;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { BASE_CALLERS } from "./base.mjs";
2
- import { getRewritableCallers, toSwcExtraCallers } from "./transform.mjs";
2
+ import { getRewritableCallers, isRewritableCaller, toSwcExtraCallers } from "./transform.mjs";
3
3
  import { I18NEXT_CALLERS } from "./compat/i18next.mjs";
4
4
  import { LINGUI_CALLERS } from "./compat/lingui.mjs";
5
5
  import { NEXT_INTL_CALLERS } from "./compat/nextIntl.mjs";
@@ -68,5 +68,5 @@ const isCallerActive = (descriptor, fileImportSources) => {
68
68
  };
69
69
 
70
70
  //#endregion
71
- export { ALL_CALLERS, BASE_CALLERS, CALLERS_BY_NAME, COMPAT_CALLERS, I18NEXT_CALLERS, LINGUI_CALLERS, NEXT_INTL_CALLERS, REACT_I18NEXT_CALLERS, REACT_INTL_CALLERS, USE_INTL_CALLERS, VUE_I18N_CALLERS, getPositionalKeyCallerNames, getRewritableCallers, isCallerActive, toSwcExtraCallers };
71
+ export { ALL_CALLERS, BASE_CALLERS, CALLERS_BY_NAME, COMPAT_CALLERS, I18NEXT_CALLERS, LINGUI_CALLERS, NEXT_INTL_CALLERS, REACT_I18NEXT_CALLERS, REACT_INTL_CALLERS, USE_INTL_CALLERS, VUE_I18N_CALLERS, getPositionalKeyCallerNames, getRewritableCallers, isCallerActive, isRewritableCaller, toSwcExtraCallers };
72
72
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/callers/index.ts"],"sourcesContent":["import { BASE_CALLERS } from './base';\nimport { I18NEXT_CALLERS } from './compat/i18next';\nimport { LINGUI_CALLERS } from './compat/lingui';\nimport { NEXT_INTL_CALLERS } from './compat/nextIntl';\nimport { REACT_I18NEXT_CALLERS } from './compat/reactI18next';\nimport { REACT_INTL_CALLERS } from './compat/reactIntl';\nimport { USE_INTL_CALLERS } from './compat/useIntl';\nimport { VUE_I18N_CALLERS } from './compat/vueI18n';\nimport type { CallerDescriptor } from './types';\n\nexport { BASE_CALLERS } from './base';\nexport { I18NEXT_CALLERS } from './compat/i18next';\nexport { LINGUI_CALLERS } from './compat/lingui';\nexport { NEXT_INTL_CALLERS } from './compat/nextIntl';\nexport { REACT_I18NEXT_CALLERS } from './compat/reactI18next';\nexport { REACT_INTL_CALLERS } from './compat/reactIntl';\nexport { USE_INTL_CALLERS } from './compat/useIntl';\nexport { VUE_I18N_CALLERS } from './compat/vueI18n';\nexport {\n getRewritableCallers,\n type SwcExtraCallerConfig,\n toSwcExtraCallers,\n} from './transform';\nexport type {\n CallerDescriptor,\n CallerResultShape,\n CallerValueSource,\n} from './types';\n\n/**\n * Compat-adapter callers, grouped in one list. Each compat package's bundler\n * plugin injects its own slice (e.g. `REACT_I18NEXT_CALLERS`) into the build\n * pipeline; this aggregate exists for consumers that need every syntax at\n * once, such as the LSP.\n */\nexport const COMPAT_CALLERS: CallerDescriptor[] = [\n ...I18NEXT_CALLERS,\n ...REACT_I18NEXT_CALLERS,\n ...NEXT_INTL_CALLERS,\n ...USE_INTL_CALLERS,\n ...REACT_INTL_CALLERS,\n ...LINGUI_CALLERS,\n ...VUE_I18N_CALLERS,\n];\n\n/** Base + compat callers — the full registry the matchers run against. */\nexport const ALL_CALLERS: CallerDescriptor[] = [\n ...BASE_CALLERS,\n ...COMPAT_CALLERS,\n];\n\n/**\n * Descriptors indexed by caller name. A name can map to several descriptors\n * (e.g. `Trans` exists in both react-i18next and lingui with different\n * attributes); matchers try them in registry order.\n */\nexport const CALLERS_BY_NAME: Map<string, CallerDescriptor[]> = (() => {\n const byName = new Map<string, CallerDescriptor[]>();\n\n for (const descriptor of ALL_CALLERS) {\n const existing = byName.get(descriptor.callerName);\n\n if (existing) {\n existing.push(descriptor);\n } else {\n byName.set(descriptor.callerName, [descriptor]);\n }\n }\n\n return byName;\n})();\n\n/**\n * Caller names whose dictionary key can appear as a positional string literal\n * argument (`caller('key', …)` / `caller(locale, 'key', …)`). Used to build\n * text-search regexes over project source files (find-references) and the\n * completion trigger pattern. Callers whose key never appears positionally\n * (fixed namespace, options object, JSX-only) are excluded on purpose.\n */\nexport const getPositionalKeyCallerNames = (): string[] => {\n const names = new Set<string>();\n\n for (const descriptor of ALL_CALLERS) {\n const hasPositionalNamespace = descriptor.namespaceSources.some(\n (source) => source.from === 'argument'\n );\n\n if (hasPositionalNamespace) names.add(descriptor.callerName);\n }\n\n return [...names];\n};\n\n/**\n * Returns `true` when the descriptor may participate in matching for a file\n * importing from `importSources`. Descriptors flagged `requiresImport` only\n * activate when the file imports from one of their declared modules;\n * everything else is always active (results are still validated against the\n * project's dictionaries downstream).\n *\n * @param descriptor - The caller descriptor to gate.\n * @param fileImportSources - Module specifiers imported by the analysed file.\n */\nexport const isCallerActive = (\n descriptor: CallerDescriptor,\n fileImportSources: ReadonlySet<string>\n): boolean => {\n if (!descriptor.requiresImport) return true;\n\n return descriptor.importSources.some((source) =>\n fileImportSources.has(source)\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,MAAa,iBAAqC;CAChD,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACL;;AAGA,MAAa,cAAkC,CAC7C,GAAG,cACH,GAAG,cACL;;;;;;AAOA,MAAa,yBAA0D;CACrE,MAAM,yBAAS,IAAI,IAAgC;CAEnD,KAAK,MAAM,cAAc,aAAa;EACpC,MAAM,WAAW,OAAO,IAAI,WAAW,UAAU;EAEjD,IAAI,UACF,SAAS,KAAK,UAAU;OAExB,OAAO,IAAI,WAAW,YAAY,CAAC,UAAU,CAAC;CAElD;CAEA,OAAO;AACT,EAAC,CAAE;;;;;;;;AASH,MAAa,oCAA8C;CACzD,MAAM,wBAAQ,IAAI,IAAY;CAE9B,KAAK,MAAM,cAAc,aAKvB,IAJ+B,WAAW,iBAAiB,MACxD,WAAW,OAAO,SAAS,UAGL,GAAG,MAAM,IAAI,WAAW,UAAU;CAG7D,OAAO,CAAC,GAAG,KAAK;AAClB;;;;;;;;;;;AAYA,MAAa,kBACX,YACA,sBACY;CACZ,IAAI,CAAC,WAAW,gBAAgB,OAAO;CAEvC,OAAO,WAAW,cAAc,MAAM,WACpC,kBAAkB,IAAI,MAAM,CAC9B;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/callers/index.ts"],"sourcesContent":["import { BASE_CALLERS } from './base';\nimport { I18NEXT_CALLERS } from './compat/i18next';\nimport { LINGUI_CALLERS } from './compat/lingui';\nimport { NEXT_INTL_CALLERS } from './compat/nextIntl';\nimport { REACT_I18NEXT_CALLERS } from './compat/reactI18next';\nimport { REACT_INTL_CALLERS } from './compat/reactIntl';\nimport { USE_INTL_CALLERS } from './compat/useIntl';\nimport { VUE_I18N_CALLERS } from './compat/vueI18n';\nimport type { CallerDescriptor } from './types';\n\nexport { BASE_CALLERS } from './base';\nexport { I18NEXT_CALLERS } from './compat/i18next';\nexport { LINGUI_CALLERS } from './compat/lingui';\nexport { NEXT_INTL_CALLERS } from './compat/nextIntl';\nexport { REACT_I18NEXT_CALLERS } from './compat/reactI18next';\nexport { REACT_INTL_CALLERS } from './compat/reactIntl';\nexport { USE_INTL_CALLERS } from './compat/useIntl';\nexport { VUE_I18N_CALLERS } from './compat/vueI18n';\nexport {\n getRewritableCallers,\n isRewritableCaller,\n type SwcExtraCallerConfig,\n toSwcExtraCallers,\n} from './transform';\nexport type {\n CallerDescriptor,\n CallerResultShape,\n CallerValueSource,\n} from './types';\n\n/**\n * Compat-adapter callers, grouped in one list. Each compat package's bundler\n * plugin injects its own slice (e.g. `REACT_I18NEXT_CALLERS`) into the build\n * pipeline; this aggregate exists for consumers that need every syntax at\n * once, such as the LSP.\n */\nexport const COMPAT_CALLERS: CallerDescriptor[] = [\n ...I18NEXT_CALLERS,\n ...REACT_I18NEXT_CALLERS,\n ...NEXT_INTL_CALLERS,\n ...USE_INTL_CALLERS,\n ...REACT_INTL_CALLERS,\n ...LINGUI_CALLERS,\n ...VUE_I18N_CALLERS,\n];\n\n/** Base + compat callers — the full registry the matchers run against. */\nexport const ALL_CALLERS: CallerDescriptor[] = [\n ...BASE_CALLERS,\n ...COMPAT_CALLERS,\n];\n\n/**\n * Descriptors indexed by caller name. A name can map to several descriptors\n * (e.g. `Trans` exists in both react-i18next and lingui with different\n * attributes); matchers try them in registry order.\n */\nexport const CALLERS_BY_NAME: Map<string, CallerDescriptor[]> = (() => {\n const byName = new Map<string, CallerDescriptor[]>();\n\n for (const descriptor of ALL_CALLERS) {\n const existing = byName.get(descriptor.callerName);\n\n if (existing) {\n existing.push(descriptor);\n } else {\n byName.set(descriptor.callerName, [descriptor]);\n }\n }\n\n return byName;\n})();\n\n/**\n * Caller names whose dictionary key can appear as a positional string literal\n * argument (`caller('key', …)` / `caller(locale, 'key', …)`). Used to build\n * text-search regexes over project source files (find-references) and the\n * completion trigger pattern. Callers whose key never appears positionally\n * (fixed namespace, options object, JSX-only) are excluded on purpose.\n */\nexport const getPositionalKeyCallerNames = (): string[] => {\n const names = new Set<string>();\n\n for (const descriptor of ALL_CALLERS) {\n const hasPositionalNamespace = descriptor.namespaceSources.some(\n (source) => source.from === 'argument'\n );\n\n if (hasPositionalNamespace) names.add(descriptor.callerName);\n }\n\n return [...names];\n};\n\n/**\n * Returns `true` when the descriptor may participate in matching for a file\n * importing from `importSources`. Descriptors flagged `requiresImport` only\n * activate when the file imports from one of their declared modules;\n * everything else is always active (results are still validated against the\n * project's dictionaries downstream).\n *\n * @param descriptor - The caller descriptor to gate.\n * @param fileImportSources - Module specifiers imported by the analysed file.\n */\nexport const isCallerActive = (\n descriptor: CallerDescriptor,\n fileImportSources: ReadonlySet<string>\n): boolean => {\n if (!descriptor.requiresImport) return true;\n\n return descriptor.importSources.some((source) =>\n fileImportSources.has(source)\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAa,iBAAqC;CAChD,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACL;;AAGA,MAAa,cAAkC,CAC7C,GAAG,cACH,GAAG,cACL;;;;;;AAOA,MAAa,yBAA0D;CACrE,MAAM,yBAAS,IAAI,IAAgC;CAEnD,KAAK,MAAM,cAAc,aAAa;EACpC,MAAM,WAAW,OAAO,IAAI,WAAW,UAAU;EAEjD,IAAI,UACF,SAAS,KAAK,UAAU;OAExB,OAAO,IAAI,WAAW,YAAY,CAAC,UAAU,CAAC;CAElD;CAEA,OAAO;AACT,EAAC,CAAE;;;;;;;;AASH,MAAa,oCAA8C;CACzD,MAAM,wBAAQ,IAAI,IAAY;CAE9B,KAAK,MAAM,cAAc,aAKvB,IAJ+B,WAAW,iBAAiB,MACxD,WAAW,OAAO,SAAS,UAGL,GAAG,MAAM,IAAI,WAAW,UAAU;CAG7D,OAAO,CAAC,GAAG,KAAK;AAClB;;;;;;;;;;;AAYA,MAAa,kBACX,YACA,sBACY;CACZ,IAAI,CAAC,WAAW,gBAAgB,OAAO;CAEvC,OAAO,WAAW,cAAc,MAAM,WACpC,kBAAkB,IAAI,MAAM,CAC9B;AACF"}
@@ -1,23 +1,29 @@
1
1
  //#region src/callers/transform.ts
2
2
  /**
3
- * Returns the callers of a registry slice that the optimize pass can rewrite
4
- * at build time: plain imported functions carrying both replacement names.
3
+ * Whether the optimize pass can rewrite this caller's call sites at build time.
5
4
  *
6
- * Method-matched callers (`i18n.getFixedT`) and JSX components are excluded
7
- * their call sites cannot be re-pointed through an import specifier rename.
5
+ * Requires both replacement names and a call shape reachable through an import
6
+ * specifier rename. Method-matched callers (`i18n.getFixedT`, `intl.formatMessage`)
7
+ * and JSX components (`<Trans>`, `<FormattedMessage>`) are excluded — their call
8
+ * sites keep resolving through the runtime dictionary registry.
9
+ */
10
+ const isRewritableCaller = (descriptor) => descriptor.staticReplacement !== void 0 && descriptor.dynamicReplacement !== void 0 && descriptor.matchAsMethod !== true && descriptor.jsxIdAttribute === void 0;
11
+ /**
12
+ * Returns the callers of a registry slice that the optimize pass can rewrite
13
+ * at build time. See {@link isRewritableCaller}.
8
14
  */
9
- const getRewritableCallers = (descriptors) => descriptors.filter((descriptor) => descriptor.staticReplacement !== void 0 && descriptor.dynamicReplacement !== void 0 && descriptor.matchAsMethod !== true && descriptor.jsxIdAttribute === void 0);
15
+ const getRewritableCallers = (descriptors) => descriptors.filter(isRewritableCaller);
10
16
  const findSource = (sources, from) => sources.find((source) => source.from === from);
11
17
  /**
12
18
  * Serialises the rewritable callers of a registry slice into the
13
19
  * `@intlayer/swc` plugin wire format (`extraCallers` option).
14
20
  *
15
- * Callers whose namespace can only be derived per-message id
16
- * (`path-first-segment`) are skipped: the transform cannot bind a single
17
- * dictionary to the call site.
21
+ * A caller with no statically readable namespace source is dropped: the plugin
22
+ * binds a dictionary from an argument, an option property or a fixed value
23
+ * only, so forwarding it would emit a descriptor no call site can match.
18
24
  *
19
25
  * @param descriptors - Registry slice, e.g. `REACT_I18NEXT_CALLERS`.
20
- * @returns Configs ready to pass as `swcExtraCallers` / `extraCallers`.
26
+ * @returns Configs ready to pass as the plugin's `extraCallers` option.
21
27
  */
22
28
  const toSwcExtraCallers = (descriptors) => getRewritableCallers(descriptors).flatMap((descriptor) => {
23
29
  const argumentSource = findSource(descriptor.namespaceSources, "argument");
@@ -39,5 +45,5 @@ const toSwcExtraCallers = (descriptors) => getRewritableCallers(descriptors).fla
39
45
  });
40
46
 
41
47
  //#endregion
42
- export { getRewritableCallers, toSwcExtraCallers };
48
+ export { getRewritableCallers, isRewritableCaller, toSwcExtraCallers };
43
49
  //# sourceMappingURL=transform.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform.mjs","names":[],"sources":["../../../src/callers/transform.ts"],"sourcesContent":["import type { CallerDescriptor, CallerValueSource } from './types';\n\n/**\n * Wire format of an extra caller forwarded to the `@intlayer/swc` plugin.\n *\n * Field names mirror the serde attributes of `ExtraCallerConfig` in\n * `packages/@intlayer/swc/src/lib.rs` — both sides must stay in sync.\n */\nexport type SwcExtraCallerConfig = {\n /** The function name the user calls, e.g. `\"useTranslation\"`. */\n callerName: string;\n /** Module specifiers exporting the function (original + `@intlayer/*`). */\n importSources: string[];\n /**\n * Zero-based index of the positional argument holding the namespace string.\n * Omitted for fixed/option namespace callers.\n */\n namespaceArgIndex?: number;\n /**\n * Compile-time constant namespace — the dictionary ident is inserted as a\n * new first argument (lingui's `useLingui()`).\n */\n fixedNamespace?: string;\n /**\n * Namespace read from a property of an options-object argument — the\n * dictionary ident is inserted as a new first argument and the property is\n * rewritten to the key-prefix remainder (vue-i18n's `useI18n({ namespace })`).\n */\n namespaceOption?: { argumentIndex: number; property: string };\n /** Replacement function name for static import mode, e.g. `\"useDictionary\"`. */\n staticReplacement: string;\n /** Replacement function name for dynamic/fetch mode, e.g. `\"useDictionaryDynamic\"`. */\n dynamicReplacement: string;\n};\n\n/**\n * Returns the callers of a registry slice that the optimize pass can rewrite\n * at build time: plain imported functions carrying both replacement names.\n *\n * Method-matched callers (`i18n.getFixedT`) and JSX components are excluded —\n * their call sites cannot be re-pointed through an import specifier rename.\n */\nexport const getRewritableCallers = (\n descriptors: CallerDescriptor[]\n): CallerDescriptor[] =>\n descriptors.filter(\n (descriptor) =>\n descriptor.staticReplacement !== undefined &&\n descriptor.dynamicReplacement !== undefined &&\n descriptor.matchAsMethod !== true &&\n descriptor.jsxIdAttribute === undefined\n );\n\nconst findSource = <F extends CallerValueSource['from']>(\n sources: CallerValueSource[],\n from: F\n): Extract<CallerValueSource, { from: F }> | undefined =>\n sources.find(\n (source): source is Extract<CallerValueSource, { from: F }> =>\n source.from === from\n );\n\n/**\n * Serialises the rewritable callers of a registry slice into the\n * `@intlayer/swc` plugin wire format (`extraCallers` option).\n *\n * Callers whose namespace can only be derived per-message id\n * (`path-first-segment`) are skipped: the transform cannot bind a single\n * dictionary to the call site.\n *\n * @param descriptors - Registry slice, e.g. `REACT_I18NEXT_CALLERS`.\n * @returns Configs ready to pass as `swcExtraCallers` / `extraCallers`.\n */\nexport const toSwcExtraCallers = (\n descriptors: CallerDescriptor[]\n): SwcExtraCallerConfig[] =>\n getRewritableCallers(descriptors).flatMap((descriptor) => {\n const argumentSource = findSource(descriptor.namespaceSources, 'argument');\n const optionSource = findSource(descriptor.namespaceSources, 'option');\n const fixedSource = findSource(descriptor.namespaceSources, 'fixed');\n\n if (!argumentSource && !optionSource && !fixedSource) return [];\n\n return [\n {\n callerName: descriptor.callerName,\n importSources: descriptor.importSources,\n ...(argumentSource ? { namespaceArgIndex: argumentSource.index } : {}),\n ...(fixedSource ? { fixedNamespace: fixedSource.value } : {}),\n ...(optionSource\n ? {\n namespaceOption: {\n argumentIndex: optionSource.argumentIndex,\n property: optionSource.property,\n },\n }\n : {}),\n staticReplacement: descriptor.staticReplacement!,\n dynamicReplacement: descriptor.dynamicReplacement!,\n },\n ];\n });\n"],"mappings":";;;;;;;;AA0CA,MAAa,wBACX,gBAEA,YAAY,QACT,eACC,WAAW,sBAAsB,UACjC,WAAW,uBAAuB,UAClC,WAAW,kBAAkB,QAC7B,WAAW,mBAAmB,MAClC;AAEF,MAAM,cACJ,SACA,SAEA,QAAQ,MACL,WACC,OAAO,SAAS,IACpB;;;;;;;;;;;;AAaF,MAAa,qBACX,gBAEA,qBAAqB,WAAW,CAAC,CAAC,SAAS,eAAe;CACxD,MAAM,iBAAiB,WAAW,WAAW,kBAAkB,UAAU;CACzE,MAAM,eAAe,WAAW,WAAW,kBAAkB,QAAQ;CACrE,MAAM,cAAc,WAAW,WAAW,kBAAkB,OAAO;CAEnE,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,aAAa,OAAO,CAAC;CAE9D,OAAO,CACL;EACE,YAAY,WAAW;EACvB,eAAe,WAAW;EAC1B,GAAI,iBAAiB,EAAE,mBAAmB,eAAe,MAAM,IAAI,CAAC;EACpE,GAAI,cAAc,EAAE,gBAAgB,YAAY,MAAM,IAAI,CAAC;EAC3D,GAAI,eACA,EACE,iBAAiB;GACf,eAAe,aAAa;GAC5B,UAAU,aAAa;EACzB,EACF,IACA,CAAC;EACL,mBAAmB,WAAW;EAC9B,oBAAoB,WAAW;CACjC,CACF;AACF,CAAC"}
1
+ {"version":3,"file":"transform.mjs","names":[],"sources":["../../../src/callers/transform.ts"],"sourcesContent":["import type { CallerDescriptor, CallerValueSource } from './types';\n\n/**\n * Wire format of an extra caller forwarded to the `@intlayer/swc` plugin.\n *\n * Field names mirror the serde attributes of `ExtraCallerConfig` in\n * `packages/@intlayer/swc/src/lib.rs` — both sides must stay in sync.\n */\nexport type SwcExtraCallerConfig = {\n /** The function name the user calls, e.g. `\"useTranslation\"`. */\n callerName: string;\n /** Module specifiers exporting the function (original + `@intlayer/*`). */\n importSources: string[];\n /**\n * Zero-based index of the positional argument holding the namespace string.\n * Omitted for fixed/option namespace callers.\n */\n namespaceArgIndex?: number;\n /**\n * Compile-time constant namespace — the dictionary ident is inserted as a\n * new first argument (lingui's `useLingui()`).\n */\n fixedNamespace?: string;\n /**\n * Namespace read from a property of an options-object argument — the\n * dictionary ident is inserted as a new first argument and the property is\n * rewritten to the key-prefix remainder (vue-i18n's `useI18n({ namespace })`).\n */\n namespaceOption?: { argumentIndex: number; property: string };\n /** Replacement function name for static import mode, e.g. `\"useDictionary\"`. */\n staticReplacement: string;\n /** Replacement function name for dynamic/fetch mode, e.g. `\"useDictionaryDynamic\"`. */\n dynamicReplacement: string;\n};\n\n/**\n * Whether the optimize pass can rewrite this caller's call sites at build time.\n *\n * Requires both replacement names and a call shape reachable through an import\n * specifier rename. Method-matched callers (`i18n.getFixedT`, `intl.formatMessage`)\n * and JSX components (`<Trans>`, `<FormattedMessage>`) are excluded their call\n * sites keep resolving through the runtime dictionary registry.\n */\nexport const isRewritableCaller = (descriptor: CallerDescriptor): boolean =>\n descriptor.staticReplacement !== undefined &&\n descriptor.dynamicReplacement !== undefined &&\n descriptor.matchAsMethod !== true &&\n descriptor.jsxIdAttribute === undefined;\n\n/**\n * Returns the callers of a registry slice that the optimize pass can rewrite\n * at build time. See {@link isRewritableCaller}.\n */\nexport const getRewritableCallers = (\n descriptors: CallerDescriptor[]\n): CallerDescriptor[] => descriptors.filter(isRewritableCaller);\n\nconst findSource = <F extends CallerValueSource['from']>(\n sources: CallerValueSource[],\n from: F\n): Extract<CallerValueSource, { from: F }> | undefined =>\n sources.find(\n (source): source is Extract<CallerValueSource, { from: F }> =>\n source.from === from\n );\n\n/**\n * Serialises the rewritable callers of a registry slice into the\n * `@intlayer/swc` plugin wire format (`extraCallers` option).\n *\n * A caller with no statically readable namespace source is dropped: the plugin\n * binds a dictionary from an argument, an option property or a fixed value\n * only, so forwarding it would emit a descriptor no call site can match.\n *\n * @param descriptors - Registry slice, e.g. `REACT_I18NEXT_CALLERS`.\n * @returns Configs ready to pass as the plugin's `extraCallers` option.\n */\nexport const toSwcExtraCallers = (\n descriptors: CallerDescriptor[]\n): SwcExtraCallerConfig[] =>\n getRewritableCallers(descriptors).flatMap((descriptor) => {\n const argumentSource = findSource(descriptor.namespaceSources, 'argument');\n const optionSource = findSource(descriptor.namespaceSources, 'option');\n const fixedSource = findSource(descriptor.namespaceSources, 'fixed');\n\n if (!argumentSource && !optionSource && !fixedSource) return [];\n\n return [\n {\n callerName: descriptor.callerName,\n importSources: descriptor.importSources,\n ...(argumentSource ? { namespaceArgIndex: argumentSource.index } : {}),\n ...(fixedSource ? { fixedNamespace: fixedSource.value } : {}),\n ...(optionSource\n ? {\n namespaceOption: {\n argumentIndex: optionSource.argumentIndex,\n property: optionSource.property,\n },\n }\n : {}),\n staticReplacement: descriptor.staticReplacement!,\n dynamicReplacement: descriptor.dynamicReplacement!,\n },\n ];\n });\n"],"mappings":";;;;;;;;;AA2CA,MAAa,sBAAsB,eACjC,WAAW,sBAAsB,UACjC,WAAW,uBAAuB,UAClC,WAAW,kBAAkB,QAC7B,WAAW,mBAAmB;;;;;AAMhC,MAAa,wBACX,gBACuB,YAAY,OAAO,kBAAkB;AAE9D,MAAM,cACJ,SACA,SAEA,QAAQ,MACL,WACC,OAAO,SAAS,IACpB;;;;;;;;;;;;AAaF,MAAa,qBACX,gBAEA,qBAAqB,WAAW,CAAC,CAAC,SAAS,eAAe;CACxD,MAAM,iBAAiB,WAAW,WAAW,kBAAkB,UAAU;CACzE,MAAM,eAAe,WAAW,WAAW,kBAAkB,QAAQ;CACrE,MAAM,cAAc,WAAW,WAAW,kBAAkB,OAAO;CAEnE,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,aAAa,OAAO,CAAC;CAE9D,OAAO,CACL;EACE,YAAY,WAAW;EACvB,eAAe,WAAW;EAC1B,GAAI,iBAAiB,EAAE,mBAAmB,eAAe,MAAM,IAAI,CAAC;EACpE,GAAI,cAAc,EAAE,gBAAgB,YAAY,MAAM,IAAI,CAAC;EAC3D,GAAI,eACA,EACE,iBAAiB;GACf,eAAe,aAAa;GAC5B,UAAU,aAAa;EACzB,EACF,IACA,CAAC;EACL,mBAAmB,WAAW;EAC9B,oBAAoB,WAAW;CACjC,CACF;AACF,CAAC"}
@@ -3,18 +3,18 @@
3
3
  * @intlayer/config/built is a package that only returns the configuration file as a JSON object.
4
4
  * Using an external package allow to alias it in the bundle configuration (such as webpack).
5
5
  */
6
- export declare const internationalization: any;
7
- export declare const dictionary: any;
8
- export declare const routing: any;
9
- export declare const content: any;
10
- export declare const system: any;
11
- export declare const editor: any;
12
- export declare const analytics: any;
13
- export declare const log: any;
14
- export declare const ai: any;
15
- export declare const build: any;
16
- export declare const compiler: any;
17
- export declare const schemas: any;
18
- export declare const plugins: any;
6
+ export declare const internationalization: import("@intlayer/types/config").InternationalizationConfig;
7
+ export declare const dictionary: Partial<import("@intlayer/types/config").DictionaryConfig>;
8
+ export declare const routing: import("@intlayer/types/config").RoutingConfig;
9
+ export declare const content: import("@intlayer/types/config").ContentConfig;
10
+ export declare const system: import("@intlayer/types/config").SystemConfig;
11
+ export declare const editor: import("@intlayer/types/config").EditorConfig;
12
+ export declare const analytics: import("@intlayer/types/config").AnalyticsConfig;
13
+ export declare const log: import("@intlayer/types/config").LogConfig;
14
+ export declare const ai: Partial<import("@intlayer/types/config").AiConfig>;
15
+ export declare const build: import("@intlayer/types/config").BuildConfig;
16
+ export declare const compiler: import("@intlayer/types/config").CompilerConfig;
17
+ export declare const schemas: Record<string, import("@intlayer/types/config").ConfigSchema>;
18
+ export declare const plugins: import("@intlayer/types/plugin").Plugin[];
19
19
  //#endregion
20
20
  //# sourceMappingURL=built.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"built.d.ts","names":[],"sources":["../../src/built.ts"],"mappings":";;;;;qBAaa;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
1
+ {"version":3,"file":"built.d.ts","names":[],"sources":["../../src/built.ts"],"mappings":";;;;;qBAea,uDAAoB;qBACpB,YAAU,yCAAA;qBACV,0CAAO;qBACP,0CAAO;qBACP,yCAAM;qBACN,yCAAM;qBACN,4CAAS;qBACT,sCAAG;qBACH,IAAE,yCAAA;qBACF,wCAAK;qBACL,2CAAQ;qBACR,SAAO,gDAAA;qBACP,0CAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"lingui.d.ts","names":[],"sources":["../../../../src/callers/compat/lingui.ts"],"mappings":";;qBAwBa,gBAAgB"}
1
+ {"version":3,"file":"lingui.d.ts","names":[],"sources":["../../../../src/callers/compat/lingui.ts"],"mappings":";;qBA8Ba,gBAAgB"}
@@ -7,7 +7,7 @@ import { REACT_I18NEXT_CALLERS } from "./compat/reactI18next.js";
7
7
  import { REACT_INTL_CALLERS } from "./compat/reactIntl.js";
8
8
  import { USE_INTL_CALLERS } from "./compat/useIntl.js";
9
9
  import { VUE_I18N_CALLERS } from "./compat/vueI18n.js";
10
- import { SwcExtraCallerConfig, getRewritableCallers, toSwcExtraCallers } from "./transform.js";
10
+ import { SwcExtraCallerConfig, getRewritableCallers, isRewritableCaller, toSwcExtraCallers } from "./transform.js";
11
11
  //#region src/callers/index.d.ts
12
12
  /**
13
13
  * Compat-adapter callers, grouped in one list. Each compat package's bundler
@@ -44,5 +44,5 @@ export declare const getPositionalKeyCallerNames: () => string[];
44
44
  */
45
45
  export declare const isCallerActive: (descriptor: CallerDescriptor, fileImportSources: ReadonlySet<string>) => boolean;
46
46
  //#endregion
47
- export { BASE_CALLERS, type CallerDescriptor, type CallerResultShape, type CallerValueSource, I18NEXT_CALLERS, LINGUI_CALLERS, NEXT_INTL_CALLERS, REACT_I18NEXT_CALLERS, REACT_INTL_CALLERS, type SwcExtraCallerConfig, USE_INTL_CALLERS, VUE_I18N_CALLERS, getRewritableCallers, toSwcExtraCallers };
47
+ export { BASE_CALLERS, type CallerDescriptor, type CallerResultShape, type CallerValueSource, I18NEXT_CALLERS, LINGUI_CALLERS, NEXT_INTL_CALLERS, REACT_I18NEXT_CALLERS, REACT_INTL_CALLERS, type SwcExtraCallerConfig, USE_INTL_CALLERS, VUE_I18N_CALLERS, getRewritableCallers, isRewritableCaller, toSwcExtraCallers };
48
48
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/callers/index.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAmCa,gBAAgB;;qBAWhB,aAAa;;;;;;qBAUb,iBAAiB,YAAY;;;;;;;;qBAuB7B;;;;;;;;;;;qBAwBA,iBAAc,YACb,kBAAgB,mBACT"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/callers/index.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAoCa,gBAAgB;;qBAWhB,aAAa;;;;;;qBAUb,iBAAiB,YAAY;;;;;;;;qBAuB7B;;;;;;;;;;;qBAwBA,iBAAc,YACb,kBAAgB,mBACT"}
@@ -36,23 +36,29 @@ export type SwcExtraCallerConfig = {
36
36
  dynamicReplacement: string;
37
37
  };
38
38
  /**
39
- * Returns the callers of a registry slice that the optimize pass can rewrite
40
- * at build time: plain imported functions carrying both replacement names.
39
+ * Whether the optimize pass can rewrite this caller's call sites at build time.
41
40
  *
42
- * Method-matched callers (`i18n.getFixedT`) and JSX components are excluded
43
- * their call sites cannot be re-pointed through an import specifier rename.
41
+ * Requires both replacement names and a call shape reachable through an import
42
+ * specifier rename. Method-matched callers (`i18n.getFixedT`, `intl.formatMessage`)
43
+ * and JSX components (`<Trans>`, `<FormattedMessage>`) are excluded — their call
44
+ * sites keep resolving through the runtime dictionary registry.
45
+ */
46
+ export declare const isRewritableCaller: (descriptor: CallerDescriptor) => boolean;
47
+ /**
48
+ * Returns the callers of a registry slice that the optimize pass can rewrite
49
+ * at build time. See {@link isRewritableCaller}.
44
50
  */
45
51
  export declare const getRewritableCallers: (descriptors: CallerDescriptor[]) => CallerDescriptor[];
46
52
  /**
47
53
  * Serialises the rewritable callers of a registry slice into the
48
54
  * `@intlayer/swc` plugin wire format (`extraCallers` option).
49
55
  *
50
- * Callers whose namespace can only be derived per-message id
51
- * (`path-first-segment`) are skipped: the transform cannot bind a single
52
- * dictionary to the call site.
56
+ * A caller with no statically readable namespace source is dropped: the plugin
57
+ * binds a dictionary from an argument, an option property or a fixed value
58
+ * only, so forwarding it would emit a descriptor no call site can match.
53
59
  *
54
60
  * @param descriptors - Registry slice, e.g. `REACT_I18NEXT_CALLERS`.
55
- * @returns Configs ready to pass as `swcExtraCallers` / `extraCallers`.
61
+ * @returns Configs ready to pass as the plugin's `extraCallers` option.
56
62
  */
57
63
  export declare const toSwcExtraCallers: (descriptors: CallerDescriptor[]) => SwcExtraCallerConfig[];
58
64
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","names":[],"sources":["../../../src/callers/transform.ts"],"mappings":";;;;;;;;YAQY;;EAEV;;EAEA;;;;;EAKA;;;;;EAKA;;;;;;EAMA;IAAoB;IAAuB;;;EAE3C;;EAEA;;;;;;;;;qBAUW,uBAAoB,aAClB,uBACZ;;;;;;;;;;;;qBA6BU,oBAAiB,aACf,uBACZ"}
1
+ {"version":3,"file":"transform.d.ts","names":[],"sources":["../../../src/callers/transform.ts"],"mappings":";;;;;;;;YAQY;;EAEV;;EAEA;;;;;EAKA;;;;;EAKA;;;;;;EAMA;IAAoB;IAAuB;;;EAE3C;;EAEA;;;;;;;;;;qBAWW,qBAAkB,YAAgB;;;;;qBAUlC,uBAAoB,aAClB,uBACZ;;;;;;;;;;;;qBAsBU,oBAAiB,aACf,uBACZ"}
@@ -129,6 +129,12 @@ export type CallerDescriptor = {
129
129
  * When `true`, the caller may be invoked without any namespace
130
130
  * (`useTranslations()` root scope) — the dictionary key is then the first
131
131
  * dot-segment of each message id passed to the returned `t()`.
132
+ *
133
+ * Analysis-only: the LSP resolves such bindings for go-to-definition, and
134
+ * the ESLint rule stops reporting the missing argument as a dynamic key.
135
+ * The optimize passes do **not** honour it — a call with no readable
136
+ * namespace is left to the runtime registry, so declaring it never changes
137
+ * the emitted bundle.
132
138
  */
133
139
  allowRootScope?: boolean;
134
140
  /** How translated content is obtained from the caller's result. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/callers/types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;YAyBY;;;EAEN;EAAkB;;;;EAElB;EAAgB;EAAuB;;;;;;;EAKvC;EAAe;;;;;;;;EAMf;;;;;;;;;;;;;;;;;;YAkBM;;;;YAUA;;EAEV;;EAEA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;EAEA;;;;;;EAMA;;;;;EAKA;;;;;EAKA,kBAAkB;;;;;;EAMlB,mBAAmB;;;;;;;EAOnB;;;;;;EAMA;;EAEA,qBAAqB;;;;;;EAMrB;;;;;;;;;;EAUA;;;;;EAKA"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/callers/types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;YAyBY;;;EAEN;EAAkB;;;;EAElB;EAAgB;EAAuB;;;;;;;EAKvC;EAAe;;;;;;;;EAMf;;;;;;;;;;;;;;;;;;YAkBM;;;;YAUA;;EAEV;;EAEA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;EAEA;;;;;;EAMA;;;;;EAKA;;;;;EAKA,kBAAkB;;;;;;EAMlB,mBAAmB;;;;;;;EAOnB;;;;;;;;;;;;EAYA;;EAEA,qBAAqB;;;;;;EAMrB;;;;;;;;;;EAUA;;;;;EAKA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/config",
3
- "version": "9.4.4",
3
+ "version": "9.5.1",
4
4
  "private": false,
5
5
  "description": "Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.",
6
6
  "keywords": [
@@ -189,7 +189,7 @@
189
189
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
190
190
  },
191
191
  "dependencies": {
192
- "@intlayer/types": "9.4.4",
192
+ "@intlayer/types": "9.5.1",
193
193
  "defu": "6.1.7",
194
194
  "dotenv": "17.4.2",
195
195
  "esbuild": "0.28.2",
@@ -197,7 +197,7 @@
197
197
  "zod": "4.5.4"
198
198
  },
199
199
  "devDependencies": {
200
- "@types/node": "26.4.1",
200
+ "@types/node": "26.5.0",
201
201
  "@utils/ts-config": "1.0.4",
202
202
  "@utils/ts-config-types": "1.0.4",
203
203
  "@utils/tsdown-config": "1.0.4",