@tarojs/runtime 3.5.7-alpha.9 → 3.5.8
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/window.d.ts +0 -2
- package/dist/constants/index.d.ts +0 -9
- package/dist/dsl/instance.d.ts +0 -1
- package/dist/index.d.ts +1 -2
- package/dist/runtime.esm.d.ts +1 -18
- package/dist/runtime.esm.js +15 -691
- package/dist/runtime.esm.js.map +1 -1
- package/package.json +3 -6
- package/dist/bom/URLSearchParams.d.ts +0 -14
- package/dist/bom/history.d.ts +0 -29
- package/dist/bom/location.d.ts +0 -36
- package/dist/utils/cache.d.ts +0 -12
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, controlledComponent, Events
|
|
1
|
+
import { noop, isFunction, getComponentsAlias as getComponentsAlias$1, internalComponents, EMPTY_OBJ, hooks, toCamelCase, isObject, warn, isArray, ensure, isNull, isUndefined, toDashed, isString, controlledComponent, Events } from '@tarojs/shared';
|
|
2
2
|
export { Events, hooks } from '@tarojs/shared';
|
|
3
3
|
|
|
4
4
|
const PROPERTY_THRESHOLD = 2046;
|
|
@@ -44,16 +44,6 @@ const ON_HIDE = 'onHide';
|
|
|
44
44
|
const OPTIONS = 'options';
|
|
45
45
|
const EXTERNAL_CLASSES = 'externalClasses';
|
|
46
46
|
const BEHAVIORS = 'behaviors';
|
|
47
|
-
/**
|
|
48
|
-
* 页面上下文切换时的行为
|
|
49
|
-
*/
|
|
50
|
-
var CONTEXT_ACTIONS;
|
|
51
|
-
(function (CONTEXT_ACTIONS) {
|
|
52
|
-
CONTEXT_ACTIONS["INIT"] = "0";
|
|
53
|
-
CONTEXT_ACTIONS["RECOVER"] = "1";
|
|
54
|
-
CONTEXT_ACTIONS["RESTORE"] = "2";
|
|
55
|
-
CONTEXT_ACTIONS["DESTORY"] = "3";
|
|
56
|
-
})(CONTEXT_ACTIONS || (CONTEXT_ACTIONS = {}));
|
|
57
47
|
|
|
58
48
|
const observers = [];
|
|
59
49
|
/**
|
|
@@ -2426,18 +2416,11 @@ function createEvent(event, node) {
|
|
|
2426
2416
|
const eventsBatch = {};
|
|
2427
2417
|
// 小程序的事件代理回调函数
|
|
2428
2418
|
function eventHandler(event) {
|
|
2429
|
-
var _a
|
|
2430
|
-
// Note: ohos 上事件没有设置 type、detail 类型 setter 方法,且部分事件(例如 load 等)缺失 target 导致事件错误
|
|
2431
|
-
!event.type && Object.defineProperty(event, 'type', {
|
|
2432
|
-
value: event._type // ohos only
|
|
2433
|
-
});
|
|
2434
|
-
!event.detail && Object.defineProperty(event, 'detail', {
|
|
2435
|
-
value: event._detail || Object.assign({}, event) // ohos only
|
|
2436
|
-
});
|
|
2437
|
-
event.currentTarget = event.currentTarget || event.target || Object.assign({}, event);
|
|
2419
|
+
var _a;
|
|
2438
2420
|
hooks.call('modifyMpEventImpl', event);
|
|
2421
|
+
event.currentTarget || (event.currentTarget = event.target);
|
|
2439
2422
|
const currentTarget = event.currentTarget;
|
|
2440
|
-
const id = ((_a = currentTarget.dataset) === null || _a === void 0 ? void 0 : _a.sid /** sid */) || currentTarget.id /** uid */ ||
|
|
2423
|
+
const id = ((_a = currentTarget.dataset) === null || _a === void 0 ? void 0 : _a.sid /** sid */) || currentTarget.id /** uid */ || '';
|
|
2441
2424
|
const node = env.document.getElementById(id);
|
|
2442
2425
|
if (node) {
|
|
2443
2426
|
const dispatch = () => {
|
|
@@ -2629,9 +2612,9 @@ class TaroRootElement extends TaroElement {
|
|
|
2629
2612
|
}
|
|
2630
2613
|
}
|
|
2631
2614
|
}
|
|
2632
|
-
const
|
|
2615
|
+
const customWrpperCount = customWrapperMap.size;
|
|
2633
2616
|
const isNeedNormalUpdate = Object.keys(normalUpdate).length > 0;
|
|
2634
|
-
const updateArrLen =
|
|
2617
|
+
const updateArrLen = customWrpperCount + (isNeedNormalUpdate ? 1 : 0);
|
|
2635
2618
|
let executeTime = 0;
|
|
2636
2619
|
const cb = () => {
|
|
2637
2620
|
if (++executeTime === updateArrLen) {
|
|
@@ -2641,7 +2624,7 @@ class TaroRootElement extends TaroElement {
|
|
|
2641
2624
|
}
|
|
2642
2625
|
};
|
|
2643
2626
|
// custom-wrapper setData
|
|
2644
|
-
if (
|
|
2627
|
+
if (customWrpperCount) {
|
|
2645
2628
|
customWrapperMap.forEach((data, ctx) => {
|
|
2646
2629
|
if (process.env.NODE_ENV !== 'production' && options.debug) {
|
|
2647
2630
|
// eslint-disable-next-line no-console
|
|
@@ -2860,629 +2843,8 @@ const _caf = typeof cancelAnimationFrame !== 'undefined' && cancelAnimationFrame
|
|
|
2860
2843
|
clearTimeout(seed);
|
|
2861
2844
|
};
|
|
2862
2845
|
|
|
2863
|
-
/******************************************************************************
|
|
2864
|
-
Copyright (c) Microsoft Corporation.
|
|
2865
|
-
|
|
2866
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
2867
|
-
purpose with or without fee is hereby granted.
|
|
2868
|
-
|
|
2869
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2870
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2871
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2872
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2873
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2874
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2875
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
2876
|
-
***************************************************************************** */
|
|
2877
|
-
|
|
2878
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
2879
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
2880
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
2881
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
2882
|
-
}
|
|
2883
|
-
|
|
2884
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
2885
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
2886
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
2887
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
2888
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
2889
|
-
}
|
|
2890
|
-
|
|
2891
|
-
var _URLSearchParams_dict;
|
|
2892
|
-
const findReg = /[!'()~]|%20|%00/g;
|
|
2893
|
-
const plusReg = /\+/g;
|
|
2894
|
-
const replaceCharMap = {
|
|
2895
|
-
'!': '%21',
|
|
2896
|
-
"'": '%27',
|
|
2897
|
-
'(': '%28',
|
|
2898
|
-
')': '%29',
|
|
2899
|
-
'~': '%7E',
|
|
2900
|
-
'%20': '+',
|
|
2901
|
-
'%00': '\x00',
|
|
2902
|
-
};
|
|
2903
|
-
function replacer(match) {
|
|
2904
|
-
return replaceCharMap[match];
|
|
2905
|
-
}
|
|
2906
|
-
function appendTo(dict, name, value) {
|
|
2907
|
-
const res = isArray(value) ? value.join(',') : value;
|
|
2908
|
-
if (name in dict)
|
|
2909
|
-
dict[name].push(res);
|
|
2910
|
-
else
|
|
2911
|
-
dict[name] = [res];
|
|
2912
|
-
}
|
|
2913
|
-
function addEach(value, key) {
|
|
2914
|
-
appendTo(this, key, value);
|
|
2915
|
-
}
|
|
2916
|
-
function decode(str) {
|
|
2917
|
-
return decodeURIComponent(str.replace(plusReg, ' '));
|
|
2918
|
-
}
|
|
2919
|
-
function encode(str) {
|
|
2920
|
-
return encodeURIComponent(str).replace(findReg, replacer);
|
|
2921
|
-
}
|
|
2922
|
-
class URLSearchParams {
|
|
2923
|
-
constructor(query) {
|
|
2924
|
-
_URLSearchParams_dict.set(this, Object.create(null));
|
|
2925
|
-
if (!query)
|
|
2926
|
-
return;
|
|
2927
|
-
const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
2928
|
-
if (typeof query === 'string') {
|
|
2929
|
-
if (query.charAt(0) === '?') {
|
|
2930
|
-
query = query.slice(1);
|
|
2931
|
-
}
|
|
2932
|
-
for (let pairs = query.split('&'), i = 0, length = pairs.length; i < length; i++) {
|
|
2933
|
-
const value = pairs[i];
|
|
2934
|
-
const index = value.indexOf('=');
|
|
2935
|
-
if (index > -1) {
|
|
2936
|
-
appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
|
|
2937
|
-
}
|
|
2938
|
-
else if (value.length) {
|
|
2939
|
-
appendTo(dict, decode(value), '');
|
|
2940
|
-
}
|
|
2941
|
-
}
|
|
2942
|
-
}
|
|
2943
|
-
else {
|
|
2944
|
-
if (isArray(query)) {
|
|
2945
|
-
for (let i = 0, length = query.length; i < length; i++) {
|
|
2946
|
-
const value = query[i];
|
|
2947
|
-
appendTo(dict, value[0], value[1]);
|
|
2948
|
-
}
|
|
2949
|
-
}
|
|
2950
|
-
else if (query.forEach) {
|
|
2951
|
-
query.forEach(addEach, dict);
|
|
2952
|
-
}
|
|
2953
|
-
else {
|
|
2954
|
-
for (const key in query) {
|
|
2955
|
-
appendTo(dict, key, query[key]);
|
|
2956
|
-
}
|
|
2957
|
-
}
|
|
2958
|
-
}
|
|
2959
|
-
}
|
|
2960
|
-
append(name, value) {
|
|
2961
|
-
appendTo(__classPrivateFieldGet(this, _URLSearchParams_dict, "f"), name, value);
|
|
2962
|
-
}
|
|
2963
|
-
delete(name) {
|
|
2964
|
-
delete __classPrivateFieldGet(this, _URLSearchParams_dict, "f")[name];
|
|
2965
|
-
}
|
|
2966
|
-
get(name) {
|
|
2967
|
-
const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
2968
|
-
return name in dict ? dict[name][0] : null;
|
|
2969
|
-
}
|
|
2970
|
-
getAll(name) {
|
|
2971
|
-
const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
2972
|
-
return name in dict ? dict[name].slice(0) : [];
|
|
2973
|
-
}
|
|
2974
|
-
has(name) {
|
|
2975
|
-
return name in __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
2976
|
-
}
|
|
2977
|
-
keys() {
|
|
2978
|
-
return Object.keys(__classPrivateFieldGet(this, _URLSearchParams_dict, "f"));
|
|
2979
|
-
}
|
|
2980
|
-
set(name, value) {
|
|
2981
|
-
__classPrivateFieldGet(this, _URLSearchParams_dict, "f")[name] = ['' + value];
|
|
2982
|
-
}
|
|
2983
|
-
forEach(callback, thisArg) {
|
|
2984
|
-
const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
2985
|
-
Object.getOwnPropertyNames(dict).forEach(function (name) {
|
|
2986
|
-
dict[name].forEach(function (value) {
|
|
2987
|
-
callback.call(thisArg, value, name, this);
|
|
2988
|
-
}, this);
|
|
2989
|
-
}, this);
|
|
2990
|
-
}
|
|
2991
|
-
toJSON() {
|
|
2992
|
-
return {};
|
|
2993
|
-
}
|
|
2994
|
-
toString() {
|
|
2995
|
-
const dict = __classPrivateFieldGet(this, _URLSearchParams_dict, "f");
|
|
2996
|
-
const query = [];
|
|
2997
|
-
for (const key in dict) {
|
|
2998
|
-
const name = encode(key);
|
|
2999
|
-
for (let i = 0, value = dict[key]; i < value.length; i++) {
|
|
3000
|
-
query.push(name + '=' + encode(value[i]));
|
|
3001
|
-
}
|
|
3002
|
-
}
|
|
3003
|
-
return query.join('&');
|
|
3004
|
-
}
|
|
3005
|
-
}
|
|
3006
|
-
_URLSearchParams_dict = new WeakMap();
|
|
3007
|
-
|
|
3008
2846
|
const eventCenter = hooks.call('getEventCenter', Events);
|
|
3009
2847
|
|
|
3010
|
-
/**
|
|
3011
|
-
* 一个小型缓存池,用于在切换页面时,存储一些上下文信息
|
|
3012
|
-
*/
|
|
3013
|
-
class RuntimeCache {
|
|
3014
|
-
constructor(name) {
|
|
3015
|
-
this.cache = new Map();
|
|
3016
|
-
this.name = name;
|
|
3017
|
-
}
|
|
3018
|
-
has(identifier) {
|
|
3019
|
-
return this.cache.has(identifier);
|
|
3020
|
-
}
|
|
3021
|
-
set(identifier, ctx) {
|
|
3022
|
-
if (identifier && ctx) {
|
|
3023
|
-
this.cache.set(identifier, ctx);
|
|
3024
|
-
}
|
|
3025
|
-
}
|
|
3026
|
-
get(identifier) {
|
|
3027
|
-
if (this.has(identifier))
|
|
3028
|
-
return this.cache.get(identifier);
|
|
3029
|
-
}
|
|
3030
|
-
delete(identifier) {
|
|
3031
|
-
this.cache.delete(identifier);
|
|
3032
|
-
}
|
|
3033
|
-
}
|
|
3034
|
-
|
|
3035
|
-
var _History_instances, _History_location, _History_stack, _History_cur, _History_window, _History_reset;
|
|
3036
|
-
const cache$1 = new RuntimeCache('history');
|
|
3037
|
-
class History extends Events {
|
|
3038
|
-
constructor(location, options) {
|
|
3039
|
-
super();
|
|
3040
|
-
_History_instances.add(this);
|
|
3041
|
-
/* private property */
|
|
3042
|
-
_History_location.set(this, void 0);
|
|
3043
|
-
_History_stack.set(this, []);
|
|
3044
|
-
_History_cur.set(this, 0);
|
|
3045
|
-
_History_window.set(this, void 0);
|
|
3046
|
-
__classPrivateFieldSet(this, _History_window, options.window, "f");
|
|
3047
|
-
__classPrivateFieldSet(this, _History_location, location, "f");
|
|
3048
|
-
__classPrivateFieldGet(this, _History_location, "f").on('__record_history__', (href) => {
|
|
3049
|
-
var _a;
|
|
3050
|
-
__classPrivateFieldSet(this, _History_cur, (_a = __classPrivateFieldGet(this, _History_cur, "f"), _a++, _a), "f");
|
|
3051
|
-
__classPrivateFieldSet(this, _History_stack, __classPrivateFieldGet(this, _History_stack, "f").slice(0, __classPrivateFieldGet(this, _History_cur, "f")), "f");
|
|
3052
|
-
__classPrivateFieldGet(this, _History_stack, "f").push({
|
|
3053
|
-
state: null,
|
|
3054
|
-
title: '',
|
|
3055
|
-
url: href
|
|
3056
|
-
});
|
|
3057
|
-
}, null);
|
|
3058
|
-
__classPrivateFieldGet(this, _History_location, "f").on('__reset_history__', (href) => {
|
|
3059
|
-
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this, href);
|
|
3060
|
-
}, null);
|
|
3061
|
-
// 切换上下文行为
|
|
3062
|
-
this.on(CONTEXT_ACTIONS.INIT, () => {
|
|
3063
|
-
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
|
|
3064
|
-
}, null);
|
|
3065
|
-
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
3066
|
-
cache$1.set(pageId, {
|
|
3067
|
-
location: __classPrivateFieldGet(this, _History_location, "f"),
|
|
3068
|
-
stack: __classPrivateFieldGet(this, _History_stack, "f"),
|
|
3069
|
-
cur: __classPrivateFieldGet(this, _History_cur, "f")
|
|
3070
|
-
});
|
|
3071
|
-
}, null);
|
|
3072
|
-
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
3073
|
-
if (cache$1.has(pageId)) {
|
|
3074
|
-
const ctx = cache$1.get(pageId);
|
|
3075
|
-
__classPrivateFieldSet(this, _History_location, ctx.location, "f");
|
|
3076
|
-
__classPrivateFieldSet(this, _History_stack, ctx.stack, "f");
|
|
3077
|
-
__classPrivateFieldSet(this, _History_cur, ctx.cur, "f");
|
|
3078
|
-
}
|
|
3079
|
-
}, null);
|
|
3080
|
-
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
3081
|
-
cache$1.delete(pageId);
|
|
3082
|
-
}, null);
|
|
3083
|
-
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
|
|
3084
|
-
}
|
|
3085
|
-
/* public property */
|
|
3086
|
-
get length() {
|
|
3087
|
-
return __classPrivateFieldGet(this, _History_stack, "f").length;
|
|
3088
|
-
}
|
|
3089
|
-
get state() {
|
|
3090
|
-
return __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")];
|
|
3091
|
-
}
|
|
3092
|
-
/* public method */
|
|
3093
|
-
go(delta) {
|
|
3094
|
-
if (!isNumber(delta) || isNaN(delta))
|
|
3095
|
-
return;
|
|
3096
|
-
let targetIdx = __classPrivateFieldGet(this, _History_cur, "f") + delta;
|
|
3097
|
-
targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);
|
|
3098
|
-
__classPrivateFieldSet(this, _History_cur, targetIdx, "f");
|
|
3099
|
-
__classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")].url);
|
|
3100
|
-
__classPrivateFieldGet(this, _History_window, "f").trigger('popstate', __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")]);
|
|
3101
|
-
}
|
|
3102
|
-
back() {
|
|
3103
|
-
this.go(-1);
|
|
3104
|
-
}
|
|
3105
|
-
forward() {
|
|
3106
|
-
this.go(1);
|
|
3107
|
-
}
|
|
3108
|
-
pushState(state, title, url) {
|
|
3109
|
-
if (!url || !isString(url))
|
|
3110
|
-
return;
|
|
3111
|
-
__classPrivateFieldSet(this, _History_stack, __classPrivateFieldGet(this, _History_stack, "f").slice(0, __classPrivateFieldGet(this, _History_cur, "f") + 1), "f");
|
|
3112
|
-
__classPrivateFieldGet(this, _History_stack, "f").push({
|
|
3113
|
-
state,
|
|
3114
|
-
title,
|
|
3115
|
-
url
|
|
3116
|
-
});
|
|
3117
|
-
__classPrivateFieldSet(this, _History_cur, this.length - 1, "f");
|
|
3118
|
-
__classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', url);
|
|
3119
|
-
}
|
|
3120
|
-
replaceState(state, title, url) {
|
|
3121
|
-
if (!url || !isString(url))
|
|
3122
|
-
return;
|
|
3123
|
-
__classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")] = {
|
|
3124
|
-
state,
|
|
3125
|
-
title,
|
|
3126
|
-
url
|
|
3127
|
-
};
|
|
3128
|
-
__classPrivateFieldGet(this, _History_location, "f").trigger('__set_href_without_history__', url);
|
|
3129
|
-
}
|
|
3130
|
-
// For debug
|
|
3131
|
-
get cache() {
|
|
3132
|
-
return cache$1;
|
|
3133
|
-
}
|
|
3134
|
-
}
|
|
3135
|
-
_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 = '') {
|
|
3136
|
-
__classPrivateFieldSet(this, _History_stack, [
|
|
3137
|
-
{
|
|
3138
|
-
state: null,
|
|
3139
|
-
title: '',
|
|
3140
|
-
url: href || __classPrivateFieldGet(this, _History_location, "f").href
|
|
3141
|
-
}
|
|
3142
|
-
], "f");
|
|
3143
|
-
__classPrivateFieldSet(this, _History_cur, 0, "f");
|
|
3144
|
-
};
|
|
3145
|
-
|
|
3146
|
-
const Current = {
|
|
3147
|
-
app: null,
|
|
3148
|
-
router: null,
|
|
3149
|
-
page: null
|
|
3150
|
-
};
|
|
3151
|
-
const getCurrentInstance = () => Current;
|
|
3152
|
-
|
|
3153
|
-
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;
|
|
3154
|
-
const DEFAULT_HOSTNAME = 'taro.com';
|
|
3155
|
-
const cache = new RuntimeCache('location');
|
|
3156
|
-
class Location extends Events {
|
|
3157
|
-
constructor(options) {
|
|
3158
|
-
super();
|
|
3159
|
-
_Location_instances.add(this);
|
|
3160
|
-
/* private property */
|
|
3161
|
-
_Location_hash.set(this, '');
|
|
3162
|
-
_Location_hostname.set(this, DEFAULT_HOSTNAME);
|
|
3163
|
-
_Location_pathname.set(this, '/');
|
|
3164
|
-
_Location_port.set(this, '');
|
|
3165
|
-
_Location_protocol.set(this, 'https:');
|
|
3166
|
-
_Location_search.set(this, '');
|
|
3167
|
-
_Location_noCheckUrl.set(this, false);
|
|
3168
|
-
_Location_window.set(this, void 0);
|
|
3169
|
-
__classPrivateFieldSet(this, _Location_window, options.window, "f");
|
|
3170
|
-
__classPrivateFieldGet(this, _Location_instances, "m", _Location_reset).call(this);
|
|
3171
|
-
this.on('__set_href_without_history__', (href) => {
|
|
3172
|
-
__classPrivateFieldSet(this, _Location_noCheckUrl, true, "f");
|
|
3173
|
-
const lastHash = __classPrivateFieldGet(this, _Location_hash, "f");
|
|
3174
|
-
this.href = generateFullUrl(href);
|
|
3175
|
-
if (lastHash !== __classPrivateFieldGet(this, _Location_hash, "f")) {
|
|
3176
|
-
__classPrivateFieldGet(this, _Location_window, "f").trigger('hashchange');
|
|
3177
|
-
}
|
|
3178
|
-
__classPrivateFieldSet(this, _Location_noCheckUrl, false, "f");
|
|
3179
|
-
}, null);
|
|
3180
|
-
// 切换上下文行为
|
|
3181
|
-
this.on(CONTEXT_ACTIONS.INIT, () => {
|
|
3182
|
-
__classPrivateFieldGet(this, _Location_instances, "m", _Location_reset).call(this);
|
|
3183
|
-
}, null);
|
|
3184
|
-
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
3185
|
-
cache.set(pageId, {
|
|
3186
|
-
lastHref: this.href
|
|
3187
|
-
});
|
|
3188
|
-
}, null);
|
|
3189
|
-
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
3190
|
-
// 数据恢复时,不需要执行跳转
|
|
3191
|
-
if (cache.has(pageId)) {
|
|
3192
|
-
const ctx = cache.get(pageId);
|
|
3193
|
-
__classPrivateFieldSet(this, _Location_noCheckUrl, true, "f");
|
|
3194
|
-
this.href = ctx.lastHref;
|
|
3195
|
-
__classPrivateFieldSet(this, _Location_noCheckUrl, false, "f");
|
|
3196
|
-
}
|
|
3197
|
-
}, null);
|
|
3198
|
-
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
3199
|
-
cache.delete(pageId);
|
|
3200
|
-
}, null);
|
|
3201
|
-
}
|
|
3202
|
-
/* public property */
|
|
3203
|
-
get protocol() {
|
|
3204
|
-
return __classPrivateFieldGet(this, _Location_protocol, "f");
|
|
3205
|
-
}
|
|
3206
|
-
set protocol(val) {
|
|
3207
|
-
const reg = /^(http|https):?$/i;
|
|
3208
|
-
if (!val || !isString(val) || !reg.test(val.trim()))
|
|
3209
|
-
return;
|
|
3210
|
-
val = val.trim();
|
|
3211
|
-
const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
|
|
3212
|
-
__classPrivateFieldSet(this, _Location_protocol, val.endsWith(':') ? val : `${val}:`, "f");
|
|
3213
|
-
if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
|
|
3214
|
-
__classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
|
|
3215
|
-
}
|
|
3216
|
-
get host() {
|
|
3217
|
-
return (__classPrivateFieldGet(this, _Location_hostname, "f") || '') + (__classPrivateFieldGet(this, _Location_port, "f") ? ':' + __classPrivateFieldGet(this, _Location_port, "f") : '');
|
|
3218
|
-
}
|
|
3219
|
-
set host(val) {
|
|
3220
|
-
if (!val || !isString(val))
|
|
3221
|
-
return;
|
|
3222
|
-
val = val.trim();
|
|
3223
|
-
const { hostname, port } = parseUrl(`//${val}`);
|
|
3224
|
-
const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
|
|
3225
|
-
__classPrivateFieldSet(this, _Location_hostname, hostname, "f");
|
|
3226
|
-
__classPrivateFieldSet(this, _Location_port, port, "f");
|
|
3227
|
-
if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
|
|
3228
|
-
__classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
|
|
3229
|
-
}
|
|
3230
|
-
get hostname() {
|
|
3231
|
-
return __classPrivateFieldGet(this, _Location_hostname, "f");
|
|
3232
|
-
}
|
|
3233
|
-
set hostname(val) {
|
|
3234
|
-
if (!val || !isString(val))
|
|
3235
|
-
return;
|
|
3236
|
-
val = val.trim();
|
|
3237
|
-
const { hostname } = parseUrl(`//${val}`);
|
|
3238
|
-
const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
|
|
3239
|
-
__classPrivateFieldSet(this, _Location_hostname, hostname, "f");
|
|
3240
|
-
if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
|
|
3241
|
-
__classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
|
|
3242
|
-
}
|
|
3243
|
-
get port() {
|
|
3244
|
-
return __classPrivateFieldGet(this, _Location_port, "f");
|
|
3245
|
-
}
|
|
3246
|
-
set port(val) {
|
|
3247
|
-
const xVal = Number((val = val.trim()));
|
|
3248
|
-
if (!isNumber(xVal) || xVal <= 0)
|
|
3249
|
-
return;
|
|
3250
|
-
if (val === __classPrivateFieldGet(this, _Location_port, "f"))
|
|
3251
|
-
return;
|
|
3252
|
-
const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
|
|
3253
|
-
__classPrivateFieldSet(this, _Location_port, val, "f");
|
|
3254
|
-
if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
|
|
3255
|
-
__classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
|
|
3256
|
-
}
|
|
3257
|
-
get pathname() {
|
|
3258
|
-
return __classPrivateFieldGet(this, _Location_pathname, "f");
|
|
3259
|
-
}
|
|
3260
|
-
set pathname(val) {
|
|
3261
|
-
if (!val || !isString(val))
|
|
3262
|
-
return;
|
|
3263
|
-
val = val.trim();
|
|
3264
|
-
const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
|
|
3265
|
-
let newPathName = '';
|
|
3266
|
-
if (val.startsWith('/')) {
|
|
3267
|
-
newPathName = __classPrivateFieldGet(this, _Location_pathname, "f") + val;
|
|
3268
|
-
}
|
|
3269
|
-
else if (val.startsWith('./')) {
|
|
3270
|
-
val = val.replace(/\.\//, '/');
|
|
3271
|
-
newPathName = __classPrivateFieldGet(this, _Location_pathname, "f") + val;
|
|
3272
|
-
}
|
|
3273
|
-
else if (val.startsWith('../')) {
|
|
3274
|
-
newPathName = resolveRelativePath(val, preValue.pathname);
|
|
3275
|
-
}
|
|
3276
|
-
const { pathname, search, hash } = parseUrl(`//${DEFAULT_HOSTNAME}${newPathName}`);
|
|
3277
|
-
__classPrivateFieldSet(this, _Location_pathname, pathname, "f");
|
|
3278
|
-
__classPrivateFieldSet(this, _Location_search, search, "f");
|
|
3279
|
-
__classPrivateFieldSet(this, _Location_hash, hash, "f");
|
|
3280
|
-
if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
|
|
3281
|
-
__classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
|
|
3282
|
-
}
|
|
3283
|
-
get search() {
|
|
3284
|
-
return __classPrivateFieldGet(this, _Location_search, "f");
|
|
3285
|
-
}
|
|
3286
|
-
set search(val) {
|
|
3287
|
-
if (!val || !isString(val))
|
|
3288
|
-
return;
|
|
3289
|
-
val = val.trim();
|
|
3290
|
-
val = val.startsWith('?') ? val : `?${val}`;
|
|
3291
|
-
const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
|
|
3292
|
-
const { search } = parseUrl(`//${DEFAULT_HOSTNAME}${val}`);
|
|
3293
|
-
__classPrivateFieldSet(this, _Location_search, search, "f");
|
|
3294
|
-
if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
|
|
3295
|
-
__classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
|
|
3296
|
-
}
|
|
3297
|
-
get hash() {
|
|
3298
|
-
return __classPrivateFieldGet(this, _Location_hash, "f");
|
|
3299
|
-
}
|
|
3300
|
-
// 小程序的navigateTo存在截断hash字符串的问题
|
|
3301
|
-
set hash(val) {
|
|
3302
|
-
if (!val || !isString(val))
|
|
3303
|
-
return;
|
|
3304
|
-
val = val.trim();
|
|
3305
|
-
val = val.startsWith('#') ? val : `#${val}`;
|
|
3306
|
-
const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
|
|
3307
|
-
const { hash } = parseUrl(`//${DEFAULT_HOSTNAME}${val}`);
|
|
3308
|
-
__classPrivateFieldSet(this, _Location_hash, hash, "f");
|
|
3309
|
-
if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
|
|
3310
|
-
__classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
|
|
3311
|
-
}
|
|
3312
|
-
get href() {
|
|
3313
|
-
return `${__classPrivateFieldGet(this, _Location_protocol, "f")}//${this.host}${__classPrivateFieldGet(this, _Location_pathname, "f")}${__classPrivateFieldGet(this, _Location_search, "f")}${__classPrivateFieldGet(this, _Location_hash, "f")}`;
|
|
3314
|
-
}
|
|
3315
|
-
set href(val) {
|
|
3316
|
-
const reg = /^(http:|https:)?\/\/.+/;
|
|
3317
|
-
if (!val || !isString(val) || !reg.test((val = val.trim())))
|
|
3318
|
-
return;
|
|
3319
|
-
const { protocol, hostname, port, hash, search, pathname } = parseUrl(val);
|
|
3320
|
-
const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
|
|
3321
|
-
__classPrivateFieldSet(this, _Location_protocol, protocol, "f");
|
|
3322
|
-
__classPrivateFieldSet(this, _Location_hostname, hostname, "f");
|
|
3323
|
-
__classPrivateFieldSet(this, _Location_port, port, "f");
|
|
3324
|
-
__classPrivateFieldSet(this, _Location_pathname, pathname, "f");
|
|
3325
|
-
__classPrivateFieldSet(this, _Location_search, search, "f");
|
|
3326
|
-
__classPrivateFieldSet(this, _Location_hash, hash, "f");
|
|
3327
|
-
if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
|
|
3328
|
-
__classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
|
|
3329
|
-
}
|
|
3330
|
-
get origin() {
|
|
3331
|
-
return `${__classPrivateFieldGet(this, _Location_protocol, "f")}//${this.host}`;
|
|
3332
|
-
}
|
|
3333
|
-
set origin(val) {
|
|
3334
|
-
const reg = /^(http:|https:)?\/\/.+/;
|
|
3335
|
-
if (!val || !isString(val) || !reg.test((val = val.trim())))
|
|
3336
|
-
return;
|
|
3337
|
-
const { protocol, hostname, port } = parseUrl(val);
|
|
3338
|
-
const preValue = __classPrivateFieldGet(this, _Location_instances, "m", _Location_getPreValue).call(this);
|
|
3339
|
-
__classPrivateFieldSet(this, _Location_protocol, protocol, "f");
|
|
3340
|
-
__classPrivateFieldSet(this, _Location_hostname, hostname, "f");
|
|
3341
|
-
__classPrivateFieldSet(this, _Location_port, port, "f");
|
|
3342
|
-
if (__classPrivateFieldGet(this, _Location_instances, "m", _Location_checkUrlChange).call(this, preValue))
|
|
3343
|
-
__classPrivateFieldGet(this, _Location_instances, "m", _Location_recordHistory).call(this);
|
|
3344
|
-
}
|
|
3345
|
-
/* public method */
|
|
3346
|
-
assign() {
|
|
3347
|
-
warn(true, '小程序环境中调用location.assign()无效.');
|
|
3348
|
-
}
|
|
3349
|
-
reload() {
|
|
3350
|
-
warn(true, '小程序环境中调用location.reload()无效.');
|
|
3351
|
-
}
|
|
3352
|
-
replace(val) {
|
|
3353
|
-
this.trigger('__set_href_without_history__', val);
|
|
3354
|
-
}
|
|
3355
|
-
toString() {
|
|
3356
|
-
return this.href;
|
|
3357
|
-
}
|
|
3358
|
-
// For debug
|
|
3359
|
-
get cache() {
|
|
3360
|
-
return cache;
|
|
3361
|
-
}
|
|
3362
|
-
}
|
|
3363
|
-
_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() {
|
|
3364
|
-
const Current = getCurrentInstance();
|
|
3365
|
-
const router = Current.router;
|
|
3366
|
-
if (router) {
|
|
3367
|
-
const { path, params } = router;
|
|
3368
|
-
const searchArr = Object.keys(params).map(key => {
|
|
3369
|
-
return `${key}=${params[key]}`;
|
|
3370
|
-
});
|
|
3371
|
-
const searchStr = searchArr.length > 0 ? '?' + searchArr.join('&') : '';
|
|
3372
|
-
const url = `https://${DEFAULT_HOSTNAME}${path.startsWith('/') ? path : '/' + path}${searchStr}`;
|
|
3373
|
-
// 初始化页面链接时,默认pathname为 "/"
|
|
3374
|
-
// const url = `https://${DEFAULT_HOSTNAME}${searchStr}`
|
|
3375
|
-
const { protocol, hostname, port, pathname, search, hash } = parseUrl(url);
|
|
3376
|
-
__classPrivateFieldSet(this, _Location_protocol, protocol, "f");
|
|
3377
|
-
__classPrivateFieldSet(this, _Location_hostname, hostname, "f");
|
|
3378
|
-
__classPrivateFieldSet(this, _Location_port, port, "f");
|
|
3379
|
-
__classPrivateFieldSet(this, _Location_pathname, pathname, "f");
|
|
3380
|
-
__classPrivateFieldSet(this, _Location_search, search, "f");
|
|
3381
|
-
__classPrivateFieldSet(this, _Location_hash, hash, "f");
|
|
3382
|
-
this.trigger('__reset_history__', this.href);
|
|
3383
|
-
}
|
|
3384
|
-
}, _Location_getPreValue = function _Location_getPreValue() {
|
|
3385
|
-
return {
|
|
3386
|
-
protocol: __classPrivateFieldGet(this, _Location_protocol, "f"),
|
|
3387
|
-
hostname: __classPrivateFieldGet(this, _Location_hostname, "f"),
|
|
3388
|
-
port: __classPrivateFieldGet(this, _Location_port, "f"),
|
|
3389
|
-
pathname: __classPrivateFieldGet(this, _Location_pathname, "f"),
|
|
3390
|
-
search: __classPrivateFieldGet(this, _Location_search, "f"),
|
|
3391
|
-
hash: __classPrivateFieldGet(this, _Location_hash, "f")
|
|
3392
|
-
};
|
|
3393
|
-
}, _Location_rollBack = function _Location_rollBack(preValue) {
|
|
3394
|
-
__classPrivateFieldSet(this, _Location_protocol, preValue.protocol, "f");
|
|
3395
|
-
__classPrivateFieldSet(this, _Location_hostname, preValue.hostname, "f");
|
|
3396
|
-
__classPrivateFieldSet(this, _Location_port, preValue.port, "f");
|
|
3397
|
-
__classPrivateFieldSet(this, _Location_pathname, preValue.pathname, "f");
|
|
3398
|
-
__classPrivateFieldSet(this, _Location_search, preValue.search, "f");
|
|
3399
|
-
__classPrivateFieldSet(this, _Location_hash, preValue.hash, "f");
|
|
3400
|
-
}, _Location_recordHistory = function _Location_recordHistory() {
|
|
3401
|
-
this.trigger('__record_history__', this.href);
|
|
3402
|
-
}, _Location_checkUrlChange = function _Location_checkUrlChange(preValue) {
|
|
3403
|
-
if (__classPrivateFieldGet(this, _Location_noCheckUrl, "f")) {
|
|
3404
|
-
return false;
|
|
3405
|
-
}
|
|
3406
|
-
// 跨域三要素不允许修改
|
|
3407
|
-
if (__classPrivateFieldGet(this, _Location_protocol, "f") !== preValue.protocol || __classPrivateFieldGet(this, _Location_hostname, "f") !== preValue.hostname || this.port !== preValue.port) {
|
|
3408
|
-
__classPrivateFieldGet(this, _Location_instances, "m", _Location_rollBack).call(this, preValue);
|
|
3409
|
-
return false;
|
|
3410
|
-
}
|
|
3411
|
-
// pathname
|
|
3412
|
-
if (__classPrivateFieldGet(this, _Location_pathname, "f") !== preValue.pathname) {
|
|
3413
|
-
return true;
|
|
3414
|
-
}
|
|
3415
|
-
// search
|
|
3416
|
-
if (__classPrivateFieldGet(this, _Location_search, "f") !== preValue.search) {
|
|
3417
|
-
return true;
|
|
3418
|
-
}
|
|
3419
|
-
// hashchange
|
|
3420
|
-
if (__classPrivateFieldGet(this, _Location_hash, "f") !== preValue.hash) {
|
|
3421
|
-
__classPrivateFieldGet(this, _Location_window, "f").trigger('hashchange');
|
|
3422
|
-
return true;
|
|
3423
|
-
}
|
|
3424
|
-
__classPrivateFieldGet(this, _Location_instances, "m", _Location_rollBack).call(this, preValue);
|
|
3425
|
-
return false;
|
|
3426
|
-
};
|
|
3427
|
-
function resolveRelativePath(path, relative) {
|
|
3428
|
-
const relativeArr = relative.split('/');
|
|
3429
|
-
const parent = relativeArr.slice(0, relativeArr.length - 1);
|
|
3430
|
-
let depth = 0;
|
|
3431
|
-
const dests = path.split('../').map(v => {
|
|
3432
|
-
v === '' && depth++;
|
|
3433
|
-
return v;
|
|
3434
|
-
});
|
|
3435
|
-
if (depth > parent.length)
|
|
3436
|
-
return relative;
|
|
3437
|
-
return parent.slice(0, parent.length - depth).concat(dests.filter(v => v !== '')).join('/');
|
|
3438
|
-
}
|
|
3439
|
-
function generateFullUrl(val = '') {
|
|
3440
|
-
const origin = `https://${DEFAULT_HOSTNAME}`;
|
|
3441
|
-
if (val.startsWith('/')) {
|
|
3442
|
-
return origin + val;
|
|
3443
|
-
}
|
|
3444
|
-
if (val.startsWith('?')) {
|
|
3445
|
-
return origin + val;
|
|
3446
|
-
}
|
|
3447
|
-
if (val.startsWith('#')) {
|
|
3448
|
-
return origin + val;
|
|
3449
|
-
}
|
|
3450
|
-
if (/(https?:)?\/\//.test(val)) {
|
|
3451
|
-
return val;
|
|
3452
|
-
}
|
|
3453
|
-
return val;
|
|
3454
|
-
}
|
|
3455
|
-
function parseUrl(url = '') {
|
|
3456
|
-
const result = {
|
|
3457
|
-
href: '',
|
|
3458
|
-
origin: '',
|
|
3459
|
-
protocol: '',
|
|
3460
|
-
hostname: '',
|
|
3461
|
-
host: '',
|
|
3462
|
-
port: '',
|
|
3463
|
-
pathname: '',
|
|
3464
|
-
search: '',
|
|
3465
|
-
hash: ''
|
|
3466
|
-
};
|
|
3467
|
-
if (!url || !isString(url))
|
|
3468
|
-
return result;
|
|
3469
|
-
url = url.trim();
|
|
3470
|
-
const PATTERN = /^(([^:/?#]+):)?\/\/(([^/?#]+):(.+)@)?([^/?#:]*)(:(\d+))?([^?#]*)(\?([^#]*))?(#(.*))?/;
|
|
3471
|
-
const matches = url.match(PATTERN);
|
|
3472
|
-
if (!matches)
|
|
3473
|
-
return result;
|
|
3474
|
-
result.protocol = matches[1] || 'https:';
|
|
3475
|
-
result.hostname = matches[6] || DEFAULT_HOSTNAME;
|
|
3476
|
-
result.port = matches[8] || '';
|
|
3477
|
-
result.pathname = matches[9] || '/';
|
|
3478
|
-
result.search = matches[10] || '';
|
|
3479
|
-
result.hash = matches[12] || '';
|
|
3480
|
-
result.href = url;
|
|
3481
|
-
result.origin = result.protocol + '//' + result.hostname;
|
|
3482
|
-
result.host = result.hostname + (result.port ? `:${result.port}` : '');
|
|
3483
|
-
return result;
|
|
3484
|
-
}
|
|
3485
|
-
|
|
3486
2848
|
let window$1;
|
|
3487
2849
|
if (process.env.TARO_ENV && process.env.TARO_ENV !== 'h5') {
|
|
3488
2850
|
class Window extends Events {
|
|
@@ -3504,33 +2866,6 @@ if (process.env.TARO_ENV && process.env.TARO_ENV !== 'h5') {
|
|
|
3504
2866
|
}
|
|
3505
2867
|
});
|
|
3506
2868
|
this.Date || (this.Date = Date);
|
|
3507
|
-
// 应用启动时,提供给需要读取历史信息的库使用
|
|
3508
|
-
this.location = new Location({ window: this });
|
|
3509
|
-
this.history = new History(this.location, { window: this });
|
|
3510
|
-
this.initEvent();
|
|
3511
|
-
}
|
|
3512
|
-
initEvent() {
|
|
3513
|
-
const _location = this.location;
|
|
3514
|
-
const _history = this.history;
|
|
3515
|
-
this.on(CONTEXT_ACTIONS.INIT, (pageId) => {
|
|
3516
|
-
// 页面onload,为该页面建立新的上下文信息
|
|
3517
|
-
_location.trigger(CONTEXT_ACTIONS.INIT, pageId);
|
|
3518
|
-
}, null);
|
|
3519
|
-
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
3520
|
-
// 页面onshow,恢复当前页面的上下文信息
|
|
3521
|
-
_location.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
3522
|
-
_history.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
3523
|
-
}, null);
|
|
3524
|
-
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
3525
|
-
// 页面onhide,缓存当前页面的上下文信息
|
|
3526
|
-
_location.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
3527
|
-
_history.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
3528
|
-
}, null);
|
|
3529
|
-
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
3530
|
-
// 页面onunload,清除当前页面的上下文信息
|
|
3531
|
-
_location.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
3532
|
-
_history.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
3533
|
-
}, null);
|
|
3534
2869
|
}
|
|
3535
2870
|
get document() {
|
|
3536
2871
|
return env.document;
|
|
@@ -3557,13 +2892,18 @@ if (process.env.TARO_ENV && process.env.TARO_ENV !== 'h5') {
|
|
|
3557
2892
|
else {
|
|
3558
2893
|
window$1 = env.window;
|
|
3559
2894
|
}
|
|
3560
|
-
const location = window$1.location;
|
|
3561
|
-
const history = window$1.history;
|
|
3562
2895
|
|
|
3563
2896
|
// for Vue3
|
|
3564
2897
|
class SVGElement extends TaroElement {
|
|
3565
2898
|
}
|
|
3566
2899
|
|
|
2900
|
+
const Current = {
|
|
2901
|
+
app: null,
|
|
2902
|
+
router: null,
|
|
2903
|
+
page: null
|
|
2904
|
+
};
|
|
2905
|
+
const getCurrentInstance = () => Current;
|
|
2906
|
+
|
|
3567
2907
|
/* eslint-disable dot-notation */
|
|
3568
2908
|
const instances = new Map();
|
|
3569
2909
|
const pageId = incrementId();
|
|
@@ -3665,10 +3005,6 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3665
3005
|
this.$taroParams = uniqueOptions;
|
|
3666
3006
|
}
|
|
3667
3007
|
setCurrentRouter(this);
|
|
3668
|
-
// 初始化当前页面的上下文信息
|
|
3669
|
-
if (process.env.TARO_ENV !== 'h5') {
|
|
3670
|
-
window$1.trigger(CONTEXT_ACTIONS.INIT, this.$taroPath);
|
|
3671
|
-
}
|
|
3672
3008
|
const mount = () => {
|
|
3673
3009
|
Current.app.mount(component, $taroPath, () => {
|
|
3674
3010
|
pageElement = env.document.getElementById($taroPath);
|
|
@@ -3693,10 +3029,6 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3693
3029
|
},
|
|
3694
3030
|
[ONUNLOAD]() {
|
|
3695
3031
|
const $taroPath = this.$taroPath;
|
|
3696
|
-
// 销毁当前页面的上下文信息
|
|
3697
|
-
if (process.env.TARO_ENV !== 'h5') {
|
|
3698
|
-
window$1.trigger(CONTEXT_ACTIONS.DESTORY, $taroPath);
|
|
3699
|
-
}
|
|
3700
3032
|
// 触发onUnload生命周期
|
|
3701
3033
|
safeExecute($taroPath, ONUNLOAD);
|
|
3702
3034
|
unmounting = true;
|
|
@@ -3725,10 +3057,6 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3725
3057
|
// 设置 Current 的 page 和 router
|
|
3726
3058
|
Current.page = this;
|
|
3727
3059
|
setCurrentRouter(this);
|
|
3728
|
-
// 恢复上下文信息
|
|
3729
|
-
if (process.env.TARO_ENV !== 'h5') {
|
|
3730
|
-
window$1.trigger(CONTEXT_ACTIONS.RECOVER, this.$taroPath);
|
|
3731
|
-
}
|
|
3732
3060
|
// 触发生命周期
|
|
3733
3061
|
safeExecute(this.$taroPath, ON_SHOW, options);
|
|
3734
3062
|
// 通过事件触发子组件的生命周期
|
|
@@ -3736,10 +3064,6 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3736
3064
|
});
|
|
3737
3065
|
},
|
|
3738
3066
|
[ONHIDE]() {
|
|
3739
|
-
// 缓存当前页面上下文信息
|
|
3740
|
-
if (process.env.TARO_ENV !== 'h5') {
|
|
3741
|
-
window$1.trigger(CONTEXT_ACTIONS.RESTORE, this.$taroPath);
|
|
3742
|
-
}
|
|
3743
3067
|
// 设置 Current 的 page 和 router
|
|
3744
3068
|
if (Current.page === this) {
|
|
3745
3069
|
Current.page = null;
|
|
@@ -3897,5 +3221,5 @@ const nextTick = (cb, ctx) => {
|
|
|
3897
3221
|
}
|
|
3898
3222
|
};
|
|
3899
3223
|
|
|
3900
|
-
export { Current, FormElement, MutationObserver, SVGElement, Style, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText,
|
|
3224
|
+
export { Current, FormElement, MutationObserver, SVGElement, Style, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, addLeadingSlash, _caf as cancelAnimationFrame, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, document$1 as document, eventCenter, eventHandler, eventSource, getComputedStyle, getCurrentInstance, getPageInstance, hydrate, incrementId, injectPageInstance, nav as navigator, nextTick, now, options, removePageInstance, _raf as requestAnimationFrame, safeExecute, stringify, window$1 as window };
|
|
3901
3225
|
//# sourceMappingURL=runtime.esm.js.map
|