Skip to content

Commit

Permalink
[expo-asset] Clean up some asset stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
wschurman committed Jan 8, 2024
1 parent a2fa1fa commit ebc9ae8
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions packages/expo-asset/src/Asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,22 @@ export { AssetMetadata };
* name and type) and provides facilities to load the asset data.
*/
export class Asset {
/**
* @private
*/
static byHash = {};
/**
* @private
*/
static byUri = {};
private static byHash = {};
private static byUri = {};

/**
* The name of the asset file without the extension. Also without the part from `@` onward in the
* filename (used to specify scale factor for images).
*/
name: string;
public name: string;
/**
* The extension of the asset filename.
*/
type: string;
public readonly type: string;
/**
* The MD5 hash of the asset's data.
*/
hash: string | null = null;
public readonly hash: string | null = null;
/**
* A URI that points to the asset's data on the remote server. When running the published version
* of your app, this refers to the location on Expo's asset server where Expo has stored your
Expand All @@ -61,30 +55,30 @@ export class Asset {
* are not using Classic Updates (legacy), this field should be ignored as we ensure your assets
* are on device before before running your application logic.
*/
uri: string;
public readonly uri: string;
/**
* If the asset has been downloaded (by calling [`downloadAsync()`](#downloadasync)), the
* `file://` URI pointing to the local file on the device that contains the asset data.
*/
localUri: string | null = null;
public localUri: string | null = null;
/**
* If the asset is an image, the width of the image data divided by the scale factor. The scale
* factor is the number after `@` in the filename, or `1` if not present.
*/
width: number | null = null;
public width: number | null = null;
/**
* If the asset is an image, the height of the image data divided by the scale factor. The scale factor is the number after `@` in the filename, or `1` if not present.
*/
height: number | null = null;
// @docsMissing
downloading: boolean = false;
// @docsMissing
downloaded: boolean = false;
public height: number | null = null;

private downloading: boolean = false;

/**
* @private
* Whether the asset has finished downloading from a call to [`downloadAsync()`](#downloadasync).
*/
_downloadCallbacks: DownloadPromiseCallbacks[] = [];
public downloaded: boolean = false;

private _downloadCallbacks: DownloadPromiseCallbacks[] = [];

constructor({ name, type, hash = null, uri, width, height }: AssetDescriptor) {
this.name = name;
Expand Down

0 comments on commit ebc9ae8

Please sign in to comment.