@rock-js/plugin-metro 0.11.3 → 0.11.4

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 (57) hide show
  1. package/dist/src/index.d.ts.map +1 -0
  2. package/dist/src/lib/bundle/__tests__/filterPlatformAssetScales-test.d.ts +8 -0
  3. package/dist/src/lib/bundle/__tests__/filterPlatformAssetScales-test.js +29 -0
  4. package/dist/src/lib/bundle/__tests__/filterPlatformAssetScales-test.js.map +1 -0
  5. package/dist/src/lib/bundle/assetCatalogIOS.d.ts +21 -0
  6. package/dist/src/lib/bundle/assetCatalogIOS.js +54 -0
  7. package/dist/src/lib/bundle/assetCatalogIOS.js.map +1 -0
  8. package/dist/src/lib/bundle/assetPathUtils.d.ts +28 -0
  9. package/dist/src/lib/bundle/assetPathUtils.js +72 -0
  10. package/dist/src/lib/bundle/assetPathUtils.js.map +1 -0
  11. package/dist/src/lib/bundle/buildBundle.d.ts +57 -0
  12. package/dist/src/lib/bundle/buildBundle.js +99 -0
  13. package/dist/src/lib/bundle/buildBundle.js.map +1 -0
  14. package/dist/src/lib/bundle/command.d.ts.map +1 -0
  15. package/dist/src/lib/bundle/createKeepFileAsync.d.ts +10 -0
  16. package/dist/src/lib/bundle/createKeepFileAsync.js +28 -0
  17. package/dist/src/lib/bundle/createKeepFileAsync.js.map +1 -0
  18. package/dist/src/lib/bundle/filterPlatformAssetScales.d.ts +9 -0
  19. package/dist/src/lib/bundle/filterPlatformAssetScales.js +36 -0
  20. package/dist/src/lib/bundle/filterPlatformAssetScales.js.map +1 -0
  21. package/dist/src/lib/bundle/getAssetDestPathAndroid.d.ts +10 -0
  22. package/dist/src/lib/bundle/getAssetDestPathAndroid.js +16 -0
  23. package/dist/src/lib/bundle/getAssetDestPathAndroid.js.map +1 -0
  24. package/dist/src/lib/bundle/getAssetDestPathIOS.d.ts +10 -0
  25. package/dist/src/lib/bundle/getAssetDestPathIOS.js +19 -0
  26. package/dist/src/lib/bundle/getAssetDestPathIOS.js.map +1 -0
  27. package/dist/src/lib/bundle/index.d.ts +11 -0
  28. package/dist/src/lib/bundle/index.js +106 -0
  29. package/dist/src/lib/bundle/index.js.map +1 -0
  30. package/dist/src/lib/bundle/saveAssets.d.ts +10 -0
  31. package/dist/src/lib/bundle/saveAssets.js +112 -0
  32. package/dist/src/lib/bundle/saveAssets.js.map +1 -0
  33. package/dist/src/lib/getDevMiddleware.d.ts +2 -0
  34. package/dist/src/lib/getDevMiddleware.js +15 -0
  35. package/dist/src/lib/getDevMiddleware.js.map +1 -0
  36. package/dist/src/lib/loadMetroConfig.d.ts +24 -0
  37. package/dist/src/lib/loadMetroConfig.js +76 -0
  38. package/dist/src/lib/loadMetroConfig.js.map +1 -0
  39. package/dist/src/lib/pluginMetro.d.ts.map +1 -0
  40. package/dist/src/lib/start/OpenDebuggerKeyboardHandler.d.ts.map +1 -0
  41. package/dist/src/lib/start/attachKeyHandlers.d.ts.map +1 -0
  42. package/dist/src/lib/start/command.d.ts.map +1 -0
  43. package/dist/src/lib/start/createDevMiddlewareLogger.d.ts.map +1 -0
  44. package/dist/src/lib/start/loadMetroConfig.d.ts.map +1 -0
  45. package/dist/src/lib/start/metroPlatformResolver.d.ts.map +1 -0
  46. package/dist/src/lib/start/runServer.d.ts.map +1 -0
  47. package/dist/src/utils/loadMetroConfig.d.ts +24 -0
  48. package/dist/src/utils/loadMetroConfig.js +76 -0
  49. package/dist/src/utils/loadMetroConfig.js.map +1 -0
  50. package/dist/src/utils/metroPlatformResolver.d.ts +24 -0
  51. package/dist/src/utils/metroPlatformResolver.js +38 -0
  52. package/dist/src/utils/metroPlatformResolver.js.map +1 -0
  53. package/dist/src/utils/parseKeyValueParamArray.d.ts +8 -0
  54. package/dist/src/utils/parseKeyValueParamArray.js +21 -0
  55. package/dist/src/utils/parseKeyValueParamArray.js.map +1 -0
  56. package/package.json +3 -3
  57. package/template/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,8 @@
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
+ */
8
+ export {};
@@ -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
+ */
8
+ import filterPlatformAssetScales from '../filterPlatformAssetScales';
9
+ jest.dontMock('../filterPlatformAssetScales').dontMock('../assetPathUtils');
10
+ describe('filterPlatformAssetScales', () => {
11
+ test('removes everything but 2x and 3x for iOS', () => {
12
+ expect(filterPlatformAssetScales('ios', [1, 1.5, 2, 3, 4])).toEqual([
13
+ 1, 2, 3,
14
+ ]);
15
+ expect(filterPlatformAssetScales('ios', [3, 4])).toEqual([3]);
16
+ });
17
+ test('keeps closest largest one if nothing matches', () => {
18
+ expect(filterPlatformAssetScales('ios', [0.5, 4, 100])).toEqual([4]);
19
+ expect(filterPlatformAssetScales('ios', [0.5, 100])).toEqual([100]);
20
+ expect(filterPlatformAssetScales('ios', [0.5])).toEqual([0.5]);
21
+ expect(filterPlatformAssetScales('ios', [])).toEqual([]);
22
+ });
23
+ test('keeps all scales for unknown platform', () => {
24
+ expect(filterPlatformAssetScales('freebsd', [1, 1.5, 2, 3.7])).toEqual([
25
+ 1, 1.5, 2, 3.7,
26
+ ]);
27
+ });
28
+ });
29
+ //# sourceMappingURL=filterPlatformAssetScales-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterPlatformAssetScales-test.js","sourceRoot":"","sources":["../../../../../src/lib/bundle/__tests__/filterPlatformAssetScales-test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,yBAAyB,MAAM,8BAA8B,CAAC;AAErE,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,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YACrE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG;SACf,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,21 @@
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
+ */
8
+ import type { AssetData } from 'metro';
9
+ export declare function cleanAssetCatalog(catalogDir: string): void;
10
+ type ImageSet = {
11
+ basePath: string;
12
+ files: {
13
+ name: string;
14
+ src: string;
15
+ scale: number;
16
+ }[];
17
+ };
18
+ export declare function getImageSet(catalogDir: string, asset: AssetData, scales: ReadonlyArray<number>): ImageSet;
19
+ export declare function isCatalogAsset(asset: AssetData): boolean;
20
+ export declare function writeImageSet(imageSet: ImageSet): void;
21
+ export {};
@@ -0,0 +1,54 @@
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
+ */
8
+ import fs from 'fs';
9
+ import path from 'path';
10
+ import assetPathUtils from './assetPathUtils.js';
11
+ export function cleanAssetCatalog(catalogDir) {
12
+ const files = fs
13
+ .readdirSync(catalogDir)
14
+ .filter((file) => file.endsWith('.imageset'));
15
+ for (const file of files) {
16
+ fs.rmSync(path.join(catalogDir, file), { recursive: true, force: true });
17
+ }
18
+ }
19
+ export function getImageSet(catalogDir, asset, scales) {
20
+ const fileName = assetPathUtils.getResourceIdentifier(asset);
21
+ return {
22
+ basePath: path.join(catalogDir, `${fileName}.imageset`),
23
+ files: scales.map((scale, idx) => {
24
+ const suffix = scale === 1 ? '' : `@${scale}x`;
25
+ return {
26
+ name: `${fileName + suffix}.${asset.type}`,
27
+ scale,
28
+ src: asset.files[idx],
29
+ };
30
+ }),
31
+ };
32
+ }
33
+ export function isCatalogAsset(asset) {
34
+ return asset.type === 'png' || asset.type === 'jpg' || asset.type === 'jpeg';
35
+ }
36
+ export function writeImageSet(imageSet) {
37
+ fs.mkdirSync(imageSet.basePath, { recursive: true });
38
+ for (const file of imageSet.files) {
39
+ const dest = path.join(imageSet.basePath, file.name);
40
+ fs.copyFileSync(file.src, dest);
41
+ }
42
+ fs.writeFileSync(path.join(imageSet.basePath, 'Contents.json'), JSON.stringify({
43
+ images: imageSet.files.map((file) => ({
44
+ filename: file.name,
45
+ idiom: 'universal',
46
+ scale: `${file.scale}x`,
47
+ })),
48
+ info: {
49
+ author: 'xcode',
50
+ version: 1,
51
+ },
52
+ }));
53
+ }
54
+ //# sourceMappingURL=assetCatalogIOS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assetCatalogIOS.js","sourceRoot":"","sources":["../../../../src/lib/bundle/assetCatalogIOS.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,MAAM,KAAK,GAAG,EAAE;SACb,WAAW,CAAC,UAAU,CAAC;SACvB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;IAChD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC;AAOD,MAAM,UAAU,WAAW,CACzB,UAAkB,EAClB,KAAgB,EAChB,MAA6B;IAE7B,MAAM,QAAQ,GAAG,cAAc,CAAC,qBAAqB,CAAC,K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CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACpC,QAAQ,EAAE,IAAI,CAAC,IAAI;YACnB,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,GAAG;SACxB,CAAC,CAAC;QACH,IAAI,EAAE;YACJ,MAAM,EAAE,OAAO;YACf,OAAO,EAAE,CAAC;SACX;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,28 @@
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
+ */
8
+ export type PackagerAsset = Readonly<{
9
+ httpServerLocation: string;
10
+ name: string;
11
+ type: string;
12
+ }>;
13
+ /**
14
+ * FIXME: using number to represent discrete scale numbers is fragile in essence because of
15
+ * floating point numbers imprecision.
16
+ */
17
+ declare function getAndroidAssetSuffix(scale: number): string;
18
+ declare function getAndroidResourceFolderName(asset: PackagerAsset, scale: number): string;
19
+ declare function getResourceIdentifier(asset: PackagerAsset): string;
20
+ declare function getBasePath(asset: PackagerAsset): string;
21
+ declare const _default: {
22
+ drawableFileTypes: Set<string>;
23
+ getAndroidAssetSuffix: typeof getAndroidAssetSuffix;
24
+ getAndroidResourceFolderName: typeof getAndroidResourceFolderName;
25
+ getResourceIdentifier: typeof getResourceIdentifier;
26
+ getBasePath: typeof getBasePath;
27
+ };
28
+ export default _default;
@@ -0,0 +1,72 @@
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
+ */
8
+ /**
9
+ * FIXME: using number to represent discrete scale numbers is fragile in essence because of
10
+ * floating point numbers imprecision.
11
+ */
12
+ function getAndroidAssetSuffix(scale) {
13
+ switch (scale) {
14
+ case 0.75:
15
+ return 'ldpi';
16
+ case 1:
17
+ return 'mdpi';
18
+ case 1.5:
19
+ return 'hdpi';
20
+ case 2:
21
+ return 'xhdpi';
22
+ case 3:
23
+ return 'xxhdpi';
24
+ case 4:
25
+ return 'xxxhdpi';
26
+ default:
27
+ return '';
28
+ }
29
+ }
30
+ // See https://developer.android.com/guide/topics/resources/drawable-resource.html
31
+ const drawableFileTypes = new Set([
32
+ 'gif',
33
+ 'jpeg',
34
+ 'jpg',
35
+ 'png',
36
+ 'webp',
37
+ 'xml',
38
+ ]);
39
+ function getAndroidResourceFolderName(asset, scale) {
40
+ if (!drawableFileTypes.has(asset.type)) {
41
+ return 'raw';
42
+ }
43
+ const suffix = getAndroidAssetSuffix(scale);
44
+ if (!suffix) {
45
+ throw new Error(`Don't know which android drawable suffix to use for asset: ${JSON.stringify(asset)}`);
46
+ }
47
+ const androidFolder = `drawable-${suffix}`;
48
+ return androidFolder;
49
+ }
50
+ function getResourceIdentifier(asset) {
51
+ const folderPath = getBasePath(asset);
52
+ return `${folderPath}/${asset.name}`
53
+ .toLowerCase()
54
+ .replace(/\//g, '_') // Encode folder structure in file name
55
+ .replace(/([^a-z0-9_])/g, '') // Remove illegal chars
56
+ .replace(/^assets_/, ''); // Remove "assets_" prefix
57
+ }
58
+ function getBasePath(asset) {
59
+ let basePath = asset.httpServerLocation;
60
+ if (basePath[0] === '/') {
61
+ basePath = basePath.substr(1);
62
+ }
63
+ return basePath;
64
+ }
65
+ export default {
66
+ drawableFileTypes,
67
+ getAndroidAssetSuffix,
68
+ getAndroidResourceFolderName,
69
+ getResourceIdentifier,
70
+ getBasePath,
71
+ };
72
+ //# sourceMappingURL=assetPathUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assetPathUtils.js","sourceRoot":"","sources":["../../../../src/lib/bundle/assetPathUtils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH;;;GAGG;AACH,SAAS,qBAAqB,CAAC,KAAa;IAC1C,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,IAAI;YACP,OAAO,MAAM,C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IAAI,QAAQ,GAAG,KAAK,CAAC,kBAAkB,CAAC;IACxC,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACxB,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,eAAe;IACb,iBAAiB;IACjB,qBAAqB;IACrB,4BAA4B;IAC5B,qBAAqB;IACrB,WAAW;CACZ,CAAC"}
@@ -0,0 +1,57 @@
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
+ */
8
+ import type { RunBuildOptions } from 'metro';
9
+ import type { ConfigT } from 'metro-config';
10
+ export type BundleCommandArgs = {
11
+ assetsDest?: string;
12
+ assetCatalogDest?: string;
13
+ entryFile: string;
14
+ resetCache: boolean;
15
+ resetGlobalCache: boolean;
16
+ transformer?: string;
17
+ minify?: boolean;
18
+ config?: string;
19
+ platform: string;
20
+ dev: boolean;
21
+ bundleOutput: string;
22
+ bundleEncoding?: 'utf8' | 'utf16le' | 'ascii';
23
+ maxWorkers?: string;
24
+ sourcemapOutput?: string;
25
+ sourcemapSourcesRoot?: string;
26
+ sourcemapUseAbsolutePath: boolean;
27
+ verbose: boolean;
28
+ unstableTransformProfile: 'hermes-stable' | 'hermes-canary' | 'default';
29
+ indexedRamBundle?: boolean;
30
+ resolverOption?: Array<string>;
31
+ hermes: boolean;
32
+ };
33
+ export type Config = {
34
+ root: string;
35
+ reactNativeVersion: string;
36
+ reactNativePath: string;
37
+ platforms: Record<string, object>;
38
+ };
39
+ declare function buildBundle(options: {
40
+ platforms: Record<string, object>;
41
+ reactNativeVersion: string;
42
+ reactNativePath: string;
43
+ root: string;
44
+ }, args: BundleCommandArgs, bundleImpl?: RunBuildOptions['output']): Promise<void>;
45
+ declare function buildBundleWithConfig(args: BundleCommandArgs, config: ConfigT, bundleImpl?: RunBuildOptions['output']): Promise<void>;
46
+ /**
47
+ * UNSTABLE: This function is likely to be relocated and its API changed in
48
+ * the near future. `@react-native/community-cli-plugin` should not be directly
49
+ * depended on by projects or integrators -- this is exported for legacy
50
+ * compatibility.
51
+ *
52
+ * Create a bundle using a pre-loaded Metro config. The config can be
53
+ * re-used for several bundling calls if multiple platforms are being
54
+ * bundled.
55
+ */
56
+ export declare const unstable_buildBundleWithConfig: typeof buildBundleWithConfig;
57
+ export default buildBundle;
@@ -0,0 +1,99 @@
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
+ */
8
+ import { promises as fs } from 'fs';
9
+ import { runBuild } from 'metro';
10
+ import path from 'path';
11
+ import loadMetroConfig from '../../utils/loadMetroConfig.js';
12
+ import parseKeyValueParamArray from '../../utils/parseKeyValueParamArray.js';
13
+ import saveAssets from './saveAssets.js';
14
+ // import { styleText } from 'util'; // Not available in all Node versions
15
+ function styleText(style, text) {
16
+ const styles = {
17
+ red: '\x1b[31m',
18
+ bold: '\x1b[1m',
19
+ reset: '\x1b[0m',
20
+ };
21
+ const colorCode = styles[style] || '';
22
+ return `${colorCode}${text}${styles.reset}`;
23
+ }
24
+ async function buildBundle(options, args, bundleImpl) {
25
+ const config = await loadMetroConfig({
26
+ platforms: options.platforms,
27
+ reactNativeVersion: options.reactNativeVersion,
28
+ reactNativePath: options.reactNativePath,
29
+ root: options.root,
30
+ }, {
31
+ maxWorkers: args.maxWorkers,
32
+ resetCache: args.resetCache,
33
+ config: args.config,
34
+ });
35
+ return buildBundleWithConfig(args, config, bundleImpl);
36
+ }
37
+ async function buildBundleWithConfig(args, config, bundleImpl) {
38
+ const customResolverOptions = parseKeyValueParamArray(args.resolverOption ?? []);
39
+ if (config.resolver.platforms.indexOf(args.platform) === -1) {
40
+ console.error(`${styleText('red', 'error')}: Invalid platform ${args.platform ? `"${styleText('bold', args.platform)}" ` : ''}selected.`);
41
+ console.info(`Available platforms are: ${config.resolver.platforms
42
+ .map((x) => `"${styleText('bold', x)}"`)
43
+ .join(', ')}. If you are trying to bundle for an out-of-tree platform, it may not be installed.`);
44
+ throw new Error('Bundling failed');
45
+ }
46
+ // This is used by a bazillion of npm modules we don't control so we don't
47
+ // have other choice than defining it as an env variable here.
48
+ process.env['NODE_ENV'] = args.dev ? 'development' : 'production';
49
+ let sourceMapUrl = args.sourcemapOutput;
50
+ if (sourceMapUrl != null && !args.sourcemapUseAbsolutePath) {
51
+ sourceMapUrl = path.basename(sourceMapUrl);
52
+ }
53
+ const runBuildOptions = {
54
+ // @ts-expect-error - missing type, available in Flow types
55
+ bundleOut: args.bundleOutput,
56
+ customResolverOptions,
57
+ dev: args.dev,
58
+ entry: args.entryFile,
59
+ minify: args.minify !== undefined ? args.minify : !args.dev,
60
+ output: bundleImpl,
61
+ platform: args.platform,
62
+ sourceMap: args.sourcemapOutput != null,
63
+ sourceMapOut: args.sourcemapOutput,
64
+ sourceMapUrl,
65
+ unstable_transformProfile: args.unstableTransformProfile,
66
+ };
67
+ // Ensure destination directory exists before running the build
68
+ await fs.mkdir(path.dirname(args.bundleOutput), {
69
+ recursive: true,
70
+ mode: 0o755,
71
+ });
72
+ const result = await runBuild(config, runBuildOptions);
73
+ if (args.assetsDest == null) {
74
+ console.warn('Warning: Assets destination folder is not set, skipping...');
75
+ return;
76
+ }
77
+ // Save the assets of the bundle
78
+ // @ts-expect-error - runBuild returns result with assets
79
+ if (!result || !result.assets) {
80
+ throw new Error("Assets missing from Metro's runBuild result");
81
+ }
82
+ // @ts-expect-error - runBuild returns result with assets
83
+ const outputAssets = result.assets;
84
+ // When we're done saving bundle output and the assets, we're done.
85
+ await saveAssets(outputAssets, args.platform, args.assetsDest, args.assetCatalogDest);
86
+ }
87
+ /**
88
+ * UNSTABLE: This function is likely to be relocated and its API changed in
89
+ * the near future. `@react-native/community-cli-plugin` should not be directly
90
+ * depended on by projects or integrators -- this is exported for legacy
91
+ * compatibility.
92
+ *
93
+ * Create a bundle using a pre-loaded Metro config. The config can be
94
+ * re-used for several bundling calls if multiple platforms are being
95
+ * bundled.
96
+ */
97
+ export const unstable_buildBundleWithConfig = buildBundleWithConfig;
98
+ export default buildBundle;
99
+ //# sourceMappingURL=buildBundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildBundle.js","sourceRoot":"","sources":["../../../../src/lib/bundle/buildBundle.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,eAAe,MAAM,gCAAgC,CAAC;AAC7D,OAAO,uBAAuB,MAAM,wCAAwC,CAAC;AAC7E,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,0EAA0E;AAC1E,SAAS,SAAS,CAAC,KAAa,EAAE,IAAY;IAC5C,MAAM,MAAM,GAAG;QACb,GAAG,EAAE,UAAU;QACf,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB,CAAC;IACF,MAAM,SAAS,GAAG,MAAM,CAAC,KAA4B,CAAC,IAAI,EAAE,CAAC;IAC7D,OAAO,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;AAC9C,CAAC;AAkCD,KAAK,UAAU,WAAW,CACxB,OAKC,EACD,IAAuB,EACvB,UAAsC;IAEtC,MAAM,MAAM,GAAG,MAAM,eAAe,CAClC;QACE,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,EACD;QACE,UAAU,EAAE,IAAI,CAAC,U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b,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,gBAAgB,CACtB,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,qBAAqB,CAAC;AAEpE,eAAe,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/lib/bundle/command.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAoC9C,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,SAAS,QA0DnD"}
@@ -0,0 +1,10 @@
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
+ */
8
+ import type { AssetData } from 'metro';
9
+ declare function createKeepFileAsync(assets: ReadonlyArray<AssetData>, outputDirectory: string): Promise<void>;
10
+ export default createKeepFileAsync;
@@ -0,0 +1,28 @@
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
+ */
8
+ import fs from 'fs';
9
+ import path from 'path';
10
+ import assetPathUtils from './assetPathUtils.js';
11
+ async function createKeepFileAsync(assets, outputDirectory) {
12
+ if (!assets.length) {
13
+ return;
14
+ }
15
+ const assetsList = [];
16
+ for (const asset of assets) {
17
+ const prefix = assetPathUtils.drawableFileTypes.has(asset.type)
18
+ ? 'drawable'
19
+ : 'raw';
20
+ assetsList.push(`@${prefix}/${assetPathUtils.getResourceIdentifier(asset)}`);
21
+ }
22
+ const keepPath = path.join(outputDirectory, 'raw/keep.xml');
23
+ const content = `<resources xmlns:tools="http://schemas.android.com/tools" tools:keep="${assetsList.join(',')}" />\n`;
24
+ await fs.promises.mkdir(path.dirname(keepPath), { recursive: true });
25
+ await fs.promises.writeFile(keepPath, content);
26
+ }
27
+ export default createKeepFileAsync;
28
+ //# sourceMappingURL=createKeepFileAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createKeepFileAsync.js","sourceRoot":"","sources":["../../../../src/lib/bundle/createKeepFileAsync.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,KAAK,UAAU,mBAAmB,CAChC,MAAgC,EAChC,eAAuB;IAEvB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACnB,OAAO;IACT,CAAC;IACD,MAAM,UAAU,GAAG,EAAE,CAAC;IACtB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,cAAc,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;YAC7D,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,KAAK,CAAC;QACV,UAAU,CAAC,IAAI,CACb,IAAI,MAAM,IAAI,cAAc,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAC5D,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,yEAAyE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;IACtH,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACrE,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAED,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,9 @@
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
+ */
8
+ declare function filterPlatformAssetScales(platform: string, scales: ReadonlyArray<number>): ReadonlyArray<number>;
9
+ export default filterPlatformAssetScales;
@@ -0,0 +1,36 @@
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
+ */
8
+ const ALLOWED_SCALES = {
9
+ ios: [1, 2, 3],
10
+ };
11
+ function filterPlatformAssetScales(platform, scales) {
12
+ const whitelist = ALLOWED_SCALES[platform];
13
+ if (!whitelist) {
14
+ return scales;
15
+ }
16
+ const result = scales.filter((scale) => whitelist.indexOf(scale) > -1);
17
+ if (result.length === 0 && scales.length > 0) {
18
+ // No matching scale found, but there are some available. Ideally we don't
19
+ // want to be in this situation and should throw, but for now as a fallback
20
+ // let's just use the closest larger image
21
+ const maxScale = whitelist[whitelist.length - 1];
22
+ for (const scale of scales) {
23
+ if (scale > maxScale) {
24
+ result.push(scale);
25
+ break;
26
+ }
27
+ }
28
+ // There is no larger scales available, use the largest we have
29
+ if (result.length === 0) {
30
+ result.push(scales[scales.length - 1]);
31
+ }
32
+ }
33
+ return result;
34
+ }
35
+ export default filterPlatformAssetScales;
36
+ //# sourceMappingURL=filterPlatformAssetScales.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterPlatformAssetScales.js","sourceRoot":"","sources":["../../../../src/lib/bundle/filterPlatformAssetScales.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,cAAc,GAAgC;IAClD,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;CACf,CAAC;AAEF,SAAS,yBAAyB,CAChC,QAAgB,EAChB,MAA6B;IAE7B,MAAM,SAAS,GAAa,cAAc,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACvE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7C,0EAA0E;QAC1E,2EAA2E;QAC3E,0CAA0C;QAC1C,MAAM,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,KAAK,GAAG,QAAQ,EAAE,CAAC;gBACrB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACnB,MAAM;YACR,CAAC;QACH,CAAC;QAED,+DAA+D;QAC/D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,eAAe,yBAAyB,CAAC"}
@@ -0,0 +1,10 @@
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
+ */
8
+ import type { PackagerAsset } from './assetPathUtils.js';
9
+ declare function getAssetDestPathAndroid(asset: PackagerAsset, scale: number): string;
10
+ export default getAssetDestPathAndroid;
@@ -0,0 +1,16 @@
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
+ */
8
+ import path from 'path';
9
+ import assetPathUtils from './assetPathUtils.js';
10
+ function getAssetDestPathAndroid(asset, scale) {
11
+ const androidFolder = assetPathUtils.getAndroidResourceFolderName(asset, scale);
12
+ const fileName = assetPathUtils.getResourceIdentifier(asset);
13
+ return path.join(androidFolder, `${fileName}.${asset.type}`);
14
+ }
15
+ export default getAssetDestPathAndroid;
16
+ //# sourceMappingURL=getAssetDestPathAndroid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAssetDestPathAndroid.js","sourceRoot":"","sources":["../../../../src/lib/bundle/getAssetDestPathAndroid.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,SAAS,uBAAuB,CAAC,KAAoB,EAAE,KAAa;IAClE,MAAM,aAAa,GAAG,cAAc,CAAC,4BAA4B,CAC/D,KAAK,EACL,KAAK,CACN,CAAC;IACF,MAAM,QAAQ,GAAG,cAAc,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC7D,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,10 @@
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
+ */
8
+ import type { PackagerAsset } from './assetPathUtils.js';
9
+ declare function getAssetDestPathIOS(asset: PackagerAsset, scale: number): string;
10
+ export default getAssetDestPathIOS;
@@ -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
+ */
8
+ import path from 'path';
9
+ function getAssetDestPathIOS(asset, scale) {
10
+ const suffix = scale === 1 ? '' : `@${scale}x`;
11
+ const fileName = `${asset.name + suffix}.${asset.type}`;
12
+ return path.join(
13
+ // Assets can have relative paths outside of the project root.
14
+ // Replace `../` with `_` to make sure they don't end up outside of
15
+ // the expected assets directory.
16
+ asset.httpServerLocation.substr(1).replace(/\.\.\//g, '_'), fileName);
17
+ }
18
+ export default getAssetDestPathIOS;
19
+ //# sourceMappingURL=getAssetDestPathIOS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAssetDestPathIOS.js","sourceRoot":"","sources":["../../../../src/lib/bundle/getAssetDestPathIOS.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,SAAS,mBAAmB,CAAC,KAAoB,EAAE,KAAa;IAC9D,MAAM,MAAM,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC;IAC/C,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,IAAI,GAAG,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;IACxD,OAAO,IAAI,CAAC,IAAI;IACd,8DAA8D;IAC9D,mEAAmE;IACnE,iCAAiC;IACjC,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,EAC1D,QAAQ,CACT,CAAC;AACJ,CAAC;AAED,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,11 @@
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
+ */
8
+ import type { CommandType } from '@rnef/config';
9
+ export type { BundleCommandArgs } from './buildBundle.js';
10
+ declare const bundleCommand: CommandType;
11
+ export { bundleCommand };