@delta-comic/model 0.0.3 → 0.0.5

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/index.js CHANGED
@@ -46,12 +46,12 @@ function O(e) {
46
46
  let t = e?.constructor;
47
47
  return e === (typeof t == "function" ? t.prototype : Object.prototype);
48
48
  }
49
- function ee(e) {
49
+ function k(e) {
50
50
  return b(e);
51
51
  }
52
- function k(e) {
52
+ function A(e) {
53
53
  if (e == null) return !0;
54
- if (T(e)) return typeof e.splice != "function" && typeof e != "string" && (typeof Buffer > "u" || !Buffer.isBuffer(e)) && !ee(e) && !E(e) ? !1 : e.length === 0;
54
+ if (T(e)) return typeof e.splice != "function" && typeof e != "string" && (typeof Buffer > "u" || !Buffer.isBuffer(e)) && !k(e) && !E(e) ? !1 : e.length === 0;
55
55
  if (typeof e == "object") {
56
56
  if (e instanceof Map || e instanceof Set) return e.size === 0;
57
57
  let t = Object.keys(e);
@@ -59,9 +59,9 @@ function k(e) {
59
59
  }
60
60
  return !0;
61
61
  }
62
- function A(e) {
62
+ function j(e) {
63
63
  return {
64
- all: e ||= /* @__PURE__ */ new Map(),
64
+ all: e ||= new Map(),
65
65
  on: function(t, n) {
66
66
  var r = e.get(t);
67
67
  r ? r.push(n) : e.set(t, [n]);
@@ -80,10 +80,7 @@ function A(e) {
80
80
  }
81
81
  };
82
82
  }
83
- /**
84
- * 扩展内容的`Promise`,可视为普通`Promise`使用
85
- */
86
- var j = class t {
83
+ var M = class t {
87
84
  [Symbol.toStringTag] = "PromiseContent";
88
85
  static _this;
89
86
  static {
@@ -95,9 +92,6 @@ var j = class t {
95
92
  static fromPromise(e, t = (e) => e) {
96
93
  return r(new this._this(e, t));
97
94
  }
98
- /**
99
- * 使用`PromiseContent.fromPromise`或`PromiseContent.fromAsyncFunction`代替`new PromiseContent`
100
- */
101
95
  constructor(e, t = (e) => e) {
102
96
  this.promise = e, this.processor = t, this.loadPromise(e);
103
97
  }
@@ -105,13 +99,13 @@ var j = class t {
105
99
  this.data.value = void 0, this.isLoading.value = !0, this.isError.value = !1, this.errorCause.value = void 0, this.isEmpty.value = !0;
106
100
  try {
107
101
  let t = await e;
108
- this.data.value = this.processor(t), this.isLoading.value = !1, this.isError.value = !1, this.isEmpty.value = k(t), this.emitter.emit("success", this.data.value);
102
+ this.data.value = this.processor(t), this.isLoading.value = !1, this.isError.value = !1, this.isEmpty.value = A(t), this.emitter.emit("success", this.data.value);
109
103
  } catch (e) {
110
104
  this.data.value = void 0, this.isError.value = !0, this.errorCause.value = S(e) ? e : Error(String(e)), console.error("Non-throw Error [PromiseContent]", e), this.emitter.emit("error", e);
111
105
  }
112
106
  this.emitter.emit("finial", void 0);
113
107
  }
114
- emitter = A();
108
+ emitter = j();
115
109
  onError(e) {
116
110
  return this.emitter.on("error", e), () => this.emitter.off("error", e);
117
111
  }
@@ -121,9 +115,6 @@ var j = class t {
121
115
  onFinal(e) {
122
116
  return this.emitter.on("finial", e), () => this.emitter.off("finial", e);
123
117
  }
124
- /**
125
- * 对`this.data.value`做出处理,多次调用仅最后一次生效
126
- */
127
118
  setProcessor(e) {
128
119
  return t.fromPromise(this.promise, e);
129
120
  }
@@ -163,7 +154,7 @@ var j = class t {
163
154
  }
164
155
  };
165
156
  }
166
- }, M = class {
157
+ }, N = class {
167
158
  toJSON(e) {
168
159
  return w(e) ? this.parse(e) : e;
169
160
  }
@@ -180,14 +171,14 @@ var j = class t {
180
171
  constructor(e = ":") {
181
172
  this.separator = e;
182
173
  }
183
- }, N = class extends M {
174
+ }, P = class extends N {
184
175
  static create(e = ":") {
185
176
  return o(new this(e));
186
177
  }
187
178
  constructor(e = ":") {
188
179
  super(e);
189
180
  }
190
- store = o(/* @__PURE__ */ new Map());
181
+ store = o(new Map());
191
182
  get size() {
192
183
  return this.store.size;
193
184
  }
@@ -225,9 +216,9 @@ var j = class t {
225
216
  return this.entries();
226
217
  }
227
218
  };
228
- function P(e) {
219
+ function ee(e) {
229
220
  return {
230
- all: e ||= /* @__PURE__ */ new Map(),
221
+ all: e ||= new Map(),
231
222
  on: function(t, n) {
232
223
  var r = e.get(t);
233
224
  r ? r.push(n) : e.set(t, [n]);
@@ -248,7 +239,7 @@ function P(e) {
248
239
  }
249
240
  var F = class {
250
241
  _controller = new AbortController();
251
- mitt = P();
242
+ mitt = ee();
252
243
  get signal() {
253
244
  return this._controller.signal;
254
245
  }
@@ -347,12 +338,9 @@ function L(e, t = !1) {
347
338
  function R(e) {
348
339
  return L(e);
349
340
  }
350
- var z = /* @__PURE__ */ new Map(), B = class {
351
- /**
352
- * 使用`Stream.create`代替`new Stream`
353
- */
341
+ var z = new Map(), B = class {
354
342
  constructor(e) {
355
- this.generator = e(this.abortController.signal, this), z.set(this, e);
343
+ this.generator = e.bind(this)(this.abortController.signal, this), z.set(this, e);
356
344
  }
357
345
  static _this;
358
346
  static {
@@ -367,7 +355,6 @@ var z = /* @__PURE__ */ new Map(), B = class {
367
355
  abortController = new F();
368
356
  generator;
369
357
  _setupData = [];
370
- /** 初始存在的数据(置顶) */
371
358
  setupData(e) {
372
359
  return this._setupData.push(...e), this.data.value.unshift(...e), this;
373
360
  }
@@ -402,87 +389,69 @@ var z = /* @__PURE__ */ new Map(), B = class {
402
389
  done: !0
403
390
  };
404
391
  }
405
- /** 重置 */
392
+ toReadableStream() {
393
+ let e = this;
394
+ return new ReadableStream({ async pull(t) {
395
+ let { value: n, done: r } = await e.next();
396
+ r ? t.close() : t.enqueue(n);
397
+ } });
398
+ }
406
399
  reset() {
407
- this.generator = z.get(this)(this.abortController.signal, this), this.total.value = NaN, this.page.value = 0, this.pageSize.value = NaN, this.data.value = this._setupData, this.isDone.value = !1, this.isRequesting.value = !1, this.error.value = void 0;
400
+ this.generator = z.get(this).bind(this)(this.abortController.signal, this), this.total.value = NaN, this.page.value = 0, this.pageSize.value = NaN, this.data.value = this._setupData, this.isDone.value = !1, this.isRequesting.value = !1, this.error.value = void 0;
408
401
  }
409
- /** 重试 */
410
402
  async retry() {
411
403
  return this.page.value--, this.next();
412
404
  }
413
- /** 一次性全部加载 */
414
405
  async nextToDone() {
415
406
  isNaN(this._pages) && await this.next(!0);
416
407
  let e = [];
417
408
  for (let t = this._page + 1; t <= this._pages; t++) e.push(this.next(!0));
418
409
  return await Promise.all(e), this._data;
419
410
  }
420
- /** 停止正在进行的请求 */
421
411
  stop() {
422
412
  this.abortController.abort(), this.isRequesting.value = !1;
423
413
  }
424
414
  [Symbol.asyncIterator]() {
425
415
  return this;
426
416
  }
427
- /** 错误(如果有) */
428
417
  error = s();
429
- /** 数据 */
430
418
  data = a([]);
431
- /** 数据 */
432
419
  get _data() {
433
420
  return this.data.value;
434
421
  }
435
- /** 当前页 */
436
422
  page = s(0);
437
- /** 当前页 */
438
423
  get _page() {
439
424
  return this.page.value;
440
425
  }
441
- /** 总页数 */
442
426
  pages = s(NaN);
443
- /** 总页数 */
444
427
  get _pages() {
445
428
  return this.pages.value;
446
429
  }
447
- /** 总条目数 */
448
430
  total = s(NaN);
449
- /** 总条目数 */
450
431
  get _total() {
451
432
  return this.total.value;
452
433
  }
453
- /** 单页条目数 */
454
434
  pageSize = s(NaN);
455
- /** 单页条目数 */
456
435
  get _pageSize() {
457
436
  return this.pageSize.value;
458
437
  }
459
- /** 数据当前总数 */
460
438
  length = t(() => this.data.value.length);
461
- /** 数据当前总数 */
462
439
  get _length() {
463
440
  return this.data.value.length;
464
441
  }
465
- /** 是否正在网络请求 */
466
442
  isRequesting = s(!1);
467
- /** 是否正在网络请求 */
468
443
  get _isRequesting() {
469
444
  return this.isRequesting.value;
470
445
  }
471
- /** 是否全部获取完成 */
472
446
  isDone = s(!1);
473
- /** 是否全部获取完成 */
474
447
  get _isDone() {
475
448
  return this.isDone.value;
476
449
  }
477
- /** 是否无结果 */
478
450
  isNoData = t(() => this.isDone.value && this.isEmpty.value);
479
- /** 是否无结果 */
480
451
  get _isNoData() {
481
452
  return this.isNoData.value;
482
453
  }
483
- /** 是否当前为空 */
484
454
  isEmpty = t(() => this.length.value === 0);
485
- /** 是否当前为空 */
486
455
  get _isEmpty() {
487
456
  return this.isEmpty.value;
488
457
  }
@@ -491,23 +460,17 @@ const V = (e) => {
491
460
  let { resolve: t, promise: n } = Promise.withResolvers();
492
461
  return e(t), n;
493
462
  };
494
- /**
495
- * 可以结构化的数据,调用`toJSON`获取纯粹的json(没有get/set或method)
496
- */
497
463
  var H = class e {
498
464
  toJSON() {
499
465
  return JSON.parse(JSON.stringify(this.$$raw));
500
466
  }
501
- /**
502
- * @param $$raw 一个纯粹json对象,不可以是高级对象
503
- */
504
467
  constructor(e) {
505
468
  this.$$raw = e;
506
469
  }
507
470
  static toRaw(t) {
508
471
  return t instanceof e ? t.toJSON() : t;
509
472
  }
510
- }, U = /* @__PURE__ */ g(((e, t) => {
473
+ }, U = g(((e, t) => {
511
474
  (function(n, r) {
512
475
  typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self).dayjs = r();
513
476
  })(e, (function() {
@@ -596,8 +559,8 @@ var H = class e {
596
559
  return _.parse = function(e) {
597
560
  this.$d = function(e) {
598
561
  var t = e.date, n = e.utc;
599
- if (t === null) return /* @__PURE__ */ new Date(NaN);
600
- if (T.u(t)) return /* @__PURE__ */ new Date();
562
+ if (t === null) return new Date(NaN);
563
+ if (T.u(t)) return new Date();
601
564
  if (t instanceof Date) return new Date(t);
602
565
  if (typeof t == "string" && !/Z$/i.test(t)) {
603
566
  var r = t.match(m);
@@ -801,8 +764,8 @@ var H = class e {
801
764
  return w(1e3 * e);
802
765
  }, w.en = b[y], w.Ls = b, w.p = {}, w;
803
766
  }));
804
- })), W = /* @__PURE__ */ _({ Comment: () => K }), G = /* @__PURE__ */ y(U(), 1), K = class extends H {
805
- static commentRow = N.create();
767
+ })), W = _({ Comment: () => K }), G = y(U(), 1), K = class extends H {
768
+ static commentRow = P.create();
806
769
  constructor(e) {
807
770
  super(e), this.content = e.content, this.time = e.time, this.id = e.id, this.childrenCount = e.childrenCount, this.likeCount = e.likeCount, this.isLiked = e.isLiked, this.reported = e.reported, this.$$plugin = e.$$plugin, this.$$meta = e.$$meta, this.isTop = e.isTop;
808
771
  }
@@ -819,7 +782,7 @@ var H = class e {
819
782
  reported;
820
783
  $$plugin;
821
784
  $$meta;
822
- }, q = /* @__PURE__ */ _({ Ep: () => J }), J = class extends H {
785
+ }, q = _({ Ep: () => J }), J = class extends H {
823
786
  name;
824
787
  index;
825
788
  $$plugin;
@@ -827,10 +790,10 @@ var H = class e {
827
790
  constructor(e) {
828
791
  super(e), this.name = e.name, this.index = e.index, this.$$plugin = e.$$plugin, this.$$meta = e.$$meta;
829
792
  }
830
- }, Y = /* @__PURE__ */ _({ Resource: () => X }), X = class t extends H {
831
- static processInstances = e(N.create(), "uni/resource/processInstances");
832
- static fork = e(N.create(), "uni/resource/fork");
833
- static precedenceFork = e(N.create(), "uni/resource/precedenceFork");
793
+ }, Y = _({ Resource: () => X }), X = class t extends H {
794
+ static processInstances = e(P.create(), "uni/resource/processInstances");
795
+ static fork = e(P.create(), "uni/resource/fork");
796
+ static precedenceFork = e(P.create(), "uni/resource/precedenceFork");
834
797
  static is(e) {
835
798
  return e instanceof this;
836
799
  }
@@ -861,21 +824,19 @@ var H = class e {
861
824
  }
862
825
  return URL.canParse(e) ? e : `${this.getThisFork()}/${e}`;
863
826
  }
864
- omittedForks = o(/* @__PURE__ */ new Set());
827
+ omittedForks = o(new Set());
865
828
  getThisFork() {
866
- let e = new Set(t.fork.get([this.$$plugin, this.type])?.urls ?? []);
867
- if (this.omittedForks.size == 0) var n = t.precedenceFork.get([this.$$plugin, this.type]);
868
- else var n = Array.from(e.difference(this.omittedForks).values())[0];
869
- if (!n) throw Error(`[Resource.getThisFork] fork not found, type: [${this.$$plugin}, ${this.type}]`);
829
+ let e = new Set(t.fork.get([this.$$plugin, this.type])?.urls ?? []), n;
830
+ if (n = A(this.omittedForks) ? t.precedenceFork.get([this.$$plugin, this.type]) : Array.from(e.difference(this.omittedForks).values())[0], !n) throw Error(`[Resource.getThisFork] fork not found, type: [${this.$$plugin}, ${this.type}]`);
870
831
  return n;
871
832
  }
872
833
  localChangeFork() {
873
834
  let e = new Set(t.fork.get([this.$$plugin, this.type])?.urls ?? []);
874
835
  this.omittedForks.add(this.getThisFork());
875
- let n = e.difference(this.omittedForks).size != 0;
836
+ let n = A(e.difference(this.omittedForks));
876
837
  return n && this.omittedForks.clear(), n;
877
838
  }
878
- }, Z = /* @__PURE__ */ _({ Image: () => Q }), Q = class extends X {
839
+ }, Z = _({ Image: () => Q }), Q = class extends X {
879
840
  static is(e) {
880
841
  return e instanceof this;
881
842
  }
@@ -900,15 +861,15 @@ var H = class e {
900
861
  set aspect(e) {
901
862
  this.$$meta ??= {}, this.$$meta.width = e.width, this.$$meta.height = e.height;
902
863
  }
903
- }, te = /* @__PURE__ */ _({ Item: () => ne }), ne = class extends H {
904
- static itemTranslator = N.create();
864
+ }, te = _({ Item: () => ne }), ne = class extends H {
865
+ static itemTranslator = P.create();
905
866
  static create(e) {
906
867
  let t = this.itemTranslator.get(e.contentType);
907
868
  if (!t) throw Error(`can not found itemTranslator contentType:"${$.contentPage.toString(e.contentType)}"`);
908
869
  return t(e);
909
870
  }
910
- static authorIcon = N.create();
911
- static itemCard = e(N.create(), "uni/item/itemCard");
871
+ static authorIcon = P.create();
872
+ static itemCard = e(P.create(), "uni/item/itemCard");
912
873
  static is(e) {
913
874
  return e instanceof this;
914
875
  }
@@ -948,21 +909,21 @@ var H = class e {
948
909
  let e = (e) => /(^|[\((\[\s【])ai[】\))\]\s]?/gi.test(e);
949
910
  return this.customIsAI || e(this.title) || this.author.some((t) => e(`${t.label}\u1145${t.description}`));
950
911
  }
951
- }, re = /* @__PURE__ */ _({ ContentPage: () => $ }), $ = class {
952
- static viewLayout = e(N.create(), "uni/contentPage/viewLayout");
953
- static contentPage = e(N.create(), "uni/contentPage/contentPage");
912
+ }, re = _({ ContentPage: () => $ }), $ = class {
913
+ static viewLayout = e(P.create(), "uni/contentPage/viewLayout");
914
+ static contentPage = e(P.create(), "uni/contentPage/contentPage");
954
915
  constructor(e, t, n) {
955
916
  this.id = t, this.ep = n, this.preload.value = e;
956
917
  }
957
- pid = j.withResolvers();
918
+ pid = M.withResolvers();
958
919
  preload = s(void 0);
959
- detail = j.withResolvers();
920
+ detail = M.withResolvers();
960
921
  union = t(() => this.detail.content.data.value ?? this.preload.value);
961
- recommends = j.withResolvers();
962
- eps = j.withResolvers();
963
- }, ie = /* @__PURE__ */ _({ Downloader: () => ae }), ae = class {}, oe = /* @__PURE__ */ _({ User: () => se }), se = class {
964
- static userBase = o(/* @__PURE__ */ new Map());
965
- static userEditorBase = o(/* @__PURE__ */ new Map());
922
+ recommends = M.withResolvers();
923
+ eps = M.withResolvers();
924
+ }, ie = _({ Downloader: () => ae }), ae = class {}, oe = _({ User: () => se }), se = class {
925
+ static userBase = o(new Map());
926
+ static userEditorBase = o(new Map());
966
927
  constructor(e) {
967
928
  e.avatar && (this.avatar = Q.create(e.avatar)), this.name = e.name, this.id = e.id, this.$$plugin = e.$$plugin;
968
929
  }
@@ -970,7 +931,7 @@ var H = class e {
970
931
  name;
971
932
  id;
972
933
  $$plugin;
973
- }, ce = /* @__PURE__ */ _({
934
+ }, ce = _({
974
935
  comment: () => W,
975
936
  content: () => re,
976
937
  download: () => ie,
@@ -980,6 +941,6 @@ var H = class e {
980
941
  resource: () => Y,
981
942
  user: () => oe
982
943
  });
983
- export { j as PromiseContent, N as SourcedKeyMap, M as SourcedValue, B as Stream, H as Struct, V as callbackToPromise, ce as uni };
944
+ export { M as PromiseContent, P as SourcedKeyMap, N as SourcedValue, B as Stream, H as Struct, V as callbackToPromise, ce as uni };
984
945
 
985
946
  //# sourceMappingURL=index.js.map