react-native-bootsplash 6.0.0-beta.6 → 6.0.0-beta.7

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,4 +1,4 @@
1
- import { ImageProps, ImageRequireSource, ViewProps } from "react-native";
1
+ import { ImageRequireSource, ImageResizeMode, ImageSourcePropType, ImageStyle, ViewStyle } from "react-native";
2
2
  export type Config = {
3
3
  fade?: boolean;
4
4
  };
@@ -26,10 +26,28 @@ export type UseHideAnimationConfig = {
26
26
  statusBarTranslucent?: boolean;
27
27
  navigationBarTranslucent?: boolean;
28
28
  };
29
+ export type ContainerProps = {
30
+ style: ViewStyle;
31
+ onLayout: () => void;
32
+ };
33
+ export type LogoProps = {
34
+ source: ImageSourcePropType;
35
+ fadeDuration?: number;
36
+ resizeMode?: ImageResizeMode;
37
+ style?: ImageStyle;
38
+ onLoadEnd?: () => void;
39
+ };
40
+ export type BrandProps = {
41
+ source: ImageSourcePropType;
42
+ fadeDuration?: number;
43
+ resizeMode?: ImageResizeMode;
44
+ style?: ImageStyle;
45
+ onLoadEnd?: () => void;
46
+ };
29
47
  export type UseHideAnimation = {
30
- container: ViewProps;
31
- logo: ImageProps;
32
- brand: ImageProps;
48
+ container: ContainerProps;
49
+ logo: LogoProps;
50
+ brand: BrandProps;
33
51
  };
34
52
  export declare function hide(config?: Config): Promise<void>;
35
53
  export declare function isVisible(): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,kBAAkB,EAGlB,SAAS,EAEV,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,EA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;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,cAAc,CAAC;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,wBAAgB,IAAI,CAAC,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvD;AAED,wBAAgB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAE5C;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,oBAoL9D;;;;;;AAED,wBAIE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-bootsplash",
3
- "version": "6.0.0-beta.6",
3
+ "version": "6.0.0-beta.7",
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,7 +64,6 @@
64
64
  "react-native": ">=0.70.0"
65
65
  },
