@menapo/vi18n 0.0.0-stage → 0.1.0

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 (100) hide show
  1. package/LICENSE +49 -0
  2. package/README.md +110 -2
  3. package/dist/apply-Bre-lY9J.js +228 -0
  4. package/dist/captured-Bj8bO6vd.js +1034 -0
  5. package/dist/check-D34P-S--.js +1 -0
  6. package/dist/check-DyrAbv73.js +201 -0
  7. package/dist/cli.d.ts +1 -0
  8. package/dist/cli.js +41 -0
  9. package/dist/codec-DuvU2VQy.js +207 -0
  10. package/dist/collect-Cx4_SKOe.js +13 -0
  11. package/dist/collisions-CfpZU8e4.js +217 -0
  12. package/dist/compile-B5Mz6WJm.js +245 -0
  13. package/dist/compile-Cc97JaW2.js +2502 -0
  14. package/dist/concurrency-C9UUWuDC.js +96 -0
  15. package/dist/concurrency-DONL7t4V.js +1 -0
  16. package/dist/config.d.ts +21 -0
  17. package/dist/config.js +39 -0
  18. package/dist/dir-zw6bGMKQ.js +290 -0
  19. package/dist/duplicates-yuRljQ6h.js +185 -0
  20. package/dist/engine-B7p40M__.js +531 -0
  21. package/dist/engine.d.ts +43 -0
  22. package/dist/engine.js +1241 -0
  23. package/dist/exclude-Du-Zd_qI.js +26 -0
  24. package/dist/export-DGsMbcTZ.js +103 -0
  25. package/dist/extract-Dujlsgnk.js +298 -0
  26. package/dist/formats-KPIg-08V.js +781 -0
  27. package/dist/i18next-CrUnKFfh.js +1596 -0
  28. package/dist/i18next-Rgo-v9l0.js +1 -0
  29. package/dist/import-Cwdhcywt.js +225 -0
  30. package/dist/index.d.ts +156 -0
  31. package/dist/index.js +239 -0
  32. package/dist/init-BecCTvKi.js +792 -0
  33. package/dist/library-D5CWvTQs.js +1882 -0
  34. package/dist/lingui--PcOOYry.js +833 -0
  35. package/dist/lint.d.ts +105 -0
  36. package/dist/lint.js +971 -0
  37. package/dist/load-CQRz4PpM.js +2950 -0
  38. package/dist/load-gW-oJt1Q.js +747 -0
  39. package/dist/locales-DX4MOBFE.js +827 -0
  40. package/dist/lsp-Cq1Nuu-Q.js +31 -0
  41. package/dist/match-BGr8EXB3.js +89 -0
  42. package/dist/mcp-Cf0T7qPW.js +28 -0
  43. package/dist/merge-driver-CpiiSVIc.js +422 -0
  44. package/dist/messages-Cxa-5tR0.js +166 -0
  45. package/dist/migrate-CntqvrW4.js +1 -0
  46. package/dist/migrate-dPgq9uzy.js +1484 -0
  47. package/dist/openai-CTaMDcl-.js +346 -0
  48. package/dist/output-DsaHKHEt.js +164 -0
  49. package/dist/parse.d.ts +62 -0
  50. package/dist/parse.js +156 -0
  51. package/dist/pipeline-C7g11THL.js +2031 -0
  52. package/dist/pipeline-wxS0SApG.js +1 -0
  53. package/dist/project-Dwx7iPm6.js +381 -0
  54. package/dist/project-pXipT8iG.js +1046 -0
  55. package/dist/pseudo-DRv30iN5.js +145 -0
  56. package/dist/raw-C4Y6vyGY.js +4708 -0
  57. package/dist/react-intl-CaBVwJ9u.js +519 -0
  58. package/dist/restore-Btq66Tid.js +175 -0
  59. package/dist/rewrite-CiTRAICl.js +803 -0
  60. package/dist/rich-DCUKl5HM.js +97 -0
  61. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  62. package/dist/run-DYD_VXKy.js +694 -0
  63. package/dist/runtime-DTMmliT1.js +64 -0
  64. package/dist/scan-worker.d.ts +62 -0
  65. package/dist/scan-worker.js +1 -0
  66. package/dist/scoped-BMYpSthj.js +44 -0
  67. package/dist/server-BDkykMjb.js +11823 -0
  68. package/dist/server-qv3mz70d.js +10485 -0
  69. package/dist/server.d.ts +169 -0
  70. package/dist/server.js +1234 -0
  71. package/dist/sitemap-DV3o8QD7.js +159 -0
  72. package/dist/sources-D19czDSA.js +2242 -0
  73. package/dist/status-DZArW5aE.js +149 -0
  74. package/dist/stdio-CVaJfxA7.js +29 -0
  75. package/dist/stdio-FPOKQAgu.js +95 -0
  76. package/dist/sync-CcVzger_.js +658 -0
  77. package/dist/t-DC-c9zE5.js +454 -0
  78. package/dist/test.d.ts +116 -0
  79. package/dist/test.js +319 -0
  80. package/dist/translate-DZR3MkSA.js +299 -0
  81. package/dist/ts-BaU5yOf0.js +4863 -0
  82. package/dist/types-CgUCkFU1.d.ts +707 -0
  83. package/dist/types-D3QGM8XO.js +146 -0
  84. package/dist/types-DsdWBG0b.d.ts +558 -0
  85. package/dist/types-DtvQ7UdD.js +1948 -0
  86. package/dist/types-wSh9fCBY.js +11 -0
  87. package/dist/units-CQ5Q99RC.js +150 -0
  88. package/dist/url-CRfCOhUI.js +172 -0
  89. package/dist/url-CsBkRaJy.js +225 -0
  90. package/dist/validate-BxpupdAf.js +2615 -0
  91. package/dist/validate-D6DJepZv.js +365 -0
  92. package/dist/version-BlyLGlOa.js +28 -0
  93. package/dist/vite-scan-B_YW4X_a.js +242 -0
  94. package/dist/vite.d.ts +34 -0
  95. package/dist/vite.js +7558 -0
  96. package/dist/vue-i18n-CEMnpv7k.js +651 -0
  97. package/dist/which-C6PFI1Dm.js +116 -0
  98. package/dist/worker-84U6uYB3.js +1656 -0
  99. package/package.json +97 -3
  100. package/schemas/catalog.json +57 -0
