react-native-legal 1.3.1 → 1.4.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.
Files changed (35) hide show
  1. package/android/src/main/java/com/reactnativelegal/ReactNativeLegalModuleImpl.kt +42 -0
  2. package/android/src/newarch/java/com/reactnativelegal/ReactNativeLegalModule.kt +9 -0
  3. package/android/src/oldarch/java/com/reactnativelegal/ReactNativeLegalModule.kt +9 -0
  4. package/ios/ReactNativeLegalModule.mm +9 -0
  5. package/ios/ReactNativeLegalModuleImpl.swift +26 -0
  6. package/lib/commonjs/NativeReactNativeLegal.js.map +1 -1
  7. package/lib/commonjs/ReactNativeLegal.android.js +3 -0
  8. package/lib/commonjs/ReactNativeLegal.android.js.map +1 -1
  9. package/lib/commonjs/ReactNativeLegal.ios.js +3 -0
  10. package/lib/commonjs/ReactNativeLegal.ios.js.map +1 -1
  11. package/lib/commonjs/ReactNativeLegal.js +5 -0
  12. package/lib/commonjs/ReactNativeLegal.js.map +1 -1
  13. package/lib/module/NativeReactNativeLegal.js.map +1 -1
  14. package/lib/module/ReactNativeLegal.android.js +3 -0
  15. package/lib/module/ReactNativeLegal.android.js.map +1 -1
  16. package/lib/module/ReactNativeLegal.ios.js +3 -0
  17. package/lib/module/ReactNativeLegal.ios.js.map +1 -1
  18. package/lib/module/ReactNativeLegal.js +5 -0
  19. package/lib/module/ReactNativeLegal.js.map +1 -1
  20. package/lib/typescript/NativeReactNativeLegal.d.ts +40 -0
  21. package/lib/typescript/NativeReactNativeLegal.d.ts.map +1 -1
  22. package/lib/typescript/ReactNativeLegal.android.d.ts +1 -0
  23. package/lib/typescript/ReactNativeLegal.android.d.ts.map +1 -1
  24. package/lib/typescript/ReactNativeLegal.d.ts +2 -0
  25. package/lib/typescript/ReactNativeLegal.d.ts.map +1 -1
  26. package/lib/typescript/ReactNativeLegal.ios.d.ts +1 -0
  27. package/lib/typescript/ReactNativeLegal.ios.d.ts.map +1 -1
  28. package/lib/typescript/index.d.ts +1 -0
  29. package/lib/typescript/index.d.ts.map +1 -1
  30. package/package.json +1 -1
  31. package/src/NativeReactNativeLegal.ts +43 -0
  32. package/src/ReactNativeLegal.android.ts +3 -0
  33. package/src/ReactNativeLegal.ios.ts +3 -0
  34. package/src/ReactNativeLegal.ts +5 -0
  35. package/src/index.ts +1 -0
@@ -1,12 +1,20 @@
1
1
  package com.reactnativelegal
2
2
 
3
3
  import android.content.Intent
4
+ import android.os.Bundle
5
+ import androidx.core.os.bundleOf
6
+ import com.facebook.react.bridge.Arguments
4
7
  import com.facebook.react.bridge.ReactApplicationContext
8
+ import com.facebook.react.bridge.WritableMap
9
+ import com.mikepenz.aboutlibraries.Libs
5
10
  import com.mikepenz.aboutlibraries.LibsBuilder
11
+ import com.mikepenz.aboutlibraries.util.withContext
6
12
 
