Skip to content

Commit 9f109d5

Browse files
Merge pull request #8 from mendix/new-architecture
[MOO-2027]: RN new architecture support
2 parents fe03c96 + e5c3605 commit 9f109d5

File tree

301 files changed

+23417
-16200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

301 files changed

+23417
-16200
lines changed

.github/workflows/secret-scan.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Secret Scan
2+
3+
on:
4+
push:
5+
branches: [ "**" ]
6+
pull_request:
7+
branches: [ "**" ]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
security-events: write
13+
14+
jobs:
15+
gitleaks:
16+
name: Gitleaks Scan
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Run gitleaks
25+
id: gitleaks
26+
uses: gitleaks/gitleaks-action@v2
27+
with:
28+
config-path: .gitleaks.toml
29+
args: --report-format sarif --report-path gitleaks.sarif
30+
31+
- name: Upload SARIF to code scanning
32+
uses: github/codeql-action/upload-sarif@v3
33+
with:
34+
sarif_file: gitleaks.sarif

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ DerivedData
3030
project.xcworkspace
3131
*.env.local
3232
ios/Pods
33+
example/ios/Pods
34+
ios/build
35+
example/vendor
3336

3437
# Android/IJ
3538
#

.gitleaks.toml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
title = "mendix-native gitleaks config"
2+
# Base config uses gitleaks defaults; we extend with allowlists and a few custom regexes
3+
4+
[allowlist]
5+
description = "Global allowlist"
6+
files = [
7+
"yarn.lock",
8+
"package-lock.json",
9+
"pnpm-lock.yaml",
10+
"gradlew",
11+
"gradlew.bat",
12+
"example/ios/Pods/",
13+
"example/android/"
14+
]
15+
regexes = [
16+
# Common false positives
17+
'''(?i)localhost(:[0-9]{2,5})?''',
18+
'''(?i)internal-slot''',
19+
'''(?i)eastasianwidth'''
20+
]
21+
22+
[[rules]]
23+
id = "generic-api-key"
24+
description = "Generic API key format"
25+
regex = '''(?i)(api|access|auth)[_-]?key["'\s:=]+[A-Za-z0-9_\-]{16,}'''
26+
tags = ["api", "key", "generic"]
27+
28+
[[rules]]
29+
id = "bearer-token-inline"
30+
description = "Potential hard-coded bearer token"
31+
regex = '''Bearer\s+[A-Za-z0-9\-_.]{20,}'''
32+
tags = ["auth", "token"]
33+
34+
[[rules]]
35+
id = "jwt"
36+
description = "JSON Web Token"
37+
regex = '''eyJ[a-zA-Z0-9_-]{10,}\.[a-zA-Z0-9_-]{10,}\.[a-zA-Z0-9_-]{10,}'''
38+
tags = ["jwt", "token"]
39+
40+
[[rules]]
41+
id = "aws-access-key"
42+
description = "AWS Access Key ID"
43+
regex = '''AKIA[0-9A-Z]{16}'''
44+
tags = ["aws", "key"]
45+
46+
[[rules]]
47+
id = "github-token"
48+
description = "GitHub Personal Access Token"
49+
regex = '''ghp_[A-Za-z0-9]{36,}'''
50+
tags = ["github", "token"]
51+
52+
[[rules]]
53+
id = "slack-token"
54+
description = "Slack token"
55+
regex = '''xox[baprs]-[A-Za-z0-9\-]{10,}'''
56+
tags = ["slack", "token"]
57+
58+
[[rules]]
59+
id = "stripe-secret-key"
60+
description = "Stripe live secret key"
61+
regex = '''sk_live_[0-9a-zA-Z]{10,}'''
62+
tags = ["stripe", "secret"]
63+
64+
[[rules]]
65+
id = "private-key-block"
66+
description = "Private key block"
67+
regex = '''-----BEGIN (EC|RSA|DSA|OPENSSH|PRIVATE) KEY-----'''
68+
tags = ["crypto", "private-key"]
69+
70+
[whitelist] # backward compatibility for older gitleaks versions
71+
description = "Legacy whitelist alias"
Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
diff --git a/android/build.gradle b/android/build.gradle
2+
index d36fd855813e87b17da43156be64782b325b2733..751355645c0b6e28e2df01e9bdc32f545d8dc83c 100644
3+
--- a/android/build.gradle
4+
+++ b/android/build.gradle
5+
@@ -1,5 +1,4 @@
6+
import java.nio.file.Paths
7+
-import groovy.json.JsonSlurper
8+
9+
buildscript {
10+
ext.getExtOrDefault = {name ->
11+
@@ -27,57 +26,16 @@ def getExtOrIntegerDefault(name) {
12+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["OPSQLite_" + name]).toInteger()
13+
}
14+
15+
-def useSQLCipher = false
16+
+def useSQLCipher = true
17+
def useLibsql = false
18+
def useCRSQLite = false
19+
-def performanceMode = false
20+
+def performanceMode = true
21+
def sqliteFlags = ""
22+
def enableFTS5 = false
23+
def useSqliteVec = false
24+
def enableRtree = false
25+
def tokenizers = []
26+
27+
-// On the example app, the package.json is located at the root of the project
28+
-// On the user app, the package.json is located at the root of the node_modules directory
29+
-def isUserApp = rootDir.absolutePath.contains("node_modules")
30+
-def packageJsonFile
31+
-
32+
-if (isUserApp) {
33+
- // Start from the root + 1 level up (to avoid detecting the op-sqlite/package.json) and traverse upwards to find the first package.json
34+
- File currentDir = new File("$rootDir/../")
35+
- packageJsonFile = null
36+
-
37+
- // Try to find package.json by traversing upwards
38+
- while (currentDir != null) {
39+
- File potential = new File(currentDir, "package.json")
40+
- if (potential.exists()) {
41+
- packageJsonFile = potential
42+
- break
43+
- }
44+
- currentDir = currentDir.parentFile
45+
- }
46+
-} else {
47+
- packageJsonFile = new File("$rootDir/../package.json")
48+
-}
49+
-
50+
-
51+
-def packageJson = new JsonSlurper().parseText(packageJsonFile.text)
52+
-
53+
-def opsqliteConfig = packageJson["op-sqlite"]
54+
-
55+
-if(opsqliteConfig) {
56+
- println "[OP-SQLITE] Detected op-sqlite config from package.json at: " + packageJsonFile.absolutePath
57+
- useSQLCipher = opsqliteConfig["sqlcipher"]
58+
- useCRSQLite = opsqliteConfig["crsqlite"]
59+
- useSqliteVec = opsqliteConfig["sqliteVec"]
60+
- performanceMode = opsqliteConfig["performanceMode"]
61+
- sqliteFlags = opsqliteConfig["sqliteFlags"] ? opsqliteConfig["sqliteFlags"] : ""
62+
- enableFTS5 = opsqliteConfig["fts5"]
63+
- useLibsql = opsqliteConfig["libsql"]
64+
- enableRtree = opsqliteConfig["rtree"]
65+
- tokenizers = opsqliteConfig["tokenizers"] ? opsqliteConfig["tokenizers"] : []
66+
-}
67+
-
68+
if(useSQLCipher) {
69+
println "[OP-SQLITE] using sqlcipher."
70+
} else if(useLibsql) {
71+
diff --git a/android/cpp-adapter.cpp b/android/cpp-adapter.cpp
72+
index 8feaf7719661ef248113f11b1643deedb4b510af..2393963bf982f80ccff2ed396f1538be7ee18fcb 100644
73+
--- a/android/cpp-adapter.cpp
74+
+++ b/android/cpp-adapter.cpp
75+
@@ -19,8 +19,8 @@ struct OPSQLiteBridge : jni::JavaClass<OPSQLiteBridge> {
76+
static void registerNatives() {
77+
javaClassStatic()->registerNatives(
78+
{makeNativeMethod("installNativeJsi", OPSQLiteBridge::installNativeJsi),
79+
- makeNativeMethod("clearStateNativeJsi",
80+
- OPSQLiteBridge::clearStateNativeJsi)});
81+
+ makeNativeMethod("clearStateNativeJsi", OPSQLiteBridge::clearStateNativeJsi),
82+
+ makeNativeMethod("deleteAllDBsJsi", OPSQLiteBridge::deleteAllDBsJsi)});
83+
}
84+
85+
private:
86+
@@ -39,6 +39,10 @@ private:
87+
static void clearStateNativeJsi(jni::alias_ref<jni::JObject> thiz) {
88+
opsqlite::invalidate();
89+
}
90+
+
91+
+ static bool deleteAllDBsJsi(jni::alias_ref<jni::JObject> thiz) {
92+
+ return opsqlite::deleteAllDbs();
93+
+ }
94+
};
95+
96+
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *) {
97+
diff --git a/android/src/main/java/com/op/sqlite/OPSQLiteBridge.kt b/android/src/main/java/com/op/sqlite/OPSQLiteBridge.kt
98+
index 44f86df6a21a6f7272b2c79b196586ef8fec886b..9d9f7100fd34361701b2addf09a4f36e33b35d56 100644
99+
--- a/android/src/main/java/com/op/sqlite/OPSQLiteBridge.kt
100+
+++ b/android/src/main/java/com/op/sqlite/OPSQLiteBridge.kt
101+
@@ -12,6 +12,7 @@ class OPSQLiteBridge {
102+
docPath: String
103+
)
104+
private external fun clearStateNativeJsi()
105+
+ private external fun deleteAllDBsJsi(): Boolean
106+
107+
fun install(context: ReactContext) {
108+
val jsContextPointer = context.javaScriptContextHolder!!.get()
109+
@@ -31,6 +32,10 @@ class OPSQLiteBridge {
110+
clearStateNativeJsi()
111+
}
112+
113+
+ fun deleteAllDBs() {
114+
+ deleteAllDBsJsi()
115+
+ }
116+
+
117+
companion object {
118+
val instance = OPSQLiteBridge()
119+
}
120+
diff --git a/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt b/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt
121+
index 688832fa2f9a7f91d16cd50495caa8c9f8873864..9ea814bfa63f27356e804b82e941b7121152db3a 100644
122+
--- a/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt
123+
+++ b/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt
124+
@@ -13,7 +13,7 @@ import java.io.OutputStream
125+
import com.facebook.react.util.RNLog;
126+
127+
//@ReactModule(name = OPSQLiteModule.NAME)
128+
-internal class OPSQLiteModule(context: ReactApplicationContext?) : ReactContextBaseJavaModule(context) {
129+
+class OPSQLiteModule(context: ReactApplicationContext?) : ReactContextBaseJavaModule(context) {
130+
override fun getName(): String {
131+
return NAME
132+
}
133+
@@ -56,6 +56,17 @@ internal class OPSQLiteModule(context: ReactApplicationContext?) : ReactContextB
134+
return true
135+
}
136+
137+
+ @ReactMethod(isBlockingSynchronousMethod = true)
138+
+ fun closeAllConnections() {
139+
+ OPSQLiteBridge.instance.invalidate()
140+
+ }
141+
+
142+
+ @ReactMethod(isBlockingSynchronousMethod = true)
143+
+ fun deleteAllDBs() {
144+
+ OPSQLiteBridge.instance.deleteAllDBs();
145+
+ }
146+
+
147+
+
148+
@ReactMethod
149+
fun moveAssetsDatabase(args: ReadableMap, promise: Promise) {
150+
val filename = args.getString("filename")!!
151+
diff --git a/cpp/DBHostObject.cpp b/cpp/DBHostObject.cpp
152+
index 85710eea286d45685aa526ed3851e8f1e1411039..8cf10f21ba467dea430aab106d43dd4e2adeacd6 100644
153+
--- a/cpp/DBHostObject.cpp
154+
+++ b/cpp/DBHostObject.cpp
155+
@@ -889,6 +889,10 @@ void DBHostObject::invalidate() {
156+
#endif
157+
}
158+
159+
+void DBHostObject::drop() {
160+
+ opsqlite_remove(db, db_name, std::string(base_path));
161+
+}
162+
+
163+
DBHostObject::~DBHostObject() { invalidate(); }
164+
165+
} // namespace opsqlite
166+
diff --git a/cpp/DBHostObject.h b/cpp/DBHostObject.h
167+
index cc174b7c8c5ce500a6ffe5dc6fe092d282d2554c..ff36f742a22b8a84f37d6dd28441dbe9d0c6c873 100644
168+
--- a/cpp/DBHostObject.h
169+
+++ b/cpp/DBHostObject.h
170+
@@ -73,6 +73,7 @@ class JSI_EXPORT DBHostObject : public jsi::HostObject {
171+
void on_commit();
172+
void on_rollback();
173+
void invalidate();
174+
+ void drop();
175+
~DBHostObject() override;
176+
177+
private:
178+
diff --git a/cpp/bindings.cpp b/cpp/bindings.cpp
179+
index 5e1c1de234e7bdb131769728fc862d389f9995a5..dc21c6503ffe18f3ae1cf99f327e8aa1fc587b71 100644
180+
--- a/cpp/bindings.cpp
181+
+++ b/cpp/bindings.cpp
182+
@@ -36,6 +36,13 @@ void invalidate() {
183+
dbs.clear();
184+
}
185+
186+
+bool deleteAllDbs() {
187+
+ for(const auto &db : dbs) {
188+
+ db->drop();
189+
+ }
190+
+ return true;
191+
+}
192+
+
193+
void install(jsi::Runtime &rt,
194+
const std::shared_ptr<react::CallInvoker> &invoker,
195+
const char *base_path, const char *crsqlite_path,
196+
diff --git a/op-sqlite.podspec b/op-sqlite.podspec
197+
index 375cc3ef0838a3cffb87ec970f636880a8676bb3..e6fce21630ed00aa863f2baae7b3d04de783dcb0 100644
198+
--- a/op-sqlite.podspec
199+
+++ b/op-sqlite.podspec
200+
@@ -1,4 +1,3 @@
201+
-require "json"
202+
require_relative "./generate_tokenizers_header_file"
203+
204+
log_message = lambda do |message|
205+
@@ -39,11 +38,10 @@ else
206+
app_package = JSON.parse(File.read(File.join(__dir__, "example", "package.json")))
207+
end
208+
209+
-op_sqlite_config = app_package["op-sqlite"]
210+
-use_sqlcipher = false
211+
+use_sqlcipher = true
212+
use_crsqlite = false
213+
use_libsql = false
214+
-performance_mode = false
215+
+performance_mode = true
216+
phone_version = false
217+
sqlite_flags = ""
218+
fts5 = false
219+
@@ -51,37 +49,6 @@ rtree = false
220+
use_sqlite_vec = false
221+
tokenizers = []
222+
223+
-if(op_sqlite_config != nil)
224+
- use_sqlcipher = op_sqlite_config["sqlcipher"] == true
225+
- use_crsqlite = op_sqlite_config["crsqlite"] == true
226+
- use_libsql = op_sqlite_config["libsql"] == true
227+
- performance_mode = op_sqlite_config["performanceMode"] || false
228+
- phone_version = op_sqlite_config["iosSqlite"] == true
229+
- sqlite_flags = op_sqlite_config["sqliteFlags"] || ""
230+
- fts5 = op_sqlite_config["fts5"] == true
231+
- rtree = op_sqlite_config["rtree"] == true
232+
- use_sqlite_vec = op_sqlite_config["sqliteVec"] == true
233+
- tokenizers = op_sqlite_config["tokenizers"] || []
234+
-end
235+
-
236+
-if phone_version then
237+
- if use_sqlcipher then
238+
- raise "SQLCipher is not supported with phone version"
239+
- end
240+
-
241+
- if use_crsqlite then
242+
- raise "CRSQLite is not supported with phone version"
243+
- end
244+
-
245+
- if rtree then
246+
- raise "RTree is not supported with phone version"
247+
- end
248+
-
249+
- if use_sqlite_vec then
250+
- raise "SQLite Vec is not supported with phone version"
251+
- end
252+
-end
253+
-
254+
Pod::Spec.new do |s|
255+
s.name = "op-sqlite"
256+
s.version = package["version"]

.yarnrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nodeLinker: node-modules
2+
nmHoistingLimits: workspaces

0 commit comments

Comments
 (0)