@intlayer/config 9.0.0-canary.11 → 9.0.0-canary.12

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 (67) hide show
  1. package/dist/cjs/bundle/index.cjs +1 -1
  2. package/dist/cjs/callers/base.cjs +42 -0
  3. package/dist/cjs/callers/base.cjs.map +1 -0
  4. package/dist/cjs/callers/compat/i18next.cjs +27 -0
  5. package/dist/cjs/callers/compat/i18next.cjs.map +1 -0
  6. package/dist/cjs/callers/compat/lingui.cjs +82 -0
  7. package/dist/cjs/callers/compat/lingui.cjs.map +1 -0
  8. package/dist/cjs/callers/compat/nextIntl.cjs +44 -0
  9. package/dist/cjs/callers/compat/nextIntl.cjs.map +1 -0
  10. package/dist/cjs/callers/compat/reactI18next.cjs +50 -0
  11. package/dist/cjs/callers/compat/reactI18next.cjs.map +1 -0
  12. package/dist/cjs/callers/compat/reactIntl.cjs +31 -0
  13. package/dist/cjs/callers/compat/reactIntl.cjs.map +1 -0
  14. package/dist/cjs/callers/compat/useIntl.cjs +46 -0
  15. package/dist/cjs/callers/compat/useIntl.cjs.map +1 -0
  16. package/dist/cjs/callers/compat/vueI18n.cjs +26 -0
  17. package/dist/cjs/callers/compat/vueI18n.cjs.map +1 -0
  18. package/dist/cjs/callers/index.cjs +87 -0
  19. package/dist/cjs/callers/index.cjs.map +1 -0
  20. package/dist/cjs/callers/transform.cjs +46 -0
  21. package/dist/cjs/callers/transform.cjs.map +1 -0
  22. package/dist/cjs/callers/types.cjs +0 -0
  23. package/dist/esm/callers/base.mjs +40 -0
  24. package/dist/esm/callers/base.mjs.map +1 -0
  25. package/dist/esm/callers/compat/i18next.mjs +25 -0
  26. package/dist/esm/callers/compat/i18next.mjs.map +1 -0
  27. package/dist/esm/callers/compat/lingui.mjs +80 -0
  28. package/dist/esm/callers/compat/lingui.mjs.map +1 -0
  29. package/dist/esm/callers/compat/nextIntl.mjs +42 -0
  30. package/dist/esm/callers/compat/nextIntl.mjs.map +1 -0
  31. package/dist/esm/callers/compat/reactI18next.mjs +48 -0
  32. package/dist/esm/callers/compat/reactI18next.mjs.map +1 -0
  33. package/dist/esm/callers/compat/reactIntl.mjs +29 -0
  34. package/dist/esm/callers/compat/reactIntl.mjs.map +1 -0
  35. package/dist/esm/callers/compat/useIntl.mjs +44 -0
  36. package/dist/esm/callers/compat/useIntl.mjs.map +1 -0
  37. package/dist/esm/callers/compat/vueI18n.mjs +24 -0
  38. package/dist/esm/callers/compat/vueI18n.mjs.map +1 -0
  39. package/dist/esm/callers/index.mjs +72 -0
  40. package/dist/esm/callers/index.mjs.map +1 -0
  41. package/dist/esm/callers/transform.mjs +43 -0
  42. package/dist/esm/callers/transform.mjs.map +1 -0
  43. package/dist/esm/callers/types.mjs +0 -0
  44. package/dist/types/callers/base.d.ts +14 -0
  45. package/dist/types/callers/base.d.ts.map +1 -0
  46. package/dist/types/callers/compat/i18next.d.ts +12 -0
  47. package/dist/types/callers/compat/i18next.d.ts.map +1 -0
  48. package/dist/types/callers/compat/lingui.d.ts +7 -0
  49. package/dist/types/callers/compat/lingui.d.ts.map +1 -0
  50. package/dist/types/callers/compat/nextIntl.d.ts +13 -0
  51. package/dist/types/callers/compat/nextIntl.d.ts.map +1 -0
  52. package/dist/types/callers/compat/reactI18next.d.ts +15 -0
  53. package/dist/types/callers/compat/reactI18next.d.ts.map +1 -0
  54. package/dist/types/callers/compat/reactIntl.d.ts +16 -0
  55. package/dist/types/callers/compat/reactIntl.d.ts.map +1 -0
  56. package/dist/types/callers/compat/useIntl.d.ts +12 -0
  57. package/dist/types/callers/compat/useIntl.d.ts.map +1 -0
  58. package/dist/types/callers/compat/vueI18n.d.ts +12 -0
  59. package/dist/types/callers/compat/vueI18n.d.ts.map +1 -0
  60. package/dist/types/callers/index.d.ts +49 -0
  61. package/dist/types/callers/index.d.ts.map +1 -0
  62. package/dist/types/callers/transform.d.ts +57 -0
  63. package/dist/types/callers/transform.d.ts.map +1 -0
  64. package/dist/types/callers/types.d.ts +152 -0
  65. package/dist/types/callers/types.d.ts.map +1 -0
  66. package/dist/types/configFile/configurationSchema.d.ts +2 -2
  67. package/package.json +7 -2
@@ -2,8 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
3
  const require_utils_alias = require('../utils/alias.cjs');
4
4
  const require_configFile_getConfiguration = require('../configFile/getConfiguration.cjs');
5
- const require_envVars_envVars = require('../envVars/envVars.cjs');
6
5
  const require_bundle_logBundle = require('./logBundle.cjs');
