@wiajs/core 1.2.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * wia core v1.2.1
3
- * (c) 2015-2025 Sibyl Yu and contributors
2
+ * wia core v2.1.0
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,527 @@
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
+ * @typedef {Object} LogOptions
2868
+ * @property {string} m - 模块名称
2869
+ */
2870
+
2871
+ /**
2872
+ * @typedef {((...args: any[]) => void) & { debug: (...args: any[])=>void, info: (...args: any[])=>void, warn: (...args: any[])=>void, error: (...args: any[])=>void, err: (...args: any[])=>void }} ScopedLogger
2873
+ */
2874
+
2875
+ /**
2876
+ * @typedef {((...args: any[]) => void) & { log: (...args: any[])=>void, debug: (...args: any[])=>void, info: (...args: any[])=>void, warn: (...args: any[])=>void, error: (...args: any[])=>void, err: (...args: any[])=>void, fn: (name: string) => ScopedLogger }} LoggerFn
2877
+ */
2878
+
2879
+ // 1. 安全地获取开发环境状态(兼容打包工具、浏览器和 Node.js)
2880
+ // 如果 Rspack 注入了 __DEV__,就用注入的值;如果是在 Node.js 下,就回退读取 "production"
2881
+ const isDev = typeof __DEV__ !== 'undefined' ? __DEV__ : "production" !== 'production';
2882
+
2883
+ /**
2884
+ * 前端日志输出,封装 console 日志,简化代码
2885
+ * 自动识别并重排提示符与对象,保持前后端一致性
2886
+ */
2887
+ class Log {
2888
+ /** @type {string} 模块名称 */
2889
+ m = ''
2890
+
2891
+ /** @type {string} 函数名称 */
2892
+ fnName = ''
2893
+
2894
+ /**
2895
+ * @param {string} [m=''] 模块
2896
+ * @param {string} [fnName=''] 函数
2897
+ */
2898
+ constructor(m = '', fnName = '') {
2899
+ this.m = m;
2900
+ this.fnName = fnName;
2901
+ }
2902
+
2903
+ /**
2904
+ * 格式化参数:提取提示符,构建前缀,将对象后置
2905
+ * 格式要求:[模块名称:函数名称]提示符: {对象}
2906
+ * @param {any[]} args
2907
+ * @returns {any[]} 返回处理后传递给 console 的参数数组
2908
+ */
2909
+ formatArgs(args) {
2910
+ let R = '';
2911
+ const _ = this;
2912
+ try {
2913
+ const msgs = [];
2914
+ const objs = [];
2915
+
2916
+ // 1. 将字符串(提示符)和非字符串(对象/数值等)分开
2917
+ for (const arg of args) {
2918
+ if (typeof arg === 'string') msgs.push(arg);
2919
+ else objs.push(arg);
2920
+ }
2921
+
2922
+ let prefix = '';
2923
+
2924
+ // 2. 添加模块与函数前缀
2925
+ if (_.m) prefix = `[${_.m}${_.fnName ? ':' + _.fnName : ''}]`;
2926
+ else if (_.fnName) prefix = `[:${_.fnName}]`;
2927
+
2928
+ // 3. 拼接提示符
2929
+ const msg = msgs.join(' ');
2930
+ if (msg) prefix += msg;
2931
+
2932
+ R = [];
2933
+ if (prefix) R.push(prefix);
2934
+ R.push(...objs);
2935
+ } catch (e) {
2936
+ console.error(`formatArgs exp:${e.message}`);
2937
+ }
2938
+
2939
+ return R
2940
+ }
2941
+
2942
+ /** @param {...any} args */
2943
+ log(...args) {
2944
+ // 生产环境安全剔除 (需 Rspack DefinePlugin 注入 __DEV__)
2945
+ if (isDev) console.log(...this.formatArgs(args));
2946
+ }
2947
+
2948
+ /** @param {...any} args */
2949
+ debug(...args) {
2950
+ if (isDev) console.debug(...this.formatArgs(args));
2951
+ }
2952
+
2953
+ /** @param {...any} args */
2954
+ info(...args) {
2955
+ if (isDev) console.info(...this.formatArgs(args));
2956
+ }
2957
+
2958
+ /** @param {...any} args */
2959
+ warn(...args) {
2960
+ if (isDev) console.warn(...this.formatArgs(args));
2961
+ }
2962
+
2963
+ /** @param {...any} args */
2964
+ trace(...args) {
2965
+ if (isDev) console.trace(...this.formatArgs(args));
2966
+ }
2967
+
2968
+ /** * error 会在生产环境保留
2969
+ * @param {...any} args
2970
+ */
2971
+ error(...args) {
2972
+ console.error(...this.formatArgs(args));
2973
+ }
2974
+
2975
+ /**
2976
+ * 用于 catch(e) log.err(e) 或 log.err("提示符", e) 或 log.err(e, "提示符")
2977
+ * 自动对齐前缀 [模块:函数] 提示符: Error对象,并保留堆栈
2978
+ * @param {...any} args
2979
+ */
2980
+ err(...args) {
2981
+ // 生产环境安全输出,不会被 Tree-shaking 摇掉
2982
+ // formatArgs 会自动分离字符串与 Error 对象,并补全冒号
2983
+ const formattedArgs = this.formatArgs(args);
2984
+
2985
+ // 原生打印,保持 stack trace 可点击跳转!
2986
+ console.error(...formattedArgs);
2987
+ }
2988
+
2989
+ /**
2990
+ * 派生函数级别日志实例 (完美对齐后端 log.fn)
2991
+ * @param {string} name 函数名称
2992
+ * @returns {ScopedLogger}
2993
+ */
2994
+ fn(name) {
2995
+ const scopedLog = new Log(this.m, name);
2996
+
2997
+ /** @type {any} */
2998
+ const R = (...args) => scopedLog.log(...args);
2999
+
3000
+ R.debug = scopedLog.debug.bind(scopedLog);
3001
+ R.info = scopedLog.info.bind(scopedLog);
3002
+ R.warn = scopedLog.warn.bind(scopedLog);
3003
+ R.trace = scopedLog.trace.bind(scopedLog);
3004
+ R.error = scopedLog.error.bind(scopedLog);
3005
+ R.err = scopedLog.err.bind(scopedLog);
3006
+
3007
+ return /** @type {ScopedLogger} */ (R)
3008
+ }
3009
+ }
3010
+
3011
+ // 实例化唯一的全局日志单例
3012
+ const _log = new Log();
3013
+
3014
+ /**
3015
+ * 标准日志输出或构建模块日志类实例,用于模块中带[m:xxx]标记日志输出
3016
+ * 传入 { m: '模块名' } 构建实例,或直接传入参数输出全局日志
3017
+ * @param {...any} args - params
3018
+ * returns {*}
3019
+ */
3020
+ function log(...args) {
3021
+ const last = args.at(-1);
3022
+
3023
+ // 1. 如果只有一个参数且带 m 属性,说明是构造 Logger 实例 (如: const log = Log({m: 'User'}))
3024
+ if (args.length === 1 && typeof last === 'object' && last !== null && 'm' in last) {
3025
+ const lg = new Log(last.m);
3026
+
3027
+ /** @type {any} */
3028
+ const R = (...args2) => lg.log(...args2);
3029
+
3030
+ R.log = lg.log.bind(lg);
3031
+ R.debug = lg.debug.bind(lg);
3032
+ R.info = lg.info.bind(lg);
3033
+ R.warn = lg.warn.bind(lg);
3034
+ R.trace = lg.trace.bind(lg);
3035
+ R.error = lg.error.bind(lg);
3036
+ R.err = lg.err.bind(lg);
3037
+ R.fn = lg.fn.bind(lg); // 暴露派生函数作用域方法
3038
+
3039
+ return /** @type {LoggerFn} */ (R)
3040
+ }
3041
+
3042
+ // 2. 否则作为全局普通日志直接输出
3043
+ _log.log(...args);
3044
+ }
3045
+
3046
+ // 绑定全局快捷方法,方便直接调用 log.err(e) 等
3047
+ log.err = _log.err.bind(_log);
3048
+ log.error = _log.error.bind(_log);
3049
+ log.warn = _log.warn.bind(_log);
3050
+ log.info = _log.info.bind(_log);
3051
+ log.debug = _log.debug.bind(_log);
3052
+ log.trace = _log.trace.bind(_log);
3053
+
2533
3054
  var Page = function (_Event) {
2534
3055
  function Page(app, name, title, style) {
2535
3056
  var _this;
@@ -2559,27 +3080,27 @@
2559
3080
  this.emit('local::load pageLoad', param);
2560
3081
  this.emit('pageLoad', this, param);
2561
3082
  };
2562
- _proto.ready = function ready(view, param, back) {
3083
+ _proto.ready = function ready(view, param, lastPath) {
2563
3084
  this.init();
2564
- this.emit('local::ready', view, param, back);
2565
- this.emit('pageReady', this, view, param, back);
3085
+ this.emit('local::ready', view, param, lastPath);
3086
+ this.emit('pageReady', this, view, param, lastPath);
2566
3087
  };
2567
3088
  _proto.init = function init(v) {
2568
3089
  var view = this.view;
2569
3090
  v = v ? $(v) : view;
2570
3091
  };
2571
- _proto.show = function show(view, param) {
3092
+ _proto.show = function show(view, param, lastPath) {
2572
3093
  view.qus('[name$=-tp]').hide();
2573
3094
  view.qus('a[href=""]').attr('href', 'javascript:;');
2574
3095
  if (this.reset) this.reset();
2575
- this.emit('local::show', view, param);
2576
- this.emit('pageShow', this, view, param);
3096
+ this.emit('local::show', view, param, lastPath);
3097
+ this.emit('pageShow', this, view, param, lastPath);
2577
3098
  };
2578
- _proto.back = function back(view, param) {
3099
+ _proto.back = function back(view, param, lastPath) {
2579
3100
  view.qus('[name$=-tp]').hide();
2580
3101
  view.qus('a[href=""]').attr('href', 'javascript:;');
2581
- this.emit('local::back', view, param);
2582
- this.emit('pageBack', this, view, param);
3102
+ this.emit('local::back', view, param, lastPath);
3103
+ this.emit('pageBack', this, view, param, lastPath);
2583
3104
  };
2584
3105
  _proto.change = function change(view, param, lastParam) {
2585
3106
  this.emit('local::change', view, param, lastParam);
@@ -2595,6 +3116,165 @@
2595
3116
  };
2596
3117
  return Page;
2597
3118
  }(Event);
3119
+ function page(def, hooks) {
3120
+ if (hooks === void 0) {
3121
+ hooks = {};
3122
+ }
3123
+ var _log = log({
3124
+ m: "" + def.name
3125
+ });
3126
+ return function (_Page) {
3127
+ function _class(opts) {
3128
+ var _this2;
3129
+ if (opts === void 0) {
3130
+ opts = {};
3131
+ }
3132
+ var opt = _extends({}, def, opts);
3133
+ _this2 = _Page.call(this, opt.app, opt.name, opt.title) || this;
3134
+ _this2.opt = opt;
3135
+ _this2.on('local::load', function (param) {
3136
+ return _log({
3137
+ param: param
3138
+ }, 'load');
3139
+ });
3140
+ _this2.on('local::ready', function (v, param, lastPath) {
3141
+ return _log({
3142
+ v: v,
3143
+ param: param,
3144
+ lastPath: lastPath,
3145
+ id: _this2.id
3146
+ }, 'ready');
3147
+ });
3148
+ _this2.on('local::show', function (v, param, lastPath) {
3149
+ return _log({
3150
+ v: v,
3151
+ param: param,
3152
+ lastPath: lastPath,
3153
+ id: _this2.id
3154
+ }, 'show');
3155
+ });
3156
+ _this2.on('local::change', function (v, param, lastParam) {
3157
+ return _log({
3158
+ v: v,
3159
+ param: param,
3160
+ lastParam: lastParam
3161
+ }, 'change');
3162
+ });
3163
+ _this2.on('local::back', function (v, param, lastPath) {
3164
+ return _log({
3165
+ v: v,
3166
+ param: param,
3167
+ lastPath: lastPath,
3168
+ id: _this2.id
3169
+ }, 'back');
3170
+ });
3171
+ _this2.on('local::hide', function (v) {
3172
+ return _log({
3173
+ v: v,
3174
+ id: _this2.id
3175
+ }, 'hide');
3176
+ });
3177
+ _this2.on('local::unload', function (v) {
3178
+ return _log({
3179
+ v: v,
3180
+ id: _this2.id
3181
+ }, 'unload');
3182
+ });
3183
+ return _this2;
3184
+ }
3185
+ _inheritsLoose(_class, _Page);
3186
+ var _proto2 = _class.prototype;
3187
+ _proto2.load = function load(param) {
3188
+ _Page.prototype.load.call(this, param);
3189
+ if (hooks.load) hooks.load({
3190
+ param: param,
3191
+ pg: this,
3192
+ log: _log
3193
+ });
3194
+ };
3195
+ _proto2.ready = function () {
3196
+ var _ready = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(v, param, lastPath) {
3197
+ var ctx;
3198
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
3199
+ while (1) switch (_context.prev = _context.next) {
3200
+ case 0:
3201
+ _Page.prototype.ready.call(this, v, param, lastPath);
3202
+ ctx = {
3203
+ v: v,
3204
+ pg: this,
3205
+ param: param,
3206
+ lastPath: lastPath,
3207
+ log: _log
3208
+ };
3209
+ if (!hooks.init) {
3210
+ _context.next = 5;
3211
+ break;
3212
+ }
3213
+ _context.next = 5;
3214
+ return hooks.init(ctx);
3215
+ case 5:
3216
+ if (hooks.bind) hooks.bind(ctx);
3217
+ case 6:
3218
+ case "end":
3219
+ return _context.stop();
3220
+ }
3221
+ }, _callee, this);
3222
+ }));
3223
+ function ready(_x, _x2, _x3) {
3224
+ return _ready.apply(this, arguments);
3225
+ }
3226
+ return ready;
3227
+ }();
3228
+ _proto2.show = function show(v, param, lastPath) {
3229
+ _Page.prototype.show.call(this, v, param, lastPath);
3230
+ if (hooks.show) hooks.show({
3231
+ v: v,
3232
+ pg: this,
3233
+ param: param,
3234
+ lastPath: lastPath,
3235
+ log: _log
3236
+ });
3237
+ };
3238
+ _proto2.change = function change(v, param, lastParam) {
3239
+ _Page.prototype.change.call(this, v, param, lastParam);
3240
+ if (hooks.change) hooks.change({
3241
+ v: v,
3242
+ pg: this,
3243
+ param: param,
3244
+ lastParam: lastParam,
3245
+ log: _log
3246
+ });
3247
+ };
3248
+ _proto2.back = function back(v, param, lastPath) {
3249
+ _Page.prototype.back.call(this, v, param, lastPath);
3250
+ if (hooks.back) hooks.back({
3251
+ v: v,
3252
+ pg: this,
3253
+ param: param,
3254
+ lastPath: lastPath,
3255
+ log: _log
3256
+ });
3257
+ };
3258
+ _proto2.hide = function hide(v, param) {
3259
+ _Page.prototype.hide.call(this, v, param);
3260
+ if (hooks.hide) hooks.hide({
3261
+ v: v,
3262
+ pg: this,
3263
+ param: param,
3264
+ log: _log
3265
+ });
3266
+ };
3267
+ _proto2.unload = function unload(v) {
3268
+ _Page.prototype.unload.call(this, v);
3269
+ if (hooks.unload) hooks.unload({
3270
+ v: v,
3271
+ pg: this,
3272
+ log: _log
3273
+ });
3274
+ };
3275
+ return _class;
3276
+ }(Page);
3277
+ }
2598
3278
 
2599
3279
  var Module = function (_Event) {
2600
3280
  function Module(params, parents) {
@@ -4371,5 +5051,6 @@
4371
5051
  exports.Utils = Utils;
4372
5052
  exports.jsx = jsx;
4373
5053
  exports.loadModule = loadModule;
5054
+ exports.page = page;
4374
5055
 
4375
5056
  }));