Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions config/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type BookTabConfig = {
bookTabID: string;
type: string;
file: string;
features: any;
features: FeatureConfig;
chapters?: number;
chaptersN?: string;
style?: StyleConfig;
Expand Down Expand Up @@ -78,7 +78,7 @@ export type BookConfig = {

export type BookCollectionConfig = {
id: string;
features: any;
features: FeatureConfig;
books: BookConfig[];
style?: StyleConfig;
fonts: string[];
Expand Down Expand Up @@ -251,7 +251,7 @@ export type AppConfig = {

export type ScriptureConfig = AppConfig & {
programType: 'SAB';
traits?: any;
traits?: FeatureConfig;
bookCollections?: BookCollectionConfig[];
videos?: {
id: string;
Expand Down Expand Up @@ -304,20 +304,22 @@ export type ScriptureConfig = AppConfig & {
features: {
[key: string]: string;
};
plans: {
id: string;
days: number;
title: {
[lang: string]: string;
};
filename: string;
jsonFilename: string;
image?: {
width: number;
height: number;
file: string;
};
}[];
plans: PlanItem[];
};
};

export type PlanItem = {
id: string;
days: number;
title: {
[lang: string]: string;
};
filename: string;
jsonFilename: string;
image?: {
width: number;
height: number;
file: string;
};
};

Expand Down Expand Up @@ -396,7 +398,7 @@ export type LinkMeta = {
export type ContentItem = {
id: number;
heading?: boolean;
features?: any;
features?: FeatureConfig;
title: LangContainer;
subtitle?: LangContainer;
audioFilename?: LangContainer;
Expand Down Expand Up @@ -425,7 +427,7 @@ export type ContentsData = {
title?: {
[lang: string]: string;
};
features?: any;
features?: FeatureConfig;
items?: ContentItem[];
nestedItems?: boolean;
screens?: ContentScreen[];
Expand Down
4 changes: 2 additions & 2 deletions convert/convertBooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ export async function convertBooks(
//loop through books in collection
const ignoredBooks = [];
// If the collection has a glossary, load it
if (scriptureConfig.traits['has-glossary']) {
if (scriptureConfig.traits?.['has-glossary']) {
bcGlossary = loadGlossary(collection, dataDir);
}
//add empty array of quizzes for book collection
Expand Down Expand Up @@ -777,7 +777,7 @@ function convertScriptureBook(
'\n' +
remainingLines;
}
if (context.scriptureConfig.traits['has-glossary']) {
if (context.scriptureConfig.traits?.['has-glossary']) {
content = verifyGlossaryEntries(content, bcGlossary);
}
if (context.scriptureConfig.mainFeatures['hide-empty-verses'] === true) {
Expand Down
5 changes: 4 additions & 1 deletion convert/convertConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@ function convertConfig(dataDir: string, verbose: number) {
if (videos.length > 0) {
data.videos = videos;
}
data.traits['has-video'] = data.videos && data.videos.length > 0;
const hasVideo = !!data.videos && data.videos.length > 0;
data.traits = data.traits
? { ...data.traits, 'has-video': hasVideo }
: { 'has-video': hasVideo };
data.illustrations = parseIllustrations(document, verbose);

const { layouts, defaultLayout } = parseLayouts(document, data.bookCollections, verbose);
Expand Down
15 changes: 9 additions & 6 deletions src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="@sveltejs/kit" />
/// <reference types="svelte-gestures" />
/// <reference types="$config" />
/// <reference types="svelte" />

// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
Expand Down Expand Up @@ -40,14 +41,16 @@ declare namespace App {
penColor: string;
}

type MenuActionHandler = (args: { text: string; url: string }) => void;

type TabMenuActionHandler = (args: { text: string; url: string; tab: string }) => void;

interface TabMenuOptions {
[key: string]: {
tab?: {
component: any;
props?: any;
icon?: Snippet<[string]>;
};
component: any;
props: any;
snippet?: Snippet<[string, TabMenuActionHandler]>;
visible: boolean;
};
}
Expand Down Expand Up @@ -75,8 +78,8 @@ declare namespace App {

interface CollectionGroup {
singlePane?: CollectionEntry;
sideBySide?: FixedLengthArray<[CollectionEntry, CollectionEntry]>;
verseByVerse?: FixedLengthArray<[CollectionEntry, CollectionEntry, CollectionEntry]>;
sideBySide?: [CollectionEntry, CollectionEntry];
verseByVerse?: [CollectionEntry, CollectionEntry, CollectionEntry];
}

interface UserPreferenceSetting {
Expand Down
26 changes: 14 additions & 12 deletions src/lib/components/AudioBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,34 @@ TODO:
refs,
s,
t,
userSettings
userSettings,
type PlayModeSettings
} from '$lib/data/stores';
import { AudioIcon } from '$lib/icons';
import PlayButton from './PlayButton.svelte';
import RepeatButton from './RepeatButton.svelte';

function mayResetPlayMode(hasTiming) {
function mayResetPlayMode(hasTiming: boolean) {
// If the current mode is repeatSelection and the reference is changed to something without timing
// (even chapter without audio), then reset the playMode. This matches how the Android app behaves.
if (!hasTiming && $playMode.mode === 'repeatSelection') {
playMode.reset();
}
}

function seekAudio(event) {
function seekAudio(event: MouseEvent) {
if (!$audioPlayer.loaded) {
return;
}
const progressBar = document.getElementById('progress-bar');
const percent = (event.clientX - progressBar.offsetLeft) / progressBar.offsetWidth;
const percent =
(event.clientX - (progressBar?.offsetLeft ?? 0)) / (progressBar?.offsetWidth ?? 1);
// Set the current time of the audio element to the corresponding time based on the percent
seek($audioPlayer.duration * percent);
}

let lastPlayMode = '';
function playModeChanged(value) {
function playModeChanged(value: PlayModeSettings) {
let key = '';

switch (value.mode) {
Expand All @@ -77,8 +79,8 @@ TODO:

let hintText = $state('');
let showHint = $state(false);
let hintTimeoutId = null;
function startShowHint(text) {
let hintTimeoutId: NodeJS.Timeout | null = null;
function startShowHint(text: string) {
showHint = true;
hintText = text;
if (hintTimeoutId) {
Expand All @@ -92,14 +94,14 @@ TODO:

const showSpeed = config.mainFeatures['settings-audio-speed'];
const showRepeatMode = config.mainFeatures['audio-repeat-mode-button'];
const hintStyle = convertStyle($s['ui.bar.audio.hint.text']);
const hintStyle = convertStyle($s?.['ui.bar.audio.hint.text']);
const playButtonState = $derived($audioPlayer.playing ? 'pause' : 'play');
const iconColor = $derived($s['ui.bar.audio.icon']['color']);
const iconPlayColor = $derived($s['ui.bar.audio.play.icon']['color']);
const backgroundColor = $derived($s['ui.bar.audio']['background-color']);
const iconColor = $derived($s?.['ui.bar.audio.icon']['color']);
const iconPlayColor = $derived($s?.['ui.bar.audio.play.icon']['color']);
const backgroundColor = $derived($s?.['ui.bar.audio']['background-color']);
const audioBarClass = $derived($refs.hasAudio?.timingFile ? 'audio-bar' : 'audio-bar-progress');
$effect(() => mayResetPlayMode($refs.hasAudio?.timing));
$effect(() => updatePlaybackSpeed($userSettings['audio-speed']));
$effect(() => updatePlaybackSpeed($userSettings['audio-speed'] as string));
</script>

<div class="relative {audioBarClass}" style:background-color={backgroundColor}>
Expand Down
12 changes: 6 additions & 6 deletions src/lib/components/AudioPlaybackSpeed.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script>
<script lang="ts">
import { monoIconColor, t, userSettings } from '$lib/data/stores';
import Modal from './Modal.svelte';

Expand All @@ -19,17 +19,17 @@
{ value: '1.6', label: '1.6x' }
];

function setPlaySpeed(event) {
$userSettings['audio-speed'] = event.target.value;
function setPlaySpeed(value: string) {
$userSettings['audio-speed'] = value;
}

let modalThis;
let modalThis: HTMLDialogElement;
export function showModal() {
modalThis.showModal();
}
</script>

<Modal bind:this={modalThis} id={modalId}>
<Modal bind:dialog={modalThis} id={modalId}>
<div style="color: {$monoIconColor}">
<h1>
<b>{$t['Settings_Audio_Speed']}</b>
Expand All @@ -41,7 +41,7 @@
type="radio"
name="speed"
{value}
on:click={setPlaySpeed}
on:click={(e) => setPlaySpeed(e.currentTarget.value)}
checked={$userSettings['audio-speed'] === value}
/>
{label}
Expand Down
Loading
Loading