Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
324 changes: 162 additions & 162 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,162 +1,162 @@
{
"name": "react-native-vosk",
"version": "2.1.2",
"description": "Speech recognition module for react native using Vosk library",
"types": "lib/typescript/src/index.d.ts",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
"react-native": "src/index.ts",
"files": [
"src",
"lib",
"android",
"ios",
"plugin/build",
"cpp",
"app.plugin.js",
"*.podspec",
"react-native.config.js",
"!ios/build",
"!android/build",
"!android/gradle",
"!android/gradlew",
"!android/gradlew.bat",
"!android/local.properties",
"!**/__tests__",
"!**/__fixtures__",
"!**/__mocks__",
"!**/.*"
],
"scripts": {
"example": "yarn workspace react-native-vosk-example",
"test": "jest",
"typecheck": "tsc",
"lint": "eslint \"**/*.{js,ts,tsx}\"",
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
"prepare": "bob build && tsc --project plugin/tsconfig.json",
"release": "release-it"
},
"keywords": [
"react-native",
"ios",
"android",
"vosk",
"speech-to-text",
"speech-recognition",
"asr",
"offline"
],
"repository": {
"type": "git",
"url": "git+https://github.com/riderodd/react-native-vosk.git"
},
"author": "riderodd <contact@jg-web.site> (https://github.com/riderodd)",
"license": "MIT",
"bugs": {
"url": "https://github.com/riderodd/react-native-vosk/issues"
},
"homepage": "https://github.com/riderodd/react-native-vosk#readme",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"devDependencies": {
"@commitlint/config-conventional": "^19.8.1",
"@eslint/compat": "^1.3.2",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.35.0",
"@evilmartians/lefthook": "^1.12.3",
"@expo/config-plugins": "^54.0.1",
"@react-native-community/cli": "20.0.1",
"@react-native/babel-preset": "0.81.1",
"@react-native/eslint-config": "^0.81.1",
"@release-it/conventional-changelog": "^10.0.1",
"@types/jest": "^29.5.14",
"@types/react": "^19.1.0",
"commitlint": "^19.8.1",
"del-cli": "^6.0.0",
"eslint": "^9.35.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-prettier": "^5.5.4",
"expo-module-scripts": "^5.0.7",
"jest": "^29.7.0",
"prettier": "^3.6.2",
"react": "19.1.0",
"react-native": "0.81.1",
"react-native-builder-bob": "^0.40.13",
"release-it": "^19.0.4",
"turbo": "^2.5.6",
"typescript": "^5.9.2"
},
"peerDependencies": {
"react": "*",
"react-native": "*"
},
"workspaces": [
"example"
],
"packageManager": "yarn@3.8.7+sha512.bbe7e310ff7fd20dc63b111110f96fe18192234bb0d4f10441fa6b85d2b644c8923db8fbe6d7886257ace948440ab1f83325ad02af457a1806cdc97f03d2508e",
"engines": {
"node": ">= 18.0.0"
},
"jest": {
"preset": "react-native",
"modulePathIgnorePatterns": [
"<rootDir>/example/node_modules",
"<rootDir>/lib/"
]
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"release-it": {
"git": {
"commitMessage": "chore: release ${version}",
"tagName": "v${version}"
},
"npm": {
"publish": false
},
"github": {
"release": true
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": {
"name": "angular"
}
}
}
},
"prettier": {
"quoteProps": "consistent",
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
},
"react-native-builder-bob": {
"source": "src",
"output": "lib",
"targets": [
"module",
"commonjs",
"typescript"
]
},
"codegenConfig": {
"name": "VoskSpec",
"type": "modules",
"jsSrcsDir": "src",
"android": {
"javaPackageName": "com.vosk"
}
},
"create-react-native-library": {
"languages": "kotlin-objc",
"type": "turbo-module",
"version": "0.54.2"
}
}
{
"name": "react-native-vosk",
"version": "2.1.3",
"description": "Speech recognition module for react native using Vosk library",
"types": "lib/typescript/src/index.d.ts",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
"react-native": "src/index.ts",
"files": [
"src",
"lib",
"android",
"ios",
"plugin/build",
"cpp",
"app.plugin.js",
"*.podspec",
"react-native.config.js",
"!ios/build",
"!android/build",
"!android/gradle",
"!android/gradlew",
"!android/gradlew.bat",
"!android/local.properties",
"!**/__tests__",
"!**/__fixtures__",
"!**/__mocks__",
"!**/.*"
],
"scripts": {
"example": "yarn workspace react-native-vosk-example",
"test": "jest",
"typecheck": "tsc",
"lint": "eslint \"**/*.{js,ts,tsx}\"",
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
"prepare": "bob build && tsc --project plugin/tsconfig.json",
"release": "release-it"
},
"keywords": [
"react-native",
"ios",
"android",
"vosk",
"speech-to-text",
"speech-recognition",
"asr",
"offline"
],
"repository": {
"type": "git",
"url": "git+https://github.com/riderodd/react-native-vosk.git"
},
"author": "riderodd <contact@jg-web.site> (https://github.com/riderodd)",
"license": "MIT",
"bugs": {
"url": "https://github.com/riderodd/react-native-vosk/issues"
},
"homepage": "https://github.com/riderodd/react-native-vosk#readme",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"devDependencies": {
"@commitlint/config-conventional": "^19.8.1",
"@eslint/compat": "^1.3.2",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.35.0",
"@evilmartians/lefthook": "^1.12.3",
"@expo/config-plugins": "^54.0.1",
"@react-native-community/cli": "20.0.1",
"@react-native/babel-preset": "0.81.1",
"@react-native/eslint-config": "^0.81.1",
"@release-it/conventional-changelog": "^10.0.1",
"@types/jest": "^29.5.14",
"@types/react": "^19.1.0",
"commitlint": "^19.8.1",
"del-cli": "^6.0.0",
"eslint": "^9.35.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-prettier": "^5.5.4",
"expo-module-scripts": "^5.0.7",
"jest": "^29.7.0",
"prettier": "^3.6.2",
"react": "19.1.0",
"react-native": "0.81.1",
"react-native-builder-bob": "^0.40.13",
"release-it": "^19.0.4",
"turbo": "^2.5.6",
"typescript": "^5.9.2"
},
"peerDependencies": {
"react": "*",
"react-native": "*"
},
"workspaces": [
"example"
],
"packageManager": "yarn@3.8.7+sha512.bbe7e310ff7fd20dc63b111110f96fe18192234bb0d4f10441fa6b85d2b644c8923db8fbe6d7886257ace948440ab1f83325ad02af457a1806cdc97f03d2508e",
"engines": {
"node": ">= 18.0.0"
},
"jest": {
"preset": "react-native",
"modulePathIgnorePatterns": [
"<rootDir>/example/node_modules",
"<rootDir>/lib/"
]
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"release-it": {
"git": {
"commitMessage": "chore: release ${version}",
"tagName": "v${version}"
},
"npm": {
"publish": false
},
"github": {
"release": true
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": {
"name": "angular"
}
}
}
},
"prettier": {
"quoteProps": "consistent",
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
},
"react-native-builder-bob": {
"source": "src",
"output": "lib",
"targets": [
"module",
"commonjs",
"typescript"
]
},
"codegenConfig": {
"name": "VoskSpec",
"type": "modules",
"jsSrcsDir": "src",
"android": {
"javaPackageName": "com.vosk"
}
},
"create-react-native-library": {
"languages": "kotlin-objc",
"type": "turbo-module",
"version": "0.54.2"
}
}
29 changes: 11 additions & 18 deletions plugin/src/withVosk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
withXcodeProject,
withGradleProperties,
createRunOncePlugin,
IOSConfig,
} from '@expo/config-plugins';
import fs from 'fs';
import path from 'path';
Expand All @@ -30,32 +31,24 @@ const withVosk: ConfigPlugin<VoskPluginProps | void> = (config, props) => {
if (models.length) {
withXcodeProject(config, (configMod) => {
const project = configMod.modResults;
const iosRoot = configMod.modRequest.platformProjectRoot; // <app>/ios
const iosRoot = configMod.modRequest.projectRoot; // <app>/ios
IOSConfig.XcodeUtils.ensureGroupRecursively(project, 'Resources');

models.forEach((relModelPath: string) => {
const absSource = path.join(
configMod.modRequest.projectRoot,
relModelPath
);
const absSource = path.relative(iosRoot, relModelPath);

Copilot AI Sep 12, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path.relative function returns a relative path from iosRoot to relModelPath, but the variable name absSource suggests it should be an absolute path. This will likely cause the fs.existsSync check on line 39 to fail when relModelPath is already an absolute path. Consider using path.resolve(configMod.modRequest.projectRoot, relModelPath) instead to create a proper absolute path.

Suggested change
const absSource = path.relative(iosRoot, relModelPath);
const absSource = path.resolve(iosRoot, relModelPath);

Copilot uses AI. Check for mistakes.
if (!fs.existsSync(absSource)) {
console.warn(
'[react-native-vosk] iOS model path not found: ' + absSource
);
return;
}
const modelFolderName = path.basename(absSource);
// Destination inside ios folder (copy folder to keep it under version control if needed)
const destFolder = path.join(iosRoot, modelFolderName);
if (!fs.existsSync(destFolder)) {
fs.cpSync(absSource, destFolder, { recursive: true });
}

// Add to Xcode project if not already
const projectRelative = modelFolderName;
const fileRef = project.hasFile(projectRelative);
if (!fileRef) {
project.addResourceFile(projectRelative, { variantGroup: false });
}
IOSConfig.XcodeUtils.addResourceFileToGroup({
filepath: absSource,
groupName: 'Resources',
project,
isBuildFile: true,
verbose: true,
});
});

return configMod;
Expand Down
Loading