From 456829e92ac25b510b8f8f7ddf1e697842780b07 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Sat, 10 May 2025 02:06:55 +0700 Subject: [PATCH] feat(lib/assets): export `getAllAssets` --- lib/assets/src/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/assets/src/index.ts b/lib/assets/src/index.ts index 80cace5..0c4fc3d 100644 --- a/lib/assets/src/index.ts +++ b/lib/assets/src/index.ts @@ -10,6 +10,13 @@ export { AssetRegistry, AssetRegistryModuleId } from './preinit' // iOS cannot display SVGs let _preferredType: Asset['type'] = ReactNative.Platform.OS === 'ios' ? 'png' : 'svg' +/** + * Yields all registered assets, including ones with same name but different types, custom assets, and overriden assets. + */ +export function* getAllAssets() { + for (const name of _assets.keys()) for (const asset of Object.values(_assets.get(name)![1])) yield asset +} + /** * Get an asset by its ID. **This may throw an error if the asset-registry has not been initialized.** *