react-native-bootsplash 6.3.11 → 7.0.0-beta.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.
Files changed (75) hide show
  1. package/README.md +13 -41
  2. package/android/build.gradle +10 -17
  3. package/android/src/main/AndroidManifest.xml +1 -1
  4. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashModuleImpl.kt +2 -2
  5. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashPackage.kt +0 -1
  6. package/android/src/main/java/com/zoontek/rnbootsplash/RNBootSplashQueue.kt +1 -1
  7. package/android/src/main/res/drawable/compat_splash_screen.xml +11 -6
  8. package/android/src/main/res/drawable/compat_splash_screen_oneui_4.xml +13 -6
  9. package/android/src/main/res/values/colors.xml +1 -3
  10. package/android/src/main/res/values/public.xml +0 -2
  11. package/android/src/main/res/values/styles.xml +13 -19
  12. package/android/src/main/res/values-night/styles.xml +1 -1
  13. package/android/src/main/res/values-v27/colors.xml +4 -0
  14. package/android/src/main/res/values-v27/styles.xml +1 -6
  15. package/android/src/main/res/values-v29/styles.xml +1 -11
  16. package/android/src/main/res/values-v30/styles.xml +1 -9
  17. package/android/src/main/res/values-v31/styles.xml +1 -1
  18. package/android/src/newarch/com/zoontek/rnbootsplash/RNBootSplashModule.kt +2 -2
  19. package/android/src/oldarch/com/zoontek/rnbootsplash/RNBootSplashModule.kt +3 -3
  20. package/app.plugin.js +1 -1
  21. package/cli.js +2 -11
  22. package/dist/commonjs/addon/index.js +49 -49
  23. package/dist/commonjs/addon/index.js.map +1 -1
  24. package/dist/commonjs/generate.js +811 -541
  25. package/dist/commonjs/generate.js.map +1 -1
  26. package/dist/commonjs/index.js +1 -1
  27. package/dist/commonjs/index.js.map +1 -1
  28. package/dist/commonjs/specs/NativeRNBootSplash.js.map +1 -0
  29. package/dist/commonjs/{NativeRNBootSplash.web.js → specs/NativeRNBootSplash.web.js} +1 -1
  30. package/dist/commonjs/specs/NativeRNBootSplash.web.js.map +1 -0
  31. package/dist/module/addon/index.js +49 -49
  32. package/dist/module/addon/index.js.map +1 -1
  33. package/dist/module/generate.js +807 -539
  34. package/dist/module/generate.js.map +1 -1
  35. package/dist/module/index.js +1 -1
  36. package/dist/module/index.js.map +1 -1
  37. package/dist/module/specs/NativeRNBootSplash.js.map +1 -0
  38. package/dist/module/{NativeRNBootSplash.web.js → specs/NativeRNBootSplash.web.js} +1 -1
  39. package/dist/module/specs/NativeRNBootSplash.web.js.map +1 -0
  40. package/dist/typescript/addon/index.d.ts +8 -2
  41. package/dist/typescript/addon/index.d.ts.map +1 -1
  42. package/dist/typescript/generate.d.ts +90 -35
  43. package/dist/typescript/generate.d.ts.map +1 -1
  44. package/dist/typescript/index.d.ts +2 -2
  45. package/dist/typescript/index.d.ts.map +1 -1
  46. package/dist/typescript/{NativeRNBootSplash.d.ts → specs/NativeRNBootSplash.d.ts} +1 -1
  47. package/dist/typescript/specs/NativeRNBootSplash.d.ts.map +1 -0
  48. package/dist/typescript/{NativeRNBootSplash.web.d.ts → specs/NativeRNBootSplash.web.d.ts} +1 -1
  49. package/dist/typescript/specs/NativeRNBootSplash.web.d.ts.map +1 -0
  50. package/ios/RNBootSplash.mm +4 -10
  51. package/package.json +24 -29
  52. package/src/generate.ts +1048 -782
  53. package/src/index.ts +7 -7
  54. package/src/{NativeRNBootSplash.ts → specs/NativeRNBootSplash.ts} +1 -1
  55. package/src/{NativeRNBootSplash.web.ts → specs/NativeRNBootSplash.web.ts} +1 -1
  56. package/android/src/main/AndroidManifestNew.xml +0 -3
  57. package/android/src/main/res/drawable-v23/compat_splash_screen.xml +0 -19
  58. package/android/src/main/res/drawable-v23/compat_splash_screen_oneui_4.xml +0 -21
  59. package/android/src/main/res/values-v23/styles.xml +0 -13
  60. package/dist/commonjs/NativeRNBootSplash.js.map +0 -1
  61. package/dist/commonjs/NativeRNBootSplash.web.js.map +0 -1
  62. package/dist/commonjs/expo.js +0 -348
  63. package/dist/commonjs/expo.js.map +0 -1
  64. package/dist/module/NativeRNBootSplash.js.map +0 -1
  65. package/dist/module/NativeRNBootSplash.web.js.map +0 -1
  66. package/dist/module/expo.js +0 -341
  67. package/dist/module/expo.js.map +0 -1
  68. package/dist/typescript/NativeRNBootSplash.d.ts.map +0 -1
  69. package/dist/typescript/NativeRNBootSplash.web.d.ts.map +0 -1
  70. package/dist/typescript/expo.d.ts +0 -11
  71. package/dist/typescript/expo.d.ts.map +0 -1
  72. package/react-native.config.js +0 -101
  73. package/src/expo.ts +0 -439
  74. /package/dist/commonjs/{NativeRNBootSplash.js → specs/NativeRNBootSplash.js} +0 -0
  75. /package/dist/module/{NativeRNBootSplash.js → specs/NativeRNBootSplash.js} +0 -0
