node-sword-interface 1.0.104 → 1.0.106

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.
Files changed (57) hide show
  1. package/CMakeLists.txt +3 -2
  2. package/binding.gyp +7 -2
  3. package/examples/install_kjv.js +4 -4
  4. package/examples/print_kjv_matthew.js +7 -7
  5. package/index.js +2 -2
  6. package/package.json +1 -1
  7. package/scripts/benchmark.js +50 -0
  8. package/scripts/build_sword.sh +1 -1
  9. package/scripts/get_sword_build_win32.js +1 -1
  10. package/scripts/get_sword_include_path.sh +1 -1
  11. package/scripts/get_sword_library.sh +1 -1
  12. package/scripts/ios_framework_postbuild.sh +18 -0
  13. package/scripts/postinstall.js +1 -1
  14. package/src/{sword_backend → lib}/unzip/unzip.c +3 -0
  15. package/src/napi_module/api_lock.cpp +1 -1
  16. package/src/napi_module/api_lock.hpp +1 -1
  17. package/src/napi_module/binding.cpp +1 -1
  18. package/src/napi_module/install_module_worker.cpp +1 -1
  19. package/src/napi_module/install_module_worker.hpp +2 -2
  20. package/src/napi_module/module_search_worker.cpp +1 -1
  21. package/src/napi_module/module_search_worker.hpp +1 -1
  22. package/src/napi_module/napi_sword_helper.cpp +1 -1
  23. package/src/napi_module/napi_sword_helper.hpp +1 -1
  24. package/src/napi_module/node_sword_interface.cpp +1 -1
  25. package/src/napi_module/node_sword_interface.hpp +1 -1
  26. package/src/napi_module/worker.hpp +1 -1
  27. package/src/sword_backend/common_defs.hpp +1 -1
  28. package/src/sword_backend/dict_helper.cpp +1 -1
  29. package/src/sword_backend/dict_helper.hpp +1 -1
  30. package/src/sword_backend/file_system_helper.cpp +10 -2
  31. package/src/sword_backend/file_system_helper.hpp +1 -1
  32. package/src/sword_backend/module_helper.cpp +1 -1
  33. package/src/sword_backend/module_helper.hpp +1 -1
  34. package/src/sword_backend/module_installer.cpp +1 -1
  35. package/src/sword_backend/module_installer.hpp +1 -1
  36. package/src/sword_backend/module_search.cpp +1 -1
  37. package/src/sword_backend/module_search.hpp +1 -1
  38. package/src/sword_backend/module_store.cpp +1 -1
  39. package/src/sword_backend/module_store.hpp +1 -1
  40. package/src/sword_backend/mutex.cpp +1 -1
  41. package/src/sword_backend/mutex.hpp +1 -1
  42. package/src/sword_backend/percentage_calc.hpp +1 -1
  43. package/src/sword_backend/repository_interface.cpp +1 -1
  44. package/src/sword_backend/repository_interface.hpp +1 -1
  45. package/src/sword_backend/string_helper.cpp +1 -1
  46. package/src/sword_backend/string_helper.hpp +1 -1
  47. package/src/sword_backend/strongs_entry.cpp +1 -1
  48. package/src/sword_backend/strongs_entry.hpp +1 -1
  49. package/src/sword_backend/sword_status_reporter.cpp +1 -1
  50. package/src/sword_backend/sword_status_reporter.hpp +1 -1
  51. package/src/sword_backend/sword_translation_helper.hpp +1 -1
  52. package/src/sword_backend/text_processor.cpp +143 -15
  53. package/src/sword_backend/text_processor.hpp +10 -1
  54. package/.github/dependabot.yml +0 -12
  55. /package/src/{sword_backend → lib}/unzip/ioapi.c +0 -0
  56. /package/src/{sword_backend → lib}/unzip/ioapi.h +0 -0
  57. /package/src/{sword_backend → lib}/unzip/unzip.h +0 -0
package/CMakeLists.txt CHANGED
@@ -5,6 +5,7 @@ project(node_sword_cli)
5
5
  set(CMAKE_CXX_FLAGS "-g -rdynamic -std=c++11")
6
6
 
