@expensify/react-native-live-markdown 0.1.126 → 0.1.128

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,5 +1,9 @@
1
1
  require "json"
2
2
 
3
+ react_native_node_modules_dir = ENV['REACT_NATIVE_NODE_MODULES_DIR'] || File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`), '..')
4
+ react_native_json = JSON.parse(File.read(File.join(react_native_node_modules_dir, 'react-native/package.json')))
5
+ react_native_minor_version = react_native_json['version'].split('.')[1].to_i
6
+
3
7
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
8
  folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
9
 
@@ -20,6 +24,10 @@ Pod::Spec.new do |s|
20
24
 
21
25
  s.dependency "hermes-engine"
22
26
 
27
+ s.xcconfig = {
28
+ "OTHER_CFLAGS" => "$(inherited) -DREACT_NATIVE_MINOR_VERSION=#{react_native_minor_version}"
29
+ }
30
+
23
31
  install_modules_dependencies(s)
24
32
 
25
33
  if ENV['USE_FRAMEWORKS'] && ENV['RCT_NEW_ARCH_ENABLED']
@@ -32,6 +32,11 @@ def getExtOrIntegerDefault(name) {
32
32
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["LiveMarkdown_" + name]).toInteger()
33
33
  }
34
34
 
35
+ def safeAppExtGet(prop, fallback) {
36
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
37
+ appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
38
+ }
39
+
35
40
  def supportsNamespace() {
36
41
  def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
37
42
  def major = parsed[0].toInteger()
@@ -41,6 +46,40 @@ def supportsNamespace() {
41
46
  return (major == 7 && minor >= 3) || major >= 8
42
47
  }
43
48
 
49
+ def resolveReactNativeDirectory() {
50
+ def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
51
+ if (reactNativeLocation != null) {
52
+ return file(reactNativeLocation)
53
+ }
54
+
55
+ // monorepo workaround
56
+ // react-native can be hoisted or in project's own node_modules
57
+ def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native")
58
+ if (reactNativeFromProjectNodeModules.exists()) {
59
+ return reactNativeFromProjectNodeModules
60
+ }
61
+
62
+ def reactNativeFromLiveMarkdownMonorepo = file("${projectDir}/../../../node_modules/react-native")
63
+ if (reactNativeFromLiveMarkdownMonorepo.exists()) {
64
+ return reactNativeFromLiveMarkdownMonorepo
65
+ }
66
+
67
+ def reactNativeFromNodeModulesWithLiveMarkdown = file("${projectDir}/../../react-native")
68
+ if (reactNativeFromNodeModulesWithLiveMarkdown.exists()) {
69
+ return reactNativeFromNodeModulesWithLiveMarkdown
70
+ }
71
+
72
+ throw new GradleException("[react-native-live-markdown] Unable to resolve react-native location in node_modules. Your app should define `REACT_NATIVE_NODE_MODULES_DIR` extension property in `app/build.gradle` with a path to react-native in node_modules.")
73
+ }
74
+
75
+ def getReactNativeMinorVersion() {
76
+ def reactNativeRootDir = resolveReactNativeDirectory()
77
+ def reactNativeProperties = new Properties()
78
+ file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactNativeProperties.load(it) }
79
+ def reactNativeVersion = reactNativeProperties.getProperty("VERSION_NAME")
80
+ return reactNativeVersion.split("\\.")[1].toInteger()
81
+ }
82
+
44
83
  android {
45
84
  if (supportsNamespace()) {
46
85
  namespace "com.expensify.livemarkdown"
@@ -57,13 +96,17 @@ android {
57
96
  defaultConfig {
58
97
  minSdkVersion getExtOrIntegerDefault("minSdkVersion")
59
98
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
99
+
100
+ buildConfigField "int", "REACT_NATIVE_MINOR_VERSION", getReactNativeMinorVersion().toString()
60
101
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
61
-
102
+
62
103
  consumerProguardFiles "proguard-rules.pro"
63
-
104
+
64
105
  externalNativeBuild {
65
106
  cmake {
66
- arguments "-DANDROID_STL=c++_shared", "-DANDROID_TOOLCHAIN=clang"
107
+ arguments "-DANDROID_STL=c++_shared",
108
+ "-DANDROID_TOOLCHAIN=clang",
109
+ "-DREACT_NATIVE_MINOR_VERSION=${getReactNativeMinorVersion()}"
67
110
  abiFilters (*reactNativeArchitectures())
68
111
  }
69
112
  }
@@ -6,6 +6,8 @@ set(CMAKE_VERBOSE_MAKEFILE on)
6
6
 
7
7
  add_compile_options(-fvisibility=hidden -fexceptions -frtti)
8
8
 
9
+ string(APPEND CMAKE_CXX_FLAGS " -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}")
10
+
9
11
  file(GLOB livemarkdown_SRC CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
10
12
 
11
13
  add_library(${CMAKE_PROJECT_NAME} SHARED ${livemarkdown_SRC})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expensify/react-native-live-markdown",
3
- "version": "0.1.126",
3
+ "version": "0.1.128",
4
4
  "description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",