Skip to content

Commit f37bc1f

Browse files
feat: Migrate library to a react-native-nitro-modules (#55)
Co-authored-by: Oskar Kwaśniewski <[email protected]>
1 parent ef09582 commit f37bc1f

File tree

90 files changed

+87921
-91621
lines changed

Some content is hidden

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

90 files changed

+87921
-91621
lines changed

.github/workflows/lint-cpp.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
- "**/*.cpp"
1212
- "**/*.c"
1313
- "**/*.mm"
14+
paths-ignore:
15+
- "node_modules"
16+
- "**/node_modules"
1417
pull_request:
1518
paths:
1619
- ".github/workflows/lint-cpp.yml"
@@ -19,6 +22,9 @@ on:
1922
- "**/*.cpp"
2023
- "**/*.c"
2124
- "**/*.mm"
25+
paths-ignore:
26+
- "node_modules"
27+
- "**/node_modules"
2228

2329
jobs:
2430
lint:

bun.lockb

3.96 KB
Binary file not shown.

example/ios/Podfile.lock

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ PODS:
77
- hermes-engine (0.76.1):
88
- hermes-engine/Pre-built (= 0.76.1)
99
- hermes-engine/Pre-built (0.76.1)
10+
- NitroModules (0.16.1):
11+
- DoubleConversion
12+
- glog
13+
- hermes-engine
14+
- RCT-Folly (= 2024.01.01.00)
15+
- RCTRequired
16+
- RCTTypeSafety
17+
- React-Core
18+
- React-debug
19+
- React-Fabric
20+
- React-featureflags
21+
- React-graphics
22+
- React-ImageManager
23+
- React-NativeModulesApple
24+
- React-RCTFabric
25+
- React-rendererdebug
26+
- React-utils
27+
- ReactCodegen
28+
- ReactCommon/turbomodule/bridging
29+
- ReactCommon/turbomodule/core
30+
- Yoga
1031
- RCT-Folly (2024.01.01.00):
1132
- boost
1233
- DoubleConversion
@@ -1242,27 +1263,6 @@ PODS:
12421263
- ReactCommon/turbomodule/bridging
12431264
- ReactCommon/turbomodule/core
12441265
- Yoga
1245-
- react-native-quick-sqlite (8.2.5):
1246-
- DoubleConversion
1247-
- glog
1248-
- hermes-engine
1249-
- RCT-Folly (= 2024.01.01.00)
1250-
- RCTRequired
1251-
- RCTTypeSafety
1252-
- React-Core
1253-
- React-debug
1254-
- React-Fabric
1255-
- React-featureflags
1256-
- React-graphics
1257-
- React-ImageManager
1258-
- React-NativeModulesApple
1259-
- React-RCTFabric
1260-
- React-rendererdebug
1261-
- React-utils
1262-
- ReactCodegen
1263-
- ReactCommon/turbomodule/bridging
1264-
- ReactCommon/turbomodule/core
1265-
- Yoga
12661266
- react-native-safe-area-context (4.14.0):
12671267
- DoubleConversion
12681268
- glog
@@ -1596,6 +1596,28 @@ PODS:
15961596
- React-logger (= 0.76.1)
15971597
- React-perflogger (= 0.76.1)
15981598
- React-utils (= 0.76.1)
1599+
- RNQuickSQLite (8.2.5):
1600+
- DoubleConversion
1601+
- glog
1602+
- hermes-engine
1603+
- NitroModules
1604+
- RCT-Folly (= 2024.01.01.00)
1605+
- RCTRequired
1606+
- RCTTypeSafety
1607+
- React-Core
1608+
- React-debug
1609+
- React-Fabric
1610+
- React-featureflags
1611+
- React-graphics
1612+
- React-ImageManager
1613+
- React-NativeModulesApple
1614+
- React-RCTFabric
1615+
- React-rendererdebug
1616+
- React-utils
1617+
- ReactCodegen
1618+
- ReactCommon/turbomodule/bridging
1619+
- ReactCommon/turbomodule/core
1620+
- Yoga
15991621
- RNScreens (3.35.0):
16001622
- DoubleConversion
16011623
- glog
@@ -1651,6 +1673,7 @@ DEPENDENCIES:
16511673
- fmt (from `../../node_modules/react-native/third-party-podspecs/fmt.podspec`)
16521674
- glog (from `../../node_modules/react-native/third-party-podspecs/glog.podspec`)
16531675
- hermes-engine (from `../../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
1676+
- NitroModules (from `../../node_modules/react-native-nitro-modules`)
16541677
- RCT-Folly (from `../../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
16551678
- RCT-Folly/Fabric (from `../../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
16561679
- RCTDeprecation (from `../../node_modules/react-native/ReactApple/Libraries/RCTFoundation/RCTDeprecation`)
@@ -1682,7 +1705,6 @@ DEPENDENCIES:
16821705
- React-logger (from `../../node_modules/react-native/ReactCommon/logger`)
16831706
- React-Mapbuffer (from `../../node_modules/react-native/ReactCommon`)
16841707
- React-microtasksnativemodule (from `../../node_modules/react-native/ReactCommon/react/nativemodule/microtasks`)
1685-
- react-native-quick-sqlite (from `../../package`)
16861708
- react-native-safe-area-context (from `../../node_modules/react-native-safe-area-context`)
16871709
- React-nativeconfig (from `../../node_modules/react-native/ReactCommon`)
16881710
- React-NativeModulesApple (from `../../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
@@ -1711,6 +1733,7 @@ DEPENDENCIES:
17111733
- React-utils (from `../../node_modules/react-native/ReactCommon/react/utils`)
17121734
- ReactCodegen (from `build/generated/ios`)
17131735
- ReactCommon/turbomodule/core (from `../../node_modules/react-native/ReactCommon`)
1736+
- RNQuickSQLite (from `../../package`)
17141737
- RNScreens (from `../../node_modules/react-native-screens`)
17151738
- Yoga (from `../../node_modules/react-native/ReactCommon/yoga`)
17161739

@@ -1732,6 +1755,8 @@ EXTERNAL SOURCES:
17321755
hermes-engine:
17331756
:podspec: "../../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec"
17341757
:tag: hermes-2024-09-09-RNv0.76.0-db6d12e202e15f7a446d8848d6ca8f7abb3cfb32
1758+
NitroModules:
1759+
:path: "../../node_modules/react-native-nitro-modules"
17351760
RCT-Folly:
17361761
:podspec: "../../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec"
17371762
RCTDeprecation:
@@ -1790,8 +1815,6 @@ EXTERNAL SOURCES:
17901815
:path: "../../node_modules/react-native/ReactCommon"
17911816
React-microtasksnativemodule:
17921817
:path: "../../node_modules/react-native/ReactCommon/react/nativemodule/microtasks"
1793-
react-native-quick-sqlite:
1794-
:path: "../../package"
17951818
react-native-safe-area-context:
17961819
:path: "../../node_modules/react-native-safe-area-context"
17971820
React-nativeconfig:
@@ -1848,6 +1871,8 @@ EXTERNAL SOURCES:
18481871
:path: build/generated/ios
18491872
ReactCommon:
18501873
:path: "../../node_modules/react-native/ReactCommon"
1874+
RNQuickSQLite:
1875+
:path: "../../package"
18511876
RNScreens:
18521877
:path: "../../node_modules/react-native-screens"
18531878
Yoga:
@@ -1860,6 +1885,7 @@ SPEC CHECKSUMS:
18601885
fmt: 10c6e61f4be25dc963c36bd73fc7b1705fe975be
18611886
glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a
18621887
hermes-engine: 46f1ffbf0297f4298862068dd4c274d4ac17a1fd
1888+
NitroModules: 69af449f389d4c548848a400e1270f672a64e5a3
18631889
RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648
18641890
RCTDeprecation: fde92935b3caa6cb65cbff9fbb7d3a9867ffb259
18651891
RCTRequired: 75c6cee42d21c1530a6f204ba32ff57335d19007
@@ -1889,7 +1915,6 @@ SPEC CHECKSUMS:
18891915
React-logger: 97c9dafae1f1a638001a9d1d0e93d431f2f9cb7b
18901916
React-Mapbuffer: 3146a13424f9fec2ea1f1462d49d566e4d69b732
18911917
React-microtasksnativemodule: 02d218c79c72d373a92a8552183f4ead0d1c6e05
1892-
react-native-quick-sqlite: 975bea33bc233f8cd468b3a27c50d88521ade800
18931918
react-native-safe-area-context: 2500e4fe998caad50ad3bc51ec23ef951308569e
18941919
React-nativeconfig: 93fe8c85a8c40820c57814e30f3e44b94c995a7b
18951920
React-NativeModulesApple: b3e076fd0d7b73417fe1e8c8b26e3c57ae9b74aa
@@ -1918,6 +1943,7 @@ SPEC CHECKSUMS:
19181943
React-utils: 5362bd16a9563f9916e7a56c011ddc533507650f
19191944
ReactCodegen: 4e26d365313307cc7c95e693529e539acfb5c64c
19201945
ReactCommon: 422e364463f33e336fc4db196aeb50fd801d90d6
1946+
RNQuickSQLite: 8ef02913f22a4ca65f44cf826acd0185aa5d6771
19211947
RNScreens: e389d6a6a66a4f0d3662924ecae803073ccce8ec
19221948
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
19231949
Yoga: db69236006b8b1c6d55ab453390c882306cbf219

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"expo-status-bar": "^1.12.1",
2424
"react": "*",
2525
"react-native": "*",
26+
"react-native-nitro-modules": "*",
2627
"react-native-quick-sqlite": "8.2.5",
2728
"react-native-safe-area-context": "^4.14.0",
2829
"react-native-screens": "^3.35.0",

example/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const Stack = createNativeStackNavigator<ParamList>()
1313
export default function App() {
1414
return (
1515
<NavigationContainer>
16-
<Stack.Navigator initialRouteName="QuickSQLite Example">
17-
<Stack.Screen name="QuickSQLite Example" component={HomeScreen} />
16+
<Stack.Navigator initialRouteName="NitroSQLite Example">
17+
<Stack.Screen name="NitroSQLite Example" component={HomeScreen} />
1818
<Stack.Screen name="Unit Tests" component={UnitTestScreen} />
1919
<Stack.Screen name="Benchmarks" component={BenchmarkScreen} />
2020
</Stack.Navigator>

example/src/navigation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export type ParamList = {
2-
'QuickSQLite Example': undefined
2+
'NitroSQLite Example': undefined
33
'Unit Tests': undefined
44
'Benchmarks': undefined
55
}

example/src/screens/BenchmarkScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export const BenchmarkScreen: React.FC<Props> = () => {
107107

108108
setResults({})
109109
setIsLoading(true)
110-
console.log('--------- BEGINNING QuickSQLite BENCHMARKS ---------')
110+
console.log('--------- BEGINNING NitroSQLite BENCHMARKS ---------')
111111

112112
async function start(i = 0): Promise<void> {
113113
const benchmark = benchmarks[i]!
@@ -121,7 +121,7 @@ export const BenchmarkScreen: React.FC<Props> = () => {
121121

122122
await start()
123123

124-
console.log('--------- FINISHED QuickSQLite BENCHMARKS! ---------')
124+
console.log('--------- FINISHED NitroSQLite BENCHMARKS! ---------')
125125
setIsLoading(false)
126126
}, [])
127127

example/src/screens/HomeScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { ParamList } from '../navigation'
55
import { StatusBar } from 'expo-status-bar'
66
import { ScreenStyles } from '../styles'
77

8-
type Props = NativeStackScreenProps<ParamList, 'QuickSQLite Example'>
8+
type Props = NativeStackScreenProps<ParamList, 'NitroSQLite Example'>
99

1010
export const HomeScreen: React.FC<Props> = ({ navigation }) => {
1111
return (

example/src/tests/db.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Chance from 'chance'
22
import type {
33
QuickSQLiteConnection,
4-
SQLBatchTuple,
4+
BatchQueryCommand,
55
} from 'react-native-quick-sqlite'
66
import { open } from 'react-native-quick-sqlite'
77

@@ -24,7 +24,7 @@ export function resetTestDb() {
2424

2525
// Copyright 2024 Oscar Franco
2626
// Taken from "op-sqlite" example project.
27-
// Used to demonstrate the performance of QuickSQLite.
27+
// Used to demonstrate the performance of NitroSQLite.
2828
const ROWS = 300000
2929
export let largeDb: QuickSQLiteConnection | undefined
3030
export function resetLargeDb() {
@@ -43,11 +43,12 @@ export function resetLargeDb() {
4343

4444
largeDb.execute('PRAGMA mmap_size=268435456')
4545

46-
const insertions: SQLBatchTuple[] = []
46+
const insertions: BatchQueryCommand[] = []
4747
for (let i = 0; i < ROWS; i++) {
48-
insertions.push([
49-
'INSERT INTO "Test" (id, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
50-
[
48+
insertions.push({
49+
query:
50+
'INSERT INTO "Test" (id, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
51+
params: [
5152
i,
5253
chance.name(),
5354
chance.name(),
@@ -64,7 +65,7 @@ export function resetLargeDb() {
6465
chance.floating(),
6566
chance.floating(),
6667
],
67-
])
68+
})
6869
}
6970

7071
largeDb.executeBatch(insertions)

example/src/tests/unitTests.spec.ts

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Chance from 'chance'
22
import type {
33
QuickSQLiteConnection,
4-
SQLBatchTuple,
4+
BatchQueryCommand,
55
} from 'react-native-quick-sqlite'
66
import { beforeEach, describe, it } from './MochaRNAdapter'
77
import chai from 'chai'
88
import { testDb as testDbInternal, resetTestDb } from './db'
9-
import type { User } from '../model/User'
9+
import { User } from '../model/User'
1010

1111
function isError(e: unknown): e is Error {
1212
return e instanceof Error
@@ -424,10 +424,8 @@ export function registerUnitTests() {
424424
})
425425
} catch (e) {
426426
if (isError(e)) {
427-
console.log(e.message)
428-
429427
expect(e.message)
430-
.to.include('SQL execution error')
428+
.to.include('SqlExecutionError')
431429
.and.to.include('cannot store TEXT value in REAL column User.id')
432430

433431
const res = testDb.execute('SELECT * FROM User')
@@ -578,15 +576,17 @@ export function registerUnitTests() {
578576
const name2 = chance.name()
579577
const age2 = chance.integer()
580578
const networth2 = chance.floating()
581-
const commands: SQLBatchTuple[] = [
582-
[
583-
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
584-
[id1, name1, age1, networth1],
585-
],
586-
[
587-
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
588-
[id2, name2, age2, networth2],
589-
],
579+
const commands: BatchQueryCommand[] = [
580+
{
581+
query:
582+
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
583+
params: [id1, name1, age1, networth1],
584+
},
585+
{
586+
query:
587+
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
588+
params: [id2, name2, age2, networth2],
589+
},
590590
]
591591

592592
testDb.executeBatch(commands)
@@ -612,15 +612,17 @@ export function registerUnitTests() {
612612
const name2 = chance.name()
613613
const age2 = chance.integer()
614614
const networth2 = chance.floating()
615-
const commands: SQLBatchTuple[] = [
616-
[
617-
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
618-
[id1, name1, age1, networth1],
619-
],
620-
[
621-
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
622-
[id2, name2, age2, networth2],
623-
],
615+
const commands: BatchQueryCommand[] = [
616+
{
617+
query:
618+
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
619+
params: [id1, name1, age1, networth1],
620+
},
621+
{
622+
query:
623+
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
624+
params: [id2, name2, age2, networth2],
625+
},
624626
]
625627

626628
await testDb.executeBatchAsync(commands)

0 commit comments

Comments
 (0)