react-native-bootsplash 6.0.0-beta.8 → 6.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.
@@ -1 +1 @@
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,CAAC,EAAE,CAAC;AAE/C,MAAM,MAAM,QAAQ,GAAG;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,QAAQ,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,GAAG;kBACA,MAAM;mBAGL,MAAM,QAAQ,MAAM;iBAGtB,MAAM;sBAGD,MAAM,eAAe;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAQzE,CAAC;AA2FF,eAAO,MAAM,GAAG;mBACC,MAAM;mBACN,MAAM;kBACP,MAAM;iBACP,MAAM;oBACH,MAAM;qBACL,MAAM;eACZ,MAAM;iBACJ,MAAM;gBAEP,MAAM,QAAQ,MAAM;qBAYf,MAAM;kBAGT,MAAM,WAAW,MAAM;C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;AAYF,eAAO,MAAM,QAAQ,mEAQlB;IACD,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,GAAG,CAAC,EAAE,gBAAgB,CAAC;IAEvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IAEf,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,kBA0lBA,CAAC"}
@@ -77,54 +77,50 @@ RCT_EXPORT_MODULE();
77
77
  return;
78
78
  }
79
79
 
80
- static dispatch_once_t onceToken;
81
-
82
- dispatch_once(&onceToken, ^(void) {
83
- [NSTimer scheduledTimerWithTimeInterval:0.35
84
- repeats:NO
85
- block:^(NSTimer * _Nonnull timer) {
86
- // wait for native iOS launch screen to fade out
87
- _nativeHidden = true;
88
-
89
- // hide has been called before native launch screen fade out
90
- if ([_resolveQueue count] > 0) {
91
- [self hideAndClearPromiseQueue];
92
- }
93
- }];
80
+ [NSTimer scheduledTimerWithTimeInterval:0.35
81
+ repeats:NO
82
+ block:^(NSTimer * _Nonnull timer) {
83
+ // wait for native iOS launch screen to fade out
84
+ _nativeHidden = true;
85
+
86
+ // hide has been called before native launch screen fade out
87
+ if ([_resolveQueue count] > 0) {
88
+ [self hideAndClearPromiseQueue];
89
+ }
90
+ }];
94
91
 
92
+ if (rootView != nil) {
95
93
  #ifdef RCT_NEW_ARCH_ENABLED
96
- if (rootView != nil && [rootView isKindOfClass:[RCTSurfaceHostingProxyRootView class]]) {
97
- _rootView = (RCTSurfaceHostingProxyRootView *)rootView;
94
+ _rootView = (RCTSurfaceHostingProxyRootView *)rootView;
98
95
  #else
99
- if (rootView != nil && [rootView isKindOfClass:[RCTRootView class]]) {
100
- _rootView = (RCTRootView *)rootView;
96
+ _rootView = (RCTRootView *)rootView;
101
97
  #endif
102
- UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
103
98
 
104
- _loadingView = [[storyboard instantiateInitialViewController] view];
105
- _loadingView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
106
- _loadingView.frame = _rootView.bounds;
107
- _loadingView.center = (CGPoint){CGRectGetMidX(_rootView.bounds), CGRectGetMidY(_rootView.bounds)};
108
- _loadingView.hidden = NO;
99
+ UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
100
+
101
+ _loadingView = [[storyboard instantiateInitialViewController] view];
102
+ _loadingView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
103
+ _loadingView.frame = _rootView.bounds;
104
+ _loadingView.center = (CGPoint){CGRectGetMidX(_rootView.bounds), CGRectGetMidY(_rootView.bounds)};
105
+ _loadingView.hidden = NO;
109
106
 
110
107
  #if RCT_NEW_ARCH_ENABLED
111
- [_rootView disableActivityIndicatorAutoHide:YES];
112
- [_rootView setLoadingView:_loadingView];
108
+ [_rootView disableActivityIndicatorAutoHide:YES];
109
+ [_rootView setLoadingView:_loadingView];
113
110
  #else
114
- [_rootView addSubview:_loadingView];
111
+ [_rootView addSubview:_loadingView];
115
112
  #endif
116
113
 
117
- [[NSNotificationCenter defaultCenter] addObserver:self
118
- selector:@selector(onJavaScriptDidLoad)
119
- name:RCTJavaScriptDidLoadNotification
120
- object:nil];
114
+ [[NSNotificationCenter defaultCenter] addObserver:self
115
+ selector:@selector(onJavaScriptDidLoad)
116
+ name:RCTJavaScriptDidLoadNotification
117
+ object:nil];
121
118
 
122
- [[NSNotificationCenter defaultCenter] addObserver:self
123
- selector:@selector(onJavaScriptDidFailToLoad)
124
- name:RCTJavaScriptDidFailToLoadNotification
125
- object:nil];
126
- }
127
- });
119
+ [[NSNotificationCenter defaultCenter] addObserver:self
120
+ selector:@selector(onJavaScriptDidFailToLoad)
121
+ name:RCTJavaScriptDidFailToLoadNotification
122
+ object:nil];
123
+ }
128
124
  }
