@succinctlabs/react-native-zcam1 0.4.0-alpha.3 → 0.4.0-alpha.5
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.
- package/android/CMakeLists.txt +45 -28
- package/android/build.gradle +48 -23
- package/app.plugin.js +20 -2
- package/package.json +7 -7
package/android/CMakeLists.txt
CHANGED
|
@@ -16,16 +16,23 @@ execute_process(
|
|
|
16
16
|
# paths with Windows path separators.
|
|
17
17
|
get_filename_component(UNIFFI_BINDGEN_PATH "${UNIFFI_BINDGEN_PATH}" DIRECTORY)
|
|
18
18
|
|
|
19
|
+
option(ZCAM1_ENABLE_PROVING "Enable proving support" OFF)
|
|
20
|
+
|
|
19
21
|
# Specifies a path to native header files.
|
|
20
22
|
include_directories(
|
|
21
23
|
../cpp
|
|
22
24
|
../cpp/generated
|
|
23
|
-
../cpp/proving
|
|
24
|
-
../cpp/proving/generated
|
|
25
25
|
|
|
26
26
|
${UNIFFI_BINDGEN_PATH}/cpp/includes
|
|
27
27
|
)
|
|
28
28
|
|
|
29
|
+
if (ZCAM1_ENABLE_PROVING)
|
|
30
|
+
include_directories(
|
|
31
|
+
../cpp/proving
|
|
32
|
+
../cpp/proving/generated
|
|
33
|
+
)
|
|
34
|
+
endif()
|
|
35
|
+
|
|
29
36
|
add_library(zcam1-sdk SHARED
|
|
30
37
|
../cpp/zcam1-sdk.cpp
|
|
31
38
|
../cpp/generated/zcam1_c2pa_utils.cpp
|
|
@@ -35,12 +42,14 @@ add_library(zcam1-sdk SHARED
|
|
|
35
42
|
cpp-adapter.cpp
|
|
36
43
|
)
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
if (ZCAM1_ENABLE_PROVING)
|
|
46
|
+
add_library(zcam1-proving SHARED
|
|
47
|
+
../cpp/proving/zcam1-proving.cpp
|
|
48
|
+
../cpp/proving/generated/zcam1_common.cpp
|
|
49
|
+
../cpp/proving/generated/zcam1_proving_utils.cpp
|
|
50
|
+
cpp-adapter-proving.cpp
|
|
51
|
+
)
|
|
52
|
+
endif()
|
|
44
53
|
|
|
45
54
|
# Set C++ compiler flags
|
|
46
55
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
|
@@ -55,21 +64,23 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,max-page-size
|
|
|
55
64
|
|
|
56
65
|
cmake_path(
|
|
57
66
|
SET MY_RUST_LIB
|
|
58
|
-
${CMAKE_SOURCE_DIR}
|
|
67
|
+
${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libzcam1_bindings.a
|
|
59
68
|
|
|
60
69
|
NORMALIZE
|
|
61
70
|
)
|
|
62
71
|
add_library(my_rust_lib STATIC IMPORTED)
|
|
63
72
|
set_target_properties(my_rust_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_LIB})
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
if (ZCAM1_ENABLE_PROVING)
|
|
75
|
+
cmake_path(
|
|
76
|
+
SET MY_RUST_PROVING_LIB
|
|
77
|
+
${CMAKE_SOURCE_DIR}/src/main/jniProvingLibs/${ANDROID_ABI}/libzcam1_proving_bindings.a
|
|
68
78
|
|
|
69
|
-
|
|
70
|
-
)
|
|
71
|
-
add_library(my_rust_proving_lib STATIC IMPORTED)
|
|
72
|
-
set_target_properties(my_rust_proving_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_PROVING_LIB})
|
|
79
|
+
NORMALIZE
|
|
80
|
+
)
|
|
81
|
+
add_library(my_rust_proving_lib STATIC IMPORTED)
|
|
82
|
+
set_target_properties(my_rust_proving_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_PROVING_LIB})
|
|
83
|
+
endif()
|
|
73
84
|
|
|
74
85
|
# Add ReactAndroid libraries, being careful to account for different versions.
|
|
75
86
|
find_package(ReactAndroid REQUIRED CONFIG)
|
|
@@ -85,16 +96,20 @@ endif()
|
|
|
85
96
|
# This if-then-else can be removed once this library does not support version below 0.76
|
|
86
97
|
if (REACTNATIVE_MERGED_SO)
|
|
87
98
|
target_link_libraries(zcam1-sdk ReactAndroid::reactnative)
|
|
88
|
-
|
|
99
|
+
if (ZCAM1_ENABLE_PROVING)
|
|
100
|
+
target_link_libraries(zcam1-proving ReactAndroid::reactnative)
|
|
101
|
+
endif()
|
|
89
102
|
else()
|
|
90
103
|
target_link_libraries(zcam1-sdk
|
|
91
104
|
ReactAndroid::turbomodulejsijni
|
|
92
105
|
ReactAndroid::react_nativemodule_core
|
|
93
106
|
)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
if (ZCAM1_ENABLE_PROVING)
|
|
108
|
+
target_link_libraries(zcam1-proving
|
|
109
|
+
ReactAndroid::turbomodulejsijni
|
|
110
|
+
ReactAndroid::react_nativemodule_core
|
|
111
|
+
)
|
|
112
|
+
endif()
|
|
98
113
|
endif()
|
|
99
114
|
|
|
100
115
|
find_package(fbjni REQUIRED CONFIG)
|
|
@@ -105,10 +120,12 @@ target_link_libraries(
|
|
|
105
120
|
${LOGCAT}
|
|
106
121
|
my_rust_lib
|
|
107
122
|
)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
if (ZCAM1_ENABLE_PROVING)
|
|
124
|
+
target_link_libraries(
|
|
125
|
+
zcam1-proving
|
|
126
|
+
fbjni::fbjni
|
|
127
|
+
ReactAndroid::jsi
|
|
128
|
+
${LOGCAT}
|
|
129
|
+
my_rust_proving_lib
|
|
130
|
+
)
|
|
131
|
+
endif()
|
package/android/build.gradle
CHANGED
|
@@ -23,11 +23,31 @@ def getPackageVersion() {
|
|
|
23
23
|
return packageJson.version
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
// Proving is opt-in.
|
|
27
|
+
//
|
|
28
|
+
// Enable proving in one of these ways:
|
|
29
|
+
//
|
|
30
|
+
// 1) Environment variable (works for Expo + non-Expo):
|
|
31
|
+
// ZCAM1_ENABLE_PROVING=1 ./gradlew ...
|
|
32
|
+
//
|
|
33
|
+
// 2) gradle.properties (recommended for Expo plugins):
|
|
34
|
+
// android/gradle.properties:
|
|
35
|
+
// enableProving=true
|
|
36
|
+
//
|
|
37
|
+
def isProvingEnabled() {
|
|
38
|
+
def fromEnv = System.getenv("ZCAM1_ENABLE_PROVING")
|
|
39
|
+
if (fromEnv == "1" || fromEnv?.toLowerCase() == "true") return true
|
|
40
|
+
def fromProps = rootProject.findProperty("enableProving") ?: project.findProperty("enableProving")
|
|
41
|
+
return fromProps == "true" || fromProps == true
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
def enableProving = isProvingEnabled()
|
|
45
|
+
|
|
26
46
|
task downloadJniLibs {
|
|
27
47
|
def version = getPackageVersion()
|
|
28
48
|
def baseUrl = "https://github.com/succinctlabs/zcam1-sdk/releases/download/react-native-zcam1-v${version}"
|
|
29
|
-
def jniLibsDir = file("
|
|
30
|
-
def jniLibsProvingDir = file("
|
|
49
|
+
def jniLibsDir = file("src/main/jniLibs")
|
|
50
|
+
def jniLibsProvingDir = file("src/main/jniProvingLibs")
|
|
31
51
|
def markerFile = file(".jnilibs-version")
|
|
32
52
|
|
|
33
53
|
doFirst {
|
|
@@ -36,7 +56,12 @@ task downloadJniLibs {
|
|
|
36
56
|
// - dir present, marker absent → Yalc/local dev (package includes JNI libs), skip
|
|
37
57
|
// - dir present, marker present, version differs → re-download (public npm upgrade)
|
|
38
58
|
// - dir present, marker present, version matches → already up to date, skip
|
|
39
|
-
[Zcam1Jni: jniLibsDir
|
|
59
|
+
def libs = [Zcam1Jni: jniLibsDir]
|
|
60
|
+
if (enableProving) {
|
|
61
|
+
libs["Zcam1ProvingJni"] = jniLibsProvingDir
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
libs.each { name, dir ->
|
|
40
65
|
def zipName = "${name}.zip"
|
|
41
66
|
def zipUrl = "${baseUrl}/${zipName}"
|
|
42
67
|
|
|
@@ -44,11 +69,11 @@ task downloadJniLibs {
|
|
|
44
69
|
println "Downloading ${name} v${version}..."
|
|
45
70
|
exec {
|
|
46
71
|
commandLine "curl", "-fL", zipUrl, "-o", zipName
|
|
47
|
-
workingDir "
|
|
72
|
+
workingDir "src/main"
|
|
48
73
|
}
|
|
49
74
|
exec {
|
|
50
75
|
commandLine "unzip", "-q", zipName
|
|
51
|
-
workingDir "
|
|
76
|
+
workingDir "src/main"
|
|
52
77
|
}
|
|
53
78
|
new File("${projectDir}/../${zipName}").delete()
|
|
54
79
|
markerFile.text = version
|
|
@@ -57,13 +82,13 @@ task downloadJniLibs {
|
|
|
57
82
|
dir.deleteDir()
|
|
58
83
|
exec {
|
|
59
84
|
commandLine "curl", "-fL", zipUrl, "-o", zipName
|
|
60
|
-
workingDir "
|
|
85
|
+
workingDir "src/main"
|
|
61
86
|
}
|
|
62
87
|
exec {
|
|
63
88
|
commandLine "unzip", "-q", zipName
|
|
64
|
-
workingDir "
|
|
89
|
+
workingDir "src/main"
|
|
65
90
|
}
|
|
66
|
-
new File("${projectDir}
|
|
91
|
+
new File("${projectDir}/src/main/${zipName}").delete()
|
|
67
92
|
markerFile.text = version
|
|
68
93
|
}
|
|
69
94
|
}
|
|
@@ -72,21 +97,21 @@ task downloadJniLibs {
|
|
|
72
97
|
|
|
73
98
|
afterEvaluate {
|
|
74
99
|
preBuild.dependsOn downloadJniLibs
|
|
75
|
-
|
|
100
|
+
// CMake build tasks don't depend on preBuild, so explicitly wire them to
|
|
101
|
+
// downloadJniLibs so the .a files are present before ninja links against them.
|
|
102
|
+
tasks.configureEach { task ->
|
|
103
|
+
if (task.name.startsWith("buildCMake") || task.name.startsWith("configureCMake")) {
|
|
104
|
+
task.dependsOn downloadJniLibs
|
|
105
|
+
}
|
|
106
|
+
}
|
|
76
107
|
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (codegenTask) {
|
|
85
|
-
rootProject.subprojects { subproject ->
|
|
86
|
-
subproject.tasks.matching { it.name.startsWith('configureCMake') }.configureEach { cmakeTask ->
|
|
87
|
-
cmakeTask.dependsOn(codegenTask)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
108
|
+
// The React Native gradle plugin does not wire the app's configureCMake task to depend
|
|
109
|
+
// on this module's generateCodegenArtifactsFromSchema, so on a fresh npm install the
|
|
110
|
+
// app's CMake configuration fails because the codegen JNI directory doesn't exist yet.
|
|
111
|
+
// Fix: make every app:configureCMake* task depend on our codegen task.
|
|
112
|
+
rootProject.findProject(":app")?.tasks?.configureEach { task ->
|
|
113
|
+
if (task.name.startsWith("configureCMake")) {
|
|
114
|
+
task.dependsOn tasks.named("generateCodegenArtifactsFromSchema")
|
|
90
115
|
}
|
|
91
116
|
}
|
|
92
117
|
}
|
|
@@ -149,7 +174,7 @@ android {
|
|
|
149
174
|
}
|
|
150
175
|
externalNativeBuild {
|
|
151
176
|
cmake {
|
|
152
|
-
arguments '-DANDROID_STL=c++_shared'
|
|
177
|
+
arguments '-DANDROID_STL=c++_shared', "-DZCAM1_ENABLE_PROVING=${enableProving ? '1' : '0'}"
|
|
153
178
|
abiFilters (*reactNativeArchitectures())
|
|
154
179
|
}
|
|
155
180
|
}
|
package/app.plugin.js
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
import ConfigPlugins from "@expo/config-plugins";
|
|
2
|
-
const { withPodfileProperties } = ConfigPlugins;
|
|
2
|
+
const { withPodfileProperties, withGradleProperties } = ConfigPlugins;
|
|
3
|
+
|
|
3
4
|
function withZcam1Sdk(config, props) {
|
|
4
5
|
const enableProving = !!(props && props.enableProving);
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
// iOS: write to Podfile.properties.json (read by Zcam1Sdk.podspec)
|
|
8
|
+
config = withPodfileProperties(config, (config) => {
|
|
6
9
|
config.modResults.enableProving = enableProving ? "true" : "false";
|
|
7
10
|
return config;
|
|
8
11
|
});
|
|
12
|
+
|
|
13
|
+
// Android: write to gradle.properties (read by build.gradle)
|
|
14
|
+
config = withGradleProperties(config, (config) => {
|
|
15
|
+
config.modResults = config.modResults.filter(
|
|
16
|
+
(item) => !(item.type === "property" && item.key === "enableProving")
|
|
17
|
+
);
|
|
18
|
+
config.modResults.push({
|
|
19
|
+
type: "property",
|
|
20
|
+
key: "enableProving",
|
|
21
|
+
value: enableProving ? "true" : "false",
|
|
22
|
+
});
|
|
23
|
+
return config;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return config;
|
|
9
27
|
}
|
|
10
28
|
|
|
11
29
|
export { withZcam1Sdk as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@succinctlabs/react-native-zcam1",
|
|
3
|
-
"version": "0.4.0-alpha.
|
|
3
|
+
"version": "0.4.0-alpha.5",
|
|
4
4
|
"description": "ZCAM1 SDK",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"codegenConfig": {
|
|
@@ -77,14 +77,14 @@
|
|
|
77
77
|
"ubrn:web": "ubrn build web",
|
|
78
78
|
"clean": "rm -rfv cpp/ android/CMakeLists.txt android/src/main/java android/*.cpp ios/ src/generated/",
|
|
79
79
|
"build": "bob build",
|
|
80
|
-
"prepack": "npm run ubrn:ios -- --release && npm run ubrn:ios:proving -- --release && npm run ubrn:android -- --release && npm run ubrn:android:proving -- --release && npm run build && if [ -z \"$NPM_CONFIG_REGISTRY\" ]; then mv Zcam1Framework.xcframework Zcam1Framework.xcframework.excluded && mv Zcam1ProvingFramework.xcframework Zcam1ProvingFramework.xcframework.excluded && mv
|
|
80
|
+
"prepack": "npm run ubrn:ios -- --release && npm run ubrn:ios:proving -- --release && npm run ubrn:android -- --release && npm run ubrn:android:proving -- --release && npm run build && if [ -z \"$NPM_CONFIG_REGISTRY\" ]; then mv Zcam1Framework.xcframework Zcam1Framework.xcframework.excluded && mv Zcam1ProvingFramework.xcframework Zcam1ProvingFramework.xcframework.excluded && mv android/src/main/jniLibs android/src/main/jniLibs.excluded && mv android/src/main/jniProvingLibs android/src/main/jniProvingLibs.excluded; fi",
|
|
81
81
|
"lint": "eslint src/",
|
|
82
82
|
"lint:fix": "eslint src/ --fix",
|
|
83
83
|
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
84
84
|
"format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
|
|
85
|
-
"preyalcpublish": "mv Zcam1Framework.xcframework.excluded Zcam1Framework.xcframework && mv Zcam1ProvingFramework.xcframework.excluded Zcam1ProvingFramework.xcframework && mv
|
|
86
|
-
"postyalcpublish": "mv Zcam1Framework.xcframework Zcam1Framework.xcframework.excluded && mv Zcam1ProvingFramework.xcframework Zcam1ProvingFramework.xcframework.excluded && mv
|
|
87
|
-
"postpublish": "if [ -e Zcam1Framework.xcframework.excluded ]; then mv Zcam1Framework.xcframework.excluded Zcam1Framework.xcframework && mv Zcam1ProvingFramework.xcframework.excluded Zcam1ProvingFramework.xcframework && mv
|
|
85
|
+
"preyalcpublish": "mv Zcam1Framework.xcframework.excluded Zcam1Framework.xcframework && mv Zcam1ProvingFramework.xcframework.excluded Zcam1ProvingFramework.xcframework && mv android/src/main/jniLibs.excluded android/src/main/jniLibs && mv android/src/main/jniProvingLibs.excluded android/src/main/jniProvingLibs",
|
|
86
|
+
"postyalcpublish": "mv Zcam1Framework.xcframework Zcam1Framework.xcframework.excluded && mv Zcam1ProvingFramework.xcframework Zcam1ProvingFramework.xcframework.excluded && mv android/src/main/jniLibs android/src/main/jniLibs.excluded && mv android/src/main/jniProvingLibs android/src/main/jniProvingLibs.excluded",
|
|
87
|
+
"postpublish": "if [ -e Zcam1Framework.xcframework.excluded ]; then mv Zcam1Framework.xcframework.excluded Zcam1Framework.xcframework && mv Zcam1ProvingFramework.xcframework.excluded Zcam1ProvingFramework.xcframework && mv android/src/main/jniLibs.excluded android/src/main/jniLibs && mv android/src/main/jniProvingLibs.excluded android/src/main/jniProvingLibs; fi"
|
|
88
88
|
},
|
|
89
89
|
"files": [
|
|
90
90
|
"src",
|
|
@@ -96,11 +96,11 @@
|
|
|
96
96
|
"!**/__tests__",
|
|
97
97
|
"!**/__fixtures__",
|
|
98
98
|
"!**/__mocks__",
|
|
99
|
+
"!android/src/main/jniLibs.excluded",
|
|
100
|
+
"!android/src/main/jniProvingLibs.excluded",
|
|
99
101
|
"*.podspec",
|
|
100
102
|
"Zcam1Framework.xcframework",
|
|
101
103
|
"Zcam1ProvingFramework.xcframework",
|
|
102
|
-
"Zcam1Jni",
|
|
103
|
-
"Zcam1ProvingJni",
|
|
104
104
|
"app.plugin.js",
|
|
105
105
|
"react-native.config.js",
|
|
106
106
|
"turbo.json"
|