react-native-bootsplash 4.7.4 β†’ 5.0.0-beta.0

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 (54) hide show
  1. package/README.md +214 -107
  2. package/RNBootSplash.podspec +11 -11
  3. package/android/.npmignore +11 -0
  4. package/android/build.gradle +0 -1
  5. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplash.java +3 -2
  6. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashDialog.java +49 -0
  7. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModuleImpl.java +157 -87
  8. package/android/src/main/res/anim/bootsplash_fade_in.xml +7 -0
  9. package/android/src/main/res/anim/bootsplash_fade_out.xml +7 -0
  10. package/android/src/main/res/drawable/compat_splash_screen.xml +19 -0
  11. package/android/src/main/res/values/attrs.xml +8 -0
  12. package/android/src/main/res/values/public.xml +7 -0
  13. package/android/src/main/res/values/styles.xml +29 -0
  14. package/android/src/main/res/values-v31/styles.xml +7 -0
  15. package/android/src/newarch/com/zoontek/rnbootsplash/RNBootSplashModule.java +11 -4
  16. package/android/src/oldarch/com/zoontek/rnbootsplash/RNBootSplashModule.java +13 -4
  17. package/dist/commonjs/NativeRNBootSplash.js.map +1 -1
  18. package/dist/commonjs/addon/index.js +3 -0
  19. package/dist/commonjs/addon/index.js.map +1 -0
  20. package/dist/commonjs/generate.js +289 -194
  21. package/dist/commonjs/generate.js.map +1 -1
  22. package/dist/commonjs/index.js +115 -7
  23. package/dist/commonjs/index.js.map +1 -1
  24. package/dist/module/NativeRNBootSplash.js.map +1 -1
  25. package/dist/module/addon/index.js +3 -0
  26. package/dist/module/addon/index.js.map +1 -0
  27. package/dist/module/generate.js +287 -195
  28. package/dist/module/generate.js.map +1 -1
  29. package/dist/module/index.js +113 -6
  30. package/dist/module/index.js.map +1 -1
  31. package/dist/typescript/NativeRNBootSplash.d.ts +6 -3
  32. package/dist/typescript/NativeRNBootSplash.d.ts.map +1 -1
  33. package/dist/typescript/addon/index.d.ts +3 -0
  34. package/dist/typescript/addon/index.d.ts.map +1 -0
  35. package/dist/typescript/generate.d.ts +47 -14
  36. package/dist/typescript/generate.d.ts.map +1 -1
  37. package/dist/typescript/index.d.ts +33 -5
  38. package/dist/typescript/index.d.ts.map +1 -1
  39. package/example/android/app/debug.keystore +0 -0
  40. package/example/vendor/bundle/ruby/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/.travis/compile +351 -0
  41. package/example/vendor/bundle/ruby/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.bhaible/Makefile +28 -0
  42. package/ios/.DS_Store +0 -0
  43. package/ios/.npmignore +8 -0
  44. package/ios/RNBootSplash.mm +101 -95
  45. package/package.json +22 -15
  46. package/react-native.config.js +74 -76
  47. package/src/.DS_Store +0 -0
  48. package/src/.npmignore +1 -0
  49. package/src/NativeRNBootSplash.ts +3 -4
  50. package/src/addon/index.ts +788 -0
  51. package/src/generate.ts +457 -232
  52. package/src/index.ts +205 -8
  53. package/RNBootSplash.res +0 -29
  54. package/bsconfig.json +0 -14
@@ -2,49 +2,69 @@ import fs from "fs-extra";
2
2
  import path from "path";
3
3
  import pc from "picocolors";
4
4
  import sharp from "sharp";
