react-native-bootsplash 7.0.0-beta.1 → 7.0.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.
- package/README.md +83 -12
- package/app.plugin.js +1 -1
- package/dist/commonjs/addon/index.js +31 -31
- package/dist/commonjs/addon/index.js.map +1 -1
- package/dist/commonjs/expo.js +325 -0
- package/dist/commonjs/expo.js.map +1 -0
- package/dist/commonjs/generate.js +34 -336
- package/dist/commonjs/generate.js.map +1 -1
- package/dist/module/addon/index.js +31 -31
- package/dist/module/addon/index.js.map +1 -1
- package/dist/module/expo.js +319 -0
- package/dist/module/expo.js.map +1 -0
- package/dist/module/generate.js +32 -342
- package/dist/module/generate.js.map +1 -1
- package/dist/typescript/addon/index.d.ts +23 -20
- package/dist/typescript/addon/index.d.ts.map +1 -1
- package/dist/typescript/expo.d.ts +6 -0
- package/dist/typescript/expo.d.ts.map +1 -0
- package/dist/typescript/generate.d.ts +50 -14
- package/dist/typescript/generate.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/expo.ts +382 -0
- package/src/generate.ts +62 -427
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import * as Expo from "@expo/config-plugins";
|
|
2
2
|
import { type AddonConfig, type Props } from "../generate";
|
|
3
|
-
|
|
4
|
-
androidOutputPath:
|
|
5
|
-
props:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
props:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
props:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
props:
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
declare const _default: {
|
|
4
|
+
execute: ({ props, androidOutputPath, iosOutputPath, htmlTemplatePath, }: AddonConfig) => Promise<void>;
|
|
5
|
+
writeAndroidAssets: ({ androidOutputPath, props, }: {
|
|
6
|
+
androidOutputPath: string;
|
|
7
|
+
props: Props;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
writeIOSAssets: ({ iosOutputPath, props, }: {
|
|
10
|
+
iosOutputPath: string;
|
|
11
|
+
props: Props;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
writeWebAssets: ({ htmlTemplatePath, props, }: {
|
|
14
|
+
htmlTemplatePath: string;
|
|
15
|
+
props: Props;
|
|
16
|
+
}) => Promise<void>;
|
|
17
|
+
writeGenericAssets: ({ props }: {
|
|
18
|
+
props: Props;
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
withAndroidColorsNight: ({ config, props, }: {
|
|
21
|
+
config: Expo.ExportedConfigWithProps;
|
|
22
|
+
props: Props;
|
|
23
|
+
}) => Promise<Expo.ExportedConfigWithProps>;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
23
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/addon/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAS7C,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/addon/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAS7C,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,KAAK,EAOX,MAAM,aAAa,CAAC;;8EA2wBlB,WAAW;wDArdX;QACD,iBAAiB,EAAE,MAAM,CAAC;QAC1B,KAAK,EAAE,KAAK,CAAC;KACd;gDA0CE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,EAAE,KAAK,CAAC;KACd;mDA4NE;QACD,gBAAgB,EAAE,MAAM,CAAC;QACzB,KAAK,EAAE,KAAK,CAAC;KACd;oCAmH4C;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE;iDA4D1D;QACD,MAAM,EAAE,IAAI,CAAC,uBAAuB,CAAC;QACrC,KAAK,EAAE,KAAK,CAAC;KACd,KAAG,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC;;AA4EzC,wBAO4C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expo.d.ts","sourceRoot":"","sources":["../../src/expo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAS7C,OAAO,EACL,KAAK,QAAQ,EAWd,MAAM,YAAY,CAAC;AA8SpB,eAAO,MAAM,cAAc;UACI,MAAM;eAyDtB,CAAC"}
|
|
@@ -4,8 +4,8 @@ import { HTMLElement } from "node-html-parser";
|
|
|
4
4
|
import type { Options as PrettierOptions } from "prettier";
|
|
5
5
|
import { type Sharp } from "sharp";
|
|
6
6
|
import { type XMLFormatterOptions } from "xml-formatter";
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
type Platforms = ("android" | "ios" | "web")[];
|
|
8
|
+
type RGBColor = {
|
|
9
9
|
R: string;
|
|
10
10
|
G: string;
|
|
11
11
|
B: string;
|
|
@@ -14,6 +14,8 @@ type Color = {
|
|
|
14
14
|
hex: string;
|
|
15
15
|
rgb: RGBColor;
|
|
16
16
|
};
|
|
17
|
+
export declare const packageName = "react-native-bootsplash";
|
|
18
|
+
export declare const setIsExpo: (value: boolean) => void;
|
|
17
19
|
export declare const log: {
|
|
18
20
|
error: (text: string) => void;
|
|
19
21
|
title: (emoji: string, text: string) => void;
|
|
@@ -55,7 +57,14 @@ export declare const readXmlLike: (filePath: string) => {
|
|
|
55
57
|
};
|
|
56
58
|
};
|
|
57
59
|
export declare const writeXmlLike: (filePath: string, content: string, { indent, ...formatOptions }: FormatOptions) => Promise<void>;
|
|
58
|
-
type
|
|
60
|
+
export type Asset = {
|
|
61
|
+
path: string;
|
|
62
|
+
image: Sharp;
|
|
63
|
+
hash: string;
|
|
64
|
+
height: number;
|
|
65
|
+
width: number;
|
|
66
|
+
};
|
|
67
|
+
export type RawProps = {
|
|
59
68
|
logo: string;
|
|
60
69
|
background: string;
|
|
61
70
|
logoWidth: number;
|
|
@@ -70,14 +79,7 @@ type RawProps = {
|
|
|
70
79
|
darkContentBarsStyle?: boolean;
|
|
71
80
|
};
|
|
72
81
|
};
|
|
73
|
-
export
|
|
74
|
-
path: string;
|
|
75
|
-
image: Sharp;
|
|
76
|
-
hash: string;
|
|
77
|
-
height: number;
|
|
78
|
-
width: number;
|
|
79
|
-
};
|
|
80
|
-
declare const transformProps: (rootPath: string, { android, licenseKey, ...rawProps }: RawProps) => Promise<{
|
|
82
|
+
export declare const transformProps: (rootPath: string, { android, licenseKey, ...rawProps }: RawProps) => Promise<{
|
|
81
83
|
android: {
|
|
82
84
|
darkContentBarsStyle?: boolean;
|
|
83
85
|
};
|
|
@@ -93,12 +95,49 @@ declare const transformProps: (rootPath: string, { android, licenseKey, ...rawPr
|
|
|
93
95
|
fileNameSuffix: string;
|
|
94
96
|
}>;
|
|
95
97
|
export type Props = Awaited<ReturnType<typeof transformProps>>;
|
|
98
|
+
export declare const writeAndroidAssets: ({ androidOutputPath, props, }: {
|
|
99
|
+
androidOutputPath: string;
|
|
100
|
+
props: Props;
|
|
101
|
+
}) => Promise<void>;
|
|
102
|
+
export declare const writeIOSAssets: ({ iosOutputPath, props, }: {
|
|
103
|
+
iosOutputPath: string;
|
|
104
|
+
props: Props;
|
|
105
|
+
}) => Promise<void>;
|
|
106
|
+
export declare const writeWebAssets: ({ htmlTemplatePath, props, }: {
|
|
107
|
+
htmlTemplatePath: string;
|
|
108
|
+
props: Props;
|
|
109
|
+
}) => Promise<void>;
|
|
110
|
+
export declare const writeGenericAssets: ({ props }: {
|
|
111
|
+
props: Props;
|
|
112
|
+
}) => Promise<void>;
|
|
96
113
|
export type AddonConfig = {
|
|
97
114
|
props: Props;
|
|
98
115
|
androidOutputPath: string | void;
|
|
99
116
|
iosOutputPath: string | void;
|
|
100
117
|
htmlTemplatePath: string | void;
|
|
101
118
|
};
|
|
119
|
+
export declare const requireAddon: ({ executeAddon, licenseKey, }: Props) => {
|
|
120
|
+
execute: (config: AddonConfig) => Promise<void>;
|
|
121
|
+
writeAndroidAssets: (_: {
|
|
122
|
+
androidOutputPath: string;
|
|
123
|
+
props: Props;
|
|
124
|
+
}) => Promise<void>;
|
|
125
|
+
writeIOSAssets: (_: {
|
|
126
|
+
iosOutputPath: string;
|
|
127
|
+
props: Props;
|
|
128
|
+
}) => Promise<void>;
|
|
129
|
+
writeWebAssets: (_: {
|
|
130
|
+
htmlTemplatePath: string;
|
|
131
|
+
props: Props;
|
|
132
|
+
}) => Promise<void>;
|
|
133
|
+
writeGenericAssets: (_: {
|
|
134
|
+
props: Props;
|
|
135
|
+
}) => Promise<void>;
|
|
136
|
+
withAndroidColorsNight: (_: {
|
|
137
|
+
config: Expo.ExportedConfigWithProps;
|
|
138
|
+
props: Props;
|
|
139
|
+
}) => Promise<Expo.ExportedConfigWithProps>;
|
|
140
|
+
} | undefined;
|
|
102
141
|
export declare const generate: ({ platforms, html, flavor, plist, ...rawProps }: {
|
|
103
142
|
platforms: Platforms;
|
|
104
143
|
html: string;
|
|
@@ -115,8 +154,5 @@ export declare const generate: ({ platforms, html, flavor, plist, ...rawProps }:
|
|
|
115
154
|
darkLogo?: string;
|
|
116
155
|
darkBrand?: string;
|
|
117
156
|
}) => Promise<void>;
|
|
118
|
-
export declare const withBootSplash: Expo.ConfigPlugin<(Partial<RawProps> & {
|
|
119
|
-
logo: string;
|
|
120
|
-
}) | undefined>;
|
|
121
157
|
export {};
|
|
122
158
|
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/generate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/generate.ts"],"names":[],"mappings":"AAAA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MAAM,CAAC;QACzB,KAAK,EAAE,KAAK,CAAC;KACd,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpB,kBAAkB,EAAE,CAAC,CAAC,EAAE;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3D,sBAAsB,EAAE,CAAC,CAAC,EAAE;QAC1B,MAAM,EAAE,IAAI,CAAC,uBAAuB,CAAC;QACrC,KAAK,EAAE,KAAK,CAAC;KACd,KAAK,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;CAC7C,GACD,SASH,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAU,iDAM5B;IACD,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,kBAuNA,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-bootsplash",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
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>",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"fs-extra": "^11.3.3",
|
|
77
77
|
"node-html-parser": "^7.0.2",
|
|
78
78
|
"picocolors": "^1.1.1",
|
|
79
|
-
"prettier": "^3.
|
|
79
|
+
"prettier": "^3.8.1",
|
|
80
80
|
"react-native-is-edge-to-edge": "^1.2.1",
|
|
81
81
|
"sharp": "^0.34.5",
|
|
82
82
|
"ts-dedent": "^2.2.0",
|
|
@@ -87,10 +87,10 @@
|
|
|
87
87
|
"@babel/preset-env": "^7.25.3",
|
|
88
88
|
"@react-native-community/cli-types": "^20.0.0",
|
|
89
89
|
"@types/fs-extra": "^11.0.4",
|
|
90
|
-
"@types/node": "^20.19.
|
|
90
|
+
"@types/node": "^20.19.30",
|
|
91
91
|
"@types/react": "^19.2.0",
|
|
92
92
|
"@types/semver": "^7.7.1",
|
|
93
|
-
"oxlint": "^1.
|
|
93
|
+
"oxlint": "^1.41.0",
|
|
94
94
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
95
95
|
"react": "19.2.0",
|
|
96
96
|
"react-native": "0.83.1",
|
package/src/expo.ts
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import * as Expo from "@expo/config-plugins";
|
|
2
|
+
import { assignColorValue } from "@expo/config-plugins/build/android/Colors";
|
|
3
|
+
import { addImports } from "@expo/config-plugins/build/android/codeMod";
|
|
4
|
+
import { mergeContents } from "@expo/config-plugins/build/utils/generateCode";
|
|
5
|
+
import childProcess from "child_process";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import semver from "semver";
|
|
8
|
+
import { dedent } from "ts-dedent";
|
|
9
|
+
import util from "util";
|
|
10
|
+
import {
|
|
11
|
+
type RawProps,
|
|
12
|
+
hfs,
|
|
13
|
+
log,
|
|
14
|
+
packageName,
|
|
15
|
+
requireAddon,
|
|
16
|
+
setIsExpo,
|
|
17
|
+
transformProps,
|
|
18
|
+
writeAndroidAssets,
|
|
19
|
+
writeGenericAssets,
|
|
20
|
+
writeIOSAssets,
|
|
21
|
+
writeWebAssets,
|
|
22
|
+
} from "./generate";
|
|
23
|
+
|
|
24
|
+
const promisifiedExec = util.promisify(childProcess.exec);
|
|
25
|
+
|
|
26
|
+
const exec = (cmd: string) =>
|
|
27
|
+
promisifiedExec(cmd).then(({ stdout, stderr }) => stdout || stderr);
|
|
28
|
+
|
|
29
|
+
const withoutExpoSplashScreen: Expo.ConfigPlugin<RawProps> =
|
|
30
|
+
Expo.createRunOncePlugin(
|
|
31
|
+
(expoConfig) => expoConfig,
|
|
32
|
+
"expo-splash-screen",
|
|
33
|
+
"skip",
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const withAndroidAssets: Expo.ConfigPlugin<RawProps> = (expoConfig, rawProps) =>
|
|
37
|
+
Expo.withDangerousMod(expoConfig, [
|
|
38
|
+
"android",
|
|
39
|
+
async (config) => {
|
|
40
|
+
const { platformProjectRoot, projectRoot } = config.modRequest;
|
|
41
|
+
const props = await transformProps(projectRoot, rawProps);
|
|
42
|
+
const addon = requireAddon(props);
|
|
43
|
+
|
|
44
|
+
const androidOutputPath = path.resolve(
|
|
45
|
+
platformProjectRoot,
|
|
46
|
+
"app",
|
|
47
|
+
"src",
|
|
48
|
+
"main",
|
|
49
|
+
"res",
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
await writeAndroidAssets({ androidOutputPath, props });
|
|
53
|
+
await addon?.writeAndroidAssets({ androidOutputPath, props });
|
|
54
|
+
|
|
55
|
+
return config;
|
|
56
|
+
},
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
const withAndroidManifest: Expo.ConfigPlugin<RawProps> = (expoConfig) =>
|
|
60
|
+
Expo.withAndroidManifest(expoConfig, (config) => {
|
|
61
|
+
config.modResults.manifest.application?.forEach((application) => {
|
|
62
|
+
if (application.$["android:name"] === ".MainApplication") {
|
|
63
|
+
const { activity } = application;
|
|
64
|
+
|
|
65
|
+
activity?.forEach((activity) => {
|
|
66
|
+
if (activity.$["android:name"] === ".MainActivity") {
|
|
67
|
+
activity.$["android:theme"] = "@style/BootTheme";
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return config;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const withMainActivity: Expo.ConfigPlugin<RawProps> = (expoConfig) =>
|
|
77
|
+
Expo.withMainActivity(expoConfig, (config) => {
|
|
78
|
+
const { modResults } = config;
|
|
79
|
+
|
|
80
|
+
const withImports = addImports(
|
|
81
|
+
modResults.contents.replace(
|
|
82
|
+
/(\/\/ )?setTheme\(R\.style\.AppTheme\)/,
|
|
83
|
+
"// setTheme(R.style.AppTheme)",
|
|
84
|
+
),
|
|
85
|
+
["android.os.Bundle", "com.zoontek.rnbootsplash.RNBootSplash"],
|
|
86
|
+
false,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// indented with 4 spaces
|
|
90
|
+
const withInit = mergeContents({
|
|
91
|
+
src: withImports,
|
|
92
|
+
comment: " //",
|
|
93
|
+
tag: "bootsplash-init",
|
|
94
|
+
offset: 0,
|
|
95
|
+
anchor: /super\.onCreate\((null|savedInstanceState)\)/,
|
|
96
|
+
newSrc: " RNBootSplash.init(this, R.style.BootTheme)",
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
...config,
|
|
101
|
+
modResults: {
|
|
102
|
+
...modResults,
|
|
103
|
+
contents: withInit.contents,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const withAndroidStyles: Expo.ConfigPlugin<RawProps> = (expoConfig, rawProps) =>
|
|
109
|
+
Expo.withAndroidStyles(expoConfig, async (config) => {
|
|
110
|
+
const { projectRoot } = config.modRequest;
|
|
111
|
+
const { android, brand } = await transformProps(projectRoot, rawProps);
|
|
112
|
+
const { darkContentBarsStyle } = android;
|
|
113
|
+
|
|
114
|
+
const { modResults } = config;
|
|
115
|
+
const { resources } = modResults;
|
|
116
|
+
const { style = [] } = resources;
|
|
117
|
+
|
|
118
|
+
const item = [
|
|
119
|
+
{
|
|
120
|
+
$: { name: "postBootSplashTheme" },
|
|
121
|
+
_: "@style/AppTheme",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
$: { name: "bootSplashBackground" },
|
|
125
|
+
_: "@color/bootsplash_background",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
$: { name: "bootSplashLogo" },
|
|
129
|
+
_: "@drawable/bootsplash_logo",
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
if (brand != null) {
|
|
134
|
+
item.push({
|
|
135
|
+
$: { name: "bootSplashBrand" },
|
|
136
|
+
_: "@drawable/bootsplash_brand",
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (darkContentBarsStyle != null) {
|
|
140
|
+
item.push({
|
|
141
|
+
$: { name: "darkContentBarsStyle" },
|
|
142
|
+
_: String(darkContentBarsStyle),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const withBootTheme = [
|
|
147
|
+
...style.filter(({ $ }) => $.name !== "BootTheme"),
|
|
148
|
+
{
|
|
149
|
+
$: {
|
|
150
|
+
name: "BootTheme",
|
|
151
|
+
parent: "Theme.BootSplash",
|
|
152
|
+
},
|
|
153
|
+
item,
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
...config,
|
|
159
|
+
modResults: {
|
|
160
|
+
...modResults,
|
|
161
|
+
resources: {
|
|
162
|
+
...resources,
|
|
163
|
+
style: withBootTheme,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const withAndroidColors: Expo.ConfigPlugin<RawProps> = (expoConfig, rawProps) =>
|
|
170
|
+
Expo.withAndroidColors(expoConfig, async (config) => {
|
|
171
|
+
const { projectRoot } = config.modRequest;
|
|
172
|
+
const { background } = await transformProps(projectRoot, rawProps);
|
|
173
|
+
|
|
174
|
+
config.modResults = assignColorValue(config.modResults, {
|
|
175
|
+
name: "bootsplash_background",
|
|
176
|
+
value: background.hex,
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
return config;
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const withAndroidColorsNight: Expo.ConfigPlugin<RawProps> = (
|
|
183
|
+
expoConfig,
|
|
184
|
+
rawProps,
|
|
185
|
+
) =>
|
|
186
|
+
Expo.withAndroidColorsNight(expoConfig, async (config) => {
|
|
187
|
+
const { projectRoot } = config.modRequest;
|
|
188
|
+
const props = await transformProps(projectRoot, rawProps);
|
|
189
|
+
const addon = requireAddon(props);
|
|
190
|
+
|
|
191
|
+
return addon != null
|
|
192
|
+
? await addon.withAndroidColorsNight({ config, props })
|
|
193
|
+
: config;
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const withIOSAssets: Expo.ConfigPlugin<RawProps> = (expoConfig, rawProps) =>
|
|
197
|
+
Expo.withDangerousMod(expoConfig, [
|
|
198
|
+
"ios",
|
|
199
|
+
async (config) => {
|
|
200
|
+
const {
|
|
201
|
+
platformProjectRoot,
|
|
202
|
+
projectName = "",
|
|
203
|
+
projectRoot,
|
|
204
|
+
} = config.modRequest;
|
|
205
|
+
|
|
206
|
+
const props = await transformProps(projectRoot, rawProps);
|
|
207
|
+
const addon = requireAddon(props);
|
|
208
|
+
const iosOutputPath = path.resolve(platformProjectRoot, projectName);
|
|
209
|
+
|
|
210
|
+
await writeIOSAssets({ iosOutputPath, props });
|
|
211
|
+
await addon?.writeIOSAssets({ iosOutputPath, props });
|
|
212
|
+
|
|
213
|
+
return config;
|
|
214
|
+
},
|
|
215
|
+
]);
|
|
216
|
+
|
|
217
|
+
const withAppDelegate: Expo.ConfigPlugin<RawProps> = (expoConfig) =>
|
|
218
|
+
Expo.withAppDelegate(expoConfig, (config) => {
|
|
219
|
+
const { modResults } = config;
|
|
220
|
+
const { language } = modResults;
|
|
221
|
+
|
|
222
|
+
if (language !== "swift") {
|
|
223
|
+
throw new Error(
|
|
224
|
+
`Cannot modify the project AppDelegate as it's not in a supported language: ${language}`,
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const withHeader = mergeContents({
|
|
229
|
+
src: modResults.contents,
|
|
230
|
+
comment: "//",
|
|
231
|
+
tag: "bootsplash-header",
|
|
232
|
+
offset: 1,
|
|
233
|
+
anchor: /import Expo/,
|
|
234
|
+
newSrc: "import RNBootSplash",
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
const withRootView = mergeContents({
|
|
238
|
+
src: withHeader.contents,
|
|
239
|
+
comment: "//",
|
|
240
|
+
tag: "bootsplash-init",
|
|
241
|
+
offset: 1,
|
|
242
|
+
anchor: /class ReactNativeDelegate: ExpoReactNativeFactoryDelegate {/,
|
|
243
|
+
newSrc: dedent`
|
|
244
|
+
public override func customize(_ rootView: UIView) {
|
|
245
|
+
super.customize(rootView)
|
|
246
|
+
RNBootSplash.initWithStoryboard("BootSplash", rootView: rootView)
|
|
247
|
+
}
|
|
248
|
+
`,
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
return {
|
|
252
|
+
...config,
|
|
253
|
+
modResults: {
|
|
254
|
+
...modResults,
|
|
255
|
+
contents: withRootView.contents,
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
const withInfoPlist: Expo.ConfigPlugin<RawProps> = (expoConfig) =>
|
|
261
|
+
Expo.withInfoPlist(expoConfig, (config) => {
|
|
262
|
+
config.modResults["UILaunchStoryboardName"] = "BootSplash";
|
|
263
|
+
return config;
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
const withXcodeProject: Expo.ConfigPlugin<RawProps> = (expoConfig) =>
|
|
267
|
+
Expo.withXcodeProject(expoConfig, (config) => {
|
|
268
|
+
const { projectName = "" } = config.modRequest;
|
|
269
|
+
|
|
270
|
+
Expo.IOSConfig.XcodeUtils.addResourceFileToGroup({
|
|
271
|
+
filepath: path.join(projectName, "BootSplash.storyboard"),
|
|
272
|
+
groupName: projectName,
|
|
273
|
+
project: config.modResults,
|
|
274
|
+
isBuildFile: true,
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
Expo.IOSConfig.XcodeUtils.addResourceFileToGroup({
|
|
278
|
+
filepath: path.join(projectName, "Colors.xcassets"),
|
|
279
|
+
groupName: projectName,
|
|
280
|
+
project: config.modResults,
|
|
281
|
+
isBuildFile: true,
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
return config;
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
const withWebAssets: Expo.ConfigPlugin<RawProps> = (expoConfig, rawProps) =>
|
|
288
|
+
Expo.withDangerousMod(expoConfig, [
|
|
289
|
+
expoConfig.platforms?.includes("ios") ? "ios" : "android",
|
|
290
|
+
async (config) => {
|
|
291
|
+
const { projectRoot } = config.modRequest;
|
|
292
|
+
const props = await transformProps(projectRoot, rawProps);
|
|
293
|
+
const addon = requireAddon(props);
|
|
294
|
+
|
|
295
|
+
const fileName = "public/index.html";
|
|
296
|
+
const htmlTemplatePath = path.resolve(projectRoot, fileName);
|
|
297
|
+
|
|
298
|
+
if (!hfs.exists(htmlTemplatePath)) {
|
|
299
|
+
await exec(`npx expo customize ${fileName}`);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
await writeWebAssets({ htmlTemplatePath, props });
|
|
303
|
+
await addon?.writeWebAssets({ htmlTemplatePath, props });
|
|
304
|
+
|
|
305
|
+
return config;
|
|
306
|
+
},
|
|
307
|
+
]);
|
|
308
|
+
|
|
309
|
+
const withGenericAssets: Expo.ConfigPlugin<RawProps> = (expoConfig, rawProps) =>
|
|
310
|
+
Expo.withDangerousMod(expoConfig, [
|
|
311
|
+
expoConfig.platforms?.includes("ios") ? "ios" : "android",
|
|
312
|
+
async (config) => {
|
|
313
|
+
const { projectRoot } = config.modRequest;
|
|
314
|
+
const props = await transformProps(projectRoot, rawProps);
|
|
315
|
+
const addon = requireAddon(props);
|
|
316
|
+
|
|
317
|
+
await writeGenericAssets({ props });
|
|
318
|
+
await addon?.writeGenericAssets({ props });
|
|
319
|
+
|
|
320
|
+
return config;
|
|
321
|
+
},
|
|
322
|
+
]);
|
|
323
|
+
|
|
324
|
+
export const withBootSplash = Expo.createRunOncePlugin<
|
|
325
|
+
(Partial<RawProps> & { logo: string }) | undefined
|
|
326
|
+
>((expoConfig, baseProps) => {
|
|
327
|
+
const { platforms = [], sdkVersion = "0.1.0" } = expoConfig;
|
|
328
|
+
|
|
329
|
+
setIsExpo(true);
|
|
330
|
+
|
|
331
|
+
if (semver.lt(sdkVersion, "54.0.0")) {
|
|
332
|
+
log.error("Requires Expo 54.0.0 (or higher)");
|
|
333
|
+
process.exit(1);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (!baseProps?.logo) {
|
|
337
|
+
log.error("Missing required parameter 'logo'");
|
|
338
|
+
process.exit(1);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const rawProps: RawProps = {
|
|
342
|
+
assetsOutput: "assets/bootsplash",
|
|
343
|
+
background: "#fff",
|
|
344
|
+
brandWidth: 80,
|
|
345
|
+
logoWidth: 100,
|
|
346
|
+
...baseProps,
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const plugins: Expo.ConfigPlugin<RawProps>[] = [
|
|
350
|
+
withoutExpoSplashScreen,
|
|
351
|
+
withGenericAssets,
|
|
352
|
+
];
|
|
353
|
+
|
|
354
|
+
if (platforms.includes("android")) {
|
|
355
|
+
plugins.push(
|
|
356
|
+
withAndroidAssets,
|
|
357
|
+
withAndroidManifest,
|
|
358
|
+
withMainActivity,
|
|
359
|
+
withAndroidStyles,
|
|
360
|
+
withAndroidColors,
|
|
361
|
+
withAndroidColorsNight,
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (platforms.includes("ios")) {
|
|
366
|
+
plugins.push(
|
|
367
|
+
withIOSAssets,
|
|
368
|
+
withAppDelegate,
|
|
369
|
+
withInfoPlist,
|
|
370
|
+
withXcodeProject,
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (platforms.includes("web")) {
|
|
375
|
+
plugins.push(withWebAssets);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return Expo.withPlugins(
|
|
379
|
+
expoConfig,
|
|
380
|
+
plugins.map((plugin) => [plugin, rawProps]),
|
|
381
|
+
);
|
|
382
|
+
}, packageName);
|