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 readDir = denodeify(fs.readdir);
|
||||||
const readFile = denodeify(fs.readFile);
|
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 = {|
|
export type AssetInfo = {|
|
||||||
files: Array<string>,
|
+files: Array<string>,
|
||||||
hash: string,
|
+hash: string,
|
||||||
name: string,
|
+name: string,
|
||||||
scales: Array<number>,
|
+scales: Array<number>,
|
||||||
type: string,
|
+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) {
|
const hashFiles = denodeify(function hashFilesCb(files, hash, callback) {
|
||||||
if (!files.length) {
|
if (!files.length) {
|
||||||
callback(null);
|
callback(null);
|
||||||
|
@ -268,7 +269,7 @@ async function getAssetFiles(
|
||||||
assetPath: string,
|
assetPath: string,
|
||||||
platform: ?string = null,
|
platform: ?string = null,
|
||||||
): Promise<Array<string>> {
|
): Promise<Array<string>> {
|
||||||
const assetData = await getAbsoluteAssetInfo(assetPath, platform);
|
const assetData = await getAbsoluteAssetRecord(assetPath, platform);
|
||||||
|
|
||||||
return assetData.files;
|
return assetData.files;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,21 +62,6 @@ export type GetTransformOptions = (
|
||||||
getDependenciesOf: (string) => Promise<Array<string>>,
|
getDependenciesOf: (string) => Promise<Array<string>>,
|
||||||
) => Promise<ExtraTransformOptions>;
|
) => 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 = ({
|
export type PostMinifyProcess = ({
|
||||||
code: string,
|
code: string,
|
||||||
map: ?MappingsMap,
|
map: ?MappingsMap,
|
||||||
|
|
|
@ -13,10 +13,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const babel = require('babel-core');
|
const babel = require('babel-core');
|
||||||
const babelGenerate = require('babel-generator').default;
|
|
||||||
const babylon = require('babylon');
|
const babylon = require('babylon');
|
||||||
|
|
||||||
import type {ExtendedAssetDescriptor} from '.';
|
import type {AssetDataWithoutFiles} from '../Assets';
|
||||||
import type {ModuleTransportLike} from '../shared/types.flow';
|
import type {ModuleTransportLike} from '../shared/types.flow';
|
||||||
|
|
||||||
// Structure of the object: dir.name.scale = asset
|
// Structure of the object: dir.name.scale = asset
|
||||||
|
@ -42,7 +41,7 @@ const assetPropertyBlacklist = new Set(['files', 'fileSystemLocation', 'path']);
|
||||||
|
|
||||||
function generateAssetCodeFileAst(
|
function generateAssetCodeFileAst(
|
||||||
assetRegistryPath: string,
|
assetRegistryPath: string,
|
||||||
assetDescriptor: ExtendedAssetDescriptor,
|
assetDescriptor: AssetDataWithoutFiles,
|
||||||
): Ast {
|
): Ast {
|
||||||
const properDescriptor = filterObject(
|
const properDescriptor = filterObject(
|
||||||
assetDescriptor,
|
assetDescriptor,
|
||||||
|
@ -93,7 +92,7 @@ function generateAssetCodeFileAst(
|
||||||
*/
|
*/
|
||||||
function generateRemoteAssetCodeFileAst(
|
function generateRemoteAssetCodeFileAst(
|
||||||
assetSourceResolverPath: string,
|
assetSourceResolverPath: string,
|
||||||
assetDescriptor: ExtendedAssetDescriptor,
|
assetDescriptor: AssetDataWithoutFiles,
|
||||||
remoteServer: string,
|
remoteServer: string,
|
||||||
remoteFileMap: RemoteFileMap,
|
remoteFileMap: RemoteFileMap,
|
||||||
): ?Ast {
|
): ?Ast {
|
||||||
|
|
Loading…
Reference in New Issue