2015-05-08 00:30:41 +00:00
|
|
|
/**
|
2017-03-08 08:51:23 +00:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-05-08 00:30:41 +00:00
|
|
|
*
|
|
|
|
* @providesModule AssetRegistry
|
2015-08-27 01:30:46 +00:00
|
|
|
* @flow
|
2018-01-15 03:32:26 +00:00
|
|
|
* @format
|
2015-05-08 00:30:41 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2015-08-27 01:30:46 +00:00
|
|
|
export type PackagerAsset = {
|
2017-04-25 18:49:41 +00:00
|
|
|
+__packager_asset: boolean,
|
|
|
|
+fileSystemLocation: string,
|
|
|
|
+httpServerLocation: string,
|
|
|
|
+width: ?number,
|
|
|
|
+height: ?number,
|
|
|
|
+scales: Array<number>,
|
|
|
|
+hash: string,
|
|
|
|
+name: string,
|
|
|
|
+type: string,
|
2015-08-27 01:30:46 +00:00
|
|
|
};
|
2015-05-08 00:30:41 +00:00
|
|
|
|
2015-08-27 01:30:46 +00:00
|
|
|
var assets: Array<PackagerAsset> = [];
|
|
|
|
|
|
|
|
function registerAsset(asset: PackagerAsset): number {
|
2015-05-08 00:30:41 +00:00
|
|
|
// `push` returns new array length, so the first asset will
|
|
|
|
// get id 1 (not 0) to make the value truthy
|
|
|
|
return assets.push(asset);
|
|
|
|
}
|
|
|
|
|
2015-08-27 01:30:46 +00:00
|
|
|
function getAssetByID(assetId: number): PackagerAsset {
|
2015-05-08 00:30:41 +00:00
|
|
|
return assets[assetId - 1];
|
|
|
|
}
|
|
|
|
|
2018-01-15 03:32:26 +00:00
|
|
|
module.exports = {registerAsset, getAssetByID};
|