@menapo/vi18n 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/{apply-Bre-lY9J.js → apply-FAHl1R6T.js} +69 -89
  2. package/dist/{captured-Bj8bO6vd.js → captured-CTjjDF5o.js} +196 -217
  3. package/dist/{check-BIKEuu6B.js → check-DwFwOB1d.js} +66 -84
  4. package/dist/cli.js +2 -3
  5. package/dist/{collect-Cx4_SKOe.js → collect-CYATDjdo.js} +1 -2
  6. package/dist/collisions-uMTuq36M.js +215 -0
  7. package/dist/compile-CEvH-6sY.js +240 -0
  8. package/dist/{compile-Cc97JaW2.js → compile-DqkofbiO.js} +376 -331
  9. package/dist/concurrency-BCY_4zcr.js +1 -0
  10. package/dist/concurrency-Dy2ny50V.js +107 -0
  11. package/dist/config.d.ts +1 -5
  12. package/dist/config.js +4 -5
  13. package/dist/{types-D3QGM8XO.js → diagnostics-1onDF6Ua.js} +26 -26
  14. package/dist/{dir-zw6bGMKQ.js → dir-TGLYuOZb.js} +34 -37
  15. package/dist/{duplicates-yuRljQ6h.js → duplicates-CsUXRX2J.js} +10 -27
  16. package/dist/engine-Bf7nVigL.js +556 -0
  17. package/dist/engine.d.ts +1 -5
  18. package/dist/engine.js +297 -168
  19. package/dist/exchange-DYG9RZoT.js +41 -0
  20. package/dist/{exclude-Du-Zd_qI.js → exclude-vMnm3lqU.js} +2 -3
  21. package/dist/{export-C9Sy6UWv.js → export-BYq0gfLd.js} +17 -38
  22. package/dist/{extract-C3S8btx0.js → extract-CYtuEo8u.js} +114 -82
  23. package/dist/{formats-9unqj_fZ.js → formats-ChV1LVH_.js} +352 -276
  24. package/dist/fs-ezCMZeDV.js +52 -0
  25. package/dist/i18next-1waHziMy.js +1 -0
  26. package/dist/i18next-D66Icz3L.js +1907 -0
  27. package/dist/{import-nANvQutw.js → import-BApbQlmm.js} +81 -75
  28. package/dist/index.d.ts +1 -13
  29. package/dist/index.js +14 -16
  30. package/dist/{init-C2ScuW6a.js → init-J7AwwA5e.js} +466 -501
  31. package/dist/{library-D5CWvTQs.js → library-BfSOBeBd.js} +975 -451
  32. package/dist/lingui-Ee2farVo.js +902 -0
  33. package/dist/lint.d.ts +0 -4
  34. package/dist/lint.js +68 -81
  35. package/dist/{load-gW-oJt1Q.js → load-BFLLqY8x.js} +272 -147
  36. package/dist/{load-CQRz4PpM.js → load-CMwhukZ4.js} +1211 -1115
  37. package/dist/{locales-DX4MOBFE.js → locales-DxLDrx-h.js} +271 -237
  38. package/dist/{lsp-RMMMc88P.js → lsp-BC7xDGON.js} +4 -5
  39. package/dist/{match-BGr8EXB3.js → match-BLDcj610.js} +11 -4
  40. package/dist/{mcp-CHVwBoRP.js → mcp-Cka8ywDF.js} +4 -5
  41. package/dist/{merge-driver-BTX87aVm.js → merge-driver-B04Apm29.js} +138 -122
  42. package/dist/migrate-D7TNl6SD.js +2169 -0
  43. package/dist/migrate-khCY8TE0.js +1 -0
  44. package/dist/{openai-CTaMDcl-.js → openai-RWw0YlAx.js} +128 -87
  45. package/dist/{output-DWE3SIUA.js → output-CF9uvk_-.js} +15 -9
  46. package/dist/parse.d.ts +1 -3
  47. package/dist/parse.js +7 -8
  48. package/dist/{pipeline-DbX6rlo5.js → pipeline-B30irGMD.js} +1 -1
  49. package/dist/{pipeline-C9Dbotkh.js → pipeline-sgl_q_op.js} +387 -359
  50. package/dist/project-DSzWKU3C.js +544 -0
  51. package/dist/{pseudo-DRv30iN5.js → pseudo-DNbNNVGP.js} +125 -3
  52. package/dist/{raw-C4Y6vyGY.js → raw-YsYZMS9n.js} +52 -29
  53. package/dist/react-intl-tzGIk6G3.js +634 -0
  54. package/dist/restore-BG_zMpSj.js +199 -0
  55. package/dist/rewrite-hAcRJwiZ.js +415 -0
  56. package/dist/{rich-DCUKl5HM.js → rich-ApY1Dm4S.js} +35 -28
  57. package/dist/rolldown-runtime-C1I3wEg2.js +43 -0
  58. package/dist/{rolldown-runtime-D7D4PA-g.js → rolldown-runtime-D8jQpDG7.js} +1 -2
  59. package/dist/run-CFzR3V93.js +647 -0
  60. package/dist/scan-worker.d.ts +2 -4
  61. package/dist/scan-worker.js +1 -1
  62. package/dist/{scoped-BMYpSthj.js → scoped-h3KE8XWW.js} +3 -4
  63. package/dist/{server-deBOq2vq.js → server-WlxZH0oX.js} +275 -330
  64. package/dist/{server-Da1Ot9IN.js → server-ceuzzkal.js} +292 -386
  65. package/dist/server.d.ts +1 -17
  66. package/dist/server.js +415 -381
  67. package/dist/{sitemap-DJXzKoza.js → sitemap-796jJKUT.js} +21 -33
  68. package/dist/{sources-D19czDSA.js → sources-DuOdM02f.js} +712 -373
  69. package/dist/{status-zr4jY59Y.js → status-CTH3qI-0.js} +30 -30
  70. package/dist/{stdio-FPOKQAgu.js → stdio-D9kTzyqB.js} +2 -4
  71. package/dist/{stdio-CVaJfxA7.js → stdio-FWIVU3P4.js} +1 -2
  72. package/dist/sync-CpL0Qsgw.js +1352 -0
  73. package/dist/{t-DC-c9zE5.js → t-gvEXx25s.js} +76 -53
  74. package/dist/test.d.ts +5 -16
  75. package/dist/test.js +77 -48
  76. package/dist/translate-BrfVRkjl.js +336 -0
  77. package/dist/{ts-BaU5yOf0.js → ts-BX6kwig5.js} +25 -14
  78. package/dist/{types-DtvQ7UdD.js → types-3kwyaCAm.js} +1 -2
  79. package/dist/{types-DsdWBG0b.d.ts → types-BaG1LboH.d.ts} +2 -6
  80. package/dist/{types-CgUCkFU1.d.ts → types-Cy2bPdSg.d.ts} +14 -20
  81. package/dist/types-Ds_vebja.js +41 -0
  82. package/dist/{units-CQ5Q99RC.js → units-VVLgQ7x7.js} +7 -16
  83. package/dist/{url-CRfCOhUI.js → url-Bpc6wLea.js} +24 -11
  84. package/dist/{url-CsBkRaJy.js → url-D2_VlEeH.js} +25 -12
  85. package/dist/{validate-D6DJepZv.js → validate-PGgMsasz.js} +3 -5
  86. package/dist/{validate-BxpupdAf.js → validate-zv4-IZyZ.js} +690 -377
  87. package/dist/{version-Byqi2guX.js → version-BFs370Ce.js} +3 -5
  88. package/dist/{vite-scan-CT_vsp4g.js → vite-scan-DFKSGVE9.js} +87 -92
  89. package/dist/vite.d.ts +2 -6
  90. package/dist/vite.js +6482 -6018
  91. package/dist/vue-i18n-CBmZqHbG.js +806 -0
  92. package/dist/{which-BOemZ5Q8.js → which-BpyJyBkX.js} +44 -37
  93. package/dist/{worker-84U6uYB3.js → worker-BjzVqJVO.js} +454 -608
  94. package/package.json +5 -5
  95. package/dist/check-HsmmpJZg.js +0 -1
  96. package/dist/codec-DuvU2VQy.js +0 -207
  97. package/dist/collisions-CfpZU8e4.js +0 -217
  98. package/dist/compile-BaDh0cHG.js +0 -245
  99. package/dist/concurrency-C9UUWuDC.js +0 -96
  100. package/dist/concurrency-DONL7t4V.js +0 -1
  101. package/dist/engine-C2ENBRJe.js +0 -531
  102. package/dist/i18next-9HAoxwUI.js +0 -1
  103. package/dist/i18next-BEJgv_S8.js +0 -1596
  104. package/dist/lingui-zUiCl9Um.js +0 -833
  105. package/dist/messages-BfjIExyB.js +0 -166
  106. package/dist/migrate-IpLDMXmq.js +0 -1484
  107. package/dist/migrate-rCQuOGsf.js +0 -1
  108. package/dist/project-Bw9UPIdx.js +0 -1046
  109. package/dist/project-C4GpaN-n.js +0 -381
  110. package/dist/react-intl-BP0u-D5m.js +0 -519
  111. package/dist/restore-CiYv-jxS.js +0 -175
  112. package/dist/rewrite-EsIw_lsq.js +0 -803
  113. package/dist/run-BEcnBbu-.js +0 -694
  114. package/dist/runtime-DTMmliT1.js +0 -64
  115. package/dist/sync-B9V2KFwb.js +0 -658
  116. package/dist/translate-CQnJfLjO.js +0 -299
  117. package/dist/types-wSh9fCBY.js +0 -11
  118. package/dist/vue-i18n-g0iGy6CZ.js +0 -651
