@secundus-studio/stift-generator 0.0.0-stage → 0.4.31

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.
@@ -0,0 +1,1149 @@
1
+ import { LocaleTag, UnitCategory, RegisteredLocale, LoadingStrategy, NamespaceId, UrlDetectionConfig, CookiePersistenceConfig, StateConfig, MessageKey, PackSecurityTier as PackSecurityTier$1, PackEncoding as PackEncoding$1, PackCompression as PackCompression$1, PackCatalog, LocaleShard } from '@secundus-studio/stift-core';
2
+ export { IcuNode, IcuOption, ParseResult, collectFunctions, parseMessage } from '@secundus-studio/stift-core';
3
+ import { z } from 'zod';
4
+
5
+ /**
6
+ * Project config types (docs/05-config.md + docs/02-schemas.ts §9).
7
+ *
8
+ * Moved into `@secundus-studio/stift-generator` rather than `@secundus-studio/stift-core/config` (the
9
+ * path doc 05 shows): the config file is loaded by build tooling and never
10
+ * touches the runtime, and keeping it out of core avoids pulling the build
11
+ * surface / a Zod dep into the headless runtime. `LocaleTag` is re-exported
12
+ * from core so config authoring shares the branded type.
13
+ */
14
+
15
+ /** `'any'` = accept any engine-supported value; a list narrows the generated `Register` union. */
16
+ type NumberingSystemConfig = 'any' | readonly string[];
17
+ /** `'any'` = accept any engine-supported value; a list narrows the generated `Register` union. */
18
+ type CurrencyConfig = 'any' | readonly string[];
19
+ /**
20
+ * Per-category unit declaration (docs/17-units.md). `supportedValues` sets the
21
+ * category's allowed units (omitted or `'all'` = the full canonical catalog);
22
+ * `defaults` carries the per-locale default units in the same shape as context
23
+ * params (docs/16): the required `all` key is the catch-all, and locale keys
24
+ * are overrides that outrank it via the locale hierarchy (exact tag → stripped
25
+ * subtags → `all`). An unsupported locale key is a *runtime* error via
26
+ * `unitsSchema`. A global override via `stift.setUnit` outranks everything.
27
+ *
28
+ * Nesting per-locale defaults (never top-level keys) is what lets the
29
+ * `supportedValues` reserved key coexist with a `Partial<Record<RegisteredLocale, string>>`
30
+ * — under an unaugmented `Register.locale` (no generated `stift.gen.d.ts`)
31
+ * that mapped type collapses to a broad index signature whose `string` value
32
+ * conflicts with the `readonly string[]` of `supportedValues`.
33
+ */
34
+ type UnitCategoryConfig = {
35
+ /** The category's allowed units. */
36
+ supportedValues: 'all' | readonly string[];
37
+ /** Per-locale default units. `all` is the required catch-all; remaining
38
+ * keys are per-locale overrides, restricted to the generated
39
+ * `Register.locale` union so an unsupported locale is a type error at the
40
+ * config file. */
41
+ defaults: {
42
+ all: string;
43
+ } & Partial<Record<RegisteredLocale, string>>;
44
+ /** Persist a `setUnit` override to the state backend (default `true`).
45
+ * `false` keeps the override in memory only — use it for session-scoped
46
+ * or backend-authoritative values. */
47
+ persist?: boolean;
48
+ };
49
+ /** Units config. `'all'` opens every category with its canonical default;
50
+ * a partial object leaves the omitted categories open the same way. */
51
+ type UnitsConfig = 'all' | Partial<Record<UnitCategory, UnitCategoryConfig>>;
52
+ /**
53
+ * Pack serialization encoding.
54
+ *
55
+ * - `'msgpack'` — MessagePack binary (default). Compact, fast, not
56
+ * human-readable. Emitted as `.dat`.
57
+ * - `'cbor'` — CBOR binary. Same role, different size/speed tradeoff.
58
+ * Emitted as `.dat`.
59
+ * - `'json'` — Plain readable JSON bytes. Emitted as `.json`, fetched and
60
+ * parsed as JSON at runtime — no codec, decompression, or key. Only valid
61
+ * with `tier: 'none'` + `compression: 'none'`.
62
+ */
63
+ type PackEncoding = 'msgpack' | 'cbor' | 'json';
64
+ /**
65
+ * Pack compression (applied after serialization, before encryption).
66
+ *
67
+ * - `'none'` — Skip compression. Required with `encoding: 'json'`.
68
+ * - `'gzip'` — Default. `node:zlib` at build time, platform
69
+ * `DecompressionStream` in the browser.
70
+ * - `'brotli'` — Smaller than gzip; browser decodes via `brotli-wasm`
71
+ * (lazy import, so gzip users never ship it).
72
+ */
73
+ type PackCompression = 'none' | 'gzip' | 'brotli';
74
+ /**
75
+ * Pack security tier (docs/03-architecture.md §4).
76
+ *
77
+ * - `'none'` — No obfuscation or encryption. Pair with `encoding: 'json'` +
78
+ * `compression: 'none'` for plain `.json` packs; with a binary encoding it
79
+ * still emits a `.dat` container, just with tier byte `0`.
80
+ * - `'obfuscated'` — Default for prod. Binary codec + compression: defeats
81
+ * casual network-tab scraping, naive JSON scrapers, accidental leakage of
82
+ * unreleased strings — not a motivated attacker (public spec).
83
+ * - `'encrypted-static'` — + AES-GCM with a build-time key (`staticKey` /
84
+ * `STIFT_STATIC_KEY`, also baked into the client bundle — weak by design).
85
+ * - `'encrypted-session'` — + AES-GCM with a per-session key from the app's
86
+ * authenticated endpoint (`getSessionKey`). Real access control for
87
+ * entitlement-gated locales.
88
+ */
89
+ type PackSecurityTier = 'none' | 'obfuscated' | 'encrypted-static' | 'encrypted-session';
90
+ /**
91
+ * Per-locale defaults for a declared context param (docs/16). Always the
92
+ * object form: the reserved `all` key is the guaranteed catch-all fallback
93
+ * (required — a value can never be undefined), and locale keys are restricted
94
+ * to the generated `Register.locale` union, so an unsupported locale is a
95
+ * type error at the config file. Resolution walks the locale hierarchy
96
+ * (exact tag → stripped subtags → `all`).
97
+ */
98
+ type ParamDefaults = {
99
+ all: string;
100
+ } & Partial<Record<RegisteredLocale, string>>;
101
+ interface ContextParamConfig {
102
+ /**
103
+ * Declared context param name (e.g. `gender`, `politeness`). Declared params
104
+ * are context-supplied and *optional* at call sites (docs/16 §Design).
105
+ */
106
+ name: string;
107
+ /** Canonical category set — the type union emitted for this param
108
+ * everywhere it is used, and the set `defaults`/`setParam` values validate
109
+ * against. */
110
+ values: readonly string[];
111
+ /** Per-locale defaults. Every value must be a member of `values`; the `all`
112
+ * key is required and serves as the fallback when no locale-specific entry
113
+ * (or a parent locale's entry) matches. */
114
+ defaults: ParamDefaults;
115
+ /** Persist a `setParam` override to the state backend (default `true`).
116
+ * `false` keeps the override in memory only — use it for session-scoped
117
+ * or backend-authoritative values (e.g. a plan/tenant the backend owns). */
118
+ persist?: boolean;
119
+ }
120
+ interface ParamsConfig {
121
+ /** Declared context params (grammatical agreement, docs/16). */
122
+ context?: readonly ContextParamConfig[];
123
+ }
124
+ interface DetectionConfig {
125
+ /**
126
+ * Detector priority order (min 1 entry), most-trusted first — e.g.
127
+ * `['explicit', 'custom', 'navigator']`. `'custom'` is a reserved slot: the
128
+ * function itself is registered at runtime via
129
+ * `createStift({ detectors: { custom: [...] } })`, never here.
130
+ */
131
+ order: string[];
132
+ /**
133
+ * Per-detector timeout: local/sync detectors get a short leash, a DB-backed
134
+ * custom detector gets network slack. A flat number (e.g. `1500`) works when
135
+ * no split is needed; a function gets full dynamic control
136
+ * (e.g. skip the custom allowance when offline).
137
+ */
138
+ timeout?: number | (Partial<Record<string, number>> & {
139
+ default: number;
140
+ }) | ((detectorId: string) => number);
141
+ /** Locale-in-the-URL strategy for the built-in `url` detector
142
+ * (docs/07-detection-and-middleware.md §4). */
143
+ url?: UrlDetectionConfig;
144
+ /**
145
+ * Opt-in client-side cookie persistence of the active locale
146
+ * (docs/07-detection-and-middleware.md §2): a discovery win
147
+ * (header/navigator/custom) or an explicit `setLocale` writes the locale to
148
+ * a `document.cookie`, and the `cookie` detector reads it back on later
149
+ * visits so the user's saved choice prevails over the first-visit guess.
150
+ */
151
+ cookie?: CookiePersistenceConfig;
152
+ /** Last-resort locale when every detector has no opinion. Usually the default locale. */
153
+ fallback?: LocaleTag;
154
+ }
155
+ interface NamespacesConfig {
156
+ /** Translation-files directory, relative to the project root (e.g. `'locales'`). */
157
+ dir: string;
158
+ /**
159
+ * How namespaces are discovered: `'convention'` walks
160
+ * `<dir>/<locale>/<namespace>.json` (nested dirs supported:
161
+ * `locales/en/common/systemStatus/notifications.json` → namespace
162
+ * `"common/systemStatus/notifications"`); `'manifest'` reads an explicit list.
163
+ */
164
+ discovery: 'convention' | 'manifest';
165
+ /** Namespaces seeded into `memory.preload` (pinned, LRU-exempt at runtime). */
166
+ default: readonly string[];
167
+ }
168
+ /**
169
+ * Pack compile pipeline config (docs/03-architecture.md §4).
170
+ * Absent entirely = `{ tier: 'obfuscated', encoding: 'msgpack', compression: 'gzip' }`.
171
+ */
172
+ interface SecurityConfig {
173
+ /** What the tier buys is documented per value — default `'obfuscated'`. */
174
+ tier: PackSecurityTier;
175
+ /** Serializer — default `'msgpack'`. `'json'` emits plain `.json` packs (only with `tier: 'none'` + `compression: 'none'`). */
176
+ encoding: PackEncoding;
177
+ /** Post-serialization compression — default `'gzip'`. `'none'` is required with `encoding: 'json'`. */
178
+ compression: PackCompression;
179
+ /**
180
+ * AES-GCM key string for encrypted tiers (docs/03-architecture.md §4).
181
+ * `encrypted-static`: also baked into the client bundle by the generated
182
+ * runtime (weak by design). `encrypted-session`: used at build time only;
183
+ * the runtime gets the per-session key from the app's auth endpoint via
184
+ * `getSessionKey`. Prefer an env var (`STIFT_STATIC_KEY`) over a literal.
185
+ */
186
+ staticKey?: string;
187
+ }
188
+ interface MemoryConfig {
189
+ /** Max in-memory cached namespaces before eviction. Pinned + live-subscriber entries are exempt. */
190
+ maxCachedNamespaces?: number;
191
+ /** Eviction policy: `'lru'` (recency, default) or `'ttl'` (age via `ttlMs`). */
192
+ evictionPolicy?: 'lru' | 'ttl';
193
+ /** `'ttl'` only: entry lifetime in ms. */
194
+ ttlMs?: number;
195
+ }
196
+ interface StiftConfig {
197
+ /** Locales: `default` (schema locale, must be in `supported`) + every supported tag incl. registered dialects (e.g. `['en', 'ar', 'ar-SY-x-lattakia']`). Narrows `Register.locale` in typegen. */
198
+ locales: {
199
+ /** BCP 47 tag of the schema locale (e.g. `'en'`). New keys propagate from here to every locale. */
200
+ default: LocaleTag;
201
+ /** Every tag with translations + registered dialects. Each scaffolds/completes a `locales/<tag>/` dir. */
202
+ supported: readonly LocaleTag[];
203
+ };
204
+ /** `'any'` or an explicit list (validated via `Intl.supportedValuesOf`).
205
+ * Narrows `Register.numberingSystems` for the format call-sites.
206
+ * Optional — absent behaves exactly like `'any'`. */
207
+ numberingSystems?: NumberingSystemConfig;
208
+ /** Default 'any'. A literal list drives the generated `Register.currencies`
209
+ * union used by `@secundus-studio/stift-format`'s typed currency formatting. */
210
+ currencies?: CurrencyConfig;
211
+ /** Units config (docs/17-units.md). A per-category declaration restricts
212
+ * the category's allowed units + per-locale defaults; `'all'` (or omitting
213
+ * a category) opens it with the canonical default. Drives the generated
214
+ * `Register.units` unions and the runtime's unit defaults. */
215
+ units?: UnitsConfig;
216
+ /** Which files get watched/compiled — feeds the compiler and the dev-mode loader. */
217
+ namespaces: NamespacesConfig;
218
+ /** ICU message format flavor the packs compile with. Only `'icu-mf1'` is
219
+ * supported — `'icu-mf2'` names a future formatter engine and is rejected
220
+ * at config load, so selecting it fails fast instead of silently building
221
+ * MF1 packs. Selects the runtime `FormatterEngine`. */
222
+ messageFormat: 'icu-mf1';
223
+ /** Grammatical-agreement declarations (docs/16). Declared params are optional at call sites; undeclared params are always required. */
224
+ params?: ParamsConfig;
225
+ /** Pack encoding/compression/encryption. Absent = `{ tier: 'obfuscated', encoding: 'msgpack', compression: 'gzip' }`. */
226
+ security?: SecurityConfig;
227
+ /** In-memory cache bounds + eviction policy for `PackManager`. */
228
+ memory?: MemoryConfig;
229
+ /** Namespace fetch policy (docs/01-feature-spec.md §4.16). Default:
230
+ * 'lazy-per-namespace'. SPA/PWA projects should generally set
231
+ * 'critical-then-full-background' or 'boot-all'. */
232
+ loadingStrategy?: LoadingStrategy;
233
+ /** 'boot-all' only: namespaces excluded from the boot load. Excluded
234
+ * namespaces fall back to 'critical-then-full-background' individually. */
235
+ bootExclude?: readonly NamespaceId[];
236
+ /** Default detector order/timeouts/URL strategy/cookie persistence. Custom detector *functions* still come from `createStift`. */
237
+ detection?: DetectionConfig;
238
+ /**
239
+ * Persisted user state (docs/05-config.md): key prefix + storage backend for
240
+ * the active locale, context-param overrides, and unit overrides. Entirely
241
+ * optional — the defaults are `{ prefix: '__stift_', storage: 'webStorage' }`
242
+ * (e.g. `__stift_locale`, `__stift_gender`). `createStift({ state })` can
243
+ * override at runtime.
244
+ */
245
+ state?: StateConfig;
246
+ }
247
+ /** Identity helper for editor autocomplete while authoring the config. */
248
+ declare function defineConfig(config: StiftConfig): StiftConfig;
249
+
250
+ /** One discovered namespace file with its home locale + namespace id. */
251
+ interface DiscoveredNamespace {
252
+ locale: string;
253
+ namespace: string;
254
+ /** Absolute path to `<locale>/<namespace>.json`. */
255
+ file: string;
256
+ }
257
+ interface DiscoveryResult {
258
+ /** `locale -> discovered namespaces` for every locale that has any. */
259
+ byLocale: Map<string, DiscoveredNamespace[]>;
260
+ /** Every namespace, flat, sorted for stable output. */
261
+ all: DiscoveredNamespace[];
262
+ }
263
+ /**
264
+ * Walk a `locales/` tree under `root`. Locale directories are the direct
265
+ * children of `locales/`; anything below a locale directory (recursively)
266
+ * that ends in `.json` becomes a namespace with the `/`-joined relative
267
+ * path, extension stripped.
268
+ */
269
+ declare function discoverConvention(root: string, localesDir?: string): Promise<DiscoveryResult>;
270
+
271
+ /**
272
+ * Type extraction (docs/08-grammatical-agreement.md:138-150).
273
+ *
274
+ * For each message key, parse every locale variant's ICU source and derive
275
+ * its param shape:
276
+ * - `plural` / `selectordinal` argument → `number`
277
+ * - `select` argument → the literal union of its case labels, collected
278
+ * across every nesting depth
279
+ * Then union the resulting param shape across all locales' variants of that
280
+ * key, per docs/01-feature-spec.md §4.3's union-across-locales rule — a
281
+ * param required by any locale is required at every call site (declared
282
+ * context params are the exception: the message uses them but the app
283
+ * supplies them, so they're optional — docs/16).
284
+ *
285
+ * `params.context` (docs/02-schemas.ts §8) supplies canonical category sets
286
+ * for recurring params like `gender`: when a `select` argument's name is
287
+ * configured, its categories are reconciled against the canonical set and a
288
+ * warning is emitted on mismatch. This does not change the emitted type —
289
+ * it is a lint/consistency check.
290
+ */
291
+
292
+ /** Fully-qualified context for one message source. */
293
+ interface MessageSourceInput {
294
+ locale: string;
295
+ namespace: string;
296
+ key: MessageKey;
297
+ value: string;
298
+ }
299
+ type ParamType = {
300
+ kind: 'number';
301
+ } | {
302
+ kind: 'select';
303
+ categories: string[];
304
+ } | {
305
+ kind: 'primitive';
306
+ };
307
+ /**
308
+ * Raw per-locale derived shape for one key. `params` maps param name → the
309
+ * type derived from THIS locale's source only.
310
+ */
311
+ interface KeyLocaleShape {
312
+ params: Record<string, ParamType>;
313
+ }
314
+ interface KeyShape {
315
+ /** Union across locales. Values are sorted for stable output. */
316
+ params: Record<string, ParamType>;
317
+ /** Which locales actually use each param (devtools data). */
318
+ paramLocales: Record<string, string[]>;
319
+ }
320
+ interface ExtractResult {
321
+ /** namespace → key → shape, for every key seen across any locale. */
322
+ byNamespace: Map<string, Map<MessageKey, KeyShape>>;
323
+ /** Consistency warnings from params.context reconciliation. */
324
+ warnings: string[];
325
+ }
326
+ /**
327
+ * Derive the param shape of a single message source by walking its full ICU
328
+ * AST (nested select/plural included).
329
+ */
330
+ declare function deriveLocaleShape(source: string): Record<string, ParamType>;
331
+ /**
332
+ * Union the per-key shapes across every locale that defines the key, and
333
+ * reconcile `params.context` canonical sets. Param requiredness is reflected
334
+ * in the emitted type (handled upstream in typegen).
335
+ */
336
+ declare function extractShapes(sources: MessageSourceInput[], paramsConfig?: ParamsConfig): ExtractResult;
337
+
338
+ /**
339
+ * Locale diffing (docs/06-build-plugin.md §3, docs/04-execution-plan.md
340
+ * Phase 2): which keys exist in a reference (default) locale but are missing
341
+ * in other locales. Reported so CI / `stift generate` can fail or warn on
342
+ * an untranslated namespace.
343
+ *
344
+ * Presence is computed from the raw per-locale sources (not the unioned
345
+ * `extract`, which spans every locale and would hide per-locale gaps).
346
+ */
347
+
348
+ interface MissingDiffIssue {
349
+ namespace: string;
350
+ key: MessageKey;
351
+ /** The locale whose source file is missing this key. */
352
+ locale: string;
353
+ }
354
+ interface DiffResult {
355
+ /** Missing keys, one per (namespace, key, locale). */
356
+ missing: MissingDiffIssue[];
357
+ }
358
+ /**
359
+ * Diff the default locale against every base (non-dialect) locale. A key is
360
+ * "missing" for a base locale when the default defines it but that locale's
361
+ * own source has no value for it.
362
+ *
363
+ * Dialect/variant locales (e.g. `ar-SY`, `ar-SY-x-lattakia`) are intentionally
364
+ * excluded: they partially override their parent, and the runtime resolves
365
+ * gaps through the fallback chain (docs/07-detection / docs/02-schemas §9).
366
+ * Flagging them would turn legitimate partial overrides into false positives.
367
+ *
368
+ * `locales` is the full set of discovered on-disk locales; `defaultLocale` is
369
+ * the reference. Only locales with no parent in `locales` are treated as base
370
+ * anchors and compared. Missing = key present in default, absent in the base
371
+ * locale's own sources.
372
+ */
373
+ declare function diffLocales(sources: MessageSourceInput[], locales: string[], defaultLocale: string): DiffResult;
374
+
375
+ interface ScaffoldResult {
376
+ /** Directories that did not exist and were created. */
377
+ createdDirs: string[];
378
+ }
379
+
380
+ interface OrphanKeyIssue {
381
+ namespace: string;
382
+ key: string;
383
+ locale: string;
384
+ }
385
+ interface CompletionResult {
386
+ /** Completed flat sources — feed these to extract/diff/compile. */
387
+ sources: MessageSourceInput[];
388
+ /** Absolute paths rewritten this run. */
389
+ writtenFiles: string[];
390
+ /** Absolute paths created this run (subset of `writtenFiles`). */
391
+ createdFiles: string[];
392
+ orphanKeys: OrphanKeyIssue[];
393
+ /** Keys that inherited a value from an ancestor or the default this run. */
394
+ filledKeys: number;
395
+ /**
396
+ * Per-locale translation coverage (0-1): keys authored in the locale itself
397
+ * or inherited from a non-default registered ancestor, over the default
398
+ * locale's schema keys. Values inherited from the default (i.e. still shown
399
+ * in the default language at runtime) count as untranslated — this is the
400
+ * "78% translated" signal the catalog ships as `coverage`. The default
401
+ * locale itself reads 1.
402
+ */
403
+ authoredCoverage: Record<string, number>;
404
+ warnings: string[];
405
+ }
406
+
407
+ /** Security config consumed by the compiler (subset of StiftConfig). */
408
+ interface CompileSecurityConfig {
409
+ tier: PackSecurityTier$1;
410
+ encoding: PackEncoding$1;
411
+ compression: PackCompression$1;
412
+ /** Required for both encrypted tiers — see docs/03-architecture.md §4. */
413
+ staticKey?: string;
414
+ }
415
+ /**
416
+ * Resolve the effective compiler security from a loaded config: `security`
417
+ * or the module defaults, with `STIFT_STATIC_KEY` as the static-key
418
+ * fallback for the encrypted tiers. Shared by `Generator.compileAsync` and
419
+ * the Vite plugin's incremental dev compile so both stay in lockstep.
420
+ */
421
+ declare function resolveCompileSecurity(config: Pick<StiftConfig, 'security'>): CompileSecurityConfig;
422
+ interface CompileNamespaceOptions {
423
+ security: CompileSecurityConfig;
424
+ }
425
+ /** One compiled namespace ready for emission. */
426
+ interface CompiledNamespaceOutput {
427
+ locale: LocaleTag;
428
+ namespace: NamespaceId;
429
+ /** `/`-joined: `${locale}/${namespace}` — matches PersisterAdapter keys. */
430
+ persistKey: string;
431
+ bytes: Uint8Array;
432
+ byteLength: number;
433
+ contentHash: string;
434
+ }
435
+ /**
436
+ * One cached compiled namespace, for incremental dev compilation (the Vite
437
+ * plugin's serve loop reuses prior `.dat` bytes when a namespace's source
438
+ * hasn't changed — docs/06-build-plugin.md). `sourceHash` is a cheap hash of
439
+ * the normalized source (UTF-8 JSON bytes), distinct from `contentHash`
440
+ * (over the compiled bytes).
441
+ */
442
+ interface CompiledNamespaceCacheEntry {
443
+ /** Hash over the namespace's normalized source JSON bytes. */
444
+ sourceHash: string;
445
+ bytes: Uint8Array;
446
+ byteLength: number;
447
+ contentHash: string;
448
+ }
449
+ /** `persistKey -> compiled entry`, the incremental dev compile cache. */
450
+ type CompiledCache = Map<string, CompiledNamespaceCacheEntry>;
451
+ /** One compiled locale shard ready for emission. */
452
+ interface LocaleShardOutput {
453
+ locale: LocaleTag;
454
+ /** Parsed shard (mirrors `bytes` — kept so callers needn't re-parse). */
455
+ shard: LocaleShard;
456
+ /** Serialized shard bytes (minified JSON) — what gets emitted + hashed. */
457
+ bytes: Uint8Array;
458
+ byteLength: number;
459
+ /** sha256 over the shard bytes — the index's two-tier invalidation key. */
460
+ namespacesHash: string;
461
+ }
462
+ /** What compileAll returns: every compiled namespace + the catalog index + shards. */
463
+ interface CompileAllResult {
464
+ outputs: CompiledNamespaceOutput[];
465
+ /** Tiny index: one row per locale, no per-namespace hashes/URLs. */
466
+ catalog: PackCatalog;
467
+ /** One shard per locale with the full namespace metadata. */
468
+ shards: LocaleShardOutput[];
469
+ /** Fresh cache for the caller to hold between incremental runs. */
470
+ cache: CompiledCache;
471
+ /** Namespaces compiled this run (not reused from `cache`). */
472
+ compiledCount: number;
473
+ /** Namespaces whose prior compiled bytes were reused unchanged. */
474
+ reusedCount: number;
475
+ }
476
+ interface CompileAllOptions {
477
+ /** locales/<locale>/<namespace>.json files already read (extract shape). */
478
+ sources: MessageSourceInput[];
479
+ /** Every locale that has files on disk, for catalog coverage. */
480
+ locales: readonly LocaleTag[];
481
+ defaultLocale: LocaleTag;
482
+ security: CompileSecurityConfig;
483
+ /**
484
+ * Prior compiled bytes by persistKey. Entries whose `sourceHash` still
485
+ * matches are reused verbatim (bytes + contentHash), so a dev edit
486
+ * recompiles only the namespaces that actually changed.
487
+ */
488
+ cache?: CompiledCache;
489
+ /**
490
+ * Resolve the fetch URL for one (locale, namespace) — lets the Vite plugin
491
+ * route `.dat` files through the app's asset pipeline (opaque/hashed names,
492
+ * docs/02-schemas.ts §3b + docs/14-obfuscation-compatibility.md), while the
493
+ * CLI uses a simple conventional path. The third argument is the compiled
494
+ * bytes' content hash, available for content-addressed URLs
495
+ * (`<ns>.<hash>.dat`) — optional so existing callers keep compiling.
496
+ */
497
+ urlFor(locale: LocaleTag, namespace: NamespaceId, contentHash?: string): string;
498
+ /**
499
+ * Resolve the fetch URL for one locale's shard — content-addressed
500
+ * (`catalog/<locale>.<namespacesHash>.json`), immutable per content, so
501
+ * browsers cache shards forever and the index always points at fresh ones.
502
+ * Optional so existing callers keep compiling (falls back to a conventional
503
+ * `catalog/<locale>.<hash>.json` path — same shape, caller-supplied base).
504
+ */
505
+ shardUrlFor?(locale: LocaleTag, namespacesHash: string): string;
506
+ /**
507
+ * Per-locale translation coverage override (0-1), preferred over the
508
+ * key-presence fallback below. The real pipeline feeds this from
509
+ * completion (`authoredCoverage` — authored/inherited keys vs filled-from-
510
+ * default). Direct `compileAll` consumers without it get coverage from the
511
+ * sources as given: keys present vs the default locale's keys.
512
+ */
513
+ coverageByLocale?: Partial<Record<LocaleTag, number>>;
514
+ }
515
+ /**
516
+ * Compile one namespace's message map into pack bytes. Binary encodings
517
+ * produce a `.dat` container; `encoding: 'json'` produces raw UTF-8 JSON
518
+ * bytes (no header, compression, or encryption — enforced here as well as
519
+ * in the config schema, so direct `compileAll` callers can't slip through).
520
+ * Exported for direct/unit use; `compileAll` drives the whole tree.
521
+ */
522
+ declare function compileNamespace(messages: Record<MessageKey, string>, options: CompileNamespaceOptions): Promise<Uint8Array>;
523
+ /**
524
+ * Compile every (locale, namespace) present in `sources` and build the
525
+ * catalog index + one shard per locale. `baseLocale` is the direct parent in
526
+ * the fallback chain when it's a registered locale; `packVersion` is a short
527
+ * content-derived hash (display only — contentHash is the real invalidation
528
+ * key, docs/13-cache-invalidation.md).
529
+ */
530
+ declare function compileAll(options: CompileAllOptions): Promise<CompileAllResult>;
531
+
532
+ interface GenerateOptions {
533
+ root?: string;
534
+ configFile?: string;
535
+ /** Output path for the generated `.d.ts`. Default `<root>/src/stift.gen.d.ts`. */
536
+ outputFile?: string;
537
+ }
538
+ interface GenerateResult {
539
+ config: StiftConfig;
540
+ discovery: DiscoveryResult;
541
+ extract: ExtractResult;
542
+ diff: DiffResult;
543
+ sources: MessageSourceInput[];
544
+ /** Scaffold + completion stats (default-locale-as-schema authoring). */
545
+ scaffold: ScaffoldResult;
546
+ completion: CompletionResult;
547
+ /** Absolute path the `.d.ts` was written to. */
548
+ outputFile: string;
549
+ warnings: string[];
550
+ }
551
+ /** Default relative output path for the generated module. */
552
+ declare const DEFAULT_OUTPUT_REL: string;
553
+ /** Options for the Phase 5 compiled-pack pipeline. */
554
+ interface CompileOptions {
555
+ root?: string;
556
+ configFile?: string;
557
+ /** Write `.dat` files + `catalog.json` here (CLI/vanilla path). */
558
+ outDir?: string;
559
+ /** Override the security config (defaults to config.security). */
560
+ security?: CompileSecurityConfig;
561
+ /** Resolve each namespace's fetch URL (defaults to `${locale}/${ns}.dat`);
562
+ * receives the compiled bytes' content hash for content-addressed names. */
563
+ urlFor?(locale: string, namespace: string, contentHash?: string): string;
564
+ /** Resolve each locale shard's URL (defaults to
565
+ * `catalog/${locale}.${namespacesHash}.json`). */
566
+ shardUrlFor?(locale: string, namespacesHash: string): string;
567
+ }
568
+ interface CompileResult {
569
+ config: StiftConfig;
570
+ result: CompileAllResult;
571
+ /** Absolute paths written, when `outDir` was provided. */
572
+ writtenFiles: string[];
573
+ }
574
+ /** Defaults when `security` is absent from the config (docs/03 §4). */
575
+ declare class Generator {
576
+ constructor(options?: {
577
+ root?: string;
578
+ });
579
+ private root;
580
+ /**
581
+ * Full one-shot pipeline. Returns everything the caller may need to print
582
+ * a report; also writes the generated `.d.ts`.
583
+ */
584
+ generateAsync(options?: GenerateOptions): Promise<GenerateResult>;
585
+ /**
586
+ * Build a predicate telling the CLI/Vite watcher whether a changed file
587
+ * should trigger regeneration (a `.json` under `<root>/locales/`).
588
+ */
589
+ makeWatchFilter(root: string, localesDir: string): (file: string) => boolean;
590
+ /**
591
+ * Phase 5: compile every (locale, namespace) into pack files (`.dat`
592
+ * containers, or raw `.json` when `security.encoding` is `'json'`) + the
593
+ * catalog index + one shard per locale. When `outDir` is given, writes
594
+ * `<outDir>/<locale>/<namespace>.dat` (or `.json`), `<outDir>/catalog.json`
595
+ * (the index), and `<outDir>/catalog/<locale>.<hash>.json` (shards);
596
+ * otherwise returns in-memory bytes for the Vite plugin to emit through
597
+ * the asset pipeline.
598
+ */
599
+ compileAsync(options?: CompileOptions): Promise<CompileResult>;
600
+ }
601
+
602
+ interface LoadConfigOptions {
603
+ root?: string;
604
+ configFile?: string;
605
+ }
606
+ interface LoadedConfig {
607
+ config: StiftConfig;
608
+ /** Absolute path to the resolved config file. */
609
+ file: string;
610
+ }
611
+ declare function findConfigFile(root: string): string | undefined;
612
+ /**
613
+ * Resolve + validate the config. Throws a descriptive error if missing or
614
+ * failing schema validation.
615
+ */
616
+ declare function loadConfig(options?: LoadConfigOptions): Promise<LoadedConfig>;
617
+
618
+ /**
619
+ * Register typegen (docs/06-build-plugin.md §3, docs/02-schemas.ts §8).
620
+ *
621
+ * Emits an `stift.gen.d.ts` containing:
622
+ * declare module "@secundus-studio/stift-core" {
623
+ * interface Register {
624
+ * locale: "en" | "ar" | ...
625
+ * numberingSystems: ...
626
+ * numberingSystems: ...
627
+ * messages: {
628
+ * checkout: {
629
+ * proceed: { gender: "male" | "female" | "other" }
630
+ * total: { amount: number }
631
+ * save: {}
632
+ * }
633
+ * }
634
+ * }
635
+ * }
636
+ *
637
+ * - Namespaces are keyed by their `/`-joined id; each maps `MessageKey` →
638
+ * its union-across-locales param object (`{}` when it takes no params).
639
+ * - Keys are quoted (dot-paths are common and must not collide with dot
640
+ * accessor syntax in a literal union).
641
+ * - `context` (declared `params.context`) emits each param's canonical
642
+ * `values` union. A declared param a message uses is *optional* at the call
643
+ * site (R1 — context-supplied, docs/16); every other param the message
644
+ * text references is *required*, so the type system guarantees the message
645
+ * always receives its data params.
646
+ * - `numberingSystems` / `currencies`: a literal
647
+ * list emits a literal union; `'any'` (or an absent key) emits the engine's
648
+ * supported set (`Intl.supportedValuesOf`) as a literal union too — pinned
649
+ * to the ICU / tzdata of the machine that regenerates the file
650
+ * (docs/06-build-plugin.md §Typegen), falling back to `string` only if the
651
+ * engine has no list.
652
+ */
653
+
654
+ interface GenerateTypegenOptions {
655
+ config: StiftConfig;
656
+ extract: ExtractResult;
657
+ }
658
+ declare function generateTypegen(options: GenerateTypegenOptions): string;
659
+
660
+ /**
661
+ * Zod schema validating an `StiftConfig` (docs/05-config.md:123-127 —
662
+ * "the loaded config is validated against a schema before anything reads
663
+ * it"). Lane per: a malformed BCP 47 tag or invalid security tier fails fast
664
+ * with a clear message instead of surfacing as a confusing runtime bug.
665
+ */
666
+
667
+ declare const configSchema: z.ZodEffects<z.ZodObject<{
668
+ locales: z.ZodObject<{
669
+ default: z.ZodEffects<z.ZodString, string, string>;
670
+ supported: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
671
+ }, "strip", z.ZodTypeAny, {
672
+ default: string;
673
+ supported: string[];
674
+ }, {
675
+ default: string;
676
+ supported: string[];
677
+ }>;
678
+ numberingSystems: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"any">, z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">]>>;
679
+ currencies: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"any">, z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">]>>;
680
+ namespaces: z.ZodObject<{
681
+ dir: z.ZodString;
682
+ discovery: z.ZodEnum<["convention", "manifest"]>;
683
+ default: z.ZodArray<z.ZodString, "many">;
684
+ }, "strip", z.ZodTypeAny, {
685
+ default: string[];
686
+ dir: string;
687
+ discovery: "convention" | "manifest";
688
+ }, {
689
+ default: string[];
690
+ dir: string;
691
+ discovery: "convention" | "manifest";
692
+ }>;
693
+ messageFormat: z.ZodEffects<z.ZodEnum<["icu-mf1", "icu-mf2"]>, "icu-mf1" | "icu-mf2", "icu-mf1" | "icu-mf2">;
694
+ params: z.ZodOptional<z.ZodObject<{
695
+ context: z.ZodOptional<z.ZodArray<z.ZodObject<{
696
+ name: z.ZodString;
697
+ values: z.ZodArray<z.ZodString, "many">;
698
+ defaults: z.ZodRecord<z.ZodString, z.ZodString>;
699
+ persist: z.ZodOptional<z.ZodBoolean>;
700
+ }, "strip", z.ZodTypeAny, {
701
+ values: string[];
702
+ name: string;
703
+ defaults: Record<string, string>;
704
+ persist?: boolean | undefined;
705
+ }, {
706
+ values: string[];
707
+ name: string;
708
+ defaults: Record<string, string>;
709
+ persist?: boolean | undefined;
710
+ }>, "many">>;
711
+ }, "strip", z.ZodTypeAny, {
712
+ context?: {
713
+ values: string[];
714
+ name: string;
715
+ defaults: Record<string, string>;
716
+ persist?: boolean | undefined;
717
+ }[] | undefined;
718
+ }, {
719
+ context?: {
720
+ values: string[];
721
+ name: string;
722
+ defaults: Record<string, string>;
723
+ persist?: boolean | undefined;
724
+ }[] | undefined;
725
+ }>>;
726
+ units: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"all">, z.ZodRecord<z.ZodEnum<["length", "mass", "area", "temperature", "digital"]>, z.ZodObject<{
727
+ supportedValues: z.ZodUnion<[z.ZodLiteral<"all">, z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">]>;
728
+ defaults: z.ZodObject<{
729
+ all: z.ZodEffects<z.ZodString, string, string>;
730
+ }, "strip", z.ZodEffects<z.ZodString, string, string>, z.objectOutputType<{
731
+ all: z.ZodEffects<z.ZodString, string, string>;
732
+ }, z.ZodEffects<z.ZodString, string, string>, "strip">, z.objectInputType<{
733
+ all: z.ZodEffects<z.ZodString, string, string>;
734
+ }, z.ZodEffects<z.ZodString, string, string>, "strip">>;
735
+ persist: z.ZodOptional<z.ZodBoolean>;
736
+ }, "strip", z.ZodTypeAny, {
737
+ defaults: {
738
+ all: string;
739
+ } & {
740
+ [k: string]: string;
741
+ };
742
+ supportedValues: "all" | string[];
743
+ persist?: boolean | undefined;
744
+ }, {
745
+ defaults: {
746
+ all: string;
747
+ } & {
748
+ [k: string]: string;
749
+ };
750
+ supportedValues: "all" | string[];
751
+ persist?: boolean | undefined;
752
+ }>>]>>;
753
+ security: z.ZodOptional<z.ZodEffects<z.ZodObject<{
754
+ tier: z.ZodEnum<["none", "obfuscated", "encrypted-static", "encrypted-session"]>;
755
+ encoding: z.ZodEnum<["msgpack", "cbor", "json"]>;
756
+ compression: z.ZodEnum<["none", "gzip", "brotli"]>;
757
+ staticKey: z.ZodOptional<z.ZodString>;
758
+ }, "strip", z.ZodTypeAny, {
759
+ tier: "none" | "obfuscated" | "encrypted-static" | "encrypted-session";
760
+ encoding: "msgpack" | "cbor" | "json";
761
+ compression: "none" | "gzip" | "brotli";
762
+ staticKey?: string | undefined;
763
+ }, {
764
+ tier: "none" | "obfuscated" | "encrypted-static" | "encrypted-session";
765
+ encoding: "msgpack" | "cbor" | "json";
766
+ compression: "none" | "gzip" | "brotli";
767
+ staticKey?: string | undefined;
768
+ }>, {
769
+ tier: "none" | "obfuscated" | "encrypted-static" | "encrypted-session";
770
+ encoding: "msgpack" | "cbor" | "json";
771
+ compression: "none" | "gzip" | "brotli";
772
+ staticKey?: string | undefined;
773
+ }, {
774
+ tier: "none" | "obfuscated" | "encrypted-static" | "encrypted-session";
775
+ encoding: "msgpack" | "cbor" | "json";
776
+ compression: "none" | "gzip" | "brotli";
777
+ staticKey?: string | undefined;
778
+ }>>;
779
+ memory: z.ZodOptional<z.ZodObject<{
780
+ maxCachedNamespaces: z.ZodOptional<z.ZodNumber>;
781
+ evictionPolicy: z.ZodOptional<z.ZodEnum<["lru", "ttl"]>>;
782
+ ttlMs: z.ZodOptional<z.ZodNumber>;
783
+ }, "strip", z.ZodTypeAny, {
784
+ maxCachedNamespaces?: number | undefined;
785
+ evictionPolicy?: "lru" | "ttl" | undefined;
786
+ ttlMs?: number | undefined;
787
+ }, {
788
+ maxCachedNamespaces?: number | undefined;
789
+ evictionPolicy?: "lru" | "ttl" | undefined;
790
+ ttlMs?: number | undefined;
791
+ }>>;
792
+ loadingStrategy: z.ZodOptional<z.ZodEnum<["lazy-per-namespace", "critical-then-full-background", "boot-all"]>>;
793
+ bootExclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
794
+ detection: z.ZodOptional<z.ZodObject<{
795
+ order: z.ZodArray<z.ZodString, "many">;
796
+ timeout: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodNumber>, z.ZodObject<{
797
+ default: z.ZodNumber;
798
+ }, "strip", z.ZodTypeAny, {
799
+ default: number;
800
+ }, {
801
+ default: number;
802
+ }>>, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>]>>;
803
+ url: z.ZodOptional<z.ZodObject<{
804
+ strategy: z.ZodEnum<["path-prefix", "subdomain", "domain", "query-param"]>;
805
+ paramName: z.ZodOptional<z.ZodString>;
806
+ domainMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, string, string>>>;
807
+ }, "strip", z.ZodTypeAny, {
808
+ strategy: "path-prefix" | "subdomain" | "domain" | "query-param";
809
+ paramName?: string | undefined;
810
+ domainMap?: Record<string, string> | undefined;
811
+ }, {
812
+ strategy: "path-prefix" | "subdomain" | "domain" | "query-param";
813
+ paramName?: string | undefined;
814
+ domainMap?: Record<string, string> | undefined;
815
+ }>>;
816
+ cookie: z.ZodOptional<z.ZodObject<{
817
+ name: z.ZodOptional<z.ZodString>;
818
+ maxAge: z.ZodOptional<z.ZodNumber>;
819
+ path: z.ZodOptional<z.ZodString>;
820
+ sameSite: z.ZodOptional<z.ZodEnum<["strict", "lax", "none"]>>;
821
+ secure: z.ZodOptional<z.ZodBoolean>;
822
+ }, "strip", z.ZodTypeAny, {
823
+ path?: string | undefined;
824
+ name?: string | undefined;
825
+ maxAge?: number | undefined;
826
+ sameSite?: "none" | "strict" | "lax" | undefined;
827
+ secure?: boolean | undefined;
828
+ }, {
829
+ path?: string | undefined;
830
+ name?: string | undefined;
831
+ maxAge?: number | undefined;
832
+ sameSite?: "none" | "strict" | "lax" | undefined;
833
+ secure?: boolean | undefined;
834
+ }>>;
835
+ fallback: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
836
+ }, "strip", z.ZodTypeAny, {
837
+ order: string[];
838
+ url?: {
839
+ strategy: "path-prefix" | "subdomain" | "domain" | "query-param";
840
+ paramName?: string | undefined;
841
+ domainMap?: Record<string, string> | undefined;
842
+ } | undefined;
843
+ timeout?: number | (Record<string, number> & {
844
+ default: number;
845
+ }) | ((...args: unknown[]) => unknown) | undefined;
846
+ cookie?: {
847
+ path?: string | undefined;
848
+ name?: string | undefined;
849
+ maxAge?: number | undefined;
850
+ sameSite?: "none" | "strict" | "lax" | undefined;
851
+ secure?: boolean | undefined;
852
+ } | undefined;
853
+ fallback?: string | undefined;
854
+ }, {
855
+ order: string[];
856
+ url?: {
857
+ strategy: "path-prefix" | "subdomain" | "domain" | "query-param";
858
+ paramName?: string | undefined;
859
+ domainMap?: Record<string, string> | undefined;
860
+ } | undefined;
861
+ timeout?: number | (Record<string, number> & {
862
+ default: number;
863
+ }) | ((...args: unknown[]) => unknown) | undefined;
864
+ cookie?: {
865
+ path?: string | undefined;
866
+ name?: string | undefined;
867
+ maxAge?: number | undefined;
868
+ sameSite?: "none" | "strict" | "lax" | undefined;
869
+ secure?: boolean | undefined;
870
+ } | undefined;
871
+ fallback?: string | undefined;
872
+ }>>;
873
+ state: z.ZodOptional<z.ZodObject<{
874
+ prefix: z.ZodOptional<z.ZodString>;
875
+ storage: z.ZodOptional<z.ZodEnum<["webStorage", "cookie", "none"]>>;
876
+ }, "strip", z.ZodTypeAny, {
877
+ prefix?: string | undefined;
878
+ storage?: "none" | "cookie" | "webStorage" | undefined;
879
+ }, {
880
+ prefix?: string | undefined;
881
+ storage?: "none" | "cookie" | "webStorage" | undefined;
882
+ }>>;
883
+ }, "strip", z.ZodTypeAny, {
884
+ locales: {
885
+ default: string;
886
+ supported: string[];
887
+ };
888
+ namespaces: {
889
+ default: string[];
890
+ dir: string;
891
+ discovery: "convention" | "manifest";
892
+ };
893
+ messageFormat: "icu-mf1" | "icu-mf2";
894
+ params?: {
895
+ context?: {
896
+ values: string[];
897
+ name: string;
898
+ defaults: Record<string, string>;
899
+ persist?: boolean | undefined;
900
+ }[] | undefined;
901
+ } | undefined;
902
+ numberingSystems?: "any" | string[] | undefined;
903
+ currencies?: "any" | string[] | undefined;
904
+ units?: "all" | Partial<Record<"length" | "mass" | "area" | "temperature" | "digital", {
905
+ defaults: {
906
+ all: string;
907
+ } & {
908
+ [k: string]: string;
909
+ };
910
+ supportedValues: "all" | string[];
911
+ persist?: boolean | undefined;
912
+ }>> | undefined;
913
+ security?: {
914
+ tier: "none" | "obfuscated" | "encrypted-static" | "encrypted-session";
915
+ encoding: "msgpack" | "cbor" | "json";
916
+ compression: "none" | "gzip" | "brotli";
917
+ staticKey?: string | undefined;
918
+ } | undefined;
919
+ memory?: {
920
+ maxCachedNamespaces?: number | undefined;
921
+ evictionPolicy?: "lru" | "ttl" | undefined;
922
+ ttlMs?: number | undefined;
923
+ } | undefined;
924
+ loadingStrategy?: "lazy-per-namespace" | "critical-then-full-background" | "boot-all" | undefined;
925
+ bootExclude?: string[] | undefined;
926
+ detection?: {
927
+ order: string[];
928
+ url?: {
929
+ strategy: "path-prefix" | "subdomain" | "domain" | "query-param";
930
+ paramName?: string | undefined;
931
+ domainMap?: Record<string, string> | undefined;
932
+ } | undefined;
933
+ timeout?: number | (Record<string, number> & {
934
+ default: number;
935
+ }) | ((...args: unknown[]) => unknown) | undefined;
936
+ cookie?: {
937
+ path?: string | undefined;
938
+ name?: string | undefined;
939
+ maxAge?: number | undefined;
940
+ sameSite?: "none" | "strict" | "lax" | undefined;
941
+ secure?: boolean | undefined;
942
+ } | undefined;
943
+ fallback?: string | undefined;
944
+ } | undefined;
945
+ state?: {
946
+ prefix?: string | undefined;
947
+ storage?: "none" | "cookie" | "webStorage" | undefined;
948
+ } | undefined;
949
+ }, {
950
+ locales: {
951
+ default: string;
952
+ supported: string[];
953
+ };
954
+ namespaces: {
955
+ default: string[];
956
+ dir: string;
957
+ discovery: "convention" | "manifest";
958
+ };
959
+ messageFormat: "icu-mf1" | "icu-mf2";
960
+ params?: {
961
+ context?: {
962
+ values: string[];
963
+ name: string;
964
+ defaults: Record<string, string>;
965
+ persist?: boolean | undefined;
966
+ }[] | undefined;
967
+ } | undefined;
968
+ numberingSystems?: "any" | string[] | undefined;
969
+ currencies?: "any" | string[] | undefined;
970
+ units?: "all" | Partial<Record<"length" | "mass" | "area" | "temperature" | "digital", {
971
+ defaults: {
972
+ all: string;
973
+ } & {
974
+ [k: string]: string;
975
+ };
976
+ supportedValues: "all" | string[];
977
+ persist?: boolean | undefined;
978
+ }>> | undefined;
979
+ security?: {
980
+ tier: "none" | "obfuscated" | "encrypted-static" | "encrypted-session";
981
+ encoding: "msgpack" | "cbor" | "json";
982
+ compression: "none" | "gzip" | "brotli";
983
+ staticKey?: string | undefined;
984
+ } | undefined;
985
+ memory?: {
986
+ maxCachedNamespaces?: number | undefined;
987
+ evictionPolicy?: "lru" | "ttl" | undefined;
988
+ ttlMs?: number | undefined;
989
+ } | undefined;
990
+ loadingStrategy?: "lazy-per-namespace" | "critical-then-full-background" | "boot-all" | undefined;
991
+ bootExclude?: string[] | undefined;
992
+ detection?: {
993
+ order: string[];
994
+ url?: {
995
+ strategy: "path-prefix" | "subdomain" | "domain" | "query-param";
996
+ paramName?: string | undefined;
997
+ domainMap?: Record<string, string> | undefined;
998
+ } | undefined;
999
+ timeout?: number | (Record<string, number> & {
1000
+ default: number;
1001
+ }) | ((...args: unknown[]) => unknown) | undefined;
1002
+ cookie?: {
1003
+ path?: string | undefined;
1004
+ name?: string | undefined;
1005
+ maxAge?: number | undefined;
1006
+ sameSite?: "none" | "strict" | "lax" | undefined;
1007
+ secure?: boolean | undefined;
1008
+ } | undefined;
1009
+ fallback?: string | undefined;
1010
+ } | undefined;
1011
+ state?: {
1012
+ prefix?: string | undefined;
1013
+ storage?: "none" | "cookie" | "webStorage" | undefined;
1014
+ } | undefined;
1015
+ }>, {
1016
+ locales: {
1017
+ default: string;
1018
+ supported: string[];
1019
+ };
1020
+ namespaces: {
1021
+ default: string[];
1022
+ dir: string;
1023
+ discovery: "convention" | "manifest";
1024
+ };
1025
+ messageFormat: "icu-mf1" | "icu-mf2";
1026
+ params?: {
1027
+ context?: {
1028
+ values: string[];
1029
+ name: string;
1030
+ defaults: Record<string, string>;
1031
+ persist?: boolean | undefined;
1032
+ }[] | undefined;
1033
+ } | undefined;
1034
+ numberingSystems?: "any" | string[] | undefined;
1035
+ currencies?: "any" | string[] | undefined;
1036
+ units?: "all" | Partial<Record<"length" | "mass" | "area" | "temperature" | "digital", {
1037
+ defaults: {
1038
+ all: string;
1039
+ } & {
1040
+ [k: string]: string;
1041
+ };
1042
+ supportedValues: "all" | string[];
1043
+ persist?: boolean | undefined;
1044
+ }>> | undefined;
1045
+ security?: {
1046
+ tier: "none" | "obfuscated" | "encrypted-static" | "encrypted-session";
1047
+ encoding: "msgpack" | "cbor" | "json";
1048
+ compression: "none" | "gzip" | "brotli";
1049
+ staticKey?: string | undefined;
1050
+ } | undefined;
1051
+ memory?: {
1052
+ maxCachedNamespaces?: number | undefined;
1053
+ evictionPolicy?: "lru" | "ttl" | undefined;
1054
+ ttlMs?: number | undefined;
1055
+ } | undefined;
1056
+ loadingStrategy?: "lazy-per-namespace" | "critical-then-full-background" | "boot-all" | undefined;
1057
+ bootExclude?: string[] | undefined;
1058
+ detection?: {
1059
+ order: string[];
1060
+ url?: {
1061
+ strategy: "path-prefix" | "subdomain" | "domain" | "query-param";
1062
+ paramName?: string | undefined;
1063
+ domainMap?: Record<string, string> | undefined;
1064
+ } | undefined;
1065
+ timeout?: number | (Record<string, number> & {
1066
+ default: number;
1067
+ }) | ((...args: unknown[]) => unknown) | undefined;
1068
+ cookie?: {
1069
+ path?: string | undefined;
1070
+ name?: string | undefined;
1071
+ maxAge?: number | undefined;
1072
+ sameSite?: "none" | "strict" | "lax" | undefined;
1073
+ secure?: boolean | undefined;
1074
+ } | undefined;
1075
+ fallback?: string | undefined;
1076
+ } | undefined;
1077
+ state?: {
1078
+ prefix?: string | undefined;
1079
+ storage?: "none" | "cookie" | "webStorage" | undefined;
1080
+ } | undefined;
1081
+ }, {
1082
+ locales: {
1083
+ default: string;
1084
+ supported: string[];
1085
+ };
1086
+ namespaces: {
1087
+ default: string[];
1088
+ dir: string;
1089
+ discovery: "convention" | "manifest";
1090
+ };
1091
+ messageFormat: "icu-mf1" | "icu-mf2";
1092
+ params?: {
1093
+ context?: {
1094
+ values: string[];
1095
+ name: string;
1096
+ defaults: Record<string, string>;
1097
+ persist?: boolean | undefined;
1098
+ }[] | undefined;
1099
+ } | undefined;
1100
+ numberingSystems?: "any" | string[] | undefined;
1101
+ currencies?: "any" | string[] | undefined;
1102
+ units?: "all" | Partial<Record<"length" | "mass" | "area" | "temperature" | "digital", {
1103
+ defaults: {
1104
+ all: string;
1105
+ } & {
1106
+ [k: string]: string;
1107
+ };
1108
+ supportedValues: "all" | string[];
1109
+ persist?: boolean | undefined;
1110
+ }>> | undefined;
1111
+ security?: {
1112
+ tier: "none" | "obfuscated" | "encrypted-static" | "encrypted-session";
1113
+ encoding: "msgpack" | "cbor" | "json";
1114
+ compression: "none" | "gzip" | "brotli";
1115
+ staticKey?: string | undefined;
1116
+ } | undefined;
1117
+ memory?: {
1118
+ maxCachedNamespaces?: number | undefined;
1119
+ evictionPolicy?: "lru" | "ttl" | undefined;
1120
+ ttlMs?: number | undefined;
1121
+ } | undefined;
1122
+ loadingStrategy?: "lazy-per-namespace" | "critical-then-full-background" | "boot-all" | undefined;
1123
+ bootExclude?: string[] | undefined;
1124
+ detection?: {
1125
+ order: string[];
1126
+ url?: {
1127
+ strategy: "path-prefix" | "subdomain" | "domain" | "query-param";
1128
+ paramName?: string | undefined;
1129
+ domainMap?: Record<string, string> | undefined;
1130
+ } | undefined;
1131
+ timeout?: number | (Record<string, number> & {
1132
+ default: number;
1133
+ }) | ((...args: unknown[]) => unknown) | undefined;
1134
+ cookie?: {
1135
+ path?: string | undefined;
1136
+ name?: string | undefined;
1137
+ maxAge?: number | undefined;
1138
+ sameSite?: "none" | "strict" | "lax" | undefined;
1139
+ secure?: boolean | undefined;
1140
+ } | undefined;
1141
+ fallback?: string | undefined;
1142
+ } | undefined;
1143
+ state?: {
1144
+ prefix?: string | undefined;
1145
+ storage?: "none" | "cookie" | "webStorage" | undefined;
1146
+ } | undefined;
1147
+ }>;
1148
+
1149
+ export { type CompileAllOptions, type CompileAllResult, type CompileNamespaceOptions, type CompileOptions, type CompileResult, type CompileSecurityConfig, type CompiledCache, type CompiledNamespaceCacheEntry, type CompiledNamespaceOutput, type ContextParamConfig, DEFAULT_OUTPUT_REL, type DetectionConfig, type DiffResult, type DiscoveredNamespace, type DiscoveryResult, type ExtractResult, type GenerateOptions, type GenerateResult, type GenerateTypegenOptions, Generator, type KeyLocaleShape, type KeyShape, type LoadConfigOptions, type LoadedConfig, type LocaleShardOutput, type MessageSourceInput, type MissingDiffIssue, type NamespacesConfig, type ParamType, type ParamsConfig, type StiftConfig, compileAll, compileNamespace, configSchema, defineConfig, deriveLocaleShape, diffLocales, discoverConvention, extractShapes, findConfigFile, generateTypegen, loadConfig, resolveCompileSecurity };