x-runtime-lib 0.8.198 → 0.8.200

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.
@@ -1,2 +1,2 @@
1
- import { NodePair } from "@/types";
1
+ import { NodePair } from '@/types';
2
2
  export declare function spawn(type: string, subtype: string): NodePair | undefined;
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";
@@ -1500,7 +1500,7 @@ function useElementSlotProperty(e, p, m, g) {
1500
1500
  }), onUnmounted(() => {
1501
1501
  e.eventBus.off(`property/${m}/get`, _), e.eventBus.off(`property/${m}/set`, v);
1502
1502
  }), watch(g, (g, _) => {
1503
- e.hooks.onPropertyChange(makePropertyId("elementAdaptSlotProperty", "globality", makePropertyKeyOfElementSlot(p.value.basic.key, e.slotId, m)), g, _, e.instance), e.parent && e.parent.hooks.onPropertyChange(makePropertyId("elementSlotProperty", e.nodeId, makePropertyKeyOfElementSlot(p.value.basic.key, e.slotId, m)), g, _, e.instance);
1503
+ e.hooks.onPropertyChange(makePropertyId("elementAdaptSlotProperty", "globality", makePropertyKeyOfElementSlot(p.value.basic.key, e.slotId, m)), g, _, e.instance);
1504
1504
  }, { immediate: !0 });
1505
1505
  }
1506
1506
  function useElementSlotRender(e, p, m) {
@@ -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 && (await this.parent.triggerEvent(makeEventId("refEvent", this.nodeId, m), p), await this.parent.triggerEvent(makeEventId("multipleRefEvent", this.nodeId, m), p, this.instance));
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,17 +10901,16 @@ 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);
10777
10912
  if (!v) throw Error("node not found");
10778
10913
  if (m === "elementProperty") return await this.getElementProperty(e, v, _);
10779
- if (m === "elementSlotProperty") return await this.getElementSlotProperty(e, g, _);
10780
- if (m === "multipleElementSlotProperty") return await this.getMultipleElementSlotProperty(e, g, _, p);
10781
10914
  if (m === "refProperty") return await this.getRefProperty(e, g, _);
10782
10915
  if (m === "multipleRefProperty") return await this.getMultipleRefProperty(e, g, _, p);
10783
10916
  if (m === "customSlotProperty") return await this.getCustomSlotProperty(e, g, _);
@@ -10791,21 +10924,6 @@ var PromiseManager = class {
10791
10924
  if (!this.isValidOfElementProperty(p.basic.key, m)) throw console.warn(`Sandbox/getElementProperty invalid element property id=${e}`), Error("invalid element property");
10792
10925
  return getField(p, m);
10793
10926
  }
