Documentation
¶
Index ¶
- Constants
- 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) BuildOnDisk() bool
- func (c *AssetMin) EnsureOutputDirectoryExists()
- 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) 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 GoMod
- 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 ¶
const PackageName = "github.com/tinywasm/assetmin"
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) BuildOnDisk ¶ added in v0.0.71
BuildOnDisk returns true if assets are written to disk.
func (*AssetMin) EnsureOutputDirectoryExists ¶
func (c *AssetMin) EnsureOutputDirectoryExists()
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.
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
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 GoMod ¶ added in v0.0.73
type GoMod struct {
// contains filtered or unexported fields
}
func (*GoMod) CheckAndUpdate ¶ added in v0.0.74
func (*GoMod) NewFileEvent ¶ added in v0.0.74
func (*GoMod) SetRootPath ¶ added in v0.0.73
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