react-native-bootsplash 6.0.0-beta.9 → 6.1.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.
@@ -0,0 +1,283 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withBootSplash = void 0;
7
+ var Expo = _interopRequireWildcard(require("@expo/config-plugins"));
8
+ var _Colors = require("@expo/config-plugins/build/android/Colors");
9
+ var _codeMod = require("@expo/config-plugins/build/android/codeMod");
10
+ var _generateCode = require("@expo/config-plugins/build/utils/generateCode");
11
+ var _path = _interopRequireDefault(require("path"));
12
+ var _tsDedent = require("ts-dedent");
13
+ var _generate = require("./generate");
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ const withExpoVersionCheck = platform => config => Expo.withDangerousMod(config, [platform, config => {
18
+ (0, _generate.getExpoConfig)(config.modRequest.projectRoot); // will exit process if expo < 51.0.20
19
+ return config;
20
+ }]);
21
+ const withAndroidAssets = (config, props) => Expo.withDangerousMod(config, ["android", config => {
22
+ const {
23
+ assetsDir = "assets/bootsplash"
24
+ } = props;
25
+ const {
26
+ projectRoot,
27
+ platformProjectRoot
28
+ } = config.modRequest;
29
+ const srcDir = _path.default.resolve(projectRoot, assetsDir, "android");
30
+ const destDir = _path.default.resolve(platformProjectRoot, "app", "src", "main", "res");
31
+ for (const drawableDir of _generate.hfs.readDir(srcDir)) {
32
+ const srcDrawableDir = _path.default.join(srcDir, drawableDir);
33
+ const destDrawableDir = _path.default.join(destDir, drawableDir);
34
+ _generate.hfs.ensureDir(destDrawableDir);
35
+ for (const file of _generate.hfs.readDir(srcDrawableDir)) {
36
+ _generate.hfs.copy(_path.default.join(srcDrawableDir, file), _path.default.join(destDrawableDir, file));
37
+ }
38
+ }
39
+ return config;
40
+ }]);
41
+ const withAndroidManifest = config => Expo.withAndroidManifest(config, config => {
42
+ config.modResults.manifest.application?.forEach(application => {
43
+ if (application.$["android:name"] === ".MainApplication") {
44
+ const {
45
+ activity
46
+ } = application;
47
+ activity?.forEach(activity => {
48
+ if (activity.$["android:name"] === ".MainActivity") {
49
+ activity.$["android:theme"] = "@style/BootTheme";
50
+ }
51
+ });
52
+ }
53
+ });
54
+ return config;
55
+ });
56
+ const withMainActivity = config => Expo.withMainActivity(config, config => {
57
+ const {
58
+ modResults
59
+ } = config;
60
+ const {
61
+ language
62
+ } = modResults;
63
+ const withImports = (0, _codeMod.addImports)(modResults.contents.replace(/(\/\/ )?setTheme\(R\.style\.AppTheme\)/, "// setTheme(R.style.AppTheme)"), ["android.os.Bundle", "com.zoontek.rnbootsplash.RNBootSplash"], language === "java");
64
+
65
+ // indented with 4 spaces
66
+ const withInit = (0, _generateCode.mergeContents)({
67
+ src: withImports,
68
+ comment: " //",
69
+ tag: "bootsplash-init",
70
+ offset: 0,
71
+ anchor: /super\.onCreate\(null\)/,
72
+ newSrc: " RNBootSplash.init(this, R.style.BootTheme)" + (language === "java" ? ";" : "")
73
+ });
74
+ return {
75
+ ...config,
76
+ modResults: {
77
+ ...modResults,
78
+ contents: withInit.contents
79
+ }
80
+ };
81
+ });
82
+ const withAndroidStyles = (config, props) => Expo.withAndroidStyles(config, async config => {
83
+ const {
84
+ assetsDir = "assets/bootsplash",
85
+ android = {}
86
+ } = props;
87
+ const {
88
+ parentTheme,
89
+ darkContentBarsStyle
90
+ } = android;
91
+ const {
92
+ modRequest,
93
+ modResults
94
+ } = config;
95
+ const {
96
+ resources
97
+ } = modResults;
98
+ const {
99
+ style = []
100
+ } = resources;
101
+ const manifest = await _generate.hfs.json(_path.default.resolve(modRequest.projectRoot, assetsDir, "manifest.json"));
102
+ const item = [{
103
+ $: {
104
+ name: "postBootSplashTheme"
105
+ },
106
+ _: "@style/AppTheme"
107
+ }, {
108
+ $: {
109
+ name: "bootSplashBackground"
110
+ },
111
+ _: "@color/bootsplash_background"
112
+ }, {
113
+ $: {
114
+ name: "bootSplashLogo"
115
+ },
116
+ _: "@drawable/bootsplash_logo"
117
+ }];
118
+ if (manifest.brand != null) {
119
+ item.push({
120
+ $: {
121
+ name: "bootSplashBrand"
122
+ },
123
+ _: "@drawable/bootsplash_brand"
124
+ });
125
+ }
126
+ if (darkContentBarsStyle != null) {
127
+ item.push({
128
+ $: {
129
+ name: "darkContentBarsStyle"
130
+ },
131
+ _: String(darkContentBarsStyle)
132
+ });
133
+ }
134
+ const withBootTheme = [...style.filter(({
135
+ $
136
+ }) => $.name !== "BootTheme"), {
137
+ $: {
138
+ name: "BootTheme",
139
+ parent: parentTheme === "TransparentStatus" ? "Theme.BootSplash.TransparentStatus" : parentTheme === "EdgeToEdge" ? "Theme.BootSplash.EdgeToEdge" : "Theme.BootSplash"
140
+ },
141
+ item
142
+ }];
143
+ return {
144
+ ...config,
145
+ modResults: {
146
+ ...modResults,
147
+ resources: {
148
+ ...resources,
149
+ style: withBootTheme
150
+ }
151
+ }
152
+ };
153
+ });
154
+ const withAndroidColors = (config, props) => Expo.withAndroidColors(config, async config => {
155
+ const {
156
+ assetsDir = "assets/bootsplash"
157
+ } = props;
158
+ const {
159
+ projectRoot
160
+ } = config.modRequest;
161
+ const manifest = await _generate.hfs.json(_path.default.resolve(projectRoot, assetsDir, "manifest.json"));
162
+ config.modResults = (0, _Colors.assignColorValue)(config.modResults, {
163
+ name: "bootsplash_background",
164
+ value: manifest.background
165
+ });
166
+ return config;
167
+ });
168
+ const withAndroidColorsNight = (config, props) => Expo.withAndroidColorsNight(config, async config => {
169
+ const {
170
+ assetsDir = "assets/bootsplash"
171
+ } = props;
172
+ const {
173
+ projectRoot
174
+ } = config.modRequest;
175
+ const manifest = await _generate.hfs.json(_path.default.resolve(projectRoot, assetsDir, "manifest.json"));
176
+ if (manifest.darkBackground != null) {
177
+ config.modResults = (0, _Colors.assignColorValue)(config.modResults, {
178
+ name: "bootsplash_background",
179
+ value: manifest.darkBackground
180
+ });
181
+ }
182
+ return config;
183
+ });
184
+ const withIOSAssets = (config, props) => Expo.withDangerousMod(config, ["ios", config => {
185
+ const {
186
+ assetsDir = "assets/bootsplash"
187
+ } = props;
188
+ const {
189
+ projectRoot,
190
+ platformProjectRoot,
191
+ projectName = ""
192
+ } = config.modRequest;
193
+ const srcDir = _path.default.resolve(projectRoot, assetsDir, "ios");
194
+ const destDir = _path.default.resolve(platformProjectRoot, projectName);
195
+ (0, _generate.cleanIOSAssets)(destDir);
196
+ _generate.hfs.copy(_path.default.join(srcDir, "BootSplash.storyboard"), _path.default.join(destDir, "BootSplash.storyboard"));
197
+ for (const xcassetsDir of ["Colors.xcassets", "Images.xcassets"]) {
198
+ const srcXcassetsDir = _path.default.join(srcDir, xcassetsDir);
199
+ const destXcassetsDir = _path.default.join(destDir, xcassetsDir);
200
+ _generate.hfs.ensureDir(destXcassetsDir);
201
+ for (const file of _generate.hfs.readDir(srcXcassetsDir)) {
202
+ _generate.hfs.copy(_path.default.join(srcXcassetsDir, file), _path.default.join(destXcassetsDir, file));
203
+ }
204
+ }
205
+ return config;
206
+ }]);
207
+ const withAppDelegate = config => Expo.withAppDelegate(config, config => {
208
+ const {
209
+ modResults
210
+ } = config;
211
+ const {
212
+ language
213
+ } = modResults;
214
+ if (language !== "objc" && language !== "objcpp") {
215
+ throw new Error(`Cannot modify the project AppDelegate as it's not in a supported language: ${language}`);
216
+ }
217
+ const withHeader = (0, _generateCode.mergeContents)({
218
+ src: modResults.contents,
219
+ comment: "//",
220
+ tag: "bootsplash-header",
221
+ offset: 1,
222
+ anchor: /#import "AppDelegate\.h"/,
223
+ newSrc: '#import "RNBootSplash.h"'
224
+ });
225
+ const withRootView = (0, _generateCode.mergeContents)({
226
+ src: withHeader.contents,
227
+ comment: "//",
228
+ tag: "bootsplash-init",
229
+ offset: 0,
230
+ anchor: /@end/,
231
+ newSrc: (0, _tsDedent.dedent)`
232
+ - (void)customizeRootView:(RCTRootView *)rootView {
233
+ [RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView];
234
+ }
235
+ `
236
+ });
237
+ return {
238
+ ...config,
239
+ modResults: {
240
+ ...modResults,
241
+ contents: withRootView.contents
242
+ }
243
+ };
244
+ });
245
+ const withInfoPlist = config => Expo.withInfoPlist(config, config => {
246
+ config.modResults["UILaunchStoryboardName"] = "BootSplash";
247
+ return config;
248
+ });
249
+ const withXcodeProject = config => Expo.withXcodeProject(config, config => {
250
+ const {
251
+ projectName = ""
252
+ } = config.modRequest;
253
+ Expo.IOSConfig.XcodeUtils.addResourceFileToGroup({
254
+ filepath: _path.default.join(projectName, "BootSplash.storyboard"),
255
+ groupName: projectName,
256
+ project: config.modResults,
257
+ isBuildFile: true
258
+ });
259
+ Expo.IOSConfig.XcodeUtils.addResourceFileToGroup({
260
+ filepath: _path.default.join(projectName, "Colors.xcassets"),
261
+ groupName: projectName,
262
+ project: config.modResults,
263
+ isBuildFile: true
264
+ });
265
+ return config;
266
+ });
267
+ const withoutExpoSplashScreen = Expo.createRunOncePlugin(config => config, "expo-splash-screen", "skip");
268
+ const withBootSplash = (config, props = {}) => {
269
+ const plugins = [];
270
+ const {
271
+ platforms = []
272
+ } = config;
273
+ plugins.push(withoutExpoSplashScreen);
274
+ if (platforms.includes("android")) {
275
+ plugins.push(withExpoVersionCheck("android"), withAndroidAssets, withAndroidManifest, withMainActivity, withAndroidStyles, withAndroidColors, withAndroidColorsNight);
276
+ }
277
+ if (platforms.includes("ios")) {
278
+ plugins.push(withExpoVersionCheck("ios"), withIOSAssets, withAppDelegate, withInfoPlist, withXcodeProject);
279
+ }
280
+ return Expo.withPlugins(config, plugins.map(plugin => [plugin, props]));
281
+ };
282
+ exports.withBootSplash = withBootSplash;
283
+ //# sourceMappingURL=expo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Expo","_interopRequireWildcard","require","_Colors","_codeMod","_generateCode","_path","_interopRequireDefault","_tsDedent","_generate","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","withExpoVersionCheck","platform","config","withDangerousMod","getExpoConfig","modRequest","projectRoot","withAndroidAssets","props","assetsDir","platformProjectRoot","srcDir","path","resolve","destDir","drawableDir","hfs","readDir","srcDrawableDir","join","destDrawableDir","ensureDir","file","copy","withAndroidManifest","modResults","manifest","application","forEach","$","activity","withMainActivity","language","withImports","addImports","contents","replace","withInit","mergeContents","src","comment","tag","offset","anchor","newSrc","withAndroidStyles","android","parentTheme","darkContentBarsStyle","resources","style","json","item","name","_","brand","push","String","withBootTheme","filter","parent","withAndroidColors","assignColorValue","value","background","withAndroidColorsNight","darkBackground","withIOSAssets","projectName","cleanIOSAssets","xcassetsDir","srcXcassetsDir","destXcassetsDir","withAppDelegate","Error","withHeader","withRootView","dedent","withInfoPlist","withXcodeProject","IOSConfig","XcodeUtils","addResourceFileToGroup","filepath","groupName","project","isBuildFile","withoutExpoSplashScreen","createRunOncePlugin","withBootSplash","plugins","platforms","includes","withPlugins","map","plugin","exports"],"sourceRoot":"../../src","sources":["expo.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAA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AAW,EAAE;EACf,CAAC,CAAC;EAEF,OAAOpF,MAAM;AACf,CAAC,CAAC;AAEJ,MAAMqF,uBAAmC,GAAGrH,IAAI,CAACsH,mBAAmB,CACjEtF,MAAM,IAAKA,MAAM,EAClB,oBAAoB,EACpB,MACF,CAAC;AAEM,MAAMuF,cAA0B,GAAGA,CAACvF,MAAM,EAAEM,KAAK,GAAG,CAAC,CAAC,KAAK;EAChE,MAAMkF,OAAqB,GAAG,EAAE;EAChC,MAAM;IAAEC,SAAS,GAAG;EAAG,CAAC,GAAGzF,MAAM;EAEjCwF,OAAO,CAAClC,IAAI,CAAC+B,uBAAuB,CAAC;EAErC,IAAII,SAAS,CAACC,QAAQ,CAAC,SAAS,CAAC,EAAE;IACjCF,OAAO,CAAClC,IAAI,CACVxD,oBAAoB,CAAC,SAAS,CAAC,EAC/BO,iBAAiB,EACjBiB,mBAAmB,EACnBO,gBAAgB,EAChBc,iBAAiB,EACjBgB,iBAAiB,EACjBI,sBACF,CAAC;EACH;EAEA,IAAI0B,SAAS,CAACC,QAAQ,CAAC,KAAK,CAAC,EAAE;IAC7BF,OAAO,CAAClC,IAAI,CACVxD,oBAAoB,CAAC,KAAK,CAAC,EAC3BmE,aAAa,EACbM,eAAe,EACfK,aAAa,EACbC,gBACF,CAAC;EACH;EAEA,OAAO7G,IAAI,CAAC2H,WAAW,CACrB3F,MAAM,EACNwF,OAAO,CAACI,GAAG,CAAEC,MAAM,IAAK,CAACA,MAAM,EAAEvF,KAAK,CAAC,CACzC,CAAC;AACH,CAAC;AAACwF,OAAA,CAAAP,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -3,12 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.writeXmlLike = exports.writeJson = exports.withGenerate = exports.readXmlLike = exports.log = exports.hfs = exports.generate = void 0;
7
- var _config = require("@expo/config");
6
+ exports.writeXmlLike = exports.writeJson = exports.readXmlLike = exports.log = exports.hfs = exports.getExpoConfig = exports.generate = exports.cleanIOSAssets = void 0;
8
7
  var Expo = _interopRequireWildcard(require("@expo/config-plugins"));
