react-native-bootsplash 6.0.0-beta.6 → 6.0.0-beta.8
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 +7 -53
- package/dist/commonjs/addon/index.js +31 -31
- package/dist/commonjs/addon/index.js.map +1 -1
- package/dist/commonjs/generate.js +120 -82
- package/dist/commonjs/generate.js.map +1 -1
- package/dist/commonjs/index.js +2 -2
- package/dist/commonjs/index.js.map +1 -1
- package/dist/module/addon/index.js +31 -31
- package/dist/module/addon/index.js.map +1 -1
- package/dist/module/generate.js +119 -77
- package/dist/module/generate.js.map +1 -1
- package/dist/module/index.js +2 -2
- package/dist/module/index.js.map +1 -1
- package/dist/typescript/addon/index.d.ts.map +1 -1
- package/dist/typescript/generate.d.ts +25 -16
- package/dist/typescript/generate.d.ts.map +1 -1
- package/dist/typescript/index.d.ts +22 -4
- package/dist/typescript/index.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/generate.ts +185 -77
- package/src/index.ts +32 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/generate.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/generate.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAM7C,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAsB,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AAItD,OAAc,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAErC,OAAkB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAM/D,KAAK,SAAS,GAAG,CAAC,SAAS,GAAG,KAAK,GAAG,KAAK,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MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,kBA6lBA,CAAC;AAEF,KAAK,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE;QACR,WAAW,CAAC,EAAE,mBAAmB,GAAG,YAAY,CAAC;QACjD,oBAAoB,CAAC,EAAE,OAAO,CAAC;KAChC,CAAC;CACH,CAAC,CAAC;AAgTH,eAAO,MAAM,YAAY,EAAE,UA8B1B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ImageRequireSource, ImageResizeMode, ImageSourcePropType, ImageStyle, ViewStyle } from "react-native";
|
|
2
2
|
export type Config = {
|
|
3
3
|
fade?: boolean;
|
|
4
4
|
};
|
|
@@ -26,10 +26,28 @@ export type UseHideAnimationConfig = {
|
|
|
26
26
|
statusBarTranslucent?: boolean;
|
|
27
27
|
navigationBarTranslucent?: boolean;
|
|
28
28
|
};
|
|
29
|
+
export type ContainerProps = {
|
|
30
|
+
style: ViewStyle;
|
|
31
|
+
onLayout: () => void;
|
|
32
|
+
};
|
|
33
|
+
export type LogoProps = {
|
|
34
|
+
source: ImageSourcePropType;
|
|
35
|
+
fadeDuration?: number;
|
|
36
|
+
resizeMode?: ImageResizeMode;
|
|
37
|
+
style?: ImageStyle;
|
|
38
|
+
onLoadEnd?: () => void;
|
|
39
|
+
};
|
|
40
|
+
export type BrandProps = {
|
|
41
|
+
source: ImageSourcePropType;
|
|
42
|
+
fadeDuration?: number;
|
|
43
|
+
resizeMode?: ImageResizeMode;
|
|
44
|
+
style?: ImageStyle;
|
|
45
|
+
onLoadEnd?: () => void;
|
|
46
|
+
};
|
|
29
47
|
export type UseHideAnimation = {
|
|
30
|
-
container:
|
|
31
|
-
logo:
|
|
32
|
-
brand:
|
|
48
|
+
container: ContainerProps;
|
|
49
|
+
logo: LogoProps;
|
|
50
|
+
brand: BrandProps;
|
|
33
51
|
};
|
|
34
52
|
export declare function hide(config?: Config): Promise<void>;
|
|
35
53
|
export declare function isVisible(): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,UAAU,EAGV,SAAS,EACV,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,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,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,cAAc,GAAG;IAC3B,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,cAAc,CAAC;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;CACnB,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,oBAoL9D;;;;;;AAED,wBAIE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-bootsplash",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.8",
|
|
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>",
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
"react-native": ">=0.70.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@emotion/hash": "^0.9.1",
|
|
68
67
|
"@expo/config": "^8.1.2 || ^9.0.1",
|
|
69
68
|
"@expo/config-plugins": "^7.2.5 || ^8.0.4",
|
|
70
69
|
"detect-indent": "^6.1.0",
|
package/src/generate.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import murmurhash from "@emotion/hash";
|
|
2
1
|
import { getConfig as getExpoConfig } from "@expo/config";
|
|
3
2
|
import * as Expo from "@expo/config-plugins";
|
|
4
3
|
import { assignColorValue } from "@expo/config-plugins/build/android/Colors";
|
|
@@ -10,9 +9,10 @@ import {
|
|
|
10
9
|
AndroidProjectConfig,
|
|
11
10
|
IOSProjectConfig,
|
|
12
11
|
} from "@react-native-community/cli-types";
|
|
12
|
+
import crypto from "crypto";
|
|
13
13
|
import detectIndent from "detect-indent";
|
|
14
14
|
import fs from "fs-extra";
|
|
15
|
-
import { parse as parseHtml } from "node-html-parser";
|
|
15
|
+
import { HTMLElement, parse as parseHtml } from "node-html-parser";
|
|
16
16
|
import path from "path";
|
|
17
17
|
import pc from "picocolors";
|
|
18
18
|
import { Options as PrettierOptions } from "prettier";
|
|
@@ -27,7 +27,7 @@ import { Manifest } from ".";
|
|
|
27
27
|
const workingPath = process.env.INIT_CWD ?? process.env.PWD ?? process.cwd();
|
|
28
28
|
const projectRoot = findProjectRoot(workingPath);
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
type Platforms = ("android" | "ios" | "web")[];
|
|
31
31
|
|
|
32
32
|
export type RGBColor = {
|
|
33
33
|
R: string;
|
|
@@ -35,7 +35,7 @@ export type RGBColor = {
|
|
|
35
35
|
B: string;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
type Color = {
|
|
39
39
|
hex: string;
|
|
40
40
|
rgb: RGBColor;
|
|
41
41
|
};
|
|
@@ -60,7 +60,7 @@ export const log = {
|
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
const parseColor = (value: string): Color => {
|
|
64
64
|
const up = value.toUpperCase().replace(/[^0-9A-F]/g, "");
|
|
65
65
|
|
|
66
66
|
if (up.length !== 3 && up.length !== 6) {
|
|
@@ -185,62 +185,75 @@ export const writeJson = (filePath: string, content: object) => {
|
|
|
185
185
|
log.write(filePath);
|
|
186
186
|
};
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
type FormatOptions = { indent?: detectIndent.Indent } & (
|
|
189
|
+
| {
|
|
190
|
+
formatter: "prettier";
|
|
191
|
+
selfClosingTags?: boolean;
|
|
192
|
+
useCssPlugin?: boolean;
|
|
193
|
+
htmlWhitespaceSensitivity?: PrettierOptions["htmlWhitespaceSensitivity"];
|
|
194
|
+
singleAttributePerLine?: PrettierOptions["singleAttributePerLine"];
|
|
195
|
+
}
|
|
196
|
+
| {
|
|
197
|
+
formatter: "xmlFormatter";
|
|
198
|
+
whiteSpaceAtEndOfSelfclosingTag?: XMLFormatterOptions["whiteSpaceAtEndOfSelfclosingTag"];
|
|
199
|
+
}
|
|
200
|
+
);
|
|
191
201
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
};
|
|
202
|
+
export const readXmlLike = (filePath: string) => {
|
|
203
|
+
const content = hfs.text(filePath);
|
|
195
204
|
|
|
196
|
-
return {
|
|
205
|
+
return {
|
|
206
|
+
root: parseHtml(content),
|
|
207
|
+
formatOptions: { indent: detectIndent(content) },
|
|
208
|
+
};
|
|
197
209
|
};
|
|
198
210
|
|
|
199
|
-
export const
|
|
211
|
+
export const writeXmlLike = async (
|
|
200
212
|
filePath: string,
|
|
201
213
|
content: string,
|
|
202
|
-
|
|
214
|
+
{ indent, ...formatOptions }: FormatOptions,
|
|
203
215
|
) => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const formatOptions: PrettierOptions = {
|
|
222
|
-
useTabs: type === "tab",
|
|
223
|
-
tabWidth: amount || 2,
|
|
224
|
-
};
|
|
216
|
+
if (formatOptions.formatter === "prettier") {
|
|
217
|
+
const {
|
|
218
|
+
formatter,
|
|
219
|
+
useCssPlugin = false,
|
|
220
|
+
selfClosingTags = false,
|
|
221
|
+
...options
|
|
222
|
+
} = formatOptions;
|
|
223
|
+
|
|
224
|
+
const formatted = await prettier.format(content, {
|
|
225
|
+
parser: "html",
|
|
226
|
+
bracketSameLine: true,
|
|
227
|
+
printWidth: 10000,
|
|
228
|
+
plugins: [htmlPlugin, ...(useCssPlugin ? [cssPlugin] : [])],
|
|
229
|
+
useTabs: indent?.type === "tab",
|
|
230
|
+
tabWidth: (indent?.amount ?? 0) || 2,
|
|
231
|
+
...options,
|
|
232
|
+
});
|
|
225
233
|
|
|
226
|
-
|
|
227
|
-
|
|
234
|
+
hfs.write(
|
|
235
|
+
filePath,
|
|
236
|
+
selfClosingTags
|
|
237
|
+
? formatted.replace(/><\/[a-z-0-9]+>/gi, " />")
|
|
238
|
+
: formatted,
|
|
239
|
+
);
|
|
228
240
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
+
log.write(filePath);
|
|
242
|
+
} else {
|
|
243
|
+
const { formatter, ...options } = formatOptions;
|
|
244
|
+
|
|
245
|
+
const formatted = formatXml(content, {
|
|
246
|
+
collapseContent: true,
|
|
247
|
+
forceSelfClosingEmptyTag: true,
|
|
248
|
+
lineSeparator: "\n",
|
|
249
|
+
whiteSpaceAtEndOfSelfclosingTag: true,
|
|
250
|
+
indentation: (indent?.indent ?? "") || " ",
|
|
251
|
+
...options,
|
|
252
|
+
});
|
|
241
253
|
|
|
242
|
-
|
|
243
|
-
|
|
254
|
+
hfs.write(filePath, formatted);
|
|
255
|
+
log.write(filePath);
|
|
256
|
+
}
|
|
244
257
|
};
|
|
245
258
|
|
|
246
259
|
const cleanIOS = (dir: string) => {
|
|
@@ -316,7 +329,11 @@ const getFileNameSuffix = async ({
|
|
|
316
329
|
.map((key) => record[key])
|
|
317
330
|
.join();
|
|
318
331
|
|
|
319
|
-
return
|
|
332
|
+
return crypto
|
|
333
|
+
.createHash("shake256", { outputLength: 3 })
|
|
334
|
+
.update(stableKey)
|
|
335
|
+
.digest("hex")
|
|
336
|
+
.toLowerCase();
|
|
320
337
|
};
|
|
321
338
|
|
|
322
339
|
const ensureSupportedFormat = async (
|
|
@@ -402,8 +419,8 @@ const getAndroidOutputPath = ({
|
|
|
402
419
|
};
|
|
403
420
|
|
|
404
421
|
const getIOSOutputPath = ({
|
|
405
|
-
assetsOutputPath,
|
|
406
422
|
ios,
|
|
423
|
+
assetsOutputPath,
|
|
407
424
|
isExpo,
|
|
408
425
|
platforms,
|
|
409
426
|
}: {
|
|
@@ -466,7 +483,7 @@ const getHtmlTemplatePath = ({
|
|
|
466
483
|
return htmlTemplatePath;
|
|
467
484
|
};
|
|
468
485
|
|
|
469
|
-
|
|
486
|
+
const getImageHeight = (
|
|
470
487
|
image: Sharp | undefined,
|
|
471
488
|
width: number,
|
|
472
489
|
): Promise<number> => {
|
|
@@ -735,6 +752,29 @@ export const generate = async ({
|
|
|
735
752
|
);
|
|
736
753
|
|
|
737
754
|
if (!isExpo) {
|
|
755
|
+
const manifestXmlPath = path.resolve(
|
|
756
|
+
androidOutputPath,
|
|
757
|
+
"..",
|
|
758
|
+
"AndroidManifest.xml",
|
|
759
|
+
);
|
|
760
|
+
|
|
761
|
+
const manifestXml = readXmlLike(manifestXmlPath);
|
|
762
|
+
const activities = manifestXml.root.querySelectorAll("activity");
|
|
763
|
+
|
|
764
|
+
for (const activity of activities) {
|
|
765
|
+
if (activity.getAttribute("android:name") === ".MainActivity") {
|
|
766
|
+
activity.setAttribute("android:theme", "@style/BootTheme");
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
await writeXmlLike(manifestXmlPath, manifestXml.root.toString(), {
|
|
771
|
+
...manifestXml.formatOptions,
|
|
772
|
+
formatter: "prettier",
|
|
773
|
+
htmlWhitespaceSensitivity: "ignore",
|
|
774
|
+
selfClosingTags: true,
|
|
775
|
+
singleAttributePerLine: true,
|
|
776
|
+
});
|
|
777
|
+
|
|
738
778
|
const valuesPath = path.resolve(androidOutputPath, "values");
|
|
739
779
|
hfs.ensureDir(valuesPath);
|
|
740
780
|
|
|
@@ -742,23 +782,86 @@ export const generate = async ({
|
|
|
742
782
|
const colorsXmlEntry = `<color name="bootsplash_background">${background.hex}</color>`;
|
|
743
783
|
|
|
744
784
|
if (hfs.exists(colorsXmlPath)) {
|
|
745
|
-
const
|
|
785
|
+
const colorsXml = readXmlLike(colorsXmlPath);
|
|
746
786
|
const nextColor = parseHtml(colorsXmlEntry);
|
|
747
787
|
|
|
748
|
-
const prevColor = root.querySelector(
|
|
788
|
+
const prevColor = colorsXml.root.querySelector(
|
|
749
789
|
'color[name="bootsplash_background"]',
|
|
750
790
|
);
|
|
751
791
|
|
|
752
792
|
if (prevColor != null) {
|
|
753
793
|
prevColor.replaceWith(nextColor);
|
|
754
794
|
} else {
|
|
755
|
-
root.querySelector("resources")?.appendChild(nextColor);
|
|
795
|
+
colorsXml.root.querySelector("resources")?.appendChild(nextColor);
|
|
756
796
|
}
|
|
757
797
|
|
|
758
|
-
|
|
798
|
+
await writeXmlLike(colorsXmlPath, colorsXml.root.toString(), {
|
|
799
|
+
...colorsXml.formatOptions,
|
|
800
|
+
formatter: "xmlFormatter",
|
|
801
|
+
});
|
|
759
802
|
} else {
|
|
760
|
-
|
|
803
|
+
await writeXmlLike(
|
|
804
|
+
colorsXmlPath,
|
|
805
|
+
`<resources>${colorsXmlEntry}</resources>`,
|
|
806
|
+
{ formatter: "xmlFormatter" },
|
|
807
|
+
);
|
|
761
808
|
}
|
|
809
|
+
|
|
810
|
+
const stylesXmlPath = path.resolve(valuesPath, "styles.xml");
|
|
811
|
+
const stylesXml = readXmlLike(stylesXmlPath);
|
|
812
|
+
|
|
813
|
+
const prevStyle = stylesXml.root.querySelector('style[name="BootTheme"]');
|
|
814
|
+
const parent = prevStyle?.getAttribute("parent") ?? "Theme.BootSplash";
|
|
815
|
+
|
|
816
|
+
const extraItems = parseHtml(
|
|
817
|
+
prevStyle?.text
|
|
818
|
+
.split("\n")
|
|
819
|
+
.map((line) => line.trim())
|
|
820
|
+
.join("") ?? "",
|
|
821
|
+
)
|
|
822
|
+
.childNodes.filter((node) => {
|
|
823
|
+
if (!(node instanceof HTMLElement)) {
|
|
824
|
+
return true;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
const name = node.getAttribute("name");
|
|
828
|
+
|
|
829
|
+
return (
|
|
830
|
+
name !== "bootSplashBackground" &&
|
|
831
|
+
name !== "bootSplashLogo" &&
|
|
832
|
+
name !== "bootSplashBrand" &&
|
|
833
|
+
name !== "postBootSplashTheme"
|
|
834
|
+
);
|
|
835
|
+
})
|
|
836
|
+
.map((node) => node.toString());
|
|
837
|
+
|
|
838
|
+
const styleItems: string[] = [
|
|
839
|
+
...(extraItems.length > 0 ? [...extraItems, ""] : []),
|
|
840
|
+
|
|
841
|
+
'<item name="bootSplashBackground">@color/bootsplash_background</item>',
|
|
842
|
+
'<item name="bootSplashLogo">@drawable/bootsplash_logo</item>',
|
|
843
|
+
|
|
844
|
+
...(brand != null && brandPath != null
|
|
845
|
+
? ['<item name="bootSplashBrand">@drawable/bootsplash_brand</item>']
|
|
846
|
+
: []),
|
|
847
|
+
|
|
848
|
+
'<item name="postBootSplashTheme">@style/AppTheme</item>',
|
|
849
|
+
];
|
|
850
|
+
|
|
851
|
+
const nextStyle = parseHtml(dedent`
|
|
852
|
+
<style name="BootTheme" parent="${parent}">
|
|
853
|
+
${styleItems.join("\n")}
|
|
854
|
+
</style>
|
|
855
|
+
`);
|
|
856
|
+
|
|
857
|
+
prevStyle?.remove(); // remove the existing style
|
|
858
|
+
stylesXml.root.querySelector("resources")?.appendChild(nextStyle);
|
|
859
|
+
|
|
860
|
+
await writeXmlLike(stylesXmlPath, stylesXml.root.toString(), {
|
|
861
|
+
...stylesXml.formatOptions,
|
|
862
|
+
formatter: "prettier",
|
|
863
|
+
htmlWhitespaceSensitivity: "ignore",
|
|
864
|
+
});
|
|
762
865
|
}
|
|
763
866
|
}
|
|
764
867
|
|
|
@@ -785,7 +888,7 @@ export const generate = async ({
|
|
|
785
888
|
hfs.ensureDir(colorsSetPath);
|
|
786
889
|
hfs.ensureDir(imageSetPath);
|
|
787
890
|
|
|
788
|
-
|
|
891
|
+
await writeXmlLike(
|
|
789
892
|
storyboardPath,
|
|
790
893
|
getStoryboard({
|
|
791
894
|
logoHeight,
|
|
@@ -793,7 +896,10 @@ export const generate = async ({
|
|
|
793
896
|
background: background.rgb,
|
|
794
897
|
fileNameSuffix,
|
|
795
898
|
}),
|
|
796
|
-
{
|
|
899
|
+
{
|
|
900
|
+
formatter: "xmlFormatter",
|
|
901
|
+
whiteSpaceAtEndOfSelfclosingTag: false,
|
|
902
|
+
},
|
|
797
903
|
);
|
|
798
904
|
|
|
799
905
|
writeJson(path.resolve(colorsSetPath, "Contents.json"), {
|
|
@@ -919,9 +1025,9 @@ export const generate = async ({
|
|
|
919
1025
|
if (htmlTemplatePath != null) {
|
|
920
1026
|
log.title("🌐", "Web");
|
|
921
1027
|
|
|
922
|
-
const
|
|
1028
|
+
const htmlTemplate = readXmlLike(htmlTemplatePath);
|
|
923
1029
|
const { format } = await logo.metadata();
|
|
924
|
-
const prevStyle = root.querySelector("#bootsplash-style");
|
|
1030
|
+
const prevStyle = htmlTemplate.root.querySelector("#bootsplash-style");
|
|
925
1031
|
|
|
926
1032
|
const base64 = (
|
|
927
1033
|
format === "svg"
|
|
@@ -960,10 +1066,10 @@ export const generate = async ({
|
|
|
960
1066
|
if (prevStyle != null) {
|
|
961
1067
|
prevStyle.replaceWith(nextStyle);
|
|
962
1068
|
} else {
|
|
963
|
-
root.querySelector("head")?.appendChild(nextStyle);
|
|
1069
|
+
htmlTemplate.root.querySelector("head")?.appendChild(nextStyle);
|
|
964
1070
|
}
|
|
965
1071
|
|
|
966
|
-
const prevDiv = root.querySelector("#bootsplash");
|
|
1072
|
+
const prevDiv = htmlTemplate.root.querySelector("#bootsplash");
|
|
967
1073
|
|
|
968
1074
|
const nextDiv = parseHtml(dedent`
|
|
969
1075
|
<div id="bootsplash">
|
|
@@ -974,10 +1080,14 @@ export const generate = async ({
|
|
|
974
1080
|
if (prevDiv != null) {
|
|
975
1081
|
prevDiv.replaceWith(nextDiv);
|
|
976
1082
|
} else {
|
|
977
|
-
root.querySelector("body")?.appendChild(nextDiv);
|
|
1083
|
+
htmlTemplate.root.querySelector("body")?.appendChild(nextDiv);
|
|
978
1084
|
}
|
|
979
1085
|
|
|
980
|
-
await
|
|
1086
|
+
await writeXmlLike(htmlTemplatePath, htmlTemplate.root.toString(), {
|
|
1087
|
+
...htmlTemplate.formatOptions,
|
|
1088
|
+
formatter: "prettier",
|
|
1089
|
+
useCssPlugin: true,
|
|
1090
|
+
});
|
|
981
1091
|
}
|
|
982
1092
|
|
|
983
1093
|
log.title("📄", "Assets");
|
|
@@ -1061,15 +1171,13 @@ ${pc.blue("┗━━━━━━━━━━━━━━━━━━━━━━
|
|
|
1061
1171
|
);
|
|
1062
1172
|
};
|
|
1063
1173
|
|
|
1064
|
-
|
|
1174
|
+
type ExpoPlugin = Expo.ConfigPlugin<{
|
|
1065
1175
|
assetsDir?: string;
|
|
1066
1176
|
android?: {
|
|
1067
1177
|
parentTheme?: "TransparentStatus" | "EdgeToEdge";
|
|
1068
1178
|
darkContentBarsStyle?: boolean;
|
|
1069
1179
|
};
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
export type ExpoPlugin = Expo.ConfigPlugin<ExpoProps>;
|
|
1180
|
+
}>;
|
|
1073
1181
|
|
|
1074
1182
|
const withAndroidAssets: ExpoPlugin = (config, props) =>
|
|
1075
1183
|
Expo.withDangerousMod(config, [
|
|
@@ -1323,12 +1431,12 @@ const withAppDelegate: ExpoPlugin = (config) =>
|
|
|
1323
1431
|
offset: 0,
|
|
1324
1432
|
anchor: /@end/,
|
|
1325
1433
|
newSrc: dedent`
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1434
|
+
- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initProps:(NSDictionary *)initProps {
|
|
1435
|
+
UIView *rootView = [super createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps];
|
|
1436
|
+
[RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView];
|
|
1437
|
+
return rootView;
|
|
1438
|
+
}
|
|
1439
|
+
`,
|
|
1332
1440
|
});
|
|
1333
1441
|
|
|
1334
1442
|
return {
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import {
|
|
3
|
-
ImageProps,
|
|
4
3
|
ImageRequireSource,
|
|
4
|
+
ImageResizeMode,
|
|
5
|
+
ImageSourcePropType,
|
|
6
|
+
ImageStyle,
|
|
5
7
|
Platform,
|
|
6
8
|
StyleSheet,
|
|
7
|
-
ViewProps,
|
|
8
9
|
ViewStyle,
|
|
9
10
|
} from "react-native";
|
|
10
11
|
import NativeModule from "./NativeRNBootSplash";
|
|
@@ -42,10 +43,31 @@ export type UseHideAnimationConfig = {
|
|
|
42
43
|
navigationBarTranslucent?: boolean;
|
|
43
44
|
};
|
|
44
45
|
|
|
46
|
+
export type ContainerProps = {
|
|
47
|
+
style: ViewStyle;
|
|
48
|
+
onLayout: () => void;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type LogoProps = {
|
|
52
|
+
source: ImageSourcePropType;
|
|
53
|
+
fadeDuration?: number;
|
|
54
|
+
resizeMode?: ImageResizeMode;
|
|
55
|
+
style?: ImageStyle;
|
|
56
|
+
onLoadEnd?: () => void;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type BrandProps = {
|
|
60
|
+
source: ImageSourcePropType;
|
|
61
|
+
fadeDuration?: number;
|
|
62
|
+
resizeMode?: ImageResizeMode;
|
|
63
|
+
style?: ImageStyle;
|
|
64
|
+
onLoadEnd?: () => void;
|
|
65
|
+
};
|
|
66
|
+
|
|
45
67
|
export type UseHideAnimation = {
|
|
46
|
-
container:
|
|
47
|
-
logo:
|
|
48
|
-
brand:
|
|
68
|
+
container: ContainerProps;
|
|
69
|
+
logo: LogoProps;
|
|
70
|
+
brand: BrandProps;
|
|
49
71
|
};
|
|
50
72
|
|
|
51
73
|
export function hide(config: Config = {}): Promise<void> {
|
|
@@ -149,7 +171,7 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
|
|
|
149
171
|
justifyContent: "center",
|
|
150
172
|
};
|
|
151
173
|
|
|
152
|
-
const container:
|
|
174
|
+
const container: ContainerProps = {
|
|
153
175
|
style: containerStyle,
|
|
154
176
|
onLayout: () => {
|
|
155
177
|
ref.current.layoutReady = true;
|
|
@@ -157,13 +179,13 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
|
|
|
157
179
|
},
|
|
158
180
|
};
|
|
159
181
|
|
|
160
|
-
const logo:
|
|
182
|
+
const logo: LogoProps =
|
|
161
183
|
logoFinalSrc == null
|
|
162
184
|
? { source: -1 }
|
|
163
185
|
: {
|
|
186
|
+
source: logoFinalSrc,
|
|
164
187
|
fadeDuration: 0,
|
|
165
188
|
resizeMode: "contain",
|
|
166
|
-
source: logoFinalSrc,
|
|
167
189
|
style: {
|
|
168
190
|
width: logoWidth,
|
|
169
191
|
height: logoHeight,
|
|
@@ -174,13 +196,13 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
|
|
|
174
196
|
},
|
|
175
197
|
};
|
|
176
198
|
|
|
177
|
-
const brand:
|
|
199
|
+
const brand: BrandProps =
|
|
178
200
|
brandFinalSrc == null
|
|
179
201
|
? { source: -1 }
|
|
180
202
|
: {
|
|
203
|
+
source: brandFinalSrc,
|
|
181
204
|
fadeDuration: 0,
|
|
182
205
|
resizeMode: "contain",
|
|
183
|
-
source: brandFinalSrc,
|
|
184
206
|
style: {
|
|
185
207
|
position: "absolute",
|
|
186
208
|
bottom: Platform.OS === "web" ? 60 : brandBottom,
|