node-sword-interface 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CMakeLists.txt
CHANGED
|
@@ -14,17 +14,12 @@ include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_SOURCE_DIR}/node_modules/no
|
|
|
14
14
|
|
|
15
15
|
link_directories(${CMAKE_SOURCE_DIR}/sword_build)
|
|
16
16
|
|
|
17
|
-
# ICU Components Reference:
|
|
18
|
-
# https://cmake.org/cmake/help/latest/module/FindICU.html
|
|
19
|
-
# ICU components = data, i18n, io, le, lx, test, tu and uc.
|
|
20
|
-
|
|
21
|
-
find_package(ICU COMPONENTS uc i18n data REQUIRED)
|
|
22
17
|
find_package(ZLIB REQUIRED)
|
|
23
18
|
find_package(CURL REQUIRED)
|
|
24
19
|
find_package(BZip2 REQUIRED)
|
|
25
20
|
|
|
26
21
|
set(SWORD_LIBRARY_NAME "libsword.a")
|
|
27
|
-
set(DEPENDENT_LIBS
|
|
22
|
+
set(DEPENDENT_LIBS ${ZLIB_LIBRARIES} ${CURL_LIBRARIES} ${BZIP2_LIBRARIES})
|
|
28
23
|
|
|
29
24
|
if (UNIX)
|
|
30
25
|
set(DEPENDENT_LIBS ${DEPENDENT_LIBS} pthread)
|
package/binding.gyp
CHANGED
|
@@ -82,8 +82,7 @@
|
|
|
82
82
|
],
|
|
83
83
|
"libraries": [
|
|
84
84
|
'<!@(./scripts/get_sword_library.sh \"../sword_build/libsword.a\")',
|
|
85
|
-
'<!@(pkg-config --libs libcurl)'
|
|
86
|
-
'<!@(pkg-config --libs icu-uc icu-io)'
|
|
85
|
+
'<!@(pkg-config --libs libcurl)'
|
|
87
86
|
],
|
|
88
87
|
"dependencies": [
|
|
89
88
|
"<!(node -p \"require('node-addon-api').gyp\")",
|
package/package.json
CHANGED
package/scripts/build_sword.sh
CHANGED
|
@@ -75,7 +75,9 @@ else
|
|
|
75
75
|
# macOS & Linux
|
|
76
76
|
|
|
77
77
|
cd sword_build
|
|
78
|
-
cmake -DLIBSWORD_LIBRARY_TYPE=Static -DCMAKE_CXX_STANDARD=11 -DCMAKE_BUILD_TYPE=Release
|
|
78
|
+
cmake -DLIBSWORD_LIBRARY_TYPE=Static -DCMAKE_CXX_STANDARD=11 -DCMAKE_BUILD_TYPE=Release \
|
|
79
|
+
-DCMAKE_DISABLE_FIND_PACKAGE_ICU=TRUE \
|
|
80
|
+
../sword
|
|
79
81
|
fi
|
|
80
82
|
|
|
81
83
|
make -j4 sword_static
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
#include <algorithm>
|
|
24
24
|
|
|
25
25
|
// sword includes
|
|
26
|
+
#include <swmgr.h>
|
|
26
27
|
#include <swmodule.h>
|
|
27
28
|
#include <versekey.h>
|
|
28
29
|
|
|
@@ -100,7 +101,7 @@ vector<Verse> ModuleSearch::getModuleSearchResults(string moduleName,
|
|
|
100
101
|
bool useExtendedVerseBoundaries)
|
|
101
102
|
{
|
|
102
103
|
this->_currentModuleName = moduleName;
|
|
103
|
-
SWModule* module = this->_moduleStore.
|
|
104
|
+
SWModule* module = this->_moduleStore.getSearchSwMgr()->getModule(moduleName.c_str());
|
|
104
105
|
ListKey listKey;
|
|
105
106
|
SWKey* scope = 0;
|
|
106
107
|
int flags = 0;
|
|
@@ -196,7 +197,7 @@ vector<Verse> ModuleSearch::getModuleSearchResults(string moduleName,
|
|
|
196
197
|
void ModuleSearch::terminate()
|
|
197
198
|
{
|
|
198
199
|
if (this->_currentModuleName != "") {
|
|
199
|
-
SWModule* module = this->_moduleStore.
|
|
200
|
+
SWModule* module = this->_moduleStore.getSearchSwMgr()->getModule(this->_currentModuleName.c_str());
|
|
200
201
|
module->terminateSearch = true;
|
|
201
202
|
this->_currentModuleName = "";
|
|
202
203
|
}
|
|
@@ -36,60 +36,78 @@ ModuleStore::ModuleStore(string customHomeDir)
|
|
|
36
36
|
{
|
|
37
37
|
this->_fileSystemHelper.setCustomHomeDir(customHomeDir);
|
|
38
38
|
this->_fileSystemHelper.createBasicDirectories();
|
|
39
|
+
this->customHomeDir = customHomeDir;
|
|
39
40
|
|
|
41
|
+
this->_mgr = this->createSWMgr();
|
|
42
|
+
this->_mgr->setGlobalOption("Headings", "On");
|
|
43
|
+
|
|
44
|
+
// After creating the searchMgr we turn off features that we are not interested in when searching
|
|
45
|
+
this->_searchMgr = this->createSWMgr();
|
|
46
|
+
this->_searchMgr->setGlobalOption("Headings", "Off");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
ModuleStore::~ModuleStore()
|
|
50
|
+
{
|
|
51
|
+
if (this->_mgr != 0) {
|
|
52
|
+
delete this->_mgr;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (this->_searchMgr != 0) {
|
|
56
|
+
delete this->_searchMgr;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
SWMgr* ModuleStore::createSWMgr()
|
|
61
|
+
{
|
|
62
|
+
SWMgr* swMgr = 0;
|
|
40
63
|
bool isAndroid = false;
|
|
41
64
|
#if defined(__ANDROID__)
|
|
42
65
|
isAndroid = true;
|
|
43
66
|
#endif
|
|
44
67
|
|
|
45
68
|
if (customHomeDir != "" || isAndroid) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
69
|
+
swMgr = new SWMgr(this->_fileSystemHelper.getUserSwordDir().c_str(),
|
|
70
|
+
true, // autoload
|
|
71
|
+
0, // filterMgr
|
|
72
|
+
false, // multiMod
|
|
73
|
+
false); // augmentHome
|
|
51
74
|
|
|
52
75
|
if (isAndroid) {
|
|
53
76
|
// Also consider the originally used path for Android, which does not work anymore from Android 11, but is still relevant
|
|
54
77
|
// for existing translations on Android versions < 11.
|
|
55
|
-
|
|
78
|
+
swMgr->augmentModules("/sdcard/sword");
|
|
56
79
|
}
|
|
57
80
|
} else {
|
|
58
81
|
#ifdef _WIN32
|
|
59
|
-
|
|
82
|
+
swMgr = new SWMgr(this->_fileSystemHelper.getUserSwordDir().c_str());
|
|
60
83
|
|
|
61
84
|
// This has been disabled because it lead to a crash.
|
|
62
85
|
// We're keeping it here for now in case this becomes relevant again.
|
|
63
86
|
// this->_mgr->augmentModules(this->_fileSystemHelper.getSystemSwordDir().c_str());
|
|
64
87
|
#elif defined(__APPLE__)
|
|
65
|
-
|
|
88
|
+
swMgr = new SWMgr();
|
|
66
89
|
|
|
67
90
|
stringstream appSupport;
|
|
68
91
|
appSupport << string(getenv("HOME")) << "/Library/Application Support/Sword";
|
|
69
|
-
|
|
92
|
+
swMgr->augmentModules(appSupport.str().c_str());
|
|
70
93
|
#else
|
|
71
|
-
|
|
94
|
+
swMgr = new SWMgr();
|
|
72
95
|
#endif
|
|
73
96
|
}
|
|
74
97
|
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
ModuleStore::~ModuleStore()
|
|
79
|
-
{
|
|
80
|
-
if (this->_mgr != 0) {
|
|
81
|
-
delete this->_mgr;
|
|
82
|
-
}
|
|
98
|
+
return swMgr;
|
|
83
99
|
}
|
|
84
100
|
|
|
85
101
|
void ModuleStore::refreshMgr()
|
|
86
102
|
{
|
|
87
103
|
this->_mgr->augmentModules(this->_fileSystemHelper.getUserSwordDir().c_str());
|
|
104
|
+
this->_searchMgr->augmentModules(this->_fileSystemHelper.getUserSwordDir().c_str());
|
|
88
105
|
}
|
|
89
106
|
|
|
90
107
|
void ModuleStore::deleteModule(string moduleName)
|
|
91
108
|
{
|
|
92
109
|
this->_mgr->deleteModule(moduleName.c_str());
|
|
110
|
+
this->_searchMgr->deleteModule(moduleName.c_str());
|
|
93
111
|
}
|
|
94
112
|
|
|
95
113
|
SWModule* ModuleStore::getLocalModule(string moduleName)
|
|
@@ -189,7 +207,12 @@ string ModuleStore::getModuleDataPath(sword::SWModule* module)
|
|
|
189
207
|
return dataPath;
|
|
190
208
|
}
|
|
191
209
|
|
|
192
|
-
|
|
210
|
+
SWMgr* ModuleStore::getSwMgr()
|
|
193
211
|
{
|
|
194
212
|
return this->_mgr;
|
|
195
213
|
}
|
|
214
|
+
|
|
215
|
+
SWMgr* ModuleStore::getSearchSwMgr()
|
|
216
|
+
{
|
|
217
|
+
return this->_searchMgr;
|
|
218
|
+
}
|
|
@@ -35,6 +35,7 @@ public:
|
|
|
35
35
|
ModuleStore(std::string customHomeDir="");
|
|
36
36
|
virtual ~ModuleStore();
|
|
37
37
|
|
|
38
|
+
sword::SWMgr* createSWMgr();
|
|
38
39
|
sword::SWModule* getLocalModule(std::string moduleName);
|
|
39
40
|
std::vector<sword::SWModule*> getAllLocalModules(ModuleType moduleType=ModuleType::bible);
|
|
40
41
|
|
|
@@ -46,10 +47,13 @@ public:
|
|
|
46
47
|
void deleteModule(std::string moduleName);
|
|
47
48
|
|
|
48
49
|
sword::SWMgr* getSwMgr();
|
|
50
|
+
sword::SWMgr* getSearchSwMgr();
|
|
49
51
|
|
|
50
52
|
private:
|
|
53
|
+
std::string customHomeDir;
|
|
51
54
|
std::vector<std::string> getModuleLanguages(ModuleType moduleType=ModuleType::bible);
|
|
52
55
|
sword::SWMgr* _mgr = 0;
|
|
56
|
+
sword::SWMgr* _searchMgr = 0;
|
|
53
57
|
FileSystemHelper _fileSystemHelper;
|
|
54
58
|
};
|
|
55
59
|
|