@@ -2,9 +2,8 @@ import "node:path";
2
2
  import "node:crypto";
3
3
  import "node:fs";
4
4
  import "node:url";
5
- //#endregion
6
- //#region src/core/version.ts
7
- const VERSION = "0.1.1";
5
+ // src/core/version.ts
6
+ const VERSION = "0.1.2";
8
7
  let fingerprint;
9
8
  let cacheVersionMemo;
10
9
  /**
@@ -16,7 +15,7 @@ let cacheVersionMemo;
16
15
  */
17
16
  function codeFingerprint() {
18
17
  if (fingerprint !== void 0) return fingerprint;
19
- fingerprint = "0UPRQnKMBktq7h16";
18
+ fingerprint = "QSlL6IybBL_kcdW5";
20
19
  return fingerprint;
21
20
  }
22
21
  /** `VERSION` and `codeFingerprint()`: the version every cache key and `configHash` carries. */
@@ -24,5 +23,4 @@ function cacheVersion() {
24
23
  cacheVersionMemo ??= `${VERSION}+${codeFingerprint()}`;
25
24
  return cacheVersionMemo;
26
25
  }
27
- //#endregion
28
26
  export { cacheVersion as n, VERSION as t };
@@ -1,11 +1,15 @@
1
- import { a as toPosix, i as listProjectFiles, o as aggregateOccurrences, t as refMapper } from "./project-Bw9UPIdx.js";
2
- import { t as ABORT_CODES } from "./worker-84U6uYB3.js";
3
- import { n as setCollector } from "./collect-Cx4_SKOe.js";
1
+ import { c as aggregateOccurrences, o as refMapper } from "./sync-CpL0Qsgw.js";
2
+ import { n as setCollector } from "./collect-CYATDjdo.js";
3
+ import { I as listProjectFiles } from "./library-BfSOBeBd.js";
4
+ import { c as mapLimit, u as toPosix } from "./validate-zv4-IZyZ.js";
5
+ import { t as ABORT_CODES } from "./worker-BjzVqJVO.js";
6
+ import { o as errorMessage } from "./output-CF9uvk_-.js";
7
+ import { t as findViteConfig } from "./fs-ezCMZeDV.js";
8
+ import { r as compareText } from "./project-DSzWKU3C.js";
4
9
  import { createRequire } from "node:module";
