├── .bundle
└── config
├── .changeset
├── README.md
├── config.json
├── funny-crabs-smoke.md
└── six-moose-buy.md
├── .envrc
├── .gitattributes
├── .github
├── FUNDING.yml
└── workflows
│ ├── build-packages.yaml
│ ├── dev-packages.yaml
│ ├── release.yml
│ └── test.yaml
├── .gitignore
├── .mtslconfig.json
├── .nvmrc
├── .prettierignore
├── .prettierrc
├── .ruby-version
├── .tool-versions
├── CHANGELOG.md
├── CONTRIBUTING.md
├── Gemfile
├── Gemfile.lock
├── LICENSE
├── README.md
├── android
├── .project
├── .settings
│ └── org.eclipse.buildship.core.prefs
├── CMakeLists.txt
├── build.gradle
├── cpp-adapter.cpp
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── reactnativequicksqlite
│ ├── QuickSQLiteBridge.java
│ ├── SequelModule.java
│ └── SequelPackage.java
├── app.plugin.js
├── babel.config.js
├── cpp
├── ConnectionPool.cpp
├── ConnectionPool.h
├── ConnectionState.cpp
├── ConnectionState.h
├── JSIHelper.cpp
├── JSIHelper.h
├── bindings.cpp
├── bindings.h
├── fileUtils.cpp
├── fileUtils.h
├── logs.h
├── macros.h
├── sqlbatchexecutor.cpp
├── sqlbatchexecutor.h
├── sqlite3.c
├── sqlite3.h
├── sqliteBridge.cpp
├── sqliteBridge.h
├── sqliteExecute.cpp
└── sqliteExecute.h
├── header2.png
├── ios
├── QuickSQLite.h
├── QuickSQLite.mm
└── QuickSQLite.xcodeproj
│ └── project.pbxproj
├── package.json
├── react-native-quick-sqlite.podspec
├── scripts
├── bootstrap.js
└── dev-package-pre-version.js
├── sponsors
└── stream.png
├── src
├── DBListenerManager.ts
├── index.ts
├── lock-hooks.ts
├── setup-open.ts
├── table-updates.ts
├── type-orm.ts
├── types.ts
├── utils.ts
├── utils
│ └── BaseObserver.ts
└── withUseFrameworks.ts
├── tests
├── .gitignore
├── App.tsx
├── android
│ ├── .gitignore
│ ├── app
│ │ ├── build.gradle
│ │ ├── debug.keystore
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── reactnativequicksqlite
│ │ │ │ └── tests
│ │ │ │ ├── MainActivity.kt
│ │ │ │ └── MainApplication.kt
│ │ │ └── res
│ │ │ ├── drawable-hdpi
│ │ │ └── splashscreen_logo.png
│ │ │ ├── drawable-mdpi
│ │ │ └── splashscreen_logo.png
│ │ │ ├── drawable-xhdpi
│ │ │ └── splashscreen_logo.png
│ │ │ ├── drawable-xxhdpi
│ │ │ └── splashscreen_logo.png
│ │ │ ├── drawable-xxxhdpi
│ │ │ └── splashscreen_logo.png
│ │ │ ├── drawable
│ │ │ ├── ic_launcher_background.xml
│ │ │ └── rn_edit_text_material.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.webp
│ │ │ ├── ic_launcher_foreground.webp
│ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.webp
│ │ │ ├── ic_launcher_foreground.webp
│ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.webp
│ │ │ ├── ic_launcher_foreground.webp
│ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.webp
│ │ │ ├── ic_launcher_foreground.webp
│ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.webp
│ │ │ ├── ic_launcher_foreground.webp
│ │ │ └── ic_launcher_round.webp
│ │ │ ├── values-night
│ │ │ └── colors.xml
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── app.json
├── assets
│ ├── adaptive-icon.png
│ ├── favicon.png
│ ├── icon.png
│ └── splash.png
├── babel.config.js
├── index.js
├── ios
│ ├── .gitignore
│ ├── .xcode.env
│ ├── Podfile
│ ├── Podfile.lock
│ ├── Podfile.properties.json
│ ├── tests.xcodeproj
│ │ ├── project.pbxproj
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── tests.xcscheme
│ ├── tests.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── tests
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.mm
│ │ ├── Images.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── App-Icon-1024x1024@1x.png
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ ├── SplashScreenBackground.colorset
│ │ │ └── Contents.json
│ │ └── SplashScreenLogo.imageset
│ │ │ ├── Contents.json
│ │ │ ├── image.png
│ │ │ ├── image@2x.png
│ │ │ └── image@3x.png
│ │ ├── Info.plist
│ │ ├── PrivacyInfo.xcprivacy
│ │ ├── SplashScreen.storyboard
│ │ ├── Supporting
│ │ └── Expo.plist
│ │ ├── main.m
│ │ ├── noop-file.swift
│ │ ├── tests-Bridging-Header.h
│ │ └── tests.entitlements
├── metro.config.js
├── package.json
├── scripts
│ └── test.js
├── tests
│ ├── index.ts
│ ├── mocha
│ │ ├── MochaRNAdapter.ts
│ │ └── MochaSetup.ts
│ ├── sqlite
│ │ ├── rawQueries.spec.ts
│ │ └── utils.ts
│ └── type-orm
│ │ ├── Database.ts
│ │ ├── models
│ │ ├── Book.ts
│ │ └── User.ts
│ │ └── typeorm.spec.ts
├── tsconfig.json
└── yarn.lock
├── tsconfig.json
└── yarn.lock
/.bundle/config:
--------------------------------------------------------------------------------
1 | BUNDLE_PATH: "vendor/bundle"
2 | BUNDLE_FORCE_RUBY_PLATFORM: 1
--------------------------------------------------------------------------------
/.changeset/README.md:
--------------------------------------------------------------------------------
1 | # Changesets
2 |
3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4 | with multi-package repos, or single-package repos to help you version and publish your code. You can
5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6 |
7 | We have a quick list of common questions to get you started engaging with this project in
8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
9 |
--------------------------------------------------------------------------------
/.changeset/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
3 | "changelog": "@changesets/cli/changelog",
4 | "commit": false,
5 | "fixed": [],
6 | "linked": [],
7 | "access": "restricted",
8 | "baseBranch": "main",
9 | "updateInternalDependencies": "patch",
10 | "ignore": []
11 | }
12 |
--------------------------------------------------------------------------------
/.changeset/funny-crabs-smoke.md:
--------------------------------------------------------------------------------
1 | ---
2 | "@journeyapps/react-native-quick-sqlite": patch
3 | ---
4 |
5 | Added expo config plugin, that automatically applies podfile changes needed for use_frameworks when `staticLibrary` option is specified for the plugin.
6 |
--------------------------------------------------------------------------------
/.changeset/six-moose-buy.md:
--------------------------------------------------------------------------------
1 | ---
2 | "@journeyapps/react-native-quick-sqlite": patch
3 | ---
4 |
5 | Fix crash when binding or reading blobs.
6 |
--------------------------------------------------------------------------------
/.envrc:
--------------------------------------------------------------------------------
1 | layout node
2 | use node
3 | [ -f .env ] && dotenv
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
2 | # specific for windows script files
3 | *.bat text eol=crlf
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [mrousavy]
2 |
--------------------------------------------------------------------------------
/.github/workflows/build-packages.yaml:
--------------------------------------------------------------------------------
1 | # Ensures packages build correctly
2 | name: Build Packages
3 |
4 | on:
5 | push:
6 |
7 | jobs:
8 | build:
9 | name: Build Packages
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v4
13 | with:
14 | persist-credentials: false
15 |
16 | - name: Setup NodeJS
17 | uses: actions/setup-node@v4
18 | with:
19 | node-version: 18
20 | cache: 'yarn'
21 |
22 | - name: Setup Yarn
23 | run: |
24 | npm install -g yarn
25 | echo "Yarn version: $(yarn -v)"
26 |
27 | # Build is triggered in prepare script
28 | - name: Install Dependencies
29 | run: yarn install --frozen-lockfile
30 |
--------------------------------------------------------------------------------
/.github/workflows/dev-packages.yaml:
--------------------------------------------------------------------------------
1 | # Action to publish packages under the `next` tag for testing
2 | # Packages are versioned as `0.0.0-{tag}-DATETIMESTAMP`
3 | name: Packages Deploy
4 |
5 | on: workflow_dispatch
6 |
7 | jobs:
8 | publish:
9 | name: Publish Dev Packages
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v4
13 | with:
14 | persist-credentials: false
15 |
16 | - name: Setup NodeJS
17 | uses: actions/setup-node@v4
18 | with:
19 | node-version: 18
20 |
21 | - name: Setup Yarn
22 | run: |
23 | npm install -g yarn
24 | echo "Yarn version: $(yarn -v)"
25 | echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}" >> ~/.npmrc
26 |
27 | # This also builds the package as part of the post install
28 | - name: Install Dependencies
29 | run: yarn install --frozen-lockfile
30 |
31 | - name: Development Version
32 | run: |
33 | node ./scripts/dev-package-pre-version.js
34 | yarn changeset version --no-git-tag --snapshot dev
35 | yarn changeset publish --tag dev
36 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 |
8 | concurrency: ${{ github.workflow }}-${{ github.ref }}
9 |
10 | jobs:
11 | release:
12 | name: Release
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Checkout Repo
16 | uses: actions/checkout@v4
17 |
18 | - name: Setup Node.js 18
19 | uses: actions/setup-node@v4
20 | with:
21 | node-version: 18
22 |
23 | # This also builds the package as part of the post install
24 | - name: Install Dependencies
25 | run: yarn
26 |
27 | - name: Create Release Pull Request or Publish to npm
28 | id: changesets
29 | uses: changesets/action@v1
30 | with:
31 | # This expects you to have a script called release which does a build for your packages and calls changeset publish
32 | publish: yarn release
33 | env:
34 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
36 |
--------------------------------------------------------------------------------
/.github/workflows/test.yaml:
--------------------------------------------------------------------------------
1 | name: Test
2 |
3 | on:
4 | push:
5 |
6 | jobs:
7 | test:
8 | name: Test Android
9 | runs-on: ubuntu-xl
10 | env:
11 | AVD_NAME: ubuntu-avd-x86_64-31
12 | steps:
13 | - uses: actions/checkout@v4
14 | with:
15 | persist-credentials: false
16 |
17 | - name: Enable KVM group perms
18 | run: |
19 | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
20 | sudo udevadm control --reload-rules
21 | sudo udevadm trigger --name-match=kvm
22 |
23 | - name: Gradle Cache
24 | uses: gradle/gradle-build-action@v2
25 |
26 | - name: AVD Cache
27 | uses: actions/cache@v3
28 | id: avd-cache
29 | with:
30 | path: |
31 | ~/.android/avd/*
32 | ~/.android/adb*
33 | key: avd-31
34 |
35 | - name: Setup NodeJS
36 | uses: actions/setup-node@v4
37 | with:
38 | node-version: 18
39 | cache: 'yarn'
40 |
41 | - name: Set up JDK 17
42 | uses: actions/setup-java@v3
43 | with:
44 | java-version: 17
45 | distribution: 'adopt'
46 | cache: 'gradle'
47 |
48 | - name: Setup Yarn
49 | run: |
50 | npm install -g yarn
51 | echo "Yarn version: $(yarn -v)"
52 |
53 | - name: Install Dependencies
54 | run: yarn install --frozen-lockfile
55 |
56 | - name: Configure Test App
57 | run: |
58 | cd tests
59 | yarn install --frozen-lockfile
60 |
61 | - name: Initialize Android Folder
62 | run: mkdir -p ~/.android/avd
63 |
64 | - name: create AVD and generate snapshot for caching
65 | if: steps.avd-cache.outputs.cache-hit != 'true'
66 | uses: reactivecircus/android-emulator-runner@v2.28.0
67 | with:
68 | api-level: 31
69 | force-avd-creation: false
70 | target: google_apis
71 | arch: x86_64
72 | disable-animations: false
73 | avd-name: $AVD_NAME
74 | emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
75 | script: echo "Generated AVD snapshot for caching."
76 |
77 | - name: Run connected Android tests
78 | uses: ReactiveCircus/android-emulator-runner@v2.28.0
79 | with:
80 | api-level: 31
81 | target: google_apis
82 | arch: x86_64
83 | avd-name: $AVD_NAME
84 | script: cd tests && yarn test-android --avdName $AVD_NAME
85 | force-avd-creation: false
86 | emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
87 | disable-animations: true
88 |
89 | test-ios:
90 | name: Test iOS (Only build)
91 | runs-on: macOS-13
92 | steps:
93 | - uses: actions/checkout@v4
94 | with:
95 | persist-credentials: false
96 |
97 | - uses: irgaly/xcode-cache@v1
98 | with:
99 | key: xcode-cache-deriveddata-${{ github.workflow }}-${{ github.sha }}
100 | restore-keys: xcode-cache-deriveddata-${{ github.workflow }}-
101 |
102 | - name: CocoaPods Cache
103 | uses: actions/cache@v3
104 | id: cocoapods-cache
105 | with:
106 | path: |
107 | tests/ios/Pods/*
108 | key: ${{ runner.os }}-${{ hashFiles('tests/ios/Podfile.lock') }}
109 |
110 | - name: Setup NodeJS
111 | uses: actions/setup-node@v4
112 | with:
113 | node-version: 18
114 | cache: 'yarn'
115 |
116 | - name: Setup Yarn
117 | run: |
118 | npm install -g yarn
119 | echo "Yarn version: $(yarn -v)"
120 |
121 | - name: Install Dependencies
122 | run: yarn install --frozen-lockfile
123 |
124 | - name: Configure Test App
125 | run: |
126 | cd tests
127 | yarn install --frozen-lockfile
128 |
129 | - name: Install Cocoapods
130 | run: |
131 | cd tests/ios && pod install
132 |
133 | - name: Build iOS
134 | run: |
135 | cd tests && yarn build-ios
136 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # XDE
6 | .expo/
7 |
8 | # VSCode
9 | .vscode/
10 | jsconfig.json
11 |
12 | # Xcode
13 | #
14 | build/
15 | *.pbxuser
16 | !default.pbxuser
17 | *.mode1v3
18 | !default.mode1v3
19 | *.mode2v3
20 | !default.mode2v3
21 | *.perspectivev3
22 | !default.perspectivev3
23 | xcuserdata
24 | *.xccheckout
25 | *.moved-aside
26 | DerivedData
27 | *.hmap
28 | *.ipa
29 | *.xcuserstate
30 | project.xcworkspace
31 |
32 | # Android/IJ
33 | #
34 | .idea
35 | .gradle
36 | local.properties
37 | *.iml
38 | *.hprof
39 | .cxx/
40 | example/.cxx/
41 | *.keystore
42 | !debug.keystore
43 |
44 | # Bundle
45 | #
46 | vendor/
47 |
48 | # Cocoapods
49 | #
50 | example/ios/Pods
51 | example/vendor/bundle
52 |
53 | # Temporary files created by Metro to check the health of the file watcher
54 | 63 .metro-health-check*
55 |
56 | # node.js
57 | #
58 | node_modules/
59 | npm-debug.log
60 | yarn-debug.log
61 | yarn-error.log
62 | tsconfig.tsbuildinfo
63 |
64 | # BUCK
65 | buck-out/
66 | \.buckd/
67 | android/app/libs
68 | android/keystores/debug.keystore
69 | android/.cxx
70 |
71 | # Expo
72 | .expo/*
73 |
74 | # generated by bob
75 | lib/
76 | # Gradle
77 | android/gradle/
78 | android/gradle*
--------------------------------------------------------------------------------
/.mtslconfig.json:
--------------------------------------------------------------------------------
1 | { "ignore_dirs": [".git", "node_modules", "tests"] }
2 |
--------------------------------------------------------------------------------
/.nvmrc:
--------------------------------------------------------------------------------
1 | v22.5.1
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | # Ignore all node_modules
2 | **/node_modules/**
3 |
4 | # Autogenerated files
5 | **/.expo/**
6 | **/.next/**
7 | **/.idea/**
8 | **/.fleet/**
9 |
10 | # Other
11 | **/android/**
12 | **/assets/**
13 | **/bin/**
14 | **/ios/**
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "semi": true,
3 | "singleQuote": true,
4 | "tabWidth": 2,
5 | "jsxBracketSameLine": true,
6 | "useTabs": false,
7 | "printWidth": 120,
8 | "trailingComma": "none"
9 | }
10 |
--------------------------------------------------------------------------------
/.ruby-version:
--------------------------------------------------------------------------------
1 | 3.3.0
2 |
--------------------------------------------------------------------------------
/.tool-versions:
--------------------------------------------------------------------------------
1 | nodejs 22.5.1
2 | ruby 2.7.6
3 | yarn 1.22.19
4 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # @journeyapps/react-native-quick-sqlite
2 |
3 | ## 2.4.4
4 |
5 | ### Patch Changes
6 |
7 | - d743f0c: Update SQLite from 3.39.4 to 3.49.1
8 |
9 | ## 2.4.3
10 |
11 | ### Patch Changes
12 |
13 | - 9aec2e6: Update PowerSync core extension to version 0.3.14
14 |
15 | ## 2.4.2
16 |
17 | ### Patch Changes
18 |
19 | - 85b8906: Update core PowerSync extension to 0.3.12
20 |
21 | ## 2.4.1
22 |
23 | ### Patch Changes
24 |
25 | - 0466bb5: Update PowerSync core extension to 0.3.11
26 |
27 | ## 2.4.0
28 |
29 | ### Minor Changes
30 |
31 | - 43598db: Improved behaviour for closing a database connection. This should prevent some crash issues.
32 |
33 | ## 2.3.0
34 |
35 | ### Minor Changes
36 |
37 | - 73a0a68: powersync-sqlite-core 0.3.8: Increase column limit to 1999; improved handling of migrations on views.
38 |
39 | ## 2.2.1
40 |
41 | ### Patch Changes
42 |
43 | - 761d441: Enable FTS5
44 |
45 | ## 2.2.0
46 |
47 | ### Minor Changes
48 |
49 | - cbe61de: Upgrade minSdkVersion to 24 for Expo 52
50 |
51 | ## 2.1.2
52 |
53 | ### Patch Changes
54 |
55 | - a6e21ed: Use powersync-sqlite-core 0.3.6 to fix issue with dangling rows.
56 |
57 | ## 2.1.1
58 |
59 | ### Patch Changes
60 |
61 | - 9ac4ce7: Result object keys are no longer ordered alphabetically, but rather maintain insertion order. The behaviour now matches other libraries.
62 |
63 | ## 2.1.0
64 |
65 | ### Minor Changes
66 |
67 | - 23bcb1d: Added `refreshSchema()` to bindings. Will cause all connections to be aware of a schema change.
68 |
69 | ## 2.0.1
70 |
71 | ### Patch Changes
72 |
73 | - 63cc6b2: Fix issue where new databases would not always have journal_mode = WAL.
74 |
75 | ## 2.0.0
76 |
77 | ### Major Changes
78 |
79 | - ad95915: Use powersync-sqlite-core 0.3.0
80 |
81 | ## 1.4.0
82 |
83 | ### Minor Changes
84 |
85 | - 429361a: - Remove use of nativeCallSyncHook() for new architecture support.
86 |
87 | ## 1.3.1
88 |
89 | ### Patch Changes
90 |
91 | - b8e0524: Use install_modules_dependencies if available in newer react-native versions.
92 |
93 | ## 1.3.0
94 |
95 | ### Minor Changes
96 |
97 | - 11fc707: Rename back to @journeyapps/react-native-quick-sqlite for now
98 | - 5f70fd2: Use powersync-sqlite-core 0.2.1
99 |
100 | ## 1.2.0
101 |
102 | ### Minor Changes
103 |
104 | - f9d83cc: Move package to @powersync/react-native-quick-sqlite
105 |
106 | ## For the following previous versions refer to `@journeyapps/react-native-quick-sqlite`
107 |
108 | ## 1.1.8
109 |
110 | ### Patch Changes
111 |
112 | - f072d10: Silencing transactions that are reporting on failed rollback exceptions when they are safe to ignore.
113 |
114 | ## 1.1.7
115 |
116 | ### Patch Changes
117 |
118 | - 421bcbd: The default minimum SDK for Expo 51 is 23, so attempting to compile with our package using 21 would result in a build error.
119 |
120 | ## 1.1.6
121 |
122 | ### Patch Changes
123 |
124 | - 634c9c2: Removed the requirement for `lodash` and `uuid` packages.
125 |
126 | ## 1.1.5
127 |
128 | ### Patch Changes
129 |
130 | - 40c6dd0: Fix race condition where table change notications would trigger before COMMIT had completed.
131 | - 2165048: Use memory temp_store
132 |
133 | ## 1.1.4
134 |
135 | ### Patch Changes
136 |
137 | - a1a7dec: Updated UUID dependency.
138 |
139 | ## 1.1.3
140 |
141 | ### Patch Changes
142 |
143 | - b12ec4d: This pull request improves the performance of releasing lock operations. Executing multiple lock operations, such as individual calls to `.execute`, should see a significant performance improvement.
144 |
145 | ## 1.1.2
146 |
147 | ### Patch Changes
148 |
149 | - 4979882: Fixed incorrect imports of `sqlite3.h` to use local version.
150 |
151 | ## 1.1.1
152 |
153 | ### Patch Changes
154 |
155 | - b1324f1: Updated PowerSync SQLite Core to ~>0.1.6. https://github.com/powersync-ja/powersync-sqlite-core/pull/3
156 |
157 | ## 1.1.0
158 |
159 | ### Minor Changes
160 |
161 | - 3bb0212: Added `registerTablesChangedHook` to DB connections which reports batched table updates once `writeTransaction`s and `writeLock`s have been committed. Maintained API compatibility with `registerUpdateHook` which reports table change events as they occur. Added listeners for when write transactions have been committed or rolled back.
162 |
163 | ## 1.0.0
164 |
165 | ### Major Changes
166 |
167 | - 7c54e8a: Version 1.0.0 release out of beta
168 |
169 | ## 0.1.1
170 |
171 | ### Patch Changes
172 |
173 | - 2802916: Fixed: Missing dependency for `uuid` and race condition where ommitting `await` on some lock/transaction operations could deadlock the application's main thread.
174 |
175 | ## 0.1.0
176 |
177 | ### Minor Changes
178 |
179 | - 21cdcf1: Bump to beta version
180 |
181 | ## 0.0.2
182 |
183 | ### Patch Changes
184 |
185 | - c17f91c: Added concurrent read/write connection support.
186 |
187 | ## 0.0.1
188 |
189 | ### Patch Changes
190 |
191 | - 90affb4: Bump version to 0.0.1 for consistency
192 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project.
4 |
5 | ## Development workflow
6 |
7 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
8 |
9 | ```sh
10 | yarn
11 | ```
12 |
13 | While developing, you can run the [example app](/example/) to test your changes.
14 |
15 | To start the packager:
16 |
17 | ```sh
18 | yarn example start
19 | ```
20 |
21 | To run the example app on Android:
22 |
23 | ```sh
24 | yarn example android
25 | ```
26 |
27 | To run the example app on iOS:
28 |
29 | ```sh
30 | yarn example ios
31 | ```
32 |
33 | Make sure your code passes TypeScript and ESLint. Run the following to verify:
34 |
35 | ```sh
36 | yarn typescript
37 | yarn lint
38 | ```
39 |
40 | To fix formatting errors, run the following:
41 |
42 | ```sh
43 | yarn lint --fix
44 | ```
45 |
46 | Remember to add tests for your change if possible. Run the unit tests by:
47 |
48 | ```sh
49 | yarn test
50 | ```
51 |
52 | To edit the Objective-C files, open `example/ios/SequelExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-quick-sqlite`.
53 |
54 | To edit the Kotlin files, open `example/android` in Android studio and find the source files at `reactnativequicksqlite` under `Android`.
55 |
56 | ### Commit message convention
57 |
58 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:
59 |
60 | - `fix`: bug fixes, e.g. fix crash due to deprecated method.
61 | - `feat`: new features, e.g. add new method to the module.
62 | - `refactor`: code refactor, e.g. migrate from class components to hooks.
63 | - `docs`: changes into documentation, e.g. add usage example for the module..
64 | - `test`: adding or updating tests, e.g. add integration tests using detox.
65 | - `chore`: tooling changes, e.g. change CI config.
66 |
67 | Our pre-commit hooks verify that your commit message matches this format when committing.
68 |
69 | ### Linting and tests
70 |
71 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)
72 |
73 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.
74 |
75 | Our pre-commit hooks verify that the linter and tests pass when committing.
76 |
77 | ### Scripts
78 |
79 | The `package.json` file contains various scripts for common tasks:
80 |
81 | - `yarn bootstrap`: setup project by installing all dependencies and pods.
82 | - `yarn typescript`: type-check files with TypeScript.
83 | - `yarn lint`: lint files with ESLint.
84 | - `yarn test`: run unit tests with Jest.
85 | - `yarn example start`: start the Metro server for the example app.
86 | - `yarn example android`: run the example app on Android.
87 | - `yarn example ios`: run the example app on iOS.
88 |
89 | ### Sending a pull request
90 |
91 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
92 |
93 | When you're sending a pull request:
94 |
95 | - Prefer small pull requests focused on one change.
96 | - Verify that linters and tests are passing.
97 | - Review the documentation to make sure it looks good.
98 | - Follow the pull request template when opening a pull request.
99 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue.
100 |
101 | ## Code of Conduct
102 |
103 | ### Our Pledge
104 |
105 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
106 |
107 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
108 |
109 | ### Our Standards
110 |
111 | Examples of behavior that contributes to a positive environment for our community include:
112 |
113 | - Demonstrating empathy and kindness toward other people
114 | - Being respectful of differing opinions, viewpoints, and experiences
115 | - Giving and gracefully accepting constructive feedback
116 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
117 | - Focusing on what is best not just for us as individuals, but for the overall community
118 |
119 | Examples of unacceptable behavior include:
120 |
121 | - The use of sexualized language or imagery, and sexual attention or
122 | advances of any kind
123 | - Trolling, insulting or derogatory comments, and personal or political attacks
124 | - Public or private harassment
125 | - Publishing others' private information, such as a physical or email
126 | address, without their explicit permission
127 | - Other conduct which could reasonably be considered inappropriate in a
128 | professional setting
129 |
130 | ### Enforcement Responsibilities
131 |
132 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
133 |
134 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
135 |
136 | ### Scope
137 |
138 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
139 |
140 | ### Enforcement
141 |
142 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly.
143 |
144 | All community leaders are obligated to respect the privacy and security of the reporter of any incident.
145 |
146 | ### Enforcement Guidelines
147 |
148 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
149 |
150 | #### 1. Correction
151 |
152 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
153 |
154 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
155 |
156 | #### 2. Warning
157 |
158 | **Community Impact**: A violation through a single incident or series of actions.
159 |
160 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
161 |
162 | #### 3. Temporary Ban
163 |
164 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
165 |
166 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
167 |
168 | #### 4. Permanent Ban
169 |
170 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
171 |
172 | **Consequence**: A permanent ban from any sort of public interaction within the community.
173 |
174 | ### Attribution
175 |
176 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
177 | available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
178 |
179 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
180 |
181 | [homepage]: https://www.contributor-covenant.org
182 |
183 | For answers to common questions about this code of conduct, see the FAQ at
184 | https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
185 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
3 | ruby '3.3.0'
4 | gem 'cocoapods', '~> 1.11', '>= 1.11.3'
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | CFPropertyList (3.0.6)
5 | rexml
6 | activesupport (7.0.6)
7 | concurrent-ruby (~> 1.0, >= 1.0.2)
8 | i18n (>= 1.6, < 2)
9 | minitest (>= 5.1)
10 | tzinfo (~> 2.0)
11 | addressable (2.8.4)
12 | public_suffix (>= 2.0.2, < 6.0)
13 | algoliasearch (1.27.5)
14 | httpclient (~> 2.8, >= 2.8.3)
15 | json (>= 1.5.1)
16 | atomos (0.1.3)
17 | claide (1.1.0)
18 | cocoapods (1.12.1)
19 | addressable (~> 2.8)
20 | claide (>= 1.0.2, < 2.0)
21 | cocoapods-core (= 1.12.1)
22 | cocoapods-deintegrate (>= 1.0.3, < 2.0)
23 | cocoapods-downloader (>= 1.6.0, < 2.0)
24 | cocoapods-plugins (>= 1.0.0, < 2.0)
25 | cocoapods-search (>= 1.0.0, < 2.0)
26 | cocoapods-trunk (>= 1.6.0, < 2.0)
27 | cocoapods-try (>= 1.1.0, < 2.0)
28 | colored2 (~> 3.1)
29 | escape (~> 0.0.4)
30 | fourflusher (>= 2.3.0, < 3.0)
31 | gh_inspector (~> 1.0)
32 | molinillo (~> 0.8.0)
33 | nap (~> 1.0)
34 | ruby-macho (>= 2.3.0, < 3.0)
35 | xcodeproj (>= 1.21.0, < 2.0)
36 | cocoapods-core (1.12.1)
37 | activesupport (>= 5.0, < 8)
38 | addressable (~> 2.8)
39 | algoliasearch (~> 1.0)
40 | concurrent-ruby (~> 1.1)
41 | fuzzy_match (~> 2.0.4)
42 | nap (~> 1.0)
43 | netrc (~> 0.11)
44 | public_suffix (~> 4.0)
45 | typhoeus (~> 1.0)
46 | cocoapods-deintegrate (1.0.5)
47 | cocoapods-downloader (1.6.3)
48 | cocoapods-plugins (1.0.0)
49 | nap
50 | cocoapods-search (1.0.1)
51 | cocoapods-trunk (1.6.0)
52 | nap (>= 0.8, < 2.0)
53 | netrc (~> 0.11)
54 | cocoapods-try (1.2.0)
55 | colored2 (3.1.2)
56 | concurrent-ruby (1.2.2)
57 | escape (0.0.4)
58 | ethon (0.16.0)
59 | ffi (>= 1.15.0)
60 | ffi (1.15.5)
61 | fourflusher (2.3.1)
62 | fuzzy_match (2.0.4)
63 | gh_inspector (1.1.3)
64 | httpclient (2.8.3)
65 | i18n (1.14.1)
66 | concurrent-ruby (~> 1.0)
67 | json (2.6.3)
68 | minitest (5.18.1)
69 | molinillo (0.8.0)
70 | nanaimo (0.3.0)
71 | nap (1.1.0)
72 | netrc (0.11.0)
73 | public_suffix (4.0.7)
74 | rexml (3.2.5)
75 | ruby-macho (2.5.1)
76 | typhoeus (1.4.0)
77 | ethon (>= 0.9.0)
78 | tzinfo (2.0.6)
79 | concurrent-ruby (~> 1.0)
80 | xcodeproj (1.22.0)
81 | CFPropertyList (>= 2.3.3, < 4.0)
82 | atomos (~> 0.1.3)
83 | claide (>= 1.0.2, < 2.0)
84 | colored2 (~> 3.1)
85 | nanaimo (~> 0.3.0)
86 | rexml (~> 3.2.4)
87 |
88 | PLATFORMS
89 | ruby
90 |
91 | DEPENDENCIES
92 | cocoapods (~> 1.11, >= 1.11.3)
93 |
94 | RUBY VERSION
95 | ruby 2.7.6p219
96 |
97 | BUNDLED WITH
98 | 2.3.20
99 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2023 Oscar Franco, Journey Mobile, Inc.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | This repository is a fork of [react-native-quick-sqlite](https://github.com/ospfranco/react-native-quick-sqlite?tab=readme-ov-file) that includes custom SQLite extensions built specifically for **PowerSync**. It has been modified to meet the needs of **PowerSync**, adding features or behaviors that are different from the original repository.
6 |
7 | It is **not** intended to be used independently, use [PowerSync React Native SDK](https://github.com/powersync-ja/powersync-js/tree/main/packages/react-native) and install this alongside it as a peer dependency.
8 |
9 | ### For Expo
10 |
11 | #### iOS with `use_frameworks!`
12 |
13 | If your iOS project uses `use_frameworks!`, add the `react-native-quick-sqlite` plugin to your **app.json** or **app.config.js** and configure the `staticLibrary` option:
14 |
15 | ```json
16 | {
17 | "expo": {
18 | "plugins": [
19 | [
20 | "@journeyapps/react-native-quick-sqlite",
21 | {
22 | "staticLibrary": true
23 | }
24 | ]
25 | ]
26 | }
27 | }
28 | ```
29 |
30 | This plugin automatically configures the necessary build settings for `react-native-quick-sqlite` to work with `use_frameworks!`.
31 |
--------------------------------------------------------------------------------
/android/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | journeyapps_react-native-quick-sqlite
4 | Project android_ created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.buildship.core.gradleprojectbuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.buildship.core.gradleprojectnature
16 |
17 |
18 |
19 | 1695029328310
20 |
21 | 30
22 |
23 | org.eclipse.core.resources.regexFilterMatcher
24 | node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/android/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | arguments=--init-script /var/folders/jx/_56srfzj0s3d98w7v3tl8kvr0000gn/T/d146c9752a26f79b52047fb6dc6ed385d064e120494f96f08ca63a317c41f94c.gradle --init-script /var/folders/jx/_56srfzj0s3d98w7v3tl8kvr0000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
2 | auto.sync=false
3 | build.scans.enabled=false
4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.4.2))
5 | connection.project.dir=
6 | eclipse.preferences.version=1
7 | gradle.user.home=
8 | java.home=/usr/local/Cellar/openjdk@11/11.0.14.1/libexec/openjdk.jdk/Contents/Home
9 | jvm.arguments=
10 | offline.mode=false
11 | override.workspace.settings=true
12 | show.console.view=true
13 | show.executions.view=true
14 |
--------------------------------------------------------------------------------
/android/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(ReactNativeQuickSQLite)
2 | cmake_minimum_required(VERSION 3.9.0)
3 |
4 | set (PACKAGE_NAME "react-native-quick-sqlite")
5 | set (CMAKE_VERBOSE_MAKEFILE ON)
6 | set (CMAKE_CXX_STANDARD 17)
7 | set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
8 |
9 | include_directories(
10 | ../cpp
11 | )
12 |
13 | add_definitions(
14 | -DSQLITE_TEMP_STORE=2
15 | -DSQLITE_ENABLE_FTS5=1
16 | ${SQLITE_FLAGS}
17 | )
18 |
19 | add_library(
20 | ${PACKAGE_NAME}
21 | SHARED
22 | ../cpp/sqliteBridge.cpp
23 | ../cpp/sqliteBridge.h
24 | ../cpp/bindings.cpp
25 | ../cpp/bindings.h
26 | ../cpp/sqlite3.h
27 | ../cpp/sqlite3.c
28 | ../cpp/JSIHelper.h
29 | ../cpp/JSIHelper.cpp
30 | ../cpp/fileUtils.h
31 | ../cpp/fileUtils.cpp
32 | ../cpp/sqliteExecute.h
33 | ../cpp/sqliteExecute.cpp
34 | ../cpp/sqlbatchexecutor.h
35 | ../cpp/sqlbatchexecutor.cpp
36 | ../cpp/macros.h
37 | ../cpp/ConnectionPool.cpp
38 | ../cpp/ConnectionPool.h
39 | ../cpp/ConnectionState.cpp
40 | ../cpp/ConnectionState.h
41 | cpp-adapter.cpp
42 | )
43 |
44 | set_target_properties(
45 | ${PACKAGE_NAME} PROPERTIES
46 | CXX_STANDARD 17
47 | CXX_EXTENSIONS OFF
48 | POSITION_INDEPENDENT_CODE ON
49 | )
50 |
51 | find_package(ReactAndroid REQUIRED CONFIG)
52 | find_package(fbjni REQUIRED CONFIG)
53 | find_package(powersync_sqlite_core REQUIRED CONFIG)
54 |
55 | find_library(LOG_LIB log)
56 |
57 | target_link_libraries(
58 | ${PACKAGE_NAME}
59 | ${LOG_LIB}
60 | fbjni::fbjni
61 | ReactAndroid::jsi
62 | android
63 | powersync_sqlite_core::powersync
64 | )
65 |
66 | # This if-then-else can be removed once this library does not support react-native versions below 0.76
67 | # Ideally we would just depend on `REACTNATIVE_MERGED_SO`
68 | # See https://github.com/react-native-community/discussions-and-proposals/discussions/816
69 | if(REACTNATIVE_MERGED_SO OR ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
70 | target_link_libraries(
71 | ${PACKAGE_NAME}
72 | ReactAndroid::reactnative
73 | )
74 | else()
75 | if(${USE_HERMES})
76 | set(JSEXECUTOR_LIB ReactAndroid::hermes_executor)
77 | else()
78 | set(JSEXECUTOR_LIB ReactAndroid::jscexecutor)
79 | endif()
80 |
81 | target_link_libraries(
82 | ${PACKAGE_NAME}
83 | ReactAndroid::turbomodulejsijni
84 | ReactAndroid::react_nativemodule_core
85 | ${JSEXECUTOR_LIB}
86 | )
87 | endif()
88 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | import java.nio.file.Paths
2 |
3 | buildscript {
4 | repositories {
5 | maven {
6 | url "https://plugins.gradle.org/m2/"
7 | }
8 | mavenCentral()
9 | google()
10 | }
11 |
12 | dependencies {
13 | classpath("com.android.tools.build:gradle:7.2.2")
14 | }
15 | }
16 |
17 | def resolveBuildType() {
18 | Gradle gradle = getGradle()
19 | String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()
20 |
21 | return tskReqStr.contains('Release') ? 'release' : 'debug'
22 | }
23 |
24 | def isNewArchitectureEnabled() {
25 | // - Set `newArchEnabled` to true inside the `gradle.properties` file
26 | return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
27 | }
28 |
29 | def SQLITE_FLAGS = rootProject.properties['quickSqliteFlags']
30 |
31 | apply plugin: 'com.android.library'
32 |
33 | def safeExtGet(prop, fallback) {
34 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
35 | }
36 |
37 | def reactNativeArchitectures() {
38 | def value = project.getProperties().get("reactNativeArchitectures")
39 | return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
40 | }
41 |
42 | def USE_HERMES = rootProject.ext.hermesEnabled
43 |
44 | repositories {
45 | mavenCentral()
46 | }
47 |
48 | android {
49 |
50 | namespace "com.reactnativequicksqlite"
51 | compileSdkVersion safeExtGet("compileSdkVersion", 28)
52 |
53 | // Used to override the NDK path/version on internal CI or by allowing
54 | // users to customize the NDK path/version from their root project (e.g. for M1 support)
55 | if (rootProject.hasProperty("ndkPath")) {
56 | ndkPath rootProject.ext.ndkPath
57 | }
58 | if (rootProject.hasProperty("ndkVersion")) {
59 | ndkVersion rootProject.ext.ndkVersion
60 | }
61 |
62 | buildFeatures {
63 | prefab true
64 | }
65 |
66 | sourceSets.main {
67 | jniLibs.srcDirs = ['src/main/jniLibs']
68 | }
69 |
70 | defaultConfig {
71 | minSdkVersion 24
72 | targetSdkVersion safeExtGet('targetSdkVersion', 28)
73 | versionCode 1
74 | versionName "1.0"
75 |
76 | externalNativeBuild {
77 | cmake {
78 | cppFlags "-O2", "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID"
79 | abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
80 | arguments '-DANDROID_STL=c++_shared',
81 | "-DSQLITE_FLAGS='${SQLITE_FLAGS ? SQLITE_FLAGS : ''}'",
82 | "-DUSE_HERMES=${USE_HERMES}"
83 | abiFilters (*reactNativeArchitectures())
84 | }
85 | }
86 |
87 | packagingOptions {
88 | doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
89 | excludes = [
90 | "META-INF",
91 | "META-INF/**",
92 | "**/libjsi.so",
93 | "**/libreact_nativemodule_core.so",
94 | "**/libturbomodulejsijni.so",
95 | "**/libreactnative.so",
96 | "**/libc++_shared.so",
97 | "**/libfbjni.so"
98 | ]
99 | }
100 |
101 | }
102 |
103 | compileOptions {
104 | sourceCompatibility JavaVersion.VERSION_1_8
105 | targetCompatibility JavaVersion.VERSION_1_8
106 | }
107 |
108 | externalNativeBuild {
109 | cmake {
110 | path "CMakeLists.txt"
111 | }
112 | }
113 | }
114 |
115 | dependencies {
116 | implementation 'co.powersync:powersync-sqlite-core:0.3.14'
117 | //noinspection GradleDynamicVersion
118 | implementation 'com.facebook.react:react-android:+'
119 | }
120 |
121 | // Resolves "LOCAL_SRC_FILES points to a missing file, Check that libfb.so exists or that its path is correct".
122 | tasks.whenTaskAdded { task ->
123 | if (task.name.contains("configureCMakeDebug")) {
124 | rootProject.getTasksByName("packageReactNdkDebugLibs", true).forEach {
125 | task.dependsOn(it)
126 | }
127 | }
128 | // We want to add a dependency for both configureCMakeRelease and configureCMakeRelWithDebInfo
129 | if (task.name.contains("configureCMakeRel")) {
130 | rootProject.getTasksByName("packageReactNdkReleaseLibs", true).forEach {
131 | task.dependsOn(it)
132 | }
133 | }
134 | }
--------------------------------------------------------------------------------
/android/cpp-adapter.cpp:
--------------------------------------------------------------------------------
1 | #include "bindings.h"
2 | #include "logs.h"
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | struct QuickSQLiteBridge : jni::JavaClass {
10 | static constexpr auto kJavaDescriptor =
11 | "Lcom/reactnativequicksqlite/QuickSQLiteBridge;";
12 |
13 | static void registerNatives() {
14 | javaClassStatic()->registerNatives(
15 | {// initialization for JSI
16 | makeNativeMethod("installNativeJsi",
17 | QuickSQLiteBridge::installNativeJsi),
18 | {"clearStateNativeJsi", "()V", (void*)&QuickSQLiteBridge::clearStateNativeJsi}
19 | });
20 | }
21 |
22 | private:
23 | static void installNativeJsi(
24 | jni::alias_ref thiz, jlong jsiRuntimePtr,
25 | jni::alias_ref jsCallInvokerHolder,
26 | jni::alias_ref docPath) {
27 | auto jsiRuntime = reinterpret_cast(jsiRuntimePtr);
28 | auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker();
29 | std::string docPathString = docPath->toStdString();
30 |
31 | osp::install(*jsiRuntime, jsCallInvoker, docPathString.c_str());
32 | }
33 |
34 | static void clearStateNativeJsi() {
35 | osp::clearState();
36 | }
37 | };
38 |
39 | JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *) {
40 | return jni::initialize(vm, [] { QuickSQLiteBridge::registerNatives(); });
41 | }
42 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/android/src/main/java/com/reactnativequicksqlite/QuickSQLiteBridge.java:
--------------------------------------------------------------------------------
1 | package com.reactnativequicksqlite;
2 |
3 | import android.util.Log;
4 |
5 | import com.facebook.react.bridge.ReactApplicationContext;
6 | import com.facebook.react.bridge.ReactContext;
7 | import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
8 |
9 | public class QuickSQLiteBridge {
10 | private native void installNativeJsi(long jsContextNativePointer, CallInvokerHolderImpl jsCallInvokerHolder, String docPath);
11 | private native void clearStateNativeJsi();
12 | public static final QuickSQLiteBridge instance = new QuickSQLiteBridge();
13 |
14 | public void install(ReactContext context) {
15 | long jsContextPointer = context.getJavaScriptContextHolder().get();
16 | CallInvokerHolderImpl jsCallInvokerHolder = (CallInvokerHolderImpl)context.getCatalystInstance().getJSCallInvokerHolder();
17 | final String path = context.getFilesDir().getAbsolutePath();
18 |
19 | installNativeJsi(
20 | jsContextPointer,
21 | jsCallInvokerHolder,
22 | path
23 | );
24 | }
25 |
26 | public void clearState() {
27 | clearStateNativeJsi();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/android/src/main/java/com/reactnativequicksqlite/SequelModule.java:
--------------------------------------------------------------------------------
1 | package com.reactnativequicksqlite;
2 |
3 | import androidx.annotation.NonNull;
4 | import android.util.Log;
5 |
6 | import com.facebook.jni.HybridData;
7 | import com.facebook.jni.annotations.DoNotStrip;
8 | import com.facebook.react.bridge.ReactApplicationContext;
9 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
10 | import com.facebook.react.bridge.ReactMethod;
11 | import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
12 |
13 | class SequelModule extends ReactContextBaseJavaModule {
14 | public static final String NAME = "QuickSQLite";
15 |
16 | public SequelModule(ReactApplicationContext context) {
17 | super(context);
18 | }
19 |
20 | @NonNull
21 | @Override
22 | public String getName() {
23 | return NAME;
24 | }
25 |
26 | @ReactMethod(isBlockingSynchronousMethod = true)
27 | public boolean install() {
28 | try {
29 | System.loadLibrary("react-native-quick-sqlite");
30 | QuickSQLiteBridge.instance.install(getReactApplicationContext());
31 | return true;
32 | } catch (Exception exception) {
33 | Log.e(NAME, "Failed to install JSI Bindings!", exception);
34 | return false;
35 | }
36 | }
37 |
38 | @Override
39 | public void onCatalystInstanceDestroy() {
40 | try {
41 | QuickSQLiteBridge.instance.clearState();
42 | } catch (Exception exception) {
43 | Log.e(NAME, "Failed to clear state!", exception);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/android/src/main/java/com/reactnativequicksqlite/SequelPackage.java:
--------------------------------------------------------------------------------
1 | package com.reactnativequicksqlite;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.facebook.react.ReactPackage;
6 | import com.facebook.react.bridge.NativeModule;
7 | import com.facebook.react.bridge.ReactApplicationContext;
8 | import com.facebook.react.uimanager.ViewManager;
9 |
10 | import java.util.Arrays;
11 | import java.util.Collections;
12 | import java.util.List;
13 |
14 |
15 | public class SequelPackage implements ReactPackage {
16 | @NonNull
17 | @Override
18 | public List createNativeModules(@NonNull ReactApplicationContext reactContext) {
19 | return Collections.singletonList(new SequelModule(reactContext));
20 | }
21 |
22 | @NonNull
23 | @Override
24 | public List createViewManagers(@NonNull ReactApplicationContext reactContext) {
25 | return Collections.emptyList();
26 | }
27 | }
--------------------------------------------------------------------------------
/app.plugin.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./lib/commonjs/withUseFrameworks');
2 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:metro-react-native-babel-preset'],
3 | plugins: [
4 | 'babel-plugin-transform-typescript-metadata',
5 | ['@babel/plugin-proposal-decorators', { legacy: true }],
6 | ['@babel/plugin-proposal-class-properties', { loose: true }]
7 | ]
8 | };
9 |
--------------------------------------------------------------------------------
/cpp/ConnectionPool.h:
--------------------------------------------------------------------------------
1 | #include "ConnectionState.h"
2 | #include "JSIHelper.h"
3 | #include "sqlite3.h"
4 | #include
5 | #include
6 | #include
7 |
8 | #ifndef ConnectionPool_h
9 | #define ConnectionPool_h
10 |
11 | enum TransactionEvent { COMMIT, ROLLBACK };
12 |
13 | struct TransactionCallbackPayload {
14 | std::string *dbName;
15 | TransactionEvent event;
16 | };
17 |
18 | // The number of concurrent read connections to the database.
19 | /**
20 | * Concurrent connection pool class.
21 | *
22 | * This allows for multiple (currently READ_CONNECTIONS) read connections and a
23 | * single write connection to operate concurrently.
24 | *
25 | * The SQLite database connections are opened in WAL mode, allowing for
26 | * concurrent reads and writes.
27 | *
28 | * This class acts as a simple state manager allowing requests for read and
29 | * write connections. The class will queue requests for connections and will
30 | * notify them they become available.
31 | *
32 | * Operations requesting locks here are synchronous and should be executed on a
33 | * single thread, however once a lock is active the connections can be used in a
34 | * thread pool for async statement executions.
35 | *
36 | * Synchronization, callback queueing and executions are managed by the
37 | * JavaScript portion of the library.
38 | *
39 | * The general flow is:
40 | * + JavaScript requests read/write lock on a connection via
41 | * readLock/writeLock. JS provides a unique context ID for the lock
42 | * ------> If a connection is available: The SQLite connection is locked to the
43 | * ....... connection lock context ID provided by the requestor. The JavaScript
44 | * ....... bridge is informed from the Connection pool that the requested
45 | * ....... context lock ID is now active and SQL requests can be made with the
46 | * ....... context ID (on the relevant connection).
47 | * ------> If no connections are available, the context ID is added to a FIFO
48 | * ....... queue. Once other requests are completed the JavaScript bridge is
49 | * ....... informed that the requested context lock ID is now active.
50 | *
51 | * + Any SQL requests are triggered (at the correct time) from the JavaScript
52 | * callback. Those requests are synchronized by returning JSI promises over the
53 | * bridge.
54 | *
55 | * + The JavaScript bridge makes a request to release the lock on the connection
56 | * pool once it's async callback operations are either resolved or rejected.
57 | */
58 | class ConnectionPool {
59 | private:
60 | int maxReads;
61 | std::string dbName;
62 | ConnectionState **readConnections;
63 | ConnectionState writeConnection;
64 |
65 | std::vector readQueue;
66 | std::vector writeQueue;
67 |
68 | // Cached constant payloads for c style commit/rollback callbacks
69 | const TransactionCallbackPayload commitPayload;
70 | const TransactionCallbackPayload rollbackPayload;
71 |
72 | void (*onContextCallback)(std::string, ConnectionLockId);
73 | void (*onCommitCallback)(const TransactionCallbackPayload *);
74 |
75 | bool isConcurrencyEnabled;
76 |
77 | public:
78 | bool isClosed;
79 |
80 | ConnectionPool(std::string dbName, std::string docPath,
81 | unsigned int numReadConnections);
82 | ~ConnectionPool();
83 |
84 | friend int onCommitIntermediate(ConnectionPool *pool);
85 |
86 | /**
87 | * Add a task to the read queue. If there are no available connections,
88 | * the task will be queued.
89 | */
90 | void readLock(ConnectionLockId contextId);
91 |
92 | /**
93 | * Add a task to the write queue.
94 | */
95 | void writeLock(ConnectionLockId contextId);
96 |
97 | /**
98 | * Queue in context
99 | */
100 | SQLiteOPResult queueInContext(ConnectionLockId contextId,
101 | std::function task);
102 |
103 | /**
104 | * Callback function when a new context is available for use
105 | */
106 | void setOnContextAvailable(void (*callback)(std::string, ConnectionLockId));
107 |
108 | /**
109 | * Set a callback function for table updates
110 | */
111 | void setTableUpdateHandler(void (*callback)(void *, int, const char *,
112 | const char *, sqlite3_int64));
113 |
114 | /**
115 | * Set a callback function for transaction commits/rollbacks
116 | */
117 | void setTransactionFinalizerHandler(
118 | void (*callback)(const TransactionCallbackPayload *));
119 |
120 | /**
121 | * Close a context in order to progress queue
122 | */
123 | void closeContext(ConnectionLockId contextId);
124 |
125 | // void closeContext(ConnectionLockContext *context);
126 |
127 | /**
128 | * Close all connections.
129 | */
130 | void closeAll();
131 |
132 | /**
133 | * Refreshes the schema for all connections.
134 | */
135 | std::future refreshSchema();
136 |
137 | /**
138 | * Attaches another database to all connections
139 | */
140 | SQLiteOPResult attachDatabase(std::string const dbFileName,
141 | std::string const docPath,
142 | std::string const alias);
143 |
144 | SQLiteOPResult detachDatabase(std::string const alias);
145 |
146 | private:
147 | std::vector getAllConnections();
148 |
149 | void activateContext(ConnectionState &state, ConnectionLockId contextId);
150 |
151 | SQLiteOPResult genericSqliteOpenDb(string const dbName, string const docPath,
152 | sqlite3 **db, int sqlOpenFlags);
153 | };
154 |
155 | int onCommitIntermediate(ConnectionPool *pool);
156 |
157 | #endif
--------------------------------------------------------------------------------
/cpp/ConnectionState.cpp:
--------------------------------------------------------------------------------
1 | #include "ConnectionState.h"
2 | #include "fileUtils.h"
3 | #include "sqlite3.h"
4 |
5 | const std::string EMPTY_LOCK_ID = "";
6 |
7 | SQLiteOPResult genericSqliteOpenDb(string const dbName, string const docPath,
8 | sqlite3 **db, int sqlOpenFlags);
9 |
10 | ConnectionState::ConnectionState(const std::string dbName,
11 | const std::string docPath, int SQLFlags) {
12 | auto result = genericSqliteOpenDb(dbName, docPath, &connection, SQLFlags);
13 | if (result.type != SQLiteOk) {
14 | throw std::runtime_error("Failed to open SQLite database: " + result.errorMessage);
15 | }
16 | thread = std::thread(&ConnectionState::doWork, this);
17 | this->clearLock();
18 | }
19 |
20 | ConnectionState::~ConnectionState() {
21 | if (!isClosed) {
22 | close();
23 | }
24 | }
25 |
26 | void ConnectionState::clearLock() {
27 | waitFinished();
28 | _currentLockId = EMPTY_LOCK_ID;
29 | }
30 |
31 | void ConnectionState::activateLock(const ConnectionLockId &lockId) {
32 | _currentLockId = lockId;
33 | }
34 |
35 | bool ConnectionState::matchesLock(const ConnectionLockId &lockId) {
36 | return _currentLockId == lockId;
37 | }
38 |
39 | bool ConnectionState::isEmptyLock() { return _currentLockId == EMPTY_LOCK_ID; }
40 |
41 | std::future ConnectionState::refreshSchema() {
42 | auto promise = std::make_shared>();
43 | auto future = promise->get_future();
44 |
45 | queueWork([promise](sqlite3* db) {
46 | try {
47 | int rc = sqlite3_exec(db, "PRAGMA table_info('sqlite_master')", nullptr, nullptr, nullptr);
48 | if (rc != SQLITE_OK) {
49 | throw std::runtime_error("Failed to refresh schema");
50 | }
51 | promise->set_value();
52 | } catch (...) {
53 | promise->set_exception(std::current_exception());
54 | }
55 | });
56 |
57 | return future;
58 | }
59 |
60 | void ConnectionState::close() {
61 | {
62 | std::unique_lock g(workQueueMutex);
63 | // prevent any new work from being queued
64 | isClosed = true;
65 | }
66 |
67 | // Wait for the work queue to empty
68 | waitFinished();
69 |
70 | {
71 | // Now signal the thread to stop and notify it
72 | std::unique_lock g(workQueueMutex);
73 | threadDone = true;
74 | workQueueConditionVariable.notify_all();
75 | }
76 |
77 | // Join the worker thread
78 | if (thread.joinable()) {
79 | thread.join();
80 | }
81 |
82 | // Safely close the SQLite connection
83 | sqlite3_close_v2(connection);
84 | }
85 |
86 | void ConnectionState::queueWork(std::function task) {
87 | {
88 | std::unique_lock g(workQueueMutex);
89 | if (isClosed) {
90 | throw std::runtime_error("Connection is not open. Connection has been closed before queueing work.");
91 | }
92 | workQueue.push(task);
93 | }
94 |
95 | workQueueConditionVariable.notify_all();
96 | }
97 |
98 | void ConnectionState::doWork() {
99 | // Loop while the queue is not destructing
100 | while (!threadDone) {
101 | std::function task;
102 |
103 | // Create a scope, so we don't lock the queue for longer than necessary
104 | {
105 | std::unique_lock g(workQueueMutex);
106 | workQueueConditionVariable.wait(g, [&] {
107 | // Only wake up if there are elements in the queue or the program is
108 | // shutting down
109 | return !workQueue.empty() || threadDone;
110 | });
111 |
112 | // If we are shutting down exit without trying to process more work
113 | if (threadDone) {
114 | break;
115 | }
116 |
117 | task = workQueue.front();
118 | workQueue.pop();
119 | }
120 |
121 | threadBusy = true;
122 | task(connection);
123 | threadBusy = false;
124 | // Need to notify in order for waitFinished to be updated when
125 | // the queue is empty and not busy
126 | {
127 | std::unique_lock g(workQueueMutex);
128 | workQueueConditionVariable.notify_all();
129 | }
130 | }
131 | }
132 |
133 | void ConnectionState::waitFinished() {
134 | std::unique_lock g(workQueueMutex);
135 | workQueueConditionVariable.wait(
136 | g, [&] { return workQueue.empty() && !threadBusy; });
137 | }
138 |
139 | SQLiteOPResult genericSqliteOpenDb(string const dbName, string const docPath,
140 | sqlite3 **db, int sqlOpenFlags) {
141 | string dbPath = get_db_path(dbName, docPath);
142 |
143 | int exit = 0;
144 | exit = sqlite3_open_v2(dbPath.c_str(), db, sqlOpenFlags, nullptr);
145 |
146 | if (exit != SQLITE_OK) {
147 | return SQLiteOPResult{.type = SQLiteError,
148 | .errorMessage = sqlite3_errmsg(*db)};
149 | }
150 |
151 | // Set journal mode directly when opening.
152 | // This may have some overhead on the main thread,
153 | // but prevents race conditions with multiple connections.
154 | if (sqlOpenFlags & SQLITE_OPEN_READONLY) {
155 | exit = sqlite3_exec(*db, "PRAGMA busy_timeout = 30000;"
156 | // Default to normal on all connections
157 | "PRAGMA synchronous = NORMAL;",
158 | nullptr, nullptr, nullptr
159 | );
160 | } else {
161 | exit = sqlite3_exec(*db, "PRAGMA busy_timeout = 30000;"
162 | "PRAGMA journal_mode = WAL;"
163 | // 6Mb 1.5x default checkpoint size
164 | "PRAGMA journal_size_limit = 6291456;"
165 | // Default to normal on all connections
166 | "PRAGMA synchronous = NORMAL;",
167 | nullptr, nullptr, nullptr
168 | );
169 | }
170 | if (exit != SQLITE_OK) {
171 | return SQLiteOPResult{.type = SQLiteError,
172 | .errorMessage = sqlite3_errmsg(*db)};
173 | }
174 |
175 | return SQLiteOPResult{.type = SQLiteOk, .rowsAffected = 0};
176 | }
--------------------------------------------------------------------------------
/cpp/ConnectionState.h:
--------------------------------------------------------------------------------
1 | #include "JSIHelper.h"
2 | #include "sqlite3.h"
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | #ifndef ConnectionState_h
12 | #define ConnectionState_h
13 |
14 | typedef std::string ConnectionLockId;
15 |
16 | class ConnectionState {
17 | public:
18 | // Only to be used by connection pool under some circumstances
19 | sqlite3 *connection;
20 |
21 | private:
22 | ConnectionLockId _currentLockId;
23 | // Queue of requests waiting to be processed
24 | std::queue> workQueue;
25 | // Mutex to protect workQueue
26 | std::mutex workQueueMutex;
27 | // Store thread in order to stop it gracefully
28 | std::thread thread;
29 | // This condition variable is used for the threads to wait until there is work
30 | // to do
31 | std::condition_variable_any workQueueConditionVariable;
32 | std::atomic threadBusy{false};
33 | std::atomic threadDone{false};
34 |
35 | public:
36 | std::atomic isClosed{false};
37 |
38 | ConnectionState(const std::string dbName, const std::string docPath,
39 | int SQLFlags);
40 | ~ConnectionState();
41 |
42 | void clearLock();
43 | void activateLock(const ConnectionLockId &lockId);
44 | bool matchesLock(const ConnectionLockId &lockId);
45 | bool isEmptyLock();
46 |
47 | std::future refreshSchema();
48 | void close();
49 | void queueWork(std::function task);
50 |
51 | private:
52 | void doWork();
53 | void waitFinished();
54 | };
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/cpp/JSIHelper.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // JSIHelper.cpp
3 | // react-native-quick-sqlite
4 | //
5 | // Created by Oscar on 13.03.22.
6 | //
7 |
8 | #include "JSIHelper.h"
9 |
10 | #include
11 |
12 | using namespace std;
13 | using namespace facebook;
14 |
15 | QuickValue createNullQuickValue()
16 | {
17 | return QuickValue{
18 | .dataType = NULL_VALUE};
19 | }
20 |
21 | QuickValue createBooleanQuickValue(bool value)
22 | {
23 | return QuickValue{
24 | .dataType = BOOLEAN,
25 | .booleanValue = int(value)};
26 | }
27 |
28 | QuickValue createTextQuickValue(string value)
29 | {
30 | return QuickValue{
31 | .dataType = TEXT,
32 | .textValue = std::move(value)};
33 | }
34 |
35 | QuickValue createIntegerQuickValue(int value)
36 | {
37 | return QuickValue{
38 | .dataType = INTEGER,
39 | .doubleOrIntValue = static_cast(value)};
40 | }
41 |
42 | QuickValue createIntegerQuickValue(double value)
43 | {
44 | return QuickValue{
45 | .dataType = INTEGER,
46 | .doubleOrIntValue = value};
47 | }
48 |
49 | QuickValue createInt64QuickValue(long long value)
50 | {
51 | return QuickValue{
52 | .dataType = INT64,
53 | .int64Value = value};
54 | }
55 |
56 | QuickValue createDoubleQuickValue(double value)
57 | {
58 | return QuickValue{
59 | .dataType = DOUBLE,
60 | .doubleOrIntValue = value};
61 | }
62 |
63 | QuickValue createArrayBufferQuickValueByCopying(const uint8_t *arrayBufferValue, size_t arrayBufferSize)
64 | {
65 | vector copy(arrayBufferValue, arrayBufferValue + arrayBufferSize);
66 |
67 | return QuickValue{
68 | .dataType = ARRAY_BUFFER,
69 | .arrayBuffer = copy};
70 | }
71 |
72 | void jsiQueryArgumentsToSequelParam(jsi::Runtime &rt, jsi::Value const ¶ms, vector *target)
73 | {
74 | if (params.isNull() || params.isUndefined())
75 | {
76 | return;
77 | }
78 |
79 | jsi::Array values = params.asObject(rt).asArray(rt);
80 |
81 | for (int ii = 0; ii < values.length(rt); ii++)
82 | {
83 |
84 | jsi::Value value = values.getValueAtIndex(rt, ii);
85 | if (value.isNull() || value.isUndefined())
86 | {
87 | target->push_back(createNullQuickValue());
88 | }
89 | else if (value.isBool())
90 | {
91 | target->push_back(createBooleanQuickValue(value.getBool()));
92 | }
93 | else if (value.isNumber())
94 | {
95 | double doubleVal = value.asNumber();
96 | int intVal = (int)doubleVal;
97 | long long longVal = (long)doubleVal;
98 | if (intVal == doubleVal)
99 | {
100 | target->push_back(createIntegerQuickValue(intVal));
101 | }
102 | else if (longVal == doubleVal)
103 | {
104 | target->push_back(createInt64QuickValue(longVal));
105 | }
106 | else
107 | {
108 | target->push_back(createDoubleQuickValue(doubleVal));
109 | }
110 | }
111 | else if (value.isString())
112 | {
113 | string strVal = value.asString(rt).utf8(rt);
114 | target->push_back(createTextQuickValue(strVal));
115 | }
116 | else if (value.isObject())
117 | {
118 | auto obj = value.asObject(rt);
119 | if (obj.isArrayBuffer(rt))
120 | {
121 | auto buf = obj.getArrayBuffer(rt);
122 | target->push_back(createArrayBufferQuickValueByCopying(buf.data(rt), buf.size(rt)));
123 | }
124 | }
125 | else
126 | {
127 | target->push_back(createNullQuickValue());
128 | }
129 | }
130 | }
131 |
132 | jsi::Value createSequelQueryExecutionResult(jsi::Runtime &rt, SQLiteOPResult status, vector