2015-05-08 00:30:41 +00:00
|
|
|
/**
|
2017-03-08 08:51:23 +00:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
2015-05-08 00:30:41 +00:00
|
|
|
*
|
|
|
|
* @providesModule AssetRegistry
|
2015-08-27 01:30:46 +00:00
|
|
|
* @flow
|
2015-05-08 00:30:41 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2017-03-08 08:51:23 +00:00
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { registerAsset, getAssetByID };
|