@delta-comic/plugin 0.2.4 → 0.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/index.js CHANGED
@@ -3534,7 +3534,26 @@ var Tr = lr.plugin(dr, wr, _r).defaults({ userAgent: "octokit-rest.js/22.0.1" })
3534
3534
  isMatched(e) {
3535
3535
  return e.startsWith("gh:") && e.split("/").length === 2;
3536
3536
  }
3537
- }(), Dr = (/* @__PURE__ */ G(((e) => {
3537
+ }(), Dr = "https://raw.githubusercontent.com/delta-comic/awesome-plugins/refs/heads/main/pages", Or = new class extends bt {
3538
+ description = {
3539
+ title: "快速安装插件",
3540
+ description: "输入形如: \"ap:jmcomic\"的内容"
3541
+ };
3542
+ name = "awesome";
3543
+ async installer(e) {
3544
+ let t = e.replace(/^ap:/, ""), { data: n } = await W.get(`${Dr}/${t}.json`, { responseType: "json" });
3545
+ return n.download;
3546
+ }
3547
+ async install(e) {
3548
+ return await this.installer(e);
3549
+ }
3550
+ async update(e) {
3551
+ return await this.installer(e.installInput);
3552
+ }
3553
+ isMatched(e) {
3554
+ return /^ap:[A-Za-z0-9\-\_]+$/.test(e);
3555
+ }
3556
+ }(), kr = (/* @__PURE__ */ G(((e) => {
3538
3557
  function t(e) {
3539
3558
  return e === void 0;
3540
3559
  }
@@ -3548,10 +3567,10 @@ var Tr = lr.plugin(dr, wr, _r).defaults({ userAgent: "octokit-rest.js/22.0.1" })
3548
3567
  }, {});
3549
3568
  }
3550
3569
  e.parse = n;
3551
- })))(), Or = new class extends xt {
3570
+ })))(), Ar = new class extends xt {
3552
3571
  name = "userscript";
3553
3572
  async installDownload(e) {
3554
- let t = await e.text(), n = Pe((0, Dr.parse)(t)), r = await yt(n.name.id);
3573
+ let t = await e.text(), n = Pe((0, kr.parse)(t)), r = await yt(n.name.id);
3555
3574
  return await Rt(r, { recursive: !0 }), await Wt(await Z(r, "us.js"), t, { create: !0 }), n;
3556
3575
  }
3557
3576
  canInstall(e) {
@@ -3565,7 +3584,7 @@ var Tr = lr.plugin(dr, wr, _r).defaults({ userAgent: "octokit-rest.js/22.0.1" })
3565
3584
  throw URL.revokeObjectURL(i), e;
3566
3585
  }), a.async = !0, a.src = i, document.body.appendChild(a);
3567
3586
  }
