framework

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package framework provides modular SPA framework detection and handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AngularHandler

type AngularHandler struct{}

AngularHandler handles Angular 2+ applications.

func NewAngularHandler

func NewAngularHandler() *AngularHandler

NewAngularHandler creates a new Angular handler.

func (*AngularHandler) Detect

func (h *AngularHandler) Detect(page *rod.Page) bool

Detect checks if Angular 2+ is present on the page.

func (h *AngularHandler) ExtractLinks(page *rod.Page) ([]Link, error)

ExtractLinks extracts all navigation links from the page.

func (*AngularHandler) ExtractRoutes

func (h *AngularHandler) ExtractRoutes(page *rod.Page) ([]Route, error)

ExtractRoutes extracts all routes from Angular application.

func (*AngularHandler) GetRouteChangeScript

func (h *AngularHandler) GetRouteChangeScript() string

GetRouteChangeScript returns JavaScript to detect route changes.

func (*AngularHandler) NavigateToRoute

func (h *AngularHandler) NavigateToRoute(page *rod.Page, route string) error

NavigateToRoute navigates to a specific route within the SPA.

func (*AngularHandler) Type

func (h *AngularHandler) Type() Type

Type returns the framework type.

func (*AngularHandler) WaitForReady

func (h *AngularHandler) WaitForReady(page *rod.Page) error

WaitForReady waits for Angular to be fully loaded.

type AngularJSHandler

type AngularJSHandler struct{}

AngularJSHandler handles AngularJS 1.x applications.

func NewAngularJSHandler

func NewAngularJSHandler() *AngularJSHandler

NewAngularJSHandler creates a new AngularJS handler.

func (*AngularJSHandler) Detect

func (h *AngularJSHandler) Detect(page *rod.Page) bool

Detect checks if AngularJS 1.x is present on the page.

func (h *AngularJSHandler) ExtractLinks(page *rod.Page) ([]Link, error)

ExtractLinks extracts all navigation links from the page.

func (*AngularJSHandler) ExtractRoutes

func (h *AngularJSHandler) ExtractRoutes(page *rod.Page) ([]Route, error)

ExtractRoutes extracts all routes from AngularJS application.

func (*AngularJSHandler) GetRouteChangeScript

func (h *AngularJSHandler) GetRouteChangeScript() string

GetRouteChangeScript returns JavaScript to detect route changes.

func (*AngularJSHandler) NavigateToRoute

func (h *AngularJSHandler) NavigateToRoute(page *rod.Page, route string) error

NavigateToRoute navigates to a specific route within the SPA.

func (*AngularJSHandler) Type

func (h *AngularJSHandler) Type() Type

Type returns the framework type.

func (*AngularJSHandler) WaitForReady

func (h *AngularJSHandler) WaitForReady(page *rod.Page) error

WaitForReady waits for AngularJS to be fully loaded.

type DetectionResult

type DetectionResult struct {
	Frameworks []Type
	Primary    Type
	Version    string
	IsSPA      bool
	HasRouter  bool
	RouterType string
}

DetectionResult contains the result of framework detection.

type Detector

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

Detector detects frameworks on a page.

func NewDetector

func NewDetector() *Detector

NewDetector creates a new framework detector with all handlers.

func (*Detector) Detect

func (d *Detector) Detect(page *rod.Page) *DetectionResult

Detect detects all frameworks present on the page.

func (d *Detector) ExtractAllLinks(page *rod.Page) []Link

ExtractAllLinks extracts links using all applicable handlers.

func (*Detector) ExtractAllRoutes

func (d *Detector) ExtractAllRoutes(page *rod.Page) []Route

ExtractAllRoutes extracts routes using all applicable handlers.

func (*Detector) GetHandler

func (d *Detector) GetHandler(t Type) Handler

GetHandler returns the appropriate handler for a framework type.

func (*Detector) GetPrimaryHandler

func (d *Detector) GetPrimaryHandler(page *rod.Page) Handler

GetPrimaryHandler returns the handler for the primary detected framework.

func (*Detector) WaitForFrameworks

func (d *Detector) WaitForFrameworks(page *rod.Page) error

WaitForFrameworks waits for all detected frameworks to be ready.

type EmberHandler

type EmberHandler struct{}

EmberHandler handles Ember.js applications.

func NewEmberHandler

func NewEmberHandler() *EmberHandler

NewEmberHandler creates a new Ember handler.

func (*EmberHandler) Detect

func (h *EmberHandler) Detect(page *rod.Page) bool

Detect checks if Ember.js is present on the page.

func (h *EmberHandler) ExtractLinks(page *rod.Page) ([]Link, error)

ExtractLinks extracts all navigation links from the page.

func (*EmberHandler) ExtractRoutes

func (h *EmberHandler) ExtractRoutes(page *rod.Page) ([]Route, error)

ExtractRoutes extracts all routes from Ember application.

func (*EmberHandler) GetRouteChangeScript

func (h *EmberHandler) GetRouteChangeScript() string

GetRouteChangeScript returns JavaScript to detect route changes.

func (*EmberHandler) NavigateToRoute

func (h *EmberHandler) NavigateToRoute(page *rod.Page, route string) error

NavigateToRoute navigates to a specific route within the SPA.

func (*EmberHandler) Type

func (h *EmberHandler) Type() Type

Type returns the framework type.

func (*EmberHandler) WaitForReady

func (h *EmberHandler) WaitForReady(page *rod.Page) error

WaitForReady waits for Ember to be fully loaded.

type GenericHandler

type GenericHandler struct{}

GenericHandler handles generic SPAs and traditional pages.

func NewGenericHandler

