fix(mobile): upgrade Expo SDK54 and fix iOS sqlite startup crash (#4841)

* fix(mobile): stabilize Expo SDK54 startup and sqlite migration

* fix(ci): resolve mobile typecheck and desktop release failures

* fix(ci): format files failing prettier check

* fix(ci): align drizzle and mobile menu dependency resolution

* fix(mobile): align react versions for lint

* fix(mobile): upgrade react-native-menu

* fix(mobile): patch track-player android build
This commit is contained in:
DIYgod
2026-02-14 09:35:25 +08:00
committed by GitHub
parent 2d7fe56ce2
commit 992e5ce3ea
21 changed files with 2736 additions and 3065 deletions
+1 -1
View File
@@ -121,7 +121,7 @@ const config: ForgeConfig = {
asar: true,
ignore: [ignorePattern],
prune: true,
prune: false,
extendInfo: {
ITSAppUsesNonExemptEncryption: false,
},
@@ -409,11 +409,16 @@
inputFileListPaths = (
);
inputPaths = (
"$(SRCROOT)/.xcode.env",
"$(SRCROOT)/.xcode.env.local",
"$(SRCROOT)/Folo/Folo.entitlements",
"$(SRCROOT)/Pods/Target Support Files/Pods-Folo/expo-configure-project.sh",
);
name = "[Expo] Configure project";
outputFileListPaths = (
);
outputPaths = (
"$(SRCROOT)/Pods/Target Support Files/Pods-Folo/ExpoModulesProvider.swift",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -559,6 +564,8 @@
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
"${PODS_CONFIGURATION_BUILD_DIR}/React-runtimeexecutor/React_runtimeexecutor.framework/Headers",
"${PODS_CONFIGURATION_BUILD_DIR}/React-runtimeexecutor/React_runtimeexecutor.framework/Headers/platform/ios",
);
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
@@ -629,6 +636,8 @@
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
"${PODS_CONFIGURATION_BUILD_DIR}/React-runtimeexecutor/React_runtimeexecutor.framework/Headers",
"${PODS_CONFIGURATION_BUILD_DIR}/React-runtimeexecutor/React_runtimeexecutor.framework/Headers/platform/ios",
);
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
+2
View File
@@ -84,6 +84,8 @@
<string>Allow $(PRODUCT_NAME) to save photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to access your photos.</string>
<key>RCTNewArchEnabled</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
+5 -2
View File
@@ -4,6 +4,7 @@ const { wrapWithReanimatedMetroConfig } = require("react-native-reanimated/metro
const { getSentryExpoConfig } = require("@sentry/react-native/metro")
const config = getSentryExpoConfig(__dirname, { isCSSEnabled: true })
const workspaceRoot = path.resolve(__dirname, "../..")
config.resolver.sourceExts.push("sql")
config.transformer.getTransformOptions = async () => ({
@@ -15,7 +16,7 @@ config.transformer.getTransformOptions = async () => ({
config.resolver.nodeModulesPaths = [
path.resolve(__dirname, "./node_modules"),
path.resolve(__dirname, "../../node_modules"),
path.resolve(workspaceRoot, "node_modules"),
]
config.resolver.extraNodeModules = {
@@ -23,7 +24,9 @@ config.resolver.extraNodeModules = {
"@locales": path.resolve(__dirname, "../../locales"),
}
config.watchFolders = [...config.watchFolders, path.resolve(__dirname, "../../locales")]
config.watchFolders = Array.from(
new Set([...config.watchFolders, workspaceRoot, path.resolve(workspaceRoot, "locales")]),
)
config.resolver.resolveRequest = (context, moduleName, platform) => {
const result = context.resolveRequest(context, moduleName, platform)
+2 -2
View File
@@ -29,10 +29,10 @@ Pod::Spec.new do |s|
'OTHER_SWIFT_FLAGS' => "$(inherited) #{new_arch_enabled ? '-DRCT_NEW_ARCH_ENABLED' : ''}",
}
s.source_files = "**/*.{h,m,mm,swift,hpp,cpp,js}"
s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}"
s.resource_bundles = {
'js' => ['Modules/SharedWebView/injected/**/*'],
'js' => ['Modules/SharedWebView/Injected/**/*'],
'FollowNative' => ['Media.xcassets'],
}
+46 -54
View File
@@ -19,7 +19,7 @@
},
"dependencies": {
"@better-auth/expo": "1.3.28",
"@expo/metro-runtime": "5.0.4",
"@expo/metro-runtime": "6.1.2",
"@expo/react-native-action-sheet": "4.1.1",
"@follow-app/client-sdk": "catalog:",
"@follow/components": "workspace:*",
@@ -41,10 +41,10 @@
"@react-native-firebase/app-check": "22.2.1",
"@react-native-firebase/messaging": "22.2.1",
"@react-native-masked-view/masked-view": "0.3.2",
"@react-native-menu/menu": "1.2.3",
"@react-native-picker/picker": "2.11.4",
"@sentry/react-native": "6.20.0",
"@shopify/flash-list": "2.2.2",
"@react-native-menu/menu": "2.0.0",
"@react-native-picker/picker": "2.11.1",
"@sentry/react-native": "7.2.0",
"@shopify/flash-list": "2.0.2",
"@tanstack/query-sync-storage-persister": "5.90.22",
"@tanstack/react-query": "5.90.21",
"@tanstack/react-query-persist-client": "5.90.22",
@@ -54,40 +54,40 @@
"dayjs": "1.11.19",
"dnum": "2.17.0",
"es-toolkit": "1.44.0",
"expo": "53.0.12",
"expo-apple-authentication": "7.2.4",
"expo-application": "6.1.4",
"expo-background-task": "0.2.7",
"expo-blur": "14.1.5",
"expo-build-properties": "0.14.6",
"expo-clipboard": "7.1.4",
"expo-constants": "17.1.6",
"expo-dev-client": "5.2.1",
"expo-device": "7.1.4",
"expo-document-picker": "13.1.6",
"expo-file-system": "18.1.10",
"expo": "54.0.33",
"expo-apple-authentication": "8.0.8",
"expo-application": "7.0.8",
"expo-background-task": "1.0.10",
"expo-blur": "15.0.8",
"expo-build-properties": "1.0.10",
"expo-clipboard": "8.0.8",
"expo-constants": "18.0.13",
"expo-dev-client": "6.0.20",
"expo-device": "8.0.10",
"expo-document-picker": "14.0.8",
"expo-file-system": "19.0.21",
"expo-glass-effect": "0.1.9",
"expo-haptics": "14.1.4",
"expo-haptics": "15.0.8",
"expo-iap": "2.5.0",
"expo-image": "2.3.2",
"expo-image-manipulator": "13.1.7",
"expo-image-picker": "~16.1.4",
"expo-linear-gradient": "14.1.5",
"expo-linking": "7.1.5",
"expo-localization": "16.1.5",
"expo-media-library": "17.1.7",
"expo-image": "3.0.11",
"expo-image-manipulator": "14.0.8",
"expo-image-picker": "~17.0.10",
"expo-linear-gradient": "15.0.8",
"expo-linking": "8.0.11",
"expo-localization": "17.0.8",
"expo-media-library": "18.2.1",
"expo-notifications": "0.32.16",
"expo-secure-store": "14.2.3",
"expo-sharing": "13.1.5",
"expo-splash-screen": "0.30.9",
"expo-sqlite": "15.2.12",
"expo-status-bar": "2.2.3",
"expo-symbols": "0.4.5",
"expo-system-ui": "5.0.9",
"expo-task-manager": "13.1.5",
"expo-updates": "0.28.15",
"expo-video": "2.2.2",
"expo-web-browser": "14.2.0",
"expo-secure-store": "15.0.8",
"expo-sharing": "14.0.8",
"expo-splash-screen": "31.0.13",
"expo-sqlite": "16.0.10",
"expo-status-bar": "3.0.9",
"expo-symbols": "1.0.8",
"expo-system-ui": "6.0.9",
"expo-task-manager": "14.0.9",
"expo-updates": "29.0.16",
"expo-video": "3.0.16",
"expo-web-browser": "15.0.10",
"franc-min": "6.2.0",
"i18next": "25.8.6",
"jotai": "2.17.1",
@@ -102,29 +102,30 @@
"react-error-boundary": "6.1.0",
"react-hook-form": "7.71.1",
"react-i18next": "16.5.4",
"react-native": "0.79.6",
"react-native": "0.81.5",
"react-native-awesome-slider": "2.9.0",
"react-native-bouncy-checkbox": "4.1.4",
"react-native-color-matrix-image-filters": "8.0.2",
"react-native-device-info": "15.0.1",
"react-native-gesture-handler": "2.30.0",
"react-native-edge-to-edge": "1.7.0",
"react-native-gesture-handler": "2.28.0",
"react-native-image-colors": "2.5.1",
"react-native-ios-context-menu": "3.1.1",
"react-native-ios-utilities": "5.1.5",
"react-native-keyboard-controller": "1.20.7",
"react-native-ios-context-menu": "3.2.1",
"react-native-ios-utilities": "5.2.0",
"react-native-keyboard-controller": "1.18.5",
"react-native-otp-entry": "1.8.5",
"react-native-pager-view": "6.9.1",
"react-native-reanimated": "4.1.6",
"react-native-root-siblings": "5.0.1",
"react-native-safe-area-context": "5.6.2",
"react-native-screens": "4.11.1",
"react-native-screens": "4.16.0",
"react-native-sheet-transitions": "0.1.2",
"react-native-svg": "15.15.3",
"react-native-svg": "15.12.1",
"react-native-track-player": "4.1.1",
"react-native-uikit-colors": "0.6.2",
"react-native-volume-manager": "2.0.8",
"react-native-web": "0.21.2",
"react-native-webview": "13.16.0",
"react-native-webview": "13.15.0",
"react-native-worklets": "0.5.1",
"shiki": "3.22.0",
"tailwindcss": "3.4.17",
@@ -138,7 +139,7 @@
"devDependencies": {
"@babel/core": "7.29.0",
"@follow/configs": "workspace:*",
"@types/react": "19.2.14",
"@types/react": "19.1.17",
"babel-plugin-inline-import": "3.0.0",
"eas-cli": "16.26.0",
"expo-drizzle-studio-plugin": "0.2.1",
@@ -149,15 +150,6 @@
},
"appName": "Folo",
"expo": {
"install": {
"exclude": [
"react-native@~0.76.6",
"react-native-gesture-handler@~2.20.0",
"react-native-screens@~4.4.0",
"react-native-safe-area-context@~4.12.0",
"react-native-webview@~13.12.5"
]
},
"autolinking": {
"nativeModulesDir": "./native"
}
+1 -1
View File
@@ -1,7 +1,7 @@
import { createBuildSafeHeaders } from "@follow/utils/headers"
import { IMAGE_PROXY_URL } from "@follow/utils/img-proxy"
import ImageEditor from "@react-native-community/image-editor"
import * as FileSystem from "expo-file-system"
import * as FileSystem from "expo-file-system/legacy"
import type { ImageProps, ImageSource } from "expo-image"
import { saveToLibraryAsync, usePermissions } from "expo-media-library"
import * as Sharing from "expo-sharing"
+1 -1
View File
@@ -1,4 +1,4 @@
import * as FileSystem from "expo-file-system"
import * as FileSystem from "expo-file-system/legacy"
export const getDbPath = () => {
return `${FileSystem.documentDirectory}SQLite/follow.db`
+1 -1
View File
@@ -6,7 +6,7 @@ import { createMobileAPIHeaders } from "@follow/utils/headers"
import { useQuery } from "@tanstack/react-query"
import { createAuthClient } from "better-auth/react"
import { nativeApplicationVersion } from "expo-application"
import * as FileSystem from "expo-file-system"
import * as FileSystem from "expo-file-system/legacy"
import * as SecureStore from "expo-secure-store"
import Storage from "expo-sqlite/kv-store"
import { Platform } from "react-native"
+1 -1
View File
@@ -1,4 +1,4 @@
import * as FileSystem from "expo-file-system"
import * as FileSystem from "expo-file-system/legacy"
import * as ImageManipulator from "expo-image-manipulator"
import * as ImagePicker from "expo-image-picker"
@@ -1,4 +1,4 @@
import * as FileSystem from "expo-file-system"
import * as FileSystem from "expo-file-system/legacy"
import { useTranslation } from "react-i18next"
import { Alert } from "react-native"
+1 -1
View File
@@ -1,6 +1,6 @@
import { userSyncService } from "@follow/store/user/store"
import * as DocumentPicker from "expo-document-picker"
import * as FileSystem from "expo-file-system"
import * as FileSystem from "expo-file-system/legacy"
import * as Sharing from "expo-sharing"
import { getDbPath } from "@/src/database"
@@ -3,7 +3,7 @@ import { whoami } from "@follow/store/user/getters"
import { sleep } from "@follow/utils"
import { requireNativeModule } from "expo"
import * as Clipboard from "expo-clipboard"
import * as FileSystem from "expo-file-system"
import * as FileSystem from "expo-file-system/legacy"
import * as SecureStore from "expo-secure-store"
import type { FC } from "react"
import * as React from "react"
+2 -1
View File
@@ -42,7 +42,7 @@
"@tsslint/config": "2.0.7",
"@tsslint/eslint": "2.0.7",
"@types/node": "25.2.3",
"@types/react": "19.2.14",
"@types/react": "19.1.17",
"@types/react-dom": "19.2.3",
"@vercel/node": "5.6.3",
"cross-env": "10.1.0",
@@ -58,6 +58,7 @@
"react": "19.0.0",
"react-dom": "19.0.0",
"rimraf": "6.1.2",
"serialize-error": "2.1.0",
"simple-git-hooks": "2.13.1",
"svg-parser": "2.0.4",
"tar": "7.5.7",
+1 -1
View File
@@ -38,7 +38,7 @@
"@follow/shared": "workspace:*",
"ai": "6.0.85",
"drizzle-orm": "0.45.1",
"expo-sqlite": "15.2.12",
"expo-sqlite": "16.0.10",
"sqlocal": "npm:@hyoban/sqlocal@0.14.1-fork.4",
"wa-sqlite": "git+https://github.com/rhashimoto/wa-sqlite.git#v1.0.8"
},
+5 -5
View File
@@ -1,10 +1,10 @@
import type { ExpoSQLiteDatabase } from "drizzle-orm/expo-sqlite"
import { drizzle } from "drizzle-orm/expo-sqlite"
import { migrate } from "drizzle-orm/expo-sqlite/migrator"
import * as SQLite from "expo-sqlite"
import { SQLITE_DB_NAME } from "./constant"
import migrations from "./drizzle/migrations"
import { migrateExpoSQLite } from "./migrator"
import * as schema from "./schemas"
export let sqlite = SQLite.openDatabaseSync(SQLITE_DB_NAME)
@@ -23,13 +23,13 @@ export { db }
export async function migrateDB(): Promise<void> {
try {
await migrate(db, migrations)
await migrateExpoSQLite(sqlite, migrations)
} catch (error) {
console.error("Failed to migrate database:", error)
await deleteDB()
sqlite = SQLite.openDatabaseSync(SQLITE_DB_NAME)
initializeDB()
await migrate(db, migrations)
await migrateExpoSQLite(sqlite, migrations)
}
}
@@ -37,9 +37,9 @@ export async function getDBFile() {}
export async function exportDB() {}
export async function deleteDB() {
try {
await sqlite.closeAsync()
sqlite.closeSync()
} catch {
/* empty */
}
await SQLite.deleteDatabaseAsync(SQLITE_DB_NAME)
SQLite.deleteDatabaseSync(SQLITE_DB_NAME)
}
+94 -3
View File
@@ -1,5 +1,6 @@
import type { SQL } from "drizzle-orm"
import { sql } from "drizzle-orm"
import type { SqliteRemoteDatabase } from "drizzle-orm/sqlite-proxy"
import type { SQLiteDatabase } from "expo-sqlite"
interface MigrationConfig {
journal: MigrationJournal
@@ -26,6 +27,22 @@ interface MigrationMeta {
bps: boolean
}
type MaybePromise<T> = T | Promise<T>
type SQLiteMigrationDatabase = Pick<SQLiteDatabase, "execSync" | "getAllSync">
interface SQLiteColumnInfo {
name: string
}
interface SQLiteMigrationRow {
id: number
hash: string
created_at: number | string
}
const ADD_COLUMN_RE = /^ALTER TABLE\s+[`"]?(\w+)[`"]?\s+ADD\s+[`"]?(\w+)[`"]?\s+/i
const DROP_COLUMN_RE = /^ALTER TABLE\s+[`"]?(\w+)[`"]?\s+DROP COLUMN\s+[`"]?(\w+)[`"]?\s*;?$/i
// https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/expo-sqlite/migrator.ts
async function readMigrationFiles({
journal,
@@ -60,8 +77,11 @@ async function readMigrationFiles({
}
// https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-proxy/migrator.ts
export async function migrate<TSchema extends Record<string, unknown>>(
db: SqliteRemoteDatabase<TSchema>,
export async function migrate<_TSchema extends Record<string, unknown>>(
db: {
run: (query: SQL) => MaybePromise<unknown>
values: <TResult extends unknown[]>(query: SQL) => MaybePromise<TResult[]>
},
config: MigrationConfig,
) {
const migrations = await readMigrationFiles(config)
@@ -96,3 +116,74 @@ export async function migrate<TSchema extends Record<string, unknown>>(
await db.run(sql.raw(query))
}
}
function getTableColumns(db: SQLiteMigrationDatabase, tableName: string): Set<string> {
const escapedTableName = tableName.replaceAll("`", "``")
const columns = db.getAllSync<SQLiteColumnInfo>(`PRAGMA table_info(\`${escapedTableName}\`)`)
return new Set(columns.map((column) => column.name))
}
function shouldSkipMigrationQuery(db: SQLiteMigrationDatabase, query: string): boolean {
const addColumnMatch = query.match(ADD_COLUMN_RE)
if (addColumnMatch) {
const tableName = addColumnMatch[1]
const columnName = addColumnMatch[2]
if (!tableName || !columnName) {
return false
}
const columns = getTableColumns(db, tableName)
return columns.has(columnName)
}
const dropColumnMatch = query.match(DROP_COLUMN_RE)
if (dropColumnMatch) {
const tableName = dropColumnMatch[1]
const columnName = dropColumnMatch[2]
if (!tableName || !columnName) {
return false
}
const columns = getTableColumns(db, tableName)
return !columns.has(columnName)
}
return false
}
export async function migrateExpoSQLite(db: SQLiteMigrationDatabase, config: MigrationConfig) {
const migrations = await readMigrationFiles(config)
db.execSync(`
CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (
id SERIAL PRIMARY KEY,
hash text NOT NULL,
created_at numeric
);
`)
const dbMigrations = db.getAllSync<SQLiteMigrationRow>(
`SELECT id, hash, created_at FROM "__drizzle_migrations" ORDER BY created_at DESC LIMIT 1`,
)
const lastDbMigration = dbMigrations[0] ?? undefined
for (const migration of migrations) {
if (lastDbMigration && Number(lastDbMigration.created_at) >= migration.folderMillis) {
continue
}
for (const rawQuery of migration.sql) {
const query = rawQuery.trim()
if (!query) {
continue
}
if (shouldSkipMigrationQuery(db, query)) {
continue
}
db.execSync(query)
}
const escapedHash = migration.hash.replaceAll("'", "''")
db.execSync(
`INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES('${escapedHash}', '${migration.folderMillis}')`,
)
}
}
+1 -1
View File
@@ -45,7 +45,7 @@
},
"devDependencies": {
"@follow/configs": "workspace:*",
"react-native": "0.79.6",
"react-native": "0.81.5",
"vite-tsconfig-paths": "6.1.1"
}
}
@@ -1,27 +1,27 @@
diff --git a/android/src/main/java/com/doublesymmetry/trackplayer/module/MusicModule.kt b/android/src/main/java/com/doublesymmetry/trackplayer/module/MusicModule.kt
index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..5f434a6931977d4b56d359295d53ef024c5984a6 100644
index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..cde697e28b1a098cfc654ebe5c7825f26bf2397e 100644
--- a/android/src/main/java/com/doublesymmetry/trackplayer/module/MusicModule.kt
+++ b/android/src/main/java/com/doublesymmetry/trackplayer/module/MusicModule.kt
@@ -251,8 +251,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
@ReactMethod
- fun updateOptions(data: ReadableMap?, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun updateOptions(data: ReadableMap?, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
val options = Arguments.toBundle(data)
@@ -264,14 +264,14 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
@ReactMethod
- fun add(data: ReadableArray?, insertBeforeIndex: Int, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun add(data: ReadableArray?, insertBeforeIndex: Int, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
try {
val tracks = readableArrayToTrackList(data);
if (insertBeforeIndex < -1 || insertBeforeIndex > musicService.tracks.size) {
@@ -33,7 +33,7 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..5f434a6931977d4b56d359295d53ef02
musicService.add(
@@ -285,11 +285,11 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
@ReactMethod
- fun load(data: ReadableMap?, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
@@ -48,7 +48,7 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..5f434a6931977d4b56d359295d53ef02
if (bundle is Bundle) {
@@ -301,15 +301,15 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
@ReactMethod
- fun move(fromIndex: Int, toIndex: Int, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
@@ -57,7 +57,7 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..5f434a6931977d4b56d359295d53ef02
musicService.move(fromIndex, toIndex)
callback.resolve(null)
}
@ReactMethod
- fun remove(data: ReadableArray?, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
@@ -76,262 +76,265 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..5f434a6931977d4b56d359295d53ef02
indexes.add(index)
}
@@ -332,8 +332,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
@ReactMethod
fun updateMetadataForTrack(index: Int, map: ReadableMap?, callback: Promise) =
- scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
if (index < 0 || index >= musicService.tracks.size) {
callback.reject("index_out_of_bounds", "The index is out of bounds")
@@ -348,8 +348,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
@ReactMethod
- fun updateNowPlayingMetadata(map: ReadableMap?, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun updateNowPlayingMetadata(map: ReadableMap?, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
if (musicService.tracks.isEmpty())
callback.reject("no_current_item", "There is no current item in the player")
@@ -364,8 +364,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
@ReactMethod
- fun clearNowPlayingMetadata(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun clearNowPlayingMetadata(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
if (musicService.tracks.isEmpty())
callback.reject("no_current_item", "There is no current item in the player")
@@ -375,16 +375,16 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
@ReactMethod
- fun removeUpcomingTracks(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun removeUpcomingTracks(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.removeUpcomingTracks()
callback.resolve(null)
}
@ReactMethod
- fun skip(index: Int, initialTime: Float, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun skip(index: Int, initialTime: Float, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.skip(index)
@@ -396,8 +396,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
@ReactMethod
- fun skipToNext(initialTime: Float, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun skipToNext(initialTime: Float, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.skipToNext()
@@ -409,8 +409,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
@ReactMethod
- fun skipToPrevious(initialTime: Float, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun skipToPrevious(initialTime: Float, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.skipToPrevious()
@@ -422,8 +422,8 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
@ReactMethod
- fun reset(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun reset(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.stop()
delay(300) // Allow playback to stop
@@ -433,116 +433,116 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
@@ -433,134 +433,134 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
@ReactMethod
- fun play(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun play(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.play()
callback.resolve(null)
}
@ReactMethod
- fun pause(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun pause(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.pause()
callback.resolve(null)
}
@ReactMethod
- fun stop(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun stop(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.stop()
callback.resolve(null)
}
@ReactMethod
- fun seekTo(seconds: Float, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun seekTo(seconds: Float, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.seekTo(seconds)
callback.resolve(null)
}
@ReactMethod
- fun seekBy(offset: Float, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun seekBy(offset: Float, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.seekBy(offset)
callback.resolve(null)
}
@ReactMethod
- fun retry(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun retry(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.retry()
callback.resolve(null)
}
@ReactMethod
- fun setVolume(volume: Float, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun setVolume(volume: Float, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.setVolume(volume)
callback.resolve(null)
}
@ReactMethod
- fun getVolume(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun getVolume(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
callback.resolve(musicService.getVolume())
}
@ReactMethod
- fun setRate(rate: Float, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun setRate(rate: Float, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.setRate(rate)
callback.resolve(null)
}
@ReactMethod
- fun getRate(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun getRate(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
callback.resolve(musicService.getRate())
}
@ReactMethod
- fun setRepeatMode(mode: Int, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun setRepeatMode(mode: Int, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.setRepeatMode(RepeatMode.fromOrdinal(mode))
callback.resolve(null)
}
@ReactMethod
- fun getRepeatMode(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun getRepeatMode(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
callback.resolve(musicService.getRepeatMode().ordinal)
}
@ReactMethod
- fun setPlayWhenReady(playWhenReady: Boolean, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun setPlayWhenReady(playWhenReady: Boolean, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
musicService.playWhenReady = playWhenReady
callback.resolve(null)
}
@ReactMethod
- fun getPlayWhenReady(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun getPlayWhenReady(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
callback.resolve(musicService.playWhenReady)
}
@ReactMethod
- fun getTrack(index: Int, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun getTrack(index: Int, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
if (index >= 0 && index < musicService.tracks.size) {
callback.resolve(Arguments.fromBundle(musicService.tracks[index].originalItem))
@@ -552,15 +552,15 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
- callback.resolve(Arguments.fromBundle(musicService.tracks[index].originalItem))
+ callback.resolve(musicService.tracks[index].originalItem?.let { Arguments.fromBundle(it) })
} else {
callback.resolve(null)
}
}
@ReactMethod
- fun getQueue(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun getQueue(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
callback.resolve(Arguments.fromList(musicService.tracks.map { it.originalItem }))
}
@ReactMethod
- fun setQueue(data: ReadableArray?, callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun setQueue(data: ReadableArray?, callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
try {
musicService.clear()
@@ -572,16 +572,16 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
@@ -572,48 +572,48 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
@ReactMethod
- fun getActiveTrackIndex(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
@@ -341,7 +344,7 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..5f434a6931977d4b56d359295d53ef02
if (musicService.tracks.isEmpty()) null else musicService.getCurrentTrackIndex()
)
}
@ReactMethod
- fun getActiveTrack(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
@@ -349,37 +352,42 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..5f434a6931977d4b56d359295d53ef02
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
callback.resolve(
if (musicService.tracks.isEmpty()) null
else Arguments.fromBundle(
@@ -591,29 +591,29 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
- else Arguments.fromBundle(
- musicService.tracks[musicService.getCurrentTrackIndex()].originalItem
- )
+ else musicService.tracks[musicService.getCurrentTrackIndex()].originalItem?.let {
+ Arguments.fromBundle(it)
+ }
)
}
@ReactMethod
- fun getDuration(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun getDuration(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
callback.resolve(musicService.getDurationInSeconds())
}
@ReactMethod
- fun getBufferedPosition(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun getBufferedPosition(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
callback.resolve(musicService.getBufferedPositionInSeconds())
}
@ReactMethod
- fun getPosition(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
+ fun getPosition(callback: Promise) = launchInScope {
+ if (verifyServiceBoundOrReject(callback)) return@launchInScope
callback.resolve(musicService.getPositionInSeconds())
}
@ReactMethod
- fun getProgress(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
@@ -390,7 +398,7 @@ index b2409a09939164c49c0f7a16bb6d3284e8eab8fb..5f434a6931977d4b56d359295d53ef02
bundle.putDouble("position", musicService.getPositionInSeconds());
@@ -622,8 +622,16 @@ class MusicModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
@ReactMethod
- fun getPlaybackState(callback: Promise) = scope.launch {
- if (verifyServiceBoundOrReject(callback)) return@launch
@@ -412,7 +420,7 @@ index 9d6d869efcece065618d4f2cefdc8c54831af9ed..37f41fd3fcd8dcb7b5b54c0ad3f207dd
--- a/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt
+++ b/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt
@@ -741,9 +741,7 @@ class MusicService : HeadlessJsTaskService() {
@MainThread
private fun emit(event: String, data: Bundle? = null) {
- reactNativeHost.reactInstanceManager.currentReactContext
@@ -420,29 +428,29 @@ index 9d6d869efcece065618d4f2cefdc8c54831af9ed..37f41fd3fcd8dcb7b5b54c0ad3f207dd
- ?.emit(event, data?.let { Arguments.fromBundle(it) })
+ reactContext?.emitDeviceEvent(event, data?.let { Arguments.fromBundle(it) })
}
@MainThread
@@ -751,17 +749,16 @@ class MusicService : HeadlessJsTaskService() {
val payload = Arguments.createArray()
data.forEach { payload.pushMap(Arguments.fromBundle(it)) }
- reactNativeHost.reactInstanceManager.currentReactContext
- ?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
- ?.emit(event, payload)
+ reactContext?.emitDeviceEvent(event, payload)
}
override fun getTaskConfig(intent: Intent?): HeadlessJsTaskConfig {
return HeadlessJsTaskConfig(TASK_KEY, Arguments.createMap(), 0, true)
}
+ // https://github.com/doublesymmetry/react-native-track-player/pull/2451
@MainThread
- override fun onBind(intent: Intent?): IBinder {
+ override fun onBind(intent: Intent): IBinder {
return binder
}
diff --git a/ios/RNTrackPlayer/RNTrackPlayerBridge.m b/ios/RNTrackPlayer/RNTrackPlayerBridge.m
index 7741994191921ed86f7577f7ce589b3939d9dd49..776c09ec0ae450daa4dc9031ccd3ff4baba016d3 100644
--- a/ios/RNTrackPlayer/RNTrackPlayerBridge.m
@@ -450,7 +458,7 @@ index 7741994191921ed86f7577f7ce589b3939d9dd49..776c09ec0ae450daa4dc9031ccd3ff4b
@@ -151,17 +151,4 @@ RCT_EXTERN_METHOD(updateNowPlayingMetadata:(NSDictionary *)metadata
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject);
-RCT_EXTERN_METHOD(getSleepTimerProgress:(RCTPromiseResolveBlock)resolve
- rejecter:(RCTPromiseRejectBlock)reject);
-
+2458 -2896
View File
File diff suppressed because it is too large Load Diff
+10 -7
View File
@@ -42,7 +42,10 @@ onlyBuiltDependencies:
- utf-8-validate
overrides:
"@react-native-menu/menu": 2.0.0
drizzle-orm: 0.45.1
"@electron/node-gyp": 10.2.0-electron.2
"@types/react": 19.1.17
"@floating-ui/core": 1.7.2
"@floating-ui/dom": 1.7.2
"@floating-ui/react": 0.27.14
@@ -51,10 +54,12 @@ overrides:
isarray: npm:@nolyfill/isarray@1.0.44
lan-network@<0.1.7: 0.1.7
nativewind>react-native-css-interop: 0.1.22
react: 19.0.0
react-dom: 19.0.0
react-native-ios-context-menu: 3.1.1
react-native-ios-utilities: 5.1.5
react: 19.1.0
react-dom: 19.1.0
react-native-ios-context-menu: 3.2.1
react-native-ios-utilities: 5.2.0
serialize-error: 2.1.0
global-agent>serialize-error: 7.0.1
patchedDependencies:
"@microflash/remark-callout-directives": patches/@microflash__remark-callout-directives.patch
@@ -65,8 +70,6 @@ patchedDependencies:
daisyui@4.12.24: patches/daisyui@4.12.24.patch
jsonpointer: patches/jsonpointer.patch
re-resizable@6.11.2: patches/re-resizable@6.11.2.patch
react-native-ios-utilities: patches/react-native-ios-utilities.patch
react-native-screens: patches/react-native-screens.patch
react-native-sheet-transitions: patches/react-native-sheet-transitions.patch
react-native-track-player: patches/react-native-track-player.patch
react-native-track-player@4.1.1: patches/react-native-track-player@4.1.1.patch
workbox-precaching: patches/workbox-precaching.patch