@delta-comic/plugin 0.0.4 → 0.2.0

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 { computed, createVNode, defineComponent, getCurrentInstance, getCurrentScope, h, hasInjectionContext, inject, isRef, markRaw, onMounted, reactive, ref, 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);
@@ -275,25 +275,25 @@ function watchImmediate(e, t, n) {
275
275
  function computedAsync(e, t, n) {
276
276
  let r;
277
277
  r = isRef(n) ? { evaluating: n } : n || {};
278
- let { lazy: i = !1, flush: a = "sync", evaluating: s = void 0, shallow: c = !0, onError: l = globalThis.reportError ?? noop$2 } = r, u = shallowRef(!i), d = c ? shallowRef(t) : ref(t), f = 0;
278
+ let { lazy: i = !1, flush: a = "sync", evaluating: o = void 0, shallow: c = !0, onError: l = globalThis.reportError ?? noop$2 } = r, u = shallowRef(!i), d = c ? shallowRef(t) : ref(t), f = 0;
279
279
  return watchEffect(async (t) => {
280
280
  if (!u.value) return;
281
281
  f++;
282
282
  let n = f, r = !1;
283
- s && Promise.resolve().then(() => {
284
- s.value = !0;
283
+ o && Promise.resolve().then(() => {
284
+ o.value = !0;
285
285
  });
286
286
  try {
287
287
  let i = await e((e) => {
288
288
  t(() => {
289
- s && (s.value = !1), r || e();
289
+ o && (o.value = !1), r || e();
290
290
  });
291
291
  });
292
292
  n === f && (d.value = i);
293
293
  } catch (e) {
294
294
  l(e);
295
295
  } finally {
296
- s && n === f && (s.value = !1), r = !0;
296
+ o && n === f && (o.value = !1), r = !0;
297
297
  }
298
298
  }, { flush: a }), i ? computed(() => (u.value = !0, d.value)) : d;
299
299
  }
@@ -339,7 +339,7 @@ function useSSRWidth() {
339
339
  return typeof e == "number" ? e : void 0;
340
340
  }
341
341
  function useMediaQuery(e, t = {}) {
342
- let { window: n = defaultWindow, ssrWidth: r = /* @__PURE__ */ useSSRWidth() } = t, i = /* @__PURE__ */ useSupported(() => n && "matchMedia" in n && typeof n.matchMedia == "function"), a = shallowRef(typeof r == "number"), s = shallowRef(), c = shallowRef(!1);
342
+ let { window: n = defaultWindow, ssrWidth: r = /* @__PURE__ */ useSSRWidth() } = t, i = /* @__PURE__ */ useSupported(() => n && "matchMedia" in n && typeof n.matchMedia == "function"), a = shallowRef(typeof r == "number"), o = shallowRef(), c = shallowRef(!1);
343
343
  return watchEffect(() => {
344
344
  if (a.value) {
345
345
  a.value = !i.value, c.value = toValue(e).split(",").some((e) => {
@@ -348,8 +348,8 @@ function useMediaQuery(e, t = {}) {
348
348
  });
349
349
  return;
350
350
  }
351
- i.value && (s.value = n.matchMedia(toValue(e)), c.value = s.value.matches);
352
- }), useEventListener(s, "change", (e) => {
351
+ i.value && (o.value = n.matchMedia(toValue(e)), c.value = o.value.matches);
352
+ }), useEventListener(o, "change", (e) => {
353
353
  c.value = e.matches;
354
354
  }, { passive: !0 }), computed(() => c.value);
355
355
  }
@@ -410,19 +410,19 @@ const appConfig = useGlobalVar(new ConfigPointer("core", {
410
410
  if (!n) throw Error(`not found config by plugin "${e.pluginName}"`);
411
411
  return n.value;
412
412
  }, "load"), r = usePreferredDark(), a = computed(() => {
413
- if (!s(appConfig)) return r.value;
413
+ if (!o(appConfig)) return r.value;
414
414
  switch (n(appConfig).value.darkMode) {
415
415
  case "light": return !1;
416
416
  case "dark": return !0;
417
417
  case "system": return r.value;
418
418
  default: return !1;
419
419
  }
420
- }), s = e.action((e) => t.has(e.key), "isExistConfig");
420
+ }), o = e.action((e) => t.has(e.key), "isExistConfig");
421
421
  return {
422
422
  isDark: a,
423
423
  form: t,
424
424
  $load: n,
425
- $isExistConfig: s,
425
+ $isExistConfig: o,
426
426
  $resignerConfig: e.action((e) => {
427
427
  let t = useConfig(), n = useNativeStore(e.pluginName, "config", fromPairs(Object.entries(e.config).map(([e, t]) => [e, t.defaultValue])));
428
428
  t.form.set(e.key, {
@@ -467,6 +467,7 @@ const appConfig = useGlobalVar(new ConfigPointer("core", {
467
467
  let n = this.mainLists.get(e) ?? [];
468
468
  this.mainLists.set(e, n.concat(t));
469
469
  }
470
+ envExtends = shallowReactive(/* @__PURE__ */ new Set());
470
471
  }(), "core/global");
471
472
  var import_lz_string = (/* @__PURE__ */ __commonJSMin(((e, t) => {
472
473
  var n = (function() {
@@ -6355,6 +6356,39 @@ const loadAllPlugins = PromiseContent.fromAsyncFunction(async () => {
6355
6356
  for (let e of r) await Promise.all(e.map((e) => loadPlugin(e)));
6356
6357
  console.log("[plugin bootPlugin] all load done");
6357
6358
  });
6358
- export { ConfigPointer, Global, 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 };
6359
+ var Inject_default = /* @__PURE__ */ defineComponent({
6360
+ __name: "Inject",
6361
+ props: {
6362
+ key: {},
6363
+ args: {}
6364
+ },
6365
+ setup(e) {
6366
+ 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(unref(DcAwait), {
6368
+ promise: async () => {
6369
+ try {
6370
+ return await t.condition(e.args);
6371
+ } catch (e) {
6372
+ return console.warn(e), !1;
6373
+ }
6374
+ },
6375
+ "auto-load": ""
6376
+ }, {
6377
+ default: withCtx(({ result: n }) => [n ? (openBlock(), createBlock(resolveDynamicComponent(t.component), mergeProps({
6378
+ key: 0,
6379
+ ref_for: !0
6380
+ }, e.args), null, 16)) : createCommentVNode("", !0)]),
6381
+ _: 2
6382
+ }, 1032, ["promise"]))), 256));
6383
+ }
6384
+ });
6385
+ const addInjection = (e, t, n) => {
6386
+ Global.envExtends.add({
6387
+ key: e,
6388
+ component: t,
6389
+ condition: n ?? (() => !0)
6390
+ });
6391
+ };
6392
+ 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 };
6359
6393
 
6360
6394
  //# sourceMappingURL=index.js.map