Compare commits

...

3 Commits

Author SHA1 Message Date
monoid 4669e1c0d4 chore: .gitignore and package.json 2024-09-28 23:52:55 +09:00
monoid 2a5cb909b5 feat: optimize addList method to handle large content_list 2024-09-28 23:52:31 +09:00
monoid e5d410d809 avif support 2024-09-28 23:51:17 +09:00
5 changed files with 19 additions and 4 deletions

3
.gitignore vendored
View File

@ -14,7 +14,8 @@ app/**
settings.json settings.json
comic_config.json comic_config.json
**/comic_config.json **/comic_config.json
compiled/ compile/
compile/**
deploy-scripts/ deploy-scripts/
.pnpm-store/** .pnpm-store/**

View File

@ -6,7 +6,7 @@
"scripts": { "scripts": {
"compile": "swc src --out-dir compile", "compile": "swc src --out-dir compile",
"dev": "nodemon -r @swc-node/register --enable-source-maps --exec node app.ts", "dev": "nodemon -r @swc-node/register --enable-source-maps --exec node app.ts",
"start": "node compile/app.js" "start": "node compile/src/app.js"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",

View File

@ -14,7 +14,7 @@ interface ComicDesc {
character?: string[]; character?: string[];
tags?: string[]; tags?: string[];
} }
const ImageExt = [".gif", ".png", ".jpeg", ".bmp", ".webp", ".jpg"]; const ImageExt = [".gif", ".png", ".jpeg", ".bmp", ".webp", ".jpg", ".avif"];
export class ComicReferrer extends createDefaultClass("comic") { export class ComicReferrer extends createDefaultClass("comic") {
desc: ComicDesc | undefined; desc: ComicDesc | undefined;
pagenum: number; pagenum: number;

View File

@ -21,6 +21,20 @@ class SqliteDocumentAccessor implements DocumentAccessor {
throw new Error("Method not implemented."); throw new Error("Method not implemented.");
} }
async addList(content_list: DocumentBody[]): Promise<number[]> { async addList(content_list: DocumentBody[]): Promise<number[]> {
if (content_list.length === 0) return [];
if (content_list.length > 256) {
// if content_list is too long, split it.
const chunkLength = 256;
const chunked = [];
for (let i = 0; i < content_list.length; i += chunkLength) {
chunked.push(content_list.slice(i, i + chunkLength));
}
const ids = [];
for (const chunk of chunked) {
ids.push(await this.addList(chunk));
}
return ids.flat();
}
return await this.kysely.transaction().execute(async (trx) => { return await this.kysely.transaction().execute(async (trx) => {
// add tags // add tags
const tagCollected = new Set<string>(); const tagCollected = new Set<string>();

View File

@ -68,7 +68,7 @@ function releaseZip(path: string) {
} }
async function renderZipImage(ctx: Context, path: string, page: number) { async function renderZipImage(ctx: Context, path: string, page: number) {
const image_ext = ["gif", "png", "jpeg", "bmp", "webp", "jpg"]; const image_ext = ["gif", "png", "jpeg", "bmp", "webp", "jpg", "avif"];
const marked = markUseZip(path); const marked = markUseZip(path);
const zip = await acquireZip(path, marked); const zip = await acquireZip(path, marked);
const entries = (await entriesByNaturalOrder(zip)).filter((x) => { const entries = (await entriesByNaturalOrder(zip)).filter((x) => {