Skip to content

Commit

Permalink
Update library command to support early grouping of asset files
Browse files Browse the repository at this point in the history
Summary: Updates a FB-internal type definition.

Reviewed By: yungsters

Differential Revision: D29030004

fbshipit-source-id: a917722af448c8cd8cf136e1472f33f2dc47fb98
  • Loading branch information
motiz88 authored and facebook-github-bot committed Jun 24, 2021
1 parent 47fe403 commit 42cca5e
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions packages/metro/src/ModuleGraph/types.flow.js
Expand Up @@ -171,49 +171,62 @@ export type TransformedCodeFile = {|

export type ImageSize = {|+width: number, +height: number|};

export type AssetFile = {|
/**
* The path of the asset that is shared by all potential variants
* of this asset. For example `foo/bar@3x.png` would have the
* asset path `foo/bar.png`.
*/
+assetPath: string,
export type AssetFileVariant = $ReadOnly<{
/**
* The content is encoded in Base64 so that it can be stored in JSON files,
* that are used to communicate between different commands of a Buck
* build worker, for example.
*/
+contentBase64: string,
/**
* Guessed from the file extension, for example `png` or `html`.
*/
+contentType: string,
contentBase64: string,
/**
* Hash of the asset file content.
*/
+hash: string,
hash: string,
/**
* The path of the original file for this asset. For example
* `foo/bar@3x.ios.png`. This is most useful for reporting purposes, such as
* error messages.
*/
+filePath: string,
filePath: string,
/**
* If the asset is an image, this contain the size in physical pixels (ie.
* regarless of whether it's a `@2x` or `@3x` version of a smaller image).
*/
+physicalSize: ?ImageSize,
physicalSize: ?ImageSize,
/**
* The platform this asset is designed for, for example `ios` if the file name
* is `foo.ios.js`. `null` if the asset is not platform-specific.
*/
+platform: ?string,
platform: ?string,
/**
* The scale this asset is designed for, for example `2`
* if the file name is `foo@2x.png`.
*/
+scale: number,
|};
scale: number,
}>;

// A *virtual* asset file ( = one generated JS module in the bundle)
// representing one or more asset variants ( = physical input files).
export type AssetFile = $ReadOnly<{
/**
* The path of the asset that is shared by all potential variants
* of this asset. For example `foo/bar@3x.png` would have the
* asset path `foo/bar.png`.
*/
assetPath: string,

/**
* Guessed from the file extension, for example `png` or `html`.
*/
contentType: string,

/**
* The source files for this asset.
* TODO(moti): Guarantee that an AssetFile has *all* the source files for a
* given asset.
*/
variants: $ReadOnlyArray<AssetFileVariant>,
}>;

export type TransformedSourceFile =
| {|
Expand Down

0 comments on commit 42cca5e

Please sign in to comment.