Documentation
ยถ
Index ยถ
- func FileWrite(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) EnsureOutputDirectoryExists()
- func (c *AssetMin) GetWorkMode() WorkMode
- 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) SetWorkMode(mode WorkMode)
- 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)
- type WorkMode
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 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) EnsureOutputDirectoryExists ยถ
func (c *AssetMin) EnsureOutputDirectoryExists()
func (*AssetMin) GetWorkMode ยถ
GetWorkMode returns the current work mode of AssetMin.
func (*AssetMin) NewFileEvent ยถ
event: create, remove, write, rename
func (*AssetMin) RefreshAsset ยถ
func (*AssetMin) RegisterRoutes ยถ
RegisterRoutes registers the HTTP handlers for all assets.
func (*AssetMin) SetWorkMode ยถ
SetWorkMode sets the work mode for AssetMin.
func (*AssetMin) SupportedExtensions ยถ
func (*AssetMin) UnobservedFiles ยถ
type Config ยถ
type Config struct {
OutputDir string // eg: web/static, web/public, web/assets
Logger func(message ...any) // Renamed from io.Writer to a function type
GetRuntimeInitializerJS 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
}
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