@@ -0,0 +1,64 @@
1
+ //#region src/core/config/runtime.ts
2
+ /**
3
+ * Pseudo-locales are a development aid: on in `vite dev` and non-production
4
+ * builds (previews, staging), off in production and for the CLI unless
5
+ * `vi18n compile --pseudo` asks for them.
6
+ */
7
+ function pseudoActive(command, mode) {
8
+ if (command === "serve") return true;
9
+ if (command === "build") return mode !== "production";
10
+ return false;
11
+ }
12
+ function toRuntimeConfig(config, options) {
13
+ const pseudoLocales = options.pseudo ? [...config.pseudoLocales] : [];
14
+ const { routing, ssr } = config;
15
+ return {
16
+ sourceLocale: config.sourceLocale,
17
+ locales: [...config.locales, ...pseudoLocales],
18
+ pseudoLocales,
19
+ fallbacks: mapRecord(config.fallbacks, (chain) => [...chain]),
20
+ routing: {
21
+ strategy: [...routing.strategy],
22
+ routeStrategies: mapRecord(routing.routeStrategies, (chain) => [...chain]),
23
+ url: routing.url,
24
+ redirectRoot: routing.redirectRoot,
25
+ propagate: routing.propagate,
26
+ switch: routing.switch,
27
+ cookie: {
28
+ name: routing.cookie.name,
29
+ maxAge: routing.cookie.maxAge
30
+ },
31
+ base: normalizeBase(routing.base ?? options.base),
32
+ ...Object.keys(routing.paths).length > 0 && { paths: mapRecord(routing.paths, (entry) => ({ ...entry })) },
33
+ ...Object.keys(routing.domains).length > 0 && { domains: mapRecord(routing.domains, (locale) => locale) }
34
+ },
35
+ ssr: {
36
+ timeZone: ssr.timeZone,
37
+ timeZoneFrom: mapRecord(ssr.timeZoneFrom, (source) => source),
38
+ normalizeSpaces: ssr.normalizeSpaces,
39
+ ...ssr.payload === "preload" && { payload: "preload" }
40
+ }
41
+ };
42
+ }
43
+ /** Whether the config localizes paths or routes by domain: the plugin's `__VI18N_ROUTES__`. */
44
+ function hasRoutes(config) {
45
+ return Object.keys(config.routing.paths).length > 0 || Object.keys(config.routing.domains).length > 0;
46
+ }
47
+ /**
48
+ * Vite's `base` as the URL codec needs it: a pathname starting and ending
49
+ * with `/`. A relative base (`""`, `./`) serves the app from wherever it is
50
+ * mounted, which for locale prefixes means the root; a full URL (CDN base)
51
+ * contributes its pathname.
52
+ */
53
+ function normalizeBase(base) {
54
+ let path = base;
55
+ if (/^[a-z][a-z\d+.-]*:\/\//i.test(path) || path.startsWith("//")) path = new URL(path, "http://localhost").pathname;
56
+ if (path === "" || path === "." || path === "./") return "/";
57
+ if (!path.startsWith("/")) path = "/" + path.replace(/^\.\//, "");
58
+ return path.endsWith("/") ? path : path + "/";
59
+ }
60
+ function mapRecord(record, map) {
61
+ return Object.fromEntries(Object.entries(record).map(([key, value]) => [key, map(value)]));
62
+ }
63
+ //#endregion
64
+ export { toRuntimeConfig as i, normalizeBase as n, pseudoActive as r, hasRoutes as t };
@@ -0,0 +1,62 @@
1
+ import { _ as MessageOccurrence, g as MessageCodec, h as Diagnostic, i as ResolvedConfig } from "./types-CgUCkFU1.js";
2
+ //#region src/core/extract/worker.d.ts
3
+ export interface FileTask {
4
+ /** Absolute path (a realpath from the file walk). */
5
+ file: string;
6
+ /** Posix path relative to the config root. */
7
+ refFile: string;
8
+ text: string;
9
+ }
10
+ /**
11
+ * What a file scan reads of the config. Plain data only: a worker gets it by
12
+ * structured clone, which the rest of a config (a custom AI provider holding
13
+ * an SDK client, rich-tag defaults) cannot survive.
14
+ */
15
+ export type ScanConfig = Pick<ResolvedConfig, "root" | "sourceLocale" | "project" | "extraction" | "strict">;
16
+ /** The scan's part of `config`, for a worker. */
17
+ export declare function scanConfig(config: ResolvedConfig): ScanConfig;
18
+ export interface FileResult {
19
+ occurrences: MessageOccurrence[];
20
+ diagnostics: Diagnostic[];
21
+ /** Parse errors and missing compilers abort the scan (§2.5.6). */
22
+ aborted: boolean;
23
+ }
24
+ /** Diagnostics that make `ProjectScan.aborted` true. */
25
+ export declare const ABORT_CODES: ReadonlySet<Diagnostic["code"]>;
26
+ export interface ScanSourceOptions {
27
+ /**
28
+ * Compile every framework file, as before parse-only extraction (§6
29
+ * D232): what the equivalence tests and the benchmark compare against.
30
+ */
31
+ compile?: boolean;
32
+ }
33
+ /**
34
+ * Scans one file: framework files are read parse-only or compiled first
35
+ * (each resulting module scanned on its own, positions recovered by
36
+ * search), scripts are parsed as they are. A file whose text names no
37
+ * import source, wrapper or global cannot bind a vi18n call and is not
38
+ * parsed at all.
39
+ */
40
+ export declare function scanSource(task: FileTask, config: ScanConfig, codec: MessageCodec, options?: ScanSourceOptions): Promise<FileResult>;
41
+ /** Marks this module's own workers, so importing it in any other thread starts nothing. */
42
+ export declare const WORKER_MARKER = "vi18n:scan-worker";
43
+ export interface WorkerInit {
44
+ marker: typeof WORKER_MARKER;
45
+ config: ScanConfig;
46
+ idLength: number;
47
+ }
48
+ export type WorkerRequest = {
49
+ batch: number;
50
+ tasks: FileTask[];
51
+ };
52
+ export type WorkerResponse = {
53
+ batch: number;
54
+ results: FileResult[];
55
+ } | {
56
+ batch: number;
57
+ error: {
58
+ message: string;
59
+ stack?: string;
60
+ };
61
+ };
62
+ //#endregion
@@ -0,0 +1 @@
1
+ export { t as ABORT_CODES, n as WORKER_MARKER, r as scanConfig, i as scanSource } from "./worker-84U6uYB3.js";
@@ -0,0 +1,44 @@
1
+ import { C as fTime, S as fSegment, _ as fDuration, b as fPercent, d as fCompare, f as fCurrency, g as fDisplayName, h as fDateRange, l as fCollator, m as fDate, o as formatMessage, p as fCurrencyMinor, t as lookup, u as fCompact, v as fList, w as fUnit, x as fRelative, y as fNumber } from "./t-DC-c9zE5.js";
2
+ import { r as richIn } from "./rich-DCUKl5HM.js";
3
+ //#region src/runtime/scoped.ts
4
+ /**
5
+ * The API bound to one scope (INTERNALS §2.11.8): `createTranslator`,
6
+ * `withLocale` helpers and e-mail jobs render with a fixed locale, zone and
7
+ * `now`, and never subscribe a rendering computation.
8
+ */
9
+ function createScopedApi(scope) {
10
+ const t = ((key, values) => {
11
+ const m = lookup(scope, key, false);
12
+ return typeof m === "string" ? m : formatMessage(m, values, scope);
13
+ });
14
+ const fmt = {
15
+ number: (v, o) => fNumber(scope, v, o),
16
+ currency: (v, c, o) => fCurrency(scope, v, c, o),
17
+ currencyMinor: (v, c, o) => fCurrencyMinor(scope, v, c, o),
18
+ unit: (v, u, o) => fUnit(scope, v, u, o),
19
+ compact: (v, o) => fCompact(scope, v, o),
20
+ percent: (v, o) => fPercent(scope, v, o),
21
+ date: (v, o) => fDate(scope, v, o),
22
+ time: (v, o) => fTime(scope, v, o),
23
+ dateRange: (a, b, o) => fDateRange(scope, a, b, o),
24
+ relative: (v, o) => fRelative(scope, v, o),
25
+ list: (items, o) => fList(scope, items, o),
26
+ displayName: (code, o) => fDisplayName(scope, code, o),
27
+ duration: (d, o) => fDuration(scope, d, o),
28
+ compare: (a, b, o) => fCompare(scope, a, b, o),
29
+ collator: (o) => fCollator(scope, o),
30
+ segment: (text, o) => fSegment(scope, text, o)
31
+ };
32
+ const html = (key, values) => richIn(key, values, 2, scope).join("");
33
+ const parts = (key, values) => richIn(key, values, 1, scope);
34
+ return {
35
+ locale: scope.locale,
36
+ t,
37
+ rich: (key, values) => richIn(key, values, 0, scope),
38
+ richHtml: html,
39
+ richParts: parts,
40
+ fmt
41
+ };
42
+ }
43
+ //#endregion
44
+ export { createScopedApi as t };