9
- var _Colors = require("@expo/config-plugins/build/android/Colors");
10
- var _codeMod = require("@expo/config-plugins/build/android/codeMod");
11
- var _generateCode = require("@expo/config-plugins/build/utils/generateCode");
12
8
  var _plist = _interopRequireDefault(require("@expo/plist"));
13
9
  var _cliTools = require("@react-native-community/cli-tools");
14
10
  var _child_process = _interopRequireDefault(require("child_process"));
@@ -21,11 +17,12 @@ var _picocolors = _interopRequireDefault(require("picocolors"));
21
17
  var htmlPlugin = _interopRequireWildcard(require("prettier/plugins/html"));
22
18
  var cssPlugin = _interopRequireWildcard(require("prettier/plugins/postcss"));
23
19
  var prettier = _interopRequireWildcard(require("prettier/standalone"));
20
+ var _semver = _interopRequireDefault(require("semver"));
24
21
  var _sharp = _interopRequireDefault(require("sharp"));
25
22
  var _tsDedent = require("ts-dedent");
26
23
  var _util = _interopRequireDefault(require("util"));
27
24
  var _xmlFormatter = _interopRequireDefault(require("xml-formatter"));
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
29
26
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
30
27
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
31
28
  const workingPath = process.env.INIT_CWD ?? process.env.PWD ?? process.cwd();
