@delta-comic/model 1.3.0 → 1.3.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.
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/model/comment.d.ts +47 -0
- package/dist/lib/model/content.d.ts +31 -0
- package/dist/lib/model/download.d.ts +10 -0
- package/dist/lib/model/ep.d.ts +12 -0
- package/dist/lib/model/image.d.ts +19 -0
- package/dist/lib/model/index.d.ts +8 -0
- package/dist/lib/model/item.d.ts +104 -0
- package/dist/lib/model/resource.d.ts +34 -0
- package/dist/lib/model/user.d.ts +25 -0
- package/dist/lib/struct/index.d.ts +3 -0
- package/dist/lib/struct/meta.d.ts +12 -0
- package/dist/lib/struct/store.d.ts +34 -0
- package/dist/lib/struct/struct.d.ts +12 -0
- package/dist/pack.tgz +0 -0
- package/package.json +3 -3
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { default as dayjs } from 'dayjs';
|
|
2
|
+
import { Component } from 'vue';
|
|
3
|
+
import { SourcedKeyMap, Struct, Metadata, Metadatable, StreamQuery } from '../struct';
|
|
4
|
+
import { Item } from './item';
|
|
5
|
+
import { User } from './user';
|
|
6
|
+
export interface RawComment extends Metadatable {
|
|
7
|
+
sender: User;
|
|
8
|
+
content: {
|
|
9
|
+
type: 'string' | 'html';
|
|
10
|
+
text: string;
|
|
11
|
+
};
|
|
12
|
+
time: number;
|
|
13
|
+
id: string;
|
|
14
|
+
childrenCount: number;
|
|
15
|
+
likeCount: number;
|
|
16
|
+
isLiked: boolean;
|
|
17
|
+
reported: boolean;
|
|
18
|
+
isTop: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type CommentRow = Component<{
|
|
21
|
+
comment: Comment;
|
|
22
|
+
item: Item;
|
|
23
|
+
parentComment?: Comment;
|
|
24
|
+
}>;
|
|
25
|
+
export declare abstract class Comment extends Struct<RawComment> implements RawComment {
|
|
26
|
+
static commentRow: import('vue').ShallowReactive<SourcedKeyMap<[plugin: string, name: string], CommentRow>>;
|
|
27
|
+
constructor(v: RawComment);
|
|
28
|
+
abstract sender: User;
|
|
29
|
+
content: {
|
|
30
|
+
type: 'string' | 'html';
|
|
31
|
+
text: string;
|
|
32
|
+
};
|
|
33
|
+
time: number;
|
|
34
|
+
get $time(): dayjs.Dayjs;
|
|
35
|
+
id: string;
|
|
36
|
+
childrenCount: number;
|
|
37
|
+
likeCount: number;
|
|
38
|
+
isTop: boolean;
|
|
39
|
+
isLiked: boolean;
|
|
40
|
+
reported: boolean;
|
|
41
|
+
$$plugin: string;
|
|
42
|
+
$$meta?: Metadata;
|
|
43
|
+
abstract like(signal?: AbortSignal): PromiseLike<boolean>;
|
|
44
|
+
abstract report(signal?: AbortSignal): PromiseLike<any>;
|
|
45
|
+
abstract sendComment(text: string, signal?: AbortSignal): PromiseLike<any>;
|
|
46
|
+
abstract fetchChildren: StreamQuery<[], Comment>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { SourcedKeyMap, StreamQuery, SourcedKeyType } from '../struct';
|
|
3
|
+
import * as comment from './comment';
|
|
4
|
+
import * as ep from './ep';
|
|
5
|
+
import * as item from './item';
|
|
6
|
+
export type ContentPageLike = new (preload: item.Item | undefined, id: string, ep: string) => ContentPage;
|
|
7
|
+
export type ContentType_ = SourcedKeyType<typeof ContentPage.contentPages>;
|
|
8
|
+
export type ContentType = Exclude<ContentType_, string>;
|
|
9
|
+
export type ViewComponent = Component<{
|
|
10
|
+
page: ContentPage;
|
|
11
|
+
isFullScreen: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
export type LayoutComponent = Component<{
|
|
14
|
+
page: ContentPage;
|
|
15
|
+
}>;
|
|
16
|
+
export declare abstract class ContentPage {
|
|
17
|
+
preload: item.Item | undefined;
|
|
18
|
+
id: string;
|
|
19
|
+
ep: string;
|
|
20
|
+
static layouts: import('vue').ShallowReactive<SourcedKeyMap<[plugin: string, name: string], LayoutComponent>>;
|
|
21
|
+
static contentPages: import('vue').ShallowReactive<SourcedKeyMap<[plugin: string, name: string], ContentPageLike>>;
|
|
22
|
+
constructor(preload: item.Item | undefined, id: string, ep: string);
|
|
23
|
+
abstract plugin: string;
|
|
24
|
+
abstract contentType: ContentType;
|
|
25
|
+
abstract fetchShortId: (signal?: AbortSignal) => Promise<string>;
|
|
26
|
+
abstract fetchDetail: (signal?: AbortSignal) => Promise<item.Item>;
|
|
27
|
+
abstract fetchRecommends: StreamQuery<[], item.Item>;
|
|
28
|
+
abstract fetchComments: StreamQuery<[], comment.Comment>;
|
|
29
|
+
abstract fetchEps: StreamQuery<[], ep.Ep>;
|
|
30
|
+
abstract ViewComponent: ViewComponent;
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Metadata, Metadatable } from '../struct';
|
|
2
|
+
export declare abstract class Downloader implements Metadatable {
|
|
3
|
+
abstract id: string;
|
|
4
|
+
abstract name: string;
|
|
5
|
+
abstract $$plugin: string;
|
|
6
|
+
abstract $$meta?: Metadata;
|
|
7
|
+
abstract begin: () => void;
|
|
8
|
+
abstract resume: () => void;
|
|
9
|
+
abstract pause: () => void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Struct, Metadata, Metadatable } from '../struct';
|
|
2
|
+
export interface RawEp extends Metadatable {
|
|
3
|
+
name: string;
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class Ep extends Struct<RawEp> implements RawEp {
|
|
7
|
+
name: string;
|
|
8
|
+
id: string;
|
|
9
|
+
$$plugin: string;
|
|
10
|
+
$$meta?: Metadata;
|
|
11
|
+
constructor(v: RawEp);
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Metadatable } from '../struct';
|
|
2
|
+
import { Resource, RawResource, ProcessStep_ } from './resource';
|
|
3
|
+
export interface RawImage extends Metadatable {
|
|
4
|
+
path: string;
|
|
5
|
+
forkNamespace: string;
|
|
6
|
+
processSteps?: ProcessStep_[];
|
|
7
|
+
}
|
|
8
|
+
export declare class Image extends Resource {
|
|
9
|
+
static is(value: unknown): value is Image;
|
|
10
|
+
static create(v: RawResource | RawImage, aspect?: ImageAspect): Image;
|
|
11
|
+
protected constructor(v: RawResource | RawImage, aspect?: ImageAspect);
|
|
12
|
+
get aspect(): Partial<ImageAspect> | undefined;
|
|
13
|
+
set aspect(v: Partial<ImageAspect> | undefined);
|
|
14
|
+
}
|
|
15
|
+
export interface ImageAspect {
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}
|
|
19
|
+
export type Image_ = string | Image;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * as comment from './comment';
|
|
2
|
+
export * as content from './content';
|
|
3
|
+
export * as download from './download';
|
|
4
|
+
export * as ep from './ep';
|
|
5
|
+
export * as image from './image';
|
|
6
|
+
export * as item from './item';
|
|
7
|
+
export * as resource from './resource';
|
|
8
|
+
export * as user from './user';
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { default as dayjs } from 'dayjs';
|
|
2
|
+
import { Component } from 'vue';
|
|
3
|
+
import { SourcedKeyMap, Struct, Metadatable } from '../struct';
|
|
4
|
+
import { ContentType, ContentType_ } from './content';
|
|
5
|
+
import { Ep, RawEp } from './ep';
|
|
6
|
+
import { RawResource } from './resource';
|
|
7
|
+
import * as image from './image';
|
|
8
|
+
export interface Category extends Metadatable {
|
|
9
|
+
name: string;
|
|
10
|
+
group: string;
|
|
11
|
+
search: {
|
|
12
|
+
keyword: string;
|
|
13
|
+
source: string;
|
|
14
|
+
sort: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface Author extends Metadatable {
|
|
18
|
+
label: string;
|
|
19
|
+
icon: RawResource | image.RawImage | string;
|
|
20
|
+
description: string;
|
|
21
|
+
/**
|
|
22
|
+
* 为空则不可订阅
|
|
23
|
+
* 否则传入的为`defineConfig`中定义的`subscribe.type`
|
|
24
|
+
*/ subscribe?: string;
|
|
25
|
+
actions?: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface RawItem extends Metadatable {
|
|
28
|
+
cover: RawResource | image.RawImage;
|
|
29
|
+
title: string;
|
|
30
|
+
id: string;
|
|
31
|
+
/** @alias tags */
|
|
32
|
+
categories: Category[];
|
|
33
|
+
author: Author[];
|
|
34
|
+
viewNumber?: number;
|
|
35
|
+
likeNumber?: number;
|
|
36
|
+
commentNumber?: number;
|
|
37
|
+
isLiked?: boolean;
|
|
38
|
+
updateTime?: number;
|
|
39
|
+
customIsAI?: boolean;
|
|
40
|
+
contentType: ContentType_;
|
|
41
|
+
length: string;
|
|
42
|
+
epLength: string;
|
|
43
|
+
description?: Description;
|
|
44
|
+
thisEp: RawEp;
|
|
45
|
+
commentSendable: boolean;
|
|
46
|
+
customIsSafe?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export type ItemCardComponent = Component<{
|
|
49
|
+
item: Item;
|
|
50
|
+
freeHeight?: boolean;
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
type?: 'default' | 'big' | 'small';
|
|
53
|
+
class?: any;
|
|
54
|
+
style?: any;
|
|
55
|
+
}, any, any, any, any, {
|
|
56
|
+
click: [];
|
|
57
|
+
}, {
|
|
58
|
+
default(): void;
|
|
59
|
+
smallTopInfo(): void;
|
|
60
|
+
cover(): void;
|
|
61
|
+
}>;
|
|
62
|
+
export type ItemTranslator = (raw: RawItem) => Item;
|
|
63
|
+
export type Description = string | {
|
|
64
|
+
type: 'html';
|
|
65
|
+
content: string;
|
|
66
|
+
} | {
|
|
67
|
+
type: 'text';
|
|
68
|
+
content: string;
|
|
69
|
+
};
|
|
70
|
+
export declare abstract class Item extends Struct<RawItem> implements RawItem {
|
|
71
|
+
static itemTranslator: import('vue').ShallowReactive<SourcedKeyMap<[plugin: string, name: string], ItemTranslator>>;
|
|
72
|
+
static create(raw: RawItem): Item;
|
|
73
|
+
static authorIcon: import('vue').ShallowReactive<SourcedKeyMap<[plugin: string, name: string], Component>>;
|
|
74
|
+
static itemCards: import('vue').ShallowReactive<SourcedKeyMap<[plugin: string, name: string], ItemCardComponent>>;
|
|
75
|
+
abstract like(): Promise<any>;
|
|
76
|
+
abstract report(): Promise<any>;
|
|
77
|
+
abstract sendComment(text: string): Promise<any>;
|
|
78
|
+
static is(value: unknown): value is Item;
|
|
79
|
+
cover: RawResource | image.RawImage;
|
|
80
|
+
get $cover(): image.Image;
|
|
81
|
+
title: string;
|
|
82
|
+
id: string;
|
|
83
|
+
categories: Category[];
|
|
84
|
+
author: Author[];
|
|
85
|
+
viewNumber?: number;
|
|
86
|
+
likeNumber?: number;
|
|
87
|
+
commentNumber?: number;
|
|
88
|
+
isLiked?: boolean;
|
|
89
|
+
description?: Description;
|
|
90
|
+
updateTime?: number;
|
|
91
|
+
get $updateTime(): dayjs.Dayjs;
|
|
92
|
+
contentType: ContentType;
|
|
93
|
+
length: string;
|
|
94
|
+
epLength: string;
|
|
95
|
+
$$plugin: string;
|
|
96
|
+
$$meta: import('..').Metadata | undefined;
|
|
97
|
+
thisEp: RawEp;
|
|
98
|
+
customIsSafe?: boolean;
|
|
99
|
+
get $thisEp(): Ep;
|
|
100
|
+
constructor(v: RawItem);
|
|
101
|
+
commentSendable: boolean;
|
|
102
|
+
customIsAI?: boolean;
|
|
103
|
+
get $isAi(): boolean;
|
|
104
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SourcedKeyMap, Struct, Metadata, Metadatable } from '../struct';
|
|
2
|
+
export type ProcessInstance = (nowPath: string, resource: Resource) => Promise<[path: string, exit: boolean]>;
|
|
3
|
+
export interface ProcessStep {
|
|
4
|
+
referenceName: string;
|
|
5
|
+
ignoreExit?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type ProcessStep_ = ProcessStep | string;
|
|
8
|
+
export interface ResourceType {
|
|
9
|
+
type: string;
|
|
10
|
+
urls: string[];
|
|
11
|
+
test: (url: string, signal: AbortSignal) => PromiseLike<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface RawResource extends Metadatable {
|
|
14
|
+
pathname: string;
|
|
15
|
+
type: string;
|
|
16
|
+
processSteps?: ProcessStep_[];
|
|
17
|
+
}
|
|
18
|
+
export declare class Resource extends Struct<RawResource> implements RawResource {
|
|
19
|
+
static processInstances: import('vue').ShallowReactive<SourcedKeyMap<[plugin: string, referenceName: string], ProcessInstance>>;
|
|
20
|
+
static fork: import('vue').ShallowReactive<SourcedKeyMap<[plugin: string, type: string], ResourceType>>;
|
|
21
|
+
static precedenceFork: import('vue').ShallowReactive<SourcedKeyMap<[plugin: string, type: string], string>>;
|
|
22
|
+
static is(value: unknown): value is Resource;
|
|
23
|
+
static create(v: RawResource): Resource;
|
|
24
|
+
protected constructor(v: RawResource);
|
|
25
|
+
type: string;
|
|
26
|
+
pathname: string;
|
|
27
|
+
processSteps: ProcessStep[];
|
|
28
|
+
$$meta?: Metadata;
|
|
29
|
+
$$plugin: string;
|
|
30
|
+
getUrl(): Promise<string>;
|
|
31
|
+
omittedForks: import('vue').ShallowReactive<Set<string>>;
|
|
32
|
+
getThisFork(): string;
|
|
33
|
+
localChangeFork(): boolean;
|
|
34
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { Metadata, Metadatable } from '../struct';
|
|
3
|
+
import { Image } from './image';
|
|
4
|
+
import { RawResource } from './resource';
|
|
5
|
+
export interface RawUser extends Metadatable {
|
|
6
|
+
avatar?: RawResource;
|
|
7
|
+
name: string;
|
|
8
|
+
id: string;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class User {
|
|
11
|
+
static userBase: import('vue').ShallowReactive<Map<string, User>>;
|
|
12
|
+
static userEditorBase: import('vue').ShallowReactive<Map<string, Component>>;
|
|
13
|
+
static userCards: import('vue').ShallowReactive<Map<string, UserCardComponent>>;
|
|
14
|
+
constructor(v: RawUser);
|
|
15
|
+
avatar?: Image;
|
|
16
|
+
name: string;
|
|
17
|
+
id: string;
|
|
18
|
+
$$plugin: string;
|
|
19
|
+
$$meta?: Metadata;
|
|
20
|
+
abstract customUser: object;
|
|
21
|
+
}
|
|
22
|
+
export type UserCardComponent = Component<{
|
|
23
|
+
user: User;
|
|
24
|
+
isSmall?: boolean;
|
|
25
|
+
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Metadatable {
|
|
2
|
+
$$meta?: Metadata;
|
|
3
|
+
$$plugin: string;
|
|
4
|
+
}
|
|
5
|
+
export type Metadata = Record<string | number, any>;
|
|
6
|
+
export type PageKey = string | number;
|
|
7
|
+
export interface StreamQuery<TParameters extends any[], TItem> {
|
|
8
|
+
(...args: [...TParameters, page: PageKey, signal?: AbortSignal]): Promise<TItem[] & {
|
|
9
|
+
nextPage?: PageKey;
|
|
10
|
+
}>;
|
|
11
|
+
initialPageParam: PageKey;
|
|
12
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 比如有很多需要注明来自哪个插件的值都可以用
|
|
3
|
+
*/
|
|
4
|
+
export declare class SourcedValue<T extends [string, string]> {
|
|
5
|
+
separator: string;
|
|
6
|
+
toJSON(value: T | string): T;
|
|
7
|
+
parse(value: string): T;
|
|
8
|
+
toString(value: T | string): string;
|
|
9
|
+
stringify(value: T): string;
|
|
10
|
+
constructor(separator?: string);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 相比较于普通的Map,这个元素的key操作可以是`TKey | string`
|
|
14
|
+
* _但内部保存仍使用`SourcedValue.key.toString`作为key_
|
|
15
|
+
*/
|
|
16
|
+
export declare class SourcedKeyMap<TKey extends [string, string], TValue> implements Map<string, TValue> {
|
|
17
|
+
static createReactive<TKey extends [string, string], TValue>(separator?: string): import('vue').ShallowReactive<SourcedKeyMap<TKey, TValue>>;
|
|
18
|
+
constructor(separator?: string);
|
|
19
|
+
key: SourcedValue<TKey>;
|
|
20
|
+
private store;
|
|
21
|
+
get size(): number;
|
|
22
|
+
[Symbol.toStringTag]: string;
|
|
23
|
+
clear(): void;
|
|
24
|
+
delete(key: string | TKey): boolean;
|
|
25
|
+
forEach(callbackfn: (value: TValue, key: string, map: Map<string, TValue>) => void, thisArg?: any): void;
|
|
26
|
+
get(key: string | TKey): TValue | undefined;
|
|
27
|
+
has(key: string | TKey): boolean;
|
|
28
|
+
set(key: string | TKey, value: TValue): this;
|
|
29
|
+
entries(): MapIterator<[string, TValue]>;
|
|
30
|
+
keys(): MapIterator<string>;
|
|
31
|
+
values(): MapIterator<TValue>;
|
|
32
|
+
[Symbol.iterator](): MapIterator<[string, TValue]>;
|
|
33
|
+
}
|
|
34
|
+
export type SourcedKeyType<T extends SourcedKeyMap<[string, string], any> | SourcedValue<[string, string]>> = T extends SourcedKeyMap<infer K, any> ? K | string : T extends SourcedValue<infer K> ? K | string : never;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 可以结构化的数据,调用`toJSON`获取纯粹的json(没有get/set或method)
|
|
3
|
+
*/
|
|
4
|
+
export declare class Struct<TRaw extends object> {
|
|
5
|
+
protected $$raw: TRaw;
|
|
6
|
+
toJSON(): TRaw;
|
|
7
|
+
/**
|
|
8
|
+
* @param $$raw 一个纯粹json对象,不可以是高级对象
|
|
9
|
+
*/
|
|
10
|
+
constructor($$raw: TRaw);
|
|
11
|
+
static toRaw<T extends object, TRaw = T extends Struct<infer TR> ? TR : T>(item: T): TRaw;
|
|
12
|
+
}
|
package/dist/pack.tgz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delta-comic/model",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "空阙虱楼",
|
|
5
5
|
"homepage": "https://github.com/delta-comic/delta-comic",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"vue": "^3.5",
|
|
42
|
-
"@delta-comic/request": "1.3.
|
|
43
|
-
"@delta-comic/utils": "1.3.
|
|
42
|
+
"@delta-comic/request": "1.3.1",
|
|
43
|
+
"@delta-comic/utils": "1.3.1"
|
|
44
44
|
},
|
|
45
45
|
"release": {
|
|
46
46
|
"tagFormat": "model-${version}"
|