twl-generator 1.0.0 → 1.0.2

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 CHANGED
@@ -35,12 +35,12 @@ function MyTWLComponent() {
35
35
  const [terms, setTerms] = useState(null);
36
36
  const [loading, setLoading] = useState(false);
37
37
 
38
- const loadTerms = async (book) => {
38
+ const loadTerms = async () => {
39
39
  setLoading(true);
40
40
  try {
41
41
  // First load: Downloads and processes (~3-4 seconds)
42
42
  // Subsequent loads: Uses browser cache (~instant)
43
- const termData = await generateTWTerms(book);
43
+ const termData = await generateTWTerms();
44
44
  setTerms(termData);
45
45
 
46
46
  // Debug cache info
@@ -59,8 +59,7 @@ function MyTWLComponent() {
59
59
  return (
60
60
  <div>
61
61
  {loading && <p>Loading translation words...</p>}
62
- <button onClick={() => loadTerms('JHN')}>Load John</button>
63
- <button onClick={() => loadTerms('RUT')}>Load Ruth</button>
62
+ <button onClick={() => loadTerms()}>Load Terms</button>
64
63
  <button onClick={handleClearCache}>Clear Cache</button>
65
64
  {terms && <p>Loaded {Object.keys(terms).length} terms</p>}
66
65
  </div>
@@ -71,9 +70,9 @@ function MyTWLComponent() {
71
70
  ### Node.js Module
72
71
 
73
72
  ```js
74
- import { generateTWL } from 'twl-generator';
73
+ import { generateTWLWithUsfm } from 'twl-generator';
75
74
 
76
- const result = await generateTWL('RUT');
75
+ const result = await generateTWLWithUsfm('RUT');
77
76
  console.log(result);
78
77
  ```
79
78
 
@@ -94,11 +93,10 @@ The package uses a multi-tier caching approach for optimal performance in React.
94
93
 
95
94
  ## API Reference
96
95
 
97
- ### `generateTWTerms(book)`
96
+ ### `generateTWTerms()`
98
97
 
99
- Generate terms for a Bible book with caching.
98
+ Generate terms mapping with caching.
100
99
 
101
- - **book**: Bible book code (e.g., 'JHN', 'RUT', 'GEN')
102
100
  - **Returns**: Promise<Object> - Term mapping object
103
101
 
104
102
  ### `clearCache()`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "twl-generator",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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": {
package/src/index.js CHANGED
@@ -13,7 +13,7 @@ export { generateTWTerms, processUsfmForBook };
13
13
  */
14
14
  export async function generateTWLWithUsfm(book, usfmContent = null) {
15
15
  // Generate TW terms (with caching)
16
- const terms = await generateTWTerms(book || 'gen'); // Use 'gen' as fallback for terms generation
16
+ const terms = await generateTWTerms();
17
17
 
18
18
  let verses;
19
19
  if (usfmContent) {
@@ -1,6 +1,3 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
1
  /**
5
2
  * Generate morphological variants of a term
6
3
  */
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * Usage in React.js:
8
8
  * import { generateTWTerms } from './utils/zipProcessor.js';
9
- * const terms = await generateTWTerms('JHN');
9
+ * const terms = await generateTWTerms();
10
10
  */
11
11
 
12
12
  import AdmZip from 'adm-zip';
@@ -164,9 +164,7 @@ async function cacheTerms(termMap) {
164
164
  }
165
165
  }
166
166
 
167
- export async function generateTWTerms(book) {
168
- if (!BibleBookData[book]) throw new Error(`Unknown book: ${book}`);
169
-
167
+ export async function generateTWTerms() {
170
168
  // Try to get cached terms first
171
169
  const cachedTerms = await getCachedTerms();
172
170
  if (cachedTerms) {