Skip to content

Commit

Permalink
Rename all the config types
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvire committed Nov 14, 2024
1 parent 7db575c commit 3f20fb9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
22 changes: 11 additions & 11 deletions config/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type HTML = string;

export type BookCollectionAudioData = {
export type BookCollectionAudioConfig = {
num: number;
src: string;
len?: number;
Expand All @@ -9,7 +9,7 @@ export type BookCollectionAudioData = {
timingFile: string;
};

export type StyleData = {
export type StyleConfig = {
font: string;
textSize: number;
lineHeight: number;
Expand All @@ -18,7 +18,7 @@ export type StyleData = {
verseNumbers: string;
};

export type BookData = {
export type BookConfig = {
id: string;
type?: string;
format?: string;
Expand All @@ -34,11 +34,11 @@ export type BookData = {
chaptersN: string; // 1-34
fonts: string[];
file: string;
audio: BookCollectionAudioData[];
audio: BookCollectionAudioConfig[];
features: any;
quizFeatures?: any;
footer?: HTML;
style?: StyleData;
style?: StyleConfig;
styles?: {
name: string;
category?: string;
Expand All @@ -48,11 +48,11 @@ export type BookData = {
}[];
};

export type BookCollectionData = {
export type BookCollectionConfig = {
id: string;
features: any;
books: BookData[];
style?: StyleData;
books: BookConfig[];
style?: StyleConfig;
fonts: string[];
languageCode: string;
languageName?: string;
Expand All @@ -73,7 +73,7 @@ export type BookCollectionData = {
collectionDescription?: string;
};

export type AudioData = {
export type AudioConfig = {
sources: {
[key: string]: {
type: string;
Expand Down Expand Up @@ -149,7 +149,7 @@ export type AppConfig = {

export type ScriptureConfig = AppConfig & {
traits?: any;
bookCollections?: BookCollectionData[];
bookCollections?: BookCollectionConfig[];
interfaceLanguages?: {
useSystemLanguage: boolean;
writingSystems: {
Expand All @@ -174,7 +174,7 @@ export type ScriptureConfig = AppConfig & {
};
}[];
};
audio?: AudioData;
audio?: AudioConfig;
videos?: {
id: string;
src?: string;
Expand Down
8 changes: 4 additions & 4 deletions convert/convertBooks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
///<reference path="./proskomma.d.ts"/>

import type { ScriptureConfig, BookData } from '$config';
import type { ScriptureConfig, BookConfig } from '$config';
import type { ConfigTaskOutput } from './convertConfig';
import { TaskOutput, Task, Promisable } from './Task';
import * as fs from 'fs';
Expand Down Expand Up @@ -428,7 +428,7 @@ export type Quiz = {
passScore?: number; //\pm
};

function convertHtmlBook(context: ConvertBookContext, book: BookData, files: any[]) {
function convertHtmlBook(context: ConvertBookContext, book: BookConfig, files: any[]) {
const srcFile = path.join(context.dataDir, 'books', context.bcId, book.file);
const dstFile = path.join('static', 'collections', context.bcId, book.file);

Expand All @@ -440,7 +440,7 @@ function convertHtmlBook(context: ConvertBookContext, book: BookData, files: any
});
}

function convertQuizBook(context: ConvertBookContext, book: BookData): Quiz {
function convertQuizBook(context: ConvertBookContext, book: BookConfig): Quiz {
if (context.verbose) {
console.log('Converting QuizBook:', book.id);
}
Expand Down Expand Up @@ -568,7 +568,7 @@ function updateExplanation(
function convertScriptureBook(
pk: SABProskomma,
context: ConvertBookContext,
book: BookData,
book: BookConfig,
bcGlossary: string[],
docs: Promise<void>[],
files: string[]
Expand Down
12 changes: 6 additions & 6 deletions convert/convertConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { convertMarkdownsToHTML } from './convertMarkdown';
import { splitVersion } from './stringUtils';
import type {
ScriptureConfig,
BookCollectionData,
BookCollectionAudioData,
StyleData,
BookCollectionConfig,
BookCollectionAudioConfig,
StyleConfig,
DictionaryConfig
} from '$config';

Expand Down Expand Up @@ -74,7 +74,7 @@ function parseStyles(stylesTag: Element, verbose: number) {

return styles;
}
function parseStylesInfo(stylesInfoTag: Element, verbose: number): StyleData {
function parseStylesInfo(stylesInfoTag: Element, verbose: number): StyleConfig {
return {
font: stylesInfoTag.getElementsByTagName('text-font')[0].attributes.getNamedItem('family')!
.value,
Expand Down Expand Up @@ -473,11 +473,11 @@ function parseBookCollections(document: Document, verbose: number) {
feature.attributes.getNamedItem('value')!.value
);
}
const books: BookCollectionData['books'] = [];
const books: BookCollectionConfig['books'] = [];
const bookTags = tag.getElementsByTagName('book');
for (const book of bookTags) {
if (verbose >= 2) console.log(`. book: ${book.id}`);
const audio: BookCollectionAudioData[] = [];
const audio: BookCollectionAudioConfig[] = [];
for (const page of book.getElementsByTagName('page')) {
if (verbose >= 2) console.log(`.. page: ${page.attributes[0].value}`);
const audioTag = page.getElementsByTagName('audio')[0];
Expand Down

0 comments on commit 3f20fb9

Please sign in to comment.