7
13
  object ReactNativeLegalModuleImpl {
8
14
  const val NAME = "ReactNativeLegalModule"
9
15
 
16
+ private var cachedData: List<Bundle>? = null
17
+
10
18
  fun launchLicenseListScreen(reactContext: ReactApplicationContext, licenseHeaderText: String) {
11
19
  val context = reactContext.currentActivity ?: return
12
20
  val intent =
@@ -17,4 +25,38 @@ object ReactNativeLegalModuleImpl {
17
25
 
18
26
  context.startActivity(intent)
19
27
  }
28
+
29
+ fun getLibraries(reactContext: ReactApplicationContext): WritableMap {
30
+ if (cachedData == null) {
31
+ cachedData = retrieveLibrariesArray(reactContext)
32
+ }
33
+
34
+ return Arguments.createMap().apply { putArray("data", Arguments.fromList(cachedData)) }
35
+ }
36
+
37
+ private fun retrieveLibrariesArray(reactContext: ReactApplicationContext): List<Bundle>? {
38
+ val context = reactContext.currentActivity ?: return null
39
+
40
+ val libraries = Libs.Builder().withContext(context).build().libraries
41
+
42
+ return libraries.map { library ->
43
+ bundleOf(
44
+ "id" to library.uniqueId,
45
+ "name" to library.name,
46
+ "description" to library.description,
47
+ "website" to library.website,
48
+ "developers" to library.developers.joinToString(),
49
+ "organization" to library.organization?.name,
50
+ "licenses" to
51
+ library.licenses.map { license ->
52
+ bundleOf(
53
+ "name" to license.name,
54
+ "url" to license.url,
55
+ "year" to license.year,
56
+ "licenseContent" to (license.licenseContent ?: ""),
57
+ )
58
+ },
59
+ )
60
+ }
61
+ }
20
62
  }
@@ -1,5 +1,6 @@
1
1
  package com.reactnativelegal
2
2
 
3
+ import com.facebook.react.bridge.Promise
3
4
  import com.facebook.react.bridge.ReactApplicationContext
4
5
  import com.facebook.react.module.annotations.ReactModule
5
6
 
@@ -13,6 +14,14 @@ class ReactNativeLegalModule(reactContext: ReactApplicationContext) :
13
14
  )
14
15
  }
15
16
 
17
+ override fun getLibrariesAsync(promise: Promise?) {
18
+ try {
19
+ promise?.resolve(ReactNativeLegalModuleImpl.getLibraries(reactApplicationContext))
20
+ } catch (e: Exception) {
21
+ promise?.reject(e)
22
+ }
23
+ }
24
+
16
25
  companion object {
17
26
  const val NAME = ReactNativeLegalModuleImpl.NAME
18
27
  }
@@ -18,6 +18,15 @@ class ReactNativeLegalModule(private val reactContext: ReactApplicationContext)
18
18
  )
19
19
  }
20
20
 
21
+ @ReactMethod
22
+ fun getLibrariesAsync(promise: Promise?) {
23
+ try {
24
+ promise?.resolve(ReactNativeLegalModuleImpl.getLibraries(reactApplicationContext))
25
+ } catch (e: Exception) {
26
+ promise?.reject(e)
27
+ }
28
+ }
29
+
21
30
  companion object {
22
31
  const val NAME = ReactNativeLegalModuleImpl.NAME
23
32
  }
@@ -22,6 +22,15 @@ RCT_EXPORT_METHOD(launchLicenseListScreen : (NSString *)licenseHeaderText)
22
22
  [ReactNativeLegalModuleImpl launchLicenseListScreenWithLicenseHeaderText:licenseHeaderText];
23
23
  }
24
24
 
25
+ RCT_EXPORT_METHOD(getLibrariesAsync : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject)
26
+ {
27
+ @try {
28
+ resolve([ReactNativeLegalModuleImpl getLibraries]);
29
+ } @catch (NSException *err) {
30
+ reject(err.name, err.reason, nil);
31
+ }
32
+ }
33
+
25
34
  #if RCT_NEW_ARCH_ENABLED
26
35
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
27
36
  (const facebook::react::ObjCTurboModule::InitParams &)params
@@ -31,6 +31,32 @@ public class ReactNativeLegalModuleImpl: NSObject {
31
31
  }
32
32
  }
33
33
 