7
7
  include_directories(${CMAKE_SOURCE_DIR}/src/sword_backend)
8
+ include_directories(${CMAKE_SOURCE_DIR}/src/lib)
8
9
 
9
10
  include_directories(${CMAKE_SOURCE_DIR}/sword/include)
10
11
 
@@ -46,8 +47,8 @@ ${CMAKE_SOURCE_DIR}/src/sword_backend/module_installer.cpp
46
47
  ${CMAKE_SOURCE_DIR}/src/sword_backend/text_processor.cpp
47
48
  ${CMAKE_SOURCE_DIR}/src/sword_backend/module_search.cpp
48
49
  ${CMAKE_SOURCE_DIR}/src/sword_backend/mutex.cpp
49
- ${CMAKE_SOURCE_DIR}/src/sword_backend/unzip/ioapi.c
50
- ${CMAKE_SOURCE_DIR}/src/sword_backend/unzip/unzip.c
50
+ ${CMAKE_SOURCE_DIR}/src/lib/unzip/ioapi.c
51
+ ${CMAKE_SOURCE_DIR}/src/lib/unzip/unzip.c
51
52
  )
52
53
 
53
54
  add_executable(node_sword_cli ${SOURCES})
package/binding.gyp CHANGED
@@ -88,8 +88,8 @@
88
88
  "src/sword_backend/module_installer.cpp",
89
89
  "src/sword_backend/sword_status_reporter.cpp",
90
90
  "src/sword_backend/text_processor.cpp",
91
- "src/sword_backend/unzip/unzip.c",
92
- "src/sword_backend/unzip/ioapi.c",
91
+ "src/lib/unzip/unzip.c",
92
+ "src/lib/unzip/ioapi.c",
93
93
  "src/napi_module/install_module_worker.cpp",
94
94
  "src/napi_module/module_search_worker.cpp",
95
95
  "src/napi_module/napi_sword_helper.cpp",
@@ -102,6 +102,7 @@
102
102
  "type": "shared_library",
103
103
  'include_dirs': [
104
104
  "<(module_root_dir)/src/sword_backend",
105
+ "<(module_root_dir)/src/lib",
105
106
  "<!@(node -p \"require('node-addon-api').include\")",
106
107
  "<!@(./scripts/get_sword_include_path.sh)"
107
108
  ],
