huge rewrite

This commit is contained in:
2026-11-14 18:21:12 -08:00
parent f465d1ec0d
commit 2cec85a8f3
69 changed files with 11479 additions and 1576 deletions

View File

@@ -1,51 +1,57 @@
# Manga Integration
# Manga Resolution Module
<p class="page-description">Search manga catalogs, retrieve chapter listings, and resolve reader-ready page images directly with Vyla SDK.</p>
<p class="page-description">How to integrate manga title discovery, chapter listings, and high-resolution page resolution using the Vyla SDK.</p>
Vyla SDK provides built-in manga support to discover titles, fetch full chapter indices, and resolve high-resolution page image URLs with asset dimensions and aspect ratios.
## Overview
In addition to video streaming, `@vyla-entertainment/sdk` includes a native Manga resolution module. Powered by `atsu.moe` and leveraging `node-tls-client`, the module bypasses anti-bot TLS fingerprinting by mimicking real Google Chrome 131 cryptographic handshakes.
This allows developers to build responsive, ad-free manga reading interfaces directly into their applications.
---
## Technical Architecture
Upstream manga archives frequently block standard Node.js `fetch` or `axios` requests using JA3/JA4 TLS fingerprinting. To ensure reliable connectivity:
1. **TLS Emulation**: Uses `node-tls-client` configured with `ClientIdentifier.chrome_131`.
2. **Session Persistence**: Reuses keep-alive TLS sessions across search and chapter page requests.
3. **Structured Geometry**: Returns explicit image dimensions (`width`, `height`) and pre-calculated aspect ratios so mobile and desktop readers can prevent layout shifts during image loading.
---
## Manga Methods
### `searchManga(query, page?, perPage?)`
### 1. Searching for Titles
Searches the manga catalog for titles matching a query string.
Search the manga catalog by query string with pagination support:
```javascript
const searchResults = await sdk.searchManga("Steel Ball Run", 1, 10);
console.log(searchResults.results[0]);
import VylaSDK from '@vyla-entertainment/sdk';
const sdk = new VylaSDK();
const searchResult = await sdk.searchManga('Chainsaw Man', 1, 10);
console.log(`Total results: ${searchResult.total}`);
searchResult.items.forEach((manga) => {
console.log(`[ID: ${manga.id}] ${manga.title} - ${manga.latestChapter}`);
});
```
#### Parameters
| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `query` | `string` | **Yes** | - | Title, author, or acronym search query. |
| `page` | `number` | **No** | `1` | Pagination page number. |
| `perPage` | `number` | **No** | `12` | Results per page. |
#### Response Format
#### Search Response Structure
```json
{
"page": 1,
"total": 2,
"results": [
"perPage": 10,
"total": 42,
"items": [
{
"id": "aKXN8",
"title": "JoJo's Bizarre Adventure: Part 7–Steel Ball Run",
"englishTitle": null,
"authors": ["ARAKI Hirohiko"],
"type": "Manga",
"medium": "Comic",
"status": "Completed",
"year": 2004,
"rating": 9.03681428571429,
"popularity": "1.6M",
"poster": "https://cdn.atsu.moe/static/posters/nR3hGYk9GmOqgD52.jpg",
"posterSmall": "https://cdn.atsu.moe/static/posters/nR3hGYk9GmOqgD52-small.avif",
"posterMedium": "https://cdn.atsu.moe/static/posters/nR3hGYk9GmOqgD52-medium.avif"
"id": "chainsaw-man",
"title": "Chainsaw Man",
"cover": "https://cdn.atsu.moe/covers/chainsaw-man.webp",
"status": "Ongoing",
"latestChapter": "Chapter 180"
}
]
}
@@ -53,85 +59,58 @@ console.log(searchResults.results[0]);
---
### `getManga(id)`
### 2. Fetching Manga Details & Chapters
Retrieves comprehensive details for a manga entry, including synopsis, genres, authors, and full chapter list.
Retrieve full metadata, descriptions, genres, and the complete chapter index:
```javascript
const manga = await sdk.getManga("aKXN8");
console.log(manga.title, manga.totalChapters);
const mangaDetails = await sdk.getManga('chainsaw-man');
console.log('Title:', mangaDetails.title);
console.log('Synopsis:', mangaDetails.description);
console.log('Genres:', mangaDetails.genres.join(', '));
console.log('Available Chapters:', mangaDetails.chapters.length);
const latest = mangaDetails.chapters[0];
console.log(`Latest Chapter: ${latest.chapterNumber} (ID: ${latest.id})`);
```
#### Parameters
---
| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `id` | `string` | **Yes** | - | Unique manga identifier. |
### 3. Resolving Chapter Pages
#### Response Format
To render the reader view, fetch the ordered page image assets for a specific chapter:
```javascript
const mangaId = 'chainsaw-man';
const chapterId = 'chapter-1';
const pages = await sdk.getMangaChapter(mangaId, chapterId);
console.log(`Chapter contains ${pages.length} pages.`);
pages.forEach((page, index) => {
console.log(`Page ${index + 1}: ${page.url} [${page.width}x${page.height}]`);
});
```
#### Page Object Structure
```json
{
"id": "aKXN8",
"title": "JoJo's Bizarre Adventure: Part 7–Steel Ball Run",
"englishTitle": null,
"synopsis": "Riders from around the world gather in the Wild West for the race of the century...",
"status": "Completed",
"type": "Manga",
"medium": "Comic",
"rating": 9.03681428571429,
"views": "330.5K",
"authors": ["Hirohiko Araki"],
"genres": ["Action", "Adventure", "Drama", "Historical", "Supernatural"],
"tags": ["19th Century", "Horses", "Seinen"],
"poster": "https://cdn.atsu.moe/static/posters/nR3hGYk9GmOqgD52.jpg",
"totalChapters": 95,
"chapters": [
{
"id": "8KyKadCx",
"number": 1,
"title": "# 1",
"pageCount": 48,
"createdAt": "2026-04-18T00:00:00.000Z"
}
]
"index": 1,
"url": "https://cdn.atsu.moe/data/.../01.webp",
"width": 1080,
"height": 1600,
"aspectRatio": 0.675
}
```
---
### `getMangaChapter(mangaId, chapterId)`
## Reader Layout Best Practices
Resolves all page images for a selected chapter, including pixel dimensions and aspect ratios for smooth responsive rendering.
When rendering manga pages in a frontend reader:
```javascript
const chapter = await sdk.getMangaChapter("aKXN8", "8KyKadCx");
console.log(chapter.pages[0].url);
```
#### Parameters
| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `mangaId` | `string` | **Yes** | - | Unique manga identifier. |
| `chapterId` | `string` | **Yes** | - | Unique chapter identifier. |
#### Response Format
```json
{
"id": "8KyKadCx",
"number": 1,
"title": "# 1",
"scanlatorId": "cmo3e2t970003ktp80ip0n5hb",
"pages": [
{
"number": 0,
"url": "https://cdn.atsu.moe/static/pages/aKXN8/8KyKadCx/0.webp",
"width": 1200,
"height": 1722,
"aspectRatio": 0.6968641114982579
}
]
}
```
1. **Prevent Cumulative Layout Shift (CLS)**: Use the provided `aspectRatio` or `width`/`height` in CSS (`aspect-ratio: attr(width) / attr(height);`) to reserve vertical scroll space before each image finishes downloading.
2. **Preload Neighboring Pages**: Implement a 2-page lookahead preloader so viewers turning pages experience instantaneous transitions.
3. **Session Cleanup**: In long-running background tasks, invoke `cleanup()` from the module when closing reader sessions to terminate idle TLS sockets.