UNPKG

wuchale

Version:

Protobuf-like i18n from normal code

97 lines 2.93 kB
import type { ItemType } from "./gemini.js"; type TxtScope = "script" | "markup" | "attribute"; export type HeuristicDetailsBase = { scope: TxtScope; element?: string; attribute?: string; }; export type ScriptDeclType = "variable" | "function" | "expression"; export type HeuristicDetails = HeuristicDetailsBase & { file: string; declaring?: ScriptDeclType; funcName?: string | null; topLevelCall?: string; call?: string; }; export type HeuristicFunc = (text: string, details: HeuristicDetails) => boolean | null | undefined; export declare function defaultHeuristic(text: string, details: HeuristicDetails): boolean; export declare const defaultHeuristicFuncOnly: HeuristicFunc; export declare const defaultGenerateLoadID: (filename: string) => string; export declare class NestText { text: string[]; plural: boolean; scope: TxtScope; context: string; constructor(txt: string | string[], scope: TxtScope, context: string | null); toKey: () => string; } export interface Catalog { [key: string]: ItemType; } export type CommentDirectives = { forceInclude?: boolean; context?: string; }; export declare class IndexTracker { indices: Record<string, number>; nextIndex: number; get: (txt: string) => number; } export type GlobConf = string | string[] | { include: string | string[]; ignore: string | string[]; }; export type TransformHeader = { head: string; expr: string; }; type TransformCtx = { content: string; filename: string; index: IndexTracker; header: TransformHeader; }; export type TransformOutput = { code?: string; map?: any; txts: NestText[]; }; export type TransformFunc = (ctx: TransformCtx) => TransformOutput; export type AdapterPassThruOpts = { files: GlobConf; catalog: string; granularLoad: boolean; bundleLoad: boolean; generateLoadID: (filename: string) => string; writeFiles: { compiled?: boolean; proxy?: boolean; transformed?: boolean; outDir?: string; }; importName: string; }; export type Adapter = AdapterPassThruOpts & { transform: TransformFunc; /** possible filename extensions for loader. E.g. `.js` */ loaderExts: string[]; /** available loader names, can do auto detection logic to sort, dependencies given */ defaultLoaders: (dependencies: Set<string>) => string[] | Promise<string[]>; defaultLoaderPath: (loaderName: string) => string; }; export type RuntimeOptions = { initInScope: (details: { funcName?: string; parentFunc?: string; file: string; }) => boolean; wrapInit: (expr: string) => string; wrapExpr: (expr: string) => string; }; export type AdapterArgs = Partial<AdapterPassThruOpts> & { heuristic?: HeuristicFunc; pluralsFunc?: string; runtime?: Partial<RuntimeOptions>; }; export {}; //# sourceMappingURL=adapters.d.ts.map