- WellNuoLite: облегчённая версия для модерации Apple - Обновлены chat и voice tabs - Добавлены TTS модели и сервисы - Обновлены зависимости
66 lines
1.9 KiB
JavaScript
66 lines
1.9 KiB
JavaScript
/**
|
|
* Expo Config Plugin to bundle TTS model files for iOS
|
|
* Copies the Piper model files into the iOS app bundle
|
|
*/
|
|
const { withXcodeProject, IOSConfig } = require('@expo/config-plugins');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
const withTTSModels = (config) => {
|
|
return withXcodeProject(config, async (config) => {
|
|
const projectRoot = config.modRequest.projectRoot;
|
|
const xcodeProject = config.modResults;
|
|
|
|
// Source model directory
|
|
const modelSrcDir = path.join(projectRoot, 'assets', 'tts-models');
|
|
|
|
if (!fs.existsSync(modelSrcDir)) {
|
|
console.warn('[withTTSModels] Model directory not found:', modelSrcDir);
|
|
return config;
|
|
}
|
|
|
|
// Get the project
|
|
const project = xcodeProject;
|
|
|
|
// Find the main group
|
|
const mainGroupId = project.getFirstProject().firstProject.mainGroup;
|
|
const mainGroup = project.getPBXGroupByKey(mainGroupId);
|
|
|
|
// Create a Resources group if it doesn't exist
|
|
let resourcesGroupId = null;
|
|
const groups = project.hash.project.objects.PBXGroup;
|
|
|
|
for (const key in groups) {
|
|
if (groups[key].name === 'Resources' && !key.includes('_comment')) {
|
|
resourcesGroupId = key;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!resourcesGroupId) {
|
|
resourcesGroupId = project.pbxCreateGroup('Resources', 'Resources');
|
|
project.addToPbxGroup(resourcesGroupId, mainGroupId);
|
|
}
|
|
|
|
// Add tts-models folder as a folder reference
|
|
const modelFolderName = 'tts-models';
|
|
const modelFolderPath = path.relative(
|
|
path.join(projectRoot, 'ios', 'WellNuo'),
|
|
modelSrcDir
|
|
);
|
|
|
|
// Add the folder reference to the project
|
|
project.addResourceFile(
|
|
modelSrcDir,
|
|
{ target: project.getFirstTarget().uuid },
|
|
resourcesGroupId
|
|
);
|
|
|
|
console.log('[withTTSModels] Added TTS models to iOS bundle');
|
|
|
|
return config;
|
|
});
|
|
};
|
|
|
|
module.exports = withTTSModels;
|