@faith-tools/bible-sdk 0.0.0-stage → 0.7.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.
@@ -0,0 +1,62 @@
1
+ import { Effect } from "effect";
2
+ import { ScriptureError, type BibleDisplayProvider, type BibleVersion } from "./data-types.js";
3
+ export type { BibleVersion } from "./data-types.js";
4
+ /** Provider-owned HTML must be safe to insert into a shadow root. */
5
+ export type PassageDisplay = {
6
+ html: string;
7
+ version: BibleVersion;
8
+ attribution: string;
9
+ /** Optional safe HTML for linked attribution; plain attribution remains available. */
10
+ attributionHtml?: string;
11
+ direction?: "ltr" | "rtl";
12
+ containerAttributes?: Readonly<Record<string, string>>;
13
+ stylesheets?: readonly {
14
+ kind: "bible" | "font";
15
+ href: string;
16
+ }[];
17
+ /** Preserved for existing YouVersion scripture-load consumers. */
18
+ yvpBibleVersion?: unknown;
19
+ };
20
+ /** Both built-in providers and custom providers use this contract. */
21
+ export interface BibleProvider {
22
+ readonly id: string;
23
+ readonly defaultVersionId: string;
24
+ /** Native Effect operations, supplied by built-ins. Promise-only custom providers remain supported. */
25
+ readonly effects?: BibleDisplayProvider;
26
+ getPassage(versionId: string, passageId: string): Promise<PassageDisplay>;
27
+ /** Optional for passage-only custom providers. Required by the version picker. */
28
+ listVersions?(): Promise<BibleVersion[]>;
29
+ }
30
+ export type ProviderOptions = {
31
+ /** Default: helloao. YouVersion must be selected explicitly. */
32
+ provider?: "helloao" | "youversion" | BibleProvider;
33
+ /** The selected provider's version ID, such as BSB for HelloAO. */
34
+ bibleVersionId?: string;
35
+ yvpPublicAppKey?: string;
36
+ yvpBibleVersionId?: number;
37
+ yvpApiHost?: string;
38
+ };
39
+ export declare const providerDefaults: ProviderOptions;
40
+ export declare function createHelloAOProvider(): BibleProvider & {
41
+ readonly effects: BibleDisplayProvider;
42
+ };
43
+ export declare const helloaoProvider: BibleProvider & {
44
+ readonly effects: BibleDisplayProvider;
45
+ };
46
+ /** The SDK is loaded only when this provider is used. No YouVersion requests run by default. */
47
+ export declare function createYouVersionProvider({ yvpPublicAppKey, yvpApiHost }: Pick<ProviderOptions, "yvpPublicAppKey" | "yvpApiHost">): BibleProvider & {
48
+ readonly effects: BibleDisplayProvider;
49
+ };
50
+ export declare function resolveProvider(options: ProviderOptions): BibleProvider;
51
+ export declare const resolveProviderEffect: (options: ProviderOptions) => Effect.Effect<BibleProvider, ScriptureError, never>;
52
+ export declare const listBibleVersionsEffect: (options?: ProviderOptions | undefined) => Effect.Effect<{
53
+ readonly id: string;
54
+ readonly abbreviation: string;
55
+ readonly title: string;
56
+ readonly language?: string | undefined;
57
+ readonly languageName?: string | undefined;
58
+ }[], ScriptureError, never>;
59
+ /** Lists versions available from the configured provider, never a cross-provider guess. */
60
+ export declare function listBibleVersions(options?: ProviderOptions): Promise<BibleVersion[]>;
61
+ export declare const fetchDisplayEffect: (provider: BibleProvider, versionId: string, passageId: string) => Effect.Effect<PassageDisplay, ScriptureError, never>;
62
+ export declare function fetchDisplay(provider: BibleProvider, versionId: string, passageId: string): Promise<PassageDisplay>;
@@ -0,0 +1,18 @@
1
+ import { Context, Duration, Effect, Schema } from "effect";
2
+ import { ScriptureError, type BibleDisplayProvider } from "./data-types.js";
3
+ import type { BibleProvider } from "./providers.js";
4
+ export declare const decodeResponse: <S extends Schema.Constraint & {
5
+ DecodingServices: never;
6
+ }>(schema: S) => (value: unknown) => Effect.Effect<S["Type"], ScriptureError, S["DecodingServices"]>;
7
+ /** Override per program, including in tests. The timeout bounds the entire retry sequence. */
8
+ export declare const RequestPolicy: Context.Reference<{
9
+ timeout: Duration.Input;
10
+ retries: number;
11
+ }>;
12
+ export declare function requestError(cause: unknown): ScriptureError;
13
+ /** The only Promise boundary for upstream SDKs. Pass the signal when the SDK supports it. */
14
+ export declare const request: <A>(operation: string, load: (signal: AbortSignal) => PromiseLike<A>, retry?: boolean | undefined) => Effect.Effect<A, ScriptureError, never>;
15
+ /** Promise methods are compatibility edges, not the implementation of built-in providers. */
16
+ export declare function withPromises(effects: BibleDisplayProvider): BibleProvider & {
17
+ readonly effects: BibleDisplayProvider;
18
+ };
@@ -0,0 +1,8 @@
1
+ export declare const REF_CLASS = "scripture-inline-ref";
2
+ /**
3
+ * Wraps every Bible reference under `root` in an `<a>` to its route.bible
4
+ * page. Returns the links it created. Safe to run more than once.
5
+ */
6
+ export declare function wrapReferences(root: Node): HTMLAnchorElement[];
7
+ /** Turns links from wrapReferences back into the plain text they replaced. */
8
+ export declare function unwrapReferences(links: HTMLAnchorElement[]): void;
@@ -0,0 +1,61 @@
1
+ import { type BibleProvider, type ProviderOptions } from "./providers";
2
+ export declare const SCRIPTURE_PASSAGE_TAG = "si-passage";
3
+ export declare const BIBLE_PASSAGE_TAG = "bible-sk-passage";
4
+ export declare const BIBLE_TOKENS: Record<string, string>;
5
+ export type ReferenceLayout = "heading" | "citation" | "quote" | "none";
6
+ /**
7
+ * Displays Scripture with its required attribution. Works in the page or inside a shadow root.
8
+ *
9
+ * Attributes choose what shows: `reference`, `verse-numbers="hide"`, `red-letter="off"`,
10
+ * `headings="hide"`, `direction`, and `theme`. CSS properties choose how it looks:
11
+ * `--scripture-font-size`, `--scripture-line-height`, `--scripture-font-family`, `--scripture-max-width`.
12
+ * Parts: `text`, `citation`, `version`, `attribution`, `quote`, `loader`, `error`.
13
+ */
14
+ export declare class ScripturePassage extends HTMLElement {
15
+ static observedAttributes: string[];
16
+ private providerOverride?;
17
+ /** A custom provider for this passage. The provider attribute takes precedence. */
18
+ get bibleProvider(): BibleProvider | undefined;
19
+ set bibleProvider(provider: BibleProvider | undefined);
20
+ private generation;
21
+ /** The loaded passage, kept so a layout change re-renders without a request. */
22
+ private loaded;
23
+ private scheduled;
24
+ private cancelLoad?;
25
+ private cancelTheme?;
26
+ private cancelAnimation?;
27
+ private readonly systemDark;
28
+ private readonly onSystemTheme;
29
+ /** Holds everything the element shows, inside its shadow root. */
30
+ private readonly root;
31
+ constructor();
32
+ connectedCallback(): void;
33
+ disconnectedCallback(): void;
34
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
35
+ private scheduleLoad;
36
+ private applyTheme;
37
+ /** "heading" (default), "citation", "quote", or "none". */
38
+ get referenceLayout(): ReferenceLayout;
39
+ /** Swaps the reference layout in place. Only the label moves, so there is no loader or grow. */
40
+ private relayout;
41
+ /** Builds the passage, its reference and version in the chosen layout, and its attribution. */
42
+ private compose;
43
+ private showLoading;
44
+ private showError;
45
+ private readonly load;
46
+ /** Resolves once every Bible stylesheet has loaded (or failed, so text still shows). */
47
+ private installStylesheets;
48
+ /**
49
+ * Grows from the loader's height to the passage's height after removing the loader.
50
+ * The text fades in with a light blur.
51
+ */
52
+ private growFrom;
53
+ }
54
+ /** Registers <bible-sk-passage> and its <si-passage> compatibility name. */
55
+ export declare function defineScripturePassage(options?: ProviderOptions): void;
56
+ declare global {
57
+ interface HTMLElementTagNameMap {
58
+ "si-passage": ScripturePassage;
59
+ "bible-sk-passage": ScripturePassage;
60
+ }
61
+ }
@@ -0,0 +1,64 @@
1
+ import { type BibleProvider, type BibleVersion, type ProviderOptions } from "./providers";
2
+ export declare const VERSION_INPUT_TAG = "si-version-input";
3
+ export declare const BIBLE_VERSION_INPUT_TAG = "bible-sk-version-input";
4
+ export type VersionInputDetail = {
5
+ provider: string;
6
+ bibleVersionId: string;
7
+ bibleVersion: BibleVersion | null;
8
+ };
9
+ /** A form-associated translation picker. Search names/abbreviations, not provider IDs. */
10
+ export declare class ScriptureVersionInput extends HTMLElement {
11
+ static formAssociated: boolean;
12
+ static observedAttributes: string[];
13
+ private readonly internals;
14
+ private readonly input;
15
+ private readonly language;
16
+ private readonly list;
17
+ private readonly status;
18
+ private readonly retry;
19
+ private versions;
20
+ private filtered;
21
+ private selected?;
22
+ private pendingValue?;
23
+ private provider?;
24
+ private override?;
25
+ private active;
26
+ private generation;
27
+ private scheduled;
28
+ private cancelLoad?;
29
+ private loading;
30
+ private failed;
31
+ private formDisabled;
32
+ constructor();
33
+ connectedCallback(): void;
34
+ disconnectedCallback(): void;
35
+ attributeChangedCallback(name: string, old: string | null, value: string | null): void;
36
+ get value(): string;
37
+ set value(value: string);
38
+ get bibleProvider(): BibleProvider | undefined;
39
+ set bibleProvider(provider: BibleProvider | undefined);
40
+ get form(): HTMLFormElement | null;
41
+ get validity(): ValidityState;
42
+ get validationMessage(): string;
43
+ checkValidity(): boolean;
44
+ reportValidity(): boolean;
45
+ focus(options?: FocusOptions): void;
46
+ formResetCallback(): void;
47
+ formDisabledCallback(disabled: boolean): void;
48
+ private defaultValue;
49
+ private updateDisabled;
50
+ private close;
51
+ private highlight;
52
+ private suggest;
53
+ private commit;
54
+ private scheduleLoad;
55
+ private readonly load;
56
+ }
57
+ /** Registers <bible-sk-version-input> and <si-version-input>, sharing provider defaults. */
58
+ export declare function defineVersionInput(options?: ProviderOptions): void;
59
+ declare global {
60
+ interface HTMLElementTagNameMap {
61
+ "si-version-input": ScriptureVersionInput;
62
+ "bible-sk-version-input": ScriptureVersionInput;
63
+ }
64
+ }
package/package.json CHANGED
@@ -1,6 +1,87 @@
1
1
  {
2
2
  "name": "@faith-tools/bible-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.7.0",
4
+ "description": "Unified Bible data SDK with async and Effect APIs, plus drop-in Scripture web components.",
5
+ "license": "MIT",
6
+ "author": "Cameron Pak (https://cameronpak.com)",
7
+ "homepage": "https://bible-sdk.com",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/cameronapak/bible-sdk.git"
11
+ },
12
+ "bugs": "https://github.com/cameronapak/bible-sdk/issues",
13
+ "keywords": [
14
+ "bible",
15
+ "scripture",
16
+ "web-components",
17
+ "youversion",
18
+ "bible-references"
19
+ ],
20
+ "type": "module",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/types/index.d.ts",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./data": {
27
+ "types": "./dist/types/data.d.ts",
28
+ "default": "./dist/data.js"
29
+ },
30
+ "./data/effect": {
31
+ "types": "./dist/types/data-effect.d.ts",
32
+ "default": "./dist/data/effect.js"
33
+ },
34
+ "./providers/helloao": {
35
+ "types": "./dist/types/providers/helloao.d.ts",
36
+ "default": "./dist/providers/helloao.js"
37
+ },
38
+ "./providers/youversion": {
39
+ "types": "./dist/types/providers/youversion.d.ts",
40
+ "default": "./dist/providers/youversion.js"
41
+ },
42
+ "./providers/fetch-bible": {
43
+ "types": "./dist/types/providers/fetch-bible.d.ts",
44
+ "default": "./dist/providers/fetch-bible.js"
45
+ },
46
+ "./providers/api-bible": {
47
+ "types": "./dist/types/providers/api-bible.d.ts",
48
+ "browser": null,
49
+ "node": "./dist/providers/api-bible.js"
50
+ },
51
+ "./embed": "./dist/bible-sdk.js"
52
+ },
53
+ "types": "./dist/types/index.d.ts",
54
+ "files": [
55
+ "dist"
56
+ ],
57
+ "dependencies": {
58
+ "@gracious.tech/fetch-client": "2.6.0",
59
+ "@youversion/platform-core": "^2.16.0",
60
+ "effect": "^4.1.2",
61
+ "free-use-bible-api": "^1.16.0",
62
+ "grab-bcv": "^0.1.8",
63
+ "sanitize-html": "^2.18.1"
64
+ },
65
+ "devDependencies": {
66
+ "@americanbible/api-bible-sdk": "2.0.2",
67
+ "@changesets/cli": "3.0.3",
68
+ "@effect/vitest": "4.1.2",
69
+ "@faith-tools/sensible-ui": "1.8.2",
70
+ "@types/sanitize-html": "^2.16.2",
71
+ "jsdom": "^30.1.3",
72
+ "typescript": "^7.0.2",
73
+ "vite": "^8.3.5",
74
+ "vitest": "^5.0.5"
75
+ },
76
+ "scripts": {
77
+ "dev": "vite",
78
+ "build": "vite build && vite build --mode lib && tsc -p tsconfig.build.json",
79
+ "build:site": "vite build --mode site",
80
+ "typecheck": "tsc --noEmit",
81
+ "check:data-types": "tsc --ignoreConfig --noEmit --strict --module NodeNext --moduleResolution NodeNext --target ES2022 --lib ES2022,DOM scripts/check-data-types.ts",
82
+ "test": "vitest run",
83
+ "check": "pnpm typecheck && pnpm test && pnpm build && pnpm check:data-types && pnpm build:site",
84
+ "changeset": "changeset",
85
+ "version-packages": "changeset version && node scripts/sync-cdn-version.ts"
86
+ }
6
87
  }