소스 검색

feat: support assets interface

Yeuoly 8 달 전
부모
커밋
e930633d59
2개의 변경된 파일11개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      internal/core/bundle_packager/bundle_packager.go
  2. 8 0
      internal/core/bundle_packager/generic.go

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