3568
- }(), kr = (/* @__PURE__ */ G(((e, t) => {
3587
+ }(), jr = (/* @__PURE__ */ G(((e, t) => {
3569
3588
  (function(n) {
3570
3589
  typeof e == "object" && t !== void 0 ? t.exports = n() : typeof define == "function" && define.amd ? define([], n) : (typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : this).JSZip = n();
3571
3590
  })(function() {
@@ -6593,13 +6612,13 @@ while (r === s[++i] && r === s[++i] && r === s[++i] && r === s[++i] && r === s[+
6593
6612
  }, {}]
6594
6613
  }, {}, [10])(10);
6595
6614
  });
6596
- })))(), Ar = new class extends xt {
6615
+ })))(), Mr = new class extends xt {
6597
6616
  name = "zip";
6598
6617
  async installDownload(e) {
6599
6618
  console.log("[loader zip] begin:", e);
6600
6619
  let t = await yt("__temp__");
6601
6620
  await Rt(t, { recursive: !0 }), await Ut(await Z(t, "temp.zip"), new Uint8Array(await e.arrayBuffer())), console.log("[loader zip] temp:", t);
6602
- let n = await (0, kr.loadAsync)(e);
6621
+ let n = await (0, jr.loadAsync)(e);
6603
6622
  console.log(n.files);
6604
6623
  let r = JSON.parse(await n.file("manifest.json")?.async("string") ?? "{}"), i = await yt(r.name.id);
6605
6624
  try {
@@ -6641,15 +6660,15 @@ while (r === s[++i] && r === s[++i] && r === s[++i] && r === s[++i] && r === s[+
6641
6660
  throw e;
6642
6661
  }), a.rel = "stylesheet", a.href = decodeURIComponent(mt(await Z(t, i), "local")), document.head.appendChild(a);
6643
6662
  }
6644
- }(), jr = /* @__PURE__ */ Object.assign({
6663
+ }(), Nr = /* @__PURE__ */ Object.assign({
6645
6664
  "./booter/0_configSetter.ts": St,
6646
6665
  "./booter/10_apiTest.ts": Et,
6647
6666
  "./booter/20_resourceTest.ts": Dt,
6648
6667
  "./booter/30_boot.ts": Ot,
6649
6668
  "./booter/40_auth.ts": At,
6650
6669
  "./booter/50_otherProcess.ts": jt
6651
- }), Mr = Te(Object.entries(jr), ([e]) => Number(e.match(/[\d\.]+(?=_)/)?.[0])).map((e) => e[1]);
6652
- const Nr = async (e) => {
6670
+ }), Pr = Te(Object.entries(Nr), ([e]) => Number(e.match(/[\d\.]+(?=_)/)?.[0])).map((e) => e[1]);
6671
+ const Fr = async (e) => {
6653
6672
  let { plugins: t, pluginSteps: n } = lt();
6654
6673
  t.set(e.name, y(e)), n[e.name] = {
6655
6674
  steps: [],
@@ -6660,7 +6679,7 @@ const Nr = async (e) => {
6660
6679
  };
6661
6680
  try {
6662
6681
  let t = {};
6663
- for (let r of Mr) {
6682
+ for (let r of Pr) {
6664
6683
  let i = n[e.name].steps.length;
6665
6684
  n[e.name].steps[i] = {
6666
6685
  name: r.name,
@@ -6675,26 +6694,33 @@ const Nr = async (e) => {
6675
6694
  }
6676
6695
  console.log(`[plugin usePluginStore.$loadPlugin] plugin "${e.name}" load done`);
6677
6696
  };
6678
- var Pr = /* @__PURE__ */ Object.assign({
6697
+ var Ir = /* @__PURE__ */ Object.assign({
6679
6698
  "./installer/10_normalUrl.ts": Mt,
6680
6699
  "./installer/20_local.ts": Gt,
6681
6700
  "./installer/30_dev.ts": Kt,
6682
- "./installer/40_github.ts": Er
6683
- }), Fr = Te(Object.entries(Pr), ([e]) => Number(e.match(/[\d\.]+(?=_)/)?.[0])).map((e) => e[1]).reverse();
6684
- const Ir = () => i(Y, "pluginInstallSourceOverrides", []), Lr = (e, t, n) => e.createLoading("依赖安装/检查", async (e) => {
6701
+ "./installer/40_github.ts": Er,
6702
+ "./installer/9999_awesome.ts": Or
6703
+ }), Lr = Te(Object.entries(Ir), ([e]) => Number(e.match(/[\d\.]+(?=_)/)?.[0])).map((e) => e[1]).reverse();
6704
+ const Rr = () => i(Y, "pluginInstallSourceOverrides", []), zr = (e, t, n) => e.createLoading("依赖安装/检查", async (e) => {
6685
6705
  e.retryable = !0;
6686
- let i = 0, a = n ?? new Set((await r.value.selectFrom("plugin").select("pluginName").execute()).map((e) => e.pluginName)), o = Ir();
6687
- for (let { id: n, download: r } of t.require) a.has(n) || !r || (console.log(`从 ${t.name.id} 发现未安装依赖: ${n} ->`, r), e.description = `安装: ${n}`, await Rr(o.value.find((e) => e.id == n && e.enabled)?.install ?? r), i++);
6706
+ let i = 0, a = n ?? new Set((await r.value.selectFrom("plugin").select("pluginName").execute()).map((e) => e.pluginName)), o = Rr();
6707
+ for (let { id: n, download: r } of t.require) a.has(n) || !r || (console.log(`从 ${t.name.id} 发现未安装依赖: ${n} ->`, r), e.description = `安装: ${n}`, await Br(o.value.find((e) => e.id == n && e.enabled)?.install ?? r), i++);
6688
6708
  e.description = `安装完成,共${i}个`;
6689
- }), Rr = (e, t) => H(`下载插件-${e}`, async (n) => {
6709
+ }), Br = (e, t) => H(`下载插件-${e}`, async (n) => {
6690
6710
  let [i, a] = await n.createLoading("下载", async (t) => {
6691
6711
  t.retryable = !0;
6692
- let n = Fr.filter((t) => t.isMatched(e)).at(0);
6712
+ let n = Lr.filter((t) => t.isMatched(e)).at(0);
6693
6713
  if (!n) throw Error("没有符合的下载器:" + e);
6694
- return t.description = n.name, [await n.install(e), n];
6714
+ t.description = n.name;
6715
+ let r = e;
6716
+ for (;;) {
6717
+ let e = await n.install(r);
6718
+ if (oe(e)) r = e;
6719
+ else return [e, n];
6720
+ }
6695
6721
  }), o = await n.createLoading("安装插件", async (t) => {
6696
6722
  t.retryable = !0;
6697
- let n = Hr.filter((e) => e.canInstall(i)).at(-1);
6723
+ let n = Wr.filter((e) => e.canInstall(i)).at(-1);
6698
6724
  if (!n) throw Error("没有符合的安装器:" + e);
6699
6725
  t.description = n.name;
6700
6726
  let o = await n.installDownload(i);
@@ -6708,11 +6734,11 @@ const Ir = () => i(Y, "pluginInstallSourceOverrides", []), Lr = (e, t, n) => e.c
6708
6734
  pluginName: o.name.id
6709
6735
  }).execute(), o;
6710
6736
  });
6711
- console.log(`安装插件成功: ${o.name.id} ->`, o), await Lr(n, o, t);
6712
- }), zr = (e, t) => H(`安装插件-${e.name}`, async (n) => {
6737
+ console.log(`安装插件成功: ${o.name.id} ->`, o), await zr(n, o, t);
6738
+ }), Vr = (e, t) => H(`安装插件-${e.name}`, async (n) => {
6713
6739
  let i = await n.createLoading("安装插件", async (t) => {
6714
6740
  t.retryable = !0;
6715
- let n = Hr.filter((t) => t.canInstall(e)).at(-1);
6741
+ let n = Wr.filter((t) => t.canInstall(e)).at(-1);
6716
6742
  if (!n) throw Error("没有符合的安装器");
6717
6743
  t.description = n.name;
6718
6744
  let i = await n.installDownload(e);
@@ -6726,31 +6752,37 @@ const Ir = () => i(Y, "pluginInstallSourceOverrides", []), Lr = (e, t, n) => e.c
6726
6752
  pluginName: i.name.id
6727
6753
  }).execute(), i;
6728
6754
  });
6729
- console.log(`安装插件成功: ${i.name.id} ->`, i), await Lr(n, i, t);
6730
- }), Br = async (e, t) => H(`更新插件-${e.pluginName}`, async (n) => {
6755
+ console.log(`安装插件成功: ${i.name.id} ->`, i), await zr(n, i, t);
6756
+ }), Hr = async (e, t) => H(`更新插件-${e.pluginName}`, async (n) => {
6731
6757
  let i = await n.createLoading("更新", async (t) => {
6732
6758
  t.retryable = !0;
6733
- let n = Fr.find((t) => t.name == e.installerName);
6734
- if (!n) throw Error("没有符合的下载器");
6735
- return t.description = n.name, await n.update(e);
6759
+ let n = e.installerName;
6760
+ for (;;) {
6761
+ let r = Lr.find((e) => e.name == n);
6762
+ if (!r) throw Error("没有符合的下载器");
6763
+ t.description = r.name;
6764
+ let i = await r.update(e);
6765
+ if (oe(i)) n = i;
6766
+ else return i;
6767
+ }
6736
6768
  }), a = await n.createLoading("安装插件", async (t) => {
6737
6769
  t.retryable = !0;
6738
- let n = Hr.find((t) => t.name == e.loaderName);
6770
+ let n = Wr.find((t) => t.name == e.loaderName);
6739
6771
  if (!n) throw Error("没有符合的安装器");
6740
6772
  return await n.installDownload(i);
6741
6773
  });
6742
6774
  await r.value.replaceInto("plugin").values({
6743
6775
  ...e,
6744
6776
  meta: JSON.stringify(a)
6745
- }).execute(), await Lr(n, a, t);
6777
+ }).execute(), await zr(n, a, t);
6746
6778
  });
6747
- var Vr = /* @__PURE__ */ Object.assign({
6748
- "./loader/1_userscript.ts": Or,
6749
- "./loader/2_zip.ts": Ar
6750
- }), Hr = Te(Object.entries(Vr), ([e]) => Number(e.match(/[\d\.]+(?=_)/)?.[0])).map((e) => e[1]), Ur = {}, Wr = (e) => Ur[e] ??= new le();
6751
- const Gr = async (e) => {
6779
+ var Ur = /* @__PURE__ */ Object.assign({
6780
+ "./loader/1_userscript.ts": Ar,
6781
+ "./loader/2_zip.ts": Mr
6782
+ }), Wr = Te(Object.entries(Ur), ([e]) => Number(e.match(/[\d\.]+(?=_)/)?.[0])).map((e) => e[1]), Gr = {}, Kr = (e) => Gr[e] ??= new le();
6783
+ const qr = async (e) => {
6752
6784
  console.log(`[plugin bootPlugin] booting name "${e.pluginName}"`);
6753
- let t = Wr(e.pluginName), n = lt();
6785
+ let t = Kr(e.pluginName), n = lt();
6754
6786
  n.pluginSteps[e.pluginName] = {
6755
6787
  now: {
6756
6788
  status: "wait",
@@ -6762,7 +6794,7 @@ const Gr = async (e) => {
6762
6794
  }]
6763
6795
  };
6764
6796
  try {
6765
- await t.acquire(), await Hr.find((t) => t.name == e.loaderName).load(e), await t.acquire();
6797
+ await t.acquire(), await Wr.find((t) => t.name == e.loaderName).load(e), await t.acquire();
6766
6798
  } catch (t) {
6767
6799
  throw n.pluginSteps[e.pluginName].now.status = "error", n.pluginSteps[e.pluginName].now.error = t, t;
6768
6800
  }
@@ -6770,10 +6802,10 @@ const Gr = async (e) => {
6770
6802
  };
6771
6803
  Me.on("definedPlugin", async (e) => {
6772
6804
  console.log("[plugin addPlugin] new plugin defined", e.name, e);
6773
- let t = Wr(e.name);
6774
- await Nr(e), console.log("[plugin addPlugin] done", e.name), t.release();
6775
- }), window.$api.loaders = Hr, window.$api.installers = Fr;
6776
- const Kr = F.fromAsyncFunction(async () => {
6805
+ let t = Kr(e.name);
6806
+ await Fr(e), console.log("[plugin addPlugin] done", e.name), t.release();
6807
+ }), window.$api.loaders = Wr, window.$api.installers = Lr;
6808
+ const Jr = F.fromAsyncFunction(async () => {
6777
6809
  await ut();
6778
6810
  let e = new Set([Y]), n = await t.getByEnabled(!0), r = [];
6779
6811
  for (;;) {
@@ -6783,10 +6815,10 @@ const Kr = F.fromAsyncFunction(async () => {
6783
6815
  if (Ae(t)) break;
6784
6816
  }
6785
6817
  if (!Ae(n)) throw Error(`插件循环引用: ${n.map((e) => e.pluginName).join(", ")}`);
6786
- for (let e of r) await Promise.all(e.map((e) => Gr(e)));
6818
+ for (let e of r) await Promise.all(e.map((e) => qr(e)));
6787
6819
  console.log("[plugin bootPlugin] all load done");
6788
6820
  });
6789
- var qr = /* @__PURE__ */ f({
6821
+ var Yr = /* @__PURE__ */ f({
6790
6822
  __name: "Inject",
6791
6823
  props: {
6792
6824
  key: {},
@@ -6812,13 +6844,13 @@ var qr = /* @__PURE__ */ f({
6812
6844
  }, 1032, ["promise"]))), 256));
6813
6845
  }
6814
6846
  });
6815
- const Jr = (e, t, n) => {
6847
+ const Xr = (e, t, n) => {
6816
6848
  J.envExtends.add({
6817
6849
  key: e,
6818
6850
  component: t,
6819
6851
  condition: n ?? (() => !0)
6820
6852
  });
6821
6853
  };
6822
- export { et as ConfigPointer, J as Global, qr as Inject, Jr as addInjection, tt as appConfig, Nr as bootPlugin, rt as declareDepType, Pe as decodePluginMeta, Ne as definePlugin, Lr as installDepends, zr as installFilePlugin, Rr as installPlugin, Kr as loadAllPlugins, Gr as loadPlugin, Me as pluginEmitter, at as pluginExposes, Fr as pluginInstallers, Hr as pluginLoaders, it as require, Br as updatePlugin, nt as useConfig, Ir as usePluginConfig, lt as usePluginStore };
6854
+ export { et as ConfigPointer, J as Global, Yr as Inject, Xr as addInjection, tt as appConfig, Fr as bootPlugin, rt as declareDepType, Pe as decodePluginMeta, Ne as definePlugin, zr as installDepends, Vr as installFilePlugin, Br as installPlugin, Jr as loadAllPlugins, qr as loadPlugin, Me as pluginEmitter, at as pluginExposes, Lr as pluginInstallers, Wr as pluginLoaders, it as require, Hr as updatePlugin, nt as useConfig, Rr as usePluginConfig, lt as usePluginStore };
6823
6855
 
6824
6856
  //# sourceMappingURL=index.js.map