Documentation
¶
Index ¶
- func FileWrite(pathFile string, data bytes.Buffer) error
- func FileWriteSafe(pathFile string, data bytes.Buffer) error
- func NewFaviconSvgHandler(ac *Config, outputName string) *asset
- func NewHtmlHandler(ac *Config, outputName, cssURL, jsURL string) *asset
- func NewSvgHandler(ac *Config, outputName string) *asset
- type AssetMin
- func (c *AssetMin) BuildOnDisk() bool
- func (c *AssetMin) EnsureOutputDirectoryExists()
- func (c *AssetMin) InjectCSS(name string, content string)
- func (c *AssetMin) InjectHTML(html string)
- func (c *AssetMin) InjectJS(name string, content string)
- func (c *AssetMin) InjectSpriteIcon(id, svg string) error
- func (c *AssetMin) Logger(messages ...any)
- func (c *AssetMin) MainInputFileRelativePath() string
- func (c *AssetMin) MainOutputFileAbsolutePath() string
- func (c *AssetMin) Name() string
- func (c *AssetMin) NewFileEvent(fileName, extension, filePath, event string) error
- func (c *AssetMin) RefreshAsset(extension string)
- func (c *AssetMin) RegisterRoutes(mux *http.ServeMux)
- func (c *AssetMin) SetBuildOnDisk(onDisk bool)
- func (c *AssetMin) SetExternalSSRCompiler(fn func() error, buildOnDisk bool)
- func (c *AssetMin) SetLog(f func(message ...any))
- func (c *AssetMin) ShouldCompileToWasm(fileName, filePath string) bool
- func (c *AssetMin) SupportedExtensions() []string
- func (c *AssetMin) UnobservedFiles() []string
- func (c *AssetMin) UpdateFileContentInMemory(filePath, extension, event string, content []byte) (*asset, error)
- type Config
- type TestEnvironment
- func (env *TestEnvironment) CleanDirectory()
- func (env *TestEnvironment) CreateModulesDir() *TestEnvironment
- func (env *TestEnvironment) CreatePublicDir() *TestEnvironment
- func (env *TestEnvironment) CreateThemeDir() *TestEnvironment
- func (env *TestEnvironment) TestConcurrentFileProcessing(fileExtension string, fileCount int)
- func (env *TestEnvironment) TestFileCRUDOperations(fileExtension string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileWrite ¶
pathFile e.g., "theme/htmlMainFileName" data e.g., *bytes.Buffer NOTE: The buffer data will be cleared after writing the file
func FileWriteSafe ¶ added in v0.0.76
FileWriteSafe writes the data to pathFile only if the file does not already exist.
func NewFaviconSvgHandler ¶
NewFaviconSvgHandler creates a handler for favicon.svg that simply minifies and copies the file without sprite wrapping. This handler processes standalone SVG files like favicon.svg
func NewHtmlHandler ¶
NewHtmlHandler creates an HTML asset handler using the provided output filename
func NewSvgHandler ¶
Types ¶
type AssetMin ¶
type AssetMin struct {
*Config
// contains filtered or unexported fields
}
func NewAssetMin ¶
func (*AssetMin) BuildOnDisk ¶ added in v0.0.71
BuildOnDisk returns true if assets are written to disk.
func (*AssetMin) EnsureOutputDirectoryExists ¶
func (c *AssetMin) EnsureOutputDirectoryExists()
func (*AssetMin) InjectCSS ¶ added in v0.0.81
AddCSS appends CSS content from providers to the bundle InjectCSS appends CSS content to the bundle. name is used for the virtual filename (e.g., "mycomponent.css"). AddCSS appends CSS content from providers to the bundle InjectCSS appends CSS content to the bundle. name is used for the virtual filename (e.g., "mycomponent.css").
func (*AssetMin) InjectHTML ¶ added in v0.0.81
InjectHTML appends HTML to the body
func (*AssetMin) InjectJS ¶ added in v0.0.81
AddJS appends JS content from providers to the bundle InjectJS appends JS content to the bundle. name is used for the virtual filename (e.g., "mycomponent.js").
func (*AssetMin) InjectSpriteIcon ¶ added in v0.0.81
AddIcon adds icons from providers to the bundle InjectSpriteIcon adds an icon to the sprite bundle. id: unique icon ID. svg: raw SVG content.
func (*AssetMin) MainInputFileRelativePath ¶ added in v0.0.70
MainInputFileRelativePath returns the main input file path. AssetMin manages multiple assets, so returns empty. Used by DevWatch for specific file watching logic.
func (*AssetMin) MainOutputFileAbsolutePath ¶ added in v0.0.70
MainOutputFileAbsolutePath returns the main output file path. AssetMin manages multiple outputs, so returns empty. Used by DevWatch for exclusion logic (handled by UnobservedFiles instead)
func (*AssetMin) NewFileEvent ¶
event: create, remove, write, rename
func (*AssetMin) RefreshAsset ¶
func (*AssetMin) RegisterRoutes ¶
RegisterRoutes registers the HTTP handlers for all assets.
func (*AssetMin) SetBuildOnDisk ¶ added in v0.0.71
SetBuildOnDisk sets the work mode for AssetMin. Deprecated: use SetExternalSSRCompiler instead to specify both callback and disk mode.
func (*AssetMin) SetExternalSSRCompiler ¶ added in v0.0.76
SetExternalSSRCompiler sets the external compiler trigger for SSR mode.
func (*AssetMin) ShouldCompileToWasm ¶ added in v0.0.70
ShouldCompileToWasm checks if the file triggers WASM compilation. AssetMin handles assets, not WASM, so always returns false.
func (*AssetMin) SupportedExtensions ¶
func (*AssetMin) UnobservedFiles ¶
type Config ¶
type Config struct {
OutputDir string // eg: web/static, web/public, web/assets
GetSSRClientInitJS func() (string, error) // javascript code to initialize the wasm or other handlers
AppName string // Application name for templates (default: "MyApp")
AssetsURLPrefix string // New: for HTTP routes
DevMode bool // If true, disables caching (default: false)
}
type TestEnvironment ¶
type TestEnvironment struct {
BaseDir string
ThemeDir string
PublicDir string
ModulesDir string
MainJsPath string
MainCssPath string
MainSvgPath string
MainHtmlPath string
AssetsHandler *AssetMin
// contains filtered or unexported fields
}
TestEnvironment holds all the paths and components needed for asset tests
func (*TestEnvironment) CleanDirectory ¶
func (env *TestEnvironment) CleanDirectory()
CleanDirectory removes all content from the test directory but keeps the directory itself
func (*TestEnvironment) CreateModulesDir ¶
func (env *TestEnvironment) CreateModulesDir() *TestEnvironment
CreateModulesDir creates the modules directory if it doesn't exist
func (*TestEnvironment) CreatePublicDir ¶
func (env *TestEnvironment) CreatePublicDir() *TestEnvironment
CreatePublicDir creates the public directory if it doesn't exist
func (*TestEnvironment) CreateThemeDir ¶
func (env *TestEnvironment) CreateThemeDir() *TestEnvironment
CreateThemeDir creates the theme directory if it doesn't exist
func (*TestEnvironment) TestConcurrentFileProcessing ¶
func (env *TestEnvironment) TestConcurrentFileProcessing(fileExtension string, fileCount int)
TestConcurrentFileProcessing is a reusable function to test concurrent file processing for both JS and CSS.
func (*TestEnvironment) TestFileCRUDOperations ¶
func (env *TestEnvironment) TestFileCRUDOperations(fileExtension string)
TestFileCRUDOperations tests the complete CRUD cycle (create, write, remove) for a file