twl-generator 1.1.5 → 1.2.0
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/README.md +2 -2
- package/package.json +4 -5
- package/src/utils/usfm-alignment-remover.js +10 -2
- package/src/utils/zipProcessor.js +12 -3
package/README.md
CHANGED
|
@@ -134,7 +134,7 @@ All standard Bible book abbreviations are supported:
|
|
|
134
134
|
The generated TSV contains these columns:
|
|
135
135
|
|
|
136
136
|
- **Reference**: Chapter:verse (e.g., "1:1")
|
|
137
|
-
- **ID**: Unique 4-character
|
|
137
|
+
- **ID**: Unique 4-character identifier
|
|
138
138
|
- **Tags**: Article category ("keyterm", "name", or empty)
|
|
139
139
|
- **OrigWords**: The matched text from the source
|
|
140
140
|
- **Occurrence**: Occurrence number for this term in this verse
|
|
@@ -144,7 +144,7 @@ The generated TSV contains these columns:
|
|
|
144
144
|
|
|
145
145
|
## Requirements
|
|
146
146
|
|
|
147
|
-
- **Node.js**: >=
|
|
147
|
+
- **Node.js**: >=18.0.0 (for native fetch support)
|
|
148
148
|
- **Browser**: Modern browser with ES6 modules support
|
|
149
149
|
- **React.js**: >=16.8.0 (for React usage)
|
|
150
150
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twl-generator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Generate term-to-article lists from unfoldingWord en_tw archive for Bible books. Works in both Node.js (CLI) and React.js (browser) environments.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -43,11 +43,10 @@
|
|
|
43
43
|
"LICENSE"
|
|
44
44
|
],
|
|
45
45
|
"engines": {
|
|
46
|
-
"node": ">=
|
|
46
|
+
"node": ">=18.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"jszip": "^3.10.1"
|
|
50
|
-
"node-fetch": "^3.3.2"
|
|
49
|
+
"jszip": "^3.10.1"
|
|
51
50
|
},
|
|
52
51
|
"peerDependencies": {
|
|
53
52
|
"react": ">=16.8.0"
|
|
@@ -57,4 +56,4 @@
|
|
|
57
56
|
"optional": true
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
|
-
}
|
|
59
|
+
}
|
|
@@ -8,8 +8,16 @@ const isNode = typeof window === 'undefined' && typeof process !== 'undefined' &
|
|
|
8
8
|
// Get appropriate fetch implementation
|
|
9
9
|
async function getFetch() {
|
|
10
10
|
if (isNode) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
// Use native fetch in Node.js 18+ or fallback to node-fetch
|
|
12
|
+
if (typeof globalThis.fetch !== 'undefined') {
|
|
13
|
+
return globalThis.fetch;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const nodeFetch = await import('node-fetch');
|
|
17
|
+
return nodeFetch.default;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw new Error('fetch not available. Please use Node.js 18+ or install node-fetch');
|
|
20
|
+
}
|
|
13
21
|
}
|
|
14
22
|
return globalThis.fetch;
|
|
15
23
|
}
|
|
@@ -31,10 +31,19 @@ async function getDeps() {
|
|
|
31
31
|
JSZip: jsZipModule.default
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
// Add Node.js-specific fetch if needed
|
|
34
|
+
// Add Node.js-specific fetch if needed (fallback for Node.js < 18)
|
|
35
35
|
if (isNode) {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
if (typeof globalThis.fetch === 'undefined') {
|
|
37
|
+
try {
|
|
38
|
+
const nodeModule = await import('node-fetch');
|
|
39
|
+
deps.fetch = nodeModule.default;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.warn('node-fetch not available, please use Node.js 18+ or install node-fetch');
|
|
42
|
+
deps.fetch = null;
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
deps.fetch = globalThis.fetch;
|
|
46
|
+
}
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
return deps;
|