mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 11:05:21 +00:00
packager: buck library: expose asset content
Reviewed By: davidaurelio Differential Revision: D4945778 fbshipit-source-id: ea132a3d284ed09c59c69afbdd7b707af9e521b9
This commit is contained in:
parent
3afbcfcd6b
commit
1f8d1002ef
@ -13,15 +13,15 @@
|
||||
|
||||
|
||||
export type PackagerAsset = {
|
||||
__packager_asset: boolean,
|
||||
fileSystemLocation: string,
|
||||
httpServerLocation: string,
|
||||
width: number,
|
||||
height: number,
|
||||
scales: Array<number>,
|
||||
hash: string,
|
||||
name: string,
|
||||
type: string,
|
||||
+__packager_asset: boolean,
|
||||
+fileSystemLocation: string,
|
||||
+httpServerLocation: string,
|
||||
+width: ?number,
|
||||
+height: ?number,
|
||||
+scales: Array<number>,
|
||||
+hash: string,
|
||||
+name: string,
|
||||
+type: string,
|
||||
};
|
||||
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
|
||||
export type ResolvedAssetSource = {
|
||||
__packager_asset: boolean,
|
||||
width: number,
|
||||
height: number,
|
||||
width: ?number,
|
||||
height: ?number,
|
||||
uri: string,
|
||||
scale: number,
|
||||
};
|
||||
|
@ -5,13 +5,18 @@
|
||||
* 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.
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const assetPathUtils = require('./assetPathUtils');
|
||||
const path = require('path');
|
||||
|
||||
function getAssetDestPathAndroid(asset, scale) {
|
||||
import type {PackagerAsset} from '../../Libraries/Image/AssetRegistry';
|
||||
|
||||
function getAssetDestPathAndroid(asset: PackagerAsset, scale: number): string {
|
||||
const androidFolder = assetPathUtils.getAndroidDrawableFolderName(asset, scale);
|
||||
const fileName = assetPathUtils.getAndroidResourceIdentifier(asset);
|
||||
return path.join(androidFolder, fileName + '.' + asset.type);
|
||||
|
@ -5,12 +5,17 @@
|
||||
* 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.
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
function getAssetDestPathIOS(asset, scale) {
|
||||
import type {PackagerAsset} from '../../Libraries/Image/AssetRegistry';
|
||||
|
||||
function getAssetDestPathIOS(asset: PackagerAsset, scale: number): string {
|
||||
const suffix = scale === 1 ? '' : '@' + scale + 'x';
|
||||
const fileName = asset.name + suffix + '.' + asset.type;
|
||||
return path.join(asset.httpServerLocation.substr(1), fileName);
|
||||
|
@ -68,7 +68,7 @@ export type GetTransformOptions = (
|
||||
getDependenciesOf: string => Promise<Array<string>>,
|
||||
) => Promise<ExtraTransformOptions>;
|
||||
|
||||
type AssetDescriptor = {
|
||||
export type AssetDescriptor = {
|
||||
+__packager_asset: boolean,
|
||||
+httpServerLocation: string,
|
||||
+width: ?number,
|
||||
@ -79,7 +79,7 @@ type AssetDescriptor = {
|
||||
+type: string,
|
||||
};
|
||||
|
||||
type ExtendedAssetDescriptor = AssetDescriptor & {
|
||||
export type ExtendedAssetDescriptor = AssetDescriptor & {
|
||||
+fileSystemLocation: string,
|
||||
+files: Array<string>,
|
||||
};
|
||||
|
@ -140,3 +140,11 @@ export type LibraryOptions = {|
|
||||
platform?: string,
|
||||
root: string,
|
||||
|};
|
||||
|
||||
export type Base64Content = string;
|
||||
|
||||
export type Library = {|
|
||||
files: Array<TransformedFile>,
|
||||
/* cannot be a Map because it's JSONified later on */
|
||||
assets: {[destFilePath: string]: Base64Content},
|
||||
|};
|
||||
|
Loading…
x
Reference in New Issue
Block a user