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
|
|
|
*
|
2018-06-20 07:35:29 +00:00
|
|
|
* @flow strict
|
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
|
|
|
|
2018-05-10 22:44:52 +00:00
|
|
|
const assets: Array<PackagerAsset> = [];
|
2015-08-27 01:30:46 +00:00
|
|
|
|
|
|
|
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};
|