@delta-comic/plugin 0.2.1 → 0.2.3

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
@@ -876,23 +876,21 @@ var test = async (e, t) => {
876
876
  let r = n.$getPluginDisplayName(e.name);
877
877
  t("判定鉴权状态中...");
878
878
  let i = await e.auth.passSelect(), a = Promise.withResolvers();
879
- if (console.log(`[plugin auth] ${r}, isPass: ${i}`), await authPopupMutex.acquire(), t("等待其他插件鉴权结束..."), i) t("跳过鉴权方式选择"), a.resolve(i);
880
- else {
881
- t("选择鉴权方式");
882
- try {
883
- createDialog({
884
- type: "default",
885
- positiveText: "登录",
886
- negativeText: "注册",
887
- closable: !1,
888
- maskClosable: !1,
889
- content: "选择鉴权方式",
890
- title: r
891
- }), a.resolve("logIn");
892
- } catch {
879
+ console.log(`[plugin auth] ${r}, isPass: ${i}`), await authPopupMutex.acquire(), t("等待其他插件鉴权结束..."), i ? (t("跳过鉴权方式选择"), a.resolve(i)) : (t("选择鉴权方式"), createDialog({
880
+ type: "default",
881
+ positiveText: "登录",
882
+ negativeText: "注册",
883
+ closable: !1,
884
+ maskClosable: !1,
885
+ content: "选择鉴权方式",
886
+ title: r,
887
+ onNegativeClick() {
893
888
  a.resolve("signUp");
889
+ },
890
+ onPositiveClick() {
891
+ a.resolve("logIn");
894
892
  }
895
- }
893
+ }));
896
894
  let o = await a.promise;
897
895
  t("鉴权中...");
898
896
  let s = {
@@ -1048,6 +1046,14 @@ async function readFile(e, t) {
1048
1046
  });
1049
1047
  return n instanceof ArrayBuffer ? new Uint8Array(n) : Uint8Array.from(n);
1050
1048
  }
1049
+ async function readTextFile(e, t) {
1050
+ if (e instanceof URL && e.protocol !== "file:") throw TypeError("Must be a file URL.");
1051
+ let n = await invoke("plugin:fs|read_text_file", {
1052
+ path: e instanceof URL ? e.toString() : e,
1053
+ options: t
1054
+ }), r = n instanceof ArrayBuffer ? n : Uint8Array.from(n);
1055
+ return new TextDecoder().decode(r);
1056
+ }
1051
1057
  async function remove(e, t) {
1052
1058
  if (e instanceof URL && e.protocol !== "file:") throw TypeError("Must be a file URL.");
1053
1059
  await invoke("plugin:fs|remove", {
@@ -3128,22 +3134,12 @@ var Octokit = Octokit$1.plugin(requestLog, legacyRestEndpointMethods, paginateRe
3128
3134
  return e.name.endsWith(".js");
3129
3135
  }
3130
3136
  async load(e) {
3131
- let t = await readFile(await join(await getPluginFsPath(e.pluginName), "us.js"));
3132
- if (t.includes(0)) {
3133
- let e = new Uint8Array(t.length), r = 0;
3134
- for (let n = 0; n < t.length; n++) {
3135
- let i = t[n];
3136
- i !== 0 && (e[r++] = i);
3137
- }
3138
- let i = e.subarray(0, r);
3139
- var n = new Blob([i], { type: "text/javascript" });
3140
- } else var n = new Blob([t], { type: "text/javascript" });
3141
- let r = URL.createObjectURL(n), i = document.createElement("script");
3142
- i.addEventListener("load", () => {
3143
- URL.revokeObjectURL(r);
3144
- }), i.addEventListener("error", (e) => {
3145
- throw URL.revokeObjectURL(r), e;
3146
- }), i.async = !0, i.src = r, document.body.appendChild(i);
3137
+ let t = await readTextFile(await join(await getPluginFsPath(e.pluginName), "us.js")), n = t.lastIndexOf(";") + 1, r = new Blob([t.slice(0, n)], { type: "text/javascript" }), i = URL.createObjectURL(r), a = document.createElement("script");
3138
+ a.addEventListener("load", () => {
3139
+ URL.revokeObjectURL(i);
3140
+ }), a.addEventListener("error", (e) => {
3141
+ throw URL.revokeObjectURL(i), e;
3142
+ }), a.async = !0, a.src = i, document.body.appendChild(a);
3147
3143
  }
3148
3144
  }(), import_jszip_min = (/* @__PURE__ */ __commonJSMin(((e, t) => {
3149
3145
  (function(n) {