node-sword-interface 1.0.7 → 1.0.9

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.
@@ -3,15 +3,29 @@ name: node-sword-interface build
3
3
  on: push
4
4
 
5
5
  jobs:
6
- test:
7
- name: Run build
6
+ build-linux:
7
+ name: Run Linux build
8
8
  runs-on: ubuntu-20.04
9
9
  steps:
10
10
  - uses: actions/checkout@v2
11
11
  - uses: actions/setup-node@v2
12
12
  with:
13
- node-version: '12'
13
+ node-version: '14'
14
14
 
15
15
  - run: sudo apt update && sudo apt install -y libcurl4-gnutls-dev
16
16
  - run: npm install
17
+ - run: npm run doc
18
+
19
+ build-windows:
20
+ name: Run Windows build
21
+ runs-on: windows-2019
22
+ env:
23
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - uses: actions/setup-node@v2
27
+ with:
28
+ node-version: '14'
29
+
30
+ - run: npm install --arch=ia32
17
31
  - run: npm run doc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-sword-interface",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Javascript (N-API) interface to SWORD library",
5
5
  "keywords": [
6
6
  "C++",
@@ -31,17 +31,23 @@ $AllProtocols = [System.Net.SecurityProtocolType]'Tls11,Tls12'
31
31
 
32
32
  $headers = @{}
33
33
 
34
- if (Test-Path env:CI) {
35
- $headers = @{
36
- Authorization="Bearer ${$secrets.GITHUB_TOKEN}"
37
- }
38
- }
34
+ $github_token = $env:GITHUB_TOKEN
39
35
 
40
36
  # --- Set the uri for the release
41
37
  $URI = "https://api.github.com/repos/ezra-bible-app/sword-build-win32/releases/tags/v1.8.900-2022-11-06"
42
38
 
39
+ if ($Env:CI -eq "true") {
40
+ Write-Host "GitHub actions build ... using GITHUB_TOKEN for authentication!"
41
+
42
+ $headers = @{
43
+ Authorization="Bearer $github_token"
44
+ ContentType='application/json'
45
+ }
46
+ }
47
+
43
48
  # --- Query the API to get the url of the zip
44
49
  $Response = Invoke-RestMethod -Method Get -Uri $URI -Headers $headers
50
+
45
51
  $ZipName = $Response.assets[0].name
46
52
  $ZipUrl = $Response.assets[0].browser_download_url
47
53
 
@@ -52,7 +58,7 @@ if (Test-Path sword-build-win32) {
52
58
 
53
59
  # --- Download the file to the current location
54
60
  $OutputPath = "$((Get-Location).Path)\$ZipName"
55
- Invoke-RestMethod -Method Get -Uri $ZipUrl -OutFile $OutputPath
61
+ Invoke-RestMethod -Method Get -Uri $ZipUrl -OutFile $OutputPath -Headers $headers
56
62
 
57
63
  # --- Unzip the zip file and remove it afterwards
58
64
  unzip $OutputPath $((Get-Location).Path)
@@ -61,3 +67,5 @@ Remove-Item $OutputPath
61
67
  # --- Rename the extracted folder to a standard name
62
68
  $LibDirName = $ZipName.Replace(".zip", "")
63
69
  Rename-Item -Path $LibDirName -NewName sword-build-win32
70
+
71
+ Write-Host "Download of Windows library artifacts completed!"
@@ -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.getLocalModule(moduleName);
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.getLocalModule(this->_currentModuleName);
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
- this->_mgr = new SWMgr(this->_fileSystemHelper.getUserSwordDir().c_str(),
47
- true, // autoload
48
- 0, // filterMgr
49
- false, // multiMod
50
- false); // augmentHome
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
- this->_mgr->augmentModules("/sdcard/sword");
78
+ swMgr->augmentModules("/sdcard/sword");
56
79
  }
57
80
  } else {
58
81
  #ifdef _WIN32
59
- this->_mgr = new SWMgr(this->_fileSystemHelper.getUserSwordDir().c_str());
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
- this->_mgr = new SWMgr();
88
+ swMgr = new SWMgr();
66
89
 
67
90
  stringstream appSupport;
68
91
  appSupport << string(getenv("HOME")) << "/Library/Application Support/Sword";
69
- this->_mgr->augmentModules(appSupport.str().c_str());
92
+ swMgr->augmentModules(appSupport.str().c_str());
70
93
  #else
71
- this->_mgr = new SWMgr();
94
+ swMgr = new SWMgr();
72
95
  #endif
73
96
  }
74
97
 
75
- this->_mgr->setGlobalOption("Headings", "On");
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
- sword::SWMgr* ModuleStore::getSwMgr()
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