Skip to content

Commit 4f79723

Browse files
committed
fix: load Mocha browser runtime after upgrading to v12
2 parents 4c62cf9 + 680c305 commit 4f79723

27 files changed

Lines changed: 591 additions & 46 deletions

‎.github/workflows/release.yml‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ jobs:
9696
}
9797
NODE
9898
99+
- name: Generate release notes
100+
run: node scripts/generate-release-notes.ts "$RELEASE_VERSION" "$RUNNER_TEMP/release-notes.md"
101+
env:
102+
GH_TOKEN: ${{ github.token }}
103+
RELEASE_VERSION: ${{ inputs.version }}
104+
99105
- name: Publish prepared release
100106
run: ./scripts/release.sh --publish-prepared "$RELEASE_VERSION"
101107
env:
@@ -110,14 +116,7 @@ jobs:
110116
if [[ "${version%%.*}" == 9 ]]; then
111117
latest=false
112118
fi
113-
notes="docs/releases/v${version}.md"
114-
args=("v${version}" --target "$(git rev-parse HEAD)" --title "NitroSQLite ${version}" --latest="$latest")
115-
if [ -f "$notes" ]; then
116-
args+=(--notes-file "$notes")
117-
else
118-
args+=(--generate-notes)
119-
fi
120-
gh release create "${args[@]}"
119+
gh release create "v${version}" --target "$(git rev-parse HEAD)" --title "NitroSQLite ${version}" --latest="$latest" --notes-file "$RUNNER_TEMP/release-notes.md"
121120
env:
122121
GH_TOKEN: ${{ github.token }}
123122
RELEASE_VERSION: ${{ inputs.version }}

‎.github/workflows/test-harness-ios.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,25 @@ jobs:
6060
- name: Select Xcode 26.2
6161
run: sudo xcode-select -s "/Applications/Xcode_26.2.app/Contents/Developer"
6262

