@tarojs/runtime 3.6.0-canary.8 → 3.6.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/bom/URL.d.ts +50 -0
- package/dist/bom/location.d.ts +12 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/dom/anchor-element.d.ts +13 -0
- package/dist/dom/event.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/runtime.esm.d.ts +59 -4
- package/dist/runtime.esm.js +719 -465
- package/dist/runtime.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/runtime.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { noop, isFunction, getComponentsAlias as getComponentsAlias$1, internalComponents, EMPTY_OBJ, hooks, toCamelCase, isObject, warn, isArray, ensure, isNull, isUndefined, toDashed, isString,
|
|
1
|
+
import { noop, isFunction, getComponentsAlias as getComponentsAlias$1, internalComponents, EMPTY_OBJ, hooks, toCamelCase, isObject, warn, isArray, ensure, isNull, isUndefined, toDashed, isString, Events, isNumber, controlledComponent } from '@tarojs/shared';
|
|
2
2
|
export { Events, hooks } from '@tarojs/shared';
|
|
3
3
|
|
|
4
4
|
const PROPERTY_THRESHOLD = 2046;
|
|
@@ -43,7 +43,9 @@ const ON_SHOW = 'onShow';
|
|
|
43
43
|
const ON_HIDE = 'onHide';
|
|
44
44
|
const OPTIONS = 'options';
|
|
45
45
|
const EXTERNAL_CLASSES = 'externalClasses';
|
|
46
|
+
const EVENT_CALLBACK_RESULT = 'e_result';
|
|
46
47
|
const BEHAVIORS = 'behaviors';
|
|
48
|
+
const A = 'a';
|
|
47
49
|
/**
|
|
48
50
|
* 页面上下文切换时的行为
|
|
49
51
|
*/
|
|
@@ -463,7 +465,7 @@ class TaroEventTarget {
|
|
|
463
465
|
// 因此每次绑定事件都新建一个函数,如果带来了性能问题,可以把这段逻辑抽取到 PReact 插件中。
|
|
464
466
|
const oldHandler = handler;
|
|
465
467
|
handler = function () {
|
|
466
|
-
oldHandler.apply(this, arguments); // this 指向 Element
|
|
468
|
+
return oldHandler.apply(this, arguments); // this 指向 Element
|
|
467
469
|
};
|
|
468
470
|
handler.oldHandler = oldHandler;
|
|
469
471
|
const handlers = this.__handlers[type];
|
|
@@ -1367,6 +1369,9 @@ class TaroElement extends TaroNode {
|
|
|
1367
1369
|
if ((result === false || event._end) && cancelable) {
|
|
1368
1370
|
event.defaultPrevented = true;
|
|
1369
1371
|
}
|
|
1372
|
+
if (!isUndefined(result) && event.mpEvent) {
|
|
1373
|
+
event.mpEvent[EVENT_CALLBACK_RESULT] = result;
|
|
1374
|
+
}
|
|
1370
1375
|
if (event._end && event._stop) {
|
|
1371
1376
|
break;
|
|
1372
1377
|
}
|
|
@@ -2426,6 +2431,13 @@ function createEvent(event, node) {
|
|
|
2426
2431
|
return domEv;
|
|
2427
2432
|
}
|
|
2428
2433
|
const eventsBatch = {};
|
|
2434
|
+
function getEventCBResult(event) {
|
|
2435
|
+
const result = event[EVENT_CALLBACK_RESULT];
|
|
2436
|
+
if (!isUndefined(result)) {
|
|
2437
|
+
delete event[EVENT_CALLBACK_RESULT];
|
|
2438
|
+
}
|
|
2439
|
+
return result;
|
|
2440
|
+
}
|
|
2429
2441
|
// 小程序的事件代理回调函数
|
|
2430
2442
|
function eventHandler(event) {
|
|
2431
2443
|
var _a, _b;
|
|
@@ -2460,6 +2472,7 @@ function eventHandler(event) {
|
|
|
2460
2472
|
}
|
|
2461
2473
|
dispatch();
|
|
2462
2474
|
});
|
|
2475
|
+
return getEventCBResult(event);
|
|
2463
2476
|
}
|
|
2464
2477
|
else {
|
|
2465
2478
|
// 如果上层组件也有绑定同类型的组件,委托给上层组件调用事件回调
|
|
@@ -2468,6 +2481,7 @@ function eventHandler(event) {
|
|
|
2468
2481
|
}
|
|
2469
2482
|
else {
|
|
2470
2483
|
dispatch();
|
|
2484
|
+
return getEventCBResult(event);
|
|
2471
2485
|
}
|
|
2472
2486
|
}
|
|
2473
2487
|
}
|
|
@@ -2715,153 +2729,6 @@ class TaroText extends TaroNode {
|
|
|
2715
2729
|
}
|
|
2716
2730
|
}
|
|
2717
2731
|
|
|
2718
|
-
class TaroDocument extends TaroElement {
|
|
2719
|
-
constructor() {
|
|
2720
|
-
super();
|
|
2721
|
-
this.createEvent = createEvent;
|
|
2722
|
-
this.nodeType = 9 /* NodeType.DOCUMENT_NODE */;
|
|
2723
|
-
this.nodeName = DOCUMENT_ELEMENT_NAME;
|
|
2724
|
-
}
|
|
2725
|
-
createElement(type) {
|
|
2726
|
-
if (type === ROOT_STR) {
|
|
2727
|
-
return new TaroRootElement();
|
|
2728
|
-
}
|
|
2729
|
-
const element = controlledComponent.has(type)
|
|
2730
|
-
? new FormElement()
|
|
2731
|
-
: new TaroElement();
|
|
2732
|
-
element.nodeName = type;
|
|
2733
|
-
element.tagName = type.toUpperCase();
|
|
2734
|
-
return element;
|
|
2735
|
-
}
|
|
2736
|
-
// an ugly fake createElementNS to deal with @vue/runtime-dom's
|
|
2737
|
-
// support mounting app to svg container since vue@3.0.8
|
|
2738
|
-
createElementNS(_svgNS, type) {
|
|
2739
|
-
return this.createElement(type);
|
|
2740
|
-
}
|
|
2741
|
-
createTextNode(text) {
|
|
2742
|
-
return new TaroText(text);
|
|
2743
|
-
}
|
|
2744
|
-
getElementById(id) {
|
|
2745
|
-
const el = eventSource.get(id);
|
|
2746
|
-
return isUndefined(el) ? null : el;
|
|
2747
|
-
}
|
|
2748
|
-
querySelector(query) {
|
|
2749
|
-
// 为了 Vue3 的乞丐版实现
|
|
2750
|
-
if (/^#/.test(query)) {
|
|
2751
|
-
return this.getElementById(query.slice(1));
|
|
2752
|
-
}
|
|
2753
|
-
return null;
|
|
2754
|
-
}
|
|
2755
|
-
querySelectorAll() {
|
|
2756
|
-
// fake hack
|
|
2757
|
-
return [];
|
|
2758
|
-
}
|
|
2759
|
-
// @TODO: @PERF: 在 hydrate 移除掉空的 node
|
|
2760
|
-
createComment() {
|
|
2761
|
-
const textnode = new TaroText('');
|
|
2762
|
-
textnode.nodeName = COMMENT;
|
|
2763
|
-
return textnode;
|
|
2764
|
-
}
|
|
2765
|
-
get defaultView() {
|
|
2766
|
-
return env.window;
|
|
2767
|
-
}
|
|
2768
|
-
}
|
|
2769
|
-
|
|
2770
|
-
let document$1;
|
|
2771
|
-
if (process.env.TARO_ENV && process.env.TARO_ENV !== 'h5') {
|
|
2772
|
-
/* eslint-disable no-inner-declarations */
|
|
2773
|
-
function createDocument() {
|
|
2774
|
-
/**
|
|
2775
|
-
* <document>
|
|
2776
|
-
* <html>
|
|
2777
|
-
* <head></head>
|
|
2778
|
-
* <body>
|
|
2779
|
-
* <container>
|
|
2780
|
-
* <app id="app" />
|
|
2781
|
-
* </container>
|
|
2782
|
-
* </body>
|
|
2783
|
-
* </html>
|
|
2784
|
-
* </document>
|
|
2785
|
-
*/
|
|
2786
|
-
const doc = new TaroDocument();
|
|
2787
|
-
const documentCreateElement = doc.createElement.bind(doc);
|
|
2788
|
-
const html = documentCreateElement(HTML);
|
|
2789
|
-
const head = documentCreateElement(HEAD);
|
|
2790
|
-
const body = documentCreateElement(BODY);
|
|
2791
|
-
const app = documentCreateElement(APP);
|
|
2792
|
-
app.id = APP;
|
|
2793
|
-
const container = documentCreateElement(CONTAINER); // 多包一层主要为了兼容 vue
|
|
2794
|
-
doc.appendChild(html);
|
|
2795
|
-
html.appendChild(head);
|
|
2796
|
-
html.appendChild(body);
|
|
2797
|
-
body.appendChild(container);
|
|
2798
|
-
container.appendChild(app);
|
|
2799
|
-
doc.documentElement = html;
|
|
2800
|
-
doc.head = head;
|
|
2801
|
-
doc.body = body;
|
|
2802
|
-
return doc;
|
|
2803
|
-
}
|
|
2804
|
-
document$1 = env.document = createDocument();
|
|
2805
|
-
}
|
|
2806
|
-
else {
|
|
2807
|
-
document$1 = env.document;
|
|
2808
|
-
}
|
|
2809
|
-
|
|
2810
|
-
function getComputedStyle(element) {
|
|
2811
|
-
return element.style;
|
|
2812
|
-
}
|
|
2813
|
-
|
|
2814
|
-
const machine = 'Macintosh';
|
|
2815
|
-
const arch = 'Intel Mac OS X 10_14_5';
|
|
2816
|
-
const engine = 'AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v4.1.0 Chrome/76.0.3809.132 Safari/534.36';
|
|
2817
|
-
const msg = '(' + machine + '; ' + arch + ') ' + engine;
|
|
2818
|
-
const nav = process.env.TARO_ENV === 'h5' ? env.window.navigator : {
|
|
2819
|
-
appCodeName: 'Mozilla',
|
|
2820
|
-
appName: 'Netscape',
|
|
2821
|
-
appVersion: '5.0 ' + msg,
|
|
2822
|
-
cookieEnabled: true,
|
|
2823
|
-
mimeTypes: [],
|
|
2824
|
-
onLine: true,
|
|
2825
|
-
platform: 'MacIntel',
|
|
2826
|
-
plugins: [],
|
|
2827
|
-
product: 'Taro',
|
|
2828
|
-
productSub: '20030107',
|
|
2829
|
-
userAgent: 'Mozilla/5.0 ' + msg,
|
|
2830
|
-
vendor: 'Joyent',
|
|
2831
|
-
vendorSub: ''
|
|
2832
|
-
};
|
|
2833
|
-
|
|
2834
|
-
// https://github.com/myrne/performance-now
|
|
2835
|
-
let now;
|
|
2836
|
-
(function () {
|
|
2837
|
-
let loadTime;
|
|
2838
|
-
if ((typeof performance !== 'undefined' && performance !== null) && performance.now) {
|
|
2839
|
-
now = () => performance.now();
|
|
2840
|
-
}
|
|
2841
|
-
else if (Date.now) {
|
|
2842
|
-
loadTime = Date.now();
|
|
2843
|
-
now = () => Date.now() - loadTime;
|
|
2844
|
-
}
|
|
2845
|
-
else {
|
|
2846
|
-
loadTime = new Date().getTime();
|
|
2847
|
-
now = () => new Date().getTime() - loadTime;
|
|
2848
|
-
}
|
|
2849
|
-
})();
|
|
2850
|
-
let lastTime = 0;
|
|
2851
|
-
// https://gist.github.com/paulirish/1579671
|
|
2852
|
-
// https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0
|
|
2853
|
-
const _raf = typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame !== null ? requestAnimationFrame : function (callback) {
|
|
2854
|
-
const _now = now();
|
|
2855
|
-
const nextTime = Math.max(lastTime + 16, _now); // First time will execute it immediately but barely noticeable and performance is gained.
|
|
2856
|
-
return setTimeout(function () { callback(lastTime = nextTime); }, nextTime - _now);
|
|
2857
|
-
};
|
|
2858
|
-
const _caf = typeof cancelAnimationFrame !== 'undefined' && cancelAnimationFrame !== null
|
|
2859
|
-
? cancelAnimationFrame
|
|
2860
|
-
: function (seed) {
|
|
2861
|
-
// fix https://github.com/NervJS/taro/issues/7749
|
|
2862
|
-
clearTimeout(seed);
|
|
2863
|
-
};
|
|
2864
|
-
|
|
2865
2732
|
/******************************************************************************
|
|
2866
2733
|
Copyright (c) Microsoft Corporation.
|
|
2867
2734
|
|
|
@@ -2890,271 +2757,43 @@ function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
|
2890
2757
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
2891
2758
|
}
|
|
2892
2759
|
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
'!': '%21',
|
|
2898
|
-
"'": '%27',
|
|
2899
|
-
'(': '%28',
|
|
2900
|
-
')': '%29',
|
|
2901
|
-
'~': '%7E',
|
|
2902
|
-
'%20': '+',
|
|
2903
|
-
'%00': '\x00',
|
|
2760
|
+
const Current = {
|
|
2761
|
+
app: null,
|
|
2762
|
+
router: null,
|
|
2763
|
+
page: null
|
|
2904
2764
|
};
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
appendTo(this, key, value);
|
|
2917
|
-
}
|
|
2918
|
-
function decode(str) {
|
|
2919
|
-
return decodeURIComponent(str.replace(plusReg, ' '));
|
|
2920
|
-
}
|
|
2921
|
-
function encode(str) {
|
|
2922
|
-
return encodeURIComponent(str).replace(findReg, replacer);
|
|
2923
|
-
}
|
|
2924
|
-
class URLSearchParams {
|
|
2925
|
-
constructor(query) {
|
|
2926
|
-
_URLSearchParams_dict.set(this, Object.create(null));
|
|
2927
|
-
if (!query)
|
|
2928
|
-
return;
|
|
2929
|
-
const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
2930
|
-
if (typeof query === 'string') {
|
|
2931
|
-
if (query.charAt(0) === '?') {
|
|
2932
|
-
query = query.slice(1);
|
|
2933
|
-
}
|
|
2934
|
-
for (let pairs = query.split('&'), i = 0, length = pairs.length; i < length; i++) {
|
|
2935
|
-
const value = pairs[i];
|
|
2936
|
-
const index = value.indexOf('=');
|
|
2937
|
-
if (index > -1) {
|
|
2938
|
-
appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
|
|
2939
|
-
}
|
|
2940
|
-
else if (value.length) {
|
|
2941
|
-
appendTo(dict, decode(value), '');
|
|
2942
|
-
}
|
|
2943
|
-
}
|
|
2944
|
-
}
|
|
2945
|
-
else {
|
|
2946
|
-
if (isArray(query)) {
|
|
2947
|
-
for (let i = 0, length = query.length; i < length; i++) {
|
|
2948
|
-
const value = query[i];
|
|
2949
|
-
appendTo(dict, value[0], value[1]);
|
|
2950
|
-
}
|
|
2951
|
-
}
|
|
2952
|
-
else if (query.forEach) {
|
|
2953
|
-
query.forEach(addEach, dict);
|
|
2954
|
-
}
|
|
2955
|
-
else {
|
|
2956
|
-
for (const key in query) {
|
|
2957
|
-
appendTo(dict, key, query[key]);
|
|
2958
|
-
}
|
|
2959
|
-
}
|
|
2960
|
-
}
|
|
2961
|
-
}
|
|
2962
|
-
append(name, value) {
|
|
2963
|
-
appendTo(__classPrivateFieldGet(this, _URLSearchParams_dict, "f"), name, value);
|
|
2964
|
-
}
|
|
2965
|
-
delete(name) {
|
|
2966
|
-
delete __classPrivateFieldGet(this, _URLSearchParams_dict, "f")[name];
|
|
2765
|
+
const getCurrentInstance = () => Current;
|
|
2766
|
+
|
|
2767
|
+
const eventCenter = hooks.call('getEventCenter', Events);
|
|
2768
|
+
|
|
2769
|
+
/**
|
|
2770
|
+
* 一个小型缓存池,用于在切换页面时,存储一些上下文信息
|
|
2771
|
+
*/
|
|
2772
|
+
class RuntimeCache {
|
|
2773
|
+
constructor(name) {
|
|
2774
|
+
this.cache = new Map();
|
|
2775
|
+
this.name = name;
|
|
2967
2776
|
}
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
return name in dict ? dict[name][0] : null;
|
|
2777
|
+
has(identifier) {
|
|
2778
|
+
return this.cache.has(identifier);
|
|
2971
2779
|
}
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2780
|
+
set(identifier, ctx) {
|
|
2781
|
+
if (identifier && ctx) {
|
|
2782
|
+
this.cache.set(identifier, ctx);
|
|
2783
|
+
}
|
|
2975
2784
|
}
|
|
2976
|
-
|
|
2977
|
-
|
|
2785
|
+
get(identifier) {
|
|
2786
|
+
if (this.has(identifier))
|
|
2787
|
+
return this.cache.get(identifier);
|
|
2978
2788
|
}
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
}
|
|
2982
|
-
set(name, value) {
|
|
2983
|
-
__classPrivateFieldGet(this, _URLSearchParams_dict, "f")[name] = ['' + value];
|
|
2984
|
-
}
|
|
2985
|
-
forEach(callback, thisArg) {
|
|
2986
|
-
const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
2987
|
-
Object.getOwnPropertyNames(dict).forEach(function (name) {
|
|
2988
|
-
dict[name].forEach(function (value) {
|
|
2989
|
-
callback.call(thisArg, value, name, this);
|
|
2990
|
-
}, this);
|
|
2991
|
-
}, this);
|
|
2992
|
-
}
|
|
2993
|
-
toJSON() {
|
|
2994
|
-
return {};
|
|
2995
|
-
}
|
|
2996
|
-
toString() {
|
|
2997
|
-
const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
2998
|
-
const query = [];
|
|
2999
|
-
for (const key in dict) {
|
|
3000
|
-
const name = encode(key);
|
|
3001
|
-
for (let i = 0, value = dict[key]; i < value.length; i++) {
|
|
3002
|
-
query.push(name + '=' + encode(value[i]));
|
|
3003
|
-
}
|
|
3004
|
-
}
|
|
3005
|
-
return query.join('&');
|
|
3006
|
-
}
|
|
3007
|
-
}
|
|
3008
|
-
_URLSearchParams_dict = new WeakMap();
|
|
3009
|
-
|
|
3010
|
-
const eventCenter = hooks.call('getEventCenter', Events);
|
|
3011
|
-
|
|
3012
|
-
/**
|
|
3013
|
-
* 一个小型缓存池,用于在切换页面时,存储一些上下文信息
|
|
3014
|
-
*/
|
|
3015
|
-
class RuntimeCache {
|
|
3016
|
-
constructor(name) {
|
|
3017
|
-
this.cache = new Map();
|
|
3018
|
-
this.name = name;
|
|
3019
|
-
}
|
|
3020
|
-
has(identifier) {
|
|
3021
|
-
return this.cache.has(identifier);
|
|
3022
|
-
}
|
|
3023
|
-
set(identifier, ctx) {
|
|
3024
|
-
if (identifier && ctx) {
|
|
3025
|
-
this.cache.set(identifier, ctx);
|
|
3026
|
-
}
|
|
3027
|
-
}
|
|
3028
|
-
get(identifier) {
|
|
3029
|
-
if (this.has(identifier))
|
|
3030
|
-
return this.cache.get(identifier);
|
|
3031
|
-
}
|
|
3032
|
-
delete(identifier) {
|
|
3033
|
-
this.cache.delete(identifier);
|
|
3034
|
-
}
|
|
3035
|
-
}
|
|
3036
|
-
|
|
3037
|
-
var _History_instances, _History_location, _History_stack, _History_cur, _History_window, _History_reset;
|
|
3038
|
-
const cache$1 = new RuntimeCache('history');
|
|
3039
|
-
class History extends Events {
|
|
3040
|
-
constructor(location, options) {
|
|
3041
|
-
super();
|
|
3042
|
-
_History_instances.add(this);
|
|
3043
|
-
/* private property */
|
|
3044
|
-
_History_location.set(this, void 0);
|
|
3045
|
-
_History_stack.set(this, []);
|
|
3046
|
-
_History_cur.set(this, 0);
|
|
3047
|
-
_History_window.set(this, void 0);
|
|
3048
|
-
__classPrivateFieldSet(this, _History_window, options.window, "f");
|
|
3049
|
-
__classPrivateFieldSet(this, _History_location, location, "f");
|
|
3050
|
-
__classPrivateFieldGet(this, _History_location, "f").on('__record_history__', (href) => {
|
|
3051
|
-
var _a;
|
|
3052
|
-
__classPrivateFieldSet(this, _History_cur, (_a = __classPrivateFieldGet(this, _History_cur, "f"), _a++, _a), "f");
|
|
3053
|
-
__classPrivateFieldSet(this, _History_stack, __classPrivateFieldGet(this, _History_stack, "f").slice(0, __classPrivateFieldGet(this, _History_cur, "f")), "f");
|
|
3054
|
-
__classPrivateFieldGet(this, _History_stack, "f").push({
|
|
3055
|
-
state: null,
|
|
3056
|
-
title: '',
|
|
3057
|
-
url: href
|
|
3058
|
-
});
|
|
3059
|
-
}, null);
|
|
3060
|
-
__classPrivateFieldGet(this, _History_location, "f").on('__reset_history__', (href) => {
|
|
3061
|
-
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this, href);
|
|
3062
|
-
}, null);
|
|
3063
|
-
// 切换上下文行为
|
|
3064
|
-
this.on(CONTEXT_ACTIONS.INIT, () => {
|
|
3065
|
-
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
|
|
3066
|
-
}, null);
|
|
3067
|
-
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
3068
|
-
cache$1.set(pageId, {
|
|
3069
|
-
location: __classPrivateFieldGet(this, _History_location, "f"),
|
|
3070
|
-
stack: __classPrivateFieldGet(this, _History_stack, "f"),
|
|
3071
|
-
cur: __classPrivateFieldGet(this, _History_cur, "f")
|
|
3072
|
-
});
|
|
3073
|
-
}, null);
|
|
3074
|
-
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
3075
|
-
if (cache$1.has(pageId)) {
|
|
3076
|
-
const ctx = cache$1.get(pageId);
|
|
3077
|
-
__classPrivateFieldSet(this, _History_location, ctx.location, "f");
|
|
3078
|
-
__classPrivateFieldSet(this, _History_stack, ctx.stack, "f");
|
|
3079
|
-
__classPrivateFieldSet(this, _History_cur, ctx.cur, "f");
|
|
3080
|
-
}
|
|
3081
|
-
}, null);
|
|
3082
|
-
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
3083
|
-
cache$1.delete(pageId);
|
|
3084
|
-
}, null);
|
|
3085
|
-
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
|
|
3086
|
-
}
|
|
3087
|
-
/* public property */
|
|
3088
|
-
get length() {
|
|
3089
|
-
return __classPrivateFieldGet(this, _History_stack, "f").length;
|
|
3090
|
-
}
|
|
3091
|
-
get state() {
|
|
3092
|
-
return __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")];
|
|
3093
|
-
}
|
|
3094
|
-
/* public method */
|
|
3095
|
-
go(delta) {
|
|
3096
|
-
if (!isNumber(delta) || isNaN(delta))
|
|
3097
|
-
return;
|
|
3098
|
-
let targetIdx = __classPrivateFieldGet(this, _History_cur, "f") + delta;
|
|
3099
|
-
targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);
|
|
3100
|
-
__classPrivateFieldSet(this, _History_cur, targetIdx, "f");
|
|
3101
|
-
__classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")].url);
|
|
3102
|
-
__classPrivateFieldGet(this, _History_window, "f").trigger('popstate', __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")]);
|
|
3103
|
-
}
|
|
3104
|
-
back() {
|
|
3105
|
-
this.go(-1);
|
|
3106
|
-
}
|
|
3107
|
-
forward() {
|
|
3108
|
-
this.go(1);
|
|
3109
|
-
}
|
|
3110
|
-
pushState(state, title, url) {
|
|
3111
|
-
if (!url || !isString(url))
|
|
3112
|
-
return;
|
|
3113
|
-
__classPrivateFieldSet(this, _History_stack, __classPrivateFieldGet(this, _History_stack, "f").slice(0, __classPrivateFieldGet(this, _History_cur, "f") + 1), "f");
|
|
3114
|
-
__classPrivateFieldGet(this, _History_stack, "f").push({
|
|
3115
|
-
state,
|
|
3116
|
-
title,
|
|
3117
|
-
url
|
|
3118
|
-
});
|
|
3119
|
-
__classPrivateFieldSet(this, _History_cur, this.length - 1, "f");
|
|
3120
|
-
__classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', url);
|
|
3121
|
-
}
|
|
3122
|
-
replaceState(state, title, url) {
|
|
3123
|
-
if (!url || !isString(url))
|
|
3124
|
-
return;
|
|
3125
|
-
__classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")] = {
|
|
3126
|
-
state,
|
|
3127
|
-
title,
|
|
3128
|
-
url
|
|
3129
|
-
};
|
|
3130
|
-
__classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', url);
|
|
3131
|
-
}
|
|
3132
|
-
// For debug
|
|
3133
|
-
get cache() {
|
|
3134
|
-
return cache$1;
|
|
2789
|
+
delete(identifier) {
|
|
2790
|
+
this.cache.delete(identifier);
|
|
3135
2791
|
}
|
|
3136
2792
|
}
|
|
3137
|
-
_History_location = new WeakMap(), _History_stack = new WeakMap(), _History_cur = new WeakMap(), _History_window = new WeakMap(), _History_instances = new WeakSet(), _History_reset = function _History_reset(href = '') {
|
|
3138
|
-
__classPrivateFieldSet(this, _History_stack, [
|
|
3139
|
-
{
|
|
3140
|
-
state: null,
|
|
3141
|
-
title: '',
|
|
3142
|
-
url: href || __classPrivateFieldGet(this, _History_location, "f").href
|
|
3143
|
-
}
|
|
3144
|
-
], "f");
|
|
3145
|
-
__classPrivateFieldSet(this, _History_cur, 0, "f");
|
|
3146
|
-
};
|
|
3147
|
-
|
|
3148
|
-
const Current = {
|
|
3149
|
-
app: null,
|
|
3150
|
-
router: null,
|
|
3151
|
-
page: null
|
|
3152
|
-
};
|
|
3153
|
-
const getCurrentInstance = () => Current;
|
|
3154
2793
|
|
|
3155
2794
|
var _Location_instances, _Location_hash, _Location_hostname, _Location_pathname, _Location_port, _Location_protocol, _Location_search, _Location_noCheckUrl, _Location_window, _Location_reset, _Location_getPreValue, _Location_rollBack, _Location_recordHistory, _Location_checkUrlChange;
|
|
3156
2795
|
const DEFAULT_HOSTNAME = 'taro.com';
|
|
3157
|
-
const cache = new RuntimeCache('location');
|
|
2796
|
+
const cache$1 = new RuntimeCache('location');
|
|
3158
2797
|
class Location extends Events {
|
|
3159
2798
|
constructor(options) {
|
|
3160
2799
|
super();
|
|
@@ -3184,21 +2823,21 @@ class Location extends Events {
|
|
|
3184
2823
|
__classPrivateFieldGet(this, _Location_instances, "m", _Location_reset).call(this);
|
|
3185
2824
|
}, null);
|
|
3186
2825
|
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
3187
|
-
cache.set(pageId, {
|
|
2826
|
+
cache$1.set(pageId, {
|
|
3188
2827
|
lastHref: this.href
|
|
3189
2828
|
});
|
|
3190
2829
|
}, null);
|
|
3191
2830
|
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
3192
2831
|
// 数据恢复时,不需要执行跳转
|
|
3193
|
-
if (cache.has(pageId)) {
|
|
3194
|
-
const ctx = cache.get(pageId);
|
|
2832
|
+
if (cache$1.has(pageId)) {
|
|
2833
|
+
const ctx = cache$1.get(pageId);
|
|
3195
2834
|
__classPrivateFieldSet(this, _Location_noCheckUrl, true, "f");
|
|
3196
2835
|
this.href = ctx.lastHref;
|
|
3197
2836
|
__classPrivateFieldSet(this, _Location_noCheckUrl, false, "f");
|
|
3198
2837
|
}
|
|
3199
2838
|
}, null);
|
|
3200
2839
|
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
3201
|
-
cache.delete(pageId);
|
|
2840
|
+
cache$1.delete(pageId);
|
|
3202
2841
|
}, null);
|
|
3203
2842
|
}
|
|
3204
2843
|
/* public property */
|
|
@@ -3359,7 +2998,7 @@ class Location extends Events {
|
|
|
3359
2998
|
}
|
|
3360
2999
|
// For debug
|
|
3361
3000
|
get cache() {
|
|
3362
|
-
return cache;
|
|
3001
|
+
return cache$1;
|
|
3363
3002
|
}
|
|
3364
3003
|
}
|
|
3365
3004
|
_Location_hash = new WeakMap(), _Location_hostname = new WeakMap(), _Location_pathname = new WeakMap(), _Location_port = new WeakMap(), _Location_protocol = new WeakMap(), _Location_search = new WeakMap(), _Location_noCheckUrl = new WeakMap(), _Location_window = new WeakMap(), _Location_instances = new WeakSet(), _Location_reset = function _Location_reset() {
|
|
@@ -3473,6 +3112,7 @@ function parseUrl(url = '') {
|
|
|
3473
3112
|
const matches = url.match(PATTERN);
|
|
3474
3113
|
if (!matches)
|
|
3475
3114
|
return result;
|
|
3115
|
+
// TODO: username & password ?
|
|
3476
3116
|
result.protocol = matches[1] || 'https:';
|
|
3477
3117
|
result.hostname = matches[6] || DEFAULT_HOSTNAME;
|
|
3478
3118
|
result.port = matches[8] || '';
|
|
@@ -3485,57 +3125,669 @@ function parseUrl(url = '') {
|
|
|
3485
3125
|
return result;
|
|
3486
3126
|
}
|
|
3487
3127
|
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3128
|
+
class AnchorElement extends TaroElement {
|
|
3129
|
+
get href() {
|
|
3130
|
+
var _a;
|
|
3131
|
+
return (_a = this.props["href" /* AnchorElementAttrs.HREF */]) !== null && _a !== void 0 ? _a : '';
|
|
3132
|
+
}
|
|
3133
|
+
set href(val) {
|
|
3134
|
+
this.setAttribute("href" /* AnchorElementAttrs.HREF */, val);
|
|
3135
|
+
}
|
|
3136
|
+
get protocol() {
|
|
3137
|
+
var _a;
|
|
3138
|
+
return (_a = this.props["protocol" /* AnchorElementAttrs.PROTOCOL */]) !== null && _a !== void 0 ? _a : '';
|
|
3139
|
+
}
|
|
3140
|
+
get host() {
|
|
3141
|
+
var _a;
|
|
3142
|
+
return (_a = this.props["host" /* AnchorElementAttrs.HOST */]) !== null && _a !== void 0 ? _a : '';
|
|
3143
|
+
}
|
|
3144
|
+
get search() {
|
|
3145
|
+
var _a;
|
|
3146
|
+
return (_a = this.props["search" /* AnchorElementAttrs.SEARCH */]) !== null && _a !== void 0 ? _a : '';
|
|
3147
|
+
}
|
|
3148
|
+
get hash() {
|
|
3149
|
+
var _a;
|
|
3150
|
+
return (_a = this.props["hash" /* AnchorElementAttrs.HASH */]) !== null && _a !== void 0 ? _a : '';
|
|
3151
|
+
}
|
|
3152
|
+
get hostname() {
|
|
3153
|
+
var _a;
|
|
3154
|
+
return (_a = this.props["hostname" /* AnchorElementAttrs.HOSTNAME */]) !== null && _a !== void 0 ? _a : '';
|
|
3155
|
+
}
|
|
3156
|
+
get port() {
|
|
3157
|
+
var _a;
|
|
3158
|
+
return (_a = this.props["port" /* AnchorElementAttrs.PORT */]) !== null && _a !== void 0 ? _a : '';
|
|
3159
|
+
}
|
|
3160
|
+
get pathname() {
|
|
3161
|
+
var _a;
|
|
3162
|
+
return (_a = this.props["pathname" /* AnchorElementAttrs.PATHNAME */]) !== null && _a !== void 0 ? _a : '';
|
|
3163
|
+
}
|
|
3164
|
+
setAttribute(qualifiedName, value) {
|
|
3165
|
+
if (qualifiedName === "href" /* AnchorElementAttrs.HREF */) {
|
|
3166
|
+
const willSetAttr = parseUrl(value);
|
|
3167
|
+
for (const k in willSetAttr) {
|
|
3168
|
+
super.setAttribute(k, willSetAttr[k]);
|
|
3169
|
+
}
|
|
3513
3170
|
}
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
const _history = this.history;
|
|
3517
|
-
this.on(CONTEXT_ACTIONS.INIT, (pageId) => {
|
|
3518
|
-
// 页面onload,为该页面建立新的上下文信息
|
|
3519
|
-
_location.trigger(CONTEXT_ACTIONS.INIT, pageId);
|
|
3520
|
-
}, null);
|
|
3521
|
-
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
3522
|
-
// 页面onshow,恢复当前页面的上下文信息
|
|
3523
|
-
_location.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
3524
|
-
_history.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
3525
|
-
}, null);
|
|
3526
|
-
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
3527
|
-
// 页面onhide,缓存当前页面的上下文信息
|
|
3528
|
-
_location.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
3529
|
-
_history.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
3530
|
-
}, null);
|
|
3531
|
-
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
3532
|
-
// 页面onunload,清除当前页面的上下文信息
|
|
3533
|
-
_location.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
3534
|
-
_history.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
3535
|
-
}, null);
|
|
3171
|
+
else {
|
|
3172
|
+
super.setAttribute(qualifiedName, value);
|
|
3536
3173
|
}
|
|
3537
|
-
|
|
3538
|
-
|
|
3174
|
+
}
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3177
|
+
class TaroDocument extends TaroElement {
|
|
3178
|
+
constructor() {
|
|
3179
|
+
super();
|
|
3180
|
+
this.createEvent = createEvent;
|
|
3181
|
+
this.nodeType = 9 /* NodeType.DOCUMENT_NODE */;
|
|
3182
|
+
this.nodeName = DOCUMENT_ELEMENT_NAME;
|
|
3183
|
+
}
|
|
3184
|
+
createElement(type) {
|
|
3185
|
+
const nodeName = type.toLowerCase();
|
|
3186
|
+
let element;
|
|
3187
|
+
switch (true) {
|
|
3188
|
+
case nodeName === ROOT_STR:
|
|
3189
|
+
element = new TaroRootElement();
|
|
3190
|
+
return element;
|
|
3191
|
+
case controlledComponent.has(nodeName):
|
|
3192
|
+
element = new FormElement();
|
|
3193
|
+
break;
|
|
3194
|
+
case nodeName === A:
|
|
3195
|
+
element = new AnchorElement();
|
|
3196
|
+
break;
|
|
3197
|
+
default:
|
|
3198
|
+
element = new TaroElement();
|
|
3199
|
+
break;
|
|
3200
|
+
}
|
|
3201
|
+
element.nodeName = nodeName;
|
|
3202
|
+
element.tagName = type.toUpperCase();
|
|
3203
|
+
return element;
|
|
3204
|
+
}
|
|
3205
|
+
// an ugly fake createElementNS to deal with @vue/runtime-dom's
|
|
3206
|
+
// support mounting app to svg container since vue@3.0.8
|
|
3207
|
+
createElementNS(_svgNS, type) {
|
|
3208
|
+
return this.createElement(type);
|
|
3209
|
+
}
|
|
3210
|
+
createTextNode(text) {
|
|
3211
|
+
return new TaroText(text);
|
|
3212
|
+
}
|
|
3213
|
+
getElementById(id) {
|
|
3214
|
+
const el = eventSource.get(id);
|
|
3215
|
+
return isUndefined(el) ? null : el;
|
|
3216
|
+
}
|
|
3217
|
+
querySelector(query) {
|
|
3218
|
+
// 为了 Vue3 的乞丐版实现
|
|
3219
|
+
if (/^#/.test(query)) {
|
|
3220
|
+
return this.getElementById(query.slice(1));
|
|
3221
|
+
}
|
|
3222
|
+
return null;
|
|
3223
|
+
}
|
|
3224
|
+
querySelectorAll() {
|
|
3225
|
+
// fake hack
|
|
3226
|
+
return [];
|
|
3227
|
+
}
|
|
3228
|
+
// @TODO: @PERF: 在 hydrate 移除掉空的 node
|
|
3229
|
+
createComment() {
|
|
3230
|
+
const textnode = new TaroText('');
|
|
3231
|
+
textnode.nodeName = COMMENT;
|
|
3232
|
+
return textnode;
|
|
3233
|
+
}
|
|
3234
|
+
get defaultView() {
|
|
3235
|
+
return env.window;
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3238
|
+
|
|
3239
|
+
let document$1;
|
|
3240
|
+
if (process.env.TARO_ENV && process.env.TARO_ENV !== 'h5') {
|
|
3241
|
+
/* eslint-disable no-inner-declarations */
|
|
3242
|
+
function createDocument() {
|
|
3243
|
+
/**
|
|
3244
|
+
* <document>
|
|
3245
|
+
* <html>
|
|
3246
|
+
* <head></head>
|
|
3247
|
+
* <body>
|
|
3248
|
+
* <container>
|
|
3249
|
+
* <app id="app" />
|
|
3250
|
+
* </container>
|
|
3251
|
+
* </body>
|
|
3252
|
+
* </html>
|
|
3253
|
+
* </document>
|
|
3254
|
+
*/
|
|
3255
|
+
const doc = new TaroDocument();
|
|
3256
|
+
const documentCreateElement = doc.createElement.bind(doc);
|
|
3257
|
+
const html = documentCreateElement(HTML);
|
|
3258
|
+
const head = documentCreateElement(HEAD);
|
|
3259
|
+
const body = documentCreateElement(BODY);
|
|
3260
|
+
const app = documentCreateElement(APP);
|
|
3261
|
+
app.id = APP;
|
|
3262
|
+
const container = documentCreateElement(CONTAINER); // 多包一层主要为了兼容 vue
|
|
3263
|
+
doc.appendChild(html);
|
|
3264
|
+
html.appendChild(head);
|
|
3265
|
+
html.appendChild(body);
|
|
3266
|
+
body.appendChild(container);
|
|
3267
|
+
container.appendChild(app);
|
|
3268
|
+
doc.documentElement = html;
|
|
3269
|
+
doc.head = head;
|
|
3270
|
+
doc.body = body;
|
|
3271
|
+
return doc;
|
|
3272
|
+
}
|
|
3273
|
+
document$1 = env.document = createDocument();
|
|
3274
|
+
}
|
|
3275
|
+
else {
|
|
3276
|
+
document$1 = env.document;
|
|
3277
|
+
}
|
|
3278
|
+
|
|
3279
|
+
function getComputedStyle(element) {
|
|
3280
|
+
return element.style;
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
const machine = 'Macintosh';
|
|
3284
|
+
const arch = 'Intel Mac OS X 10_14_5';
|
|
3285
|
+
const engine = 'AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v4.1.0 Chrome/76.0.3809.132 Safari/534.36';
|
|
3286
|
+
const msg = '(' + machine + '; ' + arch + ') ' + engine;
|
|
3287
|
+
const nav = process.env.TARO_ENV === 'h5' ? env.window.navigator : {
|
|
3288
|
+
appCodeName: 'Mozilla',
|
|
3289
|
+
appName: 'Netscape',
|
|
3290
|
+
appVersion: '5.0 ' + msg,
|
|
3291
|
+
cookieEnabled: true,
|
|
3292
|
+
mimeTypes: [],
|
|
3293
|
+
onLine: true,
|
|
3294
|
+
platform: 'MacIntel',
|
|
3295
|
+
plugins: [],
|
|
3296
|
+
product: 'Taro',
|
|
3297
|
+
productSub: '20030107',
|
|
3298
|
+
userAgent: 'Mozilla/5.0 ' + msg,
|
|
3299
|
+
vendor: 'Joyent',
|
|
3300
|
+
vendorSub: ''
|
|
3301
|
+
};
|
|
3302
|
+
|
|
3303
|
+
// https://github.com/myrne/performance-now
|
|
3304
|
+
let now;
|
|
3305
|
+
(function () {
|
|
3306
|
+
let loadTime;
|
|
3307
|
+
if ((typeof performance !== 'undefined' && performance !== null) && performance.now) {
|
|
3308
|
+
now = () => performance.now();
|
|
3309
|
+
}
|
|
3310
|
+
else if (Date.now) {
|
|
3311
|
+
loadTime = Date.now();
|
|
3312
|
+
now = () => Date.now() - loadTime;
|
|
3313
|
+
}
|
|
3314
|
+
else {
|
|
3315
|
+
loadTime = new Date().getTime();
|
|
3316
|
+
now = () => new Date().getTime() - loadTime;
|
|
3317
|
+
}
|
|
3318
|
+
})();
|
|
3319
|
+
let lastTime = 0;
|
|
3320
|
+
// https://gist.github.com/paulirish/1579671
|
|
3321
|
+
// https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0
|
|
3322
|
+
const _raf = typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame !== null ? requestAnimationFrame : function (callback) {
|
|
3323
|
+
const _now = now();
|
|
3324
|
+
const nextTime = Math.max(lastTime + 16, _now); // First time will execute it immediately but barely noticeable and performance is gained.
|
|
3325
|
+
return setTimeout(function () { callback(lastTime = nextTime); }, nextTime - _now);
|
|
3326
|
+
};
|
|
3327
|
+
const _caf = typeof cancelAnimationFrame !== 'undefined' && cancelAnimationFrame !== null
|
|
3328
|
+
? cancelAnimationFrame
|
|
3329
|
+
: function (seed) {
|
|
3330
|
+
// fix https://github.com/NervJS/taro/issues/7749
|
|
3331
|
+
clearTimeout(seed);
|
|
3332
|
+
};
|
|
3333
|
+
|
|
3334
|
+
var _URLSearchParams_dict;
|
|
3335
|
+
const findReg = /[!'()~]|%20|%00/g;
|
|
3336
|
+
const plusReg = /\+/g;
|
|
3337
|
+
const replaceCharMap = {
|
|
3338
|
+
'!': '%21',
|
|
3339
|
+
"'": '%27',
|
|
3340
|
+
'(': '%28',
|
|
3341
|
+
')': '%29',
|
|
3342
|
+
'~': '%7E',
|
|
3343
|
+
'%20': '+',
|
|
3344
|
+
'%00': '\x00',
|
|
3345
|
+
};
|
|
3346
|
+
function replacer(match) {
|
|
3347
|
+
return replaceCharMap[match];
|
|
3348
|
+
}
|
|
3349
|
+
function appendTo(dict, name, value) {
|
|
3350
|
+
const res = isArray(value) ? value.join(',') : value;
|
|
3351
|
+
if (name in dict)
|
|
3352
|
+
dict[name].push(res);
|
|
3353
|
+
else
|
|
3354
|
+
dict[name] = [res];
|
|
3355
|
+
}
|
|
3356
|
+
function addEach(value, key) {
|
|
3357
|
+
appendTo(this, key, value);
|
|
3358
|
+
}
|
|
3359
|
+
function decode(str) {
|
|
3360
|
+
return decodeURIComponent(str.replace(plusReg, ' '));
|
|
3361
|
+
}
|
|
3362
|
+
function encode(str) {
|
|
3363
|
+
return encodeURIComponent(str).replace(findReg, replacer);
|
|
3364
|
+
}
|
|
3365
|
+
class URLSearchParams {
|
|
3366
|
+
constructor(query) {
|
|
3367
|
+
_URLSearchParams_dict.set(this, Object.create(null));
|
|
3368
|
+
if (!query)
|
|
3369
|
+
return;
|
|
3370
|
+
const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
3371
|
+
if (typeof query === 'string') {
|
|
3372
|
+
if (query.charAt(0) === '?') {
|
|
3373
|
+
query = query.slice(1);
|
|
3374
|
+
}
|
|
3375
|
+
for (let pairs = query.split('&'), i = 0, length = pairs.length; i < length; i++) {
|
|
3376
|
+
const value = pairs[i];
|
|
3377
|
+
const index = value.indexOf('=');
|
|
3378
|
+
if (index > -1) {
|
|
3379
|
+
appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
|
|
3380
|
+
}
|
|
3381
|
+
else if (value.length) {
|
|
3382
|
+
appendTo(dict, decode(value), '');
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
else {
|
|
3387
|
+
if (isArray(query)) {
|
|
3388
|
+
for (let i = 0, length = query.length; i < length; i++) {
|
|
3389
|
+
const value = query[i];
|
|
3390
|
+
appendTo(dict, value[0], value[1]);
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
else if (query.forEach) {
|
|
3394
|
+
query.forEach(addEach, dict);
|
|
3395
|
+
}
|
|
3396
|
+
else {
|
|
3397
|
+
for (const key in query) {
|
|
3398
|
+
appendTo(dict, key, query[key]);
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
append(name, value) {
|
|
3404
|
+
appendTo(__classPrivateFieldGet(this, _URLSearchParams_dict, "f"), name, value);
|
|
3405
|
+
}
|
|
3406
|
+
delete(name) {
|
|
3407
|
+
delete __classPrivateFieldGet(this, _URLSearchParams_dict, "f")[name];
|
|
3408
|
+
}
|
|
3409
|
+
get(name) {
|
|
3410
|
+
const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
3411
|
+
return name in dict ? dict[name][0] : null;
|
|
3412
|
+
}
|
|
3413
|
+
getAll(name) {
|
|
3414
|
+
const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
3415
|
+
return name in dict ? dict[name].slice(0) : [];
|
|
3416
|
+
}
|
|
3417
|
+
has(name) {
|
|
3418
|
+
return name in __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
3419
|
+
}
|
|
3420
|
+
keys() {
|
|
3421
|
+
return Object.keys(__classPrivateFieldGet(this, _URLSearchParams_dict, "f"));
|
|
3422
|
+
}
|
|
3423
|
+
set(name, value) {
|
|
3424
|
+
__classPrivateFieldGet(this, _URLSearchParams_dict, "f")[name] = ['' + value];
|
|
3425
|
+
}
|
|
3426
|
+
forEach(callback, thisArg) {
|
|
3427
|
+
const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
3428
|
+
Object.getOwnPropertyNames(dict).forEach(function (name) {
|
|
3429
|
+
dict[name].forEach(function (value) {
|
|
3430
|
+
callback.call(thisArg, value, name, this);
|
|
3431
|
+
}, this);
|
|
3432
|
+
}, this);
|
|
3433
|
+
}
|
|
3434
|
+
toJSON() {
|
|
3435
|
+
return {};
|
|
3436
|
+
}
|
|
3437
|
+
toString() {
|
|
3438
|
+
const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
3439
|
+
const query = [];
|
|
3440
|
+
for (const key in dict) {
|
|
3441
|
+
const name = encode(key);
|
|
3442
|
+
for (let i = 0, value = dict[key]; i < value.length; i++) {
|
|
3443
|
+
query.push(name + '=' + encode(value[i]));
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
return query.join('&');
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
_URLSearchParams_dict = new WeakMap();
|
|
3450
|
+
|
|
3451
|
+
var _URL_hash, _URL_hostname, _URL_pathname, _URL_port, _URL_protocol, _URL_search;
|
|
3452
|
+
class URL {
|
|
3453
|
+
constructor(url, base) {
|
|
3454
|
+
/* private property */
|
|
3455
|
+
_URL_hash.set(this, '');
|
|
3456
|
+
_URL_hostname.set(this, '');
|
|
3457
|
+
_URL_pathname.set(this, '');
|
|
3458
|
+
_URL_port.set(this, '');
|
|
3459
|
+
_URL_protocol.set(this, '');
|
|
3460
|
+
_URL_search.set(this, '');
|
|
3461
|
+
if (!isString(url))
|
|
3462
|
+
url = String(url);
|
|
3463
|
+
const parseResult = parseUrlBase(url, base);
|
|
3464
|
+
const { hash, hostname, pathname, port, protocol, search } = parseResult;
|
|
3465
|
+
__classPrivateFieldSet(this, _URL_hash, hash, "f");
|
|
3466
|
+
__classPrivateFieldSet(this, _URL_hostname, hostname, "f");
|
|
3467
|
+
__classPrivateFieldSet(this, _URL_pathname, pathname || '/', "f");
|
|
3468
|
+
__classPrivateFieldSet(this, _URL_port, port, "f");
|
|
3469
|
+
__classPrivateFieldSet(this, _URL_protocol, protocol, "f");
|
|
3470
|
+
__classPrivateFieldSet(this, _URL_search, search, "f");
|
|
3471
|
+
}
|
|
3472
|
+
static createObjectURL() {
|
|
3473
|
+
throw new Error('Oops, not support URL.createObjectURL() in miniprogram.');
|
|
3474
|
+
}
|
|
3475
|
+
static revokeObjectURL() {
|
|
3476
|
+
throw new Error('Oops, not support URL.revokeObjectURL() in miniprogram.');
|
|
3477
|
+
}
|
|
3478
|
+
/* public property */
|
|
3479
|
+
get protocol() {
|
|
3480
|
+
return __classPrivateFieldGet(this, _URL_protocol, "f");
|
|
3481
|
+
}
|
|
3482
|
+
set protocol(val) {
|
|
3483
|
+
isString(val) && (__classPrivateFieldSet(this, _URL_protocol, val.trim(), "f"));
|
|
3484
|
+
}
|
|
3485
|
+
get host() {
|
|
3486
|
+
return this.hostname + (this.port ? ':' + this.port : '');
|
|
3487
|
+
}
|
|
3488
|
+
set host(val) {
|
|
3489
|
+
if (val && isString(val)) {
|
|
3490
|
+
val = val.trim();
|
|
3491
|
+
const { hostname, port } = parseUrl(`//${val}`);
|
|
3492
|
+
this.hostname = hostname;
|
|
3493
|
+
this.port = port;
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
get hostname() {
|
|
3497
|
+
return __classPrivateFieldGet(this, _URL_hostname, "f");
|
|
3498
|
+
}
|
|
3499
|
+
set hostname(val) {
|
|
3500
|
+
val && isString(val) && (__classPrivateFieldSet(this, _URL_hostname, val.trim(), "f"));
|
|
3501
|
+
}
|
|
3502
|
+
get port() {
|
|
3503
|
+
return __classPrivateFieldGet(this, _URL_port, "f");
|
|
3504
|
+
}
|
|
3505
|
+
set port(val) {
|
|
3506
|
+
isString(val) && (__classPrivateFieldSet(this, _URL_port, val.trim(), "f"));
|
|
3507
|
+
}
|
|
3508
|
+
get pathname() {
|
|
3509
|
+
return __classPrivateFieldGet(this, _URL_pathname, "f");
|
|
3510
|
+
}
|
|
3511
|
+
set pathname(val) {
|
|
3512
|
+
if (isString(val)) {
|
|
3513
|
+
if (val)
|
|
3514
|
+
__classPrivateFieldSet(this, _URL_pathname, val.trim(), "f");
|
|
3515
|
+
else
|
|
3516
|
+
__classPrivateFieldSet(this, _URL_pathname, '/', "f");
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
get search() {
|
|
3520
|
+
return __classPrivateFieldGet(this, _URL_search, "f");
|
|
3521
|
+
}
|
|
3522
|
+
set search(val) {
|
|
3523
|
+
if (isString(val)) {
|
|
3524
|
+
val = val.trim();
|
|
3525
|
+
if (val)
|
|
3526
|
+
__classPrivateFieldSet(this, _URL_search, val.startsWith('?') ? val : `?${val}`, "f");
|
|
3527
|
+
else
|
|
3528
|
+
__classPrivateFieldSet(this, _URL_search, '', "f");
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
get hash() {
|
|
3532
|
+
return __classPrivateFieldGet(this, _URL_hash, "f");
|
|
3533
|
+
}
|
|
3534
|
+
set hash(val) {
|
|
3535
|
+
if (isString(val)) {
|
|
3536
|
+
val = val.trim();
|
|
3537
|
+
if (val)
|
|
3538
|
+
__classPrivateFieldSet(this, _URL_hash, val.startsWith('#') ? val : `#${val}`, "f");
|
|
3539
|
+
else
|
|
3540
|
+
__classPrivateFieldSet(this, _URL_hash, '', "f");
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3543
|
+
get href() {
|
|
3544
|
+
return `${this.protocol}//${this.host}${this.pathname}${this.search}${this.hash}`;
|
|
3545
|
+
}
|
|
3546
|
+
set href(val) {
|
|
3547
|
+
if (val && isString(val)) {
|
|
3548
|
+
val = val.trim();
|
|
3549
|
+
const { protocol, hostname, port, hash, search, pathname } = parseUrl(val);
|
|
3550
|
+
this.protocol = protocol;
|
|
3551
|
+
this.hostname = hostname;
|
|
3552
|
+
this.pathname = pathname;
|
|
3553
|
+
this.port = port;
|
|
3554
|
+
this.hash = hash;
|
|
3555
|
+
this.search = search;
|
|
3556
|
+
}
|
|
3557
|
+
}
|
|
3558
|
+
get origin() {
|
|
3559
|
+
return `${this.protocol}//${this.host}`;
|
|
3560
|
+
}
|
|
3561
|
+
set origin(val) {
|
|
3562
|
+
if (val && isString(val)) {
|
|
3563
|
+
val = val.trim();
|
|
3564
|
+
const { protocol, hostname, port } = parseUrl(val);
|
|
3565
|
+
this.protocol = protocol;
|
|
3566
|
+
this.hostname = hostname;
|
|
3567
|
+
this.port = port;
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
get searchParams() {
|
|
3571
|
+
return new URLSearchParams(this.search);
|
|
3572
|
+
}
|
|
3573
|
+
// public method
|
|
3574
|
+
toString() {
|
|
3575
|
+
return this.href;
|
|
3576
|
+
}
|
|
3577
|
+
toJSON() {
|
|
3578
|
+
return this.toString();
|
|
3579
|
+
}
|
|
3580
|
+
// convenient for deconstructor
|
|
3581
|
+
_toRaw() {
|
|
3582
|
+
return {
|
|
3583
|
+
protocol: this.protocol,
|
|
3584
|
+
port: this.port,
|
|
3585
|
+
host: this.host,
|
|
3586
|
+
hostname: this.hostname,
|
|
3587
|
+
pathname: this.pathname,
|
|
3588
|
+
hash: this.hash,
|
|
3589
|
+
search: this.search,
|
|
3590
|
+
origin: this.origin,
|
|
3591
|
+
href: this.href,
|
|
3592
|
+
};
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3595
|
+
_URL_hash = new WeakMap(), _URL_hostname = new WeakMap(), _URL_pathname = new WeakMap(), _URL_port = new WeakMap(), _URL_protocol = new WeakMap(), _URL_search = new WeakMap();
|
|
3596
|
+
function parseUrlBase(url, base) {
|
|
3597
|
+
const VALID_URL = /^(https?:)\/\//i;
|
|
3598
|
+
let fullUrl = '';
|
|
3599
|
+
let parsedBase = null;
|
|
3600
|
+
if (!isUndefined(base)) {
|
|
3601
|
+
base = String(base).trim();
|
|
3602
|
+
if (!VALID_URL.test(base))
|
|
3603
|
+
throw new TypeError(`Failed to construct 'URL': Invalid base URL`);
|
|
3604
|
+
parsedBase = parseUrl(base);
|
|
3605
|
+
}
|
|
3606
|
+
url = String(url).trim();
|
|
3607
|
+
if (VALID_URL.test(url)) {
|
|
3608
|
+
fullUrl = url;
|
|
3609
|
+
}
|
|
3610
|
+
else if (parsedBase) {
|
|
3611
|
+
if (url) {
|
|
3612
|
+
if (url.startsWith('//')) {
|
|
3613
|
+
fullUrl = parsedBase.protocol + url;
|
|
3614
|
+
}
|
|
3615
|
+
else {
|
|
3616
|
+
fullUrl = parsedBase.origin + (url.startsWith('/') ? url : `/${url}`);
|
|
3617
|
+
}
|
|
3618
|
+
}
|
|
3619
|
+
else {
|
|
3620
|
+
fullUrl = parsedBase.href;
|
|
3621
|
+
}
|
|
3622
|
+
}
|
|
3623
|
+
else {
|
|
3624
|
+
throw new TypeError(`Failed to construct 'URL': Invalid URL`);
|
|
3625
|
+
}
|
|
3626
|
+
return parseUrl(fullUrl);
|
|
3627
|
+
}
|
|
3628
|
+
|
|
3629
|
+
var _History_instances, _History_location, _History_stack, _History_cur, _History_window, _History_reset;
|
|
3630
|
+
const cache = new RuntimeCache('history');
|
|
3631
|
+
class History extends Events {
|
|
3632
|
+
constructor(location, options) {
|
|
3633
|
+
super();
|
|
3634
|
+
_History_instances.add(this);
|
|
3635
|
+
/* private property */
|
|
3636
|
+
_History_location.set(this, void 0);
|
|
3637
|
+
_History_stack.set(this, []);
|
|
3638
|
+
_History_cur.set(this, 0);
|
|
3639
|
+
_History_window.set(this, void 0);
|
|
3640
|
+
__classPrivateFieldSet(this, _History_window, options.window, "f");
|
|
3641
|
+
__classPrivateFieldSet(this, _History_location, location, "f");
|
|
3642
|
+
__classPrivateFieldGet(this, _History_location, "f").on('__record_history__', (href) => {
|
|
3643
|
+
var _a;
|
|
3644
|
+
__classPrivateFieldSet(this, _History_cur, (_a = __classPrivateFieldGet(this, _History_cur, "f"), _a++, _a), "f");
|
|
3645
|
+
__classPrivateFieldSet(this, _History_stack, __classPrivateFieldGet(this, _History_stack, "f").slice(0, __classPrivateFieldGet(this, _History_cur, "f")), "f");
|
|
3646
|
+
__classPrivateFieldGet(this, _History_stack, "f").push({
|
|
3647
|
+
state: null,
|
|
3648
|
+
title: '',
|
|
3649
|
+
url: href
|
|
3650
|
+
});
|
|
3651
|
+
}, null);
|
|
3652
|
+
__classPrivateFieldGet(this, _History_location, "f").on('__reset_history__', (href) => {
|
|
3653
|
+
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this, href);
|
|
3654
|
+
}, null);
|
|
3655
|
+
// 切换上下文行为
|
|
3656
|
+
this.on(CONTEXT_ACTIONS.INIT, () => {
|
|
3657
|
+
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
|
|
3658
|
+
}, null);
|
|
3659
|
+
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
3660
|
+
cache.set(pageId, {
|
|
3661
|
+
location: __classPrivateFieldGet(this, _History_location, "f"),
|
|
3662
|
+
stack: __classPrivateFieldGet(this, _History_stack, "f"),
|
|
3663
|
+
cur: __classPrivateFieldGet(this, _History_cur, "f")
|
|
3664
|
+
});
|
|
3665
|
+
}, null);
|
|
3666
|
+
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
3667
|
+
if (cache.has(pageId)) {
|
|
3668
|
+
const ctx = cache.get(pageId);
|
|
3669
|
+
__classPrivateFieldSet(this, _History_location, ctx.location, "f");
|
|
3670
|
+
__classPrivateFieldSet(this, _History_stack, ctx.stack, "f");
|
|
3671
|
+
__classPrivateFieldSet(this, _History_cur, ctx.cur, "f");
|
|
3672
|
+
}
|
|
3673
|
+
}, null);
|
|
3674
|
+
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
3675
|
+
cache.delete(pageId);
|
|
3676
|
+
}, null);
|
|
3677
|
+
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
|
|
3678
|
+
}
|
|
3679
|
+
/* public property */
|
|
3680
|
+
get length() {
|
|
3681
|
+
return __classPrivateFieldGet(this, _History_stack, "f").length;
|
|
3682
|
+
}
|
|
3683
|
+
get state() {
|
|
3684
|
+
return __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")];
|
|
3685
|
+
}
|
|
3686
|
+
/* public method */
|
|
3687
|
+
go(delta) {
|
|
3688
|
+
if (!isNumber(delta) || isNaN(delta))
|
|
3689
|
+
return;
|
|
3690
|
+
let targetIdx = __classPrivateFieldGet(this, _History_cur, "f") + delta;
|
|
3691
|
+
targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);
|
|
3692
|
+
__classPrivateFieldSet(this, _History_cur, targetIdx, "f");
|
|
3693
|
+
__classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")].url);
|
|
3694
|
+
__classPrivateFieldGet(this, _History_window, "f").trigger('popstate', __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")]);
|
|
3695
|
+
}
|
|
3696
|
+
back() {
|
|
3697
|
+
this.go(-1);
|
|
3698
|
+
}
|
|
3699
|
+
forward() {
|
|
3700
|
+
this.go(1);
|
|
3701
|
+
}
|
|
3702
|
+
pushState(state, title, url) {
|
|
3703
|
+
if (!url || !isString(url))
|
|
3704
|
+
return;
|
|
3705
|
+
__classPrivateFieldSet(this, _History_stack, __classPrivateFieldGet(this, _History_stack, "f").slice(0, __classPrivateFieldGet(this, _History_cur, "f") + 1), "f");
|
|
3706
|
+
__classPrivateFieldGet(this, _History_stack, "f").push({
|
|
3707
|
+
state,
|
|
3708
|
+
title,
|
|
3709
|
+
url
|
|
3710
|
+
});
|
|
3711
|
+
__classPrivateFieldSet(this, _History_cur, this.length - 1, "f");
|
|
3712
|
+
__classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', url);
|
|
3713
|
+
}
|
|
3714
|
+
replaceState(state, title, url) {
|
|
3715
|
+
if (!url || !isString(url))
|
|
3716
|
+
return;
|
|
3717
|
+
__classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")] = {
|
|
3718
|
+
state,
|
|
3719
|
+
title,
|
|
3720
|
+
url
|
|
3721
|
+
};
|
|
3722
|
+
__classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', url);
|
|
3723
|
+
}
|
|
3724
|
+
// For debug
|
|
3725
|
+
get cache() {
|
|
3726
|
+
return cache;
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
_History_location = new WeakMap(), _History_stack = new WeakMap(), _History_cur = new WeakMap(), _History_window = new WeakMap(), _History_instances = new WeakSet(), _History_reset = function _History_reset(href = '') {
|
|
3730
|
+
__classPrivateFieldSet(this, _History_stack, [
|
|
3731
|
+
{
|
|
3732
|
+
state: null,
|
|
3733
|
+
title: '',
|
|
3734
|
+
url: href || __classPrivateFieldGet(this, _History_location, "f").href
|
|
3735
|
+
}
|
|
3736
|
+
], "f");
|
|
3737
|
+
__classPrivateFieldSet(this, _History_cur, 0, "f");
|
|
3738
|
+
};
|
|
3739
|
+
|
|
3740
|
+
let window$1;
|
|
3741
|
+
if (process.env.TARO_ENV && process.env.TARO_ENV !== 'h5') {
|
|
3742
|
+
class Window extends Events {
|
|
3743
|
+
constructor() {
|
|
3744
|
+
super();
|
|
3745
|
+
this.navigator = nav;
|
|
3746
|
+
this.requestAnimationFrame = _raf;
|
|
3747
|
+
this.cancelAnimationFrame = _caf;
|
|
3748
|
+
this.getComputedStyle = getComputedStyle;
|
|
3749
|
+
const globalProperties = [
|
|
3750
|
+
...Object.getOwnPropertyNames(global || {}),
|
|
3751
|
+
...Object.getOwnPropertySymbols(global || {})
|
|
3752
|
+
];
|
|
3753
|
+
globalProperties.forEach(property => {
|
|
3754
|
+
if (property === 'atob' || property === 'document')
|
|
3755
|
+
return;
|
|
3756
|
+
if (!Object.prototype.hasOwnProperty.call(this, property)) {
|
|
3757
|
+
this[property] = global[property];
|
|
3758
|
+
}
|
|
3759
|
+
});
|
|
3760
|
+
this.Date || (this.Date = Date);
|
|
3761
|
+
// 应用启动时,提供给需要读取历史信息的库使用
|
|
3762
|
+
this.location = new Location({ window: this });
|
|
3763
|
+
this.history = new History(this.location, { window: this });
|
|
3764
|
+
this.initEvent();
|
|
3765
|
+
}
|
|
3766
|
+
initEvent() {
|
|
3767
|
+
const _location = this.location;
|
|
3768
|
+
const _history = this.history;
|
|
3769
|
+
this.on(CONTEXT_ACTIONS.INIT, (pageId) => {
|
|
3770
|
+
// 页面onload,为该页面建立新的上下文信息
|
|
3771
|
+
_location.trigger(CONTEXT_ACTIONS.INIT, pageId);
|
|
3772
|
+
}, null);
|
|
3773
|
+
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
3774
|
+
// 页面onshow,恢复当前页面的上下文信息
|
|
3775
|
+
_location.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
3776
|
+
_history.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
3777
|
+
}, null);
|
|
3778
|
+
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
3779
|
+
// 页面onhide,缓存当前页面的上下文信息
|
|
3780
|
+
_location.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
3781
|
+
_history.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
3782
|
+
}, null);
|
|
3783
|
+
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
3784
|
+
// 页面onunload,清除当前页面的上下文信息
|
|
3785
|
+
_location.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
3786
|
+
_history.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
3787
|
+
}, null);
|
|
3788
|
+
}
|
|
3789
|
+
get document() {
|
|
3790
|
+
return env.document;
|
|
3539
3791
|
}
|
|
3540
3792
|
addEventListener(event, callback) {
|
|
3541
3793
|
if (!isString(event))
|
|
@@ -3716,11 +3968,13 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3716
3968
|
});
|
|
3717
3969
|
},
|
|
3718
3970
|
[ONREADY]() {
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3971
|
+
hasLoaded.then(() => {
|
|
3972
|
+
// 触发生命周期
|
|
3973
|
+
safeExecute(this.$taroPath, ON_READY);
|
|
3974
|
+
// 通过事件触发子组件的生命周期
|
|
3975
|
+
_raf(() => eventCenter.trigger(getOnReadyEventKey(id)));
|
|
3976
|
+
this.onReady.called = true;
|
|
3977
|
+
});
|
|
3724
3978
|
},
|
|
3725
3979
|
[ONSHOW](options = {}) {
|
|
3726
3980
|
hasLoaded.then(() => {
|
|
@@ -3852,7 +4106,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
3852
4106
|
i: {
|
|
3853
4107
|
type: Object,
|
|
3854
4108
|
value: {
|
|
3855
|
-
["nn" /* Shortcuts.NodeName */]: getComponentsAlias()[VIEW]._num
|
|
4109
|
+
["nn" /* Shortcuts.NodeName */]: getComponentsAlias$1(internalComponents)[VIEW]._num
|
|
3856
4110
|
}
|
|
3857
4111
|
},
|
|
3858
4112
|
l: {
|
|
@@ -3899,5 +4153,5 @@ const nextTick = (cb, ctx) => {
|
|
|
3899
4153
|
}
|
|
3900
4154
|
};
|
|
3901
4155
|
|
|
3902
|
-
export { Current, FormElement, MutationObserver, SVGElement, Style, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, URLSearchParams, addLeadingSlash, _caf as cancelAnimationFrame, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, document$1 as document, eventCenter, eventHandler, eventSource, getComputedStyle, getCurrentInstance, getPageInstance, history, hydrate, incrementId, injectPageInstance, location, nav as navigator, nextTick, now, options, removePageInstance, _raf as requestAnimationFrame, safeExecute, stringify, window$1 as window };
|
|
4156
|
+
export { Current, FormElement, MutationObserver, SVGElement, Style, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, URL, URLSearchParams, addLeadingSlash, _caf as cancelAnimationFrame, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, document$1 as document, eventCenter, eventHandler, eventSource, getComputedStyle, getCurrentInstance, getPageInstance, history, hydrate, incrementId, injectPageInstance, location, nav as navigator, nextTick, now, options, parseUrl, removePageInstance, _raf as requestAnimationFrame, safeExecute, stringify, window$1 as window };
|
|
3903
4157
|
//# sourceMappingURL=runtime.esm.js.map
|