Skip to content

Commit

Permalink
feat: support assets interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Nov 25, 2024
1 parent 0ab0fc1 commit e930633
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/core/bundle_packager/bundle_packager.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ type BundlePackager interface {
// NOTE: path is the relative path to _assets folder
FetchAsset(path string) ([]byte, error)

// Assets returns a set of assets in the bundle
Assets() (map[string][]byte, error)

// ReadFile reads the file from the bundle
// NOTE: path is the relative path to the root of the bundle
ReadFile(path string) ([]byte, error)
Expand Down
8 changes: 8 additions & 0 deletions internal/core/bundle_packager/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,11 @@ func (p *GenericBundlePackager) FetchAsset(path string) ([]byte, error) {

return asset.Bytes(), nil
}

func (p *GenericBundlePackager) Assets() (map[string][]byte, error) {
assets := make(map[string][]byte)
for path, asset := range p.assets {
assets[path] = asset.Bytes()
}
return assets, nil
}

0 comments on commit e930633

Please sign in to comment.