@delta-comic/model 2.2.0 → 3.0.0-next.4

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.
@@ -0,0 +1,557 @@
1
+ import { Component } from "vue";
2
+
3
+ //#region lib/struct/store.d.ts
4
+ /**
5
+ * 比如有很多需要注明来自哪个插件的值都可以用
6
+ */
7
+ declare class SourcedValue<T extends [string, string]> {
8
+ separator: string;
9
+ toJSON(value: T | string): T;
10
+ parse(value: string): T;
11
+ toString(value: T | string): string;
12
+ stringify(value: T): string;
13
+ constructor(separator?: string);
14
+ }
15
+ /**
16
+ * 相比较于普通的Map,这个元素的key操作可以是`TKey | string`
17
+ * _但内部保存仍使用`SourcedValue.key.toString`作为key_
18
+ */
19
+ declare class SourcedKeyMap<TKey extends [string, string], TValue> implements Map<string, TValue> {
20
+ getOrInsert(key: string | TKey, value: TValue): TValue;
21
+ getOrInsertComputed(key: string | TKey, compute: (key: string) => TValue): TValue;
22
+ static createReactive<TKey extends [string, string], TValue>(separator?: string): import("vue").ShallowReactive<SourcedKeyMap<TKey, TValue>>;
23
+ constructor(separator?: string);
24
+ key: SourcedValue<TKey>;
25
+ private store;
26
+ get size(): number;
27
+ [Symbol.toStringTag]: string;
28
+ clear(): void;
29
+ delete(key: string | TKey): boolean;
30
+ forEach(callbackfn: (value: TValue, key: string, map: Map<string, TValue>) => void, thisArg?: any): void;
31
+ get(key: string | TKey): TValue | undefined;
32
+ has(key: string | TKey): boolean;
33
+ set(key: string | TKey, value: TValue): this;
34
+ entries(): MapIterator<[string, TValue]>;
35
+ keys(): MapIterator<string>;
36
+ values(): MapIterator<TValue>;
37
+ [Symbol.iterator](): MapIterator<[string, TValue]>;
38
+ }
39
+ 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;
40
+ //#endregion
41
+ //#region lib/struct/struct.d.ts
42
+ /**
43
+ * 可以结构化的数据,调用`toJSON`获取纯粹的json(没有get/set或method)
44
+ */
45
+ declare class Struct<TRaw extends object> {
46
+ protected $$raw: TRaw;
47
+ toJSON(): TRaw;
48
+ /**
49
+ * @param $$raw 一个纯粹json对象,不可以是高级对象
50
+ */
51
+ constructor($$raw: TRaw);
52
+ static toRaw<T extends object, TRaw = (T extends Struct<infer TR> ? TR : T)>(item: T): TRaw;
53
+ }
54
+ //#endregion
55
+ //#region lib/struct/meta.d.ts
56
+ interface Metadatable {
57
+ $$meta?: Metadata;
58
+ $$plugin: string;
59
+ }
60
+ type Metadata = Record<string | number, any>;
61
+ type PageKey = string | number;
62
+ declare class StreamQuery<TResult, TData extends object = {}> {
63
+ query: (data: TData, page: PageKey, signal?: AbortSignal) => Promise<{
64
+ data: TResult[];
65
+ lastPage?: PageKey;
66
+ nextPage?: PageKey;
67
+ }>;
68
+ initPage: PageKey;
69
+ constructor(query: (data: TData, page: PageKey, signal?: AbortSignal) => Promise<{
70
+ data: TResult[];
71
+ lastPage?: PageKey;
72
+ nextPage?: PageKey;
73
+ }>, initPage: PageKey);
74
+ }
75
+ //#endregion
76
+ //#region lib/struct/from.d.ts
77
+ interface Base {
78
+ info: string;
79
+ placeholder?: string;
80
+ /**
81
+ * @default true
82
+ */
83
+ required?: boolean;
84
+ }
85
+ interface FormString extends Base {
86
+ type: 'string';
87
+ patten?: RegExp;
88
+ defaultValue?: FormDefaultValue['string'];
89
+ }
90
+ interface FormNumber extends Base {
91
+ type: 'number';
92
+ range?: [number, number];
93
+ float?: boolean;
94
+ defaultValue?: FormDefaultValue['number'];
95
+ }
96
+ interface FormRadio extends Base {
97
+ type: 'radio';
98
+ selects: {
99
+ label: string;
100
+ value: string;
101
+ }[];
102
+ comp: 'radio' | 'select';
103
+ defaultValue?: FormDefaultValue['radio'];
104
+ }
105
+ interface FormCheckbox extends Base {
106
+ type: 'checkbox';
107
+ selects: {
108
+ label: string;
109
+ value: string;
110
+ }[];
111
+ comp: 'checkbox' | 'multipleSelect';
112
+ defaultValue?: FormDefaultValue['checkbox'];
113
+ }
114
+ interface FormSwitch extends Base {
115
+ type: 'switch';
116
+ close?: string;
117
+ open?: string;
118
+ defaultValue?: FormDefaultValue['switch'];
119
+ }
120
+ interface FormDate extends Base {
121
+ type: 'date';
122
+ format: string;
123
+ time?: boolean;
124
+ defaultValue?: FormDefaultValue['date'];
125
+ }
126
+ interface FormDateRange extends Base {
127
+ type: 'dateRange';
128
+ format: string;
129
+ time?: boolean;
130
+ defaultValue?: FormDefaultValue['dateRange'];
131
+ }
132
+ interface FormPairs extends Base {
133
+ type: 'pairs';
134
+ defaultValue?: FormDefaultValue['pairs'];
135
+ noMultiple?: boolean;
136
+ }
137
+ interface FormDefaultValue {
138
+ string: string;
139
+ number: number;
140
+ radio: string;
141
+ checkbox: string[];
142
+ switch: boolean;
143
+ date: string;
144
+ pairs: {
145
+ key: string;
146
+ value: string;
147
+ }[];
148
+ dateRange: [Form: FormDefaultValue['date'], to: FormDefaultValue['date']];
149
+ }
150
+ type FormSingleConfigure = FormString | FormNumber | FormRadio | FormCheckbox | FormSwitch | FormDate | FormDateRange | FormPairs;
151
+ type FormSingleResult<T extends FormSingleConfigure> = FormDefaultValue[T['type']];
152
+ type FormConfigure = { [x in string]: FormSingleConfigure };
153
+ type FormResult<T extends FormConfigure> = { [K in keyof T]: FormSingleResult<T[K]> };
154
+ declare namespace download_d_exports {
155
+ export { ContentDownloadProvider, ContentDownloadSelection, DownloadAsset, DownloadChecksum, DownloadChecksumAlgorithm, DownloadPlan, DownloadSource, Downloader, HttpHeaderValue, HttpMirror, HttpSource, LegacyDownloader, RefreshSourceInput, RefreshSourceReason, ResolveDownloadInput, TorrentInput, TorrentSeedPolicy, TorrentSource };
156
+ }
157
+ type DownloadChecksumAlgorithm = 'sha256' | 'md5';
158
+ interface DownloadChecksum {
159
+ algorithm: DownloadChecksumAlgorithm;
160
+ value: string;
161
+ }
162
+ /** A JSON-safe HTTP header value. Sensitive values should be passed by reference. */
163
+ type HttpHeaderValue = {
164
+ type: 'value';
165
+ value: string;
166
+ } | {
167
+ type: 'secretRef';
168
+ secretRef: string;
169
+ };
170
+ interface HttpMirror {
171
+ url: string;
172
+ /** Larger values are tried first. Mirrors with the same priority keep their declared order. */
173
+ priority?: number;
174
+ headers?: Record<string, HttpHeaderValue>;
175
+ }
176
+ interface HttpSource {
177
+ type: 'http';
178
+ mirrors: HttpMirror[];
179
+ etag?: string;
180
+ lastModified?: string;
181
+ expectedSize?: number;
182
+ /** Unix timestamp in milliseconds after which the source should be refreshed. */
183
+ expiresAt?: number;
184
+ }
185
+ type TorrentInput = {
186
+ type: 'magnet';
187
+ uri: string;
188
+ } | {
189
+ type: 'url';
190
+ url: string;
191
+ } | {
192
+ type: 'bytes';
193
+ base64: string;
194
+ };
195
+ type TorrentSeedPolicy = {
196
+ mode: 'none';
197
+ } | {
198
+ mode: 'ratio';
199
+ ratio: number;
200
+ } | {
201
+ mode: 'duration';
202
+ durationSeconds: number;
203
+ } | {
204
+ mode: 'ratioOrDuration';
205
+ ratio: number;
206
+ durationSeconds: number;
207
+ };
208
+ interface TorrentSource {
209
+ type: 'torrent';
210
+ input: TorrentInput;
211
+ /** Zero-based file indexes in torrent metadata. Omit to download every file. */
212
+ onlyFiles?: number[];
213
+ seedPolicy?: TorrentSeedPolicy;
214
+ }
215
+ type DownloadSource = HttpSource | TorrentSource;
216
+ /** A JSON-serializable file entry produced by a content plugin. */
217
+ interface DownloadAsset {
218
+ /** Stable within the containing plan and across retries. */
219
+ key: string;
220
+ /** Relative to the destination selected by the host application. */
221
+ relativePath: string;
222
+ size?: number;
223
+ checksum?: DownloadChecksum;
224
+ source: DownloadSource;
225
+ }
226
+ /** A JSON-serializable group of files that should be enqueued together. */
227
+ interface DownloadPlan {
228
+ /** Stable for the content represented by this plan. */
229
+ key: string;
230
+ title: string;
231
+ assets: DownloadAsset[];
232
+ }
233
+ type ContentDownloadSelection = {
234
+ type: 'currentEpisode';
235
+ } | {
236
+ type: 'episodes';
237
+ episodeIds: string[];
238
+ } | {
239
+ type: 'allEpisodes';
240
+ };
241
+ interface ResolveDownloadInput {
242
+ page: ContentPage;
243
+ selection: ContentDownloadSelection;
244
+ }
245
+ type RefreshSourceReason = 'expired' | 'unauthorized' | 'forbidden';
246
+ interface RefreshSourceInput {
247
+ page: ContentPage;
248
+ planKey: string;
249
+ assetKey: string;
250
+ source: DownloadSource;
251
+ reason: RefreshSourceReason;
252
+ }
253
+ /**
254
+ * Resolves plugin-specific content into a portable download plan.
255
+ *
256
+ * Providers are runtime objects and are not serialized. Their returned plans and sources must be
257
+ * JSON-serializable so the native downloader can persist and resume them without a live WebView.
258
+ */
259
+ interface ContentDownloadProvider {
260
+ resolve(input: ResolveDownloadInput, signal: AbortSignal): Promise<DownloadPlan>;
261
+ refreshSource?(input: RefreshSourceInput, signal: AbortSignal): Promise<DownloadSource>;
262
+ }
263
+ /**
264
+ * Legacy imperative download controller.
265
+ *
266
+ * @deprecated Register a {@link ContentDownloadProvider} for the content type and let the native
267
+ * downloader own task state, persistence, and lifecycle controls. This class remains unchanged so
268
+ * existing plugins can migrate without an immediate breaking change.
269
+ */
270
+ declare abstract class Downloader implements Metadatable {
271
+ abstract id: string;
272
+ abstract name: string;
273
+ abstract $$plugin: string;
274
+ abstract $$meta?: Metadata;
275
+ abstract begin: () => void;
276
+ abstract resume: () => void;
277
+ abstract pause: () => void;
278
+ }
279
+ /** @deprecated Use {@link ContentDownloadProvider}. */
280
+ type LegacyDownloader = Downloader;
281
+ declare namespace ep_d_exports {
282
+ export { Ep, RawEp };
283
+ }
284
+ interface RawEp extends Metadatable {
285
+ name: string;
286
+ id: string;
287
+ }
288
+ declare class Ep extends Struct<RawEp> implements RawEp {
289
+ name: string;
290
+ id: string;
291
+ $$plugin: string;
292
+ $$meta?: Metadata;
293
+ constructor(v: RawEp);
294
+ }
295
+ declare namespace content_d_exports {
296
+ export { ContentPage, ContentPageLike, ContentType, ContentType_, LayoutComponent, ViewComponent };
297
+ }
298
+ type ContentPageLike = new (preload: Item | undefined, id: string, ep: string) => ContentPage;
299
+ type ContentType_ = SourcedKeyType<typeof ContentPage.contentPages>;
300
+ type ContentType = Exclude<ContentType_, string>;
301
+ type ViewComponent = Component<{
302
+ page: ContentPage;
303
+ union?: Item;
304
+ }>;
305
+ type LayoutComponent = Component<{
306
+ page: ContentPage;
307
+ }, any, any, any, any, any, {
308
+ view(args: {
309
+ item?: Item;
310
+ }): any;
311
+ }>;
312
+ declare abstract class ContentPage {
313
+ preload: Item | undefined;
314
+ id: string;
315
+ ep: string;
316
+ static layouts: import("vue").ShallowReactive<SourcedKeyMap<[plugin: string, name: string], LayoutComponent>>;
317
+ static contentPages: import("vue").ShallowReactive<SourcedKeyMap<[plugin: string, name: string], ContentPageLike>>;
318
+ static downloadProviders: import("vue").ShallowReactive<SourcedKeyMap<[plugin: string, name: string], ContentDownloadProvider>>;
319
+ constructor(preload: Item | undefined, id: string, ep: string);
320
+ abstract plugin: string;
321
+ abstract contentType: ContentType;
322
+ abstract fetchShortId(signal?: AbortSignal): Promise<string>;
323
+ abstract fetchDetail(signal?: AbortSignal): Promise<Item>;
324
+ abstract fetchRecommends: StreamQuery<Item>;
325
+ abstract fetchComments: StreamQuery<Comment>;
326
+ abstract fetchEps: StreamQuery<Ep>;
327
+ abstract ViewComponent: ViewComponent;
328
+ }
329
+ declare namespace resource_d_exports {
330
+ export { ProcessInstance, ProcessStep, ProcessStep_, RawResource, Resource, ResourceType };
331
+ }
332
+ type ProcessInstance = (nowPath: string, resource: Resource) => Promise<[path: string, exit: boolean]>;
333
+ interface ProcessStep {
334
+ referenceName: string;
335
+ ignoreExit?: boolean;
336
+ }
337
+ type ProcessStep_ = ProcessStep | string;
338
+ interface ResourceType {
339
+ type: string;
340
+ urls: string[];
341
+ test: (url: string, signal: AbortSignal) => PromiseLike<void>;
342
+ }
343
+ interface RawResource extends Metadatable {
344
+ pathname: string;
345
+ type: string;
346
+ processSteps?: ProcessStep_[];
347
+ }
348
+ declare class Resource extends Struct<RawResource> implements RawResource {
349
+ static processInstances: import("vue").ShallowReactive<SourcedKeyMap<[plugin: string, referenceName: string], ProcessInstance>>;
350
+ static fork: import("vue").ShallowReactive<SourcedKeyMap<[plugin: string, type: string], ResourceType>>;
351
+ static precedenceFork: import("vue").ShallowReactive<SourcedKeyMap<[plugin: string, type: string], string>>;
352
+ static is(value: unknown): value is Resource;
353
+ static create(v: RawResource): Resource;
354
+ protected constructor(v: RawResource);
355
+ type: string;
356
+ pathname: string;
357
+ processSteps: ProcessStep[];
358
+ $$meta?: Metadata;
359
+ $$plugin: string;
360
+ getUrl(): Promise<string>;
361
+ omittedForks: import("vue").ShallowReactive<Set<string>>;
362
+ getThisFork(): string;
363
+ localChangeFork(): boolean;
364
+ }
365
+ declare namespace image_d_exports {
366
+ export { Image, ImageAspect, Image_, RawImage };
367
+ }
368
+ interface RawImage extends Metadatable {
369
+ path: string;
370
+ forkNamespace: string;
371
+ processSteps?: ProcessStep_[];
372
+ }
373
+ declare class Image extends Resource {
374
+ static is(value: unknown): value is Image;
375
+ static create(v: RawResource | RawImage, aspect?: ImageAspect): Image;
376
+ protected constructor(v: RawResource | RawImage, aspect?: ImageAspect);
377
+ get aspect(): Partial<ImageAspect> | undefined;
378
+ set aspect(v: Partial<ImageAspect> | undefined);
379
+ }
380
+ interface ImageAspect {
381
+ width: number;
382
+ height: number;
383
+ }
384
+ type Image_ = string | Image;
385
+ declare namespace item_d_exports {
386
+ export { Author, Category, Description, Item, ItemCardComponent, ItemTranslator, RawItem };
387
+ }
388
+ interface Category extends Metadatable {
389
+ name: string;
390
+ group: string;
391
+ search: {
392
+ keyword: string;
393
+ source: string;
394
+ sort: string;
395
+ };
396
+ }
397
+ interface Author extends Metadatable {
398
+ label: string;
399
+ icon: RawResource | RawImage | string;
400
+ description: string;
401
+ /**
402
+ * 为空则不可订阅
403
+ * 否则传入的为`defineConfig`中定义的`subscribe.type`
404
+ */
405
+ subscribe?: string;
406
+ actions?: string[];
407
+ }
408
+ interface RawItem extends Metadatable {
409
+ cover: RawResource | RawImage;
410
+ title: string;
411
+ id: string;
412
+ /** @alias tags */
413
+ categories: Category[];
414
+ author: Author[];
415
+ viewNumber?: number;
416
+ likeNumber?: number;
417
+ commentNumber?: number;
418
+ isLiked?: boolean;
419
+ updateTime?: number;
420
+ customIsAI?: boolean;
421
+ contentType: ContentType_;
422
+ length: string;
423
+ epLength: string;
424
+ description?: Description;
425
+ thisEp: RawEp;
426
+ commentSendable: boolean;
427
+ customIsSafe?: boolean;
428
+ }
429
+ type ItemCardComponent = Component<{
430
+ item: Item;
431
+ freeHeight?: boolean;
432
+ disabled?: boolean;
433
+ type?: 'default' | 'big' | 'small';
434
+ class?: any;
435
+ style?: any;
436
+ }, any, any, any, any, {
437
+ click: [];
438
+ }, {
439
+ default(): void;
440
+ smallTopInfo(): void;
441
+ cover(): void;
442
+ }>;
443
+ type ItemTranslator = (raw: RawItem) => Item;
444
+ type Description = string | {
445
+ type: 'html';
446
+ content: string;
447
+ } | {
448
+ type: 'text';
449
+ content: string;
450
+ };
451
+ declare abstract class Item extends Struct<RawItem> implements RawItem {
452
+ static itemTranslator: import("vue").ShallowReactive<SourcedKeyMap<[plugin: string, name: string], ItemTranslator>>;
453
+ static create(raw: RawItem): Item;
454
+ static authorIcon: import("vue").ShallowReactive<SourcedKeyMap<[plugin: string, name: string], Component>>;
455
+ static itemCards: import("vue").ShallowReactive<SourcedKeyMap<[plugin: string, name: string], ItemCardComponent>>;
456
+ abstract like(): Promise<any>;
457
+ abstract report(): Promise<any>;
458
+ abstract sendComment(text: string): Promise<any>;
459
+ static is(value: unknown): value is Item;
460
+ cover: RawResource | RawImage;
461
+ get $cover(): Image;
462
+ title: string;
463
+ id: string;
464
+ categories: Category[];
465
+ author: Author[];
466
+ viewNumber?: number;
467
+ likeNumber?: number;
468
+ commentNumber?: number;
469
+ isLiked?: boolean;
470
+ description?: Description;
471
+ updateTime?: number;
472
+ contentType: ContentType;
473
+ length: string;
474
+ epLength: string;
475
+ $$plugin: string;
476
+ $$meta: Metadata | undefined;
477
+ thisEp: RawEp;
478
+ customIsSafe?: boolean;
479
+ get $thisEp(): Ep;
480
+ constructor(v: RawItem);
481
+ commentSendable: boolean;
482
+ customIsAI?: boolean;
483
+ get $isAi(): boolean;
484
+ }
485
+ declare namespace user_d_exports {
486
+ export { RawUser, User, UserCardComponent };
487
+ }
488
+ interface RawUser extends Metadatable {
489
+ avatar?: RawResource;
490
+ name: string;
491
+ id: string;
492
+ }
493
+ declare abstract class User {
494
+ static userBase: import("vue").ShallowReactive<Map<string, User>>;
495
+ static userEditorBase: import("vue").ShallowReactive<Map<string, Component>>;
496
+ static userCards: import("vue").ShallowReactive<Map<string, UserCardComponent>>;
497
+ constructor(v: RawUser);
498
+ avatar?: Image;
499
+ name: string;
500
+ id: string;
501
+ $$plugin: string;
502
+ $$meta?: Metadata;
503
+ abstract customUser: object;
504
+ }
505
+ type UserCardComponent = Component<{
506
+ user: User;
507
+ isSmall?: boolean;
508
+ }>;
509
+ declare namespace comment_d_exports {
510
+ export { Comment, CommentRow, RawComment };
511
+ }
512
+ interface RawComment extends Metadatable {
513
+ sender: User;
514
+ content: {
515
+ type: 'string' | 'html';
516
+ text: string;
517
+ };
518
+ time: number;
519
+ id: string;
520
+ childrenCount: number;
521
+ likeCount: number;
522
+ isLiked: boolean;
523
+ reported: boolean;
524
+ isTop: boolean;
525
+ }
526
+ type CommentRow = Component<{
527
+ comment: Comment;
528
+ item: Item;
529
+ parentComment?: Comment;
530
+ }>;
531
+ declare abstract class Comment extends Struct<RawComment> implements RawComment {
532
+ static commentRow: import("vue").ShallowReactive<SourcedKeyMap<[plugin: string, name: string], CommentRow>>;
533
+ constructor(v: RawComment);
534
+ abstract sender: User;
535
+ content: {
536
+ type: 'string' | 'html';
537
+ text: string;
538
+ };
539
+ time: number;
540
+ id: string;
541
+ childrenCount: number;
542
+ likeCount: number;
543
+ isTop: boolean;
544
+ isLiked: boolean;
545
+ reported: boolean;
546
+ $$plugin: string;
547
+ $$meta?: Metadata;
548
+ abstract like(signal?: AbortSignal): PromiseLike<boolean>;
549
+ abstract report(signal?: AbortSignal): PromiseLike<any>;
550
+ abstract sendComment(text: string, signal?: AbortSignal): PromiseLike<any>;
551
+ abstract fetchChildren: StreamQuery<Comment>;
552
+ }
553
+ declare namespace index_d_exports {
554
+ export { comment_d_exports as comment, content_d_exports as content, download_d_exports as download, ep_d_exports as ep, image_d_exports as image, item_d_exports as item, resource_d_exports as resource, user_d_exports as user };
555
+ }
556
+ //#endregion
557
+ export { Base, FormCheckbox, FormConfigure, FormDate, FormDateRange, FormDefaultValue, FormNumber, FormPairs, FormRadio, FormResult, FormSingleConfigure, FormSingleResult, FormString, FormSwitch, Metadata, Metadatable, PageKey, SourcedKeyMap, SourcedKeyType, SourcedValue, StreamQuery, Struct, index_d_exports as uni };