@wuchale/svelte
Version:
Protobuf-like i18n from plain code: Svelte adapter
50 lines (49 loc) • 2.79 kB
TypeScript
import type { AnyNode, VariableDeclarator } from "acorn";
import { type AST } from "svelte/compiler";
import { Message } from 'wuchale';
import { Transformer } from 'wuchale/adapter-vanilla';
import type { IndexTracker, HeuristicFunc, TransformOutput, CatalogExpr, RuntimeConf, CodePattern, UrlMatcher } from 'wuchale';
import { MixedVisitor, type CommentDirectives } from "wuchale/adapter-utils";
type MixedNodesTypes = AST.Text | AST.Tag | AST.ElementLike | AST.Block | AST.Comment;
export type RuntimeCtxSv = {
module: boolean;
};
export declare class SvelteTransformer extends Transformer<RuntimeCtxSv> {
currentElement?: string;
inCompoundText: boolean;
commentDirectivesStack: CommentDirectives[];
lastVisitIsComment: boolean;
currentSnippet: number;
moduleExportRanges: [number, number][];
mixedVisitor: MixedVisitor<MixedNodesTypes>;
constructor(content: string, filename: string, index: IndexTracker, heuristic: HeuristicFunc, patterns: CodePattern[], catalogExpr: CatalogExpr, rtConf: RuntimeConf<RuntimeCtxSv>, matchUrl: UrlMatcher);
visitExpressionTag: (node: AST.ExpressionTag) => Message[];
visitVariableDeclarator: (node: VariableDeclarator) => Message[];
initMixedVisitor: () => MixedVisitor<MixedNodesTypes>;
visitFragment: (node: AST.Fragment) => Message[];
visitRegularElement: (node: AST.ElementLike) => Message[];
visitComponent: (node: AST.ElementLike) => Message[];
visitText: (node: AST.Text) => Message[];
visitSpreadAttribute: (node: AST.SpreadAttribute) => Message[];
visitAttribute: (node: AST.Attribute) => Message[];
visitConstTag: (node: AST.ConstTag) => Message[];
visitRenderTag: (node: AST.RenderTag) => Message[];
visitSnippetBlock: (node: AST.SnippetBlock) => Message[];
visitIfBlock: (node: AST.IfBlock) => Message[];
visitEachBlock: (node: AST.EachBlock) => Message[];
visitKeyBlock: (node: AST.KeyBlock) => Message[];
visitAwaitBlock: (node: AST.AwaitBlock) => Message[];
visitSvelteBody: (node: AST.SvelteBody) => Message[];
visitSvelteDocument: (node: AST.SvelteDocument) => Message[];
visitSvelteElement: (node: AST.SvelteElement) => Message[];
visitSvelteBoundary: (node: AST.SvelteBoundary) => Message[];
visitSvelteHead: (node: AST.SvelteHead) => Message[];
visitTitleElement: (node: AST.TitleElement) => Message[];
visitSvelteWindow: (node: AST.SvelteWindow) => Message[];
visitRoot: (node: AST.Root) => Message[];
visitSv: (node: AST.SvelteNode | AnyNode) => Message[];
/** collects the ranges that will be checked if a snippet identifier is exported using RegExp test to simplify */
collectModuleExportRanges: (script: AST.Script) => void;
transformSv: () => Promise<TransformOutput>;
}
export {};