5
10
  import { join, relative } from "node:path";
6
- import { existsSync } from "node:fs";
7
11
  import { pathToFileURL } from "node:url";
8
- //#region src/cli/vite-scan.ts
12
+ // src/cli/vite-scan.ts
9
13
  /**
10
14
  * `vi18n extract --vite` (PLAN §4.5 P2, INTERNALS §2.5.9, §6 D234–D235):
11
15
  * the include scan through the project's own Vite pipeline, for projects
@@ -37,7 +41,7 @@ function urlOf(root, file) {
37
41
  return rel.startsWith("../") || rel === ".." || /^[a-zA-Z]:/.test(rel) ? "/@fs" + (toPosix(file).startsWith("/") ? "" : "/") + toPosix(file) : "/" + rel;
38
42
  }
39
43
  function messageOf(error) {
40
- return (error instanceof Error ? error.message : String(error)).split("\n")[0];
44
+ return errorMessage(error).split("\n")[0];
41
45
  }
42
46
  function collectorInto(collected, active) {
43
47
  return {
@@ -68,7 +72,7 @@ function collectorInto(collected, active) {
68
72
  async function transformFile(server, root, file, collected) {
69
73
  const path = toPosix(file);
70
74
  const url = urlOf(root, file);
71
- const names = Object.keys(server.environments).sort((a, b) => a === "client" ? -1 : b === "client" ? 1 : 0);
75
+ const names = Object.keys(server.environments).sort((a, b) => Number(b === "client") - Number(a === "client"));
72
76
  let firstError = null;
73
77
  for (const name of names) {
74
78
  const environment = server.environments[name];
@@ -116,37 +120,11 @@ async function scanWithVite(config) {
116
120
  diagnostics: [],
117
121
  failed: /* @__PURE__ */ new Set()
