Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump up op-sqlite version for react native v0.76 #37

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ react {
bundleCommand = "export:embed"

/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
// codegenDir = file("../node_modules/@react-native/codegen")
// The root of your project, i.e. where "package.json" lives. Default is '../..'
// root = file("../../")
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
// reactNativeDir = file("../../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
// codegenDir = file("../../node_modules/@react-native/codegen")

/* Variants */
// The list of variants to that are debuggable. For those we're going to
Expand Down Expand Up @@ -57,6 +57,9 @@ react {
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]

/* Autolinking */
autolinkLibrariesWithApp()
}

/**
Expand Down Expand Up @@ -110,13 +113,17 @@ android {
shrinkResources (findProperty('android.enableShrinkResourcesInReleaseBuilds')?.toBoolean() ?: false)
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
crunchPngs (findProperty('android.enablePngCrunchInReleaseBuilds')?.toBoolean() ?: true)
}
}
packagingOptions {
jniLibs {
useLegacyPackaging (findProperty('expo.useLegacyPackaging')?.toBoolean() ?: false)
}
}
androidResources {
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}

// Apply static values from `gradle.properties` to the `android.packagingOptions`
Expand Down Expand Up @@ -167,6 +174,3 @@ dependencies {
implementation jscFlavor
}
}

apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
3 changes: 1 addition & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<data android:scheme="https"/>
</intent>
</queries>
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme">
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:supportsRtl="true">
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
Expand All @@ -27,6 +27,5 @@
<data android:scheme="com.anonymous.example"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.facebook.react.ReactPackage
import com.facebook.react.ReactHost
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.soloader.SoLoader

import expo.modules.ApplicationLifecycleDispatcher
Expand All @@ -21,9 +22,10 @@ class MainApplication : Application(), ReactApplication {
this,
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> {
val packages = PackageList(this).packages
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return PackageList(this).packages
return packages
}

override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"
Expand All @@ -40,7 +42,7 @@ class MainApplication : Application(), ReactApplication {

override fun onCreate() {
super.onCreate()
SoLoader.init(this, false)
SoLoader.init(this, OpenSourceMergedSoMapping)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/splashscreen_background"/>
<item>
<bitmap android:gravity="center" android:src="@drawable/splashscreen_logo"/>
</item>
</layer-list>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions example/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<item name="android:editTextStyle">@style/ResetEditText</item>
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:statusBarColor">#ffffff</item>
</style>
<style name="ResetEditText" parent="@android:style/Widget.EditText">
<item name="android:padding">0dp</item>
<item name="android:textColorHint">#c8c8c8</item>
<item name="android:textColor">@android:color/black</item>
</style>
<style name="Theme.App.SplashScreen" parent="AppTheme">
<item name="android:windowBackground">@drawable/splashscreen</item>
<item name="android:windowBackground">@drawable/ic_launcher_background</item>
</style>
</resources>
8 changes: 4 additions & 4 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '35.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '24')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '35')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.23'
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.24'

ndkVersion = "26.1.10909125"
}
Expand Down
6 changes: 2 additions & 4 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true

# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Enable AAPT2 PNG crunching
android.enablePngCrunchInReleaseBuilds=true

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
Expand Down Expand Up @@ -54,5 +54,3 @@ EX_DEV_CLIENT_NETWORK_INSPECTOR=true

# Use legacy packaging to compress native libraries in the resulting APK.
expo.useLegacyPackaging=false

android.extraMavenRepos=[]
Binary file modified example/android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions example/android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions example/android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
26 changes: 23 additions & 3 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
pluginManagement {
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile().toString())
}
plugins { id("com.facebook.react.settings") }

extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
if (System.getenv('EXPO_USE_COMMUNITY_AUTOLINKING') == '1') {
ex.autolinkLibrariesFromCommand()
} else {
def command = [
'node',
'--no-warnings',
'--eval',
'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
'react-native-config',
'--json',
'--platform',
'android'
].toList()
ex.autolinkLibrariesFromCommand(command)
}
}

rootProject.name = 'example'

dependencyResolutionManagement {
Expand All @@ -11,8 +34,5 @@ dependencyResolutionManagement {
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle");
useExpoModules()

apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesSettingsGradle(settings)

include ':app'
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile())
14 changes: 1 addition & 13 deletions example/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@
"web": {
"favicon": "./assets/favicon.png"
},
"plugins": [
[
"expo-build-properties",
{
"ios": {
"newArchEnabled": true
},
"android": {
"newArchEnabled": true
}
}
]
]
"newArchEnabled": true
}
}
18 changes: 9 additions & 9 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
},
"dependencies": {
"@craftzdog/react-native-buffer": "^6.0.5",
"@op-engineering/op-sqlite": "^6.2.11",
"@op-engineering/op-sqlite": "^11.0.2",
"debug": "^4.3.5",
"expo": "~51.0.14",
"expo-build-properties": "~0.12.3",
"expo-status-bar": "~1.12.1",
"expo": "~52.0.11",
"expo-build-properties": "~0.13.1",
"expo-status-bar": "~2.0.0",
"pouchdb-adapter-http": "^8.0.1",
"pouchdb-core": "^8.0.1",
"pouchdb-mapreduce": "^8.0.1",
"pouchdb-replication": "^8.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.2",
"react-native-quick-crypto": "0.7.0-rc.10"
"react": "18.3.1",
"react-dom": "18.3.1",
"react-native": "0.76.3",
"react-native-quick-crypto": "0.7.7"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/core": "^7.25.2",
"@expo/webpack-config": "^18.0.1",
"babel-loader": "^8.1.0",
"babel-plugin-module-resolver": "^5.0.2"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@types/react": "^18.2.44"
},
"dependencies": {
"@op-engineering/op-sqlite": "^6.2.11",
"@op-engineering/op-sqlite": "^11.0.2",
"debug": "^4.3.5",
"pouchdb-adapter-utils": "^8.0.1",
"pouchdb-binary-utils": "^8.0.1",
Expand Down
24 changes: 12 additions & 12 deletions src/bulkDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ async function sqliteBulkDocs(
logger.debug('verify attachment:', digest)
const sql =
'SELECT count(*) as cnt FROM ' + ATTACH_STORE + ' WHERE digest=?'
const result = await tx.executeAsync(sql, [digest])
if (result.rows?.item(0).cnt === 0) {
const result = await tx.execute(sql, [digest])
if (result.rows[0]?.cnt === 0) {
const err = createError(
MISSING_STUB,
'unknown stub attachment with digest ' + digest
Expand Down Expand Up @@ -147,7 +147,7 @@ async function sqliteBulkDocs(
const params = isUpdate
? [metadataStr, seq, winningRev, id]
: [id, seq, seq, metadataStr]
await tx.executeAsync(sql, params)
await tx.execute(sql, params)
results[resultsIdx] = {
ok: true,
id: docInfo.metadata.id,
Expand All @@ -167,7 +167,7 @@ async function sqliteBulkDocs(
const sql =
'INSERT INTO ' + ATTACH_AND_SEQ_STORE + ' (digest, seq) VALUES (?,?)'
const sqlArgs = [data._attachments[att].digest, seq]
return tx.executeAsync(sql, sqlArgs)
return tx.execute(sql, sqlArgs)
}

await Promise.all(attsToAdd.map((att) => add(att)))
Expand Down Expand Up @@ -205,7 +205,7 @@ async function sqliteBulkDocs(
const sqlArgs = [id, rev, json, deletedInt]

try {
const result = await tx.executeAsync(sql, sqlArgs)
const result = await tx.execute(sql, sqlArgs)
const seq = result.insertId
if (typeof seq === 'number') {
await insertAttachmentMappings(seq)
Expand All @@ -215,8 +215,8 @@ async function sqliteBulkDocs(
// constraint error, recover by updating instead (see #1638)
// https://github.com/pouchdb/pouchdb/issues/1638
const fetchSql = select('seq', BY_SEQ_STORE, null, 'doc_id=? AND rev=?')
const res = await tx.executeAsync(fetchSql, [id, rev])
const seq = res.rows?.item(0).seq
const res = await tx.execute(fetchSql, [id, rev])
const seq = res.rows[0]!.seq as number
logger.debug(
`Got a constraint error, updating instead: seq=${seq}, id=${id}, rev=${rev}`
)
Expand All @@ -225,7 +225,7 @@ async function sqliteBulkDocs(
BY_SEQ_STORE +
' SET json=?, deleted=? WHERE doc_id=? AND rev=?;'
const sqlArgs = [json, deletedInt, id, rev]
await tx.executeAsync(sql, sqlArgs)
await tx.execute(sql, sqlArgs)
await insertAttachmentMappings(seq)
await dataWritten(tx, seq)
}
Expand Down Expand Up @@ -280,12 +280,12 @@ async function sqliteBulkDocs(
continue
}
const id = docInfo.metadata.id
const result = await tx.executeAsync(
const result = await tx.execute(
'SELECT json FROM ' + DOC_STORE + ' WHERE id = ?',
[id]
)
if (result.rows?.length) {
const metadata = safeJsonParse(result.rows.item(0).json)
const metadata = safeJsonParse(result.rows[0]!.json)
fetchedDocs.set(id, metadata)
}
}
Expand All @@ -294,11 +294,11 @@ async function sqliteBulkDocs(
async function saveAttachment(digest: string, data: any) {
logger.debug('saveAttachment:', digest)
let sql = 'SELECT digest FROM ' + ATTACH_STORE + ' WHERE digest=?'
const result = await tx.executeAsync(sql, [digest])
const result = await tx.execute(sql, [digest])
if (result.rows?.length) return
sql =
'INSERT INTO ' + ATTACH_STORE + ' (digest, body, escaped) VALUES (?,?,0)'
await tx.executeAsync(sql, [digest, data])
await tx.execute(sql, [digest, data])
}

await new Promise<void>((resolve, reject) => {
Expand Down
Loading