func NewGenericHandler() *GenericHandler

NewGenericHandler creates a new generic handler.

func (*GenericHandler) Detect

func (h *GenericHandler) Detect(page *rod.Page) bool

Detect always returns true as this is the fallback handler.

func (h *GenericHandler) ExtractLinks(page *rod.Page) ([]Link, error)

ExtractLinks extracts all navigation links from the page.

func (*GenericHandler) ExtractRoutes

func (h *GenericHandler) ExtractRoutes(page *rod.Page) ([]Route, error)

ExtractRoutes extracts all routes from the page.

func (*GenericHandler) GetRouteChangeScript

func (h *GenericHandler) GetRouteChangeScript() string

GetRouteChangeScript returns JavaScript to detect route changes.

func (*GenericHandler) NavigateToRoute

func (h *GenericHandler) NavigateToRoute(page *rod.Page, route string) error

NavigateToRoute navigates to a specific route.

func (*GenericHandler) Type

func (h *GenericHandler) Type() Type

Type returns the framework type.

func (*GenericHandler) WaitForReady

func (h *GenericHandler) WaitForReady(page *rod.Page) error

WaitForReady waits for the page to be fully loaded.

type Handler

type Handler interface {
	// Type returns the framework type.
	Type() Type

	// Detect checks if this framework is present on the page.
	Detect(page *rod.Page) bool

	// WaitForReady waits for the framework to be fully loaded.
	WaitForReady(page *rod.Page) error

	// ExtractRoutes extracts all routes defined in the application.
	ExtractRoutes(page *rod.Page) ([]Route, error)

	// ExtractLinks extracts all navigation links from the page.
	ExtractLinks(page *rod.Page) ([]Link, error)

	// NavigateToRoute navigates to a specific route within the SPA.
	NavigateToRoute(page *rod.Page, route string) error

	// GetRouteChangeScript returns JavaScript to detect route changes.
	GetRouteChangeScript() string
}

Handler defines the interface for framework-specific handling.

type Link struct {
	URL        string
	Text       string
	Attributes map[string]string
	Type       string // "href", "router-link", "ng-href", etc.
}

Link represents a discovered link.

type ReactHandler

type ReactHandler struct{}

ReactHandler handles React applications.

func NewReactHandler

func NewReactHandler() *ReactHandler

NewReactHandler creates a new React handler.

func (*ReactHandler) Detect

func (h *ReactHandler) Detect(page *rod.Page) bool

Detect checks if React is present on the page.

func (h *ReactHandler) ExtractLinks(page *rod.Page) ([]Link, error)

ExtractLinks extracts all navigation links from the page.

func (*ReactHandler) ExtractRoutes

func (h *ReactHandler) ExtractRoutes(page *rod.Page) ([]Route, error)

ExtractRoutes extracts all routes from React application.

func (*ReactHandler) GetRouteChangeScript

func (h *ReactHandler) GetRouteChangeScript() string

GetRouteChangeScript returns JavaScript to detect route changes.

func (*ReactHandler) NavigateToRoute

func (h *ReactHandler) NavigateToRoute(page *rod.Page, route string) error

NavigateToRoute navigates to a specific route within the SPA.

func (*ReactHandler) Type

func (h *ReactHandler) Type() Type

Type returns the framework type.

func (*ReactHandler) WaitForReady

func (h *ReactHandler) WaitForReady(page *rod.Page) error

WaitForReady waits for React to be fully loaded.

type Route

type Route struct {
	Path       string            // Route path (e.g., "/users", "#/popular")
	Name       string            // Route name if available
	Component  string            // Component name if available
	Parameters []string          // Route parameters (e.g., ":id", ":slug")
	Meta       map[string]string // Additional metadata
}

Route represents a discovered route.

type Type

type Type string

Type represents a JavaScript framework type.

const (
	TypeUnknown   Type = "unknown"
	TypeAngularJS Type = "angularjs" // AngularJS 1.x
	TypeAngular   Type = "angular"   // Angular 2+
	TypeReact     Type = "react"
	TypeVue       Type = "vue"
	TypeEmber     Type = "ember"
	TypeBackbone  Type = "backbone"
	TypeSvelte    Type = "svelte"
	TypeNext      Type = "nextjs"
	TypeNuxt      Type = "nuxt"
	TypeGatsby    Type = "gatsby"
)

type VueHandler

type VueHandler struct{}

VueHandler handles Vue.js applications.

func NewVueHandler

func NewVueHandler() *VueHandler

NewVueHandler creates a new Vue handler.

func (*VueHandler) Detect

func (h *VueHandler) Detect(page *rod.Page) bool

Detect checks if Vue.js is present on the page.

func (h *VueHandler) ExtractLinks(page *rod.Page) ([]Link, error)

ExtractLinks extracts all navigation links from the page.

func (*VueHandler) ExtractRoutes

func (h *VueHandler) ExtractRoutes(page *rod.Page) ([]Route, error)

ExtractRoutes extracts all routes from Vue application.

func (*VueHandler) GetRouteChangeScript

func (h *VueHandler) GetRouteChangeScript() string

GetRouteChangeScript returns JavaScript to detect route changes.

func (*VueHandler) NavigateToRoute

func (h *VueHandler) NavigateToRoute(page *rod.Page, route string) error

NavigateToRoute navigates to a specific route within the SPA.

func (*VueHandler) Type

func (h *VueHandler) Type() Type

Type returns the framework type.

func (*VueHandler) WaitForReady

func (h *VueHandler) WaitForReady(page *rod.Page) error

WaitForReady waits for Vue to be fully loaded.

Jump to

Keyboard shortcuts

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