@@ -131,6 +132,7 @@
131
132
  ["OS=='linux'", {
132
133
  'include_dirs': [
133
134
  "<(module_root_dir)/src/sword_backend",
135
+ "<(module_root_dir)/src/lib",
134
136
  "<!@(node -p \"require('node-addon-api').include\")",
135
137
  "<!@(./scripts/get_sword_include_path.sh)"
136
138
  ],
@@ -146,6 +148,7 @@
146
148
  ["OS=='android'", {
147
149
  'include_dirs': [
148
150
  "<(module_root_dir)/src/sword_backend",
151
+ "<(module_root_dir)/src/lib",
149
152
  "<!@(node -p \"require('node-addon-api').include\")",
150
153
  "<!@(./scripts/get_sword_include_path.sh)"
151
154
  ],
@@ -163,6 +166,7 @@
163
166
  ["OS=='mac'", {
164
167
  'include_dirs': [
165
168
  "<(module_root_dir)/src/sword_backend",
169
+ "<(module_root_dir)/src/lib",
166
170
  "<!@(node -p \"require('node-addon-api').include\")",
167
171
  "<!@(./scripts/get_sword_include_path.sh)"
168
172
  ],
@@ -178,6 +182,7 @@
178
182
  ["OS=='win'", {
179
183
  'include_dirs': [
180
184
  "<(module_root_dir)/src/sword_backend",
185
+ "<(module_root_dir)/src/lib",
181
186
  "<!@(node -p \"require('node-addon-api').include\")",
182
187
  "<(module_root_dir)/build/sword-build-win32/include"
183
188
  ],
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -19,15 +19,15 @@
19
19
  // Note that this uses the sources within this directory structure.
20
20
  // After installing via NPM you would use this require call: require('node-sword-interface');
21
21
  const NodeSwordInterface = require('../index.js');
22
- var interface = new NodeSwordInterface();
22
+ const nsi = new NodeSwordInterface();
23
23
 
24
24
  async function installKJV() {
25
25
  console.log("Updating repository configuration ...");
26
- await interface.updateRepositoryConfig();
26
+ await nsi.updateRepositoryConfig();
27
27
 
28
28
  console.log("Installing King James module");
29
29
  // Install the King James Version (Uses the internet connection to download and install the module)
30
- await interface.installModule('CrossWire', 'KJV');
30
+ await nsi.installModule('CrossWire', 'KJV');
31
31
  }
32
32
 
33
33
  installKJV().then(() => {
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -19,23 +19,23 @@
19
19
  // Note that this uses the sources within this directory structure.
20
20
  // After installing via NPM you would use this require call: require('node-sword-interface');
21
21
  const NodeSwordInterface = require('../index.js');
22
- var interface = new NodeSwordInterface();
22
+ const nsi = new NodeSwordInterface();
23
23
 
24
24
  function printKjvInfo() {
25
25
  // Print some module information
26
- var kjv = interface.getLocalModule('KJV');
26
+ const kjv = nsi.getLocalModule('KJV');
27
27
  console.log(kjv.description);
28
28
  console.log(kjv.about);
29
29
  }
30
30
 
31
31
  function printMatthew() {
32
32
  // Get the verses of the Gospel of Matthew
33
- var verses = interface.getBookText('KJV', 'Mat');
33
+ const verses = nsi.getBookText('KJV', 'Mat');
34
34
 
35
35
  // Do something with the verses
36
- for (var i = 0; i < verses.length; i++) {
37
- var currentVerse = verses[i];
38
- var verseReference = currentVerse.chapter + ':' + currentVerse.verseNr;
36
+ for (let i = 0; i < verses.length; i++) {
37
+ const currentVerse = verses[i];
38
+ const verseReference = currentVerse.chapter + ':' + currentVerse.verseNr;
39
39
  console.log(verseReference + ' ' + currentVerse.content);
40
40
  }
41
41
  }
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -112,7 +112,7 @@ class NodeSwordInterface {
112
112
  * @param {Number} timeoutMillis - Optional timeout in milliseconds for repository operations (default: 20000).
113
113
  */
114
114
  constructor(customHomeDir=undefined, localesBasePath=__dirname, timeoutMillis=20000) {
115
- var localesDir = path.join(localesBasePath, './locales.d');
115
+ const localesDir = path.join(localesBasePath, './locales.d');
116
116
  this.nativeInterface = new nodeSwordInterfaceModule.NodeSwordInterface(customHomeDir, localesDir, timeoutMillis);
117
117
  }
118
118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-sword-interface",
3
- "version": "1.0.104",
3
+ "version": "1.0.106",
4
4
  "description": "Javascript (N-API) interface to SWORD library",
5
5
  "keywords": [
6
6
  "C++",
@@ -0,0 +1,50 @@
1
+ // Benchmark script for performance profiling
2
+ // Run with: node --prof scripts/benchmark.js
3
+ // Then process: node --prof-process isolate-*.log > profile.txt
4
+ const NodeSwordInterface = require('../index.js');
5
+
6
+ async function runBenchmark() {
7
+ const nsi = new NodeSwordInterface();
8
+
9
+ // Check if KJV is installed
10
+ const localModules = nsi.getAllLocalModules();
11
+ const kjvInstalled = localModules.some(m => m.name === 'KJV');
12
+
13
+ if (!kjvInstalled) {
14
+ console.log('KJV module is not installed. Please install it first.');
15
+ console.log('Available modules:', localModules.map(m => m.name).join(', '));
16
+ return;
17
+ }
18
+
19
+ nsi.enableMarkup();
20
+
21
+ const iterations = 3;
22
+ const times = [];
23
+ let verseCount = 0;
24
+
25
+ console.log(`Running ${iterations} iterations of getBibleText("KJV") with markup enabled...`);
26
+ console.log('Use --prof flag to generate V8 profiler output\n');
27
+
28
+ for (let i = 0; i < iterations; i++) {
29
+ const start = process.hrtime.bigint();
30
+ const verses = nsi.getBibleText('KJV');
31
+ const end = process.hrtime.bigint();
32
+
33
+ const durationMs = Number(end - start) / 1_000_000;
34
+ times.push(durationMs);
35
+ verseCount = verses.length;
36
+
37
+ console.log(` Iteration ${i + 1}: ${durationMs.toFixed(2)} ms`);
38
+ }
39
+
40
+ const avg = times.reduce((a, b) => a + b, 0) / times.length;
41
+ const min = Math.min(...times);
42
+ const max = Math.max(...times);
43
+
44
+ console.log('\nBenchmark complete!');
45
+ console.log(` Verses processed: ${verseCount}`);
46
+ console.log(` Average time: ${avg.toFixed(2)} ms`);
47
+ console.log(` Min: ${min.toFixed(2)} ms, Max: ${max.toFixed(2)} ms`);
48
+ }
49
+
50
+ runBenchmark().catch(console.error);
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is part of node-sword-interface.
4
4
  #
5
- # Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
5
+ # Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
6
6
  #
7
7
  # node-sword-interface is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  /* This file is part of node-sword-interface.
3
3
 
4
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
4
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
5
5
 
6
6
  node-sword-interface is free software: you can redistribute it and/or modify
7
7
  it under the terms of the GNU General Public License as published by
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is part of node-sword-interface.
4
4
  #
5
- # Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
5
+ # Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
6
6
  #
7
7
  # node-sword-interface is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is part of node-sword-interface.
4
4
  #
5
- # Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
5
+ # Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
6
6
  #
7
7
  # node-sword-interface is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -1,4 +1,22 @@
1
1
  #!/bin/sh
2
+ # This file is part of node-sword-interface.
3
+ #
4
+ # Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
5
+ #
6
+ # node-sword-interface is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 2 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # node-sword-interface is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
+ # See the GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with node-sword-interface. See the file COPYING.
18
+ # If not, see <http://www.gnu.org/licenses/>.
19
+
2
20
  set -e
3
21
 
4
22
  # Accept arguments from GYP, or fallback to Xcode env vars
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1246,6 +1246,9 @@ extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCas
1246
1246
  if (file==NULL)
1247
1247
  return UNZ_PARAMERROR;
1248
1248
 
1249
+ if (szFileName==NULL)
1250
+ return UNZ_PARAMERROR;
1251
+
1249
1252
  if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
1250
1253
  return UNZ_PARAMERROR;
1251
1254
 
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -47,8 +47,8 @@ public:
47
47
  private:
48
48
  ModuleInstaller& _moduleInstaller;
49
49
  int _result;
50
- std::string _moduleName;
51
50
  std::string _repoName;
51
+ std::string _moduleName;
52
52
  long _completedBytes = 0;
53
53
  long _totalBytes = 0;
54
54
  int _totalPercent = 0;
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -437,6 +437,15 @@ bool FileSystemHelper::unZip(std::string filePath, std::string destPath)
437
437
 
438
438
  if (err != UNZ_OK) break;
439
439
 
440
+ // Ensure null-termination for safety
441
+ filename[sizeof(filename) - 1] = '\0';
442
+ size_t filenameLen = strlen(filename);
443
+
444
+ if (filenameLen == 0) {
445
+ err = unzGoToNextFile(uf);
446
+ continue;
447
+ }
448
+
440
449
  string fullPath = destPath;
441
450
  if (fullPath.back() != '/' && fullPath.back() != '\\') {
442
451
  fullPath += '/';
@@ -444,7 +453,6 @@ bool FileSystemHelper::unZip(std::string filePath, std::string destPath)
444
453
  fullPath += filename;
445
454
 
446
455
  // Check if directory
447
- size_t filenameLen = strlen(filename);
448
456
  if (filename[filenameLen - 1] == '/') {
449
457
  // Create directory
450
458
  string dummy = fullPath + "dummy";
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -74,7 +74,6 @@ string TextProcessor::getFileUrl(const string& nativePath)
74
74
  string TextProcessor::getFilteredText(const string& text, int chapter, int verseNr, bool hasStrongs, bool hasInconsistentClosingEndDivs, const string& moduleFileUrl)
75
75
  {
76
76
  static string chapterFilter = "<chapter";
77
- static regex pbElement = regex("<pb .*?/> ");
78
77
 
79
78
  static string lbBeginParagraph = "<lb type=\"x-begin-paragraph\"/>";
80
79
  static string lbEndParagraph = "<lb type=\"x-end-paragraph\"/>";
@@ -117,11 +116,6 @@ string TextProcessor::getFilteredText(const string& text, int chapter, int verse
117
116
  static string hiItalic = "<hi type=\"italic";
118
117
  static string hiSuper = "<hi type=\"super";
119
118
 
120
- static regex milestoneFilter = regex("<milestone.*?/>");
121
- static regex segStartElementFilter = regex("<seg.*?>");
122
- static regex divSectionElementFilter = regex("<div type=\"section\".*?>");
123
- static regex selfClosingElement = regex("(<)([wdiv]{1,3}) ([\\w:=\"\\- ]*?)(/>)");
124
-
125
119
  static string fullStopWithoutSpace = ".<";
126
120
  static string questionMarkWithoutSpace = "?<";
127
121
  static string exclamationMarkWithoutSpace = "!<";
@@ -130,9 +124,9 @@ string TextProcessor::getFilteredText(const string& text, int chapter, int verse
130
124
  static string colonWithoutSpace = ":<";
131
125
 
132
126
  string filteredText = text;
133
-
127
+
134
128
  // Remove the first pbElement, because it prevents correctly replacing the first note in the next step
135
- filteredText = regex_replace(filteredText, pbElement, "");
129
+ this->removePbElementsWithSpace(filteredText);
136
130
 
137
131
  // Remove <note type="variant"> if it occurs in the beginning of the verse (applicable for NA28), because it has
138
132
  // been observed that the note is not properly closed.
@@ -160,9 +154,11 @@ string TextProcessor::getFilteredText(const string& text, int chapter, int verse
160
154
  this->findAndReplaceAll(filteredText, rtxtStartElementFilter2, "<div class=\"sword-markup sword-rtxt\" rend=");
161
155
  this->findAndReplaceAll(filteredText, rtxtEndElementFilter, "</div>");
162
156
  this->findAndReplaceAll(filteredText, pbElementFilter, "<pb class=\"sword-markup sword-pb\"");
163
- filteredText = regex_replace(filteredText, milestoneFilter, "");
164
- filteredText = regex_replace(filteredText, segStartElementFilter, "");
165
- filteredText = regex_replace(filteredText, divSectionElementFilter, "");
157
+
158
+ this->replaceMilestoneLineElements(filteredText);
159
+ this->removeMilestoneElements(filteredText);
160
+ this->removeSegStartElements(filteredText);
161
+ this->removeDivSectionElements(filteredText);
166
162
 
167
163
  stringstream sectionTitleElement;
168
164
  sectionTitleElement << "<div class=\"sword-markup sword-section-title\" ";
@@ -204,7 +200,7 @@ string TextProcessor::getFilteredText(const string& text, int chapter, int verse
204
200
  this->findAndReplaceAll(filteredText, hiItalic, "<hi class=\"italic");
205
201
  this->findAndReplaceAll(filteredText, hiSuper, "<hi class=\"super");
206
202
 
207
- filteredText = regex_replace(filteredText, selfClosingElement, "<$2 $3></$2>");
203
+ this->expandSelfClosingElements(filteredText);
208
204
 
209
205
  this->findAndReplaceAll(filteredText, fullStopWithoutSpace, ". <");
210
206
  this->findAndReplaceAll(filteredText, questionMarkWithoutSpace, "? <");
@@ -316,6 +312,7 @@ string TextProcessor::getCurrentVerseText(sword::SWModule* module, bool hasStron
316
312
  VerseKey currentVerseKey = module->getKey();
317
313
  int currentChapter = currentVerseKey.getChapter();
318
314
  int currentVerseNr = currentVerseKey.getVerse();
315
+
319
316
  verseText = string(module->getRawEntry());
320
317
  StringHelper::trim(verseText);
321
318
  filteredText = verseText;
@@ -473,7 +470,7 @@ vector<Verse> TextProcessor::getText(string moduleName, string key, QueryLimit q
473
470
  } else {
474
471
  startVerseNumber = 1;
475
472
  }
476
-
473
+
477
474
  for (;;) {
478
475
  VerseKey currentVerseKey(module->getKey());
479
476
  string currentBookName(currentVerseKey.getBookAbbrev());
@@ -505,7 +502,7 @@ vector<Verse> TextProcessor::getText(string moduleName, string key, QueryLimit q
505
502
  string chapterHeading = this->getCurrentChapterHeading(module, moduleFileUrl);
506
503
  verseText += chapterHeading;
507
504
  }
508
-
505
+
509
506
  // Current verse text
510
507
  verseText += this->getCurrentVerseText(module,
511
508
  hasStrongs,
@@ -530,7 +527,9 @@ vector<Verse> TextProcessor::getText(string moduleName, string key, QueryLimit q
530
527
  lastKey = currentKey;
531
528
  lastBookName = currentBookName;
532
529
  lastChapter = currentChapter;
530
+
533
531
  module->increment();
532
+
534
533
  index++;
535
534
  }
536
535
  }
@@ -727,3 +726,132 @@ unsigned int TextProcessor::findAndReplaceAll(std::string & data, std::string to
727
726
 
728
727
  return count;
729
728
  }
729
+
730
+ // Remove elements matching pattern: <prefix ... suffix>
731
+ // This is a string-based replacement for regex patterns like "<prefix.*?suffix>"
732
+ void TextProcessor::removeElementsByPrefixSuffix(std::string& data, const std::string& prefix, const std::string& suffix)
733
+ {
734
+ size_t pos = 0;
735
+ while ((pos = data.find(prefix, pos)) != std::string::npos) {
736
+ size_t endPos = data.find(suffix, pos + prefix.size());
737
+ if (endPos != std::string::npos) {
738
+ data.erase(pos, endPos + suffix.size() - pos);
739
+ } else {
740
+ break;
741
+ }
742
+ }
743
+ }
744
+
745
+ // Remove milestone elements with type="line" and replace with <br/>
746
+ void TextProcessor::replaceMilestoneLineElements(std::string& data)
747
+ {
748
+ static const std::string milestoneStart = "<milestone";
749
+ static const std::string typeLine = "type=\"line\"";
750
+ static const std::string milestoneEnd = "/>";
751
+
752
+ size_t pos = 0;
753
+ while ((pos = data.find(milestoneStart, pos)) != std::string::npos) {
754
+ size_t endPos = data.find(milestoneEnd, pos);
755
+ if (endPos != std::string::npos) {
756
+ size_t elementEnd = endPos + milestoneEnd.size();
757
+ std::string element = data.substr(pos, elementEnd - pos);
758
+
759
+ if (element.find(typeLine) != std::string::npos) {
760
+ data.replace(pos, elementEnd - pos, "<br/>");
761
+ pos += 5; // length of "<br/>"
762
+ } else {
763
+ pos = elementEnd;
764
+ }
765
+ } else {
766
+ break;
767
+ }
768
+ }
769
+ }
770
+
771
+ // Remove all milestone elements (those not already replaced)
772
+ void TextProcessor::removeMilestoneElements(std::string& data)
773
+ {
774
+ removeElementsByPrefixSuffix(data, "<milestone", "/>");
775
+ }
776
+
777
+ // Remove seg start elements: <seg...>
778
+ void TextProcessor::removeSegStartElements(std::string& data)
779
+ {
780
+ removeElementsByPrefixSuffix(data, "<seg", ">");
781
+ }
782
+
783
+ // Remove div section elements: <div type="section"...>
784
+ void TextProcessor::removeDivSectionElements(std::string& data)
785
+ {
786
+ static const std::string divSection = "<div type=\"section\"";
787
+
788
+ size_t pos = 0;
789
+ while ((pos = data.find(divSection, pos)) != std::string::npos) {
790
+ size_t endPos = data.find(">", pos + divSection.size());
791
+ if (endPos != std::string::npos) {
792
+ data.erase(pos, endPos + 1 - pos);
793
+ } else {
794
+ break;
795
+ }
796
+ }
797
+ }
798
+
799
+ // Expand self-closing elements: <w .../> -> <w ...></w> and <div .../> -> <div ...></div>
800
+ void TextProcessor::expandSelfClosingElements(std::string& data)
801
+ {
802
+ size_t pos = 0;
803
+ while (pos < data.size()) {
804
+ // Find next '<'
805
+ size_t startPos = data.find('<', pos);
806
+ if (startPos == std::string::npos) break;
807
+
808
+ // Check if it's <w or <div followed by space
809
+ bool isW = (data.compare(startPos, 3, "<w ") == 0);
810
+ bool isDiv = (data.compare(startPos, 5, "<div ") == 0);
811
+
812
+ if (isW || isDiv) {
813
+ // Find the end of the tag
814
+ size_t endPos = data.find('>', startPos);
815
+ if (endPos != std::string::npos && endPos > startPos + 1) {
816
+ // Check if it's self-closing (ends with />)
817
+ if (data[endPos - 1] == '/') {
818
+ // It's self-closing, expand it
819
+ std::string tagName = isW ? "w" : "div";
820
+ std::string closingTag = "</" + tagName + ">";
821
+
822
+ // Remove the / before >
823
+ data.erase(endPos - 1, 1);
824
+ endPos--; // Adjust for removed character
825
+
826
+ // Insert closing tag after >
827
+ data.insert(endPos + 1, closingTag);
828
+
829
+ pos = endPos + 1 + closingTag.size();
830
+ } else {
831
+ pos = endPos + 1;
832
+ }
833
+ } else {
834
+ pos = startPos + 1;
835
+ }
836
+ } else {
837
+ pos = startPos + 1;
838
+ }
839
+ }
840
+ }
841
+
842
+ // Remove pb elements with trailing space: "<pb .../> "
843
+ void TextProcessor::removePbElementsWithSpace(std::string& data)
844
+ {
845
+ static const std::string pbStart = "<pb ";
846
+ static const std::string pbEnd = "/> ";
847
+
848
+ size_t pos = 0;
849
+ while ((pos = data.find(pbStart, pos)) != std::string::npos) {
850
+ size_t endPos = data.find(pbEnd, pos);
851
+ if (endPos != std::string::npos) {
852
+ data.erase(pos, endPos + pbEnd.size() - pos);
853
+ } else {
854
+ break;
855
+ }
856
+ }
857
+ }
@@ -1,6 +1,6 @@
1
1
  /* This file is part of node-sword-interface.
2
2
 
3
- Copyright (C) 2019 - 2025 Tobias Klein <contact@tklein.info>
3
+ Copyright (C) 2019 - 2026 Tobias Klein <contact@tklein.info>
4
4
 
5
5
  node-sword-interface is free software: you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License as published by
@@ -70,6 +70,15 @@ private:
70
70
  std::string replaceSpacesInStrongs(const std::string& text);
71
71
  unsigned int findAndReplaceAll(std::string & data, std::string toSearch, std::string replaceStr);
72
72
 
73
+ // String-based replacements for regex operations (performance optimization)
74
+ void removeElementsByPrefixSuffix(std::string& data, const std::string& prefix, const std::string& suffix);
75
+ void replaceMilestoneLineElements(std::string& data);
76
+ void removeMilestoneElements(std::string& data);
77
+ void removeSegStartElements(std::string& data);
78
+ void removeDivSectionElements(std::string& data);
79
+ void expandSelfClosingElements(std::string& data);
80
+ void removePbElementsWithSpace(std::string& data);
81
+
73
82
  std::string getBookFromReference(std::string reference);
74
83
  std::vector<std::string> getBookListFromReferences(std::vector<std::string>& references);
75
84
 
@@ -1,12 +0,0 @@
1
- # To get started with Dependabot version updates, you'll need to specify which
2
- # package ecosystems to update and where the package manifests are located.
3
- # Please see the documentation for all configuration options:
4
- # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
-
6
- version: 2
7
- updates:
8
- - package-ecosystem: "npm" # See documentation for possible values
9
- directory: "/" # Location of package manifests
10
- open-pull-requests-limit: 10
11
- schedule:
12
- interval: "daily"
File without changes
File without changes
File without changes