@wiajs/core 1.2.1 → 1.2.3
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/.oxfmtrc.jsonc +47 -0
- package/.oxlintrc.json +78 -0
- package/dist/core.cjs +306 -12
- package/dist/core.js +726 -11
- package/dist/core.min.js +11 -5
- package/dist/core.mjs +306 -13
- package/dist/jsx-runtime.js +127 -105
- package/package.json +27 -27
- package/util/tool.js +215 -0
- package/.eslintignore +0 -5
- package/.eslintrc.js +0 -121
- package/.prettierignore +0 -24
- package/prettier.config.js +0 -13
package/dist/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wia core v1.2.
|
|
3
|
-
* (c) 2015-
|
|
2
|
+
* wia core v1.2.3
|
|
3
|
+
* (c) 2015-2026 Sibyl Yu and contributors
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
@@ -2530,6 +2530,561 @@
|
|
|
2530
2530
|
return Event;
|
|
2531
2531
|
}();
|
|
2532
2532
|
|
|
2533
|
+
function _regeneratorRuntime() {
|
|
2534
|
+
_regeneratorRuntime = function _regeneratorRuntime() {
|
|
2535
|
+
return e;
|
|
2536
|
+
};
|
|
2537
|
+
var t,
|
|
2538
|
+
e = {},
|
|
2539
|
+
r = Object.prototype,
|
|
2540
|
+
n = r.hasOwnProperty,
|
|
2541
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
2542
|
+
t[e] = r.value;
|
|
2543
|
+
},
|
|
2544
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
2545
|
+
a = i.iterator || "@@iterator",
|
|
2546
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
2547
|
+
u = i.toStringTag || "@@toStringTag";
|
|
2548
|
+
function define(t, e, r) {
|
|
2549
|
+
return Object.defineProperty(t, e, {
|
|
2550
|
+
value: r,
|
|
2551
|
+
enumerable: !0,
|
|
2552
|
+
configurable: !0,
|
|
2553
|
+
writable: !0
|
|
2554
|
+
}), t[e];
|
|
2555
|
+
}
|
|
2556
|
+
try {
|
|
2557
|
+
define({}, "");
|
|
2558
|
+
} catch (t) {
|
|
2559
|
+
define = function define(t, e, r) {
|
|
2560
|
+
return t[e] = r;
|
|
2561
|
+
};
|
|
2562
|
+
}
|
|
2563
|
+
function wrap(t, e, r, n) {
|
|
2564
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
2565
|
+
a = Object.create(i.prototype),
|
|
2566
|
+
c = new Context(n || []);
|
|
2567
|
+
return o(a, "_invoke", {
|
|
2568
|
+
value: makeInvokeMethod(t, r, c)
|
|
2569
|
+
}), a;
|
|
2570
|
+
}
|
|
2571
|
+
function tryCatch(t, e, r) {
|
|
2572
|
+
try {
|
|
2573
|
+
return {
|
|
2574
|
+
type: "normal",
|
|
2575
|
+
arg: t.call(e, r)
|
|
2576
|
+
};
|
|
2577
|
+
} catch (t) {
|
|
2578
|
+
return {
|
|
2579
|
+
type: "throw",
|
|
2580
|
+
arg: t
|
|
2581
|
+
};
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
e.wrap = wrap;
|
|
2585
|
+
var h = "suspendedStart",
|
|
2586
|
+
l = "suspendedYield",
|
|
2587
|
+
f = "executing",
|
|
2588
|
+
s = "completed",
|
|
2589
|
+
y = {};
|
|
2590
|
+
function Generator() {}
|
|
2591
|
+
function GeneratorFunction() {}
|
|
2592
|
+
function GeneratorFunctionPrototype() {}
|
|
2593
|
+
var p = {};
|
|
2594
|
+
define(p, a, function () {
|
|
2595
|
+
return this;
|
|
2596
|
+
});
|
|
2597
|
+
var d = Object.getPrototypeOf,
|
|
2598
|
+
v = d && d(d(values([])));
|
|
2599
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
2600
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
2601
|
+
function defineIteratorMethods(t) {
|
|
2602
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
2603
|
+
define(t, e, function (t) {
|
|
2604
|
+
return this._invoke(e, t);
|
|
2605
|
+
});
|
|
2606
|
+
});
|
|
2607
|
+
}
|
|
2608
|
+
function AsyncIterator(t, e) {
|
|
2609
|
+
function invoke(r, o, i, a) {
|
|
2610
|
+
var c = tryCatch(t[r], t, o);
|
|
2611
|
+
if ("throw" !== c.type) {
|
|
2612
|
+
var u = c.arg,
|
|
2613
|
+
h = u.value;
|
|
2614
|
+
return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
2615
|
+
invoke("next", t, i, a);
|
|
2616
|
+
}, function (t) {
|
|
2617
|
+
invoke("throw", t, i, a);
|
|
2618
|
+
}) : e.resolve(h).then(function (t) {
|
|
2619
|
+
u.value = t, i(u);
|
|
2620
|
+
}, function (t) {
|
|
2621
|
+
return invoke("throw", t, i, a);
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
a(c.arg);
|
|
2625
|
+
}
|
|
2626
|
+
var r;
|
|
2627
|
+
o(this, "_invoke", {
|
|
2628
|
+
value: function value(t, n) {
|
|
2629
|
+
function callInvokeWithMethodAndArg() {
|
|
2630
|
+
return new e(function (e, r) {
|
|
2631
|
+
invoke(t, n, e, r);
|
|
2632
|
+
});
|
|
2633
|
+
}
|
|
2634
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
2635
|
+
}
|
|
2636
|
+
});
|
|
2637
|
+
}
|
|
2638
|
+
function makeInvokeMethod(e, r, n) {
|
|
2639
|
+
var o = h;
|
|
2640
|
+
return function (i, a) {
|
|
2641
|
+
if (o === f) throw Error("Generator is already running");
|
|
2642
|
+
if (o === s) {
|
|
2643
|
+
if ("throw" === i) throw a;
|
|
2644
|
+
return {
|
|
2645
|
+
value: t,
|
|
2646
|
+
done: !0
|
|
2647
|
+
};
|
|
2648
|
+
}
|
|
2649
|
+
for (n.method = i, n.arg = a;;) {
|
|
2650
|
+
var c = n.delegate;
|
|
2651
|
+
if (c) {
|
|
2652
|
+
var u = maybeInvokeDelegate(c, n);
|
|
2653
|
+
if (u) {
|
|
2654
|
+
if (u === y) continue;
|
|
2655
|
+
return u;
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
2659
|
+
if (o === h) throw o = s, n.arg;
|
|
2660
|
+
n.dispatchException(n.arg);
|
|
2661
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
2662
|
+
o = f;
|
|
2663
|
+
var p = tryCatch(e, r, n);
|
|
2664
|
+
if ("normal" === p.type) {
|
|
2665
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
2666
|
+
return {
|
|
2667
|
+
value: p.arg,
|
|
2668
|
+
done: n.done
|
|
2669
|
+
};
|
|
2670
|
+
}
|
|
2671
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
2672
|
+
}
|
|
2673
|
+
};
|
|
2674
|
+
}
|
|
2675
|
+
function maybeInvokeDelegate(e, r) {
|
|
2676
|
+
var n = r.method,
|
|
2677
|
+
o = e.iterator[n];
|
|
2678
|
+
if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
2679
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
2680
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
2681
|
+
var a = i.arg;
|
|
2682
|
+
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
2683
|
+
}
|
|
2684
|
+
function pushTryEntry(t) {
|
|
2685
|
+
var e = {
|
|
2686
|
+
tryLoc: t[0]
|
|
2687
|
+
};
|
|
2688
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
2689
|
+
}
|
|
2690
|
+
function resetTryEntry(t) {
|
|
2691
|
+
var e = t.completion || {};
|
|
2692
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
2693
|
+
}
|
|
2694
|
+
function Context(t) {
|
|
2695
|
+
this.tryEntries = [{
|
|
2696
|
+
tryLoc: "root"
|
|
2697
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
2698
|
+
}
|
|
2699
|
+
function values(e) {
|
|
2700
|
+
if (e || "" === e) {
|
|
2701
|
+
var r = e[a];
|
|
2702
|
+
if (r) return r.call(e);
|
|
2703
|
+
if ("function" == typeof e.next) return e;
|
|
2704
|
+
if (!isNaN(e.length)) {
|
|
2705
|
+
var o = -1,
|
|
2706
|
+
i = function next() {
|
|
2707
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
2708
|
+
return next.value = t, next.done = !0, next;
|
|
2709
|
+
};
|
|
2710
|
+
return i.next = i;
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
throw new TypeError(_typeof(e) + " is not iterable");
|
|
2714
|
+
}
|
|
2715
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
2716
|
+
value: GeneratorFunctionPrototype,
|
|
2717
|
+
configurable: !0
|
|
2718
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
2719
|
+
value: GeneratorFunction,
|
|
2720
|
+
configurable: !0
|
|
2721
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
2722
|
+
var e = "function" == typeof t && t.constructor;
|
|
2723
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
2724
|
+
}, e.mark = function (t) {
|
|
2725
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
2726
|
+
}, e.awrap = function (t) {
|
|
2727
|
+
return {
|
|
2728
|
+
__await: t
|
|
2729
|
+
};
|
|
2730
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
2731
|
+
return this;
|
|
2732
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
2733
|
+
void 0 === i && (i = Promise);
|
|
2734
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
2735
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
2736
|
+
return t.done ? t.value : a.next();
|
|
2737
|
+
});
|
|
2738
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
2739
|
+
return this;
|
|
2740
|
+
}), define(g, "toString", function () {
|
|
2741
|
+
return "[object Generator]";
|
|
2742
|
+
}), e.keys = function (t) {
|
|
2743
|
+
var e = Object(t),
|
|
2744
|
+
r = [];
|
|
2745
|
+
for (var n in e) r.push(n);
|
|
2746
|
+
return r.reverse(), function next() {
|
|
2747
|
+
for (; r.length;) {
|
|
2748
|
+
var t = r.pop();
|
|
2749
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
2750
|
+
}
|
|
2751
|
+
return next.done = !0, next;
|
|
2752
|
+
};
|
|
2753
|
+
}, e.values = values, Context.prototype = {
|
|
2754
|
+
constructor: Context,
|
|
2755
|
+
reset: function reset(e) {
|
|
2756
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
2757
|
+
},
|
|
2758
|
+
stop: function stop() {
|
|
2759
|
+
this.done = !0;
|
|
2760
|
+
var t = this.tryEntries[0].completion;
|
|
2761
|
+
if ("throw" === t.type) throw t.arg;
|
|
2762
|
+
return this.rval;
|
|
2763
|
+
},
|
|
2764
|
+
dispatchException: function dispatchException(e) {
|
|
2765
|
+
if (this.done) throw e;
|
|
2766
|
+
var r = this;
|
|
2767
|
+
function handle(n, o) {
|
|
2768
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
2769
|
+
}
|
|
2770
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
2771
|
+
var i = this.tryEntries[o],
|
|
2772
|
+
a = i.completion;
|
|
2773
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
2774
|
+
if (i.tryLoc <= this.prev) {
|
|
2775
|
+
var c = n.call(i, "catchLoc"),
|
|
2776
|
+
u = n.call(i, "finallyLoc");
|
|
2777
|
+
if (c && u) {
|
|
2778
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
2779
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
2780
|
+
} else if (c) {
|
|
2781
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
2782
|
+
} else {
|
|
2783
|
+
if (!u) throw Error("try statement without catch or finally");
|
|
2784
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
},
|
|
2789
|
+
abrupt: function abrupt(t, e) {
|
|
2790
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
2791
|
+
var o = this.tryEntries[r];
|
|
2792
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
2793
|
+
var i = o;
|
|
2794
|
+
break;
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
2798
|
+
var a = i ? i.completion : {};
|
|
2799
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
2800
|
+
},
|
|
2801
|
+
complete: function complete(t, e) {
|
|
2802
|
+
if ("throw" === t.type) throw t.arg;
|
|
2803
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
2804
|
+
},
|
|
2805
|
+
finish: function finish(t) {
|
|
2806
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
2807
|
+
var r = this.tryEntries[e];
|
|
2808
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
2809
|
+
}
|
|
2810
|
+
},
|
|
2811
|
+
"catch": function _catch(t) {
|
|
2812
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
2813
|
+
var r = this.tryEntries[e];
|
|
2814
|
+
if (r.tryLoc === t) {
|
|
2815
|
+
var n = r.completion;
|
|
2816
|
+
if ("throw" === n.type) {
|
|
2817
|
+
var o = n.arg;
|
|
2818
|
+
resetTryEntry(r);
|
|
2819
|
+
}
|
|
2820
|
+
return o;
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
throw Error("illegal catch attempt");
|
|
2824
|
+
},
|
|
2825
|
+
delegateYield: function delegateYield(e, r, n) {
|
|
2826
|
+
return this.delegate = {
|
|
2827
|
+
iterator: values(e),
|
|
2828
|
+
resultName: r,
|
|
2829
|
+
nextLoc: n
|
|
2830
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
2831
|
+
}
|
|
2832
|
+
}, e;
|
|
2833
|
+
}
|
|
2834
|
+
|
|
2835
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2836
|
+
try {
|
|
2837
|
+
var info = gen[key](arg);
|
|
2838
|
+
var value = info.value;
|
|
2839
|
+
} catch (error) {
|
|
2840
|
+
reject(error);
|
|
2841
|
+
return;
|
|
2842
|
+
}
|
|
2843
|
+
if (info.done) {
|
|
2844
|
+
resolve(value);
|
|
2845
|
+
} else {
|
|
2846
|
+
Promise.resolve(value).then(_next, _throw);
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
function _asyncToGenerator(fn) {
|
|
2850
|
+
return function () {
|
|
2851
|
+
var self = this,
|
|
2852
|
+
args = arguments;
|
|
2853
|
+
return new Promise(function (resolve, reject) {
|
|
2854
|
+
var gen = fn.apply(self, args);
|
|
2855
|
+
function _next(value) {
|
|
2856
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
2857
|
+
}
|
|
2858
|
+
function _throw(err) {
|
|
2859
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2860
|
+
}
|
|
2861
|
+
_next(undefined);
|
|
2862
|
+
});
|
|
2863
|
+
};
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
/*!
|
|
2867
|
+
* wia util v3.4.25
|
|
2868
|
+
* (c) 2018-2024 Yan (Sibyl) Yu and Yuxi (Evan) You and wia/vue contributors
|
|
2869
|
+
* Released under the MIT License.
|
|
2870
|
+
*/
|
|
2871
|
+
/**
|
|
2872
|
+
* Created by way on 10/6/16.
|
|
2873
|
+
* Part of the code comes from @vue/shared
|
|
2874
|
+
*/
|
|
2875
|
+
|
|
2876
|
+
|
|
2877
|
+
/**
|
|
2878
|
+
* 前端日志输出,封装 console日志,简化代码,支持模块或直接输出
|
|
2879
|
+
* 调用时,描述字符串后置,便于可选缺省,输出时,自带前置,类似 后端pino,保持前后端一致性
|
|
2880
|
+
* m 为模块,fn 为函数名称
|
|
2881
|
+
*/
|
|
2882
|
+
class Log {
|
|
2883
|
+
/** @type {string} 模块 */
|
|
2884
|
+
m = ''
|
|
2885
|
+
|
|
2886
|
+
/** @type {string} 函数 */
|
|
2887
|
+
fn = ''
|
|
2888
|
+
|
|
2889
|
+
/**
|
|
2890
|
+
* @param {string} m 模块
|
|
2891
|
+
*/
|
|
2892
|
+
constructor(m) {
|
|
2893
|
+
this.m = m;
|
|
2894
|
+
}
|
|
2895
|
+
|
|
2896
|
+
/**
|
|
2897
|
+
* get log desc
|
|
2898
|
+
* 描述字符串后置调用,前置显示
|
|
2899
|
+
* @param {*[]} args
|
|
2900
|
+
* @returns {string}
|
|
2901
|
+
*/
|
|
2902
|
+
getDesc(args) {
|
|
2903
|
+
let R = '';
|
|
2904
|
+
try {
|
|
2905
|
+
const _ = this;
|
|
2906
|
+
const { m } = _;
|
|
2907
|
+
let fn = '',
|
|
2908
|
+
desc = '';
|
|
2909
|
+
|
|
2910
|
+
if (args.length > 1) {
|
|
2911
|
+
const last = args.at(-1);
|
|
2912
|
+
if (typeof last === 'object') {
|
|
2913
|
+
;({ desc, fn } = last);
|
|
2914
|
+
} else if (typeof last === 'string') desc = last;
|
|
2915
|
+
if (desc || fn) {
|
|
2916
|
+
fn = fn || _.fn;
|
|
2917
|
+
_.fn = fn;
|
|
2918
|
+
args.pop();
|
|
2919
|
+
}
|
|
2920
|
+
}
|
|
2921
|
+
fn = fn || _.fn;
|
|
2922
|
+
if (m) desc = `${desc}[${m}${fn ? ':' + fn : ''}]`; // eslint-disable-line
|
|
2923
|
+
R = desc;
|
|
2924
|
+
} catch (e) {
|
|
2925
|
+
console.error(`getDesc exp:${e.message}`);
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2928
|
+
return R
|
|
2929
|
+
}
|
|
2930
|
+
|
|
2931
|
+
/** @param {...any} args - params */
|
|
2932
|
+
log(...args) {
|
|
2933
|
+
const _ = this;
|
|
2934
|
+
const last = args.at(-1);
|
|
2935
|
+
// clear fn
|
|
2936
|
+
if (args.length === 1 && typeof last === 'object' && last.fn) _.fn = '';
|
|
2937
|
+
else {
|
|
2938
|
+
const desc = _.getDesc(args);
|
|
2939
|
+
console.log(desc, ...args);
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
/** @param {...any} args - params */
|
|
2944
|
+
debug(...args) {
|
|
2945
|
+
const _ = this;
|
|
2946
|
+
const desc = _.getDesc(args);
|
|
2947
|
+
if (desc) console.log(desc, ...args);
|
|
2948
|
+
else console.log(...args);
|
|
2949
|
+
}
|
|
2950
|
+
|
|
2951
|
+
/** @param {...any} args - params */
|
|
2952
|
+
info(...args) {
|
|
2953
|
+
const _ = this;
|
|
2954
|
+
const desc = _.getDesc(args);
|
|
2955
|
+
if (desc) console.info(desc, ...args);
|
|
2956
|
+
else console.log(...args);
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
/** @param {...any} args - params */
|
|
2960
|
+
warn(...args) {
|
|
2961
|
+
const _ = this;
|
|
2962
|
+
const { desc, arg } = _.getDesc(args);
|
|
2963
|
+
if (desc) console.warn(desc, ...arg);
|
|
2964
|
+
else console.log(...args);
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
/** @param {...any} args - params */
|
|
2968
|
+
trace(...args) {
|
|
2969
|
+
const _ = this;
|
|
2970
|
+
const { desc, arg } = _.getDesc(args);
|
|
2971
|
+
if (desc) console.trace(desc, ...arg);
|
|
2972
|
+
else console.trace(...args);
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
/** @param {...any} args - params */
|
|
2976
|
+
error(...args) {
|
|
2977
|
+
const _ = this;
|
|
2978
|
+
const desc = _.getDesc(args);
|
|
2979
|
+
if (desc) console.error(desc, ...args);
|
|
2980
|
+
else console.log(...args);
|
|
2981
|
+
}
|
|
2982
|
+
|
|
2983
|
+
/**
|
|
2984
|
+
* 用于 catch(e) log.err(e)
|
|
2985
|
+
* @param {...any} args - params */
|
|
2986
|
+
err(...args) {
|
|
2987
|
+
const _ = this;
|
|
2988
|
+
const first = args?.[0];
|
|
2989
|
+
if (
|
|
2990
|
+
first instanceof Error ||
|
|
2991
|
+
(first && first.message && first.cause && first.stack)
|
|
2992
|
+
)
|
|
2993
|
+
args[0] = { exp: args[0].message };
|
|
2994
|
+
_.error(...args);
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
|
|
2998
|
+
function getDesc(args) {
|
|
2999
|
+
let desc = '';
|
|
3000
|
+
const last = args.at(-1);
|
|
3001
|
+
if (typeof last === 'string') {
|
|
3002
|
+
desc = last;
|
|
3003
|
+
args.pop();
|
|
3004
|
+
}
|
|
3005
|
+
return desc
|
|
3006
|
+
}
|
|
3007
|
+
|
|
3008
|
+
/**
|
|
3009
|
+
* 标准日志输出或构建模块日志类实例,用于模块中带[m:xxx]标记日志输出
|
|
3010
|
+
* 启用 {f:fn} 标记时,需在函数尾部清除f(log({f:''})),否则会溢出到其他函数
|
|
3011
|
+
* @param {...any} args - params
|
|
3012
|
+
* returns {*}
|
|
3013
|
+
*/
|
|
3014
|
+
function log(...args) {
|
|
3015
|
+
const last = args.at(-1);
|
|
3016
|
+
|
|
3017
|
+
// 全局日志
|
|
3018
|
+
if (args.length !== 1 || !last?.m) {
|
|
3019
|
+
const desc = getDesc(args);
|
|
3020
|
+
desc ? console.log(desc, ...args) : console.log(...args);
|
|
3021
|
+
return
|
|
3022
|
+
}
|
|
3023
|
+
|
|
3024
|
+
// 唯一 m 属性,则构造新的 log 实例,这种写法,能被jsDoc识别子属性
|
|
3025
|
+
const lg = new Log(last?.m);
|
|
3026
|
+
/** @param {*} args2 */
|
|
3027
|
+
const R = (...args2) => lg.log(...args2);
|
|
3028
|
+
R.debug = lg.debug.bind(lg);
|
|
3029
|
+
R.info = lg.info.bind(lg);
|
|
3030
|
+
R.warn = lg.warn.bind(lg);
|
|
3031
|
+
R.info = lg.info.bind(lg);
|
|
3032
|
+
R.trace = lg.trace.bind(lg);
|
|
3033
|
+
R.error = lg.error.bind(lg);
|
|
3034
|
+
R.err = lg.err.bind(lg);
|
|
3035
|
+
|
|
3036
|
+
return R
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
/**
|
|
3040
|
+
* 用于 catch(e) log.err(e)
|
|
3041
|
+
* @param {...any} args - params */
|
|
3042
|
+
log.err = (...args) => {
|
|
3043
|
+
const desc = getDesc(args);
|
|
3044
|
+
const first = args?.[0];
|
|
3045
|
+
if (
|
|
3046
|
+
first instanceof Error ||
|
|
3047
|
+
(first && first.message && first.cause && first.stack)
|
|
3048
|
+
)
|
|
3049
|
+
args[0] = { exp: args[0].message };
|
|
3050
|
+
desc ? console.error(desc, ...args) : console.error(...args);
|
|
3051
|
+
};
|
|
3052
|
+
|
|
3053
|
+
/**
|
|
3054
|
+
* @param {...any} args - params */
|
|
3055
|
+
log.error = (...args) => {
|
|
3056
|
+
const desc = getDesc(args);
|
|
3057
|
+
desc ? console.error(desc, ...args) : console.error(...args);
|
|
3058
|
+
};
|
|
3059
|
+
|
|
3060
|
+
/**
|
|
3061
|
+
* @param {...any} args - params */
|
|
3062
|
+
log.warn = (...args) => {
|
|
3063
|
+
const desc = getDesc(args);
|
|
3064
|
+
desc ? console.warn(desc, ...args) : console.warn(...args);
|
|
3065
|
+
};
|
|
3066
|
+
|
|
3067
|
+
/**
|
|
3068
|
+
* @param {...any} args - params */
|
|
3069
|
+
log.info = (...args) => {
|
|
3070
|
+
const desc = getDesc(args);
|
|
3071
|
+
desc ? console.info(desc, ...args) : console.info(...args);
|
|
3072
|
+
};
|
|
3073
|
+
|
|
3074
|
+
/**
|
|
3075
|
+
* @param {...any} args - params */
|
|
3076
|
+
log.debug = (...args) => {
|
|
3077
|
+
const desc = getDesc(args);
|
|
3078
|
+
desc ? console.log(desc, ...args) : console.log(...args);
|
|
3079
|
+
};
|
|
3080
|
+
|
|
3081
|
+
/**
|
|
3082
|
+
* @param {...any} args - params */
|
|
3083
|
+
log.trace = (...args) => {
|
|
3084
|
+
const desc = getDesc(args);
|
|
3085
|
+
desc ? console.trace(desc, ...args) : console.trace(...args);
|
|
3086
|
+
};
|
|
3087
|
+
|
|
2533
3088
|
var Page = function (_Event) {
|
|
2534
3089
|
function Page(app, name, title, style) {
|
|
2535
3090
|
var _this;
|
|
@@ -2559,27 +3114,27 @@
|
|
|
2559
3114
|
this.emit('local::load pageLoad', param);
|
|
2560
3115
|
this.emit('pageLoad', this, param);
|
|
2561
3116
|
};
|
|
2562
|
-
_proto.ready = function ready(view, param,
|
|
3117
|
+
_proto.ready = function ready(view, param, lastPath) {
|
|
2563
3118
|
this.init();
|
|
2564
|
-
this.emit('local::ready', view, param,
|
|
2565
|
-
this.emit('pageReady', this, view, param,
|
|
3119
|
+
this.emit('local::ready', view, param, lastPath);
|
|
3120
|
+
this.emit('pageReady', this, view, param, lastPath);
|
|
2566
3121
|
};
|
|
2567
3122
|
_proto.init = function init(v) {
|
|
2568
3123
|
var view = this.view;
|
|
2569
3124
|
v = v ? $(v) : view;
|
|
2570
3125
|
};
|
|
2571
|
-
_proto.show = function show(view, param) {
|
|
3126
|
+
_proto.show = function show(view, param, lastPath) {
|
|
2572
3127
|
view.qus('[name$=-tp]').hide();
|
|
2573
3128
|
view.qus('a[href=""]').attr('href', 'javascript:;');
|
|
2574
3129
|
if (this.reset) this.reset();
|
|
2575
|
-
this.emit('local::show', view, param);
|
|
2576
|
-
this.emit('pageShow', this, view, param);
|
|
3130
|
+
this.emit('local::show', view, param, lastPath);
|
|
3131
|
+
this.emit('pageShow', this, view, param, lastPath);
|
|
2577
3132
|
};
|
|
2578
|
-
_proto.back = function back(view, param) {
|
|
3133
|
+
_proto.back = function back(view, param, lastPath) {
|
|
2579
3134
|
view.qus('[name$=-tp]').hide();
|
|
2580
3135
|
view.qus('a[href=""]').attr('href', 'javascript:;');
|
|
2581
|
-
this.emit('local::back', view, param);
|
|
2582
|
-
this.emit('pageBack', this, view, param);
|
|
3136
|
+
this.emit('local::back', view, param, lastPath);
|
|
3137
|
+
this.emit('pageBack', this, view, param, lastPath);
|
|
2583
3138
|
};
|
|
2584
3139
|
_proto.change = function change(view, param, lastParam) {
|
|
2585
3140
|
this.emit('local::change', view, param, lastParam);
|
|
@@ -2595,6 +3150,165 @@
|
|
|
2595
3150
|
};
|
|
2596
3151
|
return Page;
|
|
2597
3152
|
}(Event);
|
|
3153
|
+
function page(def, hooks) {
|
|
3154
|
+
if (hooks === void 0) {
|
|
3155
|
+
hooks = {};
|
|
3156
|
+
}
|
|
3157
|
+
var _log = log({
|
|
3158
|
+
m: "" + def.name
|
|
3159
|
+
});
|
|
3160
|
+
return function (_Page) {
|
|
3161
|
+
function _class(opts) {
|
|
3162
|
+
var _this2;
|
|
3163
|
+
if (opts === void 0) {
|
|
3164
|
+
opts = {};
|
|
3165
|
+
}
|
|
3166
|
+
var opt = _extends({}, def, opts);
|
|
3167
|
+
_this2 = _Page.call(this, opt.app, opt.name, opt.title) || this;
|
|
3168
|
+
_this2.opt = opt;
|
|
3169
|
+
_this2.on('local::load', function (param) {
|
|
3170
|
+
return _log({
|
|
3171
|
+
param: param
|
|
3172
|
+
}, 'load');
|
|
3173
|
+
});
|
|
3174
|
+
_this2.on('local::ready', function (v, param, lastPath) {
|
|
3175
|
+
return _log({
|
|
3176
|
+
v: v,
|
|
3177
|
+
param: param,
|
|
3178
|
+
lastPath: lastPath,
|
|
3179
|
+
id: _this2.id
|
|
3180
|
+
}, 'ready');
|
|
3181
|
+
});
|
|
3182
|
+
_this2.on('local::show', function (v, param, lastPath) {
|
|
3183
|
+
return _log({
|
|
3184
|
+
v: v,
|
|
3185
|
+
param: param,
|
|
3186
|
+
lastPath: lastPath,
|
|
3187
|
+
id: _this2.id
|
|
3188
|
+
}, 'show');
|
|
3189
|
+
});
|
|
3190
|
+
_this2.on('local::change', function (v, param, lastParam) {
|
|
3191
|
+
return _log({
|
|
3192
|
+
v: v,
|
|
3193
|
+
param: param,
|
|
3194
|
+
lastParam: lastParam
|
|
3195
|
+
}, 'change');
|
|
3196
|
+
});
|
|
3197
|
+
_this2.on('local::back', function (v, param, lastPath) {
|
|
3198
|
+
return _log({
|
|
3199
|
+
v: v,
|
|
3200
|
+
param: param,
|
|
3201
|
+
lastPath: lastPath,
|
|
3202
|
+
id: _this2.id
|
|
3203
|
+
}, 'back');
|
|
3204
|
+
});
|
|
3205
|
+
_this2.on('local::hide', function (v) {
|
|
3206
|
+
return _log({
|
|
3207
|
+
v: v,
|
|
3208
|
+
id: _this2.id
|
|
3209
|
+
}, 'hide');
|
|
3210
|
+
});
|
|
3211
|
+
_this2.on('local::unload', function (v) {
|
|
3212
|
+
return _log({
|
|
3213
|
+
v: v,
|
|
3214
|
+
id: _this2.id
|
|
3215
|
+
}, 'unload');
|
|
3216
|
+
});
|
|
3217
|
+
return _this2;
|
|
3218
|
+
}
|
|
3219
|
+
_inheritsLoose(_class, _Page);
|
|
3220
|
+
var _proto2 = _class.prototype;
|
|
3221
|
+
_proto2.load = function load(param) {
|
|
3222
|
+
_Page.prototype.load.call(this, param);
|
|
3223
|
+
if (hooks.load) hooks.load({
|
|
3224
|
+
param: param,
|
|
3225
|
+
pg: this,
|
|
3226
|
+
log: _log
|
|
3227
|
+
});
|
|
3228
|
+
};
|
|
3229
|
+
_proto2.ready = function () {
|
|
3230
|
+
var _ready = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(v, param, lastPath) {
|
|
3231
|
+
var ctx;
|
|
3232
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3233
|
+
while (1) switch (_context.prev = _context.next) {
|
|
3234
|
+
case 0:
|
|
3235
|
+
_Page.prototype.ready.call(this, v, param, lastPath);
|
|
3236
|
+
ctx = {
|
|
3237
|
+
v: v,
|
|
3238
|
+
pg: this,
|
|
3239
|
+
param: param,
|
|
3240
|
+
lastPath: lastPath,
|
|
3241
|
+
log: _log
|
|
3242
|
+
};
|
|
3243
|
+
if (!hooks.init) {
|
|
3244
|
+
_context.next = 5;
|
|
3245
|
+
break;
|
|
3246
|
+
}
|
|
3247
|
+
_context.next = 5;
|
|
3248
|
+
return hooks.init(ctx);
|
|
3249
|
+
case 5:
|
|
3250
|
+
if (hooks.bind) hooks.bind(ctx);
|
|
3251
|
+
case 6:
|
|
3252
|
+
case "end":
|
|
3253
|
+
return _context.stop();
|
|
3254
|
+
}
|
|
3255
|
+
}, _callee, this);
|
|
3256
|
+
}));
|
|
3257
|
+
function ready(_x, _x2, _x3) {
|
|
3258
|
+
return _ready.apply(this, arguments);
|
|
3259
|
+
}
|
|
3260
|
+
return ready;
|
|
3261
|
+
}();
|
|
3262
|
+
_proto2.show = function show(v, param, lastPath) {
|
|
3263
|
+
_Page.prototype.show.call(this, v, param, lastPath);
|
|
3264
|
+
if (hooks.show) hooks.show({
|
|
3265
|
+
v: v,
|
|
3266
|
+
pg: this,
|
|
3267
|
+
param: param,
|
|
3268
|
+
lastPath: lastPath,
|
|
3269
|
+
log: _log
|
|
3270
|
+
});
|
|
3271
|
+
};
|
|
3272
|
+
_proto2.change = function change(v, param, lastParam) {
|
|
3273
|
+
_Page.prototype.change.call(this, v, param, lastParam);
|
|
3274
|
+
if (hooks.change) hooks.change({
|
|
3275
|
+
v: v,
|
|
3276
|
+
pg: this,
|
|
3277
|
+
param: param,
|
|
3278
|
+
lastParam: lastParam,
|
|
3279
|
+
log: _log
|
|
3280
|
+
});
|
|
3281
|
+
};
|
|
3282
|
+
_proto2.back = function back(v, param, lastPath) {
|
|
3283
|
+
_Page.prototype.back.call(this, v, param, lastPath);
|
|
3284
|
+
if (hooks.back) hooks.back({
|
|
3285
|
+
v: v,
|
|
3286
|
+
pg: this,
|
|
3287
|
+
param: param,
|
|
3288
|
+
lastPath: lastPath,
|
|
3289
|
+
log: _log
|
|
3290
|
+
});
|
|
3291
|
+
};
|
|
3292
|
+
_proto2.hide = function hide(v, param) {
|
|
3293
|
+
_Page.prototype.hide.call(this, v, param);
|
|
3294
|
+
if (hooks.hide) hooks.hide({
|
|
3295
|
+
v: v,
|
|
3296
|
+
pg: this,
|
|
3297
|
+
param: param,
|
|
3298
|
+
log: _log
|
|
3299
|
+
});
|
|
3300
|
+
};
|
|
3301
|
+
_proto2.unload = function unload(v) {
|
|
3302
|
+
_Page.prototype.unload.call(this, v);
|
|
3303
|
+
if (hooks.unload) hooks.unload({
|
|
3304
|
+
v: v,
|
|
3305
|
+
pg: this,
|
|
3306
|
+
log: _log
|
|
3307
|
+
});
|
|
3308
|
+
};
|
|
3309
|
+
return _class;
|
|
3310
|
+
}(Page);
|
|
3311
|
+
}
|
|
2598
3312
|
|
|
2599
3313
|
var Module = function (_Event) {
|
|
2600
3314
|
function Module(params, parents) {
|
|
@@ -4371,5 +5085,6 @@
|
|
|
4371
5085
|
exports.Utils = Utils;
|
|
4372
5086
|
exports.jsx = jsx;
|
|
4373
5087
|
exports.loadModule = loadModule;
|
|
5088
|
+
exports.page = page;
|
|
4374
5089
|
|
|
4375
5090
|
}));
|