@fluentic/i18n-compiler 0.1.0-beta.2 → 0.1.0-beta.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @fluentic/i18n-compiler
2
2
 
3
+ ## 0.1.0-beta.3
4
+
5
+ ### Minor Changes
6
+
7
+ - Add shared file and package filtering across compiler adapters, including include/exclude globs and regular expressions, includePackages/excludePackages with exact nested package ownership, and a native Vite transform hook prefilter. Preserve includeDependencies support and reload shared filters when watched config changes.
8
+
9
+ ### Patch Changes
10
+
11
+ - @fluentic/i18n@0.1.0-beta.3
12
+
3
13
  ## 0.1.0-beta.2
4
14
 
5
15
  ### Patch Changes
package/README.md CHANGED
@@ -9,3 +9,16 @@ export default { plugins: [fluentic({ config: './i18n.config.ts' })] };
9
9
  ```
10
10
 
11
11
  The compiler always compiles matching source. Config location is never assumed. Both settings are optional: pass `{config: './any/path/i18n.config.ts'}` to reuse its `compiled.hashLength`, `{hashLength: 6}` to set the value directly, or neither to use the compiler default. A direct value overrides the selected config.
12
+
13
+ File filtering is shared across the adapters:
14
+
15
+ - `include` and `exclude` accept a glob, a regular expression, or an array of either. IDs are matched without query strings or hash fragments; glob paths normalize Windows separators.
16
+ - By default, script files (`js`, `jsx`, `ts`, `tsx`, and their `m`/`c` variants) are included and `node_modules` is excluded. Setting `include` replaces the default include and removes the implicit dependency exclusion. An explicit `exclude` replaces the default exclusion.
17
+ - `includePackages` accepts an exact npm package name or an array of names. Matching packages' script files bypass file-level `include` and `exclude` rules.
18
+ - `excludePackages` accepts the same form and always wins, including over `includePackages` and `includeDependencies`.
19
+ - Package matching uses the innermost `node_modules` owner, supports scoped packages and pnpm paths, and does not apply a parent's rule to nested dependencies. Linked workspace source outside `node_modules` uses the file rules.
20
+ - `includeDependencies: true` remains supported to remove the implicit dependency exclusion for all packages.
21
+
22
+ For example, `fluentic({ includePackages: ['@acme/ui'], excludePackages: ['legacy-ui'] })` compiles application scripts and source from `@acme/ui`, while always skipping `legacy-ui`. These options also work with the Next.js wrapper; use string globs for Next.js options so Turbopack can serialize them.
23
+
24
+ Vite exposes a native `transform.filter` to skip irrelevant modules before invoking JavaScript, and its handler checks the authoritative shared filter. When an external `config` is selected, the native filter stays broad so config reloads cannot leave stale exclusions. Custom integrations can import `createTransformFilter` and `createTransformHookFilter` from `@fluentic/i18n-compiler`; the shared filter caches decisions and exposes `clear()`.
package/dist/babel.mjs CHANGED
@@ -1,9 +1,11 @@
1
- import { l as traverse, t as compileProgram } from "./src-ZYntx97W.mjs";
2
- import { n as loadOptions } from "./options-WZfxnYkT.mjs";
1
+ import { l as traverse, t as compileProgram } from "./src-BBeF3k1d.mjs";
2
+ import { i as createTransformFilter } from "./filter-Bc7CtppJ.mjs";
3
+ import { t as loadOptions } from "./options-CHPeMkCj.mjs";
3
4
  // src/babel.ts
4
5
  /** Owns parsing even when a host (e.g. Metro) passes an already parsed AST. */
5
6
  function fluenticBabel(_api, options = {}) {
6
7
  const config = loadOptions(options);
8
+ const filter = createTransformFilter(config);
7
9
  const handled = /* @__PURE__ */ new WeakSet();
8
10
  const enabled = (code) => code.includes("@fluentic/i18n");
9
11
  const compile = (code, filename) => {
@@ -15,11 +17,11 @@ function fluenticBabel(_api, options = {}) {
15
17
  return {
16
18
  name: "fluentic-i18n",
17
19
  parserOverride(code, parserOptions) {
18
- if (!enabled(code)) return void 0;
20
+ if (!enabled(code) || !filter(parserOptions.sourceFilename ?? "source.tsx")) return void 0;
19
21
  return compile(code, parserOptions.sourceFilename ?? "source.tsx");
20
22
  },
21
23
  pre(file) {
22
- if (!enabled(file.code) || handled.has(file.path.node)) return;
24
+ if (!enabled(file.code) || !filter(file.opts.filename ?? "source.tsx") || handled.has(file.path.node)) return;
23
25
  const ast = compile(file.code, file.opts.filename ?? "source.tsx");
24
26
  file.path.replaceWith(ast.program);
25
27
  file.scope.crawl();
@@ -1 +1 @@
1
- {"version":3,"file":"babel.mjs","names":[],"sources":["../src/babel.ts"],"sourcesContent":["import { traverse } from './analyze';\nimport { compileProgram } from './index';\nimport { loadOptions, type PluginOptions } from './options';\n/** Owns parsing even when a host (e.g. Metro) passes an already parsed AST. */\nexport default function fluenticBabel(_api: unknown, options: PluginOptions = {}) {\n const config = loadOptions(options);\n const handled = new WeakSet<object>();\n const enabled = (code: string) => code.includes('@fluentic/i18n');\n\n const compile = (code: string, filename: string) => {\n const { ast } = compileProgram(code, filename, config);\n // Standalone paths have a default Hub. Babel must create its own paths for presets.\n traverse.cache.clear();\n handled.add(ast.program);\n\n return ast;\n };\n\n return {\n name: 'fluentic-i18n',\n parserOverride(code: string, parserOptions: { sourceFilename?: string; }) {\n if (!enabled(code)) return undefined;\n\n return compile(code, parserOptions.sourceFilename ?? 'source.tsx');\n },\n pre(file: any) {\n if (!enabled(file.code) || handled.has(file.path.node)) return;\n\n const ast = compile(file.code, file.opts.filename ?? 'source.tsx');\n file.path.replaceWith(ast.program);\n file.scope.crawl();\n },\n };\n}\n"],"mappings":";;;;AAIA,SAAwB,cAAc,MAAe,UAAyB,CAAC,GAAG;CAChF,MAAM,SAAS,YAAY,OAAO;CAClC,MAAM,0BAAU,IAAI,QAAgB;CACpC,MAAM,WAAW,SAAiB,KAAK,SAAS,gBAAgB;CAEhE,MAAM,WAAW,MAAc,aAAqB;EAClD,MAAM,EAAE,QAAQ,eAAe,MAAM,UAAU,MAAM;EAErD,SAAS,MAAM,MAAM;EACrB,QAAQ,IAAI,IAAI,OAAO;EAEvB,OAAO;CACT;CAEA,OAAO;EACL,MAAM;EACN,eAAe,MAAc,eAA6C;GACxE,IAAI,CAAC,QAAQ,IAAI,GAAG,OAAO,KAAA;GAE3B,OAAO,QAAQ,MAAM,cAAc,kBAAkB,YAAY;EACnE;EACA,IAAI,MAAW;GACb,IAAI,CAAC,QAAQ,KAAK,IAAI,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,GAAG;GAExD,MAAM,MAAM,QAAQ,KAAK,MAAM,KAAK,KAAK,YAAY,YAAY;GACjE,KAAK,KAAK,YAAY,IAAI,OAAO;GACjC,KAAK,MAAM,MAAM;EACnB;CACF;AACF"}
1
+ {"version":3,"file":"babel.mjs","names":[],"sources":["../src/babel.ts"],"sourcesContent":["import { traverse } from './analyze';\nimport { createTransformFilter } from './filter';\nimport { compileProgram } from './index';\nimport { loadOptions, type PluginOptions } from './options';\n/** Owns parsing even when a host (e.g. Metro) passes an already parsed AST. */\nexport default function fluenticBabel(_api: unknown, options: PluginOptions = {}) {\n const config = loadOptions(options);\n const filter = createTransformFilter(config);\n const handled = new WeakSet<object>();\n const enabled = (code: string) => code.includes('@fluentic/i18n');\n\n const compile = (code: string, filename: string) => {\n const { ast } = compileProgram(code, filename, config);\n // Standalone paths have a default Hub. Babel must create its own paths for presets.\n traverse.cache.clear();\n handled.add(ast.program);\n\n return ast;\n };\n\n return {\n name: 'fluentic-i18n',\n parserOverride(code: string, parserOptions: { sourceFilename?: string; }) {\n if (!enabled(code) || !filter(parserOptions.sourceFilename ?? 'source.tsx')) return undefined;\n\n return compile(code, parserOptions.sourceFilename ?? 'source.tsx');\n },\n pre(file: any) {\n if (!enabled(file.code) || !filter(file.opts.filename ?? 'source.tsx') || handled.has(file.path.node)) return;\n\n const ast = compile(file.code, file.opts.filename ?? 'source.tsx');\n file.path.replaceWith(ast.program);\n file.scope.crawl();\n },\n };\n}\n"],"mappings":";;;;;AAKA,SAAwB,cAAc,MAAe,UAAyB,CAAC,GAAG;CAChF,MAAM,SAAS,YAAY,OAAO;CAClC,MAAM,SAAS,sBAAsB,MAAM;CAC3C,MAAM,0BAAU,IAAI,QAAgB;CACpC,MAAM,WAAW,SAAiB,KAAK,SAAS,gBAAgB;CAEhE,MAAM,WAAW,MAAc,aAAqB;EAClD,MAAM,EAAE,QAAQ,eAAe,MAAM,UAAU,MAAM;EAErD,SAAS,MAAM,MAAM;EACrB,QAAQ,IAAI,IAAI,OAAO;EAEvB,OAAO;CACT;CAEA,OAAO;EACL,MAAM;EACN,eAAe,MAAc,eAA6C;GACxE,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,OAAO,cAAc,kBAAkB,YAAY,GAAG,OAAO,KAAA;GAEpF,OAAO,QAAQ,MAAM,cAAc,kBAAkB,YAAY;EACnE;EACA,IAAI,MAAW;GACb,IAAI,CAAC,QAAQ,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,YAAY,YAAY,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,GAAG;GAEvG,MAAM,MAAM,QAAQ,KAAK,MAAM,KAAK,KAAK,YAAY,YAAY;GACjE,KAAK,KAAK,YAAY,IAAI,OAAO;GACjC,KAAK,MAAM,MAAM;EACnB;CACF;AACF"}
package/dist/esbuild.mjs CHANGED
@@ -1,5 +1,6 @@
1
- import { n as transform } from "./src-ZYntx97W.mjs";
2
- import { n as loadOptions, t as accepts } from "./options-WZfxnYkT.mjs";
1
+ import { n as transform } from "./src-BBeF3k1d.mjs";
2
+ import { i as createTransformFilter, n as DEFAULT_TRANSFORM_INCLUDE } from "./filter-Bc7CtppJ.mjs";
3
+ import { t as loadOptions } from "./options-CHPeMkCj.mjs";
3
4
  import { readFile } from "node:fs/promises";
4
5
  // src/esbuild.ts
5
6
  function fluentic(options = {}) {
@@ -7,11 +8,13 @@ function fluentic(options = {}) {
7
8
  name: "fluentic-i18n",
8
9
  setup(build) {
9
10
  let config = loadOptions(options, build.initialOptions.absWorkingDir);
11
+ let filter = createTransformFilter(config);
10
12
  build.onStart(() => {
11
13
  config = loadOptions(options, build.initialOptions.absWorkingDir);
14
+ filter = createTransformFilter(config);
12
15
  });
13
- build.onLoad({ filter: /\.[cm]?[jt]sx?$/ }, async ({ path }) => {
14
- if (!accepts(path, config)) return;
16
+ build.onLoad({ filter: options.config || options.include ? /.*/ : DEFAULT_TRANSFORM_INCLUDE }, async ({ path }) => {
17
+ if (!filter(path)) return;
15
18
  const result = transform(await readFile(path, "utf8"), {
16
19
  ...config,
17
20
  filename: path
@@ -1 +1 @@
1
- {"version":3,"file":"esbuild.mjs","names":[],"sources":["../src/esbuild.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { transform } from './index';\nimport { accepts, loadOptions, type PluginOptions } from './options';\n\nexport default function fluentic(options: PluginOptions = {}) {\n return {\n name: 'fluentic-i18n',\n setup(build: any) {\n let config = loadOptions(options, build.initialOptions.absWorkingDir);\n build.onStart(() => {\n config = loadOptions(options, build.initialOptions.absWorkingDir);\n });\n build.onLoad({ filter: /\\.[cm]?[jt]sx?$/ }, async ({ path }: { path: string; }) => {\n if (!accepts(path, config)) return;\n\n const result = transform(await readFile(path, 'utf8'), { ...config, filename: path });\n\n if (!result) return;\n\n const loader = /\\.tsx$/.test(path)\n ? 'tsx'\n : /\\.[cm]?ts$/.test(path)\n ? 'ts'\n : /\\.jsx$/.test(path)\n ? 'jsx'\n : 'js';\n\n return {\n contents: result.code + '\\n//# sourceMappingURL=data:application/json;base64,' +\n Buffer.from(JSON.stringify(result.map)).toString('base64'),\n loader,\n watchFiles: [path, ...(config.configFile ? [config.configFile] : [])],\n };\n });\n },\n };\n}\n"],"mappings":";;;;AAIA,SAAwB,SAAS,UAAyB,CAAC,GAAG;CAC5D,OAAO;EACL,MAAM;EACN,MAAM,OAAY;GAChB,IAAI,SAAS,YAAY,SAAS,MAAM,eAAe,aAAa;GACpE,MAAM,cAAc;IAClB,SAAS,YAAY,SAAS,MAAM,eAAe,aAAa;GAClE,CAAC;GACD,MAAM,OAAO,EAAE,QAAQ,kBAAkB,GAAG,OAAO,EAAE,WAA8B;IACjF,IAAI,CAAC,QAAQ,MAAM,MAAM,GAAG;IAE5B,MAAM,SAAS,UAAU,MAAM,SAAS,MAAM,MAAM,GAAG;KAAE,GAAG;KAAQ,UAAU;IAAK,CAAC;IAEpF,IAAI,CAAC,QAAQ;IAEb,MAAM,SAAS,SAAS,KAAK,IAAI,IAC7B,QACA,aAAa,KAAK,IAAI,IACtB,OACA,SAAS,KAAK,IAAI,IAClB,QACA;IAEJ,OAAO;KACL,UAAU,OAAO,OAAO,yDACtB,OAAO,KAAK,KAAK,UAAU,OAAO,GAAG,CAAC,CAAC,CAAC,SAAS,QAAQ;KAC3D;KACA,YAAY,CAAC,MAAM,GAAI,OAAO,aAAa,CAAC,OAAO,UAAU,IAAI,CAAC,CAAE;IACtE;GACF,CAAC;EACH;CACF;AACF"}
1
+ {"version":3,"file":"esbuild.mjs","names":[],"sources":["../src/esbuild.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { createTransformFilter, DEFAULT_TRANSFORM_INCLUDE } from './filter';\nimport { transform } from './index';\nimport { loadOptions, type PluginOptions } from './options';\n\nexport default function fluentic(options: PluginOptions = {}) {\n return {\n name: 'fluentic-i18n',\n setup(build: any) {\n let config = loadOptions(options, build.initialOptions.absWorkingDir);\n let filter = createTransformFilter(config);\n build.onStart(() => {\n config = loadOptions(options, build.initialOptions.absWorkingDir);\n filter = createTransformFilter(config);\n });\n build.onLoad(\n { filter: options.config || options.include ? /.*/ : DEFAULT_TRANSFORM_INCLUDE },\n async ({ path }: { path: string; }) => {\n if (!filter(path)) return;\n\n const result = transform(await readFile(path, 'utf8'), { ...config, filename: path });\n\n if (!result) return;\n\n const loader = /\\.tsx$/.test(path)\n ? 'tsx'\n : /\\.[cm]?ts$/.test(path)\n ? 'ts'\n : /\\.jsx$/.test(path)\n ? 'jsx'\n : 'js';\n\n return {\n contents: result.code + '\\n//# sourceMappingURL=data:application/json;base64,' +\n Buffer.from(JSON.stringify(result.map)).toString('base64'),\n loader,\n watchFiles: [path, ...(config.configFile ? [config.configFile] : [])],\n };\n },\n );\n },\n };\n}\n"],"mappings":";;;;;AAKA,SAAwB,SAAS,UAAyB,CAAC,GAAG;CAC5D,OAAO;EACL,MAAM;EACN,MAAM,OAAY;GAChB,IAAI,SAAS,YAAY,SAAS,MAAM,eAAe,aAAa;GACpE,IAAI,SAAS,sBAAsB,MAAM;GACzC,MAAM,cAAc;IAClB,SAAS,YAAY,SAAS,MAAM,eAAe,aAAa;IAChE,SAAS,sBAAsB,MAAM;GACvC,CAAC;GACD,MAAM,OACJ,EAAE,QAAQ,QAAQ,UAAU,QAAQ,UAAU,OAAO,0BAA0B,GAC/E,OAAO,EAAE,WAA8B;IACrC,IAAI,CAAC,OAAO,IAAI,GAAG;IAEnB,MAAM,SAAS,UAAU,MAAM,SAAS,MAAM,MAAM,GAAG;KAAE,GAAG;KAAQ,UAAU;IAAK,CAAC;IAEpF,IAAI,CAAC,QAAQ;IAEb,MAAM,SAAS,SAAS,KAAK,IAAI,IAC7B,QACA,aAAa,KAAK,IAAI,IACtB,OACA,SAAS,KAAK,IAAI,IAClB,QACA;IAEJ,OAAO;KACL,UAAU,OAAO,OAAO,yDACtB,OAAO,KAAK,KAAK,UAAU,OAAO,GAAG,CAAC,CAAC,CAAC,SAAS,QAAQ;KAC3D;KACA,YAAY,CAAC,MAAM,GAAI,OAAO,aAAa,CAAC,OAAO,UAAU,IAAI,CAAC,CAAE;IACtE;GACF,CACF;EACF;CACF;AACF"}
@@ -0,0 +1,73 @@
1
+ import picomatch from "picomatch";
2
+ // src/filter.ts
3
+ const normalizePath = (path) => path.replace(/\\/g, "/");
4
+ const DEFAULT_TRANSFORM_INCLUDE_PATTERN = "\\.[cm]?[jt]sx?$";
5
+ const DEFAULT_TRANSFORM_INCLUDE = new RegExp(DEFAULT_TRANSFORM_INCLUDE_PATTERN);
6
+ const DEFAULT_TRANSFORM_EXCLUDE = /node_modules/;
7
+ function normalizeModuleId(id) {
8
+ return id.split("?")[0]?.split("#")[0] ?? id;
9
+ }
10
+ function createTransformFilter(options = {}) {
11
+ const includes = normalizeMatchers(options.include);
12
+ const includePackages = createPackagePattern(options.includePackages);
13
+ const excludePackages = createPackagePattern(options.excludePackages);
14
+ const excludes = normalizeMatchers(options.exclude ?? (options.include || options.includeDependencies ? void 0 : DEFAULT_TRANSFORM_EXCLUDE));
15
+ const cache = /* @__PURE__ */ new Map();
16
+ const filter = ((id) => {
17
+ const filePath = normalizeModuleId(id);
18
+ const cached = cache.get(filePath);
19
+ if (cached !== void 0) return cached;
20
+ const packagePath = normalizePath(filePath);
21
+ const result = excludePackages?.test(packagePath) ? false : includePackages?.test(packagePath) ? DEFAULT_TRANSFORM_INCLUDE.test(filePath) : shouldTransform(filePath, includes, excludes);
22
+ cache.set(filePath, result);
23
+ return result;
24
+ });
25
+ filter.clear = () => {
26
+ cache.clear();
27
+ };
28
+ return filter;
29
+ }
30
+ function normalizeMatchers(patterns) {
31
+ if (!patterns) return [];
32
+ return (Array.isArray(patterns) ? patterns : [patterns]).map(createMatcher);
33
+ }
34
+ function createMatcher(pattern) {
35
+ if (pattern instanceof RegExp) return (id) => {
36
+ pattern.lastIndex = 0;
37
+ return pattern.test(id);
38
+ };
39
+ const matcher = picomatch(normalizePath(pattern), { dot: true });
40
+ return (id) => matcher(normalizePath(id));
41
+ }
42
+ function shouldTransform(id, includes, excludes) {
43
+ for (const exclude of excludes) if (exclude(id)) return false;
44
+ if (!includes.length) return DEFAULT_TRANSFORM_INCLUDE.test(id);
45
+ for (const include of includes) if (include(id)) return true;
46
+ return false;
47
+ }
48
+ /** A conservative native prefilter; the shared JS filter remains authoritative. */
49
+ function createTransformHookFilter(options = {}) {
50
+ const includePackages = createPackagePattern(options.includePackages);
51
+ const excludePackages = createPackagePattern(options.excludePackages);
52
+ const exclude = [];
53
+ if (excludePackages) exclude.push(excludePackages);
54
+ if (!options.include && !options.includeDependencies && options.exclude === void 0) exclude.push(new RegExp(`^${includePackages ? `(?!${includePackages.source})` : ""}[^?#]*node_modules`));
55
+ return { id: {
56
+ include: options.include ? void 0 : /^[^?#]*\.[cm]?[jt]sx?(?:[?#][\s\S]*)?$/,
57
+ exclude
58
+ } };
59
+ }
60
+ function createPackagePattern(packages) {
61
+ const names = typeof packages === "string" ? [packages] : packages ?? [];
62
+ if (!names.length) return void 0;
63
+ for (const name of names) if (!/^(?:@[a-zA-Z0-9_][a-zA-Z0-9._-]*\/)?[a-zA-Z0-9_][a-zA-Z0-9._-]*$/.test(name)) throw new Error(`[i18n] Invalid package name in includePackages/excludePackages: ${JSON.stringify(name)}`);
64
+ const separator = "[/\\\\]";
65
+ const alternatives = names.map((name) => name.split("/").map(escapeRegExp).join(separator)).join("|");
66
+ return new RegExp(`^(?:[^?#]*${separator})?node_modules${separator}(?:${alternatives})(?![^?#]*${separator}node_modules${separator})(?:${separator}[^?#]*)?(?:[?#][\\s\\S]*)?$`);
67
+ }
68
+ function escapeRegExp(value) {
69
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
70
+ }
71
+ export { createTransformHookFilter as a, createTransformFilter as i, DEFAULT_TRANSFORM_INCLUDE as n, normalizeModuleId as o, DEFAULT_TRANSFORM_INCLUDE_PATTERN as r, DEFAULT_TRANSFORM_EXCLUDE as t };
72
+
73
+ //# sourceMappingURL=filter-Bc7CtppJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-Bc7CtppJ.mjs","names":[],"sources":["../src/filter.ts"],"sourcesContent":["import picomatch from 'picomatch';\nconst normalizePath = (path: string) => path.replace(/\\\\/g, '/');\n\nexport const DEFAULT_TRANSFORM_INCLUDE_PATTERN = '\\\\.[cm]?[jt]sx?$';\n\nexport const DEFAULT_TRANSFORM_INCLUDE = new RegExp(DEFAULT_TRANSFORM_INCLUDE_PATTERN);\n\nexport const DEFAULT_TRANSFORM_EXCLUDE = /node_modules/;\n\nexport type FilterPattern = string | RegExp | Array<string | RegExp>;\n\nexport type TransformFilterOptions = {\n /** File globs or regular expressions matched against IDs without query/hash suffixes. */\n include?: FilterPattern;\n exclude?: FilterPattern;\n /** Backwards-compatible opt-in to all dependencies; explicit exclude still wins. */\n includeDependencies?: boolean;\n /** Exact npm package names whose script files override file include/exclude rules. */\n includePackages?: string | string[];\n /** Exact npm package names excluded before all other filter rules. */\n excludePackages?: string | string[];\n};\n\nexport type TransformFilter = {\n (id: string): boolean;\n clear(): void;\n};\n\nexport function normalizeModuleId(id: string) {\n return id.split('?')[0]?.split('#')[0] ?? id;\n}\n\nexport function createTransformFilter(options: TransformFilterOptions = {}): TransformFilter {\n const includes = normalizeMatchers(options.include);\n const includePackages = createPackagePattern(options.includePackages);\n const excludePackages = createPackagePattern(options.excludePackages);\n\n const excludes = normalizeMatchers(\n options.exclude ?? (options.include || options.includeDependencies ? undefined : DEFAULT_TRANSFORM_EXCLUDE),\n );\n\n const cache = new Map<string, boolean>();\n\n const filter = ((id: string) => {\n const filePath = normalizeModuleId(id);\n const cached = cache.get(filePath);\n\n if (cached !== undefined) return cached;\n\n const packagePath = normalizePath(filePath);\n const result = excludePackages?.test(packagePath)\n ? false\n : includePackages?.test(packagePath)\n ? DEFAULT_TRANSFORM_INCLUDE.test(filePath)\n : shouldTransform(filePath, includes, excludes);\n\n cache.set(filePath, result);\n\n return result;\n }) as TransformFilter;\n\n filter.clear = () => {\n cache.clear();\n };\n\n return filter;\n}\n\ntype FilterMatcher = (id: string) => boolean;\n\nfunction normalizeMatchers(patterns?: FilterPattern) {\n if (!patterns) return [];\n\n const items = Array.isArray(patterns) ? patterns : [patterns];\n\n return items.map(createMatcher);\n}\n\nfunction createMatcher(pattern: string | RegExp): FilterMatcher {\n if (pattern instanceof RegExp) {\n return (id) => {\n pattern.lastIndex = 0;\n return pattern.test(id);\n };\n }\n\n const matcher = picomatch(normalizePath(pattern), {\n dot: true,\n });\n\n return (id) => matcher(normalizePath(id));\n}\n\nfunction shouldTransform(\n id: string,\n includes: FilterMatcher[],\n excludes: FilterMatcher[],\n): boolean {\n for (const exclude of excludes) {\n if (exclude(id)) return false;\n }\n\n if (!includes.length) {\n return DEFAULT_TRANSFORM_INCLUDE.test(id);\n }\n\n for (const include of includes) {\n if (include(id)) return true;\n }\n\n return false;\n}\n\n/** A conservative native prefilter; the shared JS filter remains authoritative. */\nexport function createTransformHookFilter(options: TransformFilterOptions = {}) {\n const includePackages = createPackagePattern(options.includePackages);\n const excludePackages = createPackagePattern(options.excludePackages);\n const exclude: RegExp[] = [];\n if (excludePackages) exclude.push(excludePackages);\n\n if (!options.include && !options.includeDependencies && options.exclude === undefined) {\n // Package inclusions override the default node_modules exclusion.\n exclude.push(\n new RegExp(\n `^${includePackages ? `(?!${includePackages.source})` : ''}[^?#]*node_modules`,\n ),\n );\n }\n\n return {\n id: {\n // Custom globs/regexes run against normalized IDs in the shared filter.\n // Keeping the native check broad avoids changing their matching semantics.\n include: options.include ? undefined : /^[^?#]*\\.[cm]?[jt]sx?(?:[?#][\\s\\S]*)?$/,\n exclude,\n },\n };\n}\n\nfunction createPackagePattern(packages?: string | string[]): RegExp | undefined {\n const names = typeof packages === 'string' ? [packages] : packages ?? [];\n if (!names.length) return undefined;\n\n for (const name of names) {\n if (!/^(?:@[a-zA-Z0-9_][a-zA-Z0-9._-]*\\/)?[a-zA-Z0-9_][a-zA-Z0-9._-]*$/.test(name)) {\n throw new Error(\n `[i18n] Invalid package name in includePackages/excludePackages: ${JSON.stringify(name)}`,\n );\n }\n }\n\n const separator = '[/\\\\\\\\]';\n const alternatives = names.map((name) => name.split('/').map(escapeRegExp).join(separator)).join('|');\n // Match the innermost node_modules owner, including pnpm's nested layout.\n // A package's nested dependencies must not inherit its include/exclude rule.\n return new RegExp(\n `^(?:[^?#]*${separator})?node_modules${separator}(?:${alternatives})` +\n `(?![^?#]*${separator}node_modules${separator})` +\n `(?:${separator}[^?#]*)?(?:[?#][\\\\s\\\\S]*)?$`,\n );\n}\n\nfunction escapeRegExp(value: string) {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n"],"mappings":";;AACA,MAAM,iBAAiB,SAAiB,KAAK,QAAQ,OAAO,GAAG;AAE/D,MAAa,oCAAoC;AAEjD,MAAa,4BAA4B,IAAI,OAAO,iCAAiC;AAErF,MAAa,4BAA4B;AAqBzC,SAAgB,kBAAkB,IAAY;CAC5C,OAAO,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,CA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export declare const DEFAULT_TRANSFORM_INCLUDE: RegExp;
3
+ export declare const DEFAULT_TRANSFORM_EXCLUDE: RegExp;
4
+ export type FilterPattern = string | RegExp | Array<string | RegExp>;
5
+ export type TransformFilterOptions = {
6
+ /** File globs or regular expressions matched against IDs without query/hash suffixes. */
7
+ include?: FilterPattern;
8
+ exclude?: FilterPattern;
9
+ /** Backwards-compatible opt-in to all dependencies; explicit exclude still wins. */
10
+ includeDependencies?: boolean;
11
+ /** Exact npm package names whose script files override file include/exclude rules. */
12
+ includePackages?: string | string[];
13
+ /** Exact npm package names excluded before all other filter rules. */
14
+ excludePackages?: string | string[];
15
+ };
16
+ export type TransformFilter = {
17
+ (id: string): boolean;
18
+ clear(): void;
19
+ };
20
+ export declare function normalizeModuleId(id: string): string;
21
+ export declare function createTransformFilter(options?: TransformFilterOptions): TransformFilter;
22
+ /** A conservative native prefilter; the shared JS filter remains authoritative. */
23
+ export declare function createTransformHookFilter(options?: TransformFilterOptions): {
24
+ id: {
25
+ include: RegExp | undefined;
26
+ exclude: RegExp[];
27
+ };
28
+ };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import * as b from '@babel/types';
2
2
  import { type ExtractedMessage } from './analyze';
3
3
  export { collectMessages } from './analyze';
4
+ export * from './filter';
4
5
  export * from './message';
6
+ export type { PluginOptions } from './options';
5
7
  export type CompiledOptions = {
6
8
  hashLength?: number;
7
9
  };
package/dist/index.mjs CHANGED
@@ -1 +1,3 @@
1
- export { r as COMPACT_VERSION, c as collectMessages, i as compileCatalog, a as compileMessage, t as compileProgram, o as messageId, s as messageIdentity, n as transform } from "./src-ZYntx97W.mjs";
1
+ import { a as compileMessage, c as collectMessages, i as compileCatalog, n as transform, o as messageId, r as COMPACT_VERSION, s as messageIdentity, t as compileProgram } from "./src-BBeF3k1d.mjs";
2
+ import { a as createTransformHookFilter, i as createTransformFilter, n as DEFAULT_TRANSFORM_INCLUDE, o as normalizeModuleId, r as DEFAULT_TRANSFORM_INCLUDE_PATTERN, t as DEFAULT_TRANSFORM_EXCLUDE } from "./filter-Bc7CtppJ.mjs";
3
+ export { COMPACT_VERSION, DEFAULT_TRANSFORM_EXCLUDE, DEFAULT_TRANSFORM_INCLUDE, DEFAULT_TRANSFORM_INCLUDE_PATTERN, collectMessages, compileCatalog, compileMessage, compileProgram, createTransformFilter, createTransformHookFilter, messageId, messageIdentity, normalizeModuleId, transform };
package/dist/nextjs.d.ts CHANGED
@@ -1,9 +1,6 @@
1
- export type NextPluginOptions = {
1
+ import type { PluginOptions } from './options';
2
+ export type NextPluginOptions = PluginOptions & {
2
3
  requestConfig: string;
3
- /** Optional i18n config path, resolved from the application working directory. */
4
- config?: string;
5
- /** Direct override; otherwise reuse compiled.hashLength from an explicitly selected config or the default. */
6
- hashLength?: number;
7
4
  };
8
5
  /** One Next integration; preserves the application's existing webpack hook/rules. */
9
6
  export default function withFluentic(options: NextPluginOptions): (nextConfig?: any) => any;
package/dist/nextjs.mjs CHANGED
@@ -7,7 +7,9 @@ const require = createRequire(import.meta.url);
7
7
  function withFluentic(options) {
8
8
  const request = resolve(options.requestConfig);
9
9
  const loader = require.resolve("@fluentic/i18n-compiler/webpack-loader");
10
+ const { requestConfig: _requestConfig, ...pluginOptions } = options;
10
11
  const compilerOptions = {
12
+ ...pluginOptions,
11
13
  bindReactText: true,
12
14
  ...options.config ? { config: resolve(options.config) } : {},
13
15
  ...options.hashLength !== void 0 ? { hashLength: options.hashLength } : {}
@@ -28,14 +30,17 @@ function withFluentic(options) {
28
30
  "*.ts",
29
31
  "*.tsx",
30
32
  "*.mjs",
31
- "*.mts"
32
- ].map((pattern) => [pattern, [...nextConfig.turbopack?.rules?.[pattern] ? [nextConfig.turbopack.rules[pattern]].flat() : [], {
33
- condition: { not: "foreign" },
34
- loaders: [{
35
- loader,
36
- options: compilerOptions
37
- }]
38
- }]]))
33
+ "*.mts",
34
+ "*.cjs",
35
+ "*.cts",
36
+ "*.mjsx",
37
+ "*.mtsx",
38
+ "*.cjsx",
39
+ "*.ctsx"
40
+ ].map((pattern) => [pattern, [...nextConfig.turbopack?.rules?.[pattern] ? [nextConfig.turbopack.rules[pattern]].flat() : [], { loaders: [{
41
+ loader,
42
+ options: compilerOptions
43
+ }] }]]))
39
44
  }
