@helloao/tools 0.2.0 → 0.4.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.
Files changed (81) hide show
  1. package/dist/cjs/generation/api.cjs +2213 -216
  2. package/dist/cjs/generation/api.cjs.map +3 -3
  3. package/dist/cjs/generation/audio.cjs +5 -5
  4. package/dist/cjs/generation/audio.cjs.map +1 -1
  5. package/dist/cjs/generation/book-order.cjs.map +1 -1
  6. package/dist/cjs/generation/common-types.cjs +782 -14
  7. package/dist/cjs/generation/common-types.cjs.map +2 -2
  8. package/dist/cjs/generation/dataset.cjs +13 -9
  9. package/dist/cjs/generation/dataset.cjs.map +2 -2
  10. package/dist/cjs/generation/index.cjs +8 -5
  11. package/dist/cjs/generation/index.cjs.map +2 -2
  12. package/dist/cjs/generation/simple.cjs +294 -0
  13. package/dist/cjs/generation/simple.cjs.map +7 -0
  14. package/dist/cjs/generation/theographic.cjs +446 -0
  15. package/dist/cjs/generation/theographic.cjs.map +7 -0
  16. package/dist/cjs/index.cjs +4 -4
  17. package/dist/cjs/index.cjs.map +1 -1
  18. package/dist/cjs/log.cjs.map +1 -1
  19. package/dist/cjs/parser/codex-parser.cjs +3 -3
  20. package/dist/cjs/parser/codex-parser.cjs.map +3 -3
  21. package/dist/cjs/parser/commentary-csv-parser.cjs +14 -3
  22. package/dist/cjs/parser/commentary-csv-parser.cjs.map +3 -3
  23. package/dist/cjs/parser/index.cjs +1 -1
  24. package/dist/cjs/parser/iterators.cjs.map +1 -1
  25. package/dist/cjs/parser/lockman-parser.cjs +1 -1
  26. package/dist/cjs/parser/lockman-parser.cjs.map +1 -1
  27. package/dist/cjs/parser/tyndale-xml-parser.cjs +1 -1
  28. package/dist/cjs/parser/tyndale-xml-parser.cjs.map +1 -1
  29. package/dist/cjs/parser/types.cjs.map +1 -1
  30. package/dist/cjs/parser/usfm-parser.cjs +2 -2
  31. package/dist/cjs/parser/usfm-parser.cjs.map +1 -1
  32. package/dist/cjs/parser/usx-parser.cjs +122 -26
  33. package/dist/cjs/parser/usx-parser.cjs.map +2 -2
  34. package/dist/cjs/parser/words.cjs +187 -0
  35. package/dist/cjs/parser/words.cjs.map +7 -0
  36. package/dist/cjs/utils.cjs +1 -1
  37. package/dist/esm/generation/api.js +2155 -214
  38. package/dist/esm/generation/api.js.map +3 -3
  39. package/dist/esm/generation/audio.js +1 -1
  40. package/dist/esm/generation/audio.js.map +1 -1
  41. package/dist/esm/generation/book-order.js.map +1 -1
  42. package/dist/esm/generation/common-types.js +738 -14
  43. package/dist/esm/generation/common-types.js.map +2 -2
  44. package/dist/esm/generation/dataset.js +6 -2
  45. package/dist/esm/generation/dataset.js.map +2 -2
  46. package/dist/esm/generation/index.js +2 -1
  47. package/dist/esm/generation/index.js.map +2 -2
  48. package/dist/esm/generation/simple.js +260 -0
  49. package/dist/esm/generation/simple.js.map +7 -0
  50. package/dist/esm/generation/theographic.js +412 -0
  51. package/dist/esm/generation/theographic.js.map +7 -0
  52. package/dist/esm/index.js.map +1 -1
  53. package/dist/esm/log.js.map +1 -1
  54. package/dist/esm/parser/codex-parser.js +3 -3
  55. package/dist/esm/parser/codex-parser.js.map +3 -3
  56. package/dist/esm/parser/commentary-csv-parser.js +3 -2
  57. package/dist/esm/parser/commentary-csv-parser.js.map +2 -2
  58. package/dist/esm/parser/iterators.js.map +1 -1
  59. package/dist/esm/parser/lockman-parser.js +1 -1
  60. package/dist/esm/parser/lockman-parser.js.map +1 -1
  61. package/dist/esm/parser/tyndale-xml-parser.js +1 -1
  62. package/dist/esm/parser/tyndale-xml-parser.js.map +1 -1
  63. package/dist/esm/parser/usfm-parser.js +1 -1
  64. package/dist/esm/parser/usfm-parser.js.map +1 -1
  65. package/dist/esm/parser/usx-parser.js +130 -26
  66. package/dist/esm/parser/usx-parser.js.map +2 -2
  67. package/dist/esm/parser/words.js +149 -0
  68. package/dist/esm/parser/words.js.map +7 -0
  69. package/dist/types/generation/api.d.ts +9006 -1101
  70. package/dist/types/generation/common-types.d.ts +1318 -106
  71. package/dist/types/generation/dataset.d.ts +17 -1
  72. package/dist/types/generation/index.d.ts +2 -1
  73. package/dist/types/generation/simple.d.ts +110 -0
  74. package/dist/types/generation/theographic.d.ts +64 -0
  75. package/dist/types/parser/commentary-csv-parser.d.ts +1 -1
  76. package/dist/types/parser/lockman-parser.d.ts +1 -1
  77. package/dist/types/parser/tyndale-xml-parser.d.ts +1 -1
  78. package/dist/types/parser/types.d.ts +63 -0
  79. package/dist/types/parser/usx-parser.d.ts +6 -5
  80. package/dist/types/parser/words.d.ts +104 -0
  81. package/package.json +3 -2