6
+ const require_envVars_envVars = require('../envVars/envVars.cjs');
7
7
  let node_path = require("node:path");
8
8
  let node_fs_promises = require("node:fs/promises");
9
9
  let _intlayer_types_package_json = require("@intlayer/types/package.json");
@@ -0,0 +1,42 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/callers/base.ts
4
+ /**
5
+ * Base intlayer getters — always active, independent of any compat library.
6
+ *
7
+ * Their result is the dictionary content object itself: fields are consumed
8
+ * through member access (`content.title`) or destructuring
9
+ * (`const { title } = useIntlayer('home')`).
10
+ */
11
+ const BASE_CALLERS = [{
12
+ callerName: "useIntlayer",
13
+ library: "intlayer",
14
+ importSources: [
15
+ "intlayer",
16
+ "react-intlayer",
17
+ "next-intlayer",
18
+ "vue-intlayer",
19
+ "svelte-intlayer",
20
+ "solid-intlayer",
21
+ "preact-intlayer",
22
+ "angular-intlayer"
23
+ ],
24
+ namespaceSources: [{
25
+ from: "argument",
26
+ index: 0
27
+ }],
28
+ translationFunction: "content"
29
+ }, {
30
+ callerName: "getIntlayer",
31
+ library: "intlayer",
32
+ importSources: ["intlayer", "@intlayer/core"],
33
+ namespaceSources: [{
34
+ from: "argument",
35
+ index: 0
36
+ }],
37
+ translationFunction: "content"
38
+ }];
39
+
40
+ //#endregion
41
+ exports.BASE_CALLERS = BASE_CALLERS;
42
+ //# sourceMappingURL=base.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.cjs","names":[],"sources":["../../../src/callers/base.ts"],"sourcesContent":["import type { CallerDescriptor } from './types';\n\n/**\n * Base intlayer getters — always active, independent of any compat library.\n *\n * Their result is the dictionary content object itself: fields are consumed\n * through member access (`content.title`) or destructuring\n * (`const { title } = useIntlayer('home')`).\n */\nexport const BASE_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useIntlayer',\n library: 'intlayer',\n importSources: [\n 'intlayer',\n 'react-intlayer',\n 'next-intlayer',\n 'vue-intlayer',\n 'svelte-intlayer',\n 'solid-intlayer',\n 'preact-intlayer',\n 'angular-intlayer',\n ],\n namespaceSources: [{ from: 'argument', index: 0 }],\n translationFunction: 'content',\n },\n {\n callerName: 'getIntlayer',\n library: 'intlayer',\n importSources: ['intlayer', '@intlayer/core'],\n namespaceSources: [{ from: 'argument', index: 0 }],\n translationFunction: 'content',\n },\n];\n"],"mappings":";;;;;;;;;;AASA,MAAa,eAAmC,CAC9C;CACE,YAAY;CACZ,SAAS;CACT,eAAe;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CACD,kBAAkB,CAAC;EAAE,MAAM;EAAY,OAAO;EAAG,CAAC;CAClD,qBAAqB;CACtB,EACD;CACE,YAAY;CACZ,SAAS;CACT,eAAe,CAAC,YAAY,iBAAiB;CAC7C,kBAAkB,CAAC;EAAE,MAAM;EAAY,OAAO;EAAG,CAAC;CAClD,qBAAqB;CACtB,CACF"}
@@ -0,0 +1,27 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/callers/compat/i18next.ts
4
+ /**
5
+ * i18next — `@intlayer/i18next` compat adapter.
6
+ *
7
+ * Mirrors `compat/i18next/src/plugin/index.ts` (`I18NEXT_COMPAT_CALLERS`).
8
+ */
9
+ const I18NEXT_CALLERS = [{
10
+ callerName: "getFixedT",
11
+ library: "i18next",
12
+ importSources: ["i18next", "@intlayer/i18next"],
13
+ matchAsMethod: true,
14
+ namespaceSources: [{
15
+ from: "argument",
16
+ index: 1
17
+ }],
18
+ keyPrefixSources: [{
19
+ from: "argument",
20
+ index: 2
21
+ }],
22
+ translationFunction: "return-value"
23
+ }];
24
+
25
+ //#endregion
26
+ exports.I18NEXT_CALLERS = I18NEXT_CALLERS;
27
+ //# sourceMappingURL=i18next.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18next.cjs","names":[],"sources":["../../../../src/callers/compat/i18next.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * i18next — `@intlayer/i18next` compat adapter.\n *\n * Mirrors `compat/i18next/src/plugin/index.ts` (`I18NEXT_COMPAT_CALLERS`).\n */\nexport const I18NEXT_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'getFixedT',\n library: 'i18next',\n importSources: ['i18next', '@intlayer/i18next'],\n // `i18n.getFixedT(...)` — instance method, never imported as a specifier.\n matchAsMethod: true,\n // Signature: getFixedT(locale, namespace, keyPrefix?)\n namespaceSources: [{ from: 'argument', index: 1 }],\n keyPrefixSources: [{ from: 'argument', index: 2 }],\n translationFunction: 'return-value',\n },\n];\n"],"mappings":";;;;;;;;AAOA,MAAa,kBAAsC,CACjD;CACE,YAAY;CACZ,SAAS;CACT,eAAe,CAAC,WAAW,oBAAoB;CAE/C,eAAe;CAEf,kBAAkB,CAAC;EAAE,MAAM;EAAY,OAAO;EAAG,CAAC;CAClD,kBAAkB,CAAC;EAAE,MAAM;EAAY,OAAO;EAAG,CAAC;CAClD,qBAAqB;CACtB,CACF"}
@@ -0,0 +1,82 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/callers/compat/lingui.ts
4
+ /**
5
+ * Lingui — `@intlayer/lingui` compat adapter.
6
+ *
7
+ * Lingui is a single-catalog library: every message lives in the `messages`
8
+ * dictionary and catalog keys are flat (a dotted id such as
9
+ * `results-table.bundleSize` is one literal key, not a nested path).
10
+ *
11
+ * `t` and `_` are generic names, so all lingui callers require an import from
12
+ * a lingui module to participate in matching — this avoids false positives on
13
+ * unrelated `t()` helpers.
14
+ *
15
+ * Mirrors `compat/lingui/src/plugin/index.ts`.
16
+ */
17
+ const LINGUI_IMPORT_SOURCES = [
18
+ "@lingui/core",
19
+ "@lingui/react",
20
+ "@lingui/macro",
21
+ "@lingui/core/macro",
22
+ "@lingui/react/macro",
23
+ "@intlayer/lingui"
24
+ ];
25
+ const LINGUI_CALLERS = [
26
+ {
27
+ callerName: "useLingui",
28
+ library: "lingui",
29
+ importSources: LINGUI_IMPORT_SOURCES,
30
+ namespaceSources: [{
31
+ from: "fixed",
32
+ value: "messages"
33
+ }],
34
+ translationFunction: "destructured-t",
35
+ staticReplacement: "useDictionary",
36
+ dynamicReplacement: "useDictionaryDynamic"
37
+ },
38
+ {
39
+ callerName: "_",
40
+ library: "lingui",
41
+ importSources: LINGUI_IMPORT_SOURCES,
42
+ requiresImport: true,
43
+ matchAsMethod: true,
44
+ namespaceSources: [{
45
+ from: "fixed",
46
+ value: "messages"
47
+ }],
48
+ translationFunction: "self",
49
+ flatKey: true
50
+ },
51
+ {
52
+ callerName: "t",
53
+ library: "lingui",
54
+ importSources: LINGUI_IMPORT_SOURCES,
55
+ requiresImport: true,
56
+ matchAsMethod: true,
57
+ matchAsTaggedTemplate: true,
58
+ namespaceSources: [{
59
+ from: "fixed",
60
+ value: "messages"
61
+ }],
62
+ translationFunction: "self",
63
+ flatKey: true
64
+ },
65
+ {
66
+ callerName: "Trans",
67
+ library: "lingui",
68
+ importSources: LINGUI_IMPORT_SOURCES,
69
+ requiresImport: true,
70
+ jsxIdAttribute: "id",
71
+ namespaceSources: [{
72
+ from: "fixed",
73
+ value: "messages"
74
+ }],
75
+ translationFunction: "self",
76
+ flatKey: true
77
+ }
78
+ ];
79
+
80
+ //#endregion
81
+ exports.LINGUI_CALLERS = LINGUI_CALLERS;
82
+ //# sourceMappingURL=lingui.cjs.map
@@ -0,0 +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;CACD;AAED,MAAa,iBAAqC;CAChD;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EAGf,kBAAkB,CAAC;GAAE,MAAM;GAAS,OAAO;GAAY,CAAC;EACxD,qBAAqB;EACrB,mBAAmB;EACnB,oBAAoB;EACrB;CACD;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,eAAe;EACf,kBAAkB,CAAC;GAAE,MAAM;GAAS,OAAO;GAAY,CAAC;EACxD,qBAAqB;EACrB,SAAS;EACV;CACD;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,eAAe;EACf,uBAAuB;EACvB,kBAAkB,CAAC;GAAE,MAAM;GAAS,OAAO;GAAY,CAAC;EACxD,qBAAqB;EACrB,SAAS;EACV;CACD;EACE,YAAY;EACZ,SAAS;EACT,eAAe;EACf,gBAAgB;EAEhB,gBAAgB;EAChB,kBAAkB,CAAC;GAAE,MAAM;GAAS,OAAO;GAAY,CAAC;EACxD,qBAAqB;EACrB,SAAS;EACV;CACF"}
@@ -0,0 +1,44 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/callers/compat/nextIntl.ts
4
+ /**
5
+ * next-intl — `@intlayer/next-intl` compat adapter.
6
+ *
7
+ * Mirrors `compat/next-intl/src/plugin/index.ts` (`NEXT_INTL_SWC_CALLERS`),
8
+ * adding the `getTranslations({ locale, namespace })` object overload.
9
+ */
10
+ const NEXT_INTL_CALLERS = [{
11
+ callerName: "useTranslations",
12
+ library: "next-intl",
13
+ importSources: ["next-intl", "@intlayer/next-intl"],
14
+ namespaceSources: [{
15
+ from: "argument",
16
+ index: 0
17
+ }],
18
+ translationFunction: "return-value",
19
+ nestedNamespace: true,
20
+ allowRootScope: true,
21
+ staticReplacement: "useDictionary",
22
+ dynamicReplacement: "useDictionaryDynamic"
23
+ }, {
24
+ callerName: "getTranslations",
25
+ library: "next-intl",
26
+ importSources: ["next-intl/server", "@intlayer/next-intl/server"],
27
+ namespaceSources: [{
28
+ from: "argument",
29
+ index: 0
30
+ }, {
31
+ from: "option",
32
+ argumentIndex: 0,
33
+ property: "namespace"
34
+ }],
35
+ translationFunction: "return-value",
36
+ nestedNamespace: true,
37
+ allowRootScope: true,
38
+ staticReplacement: "getDictionary",
39
+ dynamicReplacement: "getDictionaryDynamic"
40
+ }];
41
+
42
+ //#endregion
43
+ exports.NEXT_INTL_CALLERS = NEXT_INTL_CALLERS;
44
+ //# sourceMappingURL=nextIntl.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextIntl.cjs","names":[],"sources":["../../../../src/callers/compat/nextIntl.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * next-intl — `@intlayer/next-intl` compat adapter.\n *\n * Mirrors `compat/next-intl/src/plugin/index.ts` (`NEXT_INTL_SWC_CALLERS`),\n * adding the `getTranslations({ locale, namespace })` object overload.\n */\nexport const NEXT_INTL_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useTranslations',\n library: 'next-intl',\n importSources: ['next-intl', '@intlayer/next-intl'],\n namespaceSources: [{ from: 'argument', index: 0 }],\n translationFunction: 'return-value',\n // useTranslations('about.counter') → dictionary `about`, prefix `counter`\n nestedNamespace: true,\n // bare useTranslations() → first id segment is the dictionary\n allowRootScope: true,\n staticReplacement: 'useDictionary',\n dynamicReplacement: 'useDictionaryDynamic',\n },\n {\n callerName: 'getTranslations',\n library: 'next-intl',\n importSources: ['next-intl/server', '@intlayer/next-intl/server'],\n // Both overloads: getTranslations('ns') and\n // getTranslations({ locale, namespace: 'ns' }).\n namespaceSources: [\n { from: 'argument', index: 0 },\n { from: 'option', argumentIndex: 0, property: 'namespace' },\n ],\n translationFunction: 'return-value',\n nestedNamespace: true,\n allowRootScope: true,\n staticReplacement: 'getDictionary',\n dynamicReplacement: 'getDictionaryDynamic',\n },\n];\n"],"mappings":";;;;;;;;;AAQA,MAAa,oBAAwC,CACnD;CACE,YAAY;CACZ,SAAS;CACT,eAAe,CAAC,aAAa,sBAAsB;CACnD,kBAAkB,CAAC;EAAE,MAAM;EAAY,OAAO;EAAG,CAAC;CAClD,qBAAqB;CAErB,iBAAiB;CAEjB,gBAAgB;CAChB,mBAAmB;CACnB,oBAAoB;CACrB,EACD;CACE,YAAY;CACZ,SAAS;CACT,eAAe,CAAC,oBAAoB,6BAA6B;CAGjE,kBAAkB,CAChB;EAAE,MAAM;EAAY,OAAO;EAAG,EAC9B;EAAE,MAAM;EAAU,eAAe;EAAG,UAAU;EAAa,CAC5D;CACD,qBAAqB;CACrB,iBAAiB;CACjB,gBAAgB;CAChB,mBAAmB;CACnB,oBAAoB;CACrB,CACF"}
@@ -0,0 +1,50 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/callers/compat/reactI18next.ts
4
+ /**
5
+ * react-i18next / next-i18next — `@intlayer/react-i18next` and
6
+ * `@intlayer/next-i18next` compat adapters (next-i18next re-exports the
7
+ * react-i18next hook, so both libraries share the same callers).
8
+ *
9
+ * Mirrors `compat/react-i18next/src/plugin/index.ts` and
10
+ * `compat/next-i18next/src/plugin/index.ts`.
11
+ */
12
+ const REACT_I18NEXT_CALLERS = [{
13
+ callerName: "useTranslation",
14
+ library: "react-i18next",
15
+ importSources: [
16
+ "react-i18next",
17
+ "next-i18next",
18
+ "@intlayer/react-i18next",
19
+ "@intlayer/next-i18next"
20
+ ],
21
+ namespaceSources: [{
22
+ from: "argument",
23
+ index: 0
24
+ }],
25
+ keyPrefixSources: [{
26
+ from: "option",
27
+ argumentIndex: 1,
28
+ property: "keyPrefix"
29
+ }],
30
+ translationFunction: "destructured-t",
31
+ staticReplacement: "useDictionary",
32
+ dynamicReplacement: "useDictionaryDynamic"
33
+ }, {
34
+ callerName: "Trans",
35
+ library: "react-i18next",
36
+ importSources: [
37
+ "react-i18next",
38
+ "next-i18next",
39
+ "@intlayer/react-i18next",
40
+ "@intlayer/next-i18next"
41
+ ],
42
+ jsxIdAttribute: "i18nKey",
43
+ jsxNamespaceAttribute: "ns",
44
+ namespaceSources: [],
45
+ translationFunction: "self"
46
+ }];
47
+
48
+ //#endregion
49
+ exports.REACT_I18NEXT_CALLERS = REACT_I18NEXT_CALLERS;
50
+ //# sourceMappingURL=reactI18next.cjs.map
@@ -0,0 +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;EACD;CACD,kBAAkB,CAAC;EAAE,MAAM;EAAY,OAAO;EAAG,CAAC;CAClD,kBAAkB,CAChB;EAAE,MAAM;EAAU,eAAe;EAAG,UAAU;EAAa,CAC5D;CACD,qBAAqB;CACrB,mBAAmB;CACnB,oBAAoB;CACrB,EACD;CACE,YAAY;CACZ,SAAS;CACT,eAAe;EACb;EACA;EACA;EACA;EACD;CAID,gBAAgB;CAChB,uBAAuB;CACvB,kBAAkB,EAAE;CACpB,qBAAqB;CACtB,CACF"}
@@ -0,0 +1,31 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/callers/compat/reactIntl.ts
4
+ /**
5
+ * react-intl (FormatJS) — `@intlayer/react-intl` compat adapter.
6
+ *
7
+ * The full dotted message id encodes both the dictionary key and the field
8
+ * path: `formatMessage({ id: 'home.title' })` → dictionary `home`, field
9
+ * `title`.
10
+ *
11
+ * Mirrors `compat/react-intl/src/plugin/index.ts`.
12
+ */
13
+ const REACT_INTL_CALLERS = [{
14
+ callerName: "formatMessage",
15
+ library: "react-intl",
16
+ importSources: ["react-intl", "@intlayer/react-intl"],
17
+ matchAsMethod: true,
18
+ namespaceSources: [{ from: "path-first-segment" }],
19
+ translationFunction: "self"
20
+ }, {
21
+ callerName: "FormattedMessage",
22
+ library: "react-intl",
23
+ importSources: ["react-intl", "@intlayer/react-intl"],
24
+ jsxIdAttribute: "id",
25
+ namespaceSources: [{ from: "path-first-segment" }],
26
+ translationFunction: "self"
27
+ }];
28
+
29
+ //#endregion
30
+ exports.REACT_INTL_CALLERS = REACT_INTL_CALLERS;
31
+ //# sourceMappingURL=reactIntl.cjs.map
@@ -0,0 +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,uBAAuB;CAGrD,eAAe;CACf,kBAAkB,CAAC,EAAE,MAAM,sBAAsB,CAAC;CAClD,qBAAqB;CACtB,EACD;CACE,YAAY;CACZ,SAAS;CACT,eAAe,CAAC,cAAc,uBAAuB;CACrD,gBAAgB;CAChB,kBAAkB,CAAC,EAAE,MAAM,sBAAsB,CAAC;CAClD,qBAAqB;CACtB,CACF"}
@@ -0,0 +1,46 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/callers/compat/useIntl.ts
4
+ /**
5
+ * use-intl — `@intlayer/use-intl` compat adapter.
6
+ *
7
+ * Mirrors `compat/use-intl/src/plugin/index.ts`.
8
+ */
9
+ const USE_INTL_CALLERS = [{
10
+ callerName: "useTranslations",
11
+ library: "use-intl",
12
+ importSources: [
13
+ "use-intl",
14
+ "use-intl/react",
15
+ "@intlayer/use-intl"
16
+ ],
17
+ namespaceSources: [{
18
+ from: "argument",
19
+ index: 0
20
+ }],
21
+ translationFunction: "return-value",
22
+ nestedNamespace: true,
23
+ allowRootScope: true,
24
+ staticReplacement: "useDictionary",
25
+ dynamicReplacement: "useDictionaryDynamic"
26
+ }, {
27
+ callerName: "createTranslator",
28
+ library: "use-intl",
29
+ importSources: [
30
+ "use-intl",
31
+ "use-intl/core",
32
+ "@intlayer/use-intl"
33
+ ],
34
+ namespaceSources: [{
35
+ from: "option",
36
+ argumentIndex: 0,
37
+ property: "namespace"
38
+ }],
39
+ translationFunction: "return-value",
40
+ nestedNamespace: true,
41
+ allowRootScope: true
42
+ }];
43
+
44
+ //#endregion
45
+ exports.USE_INTL_CALLERS = USE_INTL_CALLERS;
46
+ //# sourceMappingURL=useIntl.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIntl.cjs","names":[],"sources":["../../../../src/callers/compat/useIntl.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * use-intl — `@intlayer/use-intl` compat adapter.\n *\n * Mirrors `compat/use-intl/src/plugin/index.ts`.\n */\nexport const USE_INTL_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useTranslations',\n library: 'use-intl',\n importSources: ['use-intl', 'use-intl/react', '@intlayer/use-intl'],\n namespaceSources: [{ from: 'argument', index: 0 }],\n translationFunction: 'return-value',\n // Same namespace semantics as next-intl (next-intl re-exports use-intl).\n nestedNamespace: true,\n allowRootScope: true,\n staticReplacement: 'useDictionary',\n dynamicReplacement: 'useDictionaryDynamic',\n },\n {\n callerName: 'createTranslator',\n library: 'use-intl',\n importSources: ['use-intl', 'use-intl/core', '@intlayer/use-intl'],\n namespaceSources: [\n { from: 'option', argumentIndex: 0, property: 'namespace' },\n ],\n translationFunction: 'return-value',\n nestedNamespace: true,\n allowRootScope: true,\n },\n];\n"],"mappings":";;;;;;;;AAOA,MAAa,mBAAuC,CAClD;CACE,YAAY;CACZ,SAAS;CACT,eAAe;EAAC;EAAY;EAAkB;EAAqB;CACnE,kBAAkB,CAAC;EAAE,MAAM;EAAY,OAAO;EAAG,CAAC;CAClD,qBAAqB;CAErB,iBAAiB;CACjB,gBAAgB;CAChB,mBAAmB;CACnB,oBAAoB;CACrB,EACD;CACE,YAAY;CACZ,SAAS;CACT,eAAe;EAAC;EAAY;EAAiB;EAAqB;CAClE,kBAAkB,CAChB;EAAE,MAAM;EAAU,eAAe;EAAG,UAAU;EAAa,CAC5D;CACD,qBAAqB;CACrB,iBAAiB;CACjB,gBAAgB;CACjB,CACF"}
@@ -0,0 +1,26 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/callers/compat/vueI18n.ts
4
+ /**
5
+ * vue-i18n — `@intlayer/vue-i18n` compat adapter.
6
+ *
7
+ * Mirrors `compat/vue-i18n/src/plugin/index.ts`.
8
+ */
9
+ const VUE_I18N_CALLERS = [{
10
+ callerName: "useI18n",
11
+ library: "vue-i18n",
12
+ importSources: ["vue-i18n", "@intlayer/vue-i18n"],
13
+ namespaceSources: [{
14
+ from: "option",
15
+ argumentIndex: 0,
16
+ property: "namespace"
17
+ }],
18
+ translationFunction: "destructured-t",
19
+ allowRootScope: true,
20
+ staticReplacement: "useDictionary",
21
+ dynamicReplacement: "useDictionaryDynamic"
22
+ }];
23
+
24
+ //#endregion
25
+ exports.VUE_I18N_CALLERS = VUE_I18N_CALLERS;
26
+ //# sourceMappingURL=vueI18n.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vueI18n.cjs","names":[],"sources":["../../../../src/callers/compat/vueI18n.ts"],"sourcesContent":["import type { CallerDescriptor } from '../types';\n\n/**\n * vue-i18n — `@intlayer/vue-i18n` compat adapter.\n *\n * Mirrors `compat/vue-i18n/src/plugin/index.ts`.\n */\nexport const VUE_I18N_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useI18n',\n library: 'vue-i18n',\n importSources: ['vue-i18n', '@intlayer/vue-i18n'],\n // `const { t } = useI18n({ namespace: 'ns' })` — the namespace is an\n // intlayer extension of vue-i18n's options object.\n namespaceSources: [\n { from: 'option', argumentIndex: 0, property: 'namespace' },\n ],\n translationFunction: 'destructured-t',\n // Bare `useI18n()` resolves the first key segment as the dictionary:\n // `t('footer.github')` → dictionary `footer`, field `github`.\n allowRootScope: true,\n staticReplacement: 'useDictionary',\n dynamicReplacement: 'useDictionaryDynamic',\n },\n];\n"],"mappings":";;;;;;;;AAOA,MAAa,mBAAuC,CAClD;CACE,YAAY;CACZ,SAAS;CACT,eAAe,CAAC,YAAY,qBAAqB;CAGjD,kBAAkB,CAChB;EAAE,MAAM;EAAU,eAAe;EAAG,UAAU;EAAa,CAC5D;CACD,qBAAqB;CAGrB,gBAAgB;CAChB,mBAAmB;CACnB,oBAAoB;CACrB,CACF"}
@@ -0,0 +1,87 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_callers_base = require('./base.cjs');
3
+ const require_callers_transform = require('./transform.cjs');
4
+ const require_callers_compat_i18next = require('./compat/i18next.cjs');
5
+ const require_callers_compat_lingui = require('./compat/lingui.cjs');
6
+ const require_callers_compat_nextIntl = require('./compat/nextIntl.cjs');
7
+ const require_callers_compat_reactI18next = require('./compat/reactI18next.cjs');
8
+ const require_callers_compat_reactIntl = require('./compat/reactIntl.cjs');
9
+ const require_callers_compat_useIntl = require('./compat/useIntl.cjs');
10
+ const require_callers_compat_vueI18n = require('./compat/vueI18n.cjs');
11
+
12
+ //#region src/callers/index.ts
13
+ /**
14
+ * Compat-adapter callers, grouped in one list. Each compat package's bundler
15
+ * plugin injects its own slice (e.g. `REACT_I18NEXT_CALLERS`) into the build
16
+ * pipeline; this aggregate exists for consumers that need every syntax at
17
+ * once, such as the LSP.
18
+ */
19
+ const COMPAT_CALLERS = [
20
+ ...require_callers_compat_i18next.I18NEXT_CALLERS,
21
+ ...require_callers_compat_reactI18next.REACT_I18NEXT_CALLERS,
22
+ ...require_callers_compat_nextIntl.NEXT_INTL_CALLERS,
23
+ ...require_callers_compat_useIntl.USE_INTL_CALLERS,
24
+ ...require_callers_compat_reactIntl.REACT_INTL_CALLERS,
25
+ ...require_callers_compat_lingui.LINGUI_CALLERS,
26
+ ...require_callers_compat_vueI18n.VUE_I18N_CALLERS
27
+ ];
28
+ /** Base + compat callers — the full registry the matchers run against. */
29
+ const ALL_CALLERS = [...require_callers_base.BASE_CALLERS, ...COMPAT_CALLERS];
30
+ /**
31
+ * Descriptors indexed by caller name. A name can map to several descriptors
32
+ * (e.g. `Trans` exists in both react-i18next and lingui with different
33
+ * attributes); matchers try them in registry order.
34
+ */
35
+ const CALLERS_BY_NAME = (() => {
36
+ const byName = /* @__PURE__ */ new Map();
37
+ for (const descriptor of ALL_CALLERS) {
38
+ const existing = byName.get(descriptor.callerName);
39
+ if (existing) existing.push(descriptor);
40
+ else byName.set(descriptor.callerName, [descriptor]);
41
+ }
42
+ return byName;
43
+ })();
44
+ /**
45
+ * Caller names whose dictionary key can appear as a positional string literal
46
+ * argument (`caller('key', …)` / `caller(locale, 'key', …)`). Used to build
47
+ * text-search regexes over project source files (find-references) and the
48
+ * completion trigger pattern. Callers whose key never appears positionally
49
+ * (fixed namespace, options object, JSX-only) are excluded on purpose.
50
+ */
51
+ const getPositionalKeyCallerNames = () => {
52
+ const names = /* @__PURE__ */ new Set();
53
+ for (const descriptor of ALL_CALLERS) if (descriptor.namespaceSources.some((source) => source.from === "argument")) names.add(descriptor.callerName);
54
+ return [...names];
55
+ };
56
+ /**
57
+ * Returns `true` when the descriptor may participate in matching for a file
58
+ * importing from `importSources`. Descriptors flagged `requiresImport` only
59
+ * activate when the file imports from one of their declared modules;
60
+ * everything else is always active (results are still validated against the
61
+ * project's dictionaries downstream).
62
+ *
63
+ * @param descriptor - The caller descriptor to gate.
64
+ * @param fileImportSources - Module specifiers imported by the analysed file.
65
+ */
66
+ const isCallerActive = (descriptor, fileImportSources) => {
67
+ if (!descriptor.requiresImport) return true;
68
+ return descriptor.importSources.some((source) => fileImportSources.has(source));
69
+ };
70
+
71
+ //#endregion
72
+ exports.ALL_CALLERS = ALL_CALLERS;
73
+ exports.BASE_CALLERS = require_callers_base.BASE_CALLERS;
74
+ exports.CALLERS_BY_NAME = CALLERS_BY_NAME;
75
+ exports.COMPAT_CALLERS = COMPAT_CALLERS;
76
+ exports.I18NEXT_CALLERS = require_callers_compat_i18next.I18NEXT_CALLERS;
77
+ exports.LINGUI_CALLERS = require_callers_compat_lingui.LINGUI_CALLERS;
78
+ exports.NEXT_INTL_CALLERS = require_callers_compat_nextIntl.NEXT_INTL_CALLERS;
79
+ exports.REACT_I18NEXT_CALLERS = require_callers_compat_reactI18next.REACT_I18NEXT_CALLERS;
80
+ exports.REACT_INTL_CALLERS = require_callers_compat_reactIntl.REACT_INTL_CALLERS;
81
+ exports.USE_INTL_CALLERS = require_callers_compat_useIntl.USE_INTL_CALLERS;
82
+ exports.VUE_I18N_CALLERS = require_callers_compat_vueI18n.VUE_I18N_CALLERS;
83
+ exports.getPositionalKeyCallerNames = getPositionalKeyCallerNames;
84
+ exports.getRewritableCallers = require_callers_transform.getRewritableCallers;
85
+ exports.isCallerActive = isCallerActive;
86
+ exports.toSwcExtraCallers = require_callers_transform.toSwcExtraCallers;
87
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +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;CACJ;;AAGD,MAAa,cAAkC,CAC7C,GAAGC,mCACH,GAAG,eACJ;;;;;;AAOD,MAAa,yBAA0D;CACrE,MAAM,yBAAS,IAAI,KAAiC;AAEpD,MAAK,MAAM,cAAc,aAAa;EACpC,MAAM,WAAW,OAAO,IAAI,WAAW,WAAW;AAElD,MAAI,SACF,UAAS,KAAK,WAAW;MAEzB,QAAO,IAAI,WAAW,YAAY,CAAC,WAAW,CAAC;;AAInD,QAAO;IACL;;;;;;;;AASJ,MAAa,oCAA8C;CACzD,MAAM,wBAAQ,IAAI,KAAa;AAE/B,MAAK,MAAM,cAAc,YAKvB,KAJ+B,WAAW,iBAAiB,MACxD,WAAW,OAAO,SAAS,WAGJ,CAAE,OAAM,IAAI,WAAW,WAAW;AAG9D,QAAO,CAAC,GAAG,MAAM;;;;;;;;;;;;AAanB,MAAa,kBACX,YACA,sBACY;AACZ,KAAI,CAAC,WAAW,eAAgB,QAAO;AAEvC,QAAO,WAAW,cAAc,MAAM,WACpC,kBAAkB,IAAI,OAAO,CAC9B"}
@@ -0,0 +1,46 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/callers/transform.ts
4
+ /**
5
+ * Returns the callers of a registry slice that the optimize pass can rewrite
6
+ * at build time: plain imported functions carrying both replacement names.
7
+ *
8
+ * Method-matched callers (`i18n.getFixedT`) and JSX components are excluded —
9
+ * their call sites cannot be re-pointed through an import specifier rename.
10
+ */
11
+ const getRewritableCallers = (descriptors) => descriptors.filter((descriptor) => descriptor.staticReplacement !== void 0 && descriptor.dynamicReplacement !== void 0 && descriptor.matchAsMethod !== true && descriptor.jsxIdAttribute === void 0);
12
+ const findSource = (sources, from) => sources.find((source) => source.from === from);
13
+ /**
14
+ * Serialises the rewritable callers of a registry slice into the
15
+ * `@intlayer/swc` plugin wire format (`extraCallers` option).
16
+ *
17
+ * Callers whose namespace can only be derived per-message id
18
+ * (`path-first-segment`) are skipped: the transform cannot bind a single
19
+ * dictionary to the call site.
20
+ *
21
+ * @param descriptors - Registry slice, e.g. `REACT_I18NEXT_CALLERS`.
22
+ * @returns Configs ready to pass as `swcExtraCallers` / `extraCallers`.
23
+ */
24
+ const toSwcExtraCallers = (descriptors) => getRewritableCallers(descriptors).flatMap((descriptor) => {
25
+ const argumentSource = findSource(descriptor.namespaceSources, "argument");
26
+ const optionSource = findSource(descriptor.namespaceSources, "option");
27
+ const fixedSource = findSource(descriptor.namespaceSources, "fixed");
28
+ if (!argumentSource && !optionSource && !fixedSource) return [];
29
+ return [{
30
+ callerName: descriptor.callerName,
31
+ importSources: descriptor.importSources,
32
+ ...argumentSource ? { namespaceArgIndex: argumentSource.index } : {},
33
+ ...fixedSource ? { fixedNamespace: fixedSource.value } : {},
34
+ ...optionSource ? { namespaceOption: {
35
+ argumentIndex: optionSource.argumentIndex,
36
+ property: optionSource.property
37
+ } } : {},
38
+ staticReplacement: descriptor.staticReplacement,
39
+ dynamicReplacement: descriptor.dynamicReplacement
40
+ }];
41
+ });
42
+
43
+ //#endregion
44
+ exports.getRewritableCallers = getRewritableCallers;
45
+ exports.toSwcExtraCallers = toSwcExtraCallers;
46
+ //# sourceMappingURL=transform.cjs.map
@@ -0,0 +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,OACjC;AAEH,MAAM,cACJ,SACA,SAEA,QAAQ,MACL,WACC,OAAO,SAAS,KACnB;;;;;;;;;;;;AAaH,MAAa,qBACX,gBAEA,qBAAqB,YAAY,CAAC,SAAS,eAAe;CACxD,MAAM,iBAAiB,WAAW,WAAW,kBAAkB,WAAW;CAC1E,MAAM,eAAe,WAAW,WAAW,kBAAkB,SAAS;CACtE,MAAM,cAAc,WAAW,WAAW,kBAAkB,QAAQ;AAEpE,KAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,YAAa,QAAO,EAAE;AAE/D,QAAO,CACL;EACE,YAAY,WAAW;EACvB,eAAe,WAAW;EAC1B,GAAI,iBAAiB,EAAE,mBAAmB,eAAe,OAAO,GAAG,EAAE;EACrE,GAAI,cAAc,EAAE,gBAAgB,YAAY,OAAO,GAAG,EAAE;EAC5D,GAAI,eACA,EACE,iBAAiB;GACf,eAAe,aAAa;GAC5B,UAAU,aAAa;GACxB,EACF,GACD,EAAE;EACN,mBAAmB,WAAW;EAC9B,oBAAoB,WAAW;EAChC,CACF;EACD"}
File without changes
@@ -0,0 +1,40 @@
1
+ //#region src/callers/base.ts
2
+ /**
3
+ * Base intlayer getters — always active, independent of any compat library.
4
+ *
5
+ * Their result is the dictionary content object itself: fields are consumed
6
+ * through member access (`content.title`) or destructuring
7
+ * (`const { title } = useIntlayer('home')`).
8
+ */
9
+ const BASE_CALLERS = [{
10
+ callerName: "useIntlayer",
11
+ library: "intlayer",
12
+ importSources: [
13
+ "intlayer",
14
+ "react-intlayer",
15
+ "next-intlayer",
16
+ "vue-intlayer",
17
+ "svelte-intlayer",
18
+ "solid-intlayer",
19
+ "preact-intlayer",
20
+ "angular-intlayer"
21
+ ],
22
+ namespaceSources: [{
23
+ from: "argument",
24
+ index: 0
25
+ }],
26
+ translationFunction: "content"
27
+ }, {
28
+ callerName: "getIntlayer",
29
+ library: "intlayer",
30
+ importSources: ["intlayer", "@intlayer/core"],
31
+ namespaceSources: [{
32
+ from: "argument",
33
+ index: 0
34
+ }],
35
+ translationFunction: "content"
36
+ }];
37
+
38
+ //#endregion
39
+ export { BASE_CALLERS };
40
+ //# sourceMappingURL=base.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.mjs","names":[],"sources":["../../../src/callers/base.ts"],"sourcesContent":["import type { CallerDescriptor } from './types';\n\n/**\n * Base intlayer getters — always active, independent of any compat library.\n *\n * Their result is the dictionary content object itself: fields are consumed\n * through member access (`content.title`) or destructuring\n * (`const { title } = useIntlayer('home')`).\n */\nexport const BASE_CALLERS: CallerDescriptor[] = [\n {\n callerName: 'useIntlayer',\n library: 'intlayer',\n importSources: [\n 'intlayer',\n 'react-intlayer',\n 'next-intlayer',\n 'vue-intlayer',\n 'svelte-intlayer',\n 'solid-intlayer',\n 'preact-intlayer',\n 'angular-intlayer',\n ],\n namespaceSources: [{ from: 'argument', index: 0 }],\n translationFunction: 'content',\n },\n {\n callerName: 'getIntlayer',\n library: 'intlayer',\n importSources: ['intlayer', '@intlayer/core'],\n namespaceSources: [{ from: 'argument', index: 0 }],\n translationFunction: 'content',\n },\n];\n"],"mappings":";;;;;;;;AASA,MAAa,eAAmC,CAC9C;CACE,YAAY;CACZ,SAAS;CACT,eAAe;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CACD,kBAAkB,CAAC;EAAE,MAAM;EAAY,OAAO;EAAG,CAAC;CAClD,qBAAqB;CACtB,EACD;CACE,YAAY;CACZ,SAAS;CACT,eAAe,CAAC,YAAY,iBAAiB;CAC7C,kBAAkB,CAAC;EAAE,MAAM;EAAY,OAAO;EAAG,CAAC;CAClD,qBAAqB;CACtB,CACF"}