5
- const logoFileName = "bootsplash_logo";
6
- const xcassetName = "BootSplashLogo";
7
- const androidColorName = "bootsplash_background";
8
- const androidColorRegex = /<color name="bootsplash_background">#\w+<\/color>/g;
5
+ export const androidColorRegex = /<color name="bootsplash_background">#\w+<\/color>/g;
6
+ const workingPath = process.env.INIT_CWD ?? process.env.PWD ?? process.cwd();
7
+ const parseColor = value => {
8
+ const up = value.toUpperCase().replace(/[^0-9A-F]/g, "");
9
+ const hex = "#" + (up.length === 3 ? up + up : up);
10
+ if (hex.length !== 7) {
11
+ log.error("--background-color value is not a valid hexadecimal color.");
12
+ process.exit(1);
13
+ }
14
+ const rgb = {
15
+ R: (parseInt("" + hex[1] + hex[2], 16) / 255).toPrecision(15),
16
+ G: (parseInt("" + hex[3] + hex[4], 16) / 255).toPrecision(15),
17
+ B: (parseInt("" + hex[5] + hex[6], 16) / 255).toPrecision(15)
18
+ };
19
+ return {
20
+ hex,
21
+ rgb
22
+ };
23
+ };
9
24
  const ContentsJson = `{
10
25
  "images": [
11
26
  {
12
27
  "idiom": "universal",
13
- "filename": "${logoFileName}.png",
28
+ "filename": "bootsplash_logo.png",
14
29
  "scale": "1x"
15
30
  },
16
31
  {
17
32
  "idiom": "universal",
18
- "filename": "${logoFileName}@2x.png",
33
+ "filename": "bootsplash_logo@2x.png",
19
34
  "scale": "2x"
20
35
  },
21
36
  {
22
37
  "idiom": "universal",
23
- "filename": "${logoFileName}@3x.png",
38
+ "filename": "bootsplash_logo@3x.png",
24
39
  "scale": "3x"
25
40
  }
26
41
  ],
27
42
  "info": {
28
- "version": 1,
29
- "author": "xcode"
43
+ "author": "xcode",
44
+ "version": 1
30
45
  }
31
46
  }
32
47
  `;
33
48
  const getStoryboard = _ref => {
34
49
  let {
35
- height,
36
- width,
37
- backgroundColor: hex
50
+ logoHeight,
51
+ logoWidth,
52
+ background: {
53
+ R,
54
+ G,
55
+ B
56
+ }
38
57
  } = _ref;
39
- const r = (parseInt("" + hex[1] + hex[2], 16) / 255).toPrecision(15);
40
- const g = (parseInt("" + hex[3] + hex[4], 16) / 255).toPrecision(15);
41
- const b = (parseInt("" + hex[5] + hex[6], 16) / 255).toPrecision(15);
58
+ const frameWidth = 375;
59
+ const frameHeight = 667;
60
+ const logoX = (frameWidth - logoWidth) / 2;
61
+ const logoY = (frameHeight - logoHeight) / 2;
42
62
  return `<?xml version="1.0" encoding="UTF-8"?>
43
- <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
63
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
44
64
  <device id="retina4_7" orientation="portrait" appearance="light"/>
45
65
  <dependencies>
46
66
  <deployment identifier="iOS"/>
47
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
67
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
48
68
  <capability name="Safe area layout guides" minToolsVersion="9.0"/>
49
69
  <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
50
70
  </dependencies>
@@ -53,22 +73,19 @@ const getStoryboard = _ref => {
53
73
  <scene sceneID="EHf-IW-A2E">
54
74
  <objects>
55
75
  <viewController modalTransitionStyle="crossDissolve" id="01J-lp-oVM" sceneMemberID="viewController">
56
- <view key="view" autoresizesSubviews="NO" userInteractionEnabled="NO" contentMode="scaleToFill" id="Ze5-6b-2t3">
57
- <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
58
- <autoresizingMask key="autoresizingMask"/>
76
+ <view key="view" autoresizesSubviews="NO" contentMode="scaleToFill" id="Ze5-6b-2t3">
77
+ <rect key="frame" x="0.0" y="0.0" width="${frameWidth}" height="${frameHeight}"/>
78
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
59
79
  <subviews>
60
80
  <imageView autoresizesSubviews="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" image="BootSplashLogo" translatesAutoresizingMaskIntoConstraints="NO" id="3lX-Ut-9ad">
61
- <rect key="frame" x="${(375 - width) / 2}" y="${(667 - height) / 2}" width="${width}" height="${height}"/>
81
+ <rect key="frame" x="${logoX}" y="${logoY}" width="${logoWidth}" height="${logoHeight}"/>
62
82
  <accessibility key="accessibilityConfiguration">
63
83
  <accessibilityTraits key="traits" image="YES" notEnabled="YES"/>
64
84
  </accessibility>
65
85
  </imageView>
66
86
  </subviews>
67
87
  <viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
68
- <color key="backgroundColor" red="${r}" green="${g}" blue="${b}" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
69
- <accessibility key="accessibilityConfiguration">
70
- <accessibilityTraits key="traits" notEnabled="YES"/>
71
- </accessibility>
88
+ <color key="backgroundColor" red="${R}" green="${G}" blue="${B}" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
72
89
  <constraints>
73
90
  <constraint firstItem="3lX-Ut-9ad" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="Fh9-Fy-1nT"/>
74
91
  <constraint firstItem="3lX-Ut-9ad" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="nvB-Ic-PnI"/>
@@ -81,127 +98,148 @@ const getStoryboard = _ref => {
81
98
  </scene>
82
99
  </scenes>
83
100
  <resources>
84
- <image name="${xcassetName}" width="${width}" height="${height}"/>
101
+ <image name="BootSplashLogo" width="${logoWidth}" height="${logoHeight}"/>
85
102
  </resources>
86
103
  </document>
87
104
  `;
88
105
  };
