@crysoline/lib 0.1.1

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.
Files changed (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +98 -0
  3. package/dist/core/anime/123anime/index.d.ts +1 -0
  4. package/dist/core/anime/123anime/index.js +1 -0
  5. package/dist/core/anime/123anime/types.d.ts +11 -0
  6. package/dist/core/anime/123anime/types.js +1 -0
  7. package/dist/core/anime/animeheaven/index.d.ts +1 -0
  8. package/dist/core/anime/animeheaven/index.js +1 -0
  9. package/dist/core/anime/animeheaven/types.d.ts +6 -0
  10. package/dist/core/anime/animeheaven/types.js +1 -0
  11. package/dist/core/anime/animekai/index.d.ts +1 -0
  12. package/dist/core/anime/animekai/index.js +1 -0
  13. package/dist/core/anime/animekai/types.d.ts +36 -0
  14. package/dist/core/anime/animekai/types.js +1 -0
  15. package/dist/core/anime/animenexus/index.d.ts +1 -0
  16. package/dist/core/anime/animenexus/index.js +1 -0
  17. package/dist/core/anime/animenexus/types.d.ts +63 -0
  18. package/dist/core/anime/animenexus/types.js +1 -0
  19. package/dist/core/anime/animeonsen/index.d.ts +1 -0
  20. package/dist/core/anime/animeonsen/index.js +1 -0
  21. package/dist/core/anime/animeonsen/types.d.ts +23 -0
  22. package/dist/core/anime/animeonsen/types.js +1 -0
  23. package/dist/core/anime/animepahe/index.d.ts +1 -0
  24. package/dist/core/anime/animepahe/index.js +1 -0
  25. package/dist/core/anime/animepahe/types.d.ts +38 -0
  26. package/dist/core/anime/animepahe/types.js +1 -0
  27. package/dist/core/anime/anizone/index.d.ts +1 -0
  28. package/dist/core/anime/anizone/index.js +1 -0
  29. package/dist/core/anime/anizone/types.d.ts +19 -0
  30. package/dist/core/anime/anizone/types.js +1 -0
  31. package/dist/core/anime/hianime/index.d.ts +1 -0
  32. package/dist/core/anime/hianime/index.js +1 -0
  33. package/dist/core/anime/hianime/types.d.ts +40 -0
  34. package/dist/core/anime/hianime/types.js +1 -0
  35. package/dist/core/anime/index.d.ts +145 -0
  36. package/dist/core/anime/index.js +64 -0
  37. package/dist/core/anime/kickassanime/index.d.ts +1 -0
  38. package/dist/core/anime/kickassanime/index.js +1 -0
  39. package/dist/core/anime/kickassanime/types.d.ts +49 -0
  40. package/dist/core/anime/kickassanime/types.js +1 -0
  41. package/dist/core/anime/lunar/index.d.ts +1 -0
  42. package/dist/core/anime/lunar/index.js +1 -0
  43. package/dist/core/anime/lunar/types.d.ts +38 -0
  44. package/dist/core/anime/lunar/types.js +1 -0
  45. package/dist/core/anime/uniquestream/index.d.ts +1 -0
  46. package/dist/core/anime/uniquestream/index.js +1 -0
  47. package/dist/core/anime/uniquestream/types.d.ts +23 -0
  48. package/dist/core/anime/uniquestream/types.js +1 -0
  49. package/dist/core/hentai/hanime/index.d.ts +1 -0
  50. package/dist/core/hentai/hanime/index.js +1 -0
  51. package/dist/core/hentai/hanime/types.d.ts +23 -0
  52. package/dist/core/hentai/hanime/types.js +1 -0
  53. package/dist/core/hentai/hentaihaven/index.d.ts +1 -0
  54. package/dist/core/hentai/hentaihaven/index.js +1 -0
  55. package/dist/core/hentai/hentaihaven/types.d.ts +13 -0
  56. package/dist/core/hentai/hentaihaven/types.js +1 -0
  57. package/dist/core/hentai/hstream/index.d.ts +1 -0
  58. package/dist/core/hentai/hstream/index.js +1 -0
  59. package/dist/core/hentai/hstream/types.d.ts +6 -0
  60. package/dist/core/hentai/hstream/types.js +1 -0
  61. package/dist/core/hentai/index.d.ts +40 -0
  62. package/dist/core/hentai/index.js +19 -0
  63. package/dist/core/index.d.ts +5 -0
  64. package/dist/core/index.js +5 -0
  65. package/dist/core/manga/index.d.ts +36 -0
  66. package/dist/core/manga/index.js +19 -0
  67. package/dist/core/manga/lunar/index.d.ts +1 -0
  68. package/dist/core/manga/lunar/index.js +1 -0
  69. package/dist/core/manga/lunar/types.d.ts +41 -0
  70. package/dist/core/manga/lunar/types.js +1 -0
  71. package/dist/core/manga/mangadex/index.d.ts +1 -0
  72. package/dist/core/manga/mangadex/index.js +1 -0
  73. package/dist/core/manga/mangadex/types.d.ts +33 -0
  74. package/dist/core/manga/mangadex/types.js +14 -0
  75. package/dist/core/manga/mangafire/index.d.ts +1 -0
  76. package/dist/core/manga/mangafire/index.js +1 -0
  77. package/dist/core/manga/mangafire/types.d.ts +22 -0
  78. package/dist/core/manga/mangafire/types.js +1 -0
  79. package/dist/core/mapper/index.d.ts +7 -0
  80. package/dist/core/mapper/index.js +6 -0
  81. package/dist/core/mapper/types.d.ts +8 -0
  82. package/dist/core/mapper/types.js +1 -0
  83. package/dist/core/meta/index.d.ts +13 -0
  84. package/dist/core/meta/index.js +14 -0
  85. package/dist/core/meta/myanimelist/index.d.ts +1 -0
  86. package/dist/core/meta/myanimelist/index.js +1 -0
  87. package/dist/core/meta/myanimelist/types.d.ts +69 -0
  88. package/dist/core/meta/myanimelist/types.js +1 -0
  89. package/dist/core/meta/mymangalist/index.d.ts +1 -0
  90. package/dist/core/meta/mymangalist/index.js +1 -0
  91. package/dist/core/meta/mymangalist/types.d.ts +48 -0
  92. package/dist/core/meta/mymangalist/types.js +1 -0
  93. package/dist/core/types.d.ts +101 -0
  94. package/dist/core/types.js +6 -0
  95. package/dist/helpers/fetch.d.ts +49 -0
  96. package/dist/helpers/fetch.js +161 -0
  97. package/dist/index.d.ts +1 -0
  98. package/dist/index.js +1 -0
  99. package/package.json +33 -0
@@ -0,0 +1,48 @@
1
+ export interface MMSearchMeta {
2
+ type: string | null;
3
+ score: string | null;
4
+ members: string | null;
5
+ volumes: string | null;
6
+ }
7
+ export interface MMLink {
8
+ label: string | null;
9
+ url: string | null;
10
+ }
11
+ export interface MMLRelation {
12
+ id: number | null;
13
+ image: string | null;
14
+ title: string | null;
15
+ relationType: string | null;
16
+ }
17
+ export interface MMLCharacter {
18
+ id: number | null;
19
+ image: string | null;
20
+ name: string | null;
21
+ role: string | null;
22
+ }
23
+ export interface MMLVoiceActor {
24
+ id: number | null;
25
+ image: string | null;
26
+ name: string | null;
27
+ language: string | null;
28
+ }
29
+ export interface MMLInfoMeta {
30
+ moreInfo: string | null;
31
+ score: string | null;
32
+ rank: string | null;
33
+ popularity: string | null;
34
+ members: string | null;
35
+ type: string | null;
36
+ volumes: string | null;
37
+ chapters: string | null;
38
+ status: string | null;
39
+ published: string | null;
40
+ serialization: string | null;
41
+ genres: string[] | null;
42
+ themes: string[] | null;
43
+ authors: string[] | null;
44
+ favorites: string | null;
45
+ externalLinks: MMLink[] | null;
46
+ relations: MMLRelation[] | null;
47
+ characters: MMLCharacter[] | null;
48
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,101 @@
1
+ export interface Image {
2
+ aspectRatio: number;
3
+ small: string;
4
+ medium: string;
5
+ large: string;
6
+ }
7
+ export interface Title {
8
+ english?: string | null | undefined;
9
+ romaji?: string | null | undefined;
10
+ japanese?: string | null | undefined;
11
+ native?: string | null | undefined;
12
+ }
13
+ export interface Chapter<T = unknown> {
14
+ id?: string | null;
15
+ title?: string | null;
16
+ number?: number | null;
17
+ rating?: number | null;
18
+ updatedAt?: number | string | null;
19
+ mixdrop?: string | null;
20
+ metadata?: T;
21
+ }
22
+ export interface Episode<T = unknown> {
23
+ id?: number | string | null;
24
+ title?: string | null;
25
+ image?: Image | string | null;
26
+ description?: string | null;
27
+ number?: number | null;
28
+ teaserUrl?: string | null;
29
+ metadata?: T | null;
30
+ isFiller?: boolean | null;
31
+ isRecap?: boolean | null;
32
+ }
33
+ export interface Info<T = unknown, E = unknown> {
34
+ id?: string | number | null;
35
+ idMal?: string | number | null;
36
+ idAl?: string | number | null;
37
+ idMdx?: string | number | null;
38
+ title?: Title | null;
39
+ synonyms?: string[] | null;
40
+ description?: string | null;
41
+ image?: Image | null;
42
+ banner?: Image | null;
43
+ logo?: Image | null;
44
+ airedEpisodes?: number | null;
45
+ totalEpisodes?: number | null;
46
+ metadata?: T | null;
47
+ episodes?: Partial<E>[] | null;
48
+ }
49
+ export interface Page {
50
+ url?: string | null;
51
+ index?: number | null;
52
+ headers?: Record<string, unknown> | null;
53
+ }
54
+ export interface Search<T = unknown> {
55
+ id?: number | string | null;
56
+ title?: Title | null;
57
+ image?: Image | null;
58
+ banner?: Image | null;
59
+ logo?: Image | null;
60
+ description?: string | null;
61
+ airedEpisodes?: number | null;
62
+ totalEpisodes?: number | null;
63
+ metadata?: T | null;
64
+ }
65
+ export declare enum VideoType {
66
+ HLS = "hls",
67
+ DASH = "dash",
68
+ MP4 = "mp4"
69
+ }
70
+ export interface IntroOutro {
71
+ start?: number | null;
72
+ end?: number | null;
73
+ }
74
+ export interface Download {
75
+ url?: string | null;
76
+ quality?: string | null;
77
+ }
78
+ export interface VideoSource {
79
+ url?: string | null;
80
+ isM3U8?: boolean | null;
81
+ type?: VideoType | null;
82
+ quality?: string | null;
83
+ isDub?: boolean | null;
84
+ }
85
+ export interface Subtitle {
86
+ id?: string | null;
87
+ url?: string | null;
88
+ label?: string | null;
89
+ srcLang?: string | null;
90
+ }
91
+ export interface Source<T = unknown> {
92
+ headers?: Record<string, unknown> | null;
93
+ intro?: IntroOutro | null;
94
+ outro?: IntroOutro | null;
95
+ sources: Partial<VideoSource>[];
96
+ subtitles?: Partial<Subtitle>[] | null;
97
+ download?: Partial<Download>[] | string | null;
98
+ chapters?: string | null;
99
+ thumbnails?: string | null;
100
+ metadata?: T | null;
101
+ }
@@ -0,0 +1,6 @@
1
+ export var VideoType;
2
+ (function (VideoType) {
3
+ VideoType["HLS"] = "hls";
4
+ VideoType["DASH"] = "dash";
5
+ VideoType["MP4"] = "mp4";
6
+ })(VideoType || (VideoType = {}));
@@ -0,0 +1,49 @@
1
+ import type { Chapter, Episode, Info, Page, Search, Source } from '../core/types';
2
+ interface FetchModuleConfig {
3
+ baseUrl?: string;
4
+ provider: string;
5
+ apiKey: string;
6
+ }
7
+ export declare const AnimeFetch: <TSearchMeta = unknown, TInfoMeta = unknown, TEpisodeMeta = unknown, TSourceMeta = unknown>(config: FetchModuleConfig) => {
8
+ search: (q: string) => Promise<Search<TSearchMeta>[]>;
9
+ info: (id: string | number) => Promise<Info<TInfoMeta, Episode<TEpisodeMeta>>>;
10
+ episodes: (id: string | number) => Promise<Episode<TEpisodeMeta>[]>;
11
+ sources: (params: {
12
+ id: string | number;
13
+ episodeId: string | number;
14
+ subType?: string;
15
+ server?: string;
16
+ }) => Promise<Source<TSourceMeta>>;
17
+ };
18
+ export declare const HentaiFetch: <TSearchMeta = unknown, TInfoMeta = unknown, TEpisodeMeta = unknown, TSourceMeta = unknown>(config: FetchModuleConfig) => {
19
+ search: (q: string) => Promise<Search<TSearchMeta>[]>;
20
+ info: (id: string | number) => Promise<Info<TInfoMeta, Episode<TEpisodeMeta>>>;
21
+ episodes: (id: string | number) => Promise<Episode<TEpisodeMeta>[]>;
22
+ sources: (params: {
23
+ id: string | number;
24
+ episodeId: string | number;
25
+ subType?: string;
26
+ server?: string;
27
+ }) => Promise<Source<TSourceMeta>>;
28
+ };
29
+ export declare const MangaFetch: <TSearchMeta = unknown, TInfoMeta = unknown, TChapterMeta = unknown>(config: FetchModuleConfig) => {
30
+ search: (q: string) => Promise<Search<TSearchMeta>[]>;
31
+ info: (id: string | number) => Promise<Info<TInfoMeta, unknown>>;
32
+ chapters: (id: string | number) => Promise<Chapter<TChapterMeta>[]>;
33
+ pages: (params: {
34
+ id: string | number;
35
+ chapterId: string | number;
36
+ lang?: string;
37
+ }) => Promise<Page[]>;
38
+ };
39
+ export declare const MetaFetch: <TSearchMeta = unknown, TInfoMeta = unknown>(config: FetchModuleConfig) => {
40
+ search: (q: string) => Promise<Search<TSearchMeta>[]>;
41
+ info: (id: string | number) => Promise<Info<TInfoMeta, unknown>>;
42
+ };
43
+ export declare const MapperFetch: (config: FetchModuleConfig) => {
44
+ map: (params: {
45
+ id: number;
46
+ provider: string;
47
+ }) => Promise<unknown>;
48
+ };
49
+ export {};
@@ -0,0 +1,161 @@
1
+ const fetchFn = (baseUrl, apiKey) => {
2
+ return async (path, params) => {
3
+ const url = new URL(baseUrl + path);
4
+ if (params) {
5
+ for (const [key, value] of Object.entries(params)) {
6
+ if (value !== undefined && value !== null) {
7
+ url.searchParams.set(key, String(value));
8
+ }
9
+ }
10
+ }
11
+ const res = await fetch(url.toString(), {
12
+ headers: {
13
+ 'x-api-key': apiKey,
14
+ },
15
+ });
16
+ if (!res.ok) {
17
+ throw new Error(`Failed (${res.status}) (${res.statusText}) on ${url.pathname}`);
18
+ }
19
+ return res.json();
20
+ };
21
+ };
22
+ export const AnimeFetch = (config) => {
23
+ const { baseUrl = 'https://api.crysoline.moe', provider, apiKey } = config;
24
+ const basePath = `${baseUrl}/api/anime/${provider}/`;
25
+ const fetcher = fetchFn(basePath, apiKey);
26
+ /**
27
+ * Search for anime by query string.
28
+ *
29
+ * @param q - Search query.
30
+ */
31
+ const search = async (q) => fetcher('search', { q });
32
+ /**
33
+ * Fetch detailed info for a given anime id.
34
+ *
35
+ * @param id - Anime identifier (string or number)
36
+ */
37
+ const info = async (id) => fetcher(`info/${encodeURIComponent(id)}`);
38
+ /**
39
+ * Fetch episodes list for a given anime id.
40
+ *
41
+ * @param id - Anime identifier (string or number)
42
+ */
43
+ const episodes = async (id) => fetcher(`episodes/${encodeURIComponent(id)}`);
44
+ /**
45
+ * Fetch sources for a particular episode.
46
+ *
47
+ * @param params - Object containing `id`, `episodeId` and optional `subType` and `server`
48
+ */
49
+ const sources = (params) => fetcher('sources', params);
50
+ return {
51
+ search,
52
+ info,
53
+ episodes,
54
+ sources,
55
+ };
56
+ };
57
+ export const HentaiFetch = (config) => {
58
+ const { baseUrl = 'https://api.crysoline.moe', provider, apiKey } = config;
59
+ const basePath = `${baseUrl}/api/hentai/${provider}/`;
60
+ const fetcher = fetchFn(basePath, apiKey);
61
+ /**
62
+ * Search for hentai by query string.
63
+ *
64
+ * @param q - Search query.
65
+ */
66
+ const search = async (q) => fetcher('search', { q });
67
+ /**
68
+ * Get detailed info for an item by id.
69
+ *
70
+ * @param id - Item identifier.
71
+ */
72
+ const info = async (id) => fetcher(`info/${encodeURIComponent(id)}`);
73
+ /**
74
+ * List episodes for a specific item.
75
+ *
76
+ * @param id - Item identifier.
77
+ */
78
+ const episodes = async (id) => fetcher(`episodes/${encodeURIComponent(id)}`);
79
+ /**
80
+ * Get sources for a specific episode.
81
+ *
82
+ * @param params - Parameters to identify the episode and optional filters.
83
+ */
84
+ const sources = (params) => fetcher('sources', params);
85
+ return {
86
+ search,
87
+ info,
88
+ episodes,
89
+ sources,
90
+ };
91
+ };
92
+ export const MangaFetch = (config) => {
93
+ const { baseUrl = 'https://api.crysoline.moe', provider, apiKey } = config;
94
+ const basePath = `${baseUrl}/api/manga/${provider}/`;
95
+ const fetcher = fetchFn(basePath, apiKey);
96
+ /**
97
+ * Search for manga by query string.
98
+ *
99
+ * @param q - Search query.
100
+ */
101
+ const search = async (q) => fetcher('search', { q });
102
+ /**
103
+ * Get detailed info for a manga by id.
104
+ *
105
+ * @param id - Manga identifier.
106
+ */
107
+ const info = async (id) => fetcher(`info/${encodeURIComponent(id)}`);
108
+ /**
109
+ * List chapters for a specific manga.
110
+ *
111
+ * @param id - Manga identifier.
112
+ */
113
+ const chapters = async (id) => fetcher(`chapters/${encodeURIComponent(id)}`);
114
+ /**
115
+ * Fetch pages for a specific manga chapter.
116
+ *
117
+ * @param params - Object containing `id`, `chapterId` and optional `lang`
118
+ */
119
+ const pages = (params) => fetcher('pages', params);
120
+ return {
121
+ search,
122
+ info,
123
+ chapters,
124
+ pages,
125
+ };
126
+ };
127
+ export const MetaFetch = (config) => {
128
+ const { baseUrl = 'https://api.crysoline.moe', provider, apiKey } = config;
129
+ const basePath = `${baseUrl}/api/meta/${provider}/`;
130
+ const fetcher = fetchFn(basePath, apiKey);
131
+ /**
132
+ * Search meta provider by query string.
133
+ *
134
+ * @param q - Search query.
135
+ */
136
+ const search = async (q) => fetcher('search', { q });
137
+ /**
138
+ * Get info from meta provider by id.
139
+ *
140
+ * @param id - Resource identifier.
141
+ */
142
+ const info = async (id) => fetcher(`info/${encodeURIComponent(id)}`);
143
+ return {
144
+ search,
145
+ info,
146
+ };
147
+ };
148
+ export const MapperFetch = (config) => {
149
+ const { baseUrl = 'https://api.crysoline.moe', provider, apiKey } = config;
150
+ const basePath = `${baseUrl}/api/mapper/${provider}`;
151
+ const fetcher = fetchFn(basePath, apiKey);
152
+ /**
153
+ * Map an id from one provider to another.
154
+ *
155
+ * @param params - Mapping parameters: `id` to map and `provider` to map to.
156
+ */
157
+ const map = async (params) => fetcher('map', params);
158
+ return {
159
+ map,
160
+ };
161
+ };
@@ -0,0 +1 @@
1
+ export { Anime, Hentai, Manga, Mapper, Meta } from './core';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { Anime, Hentai, Manga, Mapper, Meta } from './core';
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@crysoline/lib",
3
+ "description": "The official crysoline library for anime, manga using the Crysoline API",
4
+ "license": "MIT",
5
+ "version": "0.1.1",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": ["dist"],
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "prepublishOnly": "npm run build",
19
+ "lint": "biome lint .",
20
+ "format": "biome format . --write"
21
+ },
22
+ "devDependencies": {
23
+ "@biomejs/biome": "2.3.10",
24
+ "typescript": "^5",
25
+ "@types/bun": "latest"
26
+ },
27
+ "keywords": [
28
+ "crysoline",
29
+ "anime",
30
+ "manga",
31
+ "meta"
32
+ ]
33
+ }