@@ -1,4 +1,4 @@
1
- import { Commentary, CommentaryBook, CommentaryBookChapter, CommentaryProfile, InputFile, Translation, TranslationBook, TranslationBookChapter, Dataset as CommonDataset, DatasetBook, DatasetBookChapter } from './common-types.js';
1
+ import { Commentary, CommentaryBook, CommentaryBookChapter, CommentaryProfile, InputFile, Translation, TranslationBook, TranslationBookChapter, Dataset as CommonDataset, DatasetBook, DatasetBookChapter, DatasetPerson, DatasetPlace, DatasetEvent, DatasetPeopleGroup } from './common-types.js';
2
2
  import { ParseMessage } from '../parser/types.js';
3
3
  export declare const DATASET_VERSION = 1;
4
4
  /**
@@ -69,6 +69,22 @@ export interface DatasetCommentaryProfile extends CommentaryProfile {
69
69
  }
70
70
  export interface DatasetDataset extends CommonDataset {
71
71
  books: DatasetDatasetBook[];
72
+ /**
73
+ * The list of people that are contained in the dataset.
74
+ */
75
+ people?: DatasetPerson[];
76
+ /**
77
+ * The list of places that are contained in the dataset.
78
+ */
79
+ places?: DatasetPlace[];
80
+ /**
81
+ * The list of events that are contained in the dataset.
82
+ */
83
+ events?: DatasetEvent[];
84
+ /**
85
+ * The list of people groups that are contained in the dataset.
86
+ */
87
+ peopleGroups?: DatasetPeopleGroup[];
72
88
  }
