@youversion/platform-core 1.20.1 → 1.21.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/dist/index.d.cts CHANGED
@@ -1,4 +1,34 @@
1
1
  import { z } from 'zod';
2
+ export { a as TransformBibleHtmlOptions, T as TransformedBibleHtml, t as transformBibleHtml } from './browser-DzQ1yOHv.cjs';
3
+
4
+ declare const SignInWithYouVersionPermission: {
5
+ readonly bibles: "bibles";
6
+ readonly highlights: "highlights";
7
+ readonly votd: "votd";
8
+ readonly demographics: "demographics";
9
+ readonly bibleActivity: "bible_activity";
10
+ };
11
+ type SignInWithYouVersionResultProps = {
12
+ accessToken?: string;
13
+ expiresIn?: number;
14
+ refreshToken?: string;
15
+ idToken?: string;
16
+ yvpUserId?: string;
17
+ name?: string;
18
+ profilePicture?: string;
19
+ email?: string;
20
+ };
21
+ declare class SignInWithYouVersionResult {
22
+ readonly accessToken: string | undefined;
23
+ readonly expiryDate: Date | undefined;
24
+ readonly refreshToken: string | undefined;
25
+ readonly idToken: string | undefined;
26
+ readonly yvpUserId: string | undefined;
27
+ readonly name: string | undefined;
28
+ readonly profilePicture: string | undefined;
29
+ readonly email: string | undefined;
30
+ constructor({ accessToken, expiresIn, refreshToken, idToken, yvpUserId, name, profilePicture, email, }: SignInWithYouVersionResultProps);
31
+ }
2
32
 
