@faith-tools/bible-sdk 0.0.0-stage → 0.6.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/LICENSE.md +21 -0
- package/README.md +535 -2
- package/dist/bible-sdk.js +261 -0
- package/dist/data/effect.js +65 -0
- package/dist/data.js +16 -0
- package/dist/index.js +946 -0
- package/dist/providers/fetch-bible.js +254 -0
- package/dist/providers/helloao.js +1 -0
- package/dist/providers/youversion.js +1 -0
- package/dist/providers-D_4UrThl.js +431 -0
- package/dist/runtime-C-BCRjZd.js +220 -0
- package/dist/scripture-inline.js +261 -0
- package/dist/types/card.d.ts +20 -0
- package/dist/types/data-effect.d.ts +184 -0
- package/dist/types/data-helpers.d.ts +21 -0
- package/dist/types/data-types.d.ts +112 -0
- package/dist/types/data.d.ts +91 -0
- package/dist/types/dom-runtime.d.ts +5 -0
- package/dist/types/find.d.ts +12 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/passage-input.d.ts +57 -0
- package/dist/types/providers/fetch-bible.d.ts +14 -0
- package/dist/types/providers/helloao.d.ts +1 -0
- package/dist/types/providers/youversion.d.ts +1 -0
- package/dist/types/providers.d.ts +62 -0
- package/dist/types/runtime.d.ts +18 -0
- package/dist/types/scan.d.ts +8 -0
- package/dist/types/scripture-passage.d.ts +61 -0
- package/dist/types/version-input.d.ts +64 -0
- package/package.json +78 -3
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { a as e, d as t, f as n, i as r, l as i, n as a, o, r as s, s as c, u as l, v as u } from "../runtime-C-BCRjZd.js";
|
|
2
|
+
import { Effect as d, Schema as f } from "effect";
|
|
3
|
+
import { FetchClient as p } from "@gracious.tech/fetch-client";
|
|
4
|
+
import m from "sanitize-html";
|
|
5
|
+
// src/providers/fetch-bible.ts
|
|
6
|
+
var h = {
|
|
7
|
+
containerAttributes: { class: "fetch-bible fb-plain scripture-bible no-notes no-chapters" },
|
|
8
|
+
stylesheets: [{
|
|
9
|
+
kind: "bible",
|
|
10
|
+
href: "https://cdn.jsdelivr.net/npm/@gracious.tech/fetch-client@2.6.0/dist/client.css"
|
|
11
|
+
}]
|
|
12
|
+
}, g = (e) => d.try({
|
|
13
|
+
try: e,
|
|
14
|
+
catch: (e) => new u({
|
|
15
|
+
code: "invalid_response",
|
|
16
|
+
message: "fetch.bible returned invalid resource data.",
|
|
17
|
+
cause: e
|
|
18
|
+
})
|
|
19
|
+
}), _ = f.Union([f.String, f.Struct({
|
|
20
|
+
type: f.Literals(["heading", "note"]),
|
|
21
|
+
contents: f.String
|
|
22
|
+
})]), v = a(f.Array(f.Struct({
|
|
23
|
+
chapter: f.Int,
|
|
24
|
+
verse: f.Int,
|
|
25
|
+
content: f.Array(_)
|
|
26
|
+
})));
|
|
27
|
+
function y(_) {
|
|
28
|
+
let y = {
|
|
29
|
+
usage: { ..._.usage },
|
|
30
|
+
remember_fetches: !1
|
|
31
|
+
}, b = new p(y), x = l(), S = (e) => ({
|
|
32
|
+
id: e.id,
|
|
33
|
+
title: e.name_local || e.name_english,
|
|
34
|
+
abbreviation: e.name_local_abbrev || e.name_english_abbrev || e.id,
|
|
35
|
+
language: new Intl.Locale(e.language).language
|
|
36
|
+
}), C = d.fn("fetchBible.catalog")(function* () {
|
|
37
|
+
return yield* x.get("catalog", () => d.gen(function* () {
|
|
38
|
+
let t = yield* s("fetchBible.collection", () => b.fetch_collection()), n = yield* g(() => t.bibles.get_resources()).pipe(d.tap(a(f.Array(f.Struct({ language: e })))));
|
|
39
|
+
return {
|
|
40
|
+
collection: t,
|
|
41
|
+
resources: new Map(n.map((e) => [e.id, e]))
|
|
42
|
+
};
|
|
43
|
+
}));
|
|
44
|
+
}), w = d.fnUntraced(function* (e, t) {
|
|
45
|
+
let { collection: n, resources: r } = yield* C(), i = r.get(e);
|
|
46
|
+
return i ? t && !n.bibles.has_book(e, t) ? yield* new u({
|
|
47
|
+
code: "unavailable",
|
|
48
|
+
message: "Book is not available in this version."
|
|
49
|
+
}) : {
|
|
50
|
+
collection: n,
|
|
51
|
+
item: i
|
|
52
|
+
} : yield* new u({
|
|
53
|
+
code: "unavailable",
|
|
54
|
+
message: "Version is unavailable for this usage configuration."
|
|
55
|
+
});
|
|
56
|
+
}), T = d.fn("fetchBible.textBook")(function* (e, t) {
|
|
57
|
+
let { collection: n, item: r } = yield* w(e, t);
|
|
58
|
+
return {
|
|
59
|
+
collection: n,
|
|
60
|
+
item: r,
|
|
61
|
+
contents: yield* x.get(JSON.stringify([
|
|
62
|
+
e,
|
|
63
|
+
t,
|
|
64
|
+
"txt"
|
|
65
|
+
]), () => s("fetchBible.textBook", () => n.bibles.fetch_book(e, t, "txt")).pipe(d.tap((e) => g(() => e.get_list()).pipe(d.flatMap(v)))))
|
|
66
|
+
};
|
|
67
|
+
}), E = (e, t) => d.gen(function* () {
|
|
68
|
+
let { collection: n } = yield* w(e, t);
|
|
69
|
+
return yield* x.get(JSON.stringify([
|
|
70
|
+
e,
|
|
71
|
+
t,
|
|
72
|
+
"html"
|
|
73
|
+
]), () => s("fetchBible.htmlBook", () => n.bibles.fetch_book(e, t, "html")).pipe(d.tap((e) => g(() => e.get_list()).pipe(d.flatMap(a(f.Array(f.Struct({ content: f.String }))))))));
|
|
74
|
+
}), D = (e) => x.get(JSON.stringify([e, "books"]), () => d.gen(function* () {
|
|
75
|
+
let { collection: t } = yield* w(e);
|
|
76
|
+
return yield* s("fetchBible.extras", () => t.bibles.fetch_translation_extras(e)), yield* g(() => t.bibles.get_books(e));
|
|
77
|
+
})), O = {
|
|
78
|
+
id: "fetch-bible",
|
|
79
|
+
defaultVersionId: "eng_bsb",
|
|
80
|
+
clearCache: x.clear.pipe(d.andThen(d.sync(() => {
|
|
81
|
+
b = new p(y);
|
|
82
|
+
}))),
|
|
83
|
+
listVersions: d.fn("fetchBible.listVersions")(function* () {
|
|
84
|
+
let { collection: e, resources: t } = yield* C();
|
|
85
|
+
return [...t.values()].map((t) => ({
|
|
86
|
+
...S(t),
|
|
87
|
+
languageName: e.bibles.get_language(t.language)?.name_english
|
|
88
|
+
}));
|
|
89
|
+
}),
|
|
90
|
+
listBooks: d.fn("fetchBible.listBooks")(function* (e) {
|
|
91
|
+
return (yield* D(e)).filter((e) => e.available).map((e) => ({
|
|
92
|
+
id: e.id.toUpperCase(),
|
|
93
|
+
title: e.name_local || e.name_english
|
|
94
|
+
}));
|
|
95
|
+
}),
|
|
96
|
+
listChapters: d.fn("fetchBible.listChapters")(function* (e, t) {
|
|
97
|
+
let n = yield* c(t), { contents: r } = yield* T(e, n.toLowerCase());
|
|
98
|
+
return [...new Set(r.get_list().map((e) => e.chapter))].map((e) => ({
|
|
99
|
+
number: e,
|
|
100
|
+
passageId: `${t}.${e}`
|
|
101
|
+
}));
|
|
102
|
+
}),
|
|
103
|
+
getPassageData: d.fn("fetchBible.getPassageData")(function* (e, r) {
|
|
104
|
+
let { book: a, chapter: o, first: s, last: c } = yield* i(r), l = a.toLowerCase(), { collection: d, item: f, contents: p } = yield* T(e, l), g = p.get_list(o, 1, o).map((e) => e.verse);
|
|
105
|
+
yield* n(g, s, c);
|
|
106
|
+
let _ = p.get_passage(o, s ?? 1, o, c ?? g.at(-1), {
|
|
107
|
+
attribute: !1,
|
|
108
|
+
headings: !1,
|
|
109
|
+
notes: !1,
|
|
110
|
+
verse_nums: !1
|
|
111
|
+
});
|
|
112
|
+
if (a === "PSA" && (s === void 0 || s === 1)) {
|
|
113
|
+
let t = yield* E(e, l), n = [];
|
|
114
|
+
m(t.get_verse(o, 1, { attribute: !1 }), {
|
|
115
|
+
allowedTags: m.defaults.allowedTags,
|
|
116
|
+
allowedAttributes: { "*": ["class"] },
|
|
117
|
+
exclusiveFilter: (e) => {
|
|
118
|
+
let t = e.attribs.class?.split(/\s+/) ?? [];
|
|
119
|
+
return t.includes("fb-d") ? (n.push(e.text.trim()), !0) : e.tag === "sup" || t.includes("fb-note");
|
|
120
|
+
}
|
|
121
|
+
}), n.length && (_ = `${n.join("\n")}\n\n${_}`);
|
|
122
|
+
}
|
|
123
|
+
let v = p.get_attribution(f.licenses[0]).trim();
|
|
124
|
+
if (!v) return yield* new u({
|
|
125
|
+
code: "unavailable",
|
|
126
|
+
message: "This Bible version has no display attribution."
|
|
127
|
+
});
|
|
128
|
+
let y = d.bibles.get_book_url(e, l, "txt"), b = (yield* D(e)).find((e) => e.id === l).name, x = [{
|
|
129
|
+
versions: [
|
|
130
|
+
"eng_bstj",
|
|
131
|
+
"eng_bstjb",
|
|
132
|
+
"grc_lxx"
|
|
133
|
+
],
|
|
134
|
+
book: "EXO",
|
|
135
|
+
firstChapter: 35,
|
|
136
|
+
firstVerse: 1,
|
|
137
|
+
lastChapter: 40,
|
|
138
|
+
lastVerse: 38
|
|
139
|
+
}, {
|
|
140
|
+
versions: [
|
|
141
|
+
"eng_bst",
|
|
142
|
+
"eng_bstb",
|
|
143
|
+
"eng_bstj",
|
|
144
|
+
"eng_bstjb",
|
|
145
|
+
"grc_bre",
|
|
146
|
+
"grc_lxx"
|
|
147
|
+
],
|
|
148
|
+
book: "JER",
|
|
149
|
+
firstChapter: 25,
|
|
150
|
+
firstVerse: 14,
|
|
151
|
+
lastChapter: 52,
|
|
152
|
+
lastVerse: 34
|
|
153
|
+
}].filter((t) => t.versions.includes(e)).map((e) => ({
|
|
154
|
+
kind: "source-trimming",
|
|
155
|
+
startPassageId: `${e.book}.${e.firstChapter}.${e.firstVerse}`,
|
|
156
|
+
endPassageId: `${e.book}.${e.lastChapter}.${e.lastVerse}`,
|
|
157
|
+
appliesToRequest: a === e.book && o >= e.firstChapter && o <= e.lastChapter && (o !== e.firstChapter || c === void 0 || c >= e.firstVerse) && (o !== e.lastChapter || s === void 0 || s <= e.lastVerse)
|
|
158
|
+
}));
|
|
159
|
+
return {
|
|
160
|
+
provider: "fetch-bible",
|
|
161
|
+
source: {
|
|
162
|
+
url: y,
|
|
163
|
+
versionId: f.id
|
|
164
|
+
},
|
|
165
|
+
requestedPassageId: r,
|
|
166
|
+
passageId: r,
|
|
167
|
+
reference: `${b} ${o}${s === void 0 ? "" : `:${s}${c === s ? "" : `-${c}`}`}`,
|
|
168
|
+
text: _.trim(),
|
|
169
|
+
version: {
|
|
170
|
+
...S(f),
|
|
171
|
+
sourceLanguage: f.language
|
|
172
|
+
},
|
|
173
|
+
attribution: {
|
|
174
|
+
text: `${v} · Source: fetch.bible`,
|
|
175
|
+
urls: [
|
|
176
|
+
f.attribution_url,
|
|
177
|
+
...f.licenses.map((e) => e.url),
|
|
178
|
+
"https://fetch.bible/"
|
|
179
|
+
].filter(Boolean)
|
|
180
|
+
},
|
|
181
|
+
licenses: f.licenses.map((e) => ({
|
|
182
|
+
name: e.name,
|
|
183
|
+
url: e.url,
|
|
184
|
+
restrictions: { ...e.restrictions }
|
|
185
|
+
})),
|
|
186
|
+
numbering: "kjv",
|
|
187
|
+
sourceLimitations: x,
|
|
188
|
+
display: {
|
|
189
|
+
format: "text",
|
|
190
|
+
whitespace: "pre-wrap",
|
|
191
|
+
attributionPlacement: "after-passage",
|
|
192
|
+
direction: f.direction,
|
|
193
|
+
language: S(f).language,
|
|
194
|
+
nativeHtml: h
|
|
195
|
+
},
|
|
196
|
+
instructions: [
|
|
197
|
+
...t(),
|
|
198
|
+
{
|
|
199
|
+
code: "fetch-bible-normalization",
|
|
200
|
+
level: "notice",
|
|
201
|
+
appliesTo: "all",
|
|
202
|
+
text: "The official collection uses KJV-normalized numbering, retains empty verse slots, and contains only the Protestant 66-book canon. sourceLimitations identifies documented trimmed ranges for this edition and whether the request overlaps them, not why an individual verse is empty. This is not an exhaustive lossless-source guarantee.",
|
|
203
|
+
urls: ["https://fetch.bible/content/", "https://fetch.bible/access/"]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
code: "fetch-bible-license",
|
|
207
|
+
level: "required",
|
|
208
|
+
appliesTo: "all",
|
|
209
|
+
text: "Usage filtering does not verify legal permission. Check the returned licenses and restrictions for the selected translation, including commercial, derivative, attribution, and share-alike conditions.",
|
|
210
|
+
urls: ["https://fetch.bible/legal/terms/"]
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
code: "fetch-bible-native-html",
|
|
214
|
+
level: "required",
|
|
215
|
+
appliesTo: "html",
|
|
216
|
+
text: "If you request native HTML through the display provider, apply its returned .fetch-bible container class and client stylesheet. The stylesheet separates notes from Scripture. Do not append inline attribution when displaying the separate attribution field.",
|
|
217
|
+
urls: ["https://fetch.bible/access/client/"]
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
};
|
|
221
|
+
}),
|
|
222
|
+
getPassageDisplay: d.fn("fetchBible.getPassageDisplay")(function* (e, t) {
|
|
223
|
+
let n = yield* O.getPassageData(e, t), { book: r, chapter: a, first: s, last: c } = yield* i(t), l = yield* E(e, r.toLowerCase()), u = s === void 0 ? l.get_chapter(a, { attribute: !1 }) : l.get_passage(a, s, a, c, { attribute: !1 });
|
|
224
|
+
return {
|
|
225
|
+
html: m(u, {
|
|
226
|
+
allowedTags: m.defaults.allowedTags,
|
|
227
|
+
allowedAttributes: {
|
|
228
|
+
"*": [
|
|
229
|
+
"class",
|
|
230
|
+
"data-c",
|
|
231
|
+
"data-v",
|
|
232
|
+
"dir",
|
|
233
|
+
"lang"
|
|
234
|
+
],
|
|
235
|
+
a: ["href"]
|
|
236
|
+
},
|
|
237
|
+
allowedSchemes: ["http", "https"],
|
|
238
|
+
exclusiveFilter: (e) => e.attribs.class?.split(/\s+/).includes("fb-note") || !1
|
|
239
|
+
}),
|
|
240
|
+
version: n.version,
|
|
241
|
+
attribution: n.attribution.text,
|
|
242
|
+
attributionHtml: `${o(n.attribution.text.replace(" · Source: fetch.bible", ""), n.licenses[0]?.url || "")} · Source: ${o("fetch.bible", "https://fetch.bible/")}`,
|
|
243
|
+
direction: n.display.direction,
|
|
244
|
+
containerAttributes: {
|
|
245
|
+
...h.containerAttributes,
|
|
246
|
+
lang: n.display.language || ""
|
|
247
|
+
},
|
|
248
|
+
stylesheets: h.stylesheets
|
|
249
|
+
};
|
|
250
|
+
})
|
|
251
|
+
};
|
|
252
|
+
return r(O);
|
|
253
|
+
}
|
|
254
|
+
export { y as createFetchBibleProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as createHelloAOProvider, i as helloaoProvider } from "../providers-D_4UrThl.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as createYouVersionProvider } from "../providers-D_4UrThl.js";
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, u, v as d } from "./runtime-C-BCRjZd.js";
|
|
2
|
+
import { Effect as f, Schema as p } from "effect";
|
|
3
|
+
import { FreeUseBibleApi as m } from "free-use-bible-api";
|
|
4
|
+
// src/providers.ts
|
|
5
|
+
var h = {}, g = o(p.Struct({ books: p.Array(p.Struct({
|
|
6
|
+
id: p.NonEmptyString,
|
|
7
|
+
name: p.String,
|
|
8
|
+
firstChapterNumber: p.Int.check(p.isGreaterThan(0)),
|
|
9
|
+
lastChapterNumber: p.Int.check(p.isGreaterThan(0))
|
|
10
|
+
}).check(p.makeFilter((e) => e.lastChapterNumber >= e.firstChapterNumber))) })), _ = p.Struct({
|
|
11
|
+
id: p.NonEmptyString,
|
|
12
|
+
name: p.String,
|
|
13
|
+
language: e,
|
|
14
|
+
shortName: p.optional(p.String),
|
|
15
|
+
languageName: p.optional(p.String),
|
|
16
|
+
languageEnglishName: p.optional(p.String)
|
|
17
|
+
}), v = p.Array(p.Union([
|
|
18
|
+
p.Struct({
|
|
19
|
+
type: p.Literal("verse"),
|
|
20
|
+
number: p.Int,
|
|
21
|
+
content: p.Array(p.Union([
|
|
22
|
+
p.String,
|
|
23
|
+
p.Struct({
|
|
24
|
+
text: p.String,
|
|
25
|
+
poem: p.optional(p.Number),
|
|
26
|
+
wordsOfJesus: p.optional(p.Boolean)
|
|
27
|
+
}),
|
|
28
|
+
p.Struct({ noteId: p.Number }),
|
|
29
|
+
p.Struct({ heading: p.String }),
|
|
30
|
+
p.Struct({ lineBreak: p.Literal(!0) })
|
|
31
|
+
]))
|
|
32
|
+
}),
|
|
33
|
+
p.Struct({
|
|
34
|
+
type: p.Literals(["heading", "hebrew_subtitle"]),
|
|
35
|
+
content: p.Array(p.Union([
|
|
36
|
+
p.String,
|
|
37
|
+
p.Struct({ text: p.String }),
|
|
38
|
+
p.Struct({ noteId: p.Number })
|
|
39
|
+
]))
|
|
40
|
+
}),
|
|
41
|
+
p.Struct({ type: p.Literal("line_break") })
|
|
42
|
+
])), y = o(p.Struct({
|
|
43
|
+
translation: p.Struct({
|
|
44
|
+
id: p.NonEmptyString,
|
|
45
|
+
name: p.String,
|
|
46
|
+
licenseUrl: p.String,
|
|
47
|
+
language: e,
|
|
48
|
+
shortName: p.optional(p.String),
|
|
49
|
+
textDirection: p.optional(p.Literals(["ltr", "rtl"])),
|
|
50
|
+
licenseNotice: p.optional(p.NullOr(p.String)),
|
|
51
|
+
licenseNotes: p.optional(p.NullOr(p.String)),
|
|
52
|
+
license: p.optional(p.NullOr(p.Record(p.String, p.Union([p.Boolean, p.String]))))
|
|
53
|
+
}),
|
|
54
|
+
book: p.Struct({ name: p.String }),
|
|
55
|
+
chapter: p.Struct({ content: v })
|
|
56
|
+
})), b = (e) => o(p.Struct({ data: p.Array(e) }));
|
|
57
|
+
function x(e) {
|
|
58
|
+
return {
|
|
59
|
+
text: `${e.licenseNotice || `${e.name}. ${e.licenseUrl}`} · Source: HelloAO Free Use Bible API`,
|
|
60
|
+
html: `${e.licenseNotice ? t(e.licenseNotice) : `${s(e.name, e.licenseUrl)}.`} · Source: ${s("HelloAO Free Use Bible API", "https://bible.helloao.org/docs/")}`
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function S(e, n) {
|
|
64
|
+
let r = n === void 0 ? "" : `<sup class="scripture-verse-number">${n}</sup> `;
|
|
65
|
+
return e.map((e) => {
|
|
66
|
+
if (typeof e == "string" || "text" in e) {
|
|
67
|
+
let n = r;
|
|
68
|
+
if (r = "", typeof e == "string") return n + t(e);
|
|
69
|
+
let i = t(e.text), a = e.wordsOfJesus ? `<span class="scripture-jesus">${i}</span>` : i;
|
|
70
|
+
return e.poem === void 0 ? n + a : `<span class="scripture-poetry" style="--indent:${e.poem}">${n}${a}</span>`;
|
|
71
|
+
}
|
|
72
|
+
return "heading" in e ? `<span class="scripture-heading">${t(e.heading)}</span>` : "lineBreak" in e ? "<br>" : " ";
|
|
73
|
+
}).join("");
|
|
74
|
+
}
|
|
75
|
+
function C() {
|
|
76
|
+
let e = new m({ useCache: !1 }), s = u(), h = (t) => s.get(JSON.stringify(["books", t]), () => c("helloao.books", (n) => e.getTranslationBooks(t, void 0, { signal: n })).pipe(f.flatMap(g))), v = (t, n, r) => s.get(JSON.stringify([
|
|
77
|
+
"chapter",
|
|
78
|
+
t,
|
|
79
|
+
n,
|
|
80
|
+
r
|
|
81
|
+
]), () => c("helloao.chapter", (i) => e.getTranslationBookChapter(t, n, r, void 0, { signal: i })).pipe(f.flatMap(y))), b = {
|
|
82
|
+
id: "helloao",
|
|
83
|
+
defaultVersionId: "BSB",
|
|
84
|
+
clearCache: s.clear,
|
|
85
|
+
listBooks: f.fn("helloao.listBooks")(function* (e) {
|
|
86
|
+
return (yield* h(e)).books.map((e) => ({
|
|
87
|
+
id: e.id,
|
|
88
|
+
title: e.name
|
|
89
|
+
}));
|
|
90
|
+
}),
|
|
91
|
+
listChapters: f.fn("helloao.listChapters")(function* (e, t) {
|
|
92
|
+
yield* l(t);
|
|
93
|
+
let n = (yield* h(e)).books.find((e) => e.id === t);
|
|
94
|
+
return n ? Array.from({ length: n.lastChapterNumber - n.firstChapterNumber + 1 }, (e, r) => {
|
|
95
|
+
let i = n.firstChapterNumber + r;
|
|
96
|
+
return {
|
|
97
|
+
number: i,
|
|
98
|
+
passageId: `${t}.${i}`
|
|
99
|
+
};
|
|
100
|
+
}) : yield* new d({
|
|
101
|
+
code: "unavailable",
|
|
102
|
+
message: "Book is not available in this version."
|
|
103
|
+
});
|
|
104
|
+
}),
|
|
105
|
+
getPassageData: f.fn("helloao.getPassageData")(function* (t, i) {
|
|
106
|
+
let { book: o, chapter: s, first: c, last: l } = yield* a(i), u = yield* v(t, o, s), d = u.chapter.content.filter((e) => e.type === "verse");
|
|
107
|
+
yield* r(d.map((e) => e.number), c, l);
|
|
108
|
+
let f = "", p = !1;
|
|
109
|
+
for (let e of u.chapter.content) if (e.type === "verse") {
|
|
110
|
+
if (p = c === void 0 || e.number >= c && e.number <= l, !p) continue;
|
|
111
|
+
f && !/\s$/.test(f) && (f += " ");
|
|
112
|
+
let t;
|
|
113
|
+
for (let [n, r] of e.content.entries()) {
|
|
114
|
+
if (typeof r == "string" || "text" in r) {
|
|
115
|
+
let i = typeof r == "string" ? void 0 : r.poem, a = e.content[n - 1], o = a !== void 0 && typeof a != "string" && "noteId" in a && t !== void 0 && i === t;
|
|
116
|
+
t === void 0 && i === void 0 || o || !f || f.endsWith("\n") || (f = f.trimEnd() + "\n"), t = i;
|
|
117
|
+
}
|
|
118
|
+
if (typeof r == "string") f += r;
|
|
119
|
+
else if ("text" in r) f += r.text;
|
|
120
|
+
else if ("lineBreak" in r) f = f.trimEnd() + "\n";
|
|
121
|
+
else if ("noteId" in r) {
|
|
122
|
+
let t = e.content.slice(n + 1).find((e) => typeof e == "string" || "text" in e), r = typeof t == "string" ? t : t && "text" in t ? t.text : "";
|
|
123
|
+
f && !/\s$/.test(f) && r && !/^[\s,.;:!?…\)\]”’]/.test(r) && (f += " ");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
} else e.type === "hebrew_subtitle" && (c === void 0 || c === 1) ? f += e.content.map((e) => typeof e == "string" ? e : "text" in e ? e.text : "lineBreak" in e ? "\n" : "").join("") + "\n\n" : e.type === "line_break" && p && (f = f.trimEnd() + "\n\n");
|
|
127
|
+
let m = u.translation;
|
|
128
|
+
return {
|
|
129
|
+
provider: "helloao",
|
|
130
|
+
source: {
|
|
131
|
+
url: `${e.endpoint.replace(/\/$/, "")}/api/${encodeURIComponent(t)}/${o}/${s}.json`,
|
|
132
|
+
versionId: t
|
|
133
|
+
},
|
|
134
|
+
requestedPassageId: i,
|
|
135
|
+
passageId: i,
|
|
136
|
+
reference: `${u.book.name} ${s}${c === void 0 ? "" : `:${c}${l === c ? "" : `-${l}`}`}`,
|
|
137
|
+
text: f.trim(),
|
|
138
|
+
version: {
|
|
139
|
+
id: m.id,
|
|
140
|
+
title: m.name,
|
|
141
|
+
abbreviation: m.shortName || m.id,
|
|
142
|
+
language: new Intl.Locale(m.language).language,
|
|
143
|
+
sourceLanguage: m.language
|
|
144
|
+
},
|
|
145
|
+
attribution: {
|
|
146
|
+
text: x(m).text,
|
|
147
|
+
urls: [m.licenseUrl, "https://bible.helloao.org/docs/"].filter(Boolean)
|
|
148
|
+
},
|
|
149
|
+
licenses: m.licenseUrl || m.license ? [{
|
|
150
|
+
url: m.licenseUrl,
|
|
151
|
+
...m.license ? { restrictions: { ...m.license } } : {}
|
|
152
|
+
}] : [],
|
|
153
|
+
numbering: "unknown",
|
|
154
|
+
display: {
|
|
155
|
+
format: "text",
|
|
156
|
+
whitespace: "pre-wrap",
|
|
157
|
+
attributionPlacement: "after-passage",
|
|
158
|
+
direction: m.textDirection,
|
|
159
|
+
language: m.language
|
|
160
|
+
},
|
|
161
|
+
instructions: [...n(), ...m.licenseNotes ? [{
|
|
162
|
+
code: "translation-license-notes",
|
|
163
|
+
level: "notice",
|
|
164
|
+
appliesTo: "all",
|
|
165
|
+
text: m.licenseNotes
|
|
166
|
+
}] : []]
|
|
167
|
+
};
|
|
168
|
+
}),
|
|
169
|
+
listVersions: f.fn("helloao.listVersions")(function* () {
|
|
170
|
+
let { translations: t } = yield* s.get("translations", () => c("helloao.translations", (t) => e.getAvailableTranslations(void 0, { signal: t })).pipe(f.tap(o(p.Struct({ translations: p.Array(_) })))));
|
|
171
|
+
return t.map((e) => ({
|
|
172
|
+
id: e.id,
|
|
173
|
+
abbreviation: e.shortName || e.id,
|
|
174
|
+
title: e.name,
|
|
175
|
+
language: new Intl.Locale(e.language).language,
|
|
176
|
+
languageName: e.languageEnglishName || e.languageName || e.language
|
|
177
|
+
}));
|
|
178
|
+
}),
|
|
179
|
+
getPassageDisplay: f.fn("helloao.getPassageDisplay")(function* (e, n) {
|
|
180
|
+
let i = yield* a(n), o = yield* v(e, i.book, i.chapter), s = o.chapter.content.filter((e) => e.type === "verse");
|
|
181
|
+
yield* r(s.map((e) => e.number), i.first, i.last);
|
|
182
|
+
let c = Math.max(...s.map((e) => e.number)), l = i.first ?? 1, u = i.last ?? c, d = "", f = "", p = !1;
|
|
183
|
+
for (let e of o.chapter.content) e.type === "heading" ? d += `<h3 class="scripture-heading">${t(e.content.join(" "))}</h3>` : e.type === "verse" ? (p = e.number >= l && e.number <= u, p && (f += `${d}<span class="scripture-verse">${S(e.content, e.number)}</span> `), d = "") : e.type === "hebrew_subtitle" && l === 1 ? f += `<p class="scripture-subtitle">${S(e.content)}</p>` : e.type === "line_break" && p && (f += "<br>");
|
|
184
|
+
let m = o.translation, h = x(m);
|
|
185
|
+
return {
|
|
186
|
+
html: f,
|
|
187
|
+
version: {
|
|
188
|
+
id: m.id,
|
|
189
|
+
abbreviation: m.shortName || m.id,
|
|
190
|
+
title: m.name
|
|
191
|
+
},
|
|
192
|
+
attribution: h.text,
|
|
193
|
+
attributionHtml: h.html,
|
|
194
|
+
direction: m.textDirection,
|
|
195
|
+
containerAttributes: {
|
|
196
|
+
class: "scripture-bible",
|
|
197
|
+
lang: m.language
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
})
|
|
201
|
+
};
|
|
202
|
+
return i(b);
|
|
203
|
+
}
|
|
204
|
+
var w = C();
|
|
205
|
+
function T({ yvpPublicAppKey: u, yvpApiHost: m }) {
|
|
206
|
+
let h = p.String.check(p.isPattern(/^[1-9]\d*$/), p.makeFilter((e) => Number.isSafeInteger(Number(e)) || "Use a safe integer version ID.")), g = f.fnUntraced(function* (e) {
|
|
207
|
+
if (!u) return yield* new d({
|
|
208
|
+
code: "authentication",
|
|
209
|
+
message: "The YouVersion provider needs a public app key."
|
|
210
|
+
});
|
|
211
|
+
e !== void 0 && (yield* p.decodeUnknownEffect(h)(e).pipe(f.mapError((e) => new d({
|
|
212
|
+
code: "unavailable",
|
|
213
|
+
message: "Set a positive YouVersion Bible version ID.",
|
|
214
|
+
cause: e
|
|
215
|
+
}))));
|
|
216
|
+
let t = yield* c("youversion.loadSdk", () => import("@youversion/platform-core"));
|
|
217
|
+
return {
|
|
218
|
+
sdk: t,
|
|
219
|
+
client: new t.ApiClient({
|
|
220
|
+
appKey: u,
|
|
221
|
+
apiHost: m
|
|
222
|
+
})
|
|
223
|
+
};
|
|
224
|
+
}), _ = {
|
|
225
|
+
id: "youversion",
|
|
226
|
+
defaultVersionId: "3034",
|
|
227
|
+
clearCache: f.void,
|
|
228
|
+
listBooks: f.fn("youversion.listBooks")(function* (e) {
|
|
229
|
+
let { sdk: t, client: n } = yield* g(e);
|
|
230
|
+
return (yield* c("youversion.books", () => t.getBooks(n, Number(e))).pipe(f.tap(b(p.Struct({
|
|
231
|
+
id: p.String,
|
|
232
|
+
title: p.String
|
|
233
|
+
}))))).data.map((e) => ({
|
|
234
|
+
id: e.id,
|
|
235
|
+
title: e.title
|
|
236
|
+
}));
|
|
237
|
+
}),
|
|
238
|
+
listChapters: f.fn("youversion.listChapters")(function* (e, t) {
|
|
239
|
+
yield* l(t);
|
|
240
|
+
let { sdk: n, client: r } = yield* g(e);
|
|
241
|
+
return (yield* c("youversion.chapters", () => n.getChapters(r, Number(e), t)).pipe(f.tap(b(p.Struct({
|
|
242
|
+
id: p.String,
|
|
243
|
+
passage_id: p.String
|
|
244
|
+
}))))).data.map((e) => ({
|
|
245
|
+
number: Number(e.id),
|
|
246
|
+
passageId: e.passage_id
|
|
247
|
+
}));
|
|
248
|
+
}),
|
|
249
|
+
getPassageData: f.fn("youversion.getPassageData")(function* (t, i) {
|
|
250
|
+
let { book: s, chapter: l, first: h, last: _ } = yield* a(i), { sdk: v, client: y } = yield* g(t), x = yield* c("youversion.verses", () => v.getVerses(y, Number(t), s, l)).pipe(f.tap(b(p.Struct({ id: p.String }))));
|
|
251
|
+
yield* r(x.data.map((e) => Number(e.id)), h, _);
|
|
252
|
+
let [S, C] = yield* f.all([c("youversion.text", () => v.getPassage(y, Number(t), i, "text", !1, !1)).pipe(f.tap(o(p.Struct({
|
|
253
|
+
id: p.String,
|
|
254
|
+
reference: p.String,
|
|
255
|
+
content: p.String
|
|
256
|
+
})))), c("youversion.version", () => v.getVersion(y, Number(t))).pipe(f.tap(o(p.Struct({
|
|
257
|
+
id: p.Number,
|
|
258
|
+
localized_title: p.String,
|
|
259
|
+
localized_abbreviation: p.String,
|
|
260
|
+
language_tag: e,
|
|
261
|
+
copyright: p.optional(p.NullOr(p.String)),
|
|
262
|
+
promotional_content: p.optional(p.NullOr(p.String)),
|
|
263
|
+
publisher_url: p.optional(p.NullOr(p.String))
|
|
264
|
+
}))))], { concurrency: 2 }), w = v.getPassageAttribution(C);
|
|
265
|
+
return w ? {
|
|
266
|
+
provider: "youversion",
|
|
267
|
+
source: {
|
|
268
|
+
url: `https://${m || "api.youversion.com"}/v1`,
|
|
269
|
+
versionId: t
|
|
270
|
+
},
|
|
271
|
+
requestedPassageId: i,
|
|
272
|
+
passageId: S.id,
|
|
273
|
+
reference: S.reference,
|
|
274
|
+
text: S.content,
|
|
275
|
+
version: {
|
|
276
|
+
id: String(C.id),
|
|
277
|
+
title: C.localized_title,
|
|
278
|
+
abbreviation: C.localized_abbreviation,
|
|
279
|
+
language: C.language_tag,
|
|
280
|
+
sourceLanguage: C.language_tag
|
|
281
|
+
},
|
|
282
|
+
attribution: {
|
|
283
|
+
text: `${w.text} · Source: YouVersion Platform`,
|
|
284
|
+
urls: [C.publisher_url, "https://developers.youversion.com/"].filter((e) => !!e)
|
|
285
|
+
},
|
|
286
|
+
licenses: [],
|
|
287
|
+
numbering: "unknown",
|
|
288
|
+
display: {
|
|
289
|
+
format: "text",
|
|
290
|
+
whitespace: "pre-wrap",
|
|
291
|
+
attributionPlacement: "after-passage",
|
|
292
|
+
language: C.language_tag,
|
|
293
|
+
nativeHtml: {
|
|
294
|
+
containerAttributes: v.BIBLE_CONTAINER_ATTRIBUTES,
|
|
295
|
+
stylesheets: v.getBibleStylesheets({
|
|
296
|
+
appKey: u,
|
|
297
|
+
apiHost: m
|
|
298
|
+
})
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
instructions: [
|
|
302
|
+
...n(),
|
|
303
|
+
{
|
|
304
|
+
code: "youversion-commercial-use",
|
|
305
|
+
level: "required",
|
|
306
|
+
appliesTo: "all",
|
|
307
|
+
text: "YouVersion has no commercial-use flag. Its Platform terms do not grant Bible-content rights: confirm the selected publisher's license and applicable Tool terms before commercial use. Paid applications must conspicuously state that the YouVersion Bible App is free. fetch.bible usage settings do not apply to YouVersion.",
|
|
308
|
+
urls: ["https://platform.youversion.com/terms"]
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
code: "youversion-ai-use",
|
|
312
|
+
level: "required",
|
|
313
|
+
appliesTo: "all",
|
|
314
|
+
text: "YouVersion prohibits using its Tools with AI for open-ended user chat, except to retrieve and display Scripture verbatim, word-for-word and unaltered. Do not use the Tools to train, develop, refine, or improve AI. Cases beyond the expressly permitted uses require prior written YouVersion approval. The terms separately permit AI-assisted engineering and content generation subject to their stated conditions; review the full terms.",
|
|
315
|
+
urls: ["https://platform.youversion.com/terms"]
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
code: "youversion-terms",
|
|
319
|
+
level: "required",
|
|
320
|
+
appliesTo: "all",
|
|
321
|
+
text: "Follow your YouVersion account and content agreements. This SDK does not establish persistent caching or offline rights. Attribution is refreshed on every data request.",
|
|
322
|
+
urls: ["https://developers.youversion.com/sdks/javascript/guides/copyright-and-attribution"]
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
code: "youversion-native-html",
|
|
326
|
+
level: "required",
|
|
327
|
+
appliesTo: "html",
|
|
328
|
+
text: "If you request native HTML through the display provider, apply its returned containerAttributes and stylesheets. Load Untitled Serif from the YouVersion Fonts API; do not download or self-host its font files. These HTML resources are not required to interpret the plain-text result.",
|
|
329
|
+
urls: ["https://developers.youversion.com/guides/display-bible-html"]
|
|
330
|
+
}
|
|
331
|
+
]
|
|
332
|
+
} : yield* new d({
|
|
333
|
+
code: "unavailable",
|
|
334
|
+
message: "This Bible version has no display attribution."
|
|
335
|
+
});
|
|
336
|
+
}),
|
|
337
|
+
listVersions: f.fn("youversion.listVersions")(function* () {
|
|
338
|
+
let { sdk: { getVersions: t }, client: n } = yield* g(), r = new Intl.DisplayNames(["en"], { type: "language" }), i = [], a = /* @__PURE__ */ new Set(), o = null;
|
|
339
|
+
do {
|
|
340
|
+
let s = yield* c("youversion.versions", () => t(n, "*", void 0, {
|
|
341
|
+
page_size: 99,
|
|
342
|
+
page_token: o || void 0,
|
|
343
|
+
fields: [
|
|
344
|
+
"id",
|
|
345
|
+
"localized_abbreviation",
|
|
346
|
+
"localized_title",
|
|
347
|
+
"language_tag"
|
|
348
|
+
]
|
|
349
|
+
})).pipe(f.tap(b(p.Struct({
|
|
350
|
+
id: p.Number,
|
|
351
|
+
localized_abbreviation: p.String,
|
|
352
|
+
localized_title: p.String,
|
|
353
|
+
language_tag: e
|
|
354
|
+
}))));
|
|
355
|
+
if (i.push(...s.data.map((e) => ({
|
|
356
|
+
id: String(e.id),
|
|
357
|
+
abbreviation: e.localized_abbreviation,
|
|
358
|
+
title: e.localized_title,
|
|
359
|
+
language: e.language_tag,
|
|
360
|
+
languageName: r.of(e.language_tag)
|
|
361
|
+
}))), o = s.next_page_token, o && a.has(o)) return yield* new d({
|
|
362
|
+
code: "invalid_response",
|
|
363
|
+
message: "Bible provider repeated a catalog page token."
|
|
364
|
+
});
|
|
365
|
+
o && a.add(o);
|
|
366
|
+
} while (o);
|
|
367
|
+
return i;
|
|
368
|
+
}),
|
|
369
|
+
getPassageDisplay: f.fn("youversion.getPassageDisplay")(function* (e, n) {
|
|
370
|
+
yield* a(n);
|
|
371
|
+
let { sdk: { getPassageDisplay: r }, client: i } = yield* g(e), o = yield* c("youversion.html", () => r(i, {
|
|
372
|
+
versionId: Number(e),
|
|
373
|
+
passageId: n,
|
|
374
|
+
includeHeadings: !0,
|
|
375
|
+
includeNotes: !1
|
|
376
|
+
}));
|
|
377
|
+
return {
|
|
378
|
+
...o,
|
|
379
|
+
version: {
|
|
380
|
+
id: String(o.version.id),
|
|
381
|
+
abbreviation: o.version.localized_abbreviation,
|
|
382
|
+
title: o.version.localized_title
|
|
383
|
+
},
|
|
384
|
+
attribution: `${o.attribution.text} · Source: YouVersion Platform`,
|
|
385
|
+
attributionHtml: `${t(o.attribution.text)} · Source: ${s("YouVersion Platform", "https://developers.youversion.com/")}`,
|
|
386
|
+
yvpBibleVersion: o.version
|
|
387
|
+
};
|
|
388
|
+
})
|
|
389
|
+
};
|
|
390
|
+
return i(_);
|
|
391
|
+
}
|
|
392
|
+
var E = /* @__PURE__ */ new Map();
|
|
393
|
+
function D(e) {
|
|
394
|
+
if (typeof e.provider == "object") return e.provider;
|
|
395
|
+
if (!e.provider || e.provider === "helloao") return w;
|
|
396
|
+
if (e.provider !== "youversion") throw new d({
|
|
397
|
+
code: "unsupported",
|
|
398
|
+
message: `Unknown Bible provider: ${e.provider}`
|
|
399
|
+
});
|
|
400
|
+
let t = JSON.stringify([e.yvpPublicAppKey, e.yvpApiHost]), n = E.get(t);
|
|
401
|
+
return n || (n = T(e), E.set(t, n)), n;
|
|
402
|
+
}
|
|
403
|
+
var O = (e) => f.try({
|
|
404
|
+
try: () => D(e),
|
|
405
|
+
catch: (e) => e instanceof d ? e : new d({
|
|
406
|
+
code: "unsupported",
|
|
407
|
+
message: "Invalid Bible provider configuration.",
|
|
408
|
+
cause: e
|
|
409
|
+
})
|
|
410
|
+
}), k = /* @__PURE__ */ new WeakMap(), A = f.fn("scripture.listBibleVersions")(function* (e = {}) {
|
|
411
|
+
let t = yield* O({
|
|
412
|
+
...h,
|
|
413
|
+
...e
|
|
414
|
+
});
|
|
415
|
+
if (!t.listVersions) return yield* new d({
|
|
416
|
+
code: "unsupported",
|
|
417
|
+
message: "This Bible provider does not support listing versions."
|
|
418
|
+
});
|
|
419
|
+
let n = k.get(t);
|
|
420
|
+
return n || k.set(t, n = u()), yield* n.get("versions", () => t.effects?.listVersions() ?? c("custom.listVersions", () => t.listVersions(), !1));
|
|
421
|
+
});
|
|
422
|
+
function j(e = {}) {
|
|
423
|
+
return f.runPromise(A(e));
|
|
424
|
+
}
|
|
425
|
+
var M = /* @__PURE__ */ new WeakMap(), N = f.fn("scripture.fetchDisplay")(function* (e, t, n) {
|
|
426
|
+
let r = M.get(e);
|
|
427
|
+
r || M.set(e, r = u());
|
|
428
|
+
let i = JSON.stringify([t, n]);
|
|
429
|
+
return yield* r.get(i, () => e.effects?.getPassageDisplay(t, n) ?? c("custom.getPassage", () => e.getPassage(t, n), !1));
|
|
430
|
+
});
|
|
431
|
+
export { j as a, D as c, w as i, O as l, T as n, A as o, N as r, h as s, C as t };
|