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, faviconURL string) *asset
- func NewSvgHandler(ac *Config, outputName string) *asset
- func ParseExistingHtmlContent(content string) (openContent, closeContent string)
- func RewriteAssetUrls(html string, newRoot string) string
- func StripLeadingUseStrict(b []byte) []byte
- type AssetMin
- func (c *AssetMin) BuildOnDisk() bool
- func (c *AssetMin) ContainsCSS(substr string) bool
- func (c *AssetMin) ContainsHTML(substr string) bool
- func (c *AssetMin) ContainsJS(substr string) bool
- func (c *AssetMin) ContainsSVG(substr string) bool
- func (c *AssetMin) EnsureOutputDirectoryExists()
- func (c *AssetMin) GetCSSURLPath() string
- func (c *AssetMin) GetCachedHTML() []byte
- func (c *AssetMin) GetFaviconURLPath() string
- func (c *AssetMin) GetInitCodeJS() (string, error)
- func (c *AssetMin) GetJSURLPath() string
- func (c *AssetMin) GetMainCssPath() string
- func (c *AssetMin) GetMainHtmlPath() string
- func (c *AssetMin) GetMainJsPath() string
- func (c *AssetMin) GetMainSvgPath() string
- func (c *AssetMin) GetMinifiedCSS() ([]byte, error)
- func (c *AssetMin) GetMinifiedJS() ([]byte, error)
- func (c *AssetMin) GetSVGURLPath() string
- func (c *AssetMin) HasIcon(id string) bool
- 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) IsSSRMode() bool
- func (c *AssetMin) LoadSSRModules() 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) RegenerateHTMLCache() error
- func (c *AssetMin) RegisterComponents(providers ...any) error
- func (c *AssetMin) RegisterRoutes(mux *http.ServeMux)
- func (c *AssetMin) ReloadSSRModule(moduleDir string) error
- func (c *AssetMin) SetBuildOnDisk(onDisk bool)
- func (c *AssetMin) SetExternalSSRCompiler(fn func() error, buildOnDisk bool)
- func (c *AssetMin) SetListModulesFn(fn func(rootDir string) ([]string, error))
- 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)
- func (c *AssetMin) UpdateSSRModule(name string, css, js, html string, icons map[string]string)
- func (c *AssetMin) UpdateSSRModuleInSlot(name string, css, js, html string, icons map[string]string, slot string)
- func (c *AssetMin) WaitForSSRLoad(timeout time.Duration)
- type Config
- type ContentFile
- type Module
- type SSRAssets
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 ¶
func ParseExistingHtmlContent ¶ added in v0.2.2
ParseExistingHtmlContent is a public wrapper for tests.
func RewriteAssetUrls ¶ added in v0.2.2
RewriteAssetUrls is a public wrapper for tests.
func StripLeadingUseStrict ¶ added in v0.2.2
StripLeadingUseStrict is a public wrapper for tests.
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) ContainsCSS ¶ added in v0.2.2
ContainsCSS checks if the CSS bundle contains the given substring.
func (*AssetMin) ContainsHTML ¶ added in v0.2.2
ContainsHTML checks if the HTML bundle contains the given substring.
func (*AssetMin) ContainsJS ¶ added in v0.2.2
ContainsJS checks if the JS bundle contains the given substring.
func (*AssetMin) ContainsSVG ¶ added in v0.2.2
ContainsSVG checks if the SVG sprite contains the given substring.
func (*AssetMin) EnsureOutputDirectoryExists ¶
func (c *AssetMin) EnsureOutputDirectoryExists()
func (*AssetMin) GetCSSURLPath ¶ added in v0.2.2
GetCSSURLPath returns the URL path for the main CSS file.
func (*AssetMin) GetCachedHTML ¶ added in v0.2.2
GetCachedHTML returns the cached minified HTML content.
func (*AssetMin) GetFaviconURLPath ¶ added in v0.2.2
GetFaviconURLPath returns the URL path for the favicon file.
func (*AssetMin) GetInitCodeJS ¶ added in v0.2.2
GetInitCodeJS returns the init code for the JS bundle.
func (*AssetMin) GetJSURLPath ¶ added in v0.2.2
GetJSURLPath returns the URL path for the main JS file.
func (*AssetMin) GetMainCssPath ¶ added in v0.2.2
GetMainCssPath returns the output path of the main CSS file.
func (*AssetMin) GetMainHtmlPath ¶ added in v0.2.2
GetMainHtmlPath returns the output path of the main HTML file.
func (*AssetMin) GetMainJsPath ¶ added in v0.2.2
GetMainJsPath returns the output path of the main JS file.
func (*AssetMin) GetMainSvgPath ¶ added in v0.2.2
GetMainSvgPath returns the output path of the main SVG file.
func (*AssetMin) GetMinifiedCSS ¶ added in v0.2.2
GetMinifiedCSS returns the minified content of the CSS bundle.
func (*AssetMin) GetMinifiedJS ¶ added in v0.2.2
GetMinifiedJS returns the minified content of the JS bundle.
func (*AssetMin) GetSVGURLPath ¶ added in v0.2.2
GetSVGURLPath returns the URL path for the SVG sprite file.
func (*AssetMin) HasIcon ¶ added in v0.2.2
HasIcon checks if an icon with the given ID is registered.
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) IsSSRMode ¶ added in v0.2.2
IsSSRMode returns true if the package is being used as a dependency (SSR mode).
func (*AssetMin) LoadSSRModules ¶ added in v0.2.2
LoadSSRModules descubre todos los módulos e inyecta sus assets.
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) RegenerateHTMLCache ¶ added in v0.2.2
RegenerateHTMLCache forces regeneration of the HTML cache.
func (*AssetMin) RegisterComponents ¶ added in v0.2.2
RegisterComponents registra structs que implementan las interfaces SSR.
func (*AssetMin) RegisterRoutes ¶
RegisterRoutes registers the HTTP handlers for all assets.
func (*AssetMin) ReloadSSRModule ¶ added in v0.2.2
ReloadSSRModule re-extrae e inyecta los assets de un único módulo por su directorio.
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) SetListModulesFn ¶ added in v0.2.2
SetListModulesFn replaces the module discovery function. Only for tests — allows injecting dummy directories without network.
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 ¶
func (*AssetMin) UpdateFileContentInMemory ¶
func (*AssetMin) UpdateSSRModule ¶ added in v0.2.2
UpdateSSRModule inyecta o reemplaza los assets de un módulo por nombre en el slot por defecto (middle).
func (*AssetMin) UpdateSSRModuleInSlot ¶ added in v0.2.2
func (c *AssetMin) UpdateSSRModuleInSlot(name string, css, js, html string, icons map[string]string, slot string)
UpdateSSRModuleInSlot inyecta o reemplaza los assets de un módulo en el slot especificado.
func (*AssetMin) WaitForSSRLoad ¶ added in v0.2.2
WaitForSSRLoad espera a que LoadSSRModules termine, hasta el timeout dado.
type Config ¶
type Config struct {
OutputDir string // eg: web/static, web/public, web/assets
RootDir string // Root directory of the project where go.mod exists
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 ContentFile ¶ added in v0.2.2
type ContentFile struct {
Path string // eg: modules/module1/file.js
Content []byte /// eg: "console.log('hello world')"
}
ContentFile represents a file with its path and content
func (*ContentFile) WriteToDisk ¶ added in v0.2.2
func (f *ContentFile) WriteToDisk() error
WriteToDisk writes the content file to disk at the specified path It creates parent directories if they don't exist