number-flow-react-native 0.1.3 → 0.1.4

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,19 +1,36 @@
1
1
  "use strict";
2
2
 
3
+ import { UIManager } from "react-native";
3
4
  /**
4
5
  * Resolves the best available MaskedView implementation:
5
6
  * 1. `@rednegniw/masked-view` — Fabric-ready fork (dev builds)
6
7
  * 2. `@react-native-masked-view/masked-view` — bundled in Expo Go / Snack
7
8
  * 3. `null` — neither available, masking degrades gracefully
9
+ *
10
+ * A module may bundle successfully but its native component might not be
11
+ * registered (e.g. in Expo Go where only pre-bundled native modules exist).
12
+ * We verify via UIManager before accepting a resolved module.
8
13
  */
14
+ function hasNativeView(name) {
15
+ return UIManager.getViewManagerConfig?.(name) != null;
16
+ }
9
17
  let Resolved = null;
10
18
  try {
11
- Resolved = require("@rednegniw/masked-view").default;
19
+ const mod = require("@rednegniw/masked-view");
20
+ if (hasNativeView("NFMaskedView")) {
21
+ Resolved = mod.default;
22
+ }
12
23
  } catch {
24
+ // Module not available
25
+ }
26
+ if (!Resolved) {
13
27
  try {
14
- Resolved = require("@react-native-masked-view/masked-view").default;
28
+ const mod = require("@react-native-masked-view/masked-view");
29
+ if (hasNativeView("RNCMaskedView")) {
30
+ Resolved = mod.default;
31
+ }
15
32
  } catch {
16
- // Neither available — mask prop will be ignored
33
+ // Module not available
17
34
  }
18
35
  }
19
36
  export default Resolved;
@@ -1 +1 @@
1
- {"version":3,"names":["Resolved","require","default"],"sourceRoot":"../../../src","sources":["native/MaskedView.tsx"],"mappings":";;AAOA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIA,QAAqD,GAAG,IAAI;AAChE,IAAI;EACHA,QAAQ,GAAGC,OAAO,CAAC,wBAAwB,CAAC,CAACC,OAAO;AACrD,CAAC,CAAC,MAAM;EACP,IAAI;IACHF,QAAQ,GAAGC,OAAO,CAAC,uCAAuC,CAAC,CAACC,OAAO;EACpE,CAAC,CAAC,MAAM;IACP;EAAA;AAEF;AAEA,eAAeF,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":["UIManager","hasNativeView","name","getViewManagerConfig","Resolved","mod","require","default"],"sourceRoot":"../../../src","sources":["native/MaskedView.tsx"],"mappings":";;AACA,SAASA,SAAS,QAAwB,cAAc;AAMxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAACC,IAAY,EAAW;EAC7C,OAAOF,SAAS,CAACG,oBAAoB,GAAGD,IAAI,CAAC,IAAI,IAAI;AACtD;AAEA,IAAIE,QAAqD,GAAG,IAAI;AAChE,IAAI;EACH,MAAMC,GAAG,GAAGC,OAAO,CAAC,wBAAwB,CAAC;EAC7C,IAAIL,aAAa,CAAC,cAAc,CAAC,EAAE;IAClCG,QAAQ,GAAGC,GAAG,CAACE,OAAO;EACvB;AACD,CAAC,CAAC,MAAM;EACP;AAAA;AAGD,IAAI,CAACH,QAAQ,EAAE;EACd,IAAI;IACH,MAAMC,GAAG,GAAGC,OAAO,CAAC,uCAAuC,CAAC;IAC5D,IAAIL,aAAa,CAAC,eAAe,CAAC,EAAE;MACnCG,QAAQ,GAAGC,GAAG,CAACE,OAAO;IACvB;EACD,CAAC,CAAC,MAAM;IACP;EAAA;AAEF;AAEA,eAAeH,QAAQ","ignoreList":[]}
@@ -1,14 +1,8 @@
1
1
  import type { ReactElement } from "react";
2
- import type { ViewProps } from "react-native";
2
+ import { type ViewProps } from "react-native";
3
3
  interface MaskedViewProps extends ViewProps {
4
4
  maskElement: ReactElement;
5
5
  }
6
- /**
7
- * Resolves the best available MaskedView implementation:
8
- * 1. `@rednegniw/masked-view` — Fabric-ready fork (dev builds)
9
- * 2. `@react-native-masked-view/masked-view` — bundled in Expo Go / Snack
10
- * 3. `null` — neither available, masking degrades gracefully
11
- */
12
6
  declare let Resolved: React.ComponentType<MaskedViewProps> | null;
13
7
  export default Resolved;
14
8
  //# sourceMappingURL=MaskedView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MaskedView.d.ts","sourceRoot":"","sources":["../../../src/native/MaskedView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,UAAU,eAAgB,SAAQ,SAAS;IAC1C,WAAW,EAAE,YAAY,CAAC;CAC1B;AAED;;;;;GAKG;AACH,QAAA,IAAI,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,eAAe,CAAC,GAAG,IAAW,CAAC;AAWjE,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"MaskedView.d.ts","sourceRoot":"","sources":["../../../src/native/MaskedView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,UAAU,eAAgB,SAAQ,SAAS;IAC1C,WAAW,EAAE,YAAY,CAAC;CAC1B;AAgBD,QAAA,IAAI,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,eAAe,CAAC,GAAG,IAAW,CAAC;AAqBjE,eAAe,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "number-flow-react-native",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Animated number transitions for React Native — View-based and Skia renderers",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",
@@ -1,5 +1,5 @@
1
1
  import type { ReactElement } from "react";
2
- import type { ViewProps } from "react-native";
2
+ import { UIManager, type ViewProps } from "react-native";
3
3
 
4
4
  interface MaskedViewProps extends ViewProps {
5
5
  maskElement: ReactElement;
@@ -10,15 +10,33 @@ interface MaskedViewProps extends ViewProps {
10
10
  * 1. `@rednegniw/masked-view` — Fabric-ready fork (dev builds)
11
11
  * 2. `@react-native-masked-view/masked-view` — bundled in Expo Go / Snack
12
12
  * 3. `null` — neither available, masking degrades gracefully
13
+ *
14
+ * A module may bundle successfully but its native component might not be
15
+ * registered (e.g. in Expo Go where only pre-bundled native modules exist).
16
+ * We verify via UIManager before accepting a resolved module.
13
17
  */
18
+ function hasNativeView(name: string): boolean {
19
+ return UIManager.getViewManagerConfig?.(name) != null;
20
+ }
21
+
14
22
  let Resolved: React.ComponentType<MaskedViewProps> | null = null;
15
23
  try {
16
- Resolved = require("@rednegniw/masked-view").default;
24
+ const mod = require("@rednegniw/masked-view");
25
+ if (hasNativeView("NFMaskedView")) {
26
+ Resolved = mod.default;
27
+ }
17
28
  } catch {
29
+ // Module not available
30
+ }
31
+
32
+ if (!Resolved) {
18
33
  try {
19
- Resolved = require("@react-native-masked-view/masked-view").default;
34
+ const mod = require("@react-native-masked-view/masked-view");
35
+ if (hasNativeView("RNCMaskedView")) {
36
+ Resolved = mod.default;
37
+ }
20
38
  } catch {
21
- // Neither available — mask prop will be ignored
39
+ // Module not available
22
40
  }
23
41
  }
24
42