@tolki/types 1.10.0 → 1.11.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/package.json +1 -1
- package/src/lang.d.ts +23 -0
package/package.json
CHANGED
package/src/lang.d.ts
CHANGED
|
@@ -233,6 +233,26 @@ type LangCountable =
|
|
|
233
233
|
/** A number, or a value whose count is the number. */
|
|
234
234
|
type ChoiceNumber = number | LangCountable;
|
|
235
235
|
|
|
236
|
+
/** What `import()` answers for a locale's JSON file: a module namespace whose default export is the lines. */
|
|
237
|
+
type LocaleModule = { readonly default: LocaleLines };
|
|
238
|
+
|
|
239
|
+
/** Fetches one locale's lines, at once or later; a file imported as a module is unwrapped. */
|
|
240
|
+
type LocaleLinesLoader = (
|
|
241
|
+
locale: string,
|
|
242
|
+
) => LocaleLines | LocaleModule | Promise<LocaleLines | LocaleModule>;
|
|
243
|
+
|
|
244
|
+
/** What `createLang()` is built from. */
|
|
245
|
+
interface LangOptions<TLines extends LangLines = LangLines> {
|
|
246
|
+
/** The locale to start in. */
|
|
247
|
+
readonly locale: string;
|
|
248
|
+
/** The locale a lookup falls back to. */
|
|
249
|
+
readonly fallback?: string | null;
|
|
250
|
+
/** The lines already at hand, one object per locale. */
|
|
251
|
+
readonly lines?: TLines;
|
|
252
|
+
/** Fetches a locale's lines when it is first needed. */
|
|
253
|
+
readonly load?: LocaleLinesLoader;
|
|
254
|
+
}
|
|
255
|
+
|
|
236
256
|
// An export list keeps the helpers above private: a .d.ts module without one exports every declaration.
|
|
237
257
|
export type {
|
|
238
258
|
ChoiceNumber,
|
|
@@ -240,8 +260,11 @@ export type {
|
|
|
240
260
|
LangGroup,
|
|
241
261
|
LangInputValue,
|
|
242
262
|
LangLines,
|
|
263
|
+
LangOptions,
|
|
243
264
|
LangValue,
|
|
244
265
|
LocaleLines,
|
|
266
|
+
LocaleLinesLoader,
|
|
267
|
+
LocaleModule,
|
|
245
268
|
LocalesResolver,
|
|
246
269
|
MissingKeyHandler,
|
|
247
270
|
Replacements,
|