x-runtime-lib 0.8.199 → 0.8.201

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,6 +1,6 @@
1
1
  import { n as __export } from "./rolldown-runtime.ofrncwta.js";
2
2
  import { C as MapControls_default, D as isEmpty_default, E as isEqual_default, O as cloneDeep_default, S as KeyboardControls_default, T as component_default$8, _ as install, b as registerTheme, d as install$5, f as install$4, g as install$3, h as install$1, i as getQuickJS, k as capitalize_default, l as encodeString, m as install$2, p as install$6, r as mitt_default, u as install$7, v as core_exports, w as OrbitControls_default, x as HTML_default, y as use } from "./vendor.pfrgnj2n.js";
3
- import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createVNode, defineComponent, h, inject, isRef, mergeModels, nextTick, normalizeClass, normalizeStyle, onBeforeMount, onMounted, onUnmounted, openBlock, provide, readonly, ref, renderList, renderSlot, resolveComponent, toDisplayString, unref, useAttrs, useId, useModel, useTemplateRef, watch, watchEffect, withCtx, withModifiers } from "vue";
3
+ import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createVNode, defineComponent, h, inject, isRef, mergeModels, nextTick, normalizeClass, normalizeStyle, onBeforeMount, onMounted, onUnmounted, openBlock, provide, readonly, ref, renderList, renderSlot, resolveComponent, shallowRef, toDisplayString, unref, useAttrs, useId, useModel, useTemplateRef, watch, watchEffect, withCtx, withModifiers } from "vue";
4
4
  import { createAxios, eventBus, getTypeDefault, globalObjects, messageError, messageInfo, messageSuccess, messageWarning, openConfirmDlg, openPromptDlg, useViewStack, waitUtil } from "x-essential-lib";
5
5
  import { CameraHelper, DirectionalLightHelper, PointLightHelper, SpotLightHelper } from "three";
6
6
  import { useTheme as useTheme$1 } from "vuetify";
@@ -3394,7 +3394,7 @@ var echarts_default = core_exports, v1_default$49 = /* @__PURE__ */ defineCompon
3394
3394
  "addIcon",
3395
3395
  "prepend"
3396
3396
  ]), { property: N } = useElementProperty(m, ["settings", "readonly"]), { property: P } = useElementProperty(m, ["settings", "ripple"]), { property: F } = useElementProperty(m, ["settings", "size"]), { property: I } = useElementProperty(m, ["settings", "stacked"]), { property: L } = useElementProperty(m, ["settings", "text"]), { theme: R } = useTheme(), { property: z } = useElementProperty(m, ["settings", "variant"]), { property: B } = useElementProperty(m, ["size", "width"]), V = async (e) => {
3397
- !g || !g.vm || (g.setGlobalVariable("__pointerPosX__", e.clientX), g.setGlobalVariable("__pointerPosY__", e.clientY), await g.callFunctionAsync("__triggerEventV1__", makeEventId("elementEvent", p.nodeId, "click"), ""));
3397
+ !g || !g.vm || (g.setGlobalVariable("__pointerPosX__", e.clientX), g.setGlobalVariable("__pointerPosY__", e.clientY), await g.triggerEvent(makeEventId("elementEvent", p.nodeId, "click"), []));
3398
3398
  };
3399
3399
  return (e, p) => {
3400
3400
  let m = resolveComponent("v-btn");
@@ -4035,7 +4035,7 @@ var v1_default$40 = /* @__PURE__ */ __plugin_vue_export_helper_default(_sfc_main
4035
4035
  let e = {}, p = _.value?.type;
4036
4036
  return g === "page" ? p === "ui" ? (E(e), D(e), O(e), k(e), T.value && (e.backgroundColor = T.value)) : console.assert(!1) : g === "comp" && p === "ui" ? (E(e), D(e), O(e), k(e), T.value && (e.backgroundColor = T.value)) : console.assert(!1), e;
4037
4037
  }), j = async () => {
4038
- await v?.callFunctionAsync("__triggerEventV1__", makeEventId("elementEvent", p.nodeId, "submit"), "");
4038
+ !v || !v.vm || await v.triggerEvent(makeEventId("elementEvent", p.nodeId, "submit"), []);
4039
4039
  };
