js

package
v0.1.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClosePool

func ClosePool()

ClosePool drains the parser pool and closes all cached parsers. It temporarily nils the pool's New function to avoid allocating fresh parsers while draining.

func ReleaseParser

func ReleaseParser(p *Parser)

ReleaseParser returns a parser to the pool

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser handles parsing JS/TS to extract CSS from tagged template literals

func AcquireParser

func AcquireParser() *Parser

AcquireParser gets a parser from the pool

func (*Parser) Close

func (p *Parser) Close()

Close closes the parser and releases its resources

func (*Parser) ParseCSS

func (p *Parser) ParseCSS(source string) (*css.ParseResult, error)

ParseCSS extracts and parses CSS from tagged template literals in JS/TS source

func (*Parser) ParseTemplates

func (p *Parser) ParseTemplates(source string) []TemplateRegion

ParseTemplates finds css/html tagged template literals and splits them at ${...} boundaries. Handles both standard form (css`...`) and generic form (css<Type>`...`).

type Segment

type Segment struct {
	// Content is the literal text of this segment
	Content string
	// StartLine is the 0-indexed line in the JS/TS source where this segment begins
	StartLine uint
	// StartCol is the 0-indexed column in the JS/TS source where this segment begins
	StartCol uint
}

Segment represents a literal text segment from a template string, between ${...} expression boundaries

type TemplateRegion

type TemplateRegion struct {
	// Segments contains the literal text parts of the template, split at ${...} boundaries
	Segments []Segment
	// Tag is the template tag function name ("css" or "html")
	Tag string
}

TemplateRegion represents a tagged template literal found in JS/TS source

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL