mirror of https://github.com/status-im/metro.git
Consolidate AssetData flow types
Reviewed By: jeanlauliac Differential Revision: D6497429 fbshipit-source-id: cd9abe2d8c5b2b7eb48d8a0335ea5bfa8ac13269
This commit is contained in:
parent
452ee5962d
commit
6d7ba472ee
|
@ -26,29 +26,30 @@ const stat = denodeify(fs.stat);
|
|||
const readDir = denodeify(fs.readdir);
|
||||
const readFile = denodeify(fs.readFile);
|
||||
|
||||
import type {AssetPath} from '../node-haste/lib/AssetPaths';
|
||||
|
||||
export type AssetData = {|
|
||||
__packager_asset: boolean,
|
||||
fileSystemLocation: string,
|
||||
httpServerLocation: string,
|
||||
width: ?number,
|
||||
height: ?number,
|
||||
scales: Array<number>,
|
||||
files: Array<string>,
|
||||
hash: string,
|
||||
name: string,
|
||||
type: string,
|
||||
|};
|
||||
|
||||
export type AssetInfo = {|
|
||||
files: Array<string>,
|
||||
hash: string,
|
||||
name: string,
|
||||
scales: Array<number>,
|
||||
type: string,
|
||||
+files: Array<string>,
|
||||
+hash: string,
|
||||
+name: string,
|
||||
+scales: Array<number>,
|
||||
+type: string,
|
||||
|};
|
||||
|
||||
export type AssetDataWithoutFiles = {
|
||||
+__packager_asset: boolean,
|
||||
+fileSystemLocation: string,
|
||||
+hash: string,
|
||||
+height: ?number,
|
||||
+httpServerLocation: string,
|
||||
+name: string,
|
||||
+scales: Array<number>,
|
||||
+type: string,
|
||||
+width: ?number,
|
||||
};
|
||||
|
||||
export type AssetData = AssetDataWithoutFiles & {
|
||||
+files: Array<string>,
|
||||
};
|
||||
|
||||
const hashFiles = denodeify(function hashFilesCb(files, hash, callback) {
|
||||
if (!files.length) {
|
||||
callback(null);
|
||||
|
@ -268,7 +269,7 @@ async function getAssetFiles(
|
|||
assetPath: string,
|
||||
platform: ?string = null,
|
||||
): Promise<Array<string>> {
|
||||
const assetData = await getAbsoluteAssetInfo(assetPath, platform);
|
||||
const assetData = await getAbsoluteAssetRecord(assetPath, platform);
|
||||
|
||||
return assetData.files;
|
||||
}
|
||||
|
|
|
@ -62,21 +62,6 @@ export type GetTransformOptions = (
|
|||
getDependenciesOf: (string) => Promise<Array<string>>,
|
||||
) => Promise<ExtraTransformOptions>;
|
||||
|
||||
export type AssetDescriptor = {
|
||||
+__packager_asset: boolean,
|
||||
+httpServerLocation: string,
|
||||
+width: ?number,
|
||||
+height: ?number,
|
||||
+scales: Array<number>,
|
||||
+hash: string,
|
||||
+name: string,
|
||||
+type: string,
|
||||
};
|
||||
|
||||
export type ExtendedAssetDescriptor = AssetDescriptor & {
|
||||
+fileSystemLocation: string,
|
||||
};
|
||||
|
||||
export type PostMinifyProcess = ({
|
||||
code: string,
|
||||
map: ?MappingsMap,
|
||||
|
|
|
@ -13,10 +13,9 @@
|
|||
'use strict';
|
||||
|
||||
const babel = require('babel-core');
|
||||
const babelGenerate = require('babel-generator').default;
|
||||
const babylon = require('babylon');
|
||||
|
||||
import type {ExtendedAssetDescriptor} from '.';
|
||||
import type {AssetDataWithoutFiles} from '../Assets';
|
||||
import type {ModuleTransportLike} from '../shared/types.flow';
|
||||
|
||||
// Structure of the object: dir.name.scale = asset
|
||||
|
@ -42,7 +41,7 @@ const assetPropertyBlacklist = new Set(['files', 'fileSystemLocation', 'path']);
|
|||
|
||||
function generateAssetCodeFileAst(
|
||||
assetRegistryPath: string,
|
||||
assetDescriptor: ExtendedAssetDescriptor,
|
||||
assetDescriptor: AssetDataWithoutFiles,
|
||||
): Ast {
|
||||
const properDescriptor = filterObject(
|
||||
assetDescriptor,
|
||||
|
@ -93,7 +92,7 @@ function generateAssetCodeFileAst(
|
|||
*/
|
||||
function generateRemoteAssetCodeFileAst(
|
||||
assetSourceResolverPath: string,
|
||||
assetDescriptor: ExtendedAssetDescriptor,
|
||||
assetDescriptor: AssetDataWithoutFiles,
|
||||
remoteServer: string,
|
||||
remoteFileMap: RemoteFileMap,
|
||||
): ?Ast {
|
||||
|
|
Loading…
Reference in New Issue