@expo/prebuild-config 6.2.0 → 6.2.2

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.
@@ -1,4 +1,4 @@
1
- export type ContentsJsonImageIdiom = 'iphone' | 'ipad' | 'ios-marketing' | 'universal';
1
+ export type ContentsJsonImageIdiom = 'iphone' | 'ipad' | 'watchos' | 'ios' | 'ios-marketing' | 'universal';
2
2
  export type ContentsJsonImageAppearance = {
3
3
  appearance: 'luminosity';
4
4
  value: 'dark';
@@ -8,8 +8,9 @@ export interface ContentsJsonImage {
8
8
  appearances?: ContentsJsonImageAppearance[];
9
9
  idiom: ContentsJsonImageIdiom;
10
10
  size?: string;
11
- scale: ContentsJsonImageScale;
11
+ scale?: ContentsJsonImageScale;
12
12
  filename?: string;
13
+ platform?: ContentsJsonImageIdiom;
13
14
  }
14
15
  export interface ContentsJson {
15
16
  images: ContentsJsonImage[];
@@ -1 +1 @@
1
- {"version":3,"file":"AssetContents.js","names":["_fsExtra","data","_interopRequireDefault","require","_path","obj","__esModule","default","createContentsJsonItem","item","writeContentsJsonAsync","directory","images","fs","ensureDir","writeFile","join","JSON","stringify","info","version","author"],"sources":["../../../src/plugins/icons/AssetContents.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport { join } from 'path';\n\nexport type ContentsJsonImageIdiom = 'iphone' | 'ipad' | 'ios-marketing' | 'universal';\n\nexport type ContentsJsonImageAppearance = {\n appearance: 'luminosity';\n value: 'dark';\n};\n\nexport type ContentsJsonImageScale = '1x' | '2x' | '3x';\n\nexport interface ContentsJsonImage {\n appearances?: ContentsJsonImageAppearance[];\n idiom: ContentsJsonImageIdiom;\n size?: string;\n scale: ContentsJsonImageScale;\n filename?: string;\n}\n\nexport interface ContentsJson {\n images: ContentsJsonImage[];\n info: {\n version: number;\n author: string;\n };\n}\n\nexport function createContentsJsonItem(item: ContentsJsonImage): ContentsJsonImage {\n return item;\n}\n\n/**\n * Writes the Config.json which is used to assign images to their respective platform, dpi, and idiom.\n *\n * @param directory path to add the Contents.json to.\n * @param contents image json data\n */\nexport async function writeContentsJsonAsync(\n directory: string,\n { images }: Pick<ContentsJson, 'images'>\n): Promise<void> {\n await fs.ensureDir(directory);\n\n await fs.writeFile(\n join(directory, 'Contents.json'),\n JSON.stringify(\n {\n images,\n info: {\n version: 1,\n // common practice is for the tool that generated the icons to be the \"author\"\n author: 'expo',\n },\n },\n null,\n 2\n )\n );\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA4B,SAAAC,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA2BrB,SAASG,sBAAsBA,CAACC,IAAuB,EAAqB;EACjF,OAAOA,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeC,sBAAsBA,CAC1CC,SAAiB,EACjB;EAAEC;AAAqC,CAAC,EACzB;EACf,MAAMC,kBAAE,CAACC,SAAS,CAACH,SAAS,CAAC;EAE7B,MAAME,kBAAE,CAACE,SAAS,CAChB,IAAAC,YAAI,EAACL,SAAS,EAAE,eAAe,CAAC,EAChCM,IAAI,CAACC,SAAS,CACZ;IACEN,MAAM;IACNO,IAAI,EAAE;MACJC,OAAO,EAAE,CAAC;MACV;MACAC,MAAM,EAAE;IACV;EACF,CAAC,EACD,IAAI,EACJ,CAAC,CACF,CACF;AACH"}
1
+ {"version":3,"file":"AssetContents.js","names":["_fsExtra","data","_interopRequireDefault","require","_path","obj","__esModule","default","createContentsJsonItem","item","writeContentsJsonAsync","directory","images","fs","ensureDir","writeFile","join","JSON","stringify","info","version","author"],"sources":["../../../src/plugins/icons/AssetContents.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport { join } from 'path';\n\nexport type ContentsJsonImageIdiom =\n | 'iphone'\n | 'ipad'\n | 'watchos'\n | 'ios'\n | 'ios-marketing'\n | 'universal';\n\nexport type ContentsJsonImageAppearance = {\n appearance: 'luminosity';\n value: 'dark';\n};\n\nexport type ContentsJsonImageScale = '1x' | '2x' | '3x';\n\nexport interface ContentsJsonImage {\n appearances?: ContentsJsonImageAppearance[];\n idiom: ContentsJsonImageIdiom;\n size?: string;\n scale?: ContentsJsonImageScale;\n filename?: string;\n platform?: ContentsJsonImageIdiom;\n}\n\nexport interface ContentsJson {\n images: ContentsJsonImage[];\n info: {\n version: number;\n author: string;\n };\n}\n\nexport function createContentsJsonItem(item: ContentsJsonImage): ContentsJsonImage {\n return item;\n}\n\n/**\n * Writes the Config.json which is used to assign images to their respective platform, dpi, and idiom.\n *\n * @param directory path to add the Contents.json to.\n * @param contents image json data\n */\nexport async function writeContentsJsonAsync(\n directory: string,\n { images }: Pick<ContentsJson, 'images'>\n): Promise<void> {\n await fs.ensureDir(directory);\n\n await fs.writeFile(\n join(directory, 'Contents.json'),\n JSON.stringify(\n {\n images,\n info: {\n version: 1,\n // common practice is for the tool that generated the icons to be the \"author\"\n author: 'expo',\n },\n },\n null,\n 2\n )\n );\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA4B,SAAAC,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAkCrB,SAASG,sBAAsBA,CAACC,IAAuB,EAAqB;EACjF,OAAOA,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeC,sBAAsBA,CAC1CC,SAAiB,EACjB;EAAEC;AAAqC,CAAC,EACzB;EACf,MAAMC,kBAAE,CAACC,SAAS,CAACH,SAAS,CAAC;EAE7B,MAAME,kBAAE,CAACE,SAAS,CAChB,IAAAC,YAAI,EAACL,SAAS,EAAE,eAAe,CAAC,EAChCM,IAAI,CAACC,SAAS,CACZ;IACEN,MAAM;IACNO,IAAI,EAAE;MACJC,OAAO,EAAE,CAAC;MACV;MACAC,MAAM,EAAE;IACV;EACF,CAAC,EACD,IAAI,EACJ,CAAC,CACF,CACF;AACH"}
@@ -1,13 +1,12 @@
1
1
  import { ConfigPlugin } from '@expo/config-plugins';
2
2
  import { ExpoConfig } from '@expo/config-types';
3
- import { ContentsJsonImageIdiom } from './AssetContents';
3
+ import { ContentsJson } from './AssetContents';
4
4
  export declare const withIosIcons: ConfigPlugin;
5
- export declare const ICON_CONTENTS: {
6
- idiom: ContentsJsonImageIdiom;
7
- sizes: {
8
- size: number;
9
- scales: (1 | 2 | 3)[];
10
- }[];
11
- }[];
12
5
  export declare function getIcons(config: Pick<ExpoConfig, 'icon' | 'ios'>): string | null;
13
6
  export declare function setIconsAsync(config: ExpoConfig, projectRoot: string): Promise<void>;
7
+ export declare function generateUniversalIconAsync(projectRoot: string, { icon, cacheKey, iosNamedProjectRoot, platform, }: {
8
+ platform: 'watchos' | 'ios';
9
+ icon: string;
10
+ iosNamedProjectRoot: string;
11
+ cacheKey: string;
12
+ }): Promise<ContentsJson['images']>;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ICON_CONTENTS = void 0;
6
+ exports.generateUniversalIconAsync = generateUniversalIconAsync;
7
7
  exports.getIcons = getIcons;
8
8
  exports.setIconsAsync = setIconsAsync;
9
9
  exports.withIosIcons = void 0;
@@ -47,6 +47,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
47
47
  const {
48
48
  getProjectName
49
49
  } = _configPlugins().IOSConfig.XcodeUtils;
50
+ const IMAGE_CACHE_NAME = 'icons';
51
+ const IMAGESET_PATH = 'Images.xcassets/AppIcon.appiconset';
50
52
  const withIosIcons = config => {
51
53
  return (0, _configPlugins().withDangerousMod)(config, ['ios', async config => {
52
54
  await setIconsAsync(config, config.modRequest.projectRoot);
@@ -54,57 +56,6 @@ const withIosIcons = config => {
54
56
  }]);
55
57
  };
56
58
  exports.withIosIcons = withIosIcons;
57
- const IMAGE_CACHE_NAME = 'icons';
58
- const IMAGESET_PATH = 'Images.xcassets/AppIcon.appiconset';
59
-
60
- // Hard-coding seemed like the clearest and safest way to implement the sizes.
61
- const ICON_CONTENTS = [{
62
- idiom: 'iphone',
63
- sizes: [{
64
- size: 20,
65
- scales: [2, 3]
66
- }, {
67
- size: 29,
68
- scales: [1, 2, 3]
69
- }, {
70
- size: 40,
71
- scales: [2, 3]
72
- }, {
73
- size: 60,
74
- scales: [2, 3]
75
- }
76
- // TODO: 76x76@2x seems unused now
77
- // {
78
- // size: 76,
79
- // scales: [2],
80
- // },
81
- ]
82
- }, {
83
- idiom: 'ipad',
84
- sizes: [{
85
- size: 20,
86
- scales: [1, 2]
87
- }, {
88
- size: 29,
89
- scales: [1, 2]
90
- }, {
91
- size: 40,
92
- scales: [1, 2]
93
- }, {
94
- size: 76,
95
- scales: [1, 2]
96
- }, {
97
- size: 83.5,
98
- scales: [2]
99
- }]
100
- }, {
101
- idiom: 'ios-marketing',
102
- sizes: [{
103
- size: 1024,
104
- scales: [1]
105
- }]
106
- }];
107
- exports.ICON_CONTENTS = ICON_CONTENTS;
108
59
  function getIcons(config) {
109
60
  var _config$ios;
110
61
  // No support for empty strings.
@@ -124,58 +75,12 @@ async function setIconsAsync(config, projectRoot) {
124
75
  await fs().ensureDir((0, _path().join)(iosNamedProjectRoot, IMAGESET_PATH));
125
76
 
126
77
  // Store the image JSON data for assigning via the Contents.json
127
- const imagesJson = [];
128
-
129
- // keep track of icons that have been generated so we can reuse them in the Contents.json
130
- const generatedIcons = {};
131
- for (const platform of ICON_CONTENTS) {
132
- const isMarketing = platform.idiom === 'ios-marketing';
133
- for (const {
134
- size,
135
- scales
136
- } of platform.sizes) {
137
- for (const scale of scales) {
138
- // The marketing icon is special because it makes no sense.
139
- const filename = isMarketing ? 'ItunesArtwork@2x.png' : getAppleIconName(size, scale);
140
- // Only create an image that hasn't already been generated.
141
- if (!(filename in generatedIcons)) {
142
- const iconSizePx = size * scale;
143
-
144
- // Using this method will cache the images in `.expo` based on the properties used to generate them.
145
- // this method also supports remote URLs and using the global sharp instance.
146
- const {
147
- source
148
- } = await (0, _imageUtils().generateImageAsync)({
149
- projectRoot,
150
- cacheType: IMAGE_CACHE_NAME
151
- }, {
152
- src: icon,
153
- name: filename,
154
- width: iconSizePx,
155
- height: iconSizePx,
156
- removeTransparency: true,
157
- // The icon should be square, but if it's not then it will be cropped.
158
- resizeMode: 'cover',
159
- // Force the background color to solid white to prevent any transparency.
160
- // TODO: Maybe use a more adaptive option based on the icon color?
161
- backgroundColor: '#ffffff'
162
- });
163
- // Write image buffer to the file system.
164
- const assetPath = (0, _path().join)(iosNamedProjectRoot, IMAGESET_PATH, filename);
165
- await fs().writeFile(assetPath, source);
166
- // Save a reference to the generated image so we don't create a duplicate.
167
- generatedIcons[filename] = true;
168
- }
169
- imagesJson.push({
170
- idiom: platform.idiom,
171
- size: `${size}x${size}`,
172
- // @ts-ignore: template types not supported in TS yet
173
- scale: `${scale}x`,
174
- filename
175
- });
176
- }
177
- }
178
- }
78
+ const imagesJson = await generateUniversalIconAsync(projectRoot, {
79
+ icon,
80
+ cacheKey: 'universal-icon',
81
+ iosNamedProjectRoot,
82
+ platform: 'ios'
83
+ });
179
84
 
180
85
  // Finally, write the Config.json
181
86
  await (0, _AssetContents().writeContentsJsonAsync)((0, _path().join)(iosNamedProjectRoot, IMAGESET_PATH), {
@@ -195,4 +100,41 @@ function getIosNamedProjectPath(projectRoot) {
195
100
  function getAppleIconName(size, scale) {
196
101
  return `App-Icon-${size}x${size}@${scale}x.png`;
197
102
  }
103
+ async function generateUniversalIconAsync(projectRoot, {
104
+ icon,
105
+ cacheKey,
106
+ iosNamedProjectRoot,
107
+ platform
108
+ }) {
109
+ const size = 1024;
110
+ const filename = getAppleIconName(size, 1);
111
+ // Using this method will cache the images in `.expo` based on the properties used to generate them.
112
+ // this method also supports remote URLs and using the global sharp instance.
113
+ const {
114
+ source
115
+ } = await (0, _imageUtils().generateImageAsync)({
116
+ projectRoot,
117
+ cacheType: IMAGE_CACHE_NAME + cacheKey
118
+ }, {
119
+ src: icon,
120
+ name: filename,
121
+ width: size,
122
+ height: size,
123
+ removeTransparency: true,
124
+ // The icon should be square, but if it's not then it will be cropped.
125
+ resizeMode: 'cover',
126
+ // Force the background color to solid white to prevent any transparency.
127
+ // TODO: Maybe use a more adaptive option based on the icon color?
128
+ backgroundColor: '#ffffff'
129
+ });
130
+ // Write image buffer to the file system.
131
+ const assetPath = (0, _path().join)(iosNamedProjectRoot, IMAGESET_PATH, filename);
132
+ await fs().writeFile(assetPath, source);
133
+ return [{
134
+ filename: getAppleIconName(size, 1),
135
+ idiom: 'universal',
136
+ platform,
137
+ size: `${size}x${size}`
138
+ }];
139
+ }
198
140
  //# sourceMappingURL=withIosIcons.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"withIosIcons.js","names":["_configPlugins","data","require","_imageUtils","fs","_interopRequireWildcard","_path","_AssetContents","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","getProjectName","IOSConfig","XcodeUtils","withIosIcons","config","withDangerousMod","setIconsAsync","modRequest","projectRoot","exports","IMAGE_CACHE_NAME","IMAGESET_PATH","ICON_CONTENTS","idiom","sizes","size","scales","getIcons","_config$ios","ios","icon","WarningAggregator","addWarningIOS","iosNamedProjectRoot","getIosNamedProjectPath","ensureDir","join","imagesJson","generatedIcons","platform","isMarketing","scale","filename","getAppleIconName","iconSizePx","source","generateImageAsync","cacheType","src","name","width","height","removeTransparency","resizeMode","backgroundColor","assetPath","writeFile","push","writeContentsJsonAsync","images","projectName"],"sources":["../../../src/plugins/icons/withIosIcons.ts"],"sourcesContent":["import { ConfigPlugin, IOSConfig, WarningAggregator, withDangerousMod } from '@expo/config-plugins';\nimport { ExpoConfig } from '@expo/config-types';\nimport { generateImageAsync } from '@expo/image-utils';\nimport * as fs from 'fs-extra';\nimport { join } from 'path';\n\nimport { ContentsJson, ContentsJsonImageIdiom, writeContentsJsonAsync } from './AssetContents';\n\nconst { getProjectName } = IOSConfig.XcodeUtils;\n\nexport const withIosIcons: ConfigPlugin = (config) => {\n return withDangerousMod(config, [\n 'ios',\n async (config) => {\n await setIconsAsync(config, config.modRequest.projectRoot);\n return config;\n },\n ]);\n};\n\nconst IMAGE_CACHE_NAME = 'icons';\nconst IMAGESET_PATH = 'Images.xcassets/AppIcon.appiconset';\n\n// Hard-coding seemed like the clearest and safest way to implement the sizes.\nexport const ICON_CONTENTS: {\n idiom: ContentsJsonImageIdiom;\n sizes: { size: number; scales: (1 | 2 | 3)[] }[];\n}[] = [\n {\n idiom: 'iphone',\n sizes: [\n {\n size: 20,\n scales: [2, 3],\n },\n {\n size: 29,\n scales: [1, 2, 3],\n },\n {\n size: 40,\n scales: [2, 3],\n },\n {\n size: 60,\n scales: [2, 3],\n },\n // TODO: 76x76@2x seems unused now\n // {\n // size: 76,\n // scales: [2],\n // },\n ],\n },\n {\n idiom: 'ipad',\n sizes: [\n {\n size: 20,\n scales: [1, 2],\n },\n {\n size: 29,\n scales: [1, 2],\n },\n {\n size: 40,\n scales: [1, 2],\n },\n {\n size: 76,\n scales: [1, 2],\n },\n {\n size: 83.5,\n scales: [2],\n },\n ],\n },\n {\n idiom: 'ios-marketing',\n sizes: [\n {\n size: 1024,\n scales: [1],\n },\n ],\n },\n];\n\nexport function getIcons(config: Pick<ExpoConfig, 'icon' | 'ios'>): string | null {\n // No support for empty strings.\n return config.ios?.icon || config.icon || null;\n}\n\nexport async function setIconsAsync(config: ExpoConfig, projectRoot: string) {\n const icon = getIcons(config);\n if (!icon) {\n WarningAggregator.addWarningIOS(\n 'icon',\n 'This is the image that your app uses on your home screen, you will need to configure it manually.'\n );\n return;\n }\n\n // Something like projectRoot/ios/MyApp/\n const iosNamedProjectRoot = getIosNamedProjectPath(projectRoot);\n\n // Ensure the Images.xcassets/AppIcon.appiconset path exists\n await fs.ensureDir(join(iosNamedProjectRoot, IMAGESET_PATH));\n\n // Store the image JSON data for assigning via the Contents.json\n const imagesJson: ContentsJson['images'] = [];\n\n // keep track of icons that have been generated so we can reuse them in the Contents.json\n const generatedIcons: Record<string, boolean> = {};\n\n for (const platform of ICON_CONTENTS) {\n const isMarketing = platform.idiom === 'ios-marketing';\n for (const { size, scales } of platform.sizes) {\n for (const scale of scales) {\n // The marketing icon is special because it makes no sense.\n const filename = isMarketing ? 'ItunesArtwork@2x.png' : getAppleIconName(size, scale);\n // Only create an image that hasn't already been generated.\n if (!(filename in generatedIcons)) {\n const iconSizePx = size * scale;\n\n // Using this method will cache the images in `.expo` based on the properties used to generate them.\n // this method also supports remote URLs and using the global sharp instance.\n const { source } = await generateImageAsync(\n { projectRoot, cacheType: IMAGE_CACHE_NAME },\n {\n src: icon,\n name: filename,\n width: iconSizePx,\n height: iconSizePx,\n removeTransparency: true,\n // The icon should be square, but if it's not then it will be cropped.\n resizeMode: 'cover',\n // Force the background color to solid white to prevent any transparency.\n // TODO: Maybe use a more adaptive option based on the icon color?\n backgroundColor: '#ffffff',\n }\n );\n // Write image buffer to the file system.\n const assetPath = join(iosNamedProjectRoot, IMAGESET_PATH, filename);\n await fs.writeFile(assetPath, source);\n // Save a reference to the generated image so we don't create a duplicate.\n generatedIcons[filename] = true;\n }\n imagesJson.push({\n idiom: platform.idiom,\n size: `${size}x${size}`,\n // @ts-ignore: template types not supported in TS yet\n scale: `${scale}x`,\n filename,\n });\n }\n }\n }\n\n // Finally, write the Config.json\n await writeContentsJsonAsync(join(iosNamedProjectRoot, IMAGESET_PATH), { images: imagesJson });\n}\n\n/**\n * Return the project's named iOS path: ios/MyProject/\n *\n * @param projectRoot Expo project root path.\n */\nfunction getIosNamedProjectPath(projectRoot: string): string {\n const projectName = getProjectName(projectRoot);\n return join(projectRoot, 'ios', projectName);\n}\n\nfunction getAppleIconName(size: number, scale: number): string {\n return `App-Icon-${size}x${size}@${scale}x.png`;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,GAAA;EAAA,MAAAH,IAAA,GAAAI,uBAAA,CAAAH,OAAA;EAAAE,EAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,eAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,cAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+F,SAAAO,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,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C;YAAE5B,WAAW;YAAE6B,SAAS,EAAE3B;UAAiB,CAAC,EAC5C;YACE4B,GAAG,EAAElB,IAAI;YACTmB,IAAI,EAAEP,QAAQ;YACdQ,KAAK,EAAEN,UAAU;YACjBO,MAAM,EAAEP,UAAU;YAClBQ,kBAAkB,EAAE,IAAI;YACxB;YACAC,UAAU,EAAE,OAAO;YACnB;YACA;YACAC,eAAe,EAAE;UACnB,CAAC,CACF;UACD;UACA,MAAMC,SAAS,GAAG,IAAAnB,YAAI,EAACH,mBAAmB,EAAEZ,aAAa,EAAEqB,QAAQ,CAAC;UACpE,MAAM1D,EAAE,GAACwE,SAAS,CAACD,SAAS,EAAEV,MAAM,CAAC;UACrC;UACAP,cAAc,CAACI,QAAQ,CAAC,GAAG,IAAI;QACjC;QACAL,UAAU,CAACoB,IAAI,CAAC;UACdlC,KAAK,EAAEgB,QAAQ,CAAChB,KAAK;UACrBE,IAAI,EAAG,GAAEA,IAAK,IAAGA,IAAK,EAAC;UACvB;UACAgB,KAAK,EAAG,GAAEA,KAAM,GAAE;UAClBC;QACF,CAAC,CAAC;MACJ;IACF;EACF;;EAEA;EACA,MAAM,IAAAgB,uCAAsB,EAAC,IAAAtB,YAAI,EAACH,mBAAmB,EAAEZ,aAAa,CAAC,EAAE;IAAEsC,MAAM,EAAEtB;EAAW,CAAC,CAAC;AAChG;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASH,sBAAsBA,CAAChB,WAAmB,EAAU;EAC3D,MAAM0C,WAAW,GAAGlD,cAAc,CAACQ,WAAW,CAAC;EAC/C,OAAO,IAAAkB,YAAI,EAAClB,WAAW,EAAE,KAAK,EAAE0C,WAAW,CAAC;AAC9C;AAEA,SAASjB,gBAAgBA,CAAClB,IAAY,EAAEgB,KAAa,EAAU;EAC7D,OAAQ,YAAWhB,IAAK,IAAGA,IAAK,IAAGgB,KAAM,OAAM;AACjD"}
1
+ {"version":3,"file":"withIosIcons.js","names":["_configPlugins","data","require","_imageUtils","fs","_interopRequireWildcard","_path","_AssetContents","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","getProjectName","IOSConfig","XcodeUtils","IMAGE_CACHE_NAME","IMAGESET_PATH","withIosIcons","config","withDangerousMod","setIconsAsync","modRequest","projectRoot","exports","getIcons","_config$ios","ios","icon","WarningAggregator","addWarningIOS","iosNamedProjectRoot","getIosNamedProjectPath","ensureDir","join","imagesJson","generateUniversalIconAsync","cacheKey","platform","writeContentsJsonAsync","images","projectName","getAppleIconName","size","scale","filename","source","generateImageAsync","cacheType","src","name","width","height","removeTransparency","resizeMode","backgroundColor","assetPath","writeFile","idiom"],"sources":["../../../src/plugins/icons/withIosIcons.ts"],"sourcesContent":["import { ConfigPlugin, IOSConfig, WarningAggregator, withDangerousMod } from '@expo/config-plugins';\nimport { ExpoConfig } from '@expo/config-types';\nimport { generateImageAsync } from '@expo/image-utils';\nimport * as fs from 'fs-extra';\nimport { join } from 'path';\n\nimport { ContentsJson, writeContentsJsonAsync } from './AssetContents';\n\nconst { getProjectName } = IOSConfig.XcodeUtils;\n\nconst IMAGE_CACHE_NAME = 'icons';\nconst IMAGESET_PATH = 'Images.xcassets/AppIcon.appiconset';\n\nexport const withIosIcons: ConfigPlugin = (config) => {\n return withDangerousMod(config, [\n 'ios',\n async (config) => {\n await setIconsAsync(config, config.modRequest.projectRoot);\n return config;\n },\n ]);\n};\n\nexport function getIcons(config: Pick<ExpoConfig, 'icon' | 'ios'>): string | null {\n // No support for empty strings.\n return config.ios?.icon || config.icon || null;\n}\n\nexport async function setIconsAsync(config: ExpoConfig, projectRoot: string) {\n const icon = getIcons(config);\n if (!icon) {\n WarningAggregator.addWarningIOS(\n 'icon',\n 'This is the image that your app uses on your home screen, you will need to configure it manually.'\n );\n return;\n }\n\n // Something like projectRoot/ios/MyApp/\n const iosNamedProjectRoot = getIosNamedProjectPath(projectRoot);\n\n // Ensure the Images.xcassets/AppIcon.appiconset path exists\n await fs.ensureDir(join(iosNamedProjectRoot, IMAGESET_PATH));\n\n // Store the image JSON data for assigning via the Contents.json\n const imagesJson: ContentsJson['images'] = await generateUniversalIconAsync(projectRoot, {\n icon,\n cacheKey: 'universal-icon',\n iosNamedProjectRoot,\n platform: 'ios',\n });\n\n // Finally, write the Config.json\n await writeContentsJsonAsync(join(iosNamedProjectRoot, IMAGESET_PATH), { images: imagesJson });\n}\n\n/**\n * Return the project's named iOS path: ios/MyProject/\n *\n * @param projectRoot Expo project root path.\n */\nfunction getIosNamedProjectPath(projectRoot: string): string {\n const projectName = getProjectName(projectRoot);\n return join(projectRoot, 'ios', projectName);\n}\n\nfunction getAppleIconName(size: number, scale: number): string {\n return `App-Icon-${size}x${size}@${scale}x.png`;\n}\n\nexport async function generateUniversalIconAsync(\n projectRoot: string,\n {\n icon,\n cacheKey,\n iosNamedProjectRoot,\n platform,\n }: { platform: 'watchos' | 'ios'; icon: string; iosNamedProjectRoot: string; cacheKey: string }\n): Promise<ContentsJson['images']> {\n const size = 1024;\n const filename = getAppleIconName(size, 1);\n // Using this method will cache the images in `.expo` based on the properties used to generate them.\n // this method also supports remote URLs and using the global sharp instance.\n const { source } = await generateImageAsync(\n { projectRoot, cacheType: IMAGE_CACHE_NAME + cacheKey },\n {\n src: icon,\n name: filename,\n width: size,\n height: size,\n removeTransparency: true,\n // The icon should be square, but if it's not then it will be cropped.\n resizeMode: 'cover',\n // Force the background color to solid white to prevent any transparency.\n // TODO: Maybe use a more adaptive option based on the icon color?\n backgroundColor: '#ffffff',\n }\n );\n // Write image buffer to the file system.\n const assetPath = join(iosNamedProjectRoot, IMAGESET_PATH, filename);\n await fs.writeFile(assetPath, source);\n\n return [\n {\n filename: getAppleIconName(size, 1),\n idiom: 'universal',\n platform,\n size: `${size}x${size}`,\n },\n ];\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,eAAA;EAAA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,GAAG,EAAErB,IAAI;IACTsB,IAAI,EAAEL,QAAQ;IACdM,KAAK,EAAER,IAAI;IACXS,MAAM,EAAET,IAAI;IACZU,kBAAkB,EAAE,IAAI;IACxB;IACAC,UAAU,EAAE,OAAO;IACnB;IACA;IACAC,eAAe,EAAE;EACnB,CAAC,CACF;EACD;EACA,MAAMC,SAAS,GAAG,IAAAtB,YAAI,EAACH,mBAAmB,EAAEd,aAAa,EAAE4B,QAAQ,CAAC;EACpE,MAAM1D,EAAE,GAACsE,SAAS,CAACD,SAAS,EAAEV,MAAM,CAAC;EAErC,OAAO,CACL;IACED,QAAQ,EAAEH,gBAAgB,CAACC,IAAI,EAAE,CAAC,CAAC;IACnCe,KAAK,EAAE,WAAW;IAClBpB,QAAQ;IACRK,IAAI,EAAG,GAAEA,IAAK,IAAGA,IAAK;EACxB,CAAC,CACF;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/prebuild-config",
3
- "version": "6.2.0",
3
+ "version": "6.2.2",
4
4
  "description": "Get the prebuild config",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -52,5 +52,5 @@
52
52
  "publishConfig": {
53
53
  "access": "public"
54
54
  },
55
- "gitHead": "fa5ecca8251986b9f197cc14074eec0ab6dfb6db"
55
+ "gitHead": "a72ae33519fe54eaf195dc3e61a49db8345103db"
56
56
  }