73
89
  export interface DatasetDatasetBook extends DatasetBook {
74
90
  chapters: DatasetBookChapter[];
@@ -2,6 +2,7 @@ import * as api from './api.js';
2
2
  import * as audio from './audio.js';
3
3
  import * as dataset from './dataset.js';
4
4
  import * as bookOrder from './book-order.js';
5
+ import * as simple from './simple.js';
5
6
  export * from './common-types.js';
6
- export { api, audio, dataset, bookOrder };
7
+ export { api, audio, dataset, bookOrder, simple };
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,110 @@
1
+ import { ChapterData, ChapterFootnote, ChapterHebrewSubtitle, ChapterVerse, ChapterWord, CommentaryChapterData, SimpleChapterData, SimpleChapterHebrewSubtitle, SimpleChapterVerse, SimpleChapterWord, SimpleCommentaryChapterData, SimpleInlineHeading, SimplePoemRange, SimpleTextRange, SimpleVerseFootnote, TranslationBookChapterWords, SimpleTranslationBookChapterWords } from './common-types.js';
2
+ /**
3
+ * The types of content that can be contained in a verse or Hebrew Subtitle.
4
+ */
5
+ type VerseContent = ChapterVerse['content'][number] | ChapterHebrewSubtitle['content'][number];
6
+ /**
7
+ * The result of flattening the content of a verse into a single string.
8
+ */
9
+ export interface SimplifiedVerseContent {
10
+ /**
11
+ * The text of the verse.
12
+ */
13
+ text: string;
14
+ /**
15
+ * The footnotes that occur in the verse.
16
+ */
17
+ footnotes: SimpleVerseFootnote[];
18
+ /**
19
+ * The headings that occur in the middle of the verse.
20
+ */
21
+ headings: SimpleInlineHeading[];
22
+ /**
23
+ * The ranges of text that represent the Words of Jesus.
24
+ */
25
+ wordsOfJesus: SimpleTextRange[];
26
+ /**
27
+ * The ranges of text that represent lines of poetry.
28
+ */
29
+ poem: SimplePoemRange[];
30
+ /**
31
+ * The word-level annotations for the verse, with their offsets remapped onto the text.
32
+ */
33
+ words: SimpleChapterWord[];
34
+ }
35
+ /**
36
+ * Flattens the content of a verse into a single string, recording the positions of the
37
+ * footnotes, headings, and formatting that occur in it.
38
+ *
39
+ * The rules used to build the text are:
40
+ * - Strings and formatted text are appended as-is. The source data already contains the
41
+ * spacing that is needed between them.
42
+ * - Lines of poetry and line breaks start a new line.
43
+ * - Footnote and heading markers are replaced with a single space when one is needed to
44
+ * keep the surrounding words apart.
45
+ *
46
+ * All of the recorded offsets are measured in UTF-16 code units, which is what
47
+ * `String.prototype.slice()` and `String.prototype.length` use.
48
+ *
49
+ * Word-level annotations are anchored to a range of characters in a single item of the
50
+ * content array. Since the simplified format replaces that array with a single string,
51
+ * their offsets are remapped onto the text that is built here.
52
+ *
53
+ * @param content The content of the verse.
54
+ * @param footnotes The footnotes for the chapter, keyed by note ID.
55
+ * @param usedFootnotes A set that the IDs of the referenced footnotes are added to.
56
+ * @param words The word-level annotations for the verse.
57
+ */
58
+ export declare function simplifyVerseContent(content: readonly VerseContent[], footnotes?: Map<number, ChapterFootnote>, usedFootnotes?: Set<number>, words?: readonly ChapterWord[]): SimplifiedVerseContent;
59
+ /**
60
+ * Converts the given verse into its simplified representation.
61
+ * @param verse The verse to convert.
62
+ * @param footnotes The footnotes for the chapter, keyed by note ID.
63
+ * @param usedFootnotes A set that the IDs of the referenced footnotes are added to.
64
+ * @param words The word-level annotations for the verse.
65
+ * @param remappedWords An array that the remapped word-level annotations are added to.
66
+ */
67
+ export declare function simplifyVerse(verse: ChapterVerse, footnotes?: Map<number, ChapterFootnote>, usedFootnotes?: Set<number>, words?: readonly ChapterWord[], remappedWords?: SimpleChapterWord[]): SimpleChapterVerse;
68
+ /**
69
+ * Converts the given Hebrew Subtitle into its simplified representation.
70
+ * @param subtitle The subtitle to convert.
71
+ * @param footnotes The footnotes for the chapter, keyed by note ID.
72
+ * @param usedFootnotes A set that the IDs of the referenced footnotes are added to.
73
+ */
74
+ export declare function simplifyHebrewSubtitle(subtitle: ChapterHebrewSubtitle, footnotes?: Map<number, ChapterFootnote>, usedFootnotes?: Set<number>): SimpleChapterHebrewSubtitle;
75
+ /**
76
+ * The result of converting a chapter into the simplified chapter format.
77
+ */
78
+ export interface SimplifiedChapter {
79
+ /**
80
+ * The simplified chapter.
81
+ */
82
+ chapter: SimpleChapterData;
83
+ /**
84
+ * The word-level annotations for the chapter, with their offsets remapped onto the
85
+ * text of each simplified verse. Empty if the chapter has no annotations.
86
+ */
87
+ words: SimpleTranslationBookChapterWords;
88
+ }
89
+ /**
90
+ * Converts the given chapter into the simplified chapter format.
91
+ *
92
+ * In the simplified format, the content of each verse is a single string instead of a list
93
+ * of formatted content, and the footnotes are available on the verse that they occur in,
94
+ * along with the offset that they occur at.
95
+ *
96
+ * The word-level annotations are returned separately, since they are published in their
97
+ * own file. They are converted here because their offsets have to be remapped onto the
98
+ * text that is built for each verse.
99
+ *
100
+ * @param chapter The chapter to convert.
101
+ * @param words The word-level annotations for the chapter, keyed by verse number.
102
+ */
103
+ export declare function simplifyChapter(chapter: ChapterData, words?: TranslationBookChapterWords): SimplifiedChapter;
104
+ /**
105
+ * Converts the given commentary chapter into the simplified chapter format.
106
+ * @param chapter The chapter to convert.
107
+ */
108
+ export declare function simplifyCommentaryChapter(chapter: CommentaryChapterData): SimpleCommentaryChapterData;
109
+ export {};
110
+ //# sourceMappingURL=simple.d.ts.map
@@ -0,0 +1,64 @@
1
+ import { Dataset } from './common-types.js';
2
+ import { DatasetDataset } from './dataset.js';
3
+ /**
4
+ * The dataset information for the Theographic Bible Metadata dataset.
5
+ * See https://github.com/robertrouse/theographic-bible-metadata
6
+ */
7
+ export declare const THEOGRAPHIC_DATASET: Dataset;
8
+ /**
9
+ * Defines an interface for a raw Theographic record.
10
+ * The Theographic JSON files are Airtable exports, where each record has an Airtable record ID and a map of fields.
11
+ */
12
+ export interface TheographicRecord {
13
+ /**
14
+ * The Airtable record ID of the record. e.g. "recO5ToygNrV47m4M"
15
+ */
16
+ id: string;
17
+ /**
18
+ * The fields of the record.
19
+ */
20
+ fields: {
21
+ [key: string]: any;
22
+ };
23
+ }
24
+ /**
25
+ * The parsed contents of the Theographic JSON files that are needed
26
+ * to generate the dataset.
27
+ */
28
+ export interface TheographicFiles {
29
+ books: TheographicRecord[];
30
+ verses: TheographicRecord[];
31
+ people: TheographicRecord[];
32
+ places: TheographicRecord[];
33
+ events: TheographicRecord[];
34
+ peopleGroups: TheographicRecord[];
35
+ }
36
+ /**
37
+ * Maps Theographic OSIS book names to USFM book IDs.
38
+ */
39
+ export declare const osisBookMap: Map<string, "GEN" | "EXO" | "LEV" | "NUM" | "DEU" | "JOS" | "JDG" | "RUT" | "1SA" | "2SA" | "1KI" | "2KI" | "1CH" | "2CH" | "EZR" | "NEH" | "EST" | "JOB" | "PSA" | "PRO" | "ECC" | "SNG" | "ISA" | "JER" | "LAM" | "EZK" | "DAN" | "HOS" | "JOL" | "AMO" | "OBA" | "JON" | "MIC" | "NAM" | "HAB" | "ZEP" | "HAG" | "ZEC" | "MAL" | "MAT" | "MRK" | "LUK" | "JHN" | "ACT" | "ROM" | "1CO" | "2CO" | "GAL" | "EPH" | "PHP" | "COL" | "1TH" | "2TH" | "1TI" | "2TI" | "TIT" | "PHM" | "HEB" | "JAS" | "1PE" | "2PE" | "1JN" | "2JN" | "3JN" | "JUD" | "REV" | "TOB" | "JDT" | "ESG" | "WIS" | "SIR" | "BAR" | "LJE" | "S3Y" | "SUS" | "BEL" | "1MA" | "2MA" | "3MA" | "4MA" | "1ES" | "2ES" | "MAN" | "PS2" | "ODA" | "PSS" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO">;
40
+ /**
41
+ * Slugifies the given string so that it can be used as an entity ID.
42
+ * @param str The string to slugify.
43
+ */
44
+ export declare function slugify(str: string): string;
45
+ /**
46
+ * Removes markdown links from the given text, keeping only the link text.
47
+ * For example, "[Esther 1:10](/esth#Esth.1.10)" becomes "Esther 1:10".
48
+ * @param text The text to clean.
49
+ */
50
+ export declare function stripMarkdownLinks(text: string): string;
51
+ /**
52
+ * Generates a dataset from the given Theographic Bible Metadata files.
53
+ *
54
+ * The returned dataset contains the people, places, events, and people groups
55
+ * from the Theographic data, with all cross-entity relationships resolved to entity IDs
56
+ * and all verse links resolved to Bible verse references.
57
+ *
58
+ * The transformation is deterministic: the same input always produces the same output.
59
+ *
60
+ * @param files The parsed Theographic JSON files.
61
+ * @param dataset The dataset information to use. Defaults to {@link THEOGRAPHIC_DATASET}.
62
+ */
63
+ export declare function generateDatasetFromTheographic(files: TheographicFiles, dataset?: Dataset): DatasetDataset;
64
+ //# sourceMappingURL=theographic.d.ts.map
@@ -1,4 +1,4 @@
1
- import { CommentaryParseTree } from './types';
1
+ import { CommentaryParseTree } from './types.js';
2
2
  export interface CsvLine {
3
3
  book: string;
4
4
  chapter: string;
@@ -1,4 +1,4 @@
1
- import { ParseTree } from './types';
1
+ import { ParseTree } from './types.js';
2
2
  export declare const LOCKMAN_PARSER_VERSION = 3;
3
3
  export declare class LockmanParser {
4
4
  parse(text: string): ParseTree[];
@@ -1,4 +1,4 @@
1
- import { CommentaryParseTree } from './types';
1
+ import { CommentaryParseTree } from './types.js';
2
2
  export declare class TyndaleXmlParser {
3
3
  private _domParser;
4
4
  constructor(domParser: DOMParser);
@@ -49,6 +49,69 @@ export interface Chapter {
49
49
  * The list of footnotes for the chapter.
50
50
  */
51
51
  footnotes: Footnote[];
52
+ /**
53
+ * The word-level annotations for the chapter's verses.
54
+ * Undefined if the source didn't contain any word-level annotations.
55
+ */
56
+ words?: ChapterWords;
57
+ }
58
+ /**
59
+ * Defines the word-level annotations for a chapter, keyed by verse number.
60
+ */
61
+ export type ChapterWords = {
62
+ [verseNumber: string]: ChapterWord[];
63
+ };
64
+ /**
65
+ * Defines an interface that represents the annotations that a source associated
66
+ * with a specific range of characters in a verse.
67
+ *
68
+ * The range is anchored to a single item of the verse's content array, so that
69
+ * consumers can highlight the exact characters that an annotation applies to.
70
+ */
71
+ export interface ChapterWord {
72
+ /**
73
+ * The index of the item in the verse's content array that the annotation applies to.
74
+ */
75
+ contentIndex: number;
76
+ /**
77
+ * The index of the first character of the annotated word in the content item's text.
78
+ */
79
+ start: number;
80
+ /**
81
+ * The index after the last character of the annotated word in the content item's text.
82
+ * That is, `text.slice(start, end)` is the annotated word.
83
+ */
84
+ end: number;
85
+ /**
86
+ * The Strong's number(s) for the word.
87
+ * Undefined if the source only provided other annotations for the word.
88
+ */
89
+ strongs?: string[];
90
+ /**
91
+ * The dictionary (citation) form of the word.
92
+ * Taken from the `lemma` attribute.
93
+ */
94
+ lemma?: string;
95
+ /**
96
+ * The morphology parse code for the word.
97
+ * Taken from the `x-morph` attribute.
98
+ */
99
+ morph?: string;
100
+ /**
101
+ * The pointer to the word in the source text, in the `<sourceName>:<location>` format.
102
+ * Taken from the `srcloc` attribute.
103
+ */
104
+ srcloc?: string;
105
+ /**
106
+ * Which occurrence of the source word this word is. 1-based.
107
+ * Taken from the `x-occurrence` attribute.
108
+ */
109
+ occurrence?: number;
110
+ /**
111
+ * The total number of times that the source word occurs.
112
+ * Taken from the `x-occurrences` attribute.
113
+ */
114
+ occurrences?: number;
52
115
  }
53
116
  /**
54
117
  * Defines an interface that represents a hebrew subtitle.
@@ -1,10 +1,11 @@
1
1
  import { Chapter, ChapterContent, FootnoteReference, ParseTree, Verse, Text, HebrewSubtitle, InlineLineBreak } from './types.js';
2
2
  import { RewindableIterator } from './iterators.js';
3
+ import { AnnotatedContent } from './words.js';
3
4
  /**
4
5
  * The version of the parser.
5
6
  * Used to determine whether input files need to be re-parsed.
6
7
  */
7
- export declare const PARSER_VERSION = 3;
8
+ export declare const PARSER_VERSION = 4;
8
9
  /**
9
10
  * Defines a class that is able to parse USX content.
10
11
  */
@@ -25,13 +26,13 @@ export declare class USXParser {
25
26
  parse(usx: string): ParseTree;
26
27
  iterateRootContent(usxElement: Element): Generator<ParseTree['content'][0]>;
27
28
  iterateChapterContent(chapter: Chapter, nodes: RewindableIterator<Node>): IterableIterator<ChapterContent>;
28
- iterateVerseContent(chapter: Chapter, verse: Verse, nodes: RewindableIterator<Node>, previousVerse?: Verse | null): IterableIterator<string | FootnoteReference | Text | InlineLineBreak>;
29
+ iterateVerseContent(chapter: Chapter, verse: Verse, nodes: RewindableIterator<Node>, previousVerse?: Verse | null): IterableIterator<string | FootnoteReference | Text | InlineLineBreak | AnnotatedContent<string | Text>>;
29
30
  parseVerse(element: Element, chapter: Chapter, nodes: RewindableIterator<Node>): Verse;
30
31
  parseHebrewSubtitle(para: Element, chapter: Chapter, nodes: RewindableIterator<Node>): IterableIterator<HebrewSubtitle | Verse>;
31
- iterateHebrewSubtitleContent(element: Element, chapter: Chapter, nodes: RewindableIterator<Node>): IterableIterator<Verse | string | Text | FootnoteReference | InlineLineBreak>;
32
- iterateNodeTextContent(nodes: RewindableIterator<Node>, node: Node, chapter: Chapter, verse?: Verse): IterableIterator<string | Text | FootnoteReference | InlineLineBreak>;
32
+ iterateHebrewSubtitleContent(element: Element, chapter: Chapter, nodes: RewindableIterator<Node>): IterableIterator<Verse | string | Text | FootnoteReference | InlineLineBreak | AnnotatedContent<string | Text>>;
33
+ iterateNodeTextContent(nodes: RewindableIterator<Node>, node: Node, chapter: Chapter, verse?: Verse): IterableIterator<string | Text | FootnoteReference | InlineLineBreak | AnnotatedContent<string | Text>>;
33
34
  iterateCharContent(char: Element): IterableIterator<string | Text>;
34
35
  iterateNote(nodes: RewindableIterator<Node>, node: Element, chapter: Chapter, verse?: Verse): IterableIterator<FootnoteReference>;
35
- iterateChar(nodes: RewindableIterator<Node>, node: Element): IterableIterator<string | Text>;
36
+ iterateChar(nodes: RewindableIterator<Node>, node: Element): IterableIterator<string | Text | AnnotatedContent<string | Text>>;
36
37
  }
37
38
  //# sourceMappingURL=usx-parser.d.ts.map
@@ -0,0 +1,104 @@
1
+ import { Chapter, ChapterWord } from './types.js';
2
+ /**
3
+ * The annotations that a source associated with a word, without any information
4
+ * about where the word is located.
5
+ */
6
+ export type WordAnnotations = Omit<ChapterWord, 'contentIndex' | 'start' | 'end'>;
7
+ /**
8
+ * Defines an interface that represents a range of characters within a single
9
+ * piece of text, along with the annotations that apply to it.
10
+ */
11
+ export interface WordRange {
12
+ /**
13
+ * The index of the first character of the word.
14
+ */
15
+ start: number;
16
+ /**
17
+ * The index after the last character of the word.
18
+ */
19
+ end: number;
20
+ /**
21
+ * The annotations that apply to the word.
22
+ */
23
+ annotations: WordAnnotations;
24
+ }
25
+ /**
26
+ * Defines an interface that pairs a piece of verse content with the word
27
+ * annotations that apply to it, so that the annotations can be passed along
28
+ * with the content while it is being parsed.
29
+ *
30
+ * The ranges are relative to the text of the content, and are never included in
31
+ * the final parse tree.
32
+ */
33
+ export interface AnnotatedContent<T> {
34
+ /**
35
+ * The content that the annotations apply to.
36
+ */
37
+ annotatedContent: T;
38
+ /**
39
+ * The ranges of the content that are annotated.
40
+ */
41
+ words: WordRange[];
42
+ }
43
+ /**
44
+ * Determines whether the given value is content that has word annotations
45
+ * attached to it.
46
+ * @param value The value to test.
47
+ */
48
+ export declare function isAnnotatedContent(value: unknown): value is AnnotatedContent<unknown>;
49
+ /**
50
+ * Reads the word annotations that are attached to the given element.
51
+ * Returns null if the element doesn't have any recognized annotations.
52
+ * @param element The element to read the annotations from.
53
+ */
54
+ export declare function readWordAnnotations(element: Element): WordAnnotations | null;
55
+ /**
56
+ * Shrinks the given range so that it doesn't include any leading or trailing
57
+ * whitespace. Returns null if the range only contains whitespace.
58
+ * @param text The text that the range is in.
59
+ * @param start The index of the first character of the range.
60
+ * @param end The index after the last character of the range.
61
+ */
62
+ export declare function trimWordRange(text: string, start: number, end: number): {
63
+ start: number;
64
+ end: number;
65
+ } | null;
66
+ /**
67
+ * Collapses the whitespace in the given text in the same manner that the
68
+ * parsers normalize text (each run of whitespace becomes a single space, and the
69
+ * result is trimmed), and returns a map from the indexes in the given text to
70
+ * the indexes in the returned text.
71
+ *
72
+ * The map contains an entry for every index in the given text, plus one for the
73
+ * index just past the end of it, so that both ends of a range can be mapped.
74
+ * @param text The text to collapse.
75
+ */
76
+ export declare function collapseWhitespaceMap(text: string): {
77
+ text: string;
78
+ map: number[];
79
+ };
80
+ /**
81
+ * Moves the words that apply to the given content item to the indexes that they
82
+ * have after the item's text was collapsed with collapseWhitespaceMap().
83
+ * Words that no longer cover any characters are removed.
84
+ * @param words The words to remap.
85
+ * @param contentIndex The index of the content item that was collapsed.
86
+ * @param map The index map that collapseWhitespaceMap() returned.
87
+ */
88
+ export declare function remapChapterWords(words: ChapterWord[], contentIndex: number, map: number[]): void;
89
+ /**
90
+ * Removes the words that apply to the given content item, and moves the words
91
+ * that apply to later items back by one to account for the item being removed.
92
+ * @param words The words to update.
93
+ * @param contentIndex The index of the content item that was removed.
94
+ */
95
+ export declare function removeChapterWordsForContent(words: ChapterWord[], contentIndex: number): void;
96
+ /**
97
+ * Adds the given words to the chapter for the given verse number.
98
+ * Does nothing if there are no words.
99
+ * @param chapter The chapter to add the words to.
100
+ * @param verseNumber The number of the verse that the words are in.
101
+ * @param words The words to add.
102
+ */
103
+ export declare function addChapterWords(chapter: Chapter, verseNumber: number, words: ChapterWord[]): void;
104
+ //# sourceMappingURL=words.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@helloao/tools",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "A set of tools for managing HelloAO's Free Bible API",
5
+ "type": "module",
5
6
  "main": "./dist/cjs/index.cjs",
6
7
  "module": "./dist/esm/index.js",
7
8
  "exports": {
@@ -49,7 +50,7 @@
49
50
  "author": "Kallyn Gowdy <kal@helloao.org>",
50
51
  "license": "MIT",
51
52
  "dependencies": {
52
- "lodash": "4.17.21",
53
+ "es-toolkit": "1.46.1",
53
54
  "zod": "^4.4.3",
54
55
  "papaparse": "5.4.1"
55
56
  },