129
125
 
130
126
  + (void)onJavaScriptDidLoad {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-bootsplash",
3
- "version": "6.0.0-beta.8",
3
+ "version": "6.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>",
@@ -64,8 +64,7 @@
64
64
  "react-native": ">=0.70.0"
65
65
  },
66
66
  "dependencies": {
67
- "@expo/config": "^8.1.2 || ^9.0.1",
68
- "@expo/config-plugins": "^7.2.5 || ^8.0.4",
67
+ "@expo/config-plugins": "^8.0.4",
69
68
  "detect-indent": "^6.1.0",
70
69
  "fs-extra": "^11.2.0",
71
70
  "node-html-parser": "^6.1.13",
@@ -81,15 +80,16 @@
81
80
  "@types/fs-extra": "^11.0.4",
82
81
  "@types/node": "^20.12.7",
83
82
  "@types/react": "^18.2.60",
84
- "@types/sharp": "^0.31.1",
83
+ "@types/semver": "^7.5.8",
85
84
  "@typescript-eslint/eslint-plugin": "^7.8.0",
86
85
  "@typescript-eslint/parser": "^7.8.0",
87
86
  "eslint": "^8.57.0",
88
87
  "eslint-plugin-react-hooks": "^4.6.2",
89
88
  "prettier-plugin-organize-imports": "^3.2.4",
90
89
  "react": "18.2.0",
91
- "react-native": "0.74.1",
90
+ "react-native": "0.74.3",
92
91
  "react-native-builder-bob": "^0.23.2",
92
+ "semver": "^7.6.2",
93
93
  "typescript": "^5.4.5"
94
94
  },
