@expo-harmony/expo-splash-screen 55.0.21-harmony.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 +40 -0
- package/app.plugin.js +3 -0
- package/expo-module.config.json +7 -0
- package/harmony/library/oh-package.json5 +23 -0
- package/harmony/library.har +0 -0
- package/index.d.ts +1 -0
- package/index.js +3 -0
- package/package.json +51 -0
- package/plugin/withSplashScreen.d.ts +22 -0
- package/plugin/withSplashScreen.js +340 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @expo-harmony/expo-splash-screen
|
|
2
|
+
|
|
3
|
+
[**GitHub 仓库**](https://github.com/renbaoshuo/expo-harmony/tree/master/packages/expo-splash-screen)
|
|
4
|
+
|
|
5
|
+
为 HarmonyOS 上的 React Native 应用提供 Expo SplashScreen 的原生实现,与官方同版本的 `expo-splash-screen` 配套使用。支持控制启动画面的自动隐藏、手动隐藏和淡出过渡,以及通过配置插件设置启动图片、背景色和深色模式资源。
|
|
6
|
+
|
|
7
|
+
如果需要在预构建时配置 HarmonyOS 原生启动画面,请在 `app.json` 的 `plugins` 中传入 `@expo-harmony/expo-splash-screen`:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"expo": {
|
|
12
|
+
"plugins": [
|
|
13
|
+
[
|
|
14
|
+
"@expo-harmony/expo-splash-screen",
|
|
15
|
+
{
|
|
16
|
+
"backgroundColor": "#FFFFFF",
|
|
17
|
+
"image": "./assets/splash.png",
|
|
18
|
+
"imageWidth": 160,
|
|
19
|
+
"resizeMode": "contain",
|
|
20
|
+
"dark": {
|
|
21
|
+
"backgroundColor": "#000000",
|
|
22
|
+
"image": "./assets/splash-dark.png"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`resizeMode` 支持 `contain`、`cover` 和 `native`。修改配置后需要重新 prebuild,使用 `dark` 资源跟随系统外观时,请将 `expo.userInterfaceStyle` 设置为 `automatic`。
|
|
32
|
+
|
|
33
|
+
运行时可通过 `SplashScreen.preventAutoHideAsync()` 保持启动画面,待应用准备就绪后调用 `SplashScreen.hide()` 或 `SplashScreen.hideAsync()` 隐藏,也可通过 `SplashScreen.setOptions()` 设置淡出效果和时长。
|
|
34
|
+
|
|
35
|
+
## Author
|
|
36
|
+
|
|
37
|
+
**expo-harmony** © [Baoshuo](https://github.com/renbaoshuo), Released under the MIT License.<br>
|
|
38
|
+
Authored and maintained by Baoshuo with help from [contributors](https://github.com/renbaoshuo/expo-harmony/contributors).
|
|
39
|
+
|
|
40
|
+
> [Personal Website](https://baoshuo.ren) · [Blog](https://blog.baoshuo.ren) · GitHub [@renbaoshuo](https://github.com/renbaoshuo) · Twitter [@baoshuo](https://twitter.com/baoshuo)
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@expo-harmony/expo-splash-screen",
|
|
3
|
+
"version": "55.0.21-harmony.1",
|
|
4
|
+
"description": "HarmonyOS port of expo-splash-screen",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react-native",
|
|
7
|
+
"expo",
|
|
8
|
+
"expo-harmony",
|
|
9
|
+
"harmonyos"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/renbaoshuo/expo-harmony/tree/master/packages/expo-splash-screen#readme",
|
|
12
|
+
"repository": "https://github.com/renbaoshuo/expo-harmony",
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Baoshuo",
|
|
15
|
+
"email": "i@baoshuo.ren",
|
|
16
|
+
"url": "https://github.com/renbaoshuo"
|
|
17
|
+
},
|
|
18
|
+
"main": "Index.ets",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@expo-harmony/expo-modules-core": "55.0.25-harmony.1"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
Binary file
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@expo-harmony/expo-splash-screen",
|
|
3
|
+
"version": "55.0.21-harmony.1",
|
|
4
|
+
"description": "HarmonyOS port of expo-splash-screen",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react-native",
|
|
7
|
+
"expo",
|
|
8
|
+
"expo-harmony",
|
|
9
|
+
"harmonyos"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/renbaoshuo/expo-harmony/tree/master/packages/expo-splash-screen#readme",
|
|
12
|
+
"bugs": "https://github.com/renbaoshuo/expo-harmony/issues",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "Baoshuo <i@baoshuo.ren>",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/renbaoshuo/expo-harmony.git",
|
|
18
|
+
"directory": "packages/expo-splash-screen"
|
|
19
|
+
},
|
|
20
|
+
"main": "index.js",
|
|
21
|
+
"types": "index.d.ts",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"harmony:clean": "expo-harmony-module prepare --clean-only",
|
|
24
|
+
"harmony:build": "expo-harmony-module prepare",
|
|
25
|
+
"prepack": "expo-harmony-module prepack"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@expo-harmony/config-plugins": "55.0.10-harmony.1",
|
|
29
|
+
"@expo/config-plugins": "55.0.10"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@expo-harmony/expo-modules-core": "55.0.25-harmony.1",
|
|
33
|
+
"expo-splash-screen": "55.0.21"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@expo-harmony/expo-module-scripts": "55.0.0-harmony.0",
|
|
37
|
+
"@expo-harmony/expo-modules-core": "55.0.25-harmony.1",
|
|
38
|
+
"@react-native-oh/react-native-harmony": "0.84.1",
|
|
39
|
+
"expo": "55.0.26",
|
|
40
|
+
"expo-modules-core": "55.0.25",
|
|
41
|
+
"expo-splash-screen": "55.0.21",
|
|
42
|
+
"react": "19.2.3",
|
|
43
|
+
"react-native": "0.84.1"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
|
|
3
|
+
export type HarmonySplashResizeMode = 'contain' | 'cover' | 'native';
|
|
4
|
+
|
|
5
|
+
export interface HarmonySplashScreenConfig {
|
|
6
|
+
backgroundColor?: string;
|
|
7
|
+
imageWidth?: number;
|
|
8
|
+
image?: string;
|
|
9
|
+
resizeMode?: HarmonySplashResizeMode;
|
|
10
|
+
dark?: {
|
|
11
|
+
backgroundColor?: string;
|
|
12
|
+
image?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface SplashScreenPluginConfig extends HarmonySplashScreenConfig {
|
|
17
|
+
harmony?: HarmonySplashScreenConfig;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare const withSplashScreen: ConfigPlugin<SplashScreenPluginConfig | null>;
|
|
21
|
+
|
|
22
|
+
export = withSplashScreen;
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
|
|
6
|
+
const { createRunOncePlugin } = require('@expo/config-plugins');
|
|
7
|
+
const {
|
|
8
|
+
HarmonyConfigPluginError,
|
|
9
|
+
registerHarmonyConfigPlugin,
|
|
10
|
+
withColors,
|
|
11
|
+
withMedia,
|
|
12
|
+
withModuleJson,
|
|
13
|
+
withStrings,
|
|
14
|
+
} = require('@expo-harmony/config-plugins');
|
|
15
|
+
|
|
16
|
+
const pkg = require('../package.json');
|
|
17
|
+
|
|
18
|
+
const MEDIA = 'expo_splash_screen';
|
|
19
|
+
const BACKGROUND = 'expo_splash_screen_background';
|
|
20
|
+
const RESIZE_MODE = 'expo_splash_screen_resize_mode';
|
|
21
|
+
const IMAGE_WIDTH = 'expo_splash_screen_image_width';
|
|
22
|
+
const RESIZE_MODES = new Set(['contain', 'cover', 'native']);
|
|
23
|
+
const COLOR = /^#[0-9a-fA-F]{6}(?:[0-9a-fA-F]{2})?$/;
|
|
24
|
+
const IMAGE_EXTENSIONS = new Set(['.png', '.jpg', '.jpeg', '.svg', '.webp', '.gif']);
|
|
25
|
+
const TRANSPARENT_PNG = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M/wHwAF/gL+3MxZ5wAAAABJRU5ErkJggg==', 'base64');
|
|
26
|
+
const OWNERSHIP = Object.freeze({
|
|
27
|
+
ability: {
|
|
28
|
+
startWindowBackground: '$color:expo_splash_screen_background',
|
|
29
|
+
startWindowIcon: '$media:expo_splash_screen',
|
|
30
|
+
},
|
|
31
|
+
resources: {
|
|
32
|
+
colors: {
|
|
33
|
+
entry: [BACKGROUND],
|
|
34
|
+
entryDark: [BACKGROUND],
|
|
35
|
+
},
|
|
36
|
+
media: {
|
|
37
|
+
entry: [MEDIA],
|
|
38
|
+
entryDark: [MEDIA],
|
|
39
|
+
},
|
|
40
|
+
strings: {
|
|
41
|
+
entry: [
|
|
42
|
+
'expo_splash_screen_has_dark_image',
|
|
43
|
+
'expo_splash_screen_has_image',
|
|
44
|
+
'expo_splash_screen_image_width',
|
|
45
|
+
'expo_splash_screen_resize_mode',
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
function setResource(items, name, value) {
|
|
52
|
+
const next = (Array.isArray(items) ? items : []).filter(item => item?.name !== name);
|
|
53
|
+
|
|
54
|
+
next.push({ name, value });
|
|
55
|
+
next.sort((left, right) => left.name.localeCompare(right.name, 'en'));
|
|
56
|
+
|
|
57
|
+
return next;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function removeResource(items, name) {
|
|
61
|
+
return (Array.isArray(items) ? items : []).filter(item => item?.name !== name);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function replaceMedia(files, base, file) {
|
|
65
|
+
for (const name of Object.keys(files)) {
|
|
66
|
+
if (path.parse(name).name === base) delete files[name];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (file) files[file.name] = { ...file, replaceBase: true };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function normalizeColor(value, field, fallback) {
|
|
73
|
+
const color = value ?? fallback;
|
|
74
|
+
if (typeof color !== 'string' || !COLOR.test(color)) {
|
|
75
|
+
throw new TypeError(`${field} must be #RRGGBB or #RRGGBBAA.`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const upper = color.toUpperCase();
|
|
79
|
+
if (upper.length === 9) {
|
|
80
|
+
// Expo config follows CSS/React Native #RRGGBBAA, while Harmony resource
|
|
81
|
+
// colors use #AARRGGBB. Six-digit opaque colors have the same ordering.
|
|
82
|
+
return `#${upper.slice(7, 9)}${upper.slice(1, 7)}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return upper;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function normalizeImageWidth(value) {
|
|
89
|
+
const width = value ?? 100;
|
|
90
|
+
if (typeof width !== 'number' || !Number.isFinite(width) || width <= 0) {
|
|
91
|
+
throw new TypeError('imageWidth must be a positive finite number.');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return width;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function normalizeImage(value, field) {
|
|
98
|
+
if (value == null) return null;
|
|
99
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
100
|
+
throw new TypeError(`${field} must be a non-empty file path.`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const ext = path.extname(value).toLowerCase();
|
|
104
|
+
if (!IMAGE_EXTENSIONS.has(ext)) {
|
|
105
|
+
throw new TypeError(`${field} must use png, jpg, jpeg, svg, webp, or gif.`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return { value, extension: ext };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function normalizeObject(value, field) {
|
|
112
|
+
if (value == null) return {};
|
|
113
|
+
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
114
|
+
throw new TypeError(`${field} splash options must be an object.`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function normalizeProps(config, props) {
|
|
121
|
+
if (props != null && (typeof props !== 'object' || Array.isArray(props))) {
|
|
122
|
+
throw new TypeError('expo-splash-screen plugin options must be an object or null.');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const expo = props == null ? normalizeObject(config?.splash, 'Expo app config') : {};
|
|
126
|
+
const options = { ...expo, ...(props ?? {}) };
|
|
127
|
+
const harmony = normalizeObject(options.harmony, 'harmony');
|
|
128
|
+
const dark = {
|
|
129
|
+
...normalizeObject(options.dark, 'dark'),
|
|
130
|
+
...normalizeObject(harmony.dark, 'harmony.dark'),
|
|
131
|
+
};
|
|
132
|
+
const resize = harmony.resizeMode ?? options.resizeMode ?? 'contain';
|
|
133
|
+
|
|
134
|
+
if (!RESIZE_MODES.has(resize)) {
|
|
135
|
+
throw new TypeError(`Unsupported Harmony splash resizeMode: ${String(resize)}.`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
backgroundColor: normalizeColor(
|
|
140
|
+
harmony.backgroundColor ?? options.backgroundColor,
|
|
141
|
+
'backgroundColor',
|
|
142
|
+
'#FFFFFF'
|
|
143
|
+
),
|
|
144
|
+
darkBackgroundColor: normalizeColor(
|
|
145
|
+
dark.backgroundColor,
|
|
146
|
+
'dark.backgroundColor',
|
|
147
|
+
harmony.backgroundColor ?? options.backgroundColor ?? '#FFFFFF'
|
|
148
|
+
),
|
|
149
|
+
image: normalizeImage(harmony.image ?? options.image, 'image'),
|
|
150
|
+
darkImage: normalizeImage(dark.image, 'dark.image'),
|
|
151
|
+
imageWidth: normalizeImageWidth(harmony.imageWidth ?? options.imageWidth),
|
|
152
|
+
resizeMode: resize,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function resolveInterfaceStyle(config) {
|
|
157
|
+
const style = config?.harmony?.userInterfaceStyle ?? config?.userInterfaceStyle ?? 'light';
|
|
158
|
+
if (!['light', 'dark', 'automatic'].includes(style)) {
|
|
159
|
+
throw new TypeError(`Unsupported Harmony userInterfaceStyle: ${String(style)}.`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return style;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function resolveQualifiedResources(options, style) {
|
|
166
|
+
if (style === 'dark') {
|
|
167
|
+
const image = options.darkImage ?? options.image;
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
entryBackgroundColor: options.darkBackgroundColor,
|
|
171
|
+
entryDarkBackgroundColor: options.darkBackgroundColor,
|
|
172
|
+
entryImage: image,
|
|
173
|
+
entryDarkImage: image,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (style === 'light') {
|
|
178
|
+
return {
|
|
179
|
+
entryBackgroundColor: options.backgroundColor,
|
|
180
|
+
entryDarkBackgroundColor: options.backgroundColor,
|
|
181
|
+
entryImage: options.image,
|
|
182
|
+
entryDarkImage: options.image,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
entryBackgroundColor: options.backgroundColor,
|
|
188
|
+
entryDarkBackgroundColor: options.darkBackgroundColor,
|
|
189
|
+
entryImage: options.image,
|
|
190
|
+
entryDarkImage: options.darkImage,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function resolveImage(root, image, field) {
|
|
195
|
+
if (!image) return null;
|
|
196
|
+
|
|
197
|
+
const source = path.resolve(root, image.value);
|
|
198
|
+
let stat;
|
|
199
|
+
|
|
200
|
+
try {
|
|
201
|
+
stat = fs.statSync(source, { throwIfNoEntry: false });
|
|
202
|
+
} catch (cause) {
|
|
203
|
+
throw new HarmonyConfigPluginError(
|
|
204
|
+
'ERR_HARMONY_CONFIG_INVALID',
|
|
205
|
+
`Unable to inspect Harmony splash ${field}: ${source}`,
|
|
206
|
+
{ operation: 'resolve-splash-image', file: source, cause }
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (!stat?.isFile()) {
|
|
211
|
+
throw new HarmonyConfigPluginError(
|
|
212
|
+
'ERR_HARMONY_CONFIG_INVALID',
|
|
213
|
+
`${field} does not resolve to a file: ${source}`,
|
|
214
|
+
{ operation: 'resolve-splash-image', file: source }
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return { name: `${MEDIA}${image.extension}`, source };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function updateEntryAbility(json) {
|
|
222
|
+
const module = json.module;
|
|
223
|
+
if (!module || typeof module !== 'object' || !Array.isArray(module.abilities)) {
|
|
224
|
+
throw new HarmonyConfigPluginError(
|
|
225
|
+
'ERR_HARMONY_CONFIG_INVALID',
|
|
226
|
+
'Harmony splash configuration requires module.abilities.',
|
|
227
|
+
{ operation: 'configure-splash-entry-ability' }
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const main = module.mainElement;
|
|
232
|
+
const matches = module.abilities.filter((ability, index) => (
|
|
233
|
+
ability && typeof ability === 'object'
|
|
234
|
+
&& (typeof main === 'string' ? ability.name === main : index === 0)
|
|
235
|
+
));
|
|
236
|
+
if (matches.length !== 1) {
|
|
237
|
+
throw new HarmonyConfigPluginError(
|
|
238
|
+
'ERR_HARMONY_CONFIG_INVALID',
|
|
239
|
+
`Harmony splash configuration expected exactly one main Ability, found ${matches.length}.`,
|
|
240
|
+
{ operation: 'configure-splash-entry-ability' }
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const abilities = module.abilities.map((ability, index) => {
|
|
245
|
+
if (!ability || typeof ability !== 'object') return ability;
|
|
246
|
+
|
|
247
|
+
const selected = typeof main === 'string' ? ability.name === main : index === 0;
|
|
248
|
+
if (!selected) return ability;
|
|
249
|
+
|
|
250
|
+
return {
|
|
251
|
+
...ability,
|
|
252
|
+
startWindowBackground: '$color:expo_splash_screen_background',
|
|
253
|
+
startWindowIcon: '$media:expo_splash_screen',
|
|
254
|
+
};
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
return { ...json, module: { ...module, abilities } };
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const withHarmonySplashScreen = (config, props) => {
|
|
261
|
+
const enabled = config.harmony?.bundleName || config.platforms?.includes('harmony');
|
|
262
|
+
if (!enabled) return config;
|
|
263
|
+
|
|
264
|
+
config = registerHarmonyConfigPlugin(config, pkg.name, OWNERSHIP);
|
|
265
|
+
|
|
266
|
+
let cache;
|
|
267
|
+
|
|
268
|
+
const resolveOptions = () => {
|
|
269
|
+
if (cache) return cache;
|
|
270
|
+
|
|
271
|
+
const normalized = normalizeProps(config, props);
|
|
272
|
+
|
|
273
|
+
cache = {
|
|
274
|
+
normalized,
|
|
275
|
+
qualified: resolveQualifiedResources(normalized, resolveInterfaceStyle(config)),
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
return cache;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
config = withModuleJson(config, (mod) => {
|
|
282
|
+
mod.modResults = updateEntryAbility(mod.modResults);
|
|
283
|
+
|
|
284
|
+
return mod;
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
config = withColors(config, (mod) => {
|
|
288
|
+
const { qualified } = resolveOptions();
|
|
289
|
+
|
|
290
|
+
mod.modResults.entry ??= {};
|
|
291
|
+
mod.modResults.entryDark ??= {};
|
|
292
|
+
|
|
293
|
+
mod.modResults.entry.color = setResource(
|
|
294
|
+
mod.modResults.entry.color,
|
|
295
|
+
BACKGROUND,
|
|
296
|
+
qualified.entryBackgroundColor
|
|
297
|
+
);
|
|
298
|
+
mod.modResults.entryDark.color = setResource(
|
|
299
|
+
mod.modResults.entryDark.color,
|
|
300
|
+
BACKGROUND,
|
|
301
|
+
qualified.entryDarkBackgroundColor
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
return mod;
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
config = withStrings(config, (mod) => {
|
|
308
|
+
const { normalized } = resolveOptions();
|
|
309
|
+
let strings = mod.modResults.entry?.string;
|
|
310
|
+
|
|
311
|
+
strings = setResource(strings, RESIZE_MODE, normalized.resizeMode);
|
|
312
|
+
strings = setResource(strings, IMAGE_WIDTH, String(normalized.imageWidth));
|
|
313
|
+
strings = removeResource(strings, 'expo_splash_screen_has_image');
|
|
314
|
+
strings = removeResource(strings, 'expo_splash_screen_has_dark_image');
|
|
315
|
+
|
|
316
|
+
mod.modResults.entry ??= {};
|
|
317
|
+
mod.modResults.entry.string = strings;
|
|
318
|
+
|
|
319
|
+
return mod;
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
config = withMedia(config, (mod) => {
|
|
323
|
+
const { qualified } = resolveOptions();
|
|
324
|
+
const root = mod.modRequest.projectRoot;
|
|
325
|
+
const image = resolveImage(root, qualified.entryImage, 'image');
|
|
326
|
+
const dark = resolveImage(root, qualified.entryDarkImage, 'darkImage');
|
|
327
|
+
|
|
328
|
+
mod.modResults.entry ??= {};
|
|
329
|
+
mod.modResults.entryDark ??= {};
|
|
330
|
+
|
|
331
|
+
replaceMedia(mod.modResults.entry, MEDIA, image ?? { name: `${MEDIA}.png`, content: TRANSPARENT_PNG });
|
|
332
|
+
replaceMedia(mod.modResults.entryDark, MEDIA, dark);
|
|
333
|
+
|
|
334
|
+
return mod;
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
return config;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
module.exports = createRunOncePlugin(withHarmonySplashScreen, pkg.name, pkg.version);
|