@tarojs/runtime 3.3.14 → 3.5.0-canary.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/raf.d.ts +1 -2
- package/dist/bom/window.d.ts +1 -18
- package/dist/constants/identifiers.d.ts +32 -0
- package/dist/constants/index.d.ts +7 -0
- package/dist/container/default-hooks.d.ts +2 -0
- package/dist/container/store.d.ts +15 -0
- package/dist/dom/document.d.ts +2 -5
- package/dist/dom/element.d.ts +4 -7
- package/dist/dom/event-target.d.ts +1 -2
- package/dist/dom/node.d.ts +3 -9
- package/dist/dom/root.d.ts +2 -9
- package/dist/dom/text.d.ts +5 -5
- package/dist/dom-external/element.d.ts +2 -1
- package/dist/dom-external/node.d.ts +6 -3
- package/dist/dsl/common.d.ts +1 -1
- package/dist/dsl/instance.d.ts +2 -2
- package/dist/env.d.ts +0 -1
- package/dist/hooks.d.ts +9 -4
- package/dist/index.d.ts +4 -6
- package/dist/interface/document.d.ts +1 -0
- package/dist/interface/hooks.d.ts +42 -2
- package/dist/runtime.esm.js +795 -2591
- package/dist/runtime.esm.js.map +1 -1
- package/package.json +4 -4
- package/dist/dsl/hooks.d.ts +0 -17
- package/dist/dsl/react.d.ts +0 -28
- package/dist/dsl/vue.d.ts +0 -7
- package/dist/dsl/vue3.d.ts +0 -5
package/dist/runtime.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isFunction, isUndefined, isObject, warn, isArray, toCamelCase, ensure, toDashed, isString, EMPTY_OBJ, internalComponents, controlledComponent, defaultReconciler, noop } from '@tarojs/shared';
|
|
2
|
+
import { injectable, inject, ContainerModule, optional, multiInject, Container } from 'inversify';
|
|
3
3
|
|
|
4
4
|
/*! *****************************************************************************
|
|
5
5
|
Copyright (C) Microsoft. All rights reserved.
|
|
@@ -16,8 +16,6 @@ See the Apache Version 2.0 License for specific language governing permissions
|
|
|
16
16
|
and limitations under the License.
|
|
17
17
|
***************************************************************************** */
|
|
18
18
|
|
|
19
|
-
/** https://github.com/rbuckton/reflect-metadata */
|
|
20
|
-
|
|
21
19
|
if (process.env.TARO_ENV === 'h5') {
|
|
22
20
|
require('reflect-metadata');
|
|
23
21
|
} else {
|
|
@@ -40,7 +38,7 @@ if (process.env.TARO_ENV === 'h5') {
|
|
|
40
38
|
factory(exporter);
|
|
41
39
|
function makeExporter(target, previous) {
|
|
42
40
|
return function (key, value) {
|
|
43
|
-
if (
|
|
41
|
+
if (!isFunction(target[key])) {
|
|
44
42
|
Object.defineProperty(target, key, { configurable: true, writable: true, value: value });
|
|
45
43
|
}
|
|
46
44
|
if (previous)
|
|
@@ -50,10 +48,10 @@ if (process.env.TARO_ENV === 'h5') {
|
|
|
50
48
|
})(function (exporter) {
|
|
51
49
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
52
50
|
// feature test for Symbol support
|
|
53
|
-
var supportsSymbol =
|
|
54
|
-
var toPrimitiveSymbol = supportsSymbol &&
|
|
55
|
-
var iteratorSymbol = supportsSymbol &&
|
|
56
|
-
var supportsCreate =
|
|
51
|
+
var supportsSymbol = isFunction(Symbol);
|
|
52
|
+
var toPrimitiveSymbol = supportsSymbol && !isUndefined(Symbol.toPrimitive) ? Symbol.toPrimitive : "@@toPrimitive";
|
|
53
|
+
var iteratorSymbol = supportsSymbol && !isUndefined(Symbol.iterator) ? Symbol.iterator : "@@iterator";
|
|
54
|
+
var supportsCreate = isFunction(Object.create); // feature test for Object.create support
|
|
57
55
|
var supportsProto = { __proto__: [] } instanceof Array; // feature test for __proto__ support
|
|
58
56
|
var downLevel = !supportsCreate && !supportsProto;
|
|
59
57
|
var HashMap = {
|
|
@@ -72,10 +70,10 @@ if (process.env.TARO_ENV === 'h5') {
|
|
|
72
70
|
};
|
|
73
71
|
// Load global or shim versions of Map, Set, and WeakMap
|
|
74
72
|
var functionPrototype = Object.getPrototypeOf(Function);
|
|
75
|
-
var usePolyfill =
|
|
76
|
-
var _Map =
|
|
77
|
-
var _Set =
|
|
78
|
-
var _WeakMap = !usePolyfill &&
|
|
73
|
+
var usePolyfill = isObject(process) && process.env && process.env["REFLECT_METADATA_USE_MAP_POLYFILL"] === "true";
|
|
74
|
+
var _Map = Map;
|
|
75
|
+
var _Set = Set;
|
|
76
|
+
var _WeakMap = !usePolyfill && isFunction(WeakMap) ? WeakMap : CreateWeakMapPolyfill();
|
|
79
77
|
// [[Metadata]] internal slot
|
|
80
78
|
// https://rbuckton.github.io/reflect-metadata/#ordinary-object-internal-methods-and-internal-slots
|
|
81
79
|
var Metadata = new _WeakMap();
|
|
@@ -725,7 +723,7 @@ if (process.env.TARO_ENV === 'h5') {
|
|
|
725
723
|
// 6.1.7 The Object Type
|
|
726
724
|
// https://tc39.github.io/ecma262/#sec-object-type
|
|
727
725
|
function IsObject(x) {
|
|
728
|
-
return
|
|
726
|
+
return isObject(x) ? x !== null : isFunction(x);
|
|
729
727
|
}
|
|
730
728
|
// 7.1 Type Conversion
|
|
731
729
|
// https://tc39.github.io/ecma262/#sec-type-conversion
|
|
@@ -816,13 +814,13 @@ if (process.env.TARO_ENV === 'h5') {
|
|
|
816
814
|
// https://tc39.github.io/ecma262/#sec-iscallable
|
|
817
815
|
function IsCallable(argument) {
|
|
818
816
|
// NOTE: This is an approximation as we cannot check for [[Call]] internal method.
|
|
819
|
-
return
|
|
817
|
+
return isFunction(argument);
|
|
820
818
|
}
|
|
821
819
|
// 7.2.4 IsConstructor(argument)
|
|
822
820
|
// https://tc39.github.io/ecma262/#sec-isconstructor
|
|
823
821
|
function IsConstructor(argument) {
|
|
824
822
|
// NOTE: This is an approximation as we cannot check for [[Construct]] internal method.
|
|
825
|
-
return
|
|
823
|
+
return isFunction(argument);
|
|
826
824
|
}
|
|
827
825
|
// 7.2.7 IsPropertyKey(argument)
|
|
828
826
|
// https://tc39.github.io/ecma262/#sec-ispropertykey
|
|
@@ -880,7 +878,7 @@ if (process.env.TARO_ENV === 'h5') {
|
|
|
880
878
|
// https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof
|
|
881
879
|
function OrdinaryGetPrototypeOf(O) {
|
|
882
880
|
var proto = Object.getPrototypeOf(O);
|
|
883
|
-
if (
|
|
881
|
+
if (!isFunction(O) || O === functionPrototype)
|
|
884
882
|
return proto;
|
|
885
883
|
// TypeScript doesn't set __proto__ in ES5, as it's non-standard.
|
|
886
884
|
// Try to determine the superclass constructor. Compatible implementations
|
|
@@ -898,7 +896,7 @@ if (process.env.TARO_ENV === 'h5') {
|
|
|
898
896
|
return proto;
|
|
899
897
|
// If the constructor was not a function, then we cannot determine the heritage.
|
|
900
898
|
var constructor = prototypeProto.constructor;
|
|
901
|
-
if (
|
|
899
|
+
if (!isFunction(constructor))
|
|
902
900
|
return proto;
|
|
903
901
|
// If we have some kind of self-reference, then we cannot determine the heritage.
|
|
904
902
|
if (constructor === O)
|
|
@@ -907,149 +905,149 @@ if (process.env.TARO_ENV === 'h5') {
|
|
|
907
905
|
return constructor;
|
|
908
906
|
}
|
|
909
907
|
// naive Map shim
|
|
910
|
-
function CreateMapPolyfill() {
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
}
|
|
908
|
+
// function CreateMapPolyfill() {
|
|
909
|
+
// var cacheSentinel = {};
|
|
910
|
+
// var arraySentinel = [];
|
|
911
|
+
// var MapIterator = /** @class */ (function () {
|
|
912
|
+
// function MapIterator(keys, values, selector) {
|
|
913
|
+
// this._index = 0;
|
|
914
|
+
// this._keys = keys;
|
|
915
|
+
// this._values = values;
|
|
916
|
+
// this._selector = selector;
|
|
917
|
+
// }
|
|
918
|
+
// MapIterator.prototype["@@iterator"] = function () { return this; };
|
|
919
|
+
// MapIterator.prototype[iteratorSymbol] = function () { return this; };
|
|
920
|
+
// MapIterator.prototype.next = function () {
|
|
921
|
+
// var index = this._index;
|
|
922
|
+
// if (index >= 0 && index < this._keys.length) {
|
|
923
|
+
// var result = this._selector(this._keys[index], this._values[index]);
|
|
924
|
+
// if (index + 1 >= this._keys.length) {
|
|
925
|
+
// this._index = -1;
|
|
926
|
+
// this._keys = arraySentinel;
|
|
927
|
+
// this._values = arraySentinel;
|
|
928
|
+
// }
|
|
929
|
+
// else {
|
|
930
|
+
// this._index++;
|
|
931
|
+
// }
|
|
932
|
+
// return { value: result, done: false };
|
|
933
|
+
// }
|
|
934
|
+
// return { value: undefined, done: true };
|
|
935
|
+
// };
|
|
936
|
+
// MapIterator.prototype.throw = function (error) {
|
|
937
|
+
// if (this._index >= 0) {
|
|
938
|
+
// this._index = -1;
|
|
939
|
+
// this._keys = arraySentinel;
|
|
940
|
+
// this._values = arraySentinel;
|
|
941
|
+
// }
|
|
942
|
+
// throw error;
|
|
943
|
+
// };
|
|
944
|
+
// MapIterator.prototype.return = function (value) {
|
|
945
|
+
// if (this._index >= 0) {
|
|
946
|
+
// this._index = -1;
|
|
947
|
+
// this._keys = arraySentinel;
|
|
948
|
+
// this._values = arraySentinel;
|
|
949
|
+
// }
|
|
950
|
+
// return { value: value, done: true };
|
|
951
|
+
// };
|
|
952
|
+
// return MapIterator;
|
|
953
|
+
// }());
|
|
954
|
+
// return /** @class */ (function () {
|
|
955
|
+
// function Map() {
|
|
956
|
+
// this._keys = [];
|
|
957
|
+
// this._values = [];
|
|
958
|
+
// this._cacheKey = cacheSentinel;
|
|
959
|
+
// this._cacheIndex = -2;
|
|
960
|
+
// }
|
|
961
|
+
// Object.defineProperty(Map.prototype, "size", {
|
|
962
|
+
// get: function () { return this._keys.length; },
|
|
963
|
+
// enumerable: true,
|
|
964
|
+
// configurable: true
|
|
965
|
+
// });
|
|
966
|
+
// Map.prototype.has = function (key) { return this._find(key, /*insert*/ false) >= 0; };
|
|
967
|
+
// Map.prototype.get = function (key) {
|
|
968
|
+
// var index = this._find(key, /*insert*/ false);
|
|
969
|
+
// return index >= 0 ? this._values[index] : undefined;
|
|
970
|
+
// };
|
|
971
|
+
// Map.prototype.set = function (key, value) {
|
|
972
|
+
// var index = this._find(key, /*insert*/ true);
|
|
973
|
+
// this._values[index] = value;
|
|
974
|
+
// return this;
|
|
975
|
+
// };
|
|
976
|
+
// Map.prototype.delete = function (key) {
|
|
977
|
+
// var index = this._find(key, /*insert*/ false);
|
|
978
|
+
// if (index >= 0) {
|
|
979
|
+
// var size = this._keys.length;
|
|
980
|
+
// for (var i = index + 1; i < size; i++) {
|
|
981
|
+
// this._keys[i - 1] = this._keys[i];
|
|
982
|
+
// this._values[i - 1] = this._values[i];
|
|
983
|
+
// }
|
|
984
|
+
// this._keys.length--;
|
|
985
|
+
// this._values.length--;
|
|
986
|
+
// if (key === this._cacheKey) {
|
|
987
|
+
// this._cacheKey = cacheSentinel;
|
|
988
|
+
// this._cacheIndex = -2;
|
|
989
|
+
// }
|
|
990
|
+
// return true;
|
|
991
|
+
// }
|
|
992
|
+
// return false;
|
|
993
|
+
// };
|
|
994
|
+
// Map.prototype.clear = function () {
|
|
995
|
+
// this._keys.length = 0;
|
|
996
|
+
// this._values.length = 0;
|
|
997
|
+
// this._cacheKey = cacheSentinel;
|
|
998
|
+
// this._cacheIndex = -2;
|
|
999
|
+
// };
|
|
1000
|
+
// Map.prototype.keys = function () { return new MapIterator(this._keys, this._values, getKey); };
|
|
1001
|
+
// Map.prototype.values = function () { return new MapIterator(this._keys, this._values, getValue); };
|
|
1002
|
+
// Map.prototype.entries = function () { return new MapIterator(this._keys, this._values, getEntry); };
|
|
1003
|
+
// Map.prototype["@@iterator"] = function () { return this.entries(); };
|
|
1004
|
+
// Map.prototype[iteratorSymbol] = function () { return this.entries(); };
|
|
1005
|
+
// Map.prototype._find = function (key, insert) {
|
|
1006
|
+
// if (this._cacheKey !== key) {
|
|
1007
|
+
// this._cacheIndex = this._keys.indexOf(this._cacheKey = key);
|
|
1008
|
+
// }
|
|
1009
|
+
// if (this._cacheIndex < 0 && insert) {
|
|
1010
|
+
// this._cacheIndex = this._keys.length;
|
|
1011
|
+
// this._keys.push(key);
|
|
1012
|
+
// this._values.push(undefined);
|
|
1013
|
+
// }
|
|
1014
|
+
// return this._cacheIndex;
|
|
1015
|
+
// };
|
|
1016
|
+
// return Map;
|
|
1017
|
+
// }());
|
|
1018
|
+
// function getKey(key, _) {
|
|
1019
|
+
// return key;
|
|
1020
|
+
// }
|
|
1021
|
+
// function getValue(_, value) {
|
|
1022
|
+
// return value;
|
|
1023
|
+
// }
|
|
1024
|
+
// function getEntry(key, value) {
|
|
1025
|
+
// return [key, value];
|
|
1026
|
+
// }
|
|
1027
|
+
// }
|
|
1030
1028
|
// naive Set shim
|
|
1031
|
-
function CreateSetPolyfill() {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
}
|
|
1029
|
+
// function CreateSetPolyfill() {
|
|
1030
|
+
// return /** @class */ (function () {
|
|
1031
|
+
// function Set() {
|
|
1032
|
+
// this._map = new _Map();
|
|
1033
|
+
// }
|
|
1034
|
+
// Object.defineProperty(Set.prototype, "size", {
|
|
1035
|
+
// get: function () { return this._map.size; },
|
|
1036
|
+
// enumerable: true,
|
|
1037
|
+
// configurable: true
|
|
1038
|
+
// });
|
|
1039
|
+
// Set.prototype.has = function (value) { return this._map.has(value); };
|
|
1040
|
+
// Set.prototype.add = function (value) { return this._map.set(value, value), this; };
|
|
1041
|
+
// Set.prototype.delete = function (value) { return this._map.delete(value); };
|
|
1042
|
+
// Set.prototype.clear = function () { this._map.clear(); };
|
|
1043
|
+
// Set.prototype.keys = function () { return this._map.keys(); };
|
|
1044
|
+
// Set.prototype.values = function () { return this._map.values(); };
|
|
1045
|
+
// Set.prototype.entries = function () { return this._map.entries(); };
|
|
1046
|
+
// Set.prototype["@@iterator"] = function () { return this.keys(); };
|
|
1047
|
+
// Set.prototype[iteratorSymbol] = function () { return this.keys(); };
|
|
1048
|
+
// return Set;
|
|
1049
|
+
// }());
|
|
1050
|
+
// }
|
|
1053
1051
|
// naive WeakMap shim
|
|
1054
1052
|
function CreateWeakMapPolyfill() {
|
|
1055
1053
|
var UUID_SIZE = 16;
|
|
@@ -1104,10 +1102,10 @@ if (process.env.TARO_ENV === 'h5') {
|
|
|
1104
1102
|
return buffer;
|
|
1105
1103
|
}
|
|
1106
1104
|
function GenRandomBytes(size) {
|
|
1107
|
-
if (
|
|
1108
|
-
if (
|
|
1105
|
+
if (isFunction(Uint8Array)) {
|
|
1106
|
+
if (!isUndefined(crypto))
|
|
1109
1107
|
return crypto.getRandomValues(new Uint8Array(size));
|
|
1110
|
-
if (
|
|
1108
|
+
if (!isUndefined(msCrypto))
|
|
1111
1109
|
return msCrypto.getRandomValues(new Uint8Array(size));
|
|
1112
1110
|
return FillRandomBytes(new Uint8Array(size), size);
|
|
1113
1111
|
}
|
|
@@ -1170,37 +1168,7 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
1170
1168
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
1171
1169
|
}
|
|
1172
1170
|
|
|
1173
|
-
const SERVICE_IDENTIFIER = {
|
|
1174
|
-
TaroElement: 'TaroElement',
|
|
1175
|
-
TaroElementFactory: 'Factory<TaroElement>',
|
|
1176
|
-
TaroText: 'TaroText',
|
|
1177
|
-
TaroTextFactory: 'Factory<TaroText>',
|
|
1178
|
-
TaroNodeImpl: 'TaroNodeImpl',
|
|
1179
|
-
TaroElementImpl: 'TaroElementImpl',
|
|
1180
|
-
Hooks: 'hooks',
|
|
1181
|
-
onRemoveAttribute: 'onRemoveAttribute',
|
|
1182
|
-
getLifecycle: 'getLifecycle',
|
|
1183
|
-
getPathIndex: 'getPathIndex',
|
|
1184
|
-
getEventCenter: 'getEventCenter',
|
|
1185
|
-
isBubbleEvents: 'isBubbleEvents',
|
|
1186
|
-
getSpecialNodes: 'getSpecialNodes',
|
|
1187
|
-
eventCenter: 'eventCenter',
|
|
1188
|
-
modifyMpEvent: 'modifyMpEvent',
|
|
1189
|
-
modifyTaroEvent: 'modifyTaroEvent',
|
|
1190
|
-
batchedEventUpdates: 'batchedEventUpdates',
|
|
1191
|
-
mergePageInstance: 'mergePageInstance',
|
|
1192
|
-
createPullDownComponent: 'createPullDownComponent',
|
|
1193
|
-
getDOMNode: 'getDOMNode',
|
|
1194
|
-
initNativeApi: 'initNativeApi',
|
|
1195
|
-
modifyHydrateData: 'modifyHydrateData',
|
|
1196
|
-
modifySetAttrPayload: 'modifySetAttrPayload',
|
|
1197
|
-
modifyRmAttrPayload: 'modifyRmAttrPayload',
|
|
1198
|
-
onAddEvent: 'onAddEvent',
|
|
1199
|
-
patchElement: 'patchElement'
|
|
1200
|
-
};
|
|
1201
|
-
|
|
1202
1171
|
const PROPERTY_THRESHOLD = 2046;
|
|
1203
|
-
const HOOKS_APP_ID = 'taro-app';
|
|
1204
1172
|
const SET_DATA = '小程序 setData';
|
|
1205
1173
|
const PAGE_INIT = '页面初始化';
|
|
1206
1174
|
const ROOT_STR = 'root';
|
|
@@ -1234,10 +1202,16 @@ const TIME_STAMP = 'timeStamp';
|
|
|
1234
1202
|
const KEY_CODE = 'keyCode';
|
|
1235
1203
|
const TOUCHMOVE = 'touchmove';
|
|
1236
1204
|
const DATE = 'Date';
|
|
1237
|
-
const SET_TIMEOUT = 'setTimeout';
|
|
1238
1205
|
const CATCHMOVE = 'catchMove';
|
|
1239
1206
|
const CATCH_VIEW = 'catch-view';
|
|
1240
|
-
const COMMENT = 'comment';
|
|
1207
|
+
const COMMENT = 'comment';
|
|
1208
|
+
const ON_LOAD = 'onLoad';
|
|
1209
|
+
const ON_READY = 'onReady';
|
|
1210
|
+
const ON_SHOW = 'onShow';
|
|
1211
|
+
const ON_HIDE = 'onHide';
|
|
1212
|
+
const OPTIONS = 'options';
|
|
1213
|
+
const EXTERNAL_CLASSES = 'externalClasses';
|
|
1214
|
+
const BEHAVIORS = 'behaviors';
|
|
1241
1215
|
|
|
1242
1216
|
const incrementId = () => {
|
|
1243
1217
|
let id = 0;
|
|
@@ -1288,11 +1262,99 @@ function shortcutAttr(key) {
|
|
|
1288
1262
|
}
|
|
1289
1263
|
}
|
|
1290
1264
|
|
|
1265
|
+
const SID_TARO_ELEMENT = '0';
|
|
1266
|
+
const SID_TARO_ELEMENT_FACTORY = '1';
|
|
1267
|
+
const SID_TARO_TEXT = '2';
|
|
1268
|
+
const SID_TARO_TEXT_FACTORY = '3';
|
|
1269
|
+
const SID_TARO_NODE_IMPL = '4';
|
|
1270
|
+
const SID_TARO_ELEMENT_IMPL = '5';
|
|
1271
|
+
const SID_HOOKS = '6';
|
|
1272
|
+
const SID_ON_REMOVE_ATTRIBUTE = '7';
|
|
1273
|
+
const SID_GET_MINI_LIFECYCLE = '8';
|
|
1274
|
+
const SID_GET_LIFECYCLE = '9';
|
|
1275
|
+
const SID_GET_PATH_INDEX = '10';
|
|
1276
|
+
const SID_GET_EVENT_CENTER = '11';
|
|
1277
|
+
const SID_IS_BUBBLE_EVENTS = '12';
|
|
1278
|
+
const SID_GET_SPECIAL_NODES = '13';
|
|
1279
|
+
const SID_EVENT_CENTER = '14';
|
|
1280
|
+
const SID_MODIFY_MP_EVENT = '15';
|
|
1281
|
+
const SID_MODIFY_TARO_EVENT = '16';
|
|
1282
|
+
const SID_MODIFY_DISPATCH_EVENT = '17';
|
|
1283
|
+
const SID_BATCHED_EVENT_UPDATES = '18';
|
|
1284
|
+
const SID_MERGE_PAGE_INSTANCE = '19';
|
|
1285
|
+
const SID_CREATE_PULLDOWN_COMPONENT = '20';
|
|
1286
|
+
const SID_GET_DOM_NODE = '21';
|
|
1287
|
+
const SID_INIT_NATIVE_API = '22';
|
|
1288
|
+
const SID_MODIFY_HYDRATE_DATA = '23';
|
|
1289
|
+
const SID_MODIFY_SET_ATTR_PAYLOAD = '24';
|
|
1290
|
+
const SID_MODIFY_RM_ATTR_PAYLOAD = '25';
|
|
1291
|
+
const SID_ON_ADD_EVENT = '26';
|
|
1292
|
+
const SID_PATCH_ELEMENT = '27';
|
|
1293
|
+
const SID_MODIFY_PAGE_OBJECT = '28';
|
|
1294
|
+
const SERVICE_IDENTIFIER = {
|
|
1295
|
+
TaroElement: SID_TARO_ELEMENT,
|
|
1296
|
+
TaroElementFactory: SID_TARO_ELEMENT_FACTORY,
|
|
1297
|
+
TaroText: SID_TARO_TEXT,
|
|
1298
|
+
TaroTextFactory: SID_TARO_TEXT_FACTORY,
|
|
1299
|
+
TaroNodeImpl: SID_TARO_NODE_IMPL,
|
|
1300
|
+
TaroElementImpl: SID_TARO_ELEMENT_IMPL,
|
|
1301
|
+
Hooks: SID_HOOKS,
|
|
1302
|
+
onRemoveAttribute: SID_ON_REMOVE_ATTRIBUTE,
|
|
1303
|
+
getMiniLifecycle: SID_GET_MINI_LIFECYCLE,
|
|
1304
|
+
getLifecycle: SID_GET_LIFECYCLE,
|
|
1305
|
+
getPathIndex: SID_GET_PATH_INDEX,
|
|
1306
|
+
getEventCenter: SID_GET_EVENT_CENTER,
|
|
1307
|
+
isBubbleEvents: SID_IS_BUBBLE_EVENTS,
|
|
1308
|
+
getSpecialNodes: SID_GET_SPECIAL_NODES,
|
|
1309
|
+
eventCenter: SID_EVENT_CENTER,
|
|
1310
|
+
modifyMpEvent: SID_MODIFY_MP_EVENT,
|
|
1311
|
+
modifyTaroEvent: SID_MODIFY_TARO_EVENT,
|
|
1312
|
+
modifyDispatchEvent: SID_MODIFY_DISPATCH_EVENT,
|
|
1313
|
+
batchedEventUpdates: SID_BATCHED_EVENT_UPDATES,
|
|
1314
|
+
mergePageInstance: SID_MERGE_PAGE_INSTANCE,
|
|
1315
|
+
createPullDownComponent: SID_CREATE_PULLDOWN_COMPONENT,
|
|
1316
|
+
getDOMNode: SID_GET_DOM_NODE,
|
|
1317
|
+
initNativeApi: SID_INIT_NATIVE_API,
|
|
1318
|
+
modifyHydrateData: SID_MODIFY_HYDRATE_DATA,
|
|
1319
|
+
modifySetAttrPayload: SID_MODIFY_SET_ATTR_PAYLOAD,
|
|
1320
|
+
modifyRmAttrPayload: SID_MODIFY_RM_ATTR_PAYLOAD,
|
|
1321
|
+
onAddEvent: SID_ON_ADD_EVENT,
|
|
1322
|
+
patchElement: SID_PATCH_ELEMENT,
|
|
1323
|
+
modifyPageObject: SID_MODIFY_PAGE_OBJECT
|
|
1324
|
+
};
|
|
1325
|
+
|
|
1326
|
+
var ElementNames;
|
|
1327
|
+
(function (ElementNames) {
|
|
1328
|
+
ElementNames["Element"] = "Element";
|
|
1329
|
+
ElementNames["Document"] = "Document";
|
|
1330
|
+
ElementNames["RootElement"] = "RootElement";
|
|
1331
|
+
ElementNames["FormElement"] = "FormElement";
|
|
1332
|
+
})(ElementNames || (ElementNames = {}));
|
|
1333
|
+
|
|
1334
|
+
const store = {
|
|
1335
|
+
container: null
|
|
1336
|
+
};
|
|
1337
|
+
function getHooks() {
|
|
1338
|
+
return store.container.get(SID_HOOKS);
|
|
1339
|
+
}
|
|
1340
|
+
function getElementFactory() {
|
|
1341
|
+
return store.container.get(SID_TARO_ELEMENT_FACTORY);
|
|
1342
|
+
}
|
|
1343
|
+
function getNodeImpl() {
|
|
1344
|
+
return store.container.get(SID_TARO_NODE_IMPL);
|
|
1345
|
+
}
|
|
1346
|
+
function getElementImpl() {
|
|
1347
|
+
return store.container.get(SID_TARO_ELEMENT_IMPL);
|
|
1348
|
+
}
|
|
1349
|
+
function getDocument() {
|
|
1350
|
+
const getElement = getElementFactory();
|
|
1351
|
+
return getElement(ElementNames.Document)();
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1291
1354
|
let TaroEventTarget = class TaroEventTarget {
|
|
1292
|
-
constructor(
|
|
1293
|
-
hooks) {
|
|
1355
|
+
constructor() {
|
|
1294
1356
|
this.__handlers = {};
|
|
1295
|
-
this.hooks =
|
|
1357
|
+
this.hooks = getHooks();
|
|
1296
1358
|
}
|
|
1297
1359
|
addEventListener(type, handler, options) {
|
|
1298
1360
|
var _a, _b;
|
|
@@ -1307,7 +1369,7 @@ let TaroEventTarget = class TaroEventTarget {
|
|
|
1307
1369
|
const handlers = this.__handlers[type];
|
|
1308
1370
|
let isCapture = Boolean(options);
|
|
1309
1371
|
let isOnce = false;
|
|
1310
|
-
if (isObject
|
|
1372
|
+
if (isObject(options)) {
|
|
1311
1373
|
isCapture = Boolean(options.capture);
|
|
1312
1374
|
isOnce = Boolean(options.once);
|
|
1313
1375
|
}
|
|
@@ -1320,7 +1382,7 @@ let TaroEventTarget = class TaroEventTarget {
|
|
|
1320
1382
|
return;
|
|
1321
1383
|
}
|
|
1322
1384
|
process.env.NODE_ENV !== 'production' && warn(isCapture, 'Taro 暂未实现 event 的 capture 特性。');
|
|
1323
|
-
if (isArray
|
|
1385
|
+
if (isArray(handlers)) {
|
|
1324
1386
|
handlers.push(handler);
|
|
1325
1387
|
}
|
|
1326
1388
|
else {
|
|
@@ -1329,11 +1391,11 @@ let TaroEventTarget = class TaroEventTarget {
|
|
|
1329
1391
|
}
|
|
1330
1392
|
removeEventListener(type, handler) {
|
|
1331
1393
|
type = type.toLowerCase();
|
|
1332
|
-
if (handler
|
|
1394
|
+
if (!handler) {
|
|
1333
1395
|
return;
|
|
1334
1396
|
}
|
|
1335
1397
|
const handlers = this.__handlers[type];
|
|
1336
|
-
if (!isArray
|
|
1398
|
+
if (!isArray(handlers)) {
|
|
1337
1399
|
return;
|
|
1338
1400
|
}
|
|
1339
1401
|
const index = handlers.indexOf(handler);
|
|
@@ -1348,8 +1410,7 @@ let TaroEventTarget = class TaroEventTarget {
|
|
|
1348
1410
|
};
|
|
1349
1411
|
TaroEventTarget = __decorate([
|
|
1350
1412
|
injectable(),
|
|
1351
|
-
|
|
1352
|
-
__metadata("design:paramtypes", [Object])
|
|
1413
|
+
__metadata("design:paramtypes", [])
|
|
1353
1414
|
], TaroEventTarget);
|
|
1354
1415
|
|
|
1355
1416
|
/**
|
|
@@ -1413,24 +1474,16 @@ function hydrate(node) {
|
|
|
1413
1474
|
|
|
1414
1475
|
const eventSource = new Map();
|
|
1415
1476
|
|
|
1416
|
-
var ElementNames;
|
|
1417
|
-
(function (ElementNames) {
|
|
1418
|
-
ElementNames["Element"] = "Element";
|
|
1419
|
-
ElementNames["Document"] = "Document";
|
|
1420
|
-
ElementNames["RootElement"] = "RootElement";
|
|
1421
|
-
ElementNames["FormElement"] = "FormElement";
|
|
1422
|
-
})(ElementNames || (ElementNames = {}));
|
|
1423
|
-
|
|
1424
1477
|
const nodeId = incrementId();
|
|
1425
1478
|
let TaroNode = class TaroNode extends TaroEventTarget {
|
|
1426
|
-
constructor(
|
|
1427
|
-
|
|
1428
|
-
super(hooks);
|
|
1479
|
+
constructor() {
|
|
1480
|
+
super();
|
|
1429
1481
|
this.parentNode = null;
|
|
1430
1482
|
this.childNodes = [];
|
|
1483
|
+
this._getElement = getElementFactory();
|
|
1431
1484
|
this.hydrate = (node) => () => hydrate(node);
|
|
1485
|
+
const impl = getNodeImpl();
|
|
1432
1486
|
impl.bind(this);
|
|
1433
|
-
this._getElement = getElement;
|
|
1434
1487
|
this.uid = `_n_${nodeId()}`;
|
|
1435
1488
|
eventSource.set(this.uid, this);
|
|
1436
1489
|
}
|
|
@@ -1586,17 +1639,6 @@ let TaroNode = class TaroNode extends TaroEventTarget {
|
|
|
1586
1639
|
var _a;
|
|
1587
1640
|
(_a = this._root) === null || _a === void 0 ? void 0 : _a.enqueueUpdate(payload);
|
|
1588
1641
|
}
|
|
1589
|
-
contains(node) {
|
|
1590
|
-
let isContains = false;
|
|
1591
|
-
this.childNodes.some(childNode => {
|
|
1592
|
-
const { uid } = childNode;
|
|
1593
|
-
if (uid === node.uid || uid === node.id || childNode.contains(node)) {
|
|
1594
|
-
isContains = true;
|
|
1595
|
-
return true;
|
|
1596
|
-
}
|
|
1597
|
-
});
|
|
1598
|
-
return isContains;
|
|
1599
|
-
}
|
|
1600
1642
|
get ownerDocument() {
|
|
1601
1643
|
const document = this._getElement(ElementNames.Document)();
|
|
1602
1644
|
return document;
|
|
@@ -1604,16 +1646,12 @@ let TaroNode = class TaroNode extends TaroEventTarget {
|
|
|
1604
1646
|
};
|
|
1605
1647
|
TaroNode = __decorate([
|
|
1606
1648
|
injectable(),
|
|
1607
|
-
|
|
1608
|
-
__param(1, inject(SERVICE_IDENTIFIER.TaroElementFactory)),
|
|
1609
|
-
__param(2, inject(SERVICE_IDENTIFIER.Hooks)),
|
|
1610
|
-
__metadata("design:paramtypes", [Function, Function, Function])
|
|
1649
|
+
__metadata("design:paramtypes", [])
|
|
1611
1650
|
], TaroNode);
|
|
1612
1651
|
|
|
1613
1652
|
let TaroText = class TaroText extends TaroNode {
|
|
1614
|
-
constructor(
|
|
1615
|
-
|
|
1616
|
-
super(nodeImpl, getElement, hooks);
|
|
1653
|
+
constructor() {
|
|
1654
|
+
super(...arguments);
|
|
1617
1655
|
this.nodeType = 3 /* TEXT_NODE */;
|
|
1618
1656
|
this.nodeName = '#text';
|
|
1619
1657
|
}
|
|
@@ -1633,13 +1671,15 @@ let TaroText = class TaroText extends TaroNode {
|
|
|
1633
1671
|
get nodeValue() {
|
|
1634
1672
|
return this._value;
|
|
1635
1673
|
}
|
|
1674
|
+
set data(text) {
|
|
1675
|
+
this.textContent = text;
|
|
1676
|
+
}
|
|
1677
|
+
get data() {
|
|
1678
|
+
return this._value;
|
|
1679
|
+
}
|
|
1636
1680
|
};
|
|
1637
1681
|
TaroText = __decorate([
|
|
1638
|
-
injectable()
|
|
1639
|
-
__param(0, inject(SERVICE_IDENTIFIER.TaroNodeImpl)),
|
|
1640
|
-
__param(1, inject(SERVICE_IDENTIFIER.TaroElementFactory)),
|
|
1641
|
-
__param(2, inject(SERVICE_IDENTIFIER.Hooks)),
|
|
1642
|
-
__metadata("design:paramtypes", [Function, Function, Function])
|
|
1682
|
+
injectable()
|
|
1643
1683
|
], TaroText);
|
|
1644
1684
|
|
|
1645
1685
|
/*
|
|
@@ -2033,15 +2073,16 @@ class ClassList extends Set {
|
|
|
2033
2073
|
}
|
|
2034
2074
|
|
|
2035
2075
|
let TaroElement = class TaroElement extends TaroNode {
|
|
2036
|
-
constructor(
|
|
2037
|
-
|
|
2038
|
-
super(
|
|
2076
|
+
constructor() {
|
|
2077
|
+
var _a, _b;
|
|
2078
|
+
super();
|
|
2039
2079
|
this.props = {};
|
|
2040
2080
|
this.dataset = EMPTY_OBJ;
|
|
2041
|
-
|
|
2081
|
+
const impl = getElementImpl();
|
|
2082
|
+
impl.bind(this);
|
|
2042
2083
|
this.nodeType = 1 /* ELEMENT_NODE */;
|
|
2043
2084
|
this.style = new Style(this);
|
|
2044
|
-
hooks.patchElement(this);
|
|
2085
|
+
(_b = (_a = this.hooks).patchElement) === null || _b === void 0 ? void 0 : _b.call(_a, this);
|
|
2045
2086
|
}
|
|
2046
2087
|
_stopPropagation(event) {
|
|
2047
2088
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
@@ -2049,7 +2090,7 @@ let TaroElement = class TaroElement extends TaroNode {
|
|
|
2049
2090
|
// eslint-disable-next-line no-cond-assign
|
|
2050
2091
|
while ((target = target.parentNode)) {
|
|
2051
2092
|
const listeners = target.__handlers[event.type];
|
|
2052
|
-
if (!isArray
|
|
2093
|
+
if (!isArray(listeners)) {
|
|
2053
2094
|
continue;
|
|
2054
2095
|
}
|
|
2055
2096
|
for (let i = listeners.length; i--;) {
|
|
@@ -2103,8 +2144,14 @@ let TaroElement = class TaroElement extends TaroNode {
|
|
|
2103
2144
|
hasAttributes() {
|
|
2104
2145
|
return this.attributes.length > 0;
|
|
2105
2146
|
}
|
|
2106
|
-
focus() {
|
|
2107
|
-
|
|
2147
|
+
get focus() {
|
|
2148
|
+
return function () {
|
|
2149
|
+
this.setAttribute(FOCUS, true);
|
|
2150
|
+
};
|
|
2151
|
+
}
|
|
2152
|
+
// 兼容 Vue3,详情请见:https://github.com/NervJS/taro/issues/10579
|
|
2153
|
+
set focus(value) {
|
|
2154
|
+
this.setAttribute(FOCUS, value);
|
|
2108
2155
|
}
|
|
2109
2156
|
blur() {
|
|
2110
2157
|
this.setAttribute(FOCUS, false);
|
|
@@ -2217,7 +2264,7 @@ let TaroElement = class TaroElement extends TaroNode {
|
|
|
2217
2264
|
dispatchEvent(event) {
|
|
2218
2265
|
const cancelable = event.cancelable;
|
|
2219
2266
|
const listeners = this.__handlers[event.type];
|
|
2220
|
-
if (!isArray
|
|
2267
|
+
if (!isArray(listeners)) {
|
|
2221
2268
|
return false;
|
|
2222
2269
|
}
|
|
2223
2270
|
for (let i = listeners.length; i--;) {
|
|
@@ -2227,6 +2274,7 @@ let TaroElement = class TaroElement extends TaroNode {
|
|
|
2227
2274
|
listener._stop = false;
|
|
2228
2275
|
}
|
|
2229
2276
|
else {
|
|
2277
|
+
this.hooks.modifyDispatchEvent(event, this);
|
|
2230
2278
|
result = listener.call(this, event);
|
|
2231
2279
|
}
|
|
2232
2280
|
if ((result === false || event._end) && cancelable) {
|
|
@@ -2269,1096 +2317,9 @@ let TaroElement = class TaroElement extends TaroNode {
|
|
|
2269
2317
|
};
|
|
2270
2318
|
TaroElement = __decorate([
|
|
2271
2319
|
injectable(),
|
|
2272
|
-
|
|
2273
|
-
__param(1, inject(SERVICE_IDENTIFIER.TaroElementFactory)),
|
|
2274
|
-
__param(2, inject(SERVICE_IDENTIFIER.Hooks)),
|
|
2275
|
-
__param(3, inject(SERVICE_IDENTIFIER.TaroElementImpl)),
|
|
2276
|
-
__metadata("design:paramtypes", [Function, Function, Function, Function])
|
|
2320
|
+
__metadata("design:paramtypes", [])
|
|
2277
2321
|
], TaroElement);
|
|
2278
2322
|
|
|
2279
|
-
/**
|
|
2280
|
-
* Checks if `value` is classified as an `Array` object.
|
|
2281
|
-
*
|
|
2282
|
-
* @static
|
|
2283
|
-
* @memberOf _
|
|
2284
|
-
* @since 0.1.0
|
|
2285
|
-
* @category Lang
|
|
2286
|
-
* @param {*} value The value to check.
|
|
2287
|
-
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
2288
|
-
* @example
|
|
2289
|
-
*
|
|
2290
|
-
* _.isArray([1, 2, 3]);
|
|
2291
|
-
* // => true
|
|
2292
|
-
*
|
|
2293
|
-
* _.isArray(document.body.children);
|
|
2294
|
-
* // => false
|
|
2295
|
-
*
|
|
2296
|
-
* _.isArray('abc');
|
|
2297
|
-
* // => false
|
|
2298
|
-
*
|
|
2299
|
-
* _.isArray(_.noop);
|
|
2300
|
-
* // => false
|
|
2301
|
-
*/
|
|
2302
|
-
var isArray = Array.isArray;
|
|
2303
|
-
|
|
2304
|
-
/** Detect free variable `global` from Node.js. */
|
|
2305
|
-
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
2306
|
-
|
|
2307
|
-
/** Detect free variable `self`. */
|
|
2308
|
-
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
2309
|
-
|
|
2310
|
-
/** Used as a reference to the global object. */
|
|
2311
|
-
var root = freeGlobal || freeSelf || Function('return this')();
|
|
2312
|
-
|
|
2313
|
-
/** Built-in value references. */
|
|
2314
|
-
var Symbol$1 = root.Symbol;
|
|
2315
|
-
|
|
2316
|
-
/** Used for built-in method references. */
|
|
2317
|
-
var objectProto = Object.prototype;
|
|
2318
|
-
|
|
2319
|
-
/** Used to check objects for own properties. */
|
|
2320
|
-
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
2321
|
-
|
|
2322
|
-
/**
|
|
2323
|
-
* Used to resolve the
|
|
2324
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
2325
|
-
* of values.
|
|
2326
|
-
*/
|
|
2327
|
-
var nativeObjectToString = objectProto.toString;
|
|
2328
|
-
|
|
2329
|
-
/** Built-in value references. */
|
|
2330
|
-
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
2331
|
-
|
|
2332
|
-
/**
|
|
2333
|
-
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
2334
|
-
*
|
|
2335
|
-
* @private
|
|
2336
|
-
* @param {*} value The value to query.
|
|
2337
|
-
* @returns {string} Returns the raw `toStringTag`.
|
|
2338
|
-
*/
|
|
2339
|
-
function getRawTag(value) {
|
|
2340
|
-
var isOwn = hasOwnProperty.call(value, symToStringTag),
|
|
2341
|
-
tag = value[symToStringTag];
|
|
2342
|
-
|
|
2343
|
-
try {
|
|
2344
|
-
value[symToStringTag] = undefined;
|
|
2345
|
-
var unmasked = true;
|
|
2346
|
-
} catch (e) {}
|
|
2347
|
-
|
|
2348
|
-
var result = nativeObjectToString.call(value);
|
|
2349
|
-
if (unmasked) {
|
|
2350
|
-
if (isOwn) {
|
|
2351
|
-
value[symToStringTag] = tag;
|
|
2352
|
-
} else {
|
|
2353
|
-
delete value[symToStringTag];
|
|
2354
|
-
}
|
|
2355
|
-
}
|
|
2356
|
-
return result;
|
|
2357
|
-
}
|
|
2358
|
-
|
|
2359
|
-
/** Used for built-in method references. */
|
|
2360
|
-
var objectProto$1 = Object.prototype;
|
|
2361
|
-
|
|
2362
|
-
/**
|
|
2363
|
-
* Used to resolve the
|
|
2364
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
2365
|
-
* of values.
|
|
2366
|
-
*/
|
|
2367
|
-
var nativeObjectToString$1 = objectProto$1.toString;
|
|
2368
|
-
|
|
2369
|
-
/**
|
|
2370
|
-
* Converts `value` to a string using `Object.prototype.toString`.
|
|
2371
|
-
*
|
|
2372
|
-
* @private
|
|
2373
|
-
* @param {*} value The value to convert.
|
|
2374
|
-
* @returns {string} Returns the converted string.
|
|
2375
|
-
*/
|
|
2376
|
-
function objectToString(value) {
|
|
2377
|
-
return nativeObjectToString$1.call(value);
|
|
2378
|
-
}
|
|
2379
|
-
|
|
2380
|
-
/** `Object#toString` result references. */
|
|
2381
|
-
var nullTag = '[object Null]',
|
|
2382
|
-
undefinedTag = '[object Undefined]';
|
|
2383
|
-
|
|
2384
|
-
/** Built-in value references. */
|
|
2385
|
-
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
2386
|
-
|
|
2387
|
-
/**
|
|
2388
|
-
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
2389
|
-
*
|
|
2390
|
-
* @private
|
|
2391
|
-
* @param {*} value The value to query.
|
|
2392
|
-
* @returns {string} Returns the `toStringTag`.
|
|
2393
|
-
*/
|
|
2394
|
-
function baseGetTag(value) {
|
|
2395
|
-
if (value == null) {
|
|
2396
|
-
return value === undefined ? undefinedTag : nullTag;
|
|
2397
|
-
}
|
|
2398
|
-
return (symToStringTag$1 && symToStringTag$1 in Object(value))
|
|
2399
|
-
? getRawTag(value)
|
|
2400
|
-
: objectToString(value);
|
|
2401
|
-
}
|
|
2402
|
-
|
|
2403
|
-
/**
|
|
2404
|
-
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
2405
|
-
* and has a `typeof` result of "object".
|
|
2406
|
-
*
|
|
2407
|
-
* @static
|
|
2408
|
-
* @memberOf _
|
|
2409
|
-
* @since 4.0.0
|
|
2410
|
-
* @category Lang
|
|
2411
|
-
* @param {*} value The value to check.
|
|
2412
|
-
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
2413
|
-
* @example
|
|
2414
|
-
*
|
|
2415
|
-
* _.isObjectLike({});
|
|
2416
|
-
* // => true
|
|
2417
|
-
*
|
|
2418
|
-
* _.isObjectLike([1, 2, 3]);
|
|
2419
|
-
* // => true
|
|
2420
|
-
*
|
|
2421
|
-
* _.isObjectLike(_.noop);
|
|
2422
|
-
* // => false
|
|
2423
|
-
*
|
|
2424
|
-
* _.isObjectLike(null);
|
|
2425
|
-
* // => false
|
|
2426
|
-
*/
|
|
2427
|
-
function isObjectLike(value) {
|
|
2428
|
-
return value != null && typeof value == 'object';
|
|
2429
|
-
}
|
|
2430
|
-
|
|
2431
|
-
/** `Object#toString` result references. */
|
|
2432
|
-
var symbolTag = '[object Symbol]';
|
|
2433
|
-
|
|
2434
|
-
/**
|
|
2435
|
-
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
2436
|
-
*
|
|
2437
|
-
* @static
|
|
2438
|
-
* @memberOf _
|
|
2439
|
-
* @since 4.0.0
|
|
2440
|
-
* @category Lang
|
|
2441
|
-
* @param {*} value The value to check.
|
|
2442
|
-
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
2443
|
-
* @example
|
|
2444
|
-
*
|
|
2445
|
-
* _.isSymbol(Symbol.iterator);
|
|
2446
|
-
* // => true
|
|
2447
|
-
*
|
|
2448
|
-
* _.isSymbol('abc');
|
|
2449
|
-
* // => false
|
|
2450
|
-
*/
|
|
2451
|
-
function isSymbol(value) {
|
|
2452
|
-
return typeof value == 'symbol' ||
|
|
2453
|
-
(isObjectLike(value) && baseGetTag(value) == symbolTag);
|
|
2454
|
-
}
|
|
2455
|
-
|
|
2456
|
-
/** Used to match property names within property paths. */
|
|
2457
|
-
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
|
2458
|
-
reIsPlainProp = /^\w*$/;
|
|
2459
|
-
|
|
2460
|
-
/**
|
|
2461
|
-
* Checks if `value` is a property name and not a property path.
|
|
2462
|
-
*
|
|
2463
|
-
* @private
|
|
2464
|
-
* @param {*} value The value to check.
|
|
2465
|
-
* @param {Object} [object] The object to query keys on.
|
|
2466
|
-
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
|
2467
|
-
*/
|
|
2468
|
-
function isKey(value, object) {
|
|
2469
|
-
if (isArray(value)) {
|
|
2470
|
-
return false;
|
|
2471
|
-
}
|
|
2472
|
-
var type = typeof value;
|
|
2473
|
-
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
|
|
2474
|
-
value == null || isSymbol(value)) {
|
|
2475
|
-
return true;
|
|
2476
|
-
}
|
|
2477
|
-
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
|
2478
|
-
(object != null && value in Object(object));
|
|
2479
|
-
}
|
|
2480
|
-
|
|
2481
|
-
/**
|
|
2482
|
-
* Checks if `value` is the
|
|
2483
|
-
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
2484
|
-
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
2485
|
-
*
|
|
2486
|
-
* @static
|
|
2487
|
-
* @memberOf _
|
|
2488
|
-
* @since 0.1.0
|
|
2489
|
-
* @category Lang
|
|
2490
|
-
* @param {*} value The value to check.
|
|
2491
|
-
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
2492
|
-
* @example
|
|
2493
|
-
*
|
|
2494
|
-
* _.isObject({});
|
|
2495
|
-
* // => true
|
|
2496
|
-
*
|
|
2497
|
-
* _.isObject([1, 2, 3]);
|
|
2498
|
-
* // => true
|
|
2499
|
-
*
|
|
2500
|
-
* _.isObject(_.noop);
|
|
2501
|
-
* // => true
|
|
2502
|
-
*
|
|
2503
|
-
* _.isObject(null);
|
|
2504
|
-
* // => false
|
|
2505
|
-
*/
|
|
2506
|
-
function isObject(value) {
|
|
2507
|
-
var type = typeof value;
|
|
2508
|
-
return value != null && (type == 'object' || type == 'function');
|
|
2509
|
-
}
|
|
2510
|
-
|
|
2511
|
-
/** `Object#toString` result references. */
|
|
2512
|
-
var asyncTag = '[object AsyncFunction]',
|
|
2513
|
-
funcTag = '[object Function]',
|
|
2514
|
-
genTag = '[object GeneratorFunction]',
|
|
2515
|
-
proxyTag = '[object Proxy]';
|
|
2516
|
-
|
|
2517
|
-
/**
|
|
2518
|
-
* Checks if `value` is classified as a `Function` object.
|
|
2519
|
-
*
|
|
2520
|
-
* @static
|
|
2521
|
-
* @memberOf _
|
|
2522
|
-
* @since 0.1.0
|
|
2523
|
-
* @category Lang
|
|
2524
|
-
* @param {*} value The value to check.
|
|
2525
|
-
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
2526
|
-
* @example
|
|
2527
|
-
*
|
|
2528
|
-
* _.isFunction(_);
|
|
2529
|
-
* // => true
|
|
2530
|
-
*
|
|
2531
|
-
* _.isFunction(/abc/);
|
|
2532
|
-
* // => false
|
|
2533
|
-
*/
|
|
2534
|
-
function isFunction(value) {
|
|
2535
|
-
if (!isObject(value)) {
|
|
2536
|
-
return false;
|
|
2537
|
-
}
|
|
2538
|
-
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
2539
|
-
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
2540
|
-
var tag = baseGetTag(value);
|
|
2541
|
-
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
2542
|
-
}
|
|
2543
|
-
|
|
2544
|
-
/** Used to detect overreaching core-js shims. */
|
|
2545
|
-
var coreJsData = root['__core-js_shared__'];
|
|
2546
|
-
|
|
2547
|
-
/** Used to detect methods masquerading as native. */
|
|
2548
|
-
var maskSrcKey = (function() {
|
|
2549
|
-
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
2550
|
-
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|
2551
|
-
}());
|
|
2552
|
-
|
|
2553
|
-
/**
|
|
2554
|
-
* Checks if `func` has its source masked.
|
|
2555
|
-
*
|
|
2556
|
-
* @private
|
|
2557
|
-
* @param {Function} func The function to check.
|
|
2558
|
-
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
2559
|
-
*/
|
|
2560
|
-
function isMasked(func) {
|
|
2561
|
-
return !!maskSrcKey && (maskSrcKey in func);
|
|
2562
|
-
}
|
|
2563
|
-
|
|
2564
|
-
/** Used for built-in method references. */
|
|
2565
|
-
var funcProto = Function.prototype;
|
|
2566
|
-
|
|
2567
|
-
/** Used to resolve the decompiled source of functions. */
|
|
2568
|
-
var funcToString = funcProto.toString;
|
|
2569
|
-
|
|
2570
|
-
/**
|
|
2571
|
-
* Converts `func` to its source code.
|
|
2572
|
-
*
|
|
2573
|
-
* @private
|
|
2574
|
-
* @param {Function} func The function to convert.
|
|
2575
|
-
* @returns {string} Returns the source code.
|
|
2576
|
-
*/
|
|
2577
|
-
function toSource(func) {
|
|
2578
|
-
if (func != null) {
|
|
2579
|
-
try {
|
|
2580
|
-
return funcToString.call(func);
|
|
2581
|
-
} catch (e) {}
|
|
2582
|
-
try {
|
|
2583
|
-
return (func + '');
|
|
2584
|
-
} catch (e) {}
|
|
2585
|
-
}
|
|
2586
|
-
return '';
|
|
2587
|
-
}
|
|
2588
|
-
|
|
2589
|
-
/**
|
|
2590
|
-
* Used to match `RegExp`
|
|
2591
|
-
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
2592
|
-
*/
|
|
2593
|
-
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
2594
|
-
|
|
2595
|
-
/** Used to detect host constructors (Safari). */
|
|
2596
|
-
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
2597
|
-
|
|
2598
|
-
/** Used for built-in method references. */
|
|
2599
|
-
var funcProto$1 = Function.prototype,
|
|
2600
|
-
objectProto$2 = Object.prototype;
|
|
2601
|
-
|
|
2602
|
-
/** Used to resolve the decompiled source of functions. */
|
|
2603
|
-
var funcToString$1 = funcProto$1.toString;
|
|
2604
|
-
|
|
2605
|
-
/** Used to check objects for own properties. */
|
|
2606
|
-
var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
|
|
2607
|
-
|
|
2608
|
-
/** Used to detect if a method is native. */
|
|
2609
|
-
var reIsNative = RegExp('^' +
|
|
2610
|
-
funcToString$1.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
|
|
2611
|
-
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
2612
|
-
);
|
|
2613
|
-
|
|
2614
|
-
/**
|
|
2615
|
-
* The base implementation of `_.isNative` without bad shim checks.
|
|
2616
|
-
*
|
|
2617
|
-
* @private
|
|
2618
|
-
* @param {*} value The value to check.
|
|
2619
|
-
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
2620
|
-
* else `false`.
|
|
2621
|
-
*/
|
|
2622
|
-
function baseIsNative(value) {
|
|
2623
|
-
if (!isObject(value) || isMasked(value)) {
|
|
2624
|
-
return false;
|
|
2625
|
-
}
|
|
2626
|
-
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
2627
|
-
return pattern.test(toSource(value));
|
|
2628
|
-
}
|
|
2629
|
-
|
|
2630
|
-
/**
|
|
2631
|
-
* Gets the value at `key` of `object`.
|
|
2632
|
-
*
|
|
2633
|
-
* @private
|
|
2634
|
-
* @param {Object} [object] The object to query.
|
|
2635
|
-
* @param {string} key The key of the property to get.
|
|
2636
|
-
* @returns {*} Returns the property value.
|
|
2637
|
-
*/
|
|
2638
|
-
function getValue(object, key) {
|
|
2639
|
-
return object == null ? undefined : object[key];
|
|
2640
|
-
}
|
|
2641
|
-
|
|
2642
|
-
/**
|
|
2643
|
-
* Gets the native function at `key` of `object`.
|
|
2644
|
-
*
|
|
2645
|
-
* @private
|
|
2646
|
-
* @param {Object} object The object to query.
|
|
2647
|
-
* @param {string} key The key of the method to get.
|
|
2648
|
-
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
2649
|
-
*/
|
|
2650
|
-
function getNative(object, key) {
|
|
2651
|
-
var value = getValue(object, key);
|
|
2652
|
-
return baseIsNative(value) ? value : undefined;
|
|
2653
|
-
}
|
|
2654
|
-
|
|
2655
|
-
/* Built-in method references that are verified to be native. */
|
|
2656
|
-
var nativeCreate = getNative(Object, 'create');
|
|
2657
|
-
|
|
2658
|
-
/**
|
|
2659
|
-
* Removes all key-value entries from the hash.
|
|
2660
|
-
*
|
|
2661
|
-
* @private
|
|
2662
|
-
* @name clear
|
|
2663
|
-
* @memberOf Hash
|
|
2664
|
-
*/
|
|
2665
|
-
function hashClear() {
|
|
2666
|
-
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
2667
|
-
this.size = 0;
|
|
2668
|
-
}
|
|
2669
|
-
|
|
2670
|
-
/**
|
|
2671
|
-
* Removes `key` and its value from the hash.
|
|
2672
|
-
*
|
|
2673
|
-
* @private
|
|
2674
|
-
* @name delete
|
|
2675
|
-
* @memberOf Hash
|
|
2676
|
-
* @param {Object} hash The hash to modify.
|
|
2677
|
-
* @param {string} key The key of the value to remove.
|
|
2678
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
2679
|
-
*/
|
|
2680
|
-
function hashDelete(key) {
|
|
2681
|
-
var result = this.has(key) && delete this.__data__[key];
|
|
2682
|
-
this.size -= result ? 1 : 0;
|
|
2683
|
-
return result;
|
|
2684
|
-
}
|
|
2685
|
-
|
|
2686
|
-
/** Used to stand-in for `undefined` hash values. */
|
|
2687
|
-
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
2688
|
-
|
|
2689
|
-
/** Used for built-in method references. */
|
|
2690
|
-
var objectProto$3 = Object.prototype;
|
|
2691
|
-
|
|
2692
|
-
/** Used to check objects for own properties. */
|
|
2693
|
-
var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
|
|
2694
|
-
|
|
2695
|
-
/**
|
|
2696
|
-
* Gets the hash value for `key`.
|
|
2697
|
-
*
|
|
2698
|
-
* @private
|
|
2699
|
-
* @name get
|
|
2700
|
-
* @memberOf Hash
|
|
2701
|
-
* @param {string} key The key of the value to get.
|
|
2702
|
-
* @returns {*} Returns the entry value.
|
|
2703
|
-
*/
|
|
2704
|
-
function hashGet(key) {
|
|
2705
|
-
var data = this.__data__;
|
|
2706
|
-
if (nativeCreate) {
|
|
2707
|
-
var result = data[key];
|
|
2708
|
-
return result === HASH_UNDEFINED ? undefined : result;
|
|
2709
|
-
}
|
|
2710
|
-
return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
|
|
2711
|
-
}
|
|
2712
|
-
|
|
2713
|
-
/** Used for built-in method references. */
|
|
2714
|
-
var objectProto$4 = Object.prototype;
|
|
2715
|
-
|
|
2716
|
-
/** Used to check objects for own properties. */
|
|
2717
|
-
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
|
|
2718
|
-
|
|
2719
|
-
/**
|
|
2720
|
-
* Checks if a hash value for `key` exists.
|
|
2721
|
-
*
|
|
2722
|
-
* @private
|
|
2723
|
-
* @name has
|
|
2724
|
-
* @memberOf Hash
|
|
2725
|
-
* @param {string} key The key of the entry to check.
|
|
2726
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
2727
|
-
*/
|
|
2728
|
-
function hashHas(key) {
|
|
2729
|
-
var data = this.__data__;
|
|
2730
|
-
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$3.call(data, key);
|
|
2731
|
-
}
|
|
2732
|
-
|
|
2733
|
-
/** Used to stand-in for `undefined` hash values. */
|
|
2734
|
-
var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
|
2735
|
-
|
|
2736
|
-
/**
|
|
2737
|
-
* Sets the hash `key` to `value`.
|
|
2738
|
-
*
|
|
2739
|
-
* @private
|
|
2740
|
-
* @name set
|
|
2741
|
-
* @memberOf Hash
|
|
2742
|
-
* @param {string} key The key of the value to set.
|
|
2743
|
-
* @param {*} value The value to set.
|
|
2744
|
-
* @returns {Object} Returns the hash instance.
|
|
2745
|
-
*/
|
|
2746
|
-
function hashSet(key, value) {
|
|
2747
|
-
var data = this.__data__;
|
|
2748
|
-
this.size += this.has(key) ? 0 : 1;
|
|
2749
|
-
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
|
|
2750
|
-
return this;
|
|
2751
|
-
}
|
|
2752
|
-
|
|
2753
|
-
/**
|
|
2754
|
-
* Creates a hash object.
|
|
2755
|
-
*
|
|
2756
|
-
* @private
|
|
2757
|
-
* @constructor
|
|
2758
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
2759
|
-
*/
|
|
2760
|
-
function Hash(entries) {
|
|
2761
|
-
var index = -1,
|
|
2762
|
-
length = entries == null ? 0 : entries.length;
|
|
2763
|
-
|
|
2764
|
-
this.clear();
|
|
2765
|
-
while (++index < length) {
|
|
2766
|
-
var entry = entries[index];
|
|
2767
|
-
this.set(entry[0], entry[1]);
|
|
2768
|
-
}
|
|
2769
|
-
}
|
|
2770
|
-
|
|
2771
|
-
// Add methods to `Hash`.
|
|
2772
|
-
Hash.prototype.clear = hashClear;
|
|
2773
|
-
Hash.prototype['delete'] = hashDelete;
|
|
2774
|
-
Hash.prototype.get = hashGet;
|
|
2775
|
-
Hash.prototype.has = hashHas;
|
|
2776
|
-
Hash.prototype.set = hashSet;
|
|
2777
|
-
|
|
2778
|
-
/**
|
|
2779
|
-
* Removes all key-value entries from the list cache.
|
|
2780
|
-
*
|
|
2781
|
-
* @private
|
|
2782
|
-
* @name clear
|
|
2783
|
-
* @memberOf ListCache
|
|
2784
|
-
*/
|
|
2785
|
-
function listCacheClear() {
|
|
2786
|
-
this.__data__ = [];
|
|
2787
|
-
this.size = 0;
|
|
2788
|
-
}
|
|
2789
|
-
|
|
2790
|
-
/**
|
|
2791
|
-
* Performs a
|
|
2792
|
-
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
2793
|
-
* comparison between two values to determine if they are equivalent.
|
|
2794
|
-
*
|
|
2795
|
-
* @static
|
|
2796
|
-
* @memberOf _
|
|
2797
|
-
* @since 4.0.0
|
|
2798
|
-
* @category Lang
|
|
2799
|
-
* @param {*} value The value to compare.
|
|
2800
|
-
* @param {*} other The other value to compare.
|
|
2801
|
-
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
2802
|
-
* @example
|
|
2803
|
-
*
|
|
2804
|
-
* var object = { 'a': 1 };
|
|
2805
|
-
* var other = { 'a': 1 };
|
|
2806
|
-
*
|
|
2807
|
-
* _.eq(object, object);
|
|
2808
|
-
* // => true
|
|
2809
|
-
*
|
|
2810
|
-
* _.eq(object, other);
|
|
2811
|
-
* // => false
|
|
2812
|
-
*
|
|
2813
|
-
* _.eq('a', 'a');
|
|
2814
|
-
* // => true
|
|
2815
|
-
*
|
|
2816
|
-
* _.eq('a', Object('a'));
|
|
2817
|
-
* // => false
|
|
2818
|
-
*
|
|
2819
|
-
* _.eq(NaN, NaN);
|
|
2820
|
-
* // => true
|
|
2821
|
-
*/
|
|
2822
|
-
function eq(value, other) {
|
|
2823
|
-
return value === other || (value !== value && other !== other);
|
|
2824
|
-
}
|
|
2825
|
-
|
|
2826
|
-
/**
|
|
2827
|
-
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
2828
|
-
*
|
|
2829
|
-
* @private
|
|
2830
|
-
* @param {Array} array The array to inspect.
|
|
2831
|
-
* @param {*} key The key to search for.
|
|
2832
|
-
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
2833
|
-
*/
|
|
2834
|
-
function assocIndexOf(array, key) {
|
|
2835
|
-
var length = array.length;
|
|
2836
|
-
while (length--) {
|
|
2837
|
-
if (eq(array[length][0], key)) {
|
|
2838
|
-
return length;
|
|
2839
|
-
}
|
|
2840
|
-
}
|
|
2841
|
-
return -1;
|
|
2842
|
-
}
|
|
2843
|
-
|
|
2844
|
-
/** Used for built-in method references. */
|
|
2845
|
-
var arrayProto = Array.prototype;
|
|
2846
|
-
|
|
2847
|
-
/** Built-in value references. */
|
|
2848
|
-
var splice = arrayProto.splice;
|
|
2849
|
-
|
|
2850
|
-
/**
|
|
2851
|
-
* Removes `key` and its value from the list cache.
|
|
2852
|
-
*
|
|
2853
|
-
* @private
|
|
2854
|
-
* @name delete
|
|
2855
|
-
* @memberOf ListCache
|
|
2856
|
-
* @param {string} key The key of the value to remove.
|
|
2857
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
2858
|
-
*/
|
|
2859
|
-
function listCacheDelete(key) {
|
|
2860
|
-
var data = this.__data__,
|
|
2861
|
-
index = assocIndexOf(data, key);
|
|
2862
|
-
|
|
2863
|
-
if (index < 0) {
|
|
2864
|
-
return false;
|
|
2865
|
-
}
|
|
2866
|
-
var lastIndex = data.length - 1;
|
|
2867
|
-
if (index == lastIndex) {
|
|
2868
|
-
data.pop();
|
|
2869
|
-
} else {
|
|
2870
|
-
splice.call(data, index, 1);
|
|
2871
|
-
}
|
|
2872
|
-
--this.size;
|
|
2873
|
-
return true;
|
|
2874
|
-
}
|
|
2875
|
-
|
|
2876
|
-
/**
|
|
2877
|
-
* Gets the list cache value for `key`.
|
|
2878
|
-
*
|
|
2879
|
-
* @private
|
|
2880
|
-
* @name get
|
|
2881
|
-
* @memberOf ListCache
|
|
2882
|
-
* @param {string} key The key of the value to get.
|
|
2883
|
-
* @returns {*} Returns the entry value.
|
|
2884
|
-
*/
|
|
2885
|
-
function listCacheGet(key) {
|
|
2886
|
-
var data = this.__data__,
|
|
2887
|
-
index = assocIndexOf(data, key);
|
|
2888
|
-
|
|
2889
|
-
return index < 0 ? undefined : data[index][1];
|
|
2890
|
-
}
|
|
2891
|
-
|
|
2892
|
-
/**
|
|
2893
|
-
* Checks if a list cache value for `key` exists.
|
|
2894
|
-
*
|
|
2895
|
-
* @private
|
|
2896
|
-
* @name has
|
|
2897
|
-
* @memberOf ListCache
|
|
2898
|
-
* @param {string} key The key of the entry to check.
|
|
2899
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
2900
|
-
*/
|
|
2901
|
-
function listCacheHas(key) {
|
|
2902
|
-
return assocIndexOf(this.__data__, key) > -1;
|
|
2903
|
-
}
|
|
2904
|
-
|
|
2905
|
-
/**
|
|
2906
|
-
* Sets the list cache `key` to `value`.
|
|
2907
|
-
*
|
|
2908
|
-
* @private
|
|
2909
|
-
* @name set
|
|
2910
|
-
* @memberOf ListCache
|
|
2911
|
-
* @param {string} key The key of the value to set.
|
|
2912
|
-
* @param {*} value The value to set.
|
|
2913
|
-
* @returns {Object} Returns the list cache instance.
|
|
2914
|
-
*/
|
|
2915
|
-
function listCacheSet(key, value) {
|
|
2916
|
-
var data = this.__data__,
|
|
2917
|
-
index = assocIndexOf(data, key);
|
|
2918
|
-
|
|
2919
|
-
if (index < 0) {
|
|
2920
|
-
++this.size;
|
|
2921
|
-
data.push([key, value]);
|
|
2922
|
-
} else {
|
|
2923
|
-
data[index][1] = value;
|
|
2924
|
-
}
|
|
2925
|
-
return this;
|
|
2926
|
-
}
|
|
2927
|
-
|
|
2928
|
-
/**
|
|
2929
|
-
* Creates an list cache object.
|
|
2930
|
-
*
|
|
2931
|
-
* @private
|
|
2932
|
-
* @constructor
|
|
2933
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
2934
|
-
*/
|
|
2935
|
-
function ListCache(entries) {
|
|
2936
|
-
var index = -1,
|
|
2937
|
-
length = entries == null ? 0 : entries.length;
|
|
2938
|
-
|
|
2939
|
-
this.clear();
|
|
2940
|
-
while (++index < length) {
|
|
2941
|
-
var entry = entries[index];
|
|
2942
|
-
this.set(entry[0], entry[1]);
|
|
2943
|
-
}
|
|
2944
|
-
}
|
|
2945
|
-
|
|
2946
|
-
// Add methods to `ListCache`.
|
|
2947
|
-
ListCache.prototype.clear = listCacheClear;
|
|
2948
|
-
ListCache.prototype['delete'] = listCacheDelete;
|
|
2949
|
-
ListCache.prototype.get = listCacheGet;
|
|
2950
|
-
ListCache.prototype.has = listCacheHas;
|
|
2951
|
-
ListCache.prototype.set = listCacheSet;
|
|
2952
|
-
|
|
2953
|
-
/* Built-in method references that are verified to be native. */
|
|
2954
|
-
var Map$1 = getNative(root, 'Map');
|
|
2955
|
-
|
|
2956
|
-
/**
|
|
2957
|
-
* Removes all key-value entries from the map.
|
|
2958
|
-
*
|
|
2959
|
-
* @private
|
|
2960
|
-
* @name clear
|
|
2961
|
-
* @memberOf MapCache
|
|
2962
|
-
*/
|
|
2963
|
-
function mapCacheClear() {
|
|
2964
|
-
this.size = 0;
|
|
2965
|
-
this.__data__ = {
|
|
2966
|
-
'hash': new Hash,
|
|
2967
|
-
'map': new (Map$1 || ListCache),
|
|
2968
|
-
'string': new Hash
|
|
2969
|
-
};
|
|
2970
|
-
}
|
|
2971
|
-
|
|
2972
|
-
/**
|
|
2973
|
-
* Checks if `value` is suitable for use as unique object key.
|
|
2974
|
-
*
|
|
2975
|
-
* @private
|
|
2976
|
-
* @param {*} value The value to check.
|
|
2977
|
-
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
2978
|
-
*/
|
|
2979
|
-
function isKeyable(value) {
|
|
2980
|
-
var type = typeof value;
|
|
2981
|
-
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
|
2982
|
-
? (value !== '__proto__')
|
|
2983
|
-
: (value === null);
|
|
2984
|
-
}
|
|
2985
|
-
|
|
2986
|
-
/**
|
|
2987
|
-
* Gets the data for `map`.
|
|
2988
|
-
*
|
|
2989
|
-
* @private
|
|
2990
|
-
* @param {Object} map The map to query.
|
|
2991
|
-
* @param {string} key The reference key.
|
|
2992
|
-
* @returns {*} Returns the map data.
|
|
2993
|
-
*/
|
|
2994
|
-
function getMapData(map, key) {
|
|
2995
|
-
var data = map.__data__;
|
|
2996
|
-
return isKeyable(key)
|
|
2997
|
-
? data[typeof key == 'string' ? 'string' : 'hash']
|
|
2998
|
-
: data.map;
|
|
2999
|
-
}
|
|
3000
|
-
|
|
3001
|
-
/**
|
|
3002
|
-
* Removes `key` and its value from the map.
|
|
3003
|
-
*
|
|
3004
|
-
* @private
|
|
3005
|
-
* @name delete
|
|
3006
|
-
* @memberOf MapCache
|
|
3007
|
-
* @param {string} key The key of the value to remove.
|
|
3008
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
3009
|
-
*/
|
|
3010
|
-
function mapCacheDelete(key) {
|
|
3011
|
-
var result = getMapData(this, key)['delete'](key);
|
|
3012
|
-
this.size -= result ? 1 : 0;
|
|
3013
|
-
return result;
|
|
3014
|
-
}
|
|
3015
|
-
|
|
3016
|
-
/**
|
|
3017
|
-
* Gets the map value for `key`.
|
|
3018
|
-
*
|
|
3019
|
-
* @private
|
|
3020
|
-
* @name get
|
|
3021
|
-
* @memberOf MapCache
|
|
3022
|
-
* @param {string} key The key of the value to get.
|
|
3023
|
-
* @returns {*} Returns the entry value.
|
|
3024
|
-
*/
|
|
3025
|
-
function mapCacheGet(key) {
|
|
3026
|
-
return getMapData(this, key).get(key);
|
|
3027
|
-
}
|
|
3028
|
-
|
|
3029
|
-
/**
|
|
3030
|
-
* Checks if a map value for `key` exists.
|
|
3031
|
-
*
|
|
3032
|
-
* @private
|
|
3033
|
-
* @name has
|
|
3034
|
-
* @memberOf MapCache
|
|
3035
|
-
* @param {string} key The key of the entry to check.
|
|
3036
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
3037
|
-
*/
|
|
3038
|
-
function mapCacheHas(key) {
|
|
3039
|
-
return getMapData(this, key).has(key);
|
|
3040
|
-
}
|
|
3041
|
-
|
|
3042
|
-
/**
|
|
3043
|
-
* Sets the map `key` to `value`.
|
|
3044
|
-
*
|
|
3045
|
-
* @private
|
|
3046
|
-
* @name set
|
|
3047
|
-
* @memberOf MapCache
|
|
3048
|
-
* @param {string} key The key of the value to set.
|
|
3049
|
-
* @param {*} value The value to set.
|
|
3050
|
-
* @returns {Object} Returns the map cache instance.
|
|
3051
|
-
*/
|
|
3052
|
-
function mapCacheSet(key, value) {
|
|
3053
|
-
var data = getMapData(this, key),
|
|
3054
|
-
size = data.size;
|
|
3055
|
-
|
|
3056
|
-
data.set(key, value);
|
|
3057
|
-
this.size += data.size == size ? 0 : 1;
|
|
3058
|
-
return this;
|
|
3059
|
-
}
|
|
3060
|
-
|
|
3061
|
-
/**
|
|
3062
|
-
* Creates a map cache object to store key-value pairs.
|
|
3063
|
-
*
|
|
3064
|
-
* @private
|
|
3065
|
-
* @constructor
|
|
3066
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
3067
|
-
*/
|
|
3068
|
-
function MapCache(entries) {
|
|
3069
|
-
var index = -1,
|
|
3070
|
-
length = entries == null ? 0 : entries.length;
|
|
3071
|
-
|
|
3072
|
-
this.clear();
|
|
3073
|
-
while (++index < length) {
|
|
3074
|
-
var entry = entries[index];
|
|
3075
|
-
this.set(entry[0], entry[1]);
|
|
3076
|
-
}
|
|
3077
|
-
}
|
|
3078
|
-
|
|
3079
|
-
// Add methods to `MapCache`.
|
|
3080
|
-
MapCache.prototype.clear = mapCacheClear;
|
|
3081
|
-
MapCache.prototype['delete'] = mapCacheDelete;
|
|
3082
|
-
MapCache.prototype.get = mapCacheGet;
|
|
3083
|
-
MapCache.prototype.has = mapCacheHas;
|
|
3084
|
-
MapCache.prototype.set = mapCacheSet;
|
|
3085
|
-
|
|
3086
|
-
/** Error message constants. */
|
|
3087
|
-
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
3088
|
-
|
|
3089
|
-
/**
|
|
3090
|
-
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|
3091
|
-
* provided, it determines the cache key for storing the result based on the
|
|
3092
|
-
* arguments provided to the memoized function. By default, the first argument
|
|
3093
|
-
* provided to the memoized function is used as the map cache key. The `func`
|
|
3094
|
-
* is invoked with the `this` binding of the memoized function.
|
|
3095
|
-
*
|
|
3096
|
-
* **Note:** The cache is exposed as the `cache` property on the memoized
|
|
3097
|
-
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
|
3098
|
-
* constructor with one whose instances implement the
|
|
3099
|
-
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
|
3100
|
-
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
|
|
3101
|
-
*
|
|
3102
|
-
* @static
|
|
3103
|
-
* @memberOf _
|
|
3104
|
-
* @since 0.1.0
|
|
3105
|
-
* @category Function
|
|
3106
|
-
* @param {Function} func The function to have its output memoized.
|
|
3107
|
-
* @param {Function} [resolver] The function to resolve the cache key.
|
|
3108
|
-
* @returns {Function} Returns the new memoized function.
|
|
3109
|
-
* @example
|
|
3110
|
-
*
|
|
3111
|
-
* var object = { 'a': 1, 'b': 2 };
|
|
3112
|
-
* var other = { 'c': 3, 'd': 4 };
|
|
3113
|
-
*
|
|
3114
|
-
* var values = _.memoize(_.values);
|
|
3115
|
-
* values(object);
|
|
3116
|
-
* // => [1, 2]
|
|
3117
|
-
*
|
|
3118
|
-
* values(other);
|
|
3119
|
-
* // => [3, 4]
|
|
3120
|
-
*
|
|
3121
|
-
* object.a = 2;
|
|
3122
|
-
* values(object);
|
|
3123
|
-
* // => [1, 2]
|
|
3124
|
-
*
|
|
3125
|
-
* // Modify the result cache.
|
|
3126
|
-
* values.cache.set(object, ['a', 'b']);
|
|
3127
|
-
* values(object);
|
|
3128
|
-
* // => ['a', 'b']
|
|
3129
|
-
*
|
|
3130
|
-
* // Replace `_.memoize.Cache`.
|
|
3131
|
-
* _.memoize.Cache = WeakMap;
|
|
3132
|
-
*/
|
|
3133
|
-
function memoize(func, resolver) {
|
|
3134
|
-
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
|
|
3135
|
-
throw new TypeError(FUNC_ERROR_TEXT);
|
|
3136
|
-
}
|
|
3137
|
-
var memoized = function() {
|
|
3138
|
-
var args = arguments,
|
|
3139
|
-
key = resolver ? resolver.apply(this, args) : args[0],
|
|
3140
|
-
cache = memoized.cache;
|
|
3141
|
-
|
|
3142
|
-
if (cache.has(key)) {
|
|
3143
|
-
return cache.get(key);
|
|
3144
|
-
}
|
|
3145
|
-
var result = func.apply(this, args);
|
|
3146
|
-
memoized.cache = cache.set(key, result) || cache;
|
|
3147
|
-
return result;
|
|
3148
|
-
};
|
|
3149
|
-
memoized.cache = new (memoize.Cache || MapCache);
|
|
3150
|
-
return memoized;
|
|
3151
|
-
}
|
|
3152
|
-
|
|
3153
|
-
// Expose `MapCache`.
|
|
3154
|
-
memoize.Cache = MapCache;
|
|
3155
|
-
|
|
3156
|
-
/** Used as the maximum memoize cache size. */
|
|
3157
|
-
var MAX_MEMOIZE_SIZE = 500;
|
|
3158
|
-
|
|
3159
|
-
/**
|
|
3160
|
-
* A specialized version of `_.memoize` which clears the memoized function's
|
|
3161
|
-
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
|
3162
|
-
*
|
|
3163
|
-
* @private
|
|
3164
|
-
* @param {Function} func The function to have its output memoized.
|
|
3165
|
-
* @returns {Function} Returns the new memoized function.
|
|
3166
|
-
*/
|
|
3167
|
-
function memoizeCapped(func) {
|
|
3168
|
-
var result = memoize(func, function(key) {
|
|
3169
|
-
if (cache.size === MAX_MEMOIZE_SIZE) {
|
|
3170
|
-
cache.clear();
|
|
3171
|
-
}
|
|
3172
|
-
return key;
|
|
3173
|
-
});
|
|
3174
|
-
|
|
3175
|
-
var cache = result.cache;
|
|
3176
|
-
return result;
|
|
3177
|
-
}
|
|
3178
|
-
|
|
3179
|
-
/** Used to match property names within property paths. */
|
|
3180
|
-
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
3181
|
-
|
|
3182
|
-
/** Used to match backslashes in property paths. */
|
|
3183
|
-
var reEscapeChar = /\\(\\)?/g;
|
|
3184
|
-
|
|
3185
|
-
/**
|
|
3186
|
-
* Converts `string` to a property path array.
|
|
3187
|
-
*
|
|
3188
|
-
* @private
|
|
3189
|
-
* @param {string} string The string to convert.
|
|
3190
|
-
* @returns {Array} Returns the property path array.
|
|
3191
|
-
*/
|
|
3192
|
-
var stringToPath = memoizeCapped(function(string) {
|
|
3193
|
-
var result = [];
|
|
3194
|
-
if (string.charCodeAt(0) === 46 /* . */) {
|
|
3195
|
-
result.push('');
|
|
3196
|
-
}
|
|
3197
|
-
string.replace(rePropName, function(match, number, quote, subString) {
|
|
3198
|
-
result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
|
|
3199
|
-
});
|
|
3200
|
-
return result;
|
|
3201
|
-
});
|
|
3202
|
-
|
|
3203
|
-
/**
|
|
3204
|
-
* A specialized version of `_.map` for arrays without support for iteratee
|
|
3205
|
-
* shorthands.
|
|
3206
|
-
*
|
|
3207
|
-
* @private
|
|
3208
|
-
* @param {Array} [array] The array to iterate over.
|
|
3209
|
-
* @param {Function} iteratee The function invoked per iteration.
|
|
3210
|
-
* @returns {Array} Returns the new mapped array.
|
|
3211
|
-
*/
|
|
3212
|
-
function arrayMap(array, iteratee) {
|
|
3213
|
-
var index = -1,
|
|
3214
|
-
length = array == null ? 0 : array.length,
|
|
3215
|
-
result = Array(length);
|
|
3216
|
-
|
|
3217
|
-
while (++index < length) {
|
|
3218
|
-
result[index] = iteratee(array[index], index, array);
|
|
3219
|
-
}
|
|
3220
|
-
return result;
|
|
3221
|
-
}
|
|
3222
|
-
|
|
3223
|
-
/** Used as references for various `Number` constants. */
|
|
3224
|
-
var INFINITY = 1 / 0;
|
|
3225
|
-
|
|
3226
|
-
/** Used to convert symbols to primitives and strings. */
|
|
3227
|
-
var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
|
|
3228
|
-
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
|
3229
|
-
|
|
3230
|
-
/**
|
|
3231
|
-
* The base implementation of `_.toString` which doesn't convert nullish
|
|
3232
|
-
* values to empty strings.
|
|
3233
|
-
*
|
|
3234
|
-
* @private
|
|
3235
|
-
* @param {*} value The value to process.
|
|
3236
|
-
* @returns {string} Returns the string.
|
|
3237
|
-
*/
|
|
3238
|
-
function baseToString(value) {
|
|
3239
|
-
// Exit early for strings to avoid a performance hit in some environments.
|
|
3240
|
-
if (typeof value == 'string') {
|
|
3241
|
-
return value;
|
|
3242
|
-
}
|
|
3243
|
-
if (isArray(value)) {
|
|
3244
|
-
// Recursively convert values (susceptible to call stack limits).
|
|
3245
|
-
return arrayMap(value, baseToString) + '';
|
|
3246
|
-
}
|
|
3247
|
-
if (isSymbol(value)) {
|
|
3248
|
-
return symbolToString ? symbolToString.call(value) : '';
|
|
3249
|
-
}
|
|
3250
|
-
var result = (value + '');
|
|
3251
|
-
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
|
3252
|
-
}
|
|
3253
|
-
|
|
3254
|
-
/**
|
|
3255
|
-
* Converts `value` to a string. An empty string is returned for `null`
|
|
3256
|
-
* and `undefined` values. The sign of `-0` is preserved.
|
|
3257
|
-
*
|
|
3258
|
-
* @static
|
|
3259
|
-
* @memberOf _
|
|
3260
|
-
* @since 4.0.0
|
|
3261
|
-
* @category Lang
|
|
3262
|
-
* @param {*} value The value to convert.
|
|
3263
|
-
* @returns {string} Returns the converted string.
|
|
3264
|
-
* @example
|
|
3265
|
-
*
|
|
3266
|
-
* _.toString(null);
|
|
3267
|
-
* // => ''
|
|
3268
|
-
*
|
|
3269
|
-
* _.toString(-0);
|
|
3270
|
-
* // => '-0'
|
|
3271
|
-
*
|
|
3272
|
-
* _.toString([1, 2, 3]);
|
|
3273
|
-
* // => '1,2,3'
|
|
3274
|
-
*/
|
|
3275
|
-
function toString(value) {
|
|
3276
|
-
return value == null ? '' : baseToString(value);
|
|
3277
|
-
}
|
|
3278
|
-
|
|
3279
|
-
/**
|
|
3280
|
-
* Casts `value` to a path array if it's not one.
|
|
3281
|
-
*
|
|
3282
|
-
* @private
|
|
3283
|
-
* @param {*} value The value to inspect.
|
|
3284
|
-
* @param {Object} [object] The object to query keys on.
|
|
3285
|
-
* @returns {Array} Returns the cast property path array.
|
|
3286
|
-
*/
|
|
3287
|
-
function castPath(value, object) {
|
|
3288
|
-
if (isArray(value)) {
|
|
3289
|
-
return value;
|
|
3290
|
-
}
|
|
3291
|
-
return isKey(value, object) ? [value] : stringToPath(toString(value));
|
|
3292
|
-
}
|
|
3293
|
-
|
|
3294
|
-
/** Used as references for various `Number` constants. */
|
|
3295
|
-
var INFINITY$1 = 1 / 0;
|
|
3296
|
-
|
|
3297
|
-
/**
|
|
3298
|
-
* Converts `value` to a string key if it's not a string or symbol.
|
|
3299
|
-
*
|
|
3300
|
-
* @private
|
|
3301
|
-
* @param {*} value The value to inspect.
|
|
3302
|
-
* @returns {string|symbol} Returns the key.
|
|
3303
|
-
*/
|
|
3304
|
-
function toKey(value) {
|
|
3305
|
-
if (typeof value == 'string' || isSymbol(value)) {
|
|
3306
|
-
return value;
|
|
3307
|
-
}
|
|
3308
|
-
var result = (value + '');
|
|
3309
|
-
return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
|
|
3310
|
-
}
|
|
3311
|
-
|
|
3312
|
-
/**
|
|
3313
|
-
* The base implementation of `_.get` without support for default values.
|
|
3314
|
-
*
|
|
3315
|
-
* @private
|
|
3316
|
-
* @param {Object} object The object to query.
|
|
3317
|
-
* @param {Array|string} path The path of the property to get.
|
|
3318
|
-
* @returns {*} Returns the resolved value.
|
|
3319
|
-
*/
|
|
3320
|
-
function baseGet(object, path) {
|
|
3321
|
-
path = castPath(path, object);
|
|
3322
|
-
|
|
3323
|
-
var index = 0,
|
|
3324
|
-
length = path.length;
|
|
3325
|
-
|
|
3326
|
-
while (object != null && index < length) {
|
|
3327
|
-
object = object[toKey(path[index++])];
|
|
3328
|
-
}
|
|
3329
|
-
return (index && index == length) ? object : undefined;
|
|
3330
|
-
}
|
|
3331
|
-
|
|
3332
|
-
/**
|
|
3333
|
-
* Gets the value at `path` of `object`. If the resolved value is
|
|
3334
|
-
* `undefined`, the `defaultValue` is returned in its place.
|
|
3335
|
-
*
|
|
3336
|
-
* @static
|
|
3337
|
-
* @memberOf _
|
|
3338
|
-
* @since 3.7.0
|
|
3339
|
-
* @category Object
|
|
3340
|
-
* @param {Object} object The object to query.
|
|
3341
|
-
* @param {Array|string} path The path of the property to get.
|
|
3342
|
-
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
|
|
3343
|
-
* @returns {*} Returns the resolved value.
|
|
3344
|
-
* @example
|
|
3345
|
-
*
|
|
3346
|
-
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
|
3347
|
-
*
|
|
3348
|
-
* _.get(object, 'a[0].b.c');
|
|
3349
|
-
* // => 3
|
|
3350
|
-
*
|
|
3351
|
-
* _.get(object, ['a', '0', 'b', 'c']);
|
|
3352
|
-
* // => 3
|
|
3353
|
-
*
|
|
3354
|
-
* _.get(object, 'a.b.c', 'default');
|
|
3355
|
-
* // => 'default'
|
|
3356
|
-
*/
|
|
3357
|
-
function get(object, path, defaultValue) {
|
|
3358
|
-
var result = object == null ? undefined : baseGet(object, path);
|
|
3359
|
-
return result === undefined ? defaultValue : result;
|
|
3360
|
-
}
|
|
3361
|
-
|
|
3362
2323
|
const options = {
|
|
3363
2324
|
prerender: true,
|
|
3364
2325
|
debug: false
|
|
@@ -3387,18 +2348,35 @@ class Performance {
|
|
|
3387
2348
|
}
|
|
3388
2349
|
const perf = new Performance();
|
|
3389
2350
|
|
|
3390
|
-
|
|
2351
|
+
function findCustomWrapper(ctx, dataPathArr) {
|
|
2352
|
+
let currentData = ctx.__data__ || ctx.data || ctx._data;
|
|
2353
|
+
let wrapper;
|
|
2354
|
+
let index;
|
|
2355
|
+
dataPathArr.some((item, i) => {
|
|
2356
|
+
const key = item.replace(/^\[(.+)\]$/, '$1');
|
|
2357
|
+
currentData = currentData[key];
|
|
2358
|
+
if (isUndefined(currentData))
|
|
2359
|
+
return true;
|
|
2360
|
+
if (currentData.nn === CUSTOM_WRAPPER) {
|
|
2361
|
+
wrapper = currentData;
|
|
2362
|
+
index = i;
|
|
2363
|
+
}
|
|
2364
|
+
});
|
|
2365
|
+
if (wrapper) {
|
|
2366
|
+
return {
|
|
2367
|
+
wrapper,
|
|
2368
|
+
index: index
|
|
2369
|
+
};
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
3391
2372
|
let TaroRootElement = class TaroRootElement extends TaroElement {
|
|
3392
|
-
constructor(
|
|
3393
|
-
|
|
3394
|
-
super(nodeImpl, getElement, hooks, elementImpl);
|
|
3395
|
-
this.pendingFlush = false;
|
|
2373
|
+
constructor() {
|
|
2374
|
+
super();
|
|
3396
2375
|
this.updatePayloads = [];
|
|
3397
2376
|
this.updateCallbacks = [];
|
|
3398
2377
|
this.pendingUpdate = false;
|
|
3399
2378
|
this.ctx = null;
|
|
3400
2379
|
this.nodeName = ROOT_STR;
|
|
3401
|
-
this.eventCenter = eventCenter;
|
|
3402
2380
|
}
|
|
3403
2381
|
get _path() {
|
|
3404
2382
|
return ROOT_STR;
|
|
@@ -3408,7 +2386,7 @@ let TaroRootElement = class TaroRootElement extends TaroElement {
|
|
|
3408
2386
|
}
|
|
3409
2387
|
enqueueUpdate(payload) {
|
|
3410
2388
|
this.updatePayloads.push(payload);
|
|
3411
|
-
if (!this.pendingUpdate && this.ctx
|
|
2389
|
+
if (!this.pendingUpdate && this.ctx) {
|
|
3412
2390
|
this.performUpdate();
|
|
3413
2391
|
}
|
|
3414
2392
|
}
|
|
@@ -3436,97 +2414,71 @@ let TaroRootElement = class TaroRootElement extends TaroElement {
|
|
|
3436
2414
|
}
|
|
3437
2415
|
});
|
|
3438
2416
|
const value = data[path];
|
|
3439
|
-
if (isFunction
|
|
2417
|
+
if (isFunction(value)) {
|
|
3440
2418
|
data[path] = value();
|
|
3441
2419
|
}
|
|
3442
2420
|
}
|
|
3443
|
-
|
|
3444
|
-
|
|
2421
|
+
// 预渲染
|
|
2422
|
+
if (isFunction(prerender))
|
|
2423
|
+
return prerender(data);
|
|
2424
|
+
// 正常渲染
|
|
2425
|
+
this.pendingUpdate = false;
|
|
2426
|
+
let normalUpdate = {};
|
|
2427
|
+
const customWrapperMap = new Map();
|
|
2428
|
+
if (initRender) {
|
|
2429
|
+
// 初次渲染,使用页面级别的 setData
|
|
2430
|
+
normalUpdate = data;
|
|
3445
2431
|
}
|
|
3446
2432
|
else {
|
|
3447
|
-
|
|
3448
|
-
const
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
const
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
const
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
const customWrapper = ctx.selectComponent(`#${customWrapperId}`);
|
|
3461
|
-
const splitedPath = dataPathArr.slice(i).join('.');
|
|
3462
|
-
if (customWrapper) {
|
|
3463
|
-
hasCustomWrapper = true;
|
|
3464
|
-
customWrapperMap.set(customWrapper, Object.assign(Object.assign({}, (customWrapperMap.get(customWrapper) || {})), { [`i.${splitedPath}`]: data[p] }));
|
|
3465
|
-
}
|
|
3466
|
-
break;
|
|
3467
|
-
}
|
|
3468
|
-
}
|
|
3469
|
-
if (!hasCustomWrapper) {
|
|
3470
|
-
normalUpdate[p] = data[p];
|
|
2433
|
+
// 更新渲染,区分 CustomWrapper 与页面级别的 setData
|
|
2434
|
+
for (const p in data) {
|
|
2435
|
+
const dataPathArr = p.split('.');
|
|
2436
|
+
const found = findCustomWrapper(ctx, dataPathArr);
|
|
2437
|
+
if (found) {
|
|
2438
|
+
// 此项数据使用 CustomWrapper 去更新
|
|
2439
|
+
const { wrapper, index } = found;
|
|
2440
|
+
const customWrapperId = `#${wrapper.uid}`;
|
|
2441
|
+
const customWrapper = ctx.selectComponent(customWrapperId);
|
|
2442
|
+
if (customWrapper) {
|
|
2443
|
+
const splitedPath = dataPathArr.slice(index + 1).join('.');
|
|
2444
|
+
// 合并同一个 customWrapper 的相关更新到一次 setData 中
|
|
2445
|
+
customWrapperMap.set(customWrapper, Object.assign(Object.assign({}, (customWrapperMap.get(customWrapper) || {})), { [`i.${splitedPath}`]: data[p] }));
|
|
3471
2446
|
}
|
|
3472
2447
|
}
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
});
|
|
2448
|
+
else {
|
|
2449
|
+
// 此项数据使用页面去更新
|
|
2450
|
+
normalUpdate[p] = data[p];
|
|
3477
2451
|
}
|
|
3478
2452
|
}
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
this.flushUpdateCallback();
|
|
3490
|
-
}
|
|
3491
|
-
if (initRender) {
|
|
3492
|
-
perf.stop(PAGE_INIT);
|
|
3493
|
-
}
|
|
3494
|
-
}
|
|
3495
|
-
}, eventCenter);
|
|
3496
|
-
customWrapperUpdate.forEach(item => {
|
|
3497
|
-
if (process.env.NODE_ENV !== 'production' && options.debug) {
|
|
3498
|
-
// eslint-disable-next-line no-console
|
|
3499
|
-
console.log('custom wrapper setData: ', item.data);
|
|
3500
|
-
}
|
|
3501
|
-
item.ctx.setData(item.data, () => {
|
|
3502
|
-
eventCenter.trigger(eventId);
|
|
3503
|
-
});
|
|
3504
|
-
});
|
|
3505
|
-
if (Object.keys(normalUpdate).length) {
|
|
3506
|
-
if (process.env.NODE_ENV !== 'production' && options.debug) {
|
|
3507
|
-
// eslint-disable-next-line no-console
|
|
3508
|
-
console.log('setData:', normalUpdate);
|
|
3509
|
-
}
|
|
3510
|
-
ctx.setData(normalUpdate, () => {
|
|
3511
|
-
eventCenter.trigger(eventId);
|
|
3512
|
-
});
|
|
3513
|
-
}
|
|
2453
|
+
}
|
|
2454
|
+
const customWrpperCount = customWrapperMap.size;
|
|
2455
|
+
const isNeedNormalUpdate = Object.keys(normalUpdate).length > 0;
|
|
2456
|
+
const updateArrLen = customWrpperCount + (isNeedNormalUpdate ? 1 : 0);
|
|
2457
|
+
let executeTime = 0;
|
|
2458
|
+
const cb = () => {
|
|
2459
|
+
if (++executeTime === updateArrLen) {
|
|
2460
|
+
perf.stop(SET_DATA);
|
|
2461
|
+
this.flushUpdateCallback();
|
|
2462
|
+
initRender && perf.stop(PAGE_INIT);
|
|
3514
2463
|
}
|
|
3515
|
-
|
|
2464
|
+
};
|
|
2465
|
+
// custom-wrapper setData
|
|
2466
|
+
if (customWrpperCount) {
|
|
2467
|
+
customWrapperMap.forEach((data, ctx) => {
|
|
3516
2468
|
if (process.env.NODE_ENV !== 'production' && options.debug) {
|
|
3517
2469
|
// eslint-disable-next-line no-console
|
|
3518
|
-
console.log('setData:', data);
|
|
2470
|
+
console.log('custom wrapper setData: ', data);
|
|
3519
2471
|
}
|
|
3520
|
-
ctx.setData(data,
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
});
|
|
2472
|
+
ctx.setData(data, cb);
|
|
2473
|
+
});
|
|
2474
|
+
}
|
|
2475
|
+
// page setData
|
|
2476
|
+
if (isNeedNormalUpdate) {
|
|
2477
|
+
if (process.env.NODE_ENV !== 'production' && options.debug) {
|
|
2478
|
+
// eslint-disable-next-line no-console
|
|
2479
|
+
console.log('page setData:', normalUpdate);
|
|
3529
2480
|
}
|
|
2481
|
+
ctx.setData(normalUpdate, cb);
|
|
3530
2482
|
}
|
|
3531
2483
|
}, 0);
|
|
3532
2484
|
}
|
|
@@ -3536,8 +2488,10 @@ let TaroRootElement = class TaroRootElement extends TaroElement {
|
|
|
3536
2488
|
});
|
|
3537
2489
|
}
|
|
3538
2490
|
flushUpdateCallback() {
|
|
3539
|
-
|
|
3540
|
-
|
|
2491
|
+
const updateCallbacks = this.updateCallbacks;
|
|
2492
|
+
if (!updateCallbacks.length)
|
|
2493
|
+
return;
|
|
2494
|
+
const copies = updateCallbacks.slice(0);
|
|
3541
2495
|
this.updateCallbacks.length = 0;
|
|
3542
2496
|
for (let i = 0; i < copies.length; i++) {
|
|
3543
2497
|
copies[i]();
|
|
@@ -3546,12 +2500,7 @@ let TaroRootElement = class TaroRootElement extends TaroElement {
|
|
|
3546
2500
|
};
|
|
3547
2501
|
TaroRootElement = __decorate([
|
|
3548
2502
|
injectable(),
|
|
3549
|
-
|
|
3550
|
-
__param(1, inject(SERVICE_IDENTIFIER.TaroElementFactory)),
|
|
3551
|
-
__param(2, inject(SERVICE_IDENTIFIER.Hooks)),
|
|
3552
|
-
__param(3, inject(SERVICE_IDENTIFIER.TaroElementImpl)),
|
|
3553
|
-
__param(4, inject(SERVICE_IDENTIFIER.eventCenter)),
|
|
3554
|
-
__metadata("design:paramtypes", [Function, Function, Function, Function, Function])
|
|
2503
|
+
__metadata("design:paramtypes", [])
|
|
3555
2504
|
], TaroRootElement);
|
|
3556
2505
|
|
|
3557
2506
|
class FormElement extends TaroElement {
|
|
@@ -3584,6 +2533,107 @@ class FormElement extends TaroElement {
|
|
|
3584
2533
|
class SVGElement extends TaroElement {
|
|
3585
2534
|
}
|
|
3586
2535
|
|
|
2536
|
+
// Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
|
|
2537
|
+
class TaroEvent {
|
|
2538
|
+
constructor(type, opts, event) {
|
|
2539
|
+
this._stop = false;
|
|
2540
|
+
this._end = false;
|
|
2541
|
+
this.defaultPrevented = false;
|
|
2542
|
+
// timestamp can either be hi-res ( relative to page load) or low-res (relative to UNIX epoch)
|
|
2543
|
+
// here use hi-res timestamp
|
|
2544
|
+
this.timeStamp = Date.now();
|
|
2545
|
+
this.type = type.toLowerCase();
|
|
2546
|
+
this.mpEvent = event;
|
|
2547
|
+
this.bubbles = Boolean(opts && opts.bubbles);
|
|
2548
|
+
this.cancelable = Boolean(opts && opts.cancelable);
|
|
2549
|
+
}
|
|
2550
|
+
stopPropagation() {
|
|
2551
|
+
this._stop = true;
|
|
2552
|
+
}
|
|
2553
|
+
stopImmediatePropagation() {
|
|
2554
|
+
this._end = this._stop = true;
|
|
2555
|
+
}
|
|
2556
|
+
preventDefault() {
|
|
2557
|
+
this.defaultPrevented = true;
|
|
2558
|
+
}
|
|
2559
|
+
get target() {
|
|
2560
|
+
var _a, _b, _c;
|
|
2561
|
+
const element = getDocument().getElementById((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target.id);
|
|
2562
|
+
return Object.assign(Object.assign(Object.assign({}, (_b = this.mpEvent) === null || _b === void 0 ? void 0 : _b.target), (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.detail), { dataset: element !== null ? element.dataset : EMPTY_OBJ });
|
|
2563
|
+
}
|
|
2564
|
+
get currentTarget() {
|
|
2565
|
+
var _a, _b, _c;
|
|
2566
|
+
const element = getDocument().getElementById((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.currentTarget.id);
|
|
2567
|
+
if (element === null) {
|
|
2568
|
+
return this.target;
|
|
2569
|
+
}
|
|
2570
|
+
return Object.assign(Object.assign(Object.assign({}, (_b = this.mpEvent) === null || _b === void 0 ? void 0 : _b.currentTarget), (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.detail), { dataset: element.dataset });
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
function createEvent(event, node) {
|
|
2574
|
+
if (typeof event === 'string') {
|
|
2575
|
+
// For Vue3 using document.createEvent
|
|
2576
|
+
return new TaroEvent(event, { bubbles: true, cancelable: true });
|
|
2577
|
+
}
|
|
2578
|
+
const domEv = new TaroEvent(event.type, { bubbles: true, cancelable: true }, event);
|
|
2579
|
+
for (const key in event) {
|
|
2580
|
+
if (key === CURRENT_TARGET || key === TARGET || key === TYPE || key === TIME_STAMP) {
|
|
2581
|
+
continue;
|
|
2582
|
+
}
|
|
2583
|
+
else {
|
|
2584
|
+
domEv[key] = event[key];
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
if (domEv.type === CONFIRM && (node === null || node === void 0 ? void 0 : node.nodeName) === INPUT) {
|
|
2588
|
+
// eslint-disable-next-line dot-notation
|
|
2589
|
+
domEv[KEY_CODE] = 13;
|
|
2590
|
+
}
|
|
2591
|
+
return domEv;
|
|
2592
|
+
}
|
|
2593
|
+
const eventsBatch = {};
|
|
2594
|
+
// 小程序的事件代理回调函数
|
|
2595
|
+
function eventHandler(event) {
|
|
2596
|
+
var _a, _b, _c;
|
|
2597
|
+
const hooks = getHooks();
|
|
2598
|
+
(_a = hooks.modifyMpEvent) === null || _a === void 0 ? void 0 : _a.call(hooks, event);
|
|
2599
|
+
event.currentTarget || (event.currentTarget = event.target);
|
|
2600
|
+
const nid = ((_b = event.currentTarget) === null || _b === void 0 ? void 0 : _b.id) || ((_c = event.detail) === null || _c === void 0 ? void 0 : _c.id) || '';
|
|
2601
|
+
const node = getDocument().getElementById(nid);
|
|
2602
|
+
if (node) {
|
|
2603
|
+
const dispatch = () => {
|
|
2604
|
+
var _a;
|
|
2605
|
+
const e = createEvent(event, node);
|
|
2606
|
+
(_a = hooks.modifyTaroEvent) === null || _a === void 0 ? void 0 : _a.call(hooks, e, node);
|
|
2607
|
+
node.dispatchEvent(e);
|
|
2608
|
+
};
|
|
2609
|
+
if (isFunction(hooks.batchedEventUpdates)) {
|
|
2610
|
+
const type = event.type;
|
|
2611
|
+
if (!hooks.isBubbleEvents(type) ||
|
|
2612
|
+
!isParentBinded(node, type) ||
|
|
2613
|
+
(type === TOUCHMOVE && !!node.props.catchMove)) {
|
|
2614
|
+
// 最上层组件统一 batchUpdate
|
|
2615
|
+
hooks.batchedEventUpdates(() => {
|
|
2616
|
+
if (eventsBatch[type]) {
|
|
2617
|
+
eventsBatch[type].forEach(fn => fn());
|
|
2618
|
+
delete eventsBatch[type];
|
|
2619
|
+
}
|
|
2620
|
+
dispatch();
|
|
2621
|
+
});
|
|
2622
|
+
}
|
|
2623
|
+
else {
|
|
2624
|
+
// 如果上层组件也有绑定同类型的组件,委托给上层组件调用事件回调
|
|
2625
|
+
(eventsBatch[type] || (eventsBatch[type] = [])).push(dispatch);
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
else {
|
|
2629
|
+
dispatch();
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
const doc = process.env.TARO_ENV === 'h5' ? document : EMPTY_OBJ;
|
|
2635
|
+
const win = process.env.TARO_ENV === 'h5' ? window : EMPTY_OBJ;
|
|
2636
|
+
|
|
3587
2637
|
function initPosition() {
|
|
3588
2638
|
return {
|
|
3589
2639
|
index: 0,
|
|
@@ -4213,7 +3263,7 @@ function format(children, document, styleOptions, parent) {
|
|
|
4213
3263
|
// 文本节点
|
|
4214
3264
|
if (child.type === 'text') {
|
|
4215
3265
|
let text = document.createTextNode(child.content);
|
|
4216
|
-
if (isFunction
|
|
3266
|
+
if (isFunction(options.html.transformText)) {
|
|
4217
3267
|
text = options.html.transformText(text, child);
|
|
4218
3268
|
}
|
|
4219
3269
|
parent === null || parent === void 0 ? void 0 : parent.appendChild(text);
|
|
@@ -4247,7 +3297,7 @@ function format(children, document, styleOptions, parent) {
|
|
|
4247
3297
|
styleTagParser,
|
|
4248
3298
|
descendantList: list
|
|
4249
3299
|
}, el);
|
|
4250
|
-
if (isFunction
|
|
3300
|
+
if (isFunction(options.html.transformElement)) {
|
|
4251
3301
|
return options.html.transformElement(el, child);
|
|
4252
3302
|
}
|
|
4253
3303
|
return el;
|
|
@@ -4377,7 +3427,7 @@ function setInnerHTML(element, html, getDoc) {
|
|
|
4377
3427
|
* An implementation of `Element.insertAdjacentHTML()`
|
|
4378
3428
|
* to support Vue 3 with a version of or greater than `vue@3.1.2`
|
|
4379
3429
|
*/
|
|
4380
|
-
function insertAdjacentHTMLImpl(position, html
|
|
3430
|
+
function insertAdjacentHTMLImpl(getDoc, position, html) {
|
|
4381
3431
|
var _a, _b;
|
|
4382
3432
|
const parsedNodes = parser(html, getDoc());
|
|
4383
3433
|
for (let i = 0; i < parsedNodes.length; i++) {
|
|
@@ -4403,13 +3453,13 @@ function insertAdjacentHTMLImpl(position, html, getDoc) {
|
|
|
4403
3453
|
}
|
|
4404
3454
|
}
|
|
4405
3455
|
}
|
|
4406
|
-
function cloneNode(
|
|
3456
|
+
function cloneNode(getDoc, isDeep = false) {
|
|
4407
3457
|
const document = getDoc();
|
|
4408
3458
|
let newNode;
|
|
4409
|
-
if (
|
|
4410
|
-
newNode = document.createElement(
|
|
3459
|
+
if (this.nodeType === 1 /* ELEMENT_NODE */) {
|
|
3460
|
+
newNode = document.createElement(this.nodeName);
|
|
4411
3461
|
}
|
|
4412
|
-
else if (
|
|
3462
|
+
else if (this.nodeType === 3 /* TEXT_NODE */) {
|
|
4413
3463
|
newNode = document.createTextNode('');
|
|
4414
3464
|
}
|
|
4415
3465
|
for (const key in this) {
|
|
@@ -4426,9 +3476,20 @@ function cloneNode(ctx, getDoc, isDeep = false) {
|
|
|
4426
3476
|
}
|
|
4427
3477
|
}
|
|
4428
3478
|
if (isDeep) {
|
|
4429
|
-
newNode.childNodes =
|
|
3479
|
+
newNode.childNodes = this.childNodes.map(node => node.cloneNode(true));
|
|
4430
3480
|
}
|
|
4431
3481
|
return newNode;
|
|
3482
|
+
}
|
|
3483
|
+
function contains(node) {
|
|
3484
|
+
let isContains = false;
|
|
3485
|
+
this.childNodes.some(childNode => {
|
|
3486
|
+
const { uid } = childNode;
|
|
3487
|
+
if (uid === node.uid || uid === node.id || childNode.contains(node)) {
|
|
3488
|
+
isContains = true;
|
|
3489
|
+
return true;
|
|
3490
|
+
}
|
|
3491
|
+
});
|
|
3492
|
+
return isContains;
|
|
4432
3493
|
}
|
|
4433
3494
|
|
|
4434
3495
|
let TaroNodeImpl = class TaroNodeImpl {
|
|
@@ -4441,11 +3502,14 @@ let TaroNodeImpl = class TaroNodeImpl {
|
|
|
4441
3502
|
if (ENABLE_INNER_HTML) {
|
|
4442
3503
|
bindInnerHTML(ctx, getDoc);
|
|
4443
3504
|
if (ENABLE_ADJACENT_HTML) {
|
|
4444
|
-
|
|
3505
|
+
ctx.insertAdjacentHTML = insertAdjacentHTMLImpl.bind(ctx, getDoc);
|
|
4445
3506
|
}
|
|
4446
3507
|
}
|
|
4447
3508
|
if (ENABLE_CLONE_NODE) {
|
|
4448
|
-
ctx.cloneNode = cloneNode.bind(ctx,
|
|
3509
|
+
ctx.cloneNode = cloneNode.bind(ctx, getDoc);
|
|
3510
|
+
}
|
|
3511
|
+
if (ENABLE_CONTAINS) {
|
|
3512
|
+
ctx.contains = contains.bind(ctx);
|
|
4449
3513
|
}
|
|
4450
3514
|
}
|
|
4451
3515
|
};
|
|
@@ -4465,11 +3529,6 @@ function bindInnerHTML(ctx, getDoc) {
|
|
|
4465
3529
|
return '';
|
|
4466
3530
|
}
|
|
4467
3531
|
});
|
|
4468
|
-
}
|
|
4469
|
-
function bindAdjacentHTML(ctx, getDoc) {
|
|
4470
|
-
ctx.insertAdjacentHTML = function (position, html) {
|
|
4471
|
-
insertAdjacentHTMLImpl.call(ctx, position, html, getDoc);
|
|
4472
|
-
};
|
|
4473
3532
|
}
|
|
4474
3533
|
|
|
4475
3534
|
function getBoundingClientRectImpl() {
|
|
@@ -4498,9 +3557,7 @@ function getTemplateContent(ctx) {
|
|
|
4498
3557
|
let TaroElementImpl = class TaroElementImpl {
|
|
4499
3558
|
bind(ctx) {
|
|
4500
3559
|
if (ENABLE_SIZE_APIS) {
|
|
4501
|
-
ctx.getBoundingClientRect =
|
|
4502
|
-
return await getBoundingClientRectImpl.apply(ctx, args);
|
|
4503
|
-
};
|
|
3560
|
+
ctx.getBoundingClientRect = getBoundingClientRectImpl.bind(ctx);
|
|
4504
3561
|
}
|
|
4505
3562
|
if (ENABLE_TEMPLATE_CONTENT) {
|
|
4506
3563
|
bindContent(ctx);
|
|
@@ -4522,20 +3579,21 @@ function bindContent(ctx) {
|
|
|
4522
3579
|
|
|
4523
3580
|
let TaroDocument = class TaroDocument extends TaroElement {
|
|
4524
3581
|
constructor(// eslint-disable-next-line @typescript-eslint/indent
|
|
4525
|
-
|
|
4526
|
-
super(
|
|
3582
|
+
getText) {
|
|
3583
|
+
super();
|
|
4527
3584
|
this._getText = getText;
|
|
4528
3585
|
this.nodeType = 9 /* DOCUMENT_NODE */;
|
|
4529
3586
|
this.nodeName = DOCUMENT_ELEMENT_NAME;
|
|
4530
3587
|
}
|
|
4531
3588
|
createElement(type) {
|
|
3589
|
+
const getElement = this._getElement;
|
|
4532
3590
|
if (type === ROOT_STR) {
|
|
4533
|
-
return
|
|
3591
|
+
return getElement(ElementNames.RootElement)();
|
|
4534
3592
|
}
|
|
4535
3593
|
if (controlledComponent.has(type)) {
|
|
4536
|
-
return
|
|
3594
|
+
return getElement(ElementNames.FormElement)(type);
|
|
4537
3595
|
}
|
|
4538
|
-
return
|
|
3596
|
+
return getElement(ElementNames.Element)(type);
|
|
4539
3597
|
}
|
|
4540
3598
|
// an ugly fake createElementNS to deal with @vue/runtime-dom's
|
|
4541
3599
|
// support mounting app to svg container since vue@3.0.8
|
|
@@ -4569,23 +3627,109 @@ let TaroDocument = class TaroDocument extends TaroElement {
|
|
|
4569
3627
|
};
|
|
4570
3628
|
TaroDocument = __decorate([
|
|
4571
3629
|
injectable(),
|
|
4572
|
-
__param(0, inject(
|
|
4573
|
-
|
|
4574
|
-
__param(2, inject(SERVICE_IDENTIFIER.Hooks)),
|
|
4575
|
-
__param(3, inject(SERVICE_IDENTIFIER.TaroElementImpl)),
|
|
4576
|
-
__param(4, inject(SERVICE_IDENTIFIER.TaroTextFactory)),
|
|
4577
|
-
__metadata("design:paramtypes", [Function, Function, Function, Function, Function])
|
|
3630
|
+
__param(0, inject(SID_TARO_TEXT_FACTORY)),
|
|
3631
|
+
__metadata("design:paramtypes", [Function])
|
|
4578
3632
|
], TaroDocument);
|
|
4579
3633
|
|
|
3634
|
+
/**
|
|
3635
|
+
* 支持冒泡的事件, 除 支付宝小程序外,其余的可冒泡事件都和微信保持一致
|
|
3636
|
+
* 详见 见 https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxml/event.html
|
|
3637
|
+
*/
|
|
3638
|
+
const BUBBLE_EVENTS = new Set([
|
|
3639
|
+
'touchstart',
|
|
3640
|
+
'touchmove',
|
|
3641
|
+
'touchcancel',
|
|
3642
|
+
'touchend',
|
|
3643
|
+
'touchforcechange',
|
|
3644
|
+
'tap',
|
|
3645
|
+
'longpress',
|
|
3646
|
+
'longtap',
|
|
3647
|
+
'transitionend',
|
|
3648
|
+
'animationstart',
|
|
3649
|
+
'animationiteration',
|
|
3650
|
+
'animationend'
|
|
3651
|
+
]);
|
|
3652
|
+
|
|
3653
|
+
const defaultMiniLifecycle = {
|
|
3654
|
+
app: [
|
|
3655
|
+
'onLaunch',
|
|
3656
|
+
'onShow',
|
|
3657
|
+
'onHide'
|
|
3658
|
+
],
|
|
3659
|
+
page: [
|
|
3660
|
+
'onLoad',
|
|
3661
|
+
'onUnload',
|
|
3662
|
+
'onReady',
|
|
3663
|
+
'onShow',
|
|
3664
|
+
'onHide',
|
|
3665
|
+
[
|
|
3666
|
+
'onPullDownRefresh',
|
|
3667
|
+
'onReachBottom',
|
|
3668
|
+
'onPageScroll',
|
|
3669
|
+
'onResize',
|
|
3670
|
+
'onTabItemTap',
|
|
3671
|
+
'onTitleClick',
|
|
3672
|
+
'onOptionMenuClick',
|
|
3673
|
+
'onPopMenuClick',
|
|
3674
|
+
'onPullIntercept',
|
|
3675
|
+
'onAddToFavorites'
|
|
3676
|
+
]
|
|
3677
|
+
]
|
|
3678
|
+
};
|
|
3679
|
+
const getMiniLifecycle = function (defaultConfig) {
|
|
3680
|
+
return defaultConfig;
|
|
3681
|
+
};
|
|
3682
|
+
const getLifecycle = function (instance, lifecycle) {
|
|
3683
|
+
return instance[lifecycle];
|
|
3684
|
+
};
|
|
3685
|
+
const getPathIndex = function (indexOfNode) {
|
|
3686
|
+
return `[${indexOfNode}]`;
|
|
3687
|
+
};
|
|
3688
|
+
const getEventCenter = function (Events) {
|
|
3689
|
+
return new Events();
|
|
3690
|
+
};
|
|
3691
|
+
const isBubbleEvents = function (eventName) {
|
|
3692
|
+
return BUBBLE_EVENTS.has(eventName);
|
|
3693
|
+
};
|
|
3694
|
+
const getSpecialNodes = function () {
|
|
3695
|
+
return ['view', 'text', 'image'];
|
|
3696
|
+
};
|
|
3697
|
+
const DefaultHooksContainer = new ContainerModule(bind => {
|
|
3698
|
+
function bindFunction(sid, target) {
|
|
3699
|
+
return bind(sid).toFunction(target);
|
|
3700
|
+
}
|
|
3701
|
+
bindFunction(SID_GET_MINI_LIFECYCLE, getMiniLifecycle);
|
|
3702
|
+
bindFunction(SID_GET_LIFECYCLE, getLifecycle);
|
|
3703
|
+
bindFunction(SID_GET_PATH_INDEX, getPathIndex);
|
|
3704
|
+
bindFunction(SID_GET_EVENT_CENTER, getEventCenter);
|
|
3705
|
+
bindFunction(SID_IS_BUBBLE_EVENTS, isBubbleEvents);
|
|
3706
|
+
bindFunction(SID_GET_SPECIAL_NODES, getSpecialNodes);
|
|
3707
|
+
});
|
|
3708
|
+
|
|
4580
3709
|
let Hooks = class Hooks {
|
|
3710
|
+
getMiniLifecycleImpl() {
|
|
3711
|
+
return this.getMiniLifecycle(defaultMiniLifecycle);
|
|
3712
|
+
}
|
|
4581
3713
|
modifyMpEvent(e) {
|
|
4582
3714
|
var _a;
|
|
4583
|
-
(_a = this.modifyMpEventImpls) === null || _a === void 0 ? void 0 : _a.forEach(fn =>
|
|
3715
|
+
(_a = this.modifyMpEventImpls) === null || _a === void 0 ? void 0 : _a.forEach(fn => {
|
|
3716
|
+
try {
|
|
3717
|
+
// 有些小程序的事件对象的某些属性只读
|
|
3718
|
+
fn(e);
|
|
3719
|
+
}
|
|
3720
|
+
catch (error) {
|
|
3721
|
+
console.warn('[Taro modifyMpEvent hook Error]: ', error);
|
|
3722
|
+
}
|
|
3723
|
+
});
|
|
4584
3724
|
}
|
|
4585
3725
|
modifyTaroEvent(e, element) {
|
|
4586
3726
|
var _a;
|
|
4587
3727
|
(_a = this.modifyTaroEventImpls) === null || _a === void 0 ? void 0 : _a.forEach(fn => fn(e, element));
|
|
4588
3728
|
}
|
|
3729
|
+
modifyDispatchEvent(e, element) {
|
|
3730
|
+
var _a;
|
|
3731
|
+
(_a = this.modifyDispatchEventImpls) === null || _a === void 0 ? void 0 : _a.forEach(fn => fn(e, element));
|
|
3732
|
+
}
|
|
4589
3733
|
initNativeApi(taro) {
|
|
4590
3734
|
var _a;
|
|
4591
3735
|
(_a = this.initNativeApiImpls) === null || _a === void 0 ? void 0 : _a.forEach(fn => fn(taro));
|
|
@@ -4596,87 +3740,101 @@ let Hooks = class Hooks {
|
|
|
4596
3740
|
}
|
|
4597
3741
|
};
|
|
4598
3742
|
__decorate([
|
|
4599
|
-
inject(
|
|
3743
|
+
inject(SID_GET_MINI_LIFECYCLE),
|
|
3744
|
+
__metadata("design:type", Function)
|
|
3745
|
+
], Hooks.prototype, "getMiniLifecycle", void 0);
|
|
3746
|
+
__decorate([
|
|
3747
|
+
inject(SID_GET_LIFECYCLE),
|
|
4600
3748
|
__metadata("design:type", Function)
|
|
4601
3749
|
], Hooks.prototype, "getLifecycle", void 0);
|
|
4602
3750
|
__decorate([
|
|
4603
|
-
inject(
|
|
3751
|
+
inject(SID_GET_PATH_INDEX),
|
|
4604
3752
|
__metadata("design:type", Function)
|
|
4605
3753
|
], Hooks.prototype, "getPathIndex", void 0);
|
|
4606
3754
|
__decorate([
|
|
4607
|
-
inject(
|
|
3755
|
+
inject(SID_GET_EVENT_CENTER),
|
|
4608
3756
|
__metadata("design:type", Function)
|
|
4609
3757
|
], Hooks.prototype, "getEventCenter", void 0);
|
|
4610
3758
|
__decorate([
|
|
4611
|
-
inject(
|
|
3759
|
+
inject(SID_IS_BUBBLE_EVENTS),
|
|
4612
3760
|
__metadata("design:type", Function)
|
|
4613
3761
|
], Hooks.prototype, "isBubbleEvents", void 0);
|
|
4614
3762
|
__decorate([
|
|
4615
|
-
inject(
|
|
3763
|
+
inject(SID_GET_SPECIAL_NODES),
|
|
4616
3764
|
__metadata("design:type", Function)
|
|
4617
3765
|
], Hooks.prototype, "getSpecialNodes", void 0);
|
|
4618
3766
|
__decorate([
|
|
4619
|
-
inject(
|
|
3767
|
+
inject(SID_ON_REMOVE_ATTRIBUTE),
|
|
4620
3768
|
optional(),
|
|
4621
3769
|
__metadata("design:type", Function)
|
|
4622
3770
|
], Hooks.prototype, "onRemoveAttribute", void 0);
|
|
4623
3771
|
__decorate([
|
|
4624
|
-
inject(
|
|
3772
|
+
inject(SID_BATCHED_EVENT_UPDATES),
|
|
4625
3773
|
optional(),
|
|
4626
3774
|
__metadata("design:type", Function)
|
|
4627
3775
|
], Hooks.prototype, "batchedEventUpdates", void 0);
|
|
4628
3776
|
__decorate([
|
|
4629
|
-
inject(
|
|
3777
|
+
inject(SID_MERGE_PAGE_INSTANCE),
|
|
4630
3778
|
optional(),
|
|
4631
3779
|
__metadata("design:type", Function)
|
|
4632
3780
|
], Hooks.prototype, "mergePageInstance", void 0);
|
|
4633
3781
|
__decorate([
|
|
4634
|
-
inject(
|
|
3782
|
+
inject(SID_MODIFY_PAGE_OBJECT),
|
|
3783
|
+
optional(),
|
|
3784
|
+
__metadata("design:type", Function)
|
|
3785
|
+
], Hooks.prototype, "modifyPageObject", void 0);
|
|
3786
|
+
__decorate([
|
|
3787
|
+
inject(SID_CREATE_PULLDOWN_COMPONENT),
|
|
4635
3788
|
optional(),
|
|
4636
3789
|
__metadata("design:type", Function)
|
|
4637
3790
|
], Hooks.prototype, "createPullDownComponent", void 0);
|
|
4638
3791
|
__decorate([
|
|
4639
|
-
inject(
|
|
3792
|
+
inject(SID_GET_DOM_NODE),
|
|
4640
3793
|
optional(),
|
|
4641
3794
|
__metadata("design:type", Function)
|
|
4642
3795
|
], Hooks.prototype, "getDOMNode", void 0);
|
|
4643
3796
|
__decorate([
|
|
4644
|
-
inject(
|
|
3797
|
+
inject(SID_MODIFY_HYDRATE_DATA),
|
|
4645
3798
|
optional(),
|
|
4646
3799
|
__metadata("design:type", Function)
|
|
4647
3800
|
], Hooks.prototype, "modifyHydrateData", void 0);
|
|
4648
3801
|
__decorate([
|
|
4649
|
-
inject(
|
|
3802
|
+
inject(SID_MODIFY_SET_ATTR_PAYLOAD),
|
|
4650
3803
|
optional(),
|
|
4651
3804
|
__metadata("design:type", Function)
|
|
4652
3805
|
], Hooks.prototype, "modifySetAttrPayload", void 0);
|
|
4653
3806
|
__decorate([
|
|
4654
|
-
inject(
|
|
3807
|
+
inject(SID_MODIFY_RM_ATTR_PAYLOAD),
|
|
4655
3808
|
optional(),
|
|
4656
3809
|
__metadata("design:type", Function)
|
|
4657
3810
|
], Hooks.prototype, "modifyRmAttrPayload", void 0);
|
|
4658
3811
|
__decorate([
|
|
4659
|
-
inject(
|
|
3812
|
+
inject(SID_ON_ADD_EVENT),
|
|
4660
3813
|
optional(),
|
|
4661
3814
|
__metadata("design:type", Function)
|
|
4662
3815
|
], Hooks.prototype, "onAddEvent", void 0);
|
|
4663
3816
|
__decorate([
|
|
4664
|
-
multiInject(
|
|
3817
|
+
multiInject(SID_MODIFY_MP_EVENT),
|
|
4665
3818
|
optional(),
|
|
4666
3819
|
__metadata("design:type", Array)
|
|
4667
3820
|
], Hooks.prototype, "modifyMpEventImpls", void 0);
|
|
4668
3821
|
__decorate([
|
|
4669
|
-
multiInject(
|
|
3822
|
+
multiInject(SID_MODIFY_TARO_EVENT),
|
|
4670
3823
|
optional(),
|
|
4671
3824
|
__metadata("design:type", Array)
|
|
4672
3825
|
], Hooks.prototype, "modifyTaroEventImpls", void 0);
|
|
4673
3826
|
__decorate([
|
|
4674
|
-
multiInject(
|
|
3827
|
+
multiInject(SID_MODIFY_DISPATCH_EVENT),
|
|
3828
|
+
optional(),
|
|
3829
|
+
__metadata("design:type", Array)
|
|
3830
|
+
], Hooks.prototype, "modifyDispatchEventImpls", void 0);
|
|
3831
|
+
__decorate([
|
|
3832
|
+
multiInject(SID_INIT_NATIVE_API),
|
|
4675
3833
|
optional(),
|
|
4676
3834
|
__metadata("design:type", Array)
|
|
4677
3835
|
], Hooks.prototype, "initNativeApiImpls", void 0);
|
|
4678
3836
|
__decorate([
|
|
4679
|
-
multiInject(
|
|
3837
|
+
multiInject(SID_PATCH_ELEMENT),
|
|
4680
3838
|
optional(),
|
|
4681
3839
|
__metadata("design:type", Array)
|
|
4682
3840
|
], Hooks.prototype, "patchElementImpls", void 0);
|
|
@@ -4684,48 +3842,6 @@ Hooks = __decorate([
|
|
|
4684
3842
|
injectable()
|
|
4685
3843
|
], Hooks);
|
|
4686
3844
|
|
|
4687
|
-
/**
|
|
4688
|
-
* 支持冒泡的事件, 除 支付宝小程序外,其余的可冒泡事件都和微信保持一致
|
|
4689
|
-
* 详见 见 https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxml/event.html
|
|
4690
|
-
*/
|
|
4691
|
-
const BUBBLE_EVENTS = new Set([
|
|
4692
|
-
'touchstart',
|
|
4693
|
-
'touchmove',
|
|
4694
|
-
'touchcancel',
|
|
4695
|
-
'touchend',
|
|
4696
|
-
'touchforcechange',
|
|
4697
|
-
'tap',
|
|
4698
|
-
'longpress',
|
|
4699
|
-
'longtap',
|
|
4700
|
-
'transitionend',
|
|
4701
|
-
'animationstart',
|
|
4702
|
-
'animationiteration',
|
|
4703
|
-
'animationend'
|
|
4704
|
-
]);
|
|
4705
|
-
|
|
4706
|
-
const getLifecycle = function (instance, lifecycle) {
|
|
4707
|
-
return instance[lifecycle];
|
|
4708
|
-
};
|
|
4709
|
-
const getPathIndex = function (indexOfNode) {
|
|
4710
|
-
return `[${indexOfNode}]`;
|
|
4711
|
-
};
|
|
4712
|
-
const getEventCenter = function (Events) {
|
|
4713
|
-
return new Events();
|
|
4714
|
-
};
|
|
4715
|
-
const isBubbleEvents = function (eventName) {
|
|
4716
|
-
return BUBBLE_EVENTS.has(eventName);
|
|
4717
|
-
};
|
|
4718
|
-
const getSpecialNodes = function () {
|
|
4719
|
-
return ['view', 'text', 'image'];
|
|
4720
|
-
};
|
|
4721
|
-
const DefaultHooksContainer = new ContainerModule(bind => {
|
|
4722
|
-
bind(SERVICE_IDENTIFIER.getLifecycle).toFunction(getLifecycle);
|
|
4723
|
-
bind(SERVICE_IDENTIFIER.getPathIndex).toFunction(getPathIndex);
|
|
4724
|
-
bind(SERVICE_IDENTIFIER.getEventCenter).toFunction(getEventCenter);
|
|
4725
|
-
bind(SERVICE_IDENTIFIER.isBubbleEvents).toFunction(isBubbleEvents);
|
|
4726
|
-
bind(SERVICE_IDENTIFIER.getSpecialNodes).toFunction(getSpecialNodes);
|
|
4727
|
-
});
|
|
4728
|
-
|
|
4729
3845
|
function processPluginHooks(container) {
|
|
4730
3846
|
const keys = Object.keys(defaultReconciler);
|
|
4731
3847
|
keys.forEach(key => {
|
|
@@ -4733,7 +3849,7 @@ function processPluginHooks(container) {
|
|
|
4733
3849
|
// is hooks
|
|
4734
3850
|
const identifier = SERVICE_IDENTIFIER[key];
|
|
4735
3851
|
const fn = defaultReconciler[key];
|
|
4736
|
-
if (isArray
|
|
3852
|
+
if (isArray(fn)) {
|
|
4737
3853
|
// is multi
|
|
4738
3854
|
fn.forEach(item => container.bind(identifier).toFunction(item));
|
|
4739
3855
|
}
|
|
@@ -4751,14 +3867,27 @@ function processPluginHooks(container) {
|
|
|
4751
3867
|
}
|
|
4752
3868
|
|
|
4753
3869
|
const container = new Container();
|
|
3870
|
+
function bind(sid, target, options = {}) {
|
|
3871
|
+
let res = container.bind(sid).to(target);
|
|
3872
|
+
if (options.single) {
|
|
3873
|
+
res = res.inSingletonScope();
|
|
3874
|
+
}
|
|
3875
|
+
if (options.name) {
|
|
3876
|
+
res = res.whenTargetNamed(options.name);
|
|
3877
|
+
}
|
|
3878
|
+
return res;
|
|
3879
|
+
}
|
|
4754
3880
|
if (process.env.TARO_ENV !== 'h5') {
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
3881
|
+
bind(SID_TARO_TEXT, TaroText);
|
|
3882
|
+
bind(SID_TARO_ELEMENT, TaroElement, { name: ElementNames.Element });
|
|
3883
|
+
bind(SID_TARO_ELEMENT, TaroRootElement, { name: ElementNames.RootElement });
|
|
3884
|
+
bind(SID_TARO_ELEMENT, FormElement, { name: ElementNames.FormElement });
|
|
3885
|
+
bind(SID_TARO_ELEMENT, TaroDocument, { name: ElementNames.Document, single: true });
|
|
3886
|
+
bind(SID_TARO_NODE_IMPL, TaroNodeImpl, { single: true });
|
|
3887
|
+
bind(SID_TARO_ELEMENT_IMPL, TaroElementImpl, { single: true });
|
|
3888
|
+
container.bind(SID_TARO_ELEMENT_FACTORY).toFactory((context) => {
|
|
4760
3889
|
return (named) => (nodeName) => {
|
|
4761
|
-
const el = context.container.getNamed(
|
|
3890
|
+
const el = context.container.getNamed(SID_TARO_ELEMENT, named);
|
|
4762
3891
|
if (nodeName) {
|
|
4763
3892
|
el.nodeName = nodeName;
|
|
4764
3893
|
}
|
|
@@ -4766,173 +3895,64 @@ if (process.env.TARO_ENV !== 'h5') {
|
|
|
4766
3895
|
return el;
|
|
4767
3896
|
};
|
|
4768
3897
|
});
|
|
4769
|
-
container.bind(
|
|
4770
|
-
container.bind(SERVICE_IDENTIFIER.TaroTextFactory).toFactory((context) => {
|
|
3898
|
+
container.bind(SID_TARO_TEXT_FACTORY).toFactory((context) => {
|
|
4771
3899
|
return (text) => {
|
|
4772
|
-
const textNode = context.container.get(
|
|
3900
|
+
const textNode = context.container.get(SID_TARO_TEXT);
|
|
4773
3901
|
textNode._value = text;
|
|
4774
3902
|
return textNode;
|
|
4775
3903
|
};
|
|
4776
3904
|
});
|
|
4777
|
-
container.bind(SERVICE_IDENTIFIER.TaroNodeImpl).to(TaroNodeImpl).inSingletonScope();
|
|
4778
|
-
container.bind(SERVICE_IDENTIFIER.TaroElementImpl).to(TaroElementImpl).inSingletonScope();
|
|
4779
3905
|
}
|
|
4780
|
-
|
|
3906
|
+
bind(SID_HOOKS, Hooks, { single: true });
|
|
4781
3907
|
container.load(DefaultHooksContainer);
|
|
4782
|
-
processPluginHooks(container);
|
|
3908
|
+
processPluginHooks(container);
|
|
3909
|
+
store.container = container;
|
|
4783
3910
|
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
3911
|
+
function createDocument() {
|
|
3912
|
+
/**
|
|
3913
|
+
* <document>
|
|
3914
|
+
* <html>
|
|
3915
|
+
* <head></head>
|
|
3916
|
+
* <body>
|
|
3917
|
+
* <container>
|
|
3918
|
+
* <app id="app" />
|
|
3919
|
+
* </container>
|
|
3920
|
+
* </body>
|
|
3921
|
+
* </html>
|
|
3922
|
+
* </document>
|
|
3923
|
+
*/
|
|
3924
|
+
const getElement = container.get(SERVICE_IDENTIFIER.TaroElementFactory);
|
|
3925
|
+
const doc = getElement(ElementNames.Document)();
|
|
3926
|
+
const documentCreateElement = doc.createElement.bind(doc);
|
|
3927
|
+
const html = documentCreateElement(HTML);
|
|
3928
|
+
const head = documentCreateElement(HEAD);
|
|
3929
|
+
const body = documentCreateElement(BODY);
|
|
3930
|
+
const app = documentCreateElement(APP);
|
|
3931
|
+
app.id = APP;
|
|
3932
|
+
const container$1 = documentCreateElement(CONTAINER); // 多包一层主要为了兼容 vue
|
|
3933
|
+
doc.appendChild(html);
|
|
3934
|
+
html.appendChild(head);
|
|
3935
|
+
html.appendChild(body);
|
|
3936
|
+
body.appendChild(container$1);
|
|
3937
|
+
container$1.appendChild(app);
|
|
3938
|
+
doc.documentElement = html;
|
|
3939
|
+
doc.head = head;
|
|
3940
|
+
doc.body = body;
|
|
3941
|
+
doc.createEvent = createEvent;
|
|
3942
|
+
return doc;
|
|
4791
3943
|
}
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
this._stop = false;
|
|
4796
|
-
this._end = false;
|
|
4797
|
-
this.defaultPrevented = false;
|
|
4798
|
-
// timestamp can either be hi-res ( relative to page load) or low-res (relative to UNIX epoch)
|
|
4799
|
-
// here use hi-res timestamp
|
|
4800
|
-
this.timeStamp = Date.now();
|
|
4801
|
-
this.type = type.toLowerCase();
|
|
4802
|
-
this.mpEvent = event;
|
|
4803
|
-
this.bubbles = Boolean(opts && opts.bubbles);
|
|
4804
|
-
this.cancelable = Boolean(opts && opts.cancelable);
|
|
4805
|
-
}
|
|
4806
|
-
stopPropagation() {
|
|
4807
|
-
this._stop = true;
|
|
4808
|
-
}
|
|
4809
|
-
stopImmediatePropagation() {
|
|
4810
|
-
this._end = this._stop = true;
|
|
4811
|
-
}
|
|
4812
|
-
preventDefault() {
|
|
4813
|
-
this.defaultPrevented = true;
|
|
4814
|
-
}
|
|
4815
|
-
get target() {
|
|
4816
|
-
var _a, _b, _c;
|
|
4817
|
-
const element = document$1.getElementById((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target.id);
|
|
4818
|
-
return Object.assign(Object.assign(Object.assign({}, (_b = this.mpEvent) === null || _b === void 0 ? void 0 : _b.target), (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.detail), { dataset: element !== null ? element.dataset : EMPTY_OBJ });
|
|
4819
|
-
}
|
|
4820
|
-
get currentTarget() {
|
|
4821
|
-
var _a, _b, _c;
|
|
4822
|
-
const element = document$1.getElementById((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.currentTarget.id);
|
|
4823
|
-
if (element === null) {
|
|
4824
|
-
return this.target;
|
|
4825
|
-
}
|
|
4826
|
-
return Object.assign(Object.assign(Object.assign({}, (_b = this.mpEvent) === null || _b === void 0 ? void 0 : _b.currentTarget), (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.detail), { dataset: element.dataset });
|
|
4827
|
-
}
|
|
4828
|
-
}
|
|
4829
|
-
function createEvent(event, node) {
|
|
4830
|
-
if (typeof event === 'string') {
|
|
4831
|
-
// For Vue3 using document.createEvent
|
|
4832
|
-
return new TaroEvent(event, { bubbles: true, cancelable: true });
|
|
4833
|
-
}
|
|
4834
|
-
const domEv = new TaroEvent(event.type, { bubbles: true, cancelable: true }, event);
|
|
4835
|
-
for (const key in event) {
|
|
4836
|
-
if (key === CURRENT_TARGET || key === TARGET || key === TYPE || key === TIME_STAMP) {
|
|
4837
|
-
continue;
|
|
4838
|
-
}
|
|
4839
|
-
else {
|
|
4840
|
-
domEv[key] = event[key];
|
|
4841
|
-
}
|
|
4842
|
-
}
|
|
4843
|
-
if (domEv.type === CONFIRM && (node === null || node === void 0 ? void 0 : node.nodeName) === INPUT) {
|
|
4844
|
-
// eslint-disable-next-line dot-notation
|
|
4845
|
-
domEv[KEY_CODE] = 13;
|
|
4846
|
-
}
|
|
4847
|
-
return domEv;
|
|
4848
|
-
}
|
|
4849
|
-
const eventsBatch = {};
|
|
4850
|
-
// 小程序的事件代理回调函数
|
|
4851
|
-
function eventHandler(event) {
|
|
4852
|
-
var _a;
|
|
4853
|
-
(_a = hooks.modifyMpEvent) === null || _a === void 0 ? void 0 : _a.call(hooks, event);
|
|
4854
|
-
if (event.currentTarget == null) {
|
|
4855
|
-
event.currentTarget = event.target;
|
|
4856
|
-
}
|
|
4857
|
-
const node = document$1.getElementById(event.currentTarget.id);
|
|
4858
|
-
if (node) {
|
|
4859
|
-
const dispatch = () => {
|
|
4860
|
-
var _a;
|
|
4861
|
-
const e = createEvent(event, node);
|
|
4862
|
-
(_a = hooks.modifyTaroEvent) === null || _a === void 0 ? void 0 : _a.call(hooks, e, node);
|
|
4863
|
-
node.dispatchEvent(e);
|
|
4864
|
-
};
|
|
4865
|
-
if (typeof hooks.batchedEventUpdates === 'function') {
|
|
4866
|
-
const type = event.type;
|
|
4867
|
-
if (!hooks.isBubbleEvents(type) ||
|
|
4868
|
-
!isParentBinded(node, type) ||
|
|
4869
|
-
(type === TOUCHMOVE && !!node.props.catchMove)) {
|
|
4870
|
-
// 最上层组件统一 batchUpdate
|
|
4871
|
-
hooks.batchedEventUpdates(() => {
|
|
4872
|
-
if (eventsBatch[type]) {
|
|
4873
|
-
eventsBatch[type].forEach(fn => fn());
|
|
4874
|
-
delete eventsBatch[type];
|
|
4875
|
-
}
|
|
4876
|
-
dispatch();
|
|
4877
|
-
});
|
|
4878
|
-
}
|
|
4879
|
-
else {
|
|
4880
|
-
// 如果上层组件也有绑定同类型的组件,委托给上层组件调用事件回调
|
|
4881
|
-
(eventsBatch[type] || (eventsBatch[type] = [])).push(dispatch);
|
|
4882
|
-
}
|
|
4883
|
-
}
|
|
4884
|
-
else {
|
|
4885
|
-
dispatch();
|
|
4886
|
-
}
|
|
4887
|
-
}
|
|
4888
|
-
}
|
|
4889
|
-
|
|
4890
|
-
const isBrowser = typeof document !== 'undefined' && !!document.scripts;
|
|
4891
|
-
const doc = isBrowser ? document : EMPTY_OBJ;
|
|
4892
|
-
const win = isBrowser ? window : EMPTY_OBJ;
|
|
4893
|
-
|
|
4894
|
-
function createDocument() {
|
|
4895
|
-
/**
|
|
4896
|
-
* <document>
|
|
4897
|
-
* <html>
|
|
4898
|
-
* <head></head>
|
|
4899
|
-
* <body>
|
|
4900
|
-
* <container>
|
|
4901
|
-
* <app id="app" />
|
|
4902
|
-
* </container>
|
|
4903
|
-
* </body>
|
|
4904
|
-
* </html>
|
|
4905
|
-
* </document>
|
|
4906
|
-
*/
|
|
4907
|
-
const getElement = container.get(SERVICE_IDENTIFIER.TaroElementFactory);
|
|
4908
|
-
const doc = getElement(ElementNames.Document)();
|
|
4909
|
-
const documentCreateElement = doc.createElement.bind(doc);
|
|
4910
|
-
const html = documentCreateElement(HTML);
|
|
4911
|
-
const head = documentCreateElement(HEAD);
|
|
4912
|
-
const body = documentCreateElement(BODY);
|
|
4913
|
-
const app = documentCreateElement(APP);
|
|
4914
|
-
app.id = APP;
|
|
4915
|
-
const container$1 = documentCreateElement(CONTAINER); // 多包一层主要为了兼容 vue
|
|
4916
|
-
doc.appendChild(html);
|
|
4917
|
-
html.appendChild(head);
|
|
4918
|
-
html.appendChild(body);
|
|
4919
|
-
body.appendChild(container$1);
|
|
4920
|
-
container$1.appendChild(app);
|
|
4921
|
-
doc.documentElement = html;
|
|
4922
|
-
doc.head = head;
|
|
4923
|
-
doc.body = body;
|
|
4924
|
-
doc.createEvent = createEvent;
|
|
4925
|
-
return doc;
|
|
4926
|
-
}
|
|
4927
|
-
const document$2 = (isBrowser ? doc : createDocument());
|
|
3944
|
+
const document$1 = process.env.TARO_ENV === 'h5'
|
|
3945
|
+
? doc
|
|
3946
|
+
: createDocument();
|
|
4928
3947
|
|
|
4929
3948
|
const machine = 'Macintosh';
|
|
4930
3949
|
const arch = 'Intel Mac OS X 10_14_5';
|
|
4931
3950
|
const engine = 'AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v4.1.0 Chrome/76.0.3809.132 Safari/534.36';
|
|
4932
|
-
const
|
|
3951
|
+
const msg = '(' + machine + '; ' + arch + ') ' + engine;
|
|
3952
|
+
const navigator = process.env.TARO_ENV === 'h5' ? win.navigator : {
|
|
4933
3953
|
appCodeName: 'Mozilla',
|
|
4934
3954
|
appName: 'Netscape',
|
|
4935
|
-
appVersion: '5.0
|
|
3955
|
+
appVersion: '5.0 ' + msg,
|
|
4936
3956
|
cookieEnabled: true,
|
|
4937
3957
|
mimeTypes: [],
|
|
4938
3958
|
onLine: true,
|
|
@@ -4940,7 +3960,7 @@ const navigator = isBrowser ? win.navigator : {
|
|
|
4940
3960
|
plugins: [],
|
|
4941
3961
|
product: 'Taro',
|
|
4942
3962
|
productSub: '20030107',
|
|
4943
|
-
userAgent: 'Mozilla/5.0
|
|
3963
|
+
userAgent: 'Mozilla/5.0 ' + msg,
|
|
4944
3964
|
vendor: 'Joyent',
|
|
4945
3965
|
vendorSub: ''
|
|
4946
3966
|
};
|
|
@@ -4986,11 +4006,11 @@ function getComputedStyle(element) {
|
|
|
4986
4006
|
return element.style;
|
|
4987
4007
|
}
|
|
4988
4008
|
|
|
4989
|
-
const window$1 =
|
|
4009
|
+
const window$1 = process.env.TARO_ENV === 'h5' ? win : {
|
|
4990
4010
|
navigator,
|
|
4991
|
-
document: document$
|
|
4011
|
+
document: document$1
|
|
4992
4012
|
};
|
|
4993
|
-
if (
|
|
4013
|
+
if (process.env.TARO_ENV && process.env.TARO_ENV !== 'h5') {
|
|
4994
4014
|
const globalProperties = [
|
|
4995
4015
|
...Object.getOwnPropertyNames(global || win),
|
|
4996
4016
|
...Object.getOwnPropertySymbols(global || win)
|
|
@@ -5002,20 +4022,21 @@ if (!isBrowser) {
|
|
|
5002
4022
|
window$1[property] = global[property];
|
|
5003
4023
|
}
|
|
5004
4024
|
});
|
|
5005
|
-
document$2.defaultView = window$1;
|
|
5006
|
-
}
|
|
5007
|
-
if (process.env.TARO_ENV && process.env.TARO_ENV !== 'h5') {
|
|
5008
4025
|
window$1.requestAnimationFrame = raf;
|
|
5009
4026
|
window$1.cancelAnimationFrame = caf;
|
|
5010
4027
|
window$1.getComputedStyle = getComputedStyle;
|
|
5011
|
-
window$1.addEventListener =
|
|
5012
|
-
window$1.removeEventListener =
|
|
4028
|
+
window$1.addEventListener = noop;
|
|
4029
|
+
window$1.removeEventListener = noop;
|
|
5013
4030
|
if (!(DATE in window$1)) {
|
|
5014
4031
|
window$1.Date = Date;
|
|
5015
4032
|
}
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
}
|
|
4033
|
+
window$1.setTimeout = function (cb, delay) {
|
|
4034
|
+
setTimeout(cb, delay);
|
|
4035
|
+
};
|
|
4036
|
+
window$1.clearTimeout = function (seed) {
|
|
4037
|
+
clearTimeout(seed);
|
|
4038
|
+
};
|
|
4039
|
+
document$1.defaultView = window$1;
|
|
5019
4040
|
}
|
|
5020
4041
|
|
|
5021
4042
|
const Current = {
|
|
@@ -5027,12 +4048,8 @@ const getCurrentInstance = () => Current;
|
|
|
5027
4048
|
|
|
5028
4049
|
class Events {
|
|
5029
4050
|
constructor(opts) {
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
}
|
|
5033
|
-
else {
|
|
5034
|
-
this.callbacks = {};
|
|
5035
|
-
}
|
|
4051
|
+
var _a;
|
|
4052
|
+
this.callbacks = (_a = opts === null || opts === void 0 ? void 0 : opts.callbacks) !== null && _a !== void 0 ? _a : {};
|
|
5036
4053
|
}
|
|
5037
4054
|
on(eventName, callback, context) {
|
|
5038
4055
|
let event, node, tail, list;
|
|
@@ -5109,17 +4126,15 @@ class Events {
|
|
|
5109
4126
|
}
|
|
5110
4127
|
}
|
|
5111
4128
|
Events.eventSplitter = /\s+/;
|
|
5112
|
-
const
|
|
5113
|
-
|
|
5114
|
-
container.bind(SERVICE_IDENTIFIER.eventCenter).toConstantValue(eventCenter);
|
|
4129
|
+
const eventCenter = getHooks().getEventCenter(Events);
|
|
4130
|
+
container.bind(SID_EVENT_CENTER).toConstantValue(eventCenter);
|
|
5115
4131
|
|
|
5116
4132
|
/* eslint-disable dot-notation */
|
|
5117
4133
|
const instances = new Map();
|
|
5118
4134
|
const pageId = incrementId();
|
|
5119
|
-
const hooks$2 = container.get(SERVICE_IDENTIFIER.Hooks);
|
|
5120
4135
|
function injectPageInstance(inst, id) {
|
|
5121
|
-
var _a;
|
|
5122
|
-
(_a =
|
|
4136
|
+
var _a, _b;
|
|
4137
|
+
(_b = (_a = getHooks()).mergePageInstance) === null || _b === void 0 ? void 0 : _b.call(_a, instances.get(id), inst);
|
|
5123
4138
|
instances.set(id, inst);
|
|
5124
4139
|
}
|
|
5125
4140
|
function getPageInstance(id) {
|
|
@@ -5136,12 +4151,12 @@ function safeExecute(path, lifecycle, ...args) {
|
|
|
5136
4151
|
if (instance == null) {
|
|
5137
4152
|
return;
|
|
5138
4153
|
}
|
|
5139
|
-
const func =
|
|
5140
|
-
if (isArray
|
|
4154
|
+
const func = getHooks().getLifecycle(instance, lifecycle);
|
|
4155
|
+
if (isArray(func)) {
|
|
5141
4156
|
const res = func.map(fn => fn.apply(instance, args));
|
|
5142
4157
|
return res[0];
|
|
5143
4158
|
}
|
|
5144
|
-
if (!isFunction
|
|
4159
|
+
if (!isFunction(func)) {
|
|
5145
4160
|
return;
|
|
5146
4161
|
}
|
|
5147
4162
|
return func.apply(instance, args);
|
|
@@ -5157,31 +4172,43 @@ function stringify(obj) {
|
|
|
5157
4172
|
}
|
|
5158
4173
|
function getPath(id, options) {
|
|
5159
4174
|
let path = id;
|
|
5160
|
-
if (
|
|
4175
|
+
if (process.env.TARO_ENV !== 'h5') {
|
|
5161
4176
|
path = id + stringify(options);
|
|
5162
4177
|
}
|
|
5163
4178
|
return path;
|
|
5164
4179
|
}
|
|
5165
4180
|
function getOnReadyEventKey(path) {
|
|
5166
|
-
return path + '.' +
|
|
4181
|
+
return path + '.' + ON_READY;
|
|
5167
4182
|
}
|
|
5168
4183
|
function getOnShowEventKey(path) {
|
|
5169
|
-
return path + '.' +
|
|
4184
|
+
return path + '.' + ON_SHOW;
|
|
5170
4185
|
}
|
|
5171
4186
|
function getOnHideEventKey(path) {
|
|
5172
|
-
return path + '.' +
|
|
4187
|
+
return path + '.' + ON_HIDE;
|
|
5173
4188
|
}
|
|
5174
4189
|
function createPageConfig(component, pageName, data, pageConfig) {
|
|
5175
|
-
var _a, _b;
|
|
5176
|
-
const id = pageName !== null && pageName !== void 0 ? pageName : `taro_page_${pageId()}`;
|
|
4190
|
+
var _a, _b, _c;
|
|
5177
4191
|
// 小程序 Page 构造器是一个傲娇小公主,不能把复杂的对象挂载到参数上
|
|
4192
|
+
const id = pageName !== null && pageName !== void 0 ? pageName : `taro_page_${pageId()}`;
|
|
4193
|
+
const hooks = getHooks();
|
|
4194
|
+
const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES] = hooks.getMiniLifecycleImpl().page;
|
|
5178
4195
|
let pageElement = null;
|
|
5179
4196
|
let unmounting = false;
|
|
5180
4197
|
let prepareMountList = [];
|
|
4198
|
+
function setCurrentRouter(page) {
|
|
4199
|
+
const router = process.env.TARO_ENV === 'h5' ? page.$taroPath : page.route || page.__route__ || page.$taroPath;
|
|
4200
|
+
Current.router = {
|
|
4201
|
+
params: page.$taroParams,
|
|
4202
|
+
path: addLeadingSlash(router),
|
|
4203
|
+
onReady: getOnReadyEventKey(id),
|
|
4204
|
+
onShow: getOnShowEventKey(id),
|
|
4205
|
+
onHide: getOnHideEventKey(id)
|
|
4206
|
+
};
|
|
4207
|
+
}
|
|
5181
4208
|
let loadResolver;
|
|
5182
4209
|
let hasLoaded;
|
|
5183
4210
|
const config = {
|
|
5184
|
-
|
|
4211
|
+
[ONLOAD](options, cb) {
|
|
5185
4212
|
hasLoaded = new Promise(resolve => { loadResolver = resolve; });
|
|
5186
4213
|
perf.start(PAGE_INIT);
|
|
5187
4214
|
Current.page = this;
|
|
@@ -5189,30 +4216,24 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
5189
4216
|
options.$taroTimestamp = Date.now();
|
|
5190
4217
|
// this.$taroPath 是页面唯一标识,不可变,因此页面参数 options 也不可变
|
|
5191
4218
|
this.$taroPath = getPath(id, options);
|
|
4219
|
+
const $taroPath = this.$taroPath;
|
|
5192
4220
|
// this.$taroParams 作为暴露给开发者的页面参数对象,可以被随意修改
|
|
5193
4221
|
if (this.$taroParams == null) {
|
|
5194
4222
|
this.$taroParams = Object.assign({}, options);
|
|
5195
4223
|
}
|
|
5196
|
-
|
|
5197
|
-
Current.router = {
|
|
5198
|
-
params: this.$taroParams,
|
|
5199
|
-
path: addLeadingSlash(router),
|
|
5200
|
-
onReady: getOnReadyEventKey(id),
|
|
5201
|
-
onShow: getOnShowEventKey(id),
|
|
5202
|
-
onHide: getOnHideEventKey(id)
|
|
5203
|
-
};
|
|
4224
|
+
setCurrentRouter(this);
|
|
5204
4225
|
const mount = () => {
|
|
5205
|
-
Current.app.mount(component,
|
|
5206
|
-
pageElement = document$
|
|
4226
|
+
Current.app.mount(component, $taroPath, () => {
|
|
4227
|
+
pageElement = document$1.getElementById($taroPath);
|
|
5207
4228
|
ensure(pageElement !== null, '没有找到页面实例。');
|
|
5208
|
-
safeExecute(
|
|
4229
|
+
safeExecute($taroPath, ON_LOAD, this.$taroParams);
|
|
5209
4230
|
loadResolver();
|
|
5210
|
-
if (
|
|
4231
|
+
if (process.env.TARO_ENV !== 'h5') {
|
|
5211
4232
|
pageElement.ctx = this;
|
|
5212
4233
|
pageElement.performUpdate(true, cb);
|
|
5213
4234
|
}
|
|
5214
4235
|
else {
|
|
5215
|
-
isFunction
|
|
4236
|
+
isFunction(cb) && cb();
|
|
5216
4237
|
}
|
|
5217
4238
|
});
|
|
5218
4239
|
};
|
|
@@ -5223,18 +4244,12 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
5223
4244
|
mount();
|
|
5224
4245
|
}
|
|
5225
4246
|
},
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
eventCenter.trigger(getOnReadyEventKey(id));
|
|
5229
|
-
});
|
|
5230
|
-
safeExecute(this.$taroPath, 'onReady');
|
|
5231
|
-
this.onReady.called = true;
|
|
5232
|
-
},
|
|
5233
|
-
onUnload() {
|
|
4247
|
+
[ONUNLOAD]() {
|
|
4248
|
+
const $taroPath = this.$taroPath;
|
|
5234
4249
|
unmounting = true;
|
|
5235
|
-
Current.app.unmount(
|
|
4250
|
+
Current.app.unmount($taroPath, () => {
|
|
5236
4251
|
unmounting = false;
|
|
5237
|
-
instances.delete(
|
|
4252
|
+
instances.delete($taroPath);
|
|
5238
4253
|
if (pageElement) {
|
|
5239
4254
|
pageElement.ctx = null;
|
|
5240
4255
|
}
|
|
@@ -5244,72 +4259,52 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
5244
4259
|
}
|
|
5245
4260
|
});
|
|
5246
4261
|
},
|
|
5247
|
-
|
|
4262
|
+
[ONREADY]() {
|
|
4263
|
+
// 触发生命周期
|
|
4264
|
+
safeExecute(this.$taroPath, ON_READY);
|
|
4265
|
+
// 通过事件触发子组件的生命周期
|
|
4266
|
+
raf(() => eventCenter.trigger(getOnReadyEventKey(id)));
|
|
4267
|
+
this.onReady.called = true;
|
|
4268
|
+
},
|
|
4269
|
+
[ONSHOW]() {
|
|
5248
4270
|
hasLoaded.then(() => {
|
|
4271
|
+
// 设置 Current 的 page 和 router
|
|
5249
4272
|
Current.page = this;
|
|
5250
|
-
this
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
onReady: getOnReadyEventKey(id),
|
|
5256
|
-
onShow: getOnShowEventKey(id),
|
|
5257
|
-
onHide: getOnHideEventKey(id)
|
|
5258
|
-
};
|
|
5259
|
-
raf(() => {
|
|
5260
|
-
eventCenter.trigger(getOnShowEventKey(id));
|
|
5261
|
-
});
|
|
5262
|
-
safeExecute(this.$taroPath, 'onShow');
|
|
4273
|
+
setCurrentRouter(this);
|
|
4274
|
+
// 触发生命周期
|
|
4275
|
+
safeExecute(this.$taroPath, ON_SHOW);
|
|
4276
|
+
// 通过事件触发子组件的生命周期
|
|
4277
|
+
raf(() => eventCenter.trigger(getOnShowEventKey(id)));
|
|
5263
4278
|
});
|
|
5264
4279
|
},
|
|
5265
|
-
|
|
5266
|
-
Current
|
|
5267
|
-
Current.
|
|
5268
|
-
|
|
4280
|
+
[ONHIDE]() {
|
|
4281
|
+
// 设置 Current 的 page 和 router
|
|
4282
|
+
if (Current.page === this) {
|
|
4283
|
+
Current.page = null;
|
|
4284
|
+
Current.router = null;
|
|
4285
|
+
}
|
|
4286
|
+
// 触发生命周期
|
|
4287
|
+
safeExecute(this.$taroPath, ON_HIDE);
|
|
4288
|
+
// 通过事件触发子组件的生命周期
|
|
5269
4289
|
eventCenter.trigger(getOnHideEventKey(id));
|
|
5270
|
-
},
|
|
5271
|
-
onPullDownRefresh() {
|
|
5272
|
-
return safeExecute(this.$taroPath, 'onPullDownRefresh');
|
|
5273
|
-
},
|
|
5274
|
-
onReachBottom() {
|
|
5275
|
-
return safeExecute(this.$taroPath, 'onReachBottom');
|
|
5276
|
-
},
|
|
5277
|
-
onPageScroll(options) {
|
|
5278
|
-
return safeExecute(this.$taroPath, 'onPageScroll', options);
|
|
5279
|
-
},
|
|
5280
|
-
onResize(options) {
|
|
5281
|
-
return safeExecute(this.$taroPath, 'onResize', options);
|
|
5282
|
-
},
|
|
5283
|
-
onTabItemTap(options) {
|
|
5284
|
-
return safeExecute(this.$taroPath, 'onTabItemTap', options);
|
|
5285
|
-
},
|
|
5286
|
-
onTitleClick() {
|
|
5287
|
-
return safeExecute(this.$taroPath, 'onTitleClick');
|
|
5288
|
-
},
|
|
5289
|
-
onOptionMenuClick() {
|
|
5290
|
-
return safeExecute(this.$taroPath, 'onOptionMenuClick');
|
|
5291
|
-
},
|
|
5292
|
-
onPopMenuClick() {
|
|
5293
|
-
return safeExecute(this.$taroPath, 'onPopMenuClick');
|
|
5294
|
-
},
|
|
5295
|
-
onPullIntercept() {
|
|
5296
|
-
return safeExecute(this.$taroPath, 'onPullIntercept');
|
|
5297
|
-
},
|
|
5298
|
-
onAddToFavorites() {
|
|
5299
|
-
return safeExecute(this.$taroPath, 'onAddToFavorites');
|
|
5300
4290
|
}
|
|
5301
4291
|
};
|
|
4292
|
+
LIFECYCLES.forEach((lifecycle) => {
|
|
4293
|
+
config[lifecycle] = function () {
|
|
4294
|
+
return safeExecute(this.$taroPath, lifecycle, ...arguments);
|
|
4295
|
+
};
|
|
4296
|
+
});
|
|
5302
4297
|
// onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
|
|
5303
4298
|
if (component.onShareAppMessage ||
|
|
5304
4299
|
((_a = component.prototype) === null || _a === void 0 ? void 0 : _a.onShareAppMessage) ||
|
|
5305
4300
|
component.enableShareAppMessage) {
|
|
5306
4301
|
config.onShareAppMessage = function (options) {
|
|
5307
4302
|
const target = options === null || options === void 0 ? void 0 : options.target;
|
|
5308
|
-
if (target
|
|
4303
|
+
if (target) {
|
|
5309
4304
|
const id = target.id;
|
|
5310
|
-
const element = document$
|
|
5311
|
-
if (element
|
|
5312
|
-
|
|
4305
|
+
const element = document$1.getElementById(id);
|
|
4306
|
+
if (element) {
|
|
4307
|
+
target.dataset = element.dataset;
|
|
5313
4308
|
}
|
|
5314
4309
|
}
|
|
5315
4310
|
return safeExecute(this.$taroPath, 'onShareAppMessage', options);
|
|
@@ -5326,13 +4321,13 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
5326
4321
|
if (!isUndefined(data)) {
|
|
5327
4322
|
config.data = data;
|
|
5328
4323
|
}
|
|
5329
|
-
if (
|
|
4324
|
+
if (process.env.TARO_ENV === 'h5') {
|
|
5330
4325
|
config.path = id;
|
|
5331
4326
|
}
|
|
4327
|
+
(_c = hooks.modifyPageObject) === null || _c === void 0 ? void 0 : _c.call(hooks, config);
|
|
5332
4328
|
return config;
|
|
5333
4329
|
}
|
|
5334
4330
|
function createComponentConfig(component, componentName, data) {
|
|
5335
|
-
var _a, _b, _c;
|
|
5336
4331
|
const id = componentName !== null && componentName !== void 0 ? componentName : `taro_component_${pageId()}`;
|
|
5337
4332
|
let componentElement = null;
|
|
5338
4333
|
const config = {
|
|
@@ -5341,10 +4336,10 @@ function createComponentConfig(component, componentName, data) {
|
|
|
5341
4336
|
perf.start(PAGE_INIT);
|
|
5342
4337
|
const path = getPath(id, { id: ((_a = this.getPageId) === null || _a === void 0 ? void 0 : _a.call(this)) || pageId() });
|
|
5343
4338
|
Current.app.mount(component, path, () => {
|
|
5344
|
-
componentElement = document$
|
|
4339
|
+
componentElement = document$1.getElementById(path);
|
|
5345
4340
|
ensure(componentElement !== null, '没有找到组件实例。');
|
|
5346
|
-
safeExecute(path,
|
|
5347
|
-
if (
|
|
4341
|
+
safeExecute(path, ON_LOAD);
|
|
4342
|
+
if (process.env.TARO_ENV !== 'h5') {
|
|
5348
4343
|
componentElement.ctx = this;
|
|
5349
4344
|
componentElement.performUpdate(true);
|
|
5350
4345
|
}
|
|
@@ -5366,9 +4361,10 @@ function createComponentConfig(component, componentName, data) {
|
|
|
5366
4361
|
if (!isUndefined(data)) {
|
|
5367
4362
|
config.data = data;
|
|
5368
4363
|
}
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
4364
|
+
[OPTIONS, EXTERNAL_CLASSES, BEHAVIORS].forEach(key => {
|
|
4365
|
+
var _a;
|
|
4366
|
+
config[key] = (_a = component[key]) !== null && _a !== void 0 ? _a : EMPTY_OBJ;
|
|
4367
|
+
});
|
|
5372
4368
|
return config;
|
|
5373
4369
|
}
|
|
5374
4370
|
function createRecursiveComponentConfig(componentName) {
|
|
@@ -5377,7 +4373,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
5377
4373
|
i: {
|
|
5378
4374
|
type: Object,
|
|
5379
4375
|
value: {
|
|
5380
|
-
["nn" /* NodeName */]:
|
|
4376
|
+
["nn" /* NodeName */]: VIEW
|
|
5381
4377
|
}
|
|
5382
4378
|
},
|
|
5383
4379
|
l: {
|
|
@@ -5387,7 +4383,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
5387
4383
|
},
|
|
5388
4384
|
options: {
|
|
5389
4385
|
addGlobalClass: true,
|
|
5390
|
-
virtualHost: componentName !==
|
|
4386
|
+
virtualHost: componentName !== CUSTOM_WRAPPER
|
|
5391
4387
|
},
|
|
5392
4388
|
methods: {
|
|
5393
4389
|
eh: eventHandler
|
|
@@ -5395,798 +4391,6 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
5395
4391
|
};
|
|
5396
4392
|
}
|
|
5397
4393
|
|
|
5398
|
-
const hooks$3 = container.get(SERVICE_IDENTIFIER.Hooks);
|
|
5399
|
-
function isClassComponent(R, component) {
|
|
5400
|
-
var _a;
|
|
5401
|
-
return isFunction$1(component.render) ||
|
|
5402
|
-
!!((_a = component.prototype) === null || _a === void 0 ? void 0 : _a.isReactComponent) ||
|
|
5403
|
-
component.prototype instanceof R.Component; // compat for some others react-like library
|
|
5404
|
-
}
|
|
5405
|
-
// 初始值设置为 any 主要是为了过 TS 的校验
|
|
5406
|
-
let R = EMPTY_OBJ;
|
|
5407
|
-
let PageContext = EMPTY_OBJ;
|
|
5408
|
-
function connectReactPage(R, id) {
|
|
5409
|
-
const h = R.createElement;
|
|
5410
|
-
return (component) => {
|
|
5411
|
-
// eslint-disable-next-line dot-notation
|
|
5412
|
-
const isReactComponent = isClassComponent(R, component);
|
|
5413
|
-
const inject = (node) => node && injectPageInstance(node, id);
|
|
5414
|
-
const refs = isReactComponent ? { ref: inject } : {
|
|
5415
|
-
forwardedRef: inject,
|
|
5416
|
-
// 兼容 react-redux 7.20.1+
|
|
5417
|
-
reactReduxForwardedRef: inject
|
|
5418
|
-
};
|
|
5419
|
-
if (PageContext === EMPTY_OBJ) {
|
|
5420
|
-
PageContext = R.createContext('');
|
|
5421
|
-
}
|
|
5422
|
-
return class Page extends R.Component {
|
|
5423
|
-
constructor() {
|
|
5424
|
-
super(...arguments);
|
|
5425
|
-
this.state = {
|
|
5426
|
-
hasError: false
|
|
5427
|
-
};
|
|
5428
|
-
}
|
|
5429
|
-
static getDerivedStateFromError(error) {
|
|
5430
|
-
process.env.NODE_ENV !== 'production' && console.warn(error);
|
|
5431
|
-
return { hasError: true };
|
|
5432
|
-
}
|
|
5433
|
-
// React 16 uncaught error 会导致整个应用 crash,
|
|
5434
|
-
// 目前把错误缩小到页面
|
|
5435
|
-
componentDidCatch(error, info) {
|
|
5436
|
-
process.env.NODE_ENV !== 'production' && console.warn(error);
|
|
5437
|
-
process.env.NODE_ENV !== 'production' && console.error(info.componentStack);
|
|
5438
|
-
}
|
|
5439
|
-
render() {
|
|
5440
|
-
const children = this.state.hasError
|
|
5441
|
-
? []
|
|
5442
|
-
: h(PageContext.Provider, { value: id }, h(component, Object.assign(Object.assign({}, this.props), refs)));
|
|
5443
|
-
if (isBrowser) {
|
|
5444
|
-
return h('div', { id, className: 'taro_page' }, children);
|
|
5445
|
-
}
|
|
5446
|
-
return h('root', { id }, children);
|
|
5447
|
-
}
|
|
5448
|
-
};
|
|
5449
|
-
};
|
|
5450
|
-
}
|
|
5451
|
-
let ReactDOM;
|
|
5452
|
-
function setReconciler() {
|
|
5453
|
-
const getLifecycle = function (instance, lifecycle) {
|
|
5454
|
-
lifecycle = lifecycle.replace(/^on(Show|Hide)$/, 'componentDid$1');
|
|
5455
|
-
return instance[lifecycle];
|
|
5456
|
-
};
|
|
5457
|
-
const modifyMpEvent = function (event) {
|
|
5458
|
-
event.type = event.type.replace(/-/g, '');
|
|
5459
|
-
};
|
|
5460
|
-
const batchedEventUpdates = function (cb) {
|
|
5461
|
-
ReactDOM.unstable_batchedUpdates(cb);
|
|
5462
|
-
};
|
|
5463
|
-
const mergePageInstance = function (prev, next) {
|
|
5464
|
-
if (!prev || !next)
|
|
5465
|
-
return;
|
|
5466
|
-
// 子组件使用 lifecycle hooks 注册了生命周期后,会存在 prev,里面是注册的生命周期回调。
|
|
5467
|
-
// prev 使用 Object.create(null) 创建,H5 的 fast-refresh 可能也会导致存在 prev,要排除这些意外产生的 prev
|
|
5468
|
-
if ('constructor' in prev)
|
|
5469
|
-
return;
|
|
5470
|
-
Object.keys(prev).forEach(item => {
|
|
5471
|
-
if (isFunction$1(next[item])) {
|
|
5472
|
-
next[item] = [next[item], ...prev[item]];
|
|
5473
|
-
}
|
|
5474
|
-
else {
|
|
5475
|
-
next[item] = [...(next[item] || []), ...prev[item]];
|
|
5476
|
-
}
|
|
5477
|
-
});
|
|
5478
|
-
};
|
|
5479
|
-
hooks$3.getLifecycle = getLifecycle;
|
|
5480
|
-
hooks$3.modifyMpEvent = modifyMpEvent;
|
|
5481
|
-
hooks$3.batchedEventUpdates = batchedEventUpdates;
|
|
5482
|
-
hooks$3.mergePageInstance = mergePageInstance;
|
|
5483
|
-
if (process.env.TARO_ENV === 'h5') {
|
|
5484
|
-
hooks$3.createPullDownComponent = (el, _, R, customWrapper) => {
|
|
5485
|
-
const isReactComponent = isClassComponent(R, el);
|
|
5486
|
-
return R.forwardRef((props, ref) => {
|
|
5487
|
-
const newProps = Object.assign({}, props);
|
|
5488
|
-
const refs = isReactComponent ? { ref: ref } : {
|
|
5489
|
-
forwardedRef: ref,
|
|
5490
|
-
// 兼容 react-redux 7.20.1+
|
|
5491
|
-
reactReduxForwardedRef: ref
|
|
5492
|
-
};
|
|
5493
|
-
return R.createElement(customWrapper || 'taro-pull-to-refresh', null, R.createElement(el, Object.assign(Object.assign({}, newProps), refs)));
|
|
5494
|
-
});
|
|
5495
|
-
};
|
|
5496
|
-
hooks$3.getDOMNode = (inst) => {
|
|
5497
|
-
return ReactDOM.findDOMNode(inst);
|
|
5498
|
-
};
|
|
5499
|
-
}
|
|
5500
|
-
}
|
|
5501
|
-
const pageKeyId = incrementId();
|
|
5502
|
-
function createReactApp(App, react, reactdom, config) {
|
|
5503
|
-
R = react;
|
|
5504
|
-
ReactDOM = reactdom;
|
|
5505
|
-
ensure(!!ReactDOM, '构建 React/Nerv 项目请把 process.env.FRAMEWORK 设置为 \'react\'/\'nerv\' ');
|
|
5506
|
-
const ref = R.createRef();
|
|
5507
|
-
const isReactComponent = isClassComponent(R, App);
|
|
5508
|
-
setReconciler();
|
|
5509
|
-
class AppWrapper extends R.Component {
|
|
5510
|
-
constructor() {
|
|
5511
|
-
super(...arguments);
|
|
5512
|
-
// run createElement() inside the render function to make sure that owner is right
|
|
5513
|
-
this.pages = [];
|
|
5514
|
-
this.elements = [];
|
|
5515
|
-
}
|
|
5516
|
-
mount(component, id, cb) {
|
|
5517
|
-
const key = id + pageKeyId();
|
|
5518
|
-
const page = () => R.createElement(component, { key, tid: id });
|
|
5519
|
-
this.pages.push(page);
|
|
5520
|
-
this.forceUpdate(cb);
|
|
5521
|
-
}
|
|
5522
|
-
unmount(id, cb) {
|
|
5523
|
-
for (let i = 0; i < this.elements.length; i++) {
|
|
5524
|
-
const element = this.elements[i];
|
|
5525
|
-
if (element.props.tid === id) {
|
|
5526
|
-
this.elements.splice(i, 1);
|
|
5527
|
-
break;
|
|
5528
|
-
}
|
|
5529
|
-
}
|
|
5530
|
-
this.forceUpdate(cb);
|
|
5531
|
-
}
|
|
5532
|
-
render() {
|
|
5533
|
-
while (this.pages.length > 0) {
|
|
5534
|
-
const page = this.pages.pop();
|
|
5535
|
-
this.elements.push(page());
|
|
5536
|
-
}
|
|
5537
|
-
let props = null;
|
|
5538
|
-
if (isReactComponent) {
|
|
5539
|
-
props = { ref };
|
|
5540
|
-
}
|
|
5541
|
-
return R.createElement(App, props, isBrowser ? R.createElement('div', null, this.elements.slice()) : this.elements.slice());
|
|
5542
|
-
}
|
|
5543
|
-
}
|
|
5544
|
-
let wrapper;
|
|
5545
|
-
if (!isBrowser) {
|
|
5546
|
-
// eslint-disable-next-line react/no-render-return-value
|
|
5547
|
-
wrapper = ReactDOM.render(R.createElement(AppWrapper), document$2.getElementById('app'));
|
|
5548
|
-
}
|
|
5549
|
-
const app = Object.create({
|
|
5550
|
-
render(cb) {
|
|
5551
|
-
wrapper.forceUpdate(cb);
|
|
5552
|
-
},
|
|
5553
|
-
mount(component, id, cb) {
|
|
5554
|
-
const page = connectReactPage(R, id)(component);
|
|
5555
|
-
wrapper.mount(page, id, cb);
|
|
5556
|
-
},
|
|
5557
|
-
unmount(id, cb) {
|
|
5558
|
-
wrapper.unmount(id, cb);
|
|
5559
|
-
}
|
|
5560
|
-
}, {
|
|
5561
|
-
config: {
|
|
5562
|
-
writable: true,
|
|
5563
|
-
enumerable: true,
|
|
5564
|
-
configurable: true,
|
|
5565
|
-
value: config
|
|
5566
|
-
},
|
|
5567
|
-
onLaunch: {
|
|
5568
|
-
enumerable: true,
|
|
5569
|
-
writable: true,
|
|
5570
|
-
value(options) {
|
|
5571
|
-
Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
|
|
5572
|
-
if (isBrowser) {
|
|
5573
|
-
// 由于 H5 路由初始化的时候会清除 app 下的 dom 元素,所以需要在路由初始化后执行 render
|
|
5574
|
-
// eslint-disable-next-line react/no-render-return-value
|
|
5575
|
-
wrapper = ReactDOM.render(R.createElement(AppWrapper), document$2.getElementById('app'));
|
|
5576
|
-
}
|
|
5577
|
-
const app = ref.current;
|
|
5578
|
-
// For taroize
|
|
5579
|
-
// 把 App Class 上挂载的额外属性同步到全局 app 对象中
|
|
5580
|
-
if (app === null || app === void 0 ? void 0 : app.taroGlobalData) {
|
|
5581
|
-
const globalData = app.taroGlobalData;
|
|
5582
|
-
const keys = Object.keys(globalData);
|
|
5583
|
-
const descriptors = Object.getOwnPropertyDescriptors(globalData);
|
|
5584
|
-
keys.forEach(key => {
|
|
5585
|
-
Object.defineProperty(this, key, {
|
|
5586
|
-
configurable: true,
|
|
5587
|
-
enumerable: true,
|
|
5588
|
-
get() {
|
|
5589
|
-
return globalData[key];
|
|
5590
|
-
},
|
|
5591
|
-
set(value) {
|
|
5592
|
-
globalData[key] = value;
|
|
5593
|
-
}
|
|
5594
|
-
});
|
|
5595
|
-
});
|
|
5596
|
-
Object.defineProperties(this, descriptors);
|
|
5597
|
-
}
|
|
5598
|
-
this.$app = app;
|
|
5599
|
-
if (app != null && isFunction$1(app.onLaunch)) {
|
|
5600
|
-
app.onLaunch(options);
|
|
5601
|
-
}
|
|
5602
|
-
}
|
|
5603
|
-
},
|
|
5604
|
-
onShow: {
|
|
5605
|
-
enumerable: true,
|
|
5606
|
-
writable: true,
|
|
5607
|
-
value(options) {
|
|
5608
|
-
const app = ref.current;
|
|
5609
|
-
Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
|
|
5610
|
-
if (app != null && isFunction$1(app.componentDidShow)) {
|
|
5611
|
-
app.componentDidShow(options);
|
|
5612
|
-
}
|
|
5613
|
-
// app useDidShow
|
|
5614
|
-
triggerAppHook('onShow');
|
|
5615
|
-
}
|
|
5616
|
-
},
|
|
5617
|
-
onHide: {
|
|
5618
|
-
enumerable: true,
|
|
5619
|
-
writable: true,
|
|
5620
|
-
value(options) {
|
|
5621
|
-
const app = ref.current;
|
|
5622
|
-
if (app != null && isFunction$1(app.componentDidHide)) {
|
|
5623
|
-
app.componentDidHide(options);
|
|
5624
|
-
}
|
|
5625
|
-
// app useDidHide
|
|
5626
|
-
triggerAppHook('onHide');
|
|
5627
|
-
}
|
|
5628
|
-
},
|
|
5629
|
-
onPageNotFound: {
|
|
5630
|
-
enumerable: true,
|
|
5631
|
-
writable: true,
|
|
5632
|
-
value(res) {
|
|
5633
|
-
const app = ref.current;
|
|
5634
|
-
if (app != null && isFunction$1(app.onPageNotFound)) {
|
|
5635
|
-
app.onPageNotFound(res);
|
|
5636
|
-
}
|
|
5637
|
-
}
|
|
5638
|
-
}
|
|
5639
|
-
});
|
|
5640
|
-
function triggerAppHook(lifecycle) {
|
|
5641
|
-
const instance = getPageInstance(HOOKS_APP_ID);
|
|
5642
|
-
if (instance) {
|
|
5643
|
-
const app = ref.current;
|
|
5644
|
-
const func = hooks$3.getLifecycle(instance, lifecycle);
|
|
5645
|
-
if (Array.isArray(func)) {
|
|
5646
|
-
func.forEach(cb => cb.apply(app));
|
|
5647
|
-
}
|
|
5648
|
-
}
|
|
5649
|
-
}
|
|
5650
|
-
Current.app = app;
|
|
5651
|
-
return Current.app;
|
|
5652
|
-
}
|
|
5653
|
-
const getNativeCompId = incrementId();
|
|
5654
|
-
function initNativeComponentEntry(R, ReactDOM) {
|
|
5655
|
-
class NativeComponentWrapper extends R.Component {
|
|
5656
|
-
constructor() {
|
|
5657
|
-
super(...arguments);
|
|
5658
|
-
this.root = R.createRef();
|
|
5659
|
-
this.ctx = this.props.getCtx();
|
|
5660
|
-
}
|
|
5661
|
-
componentDidMount() {
|
|
5662
|
-
this.ctx.component = this;
|
|
5663
|
-
const rootElement = this.root.current;
|
|
5664
|
-
rootElement.ctx = this.ctx;
|
|
5665
|
-
rootElement.performUpdate(true);
|
|
5666
|
-
}
|
|
5667
|
-
render() {
|
|
5668
|
-
return (R.createElement('root', {
|
|
5669
|
-
ref: this.root
|
|
5670
|
-
}, this.props.renderComponent(this.ctx)));
|
|
5671
|
-
}
|
|
5672
|
-
}
|
|
5673
|
-
class Entry extends R.Component {
|
|
5674
|
-
constructor() {
|
|
5675
|
-
super(...arguments);
|
|
5676
|
-
this.state = {
|
|
5677
|
-
components: []
|
|
5678
|
-
};
|
|
5679
|
-
}
|
|
5680
|
-
componentDidMount() {
|
|
5681
|
-
Current.app = this;
|
|
5682
|
-
}
|
|
5683
|
-
mount(Component, compId, getCtx) {
|
|
5684
|
-
const isReactComponent = isClassComponent(R, Component);
|
|
5685
|
-
const inject = (node) => node && injectPageInstance(node, compId);
|
|
5686
|
-
const refs = isReactComponent ? { ref: inject } : {
|
|
5687
|
-
forwardedRef: inject,
|
|
5688
|
-
reactReduxForwardedRef: inject
|
|
5689
|
-
};
|
|
5690
|
-
const item = {
|
|
5691
|
-
compId,
|
|
5692
|
-
element: R.createElement(NativeComponentWrapper, {
|
|
5693
|
-
key: compId,
|
|
5694
|
-
getCtx,
|
|
5695
|
-
renderComponent(ctx) {
|
|
5696
|
-
return R.createElement(Component, Object.assign(Object.assign({}, (ctx.data || (ctx.data = {})).props), refs));
|
|
5697
|
-
}
|
|
5698
|
-
})
|
|
5699
|
-
};
|
|
5700
|
-
this.setState({
|
|
5701
|
-
components: [...this.state.components, item]
|
|
5702
|
-
});
|
|
5703
|
-
}
|
|
5704
|
-
unmount(compId) {
|
|
5705
|
-
const components = this.state.components;
|
|
5706
|
-
const index = components.findIndex(item => item.compId === compId);
|
|
5707
|
-
const next = [...components.slice(0, index), ...components.slice(index + 1)];
|
|
5708
|
-
this.setState({
|
|
5709
|
-
components: next
|
|
5710
|
-
});
|
|
5711
|
-
}
|
|
5712
|
-
render() {
|
|
5713
|
-
const components = this.state.components;
|
|
5714
|
-
return (components.map(({ element }) => element));
|
|
5715
|
-
}
|
|
5716
|
-
}
|
|
5717
|
-
setReconciler();
|
|
5718
|
-
const app = document$2.getElementById('app');
|
|
5719
|
-
ReactDOM.render(R.createElement(Entry, {}), app);
|
|
5720
|
-
}
|
|
5721
|
-
function createNativeComponentConfig(Component, react, reactdom, componentConfig) {
|
|
5722
|
-
R = react;
|
|
5723
|
-
ReactDOM = reactdom;
|
|
5724
|
-
setReconciler();
|
|
5725
|
-
const config = {
|
|
5726
|
-
properties: {
|
|
5727
|
-
props: {
|
|
5728
|
-
type: null,
|
|
5729
|
-
value: null,
|
|
5730
|
-
observer(_newVal, oldVal) {
|
|
5731
|
-
oldVal && this.component.forceUpdate();
|
|
5732
|
-
}
|
|
5733
|
-
}
|
|
5734
|
-
},
|
|
5735
|
-
created() {
|
|
5736
|
-
if (!Current.app) {
|
|
5737
|
-
initNativeComponentEntry(R, ReactDOM);
|
|
5738
|
-
}
|
|
5739
|
-
},
|
|
5740
|
-
attached() {
|
|
5741
|
-
setCurrent();
|
|
5742
|
-
this.compId = getNativeCompId();
|
|
5743
|
-
this.config = componentConfig;
|
|
5744
|
-
Current.app.mount(Component, this.compId, () => this);
|
|
5745
|
-
},
|
|
5746
|
-
ready() {
|
|
5747
|
-
safeExecute(this.compId, 'onReady');
|
|
5748
|
-
},
|
|
5749
|
-
detached() {
|
|
5750
|
-
Current.app.unmount(this.compId);
|
|
5751
|
-
},
|
|
5752
|
-
pageLifetimes: {
|
|
5753
|
-
show() {
|
|
5754
|
-
safeExecute(this.compId, 'onShow');
|
|
5755
|
-
},
|
|
5756
|
-
hide() {
|
|
5757
|
-
safeExecute(this.compId, 'onHide');
|
|
5758
|
-
}
|
|
5759
|
-
},
|
|
5760
|
-
methods: {
|
|
5761
|
-
eh: eventHandler
|
|
5762
|
-
}
|
|
5763
|
-
};
|
|
5764
|
-
function setCurrent() {
|
|
5765
|
-
const pages = getCurrentPages();
|
|
5766
|
-
const currentPage = pages[pages.length - 1];
|
|
5767
|
-
if (Current.page === currentPage)
|
|
5768
|
-
return;
|
|
5769
|
-
Current.page = currentPage;
|
|
5770
|
-
const route = currentPage.route || currentPage.__route__;
|
|
5771
|
-
const router = {
|
|
5772
|
-
params: currentPage.options || {},
|
|
5773
|
-
path: addLeadingSlash(route),
|
|
5774
|
-
onReady: '',
|
|
5775
|
-
onHide: '',
|
|
5776
|
-
onShow: ''
|
|
5777
|
-
};
|
|
5778
|
-
Current.router = router;
|
|
5779
|
-
if (!currentPage.options) {
|
|
5780
|
-
// 例如在微信小程序中,页面 options 的设置时机比组件 attached 慢
|
|
5781
|
-
Object.defineProperty(currentPage, 'options', {
|
|
5782
|
-
enumerable: true,
|
|
5783
|
-
configurable: true,
|
|
5784
|
-
get() {
|
|
5785
|
-
return this._optionsValue;
|
|
5786
|
-
},
|
|
5787
|
-
set(value) {
|
|
5788
|
-
router.params = value;
|
|
5789
|
-
this._optionsValue = value;
|
|
5790
|
-
}
|
|
5791
|
-
});
|
|
5792
|
-
}
|
|
5793
|
-
}
|
|
5794
|
-
return config;
|
|
5795
|
-
}
|
|
5796
|
-
|
|
5797
|
-
function connectVuePage(Vue, id) {
|
|
5798
|
-
return (component) => {
|
|
5799
|
-
const injectedPage = Vue.extend({
|
|
5800
|
-
props: {
|
|
5801
|
-
tid: String
|
|
5802
|
-
},
|
|
5803
|
-
mixins: [component, {
|
|
5804
|
-
created() {
|
|
5805
|
-
injectPageInstance(this, id);
|
|
5806
|
-
}
|
|
5807
|
-
}]
|
|
5808
|
-
});
|
|
5809
|
-
const options = {
|
|
5810
|
-
render(h) {
|
|
5811
|
-
return h(isBrowser ? 'div' : 'root', {
|
|
5812
|
-
attrs: {
|
|
5813
|
-
id,
|
|
5814
|
-
class: isBrowser ? 'taro_page' : ''
|
|
5815
|
-
}
|
|
5816
|
-
}, [
|
|
5817
|
-
h(injectedPage, { props: { tid: id } })
|
|
5818
|
-
]);
|
|
5819
|
-
}
|
|
5820
|
-
};
|
|
5821
|
-
return options;
|
|
5822
|
-
};
|
|
5823
|
-
}
|
|
5824
|
-
function setReconciler$1() {
|
|
5825
|
-
const hooks = container.get(SERVICE_IDENTIFIER.Hooks);
|
|
5826
|
-
const onRemoveAttribute = function (dom, qualifiedName) {
|
|
5827
|
-
// 处理原因: https://github.com/NervJS/taro/pull/5990
|
|
5828
|
-
const props = dom.props;
|
|
5829
|
-
if (!props.hasOwnProperty(qualifiedName) || isBoolean(props[qualifiedName])) {
|
|
5830
|
-
dom.setAttribute(qualifiedName, false);
|
|
5831
|
-
return true;
|
|
5832
|
-
}
|
|
5833
|
-
};
|
|
5834
|
-
const getLifecycle = function (instance, lifecycle) {
|
|
5835
|
-
return instance.$options[lifecycle];
|
|
5836
|
-
};
|
|
5837
|
-
hooks.onRemoveAttribute = onRemoveAttribute;
|
|
5838
|
-
hooks.getLifecycle = getLifecycle;
|
|
5839
|
-
if (process.env.TARO_ENV === 'h5') {
|
|
5840
|
-
hooks.createPullDownComponent = (el, path, vue) => {
|
|
5841
|
-
const injectedPage = vue.extend({
|
|
5842
|
-
props: {
|
|
5843
|
-
tid: String
|
|
5844
|
-
},
|
|
5845
|
-
mixins: [el, {
|
|
5846
|
-
created() {
|
|
5847
|
-
injectPageInstance(this, path);
|
|
5848
|
-
}
|
|
5849
|
-
}]
|
|
5850
|
-
});
|
|
5851
|
-
const options = {
|
|
5852
|
-
name: 'PullToRefresh',
|
|
5853
|
-
render(h) {
|
|
5854
|
-
return h('taro-pull-to-refresh', {
|
|
5855
|
-
class: ['hydrated']
|
|
5856
|
-
}, [h(injectedPage, this.$slots.default)]);
|
|
5857
|
-
}
|
|
5858
|
-
};
|
|
5859
|
-
return options;
|
|
5860
|
-
};
|
|
5861
|
-
hooks.getDOMNode = (el) => {
|
|
5862
|
-
return el.$el;
|
|
5863
|
-
};
|
|
5864
|
-
}
|
|
5865
|
-
}
|
|
5866
|
-
let Vue;
|
|
5867
|
-
function createVueApp(App, vue, config) {
|
|
5868
|
-
Vue = vue;
|
|
5869
|
-
ensure(!!Vue, '构建 Vue 项目请把 process.env.FRAMEWORK 设置为 \'vue\'');
|
|
5870
|
-
setReconciler$1();
|
|
5871
|
-
Vue.config.getTagNamespace = noop;
|
|
5872
|
-
const elements = [];
|
|
5873
|
-
const pages = [];
|
|
5874
|
-
let appInstance;
|
|
5875
|
-
const wrapper = new Vue({
|
|
5876
|
-
render(h) {
|
|
5877
|
-
while (pages.length > 0) {
|
|
5878
|
-
const page = pages.pop();
|
|
5879
|
-
elements.push(page(h));
|
|
5880
|
-
}
|
|
5881
|
-
return h(App, { ref: 'app' }, elements.slice());
|
|
5882
|
-
},
|
|
5883
|
-
methods: {
|
|
5884
|
-
mount(component, id, cb) {
|
|
5885
|
-
pages.push((h) => h(component, { key: id }));
|
|
5886
|
-
this.updateSync(cb);
|
|
5887
|
-
},
|
|
5888
|
-
updateSync(cb) {
|
|
5889
|
-
this._update(this._render(), false);
|
|
5890
|
-
this.$children.forEach((child) => child._update(child._render(), false));
|
|
5891
|
-
cb();
|
|
5892
|
-
},
|
|
5893
|
-
unmount(id, cb) {
|
|
5894
|
-
for (let i = 0; i < elements.length; i++) {
|
|
5895
|
-
const element = elements[i];
|
|
5896
|
-
if (element.key === id) {
|
|
5897
|
-
elements.splice(i, 1);
|
|
5898
|
-
break;
|
|
5899
|
-
}
|
|
5900
|
-
}
|
|
5901
|
-
this.updateSync(cb);
|
|
5902
|
-
}
|
|
5903
|
-
}
|
|
5904
|
-
});
|
|
5905
|
-
if (!isBrowser) {
|
|
5906
|
-
wrapper.$mount(document$2.getElementById('app'));
|
|
5907
|
-
}
|
|
5908
|
-
const app = Object.create({
|
|
5909
|
-
mount(component, id, cb) {
|
|
5910
|
-
const page = connectVuePage(Vue, id)(component);
|
|
5911
|
-
wrapper.mount(page, id, cb);
|
|
5912
|
-
},
|
|
5913
|
-
unmount(id, cb) {
|
|
5914
|
-
wrapper.unmount(id, cb);
|
|
5915
|
-
}
|
|
5916
|
-
}, {
|
|
5917
|
-
config: {
|
|
5918
|
-
writable: true,
|
|
5919
|
-
enumerable: true,
|
|
5920
|
-
configurable: true,
|
|
5921
|
-
value: config
|
|
5922
|
-
},
|
|
5923
|
-
onLaunch: {
|
|
5924
|
-
writable: true,
|
|
5925
|
-
enumerable: true,
|
|
5926
|
-
value(options) {
|
|
5927
|
-
Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
|
|
5928
|
-
if (isBrowser) {
|
|
5929
|
-
// 由于 H5 路由初始化的时候会清除 app 下的 dom 元素,所以需要在路由初始化后再执行 render
|
|
5930
|
-
wrapper.$mount(document$2.getElementById('app'));
|
|
5931
|
-
}
|
|
5932
|
-
appInstance = wrapper.$refs.app;
|
|
5933
|
-
if (appInstance != null && isFunction$1(appInstance.$options.onLaunch)) {
|
|
5934
|
-
appInstance.$options.onLaunch.call(appInstance, options);
|
|
5935
|
-
}
|
|
5936
|
-
}
|
|
5937
|
-
},
|
|
5938
|
-
onShow: {
|
|
5939
|
-
writable: true,
|
|
5940
|
-
enumerable: true,
|
|
5941
|
-
value(options) {
|
|
5942
|
-
Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
|
|
5943
|
-
if (appInstance != null && isFunction$1(appInstance.$options.onShow)) {
|
|
5944
|
-
appInstance.$options.onShow.call(appInstance, options);
|
|
5945
|
-
}
|
|
5946
|
-
}
|
|
5947
|
-
},
|
|
5948
|
-
onHide: {
|
|
5949
|
-
writable: true,
|
|
5950
|
-
enumerable: true,
|
|
5951
|
-
value(options) {
|
|
5952
|
-
if (appInstance != null && isFunction$1(appInstance.$options.onHide)) {
|
|
5953
|
-
appInstance.$options.onHide.call(appInstance, options);
|
|
5954
|
-
}
|
|
5955
|
-
}
|
|
5956
|
-
}
|
|
5957
|
-
});
|
|
5958
|
-
Current.app = app;
|
|
5959
|
-
return Current.app;
|
|
5960
|
-
}
|
|
5961
|
-
|
|
5962
|
-
function createVue3Page(h, id) {
|
|
5963
|
-
return function (component) {
|
|
5964
|
-
var _a;
|
|
5965
|
-
const inject = {
|
|
5966
|
-
props: {
|
|
5967
|
-
tid: String
|
|
5968
|
-
},
|
|
5969
|
-
created() {
|
|
5970
|
-
injectPageInstance(this, id);
|
|
5971
|
-
// vue3 组件 created 时机比小程序页面 onShow 慢,因此在 created 后再手动触发一次 onShow。
|
|
5972
|
-
this.$nextTick(() => {
|
|
5973
|
-
safeExecute(id, 'onShow');
|
|
5974
|
-
});
|
|
5975
|
-
}
|
|
5976
|
-
};
|
|
5977
|
-
if (isArray$1(component.mixins)) {
|
|
5978
|
-
const mixins = component.mixins;
|
|
5979
|
-
const idx = mixins.length - 1;
|
|
5980
|
-
if (!((_a = mixins[idx].props) === null || _a === void 0 ? void 0 : _a.tid)) {
|
|
5981
|
-
// mixins 里还没注入过,直接推入数组
|
|
5982
|
-
component.mixins.push(inject);
|
|
5983
|
-
}
|
|
5984
|
-
else {
|
|
5985
|
-
// mixins 里已经注入过,代替前者
|
|
5986
|
-
component.mixins[idx] = inject;
|
|
5987
|
-
}
|
|
5988
|
-
}
|
|
5989
|
-
else {
|
|
5990
|
-
component.mixins = [inject];
|
|
5991
|
-
}
|
|
5992
|
-
return h(isBrowser ? 'div' : 'root', {
|
|
5993
|
-
key: id,
|
|
5994
|
-
id,
|
|
5995
|
-
class: isBrowser ? 'taro_page' : ''
|
|
5996
|
-
}, [
|
|
5997
|
-
h(Object.assign({}, component), {
|
|
5998
|
-
tid: id
|
|
5999
|
-
})
|
|
6000
|
-
]);
|
|
6001
|
-
};
|
|
6002
|
-
}
|
|
6003
|
-
function setReconciler$2() {
|
|
6004
|
-
const hooks = container.get(SERVICE_IDENTIFIER.Hooks);
|
|
6005
|
-
const getLifecycle = function (instance, lifecycle) {
|
|
6006
|
-
return instance.$options[lifecycle];
|
|
6007
|
-
};
|
|
6008
|
-
const modifyMpEvent = function (event) {
|
|
6009
|
-
event.type = event.type.replace(/-/g, '');
|
|
6010
|
-
};
|
|
6011
|
-
hooks.getLifecycle = getLifecycle;
|
|
6012
|
-
hooks.modifyMpEvent = modifyMpEvent;
|
|
6013
|
-
if (process.env.TARO_ENV === 'h5') {
|
|
6014
|
-
hooks.createPullDownComponent = (component, path, h) => {
|
|
6015
|
-
const inject = {
|
|
6016
|
-
props: {
|
|
6017
|
-
tid: String
|
|
6018
|
-
},
|
|
6019
|
-
created() {
|
|
6020
|
-
injectPageInstance(this, path);
|
|
6021
|
-
}
|
|
6022
|
-
};
|
|
6023
|
-
component.mixins = isArray$1(component.mixins)
|
|
6024
|
-
? component.mixins.push(inject)
|
|
6025
|
-
: [inject];
|
|
6026
|
-
return {
|
|
6027
|
-
render() {
|
|
6028
|
-
return h('taro-pull-to-refresh', {
|
|
6029
|
-
class: 'hydrated'
|
|
6030
|
-
}, [h(component, this.$slots.default)]);
|
|
6031
|
-
}
|
|
6032
|
-
};
|
|
6033
|
-
};
|
|
6034
|
-
hooks.getDOMNode = (el) => {
|
|
6035
|
-
return el.$el;
|
|
6036
|
-
};
|
|
6037
|
-
}
|
|
6038
|
-
}
|
|
6039
|
-
function createVue3App(app, h, config) {
|
|
6040
|
-
let pages = [];
|
|
6041
|
-
let appInstance;
|
|
6042
|
-
ensure(!isFunction$1(app._component), '入口组件不支持使用函数式组件');
|
|
6043
|
-
setReconciler$2();
|
|
6044
|
-
app._component.render = function () {
|
|
6045
|
-
return pages.slice();
|
|
6046
|
-
};
|
|
6047
|
-
if (!isBrowser) {
|
|
6048
|
-
appInstance = app.mount('#app');
|
|
6049
|
-
}
|
|
6050
|
-
const appConfig = Object.create({
|
|
6051
|
-
mount(component, id, cb) {
|
|
6052
|
-
const page = createVue3Page(h, id)(component);
|
|
6053
|
-
pages.push(page);
|
|
6054
|
-
this.updateAppInstance(cb);
|
|
6055
|
-
},
|
|
6056
|
-
unmount(id, cb) {
|
|
6057
|
-
pages = pages.filter(page => page.key !== id);
|
|
6058
|
-
this.updateAppInstance(cb);
|
|
6059
|
-
},
|
|
6060
|
-
updateAppInstance(cb) {
|
|
6061
|
-
appInstance.$forceUpdate();
|
|
6062
|
-
appInstance.$nextTick(cb);
|
|
6063
|
-
}
|
|
6064
|
-
}, {
|
|
6065
|
-
config: {
|
|
6066
|
-
writable: true,
|
|
6067
|
-
enumerable: true,
|
|
6068
|
-
configurable: true,
|
|
6069
|
-
value: config
|
|
6070
|
-
},
|
|
6071
|
-
onLaunch: {
|
|
6072
|
-
writable: true,
|
|
6073
|
-
enumerable: true,
|
|
6074
|
-
value(options) {
|
|
6075
|
-
var _a;
|
|
6076
|
-
Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
|
|
6077
|
-
if (isBrowser) {
|
|
6078
|
-
appInstance = app.mount('#app');
|
|
6079
|
-
}
|
|
6080
|
-
// 把 App Class 上挂载的额外属性同步到全局 app 对象中
|
|
6081
|
-
// eslint-disable-next-line dot-notation
|
|
6082
|
-
if (app['taroGlobalData']) {
|
|
6083
|
-
// eslint-disable-next-line dot-notation
|
|
6084
|
-
const globalData = app['taroGlobalData'];
|
|
6085
|
-
const keys = Object.keys(globalData);
|
|
6086
|
-
const descriptors = Object.getOwnPropertyDescriptors(globalData);
|
|
6087
|
-
keys.forEach(key => {
|
|
6088
|
-
Object.defineProperty(this, key, {
|
|
6089
|
-
configurable: true,
|
|
6090
|
-
enumerable: true,
|
|
6091
|
-
get() {
|
|
6092
|
-
return globalData[key];
|
|
6093
|
-
},
|
|
6094
|
-
set(value) {
|
|
6095
|
-
globalData[key] = value;
|
|
6096
|
-
}
|
|
6097
|
-
});
|
|
6098
|
-
});
|
|
6099
|
-
Object.defineProperties(this, descriptors);
|
|
6100
|
-
}
|
|
6101
|
-
const onLaunch = (_a = appInstance === null || appInstance === void 0 ? void 0 : appInstance.$options) === null || _a === void 0 ? void 0 : _a.onLaunch;
|
|
6102
|
-
isFunction$1(onLaunch) && onLaunch.call(appInstance, options);
|
|
6103
|
-
}
|
|
6104
|
-
},
|
|
6105
|
-
onShow: {
|
|
6106
|
-
writable: true,
|
|
6107
|
-
enumerable: true,
|
|
6108
|
-
value(options) {
|
|
6109
|
-
var _a;
|
|
6110
|
-
Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
|
|
6111
|
-
const onShow = (_a = appInstance === null || appInstance === void 0 ? void 0 : appInstance.$options) === null || _a === void 0 ? void 0 : _a.onShow;
|
|
6112
|
-
isFunction$1(onShow) && onShow.call(appInstance, options);
|
|
6113
|
-
}
|
|
6114
|
-
},
|
|
6115
|
-
onHide: {
|
|
6116
|
-
writable: true,
|
|
6117
|
-
enumerable: true,
|
|
6118
|
-
value(options) {
|
|
6119
|
-
var _a;
|
|
6120
|
-
const onHide = (_a = appInstance === null || appInstance === void 0 ? void 0 : appInstance.$options) === null || _a === void 0 ? void 0 : _a.onHide;
|
|
6121
|
-
isFunction$1(onHide) && onHide.call(appInstance, options);
|
|
6122
|
-
}
|
|
6123
|
-
}
|
|
6124
|
-
});
|
|
6125
|
-
Current.app = appConfig;
|
|
6126
|
-
return Current.app;
|
|
6127
|
-
}
|
|
6128
|
-
|
|
6129
|
-
const taroHooks = (lifecycle) => {
|
|
6130
|
-
return (fn) => {
|
|
6131
|
-
const id = R.useContext(PageContext) || HOOKS_APP_ID;
|
|
6132
|
-
// hold fn ref and keep up to date
|
|
6133
|
-
const fnRef = R.useRef(fn);
|
|
6134
|
-
if (fnRef.current !== fn)
|
|
6135
|
-
fnRef.current = fn;
|
|
6136
|
-
R.useLayoutEffect(() => {
|
|
6137
|
-
let inst = getPageInstance(id);
|
|
6138
|
-
let first = false;
|
|
6139
|
-
if (inst == null) {
|
|
6140
|
-
first = true;
|
|
6141
|
-
inst = Object.create(null);
|
|
6142
|
-
}
|
|
6143
|
-
inst = inst;
|
|
6144
|
-
// callback is immutable but inner function is up to date
|
|
6145
|
-
const callback = (...args) => fnRef.current(...args);
|
|
6146
|
-
if (isFunction$1(inst[lifecycle])) {
|
|
6147
|
-
inst[lifecycle] = [inst[lifecycle], callback];
|
|
6148
|
-
}
|
|
6149
|
-
else {
|
|
6150
|
-
inst[lifecycle] = [
|
|
6151
|
-
...(inst[lifecycle] || []),
|
|
6152
|
-
callback
|
|
6153
|
-
];
|
|
6154
|
-
}
|
|
6155
|
-
if (first) {
|
|
6156
|
-
injectPageInstance(inst, id);
|
|
6157
|
-
}
|
|
6158
|
-
return () => {
|
|
6159
|
-
const inst = getPageInstance(id);
|
|
6160
|
-
const list = inst[lifecycle];
|
|
6161
|
-
if (list === callback) {
|
|
6162
|
-
inst[lifecycle] = undefined;
|
|
6163
|
-
}
|
|
6164
|
-
else if (isArray$1(list)) {
|
|
6165
|
-
inst[lifecycle] = list.filter(item => item !== callback);
|
|
6166
|
-
}
|
|
6167
|
-
};
|
|
6168
|
-
}, []);
|
|
6169
|
-
};
|
|
6170
|
-
};
|
|
6171
|
-
const useDidShow = taroHooks('componentDidShow');
|
|
6172
|
-
const useDidHide = taroHooks('componentDidHide');
|
|
6173
|
-
const usePullDownRefresh = taroHooks('onPullDownRefresh');
|
|
6174
|
-
const useReachBottom = taroHooks('onReachBottom');
|
|
6175
|
-
const usePageScroll = taroHooks('onPageScroll');
|
|
6176
|
-
const useResize = taroHooks('onResize');
|
|
6177
|
-
const useShareAppMessage = taroHooks('onShareAppMessage');
|
|
6178
|
-
const useTabItemTap = taroHooks('onTabItemTap');
|
|
6179
|
-
const useTitleClick = taroHooks('onTitleClick');
|
|
6180
|
-
const useOptionMenuClick = taroHooks('onOptionMenuClick');
|
|
6181
|
-
const usePullIntercept = taroHooks('onPullIntercept');
|
|
6182
|
-
const useShareTimeline = taroHooks('onShareTimeline');
|
|
6183
|
-
const useAddToFavorites = taroHooks('onAddToFavorites');
|
|
6184
|
-
const useReady = taroHooks('onReady');
|
|
6185
|
-
const useRouter = (dynamic = false) => {
|
|
6186
|
-
return dynamic ? Current.router : R.useMemo(() => Current.router, []);
|
|
6187
|
-
};
|
|
6188
|
-
const useScope = () => undefined;
|
|
6189
|
-
|
|
6190
4394
|
function removeLeadingSlash(path) {
|
|
6191
4395
|
if (path == null) {
|
|
6192
4396
|
return '';
|
|
@@ -6204,9 +4408,9 @@ const nextTick = (cb, ctx) => {
|
|
|
6204
4408
|
if (router !== null) {
|
|
6205
4409
|
let pageElement = null;
|
|
6206
4410
|
const path = getPath(removeLeadingSlash(router.path), router.params);
|
|
6207
|
-
pageElement = document$
|
|
4411
|
+
pageElement = document$1.getElementById(path);
|
|
6208
4412
|
if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) {
|
|
6209
|
-
if (
|
|
4413
|
+
if (process.env.TARO_ENV === 'h5') {
|
|
6210
4414
|
// eslint-disable-next-line dot-notation
|
|
6211
4415
|
(_c = (_b = (_a = pageElement.firstChild) === null || _a === void 0 ? void 0 : _a['componentOnReady']) === null || _b === void 0 ? void 0 : _b.call(_a).then(() => {
|
|
6212
4416
|
timerFunc();
|
|
@@ -6225,5 +4429,5 @@ const nextTick = (cb, ctx) => {
|
|
|
6225
4429
|
}
|
|
6226
4430
|
};
|
|
6227
4431
|
|
|
6228
|
-
export { Current, ElementNames, Events, FormElement, SERVICE_IDENTIFIER, SVGElement, Style, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, caf as cancelAnimationFrame,
|
|
4432
|
+
export { Current, ElementNames, Events, FormElement, SERVICE_IDENTIFIER, SVGElement, Style, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, addLeadingSlash, caf as cancelAnimationFrame, container, createComponentConfig, createDocument, createEvent, createPageConfig, createRecursiveComponentConfig, document$1 as document, eventCenter, eventHandler, getComputedStyle, getCurrentInstance, getPageInstance, hydrate, incrementId, injectPageInstance, navigator, nextTick, now, options, processPluginHooks, raf as requestAnimationFrame, safeExecute, stringify, window$1 as window };
|
|
6229
4433
|
//# sourceMappingURL=runtime.esm.js.map
|