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.
- package/README.md +214 -107
- package/RNBootSplash.podspec +1 -2
- package/android/build.gradle +0 -1
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplash.java +3 -2
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashDialog.java +49 -0
- package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModuleImpl.java +157 -87
- package/android/src/main/res/anim/bootsplash_fade_in.xml +7 -0
- package/android/src/main/res/anim/bootsplash_fade_out.xml +7 -0
- package/android/src/main/res/drawable/compat_splash_screen.xml +19 -0
- package/android/src/main/res/values/attrs.xml +8 -0
- package/android/src/main/res/values/public.xml +7 -0
- package/android/src/main/res/values/styles.xml +29 -0
- package/android/src/main/res/values-v31/styles.xml +7 -0
- package/android/src/newarch/com/zoontek/rnbootsplash/RNBootSplashModule.java +11 -4
- package/android/src/oldarch/com/zoontek/rnbootsplash/RNBootSplashModule.java +13 -4
- package/dist/commonjs/NativeRNBootSplash.js.map +1 -1
- package/dist/commonjs/addon/index.js +3 -0
- package/dist/commonjs/addon/index.js.map +1 -0
- package/dist/commonjs/generate.js +289 -194
- package/dist/commonjs/generate.js.map +1 -1
- package/dist/commonjs/index.js +115 -7
- package/dist/commonjs/index.js.map +1 -1
- package/dist/module/NativeRNBootSplash.js.map +1 -1
- package/dist/module/addon/index.js +3 -0
- package/dist/module/addon/index.js.map +1 -0
- package/dist/module/generate.js +287 -195
- package/dist/module/generate.js.map +1 -1
- package/dist/module/index.js +113 -6
- package/dist/module/index.js.map +1 -1
- package/dist/typescript/NativeRNBootSplash.d.ts +6 -3
- package/dist/typescript/NativeRNBootSplash.d.ts.map +1 -1
- package/dist/typescript/addon/index.d.ts +3 -0
- package/dist/typescript/addon/index.d.ts.map +1 -0
- package/dist/typescript/generate.d.ts +47 -14
- package/dist/typescript/generate.d.ts.map +1 -1
- package/dist/typescript/index.d.ts +33 -5
- package/dist/typescript/index.d.ts.map +1 -1
- package/ios/RNBootSplash.mm +101 -95
- package/package.json +20 -14
- package/react-native.config.js +74 -76
- package/src/NativeRNBootSplash.ts +3 -4
- package/src/generate.ts +457 -232
- package/src/index.ts +205 -8
- package/RNBootSplash.res +0 -29
- package/bsconfig.json +0 -14
package/dist/module/generate.js
CHANGED
|
@@ -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
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
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": "
|
|
28
|
+
"filename": "bootsplash_logo.png",
|
|
14
29
|
"scale": "1x"
|
|
15
30
|
},
|
|
16
31
|
{
|
|
17
32
|
"idiom": "universal",
|
|
18
|
-
"filename": "
|
|
33
|
+
"filename": "bootsplash_logo@2x.png",
|
|
19
34
|
"scale": "2x"
|
|
20
35
|
},
|
|
21
36
|
{
|
|
22
37
|
"idiom": "universal",
|
|
23
|
-
"filename": "
|
|
38
|
+
"filename": "bootsplash_logo@3x.png",
|
|
24
39
|
"scale": "3x"
|
|
25
40
|
}
|
|
26
41
|
],
|
|
27
42
|
"info": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
43
|
+
"author": "xcode",
|
|
44
|
+
"version": 1
|
|
30
45
|
}
|
|
31
46
|
}
|
|
32
47
|
`;
|
|
33
48
|
const getStoryboard = _ref => {
|
|
34
49
|
let {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
50
|
+
logoHeight,
|
|
51
|
+
logoWidth,
|
|
52
|
+
background: {
|
|
53
|
+
R,
|
|
54
|
+
G,
|
|
55
|
+
B
|
|
56
|
+
}
|
|
38
57
|
} = _ref;
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
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="
|
|
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="
|
|
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"
|
|
57
|
-
<rect key="frame" x="0.0" y="0.0" width="
|
|
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="${
|
|
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="${
|
|
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="
|
|
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
|
-
|
|
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
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
return
|
|
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
|
-
|
|
100
|
-
|
|
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
|
-
|
|
125
|
+
const getAndroidResPath = (android, _ref2) => {
|
|
106
126
|
let {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
workingPath,
|
|
110
|
-
logoPath,
|
|
111
|
-
assetsPath,
|
|
112
|
-
backgroundColor,
|
|
127
|
+
brandHeight,
|
|
128
|
+
brandWidth,
|
|
113
129
|
flavor,
|
|
114
|
-
|
|
115
|
-
|
|
130
|
+
logoHeight,
|
|
131
|
+
logoWidth
|
|
116
132
|
} = _ref2;
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
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
|
-
} =
|
|
136
|
-
return height;
|
|
214
|
+
} = _ref6;
|
|
215
|
+
return Math.round(height);
|
|
137
216
|
});
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
log.warn(
|
|
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
|
-
|
|
157
|
-
|
|
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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="
|
|
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
|
-
|
|
256
|
+
suffix: "mdpi"
|
|
220
257
|
}, {
|
|
221
258
|
ratio: 1.5,
|
|
222
|
-
|
|
259
|
+
suffix: "hdpi"
|
|
223
260
|
}, {
|
|
224
261
|
ratio: 2,
|
|
225
|
-
|
|
262
|
+
suffix: "xhdpi"
|
|
226
263
|
}, {
|
|
227
264
|
ratio: 3,
|
|
228
|
-
|
|
265
|
+
suffix: "xxhdpi"
|
|
229
266
|
}, {
|
|
230
267
|
ratio: 4,
|
|
231
|
-
|
|
232
|
-
}].map(
|
|
268
|
+
suffix: "xxxhdpi"
|
|
269
|
+
}].map(_ref8 => {
|
|
233
270
|
let {
|
|
234
271
|
ratio,
|
|
235
|
-
|
|
236
|
-
} =
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
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(
|
|
300
|
+
logWrite(filePath, {
|
|
262
301
|
width: canvasSize,
|
|
263
302
|
height: canvasSize
|
|
264
303
|
});
|
|
265
304
|
});
|
|
266
305
|
}));
|
|
267
306
|
}
|
|
268
|
-
if (
|
|
269
|
-
log.
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
-
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
} =
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
}
|
|
319
|
-
|
|
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
|