10794
- async getElementSlotProperty(e, p, m) {
10795
- let { elementKey: g, slotKey: _, propertyKey: v } = unwrapPropertyKeyOfElementSlot(m), y = this.children[`${p}/${_}`];
10796
- if (!y) throw Error("sandbox not found");
10797
- if (!y.isValidOfElementSlotProperty(g, _, v)) throw console.warn(`Sandbox/getElementSlotProperty invalid element slot property id=${e}`), Error("invalid element slot property");
10798
- let b = { value: void 0 };
10799
- return y.eventBus.emit(`property/${v}/get`, { result: b }), b.value;
10800
- }
10801
- async getMultipleElementSlotProperty(e, p, m, g) {
10802
- if (!g) throw Error("instance not available");
10803
- let { elementKey: _, slotKey: v, propertyKey: y } = unwrapPropertyKeyOfElementSlot(m), b = this.children[`${p}/${v}/${g}`];
10804
- if (!b) throw Error("sandbox not found");
10805
- if (!b.isValidOfElementSlotProperty(_, v, y)) throw console.warn(`Sandbox/getMultipleElementSlotProperty invalid element slot property id=${e}`), Error("invalid element slot property");
10806
- let x = { value: void 0 };
10807
- return b.eventBus.emit(`property/${y}/get`, { result: x }), x.value;
10808
- }
10809
10927
  async getRefProperty(e, p, m) {
10810
10928
  let g = this.children[p];
10811
10929
  if (!g) throw Error("sandbox not found");
@@ -10820,17 +10938,19 @@ var PromiseManager = class {
10820
10938
  return _.customProperties[m];
10821
10939
  }
10822
10940
  async getCustomSlotProperty(e, p, m) {
10823
- let { slotId: g, propertyId: _ } = unwrapPropertyKeyOfCustomSlot(m), v = this.children[p];
10824
- if (!v) throw Error("sandbox not found");
10825
- if (!v.isValidOfCustomSlotProperty(g, _)) throw console.warn(`Sandbox/getCustomSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10826
- 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];
10827
10946
  }
10828
10947
  async getMultipleCustomSlotProperty(e, p, m, g) {
10829
10948
  if (!g) throw Error("instance not available");
10830
- let { slotId: _, propertyId: v } = unwrapPropertyKeyOfCustomSlot(m), y = this.children[`${p}/${g}`];
10831
- if (!y) throw Error("sandbox not found");
10832
- if (!y.isValidOfCustomSlotProperty(_, v)) throw console.warn(`Sandbox/getMultipleCustomSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10833
- 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];
10834
10954
  }
10835
10955
  async getCustomProperty(e, p) {
10836
10956
  if (!this.isValidOfCustomProperty(p)) throw console.warn(`Sandbox/getCustomProperty invalid custom property id=${e}`), Error("invalid custom property");
@@ -10845,16 +10965,14 @@ var PromiseManager = class {
10845
10965
  }
10846
10966
  async getCustomAdaptSlotProperty(e, p) {
10847
10967
  if (!this.parent) throw Error("not in slot");
10848
- let { slotId: m, propertyId: g } = unwrapPropertyKeyOfCustomSlot(p);
10849
- if (!this.isValidOfCustomSlotProperty(m, g)) throw console.warn(`Sandbox/getCustomAdaptSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10850
- 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[_];
10851
10971
  }
10852
10972
  async setProperty(e, p, m) {
10853
10973
  let { kind: g, nodeId: v, propertyKey: y } = unwrapPropertyId(e), b = this.getNode(v);
10854
10974
  if (!b) throw Error("node not found");
10855
10975
  if (p = cloneDeep_default(p), g === "elementProperty") await this.setElementProperty(e, p, y, b);
10856
- else if (g === "elementSlotProperty") await this.setElementSlotProperty(e, p, v, y);
10857
- else if (g === "multipleElementSlotProperty") await this.setMultipleElementSlotProperty(e, p, v, y, m);
10858
10976
  else if (g === "refProperty") await this.setRefProperty(e, p, v, y);
10859
10977
  else if (g === "multipleRefProperty") await this.setMultipleRefProperty(e, p, v, y, m);
10860
10978
  else if (g === "customSlotProperty") await this.setCustomSlotProperty(e, p, v, y);
@@ -10870,25 +10988,6 @@ var PromiseManager = class {
10870
10988
  let v = getField(_, m);
10871
10989
  isEqual_default(p, v) || (setField(_, m, p), this.hooks.onPropertyChange(e, p, v));
10872
10990
  }
10873
- async setElementSlotProperty(e, p, m, _) {
10874
- let { elementKey: v, slotKey: y, propertyKey: b } = unwrapPropertyKeyOfElementSlot(_), x = this.children[`${m}/${y}`];
10875
- if (!x) throw Error("sandbox not found");
10876
- if (!x.isValidOfElementSlotProperty(v, y, b)) throw console.warn(`Sandbox/setElementSlotProperty invalid element slot property id=${e}`), Error("invalid element slot property");
10877
- let S = { value: void 0 };
10878
- x.eventBus.emit(`property/${b}/get`, { result: S });
10879
- let C = S.value;
10880
- isEqual_default(p, C) || x.eventBus.emit(`property/${b}/set`, p);
10881
- }
10882
- async setMultipleElementSlotProperty(e, p, m, _, v) {
10883
- if (!v) throw Error("instance not available");
10884
- let { elementKey: y, slotKey: b, propertyKey: x } = unwrapPropertyKeyOfElementSlot(_), S = this.children[`${m}/${b}/${v}`];
10885
- if (!S) throw Error("sandbox not found");
10886
- if (!S.isValidOfElementSlotProperty(y, b, x)) throw console.warn(`Sandbox/setMultipleElementSlotProperty invalid element slot property id=${e}`), Error("invalid element slot property");
10887
- let C = { value: void 0 };
10888
- S.eventBus.emit(`property/${x}/get`, { result: C });
10889
- let w = C.value;
10890
- isEqual_default(p, w) || S.eventBus.emit(`property/${x}/set`, p);
10891
- }
10892
10991
  async setRefProperty(e, p, m, _) {
10893
10992
  let v = this.children[m];
10894
10993
  if (!v) throw Error("sandbox not found");
@@ -10905,19 +11004,21 @@ var PromiseManager = class {
10905
11004
  isEqual_default(p, b) || (y.customProperties[_] = p, y.hooks.onPropertyChange(makePropertyId("customProperty", "globality", _), p, b, v), this.hooks.onPropertyChange(e, p, b, v));
10906
11005
  }
10907
11006
  async setCustomSlotProperty(e, p, m, _) {
10908
- let { slotId: v, propertyId: y } = unwrapPropertyKeyOfCustomSlot(_), b = this.children[m];
10909
- if (!b) throw Error("sandbox not found");
10910
- if (!b.isValidOfCustomSlotProperty(v, y)) throw console.warn(`Sandbox/setCustomSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10911
- let x = b.customSlotProperties[y];
10912
- 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));
10913
11013
  }
10914
11014
  async setMultipleCustomSlotProperty(e, p, m, _, v) {
10915
11015
  if (!v) throw Error("instance not available");
10916
- let { slotId: y, propertyId: b } = unwrapPropertyKeyOfCustomSlot(_), x = this.children[`${m}/${v}`];
10917
- if (!x) throw Error("sandbox not found");
10918
- if (!x.isValidOfCustomSlotProperty(y, b)) throw console.warn(`Sandbox/setMultipleCustomSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10919
- let S = x.customSlotProperties[b];
10920
- 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));
10921
11022
  }
10922
11023
  async setCustomProperty(e, p, m) {
10923
11024
  if (!this.isValidOfCustomProperty(m)) throw console.warn(`Sandbox/setCustomProperty invalid custom property id=${e}`), Error("invalid custom property");
@@ -10935,10 +11036,10 @@ var PromiseManager = class {
10935
11036
  }
10936
11037
  async setCustomAdaptSlotProperty(e, p, m) {
10937
11038
  if (!this.parent) throw Error("not in slot");
10938
- let { slotId: _, propertyId: v } = unwrapPropertyKeyOfCustomSlot(m);
10939
- if (!this.isValidOfCustomSlotProperty(_, v)) throw console.warn(`Sandbox/setCustomAdaptSlotProperty invalid custom slot property id=${e}`), Error("invalid custom slot property");
10940
- let y = this.customSlotProperties[v];
10941
- 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));
10942
11043
  }
10943
11044
  isValidOfElementMethod(e, p) {
10944
11045
  let m = getElement(e);
@@ -10953,23 +11054,22 @@ var PromiseManager = class {
10953
11054
  isValidOfCustomMethod(e) {
10954
11055
  return this.meta.value ? !!this.meta.value.methods?.find((p) => p.id === e) : !1;
10955
11056
  }
10956
- isValidOfCustomSlotMethod(e, p) {
10957
- if (!this.meta.value) return !1;
10958
- let m = this.meta.value.slots?.find((p) => p.id === e);
10959
- 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);
10960
11062
  }
10961
11063
  async callMethod(e, p, m) {
10962
11064
  this.debugTrace(makeFuncInfo("callMethod", e, p, m));
10963
11065
  let { kind: g, nodeId: _, methodKey: v } = unwrapMethodId(e), y = this.getNode(_);
10964
11066
  if (!y) throw Error("node not found");
10965
- if (g === "elementMethod") await this.callElementMethod(e, m, y.basic.key, v);
10966
- else if (g === "elementSlotMethod") await this.callElementSlotMethod(e, m, _, v);
10967
- else if (g === "multipeElementSlotMethod") await this.callMultipleElementSlotMethod(e, p, m, _, v);
10968
- else if (g === "refMethod") await this.callRefMethod(e, m, _, v);
10969
- else if (g === "multipleRefMethod") await this.callMultipleRefMethod(e, p, m, _, v);
10970
- else if (g === "elementAdaptSlotMethod") await this.callElementAdaptSlotMethod(e, m, v);
10971
- else if (g === "customAdaptSlotMethod") await this.callCustomAdaptSlotMethod(e, m, v);
10972
- else throw Error("not implemented method kind");
11067
+ if (g === "elementMethod") return await this.callElementMethod(e, m, y.basic.key, v);
11068
+ if (g === "refMethod") return await this.callRefMethod(e, m, _, v);
11069
+ if (g === "multipleRefMethod") return await this.callMultipleRefMethod(e, p, m, _, v);
11070
+ if (g === "elementAdaptSlotMethod") return await this.callElementAdaptSlotMethod(e, m, v);
11071
+ if (g === "customAdaptSlotMethod") return await this.callCustomAdaptSlotMethod(e, m, v);
11072
+ throw Error("not implemented method kind");
10973
11073
  }
10974
11074
  async callElementMethod(e, p, m, g) {
10975
11075
  if (!this.isValidOfElementMethod(m, g)) throw console.log(`Sandbox/callElementMethod invalid element method id=${e}`), Error("invalid element method");
@@ -10980,27 +11080,6 @@ var PromiseManager = class {
10980
11080
  outputs: _
10981
11081
  }), _;
10982
11082
  }
10983
- async callElementSlotMethod(e, p, m, g) {
10984
- let { elementKey: _, slotKey: v, methodKey: y } = unwrapMethodKeyOfElementSlot(g), b = this.children[`${m}/${v}`];
10985
- if (!b) throw Error("sandbox not found");
10986
- if (!b.isValidOfElementSlotMethod(_, v, y)) throw console.warn(`Sandbox/callElementSlotMethod invalid element slot method id=${e}`), Error("invalid element slot method");
10987
- let x = {};
10988
- return b.eventBus.emit(`method/${y}`, {
10989
- inputs: p,
10990
- outputs: x
10991
- }), x;
10992
- }
10993
- async callMultipleElementSlotMethod(e, p, m, g, _) {
10994
- if (!p) throw Error("instance not available");
10995
- let { elementKey: v, slotKey: y, methodKey: b } = unwrapMethodKeyOfElementSlot(_), x = this.children[`${g}/${y}/${p}`];
10996
- if (!x) throw Error("sandbox not found");
10997
- if (!x.isValidOfElementSlotMethod(v, y, b)) throw console.warn(`Sandbox/callMultipleElementSlotMethod invalid element slot method id=${e}`), Error("invalid element slot method");
10998
- let S = {};
10999
- return x.eventBus.emit(`method/${b}`, {
11000
- inputs: m,
11001
- outputs: S
11002
- }), S;
11003
- }
11004
11083
  async callRefMethod(e, p, m, g) {
11005
11084
  let _ = this.children[m];
11006
11085
  if (!_) throw Error("sandbox not found");
@@ -11019,15 +11098,16 @@ var PromiseManager = class {
11019
11098
  let { elementKey: g, slotKey: _, methodKey: v } = unwrapMethodKeyOfElementSlot(m);
11020
11099
  if (!this.isValidOfElementSlotMethod(g, _, v)) throw console.warn(`Sandbox/callElementAdaptSlotMethod invalid element slot method id=${e}`), Error("invalid element slot method");
11021
11100
  let y = {};
11022
- return this.eventBus.emit(`method/${_}/${v}`, {
11101
+ return this.eventBus.emit(`method/${v}`, {
11102
+ instance: this.instance,
11023
11103
  inputs: p,
11024
11104
  outputs: y
11025
11105
  }), y;
11026
11106
  }
11027
11107
  async callCustomAdaptSlotMethod(e, p, m) {
11028
11108
  if (!this.parent) throw Error("not in slot");
11029
- let { slotId: g, methodId: _ } = unwrapMethodKeyOfCustomSlot(m);
11030
- 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");
11031
11111
  if (this.kind === "customSlot") return await this.parent.callFunctionAsync(getImplementMethodName("customSlotMethod", this.nodeId, m), "", p);
11032
11112
  if (this.kind === "multipleCustomSlot") return await this.parent.callFunctionAsync(getImplementMethodName("multipleCustomSlotMethod", this.nodeId, m), this.instance, p);
11033
11113
  throw Error("unexpected sandbox kind");
@@ -11049,35 +11129,35 @@ var PromiseManager = class {
11049
11129
  }
11050
11130
  };
11051
11131
  function useSandbox(e, p, m, _, v, y, b, x) {
11052
- 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();
11053
11133
  if (!isExecutableMode(w)) return { sandbox: void 0 };
11054
- let O = injectRuntime(), k = new Sandbox(e, p, m, _, v, S, C, w, T, {
11055
- onReady: j,
11056
- onDestroy: M,
11057
- onPropertyChange: N,
11058
- 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
11059
11139
  });
11060
- provideSandbox(k), onUnmounted(() => {
11061
- k.dispose();
11140
+ provideSandbox(A), onUnmounted(() => {
11141
+ A.dispose();
11062
11142
  });
11063
- let A = async () => {
11064
- 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));
11065
11145
  };
11066
- A(), watch([y, b], () => {
11067
- A();
11146
+ j(), watch([y, b], () => {
11147
+ j();
11068
11148
  });
11069
- async function j() {
11070
- await k.triggerEvent(makeEventId("elementEvent", "globality", "startup"), "");
11149
+ async function M() {
11150
+ await A.triggerEvent(makeEventId("elementEvent", "globality", "startup"), []);
11071
11151
  let e = calcBreakpoint(E.value.width), p = calcBreakpoint(E.value.width);
11072
- 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]);
11073
11153
  }
11074
- async function M() {
11075
- k.callFunctionSync("__destroy__");
11154
+ async function N() {
11155
+ A.callFunctionSync("__destroy__");
11076
11156
  }
11077
- async function N(e, p, m, _) {
11078
- if (!k.vm) return;
11157
+ async function P(e, p, m, _) {
11158
+ if (!A.vm) return;
11079
11159
  let { kind: v, nodeId: y, propertyKey: x } = unwrapPropertyId(e);
11080
- 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") {
11081
11161
  if (isEqual_default(x, toDotString(["settings", "slot"]))) {
11082
11162
  let e = b.value?.view.nodeLites.find((e) => e.id === y);
11083
11163
  e ? e.slotId = p : console.assert(!1);
@@ -11088,16 +11168,16 @@ function useSandbox(e, p, m, _, v, y, b, x) {
11088
11168
  }
11089
11169
  }
11090
11170
  }
11091
- async function P(e, p, m) {
11092
- 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));
11093
11173
  }
11094
11174
  return watch(E, async (e, p) => {
11095
- if (!k.vm) return;
11175
+ if (!A.vm) return;
11096
11176
  let m = calcBreakpoint(e.width), g = calcBreakpoint(p?.width ?? e.width);
11097
- await k.callFunctionAsync("__triggerEventV1__", makeEventId("elementEvent", "globality", "screenSizeChange"), "", m, g);
11177
+ A.triggerEvent(makeEventId("elementEvent", "globality", "screenSizeChange"), [m, g]);
11098
11178
  }), watch(D, async (e) => {
11099
- k.vm && await k.callFunctionAsync("__triggerEventV1__", makeEventId("elementEvent", "globality", "darkModeChange"), "", e);
11100
- }), { sandbox: k };
11179
+ A.vm && A.triggerEvent(makeEventId("elementEvent", "globality", "darkModeChange"), [e]);
11180
+ }), { sandbox: A };
11101
11181
  }
11102
11182
  function useTheme() {
11103
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,11 +73,9 @@ 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
- private getElementSlotProperty;
58
- private getMultipleElementSlotProperty;
59
79
  private getRefProperty;
60
80
  private getMultipleRefProperty;
61
81
  private getCustomSlotProperty;
@@ -65,8 +85,6 @@ export declare class Sandbox {
65
85
  private getCustomAdaptSlotProperty;
66
86
  setProperty(id: string, newValue: any, instance?: string): Promise<void>;
67
87
  private setElementProperty;
68
- private setElementSlotProperty;
69
- private setMultipleElementSlotProperty;
70
88
  private setRefProperty;
71
89
  private setMultipleRefProperty;
72
90
  private setCustomSlotProperty;
@@ -77,11 +95,9 @@ export declare class Sandbox {
77
95
  isValidOfElementMethod(elementKey: string, methodKey: string): boolean;
78
96
  isValidOfElementSlotMethod(elementKey: string, slotKey: string, methodKey: string): boolean;
79
97
  isValidOfCustomMethod(methodId: string): boolean;
80
- isValidOfCustomSlotMethod(slotId: string, methodId: string): boolean;
81
- callMethod(id: string, instance: string, inputs: Inputs): Promise<void>;
98
+ isValidOfCustomSlotMethod(compId: string, slotId: string, methodId: string): boolean;
99
+ callMethod(id: string, instance: string, inputs: Inputs): Promise<any>;
82
100
  private callElementMethod;
83
- private callElementSlotMethod;
84
- private callMultipleElementSlotMethod;
85
101
  private callRefMethod;
86
102
  private callMultipleRefMethod;
87
103
  private callElementAdaptSlotMethod;
@@ -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.198",
4
+ "version": "0.8.200",
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",