@stacksjs/stx
Version:
A performant UI Framework. Powered by Bun.
117 lines • 3.51 kB
TypeScript
/**
* Decode Base64 VLQ to number
*/
export declare function decodeVLQ(encoded: string): { value: number, rest: string };
/**
* Parse an inline source map comment from content
*/
export declare function extractInlineSourceMap(content: string): SourceMapV3 | null;
/**
* Remove inline source map comments from content
*/
export declare function removeInlineSourceMap(content: string): string;
/**
* Calculate line and column from an offset in content
*/
export declare function offsetToPosition(content: string, offset: number): Position;
/**
* Calculate offset from line and column in content
*/
export declare function positionToOffset(content: string, position: Position): number;
/**
* Position in source or generated code
*/
export declare interface Position {
line: number
column: number
}
/**
* A single mapping from generated to original position
*/
export declare interface Mapping {
generated: Position
source?: string
original?: Position
name?: string
}
/**
* V3 Source Map format
* @see https://sourcemaps.info/spec.html
*/
export declare interface SourceMapV3 {
version: 3
file?: string
sourceRoot?: string
sources: string[]
sourcesContent?: (string | null)[]
names: string[]
mappings: string
}
/**
* Source map generator for stx templates
*/
export declare class SourceMapGenerator {
private file: string;
private sourceRoot?: string;
private sources: string[];
private sourcesContent: Map<string, string>;
private names: string[];
private mappings: Mapping[];
constructor(file: string, sourceRoot?: string);
addSource(path: string, content?: string): number;
addName(name: string): number;
addMapping(mapping: Mapping): void;
addMappingRange(generatedStart: Position, source: string, originalStart: Position, lineCount: number): void;
private generateMappings(): string;
toJSON(): SourceMapV3;
toString(): string;
toDataURL(): string;
toInlineComment(): string;
toJSInlineComment(): string;
toCSSInlineComment(): string;
}
/**
* Source map consumer for parsing and querying source maps
*/
export declare class SourceMapConsumer {
private sourceMap: SourceMapV3;
private decodedMappings: Array<{
generatedLine: number
generatedColumn: number
sourceIndex: number
originalLine: number
originalColumn: number
nameIndex: number
}>;
constructor(sourceMap: SourceMapV3 | string);
private decodeMappings(): void;
originalPositionFor(generated: Position): {
source: string | null
line: number | null
column: number | null
name: string | null
};
generatedPositionFor(original: { source: string, line: number, column?: number }): {
line: number | null
column: number | null
};
sourceContentFor(source: string): string | null;
}
/**
* Tracks positions during template transformation for source map generation
*/
export declare class TemplateTracker {
private generator: SourceMapGenerator;
private currentGeneratedLine: any;
private currentGeneratedColumn: any;
private sourceFile: string;
constructor(outputFile: string, sourceFile: string, sourceContent?: string);
trackReplacement(originalLine: number, originalColumn: number, generatedContent: string): void;
trackInclude(includeFile: string, includeContent: string, generatedContent: string): void;
trackGenerated(content: string): void;
newLine(): void;
getCurrentPosition(): Position;
getGenerator(): SourceMapGenerator;
toJSON(): SourceMapV3;
toInlineComment(): string;
}