63+
- name: Start iOS simulator
64+
run: |
65+
set -euo pipefail
66+
67+
simulator="$(xcrun simctl list devices available --json | node -e '
68+
const { readFileSync } = require("node:fs")
69+
const runtime = `com.apple.CoreSimulator.SimRuntime.iOS-${process.env.IOS_SIMULATOR_OS.replaceAll(".", "-")}`
70+
const devices = JSON.parse(readFileSync(0, "utf8")).devices[runtime] ?? []
71+
const device = devices.find((candidate) => candidate.name === process.env.IOS_SIMULATOR_NAME && candidate.isAvailable)
72+
if (!device) throw new Error(`Simulator ${process.env.IOS_SIMULATOR_NAME} on ${runtime} is unavailable`)
73+
console.log(`${device.udid} ${device.state}`)
74+
')"
75+
read -r simulator_udid simulator_state <<< "$simulator"
76+
echo "IOS_SIMULATOR_UDID=$simulator_udid" >> "$GITHUB_ENV"
77+
78+
if [[ "$simulator_state" == "Shutdown" ]]; then
79+
xcrun simctl boot "$simulator_udid"
80+
fi
81+
6382
- name: Install Pods
6483
working-directory: example
6584
run: bun pods
@@ -80,8 +99,14 @@ jobs:
8099
build \
81100
CODE_SIGNING_ALLOWED=NO
82101
102+
- name: Wait for iOS simulator
103+
timeout-minutes: 10
104+
run: xcrun simctl bootstatus "$IOS_SIMULATOR_UDID" -b
105+
83106
- name: Run react-native-harness on iOS
84107
uses: callstackincubator/react-native-harness@v1.5.0
108+
env:
109+
HARNESS_DEBUG: "1"
85110
with:
86111
app: ios/build/Build/Products/Debug-iphonesimulator/NitroSQLiteExample.app
87112
runner: ios

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
Nitro SQLite is a SQLite library for React Native on iOS, macOS, visionOS, and Android, built with [Nitro Modules](https://nitro.margelo.com/). It provides synchronous and asynchronous queries, transactions, and batch operations.
1212

13+
The bundled SQLite build enables [R\*Tree indexes](https://sqlite.margelo.com/docs/concepts/queries-and-indexes#query-spatial-ranges) by default on Apple platforms and Android. Set `nitroSQLite.enableRTree` to `false` in your app's `package.json` to omit it from the native build.
14+
1315
**[Read the documentation](https://sqlite.margelo.com/docs)** for setup, guides, integrations, and the API reference.
1416

1517
If you use a coding agent, give it the [NitroSQLite skill](https://github.com/margelo/react-native-skills/blob/nitro-sqlite/skills/react-native-nitro-sqlite/SKILL.md). It links to focused guidance for connections, queries, transactions, concurrency, and migration. See the [AI agent guide](https://sqlite.margelo.com/docs/guides/ai-agents) for what to check in generated code.

‎bun.lock‎

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/content/docs/concepts/queries-and-indexes.mdx‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,44 @@ db.close()
3333
```
3434

3535
Bind application values with `?`; placeholders cannot stand in for table or column names. Add an index for a query you actually run, then inspect its plan with representative data. [Parameters and results](/docs/guides/parameters-and-results) describes returned rows, and the [performance guide](/docs/guides/performance) covers keeping large reads bounded.
36+
37+
## Query spatial ranges
38+
39+
An R\*Tree index stores bounding boxes and finds those that overlap a query box. Use it for queries such as finding places inside a map viewport or events that overlap a time interval. A normal B-tree index orders values by its columns; an R\*Tree can narrow a search across several independent coordinate ranges. Bounding boxes can include candidates outside an object's exact geometry, so apply an exact check when your query requires one. See [SQLite's R\*Tree documentation](https://www.sqlite.org/rtree.html).
40+
41+
Nitro SQLite's bundled build includes `rtree` and `rtree_i32` by default. You still create the virtual table and populate it explicitly. Enabling the module does not create indexes or change queries against ordinary tables.
42+
43+
```ts
44+
import { open } from 'react-native-nitro-sqlite'
45+
46+
const db = open({ name: 'places.sqlite' })
47+
48+
await db.executeAsync(`
49+
CREATE VIRTUAL TABLE IF NOT EXISTS place_bounds USING rtree(
50+
id,
51+
minLongitude, maxLongitude,
52+
minLatitude, maxLatitude
53+
)
54+
`)
55+
await db.executeAsync(
56+
'INSERT OR REPLACE INTO place_bounds VALUES (?, ?, ?, ?, ?)',
57+
[1, 16.36, 16.38, 48.2, 48.22],
58+
)
59+
60+
const { rows } = await db.executeAsync<{ id: number }>(
61+
`SELECT id FROM place_bounds
62+
WHERE minLongitude <= ? AND maxLongitude >= ?
63+
AND minLatitude <= ? AND maxLatitude >= ?`,
64+
[16.4, 16.35, 48.23, 48.19],
65+
)
66+
console.log(rows._array) // [{ id: 1 }]
67+
db.close()
68+
```
69+
70+
If you store the same objects in an ordinary table, keep their bounding boxes in sync through triggers or updates in the same transaction. R\*Tree data takes storage and adds work to writes. Its storage and index maintenance apply to the tables you create, rather than every database opened by an app that includes the module.
71+
72+
`rtree` stores coordinates as 32-bit floats and rounds lower bounds down and upper bounds up. Overlap queries can return extra candidates. Containment queries can miss an entry at an edge unless you expand the query box as described in [SQLite's roundoff guidance](https://www.sqlite.org/rtree.html#roundoff_error). Use `rtree_i32` for signed 32-bit integer coordinates. Both support one to five dimensions.
73+
74+
A write can restructure an active R\*Tree scan and fail with `SQLITE_LOCKED`. Nitro SQLite's execution methods, including prepared statement execution, read the complete result before returning, so a completed read does not leave that scan open.
75+
76+
For apps that do not need R\*Tree, set `nitroSQLite.enableRTree` to `false` in the app's `package.json` and rebuild the native app. See [Apple configuration](/docs/configuration/ios#rtree-support) or [Android configuration](/docs/configuration/android#rtree-support). Disabling it makes R\*Tree tables unavailable. Queries and schema migrations involving those tables can fail with `no such module: rtree`, including a rename of an ordinary table referenced by a view that also uses R\*Tree. System SQLite support depends on the operating system's build.

‎docs/content/docs/configuration/android.mdx‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,31 @@ Set `nitroSqliteFlags` in the app's `android/gradle.properties` to pass definiti
1919
nitroSqliteFlags="-DSQLITE_ENABLE_FTS5=1"
2020
```
2121

22-
These are SQLite compile definitions, so they affect the bundled source when the native library is rebuilt. Android does not use the iOS `nitroSQLite` package settings or the `NITRO_SQLITE_USE_PHONE_VERSION` pod switch.
22+
These are SQLite compile definitions, so they affect the bundled source when the native library is rebuilt. The Apple `NITRO_SQLITE_USE_PHONE_VERSION` pod switch does not apply to Android.
2323

2424
To use the licensed SQLite Encryption Extension, follow [encrypt a database](/docs/guides/encryption) for the matching source files, symbol prefix, and `SQLITE_ENABLE_SEE` flag.
2525

26+
## RTree support
27+
28+
R\*Tree indexes find bounding boxes that overlap a spatial or time range. The bundled SQLite build includes `rtree` and `rtree_i32` by default. See [query spatial ranges](/docs/concepts/queries-and-indexes#query-spatial-ranges) for SQL examples and limitations.
29+
30+
To omit R\*Tree from the bundled build, set this boolean in your app's `package.json` and rebuild the native app:
31+
32+
```json
33+
{
34+
"nitroSQLite": {
35+
"enableRTree": false
36+
}
37+
}
38+
```
39+
40+
`enableRTree` defaults to `true` independently of `performanceMode`. A non-boolean value fails Gradle configuration. Disabling it omits the default `SQLITE_ENABLE_RTREE` definition. Do not add `-DSQLITE_ENABLE_RTREE=0` to `nitroSqliteFlags` to disable it: SQLite checks whether the macro is defined, so that value still enables the module. Custom compile definitions can enable the module even when the package setting is `false`.
41+
2642
## Threading
2743

2844
The native library opens each database with `SQLITE_OPEN_FULLMUTEX` and serializes calls on each handle. The JavaScript connection helper coordinates work per managed connection and rejects conflicting synchronous work. `nitroSqliteFlags` can change compile-time SQLite behavior, including `SQLITE_THREADSAFE`. Nitro SQLite rejects [independent connections](/docs/guides/multiple-connections) when SQLite was built with `SQLITE_THREADSAFE=0`; other database handles can still run concurrently, so an app disabling mutexes must serialize SQLite calls across the process.
2945

30-
Android has no separate `performanceMode` Gradle property. Its native build always applies its CMake compiler options, including `-O2`. The iOS `performanceMode` package key does not configure Android.
46+
The app's `nitroSQLite.threadSafe` and `nitroSQLite.performanceMode` settings also configure Android's SQLite defaults. Custom `nitroSqliteFlags` override individual defaults. The native build additionally applies its CMake compiler options, including `-O2`.
3147

3248
## Vector search
3349

‎docs/content/docs/configuration/ios.mdx‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ NITRO_SQLITE_USE_PHONE_VERSION=1 npx pod-install
3939

4040
The bundled source is where the pod's compile settings apply. Changing the pod's `SQLITE_THREADSAFE` or performance flags cannot change how the system library was built.
4141

42+
## RTree support
43+
44+
R\*Tree indexes find bounding boxes that overlap a spatial or time range. The bundled SQLite build includes `rtree` and `rtree_i32` by default on iOS, macOS, and visionOS. See [query spatial ranges](/docs/concepts/queries-and-indexes#query-spatial-ranges) for SQL examples and limitations.
45+
46+
To omit R\*Tree from the bundled build, set this boolean in your app's `package.json`, install Pods again, and rebuild:
47+
48+
```json
49+
{
50+
"nitroSQLite": {
51+
"enableRTree": false
52+
}
53+
}
54+
```
55+
56+
`enableRTree` defaults to `true` independently of `performanceMode`. A non-boolean value fails Pod installation. Disabling it omits `SQLITE_ENABLE_RTREE`; defining that macro as `0` still enables SQLite's module. This setting cannot change system SQLite's capabilities when you use `NITRO_SQLITE_USE_PHONE_VERSION=1`.
57+
4258
## Thread safety and performance mode
4359

4460
The bundled SQLite build defaults to `SQLITE_THREADSAFE=1` and enables the project's performance compile flags. Set either option in the app's `package.json`:

‎docs/content/docs/configuration/macos.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ The repository's macOS example targets macOS 14 or later with React Native macOS
1717

1818
To keep Metro in a separate terminal, run the `start` script in `example/macos` and launch the `macos` script with `--no-packager`. Pass `--mode Release --no-packager` to build and launch the production bundle.
1919

20-
The [iOS configuration guide](/docs/configuration/ios) describes the shared Apple build flags for bundled SQLite, thread safety, performance mode, and vector search. Run CocoaPods from `macos` when applying those settings to a macOS app.
20+
The [iOS configuration guide](/docs/configuration/ios) describes the shared Apple build flags for bundled SQLite, R\*Tree, thread safety, performance mode, and vector search. Run CocoaPods from `macos` when applying those settings to a macOS app.

‎docs/releases/v10.1.0.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
NitroSQLite 10.1.0 adds opt-in SQLite SEE encryption support and a Node.js mock backed by better-sqlite3. We've improved repeated batch execution and query-result conversion, upgraded bundled SQLite to 3.53.4, and enabled RTree indexes by default. This release includes the connection ownership fix shipped in 10.0.1, along with the newer changes on main.
2+
3+
## Encryption and Node.js testing
4+
5+
You can now pass an encryption key when opening a database built with the licensed SQLite Encryption Extension. SEE source is not bundled with NitroSQLite; enabling it requires your licensed source and a native rebuild. See the [encryption guide](https://sqlite.margelo.com/docs/guides/encryption) for setup and key handling. [#410](https://github.com/margelo/react-native-nitro-sqlite/pull/410)
6+
7+
The new `react-native-nitro-sqlite/mock` entry point runs against better-sqlite3 in Node.js. It supports independent connections, prepared statements, transactions, and batches for tests that need a real SQLite engine. Install better-sqlite3 separately when using the mock. [#395](https://github.com/margelo/react-native-nitro-sqlite/pull/395), [#420](https://github.com/margelo/react-native-nitro-sqlite/pull/420)
8+
9+
## Query performance and SQLite support
10+
11+
Grouped batch parameters reuse a prepared statement for repeated executions of the same SQL. Query results also avoid an extra native row copy during conversion to JavaScript. [#387](https://github.com/margelo/react-native-nitro-sqlite/pull/387), [#389](https://github.com/margelo/react-native-nitro-sqlite/pull/389)
12+
13+
Bundled SQLite is now 3.53.4, and its symbols are isolated from other SQLite engines linked into the same app. RTree is enabled by default for spatial and range indexes. See the [queries and indexes guide](https://sqlite.margelo.com/docs/concepts/queries-and-indexes). [#392](https://github.com/margelo/react-native-nitro-sqlite/pull/392), [#390](https://github.com/margelo/react-native-nitro-sqlite/pull/390), [#425](https://github.com/margelo/react-native-nitro-sqlite/pull/425)
14+
15+
## Reliability and upgrading
16+
17+
Connections close with the NitroSQLite owner that opened them, so replacing a runtime can reopen the same database. We've also improved transaction cleanup and error reporting, restored `undefined` parameters as SQL NULL, preserved embedded NUL bytes in text results, and corrected column metadata types. Android temporary files now use the app cache. The changelog below links each fix.
18+
19+
Update both packages to 10.1.0 if you use sqlite-vec, install Pods again on Apple platforms, and rebuild your native app. SQLite 3.53 changes floating-point-to-text conversion from 15 to 17 significant digits, so check code that depends on exact SQL text formatting. The TypeORM dependency is now 1.1.1. [#426](https://github.com/margelo/react-native-nitro-sqlite/pull/426)
20+
21+
The [documentation website](https://sqlite.margelo.com/docs) now includes guides and a generated API reference.

‎example/ios/Podfile.lock‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,8 +2222,8 @@ SPEC CHECKSUMS:
22222222
ReactCommon: 749169e12aa3461a3df3656a00e48dbe0456b2d6
22232223
ReactNativeDependencies: 94c922c39e0e6150ee9ad05e2ca1946e0ef55783
22242224
RNCClipboard: e706ef7ccbbfd69f829c1b683f893bc7668c9fdb
2225-
RNNitroSQLite: 7a3bc04bf9db485a4b88f308f5c0de186b39dfb0
2226-
RNNitroSqliteVec: b776070e72840e921c4c66ff264f035191d86b78
2225+
RNNitroSQLite: 119ba2dae35083ed5306594ad99cf5d4d7e100c0
2226+
RNNitroSqliteVec: 0c255fb910dbcea6c77ab22a9b9b2e10cefdc7f0
22272227
RNScreens: 3c977859fd13e67dc4ebfc24afb4d7c2e894db61
22282228
SocketRocket: 37aec555668fb852ec12e3c0de59a86ca58f0871
22292229
Yoga: d1c536142c5ff8ec8cd856ab2a7c227a1d875c8e

0 commit comments

Comments
 (0)