x-runtime-lib 0.8.203 → 0.8.205
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 +252 -235
- package/dist/sandbox/common/index.d.ts +22 -0
- package/dist/sandbox/sandbox/index.d.ts +29 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10437,6 +10437,28 @@ function _usingCtx() {
|
|
|
10437
10437
|
}
|
|
10438
10438
|
};
|
|
10439
10439
|
}
|
|
10440
|
+
const errors = {
|
|
10441
|
+
functionNotAvailable: /* @__PURE__ */ Error("func not available"),
|
|
10442
|
+
instanceNotAvailable: /* @__PURE__ */ Error("instance not available"),
|
|
10443
|
+
invalidCustomEvent: /* @__PURE__ */ Error("invalid custom event"),
|
|
10444
|
+
invalidCustomMethod: /* @__PURE__ */ Error("invalid custom method"),
|
|
10445
|
+
invalidCustomProperty: /* @__PURE__ */ Error("invalid custom property"),
|
|
10446
|
+
invalidCustomSlotEvent: /* @__PURE__ */ Error("invalid custom slot event"),
|
|
10447
|
+
invalidCustomSlotMethod: /* @__PURE__ */ Error("inavlid custom slot method"),
|
|
10448
|
+
invalidCustomSlotProperty: /* @__PURE__ */ Error("invalid custom slot property"),
|
|
10449
|
+
invalidElementEvent: /* @__PURE__ */ Error("invalid element event"),
|
|
10450
|
+
invalidElementMethod: /* @__PURE__ */ Error("invaild element method"),
|
|
10451
|
+
invalidElementProperty: /* @__PURE__ */ Error("invalid element property"),
|
|
10452
|
+
invalidElementSlotEvent: /* @__PURE__ */ Error("invalid element slot event"),
|
|
10453
|
+
invalidElementSlotMethod: /* @__PURE__ */ Error("invalid element slot method"),
|
|
10454
|
+
invalidElementSlotProperty: /* @__PURE__ */ Error("invalid element slot property"),
|
|
10455
|
+
invalidState: /* @__PURE__ */ Error("invalid state"),
|
|
10456
|
+
nodeNotFound: /* @__PURE__ */ Error("node not found"),
|
|
10457
|
+
notInSlot: /* @__PURE__ */ Error("not in slot"),
|
|
10458
|
+
sandboxNotFound: /* @__PURE__ */ Error("sandbox not found"),
|
|
10459
|
+
slotIncompatible: /* @__PURE__ */ Error("slot incompatible"),
|
|
10460
|
+
vmNotAvailable: /* @__PURE__ */ Error("vm not available")
|
|
10461
|
+
};
|
|
10440
10462
|
function newAny(e, p) {
|
|
10441
10463
|
if (p === void 0) return e.undefined;
|
|
10442
10464
|
if (p === null) return e.null;
|
|
@@ -10682,9 +10704,6 @@ var PromiseManager = class {
|
|
|
10682
10704
|
prepare(e, p, m, g) {
|
|
10683
10705
|
this.meta.value = e.value, this.data.value = p.value, this.depends.value = m.value, this.resetProperties(g), this.resetStates();
|
|
10684
10706
|
}
|
|
10685
|
-
getNode(e) {
|
|
10686
|
-
return this.data.value?.view.nodes[e];
|
|
10687
|
-
}
|
|
10688
10707
|
async createVm(e, p) {
|
|
10689
10708
|
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), this.data.value?.code.reactivity && await initReactivity(this, this.data.value?.code.reactivity), await nextTick(), this.hooks.onReady();
|
|
10690
10709
|
}
|
|
@@ -10693,22 +10712,22 @@ var PromiseManager = class {
|
|
|
10693
10712
|
}
|
|
10694
10713
|
setGlobalVariable(e, p) {
|
|
10695
10714
|
let { vm: m } = this;
|
|
10696
|
-
if (!m) throw
|
|
10715
|
+
if (!m) throw errors.vmNotAvailable;
|
|
10697
10716
|
m.setProp(m.global, e, newAny(m, p));
|
|
10698
10717
|
}
|
|
10699
10718
|
getGlobalVariable(e) {
|
|
10700
10719
|
let { vm: p } = this;
|
|
10701
|
-
if (!p) throw
|
|
10720
|
+
if (!p) throw errors.vmNotAvailable;
|
|
10702
10721
|
return p.getProp(p.global, e).consume((e) => p.dump(e));
|
|
10703
10722
|
}
|
|
10704
10723
|
callFunctionSync(e, ...p) {
|
|
10705
10724
|
try {
|
|
10706
10725
|
var m = _usingCtx();
|
|
10707
10726
|
let { vm: g } = this;
|
|
10708
|
-
if (!g) throw
|
|
10727
|
+
if (!g) throw errors.vmNotAvailable;
|
|
10709
10728
|
noTraceCallFuncs.includes(e) || this.debugTrace(makeFuncInfo(e, ...p));
|
|
10710
10729
|
let _ = m.u(g.getProp(g.global, e));
|
|
10711
|
-
if (g.typeof(_) !== "function") throw
|
|
10730
|
+
if (g.typeof(_) !== "function") throw errors.functionNotAvailable;
|
|
10712
10731
|
let v = p.map((e) => newAny(g, e)), y = g.unwrapResult(g.callFunction(_, g.undefined, ...v)).consume((e) => g.dump(e));
|
|
10713
10732
|
return v.forEach((e) => e.dispose()), y;
|
|
10714
10733
|
} catch (e) {
|
|
@@ -10721,10 +10740,10 @@ var PromiseManager = class {
|
|
|
10721
10740
|
try {
|
|
10722
10741
|
var m = _usingCtx();
|
|
10723
10742
|
let { vm: g } = this;
|
|
10724
|
-
if (!g) throw
|
|
10743
|
+
if (!g) throw errors.vmNotAvailable;
|
|
10725
10744
|
noTraceCallFuncs.includes(e) || this.debugTrace(makeFuncInfo(e, ...p));
|
|
10726
10745
|
let _ = m.u(g.getProp(g.global, e));
|
|
10727
|
-
if (g.typeof(_) !== "function") throw
|
|
10746
|
+
if (g.typeof(_) !== "function") throw errors.functionNotAvailable;
|
|
10728
10747
|
let v = p.map((e) => newAny(g, e)), y = g.unwrapResult(g.callFunction(_, g.undefined, ...v)).consume((e) => g.resolvePromise(e));
|
|
10729
10748
|
return g.runtime.executePendingJobs(), v.map((e) => e.dispose()), g.unwrapResult(await y).consume((e) => g.dump(e));
|
|
10730
10749
|
} catch (e) {
|
|
@@ -10733,173 +10752,24 @@ var PromiseManager = class {
|
|
|
10733
10752
|
m.d();
|
|
10734
10753
|
}
|
|
10735
10754
|
}
|
|
10736
|
-
|
|
10737
|
-
|
|
10738
|
-
return !m || !m.events ? !1 : !!m.events.find((e) => e.key === p);
|
|
10739
|
-
}
|
|
10740
|
-
isValidOfElementSlotEvent(e, p, m) {
|
|
10741
|
-
let g = getElement(e);
|
|
10742
|
-
if (!g || !g.slots) return !1;
|
|
10743
|
-
let _ = g.slots.find((e) => e.key === p);
|
|
10744
|
-
return !_ || !_.events ? !1 : !!_.events.find((e) => e.key === m);
|
|
10745
|
-
}
|
|
10746
|
-
isValidOfCustomEvent(e) {
|
|
10747
|
-
return this.meta.value ? !!this.meta.value.events?.find((p) => p.id === e) : !1;
|
|
10755
|
+
getNode(e) {
|
|
10756
|
+
return this.data.value?.view.nodes[e];
|
|
10748
10757
|
}
|
|
10749
|
-
|
|
10750
|
-
let
|
|
10758
|
+
isEqualOfElementSlot(e, p) {
|
|
10759
|
+
let m = this.getNode("globality");
|
|
10760
|
+
if (!m) return !1;
|
|
10761
|
+
let g = m.settings?.adaptSlot;
|
|
10751
10762
|
if (!g) return !1;
|
|
10752
|
-
let _
|
|
10753
|
-
return !_
|
|
10754
|
-
}
|
|
10755
|
-
async triggerEvent(e, p, m) {
|
|
10756
|
-
this.debugTrace("triggerEvent", e, p, m);
|
|
10757
|
-
let { kind: g, nodeId: _, eventKey: v } = unwrapEventId(e), y = this.getNode(_);
|
|
10758
|
-
if (!y) throw Error("node not found");
|
|
10759
|
-
if (g === "elementEvent") await this.triggerElementEvent(e, p, y, v);
|
|
10760
|
-
else if (g === "elementPropertyChangeEvent") await this.triggerElementPropertyChangeEvent(e, p, y, v);
|
|
10761
|
-
else if (g === "elementSlotEvent") await this.triggerElementSlotEvent(e, p, _, v);
|
|
10762
|
-
else if (g === "elementSlotPropertyChangeEvent") await this.triggerElementSlotPropertyChangeEvent(e, p, v);
|
|
10763
|
-
else if (g === "multipleElementSlotEvent") await this.triggerMultipleElementSlotEvent(e, p, _, v, m);
|
|
10764
|
-
else if (g === "multipleElementSlotPropertyChangeEvent") await this.triggerMultipleElementSlotPropertyChangeEvent(e, p, v, m);
|
|
10765
|
-
else if (g === "refEvent") await this.triggerRefEvent(e, p, _, v);
|
|
10766
|
-
else if (g === "refPropertyChangeEvent") await this.triggerRefPropertyChangeEvent(e, p, _, v);
|
|
10767
|
-
else if (g === "multipleRefEvent") await this.triggerMultipleRefEvent(e, p, _, v, m);
|
|
10768
|
-
else if (g === "multipleRefPropertyChangeEvent") await this.triggerMultipleRefPropertyChangeEvent(e, p, _, v, m);
|
|
10769
|
-
else if (g === "customSlotEvent") await this.triggerCustomSlotEvent(e, p, _, v);
|
|
10770
|
-
else if (g === "customSlotPropertyChangeEvent") await this.triggerCustomSlotPropertyChangeEvent(e, p, v);
|
|
10771
|
-
else if (g === "multipleCustomSlotEvent") await this.triggerMultipleCustomSlotEvent(e, p, _, v, m);
|
|
10772
|
-
else if (g === "multipleCustomSlotPropertyChangeEvent") await this.triggerMultipleCustomSlotPropertyChangeEvent(e, p, v, m);
|
|
10773
|
-
else if (g === "customEvent") await this.triggerCustomEvent(e, p, v);
|
|
10774
|
-
else if (g === "customPropertyChangeEvent") await this.triggerCustomPropertyChangeEvent(e, p, v);
|
|
10775
|
-
else if (g === "elementAdaptSlotEvent") await this.triggerElementAdaptSlotEvent(e, p, v);
|
|
10776
|
-
else if (g === "elementAdaptSlotPropertyChangeEvent") await this.triggerElementAdaptSlotPropertyChangeEvent(e, p, v);
|
|
10777
|
-
else if (g === "customAdaptSlotEvent") await this.triggerCustomAdaptSlotEvent(e, p, v);
|
|
10778
|
-
else if (g === "customAdaptSlotPropertyChangeEvent") await this.triggerCustomAdaptSlotPropertyChangeEvent(e, p, v);
|
|
10779
|
-
else if (g === "stateChangeEvent") await this.triggerStateChangeEvent(e, p, v);
|
|
10780
|
-
else throw Error("not implemented event kind");
|
|
10781
|
-
}
|
|
10782
|
-
async triggerElementEvent(e, p, m, g) {
|
|
10783
|
-
if (!this.isValidOfElementEvent(m.basic.key, g)) throw Error("invalid element event");
|
|
10784
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
10785
|
-
}
|
|
10786
|
-
async triggerElementPropertyChangeEvent(e, p, m, g) {
|
|
10787
|
-
if (!this.isValidOfElementProperty(m.basic.key, g)) throw Error("invalid element property");
|
|
10788
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
10789
|
-
}
|
|
10790
|
-
async triggerElementSlotEvent(e, p, m, g) {
|
|
10791
|
-
let { elementKey: _, slotKey: v, eventKey: y } = unwrapEventKeyOfElementSlot(g);
|
|
10792
|
-
if (!this.isValidOfElementSlotEvent(_, v, y)) throw Error("invalid element slot event");
|
|
10793
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
10794
|
-
let b = this.children[m];
|
|
10795
|
-
b && await b.triggerEvent(makeEventId("elementAdaptSlotEvent", "globality", g), p);
|
|
10796
|
-
}
|
|
10797
|
-
async triggerElementSlotPropertyChangeEvent(e, p, m) {
|
|
10798
|
-
let { elementKey: g, slotKey: _, eventKey: v } = unwrapEventKeyOfElementSlot(m);
|
|
10799
|
-
if (!this.isValidOfElementSlotProperty(g, _, v)) throw Error("invalid element slot property");
|
|
10800
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
10801
|
-
}
|
|
10802
|
-
async triggerMultipleElementSlotEvent(e, p, m, g, _) {
|
|
10803
|
-
if (!_) throw Error("instance not available");
|
|
10804
|
-
let { elementKey: v, slotKey: y, eventKey: b } = unwrapEventKeyOfElementSlot(g);
|
|
10805
|
-
if (!this.isValidOfElementSlotEvent(v, y, b)) throw Error("invalid element slot event");
|
|
10806
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p, _);
|
|
10807
|
-
let x = this.children[`${m}/${_}`];
|
|
10808
|
-
x && await x.triggerEvent(makeEventId("elementAdaptSlotEvent", "globality", g), p);
|
|
10809
|
-
}
|
|
10810
|
-
async triggerMultipleElementSlotPropertyChangeEvent(e, p, m, g) {
|
|
10811
|
-
if (!g) throw Error("instance not available");
|
|
10812
|
-
let { elementKey: _, slotKey: v, eventKey: y } = unwrapEventKeyOfElementSlot(m);
|
|
10813
|
-
if (!this.isValidOfElementSlotProperty(_, v, y)) throw Error("invalid element slot property");
|
|
10814
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p, g);
|
|
10815
|
-
}
|
|
10816
|
-
async triggerRefEvent(e, p, m, g) {
|
|
10817
|
-
let _ = this.children[m];
|
|
10818
|
-
if (!_) throw Error("sandbox not found");
|
|
10819
|
-
if (!_.isValidOfCustomEvent(g)) throw Error("invalid custom event");
|
|
10820
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
10763
|
+
let { kind: _, mainKey: v, slotKey: y } = unwrapSlotId(g);
|
|
10764
|
+
return !(_ !== "elementSlot" && _ !== "multipleElementSlot" || e !== v || p !== y);
|
|
10821
10765
|
}
|
|
10822
|
-
|
|
10823
|
-
let
|
|
10824
|
-
if (!
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
if (!_) throw Error("instance not available");
|
|
10830
|
-
let v = this.children[`${m}/${_}`];
|
|
10831
|
-
if (!v) throw Error("sandbox not found");
|
|
10832
|
-
if (!v.isValidOfCustomEvent(g)) throw Error("invalid custom event");
|
|
10833
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p, _);
|
|
10834
|
-
}
|
|
10835
|
-
async triggerMultipleRefPropertyChangeEvent(e, p, m, g, _) {
|
|
10836
|
-
if (!_) throw Error("instance not available");
|
|
10837
|
-
let v = this.children[`${m}/${_}`];
|
|
10838
|
-
if (!v) throw Error("sandbox not found");
|
|
10839
|
-
if (!v.isValidOfCustomProperty(g)) throw Error("invalid custom property");
|
|
10840
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p, _);
|
|
10841
|
-
}
|
|
10842
|
-
async triggerCustomSlotEvent(e, p, m, g) {
|
|
10843
|
-
let { compId: _, slotId: v, eventId: y } = unwrapEventKeyOfCustomSlot(g);
|
|
10844
|
-
if (!this.isValidOfCustomSlotEvent(_, v, y)) throw Error("invalid custom slot event");
|
|
10845
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
10846
|
-
let b = this.children[m];
|
|
10847
|
-
b && await b.triggerEvent(makeEventId("customAdaptSlotEvent", "globality", g), p);
|
|
10848
|
-
}
|
|
10849
|
-
async triggerCustomSlotPropertyChangeEvent(e, p, m) {
|
|
10850
|
-
let { compId: g, slotId: _, eventId: v } = unwrapEventKeyOfCustomSlot(m);
|
|
10851
|
-
if (!this.isValidOfCustomSlotProperty(g, _, v)) throw Error("invalid custom slot property");
|
|
10852
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
10853
|
-
}
|
|
10854
|
-
async triggerMultipleCustomSlotEvent(e, p, m, g, _) {
|
|
10855
|
-
if (!_) throw Error("instance not available");
|
|
10856
|
-
let { compId: v, slotId: y, eventId: b } = unwrapEventKeyOfCustomSlot(g);
|
|
10857
|
-
if (!this.isValidOfCustomSlotEvent(v, y, b)) throw Error("invalid custom slot event");
|
|
10858
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p, _);
|
|
10859
|
-
let x = this.children[`${m}/${_}`];
|
|
10860
|
-
x && await x.triggerEvent(makeEventId("customAdaptSlotEvent", "globality", g), p);
|
|
10861
|
-
}
|
|
10862
|
-
async triggerMultipleCustomSlotPropertyChangeEvent(e, p, m, g) {
|
|
10863
|
-
if (!g) throw Error("instance not available");
|
|
10864
|
-
let { compId: _, slotId: v, eventId: y } = unwrapEventKeyOfCustomSlot(m);
|
|
10865
|
-
if (!this.isValidOfCustomSlotProperty(_, v, y)) throw Error("invalid custom slot property");
|
|
10866
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p, g);
|
|
10867
|
-
}
|
|
10868
|
-
async triggerCustomEvent(e, p, m) {
|
|
10869
|
-
if (!this.isValidOfCustomEvent(m)) throw Error("invalid custom event");
|
|
10870
|
-
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));
|
|
10871
|
-
}
|
|
10872
|
-
async triggerCustomPropertyChangeEvent(e, p, m) {
|
|
10873
|
-
if (!this.isValidOfCustomProperty(m)) throw Error("invalid custom property");
|
|
10874
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
10875
|
-
}
|
|
10876
|
-
async triggerElementAdaptSlotEvent(e, p, m) {
|
|
10877
|
-
if (!this.parent) throw Error("not in slot");
|
|
10878
|
-
let { elementKey: g, slotKey: _, eventKey: v } = unwrapEventKeyOfElementSlot(m);
|
|
10879
|
-
if (!this.isValidOfElementSlotEvent(g, _, v)) throw Error("invalid element slot event");
|
|
10880
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
10881
|
-
}
|
|
10882
|
-
async triggerElementAdaptSlotPropertyChangeEvent(e, p, m) {
|
|
10883
|
-
if (!this.parent) throw Error("not in slot");
|
|
10884
|
-
let { elementKey: g, slotKey: _, eventKey: v } = unwrapEventKeyOfElementSlot(m);
|
|
10885
|
-
if (!this.isValidOfElementSlotProperty(g, _, v)) throw Error("invalid element slot property");
|
|
10886
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
10887
|
-
}
|
|
10888
|
-
async triggerCustomAdaptSlotEvent(e, p, m) {
|
|
10889
|
-
if (!this.parent) throw Error("not in slot");
|
|
10890
|
-
let { compId: g, slotId: _, eventId: v } = unwrapEventKeyOfCustomSlot(m);
|
|
10891
|
-
if (!this.isValidOfCustomSlotEvent(g, _, v)) throw Error("invalid custom slot event");
|
|
10892
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
10893
|
-
}
|
|
10894
|
-
async triggerCustomAdaptSlotPropertyChangeEvent(e, p, m) {
|
|
10895
|
-
if (!this.parent) throw Error("not in slot");
|
|
10896
|
-
let { compId: g, slotId: _, eventId: v } = unwrapEventKeyOfCustomSlot(m);
|
|
10897
|
-
if (!this.isValidOfCustomSlotProperty(g, _, v)) throw Error("invalid custom slot property");
|
|
10898
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
10899
|
-
}
|
|
10900
|
-
async triggerStateChangeEvent(e, p, m) {
|
|
10901
|
-
if (!this.isValidOfState(m)) throw Error("invalid state");
|
|
10902
|
-
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
10766
|
+
isEqualOfCustomSlot(e, p) {
|
|
10767
|
+
let m = this.getNode("globality");
|
|
10768
|
+
if (!m) return !1;
|
|
10769
|
+
let g = m.settings?.adaptSlot;
|
|
10770
|
+
if (!g) return !1;
|
|
10771
|
+
let { kind: _, mainKey: v, slotKey: y } = unwrapSlotId(g);
|
|
10772
|
+
return !(_ !== "customSlot" && _ !== "multipleCustomSlot" || e !== v || p !== y);
|
|
10903
10773
|
}
|
|
10904
10774
|
customProperties = {};
|
|
10905
10775
|
customSlotProperties = {};
|
|
@@ -10932,7 +10802,7 @@ var PromiseManager = class {
|
|
|
10932
10802
|
}
|
|
10933
10803
|
async getProperty(e, p) {
|
|
10934
10804
|
let { kind: m, nodeId: g, propertyKey: _ } = unwrapPropertyId(e), v = this.getNode(g);
|
|
10935
|
-
if (!v) throw
|
|
10805
|
+
if (!v) throw errors.nodeNotFound;
|
|
10936
10806
|
if (m === "elementProperty") return await this.getElementProperty(e, v, _);
|
|
10937
10807
|
if (m === "refProperty") return await this.getRefProperty(e, g, _);
|
|
10938
10808
|
if (m === "multipleRefProperty") return await this.getMultipleRefProperty(e, g, _, p);
|
|
@@ -10941,126 +10811,121 @@ var PromiseManager = class {
|
|
|
10941
10811
|
if (m === "customProperty") return await this.getCustomProperty(e, _);
|
|
10942
10812
|
if (m === "elementAdaptSlotProperty") return await this.getElementAdaptSlotProperty(e, _);
|
|
10943
10813
|
if (m === "customAdaptSlotProperty") return await this.getCustomAdaptSlotProperty(e, _);
|
|
10944
|
-
|
|
10814
|
+
console.assert(!1);
|
|
10945
10815
|
}
|
|
10946
10816
|
async getElementProperty(e, p, m) {
|
|
10947
|
-
if (!this.isValidOfElementProperty(p.basic.key, m)) throw console.warn(`Sandbox/getElementProperty invalid element property id=${e}`),
|
|
10817
|
+
if (!this.isValidOfElementProperty(p.basic.key, m)) throw console.warn(`Sandbox/getElementProperty invalid element property id=${e}`), errors.invalidElementProperty;
|
|
10948
10818
|
return getField(p, m);
|
|
10949
10819
|
}
|
|
10950
10820
|
async getRefProperty(e, p, m) {
|
|
10951
10821
|
let g = this.children[p];
|
|
10952
|
-
if (!g) throw
|
|
10953
|
-
if (!g.isValidOfCustomProperty(m)) throw console.warn(`Sandbox/getRefProperty invalid custom property id=${e}`),
|
|
10822
|
+
if (!g) throw errors.sandboxNotFound;
|
|
10823
|
+
if (!g.isValidOfCustomProperty(m)) throw console.warn(`Sandbox/getRefProperty invalid custom property id=${e}`), errors.invalidCustomProperty;
|
|
10954
10824
|
return g.customProperties[m];
|
|
10955
10825
|
}
|
|
10956
10826
|
async getMultipleRefProperty(e, p, m, g) {
|
|
10957
|
-
if (!g) throw
|
|
10827
|
+
if (!g) throw errors.instanceNotAvailable;
|
|
10958
10828
|
let _ = this.children[`${p}/${g}`];
|
|
10959
|
-
if (!_) throw
|
|
10960
|
-
if (!_.isValidOfCustomProperty(m)) throw console.warn(`Sandbox/getMultipleRefProperty invalid custom property id=${e}`),
|
|
10829
|
+
if (!_) throw errors.sandboxNotFound;
|
|
10830
|
+
if (!_.isValidOfCustomProperty(m)) throw console.warn(`Sandbox/getMultipleRefProperty invalid custom property id=${e}`), errors.invalidCustomProperty;
|
|
10961
10831
|
return _.customProperties[m];
|
|
10962
10832
|
}
|
|
10963
10833
|
async getCustomSlotProperty(e, p, m) {
|
|
10964
10834
|
let { compId: g, slotId: _, propertyId: v } = unwrapPropertyKeyOfCustomSlot(m);
|
|
10965
|
-
if (!this.isValidOfCustomSlotProperty(g, _, v)) throw console.warn(`Sandbox/getCustomSlotProperty invalid custom slot property id=${e}`),
|
|
10835
|
+
if (!this.isValidOfCustomSlotProperty(g, _, v)) throw console.warn(`Sandbox/getCustomSlotProperty invalid custom slot property id=${e}`), errors.invalidCustomSlotProperty;
|
|
10966
10836
|
let y = this.children[p];
|
|
10967
|
-
if (!y) throw
|
|
10837
|
+
if (!y) throw errors.sandboxNotFound;
|
|
10968
10838
|
return y.customSlotProperties[v];
|
|
10969
10839
|
}
|
|
10970
10840
|
async getMultipleCustomSlotProperty(e, p, m, g) {
|
|
10971
|
-
if (!g) throw
|
|
10841
|
+
if (!g) throw errors.instanceNotAvailable;
|
|
10972
10842
|
let { compId: _, slotId: v, propertyId: y } = unwrapPropertyKeyOfCustomSlot(m);
|
|
10973
|
-
if (!this.isValidOfCustomSlotProperty(_, v, y)) throw console.warn(`Sandbox/getMultipleCustomSlotProperty invalid custom slot property id=${e}`),
|
|
10843
|
+
if (!this.isValidOfCustomSlotProperty(_, v, y)) throw console.warn(`Sandbox/getMultipleCustomSlotProperty invalid custom slot property id=${e}`), errors.invalidCustomSlotProperty;
|
|
10974
10844
|
let b = this.children[`${p}/${g}`];
|
|
10975
|
-
if (!b) throw
|
|
10845
|
+
if (!b) throw errors.sandboxNotFound;
|
|
10976
10846
|
return b.customSlotProperties[y];
|
|
10977
10847
|
}
|
|
10978
10848
|
async getCustomProperty(e, p) {
|
|
10979
|
-
if (!this.isValidOfCustomProperty(p)) throw console.warn(`Sandbox/getCustomProperty invalid custom property id=${e}`),
|
|
10849
|
+
if (!this.isValidOfCustomProperty(p)) throw console.warn(`Sandbox/getCustomProperty invalid custom property id=${e}`), errors.invalidCustomProperty;
|
|
10980
10850
|
return this.customProperties[p];
|
|
10981
10851
|
}
|
|
10982
10852
|
async getElementAdaptSlotProperty(e, p) {
|
|
10983
|
-
if (!this.parent) throw
|
|
10853
|
+
if (!this.parent) throw errors.notInSlot;
|
|
10984
10854
|
let { elementKey: m, slotKey: g, propertyKey: _ } = unwrapPropertyKeyOfElementSlot(p);
|
|
10985
|
-
if (!this.
|
|
10855
|
+
if (!this.isEqualOfElementSlot(m, g)) throw errors.slotIncompatible;
|
|
10856
|
+
if (!this.isValidOfElementSlotProperty(m, g, _)) throw console.warn(`Sandbox/getElementAdaptSlotProperty invalid element slot property id=${e}`), errors.invalidElementSlotProperty;
|
|
10986
10857
|
let v = { value: void 0 };
|
|
10987
|
-
return this.eventBus.emit(`property/${
|
|
10858
|
+
return this.eventBus.emit(`property/${_}/get`, { result: v }), v.value;
|
|
10988
10859
|
}
|
|
10989
10860
|
async getCustomAdaptSlotProperty(e, p) {
|
|
10990
|
-
if (!this.parent) throw
|
|
10861
|
+
if (!this.parent) throw errors.notInSlot;
|
|
10991
10862
|
let { compId: m, slotId: g, propertyId: _ } = unwrapPropertyKeyOfCustomSlot(p);
|
|
10992
|
-
if (!this.
|
|
10863
|
+
if (!this.isEqualOfCustomSlot(m, g)) throw errors.slotIncompatible;
|
|
10864
|
+
if (!this.isValidOfCustomSlotProperty(m, g, _)) throw console.warn(`Sandbox/getCustomAdaptSlotProperty invalid custom slot property id=${e}`), errors.invalidCustomSlotProperty;
|
|
10993
10865
|
return this.customSlotProperties[_];
|
|
10994
10866
|
}
|
|
10995
10867
|
async setProperty(e, p, m) {
|
|
10996
10868
|
let { kind: g, nodeId: v, propertyKey: y } = unwrapPropertyId(e), b = this.getNode(v);
|
|
10997
|
-
if (!b) throw
|
|
10998
|
-
|
|
10999
|
-
else if (g === "refProperty") await this.setRefProperty(e, p, v, y);
|
|
11000
|
-
else if (g === "multipleRefProperty") await this.setMultipleRefProperty(e, p, v, y, m);
|
|
11001
|
-
else if (g === "customSlotProperty") await this.setCustomSlotProperty(e, p, v, y);
|
|
11002
|
-
else if (g === "multipleCustomSlotProperty") await this.setMultipleCustomSlotProperty(e, p, v, y, m);
|
|
11003
|
-
else if (g === "customProperty") await this.setCustomProperty(e, p, y);
|
|
11004
|
-
else if (g === "elementAdaptSlotProperty") await this.setElementAdaptSlotProperty(e, p, y);
|
|
11005
|
-
else if (g === "customAdaptSlotProperty") await this.setCustomAdaptSlotProperty(e, p, y);
|
|
11006
|
-
else throw Error("not implemented property kind");
|
|
11007
|
-
await nextTick();
|
|
10869
|
+
if (!b) throw errors.nodeNotFound;
|
|
10870
|
+
p = cloneDeep_default(p), g === "elementProperty" ? await this.setElementProperty(e, p, y, b) : g === "refProperty" ? await this.setRefProperty(e, p, v, y) : g === "multipleRefProperty" ? await this.setMultipleRefProperty(e, p, v, y, m) : g === "customSlotProperty" ? await this.setCustomSlotProperty(e, p, v, y) : g === "multipleCustomSlotProperty" ? await this.setMultipleCustomSlotProperty(e, p, v, y, m) : g === "customProperty" ? await this.setCustomProperty(e, p, y) : g === "elementAdaptSlotProperty" ? await this.setElementAdaptSlotProperty(e, p, y) : g === "customAdaptSlotProperty" ? await this.setCustomAdaptSlotProperty(e, p, y) : console.assert(!1), await nextTick();
|
|
11008
10871
|
}
|
|
11009
10872
|
async setElementProperty(e, p, m, _) {
|
|
11010
|
-
if (!this.isValidOfElementProperty(_.basic.key, m)) throw console.warn(`Sandbox/setElementProperty invalid element property id=${e}`),
|
|
10873
|
+
if (!this.isValidOfElementProperty(_.basic.key, m)) throw console.warn(`Sandbox/setElementProperty invalid element property id=${e}`), errors.invalidElementProperty;
|
|
11011
10874
|
let v = getField(_, m);
|
|
11012
10875
|
isEqual_default(p, v) || (setField(_, m, p), this.hooks.onPropertyChange(e, p, v));
|
|
11013
10876
|
}
|
|
11014
10877
|
async setRefProperty(e, p, m, _) {
|
|
11015
10878
|
let v = this.children[m];
|
|
11016
|
-
if (!v) throw
|
|
11017
|
-
if (!v.isValidOfCustomProperty(_)) throw console.warn(`Sandbox/setRefProperty invalid custom property id=${e}`),
|
|
10879
|
+
if (!v) throw errors.sandboxNotFound;
|
|
10880
|
+
if (!v.isValidOfCustomProperty(_)) throw console.warn(`Sandbox/setRefProperty invalid custom property id=${e}`), errors.invalidCustomProperty;
|
|
11018
10881
|
let y = v.customProperties[_];
|
|
11019
10882
|
isEqual_default(p, y) || (v.customProperties[_] = p, v.hooks.onPropertyChange(makePropertyId("customProperty", "globality", _), p, y), this.hooks.onPropertyChange(e, p, y));
|
|
11020
10883
|
}
|
|
11021
10884
|
async setMultipleRefProperty(e, p, m, _, v) {
|
|
11022
|
-
if (!v) throw
|
|
10885
|
+
if (!v) throw errors.instanceNotAvailable;
|
|
11023
10886
|
let y = this.children[`${m}/${v}`];
|
|
11024
|
-
if (!y) throw
|
|
11025
|
-
if (!y.isValidOfCustomProperty(_)) throw console.warn(`Sandbox/setMultipleRefProperty invalid custom property id=${e}`),
|
|
10887
|
+
if (!y) throw errors.sandboxNotFound;
|
|
10888
|
+
if (!y.isValidOfCustomProperty(_)) throw console.warn(`Sandbox/setMultipleRefProperty invalid custom property id=${e}`), errors.invalidCustomProperty;
|
|
11026
10889
|
let b = y.customProperties[_];
|
|
11027
10890
|
isEqual_default(p, b) || (y.customProperties[_] = p, y.hooks.onPropertyChange(makePropertyId("customProperty", "globality", _), p, b, v), this.hooks.onPropertyChange(e, p, b, v));
|
|
11028
10891
|
}
|
|
11029
10892
|
async setCustomSlotProperty(e, p, m, _) {
|
|
11030
10893
|
let { compId: v, slotId: y, propertyId: b } = unwrapPropertyKeyOfCustomSlot(_);
|
|
11031
|
-
if (!this.isValidOfCustomSlotProperty(v, y, b)) throw console.warn(`Sandbox/setCustomSlotProperty invalid custom slot property id=${e}`),
|
|
10894
|
+
if (!this.isValidOfCustomSlotProperty(v, y, b)) throw console.warn(`Sandbox/setCustomSlotProperty invalid custom slot property id=${e}`), errors.invalidCustomSlotProperty;
|
|
11032
10895
|
let x = this.children[m];
|
|
11033
|
-
if (!x) throw
|
|
10896
|
+
if (!x) throw errors.sandboxNotFound;
|
|
11034
10897
|
let S = x.customSlotProperties[b];
|
|
11035
10898
|
isEqual_default(p, S) || (x.customSlotProperties[b] = p, x.hooks.onPropertyChange(makePropertyId("customAdaptSlotProperty", "globality", _), p, S), this.hooks.onPropertyChange(e, p, S));
|
|
11036
10899
|
}
|
|
11037
10900
|
async setMultipleCustomSlotProperty(e, p, m, _, v) {
|
|
11038
|
-
if (!v) throw
|
|
10901
|
+
if (!v) throw errors.instanceNotAvailable;
|
|
11039
10902
|
let { compId: y, slotId: b, propertyId: x } = unwrapPropertyKeyOfCustomSlot(_);
|
|
11040
|
-
if (!this.isValidOfCustomSlotProperty(y, b, x)) throw console.warn(`Sandbox/setMultipleCustomSlotProperty invalid custom slot property id=${e}`),
|
|
10903
|
+
if (!this.isValidOfCustomSlotProperty(y, b, x)) throw console.warn(`Sandbox/setMultipleCustomSlotProperty invalid custom slot property id=${e}`), errors.invalidCustomSlotProperty;
|
|
11041
10904
|
let S = this.children[`${m}/${v}`];
|
|
11042
|
-
if (!S) throw
|
|
10905
|
+
if (!S) throw errors.sandboxNotFound;
|
|
11043
10906
|
let C = S.customSlotProperties[x];
|
|
11044
10907
|
isEqual_default(p, C) || (S.customSlotProperties[x] = p, S.hooks.onPropertyChange(makePropertyId("customAdaptSlotProperty", "globality", _), p, C, v), this.hooks.onPropertyChange(e, p, C, v));
|
|
11045
10908
|
}
|
|
11046
10909
|
async setCustomProperty(e, p, m) {
|
|
11047
|
-
if (!this.isValidOfCustomProperty(m)) throw console.warn(`Sandbox/setCustomProperty invalid custom property id=${e}`),
|
|
10910
|
+
if (!this.isValidOfCustomProperty(m)) throw console.warn(`Sandbox/setCustomProperty invalid custom property id=${e}`), errors.invalidCustomProperty;
|
|
11048
10911
|
let _ = this.customProperties[m];
|
|
11049
10912
|
isEqual_default(p, _) || (this.customProperties[m] = p, this.hooks.onPropertyChange(e, p, _), this.parent && (this.instance ? this.parent.hooks.onPropertyChange(makePropertyId("multipleRefProperty", this.nodeId, m), p, _, this.instance) : this.parent.hooks.onPropertyChange(makePropertyId("refProperty", this.nodeId, m), p, _)));
|
|
11050
10913
|
}
|
|
11051
10914
|
async setElementAdaptSlotProperty(e, p, m) {
|
|
11052
|
-
if (!this.parent) throw
|
|
10915
|
+
if (!this.parent) throw errors.notInSlot;
|
|
11053
10916
|
let { elementKey: _, slotKey: v, propertyKey: y } = unwrapPropertyKeyOfElementSlot(m);
|
|
11054
|
-
if (!this.
|
|
10917
|
+
if (!this.isEqualOfElementSlot(_, v)) throw errors.slotIncompatible;
|
|
10918
|
+
if (!this.isValidOfElementSlotProperty(_, v, y)) throw console.warn(`Sandbox/setElementAdaptSlotProperty invalid element slot property id=${e}`), errors.invalidElementSlotProperty;
|
|
11055
10919
|
let b = { value: void 0 };
|
|
11056
|
-
this.eventBus.emit(`property/${
|
|
10920
|
+
this.eventBus.emit(`property/${y}/get`, { result: b });
|
|
11057
10921
|
let x = b.value;
|
|
11058
|
-
isEqual_default(p, x) || (this.eventBus.emit(`property/${
|
|
10922
|
+
isEqual_default(p, x) || (this.eventBus.emit(`property/${y}/set`, p), this.hooks.onPropertyChange(e, p, x), this.kind === "elementSlot" ? this.parent.hooks.onPropertyChange(makePropertyId("elementSlotProperty", this.nodeId, m), p, x) : this.kind === "multipleElementSlot" && this.parent.hooks.onPropertyChange(makePropertyId("multipleElementSlotProperty", this.nodeId, m), p, x, this.instance));
|
|
11059
10923
|
}
|
|
11060
10924
|
async setCustomAdaptSlotProperty(e, p, m) {
|
|
11061
|
-
if (!this.parent) throw
|
|
10925
|
+
if (!this.parent) throw errors.notInSlot;
|
|
11062
10926
|
let { compId: _, slotId: v, propertyId: y } = unwrapPropertyKeyOfCustomSlot(m);
|
|
11063
|
-
if (!this.
|
|
10927
|
+
if (!this.isEqualOfCustomSlot(_, v)) throw errors.slotIncompatible;
|
|
10928
|
+
if (!this.isValidOfCustomSlotProperty(_, v, y)) throw console.warn(`Sandbox/setCustomAdaptSlotProperty invalid custom slot property id=${e}`), errors.invalidCustomSlotProperty;
|
|
11064
10929
|
let b = this.customSlotProperties[y];
|
|
11065
10930
|
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));
|
|
11066
10931
|
}
|
|
@@ -11086,16 +10951,16 @@ var PromiseManager = class {
|
|
|
11086
10951
|
async callMethod(e, p, m) {
|
|
11087
10952
|
this.debugTrace(makeFuncInfo("callMethod", e, p, m));
|
|
11088
10953
|
let { kind: g, nodeId: _, methodKey: v } = unwrapMethodId(e), y = this.getNode(_);
|
|
11089
|
-
if (!y) throw
|
|
10954
|
+
if (!y) throw errors.nodeNotFound;
|
|
11090
10955
|
if (g === "elementMethod") return await this.callElementMethod(e, m, y.basic.key, v);
|
|
11091
10956
|
if (g === "refMethod") return await this.callRefMethod(e, m, _, v);
|
|
11092
10957
|
if (g === "multipleRefMethod") return await this.callMultipleRefMethod(e, p, m, _, v);
|
|
11093
10958
|
if (g === "elementAdaptSlotMethod") return await this.callElementAdaptSlotMethod(e, m, v);
|
|
11094
10959
|
if (g === "customAdaptSlotMethod") return await this.callCustomAdaptSlotMethod(e, m, v);
|
|
11095
|
-
|
|
10960
|
+
console.assert(!1);
|
|
11096
10961
|
}
|
|
11097
10962
|
async callElementMethod(e, p, m, g) {
|
|
11098
|
-
if (!this.isValidOfElementMethod(m, g)) throw console.log(`Sandbox/callElementMethod invalid element method id=${e}`),
|
|
10963
|
+
if (!this.isValidOfElementMethod(m, g)) throw console.log(`Sandbox/callElementMethod invalid element method id=${e}`), errors.invalidElementMethod;
|
|
11099
10964
|
let _ = {};
|
|
11100
10965
|
return this.eventBus.emit(e, {
|
|
11101
10966
|
key: g,
|
|
@@ -11105,21 +10970,22 @@ var PromiseManager = class {
|
|
|
11105
10970
|
}
|
|
11106
10971
|
async callRefMethod(e, p, m, g) {
|
|
11107
10972
|
let _ = this.children[m];
|
|
11108
|
-
if (!_) throw
|
|
11109
|
-
if (!_.isValidOfCustomMethod(g)) throw console.warn(`Sandbox/callRefMethod invalid custom method id=${e}`),
|
|
10973
|
+
if (!_) throw errors.sandboxNotFound;
|
|
10974
|
+
if (!_.isValidOfCustomMethod(g)) throw console.warn(`Sandbox/callRefMethod invalid custom method id=${e}`), errors.invalidCustomMethod;
|
|
11110
10975
|
return await _.callFunctionAsync(getImplementMethodName("customMethod", "globality", g), "", p);
|
|
11111
10976
|
}
|
|
11112
10977
|
async callMultipleRefMethod(e, p, m, g, _) {
|
|
11113
|
-
if (!p) throw
|
|
10978
|
+
if (!p) throw errors.instanceNotAvailable;
|
|
11114
10979
|
let v = this.children[`${g}/${p}`];
|
|
11115
|
-
if (!v) throw
|
|
11116
|
-
if (!v.isValidOfCustomMethod(_)) throw console.warn(`Sandbox/callMultipleRefMethod invalid custom method id=${e}`),
|
|
10980
|
+
if (!v) throw errors.sandboxNotFound;
|
|
10981
|
+
if (!v.isValidOfCustomMethod(_)) throw console.warn(`Sandbox/callMultipleRefMethod invalid custom method id=${e}`), errors.invalidCustomMethod;
|
|
11117
10982
|
return await v.callFunctionAsync(getImplementMethodName("customMethod", "globality", _), "", m);
|
|
11118
10983
|
}
|
|
11119
10984
|
async callElementAdaptSlotMethod(e, p, m) {
|
|
11120
|
-
if (!this.parent) throw
|
|
10985
|
+
if (!this.parent) throw errors.notInSlot;
|
|
11121
10986
|
let { elementKey: g, slotKey: _, methodKey: v } = unwrapMethodKeyOfElementSlot(m);
|
|
11122
|
-
if (!this.
|
|
10987
|
+
if (!this.isEqualOfElementSlot(g, _)) throw errors.slotIncompatible;
|
|
10988
|
+
if (!this.isValidOfElementSlotMethod(g, _, v)) throw console.warn(`Sandbox/callElementAdaptSlotMethod invalid element slot method id=${e}`), errors.invalidElementSlotMethod;
|
|
11123
10989
|
let y = {};
|
|
11124
10990
|
return this.eventBus.emit(`method/${v}`, {
|
|
11125
10991
|
instance: this.instance,
|
|
@@ -11128,12 +10994,163 @@ var PromiseManager = class {
|
|
|
11128
10994
|
}), y;
|
|
11129
10995
|
}
|
|
11130
10996
|
async callCustomAdaptSlotMethod(e, p, m) {
|
|
11131
|
-
if (!this.parent) throw
|
|
10997
|
+
if (!this.parent) throw errors.notInSlot;
|
|
11132
10998
|
let { compId: g, slotId: _, methodId: v } = unwrapMethodKeyOfCustomSlot(m);
|
|
11133
|
-
if (!this.
|
|
10999
|
+
if (!this.isEqualOfCustomSlot(g, _)) throw errors.slotIncompatible;
|
|
11000
|
+
if (!this.isValidOfCustomSlotMethod(g, _, v)) throw console.warn(`Sandbox/callCustomAdaptSlotMethod invalid custom slot method id=${e}`), errors.invalidCustomSlotMethod;
|
|
11134
11001
|
if (this.kind === "customSlot") return await this.parent.callFunctionAsync(getImplementMethodName("customSlotMethod", this.nodeId, m), "", p);
|
|
11135
11002
|
if (this.kind === "multipleCustomSlot") return await this.parent.callFunctionAsync(getImplementMethodName("multipleCustomSlotMethod", this.nodeId, m), this.instance, p);
|
|
11136
|
-
|
|
11003
|
+
}
|
|
11004
|
+
isValidOfElementEvent(e, p) {
|
|
11005
|
+
let m = getElement(e);
|
|
11006
|
+
return !m || !m.events ? !1 : !!m.events.find((e) => e.key === p);
|
|
11007
|
+
}
|
|
11008
|
+
isValidOfElementSlotEvent(e, p, m) {
|
|
11009
|
+
let g = getElement(e);
|
|
11010
|
+
if (!g || !g.slots) return !1;
|
|
11011
|
+
let _ = g.slots.find((e) => e.key === p);
|
|
11012
|
+
return !_ || !_.events ? !1 : !!_.events.find((e) => e.key === m);
|
|
11013
|
+
}
|
|
11014
|
+
isValidOfCustomEvent(e) {
|
|
11015
|
+
return this.meta.value ? !!this.meta.value.events?.find((p) => p.id === e) : !1;
|
|
11016
|
+
}
|
|
11017
|
+
isValidOfCustomSlotEvent(e, p, m) {
|
|
11018
|
+
let g = this.depends.value?.[e];
|
|
11019
|
+
if (!g) return !1;
|
|
11020
|
+
let _ = g.meta.slots?.find((e) => e.id === p);
|
|
11021
|
+
return !_ || !_.events ? !1 : !!_.events.find((e) => e.id === m);
|
|
11022
|
+
}
|
|
11023
|
+
async triggerEvent(e, p, m) {
|
|
11024
|
+
this.debugTrace("triggerEvent", e, p, m);
|
|
11025
|
+
let { kind: g, nodeId: _, eventKey: v } = unwrapEventId(e), y = this.getNode(_);
|
|
11026
|
+
if (!y) throw errors.nodeNotFound;
|
|
11027
|
+
g === "elementEvent" ? await this.triggerElementEvent(e, p, y, v) : g === "elementPropertyChangeEvent" ? await this.triggerElementPropertyChangeEvent(e, p, y, v) : g === "elementSlotEvent" ? await this.triggerElementSlotEvent(e, p, _, v) : g === "elementSlotPropertyChangeEvent" ? await this.triggerElementSlotPropertyChangeEvent(e, p, v) : g === "multipleElementSlotEvent" ? await this.triggerMultipleElementSlotEvent(e, p, _, v, m) : g === "multipleElementSlotPropertyChangeEvent" ? await this.triggerMultipleElementSlotPropertyChangeEvent(e, p, v, m) : g === "refEvent" ? await this.triggerRefEvent(e, p, _, v) : g === "refPropertyChangeEvent" ? await this.triggerRefPropertyChangeEvent(e, p, _, v) : g === "multipleRefEvent" ? await this.triggerMultipleRefEvent(e, p, _, v, m) : g === "multipleRefPropertyChangeEvent" ? await this.triggerMultipleRefPropertyChangeEvent(e, p, _, v, m) : g === "customSlotEvent" ? await this.triggerCustomSlotEvent(e, p, _, v) : g === "customSlotPropertyChangeEvent" ? await this.triggerCustomSlotPropertyChangeEvent(e, p, v) : g === "multipleCustomSlotEvent" ? await this.triggerMultipleCustomSlotEvent(e, p, _, v, m) : g === "multipleCustomSlotPropertyChangeEvent" ? await this.triggerMultipleCustomSlotPropertyChangeEvent(e, p, v, m) : g === "customEvent" ? await this.triggerCustomEvent(e, p, v) : g === "customPropertyChangeEvent" ? await this.triggerCustomPropertyChangeEvent(e, p, v) : g === "elementAdaptSlotEvent" ? await this.triggerElementAdaptSlotEvent(e, p, v) : g === "elementAdaptSlotPropertyChangeEvent" ? await this.triggerElementAdaptSlotPropertyChangeEvent(e, p, v) : g === "customAdaptSlotEvent" ? await this.triggerCustomAdaptSlotEvent(e, p, v) : g === "customAdaptSlotPropertyChangeEvent" ? await this.triggerCustomAdaptSlotPropertyChangeEvent(e, p, v) : g === "stateChangeEvent" ? await this.triggerStateChangeEvent(e, p, v) : console.assert(!1);
|
|
11028
|
+
}
|
|
11029
|
+
async triggerElementEvent(e, p, m, g) {
|
|
11030
|
+
if (!this.isValidOfElementEvent(m.basic.key, g)) throw errors.invalidElementEvent;
|
|
11031
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11032
|
+
}
|
|
11033
|
+
async triggerElementPropertyChangeEvent(e, p, m, g) {
|
|
11034
|
+
if (!this.isValidOfElementProperty(m.basic.key, g)) throw errors.invalidElementProperty;
|
|
11035
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11036
|
+
}
|
|
11037
|
+
async triggerElementSlotEvent(e, p, m, g) {
|
|
11038
|
+
let { elementKey: _, slotKey: v, eventKey: y } = unwrapEventKeyOfElementSlot(g);
|
|
11039
|
+
if (!this.isValidOfElementSlotEvent(_, v, y)) throw errors.invalidElementSlotEvent;
|
|
11040
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11041
|
+
let b = this.children[m];
|
|
11042
|
+
b && await b.triggerEvent(makeEventId("elementAdaptSlotEvent", "globality", g), p);
|
|
11043
|
+
}
|
|
11044
|
+
async triggerElementSlotPropertyChangeEvent(e, p, m) {
|
|
11045
|
+
let { elementKey: g, slotKey: _, eventKey: v } = unwrapEventKeyOfElementSlot(m);
|
|
11046
|
+
if (!this.isValidOfElementSlotProperty(g, _, v)) throw errors.invalidElementSlotProperty;
|
|
11047
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11048
|
+
}
|
|
11049
|
+
async triggerMultipleElementSlotEvent(e, p, m, g, _) {
|
|
11050
|
+
if (!_) throw errors.instanceNotAvailable;
|
|
11051
|
+
let { elementKey: v, slotKey: y, eventKey: b } = unwrapEventKeyOfElementSlot(g);
|
|
11052
|
+
if (!this.isValidOfElementSlotEvent(v, y, b)) throw errors.invalidElementSlotEvent;
|
|
11053
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p, _);
|
|
11054
|
+
let x = this.children[`${m}/${_}`];
|
|
11055
|
+
x && await x.triggerEvent(makeEventId("elementAdaptSlotEvent", "globality", g), p);
|
|
11056
|
+
}
|
|
11057
|
+
async triggerMultipleElementSlotPropertyChangeEvent(e, p, m, g) {
|
|
11058
|
+
if (!g) throw errors.instanceNotAvailable;
|
|
11059
|
+
let { elementKey: _, slotKey: v, eventKey: y } = unwrapEventKeyOfElementSlot(m);
|
|
11060
|
+
if (!this.isValidOfElementSlotProperty(_, v, y)) throw errors.invalidElementSlotProperty;
|
|
11061
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p, g);
|
|
11062
|
+
}
|
|
11063
|
+
async triggerRefEvent(e, p, m, g) {
|
|
11064
|
+
let _ = this.children[m];
|
|
11065
|
+
if (!_) throw errors.sandboxNotFound;
|
|
11066
|
+
if (!_.isValidOfCustomEvent(g)) throw errors.invalidCustomEvent;
|
|
11067
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11068
|
+
}
|
|
11069
|
+
async triggerRefPropertyChangeEvent(e, p, m, g) {
|
|
11070
|
+
let _ = this.children[m];
|
|
11071
|
+
if (!_) throw errors.sandboxNotFound;
|
|
11072
|
+
if (!_.isValidOfCustomProperty(g)) throw errors.invalidCustomProperty;
|
|
11073
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11074
|
+
}
|
|
11075
|
+
async triggerMultipleRefEvent(e, p, m, g, _) {
|
|
11076
|
+
if (!_) throw errors.instanceNotAvailable;
|
|
11077
|
+
let v = this.children[`${m}/${_}`];
|
|
11078
|
+
if (!v) throw errors.sandboxNotFound;
|
|
11079
|
+
if (!v.isValidOfCustomEvent(g)) throw errors.invalidCustomEvent;
|
|
11080
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p, _);
|
|
11081
|
+
}
|
|
11082
|
+
async triggerMultipleRefPropertyChangeEvent(e, p, m, g, _) {
|
|
11083
|
+
if (!_) throw errors.instanceNotAvailable;
|
|
11084
|
+
let v = this.children[`${m}/${_}`];
|
|
11085
|
+
if (!v) throw errors.sandboxNotFound;
|
|
11086
|
+
if (!v.isValidOfCustomProperty(g)) throw errors.invalidCustomProperty;
|
|
11087
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p, _);
|
|
11088
|
+
}
|
|
11089
|
+
async triggerCustomSlotEvent(e, p, m, g) {
|
|
11090
|
+
let { compId: _, slotId: v, eventId: y } = unwrapEventKeyOfCustomSlot(g);
|
|
11091
|
+
if (!this.isValidOfCustomSlotEvent(_, v, y)) throw errors.invalidCustomSlotEvent;
|
|
11092
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11093
|
+
let b = this.children[m];
|
|
11094
|
+
b && await b.triggerEvent(makeEventId("customAdaptSlotEvent", "globality", g), p);
|
|
11095
|
+
}
|
|
11096
|
+
async triggerCustomSlotPropertyChangeEvent(e, p, m) {
|
|
11097
|
+
let { compId: g, slotId: _, eventId: v } = unwrapEventKeyOfCustomSlot(m);
|
|
11098
|
+
if (!this.isValidOfCustomSlotProperty(g, _, v)) throw errors.invalidCustomSlotProperty;
|
|
11099
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11100
|
+
}
|
|
11101
|
+
async triggerMultipleCustomSlotEvent(e, p, m, g, _) {
|
|
11102
|
+
if (!_) throw errors.instanceNotAvailable;
|
|
11103
|
+
let { compId: v, slotId: y, eventId: b } = unwrapEventKeyOfCustomSlot(g);
|
|
11104
|
+
if (!this.isValidOfCustomSlotEvent(v, y, b)) throw errors.invalidCustomSlotEvent;
|
|
11105
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p, _);
|
|
11106
|
+
let x = this.children[`${m}/${_}`];
|
|
11107
|
+
x && await x.triggerEvent(makeEventId("customAdaptSlotEvent", "globality", g), p);
|
|
11108
|
+
}
|
|
11109
|
+
async triggerMultipleCustomSlotPropertyChangeEvent(e, p, m, g) {
|
|
11110
|
+
if (!g) throw errors.instanceNotAvailable;
|
|
11111
|
+
let { compId: _, slotId: v, eventId: y } = unwrapEventKeyOfCustomSlot(m);
|
|
11112
|
+
if (!this.isValidOfCustomSlotProperty(_, v, y)) throw errors.invalidCustomSlotProperty;
|
|
11113
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p, g);
|
|
11114
|
+
}
|
|
11115
|
+
async triggerCustomEvent(e, p, m) {
|
|
11116
|
+
if (!this.isValidOfCustomEvent(m)) throw errors.invalidCustomEvent;
|
|
11117
|
+
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));
|
|
11118
|
+
}
|
|
11119
|
+
async triggerCustomPropertyChangeEvent(e, p, m) {
|
|
11120
|
+
if (!this.isValidOfCustomProperty(m)) throw errors.invalidCustomProperty;
|
|
11121
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11122
|
+
}
|
|
11123
|
+
async triggerElementAdaptSlotEvent(e, p, m) {
|
|
11124
|
+
if (!this.parent) throw errors.notInSlot;
|
|
11125
|
+
let { elementKey: g, slotKey: _, eventKey: v } = unwrapEventKeyOfElementSlot(m);
|
|
11126
|
+
if (!this.isEqualOfElementSlot(g, _)) throw errors.slotIncompatible;
|
|
11127
|
+
if (!this.isValidOfElementSlotEvent(g, _, v)) throw errors.invalidElementSlotEvent;
|
|
11128
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11129
|
+
}
|
|
11130
|
+
async triggerElementAdaptSlotPropertyChangeEvent(e, p, m) {
|
|
11131
|
+
if (!this.parent) throw errors.notInSlot;
|
|
11132
|
+
let { elementKey: g, slotKey: _, eventKey: v } = unwrapEventKeyOfElementSlot(m);
|
|
11133
|
+
if (!this.isEqualOfElementSlot(g, _)) throw errors.slotIncompatible;
|
|
11134
|
+
if (!this.isValidOfElementSlotProperty(g, _, v)) throw errors.invalidElementSlotProperty;
|
|
11135
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11136
|
+
}
|
|
11137
|
+
async triggerCustomAdaptSlotEvent(e, p, m) {
|
|
11138
|
+
if (!this.parent) throw errors.notInSlot;
|
|
11139
|
+
let { compId: g, slotId: _, eventId: v } = unwrapEventKeyOfCustomSlot(m);
|
|
11140
|
+
if (!this.isEqualOfCustomSlot(g, _)) throw errors.slotIncompatible;
|
|
11141
|
+
if (!this.isValidOfCustomSlotEvent(g, _, v)) throw errors.invalidCustomSlotEvent;
|
|
11142
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11143
|
+
}
|
|
11144
|
+
async triggerCustomAdaptSlotPropertyChangeEvent(e, p, m) {
|
|
11145
|
+
if (!this.parent) throw errors.notInSlot;
|
|
11146
|
+
let { compId: g, slotId: _, eventId: v } = unwrapEventKeyOfCustomSlot(m);
|
|
11147
|
+
if (!this.isEqualOfCustomSlot(g, _)) throw errors.slotIncompatible;
|
|
11148
|
+
if (!this.isValidOfCustomSlotProperty(g, _, v)) throw errors.invalidCustomSlotProperty;
|
|
11149
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11150
|
+
}
|
|
11151
|
+
async triggerStateChangeEvent(e, p, m) {
|
|
11152
|
+
if (!this.isValidOfState(m)) throw errors.invalidState;
|
|
11153
|
+
await this.callFunctionAsync("__triggerEventInner__", e, p);
|
|
11137
11154
|
}
|
|
11138
11155
|
states = {};
|
|
11139
11156
|
resetStates() {
|
|
@@ -11146,7 +11163,7 @@ var PromiseManager = class {
|
|
|
11146
11163
|
return this.states[e];
|
|
11147
11164
|
}
|
|
11148
11165
|
async setState(e, p) {
|
|
11149
|
-
if (this.debugTrace("setState", e, p), !this.isValidOfState(e)) throw console.warn(`Sandbox/setState invalid state id=${e}`),
|
|
11166
|
+
if (this.debugTrace("setState", e, p), !this.isValidOfState(e)) throw console.warn(`Sandbox/setState invalid state id=${e}`), errors.invalidState;
|
|
11150
11167
|
let m = this.states[e];
|
|
11151
11168
|
isEqual_default(p, m) || (this.states[e] = cloneDeep_default(p), this.hooks.onStateChange(e, p, m), await nextTick());
|
|
11152
11169
|
}
|
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
import { QuickJSContext } from 'quickjs-emscripten';
|
|
2
|
+
export declare const errors: {
|
|
3
|
+
functionNotAvailable: Error;
|
|
4
|
+
instanceNotAvailable: Error;
|
|
5
|
+
invalidCustomEvent: Error;
|
|
6
|
+
invalidCustomMethod: Error;
|
|
7
|
+
invalidCustomProperty: Error;
|
|
8
|
+
invalidCustomSlotEvent: Error;
|
|
9
|
+
invalidCustomSlotMethod: Error;
|
|
10
|
+
invalidCustomSlotProperty: Error;
|
|
11
|
+
invalidElementEvent: Error;
|
|
12
|
+
invalidElementMethod: Error;
|
|
13
|
+
invalidElementProperty: Error;
|
|
14
|
+
invalidElementSlotEvent: Error;
|
|
15
|
+
invalidElementSlotMethod: Error;
|
|
16
|
+
invalidElementSlotProperty: Error;
|
|
17
|
+
invalidState: Error;
|
|
18
|
+
nodeNotFound: Error;
|
|
19
|
+
notInSlot: Error;
|
|
20
|
+
sandboxNotFound: Error;
|
|
21
|
+
slotIncompatible: Error;
|
|
22
|
+
vmNotAvailable: Error;
|
|
23
|
+
};
|
|
2
24
|
export type InitValues = {
|
|
3
25
|
[key: string]: any;
|
|
4
26
|
};
|
|
@@ -30,39 +30,15 @@ export declare class Sandbox {
|
|
|
30
30
|
private data;
|
|
31
31
|
private depends;
|
|
32
32
|
prepare(meta: Ref<Meta | undefined>, data: Ref<Data | undefined>, depends: ShallowRef<Depends | undefined>, initValues?: InitValues): void;
|
|
33
|
-
getNode(nodeId: string): Node | undefined;
|
|
34
33
|
createVm(runtime: QuickJSRuntime, code: string): Promise<void>;
|
|
35
34
|
destroyVm(): void;
|
|
36
35
|
setGlobalVariable(key: string, value: any): void;
|
|
37
36
|
getGlobalVariable(key: string): any;
|
|
38
37
|
callFunctionSync(funcName: string, ...params: any[]): any;
|
|
39
38
|
callFunctionAsync(funcName: string, ...params: any[]): Promise<any>;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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;
|
|
39
|
+
getNode(nodeId: string): Node | undefined;
|
|
40
|
+
isEqualOfElementSlot(elementKey: string, slotKey: string): boolean;
|
|
41
|
+
isEqualOfCustomSlot(compId: string, slotId: string): boolean;
|
|
66
42
|
customProperties: {
|
|
67
43
|
[key: string]: any;
|
|
68
44
|
};
|
|
@@ -102,6 +78,32 @@ export declare class Sandbox {
|
|
|
102
78
|
private callMultipleRefMethod;
|
|
103
79
|
private callElementAdaptSlotMethod;
|
|
104
80
|
private callCustomAdaptSlotMethod;
|
|
81
|
+
isValidOfElementEvent(elementKey: string, eventKey: string): boolean;
|
|
82
|
+
isValidOfElementSlotEvent(elementKey: string, slotKey: string, eventKey: string): boolean;
|
|
83
|
+
isValidOfCustomEvent(eventId: string): boolean;
|
|
84
|
+
isValidOfCustomSlotEvent(compId: string, slotId: string, eventId: string): boolean;
|
|
85
|
+
triggerEvent(id: string, params: any[], instance?: string): Promise<void>;
|
|
86
|
+
private triggerElementEvent;
|
|
87
|
+
private triggerElementPropertyChangeEvent;
|
|
88
|
+
private triggerElementSlotEvent;
|
|
89
|
+
private triggerElementSlotPropertyChangeEvent;
|
|
90
|
+
private triggerMultipleElementSlotEvent;
|
|
91
|
+
private triggerMultipleElementSlotPropertyChangeEvent;
|
|
92
|
+
private triggerRefEvent;
|
|
93
|
+
private triggerRefPropertyChangeEvent;
|
|
94
|
+
private triggerMultipleRefEvent;
|
|
95
|
+
private triggerMultipleRefPropertyChangeEvent;
|
|
96
|
+
private triggerCustomSlotEvent;
|
|
97
|
+
private triggerCustomSlotPropertyChangeEvent;
|
|
98
|
+
private triggerMultipleCustomSlotEvent;
|
|
99
|
+
private triggerMultipleCustomSlotPropertyChangeEvent;
|
|
100
|
+
private triggerCustomEvent;
|
|
101
|
+
private triggerCustomPropertyChangeEvent;
|
|
102
|
+
private triggerElementAdaptSlotEvent;
|
|
103
|
+
private triggerElementAdaptSlotPropertyChangeEvent;
|
|
104
|
+
private triggerCustomAdaptSlotEvent;
|
|
105
|
+
private triggerCustomAdaptSlotPropertyChangeEvent;
|
|
106
|
+
private triggerStateChangeEvent;
|
|
105
107
|
private states;
|
|
106
108
|
private resetStates;
|
|
107
109
|
isValidOfState(id: string): boolean;
|