package/src/expo.ts DELETED
@@ -1,439 +0,0 @@
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 path from "path";
6
- import semver from "semver";
7
- import { dedent } from "ts-dedent";
8
- import { Manifest } from ".";
9
- import { cleanIOSAssets, getExpoConfig, hfs, log } from "./generate";
10
-
11
- type Props = {
12
- assetsDir?: string;
13
- android?: {
14
- parentTheme?: "TransparentStatus" | "EdgeToEdge";
15
- darkContentBarsStyle?: boolean;
16
- };
17
- };
18
-
19
- const withExpoVersionCheck =
20
- (platform: "android" | "ios"): Expo.ConfigPlugin<Props> =>
21
- (config) =>
22
- Expo.withDangerousMod(config, [
23
- platform,
24
- (config) => {
25
- getExpoConfig(config.modRequest.projectRoot); // will exit process if expo < 51.0.20
26
- return config;
27
- },
28
- ]);
29
-
30
- const withAndroidAssets: Expo.ConfigPlugin<Props> = (config, props) =>
31
- Expo.withDangerousMod(config, [
32
- "android",
33
- (config) => {
34
- const { assetsDir = "assets/bootsplash" } = props;
35
- const { projectRoot, platformProjectRoot } = config.modRequest;
36
-
37
- const srcDir = path.resolve(projectRoot, assetsDir, "android");
38
-
39
- if (!hfs.exists(srcDir)) {
40
- const error = `"${path.relative(projectRoot, srcDir)}" doesn't exist. Did you run the asset generation command?`;
41
- log.error(error);
42
- process.exit(1);
43
- }
44
-
45
- const destDir = path.resolve(
46
- platformProjectRoot,
47
- "app",
48
- "src",
49
- "main",
50
- "res",
51
- );
52
-
53
- for (const drawableDir of hfs.readDir(srcDir)) {
54
- const srcDrawableDir = path.join(srcDir, drawableDir);
55
- const destDrawableDir = path.join(destDir, drawableDir);
56
-
57
- if (hfs.isDir(srcDrawableDir)) {
58
- hfs.ensureDir(destDrawableDir);
59
-
60
- for (const file of hfs.readDir(srcDrawableDir)) {
61
- hfs.copy(
62
- path.join(srcDrawableDir, file),
63
- path.join(destDrawableDir, file),
64
- );
65
- }
66
- }
67
- }
68
-
69
- return config;
70
- },
71
- ]);
72
-
73
- const withAndroidManifest: Expo.ConfigPlugin<Props> = (config) =>
74
- Expo.withAndroidManifest(config, (config) => {
75
- config.modResults.manifest.application?.forEach((application) => {
76
- if (application.$["android:name"] === ".MainApplication") {
77
- const { activity } = application;
78
-
79
- activity?.forEach((activity) => {
80
- if (activity.$["android:name"] === ".MainActivity") {
81
- activity.$["android:theme"] = "@style/BootTheme";
82
- }
83
- });
84
- }
85
- });
86
-
87
- return config;
88
- });
89
-
90
- const withMainActivity: Expo.ConfigPlugin<Props> = (config) =>
91
- Expo.withMainActivity(config, (config) => {
92
- const { modResults } = config;
93
- const { language } = modResults;
94
-
95
- const withImports = addImports(
96
- modResults.contents.replace(
97
- /(\/\/ )?setTheme\(R\.style\.AppTheme\)/,
98
- "// setTheme(R.style.AppTheme)",
99
- ),
100
- ["android.os.Bundle", "com.zoontek.rnbootsplash.RNBootSplash"],
101
- language === "java",
102
- );
103
-
104
- // indented with 4 spaces
105
- const withInit = mergeContents({
106
- src: withImports,
107
- comment: " //",
108
- tag: "bootsplash-init",
109
- offset: 0,
110
- anchor: /super\.onCreate\(null\)/,
111
- newSrc:
112
- " RNBootSplash.init(this, R.style.BootTheme)" +
113
- (language === "java" ? ";" : ""),
114
- });
115
-
116
- return {
117
- ...config,
118
- modResults: {
119
- ...modResults,
120
- contents: withInit.contents,
121
- },
122
- };
123
- });
124
-
125
- const withAndroidStyles: Expo.ConfigPlugin<Props> = (config, props) =>
126
- Expo.withAndroidStyles(config, async (config) => {
127
- const { assetsDir = "assets/bootsplash", android = {} } = props;
128
- const { parentTheme, darkContentBarsStyle } = android;
129
-
130
- const { modRequest, modResults } = config;
131
- const { resources } = modResults;
132
- const { style = [] } = resources;
133
-
134
- const manifest = (await hfs.json(
135
- path.resolve(modRequest.projectRoot, assetsDir, "manifest.json"),
136
- )) as Manifest;
137
-
138
- const item = [
139
- {
140
- $: { name: "postBootSplashTheme" },
141
- _: "@style/AppTheme",
142
- },
143
- {
144
- $: { name: "bootSplashBackground" },
145
- _: "@color/bootsplash_background",
146
- },
147
- {
148
- $: { name: "bootSplashLogo" },
149
- _: "@drawable/bootsplash_logo",
150
- },
151
- ];
152
-
153
- if (manifest.brand != null) {
154
- item.push({
155
- $: { name: "bootSplashBrand" },
156
- _: "@drawable/bootsplash_brand",
157
- });
158
- }
159
- if (darkContentBarsStyle != null) {
160
- item.push({
161
- $: { name: "darkContentBarsStyle" },
162
- _: String(darkContentBarsStyle),
163
- });
164
- }
165
-
166
- const withBootTheme = [
167
- ...style.filter(({ $ }) => $.name !== "BootTheme"),
168
- {
169
- $: {
170
- name: "BootTheme",
171
- parent:
172
- parentTheme === "TransparentStatus"
173
- ? "Theme.BootSplash.TransparentStatus"
174
- : parentTheme === "EdgeToEdge"
175
- ? "Theme.BootSplash.EdgeToEdge"
176
- : "Theme.BootSplash",
177
- },
178
- item,
179
- },
180
- ];
181
-
182
- return {
183
- ...config,
184
- modResults: {
185
- ...modResults,
186
- resources: {
187
- ...resources,
188
- style: withBootTheme,
189
- },
190
- },
191
- };
192
- });
193
-
194
- const withAndroidColors: Expo.ConfigPlugin<Props> = (config, props) =>
195
- Expo.withAndroidColors(config, async (config) => {
196
- const { assetsDir = "assets/bootsplash" } = props;
197
- const { projectRoot } = config.modRequest;
198
-
199
- const manifest = (await hfs.json(
200
- path.resolve(projectRoot, assetsDir, "manifest.json"),
201
- )) as Manifest;
202
-
203
- config.modResults = assignColorValue(config.modResults, {
204
- name: "bootsplash_background",
205
- value: manifest.background,
206
- });
207
-
208
- return config;
209
- });
210
-
211
- const withAndroidColorsNight: Expo.ConfigPlugin<Props> = (config, props) =>
212
- Expo.withAndroidColorsNight(config, async (config) => {
213
- const { assetsDir = "assets/bootsplash" } = props;
214
- const { projectRoot } = config.modRequest;
215
-
216
- const manifest = (await hfs.json(
217
- path.resolve(projectRoot, assetsDir, "manifest.json"),
218
- )) as Manifest;
219
-
220
- if (manifest.darkBackground != null) {
221
- config.modResults = assignColorValue(config.modResults, {
222
- name: "bootsplash_background",
223
- value: manifest.darkBackground,
224
- });
225
- }
226
-
227
- return config;
228
- });
229
-
230
- const withIOSAssets: Expo.ConfigPlugin<Props> = (config, props) =>
231
- Expo.withDangerousMod(config, [
232
- "ios",
233
- (config) => {
234
- const { assetsDir = "assets/bootsplash" } = props;
235
-
236
- const {
237
- projectRoot,
238
- platformProjectRoot,
239
- projectName = "",
240
- } = config.modRequest;
241
-
242
- const srcDir = path.resolve(projectRoot, assetsDir, "ios");
243
- const destDir = path.resolve(platformProjectRoot, projectName);
244
-
245
- if (!hfs.exists(srcDir)) {
246
- const error = `"${path.relative(projectRoot, srcDir)}" doesn't exist. Did you run the asset generation command?`;
247
- log.error(error);
248
- process.exit(1);
249
- }
250
-
251
- cleanIOSAssets(destDir);
252
-
253
- hfs.copy(
254
- path.join(srcDir, "BootSplash.storyboard"),
255
- path.join(destDir, "BootSplash.storyboard"),
256
- );
257
-
258
- for (const xcassetsDir of ["Colors.xcassets", "Images.xcassets"]) {
259
- const srcXcassetsDir = path.join(srcDir, xcassetsDir);
260
- const destXcassetsDir = path.join(destDir, xcassetsDir);
261
-
262
- if (hfs.isDir(srcXcassetsDir)) {
263
- hfs.ensureDir(destXcassetsDir);
264
-
265
- for (const file of hfs.readDir(srcXcassetsDir)) {
266
- hfs.copy(
267
- path.join(srcXcassetsDir, file),
268
- path.join(destXcassetsDir, file),
269
- );
270
- }
271
- }
272
- }
273
-
274
- return config;
275
- },
276
- ]);
277
-
278
- const withAppDelegate: Expo.ConfigPlugin<Props> = (config) =>
279
- Expo.withAppDelegate(config, (config) => {
280
- const { modResults, sdkVersion = "0.1.0" } = config;
281
- const { language } = modResults;
282
-
283
- if (language !== "objc" && language !== "objcpp" && language !== "swift") {
284
- throw new Error(
285
- `Cannot modify the project AppDelegate as it's not in a supported language: ${language}`,
286
- );
287
- }
288
-
289
- const withRootView = ((): ReturnType<typeof mergeContents> => {
290
- // SDK 53 deprecates support for Obj-C AppDelegate
291
- if (semver.major(sdkVersion) >= 53) {
292
- const withHeader = mergeContents({
293
- src: modResults.contents,
294
- comment: "//",
295
- tag: "bootsplash-header",
296
- offset: 1,
297
- anchor: /import Expo/,
298
- newSrc: "import RNBootSplash",
299
- });
300
-
301
- return mergeContents({
302
- src: withHeader.contents,
303
- comment: "//",
304
- tag: "bootsplash-init",
305
- offset: 1,
306
- anchor: /class ReactNativeDelegate: ExpoReactNativeFactoryDelegate {/,
307
- newSrc: dedent`
308
- public override func customize(_ rootView: UIView) {
309
- super.customize(rootView)
310
- RNBootSplash.initWithStoryboard("BootSplash", rootView: rootView)
311
- }
312
- `,
313
- });
314
- }
315
-
316
- if (language === "swift") {
317
- const withHeader = mergeContents({
318
- src: modResults.contents,
319
- comment: "//",
320
- tag: "bootsplash-header",
321
- offset: 1,
322
- anchor: /import Expo/,
323
- newSrc: "import RNBootSplash",
324
- });
325
-
326
- return mergeContents({
327
- src: withHeader.contents,
328
- comment: "//",
329
- tag: "bootsplash-init",
330
- offset: 1,
331
- anchor: /public class AppDelegate: ExpoAppDelegate {/,
332
- newSrc: dedent`
333
- override func customize(_ rootView: RCTRootView!) {
334
- super.customize(rootView)
335
- RNBootSplash.initWithStoryboard("BootSplash", rootView: rootView)
336
- }
337
- `,
338
- });
339
- }
340
-
341
- const withHeader = mergeContents({
342
- src: modResults.contents,
343
- comment: "//",
344
- tag: "bootsplash-header",
345
- offset: 1,
346
- anchor: /#import "AppDelegate\.h"/,
347
- newSrc: '#import "RNBootSplash.h"',
348
- });
349
-
350
- return mergeContents({
351
- src: withHeader.contents,
352
- comment: "//",
353
- tag: "bootsplash-init",
354
- offset: 0,
355
- anchor: /@end/,
356
- newSrc: dedent`
357
- - (void)customizeRootView:(RCTRootView *)rootView {
358
- [super customizeRootView:rootView];
359
- [RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView];
360
- }
361
- `,
362
- });
363
- })();
364
-
365
- return {
366
- ...config,
367
- modResults: {
368
- ...modResults,
369
- contents: withRootView.contents,
370
- },
371
- };
372
- });
373
-
374
- const withInfoPlist: Expo.ConfigPlugin<Props> = (config) =>
375
- Expo.withInfoPlist(config, (config) => {
376
- config.modResults["UILaunchStoryboardName"] = "BootSplash";
377
- return config;
378
- });
379
-
380
- const withXcodeProject: Expo.ConfigPlugin<Props> = (config) =>
381
- Expo.withXcodeProject(config, (config) => {
382
- const { projectName = "" } = config.modRequest;
383
-
384
- Expo.IOSConfig.XcodeUtils.addResourceFileToGroup({
385
- filepath: path.join(projectName, "BootSplash.storyboard"),
386
- groupName: projectName,
387
- project: config.modResults,
388
- isBuildFile: true,
389
- });
390
-
391
- Expo.IOSConfig.XcodeUtils.addResourceFileToGroup({
392
- filepath: path.join(projectName, "Colors.xcassets"),
393
- groupName: projectName,
394
- project: config.modResults,
395
- isBuildFile: true,
396
- });
397
-
398
- return config;
399
- });
400
-
401
- const withoutExpoSplashScreen: Expo.ConfigPlugin<Props> =
402
- Expo.createRunOncePlugin((config) => config, "expo-splash-screen", "skip");
403
-
404
- export const withBootSplash: Expo.ConfigPlugin<Props | undefined> = (
405
- config,
406
- props = {},
407
- ) => {
408
- const plugins: Expo.ConfigPlugin<Props>[] = [];
409
- const { platforms = [] } = config;
410
-
411
- plugins.push(withoutExpoSplashScreen);
412
-
413
- if (platforms.includes("android")) {
414
- plugins.push(
415
- withExpoVersionCheck("android"),
416
- withAndroidAssets,
417
- withAndroidManifest,
418
- withMainActivity,
419
- withAndroidStyles,
420
- withAndroidColors,
421
- withAndroidColorsNight,
422
- );
423
- }
424
-
425
- if (platforms.includes("ios")) {
426
- plugins.push(
427
- withExpoVersionCheck("ios"),
428
- withIOSAssets,
429
- withAppDelegate,
430
- withInfoPlist,
431
- withXcodeProject,
432
- );
433
- }
434
-
435
- return Expo.withPlugins(
436
- config,
437
- plugins.map((plugin) => [plugin, props]),
438
- );
439
- };