@@ -167,6 +164,24 @@ const hfs = exports.hfs = {
167
164
  _fsExtra.default.writeFileSync(path, trimmed === "" ? trimmed : trimmed + "\n", "utf-8");
168
165
  }
169
166
  };
167
+ const getExpoConfig = projectRoot => {
168
+ try {
169
+ const pkg = hfs.json(_path.default.resolve(projectRoot, "node_modules", "expo", "package.json"));
170
+ const version = pkg.version;
171
+ if (version == null || _semver.default.lt(version, "51.0.20")) {
172
+ log.error("Requires Expo 51.0.20 (or higher)");
173
+ process.exit(1);
174
+ }
175
+ return {
176
+ isExpo: true
177
+ };
178
+ } catch {
179
+ return {
180
+ isExpo: false
181
+ };
182
+ }
183
+ };
184
+ exports.getExpoConfig = getExpoConfig;
170
185
  const writeJson = (filePath, content) => {
171
186
  hfs.write(filePath, JSON.stringify(content, null, 2));
172
187
  log.write(filePath);
@@ -222,11 +237,12 @@ const writeXmlLike = async (filePath, content, {
222
237
  }
223
238
  };
224
239
  exports.writeXmlLike = writeXmlLike;
225
- const cleanIOS = dir => {
240
+ const cleanIOSAssets = dir => {
226
241
  hfs.readDir(dir).filter(file => file === "Colors.xcassets" || file === "Images.xcassets").map(file => _path.default.join(dir, file)).flatMap(dir => hfs.readDir(dir).filter(file => file.startsWith("BootSplash")).map(file => _path.default.join(dir, file))).forEach(file => {
227
242
  hfs.rm(file);
228
243
  });
229
244
  };
245
+ exports.cleanIOSAssets = cleanIOSAssets;
230
246
  const getImageBase64 = async (image, width) => {
231
247
  if (image == null) {
232
248
  return "";
@@ -372,18 +388,15 @@ const requireAddon = () => {
372
388
  const generate = async ({
373
389
  android,
374
390
  ios,
391
+ projectType,
375
392
  platforms,
376
393
  html,
377
394
  flavor,
378
395
  licenseKey,
379
396
  ...args
380
397
  }) => {
381
- const isExpo = (0, _config.getConfig)(projectRoot, {
382
- skipSDKVersionRequirement: true
383
- }).exp.sdkVersion != null;
384
- const [nodeStringVersion = ""] = process.versions.node.split(".");
385
- const nodeVersion = Number.parseInt(nodeStringVersion, 10);
386
- if (!Number.isNaN(nodeVersion) && nodeVersion < 18) {
398
+ const isExpo = projectType === "detect" || projectType === "expo" ? getExpoConfig(workingPath).isExpo : false;
399
+ if (_semver.default.lt(process.versions.node, "18.0.0")) {
387
400
  log.error("Requires Node 18 (or higher)");
388
401
  process.exit(1);
389
402
  }
@@ -578,7 +591,7 @@ const generate = async ({
578
591
  if (iosOutputPath != null) {
579
592
  log.title("🍏", "iOS");
580
593
  hfs.ensureDir(iosOutputPath);
581
- cleanIOS(iosOutputPath);
594
+ cleanIOSAssets(iosOutputPath);
582
595
  const storyboardPath = _path.default.resolve(iosOutputPath, "BootSplash.storyboard");
583
596
  const colorsSetPath = _path.default.resolve(iosOutputPath, "Colors.xcassets", `BootSplashBackground-${fileNameSuffix}.colorset`);
584
597
  const imageSetPath = _path.default.resolve(iosOutputPath, "Images.xcassets", `BootSplashLogo-${fileNameSuffix}.imageset`);
@@ -821,259 +834,4 @@ ${_picocolors.default.blue("┗━━━━━━━━━━━━━━━━
821
834
  console.log(`\n💖 Thanks for using ${_picocolors.default.underline("react-native-bootsplash")}`);
822
835
  };
823
836
  exports.generate = generate;
824
- const withAndroidAssets = (config, props) => Expo.withDangerousMod(config, ["android", config => {
825
- const {
826
- assetsDir = "assets/bootsplash"
827
- } = props;
828
- const {
829
- platformProjectRoot
830
- } = config.modRequest;
831
- const srcDir = _path.default.resolve(workingPath, assetsDir, "android");
832
- const destDir = _path.default.resolve(platformProjectRoot, "app", "src", "main", "res");
833
- for (const drawableDir of hfs.readDir(srcDir)) {
834
- const srcDrawableDir = _path.default.join(srcDir, drawableDir);
835
- const destDrawableDir = _path.default.join(destDir, drawableDir);
836
- hfs.ensureDir(destDrawableDir);
837
- for (const file of hfs.readDir(srcDrawableDir)) {
838
- hfs.copy(_path.default.join(srcDrawableDir, file), _path.default.join(destDrawableDir, file));
839
- }
840
- }
841
- return config;
842
- }]);
843
- const withAndroidManifest = config => Expo.withAndroidManifest(config, config => {
844
- config.modResults.manifest.application?.forEach(application => {
845
- if (application.$["android:name"] === ".MainApplication") {
846
- const {
847
- activity
848
- } = application;
849
- activity?.forEach(activity => {
850
- if (activity.$["android:name"] === ".MainActivity") {
851
- activity.$["android:theme"] = "@style/BootTheme";
852
- }
853
- });
854
- }
855
- });
856
- return config;
857
- });
858
- const withMainActivity = config => Expo.withMainActivity(config, config => {
859
- const {
860
- modResults
861
- } = config;
862
- const {
863
- language
864
- } = modResults;
865
- const withImports = (0, _codeMod.addImports)(modResults.contents.replace(/(\/\/ )?setTheme\(R\.style\.AppTheme\)/, "// setTheme(R.style.AppTheme)"), ["android.os.Bundle", "com.zoontek.rnbootsplash.RNBootSplash"], language === "java");
866
-
867
- // indented with 4 spaces
868
- const withInit = (0, _generateCode.mergeContents)({
869
- src: withImports,
870
- comment: " //",
871
- tag: "bootsplash-init",
872
- offset: 0,
873
- anchor: /super\.onCreate\(null\)/,
874
- newSrc: " RNBootSplash.init(this, R.style.BootTheme)" + (language === "java" ? ";" : "")
875
- });
876
- return {
877
- ...config,
878
- modResults: {
879
- ...modResults,
880
- contents: withInit.contents
881
- }
882
- };
883
- });
884
- const withAndroidStyles = (config, props) => Expo.withAndroidStyles(config, async config => {
885
- const {
886
- assetsDir = "assets/bootsplash",
887
- android = {}
888
- } = props;
889
- const {
890
- parentTheme,
891
- darkContentBarsStyle
892
- } = android;
893
- const {
894
- modResults
895
- } = config;
896
- const {
897
- resources
898
- } = modResults;
899
- const {
900
- style = []
901
- } = resources;
902
- const manifest = await hfs.json(_path.default.resolve(workingPath, assetsDir, "manifest.json"));
903
- const item = [{
904
- $: {
905
- name: "postBootSplashTheme"
906
- },
907
- _: "@style/AppTheme"
908
- }, {
909
- $: {
910
- name: "bootSplashBackground"
911
- },
912
- _: "@color/bootsplash_background"
913
- }, {
914
- $: {
915
- name: "bootSplashLogo"
916
- },
917
- _: "@drawable/bootsplash_logo"
918
- }];
919
- if (manifest.brand != null) {
920
- item.push({
921
- $: {
922
- name: "bootSplashBrand"
923
- },
924
- _: "@drawable/bootsplash_brand"
925
- });
926
- }
927
- if (darkContentBarsStyle != null) {
928
- item.push({
929
- $: {
930
- name: "darkContentBarsStyle"
931
- },
932
- _: String(darkContentBarsStyle)
933
- });
934
- }
935
- const withBootTheme = [...style.filter(({
936
- $
937
- }) => $.name !== "BootTheme"), {
938
- $: {
939
- name: "BootTheme",
940
- parent: parentTheme === "TransparentStatus" ? "Theme.BootSplash.TransparentStatus" : parentTheme === "EdgeToEdge" ? "Theme.BootSplash.EdgeToEdge" : "Theme.BootSplash"
941
- },
942
- item
943
- }];
944
- return {
945
- ...config,
946
- modResults: {
947
- ...modResults,
948
- resources: {
949
- ...resources,
950
- style: withBootTheme
951
- }
952
- }
953
- };
954
- });
955
- const withAndroidColors = (config, props) => Expo.withAndroidColors(config, async config => {
956
- const {
957
- assetsDir = "assets/bootsplash"
958
- } = props;
959
- const manifest = await hfs.json(_path.default.resolve(workingPath, assetsDir, "manifest.json"));
960
- config.modResults = (0, _Colors.assignColorValue)(config.modResults, {
961
- name: "bootsplash_background",
962
- value: manifest.background
963
- });
964
- return config;
965
- });
966
- const withAndroidColorsNight = (config, props) => Expo.withAndroidColorsNight(config, async config => {
967
- const {
968
- assetsDir = "assets/bootsplash"
969
- } = props;
970
- const manifest = await hfs.json(_path.default.resolve(workingPath, assetsDir, "manifest.json"));
971
- if (manifest.darkBackground != null) {
972
- config.modResults = (0, _Colors.assignColorValue)(config.modResults, {
973
- name: "bootsplash_background",
974
- value: manifest.darkBackground
975
- });
976
- }
977
- return config;
978
- });
979
- const withIOSAssets = (config, props) => Expo.withDangerousMod(config, ["ios", config => {
980
- const {
981
- assetsDir = "assets/bootsplash"
982
- } = props;
983
- const {
984
- platformProjectRoot,
985
- projectName = ""
986
- } = config.modRequest;
987
- const srcDir = _path.default.resolve(workingPath, assetsDir, "ios");
988
- const destDir = _path.default.resolve(platformProjectRoot, projectName);
989
- cleanIOS(destDir);
990
- hfs.copy(_path.default.join(srcDir, "BootSplash.storyboard"), _path.default.join(destDir, "BootSplash.storyboard"));
991
- for (const xcassetsDir of ["Colors.xcassets", "Images.xcassets"]) {
992
- const srcXcassetsDir = _path.default.join(srcDir, xcassetsDir);
993
- const destXcassetsDir = _path.default.join(destDir, xcassetsDir);
994
- hfs.ensureDir(destXcassetsDir);
995
- for (const file of hfs.readDir(srcXcassetsDir)) {
996
- hfs.copy(_path.default.join(srcXcassetsDir, file), _path.default.join(destXcassetsDir, file));
997
- }
998
- }
999
- return config;
1000
- }]);
1001
- const withAppDelegate = config => Expo.withAppDelegate(config, config => {
1002
- const {
1003
- modResults
1004
- } = config;
1005
- const {
1006
- language
1007
- } = modResults;
1008
- if (language !== "objc" && language !== "objcpp") {
1009
- throw new Error(`Cannot modify the project AppDelegate as it's not in a supported language: ${language}`);
1010
- }
1011
- const withHeader = (0, _generateCode.mergeContents)({
1012
- src: modResults.contents,
1013
- comment: "//",
1014
- tag: "bootsplash-header",
1015
- offset: 1,
1016
- anchor: /#import "AppDelegate\.h"/,
1017
- newSrc: '#import "RNBootSplash.h"'
1018
- });
1019
- const withRootView = (0, _generateCode.mergeContents)({
1020
- src: withHeader.contents,
1021
- comment: "//",
1022
- tag: "bootsplash-init",
1023
- offset: 0,
1024
- anchor: /@end/,
1025
- newSrc: (0, _tsDedent.dedent)`
1026
- - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initProps:(NSDictionary *)initProps {
1027
- UIView *rootView = [super createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps];
1028
- [RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView];
1029
- return rootView;
1030
- }
1031
- `
1032
- });
1033
- return {
1034
- ...config,
1035
- modResults: {
1036
- ...modResults,
1037
- contents: withRootView.contents
1038
- }
1039
- };
1040
- });
1041
- const withInfoPlist = config => Expo.withInfoPlist(config, config => {
1042
- config.modResults["UILaunchStoryboardName"] = "BootSplash";
1043
- return config;
1044
- });
1045
- const withXcodeProject = config => Expo.withXcodeProject(config, config => {
1046
- const {
1047
- projectName = ""
1048
- } = config.modRequest;
1049
- Expo.IOSConfig.XcodeUtils.addResourceFileToGroup({
1050
- filepath: _path.default.join(projectName, "BootSplash.storyboard"),
1051
- groupName: projectName,
1052
- project: config.modResults,
1053
- isBuildFile: true
1054
- });
1055
- Expo.IOSConfig.XcodeUtils.addResourceFileToGroup({
1056
- filepath: _path.default.join(projectName, "Colors.xcassets"),
1057
- groupName: projectName,
1058
- project: config.modResults,
1059
- isBuildFile: true
1060
- });
1061
- return config;
1062
- });
1063
- const withoutExpoSplashScreen = Expo.createRunOncePlugin(config => config, "expo-splash-screen", "skip");
1064
- const withGenerate = (config, props = {}) => {
1065
- const plugins = [];
1066
- const {
1067
- platforms = []
1068
- } = config;
1069
- plugins.push(withoutExpoSplashScreen);
1070
- if (platforms.includes("android")) {
1071
- plugins.push(withAndroidAssets, withAndroidManifest, withMainActivity, withAndroidStyles, withAndroidColors, withAndroidColorsNight);
1072
- }
1073
- if (platforms.includes("ios")) {
1074
- plugins.push(withIOSAssets, withAppDelegate, withInfoPlist, withXcodeProject);
1075
- }
1076
- return Expo.withPlugins(config, plugins.map(plugin => [plugin, props]));
1077
- };
1078
- exports.withGenerate = withGenerate;
1079
837
  //# sourceMappingURL=generate.js.map