@delta-comic/plugin 0.1.0 → 0.2.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
@@ -1,10 +1,10 @@
1
1
  import { DBUtils, PluginArchiveDB, SubscribeDB, db, useNativeStore } from "@delta-comic/db";
2
2
  import { useGlobalVar } from "@delta-comic/utils";
3
- import { Fragment, computed, createBlock, createElementBlock, createVNode, defineComponent, getCurrentInstance, getCurrentScope, h, hasInjectionContext, inject, isRef, markRaw, mergeProps, onMounted, openBlock, reactive, ref, renderList, resolveDynamicComponent, shallowReactive, shallowRef, toValue, unref, watch, watchEffect } from "vue";
3
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createVNode, defineComponent, getCurrentInstance, getCurrentScope, h, hasInjectionContext, inject, isRef, markRaw, mergeProps, onMounted, openBlock, reactive, ref, renderList, resolveDynamicComponent, shallowReactive, shallowRef, toValue, unref, watch, watchEffect, withCtx } from "vue";
4
4
  import { defineStore } from "pinia";
5
5
  import { PromiseContent, SourcedKeyMap, uni } from "@delta-comic/model";
6
6
  import { SharedFunction } from "@delta-comic/core";
7
- import { DcPopup, createDialog, createDownloadMessage, createForm } from "@delta-comic/ui";
7
+ import { DcAwait, DcPopup, createDialog, createDownloadMessage, createForm } from "@delta-comic/ui";
8
8
  import axios from "axios";
9
9
  var __commonJSMin = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), __require = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
10
10
  if (typeof require < "u") return require.apply(this, arguments);
@@ -3128,12 +3128,22 @@ var Octokit = Octokit$1.plugin(requestLog, legacyRestEndpointMethods, paginateRe
3128
3128
  return e.name.endsWith(".js");
3129
3129
  }
3130
3130
  async load(e) {
3131
- let t = await readFile(await join(await getPluginFsPath(e.pluginName), "us.js")), n = document.createElement("script");
3132
- n.addEventListener("error", (e) => {
3133
- throw e;
3134
- });
3135
- let r = URL.createObjectURL(new Blob([t]));
3136
- n.async = !0, n.src = r, document.body.appendChild(n);
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
3147
  }
3138
3148
  }(), import_jszip_min = (/* @__PURE__ */ __commonJSMin(((e, t) => {
3139
3149
  (function(n) {
@@ -6364,13 +6374,29 @@ var Inject_default = /* @__PURE__ */ defineComponent({
6364
6374
  },
6365
6375
  setup(e) {
6366
6376
  let t = e, n = computed(() => Array.from(Global.envExtends.values()).filter((e) => e.key == t.key));
6367
- return (t, r) => (openBlock(!0), createElementBlock(Fragment, null, renderList(n.value, (t) => (openBlock(), createBlock(resolveDynamicComponent(t.component), mergeProps({ ref_for: !0 }, e.args), null, 16))), 256));
6377
+ return (t, r) => (openBlock(!0), createElementBlock(Fragment, null, renderList(n.value, (t) => (openBlock(), createBlock(unref(DcAwait), {
6378
+ promise: async () => {
6379
+ try {
6380
+ return await t.condition(e.args);
6381
+ } catch (e) {
6382
+ return console.warn(e), !1;
6383
+ }
6384
+ },
6385
+ "auto-load": ""
6386
+ }, {
6387
+ default: withCtx(({ result: n }) => [n ? (openBlock(), createBlock(resolveDynamicComponent(t.component), mergeProps({
6388
+ key: 0,
6389
+ ref_for: !0
6390
+ }, e.args), null, 16)) : createCommentVNode("", !0)]),
6391
+ _: 2
6392
+ }, 1032, ["promise"]))), 256));
6368
6393
  }
6369
6394
  });
6370
- const addInjection = (e, t) => {
6395
+ const addInjection = (e, t, n) => {
6371
6396
  Global.envExtends.add({
6372
6397
  key: e,
6373
- component: markRaw(t)
6398
+ component: t,
6399
+ condition: n ?? (() => !0)
6374
6400
  });
6375
6401
  };
6376
6402
  export { ConfigPointer, Global, Inject_default as Inject, addInjection, appConfig, bootPlugin, declareDepType, decodePluginMeta, definePlugin, installDepends, installFilePlugin, installPlugin, loadAllPlugins, loadPlugin, pluginEmitter, pluginExposes, installers as pluginInstallers, loaders as pluginLoaders, require$1 as require, updatePlugin, useConfig, usePluginConfig, usePluginStore };