@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.
- package/LICENSE +49 -0
- package/README.md +110 -2
- package/dist/apply-Bre-lY9J.js +228 -0
- package/dist/captured-Bj8bO6vd.js +1034 -0
- package/dist/check-D34P-S--.js +1 -0
- package/dist/check-DyrAbv73.js +201 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +41 -0
- package/dist/codec-DuvU2VQy.js +207 -0
- package/dist/collect-Cx4_SKOe.js +13 -0
- package/dist/collisions-CfpZU8e4.js +217 -0
- package/dist/compile-B5Mz6WJm.js +245 -0
- package/dist/compile-Cc97JaW2.js +2502 -0
- package/dist/concurrency-C9UUWuDC.js +96 -0
- package/dist/concurrency-DONL7t4V.js +1 -0
- package/dist/config.d.ts +21 -0
- package/dist/config.js +39 -0
- package/dist/dir-zw6bGMKQ.js +290 -0
- package/dist/duplicates-yuRljQ6h.js +185 -0
- package/dist/engine-B7p40M__.js +531 -0
- package/dist/engine.d.ts +43 -0
- package/dist/engine.js +1241 -0
- package/dist/exclude-Du-Zd_qI.js +26 -0
- package/dist/export-DGsMbcTZ.js +103 -0
- package/dist/extract-Dujlsgnk.js +298 -0
- package/dist/formats-KPIg-08V.js +781 -0
- package/dist/i18next-CrUnKFfh.js +1596 -0
- package/dist/i18next-Rgo-v9l0.js +1 -0
- package/dist/import-Cwdhcywt.js +225 -0
- package/dist/index.d.ts +156 -0
- package/dist/index.js +239 -0
- package/dist/init-BecCTvKi.js +792 -0
- package/dist/library-D5CWvTQs.js +1882 -0
- package/dist/lingui--PcOOYry.js +833 -0
- package/dist/lint.d.ts +105 -0
- package/dist/lint.js +971 -0
- package/dist/load-CQRz4PpM.js +2950 -0
- package/dist/load-gW-oJt1Q.js +747 -0
- package/dist/locales-DX4MOBFE.js +827 -0
- package/dist/lsp-Cq1Nuu-Q.js +31 -0
- package/dist/match-BGr8EXB3.js +89 -0
- package/dist/mcp-Cf0T7qPW.js +28 -0
- package/dist/merge-driver-CpiiSVIc.js +422 -0
- package/dist/messages-Cxa-5tR0.js +166 -0
- package/dist/migrate-CntqvrW4.js +1 -0
- package/dist/migrate-dPgq9uzy.js +1484 -0
- package/dist/openai-CTaMDcl-.js +346 -0
- package/dist/output-DsaHKHEt.js +164 -0
- package/dist/parse.d.ts +62 -0
- package/dist/parse.js +156 -0
- package/dist/pipeline-C7g11THL.js +2031 -0
- package/dist/pipeline-wxS0SApG.js +1 -0
- package/dist/project-Dwx7iPm6.js +381 -0
- package/dist/project-pXipT8iG.js +1046 -0
- package/dist/pseudo-DRv30iN5.js +145 -0
- package/dist/raw-C4Y6vyGY.js +4708 -0
- package/dist/react-intl-CaBVwJ9u.js +519 -0
- package/dist/restore-Btq66Tid.js +175 -0
- package/dist/rewrite-CiTRAICl.js +803 -0
- package/dist/rich-DCUKl5HM.js +97 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/run-DYD_VXKy.js +694 -0
- package/dist/runtime-DTMmliT1.js +64 -0
- package/dist/scan-worker.d.ts +62 -0
- package/dist/scan-worker.js +1 -0
- package/dist/scoped-BMYpSthj.js +44 -0
- package/dist/server-BDkykMjb.js +11823 -0
- package/dist/server-qv3mz70d.js +10485 -0
- package/dist/server.d.ts +169 -0
- package/dist/server.js +1234 -0
- package/dist/sitemap-DV3o8QD7.js +159 -0
- package/dist/sources-D19czDSA.js +2242 -0
- package/dist/status-DZArW5aE.js +149 -0
- package/dist/stdio-CVaJfxA7.js +29 -0
- package/dist/stdio-FPOKQAgu.js +95 -0
- package/dist/sync-CcVzger_.js +658 -0
- package/dist/t-DC-c9zE5.js +454 -0
- package/dist/test.d.ts +116 -0
- package/dist/test.js +319 -0
- package/dist/translate-DZR3MkSA.js +299 -0
- package/dist/ts-BaU5yOf0.js +4863 -0
- package/dist/types-CgUCkFU1.d.ts +707 -0
- package/dist/types-D3QGM8XO.js +146 -0
- package/dist/types-DsdWBG0b.d.ts +558 -0
- package/dist/types-DtvQ7UdD.js +1948 -0
- package/dist/types-wSh9fCBY.js +11 -0
- package/dist/units-CQ5Q99RC.js +150 -0
- package/dist/url-CRfCOhUI.js +172 -0
- package/dist/url-CsBkRaJy.js +225 -0
- package/dist/validate-BxpupdAf.js +2615 -0
- package/dist/validate-D6DJepZv.js +365 -0
- package/dist/version-BlyLGlOa.js +28 -0
- package/dist/vite-scan-B_YW4X_a.js +242 -0
- package/dist/vite.d.ts +34 -0
- package/dist/vite.js +7558 -0
- package/dist/vue-i18n-CEMnpv7k.js +651 -0
- package/dist/which-C6PFI1Dm.js +116 -0
- package/dist/worker-84U6uYB3.js +1656 -0
- package/package.json +97 -3
- package/schemas/catalog.json +57 -0
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
//#region src/runtime/typed.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Augmented by the generated `vi18n.gen.ts`:
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* declare module "@menapo/vi18n" {
|
|
7
|
+
* interface Register {
|
|
8
|
+
* locales: "en" | "de";
|
|
9
|
+
* }
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
interface Register {}
|
|
14
|
+
/** The configured locales once `vi18n.gen.ts` is included, otherwise `string`. */
|
|
15
|
+
type Locale = Register extends {
|
|
16
|
+
locales: infer L extends string;
|
|
17
|
+
} ? L : string;
|
|
18
|
+
/**
|
|
19
|
+
* Manual id → text of the messages the packages in `extraction.dependencies`
|
|
20
|
+
* declare (`vi18n.messages.json`), as `vi18n.gen.ts` lists them; none
|
|
21
|
+
* otherwise. `msg({ id })` names one of them without repeating its text.
|
|
22
|
+
*/
|
|
23
|
+
type LibraryMessages = Register extends {
|
|
24
|
+
messages: infer M extends {
|
|
25
|
+
readonly [id: string]: string;
|
|
26
|
+
};
|
|
27
|
+
} ? M : Record<never, never>;
|
|
28
|
+
/**
|
|
29
|
+
* Rest-parameter tuple of `t(message, ...values)` for a literal message `M`:
|
|
30
|
+
*
|
|
31
|
+
* - no arguments → `[]` (tags need no value in `t`, they render their children);
|
|
32
|
+
* - otherwise `[values: { … }]` with one required property per argument:
|
|
33
|
+
* `string | number | bigint | Date` for `{x}` (a `Date` renders as
|
|
34
|
+
* `{x, date, medium}`), `number | bigint` for `number`,
|
|
35
|
+
* `Date | number` for `date`/`time`, `string` for `select`, `number` for
|
|
36
|
+
* `plural`/`selectordinal`. A name used with two kinds takes the more
|
|
37
|
+
* specific kind's type, as the compiler's `structureOf` does: a plain `{x}`
|
|
38
|
+
* goes with any kind (`{d, date} ({d})` takes `Date | number`);
|
|
39
|
+
* - a non-literal `string` → `never`, so `t(props.label)` does not type-check
|
|
40
|
+
* (only literals and `MessageRef`s do). So does a union with any non-literal
|
|
41
|
+
* member (`"Save" | (string & {})`, or a template literal type): the
|
|
42
|
+
* extractor lets such an expression through, so this type is its only guard;
|
|
43
|
+
* - a union of two or more literals (`cond ? "Draft" : "Live"`, or a variable
|
|
44
|
+
* of type `"Draft" | "Live"`) → `never` too. The extractor takes one literal
|
|
45
|
+
* message per call, so neither text would reach the catalogs or be
|
|
46
|
+
* rewritten, and a production client would render "". It reports the
|
|
47
|
+
* `? :`, `||`, `??` and `&&` forms and a `const` holding one in the same
|
|
48
|
+
* module; a parameter or an import of such a type only this type catches.
|
|
49
|
+
* Choose between calls (`cond ? t("Draft") : t("Live")`) or between
|
|
50
|
+
* `msg()` references, which `t(ref)` takes as a union.
|
|
51
|
+
*
|
|
52
|
+
* A message this parser cannot read (an unclosed `{`, an unknown argument
|
|
53
|
+
* type) takes `[values?: Values]`: the compiler reports the syntax error with
|
|
54
|
+
* its position, which a type error at the call site could not. So does an
|
|
55
|
+
* MF2 complex message, whose values this ICU parser does not type.
|
|
56
|
+
*/
|
|
57
|
+
type ValuesOf<M extends string> = Read<M, M>;
|
|
58
|
+
/**
|
|
59
|
+
* What the message parameter of `rich()`, `richHtml()`, `richParts()` and a
|
|
60
|
+
* translator's `rich*` adds to the message's own type `M`: `unknown` for one
|
|
61
|
+
* message, `never` for a choice between texts, for the reason `ValuesOf`
|
|
62
|
+
* gives (one literal per call, §6 D120, D128). A choice is a union of two or
|
|
63
|
+
* more string types, a descriptor whose `message` is one, or a union of a
|
|
64
|
+
* text (a literal string or a descriptor of one) with anything else.
|
|
65
|
+
*
|
|
66
|
+
* Unlike `t()`, these take a non-literal `string`, descriptor or
|
|
67
|
+
* `MessageKey` (a runtime id), whose values they never type. So does an
|
|
68
|
+
* explicit tag type, `rich<ReactNode>(…)`: TypeScript infers no type
|
|
69
|
+
* argument once one is given, so `M` is `MessageKey` and only the build's
|
|
70
|
+
* scan rejects a choice there.
|
|
71
|
+
*/
|
|
72
|
+
type OneText<M> = [Choice<M>] extends [never] ? unknown : never;
|
|
73
|
+
/**
|
|
74
|
+
* Something (`1`) when `M` is a choice, else `never`. Strings, nearly every
|
|
75
|
+
* call, take one union test; a `MessageKey` that is no literal is no choice.
|
|
76
|
+
*/
|
|
77
|
+
type Choice<M> = [M] extends [string] ? Many<M> : [Literal<Alternatives<M>>] extends [never] ? never : Many<Alternatives<M>>;
|
|
78
|
+
/** One alternative per member: a descriptor's `message`, any other member itself. */
|
|
79
|
+
type Alternatives<M> = M extends {
|
|
80
|
+
readonly message: infer T;
|
|
81
|
+
} ? T : M;
|
|
82
|
+
/** The literal strings among `A` (as `Read` tells them from `string` and patterns). */
|
|
83
|
+
type Literal<A> = A extends string ? Record<never, never> extends Record<A, 1> ? never : A : never;
|
|
84
|
+
/** `1` when `T` is a union of two or more types, else `never`. */
|
|
85
|
+
type Many<T, All = T> = T extends unknown ? ([All] extends [T] ? never : 1) : never;
|
|
86
|
+
/**
|
|
87
|
+
* Rest-parameter tuple of `rich(message, ...values)` (PLAN §4.12 "Typed
|
|
88
|
+
* rich-text tag handlers", §6 D212): for a literal message, one property per
|
|
89
|
+
* ICU argument, typed as `ValuesOf` types it, and one handler `H` per tag,
|
|
90
|
+
* so a missing handler, a misspelt one and one for a tag the message does
|
|
91
|
+
* not have are type errors. A plain `{x}` also takes `N`, the node type, as
|
|
92
|
+
* `rich()` renders a node passed as a value in place. Tags with a global
|
|
93
|
+
* handler (`defaults.tags`, the generated `Register`'s `defaultTags`) may be
|
|
94
|
+
* left out.
|
|
95
|
+
*
|
|
96
|
+
* Untyped (`[values?: Values]`), as before: a non-literal message (a runtime
|
|
97
|
+
* id, a `MessageKey`, a `MessageRef`, whose tags its type does not carry), a
|
|
98
|
+
* message `ValuesOf` cannot read, and one whose tags this reader cannot tell
|
|
99
|
+
* (a `'#` before a tag: whether it quotes depends on an enclosing plural).
|
|
100
|
+
*/
|
|
101
|
+
type RichValuesOf<M, H, N = never> = Rich<TextOf<M>, H, N, true>;
|
|
102
|
+
/** `richParts()`'s values: arguments only, since every tag becomes a part and handlers are ignored. */
|
|
103
|
+
type RichPartsValuesOf<M> = Rich<TextOf<M>, never, never, false>;
|
|
104
|
+
/** Tag names that `defaults.tags` gives a global handler (`vi18n.gen.ts`); `never` without it. */
|
|
105
|
+
type DefaultTags = Register extends {
|
|
106
|
+
defaultTags: infer T extends string;
|
|
107
|
+
} ? T : never;
|
|
108
|
+
/** The literal text of a message, `never` for anything typed as a runtime id. */
|
|
109
|
+
type TextOf<M> = M extends string ? Record<never, never> extends Record<M, 1> ? never : M : M extends {
|
|
110
|
+
readonly message: infer T extends string;
|
|
111
|
+
} ? Record<never, never> extends Record<T, 1> ? never : T : never;
|
|
112
|
+
type Untyped = [values?: Values];
|
|
113
|
+
type Rich<S extends string, H, N, WithTags extends boolean> = [S] extends [never] ? Untyped : ValuesOf<S> extends (infer A) ? Unreadable extends A ? Untyped : (WithTags extends true ? TagsOf<S, never> : never) extends (infer Tg extends string) ? string extends Tg ? Untyped : Handlers<Tg, H, Args<A, N>> : never : never;
|
|
114
|
+
/** The argument object of a `ValuesOf` result; a plain `{x}` takes nodes too. */
|
|
115
|
+
type Args<A, N> = A extends [values: infer O] ? [N] extends [never] ? O : { [K in keyof O]: [Plain] extends [O[K]] ? O[K] | N : O[K]; } : unknown;
|
|
116
|
+
/**
|
|
117
|
+
* The values tuple: required while an argument or a tag without a global
|
|
118
|
+
* handler needs a value, else optional; with nothing to fill in, any key is
|
|
119
|
+
* an error (`{}` would take every object).
|
|
120
|
+
*/
|
|
121
|
+
type Handlers<Tg extends string, H, O> = [Tg] extends [never] ? unknown extends O ? [values?: {
|
|
122
|
+
readonly [name: string]: never;
|
|
123
|
+
}] : [values: O] : [Extract<Tg, DefaultTags>] extends [never] ? [values: unknown extends O ? { [K in Tg]: H; } : { [K in keyof O | Tg]: K extends Tg ? H : O[K & keyof O]; }] : [Exclude<Tg, DefaultTags>] extends [never] ? unknown extends O ? [values?: { [K in Tg]?: H; }] : [values: One<O & { [K in Tg]?: H; }>] : [values: One<O & { [K in Exclude<Tg, DefaultTags>]: H; } & { [K in Extract<Tg, DefaultTags>]?: H; }>];
|
|
124
|
+
/** One object type, as editors show it; `keyof` keeps each property's `?`. */
|
|
125
|
+
type One<T> = { [K in keyof T]: T[K]; };
|
|
126
|
+
/** First characters of a tag name: `<` and anything else is text (INTERNALS §2.1). */
|
|
127
|
+
type AsciiLetter = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z";
|
|
128
|
+
/**
|
|
129
|
+
* The tag names of a message, read like `Body` reads arguments: one template
|
|
130
|
+
* match per `<` and per `'`, never per character. Tags only stand in text,
|
|
131
|
+
* and argument names, types, option keys and styles hold neither `<` nor `'`
|
|
132
|
+
* in a message the compiler accepts, so no frame stack is needed; only
|
|
133
|
+
* quoted text hides a tag. `string` when a `'#` comes first: it quotes only
|
|
134
|
+
* inside a plural, which this reader does not track.
|
|
135
|
+
*/
|
|
136
|
+
type TagsOf<S extends string, Acc extends string> = S extends `${infer A}<${infer R}` ? A extends `${string}'${string}` ? TagQuote<S, Acc> : R extends `${infer F}${string}` ? F extends AsciiLetter ? R extends `${infer N}>${infer Rest}` ? TagsOf<Rest, Acc | TagName<N>> : string : TagsOf<R, Acc> : Acc : Acc;
|
|
137
|
+
/** `S` has a `'` before its first `<`. */
|
|
138
|
+
type TagQuote<S extends string, Acc extends string> = S extends `${string}'${infer R}` ? R extends `'${infer Rest}` ? TagsOf<Rest, Acc> : R extends `${"{" | "}" | "<" | ">"}${infer Rest}` ? TagQuoted<Rest, Acc> : R extends `#${string}` ? string : TagsOf<R, Acc> : Acc;
|
|
139
|
+
/** Quoted text ends at the next single `'`; `''` inside it is a literal `'`. */
|
|
140
|
+
type TagQuoted<S extends string, Acc extends string> = S extends `${string}'${infer R}` ? R extends `'${infer Rest}` ? TagQuoted<Rest, Acc> : TagsOf<R, Acc> : Acc;
|
|
141
|
+
/** `b`, `br/`, `br /` → the name (the compiler allows space before `/>` and `>`). */
|
|
142
|
+
type TagName<N extends string> = N extends `${infer X}/${string}` ? TrimTag<X> : TrimTag<N>;
|
|
143
|
+
type TrimTag<N extends string> = N extends `${infer X}${Space}` ? TrimTag<X> : N;
|
|
144
|
+
/**
|
|
145
|
+
* Reads `M` one member of `All` at a time. A member that is not the whole of
|
|
146
|
+
* `All` belongs to a union of literals, and every member of a union reads as
|
|
147
|
+
* `never`, so the union does.
|
|
148
|
+
*/
|
|
149
|
+
type Read<M extends string, All extends string> = M extends string ? [All] extends [M] ? Record<never, never> extends Record<M, 1> ? never : M extends `${string}{${string}` ? Mf2Form<M> extends true ? Unreadable : Flat<Body<M, [], unknown>> : [] : never : never;
|
|
150
|
+
/**
|
|
151
|
+
* A parse result with its values made one object: the accumulator is an
|
|
152
|
+
* intersection of one object per use, and a name used only plainly (still
|
|
153
|
+
* `unknown`, see `PlainUse`) takes `Plain`. `[]` and `Unreadable` stay.
|
|
154
|
+
*/
|
|
155
|
+
type Flat<R> = R extends [values: infer I] ? [values: { [K in keyof I]: unknown extends I[K] ? Plain : I[K]; }] : R;
|
|
156
|
+
type Pound = "0" | "1";
|
|
157
|
+
type Frame = `b${Pound}` | `o${Pound}`;
|
|
158
|
+
/** Pound sensitivity of the frame on top of the stack; the root message has none. */
|
|
159
|
+
type PoundOf<St extends Frame[]> = St extends [...Frame[], `${"b" | "o"}${infer P extends Pound}`] ? P : "0";
|
|
160
|
+
/** Characters that an apostrophe quotes (FormatJS's apostrophe rules). */
|
|
161
|
+
type QuoteStart<P extends Pound> = "{" | "}" | "<" | ">" | (P extends "1" ? "#" : never);
|
|
162
|
+
type Plain = string | number | bigint | Date;
|
|
163
|
+
/**
|
|
164
|
+
* What a plain `{x}` adds to the accumulator: `unknown`, so intersecting it
|
|
165
|
+
* with another kind's type keeps that type (`Date | number` survives, where
|
|
166
|
+
* `Plain & (Date | number)` would lose `Date`); `Flat` maps what is left to `Plain`.
|
|
167
|
+
*/
|
|
168
|
+
type PlainUse = unknown;
|
|
169
|
+
/** `{n, number}`, `{d, date}`, `{t, time}`: the value types they format. */
|
|
170
|
+
interface Formatted {
|
|
171
|
+
number: number | bigint;
|
|
172
|
+
date: Date | number;
|
|
173
|
+
time: Date | number;
|
|
174
|
+
}
|
|
175
|
+
/** The whole message's result once its text ends outside any option; `Flat` flattens it. */
|
|
176
|
+
type Done<Acc> = [keyof Acc] extends [never] ? [] : [values: Acc];
|
|
177
|
+
/** What an unreadable message takes (see `ValuesOf`). */
|
|
178
|
+
type Unreadable = [values?: Values];
|
|
179
|
+
/**
|
|
180
|
+
* An MF2 complex message (`.input`, `.local`, `.match` or `{{` after
|
|
181
|
+
* whitespace), which the compiler reads as MF2 (INTERNALS §2.1.4): its
|
|
182
|
+
* values are not typed, so it takes what an unreadable message takes.
|
|
183
|
+
*/
|
|
184
|
+
type Mf2Form<M extends string> = M extends `${" " | "\n" | "\t" | "\r"}${infer R}` ? Mf2Form<R> : M extends `${".input" | ".local" | ".match" | "{{"}${string}` ? true : false;
|
|
185
|
+
/** Message text: an argument when `{` comes before any `}` or `'`. */
|
|
186
|
+
type Body<S extends string, St extends Frame[], Acc> = S extends `${infer A}{${infer B}` ? A extends `${string}${"}" | "'"}${string}` ? CloseOrQuote<S, St, Acc> : B extends `${infer N}}${infer R}` ? N extends `${string},${string}` ? B extends `${infer N1},${infer T}` ? Typed<Trim<N1>, T, St, Acc> : never : Trim<N> extends (infer Name extends string) ? Name extends "" ? Unreadable : Body<R, St, Acc & { [K in Name]: PlainUse; }> : never : B extends `${infer N1},${infer T}` ? Typed<Trim<N1>, T, St, Acc> : Unreadable : CloseOrQuote<S, St, Acc>;
|
|
187
|
+
/** Message text without a `{` before the first `}` or `'`. */
|
|
188
|
+
type CloseOrQuote<S extends string, St extends Frame[], Acc> = S extends `${infer A}'${infer R}` ? A extends `${string}}${infer B}` ? St extends [...infer Up extends Frame[], Frame] ? Options<`${B}'${R}`, Up, Acc> : Body<`${B}'${R}`, St, Acc> : R extends `'${infer Rest}` ? Body<Rest, St, Acc> : R extends `${QuoteStart<PoundOf<St>>}${infer Rest}` ? Quoted<Rest, St, Acc> : Body<R, St, Acc> : S extends `${string}}${infer B}` ? St extends [...infer Up extends Frame[], Frame] ? Options<B, Up, Acc> : Body<B, St, Acc> : St extends [] ? Done<Acc> : Unreadable;
|
|
189
|
+
/** Quoted text ends at the next single `'`; `''` inside it is a literal `'`. */
|
|
190
|
+
type Quoted<S extends string, St extends Frame[], Acc> = S extends `${string}'${infer R}` ? R extends `'${infer Rest}` ? Quoted<Rest, St, Acc> : Body<R, St, Acc> : St extends [] ? Done<Acc> : Unreadable;
|
|
191
|
+
/** After `{name,`: the type, then `}`, a style (see `Style`), or an option list. */
|
|
192
|
+
type Typed<N extends string, S extends string, St extends Frame[], Acc> = N extends "" ? Unreadable : S extends `${infer K}}${infer R}` ? K extends `${string},${string}` ? Styled<N, S, St, Acc> : Trim<K> extends (infer Type extends keyof Formatted) ? Body<R, St, Acc & { [P in N]: Formatted[Type]; }> : Unreadable : Styled<N, S, St, Acc>;
|
|
193
|
+
type Styled<N extends string, S extends string, St extends Frame[], Acc> = S extends `${infer K},${infer R}` ? Trim<K> extends (infer Type) ? Type extends keyof Formatted ? Style<R, [], St, Acc & { [P in N]: Formatted[Type]; }> : Type extends "select" ? Options<R, [...St, `o${PoundOf<St>}`], Acc & { [P in N]: string; }> : Type extends "plural" | "selectordinal" ? Options<R, [...St, "o1"], Acc & { [P in N]: number; }> : Unreadable : never : Unreadable;
|
|
194
|
+
/**
|
|
195
|
+
* An option list: keys (`male`, `=0`, `offset:1 one`) carry no arguments, so
|
|
196
|
+
* only the next `{` (an option body) or `}` (the end of the argument) matters.
|
|
197
|
+
*/
|
|
198
|
+
type Options<S extends string, St extends Frame[], Acc> = S extends `${infer K}{${infer B}` ? K extends `${string}}${infer R}` ? St extends [...infer Up extends Frame[], Frame] ? Body<`${R}{${B}`, Up, Acc> : Unreadable : St extends [...Frame[], `o${infer P extends Pound}`] ? Body<B, [...St, `b${P}`], Acc> : Unreadable : S extends `${string}}${infer R}` ? St extends [...infer Up extends Frame[], Frame] ? Body<R, Up, Acc> : Unreadable : Unreadable;
|
|
199
|
+
/**
|
|
200
|
+
* A number, date or time style, read as the compiler's `simpleStyle` reads
|
|
201
|
+
* it: up to the first `}` that closes no `{` of the style, with quoted text
|
|
202
|
+
* (`'…'`, no `''` escape) opaque. `D` counts the open `{`. Without this a
|
|
203
|
+
* `'}'` in a skeleton would end the style early and hide every later argument.
|
|
204
|
+
*/
|
|
205
|
+
type Style<S extends string, D extends 0[], St extends Frame[], Acc> = S extends `${infer A}}${infer R}` ? A extends `${string}${"'" | "{"}${string}` ? StyleQuoteOrOpen<S, D, St, Acc> : D extends [0, ...infer Up extends 0[]] ? Style<R, Up, St, Acc> : Body<R, St, Acc> : Unreadable;
|
|
206
|
+
/** Style text whose first `'`, `{` or `}` is a `'` or a `{`. */
|
|
207
|
+
type StyleQuoteOrOpen<S extends string, D extends 0[], St extends Frame[], Acc> = S extends `${infer A}'${infer R}` ? A extends `${string}{${string}` ? StyleOpen<S, D, St, Acc> : R extends `${string}'${infer Rest}` ? Style<Rest, D, St, Acc> : Unreadable : StyleOpen<S, D, St, Acc>;
|
|
208
|
+
type StyleOpen<S extends string, D extends 0[], St extends Frame[], Acc> = S extends `${string}{${infer R}` ? Style<R, [...D, 0], St, Acc> : never;
|
|
209
|
+
/** ICU's Pattern_White_Space, which the compiler skips around names and keywords. */
|
|
210
|
+
type Space = " " | "\t" | "\n" | "\v" | "\f" | "\r" | "
" | "" | "" | "
" | "
";
|
|
211
|
+
type Trim<S extends string> = S extends `${Space}${infer R}` ? Trim<R> : S extends `${string}${Space}` ? TrimEnd<S, ""> : S;
|
|
212
|
+
/**
|
|
213
|
+
* LRM and RLM are Pattern_White_Space but not White_Space, so a name
|
|
214
|
+
* (`[^\p{White_Space}\p{Pattern_Syntax}]*`) may end with them: `{a\u200e}`
|
|
215
|
+
* names `a\u200e`. A trailing mark is space only when White_Space comes before
|
|
216
|
+
* it, so marks wait in `Marks` until that is known.
|
|
217
|
+
*/
|
|
218
|
+
type TrimEnd<S extends string, Marks extends string> = S extends `${infer R}${Space}` ? S extends `${R}\u200e` ? TrimEnd<R, `\u200e${Marks}`> : S extends `${R}\u200f` ? TrimEnd<R, `\u200f${Marks}`> : TrimEnd<R, ""> : `${S}${Marks}`;
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/runtime/types.d.ts
|
|
221
|
+
/**
|
|
222
|
+
* A compiled message. Plain text stays a string (about 81 % of real messages),
|
|
223
|
+
* everything else is a list of parts. Never a function: the IR has to cross
|
|
224
|
+
* JSON, the SSR payload and RSC boundaries.
|
|
225
|
+
*/
|
|
226
|
+
type Message = string | Part[];
|
|
227
|
+
/**
|
|
228
|
+
* One element of a compiled message. Arrays are told apart by length and by
|
|
229
|
+
* the numeric opcode in the second slot; `0` alone is `#`.
|
|
230
|
+
*/
|
|
231
|
+
type Part = string | PoundPart | ArgPart | SelectPart | PluralPart | FormatPart | TagPart | StandaloneTagPart;
|
|
232
|
+
/** `#` inside an immediate plural or selectordinal branch: value − offset, number-formatted. */
|
|
233
|
+
type PoundPart = 0;
|
|
234
|
+
/** `{name}` */
|
|
235
|
+
type ArgPart = [name: string];
|
|
236
|
+
/** `{name, select, …}`; cases are read with `Object.hasOwn`, falling back to `other`. */
|
|
237
|
+
type SelectPart = [name: string, op: 1, cases: Cases];
|
|
238
|
+
/**
|
|
239
|
+
* `{name, plural|selectordinal, [offset:N] …}`. `=N` keys match the raw value,
|
|
240
|
+
* category keys match value − offset. `offset` is omitted when 0.
|
|
241
|
+
*/
|
|
242
|
+
type PluralPart = [name: string, op: 2 | 3, cases: Cases, offset?: number];
|
|
243
|
+
/**
|
|
244
|
+
* `{name, number|date|time[, style]}`. The style or skeleton is resolved to Intl
|
|
245
|
+
* options at compile time; options are omitted when Intl defaults apply.
|
|
246
|
+
*/
|
|
247
|
+
type FormatPart = [name: string, op: 4 | 5 | 6, options?: IntlOptions];
|
|
248
|
+
/** `<tag>children</tag>`; children are spread parts (an empty tag is `[tag, 7]`). */
|
|
249
|
+
type TagPart = [tag: string, op: 7, ...children: Part[]];
|
|
250
|
+
/** `<tag/>` */
|
|
251
|
+
type StandaloneTagPart = [tag: string, op: 8];
|
|
252
|
+
/** Case table of a select or plural part. Keys: select values, `=N`, CLDR categories, `other`. */
|
|
253
|
+
type Cases = {
|
|
254
|
+
[key: string]: Message;
|
|
255
|
+
};
|
|
256
|
+
/** Options handed to `Intl.NumberFormat` / `Intl.DateTimeFormat` as they are. */
|
|
257
|
+
type IntlOptions = {
|
|
258
|
+
[option: string]: string | number | boolean;
|
|
259
|
+
};
|
|
260
|
+
/** Values passed to `t()` and friends. Rich-text tag handlers are passed here too. */
|
|
261
|
+
type Values = {
|
|
262
|
+
readonly [name: string]: unknown;
|
|
263
|
+
};
|
|
264
|
+
/** What the developer writes: `t({ id?, message, context?, maxLength? })`. */
|
|
265
|
+
interface Descriptor {
|
|
266
|
+
readonly id?: string;
|
|
267
|
+
readonly message: string;
|
|
268
|
+
readonly context?: string;
|
|
269
|
+
readonly maxLength?: number;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* What the dev transform emits in place of a message argument. Build output
|
|
273
|
+
* is the bare id string instead, so source text never reaches client JS.
|
|
274
|
+
*/
|
|
275
|
+
interface CompiledDescriptor {
|
|
276
|
+
readonly id: string;
|
|
277
|
+
/** Canonical source text; used for warnings only, never parsed at runtime. */
|
|
278
|
+
readonly message: string;
|
|
279
|
+
/** The source locale's compiled IR, rendered while no catalog has the id. */
|
|
280
|
+
readonly ir: Message;
|
|
281
|
+
/**
|
|
282
|
+
* Manual ids only: the hash label of the code's current text. A dev catalog
|
|
283
|
+
* whose label differs holds a translation of other text (D10), so the
|
|
284
|
+
* runtime renders `ir` and warns once.
|
|
285
|
+
*/
|
|
286
|
+
readonly h?: string;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* A message reference created by `msg()`: at runtime the id string (build) or
|
|
290
|
+
* a {@link CompiledDescriptor} (dev). The `~values` key is a phantom that
|
|
291
|
+
* carries the argument tuple for `t(ref, ...values)`; it never exists at runtime.
|
|
292
|
+
*/
|
|
293
|
+
interface MessageRef<V extends readonly unknown[] = readonly unknown[]> {
|
|
294
|
+
readonly "~values": V;
|
|
295
|
+
}
|
|
296
|
+
/** Anything `t()` accepts at runtime, after or without the plugin's rewrite. */
|
|
297
|
+
type MessageKey = string | Descriptor | CompiledDescriptor | MessageRef;
|
|
298
|
+
/** `richParts()` output. A standalone tag has `children: []`. */
|
|
299
|
+
type RichPart = string | {
|
|
300
|
+
readonly tag: string;
|
|
301
|
+
readonly children: RichPart[];
|
|
302
|
+
};
|
|
303
|
+
/** A rich-text tag handler: receives rendered children and a stable key (the part index). */
|
|
304
|
+
type TagHandler<R> = (children: (string | R)[], key: number) => R;
|
|
305
|
+
/** A `richHtml()` tag handler: children arrive HTML-escaped; the return value is trusted HTML. */
|
|
306
|
+
type HtmlTagHandler = (children: string, key: number) => string;
|
|
307
|
+
/** Where a locale may come from, in `routing.strategy` order. */
|
|
308
|
+
type LocaleStrategy = "url" | "cookie" | "header" | "localStorage" | "default";
|
|
309
|
+
/** URL codec strategies (Nuxt i18n names); domains are `routing.domains` on top of `prefix_except_default`. */
|
|
310
|
+
type UrlStrategy = "prefix_except_default" | "prefix" | "prefix_and_default" | "no_prefix";
|
|
311
|
+
/**
|
|
312
|
+
* The slice of the resolved config that runtime code needs. It is serialised
|
|
313
|
+
* into the boot module, into `vi18n compile --out`'s `config.json`, and passed
|
|
314
|
+
* to `registerCatalogs()`. Locale inputs are matched against `locales` only.
|
|
315
|
+
*/
|
|
316
|
+
interface RuntimeConfig {
|
|
317
|
+
sourceLocale: string;
|
|
318
|
+
/** Configured locales followed by the active pseudo-locales. */
|
|
319
|
+
locales: string[];
|
|
320
|
+
/** Pseudo-locales active in this build (a subset of `locales`). */
|
|
321
|
+
pseudoLocales: string[];
|
|
322
|
+
fallbacks: {
|
|
323
|
+
[locale: string]: string[];
|
|
324
|
+
};
|
|
325
|
+
routing: {
|
|
326
|
+
strategy: LocaleStrategy[];
|
|
327
|
+
/** Glob (`*`, `**`) on the delocalized pathname → strategy chain. First match wins. */
|
|
328
|
+
routeStrategies: {
|
|
329
|
+
[pattern: string]: LocaleStrategy[];
|
|
330
|
+
};
|
|
331
|
+
url: UrlStrategy;
|
|
332
|
+
redirectRoot: boolean;
|
|
333
|
+
propagate: "header" | false;
|
|
334
|
+
switch: "in-place" | "navigate";
|
|
335
|
+
cookie: {
|
|
336
|
+
name: string;
|
|
337
|
+
maxAge: number;
|
|
338
|
+
};
|
|
339
|
+
/** The app's base path (Vite `base`), starting and ending with `/`. */
|
|
340
|
+
base: string;
|
|
341
|
+
/**
|
|
342
|
+
* Localized paths (PLAN §5.14): route path → locale → that locale's path,
|
|
343
|
+
* base-free, `*` and `**` segments as in `routing.paths`. Present only
|
|
344
|
+
* when configured, so default registrations carry no table.
|
|
345
|
+
*/
|
|
346
|
+
paths?: {
|
|
347
|
+
[path: string]: {
|
|
348
|
+
[locale: string]: string;
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* Domain routing: origin (`https://example.de`) → the locale its host
|
|
353
|
+
* serves; the first origin of a locale is where links to it go. Present
|
|
354
|
+
* only when configured; its hosts are the allowlist (§6 D135).
|
|
355
|
+
*/
|
|
356
|
+
domains?: {
|
|
357
|
+
[origin: string]: string;
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* Set at runtime, never serialised: the locale of the listed host the
|
|
361
|
+
* page (client) or the codec call (server, per request) is on. It plays
|
|
362
|
+
* the part `sourceLocale` plays in the URL codec: the unprefixed locale.
|
|
363
|
+
*/
|
|
364
|
+
home?: string;
|
|
365
|
+
};
|
|
366
|
+
ssr: {
|
|
367
|
+
timeZone: string;
|
|
368
|
+
/** Glob on the delocalized pathname → time-zone source for that route. */
|
|
369
|
+
timeZoneFrom: {
|
|
370
|
+
[pattern: string]: "config" | "request";
|
|
371
|
+
};
|
|
372
|
+
normalizeSpaces: boolean;
|
|
373
|
+
/**
|
|
374
|
+
* Servers reading their catalogs from static assets (`ssr.catalogs:
|
|
375
|
+
* "assets"`, `vi18n compile --assets`): at most this many locales stay
|
|
376
|
+
* loaded, the least recently used evicted. Absent for module catalogs.
|
|
377
|
+
*/
|
|
378
|
+
maxLoadedLocales?: number;
|
|
379
|
+
/**
|
|
380
|
+
* `ssr.payload: "preload"`: payloads name the page's bundles and the page
|
|
381
|
+
* preloads them instead of inlining them. Present only when configured,
|
|
382
|
+
* so default registrations stay as they were; servers read it.
|
|
383
|
+
*/
|
|
384
|
+
payload?: "preload";
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Everything `t()` and `fmt` read. The page has one scope; on the server each
|
|
389
|
+
* request (and each `withLocale` / `createTranslator`) has its own.
|
|
390
|
+
*/
|
|
391
|
+
interface Scope {
|
|
392
|
+
readonly kind: "page" | "request" | "translator";
|
|
393
|
+
locale: string;
|
|
394
|
+
/** Complete for the locale after fallbacks; never mutated in place (merges build new Maps). */
|
|
395
|
+
messages: ReadonlyMap<string, Message>;
|
|
396
|
+
/** IANA zone; undefined means the environment's zone (client after hydration only). */
|
|
397
|
+
timeZone: string | undefined;
|
|
398
|
+
/** Epoch ms used by `fmt.relative` and serialised to the client; undefined means `Date.now()`. */
|
|
399
|
+
now: number | undefined;
|
|
400
|
+
/** Where `timeZone` came from (server); "cookie" and "cf" are per-user zones. */
|
|
401
|
+
timeZoneSource?: "explicit" | "cookie" | "cf" | "config" | "client";
|
|
402
|
+
/** Set by the runtime when it formats time-bearing output in this scope. */
|
|
403
|
+
formattedTime?: boolean;
|
|
404
|
+
/** Server: every id looked up while rendering (payload). The runtime adds to it when present, outside `State.untracked`. */
|
|
405
|
+
used?: Set<string>;
|
|
406
|
+
/**
|
|
407
|
+
* Exact source literal → generated id, from `registerCatalogs({ sources })`.
|
|
408
|
+
* The only place `t()` resolves source-text keys (untransformed server code).
|
|
409
|
+
*/
|
|
410
|
+
readonly sources?: ReadonlyMap<string, string>;
|
|
411
|
+
/**
|
|
412
|
+
* Dev only: manual id → hash label of the source its dev-catalog
|
|
413
|
+
* translation was made from (`DevCatalog.labels`). `t()` compares it with a
|
|
414
|
+
* descriptor's `h` before looking the id up (INTERNALS §2.11.2 step 1).
|
|
415
|
+
*/
|
|
416
|
+
labels?: ReadonlyMap<string, string>;
|
|
417
|
+
/**
|
|
418
|
+
* Server, with `routing.domains`: the locale of the request's host when
|
|
419
|
+
* that host is listed (never an unlisted `Host`), so links rendered in the
|
|
420
|
+
* request leave its domain only for another listed one.
|
|
421
|
+
*/
|
|
422
|
+
home?: string;
|
|
423
|
+
/**
|
|
424
|
+
* Set only by `@menapo/vi18n/test` on the page scope (PLAN §5.22): the
|
|
425
|
+
* message to render for every key, chosen with the descriptor that a
|
|
426
|
+
* catalog map never sees (ids and pseudo modes, messages keyed by source
|
|
427
|
+
* text). Builds never read it (INTERNALS §6 D189).
|
|
428
|
+
*/
|
|
429
|
+
test?: (id: string, descriptor: CompiledDescriptor | undefined, text: string) => Message;
|
|
430
|
+
/**
|
|
431
|
+
* Dev only, set on the page scope by the in-context editor (`devtools`,
|
|
432
|
+
* INTERNALS §2.18): hears every id the page looks up. Builds fold the
|
|
433
|
+
* call away.
|
|
434
|
+
*/
|
|
435
|
+
seen?: (id: string) => void;
|
|
436
|
+
}
|
|
437
|
+
/** Reported through `onMissing`. */
|
|
438
|
+
interface MissingInfo {
|
|
439
|
+
/** The id looked up, or the source text for unprocessed calls. */
|
|
440
|
+
key: string;
|
|
441
|
+
locale: string;
|
|
442
|
+
reason: "unknown-id" | "not-loaded" | "source-mismatch" | "no-scope";
|
|
443
|
+
}
|
|
444
|
+
type MissingHandler = (info: MissingInfo) => void;
|
|
445
|
+
/**
|
|
446
|
+
* A Temporal value (`Temporal.Instant`, `ZonedDateTime`, `PlainDate`,
|
|
447
|
+
* `PlainDateTime`, `PlainTime`, `PlainYearMonth`, `PlainMonthDay`), native or
|
|
448
|
+
* a polyfill's, recognised by its tag (PLAN §4.2): typed structurally, so
|
|
449
|
+
* runtime types need neither `lib.esnext.temporal` nor a polyfill.
|
|
450
|
+
*/
|
|
451
|
+
interface TemporalInput {
|
|
452
|
+
readonly [Symbol.toStringTag]: `Temporal.${string}`;
|
|
453
|
+
}
|
|
454
|
+
/** What the date members of `fmt` take. */
|
|
455
|
+
type DateInput = Date | number | TemporalInput;
|
|
456
|
+
/** `fmt` namespace members (PLAN §5.17). Every member reads the scope's locale, zone and `now`. */
|
|
457
|
+
interface Fmt {
|
|
458
|
+
number(value: number | bigint, options?: Intl.NumberFormatOptions): string;
|
|
459
|
+
currency(value: number | bigint, currency: string, options?: Intl.NumberFormatOptions): string;
|
|
460
|
+
/** Minor units; fraction digits from the currency (JPY 0, USD 2, BHD 3). */
|
|
461
|
+
currencyMinor(minor: number | bigint, currency: string, options?: Intl.NumberFormatOptions): string;
|
|
462
|
+
unit(value: number, unit: string, options?: Intl.NumberFormatOptions): string;
|
|
463
|
+
compact(value: number, options?: Intl.NumberFormatOptions): string;
|
|
464
|
+
percent(value: number, options?: Intl.NumberFormatOptions): string;
|
|
465
|
+
/** Temporal values too: exact times in the scope's zone (a ZonedDateTime in its own), wall-clock values as they are. */
|
|
466
|
+
date(value: DateInput, options?: Intl.DateTimeFormatOptions): string;
|
|
467
|
+
time(value: DateInput, options?: Intl.DateTimeFormatOptions): string;
|
|
468
|
+
dateRange(start: DateInput, end: DateInput, options?: Intl.DateTimeFormatOptions): string;
|
|
469
|
+
/** Exact times: a `Date`, epoch ms, a Temporal `Instant` or `ZonedDateTime`. */
|
|
470
|
+
relative(value: DateInput, options?: Intl.RelativeTimeFormatOptions & {
|
|
471
|
+
now?: number;
|
|
472
|
+
unit?: Intl.RelativeTimeFormatUnit;
|
|
473
|
+
}): string;
|
|
474
|
+
list(items: readonly string[], options?: Intl.ListFormatOptions): string;
|
|
475
|
+
displayName(code: string, options: Intl.DisplayNamesOptions): string | undefined;
|
|
476
|
+
duration(duration: DurationInput, options?: {
|
|
477
|
+
style?: "long" | "short" | "narrow" | "digital";
|
|
478
|
+
}): string;
|
|
479
|
+
/** The locale's string order: `-1`, `0` or `1`, from a cached `Intl.Collator`. */
|
|
480
|
+
compare(a: string, b: string, options?: Intl.CollatorOptions): number;
|
|
481
|
+
/** The cached `Intl.Collator`, for `items.sort(fmt.collator().compare)`. */
|
|
482
|
+
collator(options?: Intl.CollatorOptions): Intl.Collator;
|
|
483
|
+
/** Graphemes (default), words or sentences, from a cached `Intl.Segmenter`. */
|
|
484
|
+
segment(text: string, options?: Intl.SegmenterOptions): Intl.Segments;
|
|
485
|
+
}
|
|
486
|
+
/** `fmt.duration` input, the `Intl.DurationFormat` record. */
|
|
487
|
+
interface DurationInput {
|
|
488
|
+
years?: number;
|
|
489
|
+
months?: number;
|
|
490
|
+
weeks?: number;
|
|
491
|
+
days?: number;
|
|
492
|
+
hours?: number;
|
|
493
|
+
minutes?: number;
|
|
494
|
+
seconds?: number;
|
|
495
|
+
milliseconds?: number;
|
|
496
|
+
}
|
|
497
|
+
/** The translation function's call signatures (PLAN §5.18). */
|
|
498
|
+
interface TFunction {
|
|
499
|
+
<const M extends string>(message: M, ...values: ValuesOf<M>): string;
|
|
500
|
+
<const D extends Descriptor>(descriptor: D, ...values: ValuesOf<D["message"]>): string;
|
|
501
|
+
<V extends readonly unknown[]>(ref: MessageRef<V>, ...values: V): string;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* `rich()`'s signature (PLAN §5.16): `R` is what tag handlers return,
|
|
505
|
+
* inferred from them. A choice between texts takes `never` (`OneText`); a
|
|
506
|
+
* literal message types its arguments and one handler per tag
|
|
507
|
+
* (`RichValuesOf`).
|
|
508
|
+
*/
|
|
509
|
+
type RichFunction = <R = unknown, const M extends MessageKey = MessageKey>(message: M & OneText<M>, ...values: RichValuesOf<M, TagHandler<R>, R>) => (string | R)[];
|
|
510
|
+
/** `richHtml()`'s signature. */
|
|
511
|
+
type RichHtmlFunction = <const M extends MessageKey>(message: M & OneText<M>, ...values: RichValuesOf<M, HtmlTagHandler>) => string;
|
|
512
|
+
/** `richParts()`'s signature: tags become parts, so it takes no handlers. */
|
|
513
|
+
type RichPartsFunction = <const M extends MessageKey>(message: M & OneText<M>, ...values: RichPartsValuesOf<M>) => RichPart[];
|
|
514
|
+
/** `createTranslator()` result: the API bound to one locale, zone and `now`. */
|
|
515
|
+
interface Translator {
|
|
516
|
+
readonly locale: string;
|
|
517
|
+
readonly t: TFunction;
|
|
518
|
+
readonly rich: RichFunction;
|
|
519
|
+
readonly richHtml: RichHtmlFunction;
|
|
520
|
+
readonly richParts: RichPartsFunction;
|
|
521
|
+
readonly fmt: Fmt;
|
|
522
|
+
}
|
|
523
|
+
declare global {
|
|
524
|
+
/**
|
|
525
|
+
* Defined by `vi18n:config` (`true` in `vite dev`, `false` in builds). Runtime
|
|
526
|
+
* code reads it as `typeof __VI18N_DEV__ !== "undefined" && __VI18N_DEV__`, so
|
|
527
|
+
* code bundled without the plugin behaves as production. `var`, not `const`:
|
|
528
|
+
* the two pack configs each inline this file into their own `.d.ts` chunk,
|
|
529
|
+
* and a consumer importing both would hit a block-scoped redeclaration.
|
|
530
|
+
*/
|
|
531
|
+
var __VI18N_DEV__: boolean | undefined;
|
|
532
|
+
/**
|
|
533
|
+
* Defined by `vi18n:config`: whether the config has `routing.paths` or
|
|
534
|
+
* `routing.domains`. Code bundled without the plugin keeps the support
|
|
535
|
+
* (`typeof __VI18N_ROUTES__ === "undefined" || __VI18N_ROUTES__`), and a
|
|
536
|
+
* plugin build of a config without either folds it out (PLAN §6).
|
|
537
|
+
*/
|
|
538
|
+
var __VI18N_ROUTES__: boolean | undefined;
|
|
539
|
+
/**
|
|
540
|
+
* Defined by `vi18n:config`: whether `ssr.payload` is `"preload"`. Code
|
|
541
|
+
* bundled without the plugin keeps the support (a Nitro-built `/server`
|
|
542
|
+
* copy reads the registration's config), and a plugin build of the default
|
|
543
|
+
* config folds it out of the engine and `/server` (PLAN §6).
|
|
544
|
+
*/
|
|
545
|
+
var __VI18N_PRELOAD__: boolean | undefined;
|
|
546
|
+
/**
|
|
547
|
+
* Defined by `vi18n:config`: whether `output.compactIds` is on. Only the
|
|
548
|
+
* plugin's boot module imports the engine, so undefined reads as false.
|
|
549
|
+
*/
|
|
550
|
+
var __VI18N_COMPACT__: boolean | undefined;
|
|
551
|
+
/**
|
|
552
|
+
* Defined by `vi18n:config`: whether `output.perLocale` is on. Undefined
|
|
553
|
+
* is false, as for `__VI18N_COMPACT__`.
|
|
554
|
+
*/
|
|
555
|
+
var __VI18N_INLINE__: boolean | undefined;
|
|
556
|
+
}
|
|
557
|
+
//#endregion
|
|
558
|
+
export { Locale as C, ValuesOf as D, RichValuesOf as E, LibraryMessages as S, RichPartsValuesOf as T, TagHandler as _, Message as a, Values as b, MissingHandler as c, RichHtmlFunction as d, RichPart as f, TFunction as g, Scope as h, HtmlTagHandler as i, MissingInfo as l, RuntimeConfig as m, Descriptor as n, MessageKey as o, RichPartsFunction as p, Fmt as r, MessageRef as s, DateInput as t, RichFunction as u, TemporalInput as v, Register as w, DefaultTags as x, Translator as y };
|