react-native-bootsplash 4.7.5 β†’ 5.0.0-beta.1

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