95
95
  "codegenConfig": {
package/src/expo.ts ADDED
@@ -0,0 +1,368 @@
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 { dedent } from "ts-dedent";
7
+ import { Manifest } from ".";
8
+ import { cleanIOSAssets, getExpoConfig, hfs } from "./generate";
9
+
10
+ type ExpoPlugin = Expo.ConfigPlugin<{
11
+ assetsDir?: string;
12
+ android?: {
13
+ parentTheme?: "TransparentStatus" | "EdgeToEdge";
14
+ darkContentBarsStyle?: boolean;
15
+ };
16
+ }>;
17
+
18
+ const withExpoVersionCheck =
19
+ (platform: "android" | "ios"): ExpoPlugin =>
20
+ (config) =>
21
+ Expo.withDangerousMod(config, [
22
+ platform,
23
+ (config) => {
24
+ getExpoConfig(config.modRequest.projectRoot); // will exit process if expo < 51.0.20
25
+ return config;
26
+ },
27
+ ]);
28
+
29
+ const withAndroidAssets: ExpoPlugin = (config, props) =>
30
+ Expo.withDangerousMod(config, [
31
+ "android",
32
+ (config) => {
33
+ const { assetsDir = "assets/bootsplash" } = props;
34
+ const { projectRoot, platformProjectRoot } = config.modRequest;
35
+
36
+ const srcDir = path.resolve(projectRoot, assetsDir, "android");
37
+
38
+ const destDir = path.resolve(
39
+ platformProjectRoot,
40
+ "app",
41
+ "src",
42
+ "main",
43
+ "res",
44
+ );
45
+
46
+ for (const drawableDir of hfs.readDir(srcDir)) {
47
+ const srcDrawableDir = path.join(srcDir, drawableDir);
48
+ const destDrawableDir = path.join(destDir, drawableDir);
49
+
50
+ hfs.ensureDir(destDrawableDir);
51
+
52
+ for (const file of hfs.readDir(srcDrawableDir)) {
53
+ hfs.copy(
54
+ path.join(srcDrawableDir, file),
55
+ path.join(destDrawableDir, file),
56
+ );
57
+ }
58
+ }
59
+
60
+ return config;
61
+ },
62
+ ]);
63
+
64
+ const withAndroidManifest: ExpoPlugin = (config) =>
65
+ Expo.withAndroidManifest(config, (config) => {
66
+ config.modResults.manifest.application?.forEach((application) => {
67
+ if (application.$["android:name"] === ".MainApplication") {
68
+ const { activity } = application;
69
+
70
+ activity?.forEach((activity) => {
71
+ if (activity.$["android:name"] === ".MainActivity") {
72
+ activity.$["android:theme"] = "@style/BootTheme";
73
+ }
74
+ });
75
+ }
76
+ });
77
+
78
+ return config;
79
+ });
80
+
81
+ const withMainActivity: ExpoPlugin = (config) =>
82
+ Expo.withMainActivity(config, (config) => {
83
+ const { modResults } = config;
84
+ const { language } = modResults;
85
+
86
+ const withImports = addImports(
87
+ modResults.contents.replace(
88
+ /(\/\/ )?setTheme\(R\.style\.AppTheme\)/,
89
+ "// setTheme(R.style.AppTheme)",
90
+ ),
91
+ ["android.os.Bundle", "com.zoontek.rnbootsplash.RNBootSplash"],
92
+ language === "java",
93
+ );
94
+
95
+ // indented with 4 spaces
96
+ const withInit = mergeContents({
97
+ src: withImports,
98
+ comment: " //",
99
+ tag: "bootsplash-init",
100
+ offset: 0,
101
+ anchor: /super\.onCreate\(null\)/,
102
+ newSrc:
103
+ " RNBootSplash.init(this, R.style.BootTheme)" +
104
+ (language === "java" ? ";" : ""),
105
+ });
106
+
107
+ return {
108
+ ...config,
109
+ modResults: {
110
+ ...modResults,
111
+ contents: withInit.contents,
112
+ },
113
+ };
114
+ });
115
+
116
+ const withAndroidStyles: ExpoPlugin = (config, props) =>
117
+ Expo.withAndroidStyles(config, async (config) => {
118
+ const { assetsDir = "assets/bootsplash", android = {} } = props;
119
+ const { parentTheme, darkContentBarsStyle } = android;
120
+
121
+ const { modRequest, modResults } = config;
122
+ const { resources } = modResults;
123
+ const { style = [] } = resources;
124
+
125
+ const manifest = (await hfs.json(
126
+ path.resolve(modRequest.projectRoot, assetsDir, "manifest.json"),
127
+ )) as Manifest;
128
+
129
+ const item = [
130
+ {
131
+ $: { name: "postBootSplashTheme" },
132
+ _: "@style/AppTheme",
133
+ },
134
+ {
135
+ $: { name: "bootSplashBackground" },
136
+ _: "@color/bootsplash_background",
137
+ },
138
+ {
139
+ $: { name: "bootSplashLogo" },
140
+ _: "@drawable/bootsplash_logo",
141
+ },
142
+ ];
143
+
144
+ if (manifest.brand != null) {
145
+ item.push({
146
+ $: { name: "bootSplashBrand" },
147
+ _: "@drawable/bootsplash_brand",
148
+ });
149
+ }
150
+ if (darkContentBarsStyle != null) {
151
+ item.push({
152
+ $: { name: "darkContentBarsStyle" },
153
+ _: String(darkContentBarsStyle),
154
+ });
155
+ }
156
+
157
+ const withBootTheme = [
158
+ ...style.filter(({ $ }) => $.name !== "BootTheme"),
159
+ {
160
+ $: {
161
+ name: "BootTheme",
162
+ parent:
163
+ parentTheme === "TransparentStatus"
164
+ ? "Theme.BootSplash.TransparentStatus"
165
+ : parentTheme === "EdgeToEdge"
166
+ ? "Theme.BootSplash.EdgeToEdge"
167
+ : "Theme.BootSplash",
168
+ },
169
+ item,
170
+ },
171
+ ];
172
+
173
+ return {
174
+ ...config,
175
+ modResults: {
176
+ ...modResults,
177
+ resources: {
178
+ ...resources,
179
+ style: withBootTheme,
180
+ },
181
+ },
182
+ };
183
+ });
184
+
185
+ const withAndroidColors: ExpoPlugin = (config, props) =>
186
+ Expo.withAndroidColors(config, async (config) => {
187
+ const { assetsDir = "assets/bootsplash" } = props;
188
+ const { projectRoot } = config.modRequest;
189
+
190
+ const manifest = (await hfs.json(
191
+ path.resolve(projectRoot, assetsDir, "manifest.json"),
192
+ )) as Manifest;
193
+
194
+ config.modResults = assignColorValue(config.modResults, {
195
+ name: "bootsplash_background",
196
+ value: manifest.background,
197
+ });
198
+
199
+ return config;
200
+ });
201
+
202
+ const withAndroidColorsNight: ExpoPlugin = (config, props) =>
203
+ Expo.withAndroidColorsNight(config, async (config) => {
204
+ const { assetsDir = "assets/bootsplash" } = props;
205
+ const { projectRoot } = config.modRequest;
206
+
207
+ const manifest = (await hfs.json(
208
+ path.resolve(projectRoot, assetsDir, "manifest.json"),
209
+ )) as Manifest;
210
+
211
+ if (manifest.darkBackground != null) {
212
+ config.modResults = assignColorValue(config.modResults, {
213
+ name: "bootsplash_background",
214
+ value: manifest.darkBackground,
215
+ });
216
+ }
217
+
218
+ return config;
219
+ });
220
+
221
+ const withIOSAssets: ExpoPlugin = (config, props) =>
222
+ Expo.withDangerousMod(config, [
223
+ "ios",
224
+ (config) => {
225
+ const { assetsDir = "assets/bootsplash" } = props;
226
+
227
+ const {
228
+ projectRoot,
229
+ platformProjectRoot,
230
+ projectName = "",
231
+ } = config.modRequest;
232
+
233
+ const srcDir = path.resolve(projectRoot, assetsDir, "ios");
234
+ const destDir = path.resolve(platformProjectRoot, projectName);
235
+
236
+ cleanIOSAssets(destDir);
237
+
238
+ hfs.copy(
239
+ path.join(srcDir, "BootSplash.storyboard"),
240
+ path.join(destDir, "BootSplash.storyboard"),
241
+ );
242
+
243
+ for (const xcassetsDir of ["Colors.xcassets", "Images.xcassets"]) {
244
+ const srcXcassetsDir = path.join(srcDir, xcassetsDir);
245
+ const destXcassetsDir = path.join(destDir, xcassetsDir);
246
+
247
+ hfs.ensureDir(destXcassetsDir);
248
+
249
+ for (const file of hfs.readDir(srcXcassetsDir)) {
250
+ hfs.copy(
251
+ path.join(srcXcassetsDir, file),
252
+ path.join(destXcassetsDir, file),
253
+ );
254
+ }
255
+ }
256
+
257
+ return config;
258
+ },
259
+ ]);
260
+
261
+ const withAppDelegate: ExpoPlugin = (config) =>
262
+ Expo.withAppDelegate(config, (config) => {
263
+ const { modResults } = config;
264
+ const { language } = modResults;
265
+
266
+ if (language !== "objc" && language !== "objcpp") {
267
+ throw new Error(
268
+ `Cannot modify the project AppDelegate as it's not in a supported language: ${language}`,
269
+ );
270
+ }
271
+
272
+ const withHeader = mergeContents({
273
+ src: modResults.contents,
274
+ comment: "//",
275
+ tag: "bootsplash-header",
276
+ offset: 1,
277
+ anchor: /#import "AppDelegate\.h"/,
278
+ newSrc: '#import "RNBootSplash.h"',
279
+ });
280
+
281
+ const withRootView = mergeContents({
282
+ src: withHeader.contents,
283
+ comment: "//",
284
+ tag: "bootsplash-init",
285
+ offset: 0,
286
+ anchor: /@end/,
287
+ newSrc: dedent`
288
+ - (void)customizeRootView:(RCTRootView *)rootView {
289
+ [RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView];
290
+ }
291
+ `,
292
+ });
293
+
294
+ return {
295
+ ...config,
296
+ modResults: {
297
+ ...modResults,
298
+ contents: withRootView.contents,
299
+ },
300
+ };
301
+ });
302
+
303
+ const withInfoPlist: ExpoPlugin = (config) =>
304
+ Expo.withInfoPlist(config, (config) => {
305
+ config.modResults["UILaunchStoryboardName"] = "BootSplash";
306
+ return config;
307
+ });
308
+
309
+ const withXcodeProject: ExpoPlugin = (config) =>
310
+ Expo.withXcodeProject(config, (config) => {
311
+ const { projectName = "" } = config.modRequest;
312
+
313
+ Expo.IOSConfig.XcodeUtils.addResourceFileToGroup({
314
+ filepath: path.join(projectName, "BootSplash.storyboard"),
315
+ groupName: projectName,
316
+ project: config.modResults,
317
+ isBuildFile: true,
318
+ });
319
+
320
+ Expo.IOSConfig.XcodeUtils.addResourceFileToGroup({
321
+ filepath: path.join(projectName, "Colors.xcassets"),
322
+ groupName: projectName,
323
+ project: config.modResults,
324
+ isBuildFile: true,
325
+ });
326
+
327
+ return config;
328
+ });
329
+
330
+ const withoutExpoSplashScreen: ExpoPlugin = Expo.createRunOncePlugin(
331
+ (config) => config,
332
+ "expo-splash-screen",
333
+ "skip",
334
+ );
335
+
336
+ export const withBootSplash: ExpoPlugin = (config, props = {}) => {
337
+ const plugins: ExpoPlugin[] = [];
338
+ const { platforms = [] } = config;
339
+
340
+ plugins.push(withoutExpoSplashScreen);
341
+
342
+ if (platforms.includes("android")) {
343
+ plugins.push(
344
+ withExpoVersionCheck("android"),
345
+ withAndroidAssets,
346
+ withAndroidManifest,
347
+ withMainActivity,
348
+ withAndroidStyles,
349
+ withAndroidColors,
350
+ withAndroidColorsNight,
351
+ );
352
+ }
353
+
354
+ if (platforms.includes("ios")) {
355
+ plugins.push(
356
+ withExpoVersionCheck("ios"),
357
+ withIOSAssets,
358
+ withAppDelegate,
359
+ withInfoPlist,
360
+ withXcodeProject,
361
+ );
362
+ }
363
+
364
+ return Expo.withPlugins(
365
+ config,
366
+ plugins.map((plugin) => [plugin, props]),
367
+ );
368
+ };