@react-native/assets-registry 0.77.0-rc.6 → 0.77.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/assets-registry",
3
- "version": "0.77.0-rc.6",
3
+ "version": "0.77.0-rc.7",
4
4
  "description": "Asset support code for React Native.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/path-support.js CHANGED
@@ -4,13 +4,13 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @format
8
7
  * @flow strict
8
+ * @format
9
9
  */
10
10
 
11
11
  'use strict';
12
12
 
13
- import type {PackagerAsset} from './registry.js';
13
+ /*:: import type {PackagerAsset} from './registry.js'; */
14
14
 
15
15
  const androidScaleSuffix = {
16
16
  '0.75': 'ldpi',
@@ -27,7 +27,7 @@ const ANDROID_BASE_DENSITY = 160;
27
27
  * FIXME: using number to represent discrete scale numbers is fragile in essence because of
28
28
  * floating point numbers imprecision.
29
29
  */
30
- function getAndroidAssetSuffix(scale: number): string {
30
+ function getAndroidAssetSuffix(scale /*: number */) /*: string */ {
31
31
  if (scale.toString() in androidScaleSuffix) {
32
32
  // $FlowFixMe[invalid-computed-prop]
33
33
  return androidScaleSuffix[scale.toString()];
@@ -53,9 +53,9 @@ const drawableFileTypes = new Set([
53
53
  ]);
54
54
 
55
55
  function getAndroidResourceFolderName(
56
- asset: PackagerAsset,
57
- scale: number,
58
- ): string {
56
+ asset /*: PackagerAsset */,
57
+ scale /*: number */,
58
+ ) /*: string */ {
59
59
  if (!drawableFileTypes.has(asset.type)) {
60
60
  return 'raw';
61
61
  }
@@ -73,7 +73,9 @@ function getAndroidResourceFolderName(
73
73
  return 'drawable-' + suffix;
74
74
  }
75
75
 
76
- function getAndroidResourceIdentifier(asset: PackagerAsset): string {
76
+ function getAndroidResourceIdentifier(
77
+ asset /*: PackagerAsset */,
78
+ ) /*: string */ {
77
79
  return (getBasePath(asset) + '/' + asset.name)
78
80
  .toLowerCase()
79
81
  .replace(/\//g, '_') // Encode folder structure in file name
@@ -81,7 +83,7 @@ function getAndroidResourceIdentifier(asset: PackagerAsset): string {
81
83
  .replace(/^(?:assets|assetsunstable_path)_/, ''); // Remove "assets_" or "assetsunstable_path_" prefix
82
84
  }
83
85
 
84
- function getBasePath(asset: PackagerAsset): string {
86
+ function getBasePath(asset /*: PackagerAsset */) /*: string */ {
85
87
  const basePath = asset.httpServerLocation;
86
88
  return basePath.startsWith('/') ? basePath.slice(1) : basePath;
87
89
  }
package/registry.js CHANGED
@@ -10,6 +10,7 @@
10
10
 
11
11
  'use strict';
12
12
 
13
+ /*::
13
14
  export type AssetDestPathResolver = 'android' | 'generic';
14
15
 
15
16
  export type PackagerAsset = {
@@ -25,16 +26,17 @@ export type PackagerAsset = {
25
26
  +resolver?: AssetDestPathResolver,
26
27
  ...
27
28
  };
29
+ */
28
30
 
29
- const assets: Array<PackagerAsset> = [];
31
+ const assets /*: Array<PackagerAsset> */ = [];
30
32
 
31
- function registerAsset(asset: PackagerAsset): number {
33
+ function registerAsset(asset /*: PackagerAsset */) /*: number */ {
32
34
  // `push` returns new array length, so the first asset will
33
35
  // get id 1 (not 0) to make the value truthy
34
36
  return assets.push(asset);
35
37
  }
36
38
 
37
- function getAssetByID(assetId: number): PackagerAsset {
39
+ function getAssetByID(assetId /*: number */) /*: PackagerAsset */ {
38
40
  return assets[assetId - 1];
39
41
  }
40
42