@react-native/community-cli-plugin 0.73.0-nightly-20230922-52104c6ee

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.
Files changed (38) hide show
  1. package/README.md +91 -0
  2. package/dist/commands/bundle/assetCatalogIOS.js +74 -0
  3. package/dist/commands/bundle/assetCatalogIOS.js.flow +29 -0
  4. package/dist/commands/bundle/assetPathUtils.js +79 -0
  5. package/dist/commands/bundle/assetPathUtils.js.flow +39 -0
  6. package/dist/commands/bundle/buildBundle.js +121 -0
  7. package/dist/commands/bundle/buildBundle.js.flow +64 -0
  8. package/dist/commands/bundle/filterPlatformAssetScales.js +47 -0
  9. package/dist/commands/bundle/filterPlatformAssetScales.js.flow +17 -0
  10. package/dist/commands/bundle/getAssetDestPathAndroid.js +32 -0
  11. package/dist/commands/bundle/getAssetDestPathAndroid.js.flow +19 -0
  12. package/dist/commands/bundle/getAssetDestPathIOS.js +34 -0
  13. package/dist/commands/bundle/getAssetDestPathIOS.js.flow +19 -0
  14. package/dist/commands/bundle/index.js +124 -0
  15. package/dist/commands/bundle/index.js.flow +18 -0
  16. package/dist/commands/bundle/saveAssets.js +138 -0
  17. package/dist/commands/bundle/saveAssets.js.flow +21 -0
  18. package/dist/commands/ram-bundle/index.js +45 -0
  19. package/dist/commands/ram-bundle/index.js.flow +15 -0
  20. package/dist/commands/start/attachKeyHandlers.js +109 -0
  21. package/dist/commands/start/attachKeyHandlers.js.flow +22 -0
  22. package/dist/commands/start/index.js +105 -0
  23. package/dist/commands/start/index.js.flow +18 -0
  24. package/dist/commands/start/runServer.js +173 -0
  25. package/dist/commands/start/runServer.js.flow +38 -0
  26. package/dist/index.flow.js +36 -0
  27. package/dist/index.flow.js.flow +16 -0
  28. package/dist/index.js +3 -0
  29. package/dist/index.js.flow +12 -0
  30. package/dist/utils/KeyPressHandler.js +91 -0
  31. package/dist/utils/KeyPressHandler.js.flow +22 -0
  32. package/dist/utils/isDevServerRunning.js +74 -0
  33. package/dist/utils/isDevServerRunning.js.flow +27 -0
  34. package/dist/utils/loadMetroConfig.js +107 -0
  35. package/dist/utils/loadMetroConfig.js.flow +33 -0
  36. package/dist/utils/metroPlatformResolver.js +46 -0
  37. package/dist/utils/metroPlatformResolver.js.flow +30 -0
  38. package/package.json +43 -0
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # @react-native/community-cli-plugin
2
+
3
+ > This is an internal dependency of React Native. **Please don't depend on it directly.**
4
+
5
+ CLI entry points supporting core React Native development features.
6
+
7
+ Formerly [@react-native-community/cli-plugin-metro](https://www.npmjs.com/package/@react-native-community/cli-plugin-metro).
8
+
9
+ ## Commands
10
+
11
+ ### `start`
12
+
13
+ Start the React Native development server.
14
+
15
+ #### Usage
16
+
17
+ ```sh
18
+ npx react-native start [options]
19
+ ```
20
+
21
+ #### Options
22
+
23
+ | Option | Description |
24
+ | - | - |
25
+ | `--port <number>` | Set the server port. |
26
+ | `--host <string>` | Set the server host. |
27
+ | `--projectRoot <path>` | Set the path to the project root. |
28
+ | `--watchFolders <list>` | Specify additional folders to be added to the watch list. |
29
+ | `--assetPlugins <list>` | Specify additional asset plugins. |
30
+ | `--sourceExts <list>` | Specify additional source extensions to bundle. |
31
+ | `--max-workers <number>` | Set the maximum number of workers the worker-pool will spawn for transforming files. Defaults to the number of the cores available on your machine. |
32
+ | `--transformer <string>` | Specify a custom transformer. |
33
+ | `--reset-cache` | Remove cached files. |
34
+ | `--custom-log-reporter-path <string>` | Specify a module path exporting a replacement for `TerminalReporter`. |
35
+ | `--https` | Enable HTTPS connections. |
36
+ | `--key <path>`| Specify path to a custom SSL key. |
37
+ | `--cert <path>` | Specify path to a custom SSL cert. |
38
+ | `--config <string>` | Path to the CLI configuration file. |
39
+ | `--no-interactive` | Disable interactive mode. |
40
+
41
+ ### `bundle`
42
+
43
+ Build the bundle for the provided JavaScript entry file.
44
+
45
+ #### Usage
46
+
47
+ ```sh
48
+ npx react-native bundle --entry-file <path> [options]
49
+ ```
50
+
51
+ #### Options
52
+
53
+ | Option | Description |
54
+ | - | - |
55
+ | `--entry-file <path>` | Set the path to the root JavaScript entry file. |
56
+ | `--platform <string>` | Set the target platform (either `"android"` or `"ios"`). Defaults to `"ios"`. |
57
+ | `--transformer <string>` | Specify a custom transformer. |
58
+ | `--dev [boolean]` | If `false`, warnings are disabled and the bundle is minified. Defaults to `true`. |
59
+ | `--minify [boolean]` | Allows overriding whether bundle is minified. Defaults to `false` if `--dev` is set. Disabling minification can be useful for speeding up production builds for testing purposes. |
60
+ | `--bundle-output <string>` | Specify the path to store the resulting bundle. |
61
+ | `--bundle-encoding <string>` | Specify the encoding for writing the bundle (<https://nodejs.org/api/buffer.html#buffer_buffer>). |
62
+ | `--sourcemap-output <string>` | Specify the path to store the source map file for the resulting bundle. |
63
+ | `--sourcemap-sources-root <string>` | Set the root path for source map entries. |
64
+ | `--sourcemap-use-absolute-path` | Report `SourceMapURL` using its full path. |
65
+ | `--max-workers <number>` | Set the maximum number of workers the worker-pool will spawn for transforming files. Defaults to the number of the cores available on your machine. |
66
+ | `--assets-dest <string>` | Specify the directory path for storing assets referenced in the bundle. |
67
+ | `--reset-cache` | Remove cached files. |
68
+ | `--read-global-cache` | Attempt to fetch transformed JS code from the global cache, if configured. Defaults to `false`. |
69
+ | `--config <string>` | Path to the CLI configuration file. |
70
+
71
+ ### `ram-bundle`
72
+
73
+ Build the [RAM bundle](https://reactnative.dev/docs/ram-bundles-inline-requires) for the provided JavaScript entry file.
74
+
75
+ #### Usage
76
+
77
+ ```sh
78
+ npx react-native ram-bundle --entry-file <path> [options]
79
+ ```
80
+
81
+ #### Options
82
+
83
+ Accepts all options supported by [`bundle`](#bundle) and the following:
84
+
85
+ | Option | Description |
86
+ | - | - |
87
+ | `--indexed-ram-bundle` | Force the "Indexed RAM" bundle file format, even when building for Android. |
88
+
89
+ ## Contributing
90
+
91
+ Changes to this package can be made locally and tested against the `rn-tester` app, per the [Contributing guide](https://reactnative.dev/contributing/overview#contributing-code). During development, this package is automatically run from source with no build step.
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.cleanAssetCatalog = cleanAssetCatalog;
7
+ exports.getImageSet = getImageSet;
8
+ exports.isCatalogAsset = isCatalogAsset;
9
+ exports.writeImageSet = writeImageSet;
10
+ var _path = _interopRequireDefault(require("path"));
11
+ var _fs = _interopRequireDefault(require("fs"));
12
+ var _assetPathUtils = _interopRequireDefault(require("./assetPathUtils"));
13
+ function _interopRequireDefault(obj) {
14
+ return obj && obj.__esModule ? obj : { default: obj };
15
+ }
16
+ /**
17
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
18
+ *
19
+ * This source code is licensed under the MIT license found in the
20
+ * LICENSE file in the root directory of this source tree.
21
+ *
22
+ *
23
+ * @format
24
+ * @oncall react_native
25
+ */
26
+
27
+ function cleanAssetCatalog(catalogDir) {
28
+ const files = _fs.default
29
+ .readdirSync(catalogDir)
30
+ .filter((file) => file.endsWith(".imageset"));
31
+ for (const file of files) {
32
+ _fs.default.rmSync(_path.default.join(catalogDir, file));
33
+ }
34
+ }
35
+ function getImageSet(catalogDir, asset, scales) {
36
+ const fileName = _assetPathUtils.default.getResourceIdentifier(asset);
37
+ return {
38
+ basePath: _path.default.join(catalogDir, `${fileName}.imageset`),
39
+ files: scales.map((scale, idx) => {
40
+ const suffix = scale === 1 ? "" : `@${scale}x`;
41
+ return {
42
+ name: `${fileName + suffix}.${asset.type}`,
43
+ scale,
44
+ src: asset.files[idx],
45
+ };
46
+ }),
47
+ };
48
+ }
49
+ function isCatalogAsset(asset) {
50
+ return asset.type === "png" || asset.type === "jpg" || asset.type === "jpeg";
51
+ }
52
+ function writeImageSet(imageSet) {
53
+ _fs.default.mkdirSync(imageSet.basePath, {
54
+ recursive: true,
55
+ });
56
+ for (const file of imageSet.files) {
57
+ const dest = _path.default.join(imageSet.basePath, file.name);
58
+ _fs.default.copyFileSync(file.src, dest);
59
+ }
60
+ _fs.default.writeFileSync(
61
+ _path.default.join(imageSet.basePath, "Contents.json"),
62
+ JSON.stringify({
63
+ images: imageSet.files.map((file) => ({
64
+ filename: file.name,
65
+ idiom: "universal",
66
+ scale: `${file.scale}x`,
67
+ })),
68
+ info: {
69
+ author: "xcode",
70
+ version: 1,
71
+ },
72
+ })
73
+ );
74
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ import type { AssetData } from "metro/src/Assets";
13
+
14
+ declare export function cleanAssetCatalog(catalogDir: string): void;
15
+
16
+ type ImageSet = {
17
+ basePath: string,
18
+ files: { name: string, src: string, scale: number }[],
19
+ };
20
+
21
+ declare export function getImageSet(
22
+ catalogDir: string,
23
+ asset: AssetData,
24
+ scales: $ReadOnlyArray<number>
25
+ ): ImageSet;
26
+
27
+ declare export function isCatalogAsset(asset: AssetData): boolean;
28
+
29
+ declare export function writeImageSet(imageSet: ImageSet): void;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.default = void 0;
7
+ /**
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ *
13
+ *
14
+ * @format
15
+ * @oncall react_native
16
+ */
17
+
18
+ /**
19
+ * FIXME: using number to represent discrete scale numbers is fragile in essence because of
20
+ * floating point numbers imprecision.
21
+ */
22
+ function getAndroidAssetSuffix(scale) {
23
+ switch (scale) {
24
+ case 0.75:
25
+ return "ldpi";
26
+ case 1:
27
+ return "mdpi";
28
+ case 1.5:
29
+ return "hdpi";
30
+ case 2:
31
+ return "xhdpi";
32
+ case 3:
33
+ return "xxhdpi";
34
+ case 4:
35
+ return "xxxhdpi";
36
+ default:
37
+ return "";
38
+ }
39
+ }
40
+
41
+ // See https://developer.android.com/guide/topics/resources/drawable-resource.html
42
+ const drawableFileTypes = new Set(["gif", "jpeg", "jpg", "png", "webp", "xml"]);
43
+ function getAndroidResourceFolderName(asset, scale) {
44
+ if (!drawableFileTypes.has(asset.type)) {
45
+ return "raw";
46
+ }
47
+ const suffix = getAndroidAssetSuffix(scale);
48
+ if (!suffix) {
49
+ throw new Error(
50
+ `Don't know which android drawable suffix to use for asset: ${JSON.stringify(
51
+ asset
52
+ )}`
53
+ );
54
+ }
55
+ return `drawable-${suffix}`;
56
+ }
57
+ function getResourceIdentifier(asset) {
58
+ const folderPath = getBasePath(asset);
59
+ return `${folderPath}/${asset.name}`
60
+ .toLowerCase()
61
+ .replace(/\//g, "_") // Encode folder structure in file name
62
+ .replace(/([^a-z0-9_])/g, "") // Remove illegal chars
63
+ .replace(/^assets_/, ""); // Remove "assets_" prefix
64
+ }
65
+
66
+ function getBasePath(asset) {
67
+ let basePath = asset.httpServerLocation;
68
+ if (basePath[0] === "/") {
69
+ basePath = basePath.substr(1);
70
+ }
71
+ return basePath;
72
+ }
73
+ var _default = {
74
+ getAndroidAssetSuffix,
75
+ getAndroidResourceFolderName,
76
+ getResourceIdentifier,
77
+ getBasePath,
78
+ };
79
+ exports.default = _default;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ export type PackagerAsset = $ReadOnly<{
13
+ httpServerLocation: string,
14
+ name: string,
15
+ type: string,
16
+ ...
17
+ }>;
18
+
19
+ /**
20
+ * FIXME: using number to represent discrete scale numbers is fragile in essence because of
21
+ * floating point numbers imprecision.
22
+ */
23
+ declare function getAndroidAssetSuffix(scale: number): string;
24
+
25
+ declare function getAndroidResourceFolderName(
26
+ asset: PackagerAsset,
27
+ scale: number
28
+ ): string;
29
+
30
+ declare function getResourceIdentifier(asset: PackagerAsset): string;
31
+
32
+ declare function getBasePath(asset: PackagerAsset): string;
33
+
34
+ declare export default {
35
+ getAndroidAssetSuffix: getAndroidAssetSuffix,
36
+ getAndroidResourceFolderName: getAndroidResourceFolderName,
37
+ getResourceIdentifier: getResourceIdentifier,
38
+ getBasePath: getBasePath,
39
+ };
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.unstable_buildBundleWithConfig = exports.default = void 0;
7
+ var _Server = _interopRequireDefault(require("metro/src/Server"));
8
+ var _bundle = _interopRequireDefault(require("metro/src/shared/output/bundle"));
9
+ var _RamBundle = _interopRequireDefault(
10
+ require("metro/src/shared/output/RamBundle")
11
+ );
12
+ var _path = _interopRequireDefault(require("path"));
13
+ var _chalk = _interopRequireDefault(require("chalk"));
14
+ var _saveAssets = _interopRequireDefault(require("./saveAssets"));
15
+ var _loadMetroConfig = _interopRequireDefault(
16
+ require("../../utils/loadMetroConfig")
17
+ );
18
+ var _cliTools = require("@react-native-community/cli-tools");
19
+ function _interopRequireDefault(obj) {
20
+ return obj && obj.__esModule ? obj : { default: obj };
21
+ }
22
+ /**
23
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
24
+ *
25
+ * This source code is licensed under the MIT license found in the
26
+ * LICENSE file in the root directory of this source tree.
27
+ *
28
+ *
29
+ * @format
30
+ * @oncall react_native
31
+ */
32
+
33
+ async function buildBundle(_argv, ctx, args, bundleImpl = _bundle.default) {
34
+ const config = await (0, _loadMetroConfig.default)(ctx, {
35
+ maxWorkers: args.maxWorkers,
36
+ resetCache: args.resetCache,
37
+ config: args.config,
38
+ });
39
+ return buildBundleWithConfig(args, config, bundleImpl);
40
+ }
41
+ async function buildBundleWithConfig(
42
+ args,
43
+ config,
44
+ bundleImpl = _bundle.default
45
+ ) {
46
+ if (config.resolver.platforms.indexOf(args.platform) === -1) {
47
+ _cliTools.logger.error(
48
+ `Invalid platform ${
49
+ args.platform ? `"${_chalk.default.bold(args.platform)}" ` : ""
50
+ }selected.`
51
+ );
52
+ _cliTools.logger.info(
53
+ `Available platforms are: ${config.resolver.platforms
54
+ .map((x) => `"${_chalk.default.bold(x)}"`)
55
+ .join(
56
+ ", "
57
+ )}. If you are trying to bundle for an out-of-tree platform, it may not be installed.`
58
+ );
59
+ throw new Error("Bundling failed");
60
+ }
61
+
62
+ // This is used by a bazillion of npm modules we don't control so we don't
63
+ // have other choice than defining it as an env variable here.
64
+ process.env.NODE_ENV = args.dev ? "development" : "production";
65
+ let sourceMapUrl = args.sourcemapOutput;
66
+ if (sourceMapUrl != null && !args.sourcemapUseAbsolutePath) {
67
+ sourceMapUrl = _path.default.basename(sourceMapUrl);
68
+ }
69
+
70
+ // $FlowIgnore[prop-missing]
71
+ const requestOpts = {
72
+ entryFile: args.entryFile,
73
+ sourceMapUrl,
74
+ dev: args.dev,
75
+ minify: args.minify !== undefined ? args.minify : !args.dev,
76
+ platform: args.platform,
77
+ unstable_transformProfile: args.unstableTransformProfile,
78
+ };
79
+ const server = new _Server.default(config);
80
+ try {
81
+ const bundle = await bundleImpl.build(server, requestOpts);
82
+
83
+ // $FlowIgnore[class-object-subtyping]
84
+ // $FlowIgnore[incompatible-call]
85
+ // $FlowIgnore[prop-missing]
86
+ // $FlowIgnore[incompatible-exact]
87
+ await bundleImpl.save(bundle, args, _cliTools.logger.info);
88
+
89
+ // Save the assets of the bundle
90
+ const outputAssets = await server.getAssets({
91
+ ..._Server.default.DEFAULT_BUNDLE_OPTIONS,
92
+ ...requestOpts,
93
+ bundleType: "todo",
94
+ });
95
+
96
+ // When we're done saving bundle output and the assets, we're done.
97
+ return await (0, _saveAssets.default)(
98
+ outputAssets,
99
+ args.platform,
100
+ args.assetsDest,
101
+ args.assetCatalogDest
102
+ );
103
+ } finally {
104
+ server.end();
105
+ }
106
+ }
107
+
108
+ /**
109
+ * UNSTABLE: This function is likely to be relocated and its API changed in
110
+ * the near future. `@react-native/community-cli-plugin` should not be directly
111
+ * depended on by projects or integrators -- this is exported for legacy
112
+ * compatibility.
113
+ *
114
+ * Create a bundle using a pre-loaded Metro config. The config can be
115
+ * re-used for several bundling calls if multiple platforms are being
116
+ * bundled.
117
+ */
118
+ const unstable_buildBundleWithConfig = buildBundleWithConfig;
119
+ exports.unstable_buildBundleWithConfig = unstable_buildBundleWithConfig;
120
+ var _default = buildBundle;
121
+ exports.default = _default;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ import type { Config } from "@react-native-community/cli-types";
13
+ import type { ConfigT } from "metro-config";
14
+
15
+ import metroBundle from "metro/src/shared/output/bundle";
16
+ import metroRamBundle from "metro/src/shared/output/RamBundle";
17
+ export type BundleCommandArgs = {
18
+ assetsDest?: string,
19
+ assetCatalogDest?: string,
20
+ entryFile: string,
21
+ resetCache: boolean,
22
+ resetGlobalCache: boolean,
23
+ transformer?: string,
24
+ minify?: boolean,
25
+ config?: string,
26
+ platform: string,
27
+ dev: boolean,
28
+ bundleOutput: string,
29
+ bundleEncoding?: "utf8" | "utf16le" | "ascii",
30
+ maxWorkers?: number,
31
+ sourcemapOutput?: string,
32
+ sourcemapSourcesRoot?: string,
33
+ sourcemapUseAbsolutePath: boolean,
34
+ verbose: boolean,
35
+ unstableTransformProfile: string,
36
+ indexedRamBundle?: boolean,
37
+ };
38
+
39
+ declare function buildBundle(
40
+ _argv: Array<string>,
41
+ ctx: Config,
42
+ args: BundleCommandArgs,
43
+ bundleImpl: typeof metroBundle | typeof metroRamBundle
44
+ ): Promise<void>;
45
+
46
+ declare function buildBundleWithConfig(
47
+ args: BundleCommandArgs,
48
+ config: ConfigT,
49
+ bundleImpl: typeof metroBundle | typeof metroRamBundle
50
+ ): Promise<void>;
51
+
52
+ /**
53
+ * UNSTABLE: This function is likely to be relocated and its API changed in
54
+ * the near future. `@react-native/community-cli-plugin` should not be directly
55
+ * depended on by projects or integrators -- this is exported for legacy
56
+ * compatibility.
57
+ *
58
+ * Create a bundle using a pre-loaded Metro config. The config can be
59
+ * re-used for several bundling calls if multiple platforms are being
60
+ * bundled.
61
+ */
62
+ declare export const unstable_buildBundleWithConfig: buildBundleWithConfig;
63
+
64
+ declare export default buildBundle;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.default = void 0;
7
+ /**
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ *
13
+ *
14
+ * @format
15
+ * @oncall react_native
16
+ */
17
+
18
+ const ALLOWED_SCALES = {
19
+ ios: [1, 2, 3],
20
+ };
21
+ function filterPlatformAssetScales(platform, scales) {
22
+ const whitelist = ALLOWED_SCALES[platform];
23
+ if (!whitelist) {
24
+ return scales;
25
+ }
26
+ const result = scales.filter((scale) => whitelist.indexOf(scale) > -1);
27
+ if (result.length === 0 && scales.length > 0) {
28
+ // No matching scale found, but there are some available. Ideally we don't
29
+ // want to be in this situation and should throw, but for now as a fallback
30
+ // let's just use the closest larger image
31
+ const maxScale = whitelist[whitelist.length - 1];
32
+ for (const scale of scales) {
33
+ if (scale > maxScale) {
34
+ result.push(scale);
35
+ break;
36
+ }
37
+ }
38
+
39
+ // There is no larger scales available, use the largest we have
40
+ if (result.length === 0) {
41
+ result.push(scales[scales.length - 1]);
42
+ }
43
+ }
44
+ return result;
45
+ }
46
+ var _default = filterPlatformAssetScales;
47
+ exports.default = _default;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ declare function filterPlatformAssetScales(
13
+ platform: string,
14
+ scales: $ReadOnlyArray<number>
15
+ ): $ReadOnlyArray<number>;
16
+
17
+ declare export default filterPlatformAssetScales;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.default = void 0;
7
+ var _path = _interopRequireDefault(require("path"));
8
+ var _assetPathUtils = _interopRequireDefault(require("./assetPathUtils"));
9
+ function _interopRequireDefault(obj) {
10
+ return obj && obj.__esModule ? obj : { default: obj };
11
+ }
12
+ /**
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ *
18
+ *
19
+ * @format
20
+ * @oncall react_native
21
+ */
22
+
23
+ function getAssetDestPathAndroid(asset, scale) {
24
+ const androidFolder = _assetPathUtils.default.getAndroidResourceFolderName(
25
+ asset,
26
+ scale
27
+ );
28
+ const fileName = _assetPathUtils.default.getResourceIdentifier(asset);
29
+ return _path.default.join(androidFolder, `${fileName}.${asset.type}`);
30
+ }
31
+ var _default = getAssetDestPathAndroid;
32
+ exports.default = _default;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ import type { PackagerAsset } from "./assetPathUtils";
13
+
14
+ declare function getAssetDestPathAndroid(
15
+ asset: PackagerAsset,
16
+ scale: number
17
+ ): string;
18
+
19
+ declare export default getAssetDestPathAndroid;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.default = void 0;
7
+ var _path = _interopRequireDefault(require("path"));
8
+ function _interopRequireDefault(obj) {
9
+ return obj && obj.__esModule ? obj : { default: obj };
10
+ }
11
+ /**
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ *
17
+ *
18
+ * @format
19
+ * @oncall react_native
20
+ */
21
+
22
+ function getAssetDestPathIOS(asset, scale) {
23
+ const suffix = scale === 1 ? "" : `@${scale}x`;
24
+ const fileName = `${asset.name + suffix}.${asset.type}`;
25
+ return _path.default.join(
26
+ // Assets can have relative paths outside of the project root.
27
+ // Replace `../` with `_` to make sure they don't end up outside of
28
+ // the expected assets directory.
29
+ asset.httpServerLocation.substr(1).replace(/\.\.\//g, "_"),
30
+ fileName
31
+ );
32
+ }
33
+ var _default = getAssetDestPathIOS;
34
+ exports.default = _default;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ import type { PackagerAsset } from "./assetPathUtils";
13
+
14
+ declare function getAssetDestPathIOS(
15
+ asset: PackagerAsset,
16
+ scale: number
17
+ ): string;
18
+
19
+ declare export default getAssetDestPathIOS;