66
66
  "dependencies": {
67
- "@emotion/hash": "^0.9.1",
68
67
  "@expo/config": "^8.1.2 || ^9.0.1",
69
68
  "@expo/config-plugins": "^7.2.5 || ^8.0.4",
70
69
  "detect-indent": "^6.1.0",
package/src/generate.ts CHANGED
@@ -1,4 +1,3 @@
1
- import murmurhash from "@emotion/hash";
2
1
  import { getConfig as getExpoConfig } from "@expo/config";
3
2
  import * as Expo from "@expo/config-plugins";
4
3
  import { assignColorValue } from "@expo/config-plugins/build/android/Colors";
@@ -10,9 +9,10 @@ import {
10
9
  AndroidProjectConfig,
11
10
  IOSProjectConfig,
12
11
  } from "@react-native-community/cli-types";
12
+ import crypto from "crypto";
13
13
  import detectIndent from "detect-indent";
14
14
  import fs from "fs-extra";
15
- import { parse as parseHtml } from "node-html-parser";
15
+ import { HTMLElement, parse as parseHtml } from "node-html-parser";
16
16
  import path from "path";
17
17
  import pc from "picocolors";
18
18
  import { Options as PrettierOptions } from "prettier";
@@ -27,7 +27,7 @@ import { Manifest } from ".";
27
27
  const workingPath = process.env.INIT_CWD ?? process.env.PWD ?? process.cwd();
28
28
  const projectRoot = findProjectRoot(workingPath);
29
29
 
30
- export type Platforms = ("android" | "ios" | "web")[];
30
+ type Platforms = ("android" | "ios" | "web")[];
31
31
 
32
32
  export type RGBColor = {
33
33
  R: string;
@@ -35,7 +35,7 @@ export type RGBColor = {
35
35
  B: string;
36
36
  };
37
37
 
38
- export type Color = {
38
+ type Color = {
39
39
  hex: string;
40
40
  rgb: RGBColor;
41
41
  };
@@ -60,7 +60,7 @@ export const log = {
60
60
  },
61
61
  };
62
62
 
63
- export const parseColor = (value: string): Color => {
63
+ const parseColor = (value: string): Color => {
64
64
  const up = value.toUpperCase().replace(/[^0-9A-F]/g, "");
65
65
 
66
66
  if (up.length !== 3 && up.length !== 6) {
@@ -185,62 +185,75 @@ export const writeJson = (filePath: string, content: object) => {
185
185
  log.write(filePath);
186
186
  };
187
187
 
188
- export const readXml = (filePath: string) => {
189
- const xml = hfs.text(filePath);
190
- const { indent } = detectIndent(xml);
188
+ type FormatOptions = { indent?: detectIndent.Indent } & (
189
+ | {
190
+ formatter: "prettier";
191
+ selfClosingTags?: boolean;
192
+ useCssPlugin?: boolean;
193
+ htmlWhitespaceSensitivity?: PrettierOptions["htmlWhitespaceSensitivity"];
194
+ singleAttributePerLine?: PrettierOptions["singleAttributePerLine"];
195
+ }
196
+ | {
197
+ formatter: "xmlFormatter";
198
+ whiteSpaceAtEndOfSelfclosingTag?: XMLFormatterOptions["whiteSpaceAtEndOfSelfclosingTag"];
199
+ }
200
+ );
191
201
 
192
- const formatOptions: XMLFormatterOptions = {
193
- indentation: indent || " ",
194
- };
202
+ export const readXmlLike = (filePath: string) => {
203
+ const content = hfs.text(filePath);
195
204
 
196
- return { root: parseHtml(xml), formatOptions };
205
+ return {
206
+ root: parseHtml(content),
207
+ formatOptions: { indent: detectIndent(content) },
208
+ };
197
209
  };
198
210
 
199
- export const writeXml = (
211
+ export const writeXmlLike = async (
200
212
  filePath: string,
201
213
  content: string,
202
- options?: XMLFormatterOptions,
214
+ { indent, ...formatOptions }: FormatOptions,
203
215
  ) => {
204
- const formatted = formatXml(content, {
205
- collapseContent: true,
206
- forceSelfClosingEmptyTag: true,
207
- indentation: " ",
208
- lineSeparator: "\n",
209
- whiteSpaceAtEndOfSelfclosingTag: true,
210
- ...options,
211
- });
212
-
213
- hfs.write(filePath, formatted);
214
- log.write(filePath);
215
- };
216
-
217
- export const readHtml = (filePath: string) => {
218
- const html = hfs.text(filePath);
219
- const { type, amount } = detectIndent(html);
220
-
221
- const formatOptions: PrettierOptions = {
222
- useTabs: type === "tab",
223
- tabWidth: amount || 2,
224
- };
216
+ if (formatOptions.formatter === "prettier") {
217
+ const {
218
+ formatter,
219
+ useCssPlugin = false,
220
+ selfClosingTags = false,
221
+ ...options
222
+ } = formatOptions;
223
+
224
+ const formatted = await prettier.format(content, {
225
+ parser: "html",
226
+ bracketSameLine: true,
227
+ printWidth: 10000,
228
+ plugins: [htmlPlugin, ...(useCssPlugin ? [cssPlugin] : [])],
229
+ useTabs: indent?.type === "tab",
230
+ tabWidth: (indent?.amount ?? 0) || 2,
231
+ ...options,
232
+ });
225
233
 
226
- return { root: parseHtml(html), formatOptions };
227
- };
234
+ hfs.write(
235
+ filePath,
236
+ selfClosingTags
237
+ ? formatted.replace(/><\/[a-z-0-9]+>/gi, " />")
238
+ : formatted,
239
+ );
228
240
 
229
- export const writeHtml = async (
230
- filePath: string,
231
- content: string,
232
- options?: Omit<PrettierOptions, "parser" | "plugins">,
233
- ) => {
234
- const formatted = await prettier.format(content, {
235
- parser: "html",
236
- plugins: [htmlPlugin, cssPlugin],
237
- tabWidth: 2,
238
- useTabs: false,
239
- ...options,
240
- });
241
+ log.write(filePath);
242
+ } else {
243
+ const { formatter, ...options } = formatOptions;
244
+
245
+ const formatted = formatXml(content, {
246
+ collapseContent: true,
247
+ forceSelfClosingEmptyTag: true,
248
+ lineSeparator: "\n",
249
+ whiteSpaceAtEndOfSelfclosingTag: true,
250
+ indentation: (indent?.indent ?? "") || " ",
251
+ ...options,
252
+ });
241
253
 
242
- hfs.write(filePath, formatted);
243
- log.write(filePath);
254
+ hfs.write(filePath, formatted);
255
+ log.write(filePath);
256
+ }
244
257
  };
245
258
 
246
259
  const cleanIOS = (dir: string) => {
@@ -316,7 +329,11 @@ const getFileNameSuffix = async ({
316
329
  .map((key) => record[key])
317
330
  .join();
318
331
 
319
- return murmurhash(stableKey);
332
+ return crypto
333
+ .createHash("shake256", { outputLength: 3 })
334
+ .update(stableKey)
335
+ .digest("hex")
336
+ .toLowerCase();
320
337
  };
321
338
 
322
339
  const ensureSupportedFormat = async (
@@ -402,8 +419,8 @@ const getAndroidOutputPath = ({
402
419
  };
403
420
 
404
421
  const getIOSOutputPath = ({
405
- assetsOutputPath,
406
422
  ios,
423
+ assetsOutputPath,
407
424
  isExpo,
408
425
  platforms,
409
426
  }: {
@@ -466,7 +483,7 @@ const getHtmlTemplatePath = ({
466
483
  return htmlTemplatePath;
467
484
  };
468
485
 
469
- export const getImageHeight = (
486
+ const getImageHeight = (
470
487
  image: Sharp | undefined,
471
488
  width: number,
472
489
  ): Promise<number> => {
@@ -742,7 +759,7 @@ export const generate = async ({
742
759
  const colorsXmlEntry = `<color name="bootsplash_background">${background.hex}</color>`;
743
760
 
744
761
  if (hfs.exists(colorsXmlPath)) {
745
- const { root, formatOptions } = readXml(colorsXmlPath);
762
+ const { root, formatOptions } = readXmlLike(colorsXmlPath);
746
763
  const nextColor = parseHtml(colorsXmlEntry);
747
764
 
748
765
  const prevColor = root.querySelector(
@@ -755,9 +772,99 @@ export const generate = async ({
755
772
  root.querySelector("resources")?.appendChild(nextColor);
756
773
  }
757
774
 
758
- writeXml(colorsXmlPath, root.toString(), formatOptions);
775
+ await writeXmlLike(colorsXmlPath, root.toString(), {
776
+ ...formatOptions,
777
+ formatter: "xmlFormatter",
778
+ });
759
779
  } else {
760
- writeXml(colorsXmlPath, `<resources>${colorsXmlEntry}</resources>`);
780
+ await writeXmlLike(
781
+ colorsXmlPath,
782
+ `<resources>${colorsXmlEntry}</resources>`,
783
+ { formatter: "xmlFormatter" },
784
+ );
785
+ }
786
+
787
+ {
788
+ const manifestXmlPath = path.resolve(
789
+ androidOutputPath,
790
+ "..",
791
+ "AndroidManifest.xml",
792
+ );
793
+
794
+ const { root, formatOptions } = readXmlLike(manifestXmlPath);
795
+ const activities = root.querySelectorAll("activity");
796
+
797
+ for (const activity of activities) {
798
+ if (activity.getAttribute("android:name") === ".MainActivity") {
799
+ activity.setAttribute("android:theme", "@style/BootTheme");
800
+ }
801
+ }
802
+
803
+ await writeXmlLike(manifestXmlPath, root.toString(), {
804
+ ...formatOptions,
805
+ formatter: "prettier",
806
+ htmlWhitespaceSensitivity: "ignore",
807
+ selfClosingTags: true,
808
+ singleAttributePerLine: true,
809
+ });
810
+ }
811
+
812
+ {
813
+ const stylesXmlPath = path.resolve(valuesPath, "styles.xml");
814
+ const { root, formatOptions } = readXmlLike(stylesXmlPath);
815
+
816
+ const prevStyle = root.querySelector('style[name="BootTheme"]');
817
+ const parent = prevStyle?.getAttribute("parent") ?? "Theme.BootSplash";
818
+
819
+ const extraItems = parseHtml(
820
+ prevStyle?.text
821
+ .split("\n")
822
+ .map((line) => line.trim())
823
+ .join("") ?? "",
824
+ )
825
+ .childNodes.filter((node) => {
826
+ if (!(node instanceof HTMLElement)) {
827
+ return true;
828
+ }
829
+
830
+ const name = node.getAttribute("name");
831
+
832
+ return (
833
+ name !== "bootSplashBackground" &&
834
+ name !== "bootSplashLogo" &&
835
+ name !== "bootSplashBrand" &&
836
+ name !== "postBootSplashTheme"
837
+ );
838
+ })
839
+ .map((node) => node.toString());
840
+
841
+ const styleItems: string[] = [
842
+ ...(extraItems.length > 0 ? [...extraItems, ""] : []),
843
+
844
+ '<item name="bootSplashBackground">@color/bootsplash_background</item>',
845
+ '<item name="bootSplashLogo">@drawable/bootsplash_logo</item>',
846
+
847
+ ...(brand != null && brandPath != null
848
+ ? ['<item name="bootSplashBrand">@drawable/bootsplash_brand</item>']
849
+ : []),
850
+
851
+ '<item name="postBootSplashTheme">@style/AppTheme</item>',
852
+ ];
853
+
854
+ const nextStyle = parseHtml(dedent`
855
+ <style name="BootTheme" parent="${parent}">
856
+ ${styleItems.join("\n")}
857
+ </style>
858
+ `);
859
+
860
+ prevStyle?.remove(); // remove the existing style
861
+ root.querySelector("resources")?.appendChild(nextStyle);
862
+
863
+ await writeXmlLike(stylesXmlPath, root.toString(), {
864
+ ...formatOptions,
865
+ formatter: "prettier",
866
+ htmlWhitespaceSensitivity: "ignore",
867
+ });
761
868
  }
762
869
  }
763
870
  }
@@ -785,7 +892,7 @@ export const generate = async ({
785
892
  hfs.ensureDir(colorsSetPath);
786
893
  hfs.ensureDir(imageSetPath);
787
894
 
788
- writeXml(
895
+ await writeXmlLike(
789
896
  storyboardPath,
790
897
  getStoryboard({
791
898
  logoHeight,
@@ -793,7 +900,10 @@ export const generate = async ({
793
900
  background: background.rgb,
794
901
  fileNameSuffix,
795
902
  }),
796
- { whiteSpaceAtEndOfSelfclosingTag: false },
903
+ {
904
+ formatter: "xmlFormatter",
905
+ whiteSpaceAtEndOfSelfclosingTag: false,
906
+ },
797
907
  );
798
908
 
799
909
  writeJson(path.resolve(colorsSetPath, "Contents.json"), {
@@ -919,7 +1029,7 @@ export const generate = async ({
919
1029
  if (htmlTemplatePath != null) {
920
1030
  log.title("🌐", "Web");
921
1031
 
922
- const { root, formatOptions } = readHtml(htmlTemplatePath);
1032
+ const { root, formatOptions } = readXmlLike(htmlTemplatePath);
923
1033
  const { format } = await logo.metadata();
924
1034
  const prevStyle = root.querySelector("#bootsplash-style");
925
1035
 
@@ -977,7 +1087,11 @@ export const generate = async ({
977
1087
  root.querySelector("body")?.appendChild(nextDiv);
978
1088
  }
979
1089
 
980
- await writeHtml(htmlTemplatePath, root.toString(), formatOptions);
1090
+ await writeXmlLike(htmlTemplatePath, root.toString(), {
1091
+ ...formatOptions,
1092
+ formatter: "prettier",
1093
+ useCssPlugin: true,
1094
+ });
981
1095
  }
982
1096
 
983
1097
  log.title("📄", "Assets");
@@ -1061,15 +1175,13 @@ ${pc.blue("┗━━━━━━━━━━━━━━━━━━━━━━
1061
1175
  );
1062
1176
  };
1063
1177
 
1064
- export type ExpoProps = {
1178
+ type ExpoPlugin = Expo.ConfigPlugin<{
1065
1179
  assetsDir?: string;
1066
1180
  android?: {
1067
1181
  parentTheme?: "TransparentStatus" | "EdgeToEdge";
1068
1182
  darkContentBarsStyle?: boolean;
1069
1183
  };
1070
- };
1071
-
1072
- export type ExpoPlugin = Expo.ConfigPlugin<ExpoProps>;
1184
+ }>;
1073
1185
 
1074
1186
  const withAndroidAssets: ExpoPlugin = (config, props) =>
1075
1187
  Expo.withDangerousMod(config, [
@@ -1323,12 +1435,12 @@ const withAppDelegate: ExpoPlugin = (config) =>
1323
1435
  offset: 0,
1324
1436
  anchor: /@end/,
1325
1437
  newSrc: dedent`
1326
- - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initProps:(NSDictionary *)initProps {
1327
- UIView *rootView = [super createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps];
1328
- [RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView];
1329
- return rootView;
1330
- }
1331
- `,
1438
+ - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initProps:(NSDictionary *)initProps {
1439
+ UIView *rootView = [super createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps];
1440
+ [RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView];
1441
+ return rootView;
1442
+ }
1443
+ `,
1332
1444
  });
1333
1445
 
1334
1446
  return {
package/src/index.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
2
  import {
3
- ImageProps,
4
3
  ImageRequireSource,
4
+ ImageResizeMode,
5
+ ImageSourcePropType,
6
+ ImageStyle,
5
7
  Platform,
6
8
  StyleSheet,
7
- ViewProps,
8
9
  ViewStyle,
9
10
  } from "react-native";
10
11
  import NativeModule from "./NativeRNBootSplash";
@@ -42,10 +43,31 @@ export type UseHideAnimationConfig = {
42
43
  navigationBarTranslucent?: boolean;
43
44
  };
44
45
 
46
+ export type ContainerProps = {
47
+ style: ViewStyle;
48
+ onLayout: () => void;
49
+ };
50
+
51
+ export type LogoProps = {
52
+ source: ImageSourcePropType;
53
+ fadeDuration?: number;
54
+ resizeMode?: ImageResizeMode;
55
+ style?: ImageStyle;
56
+ onLoadEnd?: () => void;
57
+ };
58
+
59
+ export type BrandProps = {
60
+ source: ImageSourcePropType;
61
+ fadeDuration?: number;
62
+ resizeMode?: ImageResizeMode;
63
+ style?: ImageStyle;
64
+ onLoadEnd?: () => void;
65
+ };
66
+
45
67
  export type UseHideAnimation = {
46
- container: ViewProps;
47
- logo: ImageProps;
48
- brand: ImageProps;
68
+ container: ContainerProps;
69
+ logo: LogoProps;
70
+ brand: BrandProps;
49
71
  };
50
72
 
51
73
  export function hide(config: Config = {}): Promise<void> {
@@ -149,7 +171,7 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
149
171
  justifyContent: "center",
150
172
  };
151
173
 
152
- const container: ViewProps = {
174
+ const container: ContainerProps = {
153
175
  style: containerStyle,
154
176
  onLayout: () => {
155
177
  ref.current.layoutReady = true;
@@ -157,13 +179,13 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
157
179
  },
158
180
  };
159
181
 
160
- const logo: ImageProps =
182
+ const logo: LogoProps =
161
183
  logoFinalSrc == null
162
184
  ? { source: -1 }
163
185
  : {
186
+ source: logoFinalSrc,
164
187
  fadeDuration: 0,
165
188
  resizeMode: "contain",
166
- source: logoFinalSrc,
167
189
  style: {
168
190
  width: logoWidth,
169
191
  height: logoHeight,
@@ -174,13 +196,13 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
174
196
  },
175
197
  };
176
198
 
177
- const brand: ImageProps =
199
+ const brand: BrandProps =
178
200
  brandFinalSrc == null
179
201
  ? { source: -1 }
180
202
  : {
203
+ source: brandFinalSrc,
181
204
  fadeDuration: 0,
182
205
  resizeMode: "contain",
183
- source: brandFinalSrc,
184
206
  style: {
185
207
  position: "absolute",
186
208
  bottom: Platform.OS === "web" ? 60 : brandBottom,