89
- const log = {
90
- error: text => console.log(pc.red(text)),
106
+ export const log = {
107
+ error: text => console.log(pc.red(`❌ ${text}`)),
91
108
  text: text => console.log(text),
92
- warn: text => console.log(pc.yellow(text))
109
+ title: (emoji, text) => console.log(`\n${emoji} ${pc.underline(pc.bold(text))}`),
110
+ warn: text => console.log(pc.yellow(`⚠️ ${text}`))
93
111
  };
94
- const toFullHexadecimal = hex => {
95
- const up = hex.toUpperCase().replace(/[^0-9A-F]/g, "");
96
- if (up.length === 6) {
97
- return "#" + up;
112
+ export const logWrite = (filePath, dimensions) => console.log(` ${path.relative(workingPath, filePath)}` + (dimensions != null ? ` (${dimensions.width}x${dimensions.height})` : ""));
113
+ const ensureSupportedFormat = async (name, image) => {
114
+ if (image == null) {
115
+ return;
98
116
  }
99
- if (up.length === 3) {
100
- return "#" + up[0] + up[0] + up[1] + up[1] + up[2] + up[2];
117
+ const {
118
+ format
119
+ } = await image.metadata();
120
+ if (format !== "png" && format !== "svg") {
121
+ log.error(`${name} image file format (${format}) is not supported`);
122
+ process.exit(1);
101
123
  }
102
- log.error("--background-color value is not a valid hexadecimal color.");
103
- process.exit(1);
104
124
  };
105
- export const generate = async _ref2 => {
125
+ const getAndroidResPath = (android, _ref2) => {
106
126
  let {
107
- android,
108
- ios,
109
- workingPath,
110
- logoPath,
111
- assetsPath,
112
- backgroundColor,
127
+ brandHeight,
128
+ brandWidth,
113
129
  flavor,
114
- logoWidth,
115
- platforms
130
+ logoHeight,
131
+ logoWidth
116
132
  } = _ref2;
117
- const platformsIncludesAndroid = platforms.includes("android");
118
- const platformsIncludesIOS = platforms.includes("ios");
119
- if (!platformsIncludesAndroid && !platformsIncludesIOS) {
120
- log.error("--platforms value does not include at least one supported platform.");
133
+ const androidResPath = path.resolve(android.sourceDir, android.appName, "src", flavor, "res");
134
+ if (!fs.existsSync(androidResPath)) {
135
+ log.warn(`No ${path.relative(workingPath, androidResPath)} directory found. Skipping Android assets generation…`);
136
+ } else if (logoWidth > 288 || logoHeight > 288) {
137
+ log.warn("Logo size exceeding 288x288dp will be cropped by Android. Skipping Android assets generation…");
138
+ } else if (brandHeight > 80 || brandWidth > 200) {
139
+ log.warn("Brand size exceeding 200x80dp will be cropped by Android. Skipping Android assets generation…");
140
+ } else {
141
+ if (logoWidth > 192 || logoHeight > 192) {
142
+ log.warn(`Logo size exceeds 192x192dp. It might be cropped by Android.`);
143
+ }
144
+ return androidResPath;
145
+ }
146
+ };
147
+ const getIOSProjectPath = ios => {
148
+ if (ios.xcodeProject == null) {
149
+ log.warn("No Xcode project found. Skipping iOS assets generation…");
150
+ return;
151
+ }
152
+ const iosProjectPath = path.resolve(ios.sourceDir, ios.xcodeProject.name).replace(/\.(xcodeproj|xcworkspace)$/, "");
153
+ if (!fs.existsSync(iosProjectPath)) {
154
+ log.warn(`No ${path.relative(workingPath, iosProjectPath)} directory found. Skipping iOS assets generation…`);
155
+ } else {
156
+ return iosProjectPath;
157
+ }
158
+ };
159
+ const requireAddon = () => {
160
+ try {
161
+ // eslint-disable-next-line
162
+ return require("./addon");
163
+ } catch {
164
+ return;
165
+ }
166
+ };
167
+ export const generate = async (_ref3, _ref4, _ref5) => {
168
+ let [argsLogo] = _ref3;
169
+ let {
170
+ project: {
171
+ android,
172
+ ios
173
+ }
174
+ } = _ref4;
175
+ let {
176
+ flavor,
177
+ platforms,
178
+ licenseKey,
179
+ ...args
180
+ } = _ref5;
181
+ if (argsLogo == null) {
182
+ log.error("Missing required argument 'logo'");
121
183
  process.exit(1);
122
184
  }
123
- const backgroundColorHex = toFullHexadecimal(backgroundColor);
124
- const image = sharp(logoPath);
125
- const {
126
- format
127
- } = await image.metadata();
128
- if (format !== "png" && format !== "svg") {
129
- log.error("Input file is an unsupported image format");
185
+ const assetsOutputPath = args.assetsOutput != null ? path.resolve(workingPath, args.assetsOutput) : undefined;
186
+ const background = parseColor(args.background);
187
+ const logo = sharp(path.resolve(workingPath, argsLogo));
188
+ const logoWidth = args.logoWidth - args.logoWidth % 2;
189
+ const brandWidth = args.brandWidth - args.brandWidth % 2;
190
+ const brand = args.brand != null ? sharp(path.resolve(workingPath, args.brand)) : undefined;
191
+ const darkBackground = args.darkBackground != null ? parseColor(args.darkBackground) : undefined;
192
+ const darkLogo = args.darkLogo != null ? sharp(path.resolve(workingPath, args.darkLogo)) : undefined;
193
+ const darkBrand = args.darkBrand != null ? sharp(path.resolve(workingPath, args.darkBrand)) : undefined;
194
+ const executeAddon = brand != null || darkBackground != null || darkLogo != null || darkBrand != null;
195
+ if (licenseKey != null && !executeAddon) {
196
+ log.warn(`You specified a license key but none of the options that requires it.`);
197
+ }
198
+ if (licenseKey == null && executeAddon) {
199
+ const options = [brand != null ? "brand" : "", darkBackground != null ? "dark-background" : "", darkLogo != null ? "dark-logo" : "", darkBrand != null ? "dark-brand" : ""].filter(option => option !== "").map(option => `--${option}`).join(", ");
200
+ log.error(`You need to specify a license key in order to use ${options}.`);
130
201
  process.exit(1);
131
202
  }
132
- const logoHeight = await image.clone().resize(logoWidth).toBuffer().then(buffer => sharp(buffer).metadata()).then(_ref3 => {
203
+ if (brand == null && darkBrand != null) {
204
+ log.error("--dark-brand option couldn't be used without --brand.");
205
+ process.exit(1);
206
+ }
207
+ await ensureSupportedFormat("Logo", logo);
208
+ await ensureSupportedFormat("Dark logo", darkLogo);
209
+ await ensureSupportedFormat("Brand", brand);
210
+ await ensureSupportedFormat("Dark brand", darkBrand);
211
+ const logoHeight = await logo.clone().resize(logoWidth).toBuffer().then(buffer => sharp(buffer).metadata()).then(_ref6 => {
133
212
  let {
134
213
  height = 0
135
- } = _ref3;
136
- return height;
214
+ } = _ref6;
215
+ return Math.round(height);
137
216
  });
138
- const shouldSkipAndroid = logoWidth > 288 || logoHeight > 288;
139
- const logAbove288 = dimension => {
140
- const message = `⚠️ Logo ${dimension} exceed 288dp. As it will be cropped by Android, we skip generation for this platform.`;
141
- log.warn(message);
142
- };
143
- const logAbove192 = dimension => {
144
- const message = `⚠️ Logo ${dimension} exceed 192dp. It might be cropped by Android.`;
145
- log.warn(message);
146
- };
147
- if (logoWidth > 288) {
148
- logAbove288("width");
149
- } else if (logoHeight > 288) {
150
- logAbove288("height");
151
- } else if (logoWidth > 192) {
152
- logAbove192("width");
153
- } else if (logoHeight > 192) {
154
- logAbove192("height");
217
+ const brandHeight = (await (brand === null || brand === void 0 ? void 0 : brand.clone().resize(brandWidth).toBuffer().then(buffer => sharp(buffer).metadata()).then(_ref7 => {
218
+ let {
219
+ height = 0
220
+ } = _ref7;
221
+ return Math.round(height);
222
+ }))) ?? 0;
223
+ if (logoWidth < args.logoWidth) {
224
+ log.warn(`Logo width must be a multiple of 2. It has been rounded to ${logoWidth}dp.`);
155
225
  }
156
- const logWrite = (emoji, filePath, dimensions) => log.text(`${emoji} ${path.relative(workingPath, filePath)}` + (dimensions != null ? ` (${dimensions.width}x${dimensions.height})` : ""));
157
- if (assetsPath) {
158
- log.text(`\n ${pc.underline("Assets")}`);
159
- fs.ensureDirSync(assetsPath);
160
- await Promise.all([{
161
- ratio: 1,
162
- suffix: ""
163
- }, {
164
- ratio: 1.5,
165
- suffix: "@1,5x"
166
- }, {
167
- ratio: 2,
168
- suffix: "@2x"
169
- }, {
170
- ratio: 3,
171
- suffix: "@3x"
172
- }, {
173
- ratio: 4,
174
- suffix: "@4x"
175
- }].map(_ref4 => {
176
- let {
177
- ratio,
178
- suffix
179
- } = _ref4;
180
- const fileName = `${logoFileName}${suffix}.png`;
181
- const filePath = path.resolve(assetsPath, fileName);
182
- return image.clone().resize(logoWidth * ratio).png({
183
- quality: 100
184
- }).toFile(filePath).then(_ref5 => {
185
- let {
186
- width,
187
- height
188
- } = _ref5;
189
- logWrite("✨", filePath, {
190
- width,
191
- height
192
- });
193
- });
194
- }));
226
+ if (brandWidth < args.brandWidth) {
227
+ log.warn(`Brand width must be a multiple of 2. It has been rounded to ${brandWidth}dp.`);
195
228
  }
196
- if (platformsIncludesAndroid && android && !shouldSkipAndroid) {
197
- log.text(`\n ${pc.underline("Android")}`);
198
- const appPath = android.appName ? path.resolve(android.sourceDir, android.appName) : path.resolve(android.sourceDir); // @react-native-community/cli 2.x & 3.x support
199
-
200
- const resPath = path.resolve(appPath, "src", flavor, "res");
201
- const valuesPath = path.resolve(resPath, "values");
229
+ const androidResPath = platforms.includes("android") && android != null ? getAndroidResPath(android, {
230
+ brandHeight,
231
+ brandWidth,
232
+ flavor,
233
+ logoHeight,
234
+ logoWidth
235
+ }) : undefined;
236
+ const iosProjectPath = platforms.includes("ios") && ios != null ? getIOSProjectPath(ios) : undefined;
237
+ if (androidResPath != null) {
238
+ log.title("πŸ€–", "Android");
239
+ const valuesPath = path.resolve(androidResPath, "values");
202
240
  fs.ensureDirSync(valuesPath);
203
241
  const colorsXmlPath = path.resolve(valuesPath, "colors.xml");
204
- const colorsXmlEntry = `<color name="${androidColorName}">${backgroundColorHex}</color>`;
242
+ const colorsXmlEntry = `<color name="bootsplash_background">${background.hex}</color>`;
205
243
  if (fs.existsSync(colorsXmlPath)) {
206
244
  const colorsXml = fs.readFileSync(colorsXmlPath, "utf-8");
207
245
  if (colorsXml.match(androidColorRegex)) {
@@ -209,34 +247,34 @@ export const generate = async _ref2 => {
209
247
  } else {
210
248
  fs.writeFileSync(colorsXmlPath, colorsXml.replace(/<\/resources>/g, ` ${colorsXmlEntry}\n</resources>`), "utf-8");
211
249
  }
212
- logWrite("✏️ ", colorsXmlPath);
213
250
  } else {
214
251
  fs.writeFileSync(colorsXmlPath, `<resources>\n ${colorsXmlEntry}\n</resources>\n`, "utf-8");
215
- logWrite("✨", colorsXmlPath);
216
252
  }
253
+ logWrite(colorsXmlPath);
217
254
  await Promise.all([{
218
255
  ratio: 1,
219
- directory: "mipmap-mdpi"
256
+ suffix: "mdpi"
220
257
  }, {
221
258
  ratio: 1.5,
222
- directory: "mipmap-hdpi"
259
+ suffix: "hdpi"
223
260
  }, {
224
261
  ratio: 2,
225
- directory: "mipmap-xhdpi"
262
+ suffix: "xhdpi"
226
263
  }, {
227
264
  ratio: 3,
228
- directory: "mipmap-xxhdpi"
265
+ suffix: "xxhdpi"
229
266
  }, {
230
267
  ratio: 4,
231
- directory: "mipmap-xxxhdpi"
232
- }].map(_ref6 => {
268
+ suffix: "xxxhdpi"
269
+ }].map(_ref8 => {
233
270
  let {
234
271
  ratio,
235
- directory
236
- } = _ref6;
237
- const fileName = `${logoFileName}.png`;
238
- const filePath = path.resolve(resPath, directory, fileName);
239
- // https://github.com/androidx/androidx/blob/androidx-main/core/core-splashscreen/src/main/res/values/dimens.xml#L22
272
+ suffix
273
+ } = _ref8;
274
+ const drawableDirPath = path.resolve(androidResPath, `drawable-${suffix}`);
275
+ fs.ensureDirSync(drawableDirPath);
276
+
277
+ // https://developer.android.com/develop/ui/views/launch/splash-screen#dimensions
240
278
  const canvasSize = 288 * ratio;
241
279
 
242
280
  // https://sharp.pixelplumbing.com/api-constructor
@@ -253,78 +291,132 @@ export const generate = async _ref2 => {
253
291
  }
254
292
  }
255
293
  });
256
- return image.clone().resize(logoWidth * ratio).toBuffer().then(input => canvas.composite([{
294
+ const filePath = path.resolve(drawableDirPath, "bootsplash_logo.png");
295
+ return logo.clone().resize(logoWidth * ratio).toBuffer().then(input => canvas.composite([{
257
296
  input
258
297
  }]).png({
259
298
  quality: 100
260
299
  }).toFile(filePath)).then(() => {
261
- logWrite("✨", filePath, {
300
+ logWrite(filePath, {
262
301
  width: canvasSize,
263
302
  height: canvasSize
264
303
  });
265
304
  });
266
305
  }));
267
306
  }
268
- if (platformsIncludesIOS && ios) {
269
- log.text(`\n ${pc.underline("iOS")}`);
270
- const {
271
- projectPath
272
- } = ios;
273
- const imagesPath = path.resolve(projectPath, "Images.xcassets");
274
- if (fs.existsSync(projectPath)) {
275
- const storyboardPath = path.resolve(projectPath, "BootSplash.storyboard");
276
- fs.writeFileSync(storyboardPath, getStoryboard({
277
- height: logoHeight,
307
+ if (iosProjectPath != null) {
308
+ log.title("🍏", "iOS");
309
+ const storyboardPath = path.resolve(iosProjectPath, "BootSplash.storyboard");
310
+ fs.writeFileSync(storyboardPath, getStoryboard({
311
+ logoHeight,
312
+ logoWidth,
313
+ background: background.rgb
314
+ }), "utf-8");
315
+ logWrite(storyboardPath);
316
+ const imageSetPath = path.resolve(iosProjectPath, "Images.xcassets", "BootSplashLogo.imageset");
317
+ fs.ensureDirSync(imageSetPath);
318
+ fs.writeFileSync(path.resolve(imageSetPath, "Contents.json"), ContentsJson, "utf-8");
319
+ await Promise.all([{
320
+ ratio: 1,
321
+ suffix: ""
322
+ }, {
323
+ ratio: 2,
324
+ suffix: "@2x"
325
+ }, {
326
+ ratio: 3,
327
+ suffix: "@3x"
328
+ }].map(_ref9 => {
329
+ let {
330
+ ratio,
331
+ suffix
332
+ } = _ref9;
333
+ const filePath = path.resolve(imageSetPath, `bootsplash_logo${suffix}.png`);
334
+ return logo.clone().resize(logoWidth * ratio).png({
335
+ quality: 100
336
+ }).toFile(filePath).then(_ref10 => {
337
+ let {
338
+ width,
339
+ height
340
+ } = _ref10;
341
+ logWrite(filePath, {
342
+ width,
343
+ height
344
+ });
345
+ });
346
+ }));
347
+ }
348
+ if (assetsOutputPath != null) {
349
+ log.title("πŸ“„", "Assets");
350
+ fs.ensureDirSync(assetsOutputPath);
351
+ const manifest = {
352
+ background: background.hex,
353
+ logo: {
278
354
  width: logoWidth,
279
- backgroundColor: backgroundColorHex
280
- }), "utf-8");
281
- logWrite("✨", storyboardPath);
282
- } else {
283
- log.text(`No "${projectPath}" directory found. Skipping iOS storyboard generation…`);
284
- }
285
- if (fs.existsSync(imagesPath)) {
286
- const imageSetPath = path.resolve(imagesPath, xcassetName + ".imageset");
287
- fs.ensureDirSync(imageSetPath);
288
- fs.writeFileSync(path.resolve(imageSetPath, "Contents.json"), ContentsJson, "utf-8");
289
- await Promise.all([{
290
- ratio: 1,
291
- suffix: ""
292
- }, {
293
- ratio: 2,
294
- suffix: "@2x"
295
- }, {
296
- ratio: 3,
297
- suffix: "@3x"
298
- }].map(_ref7 => {
355
+ height: logoHeight
356
+ }
357
+ };
358
+ const manifestPath = path.resolve(assetsOutputPath, "bootsplash_manifest.json");
359
+ fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n", "utf-8");
360
+ logWrite(manifestPath);
361
+ await Promise.all([{
362
+ ratio: 1,
363
+ suffix: ""
364
+ }, {
365
+ ratio: 1.5,
366
+ suffix: "@1,5x"
367
+ }, {
368
+ ratio: 2,
369
+ suffix: "@2x"
370
+ }, {
371
+ ratio: 3,
372
+ suffix: "@3x"
373
+ }, {
374
+ ratio: 4,
375
+ suffix: "@4x"
376
+ }].map(_ref11 => {
377
+ let {
378
+ ratio,
379
+ suffix
380
+ } = _ref11;
381
+ const filePath = path.resolve(assetsOutputPath, `bootsplash_logo${suffix}.png`);
382
+ return logo.clone().resize(Math.round(logoWidth * ratio)).png({
383
+ quality: 100
384
+ }).toFile(filePath).then(_ref12 => {
299
385
  let {
300
- ratio,
301
- suffix
302
- } = _ref7;
303
- const fileName = `${logoFileName}${suffix}.png`;
304
- const filePath = path.resolve(imageSetPath, fileName);
305
- return image.clone().resize(logoWidth * ratio).png({
306
- quality: 100
307
- }).toFile(filePath).then(_ref8 => {
308
- let {
309
- width,
310
- height
311
- } = _ref8;
312
- logWrite("✨", filePath, {
313
- width,
314
- height
315
- });
386
+ width,
387
+ height
388
+ } = _ref12;
389
+ logWrite(filePath, {
390
+ width,
391
+ height
316
392
  });
317
- }));
318
- } else {
319
- log.text(`No "${imagesPath}" directory found. Skipping iOS images generation…`);
320
- }
393
+ });
394
+ }));
395
+ }
396
+ if (licenseKey != null && executeAddon) {
397
+ const addon = requireAddon();
398
+ await (addon === null || addon === void 0 ? void 0 : addon.execute({
399
+ licenseKey,
400
+ androidResPath,
401
+ iosProjectPath,
402
+ assetsOutputPath,
403
+ logoHeight,
404
+ logoWidth,
405
+ brandHeight,
406
+ brandWidth,
407
+ background,
408
+ brand,
409
+ darkBackground,
410
+ darkLogo,
411
+ darkBrand
412
+ }));
413
+ } else {
414
+ log.text(`
415
+ ${pc.blue("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓")}
416
+ ${pc.blue("┃")} πŸ”‘ ${pc.bold("Get a license key for brand image / dark mode support")} ${pc.blue("┃")}
417
+ ${pc.blue("┃")} ${pc.underline("https://zoontek.gumroad.com/l/bootsplash-generator")} ${pc.blue("┃")}
418
+ ${pc.blue("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛")}`);
321
419
  }
322
- log.text(`
323
- ${pc.blue("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓")}
324
- ${pc.blue("┃")} πŸ’– ${pc.bold("Love this library? Consider sponsoring!")} ${pc.blue("┃")}
325
- ${pc.blue("┃")} ${pc.underline("https://github.com/sponsors/zoontek")} ${pc.blue("┃")}
326
- ${pc.blue("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛")}
327
- `);
328
- log.text(`βœ… Done! Thanks for using ${pc.underline("react-native-bootsplash")}.`);
420
+ log.text(`\nπŸ’– Thanks for using ${pc.underline("react-native-bootsplash")}`);
329
421
  };
330
422
  //# sourceMappingURL=generate.js.map