4040
4040
  return (e, p) => {
4041
4041
  let m = resolveComponent("v-form");
@@ -10545,9 +10545,9 @@ function bindView(e) {
10545
10545
  return;
10546
10546
  }
10547
10547
  let { vm: p } = e;
10548
- p.newFunction("__triggerEventV1__", (m, g, ..._) => {
10549
- let v = p.getString(m), y = p.getString(g), b = _.map((e) => p.dump(e)), { promise: x, resolve: S, reject: C } = e.promiseManager.create();
10550
- return e.triggerEvent(v, y, ...b).then((e) => S(e), (e) => C(e)), x.settled.then(p.runtime.executePendingJobs), x.handle;
10548
+ p.newFunction("__triggerEventV1__", (m, g, _) => {
10549
+ let v = p.getString(m), y = p.dump(g), b = p.getString(_), { promise: x, resolve: S, reject: C } = e.promiseManager.create();
10550
+ return e.triggerEvent(v, y, b).then((e) => S(e), (e) => C(e)), x.settled.then(p.runtime.executePendingJobs), x.handle;
10551
10551
  }).consume((e) => p.setProp(p.global, "__triggerEventV1__", e)), p.newFunction("__getPropertyV1__", (m, g) => {
10552
10552
  let _ = p.getString(m), v = p.getString(g), { promise: y, resolve: b, reject: x } = e.promiseManager.create();
10553
10553
  return e.getProperty(_, v).then((e) => b(e), (e) => x(e)), y.settled.then(p.runtime.executePendingJobs), y.handle;
@@ -10616,7 +10616,7 @@ var PromiseManager = class {
10616
10616
  this.vm && (newAny(this.vm, m).consume((e) => p.resolve(e)), delete this.promises[e]);
10617
10617
  },
10618
10618
  reject: (m) => {
10619
- this.vm && (newAny(this.vm, m).consume((e) => p.reject(e)), delete this.promises[e]);
10619
+ this.vm && (m instanceof Error && (m = m.message), newAny(this.vm, m).consume((e) => p.reject(e)), delete this.promises[e]);
10620
10620
  }
10621
10621
  };
10622
10622
  }
@@ -10655,14 +10655,15 @@ var PromiseManager = class {
10655
10655
  }
10656
10656
  meta = ref();
10657
10657
  data = ref();
10658
- prepare(e, p, m) {
10659
- this.meta.value = e.value, this.data.value = p.value, this.resetProperties(m), this.resetStates();
10658
+ depends = shallowRef();
10659
+ prepare(e, p, m, g) {
10660
+ this.meta.value = e.value, this.data.value = p.value, this.depends.value = m.value, this.resetProperties(g), this.resetStates();
10660
10661
  }
10661
10662
  getNode(e) {
10662
10663
  return this.data.value?.view.nodes[e];
10663
10664
  }
10664
10665
  async createVm(e, p) {
10665
- this.vm = e.newContext(), this.promiseManager = new PromiseManager(this.vm), bind(this), this.vm.evalCode("\nlet __events__ = {}\n\nfunction __onEventV1__(id, callback) {\n if (typeof(id) !== 'string' || !id) {\n return\n }\n if (typeof(callback) !== 'function') {\n return\n }\n if (!__events__[id]) {\n __events__[id] = []\n }\n const callbacks = __events__[id]\n for (let i = 0; i < callbacks.length; i++) {\n if (callbacks[i] === callback) {\n return\n }\n }\n callbacks.push(callback)\n}\n\nasync function __triggerEventInner__(id, ...params) {\n if (typeof(id) !== 'string' || !id) {\n return\n }\n if (!__events__[id]) {\n return\n }\n const callbacks = __events__[id]\n if (!callbacks) {\n return\n }\n for (let i = 0; i < callbacks.length; i++) {\n await callbacks[i](...params)\n }\n}\n\nlet __timers__ = {}\nlet __currTimerId__ = 0\n\nfunction __createTimerV1__(interval, loop, count, immediate, callback) {\n if (!loop && count <= 0) {\n return\n }\n const timer = {}\n timer.id = __currTimerId__++\n timer.interval = interval\n timer.loop = loop\n timer.count = count\n timer.immediate = immediate\n timer.callback = callback\n __timers__[timer.id] = timer\n if (timer.immediate) {\n __timeoutCallbackV1__(timer.id)\n } else {\n __timeoutV1__(timer.id, timer.interval)\n }\n}\n\nasync function __timeoutCallback__(timerId) {\n const timer = __timers__[timerId]\n if (timer) {\n timer.callback()\n // 修改计数\n if (!timer.loop) {\n timer.count = timer.count - 1\n }\n // 触发超时\n if (timer.loop || timer.count > 0) {\n await __timeoutV1__(timer.id, timer.interval)\n }\n // 回收\n if (!timer.loop && timer.count <= 0) {\n delete __timers__[timer.id]\n }\n }\n}\n\nfunction __destroy__() {\n __events__ = {}\n __timers__ = {}\n}\n"), this.setGlobalVariable("__env__", this.env), this.vm.evalCode(p), await nextTick(), this.hooks.onReady();
10666
+ this.vm = e.newContext(), this.promiseManager = new PromiseManager(this.vm), bind(this), this.vm.evalCode("\nlet __events__ = {}\n\nfunction __onEventV1__(id, callback) {\n if (typeof(id) !== 'string' || !id) {\n return\n }\n if (typeof(callback) !== 'function') {\n return\n }\n if (!__events__[id]) {\n __events__[id] = []\n }\n const callbacks = __events__[id]\n for (let i = 0; i < callbacks.length; i++) {\n if (callbacks[i] === callback) {\n return\n }\n }\n callbacks.push(callback)\n}\n\nasync function __triggerEventInner__(id, params, instance) {\n if (!__events__[id]) {\n return\n }\n const callbacks = __events__[id]\n if (!callbacks) {\n return\n }\n for (let i = 0; i < callbacks.length; i++) {\n await callbacks[i](params, instance)\n }\n}\n\nlet __timers__ = {}\nlet __currTimerId__ = 0\n\nfunction __createTimerV1__(interval, loop, count, immediate, callback) {\n if (!loop && count <= 0) {\n return\n }\n const timer = {}\n timer.id = __currTimerId__++\n timer.interval = interval\n timer.loop = loop\n timer.count = count\n timer.immediate = immediate\n timer.callback = callback\n __timers__[timer.id] = timer\n if (timer.immediate) {\n __timeoutCallbackV1__(timer.id)\n } else {\n __timeoutV1__(timer.id, timer.interval)\n }\n}\n\nasync function __timeoutCallback__(timerId) {\n const timer = __timers__[timerId]\n if (timer) {\n timer.callback()\n // 修改计数\n if (!timer.loop) {\n timer.count = timer.count - 1\n }\n // 触发超时\n if (timer.loop || timer.count > 0) {\n await __timeoutV1__(timer.id, timer.interval)\n }\n // 回收\n if (!timer.loop && timer.count <= 0) {\n delete __timers__[timer.id]\n }\n }\n}\n\nfunction __destroy__() {\n __events__ = {}\n __timers__ = {}\n}\n"), this.setGlobalVariable("__env__", this.env), this.vm.evalCode(p), await nextTick(), this.hooks.onReady();
10666
10667
  }
10667
10668
  destroyVm() {
10668
10669
  this.vm && this.hooks.onDestroy(), this.promiseManager &&= (this.promiseManager.dispose(), void 0), this.vm &&= (this.vm.dispose(), void 0);
@@ -10722,27 +10723,160 @@ var PromiseManager = class {
10722
10723
  isValidOfCustomEvent(e) {
10723
10724
  return this.meta.value ? !!this.meta.value.events?.find((p) => p.id === e) : !1;
10724
10725
  }
10725
- isValidOfCustomSlotEvent(e, p) {
10726
- if (!this.meta.value) return !1;
10727
- let m = this.meta.value.slots?.find((p) => p.id === e);
10728
- return !m || !m.events ? !1 : !!m.events.find((e) => e.id === p);
10729
- }
10730
- async triggerEvent(e, p, ...m) {
10731
- this.debugTrace("triggerEvent", e, p, ...m);
10732
- let { kind: g, nodeId: _, eventKey: v } = unwrapEventId(e);
10733
- if (await this.callFunctionAsync("__triggerEventInner__", e, p, ...m), g === "elementSlotEvent") {
10734
- let e = this.children[_];
10735
- e && await e.triggerEvent(makeEventId("elementAdaptSlotEvent", "globality", v), "", ...m);
10736
- } else if (g === "multipleElementSlotEvent") {
10737
- let e = this.children[`${_}/${p}`];
10738
- e && await e.triggerEvent(makeEventId("elementAdaptSlotEvent", "globality", v), "", ...m);
10739
- } else if (g === "customSlotEvent") {
10740
- let e = this.children[_];
10741
- e && await e.triggerEvent(makeEventId("customAdaptSlotEvent", "globality", v), "", ...m);
10742
- } else if (g === "multipleCustomSlotEvent") {
10743
- let e = this.children[`${_}/${p}`];
10744
- e && await e.triggerEvent(makeEventId("customAdaptSlotEvent", "globality", v), "", ...m);
10745
- } else g === "customEvent" && this.parent && (await this.parent.triggerEvent(makeEventId("refEvent", this.nodeId, v), "", ...m), await this.parent.triggerEvent(makeEventId("multipleRefEvent", this.nodeId, v), this.instance, ...m));
10726
+ isValidOfCustomSlotEvent(e, p, m) {
10727
+ let g = this.depends.value?.[e];
10728
+ if (!g) return !1;
10729
+ let _ = g.meta.slots?.find((e) => e.id === p);
10730
+ return !_ || !_.events ? !1 : !!_.events.find((e) => e.id === m);
10731
+ }
10732
+ async triggerEvent(e, p, m) {
10733
+ this.debugTrace("triggerEvent", e, p, m);
10734
+ let { kind: g, nodeId: _, eventKey: v } = unwrapEventId(e), y = this.getNode(_);
10735
+ if (!y) throw Error("node not found");
10736
+ if (g === "elementEvent") await this.triggerElementEvent(e, p, y, v);
10737
+ else if (g === "elementPropertyChangeEvent") await this.triggerElementPropertyChangeEvent(e, p, y, v);
10738
+ else if (g === "elementSlotEvent") await this.triggerElementSlotEvent(e, p, _, v);
10739
+ else if (g === "elementSlotPropertyChangeEvent") await this.triggerElementSlotPropertyChangeEvent(e, p, v);
10740
+ else if (g === "multipleElementSlotEvent") await this.triggerMultipleElementSlotEvent(e, p, _, v, m);
10741
+ else if (g === "multipleElementSlotPropertyChangeEvent") await this.triggerMultipleElementSlotPropertyChangeEvent(e, p, v, m);
10742
+ else if (g === "refEvent") await this.triggerRefEvent(e, p, _, v);
10743
+ else if (g === "refPropertyChangeEvent") await this.triggerRefPropertyChangeEvent(e, p, _, v);
10744
+ else if (g === "multipleRefEvent") await this.triggerMultipleRefEvent(e, p, _, v, m);
10745
+ else if (g === "multipleRefPropertyChangeEvent") await this.triggerMultipleRefPropertyChangeEvent(e, p, _, v, m);
10746
+ else if (g === "customSlotEvent") await this.triggerCustomSlotEvent(e, p, _, v);
10747
+ else if (g === "customSlotPropertyChangeEvent") await this.triggerCustomSlotPropertyChangeEvent(e, p, v);
10748
+ else if (g === "multipleCustomSlotEvent") await this.triggerMultipleCustomSlotEvent(e, p, _, v, m);
10749
+ else if (g === "multipleCustomSlotPropertyChangeEvent") await this.triggerMultipleCustomSlotPropertyChangeEvent(e, p, v, m);
10750
+ else if (g === "customEvent") await this.triggerCustomEvent(e, p, v);
10751
+ else if (g === "customPropertyChangeEvent") await this.triggerCustomPropertyChangeEvent(e, p, v);
10752
+ else if (g === "elementAdaptSlotEvent") await this.triggerElementAdaptSlotEvent(e, p, v);
10753
+ else if (g === "elementAdaptSlotPropertyChangeEvent") await this.triggerElementAdaptSlotPropertyChangeEvent(e, p, v);
10754
+ else if (g === "customAdaptSlotEvent") await this.triggerCustomAdaptSlotEvent(e, p, v);
10755
+ else if (g === "customAdaptSlotPropertyChangeEvent") await this.triggerCustomAdaptSlotPropertyChangeEvent(e, p, v);
10756
+ else if (g === "stateChangeEvent") await this.triggerStateChangeEvent(e, p, v);
10757
+ else throw Error("not implemented event kind");
10758
+ }
10759
+ async triggerElementEvent(e, p, m, g) {
10760
+ if (!this.isValidOfElementEvent(m.basic.key, g)) throw Error("invalid element event");
10761
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10762
+ }
10763
+ async triggerElementPropertyChangeEvent(e, p, m, g) {
10764
+ if (!this.isValidOfElementProperty(m.basic.key, g)) throw Error("invalid element property");
10765
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10766
+ }
10767
+ async triggerElementSlotEvent(e, p, m, g) {
10768
+ let { elementKey: _, slotKey: v, eventKey: y } = unwrapEventKeyOfElementSlot(g);
10769
+ if (!this.isValidOfElementSlotEvent(_, v, y)) throw Error("invalid element slot event");
10770
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10771
+ let b = this.children[m];
10772
+ b && await b.triggerEvent(makeEventId("elementAdaptSlotEvent", "globality", g), p);
10773
+ }
10774
+ async triggerElementSlotPropertyChangeEvent(e, p, m) {
10775
+ let { elementKey: g, slotKey: _, eventKey: v } = unwrapEventKeyOfElementSlot(m);
10776
+ if (!this.isValidOfElementSlotProperty(g, _, v)) throw Error("invalid element slot property");
10777
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10778
+ }
10779
+ async triggerMultipleElementSlotEvent(e, p, m, g, _) {
10780
+ if (!_) throw Error("instance not available");
10781
+ let { elementKey: v, slotKey: y, eventKey: b } = unwrapEventKeyOfElementSlot(g);
10782
+ if (!this.isValidOfElementSlotEvent(v, y, b)) throw Error("invalid element slot event");
10783
+ await this.callFunctionAsync("__triggerEventInner__", e, p, _);
10784
+ let x = this.children[`${m}/${_}`];
10785
+ x && await x.triggerEvent(makeEventId("elementAdaptSlotEvent", "globality", g), p);
10786
+ }
10787
+ async triggerMultipleElementSlotPropertyChangeEvent(e, p, m, g) {
10788
+ if (!g) throw Error("instance not available");
10789
+ let { elementKey: _, slotKey: v, eventKey: y } = unwrapEventKeyOfElementSlot(m);
10790
+ if (!this.isValidOfElementSlotProperty(_, v, y)) throw Error("invalid element slot property");
10791
+ await this.callFunctionAsync("__triggerEventInner__", e, p, g);
10792
+ }
10793
+ async triggerRefEvent(e, p, m, g) {
10794
+ let _ = this.children[m];
10795
+ if (!_) throw Error("sandbox not found");
10796
+ if (!_.isValidOfCustomEvent(g)) throw Error("invalid custom event");
10797
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10798
+ }
10799
+ async triggerRefPropertyChangeEvent(e, p, m, g) {
10800
+ let _ = this.children[m];
10801
+ if (!_) throw Error("sandbox not found");
10802
+ if (!_.isValidOfCustomProperty(g)) throw Error("invalid custom property");
10803
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10804
+ }
10805
+ async triggerMultipleRefEvent(e, p, m, g, _) {
10806
+ if (!_) throw Error("instance not available");
10807
+ let v = this.children[`${m}/${_}`];
10808
+ if (!v) throw Error("sandbox not found");
10809
+ if (!v.isValidOfCustomEvent(g)) throw Error("invalid custom event");
10810
+ await this.callFunctionAsync("__triggerEventInner__", e, p, _);
10811
+ }
10812
+ async triggerMultipleRefPropertyChangeEvent(e, p, m, g, _) {
10813
+ if (!_) throw Error("instance not available");
10814
+ let v = this.children[`${m}/${_}`];
10815
+ if (!v) throw Error("sandbox not found");
10816
+ if (!v.isValidOfCustomProperty(g)) throw Error("invalid custom property");
10817
+ await this.callFunctionAsync("__triggerEventInner__", e, p, _);
10818
+ }
10819
+ async triggerCustomSlotEvent(e, p, m, g) {
10820
+ let { compId: _, slotId: v, eventId: y } = unwrapEventKeyOfCustomSlot(g);
10821
+ if (!this.isValidOfCustomSlotEvent(_, v, y)) throw Error("invalid custom slot event");
10822
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10823
+ let b = this.children[m];
10824
+ b && await b.triggerEvent(makeEventId("customAdaptSlotEvent", "globality", g), p);
10825
+ }
10826
+ async triggerCustomSlotPropertyChangeEvent(e, p, m) {
10827
+ let { compId: g, slotId: _, eventId: v } = unwrapEventKeyOfCustomSlot(m);
10828
+ if (!this.isValidOfCustomSlotProperty(g, _, v)) throw Error("invalid custom slot property");
10829
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10830
+ }
10831
+ async triggerMultipleCustomSlotEvent(e, p, m, g, _) {
10832
+ if (!_) throw Error("instance not available");
10833
+ let { compId: v, slotId: y, eventId: b } = unwrapEventKeyOfCustomSlot(g);
10834
+ if (!this.isValidOfCustomSlotEvent(v, y, b)) throw Error("invalid custom slot event");
10835
+ await this.callFunctionAsync("__triggerEventInner__", e, p, _);
10836
+ let x = this.children[`${m}/${_}`];
10837
+ x && await x.triggerEvent(makeEventId("customAdaptSlotEvent", "globality", g), p);
10838
+ }
10839
+ async triggerMultipleCustomSlotPropertyChangeEvent(e, p, m, g) {
10840
+ if (!g) throw Error("instance not available");
10841
+ let { compId: _, slotId: v, eventId: y } = unwrapEventKeyOfCustomSlot(m);
10842
+ if (!this.isValidOfCustomSlotProperty(_, v, y)) throw Error("invalid custom slot property");
10843
+ await this.callFunctionAsync("__triggerEventInner__", e, p, g);
10844
+ }
10845
+ async triggerCustomEvent(e, p, m) {
10846
+ if (!this.isValidOfCustomEvent(m)) throw Error("invalid custom event");
10847
+ await this.callFunctionAsync("__triggerEventInner__", e, p), this.parent && (this.instance ? await this.parent.triggerEvent(makeEventId("multipleRefEvent", this.nodeId, m), p, this.instance) : await this.parent.triggerEvent(makeEventId("refEvent", this.nodeId, m), p));
10848
+ }
10849
+ async triggerCustomPropertyChangeEvent(e, p, m) {
10850
+ if (!this.isValidOfCustomProperty(m)) throw Error("invalid custom property");
10851
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10852
+ }
10853
+ async triggerElementAdaptSlotEvent(e, p, m) {
10854
+ if (!this.parent) throw Error("not in slot");
10855
+ let { elementKey: g, slotKey: _, eventKey: v } = unwrapEventKeyOfElementSlot(m);
10856
+ if (!this.isValidOfElementSlotEvent(g, _, v)) throw Error("invalid element slot event");
10857
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10858
+ }
10859
+ async triggerElementAdaptSlotPropertyChangeEvent(e, p, m) {
10860
+ if (!this.parent) throw Error("not in slot");
10861
+ let { elementKey: g, slotKey: _, eventKey: v } = unwrapEventKeyOfElementSlot(m);
10862
+ if (!this.isValidOfElementSlotProperty(g, _, v)) throw Error("invalid element slot property");
10863
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10864
+ }
10865
+ async triggerCustomAdaptSlotEvent(e, p, m) {
10866
+ if (!this.parent) throw Error("not in slot");
10867
+ let { compId: g, slotId: _, eventId: v } = unwrapEventKeyOfCustomSlot(m);
10868
+ if (!this.isValidOfCustomSlotEvent(g, _, v)) throw Error("invalid custom slot event");
10869
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10870
+ }
10871
+ async triggerCustomAdaptSlotPropertyChangeEvent(e, p, m) {
10872
+ if (!this.parent) throw Error("not in slot");
10873
+ let { compId: g, slotId: _, eventId: v } = unwrapEventKeyOfCustomSlot(m);
10874
+ if (!this.isValidOfCustomSlotProperty(g, _, v)) throw Error("invalid custom slot property");
10875
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10876
+ }
10877
+ async triggerStateChangeEvent(e, p, m) {
10878
+ if (!this.isValidOfState(m)) throw Error("invalid state");
10879
+ await this.callFunctionAsync("__triggerEventInner__", e, p);
10746
10880
  }
10747
10881
  customProperties = {};
10748
10882
  customSlotProperties = {};
@@ -10767,10 +10901,11 @@ var PromiseManager = class {
10767
10901
  isValidOfCustomProperty(e) {
10768
10902
  return this.meta.value ? !!this.meta.value.properties?.find((p) => p.id === e) : !1;
10769
10903
  }
10770
- isValidOfCustomSlotProperty(e, p) {
10771
- if (!this.meta.value) return !1;
10772
- let m = this.meta.value.slots?.find((p) => p.id === e);
10773
- return !m || !m.properties ? !1 : !!m.properties.find((e) => e.id === p);
10904
+ isValidOfCustomSlotProperty(e, p, m) {
10905
+ let g = this.depends.value?.[e];
10906
+ if (!g) return !1;
10907
+ let _ = g.meta.slots?.find((e) => e.id === p);
10908
+ return !_ || !_.properties ? !1 : !!_.properties.find((e) => e.id === m);
10774
10909
  }
10775
10910
  async getProperty(e, p) {
10776
10911
  let { kind: m, nodeId: g, propertyKey: _ } = unwrapPropertyId(e), v = this.getNode(g);
@@ -10803,17 +10938,19 @@ var PromiseManager = class {
10803
10938
  return _.customProperties[m];
10804
10939
  }
10805
10940
  async getCustomSlotProperty(e, p, m) {
10806
- let { slotId: g, propertyId: _ } = unwrapPropertyKeyOfCustomSlot(m), v = this.children[p];
10807
- if (!v) throw Error("sandbox not found");
10808
- if (!v.isValidOfCustomSlotProperty(g, _)) throw console.warn(`Sandbox/getCustomSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10809
- return v.customSlotProperties[_];
10941
+ let { compId: g, slotId: _, propertyId: v } = unwrapPropertyKeyOfCustomSlot(m);
10942
+ if (!this.isValidOfCustomSlotProperty(g, _, v)) throw console.warn(`Sandbox/getCustomSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10943
+ let y = this.children[p];
10944
+ if (!y) throw Error("sandbox not found");
10945
+ return y.customSlotProperties[v];
10810
10946
  }
10811
10947
  async getMultipleCustomSlotProperty(e, p, m, g) {
10812
10948
  if (!g) throw Error("instance not available");
10813
- let { slotId: _, propertyId: v } = unwrapPropertyKeyOfCustomSlot(m), y = this.children[`${p}/${g}`];
10814
- if (!y) throw Error("sandbox not found");
10815
- if (!y.isValidOfCustomSlotProperty(_, v)) throw console.warn(`Sandbox/getMultipleCustomSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10816
- return y.customSlotProperties[v];
10949
+ let { compId: _, slotId: v, propertyId: y } = unwrapPropertyKeyOfCustomSlot(m);
10950
+ if (!this.isValidOfCustomSlotProperty(_, v, y)) throw console.warn(`Sandbox/getMultipleCustomSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10951
+ let b = this.children[`${p}/${g}`];
10952
+ if (!b) throw Error("sandbox not found");
10953
+ return b.customSlotProperties[y];
10817
10954
  }
10818
10955
  async getCustomProperty(e, p) {
10819
10956
  if (!this.isValidOfCustomProperty(p)) throw console.warn(`Sandbox/getCustomProperty invalid custom property id=${e}`), Error("invalid custom property");
@@ -10828,9 +10965,9 @@ var PromiseManager = class {
10828
10965
  }
10829
10966
  async getCustomAdaptSlotProperty(e, p) {
10830
10967
  if (!this.parent) throw Error("not in slot");
10831
- let { slotId: m, propertyId: g } = unwrapPropertyKeyOfCustomSlot(p);
10832
- if (!this.isValidOfCustomSlotProperty(m, g)) throw console.warn(`Sandbox/getCustomAdaptSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10833
- return this.customSlotProperties[g];
10968
+ let { compId: m, slotId: g, propertyId: _ } = unwrapPropertyKeyOfCustomSlot(p);
10969
+ if (!this.isValidOfCustomSlotProperty(m, g, _)) throw console.warn(`Sandbox/getCustomAdaptSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10970
+ return this.customSlotProperties[_];
10834
10971
  }
10835
10972
  async setProperty(e, p, m) {
10836
10973
  let { kind: g, nodeId: v, propertyKey: y } = unwrapPropertyId(e), b = this.getNode(v);
@@ -10867,19 +11004,21 @@ var PromiseManager = class {
10867
11004
  isEqual_default(p, b) || (y.customProperties[_] = p, y.hooks.onPropertyChange(makePropertyId("customProperty", "globality", _), p, b, v), this.hooks.onPropertyChange(e, p, b, v));
10868
11005
  }
10869
11006
  async setCustomSlotProperty(e, p, m, _) {
10870
- let { slotId: v, propertyId: y } = unwrapPropertyKeyOfCustomSlot(_), b = this.children[m];
10871
- if (!b) throw Error("sandbox not found");
10872
- if (!b.isValidOfCustomSlotProperty(v, y)) throw console.warn(`Sandbox/setCustomSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10873
- let x = b.customSlotProperties[y];
10874
- isEqual_default(p, x) || (b.customSlotProperties[y] = p, b.hooks.onPropertyChange(makePropertyId("customAdaptSlotProperty", "globality", _), p, x), this.hooks.onPropertyChange(e, p, x));
11007
+ let { compId: v, slotId: y, propertyId: b } = unwrapPropertyKeyOfCustomSlot(_);
11008
+ if (!this.isValidOfCustomSlotProperty(v, y, b)) throw console.warn(`Sandbox/setCustomSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
11009
+ let x = this.children[m];
11010
+ if (!x) throw Error("sandbox not found");
11011
+ let S = x.customSlotProperties[b];
11012
+ isEqual_default(p, S) || (x.customSlotProperties[b] = p, x.hooks.onPropertyChange(makePropertyId("customAdaptSlotProperty", "globality", _), p, S), this.hooks.onPropertyChange(e, p, S));
10875
11013
  }
10876
11014
  async setMultipleCustomSlotProperty(e, p, m, _, v) {
10877
11015
  if (!v) throw Error("instance not available");
10878
- let { slotId: y, propertyId: b } = unwrapPropertyKeyOfCustomSlot(_), x = this.children[`${m}/${v}`];
10879
- if (!x) throw Error("sandbox not found");
10880
- if (!x.isValidOfCustomSlotProperty(y, b)) throw console.warn(`Sandbox/setMultipleCustomSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10881
- let S = x.customSlotProperties[b];
10882
- isEqual_default(p, S) || (x.customSlotProperties[b] = p, x.hooks.onPropertyChange(makePropertyId("customAdaptSlotProperty", "globality", _), p, S, v), this.hooks.onPropertyChange(e, p, S, v));
11016
+ let { compId: y, slotId: b, propertyId: x } = unwrapPropertyKeyOfCustomSlot(_);
11017
+ if (!this.isValidOfCustomSlotProperty(y, b, x)) throw console.warn(`Sandbox/setMultipleCustomSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
11018
+ let S = this.children[`${m}/${v}`];
11019
+ if (!S) throw Error("sandbox not found");
11020
+ let C = S.customSlotProperties[x];
11021
+ isEqual_default(p, C) || (S.customSlotProperties[x] = p, S.hooks.onPropertyChange(makePropertyId("customAdaptSlotProperty", "globality", _), p, C, v), this.hooks.onPropertyChange(e, p, C, v));
10883
11022
  }
10884
11023
  async setCustomProperty(e, p, m) {
10885
11024
  if (!this.isValidOfCustomProperty(m)) throw console.warn(`Sandbox/setCustomProperty invalid custom property id=${e}`), Error("invalid custom property");
@@ -10897,10 +11036,10 @@ var PromiseManager = class {
10897
11036
  }
10898
11037
  async setCustomAdaptSlotProperty(e, p, m) {
10899
11038
  if (!this.parent) throw Error("not in slot");
10900
- let { slotId: _, propertyId: v } = unwrapPropertyKeyOfCustomSlot(m);
10901
- if (!this.isValidOfCustomSlotProperty(_, v)) throw console.warn(`Sandbox/setCustomAdaptSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10902
- let y = this.customSlotProperties[v];
10903
- isEqual_default(p, y) || (this.customSlotProperties[v] = p, this.hooks.onPropertyChange(e, p, y), this.kind === "customSlot" ? this.parent.hooks.onPropertyChange(makePropertyId("customSlotProperty", this.nodeId, m), p, y) : this.kind === "multipleCustomSlot" && this.parent.hooks.onPropertyChange(makePropertyId("multipleCustomSlotProperty", this.nodeId, m), p, y, this.instance));
11039
+ let { compId: _, slotId: v, propertyId: y } = unwrapPropertyKeyOfCustomSlot(m);
11040
+ if (!this.isValidOfCustomSlotProperty(_, v, y)) throw console.warn(`Sandbox/setCustomAdaptSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
11041
+ let b = this.customSlotProperties[y];
11042
+ isEqual_default(p, b) || (this.customSlotProperties[y] = p, this.hooks.onPropertyChange(e, p, b), this.kind === "customSlot" ? this.parent.hooks.onPropertyChange(makePropertyId("customSlotProperty", this.nodeId, m), p, b) : this.kind === "multipleCustomSlot" && this.parent.hooks.onPropertyChange(makePropertyId("multipleCustomSlotProperty", this.nodeId, m), p, b, this.instance));
10904
11043
  }
10905
11044
  isValidOfElementMethod(e, p) {
10906
11045
  let m = getElement(e);
@@ -10915,10 +11054,11 @@ var PromiseManager = class {
10915
11054
  isValidOfCustomMethod(e) {
10916
11055
  return this.meta.value ? !!this.meta.value.methods?.find((p) => p.id === e) : !1;
10917
11056
  }
10918
- isValidOfCustomSlotMethod(e, p) {
10919
- if (!this.meta.value) return !1;
10920
- let m = this.meta.value.slots?.find((p) => p.id === e);
10921
- return !m || !m.methods ? !1 : !!m.methods.find((e) => e.id === p);
11057
+ isValidOfCustomSlotMethod(e, p, m) {
11058
+ let g = this.depends.value?.[e];
11059
+ if (!g) return !1;
11060
+ let _ = g.meta.slots?.find((e) => e.id === p);
11061
+ return !_ || !_.methods ? !1 : !!_.methods.find((e) => e.id === m);
10922
11062
  }
10923
11063
  async callMethod(e, p, m) {
10924
11064
  this.debugTrace(makeFuncInfo("callMethod", e, p, m));
@@ -10966,8 +11106,8 @@ var PromiseManager = class {
10966
11106
  }
10967
11107
  async callCustomAdaptSlotMethod(e, p, m) {
10968
11108
  if (!this.parent) throw Error("not in slot");
10969
- let { slotId: g, methodId: _ } = unwrapMethodKeyOfCustomSlot(m);
10970
- if (!this.isValidOfCustomSlotMethod(g, _)) throw console.warn(`Sandbox/callCustomAdaptSlotMethod invalid custom slot method id=${e}`), Error("invalid custom slot method");
11109
+ let { compId: g, slotId: _, methodId: v } = unwrapMethodKeyOfCustomSlot(m);
11110
+ if (!this.isValidOfCustomSlotMethod(g, _, v)) throw console.warn(`Sandbox/callCustomAdaptSlotMethod invalid custom slot method id=${e}`), Error("invalid custom slot method");
10971
11111
  if (this.kind === "customSlot") return await this.parent.callFunctionAsync(getImplementMethodName("customSlotMethod", this.nodeId, m), "", p);
10972
11112
  if (this.kind === "multipleCustomSlot") return await this.parent.callFunctionAsync(getImplementMethodName("multipleCustomSlotMethod", this.nodeId, m), this.instance, p);
10973
11113
  throw Error("unexpected sandbox kind");
@@ -10989,35 +11129,35 @@ var PromiseManager = class {
10989
11129
  }
10990
11130
  };
10991
11131
  function useSandbox(e, p, m, _, v, y, b, x) {
10992
- let S = injectOrg(), C = injectEnv(), w = injectMode(), T = injectType(), E = injectDevice(), D = injectDark();
11132
+ let S = injectOrg(), C = injectEnv(), w = injectMode(), T = injectType(), E = injectDevice(), D = injectDark(), O = injectDepends();
10993
11133
  if (!isExecutableMode(w)) return { sandbox: void 0 };
10994
- let O = injectRuntime(), k = new Sandbox(e, p, m, _, v, S, C, w, T, {
10995
- onReady: j,
10996
- onDestroy: M,
10997
- onPropertyChange: N,
10998
- onStateChange: P
11134
+ let k = injectRuntime(), A = new Sandbox(e, p, m, _, v, S, C, w, T, {
11135
+ onReady: M,
11136
+ onDestroy: N,
11137
+ onPropertyChange: P,
11138
+ onStateChange: F
10999
11139
  });
11000
- provideSandbox(k), onUnmounted(() => {
11001
- k.dispose();
11140
+ provideSandbox(A), onUnmounted(() => {
11141
+ A.dispose();
11002
11142
  });
11003
- let A = async () => {
11004
- k.destroyVm(), !(!y.value || !b.value) && (k.prepare(y, b, x), await k.createVm(O, b.value.code.script));
11143
+ let j = async () => {
11144
+ A.destroyVm(), !(!y.value || !b.value) && (A.prepare(y, b, O, x), await A.createVm(k, b.value.code.script));
11005
11145
  };
11006
- A(), watch([y, b], () => {
11007
- A();
11146
+ j(), watch([y, b], () => {
11147
+ j();
11008
11148
  });
11009
- async function j() {
11010
- await k.triggerEvent(makeEventId("elementEvent", "globality", "startup"), "");
11149
+ async function M() {
11150
+ await A.triggerEvent(makeEventId("elementEvent", "globality", "startup"), []);
11011
11151
  let e = calcBreakpoint(E.value.width), p = calcBreakpoint(E.value.width);
11012
- await k.triggerEvent(makeEventId("elementEvent", "globality", "screenSizeChange"), "", e, p), await k.triggerEvent(makeEventId("elementEvent", "globality", "darkModeChange"), "", D.value);
11152
+ await A.triggerEvent(makeEventId("elementEvent", "globality", "screenSizeChange"), [e, p]), await A.triggerEvent(makeEventId("elementEvent", "globality", "darkModeChange"), [D.value]);
11013
11153
  }
11014
- async function M() {
11015
- k.callFunctionSync("__destroy__");
11154
+ async function N() {
11155
+ A.callFunctionSync("__destroy__");
11016
11156
  }
11017
- async function N(e, p, m, _) {
11018
- if (!k.vm) return;
11157
+ async function P(e, p, m, _) {
11158
+ if (!A.vm) return;
11019
11159
  let { kind: v, nodeId: y, propertyKey: x } = unwrapPropertyId(e);
11020
- if (await k.triggerEvent(makeEventId(`${v}ChangeEvent`, y, x), _ ?? "", p, m), b.value?.code.reactivity && triggerReactivity(k, b.value.code.reactivity, makeTriggerId("propertyTrigger", e), p, m), v === "elementProperty") {
11160
+ if (await A.triggerEvent(makeEventId(`${v}ChangeEvent`, y, x), [p, m], _), b.value?.code.reactivity && triggerReactivity(A, b.value.code.reactivity, makeTriggerId("propertyTrigger", e), p, m), v === "elementProperty") {
11021
11161
  if (isEqual_default(x, toDotString(["settings", "slot"]))) {
11022
11162
  let e = b.value?.view.nodeLites.find((e) => e.id === y);
11023
11163
  e ? e.slotId = p : console.assert(!1);
@@ -11028,16 +11168,16 @@ function useSandbox(e, p, m, _, v, y, b, x) {
11028
11168
  }
11029
11169
  }
11030
11170
  }
11031
- async function P(e, p, m) {
11032
- k.vm && (await k.triggerEvent(makeEventId("stateChangeEvent", "globality", e), "", p, m), b.value?.code.reactivity && triggerReactivity(k, b.value.code.reactivity, makeTriggerId("stateTrigger", e), p, m));
11171
+ async function F(e, p, m) {
11172
+ A.vm && (await A.triggerEvent(makeEventId("stateChangeEvent", "globality", e), [p, m]), b.value?.code.reactivity && triggerReactivity(A, b.value.code.reactivity, makeTriggerId("stateTrigger", e), p, m));
11033
11173
  }
11034
11174
  return watch(E, async (e, p) => {
11035
- if (!k.vm) return;
11175
+ if (!A.vm) return;
11036
11176
  let m = calcBreakpoint(e.width), g = calcBreakpoint(p?.width ?? e.width);
11037
- await k.callFunctionAsync("__triggerEventV1__", makeEventId("elementEvent", "globality", "screenSizeChange"), "", m, g);
11177
+ A.triggerEvent(makeEventId("elementEvent", "globality", "screenSizeChange"), [m, g]);
11038
11178
  }), watch(D, async (e) => {
11039
- k.vm && await k.callFunctionAsync("__triggerEventV1__", makeEventId("elementEvent", "globality", "darkModeChange"), "", e);
11040
- }), { sandbox: k };
11179
+ A.vm && A.triggerEvent(makeEventId("elementEvent", "globality", "darkModeChange"), [e]);
11180
+ }), { sandbox: A };
11041
11181
  }
11042
11182
  function useTheme() {
11043
11183
  let e = injectDark();
@@ -1,6 +1,6 @@
1
1
  import { QuickJSContext, QuickJSRuntime } from 'quickjs-emscripten';
2
- import { Ref } from 'vue';
3
- import { Data, Env, Meta, Mode, Node, SandboxKind } from '@/types';
2
+ import { Ref, ShallowRef } from 'vue';
3
+ import { Data, Depends, Env, Meta, Mode, Node, SandboxKind } from '@/types';
4
4
  import { InitValues, Inputs } from '../common';
5
5
  import { Hooks } from './hooks';
6
6
  import { PromiseManager } from './promiseManager';
@@ -28,7 +28,8 @@ export declare class Sandbox {
28
28
  private removeChild;
29
29
  private meta;
30
30
  private data;
31
- prepare(meta: Ref<Meta | undefined>, data: Ref<Data | undefined>, initValues?: InitValues): void;
31
+ private depends;
32
+ prepare(meta: Ref<Meta | undefined>, data: Ref<Data | undefined>, depends: ShallowRef<Depends | undefined>, initValues?: InitValues): void;
32
33
  getNode(nodeId: string): Node | undefined;
33
34
  createVm(runtime: QuickJSRuntime, code: string): Promise<void>;
34
35
  destroyVm(): void;
@@ -39,8 +40,29 @@ export declare class Sandbox {
39
40
  isValidOfElementEvent(elementKey: string, eventKey: string): boolean;
40
41
  isValidOfElementSlotEvent(elementKey: string, slotKey: string, eventKey: string): boolean;
41
42
  isValidOfCustomEvent(eventId: string): boolean;
42
- isValidOfCustomSlotEvent(slotId: string, eventId: string): boolean;
43
- triggerEvent(id: string, instance: string, ...params: any[]): Promise<void>;
43
+ isValidOfCustomSlotEvent(compId: string, slotId: string, eventId: string): boolean;
44
+ triggerEvent(id: string, params: any[], instance?: string): Promise<void>;
45
+ private triggerElementEvent;
46
+ private triggerElementPropertyChangeEvent;
47
+ private triggerElementSlotEvent;
48
+ private triggerElementSlotPropertyChangeEvent;
49
+ private triggerMultipleElementSlotEvent;
50
+ private triggerMultipleElementSlotPropertyChangeEvent;
51
+ private triggerRefEvent;
52
+ private triggerRefPropertyChangeEvent;
53
+ private triggerMultipleRefEvent;
54
+ private triggerMultipleRefPropertyChangeEvent;
55
+ private triggerCustomSlotEvent;
56
+ private triggerCustomSlotPropertyChangeEvent;
57
+ private triggerMultipleCustomSlotEvent;
58
+ private triggerMultipleCustomSlotPropertyChangeEvent;
59
+ private triggerCustomEvent;
60
+ private triggerCustomPropertyChangeEvent;
61
+ private triggerElementAdaptSlotEvent;
62
+ private triggerElementAdaptSlotPropertyChangeEvent;
63
+ private triggerCustomAdaptSlotEvent;
64
+ private triggerCustomAdaptSlotPropertyChangeEvent;
65
+ private triggerStateChangeEvent;
44
66
  customProperties: {
45
67
  [key: string]: any;
46
68
  };
@@ -51,7 +73,7 @@ export declare class Sandbox {
51
73
  isValidOfElementProperty(elementKey: string, propertyKey: string): boolean;
52
74
  isValidOfElementSlotProperty(elementKey: string, slotKey: string, propertyKey: string): boolean;
53
75
  isValidOfCustomProperty(propertyId: string): boolean;
54
- isValidOfCustomSlotProperty(slotId: string, propertyId: string): boolean;
76
+ isValidOfCustomSlotProperty(compId: string, slotId: string, propertyId: string): boolean;
55
77
  getProperty(id: string, instance?: string): Promise<any>;
56
78
  private getElementProperty;
57
79
  private getRefProperty;
@@ -73,7 +95,7 @@ export declare class Sandbox {
73
95
  isValidOfElementMethod(elementKey: string, methodKey: string): boolean;
74
96
  isValidOfElementSlotMethod(elementKey: string, slotKey: string, methodKey: string): boolean;
75
97
  isValidOfCustomMethod(methodId: string): boolean;
76
- isValidOfCustomSlotMethod(slotId: string, methodId: string): boolean;
98
+ isValidOfCustomSlotMethod(compId: string, slotId: string, methodId: string): boolean;
77
99
  callMethod(id: string, instance: string, inputs: Inputs): Promise<any>;
78
100
  private callElementMethod;
79
101
  private callRefMethod;
@@ -1 +1 @@
1
- export declare const initCode = "\nlet __events__ = {}\n\nfunction __onEventV1__(id, callback) {\n if (typeof(id) !== 'string' || !id) {\n return\n }\n if (typeof(callback) !== 'function') {\n return\n }\n if (!__events__[id]) {\n __events__[id] = []\n }\n const callbacks = __events__[id]\n for (let i = 0; i < callbacks.length; i++) {\n if (callbacks[i] === callback) {\n return\n }\n }\n callbacks.push(callback)\n}\n\nasync function __triggerEventInner__(id, ...params) {\n if (typeof(id) !== 'string' || !id) {\n return\n }\n if (!__events__[id]) {\n return\n }\n const callbacks = __events__[id]\n if (!callbacks) {\n return\n }\n for (let i = 0; i < callbacks.length; i++) {\n await callbacks[i](...params)\n }\n}\n\nlet __timers__ = {}\nlet __currTimerId__ = 0\n\nfunction __createTimerV1__(interval, loop, count, immediate, callback) {\n if (!loop && count <= 0) {\n return\n }\n const timer = {}\n timer.id = __currTimerId__++\n timer.interval = interval\n timer.loop = loop\n timer.count = count\n timer.immediate = immediate\n timer.callback = callback\n __timers__[timer.id] = timer\n if (timer.immediate) {\n __timeoutCallbackV1__(timer.id)\n } else {\n __timeoutV1__(timer.id, timer.interval)\n }\n}\n\nasync function __timeoutCallback__(timerId) {\n const timer = __timers__[timerId]\n if (timer) {\n timer.callback()\n // \u4FEE\u6539\u8BA1\u6570\n if (!timer.loop) {\n timer.count = timer.count - 1\n }\n // \u89E6\u53D1\u8D85\u65F6\n if (timer.loop || timer.count > 0) {\n await __timeoutV1__(timer.id, timer.interval)\n }\n // \u56DE\u6536\n if (!timer.loop && timer.count <= 0) {\n delete __timers__[timer.id]\n }\n }\n}\n\nfunction __destroy__() {\n __events__ = {}\n __timers__ = {}\n}\n";
1
+ export declare const initCode = "\nlet __events__ = {}\n\nfunction __onEventV1__(id, callback) {\n if (typeof(id) !== 'string' || !id) {\n return\n }\n if (typeof(callback) !== 'function') {\n return\n }\n if (!__events__[id]) {\n __events__[id] = []\n }\n const callbacks = __events__[id]\n for (let i = 0; i < callbacks.length; i++) {\n if (callbacks[i] === callback) {\n return\n }\n }\n callbacks.push(callback)\n}\n\nasync function __triggerEventInner__(id, params, instance) {\n if (!__events__[id]) {\n return\n }\n const callbacks = __events__[id]\n if (!callbacks) {\n return\n }\n for (let i = 0; i < callbacks.length; i++) {\n await callbacks[i](params, instance)\n }\n}\n\nlet __timers__ = {}\nlet __currTimerId__ = 0\n\nfunction __createTimerV1__(interval, loop, count, immediate, callback) {\n if (!loop && count <= 0) {\n return\n }\n const timer = {}\n timer.id = __currTimerId__++\n timer.interval = interval\n timer.loop = loop\n timer.count = count\n timer.immediate = immediate\n timer.callback = callback\n __timers__[timer.id] = timer\n if (timer.immediate) {\n __timeoutCallbackV1__(timer.id)\n } else {\n __timeoutV1__(timer.id, timer.interval)\n }\n}\n\nasync function __timeoutCallback__(timerId) {\n const timer = __timers__[timerId]\n if (timer) {\n timer.callback()\n // \u4FEE\u6539\u8BA1\u6570\n if (!timer.loop) {\n timer.count = timer.count - 1\n }\n // \u89E6\u53D1\u8D85\u65F6\n if (timer.loop || timer.count > 0) {\n await __timeoutV1__(timer.id, timer.interval)\n }\n // \u56DE\u6536\n if (!timer.loop && timer.count <= 0) {\n delete __timers__[timer.id]\n }\n }\n}\n\nfunction __destroy__() {\n __events__ = {}\n __timers__ = {}\n}\n";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-runtime-lib",
3
3
  "private": false,
4
- "version": "0.8.199",
4
+ "version": "0.8.201",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -33,8 +33,7 @@
33
33
  "three": "^0.182.0",
34
34
  "vue": "^3.5.27",
35
35
  "vue-i18n": "^11.2.8",
36
- "vuetify": "^3.11.7",
37
- "x-block-lib": "link:../x-block-lib"
36
+ "vuetify": "^3.11.7"
38
37
  },
39
38
  "peerDependencies": {
40
39
  "x-error-lib": "^0.5.13",