40
45
  },
41
46
  webpack(config, context) {
@@ -1 +1 @@
1
- {"version":3,"file":"nextjs.mjs","names":["FluenticPlugin"],"sources":["../src/nextjs.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { relative, resolve } from 'node:path';\nimport FluenticPlugin from './webpack';\nconst require = createRequire(import.meta.url);\nexport type NextPluginOptions = {\n requestConfig: string;\n /** Optional i18n config path, resolved from the application working directory. */\n config?: string;\n /** Direct override; otherwise reuse compiled.hashLength from an explicitly selected config or the default. */\n hashLength?: number;\n};\n/** One Next integration; preserves the application's existing webpack hook/rules. */\nexport default function withFluentic(options: NextPluginOptions) {\n const request = resolve(options.requestConfig);\n const loader = require.resolve('@fluentic/i18n-compiler/webpack-loader');\n const compilerOptions = {\n bindReactText: true,\n ...(options.config ? { config: resolve(options.config) } : {}),\n ...(options.hashLength !== undefined ? { hashLength: options.hashLength } : {}),\n };\n return (nextConfig: any = {}) => ({\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n resolveAlias: {\n ...nextConfig.turbopack?.resolveAlias,\n '@fluentic/i18n-nextjs/request': './' + relative(process.cwd(), request).replace(/\\\\/g, '/'),\n },\n rules: {\n ...nextConfig.turbopack?.rules,\n ...Object.fromEntries(['*.js', '*.jsx', '*.ts', '*.tsx', '*.mjs', '*.mts'].map((pattern) => [pattern, [\n ...(nextConfig.turbopack?.rules?.[pattern] ? [nextConfig.turbopack.rules[pattern]].flat() : []),\n { condition: { not: 'foreign' }, loaders: [{ loader, options: compilerOptions }] },\n ]])),\n },\n },\n webpack(config: any, context: any) {\n config.resolve ??= {};\n config.resolve.alias ??= {};\n config.resolve.alias['@fluentic/i18n-nextjs/request$'] = request;\n config.plugins ??= [];\n config.plugins.push(new Flu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CACF;AACF"}
1
+ {"version":3,"file":"nextjs.mjs","names":["FluenticPlugin"],"sources":["../src/nextjs.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { relative, resolve } from 'node:path';\nimport type { PluginOptions } from './options';\nimport FluenticPlugin from './webpack';\nconst require = createRequire(import.meta.url);\nexport type NextPluginOptions = PluginOptions & {\n requestConfig: string;\n};\n/** One Next integration; preserves the application's existing webpack hook/rules. */\nexport default function withFluentic(options: NextPluginOptions) {\n const request = resolve(options.requestConfig);\n const loader = require.resolve('@fluentic/i18n-compiler/webpack-loader');\n const { requestConfig: _requestConfig, ...pluginOptions } = options;\n const compilerOptions = {\n ...pluginOptions,\n bindReactText: true,\n ...(options.config ? { config: resolve(options.config) } : {}),\n ...(options.hashLength !== undefined ? { hashLength: options.hashLength } : {}),\n };\n return (nextConfig: any = {}) => ({\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n resolveAlias: {\n ...nextConfig.turbopack?.resolveAlias,\n '@fluentic/i18n-nextjs/request': './' + relative(process.cwd(), request).replace(/\\\\/g, '/'),\n },\n rules: {\n ...nextConfig.turbopack?.rules,\n ...Object.fromEntries(\n ['*.js', '*.jsx', '*.ts', '*.tsx', '*.mjs', '*.mts', '*.cjs', '*.cts', '*.mjsx', '*.mtsx', '*.cjsx', '*.ctsx']\n .map((pattern) => [pattern, [\n ...(nextConfig.turbopack?.rules?.[pattern] ? [nextConfig.turbopack.rules[pattern]].flat() : []),\n { loaders: [{ loader, options: compilerOptions }] },\n ]]),\n ),\n },\n },\n webpack(config: any, context: any) {\n config.resolve ??= {};\n config.resolve.alias ??= {};\n config.resolve.alias['@fluentic/i18n-nextjs/request$'] = request;\n config.plugins ??= [];\n config.plugins.push(new FluenticPlugin(compilerOptions));\n return nextConfig.webpack ? nextConfig.webpack(config, context) : config;\n },\n });\n}\n"],"mappings":";;;;AAIA,MAAM,UAAU,cAAc,YAAY,GAAG;;AAK7C,SAAwB,aAAa,SAA4B;CAC/D,MAAM,U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accepts(id, options) {
18
- return /\.[cm]?[jt]sx?$/.test(id.split("?")[0]) && (options.includeDependencies || !id.includes("/node_modules/"));
19
- }
20
- export { loadOptions as n, accepts as t };
17
+ export { loadOptions as t };
21
18
 
22
- //# sourceMappingURL=options-WZfxnYkT.mjs.map
19
+ //# sourceMappingURL=options-CHPeMkCj.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options-CHPeMkCj.mjs","names":[],"sources":["../src/options.ts"],"sourcesContent":["import { createJiti } from 'jiti';\nimport { resolve } from 'node:path';\n\nimport type { TransformFilterOptions } from './filter';\nimport type { CompiledOptions } from './index';\n\nexport type { FilterPattern, TransformFilterOptions } from './filter';\n\nexport type PluginOptions = TransformFilterOptions & {\n /** Direct override; otherwise reuse compiled.hashLength from an explicitly selected config or the default. */\n hashLength?: number;\n /** Optional i18n config path, resolved from the plugin's working directory. */\n config?: string;\n /** Next.js client modules: bind synchronous text calls to the hydration boundary. */\n bindReactText?: boolean;\n};\n\nexport function loadOptions(\n options: PluginOptions = {},\n root = process.cwd(),\n): PluginOptions & { configFile?: string; } {\n if ('compiled' in options) {\n throw new TypeError('[i18n] compiler plugins always compile; use hashLength instead of compiled');\n }\n const file = options.config ? resolve(root, options.config) : undefined;\n\n const config = file\n ? createJiti(import.meta.url, { moduleCache: false })(file) as\n & { default?: PluginOptions & { compiled?: true | CompiledOptions; }; }\n & PluginOptions\n & { compiled?: true | CompiledOptions; }\n : {};\n const loaded = (config.default ?? config) as PluginOptions & { compiled?: true | CompiledOptions; };\n const { compiled, ...configOptions } = loaded;\n const sharedHashLength = typeof compiled === 'object' ? compiled.hashLength : undefined;\n\n return {\n ...configOptions,\n ...(sharedHashLength === undefined ? {} : { hashLength: sharedHashLength }),\n ...options,\n configFile: file,\n };\n}\n"],"mappings":";;;AAiBA,SAAgB,YACd,UAAyB,CAAC,GAC1B,OAAO,QAAQ,IAAI,GACuB;CAC1C,IAAI,cAAc,SAChB,MAAM,IAAI,UAAU,4EAA4E;CAElG,MAAM,OAAO,QAAQ,SAAS,QAAQ,MAAM,QAAQ,MAAM,IAAI,KAAA;CAE9D,MAAM,SAAS,OACX,WAAW,YAAY,KAAK,EAAE,aAAa,MAAM,CAAC,CAAC,CAAC,IAAI,IAIxD,CAAC;CAEL,MAAM,EAAE,UAAU,GAAG,kBADL,OAAO,WAAW;CAElC,MAAM,mBAAmB,OAAO,aAAa,WAAW,SAAS,aAAa,KAAA;CAE9E,OAAO;EACL,GAAG;EACH,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,iBAAiB;EACzE,GAAG;EACH,YAAY;CACd;AACF"}
package/dist/options.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- export type PluginOptions = {
1
+ import type { TransformFilterOptions } from './filter';
2
+ export type { FilterPattern, TransformFilterOptions } from './filter';
3
+ export type PluginOptions = TransformFilterOptions & {
2
4
  /** Direct override; otherwise reuse compiled.hashLength from an explicitly selected config or the default. */
3
5
  hashLength?: number;
4
6
  /** Optional i18n config path, resolved from the plugin's working directory. */
5
7
  config?: string;
6
- includeDependencies?: boolean;
7
8
  /** Next.js client modules: bind synchronous text calls to the hydration boundary. */
8
9
  bindReactText?: boolean;
9
10
  };
10
11
  export declare function loadOptions(options?: PluginOptions, root?: string): PluginOptions & {
11
12
  configFile?: string;
12
13
  };
13
- export declare function accepts(id: string, options: PluginOptions): boolean;
package/dist/rollup.mjs CHANGED
@@ -1,21 +1,26 @@
1
- import { n as transform } from "./src-ZYntx97W.mjs";
2
- import { n as loadOptions, t as accepts } from "./options-WZfxnYkT.mjs";
1
+ import { n as transform } from "./src-BBeF3k1d.mjs";
2
+ import { i as createTransformFilter, o as normalizeModuleId } from "./filter-Bc7CtppJ.mjs";
3
+ import { t as loadOptions } from "./options-CHPeMkCj.mjs";
3
4
  // src/rollup.ts
4
5
  function fluentic(options = {}) {
5
6
  let config = loadOptions(options);
7
+ let filter = createTransformFilter(config);
6
8
  return {
7
9
  name: "fluentic-i18n",
8
10
  buildStart() {
9
11
  if (config.configFile) this.addWatchFile(config.configFile);
10
12
  },
11
13
  watchChange(id) {
12
- if (id === config.configFile) config = loadOptions(options);
14
+ if (id === config.configFile) {
15
+ config = loadOptions(options);
16
+ filter = createTransformFilter(config);
17
+ }
13
18
  },
14
19
  transform(code, id) {
15
- if (!accepts(id, config)) return null;
20
+ if (!filter(id)) return null;
16
21
  return transform(code, {
17
22
  ...config,
18
- filename: id.split("?")[0]
23
+ filename: normalizeModuleId(id)
19
24
  });
20
25
  }
21
26
  };
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.mjs","names":[],"sources":["../src/rollup.ts"],"sourcesContent":["import { transform } from './index';\nimport { accepts, loadOptions, type PluginOptions } from './options';\n\nexport default function fluentic(options: PluginOptions = {}) {\n let config = loadOptions(options);\n\n return {\n name: 'fluentic-i18n',\n buildStart(this: { addWatchFile(file: string): void; }) {\n if (config.configFile) this.addWatchFile(config.configFile);\n },\n watchChange(id: string) {\n if (id === config.configFile) config = loadOptions(options);\n },\n transform(code: string, id: string) {\n if (!accepts(id, config)) return null;\n\n return transform(code, { ...config, filename: id.split('?')[0] });\n },\n };\n}\n"],"mappings":";;;AAGA,SAAwB,SAAS,UAAyB,CAAC,GAAG;CAC5D,IAAI,SAAS,YAAY,OAAO;CAEhC,OAAO;EACL,MAAM;EACN,aAAwD;GACtD,IAAI,OAAO,YAAY,KAAK,aAAa,OAAO,UAAU;EAC5D;EACA,YAAY,IAAY;GACtB,IAAI,OAAO,OAAO,YAAY,SAAS,YAAY,OAAO;EAC5D;EACA,UAAU,MAAc,IAAY;GAClC,IAAI,CAAC,QAAQ,IAAI,MAAM,GAAG,OAAO;GAEjC,OAAO,UAAU,MAAM;IAAE,GAAG;IAAQ,UAAU,GAAG,MAAM,GAAG,CAAC,CAAC;GAAG,CAAC;EAClE;CACF;AACF"}
1
+ {"version":3,"file":"rollup.mjs","names":[],"sources":["../src/rollup.ts"],"sourcesContent":["import { createTransformFilter, normalizeModuleId } from './filter';\nimport { transform } from './index';\nimport { loadOptions, type PluginOptions } from './options';\n\nexport default function fluentic(options: PluginOptions = {}) {\n let config = loadOptions(options);\n let filter = createTransformFilter(config);\n\n return {\n name: 'fluentic-i18n',\n buildStart(this: { addWatchFile(file: string): void; }) {\n if (config.configFile) this.addWatchFile(config.configFile);\n },\n watchChange(id: string) {\n if (id === config.configFile) {\n config = loadOptions(options);\n filter = createTransformFilter(config);\n }\n },\n transform(code: string, id: string) {\n if (!filter(id)) return null;\n\n return transform(code, { ...config, filename: normalizeModuleId(id) });\n },\n };\n}\n"],"mappings":";;;;AAIA,SAAwB,SAAS,UAAyB,CAAC,GAAG;CAC5D,IAAI,SAAS,YAAY,OAAO;CAChC,IAAI,SAAS,sBAAsB,MAAM;CAEzC,OAAO;EACL,MAAM;EACN,aAAwD;GACtD,IAAI,OAAO,YAAY,KAAK,aAAa,OAAO,UAAU;EAC5D;EACA,YAAY,IAAY;GACtB,IAAI,OAAO,OAAO,YAAY;IAC5B,SAAS,YAAY,OAAO;IAC5B,SAAS,sBAAsB,MAAM;GACvC;EACF;EACA,UAAU,MAAc,IAAY;GAClC,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO;GAExB,OAAO,UAAU,MAAM;IAAE,GAAG;IAAQ,UAAU,kBAAkB,EAAE;GAAE,CAAC;EACvE;CACF;AACF"}
@@ -1,3 +1,4 @@
1
+ import "./filter-Bc7CtppJ.mjs";
1
2
  import * as generatorModule from "@babel/generator";
2
3
  import * as b from "@babel/types";
3
4
  import { COMPACT_VERSION, DEFAULT_HASH_LENGTH, messageHash, normalizeHashLength, normalizeMessage } from "@fluentic/i18n/compiler-support";
@@ -416,4 +417,4 @@ function transform(code, options = {}) {
416
417
  }
417
418
  export { compileMessage as a, collectMessages as c, compileCatalog as i, traverse as l, transform as n, messageId as o, COMPACT_VERSION as r, messageIdentity as s, compileProgram as t };
418
419
 
419
- //# sourceMappingURL=src-ZYntx97W.mjs.map
420
+ //# sourceMappingURL=src-BBeF3k1d.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-BBeF3k1d.mjs","names":["parse"],"sources":["../src/analyze.ts","../src/message.ts","../src/index.ts"],"sourcesContent":["import { parse } from '@babel/parser';\nimport * as traverseModule from '@babel/traverse';\nimport type { Binding, NodePath } from '@babel/traverse';\nimport * as b from '@babel/types';\nimport { normalizeMessage } from '@fluentic/i18n/compiler-support';\n\nconst traverse = ((traverseModule.default as unknown as { default?: typeof traverseModule.default; }).default ??\n traverseModule.default) as typeof traverseModule.default;\nexport { traverse };\n\nexport const importMap: Record<string, string> = {\n '@fluentic/i18n': '@fluentic/i18n/compiled',\n '@fluentic/i18n/core': '@fluentic/i18n/compiled',\n};\nexport type Scope = { context: string | null; notes: string[]; meta?: unknown; };\nexport type ExtractedMessage = Scope & { id: string; source: string; };\n\nexport function parseSource(code: string, filename: string) {\n return parse(code, {\n sourceFilename: filename,\n sourceType: 'unambiguous',\n plugins: [\n ...(/\\.[cm]?tsx?$/.test(filename) ? ['typescript' as const] : []),\n ...(!/\\.[cm]?ts$/.test(filename) ? ['jsx' as const] : []),\n 'decorators-legacy',\n 'importAttributes',\n ],\n });\n}\n\nexport function unwrap(path: NodePath): NodePath {\n while (\n path.isTSAsExpression() || path.isTSSatisfiesExpression() || path.isTSNonNullExpression() ||\n path.isTypeCastExpression() || path.isParenthesizedExpression()\n ) path = path.get('expression') as NodePath;\n\n return path;\n}\n\nexport function literal(path: NodePath, seen = new Set<Binding>()): string | null {\n path = unwrap(path);\n if (path.isStringLiteral()) return normalizeMessage(path.node.value);\n if (path.isTemplateLiteral() && !path.node.expressions.length) {\n return normalizeMessage(path.node.quasis[0].value.cooked ?? '');\n }\n if (path.isIdentifier()) {\n const binding = path.scope.getBinding(path.node.name);\n\n if (binding?.constant && binding.path.isVariableDeclarator() && !seen.has(binding)) {\n seen.add(binding);\n\n return literal(binding.path.get('init') as NodePath, seen);\n }\n }\n\n return null;\n}\n\nexport function memberName(path: NodePath): string | null {\n if (!path.isMemberExpression()) return null;\n\n const property = path.get('property');\n\n return !path.node.computed && property.isIdentifier()\n ? property.node.name\n : property.isStringLiteral()\n ? property.node.value\n : null;\n}\n\nexport function analyzer(imports = Object.keys(importMap)) {\n const memo = new Map<Binding, Scope | null>();\n const scopedBindings = new Set<Binding>();\n const scopeCalls = new Set<NodePath>();\n\n const resolve = (path: NodePath, visiting = new Set<Binding>()): Scope | null => {\n path = unwrap(path);\n if (path.isIdentifier()) {\n const binding = path.scope.getBinding(path.node.name);\n\n if (!binding) return null;\n if (memo.has(binding)) return memo.get(binding)!;\n if (visiting.has(binding)) throw new Error('[i18n] circular translator alias');\n if (binding.path.isImportSpecifier()) {\n const declaration = binding.path.parentPath;\n const imported = binding.path.node.imported;\n\n return declaration.isImportDeclaration() && imports.includes(declaration.node.source.value) &&\n (b.isIdentifier(imported) ? imported.name : imported.value) === 't' &&\n declaration.node.importKind !== 'type'\n ? { context: null, notes: [] }\n : null;\n }\n if (binding.path.isVariableDeclarator()) {\n visiting.add(binding);\n const scope = resolve(binding.path.get('init') as NodePath, visiting);\n visiting.delete(binding);\n if (scope && !binding.constant) {\n throw new Error('[i18n] translator aliases must not be reassigned: ' + path.node.name);\n }\n memo.set(binding, scope);\n if (scope) scopedBindings.add(binding);\n\n return scope;\n }\n\n return null;\n }\n if (path.isMemberExpression() && memberName(path) === 't') {\n const object = path.get('object');\n\n if (!object.isIdentifier()) return null;\n\n const binding = object.scope.getBinding(object.node.name);\n const declaration = binding?.path.parentPath;\n\n if (\n binding?.path.isImportNamespaceSpecifier() && declaration?.isImportDeclaration() &&\n imports.includes(declaration.node.source.value)\n ) return { context: null, notes: [] };\n }\n if (!path.isCallExpression()) return null;\n\n const callee = path.get('callee');\n const method = memberName(callee);\n\n if (!method || !['context', 'note', 'meta'].includes(method)) return null;\n\n const parent = resolve((callee as NodePath<b.MemberExpression>).get('object'), visiting);\n\n if (!parent) return null;\n if (path.node.arguments.length !== 1) throw new Error('[i18n] scope methods require one static argument');\n\n const argument = path.get('arguments.0') as NodePath;\n scopeCalls.add(path);\n if (method === 'meta') {\n const evaluated = argument.evaluate();\n\n if (!evaluated.confident) throw new Error('[i18n] metadata must be statically known');\n\n return { ...parent, meta: evaluated.value };\n }\n\n const value = literal(argument);\n\n if (value === null) throw new Error('[i18n] ' + method + ' must be a static string');\n\n return method === 'note'\n ? { ...parent, notes: [...parent.notes, value] }\n : { ...parent, context: parent.context ? `${parent.context}.${value}` : value };\n };\n\n return { resolve, scopedBindings, scopeCalls };\n}\n\nexport function collectMessages(code: string, filename: string, imports?: string[]): ExtractedMessage[] {\n const ast = parseSource(code, filename);\n const { resolve } = analyzer(imports);\n const messages: ExtractedMessage[] = [];\n traverse(ast, {\n CallExpression(path) {\n const callee = path.get('callee');\n const method = memberName(callee);\n\n if (!method || !['msg', 'text', 'jsx'].includes(method)) return;\n\n const scope = resolve((callee as NodePath<b.MemberExpression>).get('object'));\n\n if (!scope) return;\n\n const source = literal(path.get('arguments.0') as NodePath);\n\n if (source === null) {\n if (method === 'msg') {\n throw new Error(`[i18n] ${filename}:${path.node.loc?.start.line}: t.msg requires a static message`);\n }\n\n return;\n }\n messages.push({ ...scope, id: scope.context ? `${scope.context}\\0${source}` : source, source });\n },\n });\n\n return [...new Map(messages.map((message) => [message.id, message])).values()];\n}\n","import {\n type CompactMessage,\n type CompactPart,\n DEFAULT_HASH_LENGTH,\n messageHash,\n normalizeMessage,\n} from '@fluentic/i18n/compiler-support';\nimport { type MessageFormatElement, parse, TYPE } from '@formatjs/icu-messageformat-parser';\n\nexport { COMPACT_VERSION } from '@fluentic/i18n/compiler-support';\n\nexport function messageIdentity(context: string | null, source: string): string {\n source = normalizeMessage(source);\n return context ? `${context}\\0${source}` : source;\n}\n\nexport function messageId(context: string | null, source: string, hashLength = DEFAULT_HASH_LENGTH): string {\n return messageHash(messageIdentity(context, source), hashLength);\n}\n\nexport function compileMessage(source: string): CompactMessage {\n source = normalizeMessage(source);\n const compact = (elements: MessageFormatElement[]): CompactMessage => {\n const result: CompactPart[] = elements.map((element): CompactPart => {\n switch (element.type) {\n case TYPE.literal:\n return element.value;\n case TYPE.argument:\n return [0, element.value];\n case TYPE.number:\n case TYPE.date:\n case TYPE.time:\n return [\n element.type === TYPE.number ? 1 : element.type === TYPE.date ? 2 : 3,\n element.value,\n typeof element.style === 'object' && element.style\n ? element.style.parsedOptions as Record<string, unknown>\n : element.style ?? null,\n ];\n case TYPE.select:\n return [\n 4,\n element.value,\n Object.fromEntries(Object.entries(element.options).map(([key, option]) => [key, compact(option.value)])),\n ];\n case TYPE.plural:\n return [\n 5,\n element.value,\n element.offset,\n element.pluralType === 'ordinal' ? 1 : 0,\n Object.fromEntries(Object.entries(element.options).map(([key, option]) => [key, compact(option.value)])),\n ];\n case TYPE.pound:\n return [6];\n case TYPE.tag:\n return [7, element.value, compact(element.children)];\n }\n });\n\n return result.every((part) => typeof part === 'string') ? result.join('') : result;\n };\n\n return compact(parse(source, { captureLocation: false }));\n}\n\nexport function compileCatalog(\n records: Array<{ source: string; context: string | null; translation: string; }>,\n options: { hashLength?: number; } = {},\n): Array<[string, CompactMessage]> {\n const seen = new Map<string, string>();\n\n return records.flatMap((record) => {\n const id = messageId(record.context, record.source, options.hashLength);\n const identity = messageIdentity(record.context, record.source);\n\n if (seen.has(id) && seen.get(id) !== identity) throw new Error('[i18n] message hash collision: ' + id);\n seen.set(id, identity);\n\n return record.translation === '' ? [] : [[id, compileMessage(record.translation)] as [string, CompactMessage]];\n });\n}\n","import * as generatorModule from '@babel/generator';\nimport type { NodePath } from '@babel/traverse';\nimport * as b from '@babel/types';\nimport { DEFAULT_HASH_LENGTH, normalizeHashLength } from '@fluentic/i18n/compiler-support';\nimport {\n analyzer,\n collectMessages,\n type ExtractedMessage,\n importMap,\n literal,\n memberName,\n parseSource,\n traverse,\n} from './analyze';\nimport { compileMessage, messageId } from './message';\n\nexport { collectMessages } from './analyze';\nexport * from './filter';\nexport * from './message';\nexport type { PluginOptions } from './options';\n\nconst generate = ((generatorModule.default as unknown as { default?: typeof generatorModule.default; }).default ??\n generatorModule.default) as typeof generatorModule.default;\nexport type CompiledOptions = { hashLength?: number; };\nexport type CompilerOptions = CompiledOptions & { filename?: string; bindReactText?: boolean; };\n\ntype FunctionPath = NodePath<\n b.ArrowFunctionExpression | b.FunctionDeclaration | b.FunctionExpression | b.ObjectMethod | b.ClassMethod\n>;\n\nfunction reactFunction(path: NodePath): FunctionPath | null {\n for (\n let current = path.findParent((parent) => parent.isFunction());\n current;\n current = current.findParent(\n (parent) => parent.isFunction(),\n )\n ) {\n const fn = current as FunctionPath;\n const parent = fn.parentPath;\n const ownName = (b.isFunctionDeclaration(fn.node) || b.isFunctionExpression(fn.node)) ? fn.node.id?.name : null;\n const variableId = parent?.isVariableDeclarator() ? parent.get('id') : null;\n const name = ownName ?? (variableId?.isIdentifier() ? variableId.node.name : null);\n const exported = parent?.isExportDefaultDeclaration();\n\n if (exported || (name && (/^[A-Z]/.test(name) || /^use[A-Z]/.test(name)))) return fn;\n }\n\n return null;\n}\n\nfunction hashLength(length: CompilerOptions['hashLength']): number {\n return normalizeHashLength(length ?? DEFAULT_HASH_LENGTH);\n}\n\nfunction resolveJsxCallback(path: NodePath, seen = new Set<unknown>()): FunctionPath | null {\n while (\n path.isTSAsExpression() || path.isTSSatisfiesExpression() || path.isTSNonNullExpression() ||\n path.isTypeCastExpression() || path.isParenthesizedExpression()\n ) path = path.get('expression') as NodePath;\n if (path.isArrowFunctionExpression() || path.isFunctionExpression() || path.isFunctionDeclaration()) {\n return path as FunctionPath;\n }\n if (!path.isIdentifier()) return null;\n const binding = path.scope.getBinding(path.node.name);\n if (!binding?.constant || seen.has(binding)) return null;\n seen.add(binding);\n if (binding.path.isFunctionDeclaration()) return binding.path as FunctionPath;\n if (!binding.path.isVariableDeclarator()) return null;\n return resolveJsxCallback(binding.path.get('init') as NodePath, seen);\n}\n\nexport function compileProgram(code: string, filename: string, options: CompilerOptions = {}) {\n const ast = parseSource(code, filename);\n const messages: ExtractedMessage[] = [];\n\n const analysis = analyzer();\n\n const plans: Array<\n {\n path: NodePath<b.CallExpression>;\n source: string | null;\n scope: NonNullable<ReturnType<typeof analysis.resolve>>;\n reactOwner?: FunctionPath;\n }\n > = [];\n const declarations: NodePath<b.ImportDeclaration>[] = [];\n const jsxCallbacks = new Set<b.Function>();\n\n traverse(ast, {\n CallExpression(path) {\n const callee = path.get('callee');\n if (memberName(callee) !== 'jsx') return;\n const scope = analysis.resolve((callee as NodePath<b.MemberExpression>).get('object'));\n if (!scope) return;\n const callback = resolveJsxCallback(path.get('arguments.0') as NodePath);\n if (callback) jsxCallbacks.add(callback.node);\n },\n });\n\n let program: NodePath<b.Program> | undefined;\n const clientModule = ast.program.directives.some((directive) => directive.value.value === 'use client');\n traverse(ast, {\n Program(path) {\n program = path;\n },\n ExportAllDeclaration(path) {\n if (importMap[path.node.source.value]) {\n throw new Error('[i18n] do not re-export the translator in compiled mode; import t directly at each use');\n }\n },\n ExportNamedDeclaration(path) {\n if (\n path.node.source && importMap[path.node.source.value] &&\n path.node.specifiers.some((specifier) =>\n b.isExportSpecifier(specifier) && (b.isIdentifier(specifier.local) ? specifier.local.name : '') === 't'\n )\n ) throw new Error('[i18n] do not re-export the translator in compiled mode; export message descriptors instead');\n },\n ImportDeclaration(path) {\n if (importMap[path.node.source.value] && path.node.importKind !== 'type') declarations.push(path);\n },\n CallExpression(path) {\n const callee = path.get('callee');\n const method = memberName(callee);\n\n if (!method || !['msg', 'jsx', 'text'].includes(method)) return;\n\n const scope = analysis.resolve((callee as NodePath<b.MemberExpression>).get('object'));\n\n if (!scope) return;\n\n if (method === 'jsx' && resolveJsxCallback(path.get('arguments.0') as NodePath)) return;\n\n const source = literal(path.get('arguments.0') as NodePath);\n\n if (source === null && method === 'msg') {\n throw new Error(`[i18n] ${filename}:${path.node.loc?.start.line}: t.msg requires a static message`);\n }\n const callbackOwned = method === 'text' && Boolean(\n path.findParent((parent) => parent.isFunction() && jsxCallbacks.has(parent.node as b.Function)),\n );\n const reactOwner = options.bindReactText && clientModule && method === 'text' && !callbackOwned\n ? reactFunction(path)\n : undefined;\n if (options.bindReactText && clientModule && method === 'text' && !callbackOwned && !reactOwner) {\n throw new Error(\n `[i18n] ${filename}:${path.node.loc?.start.line}: client t.text must be rendered inside a component or hook`,\n );\n }\n plans.push({ path, source, scope, reactOwner: reactOwner ?? undefined });\n if (source !== null) {\n messages.push({ ...scope, source, id: scope.context ? `${scope.context}\\0${source}` : source });\n }\n },\n });\n // Discover unused/escaping scopes as well as scopes reached by message calls.\n traverse(ast, {\n VariableDeclarator(path) {\n analysis.resolve(path.get('id') as NodePath);\n },\n CallExpression(path) {\n const name = memberName(path.get('callee'));\n\n if (name && ['context', 'note', 'meta'].includes(name)) analysis.resolve(path);\n },\n });\n const expressionUse = (path: NodePath): NodePath => {\n while (\n path.parentPath &&\n (path.parentPath.isTSAsExpression() || path.parentPath.isTSSatisfiesExpression() ||\n path.parentPath.isTSNonNullExpression() || path.parentPath.isTypeCastExpression() ||\n path.parentPath.isParenthesizedExpression())\n ) path = path.parentPath;\n\n return path;\n };\n\n for (const path of analysis.scopeCalls) {\n const use = expressionUse(path);\n const parent = use.parentPath;\n\n if (parent?.isVariableDeclarator() || parent?.isExpressionStatement()) continue;\n if (parent?.isMemberExpression() && parent.get('object') === use && parent.parentPath?.isCallExpression()) continue;\n throw new Error('[i18n] scoped translator escapes same-file message calls');\n }\n for (const binding of analysis.scopedBindings) {\n if (binding.path.parentPath?.parentPath?.isExportNamedDeclaration()) {\n throw new Error('[i18n] scoped translators cannot be exported; repeat the context in the consuming file');\n }\n\n for (const reference of binding.referencePaths) {\n if (reference.findParent((parent) => parent.isTSType())) continue;\n\n const use = expressionUse(reference);\n const parent = use.parentPath;\n\n if (parent?.isVariableDeclarator() && parent.get('init') === use) continue;\n if (parent?.isMemberExpression() && parent.get('object') === use) {\n const method = memberName(parent);\n\n if (\n method && ['msg', 'text', 'jsx', 'context', 'note', 'meta'].includes(method) &&\n parent.parentPath?.isCallExpression()\n ) continue;\n }\n throw new Error('[i18n] scoped translator escapes same-file message calls: ' + binding.identifier.name);\n }\n }\n if (!declarations.length) return { ast, messages, changed: false };\n\n const helper = program!.scope.generateUidIdentifier('tc');\n const rendererHook = program!.scope.generateUidIdentifier('useI18nRenderer');\n const rendererBindings = new Map<FunctionPath, b.Identifier>();\n\n if (plans.length) {\n program!.unshiftContainer(\n 'body',\n b.importDeclaration([b.importSpecifier(helper, b.identifier('t'))], b.stringLiteral('@fluentic/i18n/compiled')),\n );\n }\n if (plans.some((plan) => plan.reactOwner)) {\n program!.unshiftContainer(\n 'body',\n b.importDeclaration(\n [b.importSpecifier(rendererHook, b.identifier('useI18nRenderer'))],\n b.stringLiteral('@fluentic/i18n/react'),\n ),\n );\n for (const owner of new Set(plans.map((plan) => plan.reactOwner).filter(Boolean) as FunctionPath[])) {\n const binding = owner.scope.generateUidIdentifier('text');\n rendererBindings.set(owner, binding);\n const body = owner.get('body');\n if (!body.isBlockStatement()) {\n const expression = body.node as b.Expression;\n body.replaceWith(b.blockStatement([b.returnStatement(expression)]));\n }\n (owner.get('body') as NodePath<b.BlockStatement>).unshiftContainer(\n 'body',\n b.variableDeclaration('const', [\n b.variableDeclarator(\n b.cloneNode(binding),\n b.callExpression(b.cloneNode(rendererHook), [\n b.memberExpression(b.cloneNode(helper), b.identifier('text')),\n ]),\n ),\n ]),\n );\n }\n }\n\n for (const { path, source, scope, reactOwner } of plans) {\n const callee = path.get('callee') as NodePath<b.MemberExpression>;\n const renderer = reactOwner && rendererBindings.get(reactOwner);\n if (renderer) callee.replaceWith(b.cloneNode(renderer));\n else callee.get('object').replaceWith(b.cloneNode(helper));\n if (source !== null) {\n const replacement = b.valueToNode([\n messageId(scope.context, source, hashLength(options.hashLength)),\n compileMessage(source),\n ]);\n b.inherits(replacement, path.node.arguments[0]);\n path.node.arguments[0] = replacement;\n }\n }\n // All scope uses were checked before mutation. Remove aliases from leaves to roots.\n let removed = true;\n\n while (removed) {\n removed = false;\n program!.scope.crawl();\n\n for (const binding of analysis.scopedBindings) {\n if (binding.path.removed) continue;\n\n const current = binding.path.scope.getBinding(binding.identifier.name);\n\n if (current && !current.referenced) {\n binding.path.remove();\n removed = true;\n }\n }\n }\n\n for (const path of analysis.scopeCalls) {\n if (!path.removed) {\n const use = expressionUse(path);\n\n if (use.parentPath?.isExpressionStatement()) use.parentPath.remove();\n }\n }\n for (const declaration of declarations) declaration.node.source.value = importMap[declaration.node.source.value];\n program!.scope.crawl();\n\n for (const declaration of declarations) {\n declaration.node.specifiers = declaration.node.specifiers.filter((specifier) => {\n if (\n !b.isImportSpecifier(specifier) ||\n (b.isIdentifier(specifier.imported) ? specifier.imported.name : specifier.imported.value) !== 't'\n ) return true;\n\n return Boolean(program!.scope.getBinding(specifier.local.name)?.referenced);\n });\n if (!declaration.node.specifiers.length) declaration.remove();\n }\n\n return { ast, messages, changed: true };\n}\n\nexport function transform(code: string, options: CompilerOptions = {}) {\n const filename = options.filename ?? 'source.tsx';\n const result = compileProgram(code, filename, options);\n\n if (!result.changed) return null;\n\n const output = generate(result.ast, { sourceMaps: true, sourceFileName: filename, comments: true }, code);\n\n return { code: output.code, map: output.map, messages: result.messages };\n}\n"],"mappings":";;;;;;;;AAMA,MAAM,WAAa,eAAe,QAAoE,WACpG,eAAe;AAGjB,MAAa,YAAoC;CAC/C,kBAAkB;CAClB,uBAAuB;AACzB;AAIA,SAAgB,YAAY,MAAc,UAAkB;CAC1D,OAAO,MAAM,MAAM;EACjB,gBAAgB;EAChB,YAAY;EACZ,SAAS;GACP,GAAI,eAAe,KAAK,QAAQ,IAAI,CAAC,YAAqB,IAAI,CAAC;GAC/D,GAAI,CAAC,aAAa,KAAK,QAAQ,IAAI,CAAC,KAAc,IAAI,CAAC;GACvD;GACA;EACF;CACF,CAAC;AACH;AAEA,SAAgB,OAAO,MAA0B;CAC/C,OACE,KAAK,iBAAiB,KAAK,KAAK,wBAAwB,KAAK,KAAK,sBAAsB,KACxF,KAAK,qBAAqB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CAExG,OAAO;EAAE,MAAM,OAAO;EAAM,KAAK,OAAO;EAAK,UAAU,OAAO;CAAS;AACzE"}
package/dist/vite.d.ts CHANGED
@@ -1,22 +1,33 @@
1
1
  import type { PluginOptions } from './options';
2
+ export type { PluginOptions } from './options';
2
3
  export default function fluentic(options?: PluginOptions): {
3
4
  name: string;
4
5
  buildStart(this: {
5
6
  addWatchFile(file: string): void;
6
7
  }): void;
7
8
  watchChange(id: string): void;
8
- transform(code: string, id: string): {
9
- code: string;
10
- map: {
11
- version: number;
12
- sources: string[];
13
- names: string[];
14
- sourceRoot?: string | undefined;
15
- sourcesContent?: string[] | undefined;
16
- mappings: string;
17
- file: string;
18
- } | null;
19
- messages: import("./analyze").ExtractedMessage[];
20
- } | null;
21
9
  enforce: 'pre';
10
+ transform: {
11
+ filter: {
12
+ id: {
13
+ include: RegExp | undefined;
14
+ exclude: RegExp[];
15
+ };
16
+ } | {
17
+ id: {};
18
+ };
19
+ handler: (code: string, id: string) => {
20
+ code: string;
21
+ map: {
22
+ version: number;
23
+ sources: string[];
24
+ names: string[];
25
+ sourceRoot?: string | undefined;
26
+ sourcesContent?: string[] | undefined;
27
+ mappings: string;
28
+ file: string;
29
+ } | null;
30
+ messages: import("./analyze").ExtractedMessage[];
31
+ } | null;
32
+ };
22
33
  };
package/dist/vite.mjs CHANGED
@@ -1,9 +1,15 @@
1
+ import { a as createTransformHookFilter } from "./filter-Bc7CtppJ.mjs";
1
2
  import fluentic$1 from "./rollup.mjs";
2
3
  // src/vite.ts
3
4
  function fluentic(options = {}) {
5
+ const adapter = fluentic$1(options);
4
6
  return {
5
- ...fluentic$1(options),
6
- enforce: "pre"
7
+ ...adapter,
8
+ enforce: "pre",
9
+ transform: {
10
+ filter: options.config ? { id: {} } : createTransformHookFilter(options),
11
+ handler: adapter.transform
12
+ }
7
13
  };
8
14
  }
9
15
  export { fluentic as default };
package/dist/vite.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.mjs","names":["rollup"],"sources":["../src/vite.ts"],"sourcesContent":["import type { PluginOptions } from './options';\nimport rollup from './rollup';\n\nexport default function fluentic(options: PluginOptions = {}) {\n // Vite uses the Rollup-compatible compiler adapter.\n return { ...rollup(options), enforce: 'pre' as const };\n}\n"],"mappings":";;AAGA,SAAwB,SAAS,UAAyB,CAAC,GAAG;CAE5D,OAAO;EAAE,GAAGA,WAAO,OAAO;EAAG,SAAS;CAAe;AACvD"}
1
+ {"version":3,"file":"vite.mjs","names":["rollup"],"sources":["../src/vite.ts"],"sourcesContent":["import { createTransformHookFilter } from './filter';\nimport type { PluginOptions } from './options';\nimport rollup from './rollup';\n\nexport type { PluginOptions } from './options';\n\nexport default function fluentic(options: PluginOptions = {}) {\n const adapter = rollup(options);\n return {\n ...adapter,\n enforce: 'pre' as const,\n transform: {\n // Config can change during watch mode. Keep native filtering broad in that\n // case; the adapter always checks the current authoritative shared filter.\n filter: options.config ? { id: {} } : createTransformHookFilter(options),\n handler: adapter.transform,\n },\n };\n}\n"],"mappings":";;;AAMA,SAAwB,SAAS,UAAyB,CAAC,GAAG;CAC5D,MAAM,UAAUA,WAAO,OAAO;CAC9B,OAAO;EACL,GAAG;EACH,SAAS;EACT,WAAW;GAGT,QAAQ,QAAQ,SAAS,EAAE,IAAI,CAAC,EAAE,IAAI,0BAA0B,OAAO;GACvE,SAAS,QAAQ;EACnB;CACF;AACF"}
@@ -1,15 +1,16 @@
1
- import { n as transform } from "./src-ZYntx97W.mjs";
2
- import { n as loadOptions } from "./options-WZfxnYkT.mjs";
1
+ import { n as transform } from "./src-BBeF3k1d.mjs";
2
+ import { i as createTransformFilter } from "./filter-Bc7CtppJ.mjs";
3
+ import { t as loadOptions } from "./options-CHPeMkCj.mjs";
3
4
  import remapping from "@jridgewell/remapping";
4
5
  // src/webpack-loader.ts
5
6
  function loader(code, inputMap) {
6
7
  this.cacheable?.();
7
8
  const options = loadOptions(this.getOptions?.() ?? {}, this.rootContext);
8
9
  if (options.configFile) this.addDependency(options.configFile);
9
- const result = transform(code, {
10
- filename: this.resourcePath,
11
- ...options
12
- });
10
+ const result = createTransformFilter(options)(this.resourcePath) ? transform(code, {
11
+ ...options,
12
+ filename: this.resourcePath
13
+ }) : null;
13
14
  this.callback(null, result?.code ?? code, result?.map && inputMap ? remapping([result.map, inputMap], () => null) : result?.map ?? inputMap);
14
15
  }
15
16
  export { loader as default };
@@ -1 +1 @@
1
- {"version":3,"file":"webpack-loader.mjs","names":[],"sources":["../src/webpack-loader.ts"],"sourcesContent":["import remapping from '@jridgewell/remapping';\nimport { transform } from './index';\nimport { loadOptions } from './options';\n\nexport default function loader(this: any, code: string, inputMap: unknown) {\n this.cacheable?.();\n const options = loadOptions(this.getOptions?.() ?? {}, this.rootContext);\n\n if (options.configFile) this.addDependency(options.configFile);\n\n const result = transform(code, { filename: this.resourcePath, ...options });\n this.callback(\n null,\n result?.code ?? code,\n result?.map && inputMap ? remapping([result.map as any, inputMap as any], () => null) : result?.map ?? inputMap,\n );\n}\n"],"mappings":";;;;AAIA,SAAwB,OAAkB,MAAc,UAAmB;CACzE,KAAK,YAAY;CACjB,MAAM,UAAU,YAAY,KAAK,aAAa,KAAK,CAAC,GAAG,KAAK,WAAW;CAEvE,IAAI,QAAQ,YAAY,KAAK,cAAc,QAAQ,UAAU;CAE7D,MAAM,SAAS,UAAU,MAAM;EAAE,UAAU,KAAK;EAAc,GAAG;CAAQ,CAAC;CAC1E,KAAK,SACH,MACA,QAAQ,QAAQ,MAChB,QAAQ,OAAO,WAAW,UAAU,CAAC,OAAO,KAAY,QAAe,SAAS,IAAI,IAAI,QAAQ,OAAO,QACzG;AACF"}
1
+ {"version":3,"file":"webpack-loader.mjs","names":[],"sources":["../src/webpack-loader.ts"],"sourcesContent":["import remapping from '@jridgewell/remapping';\nimport { createTransformFilter } from './filter';\nimport { transform } from './index';\nimport { loadOptions } from './options';\n\nexport default function loader(this: any, code: string, inputMap: unknown) {\n this.cacheable?.();\n const options = loadOptions(this.getOptions?.() ?? {}, this.rootContext);\n\n if (options.configFile) this.addDependency(options.configFile);\n\n const result = createTransformFilter(options)(this.resourcePath)\n ? transform(code, { ...options, filename: this.resourcePath })\n : null;\n this.callback(\n null,\n result?.code ?? code,\n result?.map && inputMap ? remapping([result.map as any, inputMap as any], () => null) : result?.map ?? inputMap,\n );\n}\n"],"mappings":";;;;;AAKA,SAAwB,OAAkB,MAAc,UAAmB;CACzE,KAAK,YAAY;CACjB,MAAM,UAAU,YAAY,KAAK,aAAa,KAAK,CAAC,GAAG,KAAK,WAAW;CAEvE,IAAI,QAAQ,YAAY,KAAK,cAAc,QAAQ,UAAU;CAE7D,MAAM,SAAS,sBAAsB,OAAO,CAAC,CAAC,KAAK,YAAY,IAC3D,UAAU,MAAM;EAAE,GAAG;EAAS,UAAU,KAAK;CAAa,CAAC,IAC3D;CACJ,KAAK,SACH,MACA,QAAQ,QAAQ,MAChB,QAAQ,OAAO,WAAW,UAAU,CAAC,OAAO,KAAY,QAAe,SAAS,IAAI,IAAI,QAAQ,OAAO,QACzG;AACF"}
package/dist/webpack.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { PluginOptions } from './options';
1
+ import { type PluginOptions } from './options';
2
2
  export default class FluenticI18nPlugin {
3
3
  private options;
4
4
  constructor(options?: PluginOptions);
package/dist/webpack.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import { i as createTransformFilter } from "./filter-Bc7CtppJ.mjs";
2
+ import { t as loadOptions } from "./options-CHPeMkCj.mjs";
1
3
  import { createRequire } from "node:module";
2
4
  // src/webpack.ts
3
5
  const require = createRequire(import.meta.url);
@@ -6,10 +8,10 @@ var FluenticI18nPlugin = class {
6
8
  this.options = options;
7
9
  }
8
10
  apply(compiler) {
11
+ const filter = this.options.config ? (id) => createTransformFilter(loadOptions(this.options, compiler.context))(id) : createTransformFilter(this.options);
9
12
  compiler.options.module.rules.push({
10
- test: /\.[cm]?[jt]sx?$/,
13
+ test: filter,
11
14
  enforce: "pre",
12
- ...this.options.includeDependencies ? {} : { exclude: /node_modules/ },
13
15
  use: [{
14
16
  loader: require.resolve("@fluentic/i18n-compiler/webpack-loader"),
15
17
  options: this.options
@@ -1 +1 @@
1
- {"version":3,"file":"webpack.mjs","names":[],"sources":["../src/webpack.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport type { PluginOptions } from './options';\n\nconst require = createRequire(import.meta.url);\nexport default class FluenticI18nPlugin {\n constructor(private options: PluginOptions = {}) {}\n apply(compiler: any) {\n compiler.options.module.rules.push({\n test: /\\.[cm]?[jt]sx?$/,\n enforce: 'pre',\n ...(this.options.includeDependencies ? {} : { exclude: /node_modules/ }),\n use: [{ loader: require.resolve('@fluentic/i18n-compiler/webpack-loader'), options: this.options }],\n });\n }\n}\n"],"mappings":";;AAGA,MAAM,UAAU,cAAc,YAAY,GAAG;AAC7C,IAAqB,qBAArB,MAAwC;CACtC,YAAY,UAAiC,CAAC,GAAG;EAA7B,KAAA,UAAA;CAA8B;CAClD,MAAM,UAAe;EACnB,SAAS,QAAQ,OAAO,MAAM,KAAK;GACjC,MAAM;GACN,SAAS;GACT,GAAI,KAAK,QAAQ,sBAAsB,CAAC,IAAI,EAAE,SAAS,eAAe;GACtE,KAAK,CAAC;IAAE,QAAQ,QAAQ,QAAQ,wCAAwC;IAAG,SAAS,KAAK;GAAQ,CAAC;EACpG,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"webpack.mjs","names":[],"sources":["../src/webpack.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { createTransformFilter } from './filter';\nimport { loadOptions, type PluginOptions } from './options';\n\nconst require = createRequire(import.meta.url);\nexport default class FluenticI18nPlugin {\n constructor(private options: PluginOptions = {}) {}\n apply(compiler: any) {\n const filter = this.options.config\n ? (id: string) => createTransformFilter(loadOptions(this.options, compiler.context))(id)\n : createTransformFilter(this.options);\n compiler.options.module.rules.push({\n test: filter,\n enforce: 'pre',\n use: [{ loader: require.resolve('@fluentic/i18n-compiler/webpack-loader'), options: this.options }],\n });\n }\n}\n"],"mappings":";;;;AAIA,MAAM,UAAU,cAAc,YAAY,GAAG;AAC7C,IAAqB,qBAArB,MAAwC;CACtC,YAAY,UAAiC,CAAC,GAAG;EAA7B,KAAA,UAAA;CAA8B;CAClD,MAAM,UAAe;EACnB,MAAM,SAAS,KAAK,QAAQ,UACvB,OAAe,sBAAsB,YAAY,KAAK,SAAS,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,IACrF,sBAAsB,KAAK,OAAO;EACtC,SAAS,QAAQ,OAAO,MAAM,KAAK;GACjC,MAAM;GACN,SAAS;GACT,KAAK,CAAC;IAAE,QAAQ,QAAQ,QAAQ,wCAAwC;IAAG,SAAS,KAAK;GAAQ,CAAC;EACpG,CAAC;CACH;AACF"}
@@ -25,6 +25,8 @@ _babel_traverse = __toESM(_babel_traverse, 1);
25
25
  let _babel_types = require("@babel/types");
26
26
  _babel_types = __toESM(_babel_types, 1);
27
27
  let _fluentic_i18n_compiler_support = require("@fluentic/i18n/compiler-support");
28
+ let picomatch = require("picomatch");
29
+ picomatch = __toESM(picomatch, 1);
28
30
  let _babel_generator = require("@babel/generator");
29
31
  _babel_generator = __toESM(_babel_generator, 1);
30
32
  let _formatjs_icu_messageformat_parser = require("@formatjs/icu-messageformat-parser");
@@ -147,6 +149,62 @@ function analyzer(imports = Object.keys(importMap)) {
147
149
  scopeCalls
148
150
  };
149
151
  }
152
+ // src/filter.ts
153
+ const normalizePath = (path) => path.replace(/\\/g, "/");
154
+ const DEFAULT_TRANSFORM_INCLUDE = /* @__PURE__ */ new RegExp("\\.[cm]?[jt]sx?$");
155
+ const DEFAULT_TRANSFORM_EXCLUDE = /node_modules/;
156
+ function normalizeModuleId(id) {
157
+ return id.split("?")[0]?.split("#")[0] ?? id;
158
+ }
159
+ function createTransformFilter(options = {}) {
160
+ const includes = normalizeMatchers(options.include);
161
+ const includePackages = createPackagePattern(options.includePackages);
162
+ const excludePackages = createPackagePattern(options.excludePackages);
163
+ const excludes = normalizeMatchers(options.exclude ?? (options.include || options.includeDependencies ? void 0 : DEFAULT_TRANSFORM_EXCLUDE));
164
+ const cache = /* @__PURE__ */ new Map();
165
+ const filter = ((id) => {
166
+ const filePath = normalizeModuleId(id);
167
+ const cached = cache.get(filePath);
168
+ if (cached !== void 0) return cached;
169
+ const packagePath = normalizePath(filePath);
170
+ const result = excludePackages?.test(packagePath) ? false : includePackages?.test(packagePath) ? DEFAULT_TRANSFORM_INCLUDE.test(filePath) : shouldTransform(filePath, includes, excludes);
171
+ cache.set(filePath, result);
172
+ return result;
173
+ });
174
+ filter.clear = () => {
175
+ cache.clear();
176
+ };
177
+ return filter;
178
+ }
179
+ function normalizeMatchers(patterns) {
180
+ if (!patterns) return [];
181
+ return (Array.isArray(patterns) ? patterns : [patterns]).map(createMatcher);
182
+ }
183
+ function createMatcher(pattern) {
184
+ if (pattern instanceof RegExp) return (id) => {
185
+ pattern.lastIndex = 0;
186
+ return pattern.test(id);
187
+ };
188
+ const matcher = (0, picomatch.default)(normalizePath(pattern), { dot: true });
189
+ return (id) => matcher(normalizePath(id));
190
+ }
191
+ function shouldTransform(id, includes, excludes) {
192
+ for (const exclude of excludes) if (exclude(id)) return false;
193
+ if (!includes.length) return DEFAULT_TRANSFORM_INCLUDE.test(id);
194
+ for (const include of includes) if (include(id)) return true;
195
+ return false;
196
+ }
197
+ function createPackagePattern(packages) {
198
+ const names = typeof packages === "string" ? [packages] : packages ?? [];
199
+ if (!names.length) return void 0;
200
+ for (const name of names) if (!/^(?:@[a-zA-Z0-9_][a-zA-Z0-9._-]*\/)?[a-zA-Z0-9_][a-zA-Z0-9._-]*$/.test(name)) throw new Error(`[i18n] Invalid package name in includePackages/excludePackages: ${JSON.stringify(name)}`);
201
+ const separator = "[/\\\\]";
202
+ const alternatives = names.map((name) => name.split("/").map(escapeRegExp).join(separator)).join("|");
203
+ return new RegExp(`^(?:[^?#]*${separator})?node_modules${separator}(?:${alternatives})(?![^?#]*${separator}node_modules${separator})(?:${separator}[^?#]*)?(?:[?#][\\s\\S]*)?$`);
204
+ }
205
+ function escapeRegExp(value) {
206
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
207
+ }
150
208
  // src/message.ts
151
209
  function messageIdentity(context, source) {
152
210
  source = (0, _fluentic_i18n_compiler_support.normalizeMessage)(source);
@@ -405,6 +463,7 @@ function loadOptions(options = {}, root = process.cwd()) {
405
463
  /** Owns parsing even when a host (e.g. Metro) passes an already parsed AST. */
406
464
  function fluenticBabel(_api, options = {}) {
407
465
  const config = loadOptions(options);
466
+ const filter = createTransformFilter(config);
408
467
  const handled = /* @__PURE__ */ new WeakSet();
409
468
  const enabled = (code) => code.includes("@fluentic/i18n");
410
469
  const compile = (code, filename) => {
@@ -416,11 +475,11 @@ function fluenticBabel(_api, options = {}) {
416
475
  return {
417
476
  name: "fluentic-i18n",
418
477
  parserOverride(code, parserOptions) {
419
- if (!enabled(code)) return void 0;
478
+ if (!enabled(code) || !filter(parserOptions.sourceFilename ?? "source.tsx")) return void 0;
420
479
  return compile(code, parserOptions.sourceFilename ?? "source.tsx");
421
480
  },
422
481
  pre(file) {
423
- if (!enabled(file.code) || handled.has(file.path.node)) return;
482
+ if (!enabled(file.code) || !filter(file.opts.filename ?? "source.tsx") || handled.has(file.path.node)) return;
424
483
  const ast = compile(file.code, file.opts.filename ?? "source.tsx");
425
484
  file.path.replaceWith(ast.program);
426
485
  file.scope.crawl();
@@ -1 +1 @@
1
- {"version":3,"file":"babel.cjs","names":["traverseModule","parse","normalizeMessage","b","normalizeMessage","DEFAULT_HASH_LENGTH","messageHash","TYPE","parse","generatorModule","b","normalizeHashLength","DEFAULT_HASH_LENGTH","resolve","createJiti"],"sources":["../src/analyze.ts","../src/message.ts","../src/index.ts","../src/options.ts","../src/babel.ts"],"sourcesContent":["import { parse } from '@babel/parser';\nimport * as traverseModule from '@babel/traverse';\nimport type { Binding, NodePath } from '@babel/traverse';\nimport * as b from '@babel/types';\nimport { normalizeMessage } from '@fluentic/i18n/compiler-support';\n\nconst traverse = ((traverseModule.default as unknown as { default?: typeof traverseModule.default; }).default ??\n traverseModule.default) as typeof traverseModule.default;\nexport { traverse };\n\nexport const importMap: Record<string, string> = {\n '@fluentic/i18n': '@fluentic/i18n/compiled',\n '@fluentic/i18n/core': '@fluentic/i18n/compiled',\n};\nexport type Scope = { context: string | null; notes: string[]; meta?: unknown; };\nexport type ExtractedMessage = Scope & { id: string; source: string; };\n\nexport function parseSource(code: string, filename: string) {\n return parse(code, {\n sourceFilename: filename,\n sourceType: 'unambiguous',\n plugins: [\n ...(/\\.[cm]?tsx?$/.test(filename) ? ['typescript' as const] : []),\n ...(!/\\.[cm]?ts$/.test(filename) ? ['jsx' as const] : []),\n 'decorators-legacy',\n 'importAttributes',\n ],\n });\n}\n\nexport function unwrap(path: NodePath): NodePath {\n while (\n path.isTSAsExpression() || path.isTSSatisfiesExpression() || path.isTSNonNullExpression() ||\n path.isTypeCastExpression() || path.isParenthesizedExpression()\n ) path = path.get('expression') as NodePath;\n\n return path;\n}\n\nexport function literal(path: NodePath, seen = new Set<Binding>()): string | null {\n path = unwrap(path);\n if (path.isStringLiteral()) return normalizeMessage(path.node.value);\n if (path.isTemplateLiteral() && !path.node.expressions.length) {\n return normalizeMessage(path.node.quasis[0].value.cooked ?? '');\n }\n if (path.isIdentifier()) {\n const binding = path.scope.getBinding(path.node.name);\n\n if (binding?.constant && binding.path.isVariableDeclarator() && !seen.has(binding)) {\n seen.add(binding);\n\n return literal(binding.path.get('init') as NodePath, seen);\n }\n }\n\n return null;\n}\n\nexport function memberName(path: NodePath): string | null {\n if (!path.isMemberExpression()) return null;\n\n const property = path.get('property');\n\n return !path.node.computed && property.isIdentifier()\n ? property.node.name\n : property.isStringLiteral()\n ? property.node.value\n : null;\n}\n\nexport function analyzer(imports = Object.keys(importMap)) {\n const memo = new Map<Binding, Scope | null>();\n const scopedBindings = new Set<Binding>();\n const scopeCalls = new Set<NodePath>();\n\n const resolve = (path: NodePath, visiting = new Set<Binding>()): Scope | null => {\n path = unwrap(path);\n if (path.isIdentifier()) {\n const binding = path.scope.getBinding(path.node.name);\n\n if (!binding) return null;\n if (memo.has(binding)) return memo.get(binding)!;\n if (visiting.has(binding)) throw new Error('[i18n] circular translator alias');\n if (binding.path.isImportSpecifier()) {\n const declaration = binding.path.parentPath;\n const imported = binding.path.node.imported;\n\n return declaration.isImportDeclaration() && imports.includes(declaration.node.source.value) &&\n (b.isIdentifier(imported) ? imported.name : imported.value) === 't' &&\n declaration.node.importKind !== 'type'\n ? { context: null, notes: [] }\n : null;\n }\n if (binding.path.isVariableDeclarator()) {\n visiting.add(binding);\n const scope = resolve(binding.path.get('init') as NodePath, visiting);\n visiting.delete(binding);\n if (scope && !binding.constant) {\n throw new Error('[i18n] translator aliases must not be reassigned: ' + path.node.name);\n }\n memo.set(binding, scope);\n if (scope) scopedBindings.add(binding);\n\n return scope;\n }\n\n return null;\n }\n if (path.isMemberExpression() && memberName(path) === 't') {\n const object = path.get('object');\n\n if (!object.isIdentifier()) return null;\n\n const binding = object.scope.getBinding(object.node.name);\n const declaration = binding?.path.parentPath;\n\n if (\n binding?.path.isImportNamespaceSpecifier() && declaration?.isImportDeclaration() &&\n imports.includes(declaration.node.source.value)\n ) return { context: null, notes: [] };\n }\n if (!path.isCallExpression()) return null;\n\n const callee = path.get('callee');\n const method = memberName(callee);\n\n if (!method || !['context', 'note', 'meta'].includes(method)) return null;\n\n const parent = resolve((callee as NodePath<b.MemberExpression>).get('object'), visiting);\n\n if (!parent) return null;\n if (path.node.arguments.length !== 1) throw new Error('[i18n] scope methods require one static argument');\n\n const argument = path.get('arguments.0') as NodePath;\n scopeCalls.add(path);\n if (method === 'meta') {\n const evaluated = argument.evaluate();\n\n if (!evaluated.confident) throw new Error('[i18n] metadata must be statically known');\n\n return { ...parent, meta: evaluated.value };\n }\n\n const value = literal(argument);\n\n if (value === null) throw new Error('[i18n] ' + method + ' must be a static string');\n\n return method === 'note'\n ? { ...parent, notes: [...parent.notes, value] }\n : { ...parent, context: parent.context ? `${parent.context}.${value}` : value };\n };\n\n return { resolve, scopedBindings, scopeCalls };\n}\n\nexport function collectMessages(code: string, filename: string, imports?: string[]): ExtractedMessage[] {\n const ast = parseSource(code, filename);\n const { resolve } = analyzer(imports);\n const messages: ExtractedMessage[] = [];\n traverse(ast, {\n CallExpression(path) {\n const callee = path.get('callee');\n const method = memberName(callee);\n\n if (!method || !['msg', 'text', 'jsx'].includes(method)) return;\n\n const scope = resolve((callee as NodePath<b.MemberExpression>).get('object'));\n\n if (!scope) return;\n\n const source = literal(path.get('arguments.0') as NodePath);\n\n if (source === null) {\n if (method === 'msg') {\n throw new Error(`[i18n] ${filename}:${path.node.loc?.start.line}: t.msg requires a static message`);\n }\n\n return;\n }\n messages.push({ ...scope, id: scope.context ? `${scope.context}\\0${source}` : source, source });\n },\n });\n\n return [...new Map(messages.map((message) => [message.id, message])).values()];\n}\n","import {\n type CompactMessage,\n type CompactPart,\n DEFAULT_HASH_LENGTH,\n messageHash,\n normalizeMessage,\n} from '@fluentic/i18n/compiler-support';\nimport { type MessageFormatElement, parse, TYPE } from '@formatjs/icu-messageformat-parser';\n\nexport { COMPACT_VERSION } from '@fluentic/i18n/compiler-support';\n\nexport function messageIdentity(context: string | null, source: string): string {\n source = normalizeMessage(source);\n return context ? `${context}\\0${source}` : source;\n}\n\nexport function messageId(context: string | null, source: string, hashLength = DEFAULT_HASH_LENGTH): string {\n return messageHash(messageIdentity(context, source), hashLength);\n}\n\nexport function compileMessage(source: string): CompactMessage {\n source = normalizeMessage(source);\n const compact = (elements: MessageFormatElement[]): CompactMessage => {\n const result: CompactPart[] = elements.map((element): CompactPart => {\n switch (element.type) {\n case TYPE.literal:\n return element.value;\n case TYPE.argument:\n return [0, element.value];\n case TYPE.number:\n case TYPE.date:\n case TYPE.time:\n return [\n element.type === TYPE.number ? 1 : element.type === TYPE.date ? 2 : 3,\n element.value,\n typeof element.style === 'object' && element.style\n ? element.style.parsedOptions as Record<string, unknown>\n : element.style ?? null,\n ];\n case TYPE.select:\n return [\n 4,\n element.value,\n Object.fromEntries(Object.entries(element.options).map(([key, option]) => [key, compact(option.value)])),\n ];\n case TYPE.plural:\n return [\n 5,\n element.value,\n element.offset,\n element.pluralType === 'ordinal' ? 1 : 0,\n Object.fromEntries(Object.entries(element.options).map(([key, option]) => [key, compact(option.value)])),\n ];\n case TYPE.pound:\n return [6];\n case TYPE.tag:\n return [7, element.value, compact(element.children)];\n }\n });\n\n return result.every((part) => typeof part === 'string') ? result.join('') : result;\n };\n\n return compact(parse(source, { captureLocation: false }));\n}\n\nexport function compileCatalog(\n records: Array<{ source: string; context: string | null; translation: string; }>,\n options: { hashLength?: number; } = {},\n): Array<[string, CompactMessage]> {\n const seen = new Map<string, string>();\n\n return records.flatMap((record) => {\n const id = messageId(record.context, record.source, options.hashLength);\n const identity = messageIdentity(record.context, record.source);\n\n if (seen.has(id) && seen.get(id) !== identity) throw new Error('[i18n] message hash collision: ' + id);\n seen.set(id, identity);\n\n return record.translation === '' ? [] : [[id, compileMessage(record.translation)] as [string, CompactMessage]];\n });\n}\n","import * as generatorModule from '@babel/generator';\nimport type { NodePath } from '@babel/traverse';\nimport * as b from '@babel/types';\nimport { DEFAULT_HASH_LENGTH, normalizeHashLength } from '@fluentic/i18n/compiler-support';\nimport {\n analyzer,\n collectMessages,\n type ExtractedMessage,\n importMap,\n literal,\n memberName,\n parseSource,\n traverse,\n} from './analyze';\nimport { compileMessage, messageId } from './message';\n\nexport { collectMessages } from './analyze';\nexport * from './message';\n\nconst generate = ((generatorModule.default as unknown as { default?: typeof generatorModule.default; }).default ??\n generatorModule.default) as typeof generatorModule.default;\nexport type CompiledOptions = { hashLength?: number; };\nexport type CompilerOptions = CompiledOptions & { filename?: string; bindReactText?: boolean; };\n\ntype FunctionPath = NodePath<\n b.ArrowFunctionExpression | b.FunctionDeclaration | b.FunctionExpression | b.ObjectMethod | b.ClassMethod\n>;\n\nfunction reactFunction(path: NodePath): FunctionPath | null {\n for (\n let current = path.findParent((parent) => parent.isFunction());\n current;\n current = current.findParent(\n (parent) => parent.isFunction(),\n )\n ) {\n const fn = current as FunctionPath;\n const parent = fn.parentPath;\n const ownName = (b.isFunctionDeclaration(fn.node) || b.isFunctionExpression(fn.node)) ? fn.node.id?.name : null;\n const variableId = parent?.isVariableDeclarator() ? parent.get('id') : null;\n const name = ownName ?? (variableId?.isIdentifier() ? variableId.node.name : null);\n const exported = parent?.isExportDefaultDeclaration();\n\n if (exported || (name && (/^[A-Z]/.test(name) || /^use[A-Z]/.test(name)))) return fn;\n }\n\n return null;\n}\n\nfunction hashLength(length: CompilerOptions['hashLength']): number {\n return normalizeHashLength(length ?? DEFAULT_HASH_LENGTH);\n}\n\nfunction resolveJsxCallback(path: NodePath, seen = new Set<unknown>()): FunctionPath | null {\n while (\n path.isTSAsExpression() || path.isTSSatisfiesExpression() || path.isTSNonNullExpression() ||\n path.isTypeCastExpression() || path.isParenthesizedExpression()\n ) path = path.get('expression') as NodePath;\n if (path.isArrowFunctionExpression() || path.isFunctionExpression() || path.isFunctionDeclaration()) {\n return path as FunctionPath;\n }\n if (!path.isIdentifier()) return null;\n const binding = path.scope.getBinding(path.node.name);\n if (!binding?.constant || seen.has(binding)) return null;\n seen.add(binding);\n if (binding.path.isFunctionDeclaration()) return binding.path as FunctionPath;\n if (!binding.path.isVariableDeclarator()) return null;\n return resolveJsxCallback(binding.path.get('init') as NodePath, seen);\n}\n\nexport function compileProgram(code: string, filename: string, options: CompilerOptions = {}) {\n const ast = parseSource(code, filename);\n const messages: ExtractedMessage[] = [];\n\n const analysis = analyzer();\n\n const plans: Array<\n {\n path: NodePath<b.CallExpression>;\n source: string | null;\n scope: NonNullable<ReturnType<typeof analysis.resolve>>;\n reactOwner?: FunctionPath;\n }\n > = [];\n const declarations: NodePath<b.ImportDeclaration>[] = [];\n const jsxCallbacks = new Set<b.Function>();\n\n traverse(ast, {\n CallExpression(path) {\n const callee = path.get('callee');\n if (memberName(callee) !== 'jsx') return;\n const scope = analysis.resolve((callee as NodePath<b.MemberExpression>).get('object'));\n if (!scope) return;\n const callback = resolveJsxCallback(path.get('arguments.0') as NodePath);\n if (callback) jsxCallbacks.add(callback.node);\n },\n });\n\n let program: NodePath<b.Program> | undefined;\n const clientModule = ast.program.directives.some((directive) => directive.value.value === 'use client');\n traverse(ast, {\n Program(path) {\n program = path;\n },\n ExportAllDeclaration(path) {\n if (importMap[path.node.source.value]) {\n throw new Error('[i18n] do not re-export the translator in compiled mode; import t directly at each use');\n }\n },\n ExportNamedDeclaration(path) {\n if (\n path.node.source && importMap[path.node.source.value] &&\n path.node.specifiers.some((specifier) =>\n b.isExportSpecifier(specifier) && (b.isIdentifier(specifier.local) ? specifier.local.name : '') === 't'\n )\n ) throw new Error('[i18n] do not re-export the translator in compiled mode; export message descriptors instead');\n },\n ImportDeclaration(path) {\n if (importMap[path.node.source.value] && path.node.importKind !== 'type') declarations.push(path);\n },\n CallExpression(path) {\n const callee = path.get('callee');\n const method = memberName(callee);\n\n if (!method || !['msg', 'jsx', 'text'].includes(method)) return;\n\n const scope = analysis.resolve((callee as NodePath<b.MemberExpression>).get('object'));\n\n if (!scope) return;\n\n if (method === 'jsx' && resolveJsxCallback(path.get('arguments.0') as NodePath)) return;\n\n const source = literal(path.get('arguments.0') as NodePath);\n\n if (source === null && method === 'msg') {\n throw new Error(`[i18n] ${filename}:${path.node.loc?.start.line}: t.msg requires a static message`);\n }\n const callbackOwned = method === 'text' && Boolean(\n path.findParent((parent) => parent.isFunction() && jsxCallbacks.has(parent.node as b.Function)),\n );\n const reactOwner = options.bindReactText && clientModule && method === 'text' && !callbackOwned\n ? reactFunction(path)\n : undefined;\n if (options.bindReactText && clientModule && method === 'text' && !callbackOwned && !reactOwner) {\n throw new Error(\n `[i18n] ${filename}:${path.node.loc?.start.line}: client t.text must be rendered inside a component or hook`,\n );\n }\n plans.push({ path, source, scope, reactOwner: reactOwner ?? undefined });\n if (source !== null) {\n messages.push({ ...scope, source, id: scope.context ? `${scope.context}\\0${source}` : source });\n }\n },\n });\n // Discover unused/escaping scopes as well as scopes reached by message calls.\n traverse(ast, {\n VariableDeclarator(path) {\n analysis.resolve(path.get('id') as NodePath);\n },\n CallExpression(path) {\n const name = memberName(path.get('callee'));\n\n if (name && ['context', 'note', 'meta'].includes(name)) analysis.resolve(path);\n },\n });\n const expressionUse = (path: NodePath): NodePath => {\n while (\n path.parentPath &&\n (path.parentPath.isTSAsExpression() || path.parentPath.isTSSatisfiesExpression() ||\n path.parentPath.isTSNonNullExpression() || path.parentPath.isTypeCastExpression() ||\n path.parentPath.isParenthesizedExpression())\n ) path = path.parentPath;\n\n return path;\n };\n\n for (const path of analysis.scopeCalls) {\n const use = expressionUse(path);\n const parent = use.parentPath;\n\n if (parent?.isVariableDeclarator() || parent?.isExpressionStatement()) continue;\n if (parent?.isMemberExpression() && parent.get('object') === use && parent.parentPath?.isCallExpression()) continue;\n throw new Error('[i18n] scoped translator escapes same-file message calls');\n }\n for (const binding of analysis.scopedBindings) {\n if (binding.path.parentPath?.parentPath?.isExportNamedDeclaration()) {\n throw new Error('[i18n] scoped translators cannot be exported; repeat the context in the consuming file');\n }\n\n for (const reference of binding.referencePaths) {\n if (reference.findParent((parent) => parent.isTSType())) continue;\n\n const use = expressionUse(reference);\n const parent = use.parentPath;\n\n if (parent?.isVariableDeclarator() && parent.get('init') === use) continue;\n if (parent?.isMemberExpression() && parent.get('object') === use) {\n const method = memberName(parent);\n\n if (\n method && ['msg', 'text', 'jsx', 'context', 'note', 'meta'].includes(method) &&\n parent.parentPath?.isCallExpression()\n ) continue;\n }\n throw new Error('[i18n] scoped translator escapes same-file message calls: ' + binding.identifier.name);\n }\n }\n if (!declarations.length) return { ast, messages, changed: false };\n\n const helper = program!.scope.generateUidIdentifier('tc');\n const rendererHook = program!.scope.generateUidIdentifier('useI18nRenderer');\n const rendererBindings = new Map<FunctionPath, b.Identifier>();\n\n if (plans.length) {\n program!.unshiftContainer(\n 'body',\n b.importDeclaration([b.importSpecifier(helper, b.identifier('t'))], b.stringLiteral('@fluentic/i18n/compiled')),\n );\n }\n if (plans.some((plan) => plan.reactOwner)) {\n program!.unshiftContainer(\n 'body',\n b.importDeclaration(\n [b.importSpecifier(rendererHook, b.identifier('useI18nRenderer'))],\n b.stringLiteral('@fluentic/i18n/react'),\n ),\n );\n for (const owner of new Set(plans.map((plan) => plan.reactOwner).filter(Boolean) as FunctionPath[])) {\n const binding = owner.scope.generateUidIdentifier('text');\n rendererBindings.set(owner, binding);\n const body = owner.get('body');\n if (!body.isBlockStatement()) {\n const expression = body.node as b.Expression;\n body.replaceWith(b.blockStatement([b.returnStatement(expression)]));\n }\n (owner.get('body') as NodePath<b.BlockStatement>).unshiftContainer(\n 'body',\n b.variableDeclaration('const', [\n b.variableDeclarator(\n b.cloneNode(binding),\n b.callExpression(b.cloneNode(rendererHook), [\n b.memberExpression(b.cloneNode(helper), b.identifier('text')),\n ]),\n ),\n ]),\n );\n }\n }\n\n for (const { path, source, scope, reactOwner } of plans) {\n const callee = path.get('callee') as NodePath<b.MemberExpression>;\n const renderer = reactOwner && rendererBindings.get(reactOwner);\n if (renderer) callee.replaceWith(b.cloneNode(renderer));\n else callee.get('object').replaceWith(b.cloneNode(helper));\n if (source !== null) {\n const replacement = b.valueToNode([\n messageId(scope.context, source, hashLength(options.hashLength)),\n compileMessage(source),\n ]);\n b.inherits(replacement, path.node.arguments[0]);\n path.node.arguments[0] = replacement;\n }\n }\n // All scope uses were checked before mutation. Remove aliases from leaves to roots.\n let removed = true;\n\n while (removed) {\n removed = false;\n program!.scope.crawl();\n\n for (const binding of analysis.scopedBindings) {\n if (binding.path.removed) continue;\n\n const current = binding.path.scope.getBinding(binding.identifier.name);\n\n if (current && !current.referenced) {\n binding.path.remove();\n removed = true;\n }\n }\n }\n\n for (const path of analysis.scopeCalls) {\n if (!path.removed) {\n const use = expressionUse(path);\n\n if (use.parentPath?.isExpressionStatement()) use.parentPath.remove();\n }\n }\n for (const declaration of declarations) declaration.node.source.value = importMap[declaration.node.source.value];\n program!.scope.crawl();\n\n for (const declaration of declarations) {\n declaration.node.specifiers = declaration.node.specifiers.filter((specifier) => {\n if (\n !b.isImportSpecifier(specifier) ||\n (b.isIdentifier(specifier.imported) ? specifier.imported.name : specifier.imported.value) !== 't'\n ) return true;\n\n return Boolean(program!.scope.getBinding(specifier.local.name)?.referenced);\n });\n if (!declaration.node.specifiers.length) declaration.remove();\n }\n\n return { ast, messages, changed: true };\n}\n\nexport function transform(code: string, options: CompilerOptions = {}) {\n const filename = options.filename ?? 'source.tsx';\n const result = compileProgram(code, filename, options);\n\n if (!result.changed) return null;\n\n const output = generate(result.ast, { sourceMaps: true, sourceFileName: filename, comments: true }, code);\n\n return { code: output.code, map: output.map, messages: result.messages };\n}\n","import { createJiti } from 'jiti';\nimport { resolve } from 'node:path';\n\nimport type { CompiledOptions } from './index';\n\nexport type PluginOptions = {\n /** Direct override; otherwise reuse compiled.hashLength from an explicitly selected config or the default. */\n hashLength?: number;\n /** Optional i18n config path, resolved from the plugin's working directory. */\n config?: string;\n includeDependencies?: boolean;\n /** Next.js client modules: bind synchronous text calls to the hydration boundary. */\n bindReactText?: boolean;\n};\n\nexport function loadOptions(\n options: PluginOptions = {},\n root = process.cwd(),\n): PluginOptions & { configFile?: string; } {\n if ('compiled' in options) {\n throw new TypeError('[i18n] compiler plugins always compile; use hashLength instead of compiled');\n }\n const file = options.config ? resolve(root, options.config) : undefined;\n\n const config = file\n ? createJiti(import.meta.url, { moduleCache: false })(file) as\n & { default?: PluginOptions & { compiled?: true | CompiledOptions; }; }\n & PluginOptions\n & { compiled?: true | CompiledOptions; }\n : {};\n const loaded = (config.default ?? config) as PluginOptions & { compiled?: true | CompiledOptions; };\n const { compiled, ...configOptions } = loaded;\n const sharedHashLength = typeof compiled === 'object' ? compiled.hashLength : undefined;\n\n return {\n ...configOptions,\n ...(sharedHashLength === undefined ? {} : { hashLength: sharedHashLength }),\n ...options,\n configFile: file,\n };\n}\n\nexport function accepts(id: string, options: PluginOptions) {\n return /\\.[cm]?[jt]sx?$/.test(id.split('?')[0]) && (options.includeDependencies || !id.includes('/node_modules/'));\n}\n","import { traverse } from './analyze';\nimport { compileProgram } from './index';\nimport { loadOptions, type PluginOptions } from './options';\n/** Owns parsing even when a host (e.g. Metro) passes an already parsed AST. */\nexport default function fluenticBabel(_api: unknown, options: PluginOptions = {}) {\n const config = loadOptions(options);\n const handled = new WeakSet<object>();\n const enabled = (code: string) => code.includes('@fluentic/i18n');\n\n const compile = (code: string, filename: string) => {\n const { ast } = compileProgram(code, filename, config);\n // Standalone paths have a default Hub. Babel must create its own paths for presets.\n traverse.cache.clear();\n handled.add(ast.program);\n\n return ast;\n };\n\n return {\n name: 'fluentic-i18n',\n parserOverride(code: string, parserOptions: { sourceFilename?: string; }) {\n if (!enabled(code)) return undefined;\n\n return compile(code, parserOptions.sourceFilename ?? 'source.tsx');\n },\n pre(file: any) {\n if (!enabled(file.code) || handled.has(file.path.node)) return;\n\n const ast = compile(file.code, file.opts.filename ?? 'source.tsx');\n file.path.replaceWith(ast.program);\n file.scope.crawl();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,WAAaA,gBAAe,QAAoE,WACpGA,gBAAe;AAGjB,MAAa,YAAoC;CAC/C,kBAAkB;CAClB,uBAAuB;AACzB;AAIA,SAAgB,YAAY,MAAc,UAAkB;CAC1D,QAAA,GAAOC,cAAAA,MAAAA,CAAM,MAAM;EACjB,gBAAgB;EAChB,YAAY;EACZ,SAAS;GACP,GAAI,eAAe,KAAK,QAAQ,IAAI,CAAC,YAAqB,IAAI,CAAC;GAC/D,GAAI,CAAC,aAAa,KAAK,QAAQ,IAAI,CAAC,KAAc,IAAI,CAAC;GACvD;GACA;EACF;CACF,CAAC;AACH;AAEA,SAAgB,OAAO,MAA0B;CAC/C,OACE,KAAK,iBAAiB,KAAK,KAAK,wBAAwB,KAAK,KAAK,sBAAsB,KACxF,KAAK,qBAAqB,KAA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OAAO;GACjC,KAAK,MAAM,MAAM;EACnB;CACF;AACF"}
1
+ {"version":3,"file":"babel.cjs","names":["traverseModule","parse","normalizeMessage","b","normalizeMessage","DEFAULT_HASH_LENGTH","messageHash","TYPE","parse","generatorModule","b","normalizeHashLength","DEFAULT_HASH_LENGTH","resolve","createJiti"],"sources":["../src/analyze.ts","../src/filter.ts","../src/message.ts","../src/index.ts","../src/options.ts","../src/babel.ts"],"sourcesContent":["import { parse } from '@babel/parser';\nimport * as traverseModule from '@babel/traverse';\nimport type { Binding, NodePath } from '@babel/traverse';\nimport * as b from '@babel/types';\nimport { normalizeMessage } from '@fluentic/i18n/compiler-support';\n\nconst traverse = ((traverseModule.default as unknown as { default?: typeof traverseModule.default; }).default ??\n traverseModule.default) as typeof traverseModule.default;\nexport { traverse };\n\nexport const importMap: Record<string, string> = {\n '@fluentic/i18n': '@fluentic/i18n/compiled',\n '@fluentic/i18n/core': '@fluentic/i18n/compiled',\n};\nexport type Scope = { context: string | null; notes: string[]; meta?: unknown; };\nexport type ExtractedMessage = Scope & { id: string; source: string; };\n\nexport function parseSource(code: string, filename: string) {\n return parse(code, {\n sourceFilename: filename,\n sourceType: 'unambiguous',\n plugins: [\n ...(/\\.[cm]?tsx?$/.test(filename) ? ['typescript' as const] : []),\n ...(!/\\.[cm]?ts$/.test(filename) ? ['jsx' as const] : []),\n 'decorators-legacy',\n 'importAttributes',\n ],\n });\n}\n\nexport function unwrap(path: NodePath): NodePath {\n while (\n path.isTSAsExpression() || path.isTSSatisfiesExpression() || path.isTSNonNullExpression() ||\n path.isTypeCastExpression() || path.isParenthesizedExpression()\n ) path = path.get('expression') as NodePath;\n\n return path;\n}\n\nexport function literal(path: NodePath, seen = new Set<Binding>()): string | null {\n path = unwrap(path);\n if (path.isStringLiteral()) return normalizeMessage(path.node.value);\n if (path.isTemplateLiteral() && !path.node.expressions.length) {\n return normalizeMessage(path.node.quasis[0].value.cooked ?? '');\n }\n if (path.isIdentifier()) {\n const binding = path.scope.getBinding(path.node.name);\n\n if (binding?.constant && binding.path.isVariableDeclarator() && !seen.has(binding)) {\n seen.add(binding);\n\n return literal(binding.path.get('init') as NodePath, seen);\n }\n }\n\n return null;\n}\n\nexport function memberName(path: NodePath): string | null {\n if (!path.isMemberExpression()) return null;\n\n const property = path.get('property');\n\n return !path.node.computed && property.isIdentifier()\n ? property.node.name\n : property.isStringLiteral()\n ? property.node.value\n : null;\n}\n\nexport function analyzer(imports = Object.keys(importMap)) {\n const memo = new Map<Binding, Scope | null>();\n const scopedBindings = new Set<Binding>();\n const scopeCalls = new Set<NodePath>();\n\n const resolve = (path: NodePath, visiting = new Set<Binding>()): Scope | null => {\n path = unwrap(path);\n if (path.isIdentifier()) {\n const binding = path.scope.getBinding(path.node.name);\n\n if (!binding) return null;\n if (memo.has(binding)) return memo.get(binding)!;\n if (visiting.has(binding)) throw new Error('[i18n] circular translator alias');\n if (binding.path.isImportSpecifier()) {\n const declaration = binding.path.parentPath;\n const imported = binding.path.node.imported;\n\n return declaration.isImportDeclaration() && imports.includes(declaration.node.source.value) &&\n (b.isIdentifier(imported) ? imported.name : imported.value) === 't' &&\n declaration.node.importKind !== 'type'\n ? { context: null, notes: [] }\n : null;\n }\n if (binding.path.isVariableDeclarator()) {\n visiting.add(binding);\n const scope = resolve(binding.path.get('init') as NodePath, visiting);\n visiting.delete(binding);\n if (scope && !binding.constant) {\n throw new Error('[i18n] translator aliases must not be reassigned: ' + path.node.name);\n }\n memo.set(binding, scope);\n if (scope) scopedBindings.add(binding);\n\n return scope;\n }\n\n return null;\n }\n if (path.isMemberExpression() && memberName(path) === 't') {\n const object = path.get('object');\n\n if (!object.isIdentifier()) return null;\n\n const binding = object.scope.getBinding(object.node.name);\n const declaration = binding?.path.parentPath;\n\n if (\n binding?.path.isImportNamespaceSpecifier() && declaration?.isImportDeclaration() &&\n imports.includes(declaration.node.source.value)\n ) return { context: null, notes: [] };\n }\n if (!path.isCallExpression()) return null;\n\n const callee = path.get('callee');\n const method = memberName(callee);\n\n if (!method || !['context', 'note', 'meta'].includes(method)) return null;\n\n const parent = resolve((callee as NodePath<b.MemberExpression>).get('object'), visiting);\n\n if (!parent) return null;\n if (path.node.arguments.length !== 1) throw new Error('[i18n] scope methods require one static argument');\n\n const argument = path.get('arguments.0') as NodePath;\n scopeCalls.add(path);\n if (method === 'meta') {\n const evaluated = argument.evaluate();\n\n if (!evaluated.confident) throw new Error('[i18n] metadata must be statically known');\n\n return { ...parent, meta: evaluated.value };\n }\n\n const value = literal(argument);\n\n if (value === null) throw new Error('[i18n] ' + method + ' must be a static string');\n\n return method === 'note'\n ? { ...parent, notes: [...parent.notes, value] }\n : { ...parent, context: parent.context ? `${parent.context}.${value}` : value };\n };\n\n return { resolve, scopedBindings, scopeCalls };\n}\n\nexport function collectMessages(code: string, filename: string, imports?: string[]): ExtractedMessage[] {\n const ast = parseSource(code, filename);\n const { resolve } = analyzer(imports);\n const messages: ExtractedMessage[] = [];\n traverse(ast, {\n CallExpression(path) {\n const callee = path.get('callee');\n const method = memberName(callee);\n\n if (!method || !['msg', 'text', 'jsx'].includes(method)) return;\n\n const scope = resolve((callee as NodePath<b.MemberExpression>).get('object'));\n\n if (!scope) return;\n\n const source = literal(path.get('arguments.0') as NodePath);\n\n if (source === null) {\n if (method === 'msg') {\n throw new Error(`[i18n] ${filename}:${path.node.loc?.start.line}: t.msg requires a static message`);\n }\n\n return;\n }\n messages.push({ ...scope, id: scope.context ? `${scope.context}\\0${source}` : source, source });\n },\n });\n\n return [...new Map(messages.map((message) => [message.id, message])).values()];\n}\n","import picomatch from 'picomatch';\nconst normalizePath = (path: string) => path.replace(/\\\\/g, '/');\n\nexport const DEFAULT_TRANSFORM_INCLUDE_PATTERN = '\\\\.[cm]?[jt]sx?$';\n\nexport const DEFAULT_TRANSFORM_INCLUDE = new RegExp(DEFAULT_TRANSFORM_INCLUDE_PATTERN);\n\nexport const DEFAULT_TRANSFORM_EXCLUDE = /node_modules/;\n\nexport type FilterPattern = string | RegExp | Array<string | RegExp>;\n\nexport type TransformFilterOptions = {\n /** File globs or regular expressions matched against IDs without query/hash suffixes. */\n include?: FilterPattern;\n exclude?: FilterPattern;\n /** Backwards-compatible opt-in to all dependencies; explicit exclude still wins. */\n includeDependencies?: boolean;\n /** Exact npm package names whose script files override file include/exclude rules. */\n includePackages?: string | string[];\n /** Exact npm package names excluded before all other filter rules. */\n excludePackages?: string | string[];\n};\n\nexport type TransformFilter = {\n (id: string): boolean;\n clear(): void;\n};\n\nexport function normalizeModuleId(id: string) {\n return id.split('?')[0]?.split('#')[0] ?? id;\n}\n\nexport function createTransformFilter(options: TransformFilterOptions = {}): TransformFilter {\n const includes = normalizeMatchers(options.include);\n const includePackages = createPackagePattern(options.includePackages);\n const excludePackages = createPackagePattern(options.excludePackages);\n\n const excludes = normalizeMatchers(\n options.exclude ?? (options.include || options.includeDependencies ? undefined : DEFAULT_TRANSFORM_EXCLUDE),\n );\n\n const cache = new Map<string, boolean>();\n\n const filter = ((id: string) => {\n const filePath = normalizeModuleId(id);\n const cached = cache.get(filePath);\n\n if (cached !== undefined) return cached;\n\n const packagePath = normalizePath(filePath);\n const result = excludePackages?.test(packagePath)\n ? false\n : includePackages?.test(packagePath)\n ? DEFAULT_TRANSFORM_INCLUDE.test(filePath)\n : shouldTransform(filePath, includes, excludes);\n\n cache.set(filePath, result);\n\n return result;\n }) as TransformFilter;\n\n filter.clear = () => {\n cache.clear();\n };\n\n return filter;\n}\n\ntype FilterMatcher = (id: string) => boolean;\n\nfunction normalizeMatchers(patterns?: FilterPattern) {\n if (!patterns) return [];\n\n const items = Array.isArray(patterns) ? patterns : [patterns];\n\n return items.map(createMatcher);\n}\n\nfunction createMatcher(pattern: string | RegExp): FilterMatcher {\n if (pattern instanceof RegExp) {\n return (id) => {\n pattern.lastIndex = 0;\n return pattern.test(id);\n };\n }\n\n const matcher = picomatch(normalizePath(pattern), {\n dot: true,\n });\n\n return (id) => matcher(normalizePath(id));\n}\n\nfunction shouldTransform(\n id: string,\n includes: FilterMatcher[],\n excludes: FilterMatcher[],\n): boolean {\n for (const exclude of excludes) {\n if (exclude(id)) return false;\n }\n\n if (!includes.length) {\n return DEFAULT_TRANSFORM_INCLUDE.test(id);\n }\n\n for (const include of includes) {\n if (include(id)) return true;\n }\n\n return false;\n}\n\n/** A conservative native prefilter; the shared JS filter remains authoritative. */\nexport function createTransformHookFilter(options: TransformFilterOptions = {}) {\n const includePackages = createPackagePattern(options.includePackages);\n const excludePackages = createPackagePattern(options.excludePackages);\n const exclude: RegExp[] = [];\n if (excludePackages) exclude.push(excludePackages);\n\n if (!options.include && !options.includeDependencies && options.exclude === undefined) {\n // Package inclusions override the default node_modules exclusion.\n exclude.push(\n new RegExp(\n `^${includePackages ? `(?!${includePackages.source})` : ''}[^?#]*node_modules`,\n ),\n );\n }\n\n return {\n id: {\n // Custom globs/regexes run against normalized IDs in the shared filter.\n // Keeping the native check broad avoids changing their matching semantics.\n include: options.include ? undefined : /^[^?#]*\\.[cm]?[jt]sx?(?:[?#][\\s\\S]*)?$/,\n exclude,\n },\n };\n}\n\nfunction createPackagePattern(packages?: string | string[]): RegExp | undefined {\n const names = typeof packages === 'string' ? [packages] : packages ?? [];\n if (!names.length) return undefined;\n\n for (const name of names) {\n if (!/^(?:@[a-zA-Z0-9_][a-zA-Z0-9._-]*\\/)?[a-zA-Z0-9_][a-zA-Z0-9._-]*$/.test(name)) {\n throw new Error(\n `[i18n] Invalid package name in includePackages/excludePackages: ${JSON.stringify(name)}`,\n );\n }\n }\n\n const separator = '[/\\\\\\\\]';\n const alternatives = names.map((name) => name.split('/').map(escapeRegExp).join(separator)).join('|');\n // Match the innermost node_modules owner, including pnpm's nested layout.\n // A package's nested dependencies must not inherit its include/exclude rule.\n return new RegExp(\n `^(?:[^?#]*${separator})?node_modules${separator}(?:${alternatives})` +\n `(?![^?#]*${separator}node_modules${separator})` +\n `(?:${separator}[^?#]*)?(?:[?#][\\\\s\\\\S]*)?$`,\n );\n}\n\nfunction escapeRegExp(value: string) {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n","import {\n type CompactMessage,\n type CompactPart,\n DEFAULT_HASH_LENGTH,\n messageHash,\n normalizeMessage,\n} from '@fluentic/i18n/compiler-support';\nimport { type MessageFormatElement, parse, TYPE } from '@formatjs/icu-messageformat-parser';\n\nexport { COMPACT_VERSION } from '@fluentic/i18n/compiler-support';\n\nexport function messageIdentity(context: string | null, source: string): string {\n source = normalizeMessage(source);\n return context ? `${context}\\0${source}` : source;\n}\n\nexport function messageId(context: string | null, source: string, hashLength = DEFAULT_HASH_LENGTH): string {\n return messageHash(messageIdentity(context, source), hashLength);\n}\n\nexport function compileMessage(source: string): CompactMessage {\n source = normalizeMessage(source);\n const compact = (elements: MessageFormatElement[]): CompactMessage => {\n const result: CompactPart[] = elements.map((element): CompactPart => {\n switch (element.type) {\n case TYPE.literal:\n return element.value;\n case TYPE.argument:\n return [0, element.value];\n case TYPE.number:\n case TYPE.date:\n case TYPE.time:\n return [\n element.type === TYPE.number ? 1 : element.type === TYPE.date ? 2 : 3,\n element.value,\n typeof element.style === 'object' && element.style\n ? element.style.parsedOptions as Record<string, unknown>\n : element.style ?? null,\n ];\n case TYPE.select:\n return [\n 4,\n element.value,\n Object.fromEntries(Object.entries(element.options).map(([key, option]) => [key, compact(option.value)])),\n ];\n case TYPE.plural:\n return [\n 5,\n element.value,\n element.offset,\n element.pluralType === 'ordinal' ? 1 : 0,\n Object.fromEntries(Object.entries(element.options).map(([key, option]) => [key, compact(option.value)])),\n ];\n case TYPE.pound:\n return [6];\n case TYPE.tag:\n return [7, element.value, compact(element.children)];\n }\n });\n\n return result.every((part) => typeof part === 'string') ? result.join('') : result;\n };\n\n return compact(parse(source, { captureLocation: false }));\n}\n\nexport function compileCatalog(\n records: Array<{ source: string; context: string | null; translation: string; }>,\n options: { hashLength?: number; } = {},\n): Array<[string, CompactMessage]> {\n const seen = new Map<string, string>();\n\n return records.flatMap((record) => {\n const id = messageId(record.context, record.source, options.hashLength);\n const identity = messageIdentity(record.context, record.source);\n\n if (seen.has(id) && seen.get(id) !== identity) throw new Error('[i18n] message hash collision: ' + id);\n seen.set(id, identity);\n\n return record.translation === '' ? [] : [[id, compileMessage(record.translation)] as [string, CompactMessage]];\n });\n}\n","import * as generatorModule from '@babel/generator';\nimport type { NodePath } from '@babel/traverse';\nimport * as b from '@babel/types';\nimport { DEFAULT_HASH_LENGTH, normalizeHashLength } from '@fluentic/i18n/compiler-support';\nimport {\n analyzer,\n collectMessages,\n type ExtractedMessage,\n importMap,\n literal,\n memberName,\n parseSource,\n traverse,\n} from './analyze';\nimport { compileMessage, messageId } from './message';\n\nexport { collectMessages } from './analyze';\nexport * from './filter';\nexport * from './message';\nexport type { PluginOptions } from './options';\n\nconst generate = ((generatorModule.default as unknown as { default?: typeof generatorModule.default; }).default ??\n generatorModule.default) as typeof generatorModule.default;\nexport type CompiledOptions = { hashLength?: number; };\nexport type CompilerOptions = CompiledOptions & { filename?: string; bindReactText?: boolean; };\n\ntype FunctionPath = NodePath<\n b.ArrowFunctionExpression | b.FunctionDeclaration | b.FunctionExpression | b.ObjectMethod | b.ClassMethod\n>;\n\nfunction reactFunction(path: NodePath): FunctionPath | null {\n for (\n let current = path.findParent((parent) => parent.isFunction());\n current;\n current = current.findParent(\n (parent) => parent.isFunction(),\n )\n ) {\n const fn = current as FunctionPath;\n const parent = fn.parentPath;\n const ownName = (b.isFunctionDeclaration(fn.node) || b.isFunctionExpression(fn.node)) ? fn.node.id?.name : null;\n const variableId = parent?.isVariableDeclarator() ? parent.get('id') : null;\n const name = ownName ?? (variableId?.isIdentifier() ? variableId.node.name : null);\n const exported = parent?.isExportDefaultDeclaration();\n\n if (exported || (name && (/^[A-Z]/.test(name) || /^use[A-Z]/.test(name)))) return fn;\n }\n\n return null;\n}\n\nfunction hashLength(length: CompilerOptions['hashLength']): number {\n return normalizeHashLength(length ?? DEFAULT_HASH_LENGTH);\n}\n\nfunction resolveJsxCallback(path: NodePath, seen = new Set<unknown>()): FunctionPath | null {\n while (\n path.isTSAsExpression() || path.isTSSatisfiesExpression() || path.isTSNonNullExpression() ||\n path.isTypeCastExpression() || path.isParenthesizedExpression()\n ) path = path.get('expression') as NodePath;\n if (path.isArrowFunctionExpression() || path.isFunctionExpression() || path.isFunctionDeclaration()) {\n return path as FunctionPath;\n }\n if (!path.isIdentifier()) return null;\n const binding = path.scope.getBinding(path.node.name);\n if (!binding?.constant || seen.has(binding)) return null;\n seen.add(binding);\n if (binding.path.isFunctionDeclaration()) return binding.path as FunctionPath;\n if (!binding.path.isVariableDeclarator()) return null;\n return resolveJsxCallback(binding.path.get('init') as NodePath, seen);\n}\n\nexport function compileProgram(code: string, filename: string, options: CompilerOptions = {}) {\n const ast = parseSource(code, filename);\n const messages: ExtractedMessage[] = [];\n\n const analysis = analyzer();\n\n const plans: Array<\n {\n path: NodePath<b.CallExpression>;\n source: string | null;\n scope: NonNullable<ReturnType<typeof analysis.resolve>>;\n reactOwner?: FunctionPath;\n }\n > = [];\n const declarations: NodePath<b.ImportDeclaration>[] = [];\n const jsxCallbacks = new Set<b.Function>();\n\n traverse(ast, {\n CallExpression(path) {\n const callee = path.get('callee');\n if (memberName(callee) !== 'jsx') return;\n const scope = analysis.resolve((callee as NodePath<b.MemberExpression>).get('object'));\n if (!scope) return;\n const callback = resolveJsxCallback(path.get('arguments.0') as NodePath);\n if (callback) jsxCallbacks.add(callback.node);\n },\n });\n\n let program: NodePath<b.Program> | undefined;\n const clientModule = ast.program.directives.some((directive) => directive.value.value === 'use client');\n traverse(ast, {\n Program(path) {\n program = path;\n },\n ExportAllDeclaration(path) {\n if (importMap[path.node.source.value]) {\n throw new Error('[i18n] do not re-export the translator in compiled mode; import t directly at each use');\n }\n },\n ExportNamedDeclaration(path) {\n if (\n path.node.source && importMap[path.node.source.value] &&\n path.node.specifiers.some((specifier) =>\n b.isExportSpecifier(specifier) && (b.isIdentifier(specifier.local) ? specifier.local.name : '') === 't'\n )\n ) throw new Error('[i18n] do not re-export the translator in compiled mode; export message descriptors instead');\n },\n ImportDeclaration(path) {\n if (importMap[path.node.source.value] && path.node.importKind !== 'type') declarations.push(path);\n },\n CallExpression(path) {\n const callee = path.get('callee');\n const method = memberName(callee);\n\n if (!method || !['msg', 'jsx', 'text'].includes(method)) return;\n\n const scope = analysis.resolve((callee as NodePath<b.MemberExpression>).get('object'));\n\n if (!scope) return;\n\n if (method === 'jsx' && resolveJsxCallback(path.get('arguments.0') as NodePath)) return;\n\n const source = literal(path.get('arguments.0') as NodePath);\n\n if (source === null && method === 'msg') {\n throw new Error(`[i18n] ${filename}:${path.node.loc?.start.line}: t.msg requires a static message`);\n }\n const callbackOwned = method === 'text' && Boolean(\n path.findParent((parent) => parent.isFunction() && jsxCallbacks.has(parent.node as b.Function)),\n );\n const reactOwner = options.bindReactText && clientModule && method === 'text' && !callbackOwned\n ? reactFunction(path)\n : undefined;\n if (options.bindReactText && clientModule && method === 'text' && !callbackOwned && !reactOwner) {\n throw new Error(\n `[i18n] ${filename}:${path.node.loc?.start.line}: client t.text must be rendered inside a component or hook`,\n );\n }\n plans.push({ path, source, scope, reactOwner: reactOwner ?? undefined });\n if (source !== null) {\n messages.push({ ...scope, source, id: scope.context ? `${scope.context}\\0${source}` : source });\n }\n },\n });\n // Discover unused/escaping scopes as well as scopes reached by message calls.\n traverse(ast, {\n VariableDeclarator(path) {\n analysis.resolve(path.get('id') as NodePath);\n },\n CallExpression(path) {\n const name = memberName(path.get('callee'));\n\n if (name && ['context', 'note', 'meta'].includes(name)) analysis.resolve(path);\n },\n });\n const expressionUse = (path: NodePath): NodePath => {\n while (\n path.parentPath &&\n (path.parentPath.isTSAsExpression() || path.parentPath.isTSSatisfiesExpression() ||\n path.parentPath.isTSNonNullExpression() || path.parentPath.isTypeCastExpression() ||\n path.parentPath.isParenthesizedExpression())\n ) path = path.parentPath;\n\n return path;\n };\n\n for (const path of analysis.scopeCalls) {\n const use = expressionUse(path);\n const parent = use.parentPath;\n\n if (parent?.isVariableDeclarator() || parent?.isExpressionStatement()) continue;\n if (parent?.isMemberExpression() && parent.get('object') === use && parent.parentPath?.isCallExpression()) continue;\n throw new Error('[i18n] scoped translator escapes same-file message calls');\n }\n for (const binding of analysis.scopedBindings) {\n if (binding.path.parentPath?.parentPath?.isExportNamedDeclaration()) {\n throw new Error('[i18n] scoped translators cannot be exported; repeat the context in the consuming file');\n }\n\n for (const reference of binding.referencePaths) {\n if (reference.findParent((parent) => parent.isTSType())) continue;\n\n const use = expressionUse(reference);\n const parent = use.parentPath;\n\n if (parent?.isVariableDeclarator() && parent.get('init') === use) continue;\n if (parent?.isMemberExpression() && parent.get('object') === use) {\n const method = memberName(parent);\n\n if (\n method && ['msg', 'text', 'jsx', 'context', 'note', 'meta'].includes(method) &&\n parent.parentPath?.isCallExpression()\n ) continue;\n }\n throw new Error('[i18n] scoped translator escapes same-file message calls: ' + binding.identifier.name);\n }\n }\n if (!declarations.length) return { ast, messages, changed: false };\n\n const helper = program!.scope.generateUidIdentifier('tc');\n const rendererHook = program!.scope.generateUidIdentifier('useI18nRenderer');\n const rendererBindings = new Map<FunctionPath, b.Identifier>();\n\n if (plans.length) {\n program!.unshiftContainer(\n 'body',\n b.importDeclaration([b.importSpecifier(helper, b.identifier('t'))], b.stringLiteral('@fluentic/i18n/compiled')),\n );\n }\n if (plans.some((plan) => plan.reactOwner)) {\n program!.unshiftContainer(\n 'body',\n b.importDeclaration(\n [b.importSpecifier(rendererHook, b.identifier('useI18nRenderer'))],\n b.stringLiteral('@fluentic/i18n/react'),\n ),\n );\n for (const owner of new Set(plans.map((plan) => plan.reactOwner).filter(Boolean) as FunctionPath[])) {\n const binding = owner.scope.generateUidIdentifier('text');\n rendererBindings.set(owner, binding);\n const body = owner.get('body');\n if (!body.isBlockStatement()) {\n const expression = body.node as b.Expression;\n body.replaceWith(b.blockStatement([b.returnStatement(expression)]));\n }\n (owner.get('body') as NodePath<b.BlockStatement>).unshiftContainer(\n 'body',\n b.variableDeclaration('const', [\n b.variableDeclarator(\n b.cloneNode(binding),\n b.callExpression(b.cloneNode(rendererHook), [\n b.memberExpression(b.cloneNode(helper), b.identifier('text')),\n ]),\n ),\n ]),\n );\n }\n }\n\n for (const { path, source, scope, reactOwner } of plans) {\n const callee = path.get('callee') as NodePath<b.MemberExpression>;\n const renderer = reactOwner && rendererBindings.get(reactOwner);\n if (renderer) callee.replaceWith(b.cloneNode(renderer));\n else callee.get('object').replaceWith(b.cloneNode(helper));\n if (source !== null) {\n const replacement = b.valueToNode([\n messageId(scope.context, source, hashLength(options.hashLength)),\n compileMessage(source),\n ]);\n b.inherits(replacement, path.node.arguments[0]);\n path.node.arguments[0] = replacement;\n }\n }\n // All scope uses were checked before mutation. Remove aliases from leaves to roots.\n let removed = true;\n\n while (removed) {\n removed = false;\n program!.scope.crawl();\n\n for (const binding of analysis.scopedBindings) {\n if (binding.path.removed) continue;\n\n const current = binding.path.scope.getBinding(binding.identifier.name);\n\n if (current && !current.referenced) {\n binding.path.remove();\n removed = true;\n }\n }\n }\n\n for (const path of analysis.scopeCalls) {\n if (!path.removed) {\n const use = expressionUse(path);\n\n if (use.parentPath?.isExpressionStatement()) use.parentPath.remove();\n }\n }\n for (const declaration of declarations) declaration.node.source.value = importMap[declaration.node.source.value];\n program!.scope.crawl();\n\n for (const declaration of declarations) {\n declaration.node.specifiers = declaration.node.specifiers.filter((specifier) => {\n if (\n !b.isImportSpecifier(specifier) ||\n (b.isIdentifier(specifier.imported) ? specifier.imported.name : specifier.imported.value) !== 't'\n ) return true;\n\n return Boolean(program!.scope.getBinding(specifier.local.name)?.referenced);\n });\n if (!declaration.node.specifiers.length) declaration.remove();\n }\n\n return { ast, messages, changed: true };\n}\n\nexport function transform(code: string, options: CompilerOptions = {}) {\n const filename = options.filename ?? 'source.tsx';\n const result = compileProgram(code, filename, options);\n\n if (!result.changed) return null;\n\n const output = generate(result.ast, { sourceMaps: true, sourceFileName: filename, comments: true }, code);\n\n return { code: output.code, map: output.map, messages: result.messages };\n}\n","import { createJiti } from 'jiti';\nimport { resolve } from 'node:path';\n\nimport type { TransformFilterOptions } from './filter';\nimport type { CompiledOptions } from './index';\n\nexport type { FilterPattern, TransformFilterOptions } from './filter';\n\nexport type PluginOptions = TransformFilterOptions & {\n /** Direct override; otherwise reuse compiled.hashLength from an explicitly selected config or the default. */\n hashLength?: number;\n /** Optional i18n config path, resolved from the plugin's working directory. */\n config?: string;\n /** Next.js client modules: bind synchronous text calls to the hydration boundary. */\n bindReactText?: boolean;\n};\n\nexport function loadOptions(\n options: PluginOptions = {},\n root = process.cwd(),\n): PluginOptions & { configFile?: string; } {\n if ('compiled' in options) {\n throw new TypeError('[i18n] compiler plugins always compile; use hashLength instead of compiled');\n }\n const file = options.config ? resolve(root, options.config) : undefined;\n\n const config = file\n ? createJiti(import.meta.url, { moduleCache: false })(file) as\n & { default?: PluginOptions & { compiled?: true | CompiledOptions; }; }\n & PluginOptions\n & { compiled?: true | CompiledOptions; }\n : {};\n const loaded = (config.default ?? config) as PluginOptions & { compiled?: true | CompiledOptions; };\n const { compiled, ...configOptions } = loaded;\n const sharedHashLength = typeof compiled === 'object' ? compiled.hashLength : undefined;\n\n return {\n ...configOptions,\n ...(sharedHashLength === undefined ? {} : { hashLength: sharedHashLength }),\n ...options,\n configFile: file,\n };\n}\n","import { traverse } from './analyze';\nimport { createTransformFilter } from './filter';\nimport { compileProgram } from './index';\nimport { loadOptions, type PluginOptions } from './options';\n/** Owns parsing even when a host (e.g. Metro) passes an already parsed AST. */\nexport default function fluenticBabel(_api: unknown, options: PluginOptions = {}) {\n const config = loadOptions(options);\n const filter = createTransformFilter(config);\n const handled = new WeakSet<object>();\n const enabled = (code: string) => code.includes('@fluentic/i18n');\n\n const compile = (code: string, filename: string) => {\n const { ast } = compileProgram(code, filename, config);\n // Standalone paths have a default Hub. Babel must create its own paths for presets.\n traverse.cache.clear();\n handled.add(ast.program);\n\n return ast;\n };\n\n return {\n name: 'fluentic-i18n',\n parserOverride(code: string, parserOptions: { sourceFilename?: string; }) {\n if (!enabled(code) || !filter(parserOptions.sourceFilename ?? 'source.tsx')) return undefined;\n\n return compile(code, parserOptions.sourceFilename ?? 'source.tsx');\n },\n pre(file: any) {\n if (!enabled(file.code) || !filter(file.opts.filename ?? 'source.tsx') || handled.has(file.path.node)) return;\n\n const ast = compile(file.code, file.opts.filename ?? 'source.tsx');\n file.path.replaceWith(ast.program);\n file.scope.crawl();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,WAAaA,gBAAe,QAAoE,WACpGA,gBAAe;AAGjB,MAAa,YAAoC;CAC/C,kBAAkB;CAClB,uBAAuB;AACzB;AAIA,SAAgB,YAAY,MAAc,UAAkB;CAC1D,QAAA,GAAOC,cAAAA,MAAAA,CAAM,MAAM;EACjB,gBAAgB;EAChB,YAAY;EACZ,SAAS;GACP,GAAI,eAAe,KAAK,QAAQ,IAAI,CAAC,YAAqB,IAAI,CAAC;GAC/D,GAAI,CAAC,aAAa,KAAK,QAAQ,IAAI,CAAC,KAAc,IAAI,CAAC;GACvD;GACA;EACF;CACF,CAAC;AACH;AAEA,SAAgB,OAAO,MAA0B;CAC/C,OACE,KAAK,iBAAiB,KAAK,KAAK,wBAAwB,KAAK,KAAK,sBAAsB,KACxF,KAAK,qBAAqB,KAAK,KAAK,0BAA0B,GAC9D,OAAO,KAAK,IAAI,YAAY;CAE9B,OAAO;AACT;AAEA,SAAgB,QAAQ,MAAgB,uBAAO,IAAI,IAAa,GAAkB;CAChF,OAAO,OAAO,IAAI;CAClB,IAAI,KAAK,gBAAgB,GAAG,QAAA,GAAOC,gCAAAA,iBAAAA,CAAiB,KAAK,KAAK,KAAK;CACnE,IAAI,KAAK,kBAAkB,KAAK,CAAC,KAAK,KAAK,YAAY,QACrD,QAAA,GAAOA,gCAAAA,iBAAAA,CAAiB,KAAK,KAAK,OAAO,EAAE,CAAC,MAAM,UAAU,EAAE;CAEhE,IAAI,KAAK,aAAa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3C,MAAM,0BAAU,IAAI,QAAgB;CACpC,MAAM,WAAW,SAAiB,KAAK,SAAS,gBAAgB;CAEhE,MAAM,WAAW,MAAc,aAAqB;EAClD,MAAM,EAAE,QAAQ,eAAe,MAAM,UAAU,MAAM;EAErD,SAAS,MAAM,MAAM;EACrB,QAAQ,IAAI,IAAI,OAAO;EAEvB,OAAO;CACT;CAEA,OAAO;EACL,MAAM;EACN,eAAe,MAAc,eAA6C;GACxE,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,OAAO,cAAc,kBAAkB,YAAY,GAAG,OAAO,KAAA;GAEpF,OAAO,QAAQ,MAAM,cAAc,kBAAkB,YAAY;EACnE;EACA,IAAI,MAAW;GACb,IAAI,CAAC,QAAQ,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,YAAY,YAAY,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,GAAG;GAEvG,MAAM,MAAM,QAAQ,KAAK,MAAM,KAAK,KAAK,YAAY,YAAY;GACjE,KAAK,KAAK,YAAY,IAAI,OAAO;GACjC,KAAK,MAAM,MAAM;EACnB;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentic/i18n-compiler",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.1.0-beta.3",
4
4
  "description": "Build-time compiler and bundler integrations for Fluentic i18n.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -64,18 +64,21 @@
64
64
  "@babel/parser": "7.29.15",
65
65
  "@babel/traverse": "7.29.15",
66
66
  "@babel/types": "7.29.15",
67
- "@types/babel__traverse": "^7.28.0",
68
67
  "@formatjs/icu-messageformat-parser": "2.11.4",
69
68
  "@jridgewell/remapping": "^2.3.5",
69
+ "@types/babel__traverse": "^7.28.0",
70
70
  "jiti": "^2.7.0",
71
+ "picomatch": "^4.0.7",
71
72
  "@fluentic/i18n": "0.1.0-beta.2"
72
73
  },
73
74
  "devDependencies": {
74
75
  "@babel/core": "7.29.13",
75
76
  "@types/babel__generator": "^7.27.0",
76
77
  "@types/node": "^22.15.0",
78
+ "@types/picomatch": "^4.0.3",
77
79
  "tsdown": "^0.22.1",
78
- "typescript": "^7.0.2"
80
+ "typescript": "^7.0.2",
81
+ "vite": "^7.3.7"
79
82
  },
80
83
  "scripts": {
81
84
  "build": "tsdown && tsc -p tsconfig.build.json",
@@ -83,4 +86,4 @@
83
86
  "typecheck": "tsc -p tsconfig.json --noEmit",
84
87
  "test": "pnpm build && node --test test/*.test.mjs"
85
88
  }
86
- }
89
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"options-WZfxnYkT.mjs","names":[],"sources":["../src/options.ts"],"sourcesContent":["import { createJiti } from 'jiti';\nimport { resolve } from 'node:path';\n\nimport type { CompiledOptions } from './index';\n\nexport type PluginOptions = {\n /** Direct override; otherwise reuse compiled.hashLength from an explicitly selected config or the default. */\n hashLength?: number;\n /** Optional i18n config path, resolved from the plugin's working directory. */\n config?: string;\n includeDependencies?: boolean;\n /** Next.js client modules: bind synchronous text calls to the hydration boundary. */\n bindReactText?: boolean;\n};\n\nexport function loadOptions(\n options: PluginOptions = {},\n root = process.cwd(),\n): PluginOptions & { configFile?: string; } {\n if ('compiled' in options) {\n throw new TypeError('[i18n] compiler plugins always compile; use hashLength instead of compiled');\n }\n const file = options.config ? resolve(root, options.config) : undefined;\n\n const config = file\n ? createJiti(import.meta.url, { moduleCache: false })(file) as\n & { default?: PluginOptions & { compiled?: true | CompiledOptions; }; }\n & PluginOptions\n & { compiled?: true | CompiledOptions; }\n : {};\n const loaded = (config.default ?? config) as PluginOptions & { compiled?: true | CompiledOptions; };\n const { compiled, ...configOptions } = loaded;\n const sharedHashLength = typeof compiled === 'object' ? compiled.hashLength : undefined;\n\n return {\n ...configOptions,\n ...(sharedHashLength === undefined ? {} : { hashLength: sharedHashLength }),\n ...options,\n configFile: file,\n };\n}\n\nexport function accepts(id: string, options: PluginOptions) {\n return /\\.[cm]?[jt]sx?$/.test(id.split('?')[0]) && (options.includeDependencies || !id.includes('/node_modules/'));\n}\n"],"mappings":";;;AAeA,SAAgB,YACd,UAAyB,CAAC,GAC1B,OAAO,QAAQ,IAAI,GACuB;CAC1C,IAAI,cAAc,SAChB,MAAM,IAAI,UAAU,4EAA4E;CAElG,MAAM,OAAO,QAAQ,SAAS,QAAQ,MAAM,QAAQ,MAAM,IAAI,KAAA;CAE9D,MAAM,SAAS,OACX,WAAW,YAAY,KAAK,EAAE,aAAa,MAAM,CAAC,CAAC,CAAC,IAAI,IAIxD,CAAC;CAEL,MAAM,EAAE,UAAU,GAAG,kBADL,OAAO,WAAW;CAElC,MAAM,mBAAmB,OAAO,aAAa,WAAW,SAAS,aAAa,KAAA;CAE9E,OAAO;EACL,GAAG;EACH,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,iBAAiB;EACzE,GAAG;EACH,YAAY;CACd;AACF;AAEA,SAAgB,QAAQ,IAAY,SAAwB;CAC1D,OAAO,kBAAkB,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,QAAQ,uBAAuB,CAAC,GAAG,SAAS,gBAAgB;AAClH"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"src-ZYntx97W.mjs","names":["parse"],"sources":["../src/analyze.ts","../src/message.ts","../src/index.ts"],"sourcesContent":["import { parse } from '@babel/parser';\nimport * as traverseModule from '@babel/traverse';\nimport type { Binding, NodePath } from '@babel/traverse';\nimport * as b from '@babel/types';\nimport { normalizeMessage } from '@fluentic/i18n/compiler-support';\n\nconst traverse = ((traverseModule.default as unknown as { default?: typeof traverseModule.default; }).default ??\n traverseModule.default) as typeof traverseModule.default;\nexport { traverse };\n\nexport const importMap: Record<string, string> = {\n '@fluentic/i18n': '@fluentic/i18n/compiled',\n '@fluentic/i18n/core': '@fluentic/i18n/compiled',\n};\nexport type Scope = { context: string | null; notes: string[]; meta?: unknown; };\nexport type ExtractedMessage = Scope & { id: string; source: string; };\n\nexport function parseSource(code: string, filename: string) {\n return parse(code, {\n sourceFilename: filename,\n sourceType: 'unambiguous',\n plugins: [\n ...(/\\.[cm]?tsx?$/.test(filename) ? ['typescript' as const] : []),\n ...(!/\\.[cm]?ts$/.test(filename) ? ['jsx' as const] : []),\n 'decorators-legacy',\n 'importAttributes',\n ],\n });\n}\n\nexport function unwrap(path: NodePath): NodePath {\n while (\n path.isTSAsExpression() || path.isTSSatisfiesExpression() || path.isTSNonNullExpression() ||\n path.isTypeCastExpression() || path.isParenthesizedExpression()\n ) path = path.get('expression') as NodePath;\n\n return path;\n}\n\nexport function literal(path: NodePath, seen = new Set<Binding>()): string | null {\n path = unwrap(path);\n if (path.isStringLiteral()) return normalizeMessage(path.node.value);\n if (path.isTemplateLiteral() && !path.node.expressions.length) {\n return normalizeMessage(path.node.quasis[0].value.cooked ?? '');\n }\n if (path.isIdentifier()) {\n const binding = path.scope.getBinding(path.node.name);\n\n if (binding?.constant && binding.path.isVariableDeclarator() && !seen.has(binding)) {\n seen.add(binding);\n\n return literal(binding.path.get('init') as NodePath, seen);\n }\n }\n\n return null;\n}\n\nexport function memberName(path: NodePath): string | null {\n if (!path.isMemberExpression()) return null;\n\n const property = path.get('property');\n\n return !path.node.computed && property.isIdentifier()\n ? property.node.name\n : property.isStringLiteral()\n ? property.node.value\n : null;\n}\n\nexport function analyzer(imports = Object.keys(importMap)) {\n const memo = new Map<Binding, Scope | null>();\n const scopedBindings = new Set<Binding>();\n const scopeCalls = new Set<NodePath>();\n\n const resolve = (path: NodePath, visiting = new Set<Binding>()): Scope | null => {\n path = unwrap(path);\n if (path.isIdentifier()) {\n const binding = path.scope.getBinding(path.node.name);\n\n if (!binding) return null;\n if (memo.has(binding)) return memo.get(binding)!;\n if (visiting.has(binding)) throw new Error('[i18n] circular translator alias');\n if (binding.path.isImportSpecifier()) {\n const declaration = binding.path.parentPath;\n const imported = binding.path.node.imported;\n\n return declaration.isImportDeclaration() && imports.includes(declaration.node.source.value) &&\n (b.isIdentifier(imported) ? imported.name : imported.value) === 't' &&\n declaration.node.importKind !== 'type'\n ? { context: null, notes: [] }\n : null;\n }\n if (binding.path.isVariableDeclarator()) {\n visiting.add(binding);\n const scope = resolve(binding.path.get('init') as NodePath, visiting);\n visiting.delete(binding);\n if (scope && !binding.constant) {\n throw new Error('[i18n] translator aliases must not be reassigned: ' + path.node.name);\n }\n memo.set(binding, scope);\n if (scope) scopedBindings.add(binding);\n\n return scope;\n }\n\n return null;\n }\n if (path.isMemberExpression() && memberName(path) === 't') {\n const object = path.get('object');\n\n if (!object.isIdentifier()) return null;\n\n const binding = object.scope.getBinding(object.node.name);\n const declaration = binding?.path.parentPath;\n\n if (\n binding?.path.isImportNamespaceSpecifier() && declaration?.isImportDeclaration() &&\n imports.includes(declaration.node.source.value)\n ) return { context: null, notes: [] };\n }\n if (!path.isCallExpression()) return null;\n\n const callee = path.get('callee');\n const method = memberName(callee);\n\n if (!method || !['context', 'note', 'meta'].includes(method)) return null;\n\n const parent = resolve((callee as NodePath<b.MemberExpression>).get('object'), visiting);\n\n if (!parent) return null;\n if (path.node.arguments.length !== 1) throw new Error('[i18n] scope methods require one static argument');\n\n const argument = path.get('arguments.0') as NodePath;\n scopeCalls.add(path);\n if (method === 'meta') {\n const evaluated = argument.evaluate();\n\n if (!evaluated.confident) throw new Error('[i18n] metadata must be statically known');\n\n return { ...parent, meta: evaluated.value };\n }\n\n const value = literal(argument);\n\n if (value === null) throw new Error('[i18n] ' + method + ' must be a static string');\n\n return method === 'note'\n ? { ...parent, notes: [...parent.notes, value] }\n : { ...parent, context: parent.context ? `${parent.context}.${value}` : value };\n };\n\n return { resolve, scopedBindings, scopeCalls };\n}\n\nexport function collectMessages(code: string, filename: string, imports?: string[]): ExtractedMessage[] {\n const ast = parseSource(code, filename);\n const { resolve } = analyzer(imports);\n const messages: ExtractedMessage[] = [];\n traverse(ast, {\n CallExpression(path) {\n const callee = path.get('callee');\n const method = memberName(callee);\n\n if (!method || !['msg', 'text', 'jsx'].includes(method)) return;\n\n const scope = resolve((callee as NodePath<b.MemberExpression>).get('object'));\n\n if (!scope) return;\n\n const source = literal(path.get('arguments.0') as NodePath);\n\n if (source === null) {\n if (method === 'msg') {\n throw new Error(`[i18n] ${filename}:${path.node.loc?.start.line}: t.msg requires a static message`);\n }\n\n return;\n }\n messages.push({ ...scope, id: scope.context ? `${scope.context}\\0${source}` : source, source });\n },\n });\n\n return [...new Map(messages.map((message) => [message.id, message])).values()];\n}\n","import {\n type CompactMessage,\n type CompactPart,\n DEFAULT_HASH_LENGTH,\n messageHash,\n normalizeMessage,\n} from '@fluentic/i18n/compiler-support';\nimport { type MessageFormatElement, parse, TYPE } from '@formatjs/icu-messageformat-parser';\n\nexport { COMPACT_VERSION } from '@fluentic/i18n/compiler-support';\n\nexport function messageIdentity(context: string | null, source: string): string {\n source = normalizeMessage(source);\n return context ? `${context}\\0${source}` : source;\n}\n\nexport function messageId(context: string | null, source: string, hashLength = DEFAULT_HASH_LENGTH): string {\n return messageHash(messageIdentity(context, source), hashLength);\n}\n\nexport function compileMessage(source: string): CompactMessage {\n source = normalizeMessage(source);\n const compact = (elements: MessageFormatElement[]): CompactMessage => {\n const result: CompactPart[] = elements.map((element): CompactPart => {\n switch (element.type) {\n case TYPE.literal:\n return element.value;\n case TYPE.argument:\n return [0, element.value];\n case TYPE.number:\n case TYPE.date:\n case TYPE.time:\n return [\n element.type === TYPE.number ? 1 : element.type === TYPE.date ? 2 : 3,\n element.value,\n typeof element.style === 'object' && element.style\n ? element.style.parsedOptions as Record<string, unknown>\n : element.style ?? null,\n ];\n case TYPE.select:\n return [\n 4,\n element.value,\n Object.fromEntries(Object.entries(element.options).map(([key, option]) => [key, compact(option.value)])),\n ];\n case TYPE.plural:\n return [\n 5,\n element.value,\n element.offset,\n element.pluralType === 'ordinal' ? 1 : 0,\n Object.fromEntries(Object.entries(element.options).map(([key, option]) => [key, compact(option.value)])),\n ];\n case TYPE.pound:\n return [6];\n case TYPE.tag:\n return [7, element.value, compact(element.children)];\n }\n });\n\n return result.every((part) => typeof part === 'string') ? result.join('') : result;\n };\n\n return compact(parse(source, { captureLocation: false }));\n}\n\nexport function compileCatalog(\n records: Array<{ source: string; context: string | null; translation: string; }>,\n options: { hashLength?: number; } = {},\n): Array<[string, CompactMessage]> {\n const seen = new Map<string, string>();\n\n return records.flatMap((record) => {\n const id = messageId(record.context, record.source, options.hashLength);\n const identity = messageIdentity(record.context, record.source);\n\n if (seen.has(id) && seen.get(id) !== identity) throw new Error('[i18n] message hash collision: ' + id);\n seen.set(id, identity);\n\n return record.translation === '' ? [] : [[id, compileMessage(record.translation)] as [string, CompactMessage]];\n });\n}\n","import * as generatorModule from '@babel/generator';\nimport type { NodePath } from '@babel/traverse';\nimport * as b from '@babel/types';\nimport { DEFAULT_HASH_LENGTH, normalizeHashLength } from '@fluentic/i18n/compiler-support';\nimport {\n analyzer,\n collectMessages,\n type ExtractedMessage,\n importMap,\n literal,\n memberName,\n parseSource,\n traverse,\n} from './analyze';\nimport { compileMessage, messageId } from './message';\n\nexport { collectMessages } from './analyze';\nexport * from './message';\n\nconst generate = ((generatorModule.default as unknown as { default?: typeof generatorModule.default; }).default ??\n generatorModule.default) as typeof generatorModule.default;\nexport type CompiledOptions = { hashLength?: number; };\nexport type CompilerOptions = CompiledOptions & { filename?: string; bindReactText?: boolean; };\n\ntype FunctionPath = NodePath<\n b.ArrowFunctionExpression | b.FunctionDeclaration | b.FunctionExpression | b.ObjectMethod | b.ClassMethod\n>;\n\nfunction reactFunction(path: NodePath): FunctionPath | null {\n for (\n let current = path.findParent((parent) => parent.isFunction());\n current;\n current = current.findParent(\n (parent) => parent.isFunction(),\n )\n ) {\n const fn = current as FunctionPath;\n const parent = fn.parentPath;\n const ownName = (b.isFunctionDeclaration(fn.node) || b.isFunctionExpression(fn.node)) ? fn.node.id?.name : null;\n const variableId = parent?.isVariableDeclarator() ? parent.get('id') : null;\n const name = ownName ?? (variableId?.isIdentifier() ? variableId.node.name : null);\n const exported = parent?.isExportDefaultDeclaration();\n\n if (exported || (name && (/^[A-Z]/.test(name) || /^use[A-Z]/.test(name)))) return fn;\n }\n\n return null;\n}\n\nfunction hashLength(length: CompilerOptions['hashLength']): number {\n return normalizeHashLength(length ?? DEFAULT_HASH_LENGTH);\n}\n\nfunction resolveJsxCallback(path: NodePath, seen = new Set<unknown>()): FunctionPath | null {\n while (\n path.isTSAsExpression() || path.isTSSatisfiesExpression() || path.isTSNonNullExpression() ||\n path.isTypeCastExpression() || path.isParenthesizedExpression()\n ) path = path.get('expression') as NodePath;\n if (path.isArrowFunctionExpression() || path.isFunctionExpression() || path.isFunctionDeclaration()) {\n return path as FunctionPath;\n }\n if (!path.isIdentifier()) return null;\n const binding = path.scope.getBinding(path.node.name);\n if (!binding?.constant || seen.has(binding)) return null;\n seen.add(binding);\n if (binding.path.isFunctionDeclaration()) return binding.path as FunctionPath;\n if (!binding.path.isVariableDeclarator()) return null;\n return resolveJsxCallback(binding.path.get('init') as NodePath, seen);\n}\n\nexport function compileProgram(code: string, filename: string, options: CompilerOptions = {}) {\n const ast = parseSource(code, filename);\n const messages: ExtractedMessage[] = [];\n\n const analysis = analyzer();\n\n const plans: Array<\n {\n path: NodePath<b.CallExpression>;\n source: string | null;\n scope: NonNullable<ReturnType<typeof analysis.resolve>>;\n reactOwner?: FunctionPath;\n }\n > = [];\n const declarations: NodePath<b.ImportDeclaration>[] = [];\n const jsxCallbacks = new Set<b.Function>();\n\n traverse(ast, {\n CallExpression(path) {\n const callee = path.get('callee');\n if (memberName(callee) !== 'jsx') return;\n const scope = analysis.resolve((callee as NodePath<b.MemberExpression>).get('object'));\n if (!scope) return;\n const callback = resolveJsxCallback(path.get('arguments.0') as NodePath);\n if (callback) jsxCallbacks.add(callback.node);\n },\n });\n\n let program: NodePath<b.Program> | undefined;\n const clientModule = ast.program.directives.some((directive) => directive.value.value === 'use client');\n traverse(ast, {\n Program(path) {\n program = path;\n },\n ExportAllDeclaration(path) {\n if (importMap[path.node.source.value]) {\n throw new Error('[i18n] do not re-export the translator in compiled mode; import t directly at each use');\n }\n },\n ExportNamedDeclaration(path) {\n if (\n path.node.source && importMap[path.node.source.value] &&\n path.node.specifiers.some((specifier) =>\n b.isExportSpecifier(specifier) && (b.isIdentifier(specifier.local) ? specifier.local.name : '') === 't'\n )\n ) throw new Error('[i18n] do not re-export the translator in compiled mode; export message descriptors instead');\n },\n ImportDeclaration(path) {\n if (importMap[path.node.source.value] && path.node.importKind !== 'type') declarations.push(path);\n },\n CallExpression(path) {\n const callee = path.get('callee');\n const method = memberName(callee);\n\n if (!method || !['msg', 'jsx', 'text'].includes(method)) return;\n\n const scope = analysis.resolve((callee as NodePath<b.MemberExpression>).get('object'));\n\n if (!scope) return;\n\n if (method === 'jsx' && resolveJsxCallback(path.get('arguments.0') as NodePath)) return;\n\n const source = literal(path.get('arguments.0') as NodePath);\n\n if (source === null && method === 'msg') {\n throw new Error(`[i18n] ${filename}:${path.node.loc?.start.line}: t.msg requires a static message`);\n }\n const callbackOwned = method === 'text' && Boolean(\n path.findParent((parent) => parent.isFunction() && jsxCallbacks.has(parent.node as b.Function)),\n );\n const reactOwner = options.bindReactText && clientModule && method === 'text' && !callbackOwned\n ? reactFunction(path)\n : undefined;\n if (options.bindReactText && clientModule && method === 'text' && !callbackOwned && !reactOwner) {\n throw new Error(\n `[i18n] ${filename}:${path.node.loc?.start.line}: client t.text must be rendered inside a component or hook`,\n );\n }\n plans.push({ path, source, scope, reactOwner: reactOwner ?? undefined });\n if (source !== null) {\n messages.push({ ...scope, source, id: scope.context ? `${scope.context}\\0${source}` : source });\n }\n },\n });\n // Discover unused/escaping scopes as well as scopes reached by message calls.\n traverse(ast, {\n VariableDeclarator(path) {\n analysis.resolve(path.get('id') as NodePath);\n },\n CallExpression(path) {\n const name = memberName(path.get('callee'));\n\n if (name && ['context', 'note', 'meta'].includes(name)) analysis.resolve(path);\n },\n });\n const expressionUse = (path: NodePath): NodePath => {\n while (\n path.parentPath &&\n (path.parentPath.isTSAsExpression() || path.parentPath.isTSSatisfiesExpression() ||\n path.parentPath.isTSNonNullExpression() || path.parentPath.isTypeCastExpression() ||\n path.parentPath.isParenthesizedExpression())\n ) path = path.parentPath;\n\n return path;\n };\n\n for (const path of analysis.scopeCalls) {\n const use = expressionUse(path);\n const parent = use.parentPath;\n\n if (parent?.isVariableDeclarator() || parent?.isExpressionStatement()) continue;\n if (parent?.isMemberExpression() && parent.get('object') === use && parent.parentPath?.isCallExpression()) continue;\n throw new Error('[i18n] scoped translator escapes same-file message calls');\n }\n for (const binding of analysis.scopedBindings) {\n if (binding.path.parentPath?.parentPath?.isExportNamedDeclaration()) {\n throw new Error('[i18n] scoped translators cannot be exported; repeat the context in the consuming file');\n }\n\n for (const reference of binding.referencePaths) {\n if (reference.findParent((parent) => parent.isTSType())) continue;\n\n const use = expressionUse(reference);\n const parent = use.parentPath;\n\n if (parent?.isVariableDeclarator() && parent.get('init') === use) continue;\n if (parent?.isMemberExpression() && parent.get('object') === use) {\n const method = memberName(parent);\n\n if (\n method && ['msg', 'text', 'jsx', 'context', 'note', 'meta'].includes(method) &&\n parent.parentPath?.isCallExpression()\n ) continue;\n }\n throw new Error('[i18n] scoped translator escapes same-file message calls: ' + binding.identifier.name);\n }\n }\n if (!declarations.length) return { ast, messages, changed: false };\n\n const helper = program!.scope.generateUidIdentifier('tc');\n const rendererHook = program!.scope.generateUidIdentifier('useI18nRenderer');\n const rendererBindings = new Map<FunctionPath, b.Identifier>();\n\n if (plans.length) {\n program!.unshiftContainer(\n 'body',\n b.importDeclaration([b.importSpecifier(helper, b.identifier('t'))], b.stringLiteral('@fluentic/i18n/compiled')),\n );\n }\n if (plans.some((plan) => plan.reactOwner)) {\n program!.unshiftContainer(\n 'body',\n b.importDeclaration(\n [b.importSpecifier(rendererHook, b.identifier('useI18nRenderer'))],\n b.stringLiteral('@fluentic/i18n/react'),\n ),\n );\n for (const owner of new Set(plans.map((plan) => plan.reactOwner).filter(Boolean) as FunctionPath[])) {\n const binding = owner.scope.generateUidIdentifier('text');\n rendererBindings.set(owner, binding);\n const body = owner.get('body');\n if (!body.isBlockStatement()) {\n const expression = body.node as b.Expression;\n body.replaceWith(b.blockStatement([b.returnStatement(expression)]));\n }\n (owner.get('body') as NodePath<b.BlockStatement>).unshiftContainer(\n 'body',\n b.variableDeclaration('const', [\n b.variableDeclarator(\n b.cloneNode(binding),\n b.callExpression(b.cloneNode(rendererHook), [\n b.memberExpression(b.cloneNode(helper), b.identifier('text')),\n ]),\n ),\n ]),\n );\n }\n }\n\n for (const { path, source, scope, reactOwner } of plans) {\n const callee = path.get('callee') as NodePath<b.MemberExpression>;\n const renderer = reactOwner && rendererBindings.get(reactOwner);\n if (renderer) callee.replaceWith(b.cloneNode(renderer));\n else callee.get('object').replaceWith(b.cloneNode(helper));\n if (source !== null) {\n const replacement = b.valueToNode([\n messageId(scope.context, source, hashLength(options.hashLength)),\n compileMessage(source),\n ]);\n b.inherits(replacement, path.node.arguments[0]);\n path.node.arguments[0] = replacement;\n }\n }\n // All scope uses were checked before mutation. Remove aliases from leaves to roots.\n let removed = true;\n\n while (removed) {\n removed = false;\n program!.scope.crawl();\n\n for (const binding of analysis.scopedBindings) {\n if (binding.path.removed) continue;\n\n const current = binding.path.scope.getBinding(binding.identifier.name);\n\n if (current && !current.referenced) {\n binding.path.remove();\n removed = true;\n }\n }\n }\n\n for (const path of analysis.scopeCalls) {\n if (!path.removed) {\n const use = expressionUse(path);\n\n if (use.parentPath?.isExpressionStatement()) use.parentPath.remove();\n }\n }\n for (const declaration of declarations) declaration.node.source.value = importMap[declaration.node.source.value];\n program!.scope.crawl();\n\n for (const declaration of declarations) {\n declaration.node.specifiers = declaration.node.specifiers.filter((specifier) => {\n if (\n !b.isImportSpecifier(specifier) ||\n (b.isIdentifier(specifier.imported) ? specifier.imported.name : specifier.imported.value) !== 't'\n ) return true;\n\n return Boolean(program!.scope.getBinding(specifier.local.name)?.referenced);\n });\n if (!declaration.node.specifiers.length) declaration.remove();\n }\n\n return { ast, messages, changed: true };\n}\n\nexport function transform(code: string, options: CompilerOptions = {}) {\n const filename = options.filename ?? 'source.tsx';\n const result = compileProgram(code, filename, options);\n\n if (!result.changed) return null;\n\n const output = generate(result.ast, { sourceMaps: true, sourceFileName: filename, comments: true }, code);\n\n return { code: output.code, map: output.map, messages: result.messages };\n}\n"],"mappings":";;;;;;;AAMA,MAAM,WAAa,eAAe,QAAoE,WACpG,eAAe;AAGjB,MAAa,YAAoC;CAC/C,kBAAkB;CAClB,uBAAuB;AACzB;AAIA,SAAgB,YAAY,MAAc,UAAkB;CAC1D,OAAO,MAAM,MAAM;EACjB,gBAAgB;EAChB,YAAY;EACZ,SAAS;GACP,GAAI,eAAe,KAAK,QAAQ,IAAI,CAAC,YAAqB,IAAI,CAAC;GAC/D,GAAI,CAAC,aAAa,KAAK,QAAQ,IAAI,CAAC,KAAc,IAAI,CAAC;GACvD;GACA;EACF;CACF,CAAC;AACH;AAEA,SAAgB,OAAO,MAA0B;CAC/C,OACE,KAAK,iBAAiB,KAAK,KAAK,wBAAwB,KAAK,KAAK,sBAAsB,KACxF,KAAK,qBAAqB,KAAK,KAAK,0BAA0B,GAC9D,OAAO,KAAK,IAAI,YAAY;CAE9B,OAAO;AACT;AAEA,SAAgB,QAAQ,MAAgB,uBAAO,IAAI,IAAa,GAAkB;CAChF,OAAO,OAAO,IAAI;CAClB,IAAI,KAAK,gBAAgB,GAAG,OAAO,iBAAiB,KAAK,KAAK,KAAK;CACnE,IAAI,KAAK,kBAAkB,KAAK,CAAC,KAAK,KAAK,YAAY,QACrD,OAAO,iBAAiB,KAAK,KAAK,OAAO,EAAE,CAAC,MAAM,UAAU,EAAE;CAEhE,IAAI,KAAK,aAAa,GAAG;EACvB,MAAM,UAAU,KAAK,MAAM,WAAW,KAAK,KAAK,IAAI;EAEpD,IAAI,SAAS,YAAY,QAAQ,KAAK,qBAAqB,KAAK,CAAC,KAAK,IAAI,OAAO,GAAG;GAClF,KAAK,IAAI,OAAO;GAEhB,OAAO,QAAQ,QA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