react-obsidian 0.0.1

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.
Files changed (216) hide show
  1. package/.buildkite/pipeline.yml +0 -0
  2. package/.eslintignore +1 -0
  3. package/.eslintrc.json +93 -0
  4. package/.nvmrc +1 -0
  5. package/LICENSE +7 -0
  6. package/README.md +160 -0
  7. package/babel.config.js +12 -0
  8. package/dist/src/GraphProperties.d.ts +6 -0
  9. package/dist/src/GraphProperties.d.ts.map +1 -0
  10. package/dist/src/GraphProperties.js +16 -0
  11. package/dist/src/GraphProperties.js.map +1 -0
  12. package/dist/src/Obsidian.d.ts +9 -0
  13. package/dist/src/Obsidian.d.ts.map +1 -0
  14. package/dist/src/Obsidian.js +22 -0
  15. package/dist/src/Obsidian.js.map +1 -0
  16. package/dist/src/ProvidedPropertiesStore.d.ts +10 -0
  17. package/dist/src/ProvidedPropertiesStore.d.ts.map +1 -0
  18. package/dist/src/ProvidedPropertiesStore.js +27 -0
  19. package/dist/src/ProvidedPropertiesStore.js.map +1 -0
  20. package/dist/src/Provides.d.ts +9 -0
  21. package/dist/src/Provides.d.ts.map +1 -0
  22. package/dist/src/Provides.js +15 -0
  23. package/dist/src/Provides.js.map +1 -0
  24. package/dist/src/ReferenceCounter.d.ts +8 -0
  25. package/dist/src/ReferenceCounter.d.ts.map +1 -0
  26. package/dist/src/ReferenceCounter.js +25 -0
  27. package/dist/src/ReferenceCounter.js.map +1 -0
  28. package/dist/src/ScopedValuesRegistry.d.ts +11 -0
  29. package/dist/src/ScopedValuesRegistry.d.ts.map +1 -0
  30. package/dist/src/ScopedValuesRegistry.js +25 -0
  31. package/dist/src/ScopedValuesRegistry.js.map +1 -0
  32. package/dist/src/decorators/Graph.d.ts +10 -0
  33. package/dist/src/decorators/Graph.d.ts.map +1 -0
  34. package/dist/src/decorators/Graph.js +17 -0
  35. package/dist/src/decorators/Graph.js.map +1 -0
  36. package/dist/src/decorators/injectClass.d.ts +7 -0
  37. package/dist/src/decorators/injectClass.d.ts.map +1 -0
  38. package/dist/src/decorators/injectClass.js +34 -0
  39. package/dist/src/decorators/injectClass.js.map +1 -0
  40. package/dist/src/graph/Graph.d.ts +6 -0
  41. package/dist/src/graph/Graph.d.ts.map +1 -0
  42. package/dist/src/graph/Graph.js +3 -0
  43. package/dist/src/graph/Graph.js.map +1 -0
  44. package/dist/src/graph/ObjectGraph.d.ts +11 -0
  45. package/dist/src/graph/ObjectGraph.d.ts.map +1 -0
  46. package/dist/src/graph/ObjectGraph.js +26 -0
  47. package/dist/src/graph/ObjectGraph.js.map +1 -0
  48. package/dist/src/graph/PropertyRetriever.d.ts +8 -0
  49. package/dist/src/graph/PropertyRetriever.d.ts.map +1 -0
  50. package/dist/src/graph/PropertyRetriever.js +40 -0
  51. package/dist/src/graph/PropertyRetriever.js.map +1 -0
  52. package/dist/src/graph/PropertyRetrieverDelegate.d.ts +5 -0
  53. package/dist/src/graph/PropertyRetrieverDelegate.d.ts.map +1 -0
  54. package/dist/src/graph/PropertyRetrieverDelegate.js +3 -0
  55. package/dist/src/graph/PropertyRetrieverDelegate.js.map +1 -0
  56. package/dist/src/graph/registry/DefaultGraphResolver.d.ts +7 -0
  57. package/dist/src/graph/registry/DefaultGraphResolver.d.ts.map +1 -0
  58. package/dist/src/graph/registry/DefaultGraphResolver.js +30 -0
  59. package/dist/src/graph/registry/DefaultGraphResolver.js.map +1 -0
  60. package/dist/src/graph/registry/GraphMiddleware.d.ts +12 -0
  61. package/dist/src/graph/registry/GraphMiddleware.d.ts.map +1 -0
  62. package/dist/src/graph/registry/GraphMiddleware.js +25 -0
  63. package/dist/src/graph/registry/GraphMiddleware.js.map +1 -0
  64. package/dist/src/graph/registry/GraphMiddlewareChain.d.ts +12 -0
  65. package/dist/src/graph/registry/GraphMiddlewareChain.d.ts.map +1 -0
  66. package/dist/src/graph/registry/GraphMiddlewareChain.js +30 -0
  67. package/dist/src/graph/registry/GraphMiddlewareChain.js.map +1 -0
  68. package/dist/src/graph/registry/GraphRegistry.d.ts +22 -0
  69. package/dist/src/graph/registry/GraphRegistry.d.ts.map +1 -0
  70. package/dist/src/graph/registry/GraphRegistry.js +65 -0
  71. package/dist/src/graph/registry/GraphRegistry.js.map +1 -0
  72. package/dist/src/index.d.ts +17 -0
  73. package/dist/src/index.d.ts.map +1 -0
  74. package/dist/src/index.js +24 -0
  75. package/dist/src/index.js.map +1 -0
  76. package/dist/src/injectHook.d.ts +5 -0
  77. package/dist/src/injectHook.d.ts.map +1 -0
  78. package/dist/src/injectHook.js +30 -0
  79. package/dist/src/injectHook.js.map +1 -0
  80. package/dist/src/injectors/components/ComponentInjector.d.ts +9 -0
  81. package/dist/src/injectors/components/ComponentInjector.d.ts.map +1 -0
  82. package/dist/src/injectors/components/ComponentInjector.js +48 -0
  83. package/dist/src/injectors/components/ComponentInjector.js.map +1 -0
  84. package/dist/src/injectors/components/PropsInjector.d.ts +7 -0
  85. package/dist/src/injectors/components/PropsInjector.d.ts.map +1 -0
  86. package/dist/src/injectors/components/PropsInjector.js +19 -0
  87. package/dist/src/injectors/components/PropsInjector.js.map +1 -0
  88. package/dist/src/injectors/components/useGraph.d.ts +5 -0
  89. package/dist/src/injectors/components/useGraph.d.ts.map +1 -0
  90. package/dist/src/injectors/components/useGraph.js +17 -0
  91. package/dist/src/injectors/components/useGraph.js.map +1 -0
  92. package/dist/test/integration/fixtures/InjectedComponent.d.ts +8 -0
  93. package/dist/test/integration/fixtures/InjectedComponent.d.ts.map +1 -0
  94. package/dist/test/integration/fixtures/InjectedComponent.js +14 -0
  95. package/dist/test/integration/fixtures/InjectedComponent.js.map +1 -0
  96. package/dist/test/integration/fixtures/MainGraph.d.ts +6 -0
  97. package/dist/test/integration/fixtures/MainGraph.d.ts.map +1 -0
  98. package/dist/test/integration/fixtures/MainGraph.js +53 -0
  99. package/dist/test/integration/fixtures/MainGraph.js.map +1 -0
  100. package/dist/test/integration/fixtures/StringProvider.d.ts +5 -0
  101. package/dist/test/integration/fixtures/StringProvider.d.ts.map +1 -0
  102. package/dist/test/integration/fixtures/StringProvider.js +15 -0
  103. package/dist/test/integration/fixtures/StringProvider.js.map +1 -0
  104. package/dist/test/integration/fixtures/Subgraph.d.ts +8 -0
  105. package/dist/test/integration/fixtures/Subgraph.d.ts.map +1 -0
  106. package/dist/test/integration/fixtures/Subgraph.js +71 -0
  107. package/dist/test/integration/fixtures/Subgraph.js.map +1 -0
  108. package/dist/test/integration/fixtures/ThrowingMainGraph.d.ts +5 -0
  109. package/dist/test/integration/fixtures/ThrowingMainGraph.d.ts.map +1 -0
  110. package/dist/test/integration/fixtures/ThrowingMainGraph.js +52 -0
  111. package/dist/test/integration/fixtures/ThrowingMainGraph.js.map +1 -0
  112. package/dist/test/integration/fixtures/injectedValues.d.ts +6 -0
  113. package/dist/test/integration/fixtures/injectedValues.d.ts.map +1 -0
  114. package/dist/test/integration/fixtures/injectedValues.js +7 -0
  115. package/dist/test/integration/fixtures/injectedValues.js.map +1 -0
  116. package/dist/testkit/index.d.ts +8 -0
  117. package/dist/testkit/index.d.ts.map +1 -0
  118. package/dist/testkit/index.js +46 -0
  119. package/dist/testkit/index.js.map +1 -0
  120. package/dist/transformers/babel-plugin-obsidian-provide/helpers/index.d.ts +9 -0
  121. package/dist/transformers/babel-plugin-obsidian-provide/helpers/index.d.ts.map +1 -0
  122. package/dist/transformers/babel-plugin-obsidian-provide/helpers/index.js +54 -0
  123. package/dist/transformers/babel-plugin-obsidian-provide/helpers/index.js.map +1 -0
  124. package/dist/transformers/babel-plugin-obsidian-provide/index.d.ts +3 -0
  125. package/dist/transformers/babel-plugin-obsidian-provide/index.d.ts.map +1 -0
  126. package/dist/transformers/babel-plugin-obsidian-provide/index.js +35 -0
  127. package/dist/transformers/babel-plugin-obsidian-provide/index.js.map +1 -0
  128. package/example/.buckconfig +6 -0
  129. package/example/.editorconfig +3 -0
  130. package/example/.eslintrc.js +4 -0
  131. package/example/.flowconfig +65 -0
  132. package/example/.gitattributes +3 -0
  133. package/example/.prettierrc.js +7 -0
  134. package/example/.watchmanconfig +1 -0
  135. package/example/App.tsx +31 -0
  136. package/example/MyInjectedComponent.tsx +28 -0
  137. package/example/__tests__/App-test.js +14 -0
  138. package/example/android/app/BUCK +55 -0
  139. package/example/android/app/build.gradle +227 -0
  140. package/example/android/app/build_defs.bzl +19 -0
  141. package/example/android/app/debug.keystore +0 -0
  142. package/example/android/app/proguard-rules.pro +10 -0
  143. package/example/android/app/src/debug/AndroidManifest.xml +13 -0
  144. package/example/android/app/src/debug/java/com/example/ReactNativeFlipper.java +72 -0
  145. package/example/android/app/src/main/AndroidManifest.xml +25 -0
  146. package/example/android/app/src/main/java/com/example/MainActivity.java +15 -0
  147. package/example/android/app/src/main/java/com/example/MainApplication.java +80 -0
  148. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  149. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  150. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  151. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  152. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  153. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  154. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  155. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  156. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  157. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  158. package/example/android/app/src/main/res/values/strings.xml +3 -0
  159. package/example/android/app/src/main/res/values/styles.xml +8 -0
  160. package/example/android/build.gradle +38 -0
  161. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  162. package/example/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  163. package/example/android/gradle.properties +28 -0
  164. package/example/android/gradlew +185 -0
  165. package/example/android/gradlew.bat +89 -0
  166. package/example/android/settings.gradle +3 -0
  167. package/example/app.json +4 -0
  168. package/example/babel.config.js +8 -0
  169. package/example/index.js +9 -0
  170. package/example/ios/Podfile +30 -0
  171. package/example/ios/Podfile.lock +526 -0
  172. package/example/ios/example/AppDelegate.h +8 -0
  173. package/example/ios/example/AppDelegate.m +62 -0
  174. package/example/ios/example/Images.xcassets/AppIcon.appiconset/Contents.json +38 -0
  175. package/example/ios/example/Images.xcassets/Contents.json +6 -0
  176. package/example/ios/example/Info.plist +55 -0
  177. package/example/ios/example/LaunchScreen.storyboard +47 -0
  178. package/example/ios/example/main.m +9 -0
  179. package/example/ios/example.xcodeproj/project.pbxproj +689 -0
  180. package/example/ios/example.xcodeproj/xcshareddata/xcschemes/example.xcscheme +88 -0
  181. package/example/ios/example.xcworkspace/contents.xcworkspacedata +10 -0
  182. package/example/ios/exampleTests/Info.plist +24 -0
  183. package/example/ios/exampleTests/exampleTests.m +65 -0
  184. package/example/metro.config.js +44 -0
  185. package/example/package.json +35 -0
  186. package/example/tsconfig.json +45 -0
  187. package/jest.config.js +12 -0
  188. package/package.json +79 -0
  189. package/src/@types/obsidian.d.ts +19 -0
  190. package/src/GraphProperties.ts +11 -0
  191. package/src/Obsidian.ts +18 -0
  192. package/src/ProvidedPropertiesStore.ts +22 -0
  193. package/src/Provides.ts +16 -0
  194. package/src/ReferenceCounter.ts +20 -0
  195. package/src/ScopedValuesRegistry.ts +26 -0
  196. package/src/decorators/Graph.ts +20 -0
  197. package/src/decorators/injectClass.ts +28 -0
  198. package/src/graph/Graph.ts +7 -0
  199. package/src/graph/ObjectGraph.ts +19 -0
  200. package/src/graph/PropertyRetriever.ts +36 -0
  201. package/src/graph/PropertyRetrieverDelegate.ts +5 -0
  202. package/src/graph/registry/DefaultGraphResolver.ts +9 -0
  203. package/src/graph/registry/GraphMiddleware.ts +24 -0
  204. package/src/graph/registry/GraphMiddlewareChain.ts +31 -0
  205. package/src/graph/registry/GraphRegistry.ts +70 -0
  206. package/src/index.ts +23 -0
  207. package/src/injectHook.ts +26 -0
  208. package/src/injectors/components/ComponentInjector.tsx +29 -0
  209. package/src/injectors/components/PropsInjector.ts +14 -0
  210. package/src/injectors/components/useGraph.ts +14 -0
  211. package/testkit/index.ts +25 -0
  212. package/transformers/babel-plugin-obsidian-provide/helpers/index.ts +59 -0
  213. package/transformers/babel-plugin-obsidian-provide/index.ts +44 -0
  214. package/tsconfig.base.json +43 -0
  215. package/tsconfig.json +3 -0
  216. package/tsconfig.prod.json +7 -0
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import type {ReactNode} from 'react';
3
+ import {SafeAreaView, ScrollView, StatusBar, useColorScheme, View} from 'react-native';
4
+
5
+ import {Colors} from 'react-native/Libraries/NewAppScreen';
6
+
7
+ import MyInjectedComponent from './MyInjectedComponent';
8
+
9
+ const App: () => ReactNode = () => {
10
+ const isDarkMode = useColorScheme() === 'dark';
11
+
12
+ const backgroundStyle = {
13
+ backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
14
+ };
15
+
16
+ return (
17
+ <SafeAreaView style={backgroundStyle}>
18
+ <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
19
+ <ScrollView contentInsetAdjustmentBehavior="automatic" style={backgroundStyle}>
20
+ <View
21
+ style={{
22
+ backgroundColor: isDarkMode ? Colors.black : Colors.white,
23
+ }}>
24
+ <MyInjectedComponent />
25
+ </View>
26
+ </ScrollView>
27
+ </SafeAreaView>
28
+ );
29
+ };
30
+
31
+ export default App;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import {Text, View} from 'react-native';
3
+ import {Graph, injectComponent, ObjectGraph, Provides} from 'react-obsidian';
4
+
5
+ interface DependenciesProps {
6
+ myText: string;
7
+ }
8
+
9
+ @Graph()
10
+ class DependenciesGraph extends ObjectGraph<DependenciesProps> {
11
+ @Provides()
12
+ myText(): string {
13
+ return 'Hello injected';
14
+ }
15
+ }
16
+
17
+ const MyInjectedComponent: React.FunctionComponent<DependenciesProps> = ({
18
+ myText,
19
+ }: DependenciesProps) => {
20
+ return (
21
+ <View style={{alignItems: 'center'}}>
22
+ <Text>{myText || 'default'}</Text>
23
+ </View>
24
+ );
25
+ };
26
+
27
+ // export default injectComponent(MyInjectedComponent, DependenciesGraph);
28
+ export default injectComponent(MyInjectedComponent, DependenciesGraph);
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @format
3
+ */
4
+
5
+ import 'react-native';
6
+ import React from 'react';
7
+ import App from '../App';
8
+
9
+ // Note: test renderer must be required after react-native.
10
+ import renderer from 'react-test-renderer';
11
+
12
+ it('renders correctly', () => {
13
+ renderer.create(<App />);
14
+ });
@@ -0,0 +1,55 @@
1
+ # To learn about Buck see [Docs](https://buckbuild.com/).
2
+ # To run your application with Buck:
3
+ # - install Buck
4
+ # - `npm start` - to start the packager
5
+ # - `cd android`
6
+ # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7
+ # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8
+ # - `buck install -r android/app` - compile, install and run application
9
+ #
10
+
11
+ load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12
+
13
+ lib_deps = []
14
+
15
+ create_aar_targets(glob(["libs/*.aar"]))
16
+
17
+ create_jar_targets(glob(["libs/*.jar"]))
18
+
19
+ android_library(
20
+ name = "all-libs",
21
+ exported_deps = lib_deps,
22
+ )
23
+
24
+ android_library(
25
+ name = "app-code",
26
+ srcs = glob([
27
+ "src/main/java/**/*.java",
28
+ ]),
29
+ deps = [
30
+ ":all-libs",
31
+ ":build_config",
32
+ ":res",
33
+ ],
34
+ )
35
+
36
+ android_build_config(
37
+ name = "build_config",
38
+ package = "com.example",
39
+ )
40
+
41
+ android_resource(
42
+ name = "res",
43
+ package = "com.example",
44
+ res = "src/main/res",
45
+ )
46
+
47
+ android_binary(
48
+ name = "app",
49
+ keystore = "//android/keystores:debug",
50
+ manifest = "src/main/AndroidManifest.xml",
51
+ package_type = "debug",
52
+ deps = [
53
+ ":app-code",
54
+ ],
55
+ )
@@ -0,0 +1,227 @@
1
+ apply plugin: "com.android.application"
2
+
3
+ import com.android.build.OutputFile
4
+
5
+ /**
6
+ * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7
+ * and bundleReleaseJsAndAssets).
8
+ * These basically call `react-native bundle` with the correct arguments during the Android build
9
+ * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10
+ * bundle directly from the development server. Below you can see all the possible configurations
11
+ * and their defaults. If you decide to add a configuration block, make sure to add it before the
12
+ * `apply from: "../../node_modules/react-native/react.gradle"` line.
13
+ *
14
+ * project.ext.react = [
15
+ * // the name of the generated asset file containing your JS bundle
16
+ * bundleAssetName: "index.android.bundle",
17
+ *
18
+ * // the entry file for bundle generation. If none specified and
19
+ * // "index.android.js" exists, it will be used. Otherwise "index.js" is
20
+ * // default. Can be overridden with ENTRY_FILE environment variable.
21
+ * entryFile: "index.android.js",
22
+ *
23
+ * // https://reactnative.dev/docs/performance#enable-the-ram-format
24
+ * bundleCommand: "ram-bundle",
25
+ *
26
+ * // whether to bundle JS and assets in debug mode
27
+ * bundleInDebug: false,
28
+ *
29
+ * // whether to bundle JS and assets in release mode
30
+ * bundleInRelease: true,
31
+ *
32
+ * // whether to bundle JS and assets in another build variant (if configured).
33
+ * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
34
+ * // The configuration property can be in the following formats
35
+ * // 'bundleIn${productFlavor}${buildType}'
36
+ * // 'bundleIn${buildType}'
37
+ * // bundleInFreeDebug: true,
38
+ * // bundleInPaidRelease: true,
39
+ * // bundleInBeta: true,
40
+ *
41
+ * // whether to disable dev mode in custom build variants (by default only disabled in release)
42
+ * // for example: to disable dev mode in the staging build type (if configured)
43
+ * devDisabledInStaging: true,
44
+ * // The configuration property can be in the following formats
45
+ * // 'devDisabledIn${productFlavor}${buildType}'
46
+ * // 'devDisabledIn${buildType}'
47
+ *
48
+ * // the root of your project, i.e. where "package.json" lives
49
+ * root: "../../",
50
+ *
51
+ * // where to put the JS bundle asset in debug mode
52
+ * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
53
+ *
54
+ * // where to put the JS bundle asset in release mode
55
+ * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
56
+ *
57
+ * // where to put drawable resources / React Native assets, e.g. the ones you use via
58
+ * // require('./image.png')), in debug mode
59
+ * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
60
+ *
61
+ * // where to put drawable resources / React Native assets, e.g. the ones you use via
62
+ * // require('./image.png')), in release mode
63
+ * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
64
+ *
65
+ * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
66
+ * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
67
+ * // date; if you have any other folders that you want to ignore for performance reasons (gradle
68
+ * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
69
+ * // for example, you might want to remove it from here.
70
+ * inputExcludes: ["android/**", "ios/**"],
71
+ *
72
+ * // override which node gets called and with what additional arguments
73
+ * nodeExecutableAndArgs: ["node"],
74
+ *
75
+ * // supply additional arguments to the packager
76
+ * extraPackagerArgs: []
77
+ * ]
78
+ */
79
+
80
+ project.ext.react = [
81
+ enableHermes: true, // clean and rebuild if changing
82
+ ]
83
+
84
+ apply from: "../../node_modules/react-native/react.gradle"
85
+
86
+ /**
87
+ * Set this to true to create two separate APKs instead of one:
88
+ * - An APK that only works on ARM devices
89
+ * - An APK that only works on x86 devices
90
+ * The advantage is the size of the APK is reduced by about 4MB.
91
+ * Upload all the APKs to the Play Store and people will download
92
+ * the correct one based on the CPU architecture of their device.
93
+ */
94
+ def enableSeparateBuildPerCPUArchitecture = false
95
+
96
+ /**
97
+ * Run Proguard to shrink the Java bytecode in release builds.
98
+ */
99
+ def enableProguardInReleaseBuilds = false
100
+
101
+ /**
102
+ * The preferred build flavor of JavaScriptCore.
103
+ *
104
+ * For example, to use the international variant, you can use:
105
+ * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
106
+ *
107
+ * The international variant includes ICU i18n library and necessary data
108
+ * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
109
+ * give correct results when using with locales other than en-US. Note that
110
+ * this variant is about 6MiB larger per architecture than default.
111
+ */
112
+ def jscFlavor = 'org.webkit:android-jsc:+'
113
+
114
+ /**
115
+ * Whether to enable the Hermes VM.
116
+ *
117
+ * This should be set on project.ext.react and mirrored here. If it is not set
118
+ * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
119
+ * and the benefits of using Hermes will therefore be sharply reduced.
120
+ */
121
+ def enableHermes = project.ext.react.get("enableHermes", false);
122
+
123
+ /**
124
+ * Architectures to build native code for in debug.
125
+ */
126
+ def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
127
+
128
+ android {
129
+ ndkVersion rootProject.ext.ndkVersion
130
+
131
+ compileSdkVersion rootProject.ext.compileSdkVersion
132
+
133
+ defaultConfig {
134
+ applicationId "com.example"
135
+ minSdkVersion rootProject.ext.minSdkVersion
136
+ targetSdkVersion rootProject.ext.targetSdkVersion
137
+ versionCode 1
138
+ versionName "1.0"
139
+ }
140
+ splits {
141
+ abi {
142
+ reset()
143
+ enable enableSeparateBuildPerCPUArchitecture
144
+ universalApk false // If true, also generate a universal APK
145
+ include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
146
+ }
147
+ }
148
+ signingConfigs {
149
+ debug {
150
+ storeFile file('debug.keystore')
151
+ storePassword 'android'
152
+ keyAlias 'androiddebugkey'
153
+ keyPassword 'android'
154
+ }
155
+ }
156
+ buildTypes {
157
+ debug {
158
+ signingConfig signingConfigs.debug
159
+ if (nativeArchitectures) {
160
+ ndk {
161
+ abiFilters nativeArchitectures.split(',')
162
+ }
163
+ }
164
+ }
165
+ release {
166
+ // Caution! In production, you need to generate your own keystore file.
167
+ // see https://reactnative.dev/docs/signed-apk-android.
168
+ signingConfig signingConfigs.debug
169
+ minifyEnabled enableProguardInReleaseBuilds
170
+ proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
171
+ }
172
+ }
173
+
174
+ // applicationVariants are e.g. debug, release
175
+ applicationVariants.all { variant ->
176
+ variant.outputs.each { output ->
177
+ // For each separate APK per architecture, set a unique version code as described here:
178
+ // https://developer.android.com/studio/build/configure-apk-splits.html
179
+ // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
180
+ def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
181
+ def abi = output.getFilter(OutputFile.ABI)
182
+ if (abi != null) { // null for the universal-debug, universal-release variants
183
+ output.versionCodeOverride =
184
+ defaultConfig.versionCode * 1000 + versionCodes.get(abi)
185
+ }
186
+
187
+ }
188
+ }
189
+ }
190
+
191
+ dependencies {
192
+ implementation fileTree(dir: "libs", include: ["*.jar"])
193
+ //noinspection GradleDynamicVersion
194
+ implementation "com.facebook.react:react-native:+" // From node_modules
195
+
196
+ implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
197
+
198
+ debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
199
+ exclude group:'com.facebook.fbjni'
200
+ }
201
+
202
+ debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
203
+ exclude group:'com.facebook.flipper'
204
+ exclude group:'com.squareup.okhttp3', module:'okhttp'
205
+ }
206
+
207
+ debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
208
+ exclude group:'com.facebook.flipper'
209
+ }
210
+
211
+ if (enableHermes) {
212
+ def hermesPath = "../../node_modules/hermes-engine/android/";
213
+ debugImplementation files(hermesPath + "hermes-debug.aar")
214
+ releaseImplementation files(hermesPath + "hermes-release.aar")
215
+ } else {
216
+ implementation jscFlavor
217
+ }
218
+ }
219
+
220
+ // Run this once to be able to run the application with BUCK
221
+ // puts all compile dependencies into folder libs for BUCK to use
222
+ task copyDownloadableDepsToLibs(type: Copy) {
223
+ from configurations.implementation
224
+ into 'libs'
225
+ }
226
+
227
+ apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
@@ -0,0 +1,19 @@
1
+ """Helper definitions to glob .aar and .jar targets"""
2
+
3
+ def create_aar_targets(aarfiles):
4
+ for aarfile in aarfiles:
5
+ name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6
+ lib_deps.append(":" + name)
7
+ android_prebuilt_aar(
8
+ name = name,
9
+ aar = aarfile,
10
+ )
11
+
12
+ def create_jar_targets(jarfiles):
13
+ for jarfile in jarfiles:
14
+ name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15
+ lib_deps.append(":" + name)
16
+ prebuilt_jar(
17
+ name = name,
18
+ binary_jar = jarfile,
19
+ )
@@ -0,0 +1,10 @@
1
+ # Add project specific ProGuard rules here.
2
+ # By default, the flags in this file are appended to flags specified
3
+ # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4
+ # You can edit the include path and order by changing the proguardFiles
5
+ # directive in build.gradle.
6
+ #
7
+ # For more details, see
8
+ # http://developer.android.com/guide/developing/tools/proguard.html
9
+
10
+ # Add any project specific keep options here:
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:tools="http://schemas.android.com/tools">
4
+
5
+ <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
6
+
7
+ <application
8
+ android:usesCleartextTraffic="true"
9
+ tools:targetApi="28"
10
+ tools:ignore="GoogleAppIndexingWarning">
11
+ <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
12
+ </application>
13
+ </manifest>
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5
+ * directory of this source tree.
6
+ */
7
+ package com.example;
8
+
9
+ import android.content.Context;
10
+ import com.facebook.flipper.android.AndroidFlipperClient;
11
+ import com.facebook.flipper.android.utils.FlipperUtils;
12
+ import com.facebook.flipper.core.FlipperClient;
13
+ import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14
+ import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15
+ import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16
+ import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17
+ import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18
+ import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19
+ import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20
+ import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21
+ import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22
+ import com.facebook.react.ReactInstanceManager;
23
+ import com.facebook.react.bridge.ReactContext;
24
+ import com.facebook.react.modules.network.NetworkingModule;
25
+ import okhttp3.OkHttpClient;
26
+
27
+ public class ReactNativeFlipper {
28
+ public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
29
+ if (FlipperUtils.shouldEnableFlipper(context)) {
30
+ final FlipperClient client = AndroidFlipperClient.getInstance(context);
31
+
32
+ client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
33
+ client.addPlugin(new ReactFlipperPlugin());
34
+ client.addPlugin(new DatabasesFlipperPlugin(context));
35
+ client.addPlugin(new SharedPreferencesFlipperPlugin(context));
36
+ client.addPlugin(CrashReporterPlugin.getInstance());
37
+
38
+ NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
39
+ NetworkingModule.setCustomClientBuilder(
40
+ new NetworkingModule.CustomClientBuilder() {
41
+ @Override
42
+ public void apply(OkHttpClient.Builder builder) {
43
+ builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
44
+ }
45
+ });
46
+ client.addPlugin(networkFlipperPlugin);
47
+ client.start();
48
+
49
+ // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
50
+ // Hence we run if after all native modules have been initialized
51
+ ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
52
+ if (reactContext == null) {
53
+ reactInstanceManager.addReactInstanceEventListener(
54
+ new ReactInstanceManager.ReactInstanceEventListener() {
55
+ @Override
56
+ public void onReactContextInitialized(ReactContext reactContext) {
57
+ reactInstanceManager.removeReactInstanceEventListener(this);
58
+ reactContext.runOnNativeModulesQueueThread(
59
+ new Runnable() {
60
+ @Override
61
+ public void run() {
62
+ client.addPlugin(new FrescoFlipperPlugin());
63
+ }
64
+ });
65
+ }
66
+ });
67
+ } else {
68
+ client.addPlugin(new FrescoFlipperPlugin());
69
+ }
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,25 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.example">
3
+
4
+ <uses-permission android:name="android.permission.INTERNET" />
5
+
6
+ <application
7
+ android:name=".MainApplication"
8
+ android:label="@string/app_name"
9
+ android:icon="@mipmap/ic_launcher"
10
+ android:roundIcon="@mipmap/ic_launcher_round"
11
+ android:allowBackup="false"
12
+ android:theme="@style/AppTheme">
13
+ <activity
14
+ android:name=".MainActivity"
15
+ android:label="@string/app_name"
16
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
17
+ android:launchMode="singleTask"
18
+ android:windowSoftInputMode="adjustResize">
19
+ <intent-filter>
20
+ <action android:name="android.intent.action.MAIN" />
21
+ <category android:name="android.intent.category.LAUNCHER" />
22
+ </intent-filter>
23
+ </activity>
24
+ </application>
25
+ </manifest>
@@ -0,0 +1,15 @@
1
+ package com.example;
2
+
3
+ import com.facebook.react.ReactActivity;
4
+
5
+ public class MainActivity extends ReactActivity {
6
+
7
+ /**
8
+ * Returns the name of the main component registered from JavaScript. This is used to schedule
9
+ * rendering of the component.
10
+ */
11
+ @Override
12
+ protected String getMainComponentName() {
13
+ return "example";
14
+ }
15
+ }
@@ -0,0 +1,80 @@
1
+ package com.example;
2
+
3
+ import android.app.Application;
4
+ import android.content.Context;
5
+ import com.facebook.react.PackageList;
6
+ import com.facebook.react.ReactApplication;
7
+ import com.facebook.react.ReactInstanceManager;
8
+ import com.facebook.react.ReactNativeHost;
9
+ import com.facebook.react.ReactPackage;
10
+ import com.facebook.soloader.SoLoader;
11
+ import java.lang.reflect.InvocationTargetException;
12
+ import java.util.List;
13
+
14
+ public class MainApplication extends Application implements ReactApplication {
15
+
16
+ private final ReactNativeHost mReactNativeHost =
17
+ new ReactNativeHost(this) {
18
+ @Override
19
+ public boolean getUseDeveloperSupport() {
20
+ return BuildConfig.DEBUG;
21
+ }
22
+
23
+ @Override
24
+ protected List<ReactPackage> getPackages() {
25
+ @SuppressWarnings("UnnecessaryLocalVariable")
26
+ List<ReactPackage> packages = new PackageList(this).getPackages();
27
+ // Packages that cannot be autolinked yet can be added manually here, for example:
28
+ // packages.add(new MyReactNativePackage());
29
+ return packages;
30
+ }
31
+
32
+ @Override
33
+ protected String getJSMainModuleName() {
34
+ return "index";
35
+ }
36
+ };
37
+
38
+ @Override
39
+ public ReactNativeHost getReactNativeHost() {
40
+ return mReactNativeHost;
41
+ }
42
+
43
+ @Override
44
+ public void onCreate() {
45
+ super.onCreate();
46
+ SoLoader.init(this, /* native exopackage */ false);
47
+ initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
48
+ }
49
+
50
+ /**
51
+ * Loads Flipper in React Native templates. Call this in the onCreate method with something like
52
+ * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
53
+ *
54
+ * @param context
55
+ * @param reactInstanceManager
56
+ */
57
+ private static void initializeFlipper(
58
+ Context context, ReactInstanceManager reactInstanceManager) {
59
+ if (BuildConfig.DEBUG) {
60
+ try {
61
+ /*
62
+ We use reflection here to pick up the class that initializes Flipper,
63
+ since Flipper library is not available in release mode
64
+ */
65
+ Class<?> aClass = Class.forName("com.example.ReactNativeFlipper");
66
+ aClass
67
+ .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
68
+ .invoke(null, context, reactInstanceManager);
69
+ } catch (ClassNotFoundException e) {
70
+ e.printStackTrace();
71
+ } catch (NoSuchMethodException e) {
72
+ e.printStackTrace();
73
+ } catch (IllegalAccessException e) {
74
+ e.printStackTrace();
75
+ } catch (InvocationTargetException e) {
76
+ e.printStackTrace();
77
+ }
78
+ }
79
+ }
80
+ }
@@ -0,0 +1,3 @@
1
+ <resources>
2
+ <string name="app_name">example</string>
3
+ </resources>
@@ -0,0 +1,8 @@
1
+ <resources>
2
+
3
+ <!-- Base application theme. -->
4
+ <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
5
+ <!-- Customize your theme here. -->
6
+ </style>
7
+
8
+ </resources>