118
122
  };
119
- let active = false;
120
- setCollector(collectorInto(collected, () => active));
123
+ const active = { value: false };
124
+ setCollector(collectorInto(collected, () => active.value));
121
125
  let server;
122
126
  try {
123
- server = await vite.createServer({
124
- configFile: viteConfigFile(config.root),
125
- logLevel: "error",
126
- clearScreen: false,
127
- appType: "custom",
128
- server: {
129
- middlewareMode: true,
130
- hmr: false,
131
- ws: false,
132
- watch: null,
133
- preTransformRequests: false
134
- },
135
- optimizeDeps: {
136
- noDiscovery: true,
137
- include: []
138
- },
139
- plugins: [{
140
- name: "vi18n:extract-vite",
141
- enforce: "pre",
142
- config: {
143
- order: "pre",
144
- handler(user) {
145
- return user.root === void 0 ? { root: config.root } : {};
146
- }
147
- }
148
- }]
149
- });
127
+ server = await vite.createServer(serverConfig(config.root));
150
128
  } catch (error) {
151
129
  setCollector(null);
152
130
  return failedScan(leading, `the Vite config could not be loaded: ${messageOf(error)}`);
@@ -154,53 +132,25 @@ async function scanWithVite(config) {
154
132
  const failures = /* @__PURE__ */ new Map();
155
133
  try {
156
134
  if (!server.config.plugins.some((plugin) => plugin.name === "vi18n:extract")) return failedScan(leading, "vi18n extract --vite found no vi18n() plugin in the Vite config; add it, or run vi18n extract without --vite");
157
- active = true;
135
+ active.value = true;
158
136
  const viteRoot = server.config.root ?? config.root;
159
- let next = 0;
160
- const lanes = [];
161
- for (let lane = 0; lane < Math.min(CONCURRENCY, listed.files.length); lane++) lanes.push((async () => {
162
- while (next < listed.files.length) {
163
- const file = listed.files[next++];
164
- const failure = await transformFile(server, viteRoot, file, collected);
165
- if (failure !== null) failures.set(file, failure);
166
- }
167
- })());
168
- await Promise.all(lanes);
137
+ await mapLimit(listed.files, CONCURRENCY, async (file) => {
138
+ const failure = await transformFile(server, viteRoot, file, collected);
139
+ if (failure !== null) failures.set(file, failure);
140
+ });
169
141
  } finally {
170
- active = false;
142
+ active.value = false;
171
143
  setCollector(null);
172
144
  await server.close();
173
145
  }
174
- const files = [];
175
- const byRef = /* @__PURE__ */ new Map();
176
- for (const diagnostic of collected.diagnostics) {
177
- const key = diagnostic.file ?? "";
178
- let list = byRef.get(key);
179
- if (list === void 0) byRef.set(key, list = []);
180
- list.push(diagnostic);
181
- }
146
+ const byRef = diagnosticsByFile(collected.diagnostics);
182
147
  const diagnostics = [...leading];
183
- for (const file of listed.files) {
184
- const refFile = ref(file);
185
- const fileDiagnostics = byRef.get(refFile) ?? [];
186
- byRef.delete(refFile);
187
- const failure = failures.get(file);
188
- if (failure !== void 0) fileDiagnostics.push({
189
- code: "extract-parse-error",
190
- severity: "error",
191
- message: `Cannot transform ${refFile} through the Vite config: ${failure}`,
192
- file: refFile
193
- });
194
- const occurrences = [...(collected.modules.get(toPosix(file)) ?? /* @__PURE__ */ new Map()).entries()].sort(([a], [b]) => (a.includes("?") ? 1 : 0) - (b.includes("?") ? 1 : 0) || (a < b ? -1 : a > b ? 1 : 0)).flatMap(([, messages]) => [...messages]);
195
- files.push({
196
- file,
197
- refFile,
198
- occurrences,
199
- diagnostics: fileDiagnostics,
200
- fromCache: false
201
- });
202
- diagnostics.push(...fileDiagnostics);
203
- }
148
+ const files = listed.files.map((file) => fileScan(file, ref(file), {
149
+ collected,
150
+ byRef,
151
+ failure: failures.get(file)
152
+ }));
153
+ for (const scan of files) diagnostics.push(...scan.diagnostics);
204
154
  for (const rest of byRef.values()) diagnostics.push(...rest);
205
155
  return {
206
156
  files,
@@ -209,21 +159,67 @@ async function scanWithVite(config) {
209
159
  aborted: diagnostics.some((diagnostic) => ABORT_CODES.has(diagnostic.code))
210
160
  };
211
161
  }
212
- const VITE_CONFIGS = [
213
- "vite.config.js",
214
- "vite.config.mjs",
215
- "vite.config.ts",
216
- "vite.config.cjs",
217
- "vite.config.mts",
218
- "vite.config.cts"
219
- ];
220
- /** Vite's own lookup, from the vi18n config's root instead of the process's directory. */
221
- function viteConfigFile(root) {
222
- for (const name of VITE_CONFIGS) {
223
- const file = join(root, name);
224
- if (existsSync(file)) return file;
162
+ /** The dev server the scan transforms through: no HMR, no watcher, no dependency discovery. */
163
+ function serverConfig(root) {
164
+ return {
165
+ configFile: findViteConfig(root) ?? false,
166
+ logLevel: "error",
167
+ clearScreen: false,
168
+ appType: "custom",
169
+ server: {
170
+ middlewareMode: true,
171
+ hmr: false,
172
+ ws: false,
173
+ watch: null,
174
+ preTransformRequests: false
175
+ },
176
+ optimizeDeps: {
177
+ noDiscovery: true,
178
+ include: []
179
+ },
180
+ plugins: [{
181
+ name: "vi18n:extract-vite",
182
+ enforce: "pre",
183
+ config: {
184
+ order: "pre",
185
+ handler(user) {
186
+ return user.root === void 0 ? { root } : {};
187
+ }
188
+ }
189
+ }]
190
+ };
191
+ }
192
+ function diagnosticsByFile(diagnostics) {
193
+ const byRef = /* @__PURE__ */ new Map();
194
+ for (const diagnostic of diagnostics) {
195
+ const key = diagnostic.file ?? "";
196
+ let list = byRef.get(key);
197
+ if (list === void 0) byRef.set(key, list = []);
198
+ list.push(diagnostic);
225
199
  }
226
- return false;
200
+ return byRef;
201
+ }
202
+ /** A module id's part (`?vue&type=…`) after the file's own module, then by id. */
203
+ function compareModuleIds(a, b) {
204
+ return Number(a.includes("?")) - Number(b.includes("?")) || compareText(a, b);
205
+ }
206
+ /** One file's scan; takes its diagnostics out of `byRef`, so what is left there belongs to no listed file. */
207
+ function fileScan(file, refFile, from) {
208
+ const fileDiagnostics = from.byRef.get(refFile) ?? [];
209
+ from.byRef.delete(refFile);
210
+ if (from.failure !== void 0) fileDiagnostics.push({
211
+ code: "extract-parse-error",
212
+ severity: "error",
213
+ message: `Cannot transform ${refFile} through the Vite config: ${from.failure}`,
214
+ file: refFile
215
+ });
216
+ return {
217
+ file,
218
+ refFile,
219
+ occurrences: [...(from.collected.modules.get(toPosix(file)) ?? /* @__PURE__ */ new Map()).entries()].sort(([a], [b]) => compareModuleIds(a, b)).flatMap(([, messages]) => [...messages]),
220
+ diagnostics: fileDiagnostics,
221
+ fromCache: false
222
+ };
227
223
  }
228
224
  function failedScan(leading, message) {
229
225
  const diagnostics = [...leading, {
@@ -238,5 +234,4 @@ function failedScan(leading, message) {
238
234
  aborted: true
239
235
  };
240
236
  }
241
- //#endregion
242
237
  export { scanWithVite };
package/dist/vite.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { n as OutputOptions } from "./types-CgUCkFU1.js";
1
+ import { n as OutputOptions } from "./types-Cy2bPdSg.js";
2
2
  import { Plugin, Rolldown } from "vite";
3
- //#region src/vite/types.d.ts
4
3
  /** Options of `vi18n()`. Everything else comes from `vi18n.config.ts`. */
5
4
  interface Vi18nPluginOptions {
6
5
  /** Path of the config file, relative to the Vite root. Default: search upward for `vi18n.config.ts`. */
@@ -10,7 +9,7 @@ interface Vi18nPluginOptions {
10
9
  /**
11
10
  * Removed before 1.0: `vi18n()` adds its own plugins to Vite's
12
11
  * `worker.plugins` (INTERNALS §2.9.9), so a worker build needs no second
13
- * instance. `true` is rejected with `config-invalid` naming that.
12
+ * instance. Any value is rejected with `config-invalid` naming that.
14
13
  */
15
14
  worker?: boolean;
16
15
  }
@@ -20,8 +19,6 @@ interface Vi18nTransformOptions {
20
19
  /** Default `"build"` (ids only). */
21
20
  mode?: "dev" | "build";
22
21
  }
23
- //#endregion
24
- //#region src/vite/index.d.ts
25
22
  export declare function vi18n(options?: Vi18nPluginOptions): Plugin[];
26
23
  /**
27
24
  * The extraction rewrite for a plain Rollup/Rolldown build (§2.8.3, last
@@ -30,5 +27,4 @@ export declare function vi18n(options?: Vi18nPluginOptions): Plugin[];
30
27
  * Vite-built server bundle or `registerCatalogs` registered catalogs.
31
28
  */
32
29
  export declare function vi18nTransform(options?: Vi18nTransformOptions): Rolldown.Plugin;
33
- //#endregion
34
30
  export { type Vi18nPluginOptions, type Vi18nTransformOptions, vi18n as default };