-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path_venera_.js
1346 lines (1231 loc) · 33.1 KB
/
_venera_.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Venera JavaScript Library
This library provides a set of APIs for interacting with the Venera app.
*/
function setTimeout(callback, delay) {
sendMessage({
method: 'delay',
time: delay,
}).then(callback);
}
/// encode, decode, hash, decrypt
let Convert = {
/**
* @param str {string}
* @returns {ArrayBuffer}
*/
encodeUtf8: (str) => {
return sendMessage({
method: "convert",
type: "utf8",
value: str,
isEncode: true
});
},
/**
* @param value {ArrayBuffer}
* @returns {string}
*/
decodeUtf8: (value) => {
return sendMessage({
method: "convert",
type: "utf8",
value: value,
isEncode: false
});
},
/**
* @param {ArrayBuffer} value
* @returns {string}
*/
encodeBase64: (value) => {
return sendMessage({
method: "convert",
type: "base64",
value: value,
isEncode: true
});
},
/**
* @param {string} value
* @returns {ArrayBuffer}
*/
decodeBase64: (value) => {
return sendMessage({
method: "convert",
type: "base64",
value: value,
isEncode: false
});
},
/**
* @param {ArrayBuffer} value
* @returns {ArrayBuffer}
*/
md5: (value) => {
return sendMessage({
method: "convert",
type: "md5",
value: value,
isEncode: true
});
},
/**
* @param {ArrayBuffer} value
* @returns {ArrayBuffer}
*/
sha1: (value) => {
return sendMessage({
method: "convert",
type: "sha1",
value: value,
isEncode: true
});
},
/**
* @param {ArrayBuffer} value
* @returns {ArrayBuffer}
*/
sha256: (value) => {
return sendMessage({
method: "convert",
type: "sha256",
value: value,
isEncode: true
});
},
/**
* @param {ArrayBuffer} value
* @returns {ArrayBuffer}
*/
sha512: (value) => {
return sendMessage({
method: "convert",
type: "sha512",
value: value,
isEncode: true
});
},
/**
* @param key {ArrayBuffer}
* @param value {ArrayBuffer}
* @param hash {string} - md5, sha1, sha256, sha512
* @returns {ArrayBuffer}
*/
hmac: (key, value, hash) => {
return sendMessage({
method: "convert",
type: "hmac",
value: value,
key: key,
hash: hash,
isEncode: true
});
},
/**
* @param key {ArrayBuffer}
* @param value {ArrayBuffer}
* @param hash {string} - md5, sha1, sha256, sha512
* @returns {string} - hex string
*/
hmacString: (key, value, hash) => {
return sendMessage({
method: "convert",
type: "hmac",
value: value,
key: key,
hash: hash,
isEncode: true,
isString: true
});
},
/**
* @param {ArrayBuffer} value
* @param {ArrayBuffer} key
* @returns {ArrayBuffer}
*/
decryptAesEcb: (value, key) => {
return sendMessage({
method: "convert",
type: "aes-ecb",
value: value,
key: key,
isEncode: false
});
},
/**
* @param {ArrayBuffer} value
* @param {ArrayBuffer} key
* @param {ArrayBuffer} iv
* @returns {ArrayBuffer}
*/
decryptAesCbc: (value, key, iv) => {
return sendMessage({
method: "convert",
type: "aes-ecb",
value: value,
key: key,
iv: iv,
isEncode: false
});
},
/**
* @param {ArrayBuffer} value
* @param {ArrayBuffer} key
* @param {number} blockSize
* @returns {ArrayBuffer}
*/
decryptAesCfb: (value, key, blockSize) => {
return sendMessage({
method: "convert",
type: "aes-cfb",
value: value,
key: key,
blockSize: blockSize,
isEncode: false
});
},
/**
* @param {ArrayBuffer} value
* @param {ArrayBuffer} key
* @param {number} blockSize
* @returns {ArrayBuffer}
*/
decryptAesOfb: (value, key, blockSize) => {
return sendMessage({
method: "convert",
type: "aes-ofb",
value: value,
key: key,
blockSize: blockSize,
isEncode: false
});
},
/**
* @param {ArrayBuffer} value
* @param {ArrayBuffer} key
* @returns {ArrayBuffer}
*/
decryptRsa: (value, key) => {
return sendMessage({
method: "convert",
type: "rsa",
value: value,
key: key,
isEncode: false
});
},
/** Encode bytes to hex string
* @param bytes {ArrayBuffer}
* @return {string}
*/
hexEncode: (bytes) => {
const hexDigits = '0123456789abcdef';
const view = new Uint8Array(bytes);
let charCodes = new Uint8Array(view.length * 2);
let j = 0;
for (let i = 0; i < view.length; i++) {
let byte = view[i];
charCodes[j++] = hexDigits.charCodeAt((byte >> 4) & 0xF);
charCodes[j++] = hexDigits.charCodeAt(byte & 0xF);
}
return String.fromCharCode(...charCodes);
},
}
/**
* create a time-based uuid
*
* Note: the engine will generate a new uuid every time it is called
*
* To get the same uuid, please save it to the local storage
*
* @returns {string}
*/
function createUuid() {
return sendMessage({
method: "uuid"
});
}
/**
* Generate a random integer between min and max
* @param min {number}
* @param max {number}
* @returns {number}
*/
function randomInt(min, max) {
return sendMessage({
method: 'random',
type: 'int',
min: min,
max: max
});
}
/**
* Generate a random double between min and max
* @param min {number}
* @param max {number}
* @returns {number}
*/
function randomDouble(min, max) {
return sendMessage({
method: 'random',
type: 'double',
min: min,
max: max
});
}
class _Timer {
delay = 0;
callback = () => { };
status = false;
constructor(delay, callback) {
this.delay = delay;
this.callback = callback;
}
run() {
this.status = true;
this._interval();
}
_interval() {
if (!this.status) {
return;
}
this.callback();
setTimeout(this._interval.bind(this), this.delay);
}
cancel() {
this.status = false;
}
}
function setInterval(callback, delay) {
let timer = new _Timer(delay, callback);
timer.run();
return timer;
}
/**
* Create a cookie object.
* @param name {string}
* @param value {string}
* @param domain {string}
* @constructor
*/
function Cookie({name, value, domain}) {
this.name = name;
this.value = value;
this.domain = domain;
}
/**
* Network object for sending HTTP requests and managing cookies.
* @namespace Network
*/
let Network = {
/**
* Sends an HTTP request.
* @param {string} method - The HTTP method (e.g., GET, POST, PUT, PATCH, DELETE).
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @param data - The data to send with the request.
* @returns {Promise<{status: number, headers: {}, body: ArrayBuffer}>} The response from the request.
*/
async fetchBytes(method, url, headers, data) {
let result = await sendMessage({
method: 'http',
http_method: method,
bytes: true,
url: url,
headers: headers,
data: data,
});
if (result.error) {
throw result.error;
}
return result;
},
/**
* Sends an HTTP request.
* @param {string} method - The HTTP method (e.g., GET, POST, PUT, PATCH, DELETE).
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @param data - The data to send with the request.
* @returns {Promise<{status: number, headers: {}, body: string}>} The response from the request.
*/
async sendRequest(method, url, headers, data) {
let result = await sendMessage({
method: 'http',
http_method: method,
url: url,
headers: headers,
data: data,
});
if (result.error) {
throw result.error;
}
return result;
},
/**
* Sends an HTTP GET request.
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @returns {Promise<{status: number, headers: {}, body: string}>} The response from the request.
*/
async get(url, headers) {
return this.sendRequest('GET', url, headers);
},
/**
* Sends an HTTP POST request.
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @param data - The data to send with the request.
* @returns {Promise<{status: number, headers: {}, body: string}>} The response from the request.
*/
async post(url, headers, data) {
return this.sendRequest('POST', url, headers, data);
},
/**
* Sends an HTTP PUT request.
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @param data - The data to send with the request.
* @returns {Promise<{status: number, headers: {}, body: string}>} The response from the request.
*/
async put(url, headers, data) {
return this.sendRequest('PUT', url, headers, data);
},
/**
* Sends an HTTP PATCH request.
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @param data - The data to send with the request.
* @returns {Promise<{status: number, headers: {}, body: string}>} The response from the request.
*/
async patch(url, headers, data) {
return this.sendRequest('PATCH', url, headers, data);
},
/**
* Sends an HTTP DELETE request.
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @returns {Promise<{status: number, headers: {}, body: string}>} The response from the request.
*/
async delete(url, headers) {
return this.sendRequest('DELETE', url, headers);
},
/**
* Sets cookies for a specific URL.
* @param {string} url - The URL to set the cookies for.
* @param {Cookie[]} cookies - The cookies to set.
*/
setCookies(url, cookies) {
sendMessage({
method: 'cookie',
function: 'set',
url: url,
cookies: cookies,
});
},
/**
* Retrieves cookies for a specific URL.
* @param {string} url - The URL to get the cookies from.
* @returns {Promise<Cookie[]>} The cookies for the given URL.
*/
getCookies(url) {
return sendMessage({
method: 'cookie',
function: 'get',
url: url,
});
},
/**
* Deletes cookies for a specific URL.
* @param {string} url - The URL to delete the cookies from.
*/
deleteCookies(url) {
sendMessage({
method: 'cookie',
function: 'delete',
url: url,
});
},
};
/**
* [fetch] function for sending HTTP requests. Same api as the browser fetch.
* @param url {string}
* @param options {{method: string, headers: Object, body: any}}
* @returns {Promise<{ok: boolean, status: number, statusText: string, headers: {}, arrayBuffer: (function(): Promise<ArrayBuffer>), text: (function(): Promise<string>), json: (function(): Promise<any>)}>}
* @since 1.2.0
*/
async function fetch(url, options) {
let method = 'GET';
let headers = {};
let data = null;
if (options) {
method = options.method || method;
headers = options.headers || headers;
data = options.body || data;
}
let result = await Network.fetchBytes(method, url, headers, data);
return {
ok: result.status >= 200 && result.status < 300,
status: result.status,
statusText: '',
headers: result.headers,
arrayBuffer: async () => result.body,
text: async () => Convert.decodeUtf8(result.body),
json: async () => JSON.parse(Convert.decodeUtf8(result.body)),
}
}
/**
* HtmlDocument class for parsing HTML and querying elements.
*/
class HtmlDocument {
static _key = 0;
key = 0;
/**
* Constructor for HtmlDocument.
* @param {string} html - The HTML string to parse.
*/
constructor(html) {
this.key = HtmlDocument._key;
HtmlDocument._key++;
sendMessage({
method: "html",
function: "parse",
key: this.key,
data: html
})
}
/**
* Query a single element from the HTML document.
* @param {string} query - The query string.
* @returns {HtmlElement | null} The first matching element.
*/
querySelector(query) {
let k = sendMessage({
method: "html",
function: "querySelector",
key: this.key,
query: query
})
if(k == null) return null;
return new HtmlElement(k, this.key);
}
/**
* Query all matching elements from the HTML document.
* @param {string} query - The query string.
* @returns {HtmlElement[]} An array of matching elements.
*/
querySelectorAll(query) {
let ks = sendMessage({
method: "html",
function: "querySelectorAll",
key: this.key,
query: query
})
return ks.map(k => new HtmlElement(k, this.key));
}
/**
* Dispose the HTML document.
* This should be called when the document is no longer needed.
*/
dispose() {
sendMessage({
method: "html",
function: "dispose",
key: this.key
})
}
/**
* Get the element by its id.
* @param id {string}
* @returns {HtmlElement|null}
*/
getElementById(id) {
let k = sendMessage({
method: "html",
function: "getElementById",
key: this.key,
id: id
})
if(k == null) return null;
return new HtmlElement(k, this.key);
}
}
/**
* HtmlDom class for interacting with HTML elements.
*/
class HtmlElement {
key = 0;
doc = 0;
/**
* Constructor for HtmlDom.
* @param {number} k - The key of the element.
* @param {number} doc - The key of the document.
*/
constructor(k, doc) {
this.key = k;
this.doc = doc;
}
/**
* Get the text content of the element.
* @returns {string} The text content.
*/
get text() {
return sendMessage({
method: "html",
function: "getText",
key: this.key,
doc: this.doc,
})
}
/**
* Get the attributes of the element.
* @returns {Object} The attributes.
*/
get attributes() {
return sendMessage({
method: "html",
function: "getAttributes",
key: this.key,
doc: this.doc,
})
}
/**
* Query a single element from the current element.
* @param {string} query - The query string.
* @returns {HtmlElement} The first matching element.
*/
querySelector(query) {
let k = sendMessage({
method: "html",
function: "dom_querySelector",
key: this.key,
query: query,
doc: this.doc,
})
if(k == null) return null;
return new HtmlElement(k, this.doc);
}
/**
* Query all matching elements from the current element.
* @param {string} query - The query string.
* @returns {HtmlElement[]} An array of matching elements.
*/
querySelectorAll(query) {
let ks = sendMessage({
method: "html",
function: "dom_querySelectorAll",
key: this.key,
query: query,
doc: this.doc,
})
return ks.map(k => new HtmlElement(k, this.doc));
}
/**
* Get the children of the current element.
* @returns {HtmlElement[]} An array of child elements.
*/
get children() {
let ks = sendMessage({
method: "html",
function: "getChildren",
key: this.key,
doc: this.doc,
})
return ks.map(k => new HtmlElement(k, this.doc));
}
/**
* Get the nodes of the current element.
* @returns {HtmlNode[]} An array of nodes.
*/
get nodes() {
let ks = sendMessage({
method: "html",
function: "getNodes",
key: this.key,
doc: this.doc,
})
return ks.map(k => new HtmlNode(k, this.doc));
}
/**
* Get inner HTML of the element.
* @returns {string} The inner HTML.
*/
get innerHTML() {
return sendMessage({
method: "html",
function: "getInnerHTML",
key: this.key,
doc: this.doc,
})
}
/**
* Get parent element of the element. If the element has no parent, return null.
* @returns {HtmlElement|null}
*/
get parent() {
let k = sendMessage({
method: "html",
function: "getParent",
key: this.key,
doc: this.doc,
})
if(k == null) return null;
return new HtmlElement(k, this.doc);
}
/**
* Get class names of the element.
* @returns {string[]} An array of class names.
*/
get classNames() {
return sendMessage({
method: "html",
function: "getClassNames",
key: this.key,
doc: this.doc,
})
}
/**
* Get id of the element.
* @returns {string | null} The id of the element.
*/
get id() {
return sendMessage({
method: "html",
function: "getId",
key: this.key,
doc: this.doc,
})
}
/**
* Get local name of the element.
* @returns {string} The tag name of the element.
*/
get localName() {
return sendMessage({
method: "html",
function: "getLocalName",
key: this.key,
doc: this.doc,
})
}
/**
* Get the previous sibling element of the element. If the element has no previous sibling, return null.
* @returns {HtmlElement|null}
*/
get previousElementSibling() {
let k = sendMessage({
method: "html",
function: "getPreviousSibling",
key: this.key,
doc: this.doc,
})
if(k == null) return null;
return new HtmlElement(k, this.doc);
}
/**
* Get the next sibling element of the element. If the element has no next sibling, return null.
* @returns {HtmlElement|null}
*/
get nextElementSibling() {
let k = sendMessage({
method: "html",
function: "getNextSibling",
key: this.key,
doc: this.doc,
})
if (k == null) return null;
return new HtmlElement(k, this.doc);
}
}
class HtmlNode {
key = 0;
doc = 0;
constructor(k, doc) {
this.key = k;
this.doc = doc;
}
/**
* Get the text content of the node.
* @returns {string} The text content.
*/
get text() {
return sendMessage({
method: "html",
function: "node_text",
key: this.key,
doc: this.doc,
})
}
/**
* Get the type of the node.
* @returns {string} The type of the node. ("text", "element", "comment", "document", "unknown")
*/
get type() {
return sendMessage({
method: "html",
function: "node_type",
key: this.key,
doc: this.doc,
})
}
/**
* Convert the node to an HtmlElement. If the node is not an element, return null.
* @returns {HtmlElement|null}
*/
toElement() {
let k = sendMessage({
method: "html",
function: "node_toElement",
key: this.key,
doc: this.doc,
})
if(k == null) return null;
return new HtmlElement(k, this.doc);
}
}
function log(level, title, content) {
sendMessage({
method: 'log',
level: level,
title: title,
content: content,
})
}
let console = {
log: (content) => {
log('info', 'JS Console', content)
},
warn: (content) => {
log('warning', 'JS Console', content)
},
error: (content) => {
log('error', 'JS Console', content)
},
};
/**
* Create a comic object
* @param id {string}
* @param title {string}
* @param subtitle {string}
* @param subTitle {string} - equal to subtitle
* @param cover {string}
* @param tags {string[]}
* @param description {string}
* @param maxPage {number?}
* @param language {string?}
* @param favoriteId {string?} - Only set this field if the comic is from favorites page
* @param stars {number?} - 0-5, double
* @constructor
*/
function Comic({id, title, subtitle, subTitle, cover, tags, description, maxPage, language, favoriteId, stars}) {
this.id = id;
this.title = title;
this.subtitle = subtitle;
this.subTitle = subTitle;
this.cover = cover;
this.tags = tags;
this.description = description;
this.maxPage = maxPage;
this.language = language;
this.favoriteId = favoriteId;
this.stars = stars;
}
/**
* Create a comic details object
* @param title {string}
* @param subtitle {string}
* @param subTitle {string} - equal to subtitle
* @param cover {string}
* @param description {string?}
* @param tags {Map<string, string[]> | {} | null | undefined}
* @param chapters {Map<string, string> | {} | null | undefined} - key: chapter id, value: chapter title
* @param isFavorite {boolean | null | undefined} - favorite status. If the comic source supports multiple folders, this field should be null
* @param subId {string?} - a param which is passed to comments api
* @param thumbnails {string[]?} - for multiple page thumbnails, set this to null, and use `loadThumbnails` api to load thumbnails
* @param recommend {Comic[]?} - related comics
* @param commentCount {number?}
* @param likesCount {number?}
* @param isLiked {boolean?}
* @param uploader {string?}
* @param updateTime {string?}
* @param uploadTime {string?}
* @param url {string?}
* @param stars {number?} - 0-5, double
* @param maxPage {number?}
* @param comments {Comment[]?}- `since 1.0.7` App will display comments in the details page.
* @constructor
*/
function ComicDetails({title, subtitle, subTitle, cover, description, tags, chapters, isFavorite, subId, thumbnails, recommend, commentCount, likesCount, isLiked, uploader, updateTime, uploadTime, url, stars, maxPage, comments}) {
this.title = title;
this.subtitle = subtitle ?? subTitle;
this.cover = cover;
this.description = description;
this.tags = tags;
this.chapters = chapters;
this.isFavorite = isFavorite;
this.subId = subId;
this.thumbnails = thumbnails;
this.recommend = recommend;
this.commentCount = commentCount;
this.likesCount = likesCount;
this.isLiked = isLiked;
this.uploader = uploader;
this.updateTime = updateTime;
this.uploadTime = uploadTime;
this.url = url;
this.stars = stars;
this.maxPage = maxPage;
this.comments = comments;
}
/**
* Create a comment object
* @param userName {string}
* @param avatar {string?}
* @param content {string}
* @param time {string?}
* @param replyCount {number?}
* @param id {string?}
* @param isLiked {boolean?}
* @param score {number?}
* @param voteStatus {number?} - 1: upvote, -1: downvote, 0: none
* @constructor
*/
function Comment({userName, avatar, content, time, replyCount, id, isLiked, score, voteStatus}) {
this.userName = userName;
this.avatar = avatar;
this.content = content;
this.time = time;
this.replyCount = replyCount;
this.id = id;
this.isLiked = isLiked;
this.score = score;
this.voteStatus = voteStatus;
}
/**
* Create image loading config
* @param url {string?}
* @param method {string?} - http method, uppercase
* @param data {any} - request data, may be null
* @param headers {Object?} - request headers
* @param onResponse {((ArrayBuffer) => ArrayBuffer)?} - modify response data
* @param modifyImage {string?}
* A js script string.
* The script will be executed in a new Isolate.
* A function named `modifyImage` should be defined in the script, which receives an [Image] as the only argument, and returns an [Image]..
* @param onLoadFailed {(() => ImageLoadingConfig)?} - called when the image loading failed
* @constructor