react-native-bootsplash 5.0.0-beta.1 → 5.0.0-beta.3
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 +3 -3
- package/dist/commonjs/addon/index.js +1 -1
- package/dist/commonjs/addon/index.js.map +1 -1
- package/dist/commonjs/generate.js +51 -39
- package/dist/commonjs/generate.js.map +1 -1
- package/dist/commonjs/index.js +5 -6
- package/dist/commonjs/index.js.map +1 -1
- package/dist/module/addon/index.js +1 -1
- package/dist/module/addon/index.js.map +1 -1
- package/dist/module/generate.js +48 -38
- package/dist/module/generate.js.map +1 -1
- package/dist/module/index.js +5 -6
- package/dist/module/index.js.map +1 -1
- package/dist/typescript/addon/index.d.ts.map +1 -1
- package/dist/typescript/generate.d.ts +4 -1
- package/dist/typescript/generate.d.ts.map +1 -1
- package/dist/typescript/index.d.ts +0 -1
- package/dist/typescript/index.d.ts.map +1 -1
- package/package.json +13 -7
- package/src/generate.ts +78 -77
- package/src/index.ts +1 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAEhB,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAEhB,MAAM,mCAAmC,CAAC;AAK3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAkB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAK/D,eAAO,MAAM,iBAAiB,QACwB,CAAC;AAEvD,MAAM,MAAM,KAAK,GAAG;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KA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AAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CA6VA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,kBAAkB,EAGlB,SAAS,EAGV,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,CAAC,EAAE;QACN,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,kBAAkB,EAGlB,SAAS,EAGV,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,CAAC,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,QAAQ,CAAC;IAEnB,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAE/B,OAAO,EAAE,MAAM,IAAI,CAAC;IAEpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,wBAAgB,IAAI,CAAC,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvD;AAED,wBAAgB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAE5C;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,oBAmJ9D;;;;;;AAED,wBAIE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-bootsplash",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Display a bootsplash on your app starts. Hide it when you want.",
|
|
6
6
|
"author": "Mathieu Acthernoene <zoontek@gmail.com>",
|
|
@@ -9,12 +9,16 @@
|
|
|
9
9
|
"module": "dist/module/index.js",
|
|
10
10
|
"types": "dist/typescript/index.d.ts",
|
|
11
11
|
"files": [
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
12
|
+
"dist",
|
|
13
|
+
"android",
|
|
14
|
+
"ios",
|
|
15
|
+
"src",
|
|
16
|
+
"!android/build",
|
|
17
|
+
"!android/.cxx",
|
|
18
|
+
"!android/.gradle",
|
|
19
|
+
"!ios/build",
|
|
20
|
+
"!src/addon",
|
|
16
21
|
"RNBootSplash.podspec",
|
|
17
|
-
"package.json",
|
|
18
22
|
"react-native.config.js"
|
|
19
23
|
],
|
|
20
24
|
"repository": {
|
|
@@ -60,9 +64,11 @@
|
|
|
60
64
|
"react-native": ">=0.70.0"
|
|
61
65
|
},
|
|
62
66
|
"dependencies": {
|
|
67
|
+
"detect-indent": "^6.1.0",
|
|
63
68
|
"fs-extra": "^11.1.1",
|
|
64
69
|
"picocolors": "^1.0.0",
|
|
65
|
-
"sharp": "^0.32.4"
|
|
70
|
+
"sharp": "^0.32.4",
|
|
71
|
+
"xml-formatter": "^3.5.0"
|
|
66
72
|
},
|
|
67
73
|
"devDependencies": {
|
|
68
74
|
"@babel/core": "^7.20.0",
|
package/src/generate.ts
CHANGED
|
@@ -3,26 +3,24 @@ import {
|
|
|
3
3
|
CommandFunction,
|
|
4
4
|
IOSProjectConfig,
|
|
5
5
|
} from "@react-native-community/cli-types";
|
|
6
|
+
import detectIndent from "detect-indent";
|
|
6
7
|
import fs from "fs-extra";
|
|
7
8
|
import path from "path";
|
|
8
9
|
import pc from "picocolors";
|
|
9
10
|
import type { Sharp } from "sharp";
|
|
10
11
|
import sharp from "sharp";
|
|
12
|
+
import xmlFormat, { XMLFormatterOptions } from "xml-formatter";
|
|
11
13
|
import type { Manifest } from ".";
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
hex: string;
|
|
15
|
-
rgb: {
|
|
16
|
-
R: string;
|
|
17
|
-
G: string;
|
|
18
|
-
B: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
15
|
+
const workingPath = process.env.INIT_CWD ?? process.env.PWD ?? process.cwd();
|
|
21
16
|
|
|
22
17
|
export const androidColorRegex =
|
|
23
18
|
/<color name="bootsplash_background">#\w+<\/color>/g;
|
|
24
19
|
|
|
25
|
-
|
|
20
|
+
export type Color = {
|
|
21
|
+
hex: string;
|
|
22
|
+
rgb: { R: string; G: string; B: string };
|
|
23
|
+
};
|
|
26
24
|
|
|
27
25
|
const parseColor = (value: string): Color => {
|
|
28
26
|
const up = value.toUpperCase().replace(/[^0-9A-F]/g, "");
|
|
@@ -42,31 +40,6 @@ const parseColor = (value: string): Color => {
|
|
|
42
40
|
return { hex, rgb };
|
|
43
41
|
};
|
|
44
42
|
|
|
45
|
-
const ContentsJson = `{
|
|
46
|
-
"images": [
|
|
47
|
-
{
|
|
48
|
-
"idiom": "universal",
|
|
49
|
-
"filename": "bootsplash_logo.png",
|
|
50
|
-
"scale": "1x"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"idiom": "universal",
|
|
54
|
-
"filename": "bootsplash_logo@2x.png",
|
|
55
|
-
"scale": "2x"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"idiom": "universal",
|
|
59
|
-
"filename": "bootsplash_logo@3x.png",
|
|
60
|
-
"scale": "3x"
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
"info": {
|
|
64
|
-
"author": "xcode",
|
|
65
|
-
"version": 1
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
`;
|
|
69
|
-
|
|
70
43
|
const getStoryboard = ({
|
|
71
44
|
logoHeight,
|
|
72
45
|
logoWidth,
|
|
@@ -143,6 +116,38 @@ export const logWrite = (
|
|
|
143
116
|
(dimensions != null ? ` (${dimensions.width}x${dimensions.height})` : ""),
|
|
144
117
|
);
|
|
145
118
|
|
|
119
|
+
export const writeJson = (file: string, json: object) => {
|
|
120
|
+
const amount = fs.existsSync(file)
|
|
121
|
+
? detectIndent(fs.readFileSync(file, "utf-8")).amount || 2
|
|
122
|
+
: 2;
|
|
123
|
+
|
|
124
|
+
fs.writeFileSync(file, JSON.stringify(json, null, amount) + "\n", "utf-8");
|
|
125
|
+
logWrite(file);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const writeXml = (
|
|
129
|
+
file: string,
|
|
130
|
+
xml: string,
|
|
131
|
+
options?: XMLFormatterOptions,
|
|
132
|
+
) => {
|
|
133
|
+
const indentation = fs.existsSync(file)
|
|
134
|
+
? detectIndent(fs.readFileSync(file, "utf-8")).indent || " "
|
|
135
|
+
: " ";
|
|
136
|
+
|
|
137
|
+
fs.writeFileSync(
|
|
138
|
+
file,
|
|
139
|
+
xmlFormat(xml, {
|
|
140
|
+
collapseContent: true,
|
|
141
|
+
...options,
|
|
142
|
+
indentation,
|
|
143
|
+
lineSeparator: "\n",
|
|
144
|
+
}) + "\n",
|
|
145
|
+
"utf-8",
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
logWrite(file);
|
|
149
|
+
};
|
|
150
|
+
|
|
146
151
|
const ensureSupportedFormat = async (
|
|
147
152
|
name: string,
|
|
148
153
|
image: Sharp | undefined,
|
|
@@ -278,6 +283,14 @@ export const generate: CommandFunction<{
|
|
|
278
283
|
{ project: { android, ios } },
|
|
279
284
|
{ flavor, platforms, licenseKey, ...args },
|
|
280
285
|
) => {
|
|
286
|
+
const [nodeStringVersion = ""] = process.versions.node.split(".");
|
|
287
|
+
const nodeVersion = parseInt(nodeStringVersion, 10);
|
|
288
|
+
|
|
289
|
+
if (!isNaN(nodeVersion) && nodeVersion < 18) {
|
|
290
|
+
log.error("Requires Node 18 (or higher)");
|
|
291
|
+
process.exit(1);
|
|
292
|
+
}
|
|
293
|
+
|
|
281
294
|
if (argsLogo == null) {
|
|
282
295
|
log.error("Missing required argument 'logo'");
|
|
283
296
|
process.exit(1);
|
|
@@ -402,32 +415,15 @@ export const generate: CommandFunction<{
|
|
|
402
415
|
if (fs.existsSync(colorsXmlPath)) {
|
|
403
416
|
const colorsXml = fs.readFileSync(colorsXmlPath, "utf-8");
|
|
404
417
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
);
|
|
411
|
-
} else {
|
|
412
|
-
fs.writeFileSync(
|
|
413
|
-
colorsXmlPath,
|
|
414
|
-
colorsXml.replace(
|
|
415
|
-
/<\/resources>/g,
|
|
416
|
-
` ${colorsXmlEntry}\n</resources>`,
|
|
417
|
-
),
|
|
418
|
-
"utf-8",
|
|
419
|
-
);
|
|
420
|
-
}
|
|
418
|
+
const nextXml = colorsXml.match(androidColorRegex)
|
|
419
|
+
? colorsXml.replace(androidColorRegex, colorsXmlEntry)
|
|
420
|
+
: colorsXml.replace(/<\/resources>/g, `${colorsXmlEntry}</resources>`);
|
|
421
|
+
|
|
422
|
+
writeXml(colorsXmlPath, nextXml);
|
|
421
423
|
} else {
|
|
422
|
-
|
|
423
|
-
colorsXmlPath,
|
|
424
|
-
`<resources>\n ${colorsXmlEntry}\n</resources>\n`,
|
|
425
|
-
"utf-8",
|
|
426
|
-
);
|
|
424
|
+
writeXml(colorsXmlPath, `<resources>${colorsXmlEntry}</resources>`);
|
|
427
425
|
}
|
|
428
426
|
|
|
429
|
-
logWrite(colorsXmlPath);
|
|
430
|
-
|
|
431
427
|
await Promise.all(
|
|
432
428
|
[
|
|
433
429
|
{ ratio: 1, suffix: "mdpi" },
|
|
@@ -511,11 +507,29 @@ export const generate: CommandFunction<{
|
|
|
511
507
|
|
|
512
508
|
fs.ensureDirSync(imageSetPath);
|
|
513
509
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
510
|
+
writeJson(path.resolve(imageSetPath, "Contents.json"), {
|
|
511
|
+
images: [
|
|
512
|
+
{
|
|
513
|
+
idiom: "universal",
|
|
514
|
+
filename: "bootsplash_logo.png",
|
|
515
|
+
scale: "1x",
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
idiom: "universal",
|
|
519
|
+
filename: "bootsplash_logo@2x.png",
|
|
520
|
+
scale: "2x",
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
idiom: "universal",
|
|
524
|
+
filename: "bootsplash_logo@3x.png",
|
|
525
|
+
scale: "3x",
|
|
526
|
+
},
|
|
527
|
+
],
|
|
528
|
+
info: {
|
|
529
|
+
author: "xcode",
|
|
530
|
+
version: 1,
|
|
531
|
+
},
|
|
532
|
+
});
|
|
519
533
|
|
|
520
534
|
await Promise.all(
|
|
521
535
|
[
|
|
@@ -545,26 +559,13 @@ export const generate: CommandFunction<{
|
|
|
545
559
|
|
|
546
560
|
fs.ensureDirSync(assetsOutputPath);
|
|
547
561
|
|
|
548
|
-
|
|
562
|
+
writeJson(path.resolve(assetsOutputPath, "bootsplash_manifest.json"), {
|
|
549
563
|
background: background.hex,
|
|
550
564
|
logo: {
|
|
551
565
|
width: logoWidth,
|
|
552
566
|
height: logoHeight,
|
|
553
567
|
},
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
const manifestPath = path.resolve(
|
|
557
|
-
assetsOutputPath,
|
|
558
|
-
"bootsplash_manifest.json",
|
|
559
|
-
);
|
|
560
|
-
|
|
561
|
-
fs.writeFileSync(
|
|
562
|
-
manifestPath,
|
|
563
|
-
JSON.stringify(manifest, null, 2) + "\n",
|
|
564
|
-
"utf-8",
|
|
565
|
-
);
|
|
566
|
-
|
|
567
|
-
logWrite(manifestPath);
|
|
568
|
+
} satisfies Manifest);
|
|
568
569
|
|
|
569
570
|
await Promise.all(
|
|
570
571
|
[
|
package/src/index.ts
CHANGED
|
@@ -22,7 +22,6 @@ export type Manifest = {
|
|
|
22
22
|
height: number;
|
|
23
23
|
};
|
|
24
24
|
brand?: {
|
|
25
|
-
bottom: number;
|
|
26
25
|
width: number;
|
|
27
26
|
height: number;
|
|
28
27
|
};
|
|
@@ -75,7 +74,6 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
|
|
|
75
74
|
const hasBrand = manifest.brand != null && brandSrc != null;
|
|
76
75
|
const logoWidth = manifest.logo.width;
|
|
77
76
|
const logoHeight = manifest.logo.height;
|
|
78
|
-
const brandBottom = manifest.brand?.bottom;
|
|
79
77
|
const brandWidth = manifest.brand?.width;
|
|
80
78
|
const brandHeight = manifest.brand?.height;
|
|
81
79
|
|
|
@@ -158,7 +156,7 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
|
|
|
158
156
|
source: brandFinalSrc,
|
|
159
157
|
style: {
|
|
160
158
|
position: "absolute",
|
|
161
|
-
bottom:
|
|
159
|
+
bottom: 60,
|
|
162
160
|
width: brandWidth,
|
|
163
161
|
height: brandHeight,
|
|
164
162
|
},
|
|
@@ -195,7 +193,6 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
|
|
|
195
193
|
|
|
196
194
|
logoWidth,
|
|
197
195
|
logoHeight,
|
|
198
|
-
brandBottom,
|
|
199
196
|
brandWidth,
|
|
200
197
|
brandHeight,
|
|
201
198
|
|