@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,169 @@
1
+ import { h as Scope, m as RuntimeConfig, y as Translator } from "./types-DsdWBG0b.js";
2
+ //#region src/server/types.d.ts
3
+ /** Options of `handle()` and `withRequest()`. */
4
+ interface HandleOptions {
5
+ /** CSP nonce for the payload `<script>` elements. */
6
+ nonce?: string;
7
+ /** Skip negotiation and use this locale (still matched against `locales`). */
8
+ locale?: string;
9
+ /** Overrides the request's zone source (cookie, `cf.timezone`, config). */
10
+ timeZone?: string;
11
+ /** Epoch ms for the scope; default `Date.now()` at request start. */
12
+ now?: number;
13
+ /**
14
+ * Inject the `#__vi18n` payload into HTML. Default: true, except under a
15
+ * `registerCatalogs()` registration, which has no client build to read it.
16
+ */
17
+ payload?: boolean;
18
+ }
19
+ /** Where `negotiate()` found the locale. `header-x` is the `x-vi18n-locale` request header. */
20
+ type NegotiationSource = "url" | "referer" | "header-x" | "cookie" | "header" | "default";
21
+ interface NegotiateResult {
22
+ locale: string;
23
+ source: NegotiationSource;
24
+ /**
25
+ * The request header the answer depends on, for the response's `Vary`
26
+ * (`handle()` adds it); absent when it depends on none, as when the URL
27
+ * decided. `Accept-Language` means the visitor's cookie or languages were
28
+ * read, or the root was negotiated: such a response must also be
29
+ * `Cache-Control: private`, since shared caches do not vary on the cookie
30
+ * (`handle()` sets both).
31
+ */
32
+ vary?: "x-vi18n-locale" | "Referer" | "Accept-Language";
33
+ /**
34
+ * Present for the canonical 301 (`/en/about` → `/about` under
35
+ * `prefix_except_default`; with `routing.paths` also `/de/about` →
36
+ * `/de/ueber-uns`, and with `routing.domains` a locale prefixed on another
37
+ * locale's host → its own host) and, with `routing.redirectRoot`, for `/`.
38
+ * Another host is always one `routing.domains` lists.
39
+ */
40
+ redirect?: URL;
41
+ /** HTTP status of `redirect`: 301 for canonicalisation, 307 for the root redirect. */
42
+ status?: 301 | 307;
43
+ }
44
+ interface AlternateLink {
45
+ rel: "alternate" | "canonical";
46
+ hreflang?: string;
47
+ href: string;
48
+ }
49
+ interface AlternateMeta {
50
+ property: "og:locale" | "og:locale:alternate";
51
+ /** `ll_TT` form, e.g. `pt_BR`. */
52
+ content: string;
53
+ }
54
+ /** `alternates(url)`: every locale + `x-default` + self-canonical, and `og:locale` metadata. */
55
+ interface Alternates {
56
+ links: AlternateLink[];
57
+ meta: AlternateMeta[];
58
+ }
59
+ /** Options of `withLocale()` and `createTranslator()`. */
60
+ interface TranslatorOptions {
61
+ timeZone?: string;
62
+ now?: number;
63
+ }
64
+ /** Second argument of `registerCatalogs()`. */
65
+ interface RegisterCatalogsOptions {
66
+ /**
67
+ * `config.json` from `vi18n compile --out`, a {@link RuntimeConfig}. Typed
68
+ * `unknown` because it usually arrives from a JSON import; it is validated.
69
+ */
70
+ config: unknown;
71
+ /**
72
+ * `sources.json` from `vi18n compile --out` (a module namespace or the plain
73
+ * object). Loading starts at registration; scopes open only after it settled.
74
+ */
75
+ sources?: () => Promise<unknown>;
76
+ }
77
+ //#endregion
78
+ //#region src/server/als.d.ts
79
+ /** Framework request stores (SvelteKit `getRequestEvent()`) supply the scope; null removes it. */
80
+ export declare function setScopeResolver(resolve: (() => Scope | undefined) | null): void;
81
+ /**
82
+ * The current scope. A `withLocale`/`createTranslator` scope entered inside
83
+ * a request outranks the framework's request store: the store would still
84
+ * name the request, and an e-mail rendered for another user inside it must
85
+ * use that user's locale. Otherwise the resolver wins over the ALS, as
86
+ * frameworks may run render code outside the async context `handle` opened.
87
+ */
88
+ export declare function getScope(): Scope | undefined;
89
+ //#endregion
90
+ //#region src/server/handle.d.ts
91
+ /**
92
+ * Negotiates the locale, answers the canonical or root redirect, renders
93
+ * `next(request)` (the original request: rewriting stays with the router)
94
+ * inside the request scope, and streams HTML through the injection.
95
+ */
96
+ export declare function handle(request: Request, next: (request: Request) => Response | Promise<Response>, options?: HandleOptions): Promise<Response>;
97
+ /**
98
+ * Runs `fn` in the request's scope, for servers that build the response
99
+ * themselves (Nuxt), and returns its value; a `Response` with a body comes
100
+ * back with the same status, headers and bytes, its body read inside the
101
+ * scope.
102
+ */
103
+ export declare function withRequest<T>(request: Request, fn: () => T | Promise<T>, options?: HandleOptions): Promise<Awaited<T>>;
104
+ /**
105
+ * Re-scopes the current request to `locale` (Astro server islands whose
106
+ * props carry it). The scope object is updated in place, so the request's
107
+ * resolver, its payload and its `<html>` attributes all follow.
108
+ */
109
+ export declare function scopeLocale(locale: string): Promise<void>;
110
+ //#endregion
111
+ //#region src/server/negotiate.d.ts
112
+ /**
113
+ * The locale `request` would render in, the redirect `handle()` would
114
+ * answer, and the header its response varies on.
115
+ */
116
+ export declare function negotiate(request: Request): NegotiateResult;
117
+ //#endregion
118
+ //#region src/server/payload.d.ts
119
+ /**
120
+ * The payload element for HTML-string hooks (Nuxt `render:html`), with its
121
+ * preload links under `ssr.payload: "preload"`: the ids rendered so far in
122
+ * the current request scope, or "" when there are none.
123
+ * After it, `handle()` only adds late payloads for ids recorded later.
124
+ */
125
+ export declare function payload(options?: {
126
+ nonce?: string;
127
+ }): string;
128
+ /** `<html lang dir>` for the current scope. */
129
+ export declare function htmlAttributes(): {
130
+ lang: string;
131
+ dir: "ltr" | "rtl";
132
+ };
133
+ //#endregion
134
+ //#region src/server/seo.d.ts
135
+ /**
136
+ * hreflang links for every locale plus `x-default` (the source locale's
137
+ * URL), the self-canonical (`origin + pathname`: queries and fragments are
138
+ * not separate pages), and `og:locale` metadata for the current locale.
139
+ */
140
+ export declare function alternates(url: URL): Alternates;
141
+ /**
142
+ * Every path in every advertised locale, for prerender entry lists. Paths are
143
+ * base-free, as for `/config`'s `localizedPaths` and `localizedParams`:
144
+ * prerenderers list routes, and one helper must not need different input
145
+ * at build time and at request time (PLAN §4).
146
+ */
147
+ export declare function localizedPaths(paths: readonly string[]): string[];
148
+ /**
149
+ * Astro `getStaticPaths()` params for a `[...lang]` route: the locale segment
150
+ * of each advertised locale, `undefined` where the locale's URL carries none
151
+ * (the source locale under `prefix_except_default`).
152
+ */
153
+ export declare function localizedParams(key?: string): {
154
+ params: Record<string, string | undefined>;
155
+ }[];
156
+ //#endregion
157
+ //#region src/server/catalogs.d.ts
158
+ export declare function registerCatalogs(loaders: Record<string, () => Promise<unknown>>, options: RegisterCatalogsOptions): void;
159
+ //#endregion
160
+ //#region src/server/translator.d.ts
161
+ /**
162
+ * Runs `fn` with `t` and `fmt` bound to `locale` (and the zone in `options`),
163
+ * also inside a request: an e-mail for another user renders in theirs.
164
+ */
165
+ export declare function withLocale<T>(locale: string, fn: () => T | Promise<T>, options?: TranslatorOptions): Promise<Awaited<T>>;
166
+ /** `t`, `rich*` and `fmt` bound to one locale and zone, for code that cannot run inside a scope. */
167
+ export declare function createTranslator(locale: string, options?: TranslatorOptions): Promise<Translator>;
168
+ //#endregion
169
+ export type { Alternates, HandleOptions, NegotiateResult, NegotiationSource, RegisterCatalogsOptions, RuntimeConfig, Scope, Translator, TranslatorOptions };