Преглед изворни кода

feat: support assets interface

Yeuoly пре 8 месеци
родитељ
комит
e930633d59

+ 3 - 0
internal/core/bundle_packager/bundle_packager.go

@@ -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)

+ 8 - 0
internal/core/bundle_packager/generic.go

@@ -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
+}