3
33
  declare const BibleVersionSchema: z.ZodObject<{
4
34
  id: z.ZodNumber;
@@ -22,15 +52,12 @@ declare const CanonSchema: z.ZodEnum<{
22
52
  new_testament: "new_testament";
23
53
  deuterocanon: "deuterocanon";
24
54
  }>;
25
- type Canon = Readonly<z.infer<typeof CanonSchema>>;
26
55
  declare const BibleBookIntroSchema: z.ZodObject<{
27
56
  id: z.ZodString;
28
57
  passage_id: z.ZodString;
29
58
  title: z.ZodString;
30
59
  }, z.core.$strip>;
31
60
  type BibleBookIntro = Readonly<z.infer<typeof BibleBookIntroSchema>>;
32
- declare const BookUsfmSchema: z.ZodUnion<readonly [...z.ZodLiteral<"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" | "3ES" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO" | "LKA">[], z.ZodType<string & {}, unknown, z.core.$ZodTypeInternals<string & {}, unknown>>]>;
33
- type BookUsfm = z.infer<typeof BookUsfmSchema>;
34
61
  declare const BibleBookSchema: z.ZodObject<{
35
62
  id: z.ZodUnion<readonly [...z.ZodLiteral<"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" | "3ES" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO" | "LKA">[], z.ZodType<string & {}, unknown, z.core.$ZodTypeInternals<string & {}, unknown>>]>;
36
63
  title: z.ZodString;
@@ -207,36 +234,6 @@ interface ApiConfig {
207
234
  installationId?: string;
208
235
  redirectUri?: string;
209
236
  }
210
-
211
- declare const SignInWithYouVersionPermission: {
212
- readonly bibles: "bibles";
213
- readonly highlights: "highlights";
214
- readonly votd: "votd";
215
- readonly demographics: "demographics";
216
- readonly bibleActivity: "bible_activity";
217
- };
218
- type SignInWithYouVersionResultProps = {
219
- accessToken?: string;
220
- expiresIn?: number;
221
- refreshToken?: string;
222
- idToken?: string;
223
- yvpUserId?: string;
224
- name?: string;
225
- profilePicture?: string;
226
- email?: string;
227
- };
228
- declare class SignInWithYouVersionResult {
229
- readonly accessToken: string | undefined;
230
- readonly expiryDate: Date | undefined;
231
- readonly refreshToken: string | undefined;
232
- readonly idToken: string | undefined;
233
- readonly yvpUserId: string | undefined;
234
- readonly name: string | undefined;
235
- readonly profilePicture: string | undefined;
236
- readonly email: string | undefined;
237
- constructor({ accessToken, expiresIn, refreshToken, idToken, yvpUserId, name, profilePicture, email, }: SignInWithYouVersionResultProps);
238
- }
239
-
240
237
  type SignInWithYouVersionPermissionValues = (typeof SignInWithYouVersionPermission)[keyof typeof SignInWithYouVersionPermission];
241
238
  interface AuthenticationState {
242
239
  readonly isAuthenticated: boolean;
@@ -247,11 +244,6 @@ interface AuthenticationState {
247
244
  readonly error: Error | null;
248
245
  }
249
246
  type AuthenticationScopes = 'profile' | 'email';
250
-
251
- /**
252
- * Legacy type for highlight colors (constants only)
253
- * Not an API response, so no schema needed
254
- */
255
247
  interface HighlightColor {
256
248
  id: number;
257
249
  color: string;
@@ -399,12 +391,18 @@ declare class BibleClient {
399
391
  /**
400
392
  * Fetches a passage (range of verses) from the Bible using the passages endpoint.
401
393
  * This is the new API format that returns HTML-formatted content.
394
+ *
395
+ * Note: The HTML returned from the API contains inline footnote content that should
396
+ * be transformed before rendering. Use `transformBibleHtml()` or
397
+ * `transformBibleHtmlForBrowser()` to clean up the HTML and extract footnotes.
398
+ *
402
399
  * @param versionId The version ID.
403
400
  * @param usfm The USFM reference (e.g., "JHN.3.1-2", "GEN.1", "JHN.3.16").
404
401
  * @param format The format to return ("html" or "text", default: "html").
405
402
  * @param include_headings Whether to include headings in the content.
406
403
  * @param include_notes Whether to include notes in the content.
407
404
  * @returns The requested BiblePassage object with HTML content.
405
+ *
408
406
  * @example
409
407
  * ```ts
410
408
  * // Get a single verse
@@ -415,6 +413,10 @@ declare class BibleClient {
415
413
  *
416
414
  * // Get an entire chapter
417
415
  * const chapter = await bibleClient.getPassage(3034, "GEN.1");
416
+ *
417
+ * // Transform HTML before rendering
418
+ * const passage = await bibleClient.getPassage(3034, "JHN.3.16", "html", true, true);
419
+ * const transformed = transformBibleHtmlForBrowser(passage.content);
418
420
  * ```
419
421
  */
420
422
  getPassage(versionId: number, usfm: string, format?: 'html' | 'text', include_headings?: boolean, include_notes?: boolean): Promise<BiblePassage>;
@@ -724,12 +726,14 @@ declare class YouVersionPlatformConfiguration {
724
726
  * a good use-case for a default Bible Version.
725
727
  */
726
728
  declare const DEFAULT_LICENSE_FREE_BIBLE_VERSION: 3034;
729
+ declare const CANON_IDS: readonly ["old_testament", "new_testament", "deuterocanon"];
727
730
  declare const BOOK_IDS: readonly ["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", "3ES", "EZA", "5EZ", "6EZ", "DAG", "PS3", "2BA", "LBA", "JUB", "ENO", "1MQ", "2MQ", "3MQ", "REP", "4BA", "LAO", "LKA"];
728
-
731
+ type CanonId = (typeof CANON_IDS)[number];
732
+ type KnownBookUsfm = (typeof BOOK_IDS)[number];
729
733
  /**
730
734
  * @see https://github.com/youversion/usfm-references/blob/main/usfm_references/books.py
731
735
  */
732
- declare const BOOK_CANON: Record<BookUsfm, Canon>;
736
+ declare const BOOK_CANON: Record<KnownBookUsfm, CanonId>;
733
737
 
734
738
  type AdjacentChapterResult = {
735
739
  bookId: string;
@@ -746,4 +750,4 @@ type AdjacentChapterResult = {
746
750
  */
747
751
  declare function getAdjacentChapter(books: BibleBook[], currentBookId: string, currentChapterId: string, direction: 'next' | 'previous'): AdjacentChapterResult;
748
752
 
749
- export { ApiClient, type ApiConfig, type AuthenticationScopes, type AuthenticationState, BOOK_CANON, BOOK_IDS, type BibleBook, type BibleBookIntro, type BibleChapter, BibleClient, type BibleIndex, type BibleIndexBook, type BibleIndexChapter, type BibleIndexVerse, type BiblePassage, type BibleVerse, type BibleVersion, type CANON, type Collection, type CreateHighlight, DEFAULT_LICENSE_FREE_BIBLE_VERSION, type DeleteHighlightOptions, type GetHighlightsOptions, type GetLanguagesOptions, type Highlight, type HighlightColor, HighlightsClient, type Language, LanguagesClient, MemoryStorageStrategy, SessionStorageStrategy, SignInWithYouVersionPermission, type SignInWithYouVersionPermissionValues, SignInWithYouVersionResult, type StorageStrategy, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON, getAdjacentChapter };
753
+ export { ApiClient, type ApiConfig, type AuthenticationScopes, type AuthenticationState, BOOK_CANON, BOOK_IDS, type BibleBook, type BibleBookIntro, type BibleChapter, BibleClient, type BibleIndex, type BibleIndexBook, type BibleIndexChapter, type BibleIndexVerse, type BiblePassage, type BibleVerse, type BibleVersion, type CANON, CANON_IDS, type Collection, type CreateHighlight, DEFAULT_LICENSE_FREE_BIBLE_VERSION, type DeleteHighlightOptions, type GetHighlightsOptions, type GetLanguagesOptions, type Highlight, type HighlightColor, HighlightsClient, type Language, LanguagesClient, MemoryStorageStrategy, SessionStorageStrategy, SignInWithYouVersionPermission, type SignInWithYouVersionPermissionValues, SignInWithYouVersionResult, type StorageStrategy, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON, getAdjacentChapter };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,34 @@
1
1
  import { z } from 'zod';
2
+ export { a as TransformBibleHtmlOptions, T as TransformedBibleHtml, t as transformBibleHtml } from './browser-DzQ1yOHv.js';
3
+
4
+ declare const SignInWithYouVersionPermission: {
5
+ readonly bibles: "bibles";
6
+ readonly highlights: "highlights";
7
+ readonly votd: "votd";
8
+ readonly demographics: "demographics";
9
+ readonly bibleActivity: "bible_activity";
10
+ };
11
+ type SignInWithYouVersionResultProps = {
12
+ accessToken?: string;
13
+ expiresIn?: number;
14
+ refreshToken?: string;
15
+ idToken?: string;
16
+ yvpUserId?: string;
17
+ name?: string;
18
+ profilePicture?: string;
19
+ email?: string;
20
+ };
21
+ declare class SignInWithYouVersionResult {
22
+ readonly accessToken: string | undefined;
23
+ readonly expiryDate: Date | undefined;
24
+ readonly refreshToken: string | undefined;
25
+ readonly idToken: string | undefined;
26
+ readonly yvpUserId: string | undefined;
27
+ readonly name: string | undefined;
28
+ readonly profilePicture: string | undefined;
29
+ readonly email: string | undefined;
30
+ constructor({ accessToken, expiresIn, refreshToken, idToken, yvpUserId, name, profilePicture, email, }: SignInWithYouVersionResultProps);
31
+ }
2
32
 
3
33
  declare const BibleVersionSchema: z.ZodObject<{
4
34
  id: z.ZodNumber;
@@ -22,15 +52,12 @@ declare const CanonSchema: z.ZodEnum<{
22
52
  new_testament: "new_testament";
23
53
  deuterocanon: "deuterocanon";
24
54
  }>;
25
- type Canon = Readonly<z.infer<typeof CanonSchema>>;
26
55
  declare const BibleBookIntroSchema: z.ZodObject<{
27
56
  id: z.ZodString;
28
57
  passage_id: z.ZodString;
29
58
  title: z.ZodString;
30
59
  }, z.core.$strip>;
31
60
  type BibleBookIntro = Readonly<z.infer<typeof BibleBookIntroSchema>>;
32
- declare const BookUsfmSchema: z.ZodUnion<readonly [...z.ZodLiteral<"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" | "3ES" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO" | "LKA">[], z.ZodType<string & {}, unknown, z.core.$ZodTypeInternals<string & {}, unknown>>]>;
33
- type BookUsfm = z.infer<typeof BookUsfmSchema>;
34
61
  declare const BibleBookSchema: z.ZodObject<{
35
62
  id: z.ZodUnion<readonly [...z.ZodLiteral<"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" | "3ES" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO" | "LKA">[], z.ZodType<string & {}, unknown, z.core.$ZodTypeInternals<string & {}, unknown>>]>;
36
63
  title: z.ZodString;
@@ -207,36 +234,6 @@ interface ApiConfig {
207
234
  installationId?: string;
208
235
  redirectUri?: string;
209
236
  }
210
-
211
- declare const SignInWithYouVersionPermission: {
212
- readonly bibles: "bibles";
213
- readonly highlights: "highlights";
214
- readonly votd: "votd";
215
- readonly demographics: "demographics";
216
- readonly bibleActivity: "bible_activity";
217
- };
218
- type SignInWithYouVersionResultProps = {
219
- accessToken?: string;
220
- expiresIn?: number;
221
- refreshToken?: string;
222
- idToken?: string;
223
- yvpUserId?: string;
224
- name?: string;
225
- profilePicture?: string;
226
- email?: string;
227
- };
228
- declare class SignInWithYouVersionResult {
229
- readonly accessToken: string | undefined;
230
- readonly expiryDate: Date | undefined;
231
- readonly refreshToken: string | undefined;
232
- readonly idToken: string | undefined;
233
- readonly yvpUserId: string | undefined;
234
- readonly name: string | undefined;
235
- readonly profilePicture: string | undefined;
236
- readonly email: string | undefined;
237
- constructor({ accessToken, expiresIn, refreshToken, idToken, yvpUserId, name, profilePicture, email, }: SignInWithYouVersionResultProps);
238
- }
239
-
240
237
  type SignInWithYouVersionPermissionValues = (typeof SignInWithYouVersionPermission)[keyof typeof SignInWithYouVersionPermission];
241
238
  interface AuthenticationState {
242
239
  readonly isAuthenticated: boolean;
@@ -247,11 +244,6 @@ interface AuthenticationState {
247
244
  readonly error: Error | null;
248
245
  }
249
246
  type AuthenticationScopes = 'profile' | 'email';
250
-
251
- /**
252
- * Legacy type for highlight colors (constants only)
253
- * Not an API response, so no schema needed
254
- */
255
247
  interface HighlightColor {
256
248
  id: number;
257
249
  color: string;
@@ -399,12 +391,18 @@ declare class BibleClient {
399
391
  /**
400
392
  * Fetches a passage (range of verses) from the Bible using the passages endpoint.
401
393
  * This is the new API format that returns HTML-formatted content.
394
+ *
395
+ * Note: The HTML returned from the API contains inline footnote content that should
396
+ * be transformed before rendering. Use `transformBibleHtml()` or
397
+ * `transformBibleHtmlForBrowser()` to clean up the HTML and extract footnotes.
398
+ *
402
399
  * @param versionId The version ID.
403
400
  * @param usfm The USFM reference (e.g., "JHN.3.1-2", "GEN.1", "JHN.3.16").
404
401
  * @param format The format to return ("html" or "text", default: "html").
405
402
  * @param include_headings Whether to include headings in the content.
406
403
  * @param include_notes Whether to include notes in the content.
407
404
  * @returns The requested BiblePassage object with HTML content.
405
+ *
408
406
  * @example
409
407
  * ```ts
410
408
  * // Get a single verse
@@ -415,6 +413,10 @@ declare class BibleClient {
415
413
  *
416
414
  * // Get an entire chapter
417
415
  * const chapter = await bibleClient.getPassage(3034, "GEN.1");
416
+ *
417
+ * // Transform HTML before rendering
418
+ * const passage = await bibleClient.getPassage(3034, "JHN.3.16", "html", true, true);
419
+ * const transformed = transformBibleHtmlForBrowser(passage.content);
418
420
  * ```
419
421
  */
420
422
  getPassage(versionId: number, usfm: string, format?: 'html' | 'text', include_headings?: boolean, include_notes?: boolean): Promise<BiblePassage>;
@@ -724,12 +726,14 @@ declare class YouVersionPlatformConfiguration {
724
726
  * a good use-case for a default Bible Version.
725
727
  */
726
728
  declare const DEFAULT_LICENSE_FREE_BIBLE_VERSION: 3034;
729
+ declare const CANON_IDS: readonly ["old_testament", "new_testament", "deuterocanon"];
727
730
  declare const BOOK_IDS: readonly ["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", "3ES", "EZA", "5EZ", "6EZ", "DAG", "PS3", "2BA", "LBA", "JUB", "ENO", "1MQ", "2MQ", "3MQ", "REP", "4BA", "LAO", "LKA"];
728
-
731
+ type CanonId = (typeof CANON_IDS)[number];
732
+ type KnownBookUsfm = (typeof BOOK_IDS)[number];
729
733
  /**
730
734
  * @see https://github.com/youversion/usfm-references/blob/main/usfm_references/books.py
731
735
  */
732
- declare const BOOK_CANON: Record<BookUsfm, Canon>;
736
+ declare const BOOK_CANON: Record<KnownBookUsfm, CanonId>;
733
737
 
734
738
  type AdjacentChapterResult = {
735
739
  bookId: string;
@@ -746,4 +750,4 @@ type AdjacentChapterResult = {
746
750
  */
747
751
  declare function getAdjacentChapter(books: BibleBook[], currentBookId: string, currentChapterId: string, direction: 'next' | 'previous'): AdjacentChapterResult;
748
752
 
749
- export { ApiClient, type ApiConfig, type AuthenticationScopes, type AuthenticationState, BOOK_CANON, BOOK_IDS, type BibleBook, type BibleBookIntro, type BibleChapter, BibleClient, type BibleIndex, type BibleIndexBook, type BibleIndexChapter, type BibleIndexVerse, type BiblePassage, type BibleVerse, type BibleVersion, type CANON, type Collection, type CreateHighlight, DEFAULT_LICENSE_FREE_BIBLE_VERSION, type DeleteHighlightOptions, type GetHighlightsOptions, type GetLanguagesOptions, type Highlight, type HighlightColor, HighlightsClient, type Language, LanguagesClient, MemoryStorageStrategy, SessionStorageStrategy, SignInWithYouVersionPermission, type SignInWithYouVersionPermissionValues, SignInWithYouVersionResult, type StorageStrategy, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON, getAdjacentChapter };
753
+ export { ApiClient, type ApiConfig, type AuthenticationScopes, type AuthenticationState, BOOK_CANON, BOOK_IDS, type BibleBook, type BibleBookIntro, type BibleChapter, BibleClient, type BibleIndex, type BibleIndexBook, type BibleIndexChapter, type BibleIndexVerse, type BiblePassage, type BibleVerse, type BibleVersion, type CANON, CANON_IDS, type Collection, type CreateHighlight, DEFAULT_LICENSE_FREE_BIBLE_VERSION, type DeleteHighlightOptions, type GetHighlightsOptions, type GetLanguagesOptions, type Highlight, type HighlightColor, HighlightsClient, type Language, LanguagesClient, MemoryStorageStrategy, SessionStorageStrategy, SignInWithYouVersionPermission, type SignInWithYouVersionPermissionValues, SignInWithYouVersionResult, type StorageStrategy, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON, getAdjacentChapter };
package/dist/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ import {
2
+ transformBibleHtml
3
+ } from "./chunk-2Z2S2WY3.js";
4
+
1
5
  // src/client.ts
2
6
  var ApiClient = class {
3
7
  baseURL;
@@ -162,6 +166,7 @@ import { z as z3 } from "zod";
162
166
 
163
167
  // src/utils/constants.ts
164
168
  var DEFAULT_LICENSE_FREE_BIBLE_VERSION = 3034;
169
+ var CANON_IDS = ["old_testament", "new_testament", "deuterocanon"];
165
170
  var BOOK_IDS = [
166
171
  "GEN",
167
172
  "EXO",
@@ -403,7 +408,7 @@ var BibleChapterSchema = z2.object({
403
408
  });
404
409
 
405
410
  // src/schemas/book.ts
406
- var CanonSchema = z3.enum(["old_testament", "new_testament", "deuterocanon"]);
411
+ var CanonSchema = z3.enum(CANON_IDS);
407
412
  var BibleBookIntroSchema = z3.object({
408
413
  /** Intro identifier */
409
414
  id: z3.string(),
@@ -746,12 +751,18 @@ var BibleClient = class _BibleClient {
746
751
  /**
747
752
  * Fetches a passage (range of verses) from the Bible using the passages endpoint.
748
753
  * This is the new API format that returns HTML-formatted content.
754
+ *
755
+ * Note: The HTML returned from the API contains inline footnote content that should
756
+ * be transformed before rendering. Use `transformBibleHtml()` or
757
+ * `transformBibleHtmlForBrowser()` to clean up the HTML and extract footnotes.
758
+ *
749
759
  * @param versionId The version ID.
750
760
  * @param usfm The USFM reference (e.g., "JHN.3.1-2", "GEN.1", "JHN.3.16").
751
761
  * @param format The format to return ("html" or "text", default: "html").
752
762
  * @param include_headings Whether to include headings in the content.
753
763
  * @param include_notes Whether to include notes in the content.
754
764
  * @returns The requested BiblePassage object with HTML content.
765
+ *
755
766
  * @example
756
767
  * ```ts
757
768
  * // Get a single verse
@@ -762,6 +773,10 @@ var BibleClient = class _BibleClient {
762
773
  *
763
774
  * // Get an entire chapter
764
775
  * const chapter = await bibleClient.getPassage(3034, "GEN.1");
776
+ *
777
+ * // Transform HTML before rendering
778
+ * const passage = await bibleClient.getPassage(3034, "JHN.3.16", "html", true, true);
779
+ * const transformed = transformBibleHtmlForBrowser(passage.content);
765
780
  * ```
766
781
  */
767
782
  async getPassage(versionId, usfm, format = "html", include_headings, include_notes) {
@@ -1694,6 +1709,7 @@ export {
1694
1709
  BOOK_CANON,
1695
1710
  BOOK_IDS,
1696
1711
  BibleClient,
1712
+ CANON_IDS,
1697
1713
  DEFAULT_LICENSE_FREE_BIBLE_VERSION,
1698
1714
  HighlightsClient,
1699
1715
  LanguagesClient,
@@ -1705,5 +1721,6 @@ export {
1705
1721
  YouVersionAPIUsers,
1706
1722
  YouVersionPlatformConfiguration,
1707
1723
  YouVersionUserInfo,
1708
- getAdjacentChapter
1724
+ getAdjacentChapter,
1725
+ transformBibleHtml
1709
1726
  };
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/server.ts
21
+ var server_exports = {};
22
+ __export(server_exports, {
23
+ transformBibleHtml: () => transformBibleHtml2
24
+ });
25
+ module.exports = __toCommonJS(server_exports);
26
+
27
+ // src/bible-html-transformer-server.ts
28
+ var import_linkedom = require("linkedom");
29
+
30
+ // src/bible-html-transformer.ts
31
+ var NON_BREAKING_SPACE = "\xA0";
32
+ var FOOTNOTE_KEY_ATTR = "data-footnote-key";
33
+ var NEEDS_SPACE_BEFORE = /^[^\s.,;:!?)}\]'"'»›]/;
34
+ var ALLOWED_TAGS = /* @__PURE__ */ new Set([
35
+ "DIV",
36
+ "P",
37
+ "SPAN",
38
+ "SUP",
39
+ "SUB",
40
+ "EM",
41
+ "STRONG",
42
+ "I",
43
+ "B",
44
+ "SMALL",
45
+ "BR",
46
+ "SECTION",
47
+ "TABLE",
48
+ "THEAD",
49
+ "TBODY",
50
+ "TR",
51
+ "TD",
52
+ "TH"
53
+ ]);
54
+ var DROP_ENTIRELY_TAGS = /* @__PURE__ */ new Set([
55
+ "SCRIPT",
56
+ "STYLE",
57
+ "IFRAME",
58
+ "OBJECT",
59
+ "EMBED",
60
+ "SVG",
61
+ "MATH",
62
+ "FORM",
63
+ "INPUT",
64
+ "BUTTON",
65
+ "TEXTAREA",
66
+ "SELECT",
67
+ "TEMPLATE",
68
+ "LINK",
69
+ "META",
70
+ "BASE",
71
+ "NOSCRIPT"
72
+ ]);
73
+ var ALLOWED_ATTRS = /* @__PURE__ */ new Set(["class", "v", "colspan", "rowspan", "dir", "usfm"]);
74
+ function sanitizeBibleHtmlDocument(doc) {
75
+ const root = doc.body ?? doc.documentElement;
76
+ for (const el of Array.from(root.querySelectorAll("*"))) {
77
+ const tag = el.tagName;
78
+ if (DROP_ENTIRELY_TAGS.has(tag)) {
79
+ el.remove();
80
+ continue;
81
+ }
82
+ if (!ALLOWED_TAGS.has(tag)) {
83
+ el.replaceWith(...Array.from(el.childNodes));
84
+ continue;
85
+ }
86
+ for (const attr of Array.from(el.attributes)) {
87
+ const name = attr.name.toLowerCase();
88
+ if (name.startsWith("on")) {
89
+ el.removeAttribute(attr.name);
90
+ continue;
91
+ }
92
+ if (!ALLOWED_ATTRS.has(name) && !name.startsWith("data-")) {
93
+ el.removeAttribute(attr.name);
94
+ }
95
+ }
96
+ }
97
+ }
98
+ function wrapVerseContent(doc) {
99
+ function wrapParagraphContent(doc2, paragraph, verseNum) {
100
+ const children = Array.from(paragraph.childNodes);
101
+ if (children.length === 0) return;
102
+ const wrapper = doc2.createElement("span");
103
+ wrapper.className = "yv-v";
104
+ wrapper.setAttribute("v", verseNum);
105
+ const firstChild = children[0];
106
+ if (firstChild) {
107
+ paragraph.insertBefore(wrapper, firstChild);
108
+ }
109
+ children.forEach((child) => {
110
+ wrapper.appendChild(child);
111
+ });
112
+ }
113
+ function wrapParagraphsUntilBoundary(doc2, verseNum, startParagraph, endParagraph) {
114
+ if (!startParagraph) return;
115
+ let currentParagraph = startParagraph.nextElementSibling;
116
+ while (currentParagraph && currentParagraph !== endParagraph) {
117
+ const isHeading = currentParagraph.classList.contains("yv-h") || currentParagraph.matches(
118
+ ".s1, .s2, .s3, .s4, .ms, .ms1, .ms2, .ms3, .ms4, .mr, .sp, .sr, .qa, .r"
119
+ );
120
+ if (isHeading) {
121
+ currentParagraph = currentParagraph.nextElementSibling;
122
+ continue;
123
+ }
124
+ if (currentParagraph.querySelector(".yv-v[v]")) break;
125
+ if (currentParagraph.classList.contains("p") || currentParagraph.tagName === "P") {
126
+ wrapParagraphContent(doc2, currentParagraph, verseNum);
127
+ }
128
+ currentParagraph = currentParagraph.nextElementSibling;
129
+ }
130
+ }
131
+ function handleParagraphWrapping(doc2, currentParagraph, nextParagraph, verseNum) {
132
+ if (!currentParagraph) return;
133
+ if (!nextParagraph) {
134
+ wrapParagraphsUntilBoundary(doc2, verseNum, currentParagraph);
135
+ return;
136
+ }
137
+ if (currentParagraph !== nextParagraph) {
138
+ wrapParagraphsUntilBoundary(doc2, verseNum, currentParagraph, nextParagraph);
139
+ }
140
+ }
141
+ function processVerseMarker(marker, index, markers) {
142
+ const verseNum = marker.getAttribute("v");
143
+ if (!verseNum) return;
144
+ const nextMarker = markers[index + 1];
145
+ const nodesToWrap = collectNodesBetweenMarkers(marker, nextMarker);
146
+ if (nodesToWrap.length === 0) return;
147
+ const currentParagraph = marker.closest(".p, p, div.p");
148
+ const nextParagraph = nextMarker?.closest(".p, p, div.p") || null;
149
+ const doc2 = marker.ownerDocument;
150
+ wrapNodesInVerse(marker, verseNum, nodesToWrap);
151
+ handleParagraphWrapping(doc2, currentParagraph, nextParagraph, verseNum);
152
+ }
153
+ function wrapNodesInVerse(marker, verseNum, nodes) {
154
+ const wrapper = marker.ownerDocument.createElement("span");
155
+ wrapper.className = "yv-v";
156
+ wrapper.setAttribute("v", verseNum);
157
+ const firstNode = nodes[0];
158
+ if (firstNode) {
159
+ marker.parentNode?.insertBefore(wrapper, firstNode);
160
+ }
161
+ nodes.forEach((node) => {
162
+ wrapper.appendChild(node);
163
+ });
164
+ marker.remove();
165
+ }
166
+ function shouldStopCollecting(node, endMarker) {
167
+ if (node === endMarker) return true;
168
+ if (endMarker && node.nodeType === 1 && node.contains(endMarker)) return true;
169
+ return false;
170
+ }
171
+ function shouldSkipNode(node) {
172
+ return node.nodeType === 1 && node.classList.contains("yv-h");
173
+ }
174
+ function collectNodesBetweenMarkers(startMarker, endMarker) {
175
+ const nodes = [];
176
+ let current = startMarker.nextSibling;
177
+ while (current && !shouldStopCollecting(current, endMarker)) {
178
+ if (shouldSkipNode(current)) {
179
+ current = current.nextSibling;
180
+ continue;
181
+ }
182
+ nodes.push(current);
183
+ current = current.nextSibling;
184
+ }
185
+ return nodes;
186
+ }
187
+ const verseMarkers = Array.from(doc.querySelectorAll(".yv-v[v]"));
188
+ verseMarkers.forEach(processVerseMarker);
189
+ }
190
+ function assignFootnoteKeys(doc) {
191
+ let introIdx = 0;
192
+ doc.querySelectorAll(".yv-n.f").forEach((fn) => {
193
+ const verseNum = fn.closest(".yv-v[v]")?.getAttribute("v");
194
+ fn.setAttribute(FOOTNOTE_KEY_ATTR, verseNum ?? `intro-${introIdx++}`);
195
+ });
196
+ }
197
+ function replaceFootnotesWithAnchors(doc, footnotes) {
198
+ for (const fn of footnotes) {
199
+ const key = fn.getAttribute(FOOTNOTE_KEY_ATTR);
200
+ if (!key) continue;
201
+ const prev = fn.previousSibling;
202
+ const next = fn.nextSibling;
203
+ const prevText = prev?.textContent ?? "";
204
+ const nextText = next?.textContent ?? "";
205
+ const prevNeedsSpace = prevText.length > 0 && !/\s$/.test(prevText);
206
+ const nextNeedsSpace = nextText.length > 0 && NEEDS_SPACE_BEFORE.test(nextText);
207
+ if (prevNeedsSpace && nextNeedsSpace && fn.parentNode) {
208
+ fn.parentNode.insertBefore(doc.createTextNode(" "), fn);
209
+ }
210
+ const anchor = doc.createElement("span");
211
+ anchor.setAttribute("data-verse-footnote", key);
212
+ anchor.setAttribute("data-verse-footnote-content", fn.innerHTML);
213
+ fn.replaceWith(anchor);
214
+ }
215
+ }
216
+ function addNbspToVerseLabels(doc) {
217
+ doc.querySelectorAll(".yv-vlbl").forEach((label) => {
218
+ const text = label.textContent || "";
219
+ if (!text.endsWith(NON_BREAKING_SPACE)) {
220
+ label.textContent = text + NON_BREAKING_SPACE;
221
+ }
222
+ });
223
+ }
224
+ function fixIrregularTables(doc) {
225
+ doc.querySelectorAll("table").forEach((table) => {
226
+ const rows = table.querySelectorAll("tr");
227
+ if (rows.length === 0) return;
228
+ let maxColumns = 0;
229
+ rows.forEach((row) => {
230
+ let count = 0;
231
+ row.querySelectorAll("td, th").forEach((cell) => {
232
+ count += parseInt(cell.getAttribute("colspan") || "1", 10);
233
+ });
234
+ maxColumns = Math.max(maxColumns, count);
235
+ });
236
+ if (maxColumns > 1) {
237
+ rows.forEach((row) => {
238
+ const cells = row.querySelectorAll("td, th");
239
+ if (cells.length === 1) {
240
+ const existing = parseInt(cells[0].getAttribute("colspan") || "1", 10);
241
+ if (existing < maxColumns) {
242
+ cells[0].setAttribute("colspan", maxColumns.toString());
243
+ }
244
+ }
245
+ });
246
+ }
247
+ });
248
+ }
249
+ function transformBibleHtml(html, options) {
250
+ const doc = options.parseHtml(html);
251
+ sanitizeBibleHtmlDocument(doc);
252
+ wrapVerseContent(doc);
253
+ assignFootnoteKeys(doc);
254
+ const footnotes = Array.from(doc.querySelectorAll(".yv-n.f"));
255
+ replaceFootnotesWithAnchors(doc, footnotes);
256
+ addNbspToVerseLabels(doc);
257
+ fixIrregularTables(doc);
258
+ const transformedHtml = options.serializeHtml(doc);
259
+ return { html: transformedHtml };
260
+ }
261
+
262
+ // src/bible-html-transformer-server.ts
263
+ function transformBibleHtml2(html) {
264
+ return transformBibleHtml(html, {
265
+ parseHtml: (h) => new import_linkedom.DOMParser().parseFromString(
266
+ `<html><body>${h}</body></html>`,
267
+ "text/html"
268
+ ),
269
+ serializeHtml: (doc) => doc.body.innerHTML
270
+ });
271
+ }
272
+ // Annotate the CommonJS export names for ESM import in node:
273
+ 0 && (module.exports = {
274
+ transformBibleHtml
275
+ });