node-sword-interface 1.0.43 → 1.0.45

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.
@@ -18,7 +18,7 @@ jobs:
18
18
 
19
19
  build-windows:
20
20
  name: Run Windows build
21
- runs-on: windows-2019
21
+ runs-on: windows-2022
22
22
  env:
23
23
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24
24
  steps:
package/binding.gyp CHANGED
@@ -44,7 +44,7 @@
44
44
  'message': 'Downloading sword-build-win32 artifacts from GitHub ...',
45
45
  'inputs': [],
46
46
  'outputs': ['sword-build-win32'],
47
- 'action': ['call PowerShell.exe -ExecutionPolicy Bypass -File <(module_root_dir)\scripts\get_sword_build_win32.ps1'],
47
+ 'action': ['call', 'PowerShell.exe', '-ExecutionPolicy', 'Bypass', '-File', '<(module_root_dir)/scripts/get_sword_build_win32.ps1'],
48
48
  }
49
49
  ]
50
50
  }]
package/index.js CHANGED
@@ -18,6 +18,10 @@
18
18
 
19
19
  const path = require('path');
20
20
  const nodeSwordInterfaceModule = require('./build/Release/node_sword_interface.node');
21
+ const { Mutex } = require('async-mutex');
22
+
23
+ // Create a mutex instance
24
+ const searchMutex = new Mutex();
21
25
 
22
26
  /**
23
27
  * An object representation of a Bible verse.
@@ -113,7 +117,7 @@ class NodeSwordInterface {
113
117
  * @param {Function} progressCB - Optional callback function that is called on progress events.
114
118
  * @return {Promise}
115
119
  */
116
- updateRepositoryConfig(progressCB=undefined) {
120
+ async updateRepositoryConfig(progressCB=undefined) {
117
121
  return new Promise((resolve, reject) => {
118
122
  if (progressCB === undefined) {
119
123
  progressCB = function(progress) {};
@@ -242,7 +246,7 @@ class NodeSwordInterface {
242
246
  * @param {Function} progressCB - Callback function that is called on progress events.
243
247
  * @return {Promise}
244
248
  */
245
- installModule(moduleCode, progressCB=undefined) {
249
+ async installModule(moduleCode, progressCB=undefined) {
246
250
  if (progressCB === undefined) {
247
251
  progressCB = function(progress) {};
248
252
  }
@@ -273,7 +277,7 @@ class NodeSwordInterface {
273
277
  * @param {String} moduleCode - The module code of the SWORD module that shall be uninstalled.
274
278
  * @return {Promise}
275
279
  */
276
- uninstallModule(moduleCode) {
280
+ async uninstallModule(moduleCode) {
277
281
  return new Promise((resolve, reject) => {
278
282
  this.nativeInterface.uninstallModule(moduleCode, function(uninstallSuccessful) {
279
283
  if (uninstallSuccessful) {
@@ -596,21 +600,27 @@ class NodeSwordInterface {
596
600
  * @param {Boolean} filterOnWordBoundaries - Whether to filter results based on word boundaries.
597
601
  * @return {Promise}
598
602
  */
599
- getModuleSearchResults(moduleCode,
600
- searchTerm,
601
- progressCB = undefined,
602
- searchType = "phrase",
603
- searchScope = "BIBLE",
604
- isCaseSensitive = false,
605
- useExtendedVerseBoundaries = false,
606
- filterOnWordBoundaries = false) {
603
+ async getModuleSearchResults(moduleCode,
604
+ searchTerm,
605
+ progressCB = undefined,
606
+ searchType = "phrase",
607
+ searchScope = "BIBLE",
608
+ isCaseSensitive = false,
609
+ useExtendedVerseBoundaries = false,
610
+ filterOnWordBoundaries = false) {
607
611
 
608
612
  if (progressCB === undefined) {
609
613
  progressCB = function(progress) {};
610
614
  }
611
615
 
612
- return new Promise((resolve, reject) => {
613
- try {
616
+ if (searchMutex.isLocked()) {
617
+ throw new Error("Module search in progress. Wait until it is finished.");
618
+ }
619
+
620
+ const release = await searchMutex.acquire();
621
+
622
+ try {
623
+ return new Promise((resolve, reject) => {
614
624
  this.nativeInterface.getModuleSearchResults(moduleCode,
615
625
  searchTerm,
616
626
  searchType,
@@ -619,11 +629,15 @@ class NodeSwordInterface {
619
629
  useExtendedVerseBoundaries,
620
630
  filterOnWordBoundaries,
621
631
  progressCB,
622
- function(searchResults) { resolve(searchResults); });
623
- } catch (error) {
624
- reject(error);
625
- }
626
- });
632
+ function(searchResults) {
633
+ release();
634
+ resolve(searchResults);
635
+ });
636
+ });
637
+ } catch (error) {
638
+ release();
639
+ throw error;
640
+ }
627
641
  }
628
642
 
629
643
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-sword-interface",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
4
4
  "description": "Javascript (N-API) interface to SWORD library",
5
5
  "keywords": [
6
6
  "C++",
@@ -17,11 +17,13 @@
17
17
  "doc": "jsdoc2md index.js > API.md",
18
18
  "pub": "rm -rf build node_modules sword sword_build test && npm publish ./",
19
19
  "deploy": "scripts/deploy_local.sh",
20
- "postinstall": "node scripts/postinstall.js"
20
+ "postinstall": "node scripts/postinstall.js",
21
+ "test": "jest"
21
22
  },
22
23
  "author": "Tobias Klein",
23
24
  "license": "GPL-2.0+",
24
25
  "dependencies": {
26
+ "async-mutex": "^0.5.0",
25
27
  "glob": "^8.0.3",
26
28
  "node-addon-api": "^8.2.2",
27
29
  "node-html-parser": "^6.1.13"
@@ -31,6 +33,7 @@
31
33
  "url": "git+https://github.com/ezra-bible-app/node-sword-interface.git"
32
34
  },
33
35
  "devDependencies": {
36
+ "jest": "^30.0.5",
34
37
  "jsdoc-to-markdown": "^9.1.1",
35
38
  "node-gyp": "^9.1.0"
36
39
  }
@@ -47,6 +47,10 @@ mkdir -p sword_build
47
47
 
48
48
  SWORD_BUILD_TYPE="Release"
49
49
 
50
+ # Newer CMake versions have removed compatibility with CMake < 3.5.
51
+ # SWORD is configured with CMake minimum 2.6.0, which leads to a build error with newer CMake versions (e.g. 4.0.3).
52
+ export CMAKE_POLICY_VERSION_MINIMUM=3.5
53
+
50
54
  if [ "$1" = "--android" ] ; then
51
55
  git clone https://github.com/karlkleinpaste/biblesync.git
52
56
  git -C biblesync checkout 2.1.0
@@ -57,9 +57,12 @@ if (Test-Path sword-build-win32) {
57
57
  }
58
58
 
59
59
  # --- Download the file to the current location
60
- $OutputPath = "$((Get-Location).Path)\$ZipName"
60
+ $OutputPath = Join-Path -Path (Get-Location).Path -ChildPath $ZipName
61
61
  Invoke-RestMethod -Method Get -Uri $ZipUrl -OutFile $OutputPath -Headers $headers
62
62
 
63
+ Write-Host "OutputPath: $OutputPath"
64
+ Write-Host "ZipUrl: $ZipUrl"
65
+
63
66
  # --- Unzip the zip file and remove it afterwards
64
67
  unzip $OutputPath $((Get-Location).Path)
65
68
  Remove-Item $OutputPath