34
+ @objc public static func getLibraries() -> [String: Any] {
35
+ guard
36
+ let settingsBundleUrl = Bundle.main.url(forResource: "Settings", withExtension: "bundle"),
37
+ let settingsBundle = Bundle(url: settingsBundleUrl),
38
+ let licensePlistUrl = settingsBundle.url(
39
+ forResource: "com.mono0926.LicensePlist", withExtension: "plist"),
40
+ let dictArray = parsePlistToDictArray(fileUrl: licensePlistUrl)
41
+ else {
42
+ return [:]
43
+ }
44
+
45
+ let libraries = parseRawLicenseMetadataToArray(
46
+ rawLicenses: getChildPaneSpecifiers(dictArray: dictArray),
47
+ licensePlistUrl: licensePlistUrl
48
+ )
49
+
50
+ return [
51
+ "data": libraries.map({ library in
52
+ [
53
+ "id": "library-\(library.name ?? "")", "name": library.name ?? "",
54
+ "licenses": [["licenseContent": library.content ?? ""]],
55
+ ]
56
+ })
57
+ ]
58
+ }
59
+
34
60
  private static func getChildPaneSpecifiers(dictArray: [[String: Any]]) -> [[String: Any]] {
35
61
  return
36
62
  dictArray
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_default","TurboModuleRegistry","getEnforcing","exports","default"],"sourceRoot":"../../src","sources":["NativeReactNativeLegal.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAMpCC,gCAAmB,CAACC,YAAY,CAAO,wBAAwB,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAJ,QAAA"}
1
+ {"version":3,"names":["_reactNative","require","_default","TurboModuleRegistry","getEnforcing","exports","default"],"sourceRoot":"../../src","sources":["NativeReactNativeLegal.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAiDpCC,gCAAmB,CAACC,YAAY,CAAO,wBAAwB,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAJ,QAAA"}
@@ -7,6 +7,9 @@ exports.ReactNativeLegal = void 0;
7
7
  var _NativeReactNativeLegal = _interopRequireDefault(require("./NativeReactNativeLegal"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
9
  const ReactNativeLegal = {
10
+ getLibrariesAsync: () => {
11
+ return _NativeReactNativeLegal.default.getLibrariesAsync();
12
+ },
10
13
  launchLicenseListScreen: licenseHeaderText => {
11
14
  /**
12
15
  * On Android, the licenses list is displayed as a custom activity
@@ -1 +1 @@
1
- {"version":3,"names":["_NativeReactNativeLegal","_interopRequireDefault","require","obj","__esModule","default","ReactNativeLegal","launchLicenseListScreen","licenseHeaderText","NativeReactNativeLegal","exports"],"sourceRoot":"../../src","sources":["ReactNativeLegal.android.ts"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEvD,MAAMG,gBAAgB,GAAG;EAC9BC,uBAAuB,EAAGC,iBAA0B,IAAK;IACvD;AACJ;AACA;IACIC,+BAAsB,CAACF,uBAAuB,CAACC,iBAAiB,IAAI,cAAc,CAAC;EACrF;AACF,CAAC;AAACE,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_NativeReactNativeLegal","_interopRequireDefault","require","obj","__esModule","default","ReactNativeLegal","getLibrariesAsync","NativeReactNativeLegal","launchLicenseListScreen","licenseHeaderText","exports"],"sourceRoot":"../../src","sources":["ReactNativeLegal.android.ts"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEvD,MAAMG,gBAAgB,GAAG;EAC9BC,iBAAiB,EAAEA,CAAA,KAAM;IACvB,OAAOC,+BAAsB,CAACD,iBAAiB,CAAC,CAAC;EACnD,CAAC;EACDE,uBAAuB,EAAGC,iBAA0B,IAAK;IACvD;AACJ;AACA;IACIF,+BAAsB,CAACC,uBAAuB,CAACC,iBAAiB,IAAI,cAAc,CAAC;EACrF;AACF,CAAC;AAACC,OAAA,CAAAL,gBAAA,GAAAA,gBAAA"}
@@ -7,6 +7,9 @@ exports.ReactNativeLegal = void 0;
7
7
  var _NativeReactNativeLegal = _interopRequireDefault(require("./NativeReactNativeLegal"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
9
  const ReactNativeLegal = {
10
+ getLibrariesAsync: () => {
11
+ return _NativeReactNativeLegal.default.getLibrariesAsync();
12
+ },
10
13
  launchLicenseListScreen: licenseHeaderText => {
11
14
  /**
12
15
  * On iOS, the licenses list is displayed as a custom table view controller
@@ -1 +1 @@
1
- {"version":3,"names":["_NativeReactNativeLegal","_interopRequireDefault","require","obj","__esModule","default","ReactNativeLegal","launchLicenseListScreen","licenseHeaderText","NativeReactNativeLegal","exports"],"sourceRoot":"../../src","sources":["ReactNativeLegal.ios.ts"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEvD,MAAMG,gBAAgB,GAAG;EAC9BC,uBAAuB,EAAGC,iBAA0B,IAAK;IACvD;AACJ;AACA;IACIC,+BAAsB,CAACF,uBAAuB,CAACC,iBAAiB,IAAI,cAAc,CAAC;EACrF;AACF,CAAC;AAACE,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_NativeReactNativeLegal","_interopRequireDefault","require","obj","__esModule","default","ReactNativeLegal","getLibrariesAsync","NativeReactNativeLegal","launchLicenseListScreen","licenseHeaderText","exports"],"sourceRoot":"../../src","sources":["ReactNativeLegal.ios.ts"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEvD,MAAMG,gBAAgB,GAAG;EAC9BC,iBAAiB,EAAEA,CAAA,KAAM;IACvB,OAAOC,+BAAsB,CAACD,iBAAiB,CAAC,CAAC;EACnD,CAAC;EACDE,uBAAuB,EAAGC,iBAA0B,IAAK;IACvD;AACJ;AACA;IACIF,+BAAsB,CAACC,uBAAuB,CAACC,iBAAiB,IAAI,cAAc,CAAC;EACrF;AACF,CAAC;AAACC,OAAA,CAAAL,gBAAA,GAAAA,gBAAA"}
@@ -5,6 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.ReactNativeLegal = void 0;
7
7
  const ReactNativeLegal = {
8
+ getLibrariesAsync: () => {
9
+ return Promise.resolve({
10
+ data: []
11
+ });
12
+ },
8
13
  launchLicenseListScreen: _licenseHeaderText => {
9
14
  //
10
15
  }
@@ -1 +1 @@
1
- {"version":3,"names":["ReactNativeLegal","launchLicenseListScreen","_licenseHeaderText","exports"],"sourceRoot":"../../src","sources":["ReactNativeLegal.ts"],"mappings":";;;;;;AAAO,MAAMA,gBAAgB,GAAG;EAC9BC,uBAAuB,EAAGC,kBAA2B,IAAK;IACxD;EAAA;AAEJ,CAAC;AAACC,OAAA,CAAAH,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["ReactNativeLegal","getLibrariesAsync","Promise","resolve","data","launchLicenseListScreen","_licenseHeaderText","exports"],"sourceRoot":"../../src","sources":["ReactNativeLegal.ts"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,GAAG;EAC9BC,iBAAiB,EAAEA,CAAA,KAAM;IACvB,OAAOC,OAAO,CAACC,OAAO,CAAkB;MAAEC,IAAI,EAAE;IAAG,CAAC,CAAC;EACvD,CAAC;EACDC,uBAAuB,EAAGC,kBAA2B,IAAK;IACxD;EAAA;AAEJ,CAAC;AAACC,OAAA,CAAAP,gBAAA,GAAAA,gBAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeReactNativeLegal.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAMlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,wBAAwB,CAAC"}
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeReactNativeLegal.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAiDlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,wBAAwB,CAAC"}
@@ -1,5 +1,8 @@
1
1
  import NativeReactNativeLegal from './NativeReactNativeLegal';
2
2
  export const ReactNativeLegal = {
3
+ getLibrariesAsync: () => {
4
+ return NativeReactNativeLegal.getLibrariesAsync();
5
+ },
3
6
  launchLicenseListScreen: licenseHeaderText => {
4
7
  /**
5
8
  * On Android, the licenses list is displayed as a custom activity
@@ -1 +1 @@
1
- {"version":3,"names":["NativeReactNativeLegal","ReactNativeLegal","launchLicenseListScreen","licenseHeaderText"],"sourceRoot":"../../src","sources":["ReactNativeLegal.android.ts"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,0BAA0B;AAE7D,OAAO,MAAMC,gBAAgB,GAAG;EAC9BC,uBAAuB,EAAGC,iBAA0B,IAAK;IACvD;AACJ;AACA;IACIH,sBAAsB,CAACE,uBAAuB,CAACC,iBAAiB,IAAI,cAAc,CAAC;EACrF;AACF,CAAC"}
1
+ {"version":3,"names":["NativeReactNativeLegal","ReactNativeLegal","getLibrariesAsync","launchLicenseListScreen","licenseHeaderText"],"sourceRoot":"../../src","sources":["ReactNativeLegal.android.ts"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,0BAA0B;AAE7D,OAAO,MAAMC,gBAAgB,GAAG;EAC9BC,iBAAiB,EAAEA,CAAA,KAAM;IACvB,OAAOF,sBAAsB,CAACE,iBAAiB,CAAC,CAAC;EACnD,CAAC;EACDC,uBAAuB,EAAGC,iBAA0B,IAAK;IACvD;AACJ;AACA;IACIJ,sBAAsB,CAACG,uBAAuB,CAACC,iBAAiB,IAAI,cAAc,CAAC;EACrF;AACF,CAAC"}
@@ -1,5 +1,8 @@
1
1
  import NativeReactNativeLegal from './NativeReactNativeLegal';
2
2
  export const ReactNativeLegal = {
3
+ getLibrariesAsync: () => {
4
+ return NativeReactNativeLegal.getLibrariesAsync();
5
+ },
3
6
  launchLicenseListScreen: licenseHeaderText => {
4
7
  /**
5
8
  * On iOS, the licenses list is displayed as a custom table view controller
@@ -1 +1 @@
1
- {"version":3,"names":["NativeReactNativeLegal","ReactNativeLegal","launchLicenseListScreen","licenseHeaderText"],"sourceRoot":"../../src","sources":["ReactNativeLegal.ios.ts"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,0BAA0B;AAE7D,OAAO,MAAMC,gBAAgB,GAAG;EAC9BC,uBAAuB,EAAGC,iBAA0B,IAAK;IACvD;AACJ;AACA;IACIH,sBAAsB,CAACE,uBAAuB,CAACC,iBAAiB,IAAI,cAAc,CAAC;EACrF;AACF,CAAC"}
1
+ {"version":3,"names":["NativeReactNativeLegal","ReactNativeLegal","getLibrariesAsync","launchLicenseListScreen","licenseHeaderText"],"sourceRoot":"../../src","sources":["ReactNativeLegal.ios.ts"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,0BAA0B;AAE7D,OAAO,MAAMC,gBAAgB,GAAG;EAC9BC,iBAAiB,EAAEA,CAAA,KAAM;IACvB,OAAOF,sBAAsB,CAACE,iBAAiB,CAAC,CAAC;EACnD,CAAC;EACDC,uBAAuB,EAAGC,iBAA0B,IAAK;IACvD;AACJ;AACA;IACIJ,sBAAsB,CAACG,uBAAuB,CAACC,iBAAiB,IAAI,cAAc,CAAC;EACrF;AACF,CAAC"}
@@ -1,4 +1,9 @@
1
1
  export const ReactNativeLegal = {
2
+ getLibrariesAsync: () => {
3
+ return Promise.resolve({
4
+ data: []
5
+ });
6
+ },
2
7
  launchLicenseListScreen: _licenseHeaderText => {
3
8
  //
4
9
  }
@@ -1 +1 @@
1
- {"version":3,"names":["ReactNativeLegal","launchLicenseListScreen","_licenseHeaderText"],"sourceRoot":"../../src","sources":["ReactNativeLegal.ts"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB,GAAG;EAC9BC,uBAAuB,EAAGC,kBAA2B,IAAK;IACxD;EAAA;AAEJ,CAAC"}
1
+ {"version":3,"names":["ReactNativeLegal","getLibrariesAsync","Promise","resolve","data","launchLicenseListScreen","_licenseHeaderText"],"sourceRoot":"../../src","sources":["ReactNativeLegal.ts"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,GAAG;EAC9BC,iBAAiB,EAAEA,CAAA,KAAM;IACvB,OAAOC,OAAO,CAACC,OAAO,CAAkB;MAAEC,IAAI,EAAE;IAAG,CAAC,CAAC;EACvD,CAAC;EACDC,uBAAuB,EAAGC,kBAA2B,IAAK;IACxD;EAAA;AAEJ,CAAC"}
@@ -1,5 +1,45 @@
1
1
  import type { TurboModule } from 'react-native';
2
+ export interface License {
3
+ licenseContent: string;
4
+ /**
5
+ * @platform Android
6
+ */
7
+ name?: string;
8
+ /**
9
+ * @platform Android
10
+ */
11
+ url?: string;
12
+ /**
13
+ * @platform Android
14
+ */
15
+ year?: string;
16
+ }
17
+ export interface Library {
18
+ id: string;
19
+ name: string;
20
+ licenses: License[];
21
+ /**
22
+ * @platform Android
23
+ */
24
+ description?: string;
25
+ /**
26
+ * @platform Android
27
+ */
28
+ developers?: string;
29
+ /**
30
+ * @platform Android
31
+ */
32
+ website?: string;
33
+ /**
34
+ * @platform Android
35
+ */
36
+ organization?: string;
37
+ }
38
+ export interface LibrariesResult {
39
+ data: Library[];
40
+ }
2
41
  export interface Spec extends TurboModule {
42
+ getLibrariesAsync(): Promise<LibrariesResult>;
3
43
  launchLicenseListScreen(licenseHeaderText: string): void;
4
44
  }
5
45
  declare const _default: Spec;
@@ -1 +1 @@
1
- {"version":3,"file":"NativeReactNativeLegal.d.ts","sourceRoot":"","sources":["../../src/NativeReactNativeLegal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,uBAAuB,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1D;;AAED,wBAAgF"}
1
+ {"version":3,"file":"NativeReactNativeLegal.d.ts","sourceRoot":"","sources":["../../src/NativeReactNativeLegal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,OAAO;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,iBAAiB,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9C,uBAAuB,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1D;;AAED,wBAAgF"}
@@ -1,4 +1,5 @@
1
1
  export declare const ReactNativeLegal: {
2
+ getLibrariesAsync: () => Promise<import("./NativeReactNativeLegal").LibrariesResult>;
2
3
  launchLicenseListScreen: (licenseHeaderText?: string) => void;
3
4
  };
4
5
  //# sourceMappingURL=ReactNativeLegal.android.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeLegal.android.d.ts","sourceRoot":"","sources":["../../src/ReactNativeLegal.android.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;kDACmB,MAAM;CAMrD,CAAC"}
1
+ {"version":3,"file":"ReactNativeLegal.android.d.ts","sourceRoot":"","sources":["../../src/ReactNativeLegal.android.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;;kDAImB,MAAM;CAMrD,CAAC"}
@@ -1,4 +1,6 @@
1
+ import type { LibrariesResult } from './NativeReactNativeLegal';
1
2
  export declare const ReactNativeLegal: {
3
+ getLibrariesAsync: () => Promise<LibrariesResult>;
2
4
  launchLicenseListScreen: (_licenseHeaderText?: string) => void;
3
5
  };
4
6
  //# sourceMappingURL=ReactNativeLegal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeLegal.d.ts","sourceRoot":"","sources":["../../src/ReactNativeLegal.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;mDACoB,MAAM;CAGtD,CAAC"}
1
+ {"version":3,"file":"ReactNativeLegal.d.ts","sourceRoot":"","sources":["../../src/ReactNativeLegal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,eAAO,MAAM,gBAAgB;;mDAIoB,MAAM;CAGtD,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export declare const ReactNativeLegal: {
2
+ getLibrariesAsync: () => Promise<import("./NativeReactNativeLegal").LibrariesResult>;
2
3
  launchLicenseListScreen: (licenseHeaderText?: string) => void;
3
4
  };
4
5
  //# sourceMappingURL=ReactNativeLegal.ios.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeLegal.ios.d.ts","sourceRoot":"","sources":["../../src/ReactNativeLegal.ios.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;kDACmB,MAAM;CAMrD,CAAC"}
1
+ {"version":3,"file":"ReactNativeLegal.ios.d.ts","sourceRoot":"","sources":["../../src/ReactNativeLegal.ios.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;;kDAImB,MAAM;CAMrD,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export { ReactNativeLegal } from './ReactNativeLegal';
2
+ export type { LibrariesResult, Library, License } from './NativeReactNativeLegal';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-legal",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Acknowledge OSS libraries used in your React Native app",
5
5
  "keywords": [
6
6
  "react-native",
@@ -1,7 +1,50 @@
1
1
  import type { TurboModule } from 'react-native';
2
2
  import { TurboModuleRegistry } from 'react-native';
3
3
 
4
+ export interface License {
5
+ licenseContent: string;
6
+ /**
7
+ * @platform Android
8
+ */
9
+ name?: string;
10
+ /**
11
+ * @platform Android
12
+ */
13
+ url?: string;
14
+ /**
15
+ * @platform Android
16
+ */
17
+ year?: string;
18
+ }
19
+
20
+ export interface Library {
21
+ id: string;
22
+ name: string;
23
+ licenses: License[];
24
+ /**
25
+ * @platform Android
26
+ */
27
+ description?: string;
28
+ /**
29
+ * @platform Android
30
+ */
31
+ developers?: string;
32
+ /**
33
+ * @platform Android
34
+ */
35
+ website?: string;
36
+ /**
37
+ * @platform Android
38
+ */
39
+ organization?: string;
40
+ }
41
+
42
+ export interface LibrariesResult {
43
+ data: Library[];
44
+ }
45
+
4
46
  export interface Spec extends TurboModule {
47
+ getLibrariesAsync(): Promise<LibrariesResult>;
5
48
  launchLicenseListScreen(licenseHeaderText: string): void;
6
49
  }
7
50
 
@@ -1,6 +1,9 @@
1
1
  import NativeReactNativeLegal from './NativeReactNativeLegal';
2
2
 
3
3
  export const ReactNativeLegal = {
4
+ getLibrariesAsync: () => {
5
+ return NativeReactNativeLegal.getLibrariesAsync();
6
+ },
4
7
  launchLicenseListScreen: (licenseHeaderText?: string) => {
5
8
  /**
6
9
  * On Android, the licenses list is displayed as a custom activity
@@ -1,6 +1,9 @@
1
1
  import NativeReactNativeLegal from './NativeReactNativeLegal';
2
2
 
3
3
  export const ReactNativeLegal = {
4
+ getLibrariesAsync: () => {
5
+ return NativeReactNativeLegal.getLibrariesAsync();
6
+ },
4
7
  launchLicenseListScreen: (licenseHeaderText?: string) => {
5
8
  /**
6
9
  * On iOS, the licenses list is displayed as a custom table view controller
@@ -1,4 +1,9 @@
1
+ import type { LibrariesResult } from './NativeReactNativeLegal';
2
+
1
3
  export const ReactNativeLegal = {
4
+ getLibrariesAsync: () => {
5
+ return Promise.resolve<LibrariesResult>({ data: [] });
6
+ },
2
7
  launchLicenseListScreen: (_licenseHeaderText?: string) => {
3
8
  //
4
9
  },
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { ReactNativeLegal } from './ReactNativeLegal';
2
+ export type { LibrariesResult, Library, License } from './NativeReactNativeLegal';