Skip to content

Commit f034407

Browse files
committed
fix(react-native): add missing AssetRegistry TypeScript types
1 parent 8d658f4 commit f034407

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎packages/react-native/types_DEPRECATED/index.d.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export * as CodegenTypes from './Libraries/Types/CodegenTypesNamespace';
144144
export * from './Libraries/Types/CoreEventTypes';
145145
export * from './Libraries/Utilities/Appearance';
146146
export * from './Libraries/Utilities/BackHandler';
147+
export * from './src/private/assets/AssetRegistry';
147148
export * from './src/private/devsupport/devmenu/DevMenu';
148149
export * from './Libraries/Utilities/DevSettings';
149150
export * from './Libraries/Utilities/Dimensions';
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
*/
9+
10+
export type AssetDestPathResolver = 'android' | 'generic';
11+
12+
export interface PackagerAsset {
13+
__packager_asset: boolean,
14+
fileSystemLocation: string,
15+
httpServerLocation: string,
16+
width: number | null | undefined,
17+
height: number | null | undefined,
18+
scales: number[],
19+
hash: string,
20+
name: string,
21+
type: string,
22+
resolver?: AssetDestPathResolver,
23+
}
24+
25+
/**
26+
* Runtime registry that maps asset IDs generated in a Metro bundle to asset
27+
* metadata. It backs `<Image>`, `Image.resolveAssetSource()`, and any code
28+
* that resolves `require('./img.png')` on native.
29+
*
30+
* Most apps do not use this directly — assets are handled through `<Image>`.
31+
*/
32+
export declare const AssetRegistry: {
33+
/**
34+
* Register an asset. Returns the asset ID.
35+
*/
36+
registerAsset(asset: PackagerAsset): number;
37+
38+
/**
39+
* Retrieve a registered asset by ID.
40+
*/
41+
getAssetByID(assetId: number): PackagerAsset;
42+
};

0 commit comments

Comments
 (0)