Documentation
¶
Overview ¶
Package sourcemap provides source map parsing and DOM-to-source mapping. This enables coding agents to locate source files for accessibility issues found in the rendered DOM.
Index ¶
- type FrameworkDetector
- func (d *FrameworkDetector) Confidence() float64
- func (d *FrameworkDetector) DetectFromHTML(html string) types.Framework
- func (d *FrameworkDetector) DetectFromPage(_ context.Context, execJS func(string) (string, error)) (types.Framework, error)
- func (d *FrameworkDetector) Framework() types.Framework
- func (d *FrameworkDetector) Signals() []string
- type Mapper
- type MapperOption
- type Segment
- type SourceMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FrameworkDetector ¶
type FrameworkDetector struct {
// contains filtered or unexported fields
}
FrameworkDetector detects the frontend framework from page content.
func NewFrameworkDetector ¶
func NewFrameworkDetector() *FrameworkDetector
NewFrameworkDetector creates a new framework detector.
func (*FrameworkDetector) Confidence ¶
func (d *FrameworkDetector) Confidence() float64
Confidence returns the detection confidence.
func (*FrameworkDetector) DetectFromHTML ¶
func (d *FrameworkDetector) DetectFromHTML(html string) types.Framework
DetectFromHTML detects the framework from HTML content.
func (*FrameworkDetector) DetectFromPage ¶
func (d *FrameworkDetector) DetectFromPage(_ context.Context, execJS func(string) (string, error)) (types.Framework, error)
DetectFromPage detects framework from a live page using JavaScript execution. This is used when the HTML alone doesn't provide enough signals. The execJS function should execute JavaScript and return the result.
func (*FrameworkDetector) Framework ¶
func (d *FrameworkDetector) Framework() types.Framework
Framework returns the detected framework.
func (*FrameworkDetector) Signals ¶
func (d *FrameworkDetector) Signals() []string
Signals returns the detection signals found.
type Mapper ¶
type Mapper struct {
// contains filtered or unexported fields
}
Mapper maps DOM elements to source code locations using source maps.
func NewMapper ¶
func NewMapper(sourceMapDir string, opts ...MapperOption) (*Mapper, error)
NewMapper creates a new source map mapper.
func (*Mapper) MapElement ¶
func (m *Mapper) MapElement(_ context.Context, selector string, html string) (*types.SourceLocation, error)
MapElement maps a DOM element to its source location. It uses the element's CSS selector to find the original source.
func (*Mapper) SetFramework ¶
SetFramework sets the detected framework.
func (*Mapper) SourceFiles ¶
SourceFiles returns all source files in loaded source maps.
type MapperOption ¶
type MapperOption func(*Mapper)
MapperOption configures the Mapper.
func WithBaseURL ¶
func WithBaseURL(url string) MapperOption
WithBaseURL sets the base URL for source map resolution from dev server.
type Segment ¶
type Segment struct {
GeneratedColumn int
SourceIndex int
SourceLine int
SourceColumn int
NameIndex int
HasName bool
}
Segment represents a single mapping segment.
type SourceMap ¶
type SourceMap struct {
Version int `json:"version"`
File string `json:"file"`
SourceRoot string `json:"sourceRoot"`
Sources []string `json:"sources"`
SourcesContent []string `json:"sourcesContent,omitempty"`
Names []string `json:"names"`
Mappings string `json:"mappings"`
// contains filtered or unexported fields
}
SourceMap represents a parsed source map (V3 format).