@tarojs/runtime 3.3.12 → 3.4.0-beta.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 +802 -2593
- 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,106 @@ 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;
|
|
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 node = getDocument().getElementById(event.currentTarget.id);
|
|
2601
|
+
if (node) {
|
|
2602
|
+
const dispatch = () => {
|
|
2603
|
+
var _a;
|
|
2604
|
+
const e = createEvent(event, node);
|
|
2605
|
+
(_a = hooks.modifyTaroEvent) === null || _a === void 0 ? void 0 : _a.call(hooks, e, node);
|
|
2606
|
+
node.dispatchEvent(e);
|
|
2607
|
+
};
|
|
2608
|
+
if (isFunction(hooks.batchedEventUpdates)) {
|
|
2609
|
+
const type = event.type;
|
|
2610
|
+
if (!hooks.isBubbleEvents(type) ||
|
|
2611
|
+
!isParentBinded(node, type) ||
|
|
2612
|
+
(type === TOUCHMOVE && !!node.props.catchMove)) {
|
|
2613
|
+
// 最上层组件统一 batchUpdate
|
|
2614
|
+
hooks.batchedEventUpdates(() => {
|
|
2615
|
+
if (eventsBatch[type]) {
|
|
2616
|
+
eventsBatch[type].forEach(fn => fn());
|
|
2617
|
+
delete eventsBatch[type];
|
|
2618
|
+
}
|
|
2619
|
+
dispatch();
|
|
2620
|
+
});
|
|
2621
|
+
}
|
|
2622
|
+
else {
|
|
2623
|
+
// 如果上层组件也有绑定同类型的组件,委托给上层组件调用事件回调
|
|
2624
|
+
(eventsBatch[type] || (eventsBatch[type] = [])).push(dispatch);
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
else {
|
|
2628
|
+
dispatch();
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
const doc = process.env.TARO_ENV === 'h5' ? document : EMPTY_OBJ;
|
|
2634
|
+
const win = process.env.TARO_ENV === 'h5' ? window : EMPTY_OBJ;
|
|
2635
|
+
|
|
3587
2636
|
function initPosition() {
|
|
3588
2637
|
return {
|
|
3589
2638
|
index: 0,
|
|
@@ -4212,9 +3261,9 @@ function format(children, document, styleOptions, parent) {
|
|
|
4212
3261
|
.map((child) => {
|
|
4213
3262
|
// 文本节点
|
|
4214
3263
|
if (child.type === 'text') {
|
|
4215
|
-
|
|
4216
|
-
if (isFunction
|
|
4217
|
-
|
|
3264
|
+
let text = document.createTextNode(child.content);
|
|
3265
|
+
if (isFunction(options.html.transformText)) {
|
|
3266
|
+
text = options.html.transformText(text, child);
|
|
4218
3267
|
}
|
|
4219
3268
|
parent === null || parent === void 0 ? void 0 : parent.appendChild(text);
|
|
4220
3269
|
return text;
|
|
@@ -4247,7 +3296,7 @@ function format(children, document, styleOptions, parent) {
|
|
|
4247
3296
|
styleTagParser,
|
|
4248
3297
|
descendantList: list
|
|
4249
3298
|
}, el);
|
|
4250
|
-
if (isFunction
|
|
3299
|
+
if (isFunction(options.html.transformElement)) {
|
|
4251
3300
|
return options.html.transformElement(el, child);
|
|
4252
3301
|
}
|
|
4253
3302
|
return el;
|
|
@@ -4377,7 +3426,7 @@ function setInnerHTML(element, html, getDoc) {
|
|
|
4377
3426
|
* An implementation of `Element.insertAdjacentHTML()`
|
|
4378
3427
|
* to support Vue 3 with a version of or greater than `vue@3.1.2`
|
|
4379
3428
|
*/
|
|
4380
|
-
function insertAdjacentHTMLImpl(position, html
|
|
3429
|
+
function insertAdjacentHTMLImpl(getDoc, position, html) {
|
|
4381
3430
|
var _a, _b;
|
|
4382
3431
|
const parsedNodes = parser(html, getDoc());
|
|
4383
3432
|
for (let i = 0; i < parsedNodes.length; i++) {
|
|
@@ -4403,13 +3452,13 @@ function insertAdjacentHTMLImpl(position, html, getDoc) {
|
|
|
4403
3452
|
}
|
|
4404
3453
|
}
|
|
4405
3454
|
}
|
|
4406
|
-
function cloneNode(
|
|
3455
|
+
function cloneNode(getDoc, isDeep = false) {
|
|
4407
3456
|
const document = getDoc();
|
|
4408
3457
|
let newNode;
|
|
4409
|
-
if (
|
|
4410
|
-
newNode = document.createElement(
|
|
3458
|
+
if (this.nodeType === 1 /* ELEMENT_NODE */) {
|
|
3459
|
+
newNode = document.createElement(this.nodeName);
|
|
4411
3460
|
}
|
|
4412
|
-
else if (
|
|
3461
|
+
else if (this.nodeType === 3 /* TEXT_NODE */) {
|
|
4413
3462
|
newNode = document.createTextNode('');
|
|
4414
3463
|
}
|
|
4415
3464
|
for (const key in this) {
|
|
@@ -4426,9 +3475,20 @@ function cloneNode(ctx, getDoc, isDeep = false) {
|
|
|
4426
3475
|
}
|
|
4427
3476
|
}
|
|
4428
3477
|
if (isDeep) {
|
|
4429
|
-
newNode.childNodes =
|
|
3478
|
+
newNode.childNodes = this.childNodes.map(node => node.cloneNode(true));
|
|
4430
3479
|
}
|
|
4431
3480
|
return newNode;
|
|
3481
|
+
}
|
|
3482
|
+
function contains(node) {
|
|
3483
|
+
let isContains = false;
|
|
3484
|
+
this.childNodes.some(childNode => {
|
|
3485
|
+
const { uid } = childNode;
|
|
3486
|
+
if (uid === node.uid || uid === node.id || childNode.contains(node)) {
|
|
3487
|
+
isContains = true;
|
|
3488
|
+
return true;
|
|
3489
|
+
}
|
|
3490
|
+
});
|
|
3491
|
+
return isContains;
|
|
4432
3492
|
}
|
|
4433
3493
|
|
|
4434
3494
|
let TaroNodeImpl = class TaroNodeImpl {
|
|
@@ -4441,11 +3501,14 @@ let TaroNodeImpl = class TaroNodeImpl {
|
|
|
4441
3501
|
if (ENABLE_INNER_HTML) {
|
|
4442
3502
|
bindInnerHTML(ctx, getDoc);
|
|
4443
3503
|
if (ENABLE_ADJACENT_HTML) {
|
|
4444
|
-
|
|
3504
|
+
ctx.insertAdjacentHTML = insertAdjacentHTMLImpl.bind(ctx, getDoc);
|
|
4445
3505
|
}
|
|
4446
3506
|
}
|
|
4447
3507
|
if (ENABLE_CLONE_NODE) {
|
|
4448
|
-
ctx.cloneNode = cloneNode.bind(ctx,
|
|
3508
|
+
ctx.cloneNode = cloneNode.bind(ctx, getDoc);
|
|
3509
|
+
}
|
|
3510
|
+
if (ENABLE_CONTAINS) {
|
|
3511
|
+
ctx.contains = contains.bind(ctx);
|
|
4449
3512
|
}
|
|
4450
3513
|
}
|
|
4451
3514
|
};
|
|
@@ -4465,11 +3528,6 @@ function bindInnerHTML(ctx, getDoc) {
|
|
|
4465
3528
|
return '';
|
|
4466
3529
|
}
|
|
4467
3530
|
});
|
|
4468
|
-
}
|
|
4469
|
-
function bindAdjacentHTML(ctx, getDoc) {
|
|
4470
|
-
ctx.insertAdjacentHTML = function (position, html) {
|
|
4471
|
-
insertAdjacentHTMLImpl.call(ctx, position, html, getDoc);
|
|
4472
|
-
};
|
|
4473
3531
|
}
|
|
4474
3532
|
|
|
4475
3533
|
function getBoundingClientRectImpl() {
|
|
@@ -4498,9 +3556,7 @@ function getTemplateContent(ctx) {
|
|
|
4498
3556
|
let TaroElementImpl = class TaroElementImpl {
|
|
4499
3557
|
bind(ctx) {
|
|
4500
3558
|
if (ENABLE_SIZE_APIS) {
|
|
4501
|
-
ctx.getBoundingClientRect =
|
|
4502
|
-
return await getBoundingClientRectImpl.apply(ctx, args);
|
|
4503
|
-
};
|
|
3559
|
+
ctx.getBoundingClientRect = getBoundingClientRectImpl.bind(ctx);
|
|
4504
3560
|
}
|
|
4505
3561
|
if (ENABLE_TEMPLATE_CONTENT) {
|
|
4506
3562
|
bindContent(ctx);
|
|
@@ -4522,20 +3578,21 @@ function bindContent(ctx) {
|
|
|
4522
3578
|
|
|
4523
3579
|
let TaroDocument = class TaroDocument extends TaroElement {
|
|
4524
3580
|
constructor(// eslint-disable-next-line @typescript-eslint/indent
|
|
4525
|
-
|
|
4526
|
-
super(
|
|
3581
|
+
getText) {
|
|
3582
|
+
super();
|
|
4527
3583
|
this._getText = getText;
|
|
4528
3584
|
this.nodeType = 9 /* DOCUMENT_NODE */;
|
|
4529
3585
|
this.nodeName = DOCUMENT_ELEMENT_NAME;
|
|
4530
3586
|
}
|
|
4531
3587
|
createElement(type) {
|
|
3588
|
+
const getElement = this._getElement;
|
|
4532
3589
|
if (type === ROOT_STR) {
|
|
4533
|
-
return
|
|
3590
|
+
return getElement(ElementNames.RootElement)();
|
|
4534
3591
|
}
|
|
4535
3592
|
if (controlledComponent.has(type)) {
|
|
4536
|
-
return
|
|
3593
|
+
return getElement(ElementNames.FormElement)(type);
|
|
4537
3594
|
}
|
|
4538
|
-
return
|
|
3595
|
+
return getElement(ElementNames.Element)(type);
|
|
4539
3596
|
}
|
|
4540
3597
|
// an ugly fake createElementNS to deal with @vue/runtime-dom's
|
|
4541
3598
|
// support mounting app to svg container since vue@3.0.8
|
|
@@ -4569,23 +3626,109 @@ let TaroDocument = class TaroDocument extends TaroElement {
|
|
|
4569
3626
|
};
|
|
4570
3627
|
TaroDocument = __decorate([
|
|
4571
3628
|
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])
|
|
3629
|
+
__param(0, inject(SID_TARO_TEXT_FACTORY)),
|
|
3630
|
+
__metadata("design:paramtypes", [Function])
|
|
4578
3631
|
], TaroDocument);
|
|
4579
3632
|
|
|
3633
|
+
/**
|
|
3634
|
+
* 支持冒泡的事件, 除 支付宝小程序外,其余的可冒泡事件都和微信保持一致
|
|
3635
|
+
* 详见 见 https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxml/event.html
|
|
3636
|
+
*/
|
|
3637
|
+
const BUBBLE_EVENTS = new Set([
|
|
3638
|
+
'touchstart',
|
|
3639
|
+
'touchmove',
|
|
3640
|
+
'touchcancel',
|
|
3641
|
+
'touchend',
|
|
3642
|
+
'touchforcechange',
|
|
3643
|
+
'tap',
|
|
3644
|
+
'longpress',
|
|
3645
|
+
'longtap',
|
|
3646
|
+
'transitionend',
|
|
3647
|
+
'animationstart',
|
|
3648
|
+
'animationiteration',
|
|
3649
|
+
'animationend'
|
|
3650
|
+
]);
|
|
3651
|
+
|
|
3652
|
+
const defaultMiniLifecycle = {
|
|
3653
|
+
app: [
|
|
3654
|
+
'onLaunch',
|
|
3655
|
+
'onShow',
|
|
3656
|
+
'onHide'
|
|
3657
|
+
],
|
|
3658
|
+
page: [
|
|
3659
|
+
'onLoad',
|
|
3660
|
+
'onUnload',
|
|
3661
|
+
'onReady',
|
|
3662
|
+
'onShow',
|
|
3663
|
+
'onHide',
|
|
3664
|
+
[
|
|
3665
|
+
'onPullDownRefresh',
|
|
3666
|
+
'onReachBottom',
|
|
3667
|
+
'onPageScroll',
|
|
3668
|
+
'onResize',
|
|
3669
|
+
'onTabItemTap',
|
|
3670
|
+
'onTitleClick',
|
|
3671
|
+
'onOptionMenuClick',
|
|
3672
|
+
'onPopMenuClick',
|
|
3673
|
+
'onPullIntercept',
|
|
3674
|
+
'onAddToFavorites'
|
|
3675
|
+
]
|
|
3676
|
+
]
|
|
3677
|
+
};
|
|
3678
|
+
const getMiniLifecycle = function (defaultConfig) {
|
|
3679
|
+
return defaultConfig;
|
|
3680
|
+
};
|
|
3681
|
+
const getLifecycle = function (instance, lifecycle) {
|
|
3682
|
+
return instance[lifecycle];
|
|
3683
|
+
};
|
|
3684
|
+
const getPathIndex = function (indexOfNode) {
|
|
3685
|
+
return `[${indexOfNode}]`;
|
|
3686
|
+
};
|
|
3687
|
+
const getEventCenter = function (Events) {
|
|
3688
|
+
return new Events();
|
|
3689
|
+
};
|
|
3690
|
+
const isBubbleEvents = function (eventName) {
|
|
3691
|
+
return BUBBLE_EVENTS.has(eventName);
|
|
3692
|
+
};
|
|
3693
|
+
const getSpecialNodes = function () {
|
|
3694
|
+
return ['view', 'text', 'image'];
|
|
3695
|
+
};
|
|
3696
|
+
const DefaultHooksContainer = new ContainerModule(bind => {
|
|
3697
|
+
function bindFunction(sid, target) {
|
|
3698
|
+
return bind(sid).toFunction(target);
|
|
3699
|
+
}
|
|
3700
|
+
bindFunction(SID_GET_MINI_LIFECYCLE, getMiniLifecycle);
|
|
3701
|
+
bindFunction(SID_GET_LIFECYCLE, getLifecycle);
|
|
3702
|
+
bindFunction(SID_GET_PATH_INDEX, getPathIndex);
|
|
3703
|
+
bindFunction(SID_GET_EVENT_CENTER, getEventCenter);
|
|
3704
|
+
bindFunction(SID_IS_BUBBLE_EVENTS, isBubbleEvents);
|
|
3705
|
+
bindFunction(SID_GET_SPECIAL_NODES, getSpecialNodes);
|
|
3706
|
+
});
|
|
3707
|
+
|
|
4580
3708
|
let Hooks = class Hooks {
|
|
3709
|
+
getMiniLifecycleImpl() {
|
|
3710
|
+
return this.getMiniLifecycle(defaultMiniLifecycle);
|
|
3711
|
+
}
|
|
4581
3712
|
modifyMpEvent(e) {
|
|
4582
3713
|
var _a;
|
|
4583
|
-
(_a = this.modifyMpEventImpls) === null || _a === void 0 ? void 0 : _a.forEach(fn =>
|
|
3714
|
+
(_a = this.modifyMpEventImpls) === null || _a === void 0 ? void 0 : _a.forEach(fn => {
|
|
3715
|
+
try {
|
|
3716
|
+
// 有些小程序的事件对象的某些属性只读
|
|
3717
|
+
fn(e);
|
|
3718
|
+
}
|
|
3719
|
+
catch (error) {
|
|
3720
|
+
console.warn('[Taro modifyMpEvent hook Error]: ', error);
|
|
3721
|
+
}
|
|
3722
|
+
});
|
|
4584
3723
|
}
|
|
4585
3724
|
modifyTaroEvent(e, element) {
|
|
4586
3725
|
var _a;
|
|
4587
3726
|
(_a = this.modifyTaroEventImpls) === null || _a === void 0 ? void 0 : _a.forEach(fn => fn(e, element));
|
|
4588
3727
|
}
|
|
3728
|
+
modifyDispatchEvent(e, element) {
|
|
3729
|
+
var _a;
|
|
3730
|
+
(_a = this.modifyDispatchEventImpls) === null || _a === void 0 ? void 0 : _a.forEach(fn => fn(e, element));
|
|
3731
|
+
}
|
|
4589
3732
|
initNativeApi(taro) {
|
|
4590
3733
|
var _a;
|
|
4591
3734
|
(_a = this.initNativeApiImpls) === null || _a === void 0 ? void 0 : _a.forEach(fn => fn(taro));
|
|
@@ -4596,87 +3739,101 @@ let Hooks = class Hooks {
|
|
|
4596
3739
|
}
|
|
4597
3740
|
};
|
|
4598
3741
|
__decorate([
|
|
4599
|
-
inject(
|
|
3742
|
+
inject(SID_GET_MINI_LIFECYCLE),
|
|
3743
|
+
__metadata("design:type", Function)
|
|
3744
|
+
], Hooks.prototype, "getMiniLifecycle", void 0);
|
|
3745
|
+
__decorate([
|
|
3746
|
+
inject(SID_GET_LIFECYCLE),
|
|
4600
3747
|
__metadata("design:type", Function)
|
|
4601
3748
|
], Hooks.prototype, "getLifecycle", void 0);
|
|
4602
3749
|
__decorate([
|
|
4603
|
-
inject(
|
|
3750
|
+
inject(SID_GET_PATH_INDEX),
|
|
4604
3751
|
__metadata("design:type", Function)
|
|
4605
3752
|
], Hooks.prototype, "getPathIndex", void 0);
|
|
4606
3753
|
__decorate([
|
|
4607
|
-
inject(
|
|
3754
|
+
inject(SID_GET_EVENT_CENTER),
|
|
4608
3755
|
__metadata("design:type", Function)
|
|
4609
3756
|
], Hooks.prototype, "getEventCenter", void 0);
|
|
4610
3757
|
__decorate([
|
|
4611
|
-
inject(
|
|
3758
|
+
inject(SID_IS_BUBBLE_EVENTS),
|
|
4612
3759
|
__metadata("design:type", Function)
|
|
4613
3760
|
], Hooks.prototype, "isBubbleEvents", void 0);
|
|
4614
3761
|
__decorate([
|
|
4615
|
-
inject(
|
|
3762
|
+
inject(SID_GET_SPECIAL_NODES),
|
|
4616
3763
|
__metadata("design:type", Function)
|
|
4617
3764
|
], Hooks.prototype, "getSpecialNodes", void 0);
|
|
4618
3765
|
__decorate([
|
|
4619
|
-
inject(
|
|
3766
|
+
inject(SID_ON_REMOVE_ATTRIBUTE),
|
|
4620
3767
|
optional(),
|
|
4621
3768
|
__metadata("design:type", Function)
|
|
4622
3769
|
], Hooks.prototype, "onRemoveAttribute", void 0);
|
|
4623
3770
|
__decorate([
|
|
4624
|
-
inject(
|
|
3771
|
+
inject(SID_BATCHED_EVENT_UPDATES),
|
|
4625
3772
|
optional(),
|
|
4626
3773
|
__metadata("design:type", Function)
|
|
4627
3774
|
], Hooks.prototype, "batchedEventUpdates", void 0);
|
|
4628
3775
|
__decorate([
|
|
4629
|
-
inject(
|
|
3776
|
+
inject(SID_MERGE_PAGE_INSTANCE),
|
|
4630
3777
|
optional(),
|
|
4631
3778
|
__metadata("design:type", Function)
|
|
4632
3779
|
], Hooks.prototype, "mergePageInstance", void 0);
|
|
4633
3780
|
__decorate([
|
|
4634
|
-
inject(
|
|
3781
|
+
inject(SID_MODIFY_PAGE_OBJECT),
|
|
3782
|
+
optional(),
|
|
3783
|
+
__metadata("design:type", Function)
|
|
3784
|
+
], Hooks.prototype, "modifyPageObject", void 0);
|
|
3785
|
+
__decorate([
|
|
3786
|
+
inject(SID_CREATE_PULLDOWN_COMPONENT),
|
|
4635
3787
|
optional(),
|
|
4636
3788
|
__metadata("design:type", Function)
|
|
4637
3789
|
], Hooks.prototype, "createPullDownComponent", void 0);
|
|
4638
3790
|
__decorate([
|
|
4639
|
-
inject(
|
|
3791
|
+
inject(SID_GET_DOM_NODE),
|
|
4640
3792
|
optional(),
|
|
4641
3793
|
__metadata("design:type", Function)
|
|
4642
3794
|
], Hooks.prototype, "getDOMNode", void 0);
|
|
4643
3795
|
__decorate([
|
|
4644
|
-
inject(
|
|
3796
|
+
inject(SID_MODIFY_HYDRATE_DATA),
|
|
4645
3797
|
optional(),
|
|
4646
3798
|
__metadata("design:type", Function)
|
|
4647
3799
|
], Hooks.prototype, "modifyHydrateData", void 0);
|
|
4648
3800
|
__decorate([
|
|
4649
|
-
inject(
|
|
3801
|
+
inject(SID_MODIFY_SET_ATTR_PAYLOAD),
|
|
4650
3802
|
optional(),
|
|
4651
3803
|
__metadata("design:type", Function)
|
|
4652
3804
|
], Hooks.prototype, "modifySetAttrPayload", void 0);
|
|
4653
3805
|
__decorate([
|
|
4654
|
-
inject(
|
|
3806
|
+
inject(SID_MODIFY_RM_ATTR_PAYLOAD),
|
|
4655
3807
|
optional(),
|
|
4656
3808
|
__metadata("design:type", Function)
|
|
4657
3809
|
], Hooks.prototype, "modifyRmAttrPayload", void 0);
|
|
4658
3810
|
__decorate([
|
|
4659
|
-
inject(
|
|
3811
|
+
inject(SID_ON_ADD_EVENT),
|
|
4660
3812
|
optional(),
|
|
4661
3813
|
__metadata("design:type", Function)
|
|
4662
3814
|
], Hooks.prototype, "onAddEvent", void 0);
|
|
4663
3815
|
__decorate([
|
|
4664
|
-
multiInject(
|
|
3816
|
+
multiInject(SID_MODIFY_MP_EVENT),
|
|
4665
3817
|
optional(),
|
|
4666
3818
|
__metadata("design:type", Array)
|
|
4667
3819
|
], Hooks.prototype, "modifyMpEventImpls", void 0);
|
|
4668
3820
|
__decorate([
|
|
4669
|
-
multiInject(
|
|
3821
|
+
multiInject(SID_MODIFY_TARO_EVENT),
|
|
4670
3822
|
optional(),
|
|
4671
3823
|
__metadata("design:type", Array)
|
|
4672
3824
|
], Hooks.prototype, "modifyTaroEventImpls", void 0);
|
|
4673
3825
|
__decorate([
|
|
4674
|
-
multiInject(
|
|
3826
|
+
multiInject(SID_MODIFY_DISPATCH_EVENT),
|
|
3827
|
+
optional(),
|
|
3828
|
+
__metadata("design:type", Array)
|
|
3829
|
+
], Hooks.prototype, "modifyDispatchEventImpls", void 0);
|
|
3830
|
+
__decorate([
|
|
3831
|
+
multiInject(SID_INIT_NATIVE_API),
|
|
4675
3832
|
optional(),
|
|
4676
3833
|
__metadata("design:type", Array)
|
|
4677
3834
|
], Hooks.prototype, "initNativeApiImpls", void 0);
|
|
4678
3835
|
__decorate([
|
|
4679
|
-
multiInject(
|
|
3836
|
+
multiInject(SID_PATCH_ELEMENT),
|
|
4680
3837
|
optional(),
|
|
4681
3838
|
__metadata("design:type", Array)
|
|
4682
3839
|
], Hooks.prototype, "patchElementImpls", void 0);
|
|
@@ -4684,48 +3841,6 @@ Hooks = __decorate([
|
|
|
4684
3841
|
injectable()
|
|
4685
3842
|
], Hooks);
|
|
4686
3843
|
|
|
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
3844
|
function processPluginHooks(container) {
|
|
4730
3845
|
const keys = Object.keys(defaultReconciler);
|
|
4731
3846
|
keys.forEach(key => {
|
|
@@ -4733,7 +3848,7 @@ function processPluginHooks(container) {
|
|
|
4733
3848
|
// is hooks
|
|
4734
3849
|
const identifier = SERVICE_IDENTIFIER[key];
|
|
4735
3850
|
const fn = defaultReconciler[key];
|
|
4736
|
-
if (isArray
|
|
3851
|
+
if (isArray(fn)) {
|
|
4737
3852
|
// is multi
|
|
4738
3853
|
fn.forEach(item => container.bind(identifier).toFunction(item));
|
|
4739
3854
|
}
|
|
@@ -4751,14 +3866,27 @@ function processPluginHooks(container) {
|
|
|
4751
3866
|
}
|
|
4752
3867
|
|
|
4753
3868
|
const container = new Container();
|
|
3869
|
+
function bind(sid, target, options = {}) {
|
|
3870
|
+
let res = container.bind(sid).to(target);
|
|
3871
|
+
if (options.single) {
|
|
3872
|
+
res = res.inSingletonScope();
|
|
3873
|
+
}
|
|
3874
|
+
if (options.name) {
|
|
3875
|
+
res = res.whenTargetNamed(options.name);
|
|
3876
|
+
}
|
|
3877
|
+
return res;
|
|
3878
|
+
}
|
|
4754
3879
|
if (process.env.TARO_ENV !== 'h5') {
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
3880
|
+
bind(SID_TARO_TEXT, TaroText);
|
|
3881
|
+
bind(SID_TARO_ELEMENT, TaroElement, { name: ElementNames.Element });
|
|
3882
|
+
bind(SID_TARO_ELEMENT, TaroRootElement, { name: ElementNames.RootElement });
|
|
3883
|
+
bind(SID_TARO_ELEMENT, FormElement, { name: ElementNames.FormElement });
|
|
3884
|
+
bind(SID_TARO_ELEMENT, TaroDocument, { name: ElementNames.Document, single: true });
|
|
3885
|
+
bind(SID_TARO_NODE_IMPL, TaroNodeImpl, { single: true });
|
|
3886
|
+
bind(SID_TARO_ELEMENT_IMPL, TaroElementImpl, { single: true });
|
|
3887
|
+
container.bind(SID_TARO_ELEMENT_FACTORY).toFactory((context) => {
|
|
4760
3888
|
return (named) => (nodeName) => {
|
|
4761
|
-
const el = context.container.getNamed(
|
|
3889
|
+
const el = context.container.getNamed(SID_TARO_ELEMENT, named);
|
|
4762
3890
|
if (nodeName) {
|
|
4763
3891
|
el.nodeName = nodeName;
|
|
4764
3892
|
}
|
|
@@ -4766,173 +3894,64 @@ if (process.env.TARO_ENV !== 'h5') {
|
|
|
4766
3894
|
return el;
|
|
4767
3895
|
};
|
|
4768
3896
|
});
|
|
4769
|
-
container.bind(
|
|
4770
|
-
container.bind(SERVICE_IDENTIFIER.TaroTextFactory).toFactory((context) => {
|
|
3897
|
+
container.bind(SID_TARO_TEXT_FACTORY).toFactory((context) => {
|
|
4771
3898
|
return (text) => {
|
|
4772
|
-
const textNode = context.container.get(
|
|
3899
|
+
const textNode = context.container.get(SID_TARO_TEXT);
|
|
4773
3900
|
textNode._value = text;
|
|
4774
3901
|
return textNode;
|
|
4775
3902
|
};
|
|
4776
3903
|
});
|
|
4777
|
-
container.bind(SERVICE_IDENTIFIER.TaroNodeImpl).to(TaroNodeImpl).inSingletonScope();
|
|
4778
|
-
container.bind(SERVICE_IDENTIFIER.TaroElementImpl).to(TaroElementImpl).inSingletonScope();
|
|
4779
3904
|
}
|
|
4780
|
-
|
|
3905
|
+
bind(SID_HOOKS, Hooks, { single: true });
|
|
4781
3906
|
container.load(DefaultHooksContainer);
|
|
4782
|
-
processPluginHooks(container);
|
|
3907
|
+
processPluginHooks(container);
|
|
3908
|
+
store.container = container;
|
|
4783
3909
|
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
3910
|
+
function createDocument() {
|
|
3911
|
+
/**
|
|
3912
|
+
* <document>
|
|
3913
|
+
* <html>
|
|
3914
|
+
* <head></head>
|
|
3915
|
+
* <body>
|
|
3916
|
+
* <container>
|
|
3917
|
+
* <app id="app" />
|
|
3918
|
+
* </container>
|
|
3919
|
+
* </body>
|
|
3920
|
+
* </html>
|
|
3921
|
+
* </document>
|
|
3922
|
+
*/
|
|
3923
|
+
const getElement = container.get(SERVICE_IDENTIFIER.TaroElementFactory);
|
|
3924
|
+
const doc = getElement(ElementNames.Document)();
|
|
3925
|
+
const documentCreateElement = doc.createElement.bind(doc);
|
|
3926
|
+
const html = documentCreateElement(HTML);
|
|
3927
|
+
const head = documentCreateElement(HEAD);
|
|
3928
|
+
const body = documentCreateElement(BODY);
|
|
3929
|
+
const app = documentCreateElement(APP);
|
|
3930
|
+
app.id = APP;
|
|
3931
|
+
const container$1 = documentCreateElement(CONTAINER); // 多包一层主要为了兼容 vue
|
|
3932
|
+
doc.appendChild(html);
|
|
3933
|
+
html.appendChild(head);
|
|
3934
|
+
html.appendChild(body);
|
|
3935
|
+
body.appendChild(container$1);
|
|
3936
|
+
container$1.appendChild(app);
|
|
3937
|
+
doc.documentElement = html;
|
|
3938
|
+
doc.head = head;
|
|
3939
|
+
doc.body = body;
|
|
3940
|
+
doc.createEvent = createEvent;
|
|
3941
|
+
return doc;
|
|
4791
3942
|
}
|
|
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());
|
|
3943
|
+
const document$1 = process.env.TARO_ENV === 'h5'
|
|
3944
|
+
? doc
|
|
3945
|
+
: createDocument();
|
|
4928
3946
|
|
|
4929
3947
|
const machine = 'Macintosh';
|
|
4930
3948
|
const arch = 'Intel Mac OS X 10_14_5';
|
|
4931
3949
|
const engine = 'AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v4.1.0 Chrome/76.0.3809.132 Safari/534.36';
|
|
4932
|
-
const
|
|
3950
|
+
const msg = '(' + machine + '; ' + arch + ') ' + engine;
|
|
3951
|
+
const navigator = process.env.TARO_ENV === 'h5' ? win.navigator : {
|
|
4933
3952
|
appCodeName: 'Mozilla',
|
|
4934
3953
|
appName: 'Netscape',
|
|
4935
|
-
appVersion: '5.0
|
|
3954
|
+
appVersion: '5.0 ' + msg,
|
|
4936
3955
|
cookieEnabled: true,
|
|
4937
3956
|
mimeTypes: [],
|
|
4938
3957
|
onLine: true,
|
|
@@ -4940,7 +3959,7 @@ const navigator = isBrowser ? win.navigator : {
|
|
|
4940
3959
|
plugins: [],
|
|
4941
3960
|
product: 'Taro',
|
|
4942
3961
|
productSub: '20030107',
|
|
4943
|
-
userAgent: 'Mozilla/5.0
|
|
3962
|
+
userAgent: 'Mozilla/5.0 ' + msg,
|
|
4944
3963
|
vendor: 'Joyent',
|
|
4945
3964
|
vendorSub: ''
|
|
4946
3965
|
};
|
|
@@ -4986,11 +4005,11 @@ function getComputedStyle(element) {
|
|
|
4986
4005
|
return element.style;
|
|
4987
4006
|
}
|
|
4988
4007
|
|
|
4989
|
-
const window$1 =
|
|
4008
|
+
const window$1 = process.env.TARO_ENV === 'h5' ? win : {
|
|
4990
4009
|
navigator,
|
|
4991
|
-
document: document$
|
|
4010
|
+
document: document$1
|
|
4992
4011
|
};
|
|
4993
|
-
if (
|
|
4012
|
+
if (process.env.TARO_ENV && process.env.TARO_ENV !== 'h5') {
|
|
4994
4013
|
const globalProperties = [
|
|
4995
4014
|
...Object.getOwnPropertyNames(global || win),
|
|
4996
4015
|
...Object.getOwnPropertySymbols(global || win)
|
|
@@ -5002,20 +4021,21 @@ if (!isBrowser) {
|
|
|
5002
4021
|
window$1[property] = global[property];
|
|
5003
4022
|
}
|
|
5004
4023
|
});
|
|
5005
|
-
document$2.defaultView = window$1;
|
|
5006
|
-
}
|
|
5007
|
-
if (process.env.TARO_ENV && process.env.TARO_ENV !== 'h5') {
|
|
5008
4024
|
window$1.requestAnimationFrame = raf;
|
|
5009
4025
|
window$1.cancelAnimationFrame = caf;
|
|
5010
4026
|
window$1.getComputedStyle = getComputedStyle;
|
|
5011
|
-
window$1.addEventListener =
|
|
5012
|
-
window$1.removeEventListener =
|
|
4027
|
+
window$1.addEventListener = noop;
|
|
4028
|
+
window$1.removeEventListener = noop;
|
|
5013
4029
|
if (!(DATE in window$1)) {
|
|
5014
4030
|
window$1.Date = Date;
|
|
5015
4031
|
}
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
}
|
|
4032
|
+
window$1.setTimeout = function (cb, delay) {
|
|
4033
|
+
setTimeout(cb, delay);
|
|
4034
|
+
};
|
|
4035
|
+
window$1.clearTimeout = function (seed) {
|
|
4036
|
+
clearTimeout(seed);
|
|
4037
|
+
};
|
|
4038
|
+
document$1.defaultView = window$1;
|
|
5019
4039
|
}
|
|
5020
4040
|
|
|
5021
4041
|
const Current = {
|
|
@@ -5027,12 +4047,8 @@ const getCurrentInstance = () => Current;
|
|
|
5027
4047
|
|
|
5028
4048
|
class Events {
|
|
5029
4049
|
constructor(opts) {
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
}
|
|
5033
|
-
else {
|
|
5034
|
-
this.callbacks = {};
|
|
5035
|
-
}
|
|
4050
|
+
var _a;
|
|
4051
|
+
this.callbacks = (_a = opts === null || opts === void 0 ? void 0 : opts.callbacks) !== null && _a !== void 0 ? _a : {};
|
|
5036
4052
|
}
|
|
5037
4053
|
on(eventName, callback, context) {
|
|
5038
4054
|
let event, node, tail, list;
|
|
@@ -5109,17 +4125,15 @@ class Events {
|
|
|
5109
4125
|
}
|
|
5110
4126
|
}
|
|
5111
4127
|
Events.eventSplitter = /\s+/;
|
|
5112
|
-
const
|
|
5113
|
-
|
|
5114
|
-
container.bind(SERVICE_IDENTIFIER.eventCenter).toConstantValue(eventCenter);
|
|
4128
|
+
const eventCenter = getHooks().getEventCenter(Events);
|
|
4129
|
+
container.bind(SID_EVENT_CENTER).toConstantValue(eventCenter);
|
|
5115
4130
|
|
|
5116
4131
|
/* eslint-disable dot-notation */
|
|
5117
4132
|
const instances = new Map();
|
|
5118
4133
|
const pageId = incrementId();
|
|
5119
|
-
const hooks$2 = container.get(SERVICE_IDENTIFIER.Hooks);
|
|
5120
4134
|
function injectPageInstance(inst, id) {
|
|
5121
|
-
var _a;
|
|
5122
|
-
(_a =
|
|
4135
|
+
var _a, _b;
|
|
4136
|
+
(_b = (_a = getHooks()).mergePageInstance) === null || _b === void 0 ? void 0 : _b.call(_a, instances.get(id), inst);
|
|
5123
4137
|
instances.set(id, inst);
|
|
5124
4138
|
}
|
|
5125
4139
|
function getPageInstance(id) {
|
|
@@ -5136,12 +4150,12 @@ function safeExecute(path, lifecycle, ...args) {
|
|
|
5136
4150
|
if (instance == null) {
|
|
5137
4151
|
return;
|
|
5138
4152
|
}
|
|
5139
|
-
const func =
|
|
5140
|
-
if (isArray
|
|
4153
|
+
const func = getHooks().getLifecycle(instance, lifecycle);
|
|
4154
|
+
if (isArray(func)) {
|
|
5141
4155
|
const res = func.map(fn => fn.apply(instance, args));
|
|
5142
4156
|
return res[0];
|
|
5143
4157
|
}
|
|
5144
|
-
if (!isFunction
|
|
4158
|
+
if (!isFunction(func)) {
|
|
5145
4159
|
return;
|
|
5146
4160
|
}
|
|
5147
4161
|
return func.apply(instance, args);
|
|
@@ -5157,58 +4171,68 @@ function stringify(obj) {
|
|
|
5157
4171
|
}
|
|
5158
4172
|
function getPath(id, options) {
|
|
5159
4173
|
let path = id;
|
|
5160
|
-
if (
|
|
4174
|
+
if (process.env.TARO_ENV !== 'h5') {
|
|
5161
4175
|
path = id + stringify(options);
|
|
5162
4176
|
}
|
|
5163
4177
|
return path;
|
|
5164
4178
|
}
|
|
5165
4179
|
function getOnReadyEventKey(path) {
|
|
5166
|
-
return path + '.' +
|
|
4180
|
+
return path + '.' + ON_READY;
|
|
5167
4181
|
}
|
|
5168
4182
|
function getOnShowEventKey(path) {
|
|
5169
|
-
return path + '.' +
|
|
4183
|
+
return path + '.' + ON_SHOW;
|
|
5170
4184
|
}
|
|
5171
4185
|
function getOnHideEventKey(path) {
|
|
5172
|
-
return path + '.' +
|
|
4186
|
+
return path + '.' + ON_HIDE;
|
|
5173
4187
|
}
|
|
5174
4188
|
function createPageConfig(component, pageName, data, pageConfig) {
|
|
5175
|
-
var _a, _b;
|
|
5176
|
-
const id = pageName !== null && pageName !== void 0 ? pageName : `taro_page_${pageId()}`;
|
|
4189
|
+
var _a, _b, _c;
|
|
5177
4190
|
// 小程序 Page 构造器是一个傲娇小公主,不能把复杂的对象挂载到参数上
|
|
4191
|
+
const id = pageName !== null && pageName !== void 0 ? pageName : `taro_page_${pageId()}`;
|
|
4192
|
+
const hooks = getHooks();
|
|
4193
|
+
const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES] = hooks.getMiniLifecycleImpl().page;
|
|
5178
4194
|
let pageElement = null;
|
|
5179
4195
|
let unmounting = false;
|
|
5180
4196
|
let prepareMountList = [];
|
|
4197
|
+
function setCurrentRouter(page) {
|
|
4198
|
+
const router = process.env.TARO_ENV === 'h5' ? page.$taroPath : page.route || page.__route__ || page.$taroPath;
|
|
4199
|
+
Current.router = {
|
|
4200
|
+
params: page.$taroParams,
|
|
4201
|
+
path: addLeadingSlash(router),
|
|
4202
|
+
onReady: getOnReadyEventKey(id),
|
|
4203
|
+
onShow: getOnShowEventKey(id),
|
|
4204
|
+
onHide: getOnHideEventKey(id)
|
|
4205
|
+
};
|
|
4206
|
+
}
|
|
4207
|
+
let loadResolver;
|
|
4208
|
+
let hasLoaded;
|
|
5181
4209
|
const config = {
|
|
5182
|
-
|
|
4210
|
+
[ONLOAD](options, cb) {
|
|
4211
|
+
hasLoaded = new Promise(resolve => { loadResolver = resolve; });
|
|
5183
4212
|
perf.start(PAGE_INIT);
|
|
5184
4213
|
Current.page = this;
|
|
5185
4214
|
this.config = pageConfig || {};
|
|
5186
4215
|
options.$taroTimestamp = Date.now();
|
|
5187
4216
|
// this.$taroPath 是页面唯一标识,不可变,因此页面参数 options 也不可变
|
|
5188
4217
|
this.$taroPath = getPath(id, options);
|
|
4218
|
+
const $taroPath = this.$taroPath;
|
|
5189
4219
|
// this.$taroParams 作为暴露给开发者的页面参数对象,可以被随意修改
|
|
5190
4220
|
if (this.$taroParams == null) {
|
|
5191
4221
|
this.$taroParams = Object.assign({}, options);
|
|
5192
4222
|
}
|
|
5193
|
-
|
|
5194
|
-
Current.router = {
|
|
5195
|
-
params: this.$taroParams,
|
|
5196
|
-
path: addLeadingSlash(router),
|
|
5197
|
-
onReady: getOnReadyEventKey(id),
|
|
5198
|
-
onShow: getOnShowEventKey(id),
|
|
5199
|
-
onHide: getOnHideEventKey(id)
|
|
5200
|
-
};
|
|
4223
|
+
setCurrentRouter(this);
|
|
5201
4224
|
const mount = () => {
|
|
5202
|
-
Current.app.mount(component,
|
|
5203
|
-
pageElement = document$
|
|
4225
|
+
Current.app.mount(component, $taroPath, () => {
|
|
4226
|
+
pageElement = document$1.getElementById($taroPath);
|
|
5204
4227
|
ensure(pageElement !== null, '没有找到页面实例。');
|
|
5205
|
-
safeExecute(
|
|
5206
|
-
|
|
4228
|
+
safeExecute($taroPath, ON_LOAD, this.$taroParams);
|
|
4229
|
+
loadResolver();
|
|
4230
|
+
if (process.env.TARO_ENV !== 'h5') {
|
|
5207
4231
|
pageElement.ctx = this;
|
|
5208
4232
|
pageElement.performUpdate(true, cb);
|
|
5209
4233
|
}
|
|
5210
4234
|
else {
|
|
5211
|
-
isFunction
|
|
4235
|
+
isFunction(cb) && cb();
|
|
5212
4236
|
}
|
|
5213
4237
|
});
|
|
5214
4238
|
};
|
|
@@ -5219,18 +4243,12 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
5219
4243
|
mount();
|
|
5220
4244
|
}
|
|
5221
4245
|
},
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
eventCenter.trigger(getOnReadyEventKey(id));
|
|
5225
|
-
});
|
|
5226
|
-
safeExecute(this.$taroPath, 'onReady');
|
|
5227
|
-
this.onReady.called = true;
|
|
5228
|
-
},
|
|
5229
|
-
onUnload() {
|
|
4246
|
+
[ONUNLOAD]() {
|
|
4247
|
+
const $taroPath = this.$taroPath;
|
|
5230
4248
|
unmounting = true;
|
|
5231
|
-
Current.app.unmount(
|
|
4249
|
+
Current.app.unmount($taroPath, () => {
|
|
5232
4250
|
unmounting = false;
|
|
5233
|
-
instances.delete(
|
|
4251
|
+
instances.delete($taroPath);
|
|
5234
4252
|
if (pageElement) {
|
|
5235
4253
|
pageElement.ctx = null;
|
|
5236
4254
|
}
|
|
@@ -5240,70 +4258,52 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
5240
4258
|
}
|
|
5241
4259
|
});
|
|
5242
4260
|
},
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
this
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
4261
|
+
[ONREADY]() {
|
|
4262
|
+
// 触发生命周期
|
|
4263
|
+
safeExecute(this.$taroPath, ON_READY);
|
|
4264
|
+
// 通过事件触发子组件的生命周期
|
|
4265
|
+
raf(() => eventCenter.trigger(getOnReadyEventKey(id)));
|
|
4266
|
+
this.onReady.called = true;
|
|
4267
|
+
},
|
|
4268
|
+
[ONSHOW]() {
|
|
4269
|
+
hasLoaded.then(() => {
|
|
4270
|
+
// 设置 Current 的 page 和 router
|
|
4271
|
+
Current.page = this;
|
|
4272
|
+
setCurrentRouter(this);
|
|
4273
|
+
// 触发生命周期
|
|
4274
|
+
safeExecute(this.$taroPath, ON_SHOW);
|
|
4275
|
+
// 通过事件触发子组件的生命周期
|
|
4276
|
+
raf(() => eventCenter.trigger(getOnShowEventKey(id)));
|
|
5256
4277
|
});
|
|
5257
|
-
safeExecute(this.$taroPath, 'onShow');
|
|
5258
4278
|
},
|
|
5259
|
-
|
|
5260
|
-
Current
|
|
5261
|
-
Current.
|
|
5262
|
-
|
|
4279
|
+
[ONHIDE]() {
|
|
4280
|
+
// 设置 Current 的 page 和 router
|
|
4281
|
+
if (Current.page === this) {
|
|
4282
|
+
Current.page = null;
|
|
4283
|
+
Current.router = null;
|
|
4284
|
+
}
|
|
4285
|
+
// 触发生命周期
|
|
4286
|
+
safeExecute(this.$taroPath, ON_HIDE);
|
|
4287
|
+
// 通过事件触发子组件的生命周期
|
|
5263
4288
|
eventCenter.trigger(getOnHideEventKey(id));
|
|
5264
|
-
},
|
|
5265
|
-
onPullDownRefresh() {
|
|
5266
|
-
return safeExecute(this.$taroPath, 'onPullDownRefresh');
|
|
5267
|
-
},
|
|
5268
|
-
onReachBottom() {
|
|
5269
|
-
return safeExecute(this.$taroPath, 'onReachBottom');
|
|
5270
|
-
},
|
|
5271
|
-
onPageScroll(options) {
|
|
5272
|
-
return safeExecute(this.$taroPath, 'onPageScroll', options);
|
|
5273
|
-
},
|
|
5274
|
-
onResize(options) {
|
|
5275
|
-
return safeExecute(this.$taroPath, 'onResize', options);
|
|
5276
|
-
},
|
|
5277
|
-
onTabItemTap(options) {
|
|
5278
|
-
return safeExecute(this.$taroPath, 'onTabItemTap', options);
|
|
5279
|
-
},
|
|
5280
|
-
onTitleClick() {
|
|
5281
|
-
return safeExecute(this.$taroPath, 'onTitleClick');
|
|
5282
|
-
},
|
|
5283
|
-
onOptionMenuClick() {
|
|
5284
|
-
return safeExecute(this.$taroPath, 'onOptionMenuClick');
|
|
5285
|
-
},
|
|
5286
|
-
onPopMenuClick() {
|
|
5287
|
-
return safeExecute(this.$taroPath, 'onPopMenuClick');
|
|
5288
|
-
},
|
|
5289
|
-
onPullIntercept() {
|
|
5290
|
-
return safeExecute(this.$taroPath, 'onPullIntercept');
|
|
5291
|
-
},
|
|
5292
|
-
onAddToFavorites() {
|
|
5293
|
-
return safeExecute(this.$taroPath, 'onAddToFavorites');
|
|
5294
4289
|
}
|
|
5295
4290
|
};
|
|
4291
|
+
LIFECYCLES.forEach((lifecycle) => {
|
|
4292
|
+
config[lifecycle] = function () {
|
|
4293
|
+
return safeExecute(this.$taroPath, lifecycle, ...arguments);
|
|
4294
|
+
};
|
|
4295
|
+
});
|
|
5296
4296
|
// onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
|
|
5297
4297
|
if (component.onShareAppMessage ||
|
|
5298
4298
|
((_a = component.prototype) === null || _a === void 0 ? void 0 : _a.onShareAppMessage) ||
|
|
5299
4299
|
component.enableShareAppMessage) {
|
|
5300
4300
|
config.onShareAppMessage = function (options) {
|
|
5301
4301
|
const target = options === null || options === void 0 ? void 0 : options.target;
|
|
5302
|
-
if (target
|
|
4302
|
+
if (target) {
|
|
5303
4303
|
const id = target.id;
|
|
5304
|
-
const element = document$
|
|
5305
|
-
if (element
|
|
5306
|
-
|
|
4304
|
+
const element = document$1.getElementById(id);
|
|
4305
|
+
if (element) {
|
|
4306
|
+
target.dataset = element.dataset;
|
|
5307
4307
|
}
|
|
5308
4308
|
}
|
|
5309
4309
|
return safeExecute(this.$taroPath, 'onShareAppMessage', options);
|
|
@@ -5320,13 +4320,13 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
5320
4320
|
if (!isUndefined(data)) {
|
|
5321
4321
|
config.data = data;
|
|
5322
4322
|
}
|
|
5323
|
-
if (
|
|
4323
|
+
if (process.env.TARO_ENV === 'h5') {
|
|
5324
4324
|
config.path = id;
|
|
5325
4325
|
}
|
|
4326
|
+
(_c = hooks.modifyPageObject) === null || _c === void 0 ? void 0 : _c.call(hooks, config);
|
|
5326
4327
|
return config;
|
|
5327
4328
|
}
|
|
5328
4329
|
function createComponentConfig(component, componentName, data) {
|
|
5329
|
-
var _a, _b, _c;
|
|
5330
4330
|
const id = componentName !== null && componentName !== void 0 ? componentName : `taro_component_${pageId()}`;
|
|
5331
4331
|
let componentElement = null;
|
|
5332
4332
|
const config = {
|
|
@@ -5335,10 +4335,10 @@ function createComponentConfig(component, componentName, data) {
|
|
|
5335
4335
|
perf.start(PAGE_INIT);
|
|
5336
4336
|
const path = getPath(id, { id: ((_a = this.getPageId) === null || _a === void 0 ? void 0 : _a.call(this)) || pageId() });
|
|
5337
4337
|
Current.app.mount(component, path, () => {
|
|
5338
|
-
componentElement = document$
|
|
4338
|
+
componentElement = document$1.getElementById(path);
|
|
5339
4339
|
ensure(componentElement !== null, '没有找到组件实例。');
|
|
5340
|
-
safeExecute(path,
|
|
5341
|
-
if (
|
|
4340
|
+
safeExecute(path, ON_LOAD);
|
|
4341
|
+
if (process.env.TARO_ENV !== 'h5') {
|
|
5342
4342
|
componentElement.ctx = this;
|
|
5343
4343
|
componentElement.performUpdate(true);
|
|
5344
4344
|
}
|
|
@@ -5360,9 +4360,10 @@ function createComponentConfig(component, componentName, data) {
|
|
|
5360
4360
|
if (!isUndefined(data)) {
|
|
5361
4361
|
config.data = data;
|
|
5362
4362
|
}
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
4363
|
+
[OPTIONS, EXTERNAL_CLASSES, BEHAVIORS].forEach(key => {
|
|
4364
|
+
var _a;
|
|
4365
|
+
config[key] = (_a = component[key]) !== null && _a !== void 0 ? _a : EMPTY_OBJ;
|
|
4366
|
+
});
|
|
5366
4367
|
return config;
|
|
5367
4368
|
}
|
|
5368
4369
|
function createRecursiveComponentConfig(componentName) {
|
|
@@ -5371,7 +4372,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
5371
4372
|
i: {
|
|
5372
4373
|
type: Object,
|
|
5373
4374
|
value: {
|
|
5374
|
-
["nn" /* NodeName */]:
|
|
4375
|
+
["nn" /* NodeName */]: VIEW
|
|
5375
4376
|
}
|
|
5376
4377
|
},
|
|
5377
4378
|
l: {
|
|
@@ -5381,806 +4382,14 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
5381
4382
|
},
|
|
5382
4383
|
options: {
|
|
5383
4384
|
addGlobalClass: true,
|
|
5384
|
-
virtualHost: componentName !==
|
|
5385
|
-
},
|
|
5386
|
-
methods: {
|
|
5387
|
-
eh: eventHandler
|
|
5388
|
-
}
|
|
5389
|
-
};
|
|
5390
|
-
}
|
|
5391
|
-
|
|
5392
|
-
const hooks$3 = container.get(SERVICE_IDENTIFIER.Hooks);
|
|
5393
|
-
function isClassComponent(R, component) {
|
|
5394
|
-
var _a;
|
|
5395
|
-
return isFunction$1(component.render) ||
|
|
5396
|
-
!!((_a = component.prototype) === null || _a === void 0 ? void 0 : _a.isReactComponent) ||
|
|
5397
|
-
component.prototype instanceof R.Component; // compat for some others react-like library
|
|
5398
|
-
}
|
|
5399
|
-
// 初始值设置为 any 主要是为了过 TS 的校验
|
|
5400
|
-
let R = EMPTY_OBJ;
|
|
5401
|
-
let PageContext = EMPTY_OBJ;
|
|
5402
|
-
function connectReactPage(R, id) {
|
|
5403
|
-
const h = R.createElement;
|
|
5404
|
-
return (component) => {
|
|
5405
|
-
// eslint-disable-next-line dot-notation
|
|
5406
|
-
const isReactComponent = isClassComponent(R, component);
|
|
5407
|
-
const inject = (node) => node && injectPageInstance(node, id);
|
|
5408
|
-
const refs = isReactComponent ? { ref: inject } : {
|
|
5409
|
-
forwardedRef: inject,
|
|
5410
|
-
// 兼容 react-redux 7.20.1+
|
|
5411
|
-
reactReduxForwardedRef: inject
|
|
5412
|
-
};
|
|
5413
|
-
if (PageContext === EMPTY_OBJ) {
|
|
5414
|
-
PageContext = R.createContext('');
|
|
5415
|
-
}
|
|
5416
|
-
return class Page extends R.Component {
|
|
5417
|
-
constructor() {
|
|
5418
|
-
super(...arguments);
|
|
5419
|
-
this.state = {
|
|
5420
|
-
hasError: false
|
|
5421
|
-
};
|
|
5422
|
-
}
|
|
5423
|
-
static getDerivedStateFromError(error) {
|
|
5424
|
-
process.env.NODE_ENV !== 'production' && console.warn(error);
|
|
5425
|
-
return { hasError: true };
|
|
5426
|
-
}
|
|
5427
|
-
// React 16 uncaught error 会导致整个应用 crash,
|
|
5428
|
-
// 目前把错误缩小到页面
|
|
5429
|
-
componentDidCatch(error, info) {
|
|
5430
|
-
process.env.NODE_ENV !== 'production' && console.warn(error);
|
|
5431
|
-
process.env.NODE_ENV !== 'production' && console.error(info.componentStack);
|
|
5432
|
-
}
|
|
5433
|
-
render() {
|
|
5434
|
-
const children = this.state.hasError
|
|
5435
|
-
? []
|
|
5436
|
-
: h(PageContext.Provider, { value: id }, h(component, Object.assign(Object.assign({}, this.props), refs)));
|
|
5437
|
-
if (isBrowser) {
|
|
5438
|
-
return h('div', { id, className: 'taro_page' }, children);
|
|
5439
|
-
}
|
|
5440
|
-
return h('root', { id }, children);
|
|
5441
|
-
}
|
|
5442
|
-
};
|
|
5443
|
-
};
|
|
5444
|
-
}
|
|
5445
|
-
let ReactDOM;
|
|
5446
|
-
function setReconciler() {
|
|
5447
|
-
const getLifecycle = function (instance, lifecycle) {
|
|
5448
|
-
lifecycle = lifecycle.replace(/^on(Show|Hide)$/, 'componentDid$1');
|
|
5449
|
-
return instance[lifecycle];
|
|
5450
|
-
};
|
|
5451
|
-
const modifyMpEvent = function (event) {
|
|
5452
|
-
event.type = event.type.replace(/-/g, '');
|
|
5453
|
-
};
|
|
5454
|
-
const batchedEventUpdates = function (cb) {
|
|
5455
|
-
ReactDOM.unstable_batchedUpdates(cb);
|
|
5456
|
-
};
|
|
5457
|
-
const mergePageInstance = function (prev, next) {
|
|
5458
|
-
if (!prev || !next)
|
|
5459
|
-
return;
|
|
5460
|
-
// 子组件使用 lifecycle hooks 注册了生命周期后,会存在 prev,里面是注册的生命周期回调。
|
|
5461
|
-
// prev 使用 Object.create(null) 创建,H5 的 fast-refresh 可能也会导致存在 prev,要排除这些意外产生的 prev
|
|
5462
|
-
if ('constructor' in prev)
|
|
5463
|
-
return;
|
|
5464
|
-
Object.keys(prev).forEach(item => {
|
|
5465
|
-
if (isFunction$1(next[item])) {
|
|
5466
|
-
next[item] = [next[item], ...prev[item]];
|
|
5467
|
-
}
|
|
5468
|
-
else {
|
|
5469
|
-
next[item] = [...(next[item] || []), ...prev[item]];
|
|
5470
|
-
}
|
|
5471
|
-
});
|
|
5472
|
-
};
|
|
5473
|
-
hooks$3.getLifecycle = getLifecycle;
|
|
5474
|
-
hooks$3.modifyMpEvent = modifyMpEvent;
|
|
5475
|
-
hooks$3.batchedEventUpdates = batchedEventUpdates;
|
|
5476
|
-
hooks$3.mergePageInstance = mergePageInstance;
|
|
5477
|
-
if (process.env.TARO_ENV === 'h5') {
|
|
5478
|
-
hooks$3.createPullDownComponent = (el, _, R, customWrapper) => {
|
|
5479
|
-
const isReactComponent = isClassComponent(R, el);
|
|
5480
|
-
return R.forwardRef((props, ref) => {
|
|
5481
|
-
const newProps = Object.assign({}, props);
|
|
5482
|
-
const refs = isReactComponent ? { ref: ref } : {
|
|
5483
|
-
forwardedRef: ref,
|
|
5484
|
-
// 兼容 react-redux 7.20.1+
|
|
5485
|
-
reactReduxForwardedRef: ref
|
|
5486
|
-
};
|
|
5487
|
-
return R.createElement(customWrapper || 'taro-pull-to-refresh', null, R.createElement(el, Object.assign(Object.assign({}, newProps), refs)));
|
|
5488
|
-
});
|
|
5489
|
-
};
|
|
5490
|
-
hooks$3.getDOMNode = (inst) => {
|
|
5491
|
-
return ReactDOM.findDOMNode(inst);
|
|
5492
|
-
};
|
|
5493
|
-
}
|
|
5494
|
-
}
|
|
5495
|
-
const pageKeyId = incrementId();
|
|
5496
|
-
function createReactApp(App, react, reactdom, config) {
|
|
5497
|
-
R = react;
|
|
5498
|
-
ReactDOM = reactdom;
|
|
5499
|
-
ensure(!!ReactDOM, '构建 React/Nerv 项目请把 process.env.FRAMEWORK 设置为 \'react\'/\'nerv\' ');
|
|
5500
|
-
const ref = R.createRef();
|
|
5501
|
-
const isReactComponent = isClassComponent(R, App);
|
|
5502
|
-
setReconciler();
|
|
5503
|
-
class AppWrapper extends R.Component {
|
|
5504
|
-
constructor() {
|
|
5505
|
-
super(...arguments);
|
|
5506
|
-
// run createElement() inside the render function to make sure that owner is right
|
|
5507
|
-
this.pages = [];
|
|
5508
|
-
this.elements = [];
|
|
5509
|
-
}
|
|
5510
|
-
mount(component, id, cb) {
|
|
5511
|
-
const key = id + pageKeyId();
|
|
5512
|
-
const page = () => R.createElement(component, { key, tid: id });
|
|
5513
|
-
this.pages.push(page);
|
|
5514
|
-
this.forceUpdate(cb);
|
|
5515
|
-
}
|
|
5516
|
-
unmount(id, cb) {
|
|
5517
|
-
for (let i = 0; i < this.elements.length; i++) {
|
|
5518
|
-
const element = this.elements[i];
|
|
5519
|
-
if (element.props.tid === id) {
|
|
5520
|
-
this.elements.splice(i, 1);
|
|
5521
|
-
break;
|
|
5522
|
-
}
|
|
5523
|
-
}
|
|
5524
|
-
this.forceUpdate(cb);
|
|
5525
|
-
}
|
|
5526
|
-
render() {
|
|
5527
|
-
while (this.pages.length > 0) {
|
|
5528
|
-
const page = this.pages.pop();
|
|
5529
|
-
this.elements.push(page());
|
|
5530
|
-
}
|
|
5531
|
-
let props = null;
|
|
5532
|
-
if (isReactComponent) {
|
|
5533
|
-
props = { ref };
|
|
5534
|
-
}
|
|
5535
|
-
return R.createElement(App, props, isBrowser ? R.createElement('div', null, this.elements.slice()) : this.elements.slice());
|
|
5536
|
-
}
|
|
5537
|
-
}
|
|
5538
|
-
let wrapper;
|
|
5539
|
-
if (!isBrowser) {
|
|
5540
|
-
// eslint-disable-next-line react/no-render-return-value
|
|
5541
|
-
wrapper = ReactDOM.render(R.createElement(AppWrapper), document$2.getElementById('app'));
|
|
5542
|
-
}
|
|
5543
|
-
const app = Object.create({
|
|
5544
|
-
render(cb) {
|
|
5545
|
-
wrapper.forceUpdate(cb);
|
|
5546
|
-
},
|
|
5547
|
-
mount(component, id, cb) {
|
|
5548
|
-
const page = connectReactPage(R, id)(component);
|
|
5549
|
-
wrapper.mount(page, id, cb);
|
|
5550
|
-
},
|
|
5551
|
-
unmount(id, cb) {
|
|
5552
|
-
wrapper.unmount(id, cb);
|
|
5553
|
-
}
|
|
5554
|
-
}, {
|
|
5555
|
-
config: {
|
|
5556
|
-
writable: true,
|
|
5557
|
-
enumerable: true,
|
|
5558
|
-
configurable: true,
|
|
5559
|
-
value: config
|
|
5560
|
-
},
|
|
5561
|
-
onLaunch: {
|
|
5562
|
-
enumerable: true,
|
|
5563
|
-
writable: true,
|
|
5564
|
-
value(options) {
|
|
5565
|
-
Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
|
|
5566
|
-
if (isBrowser) {
|
|
5567
|
-
// 由于 H5 路由初始化的时候会清除 app 下的 dom 元素,所以需要在路由初始化后执行 render
|
|
5568
|
-
// eslint-disable-next-line react/no-render-return-value
|
|
5569
|
-
wrapper = ReactDOM.render(R.createElement(AppWrapper), document$2.getElementById('app'));
|
|
5570
|
-
}
|
|
5571
|
-
const app = ref.current;
|
|
5572
|
-
// For taroize
|
|
5573
|
-
// 把 App Class 上挂载的额外属性同步到全局 app 对象中
|
|
5574
|
-
if (app === null || app === void 0 ? void 0 : app.taroGlobalData) {
|
|
5575
|
-
const globalData = app.taroGlobalData;
|
|
5576
|
-
const keys = Object.keys(globalData);
|
|
5577
|
-
const descriptors = Object.getOwnPropertyDescriptors(globalData);
|
|
5578
|
-
keys.forEach(key => {
|
|
5579
|
-
Object.defineProperty(this, key, {
|
|
5580
|
-
configurable: true,
|
|
5581
|
-
enumerable: true,
|
|
5582
|
-
get() {
|
|
5583
|
-
return globalData[key];
|
|
5584
|
-
},
|
|
5585
|
-
set(value) {
|
|
5586
|
-
globalData[key] = value;
|
|
5587
|
-
}
|
|
5588
|
-
});
|
|
5589
|
-
});
|
|
5590
|
-
Object.defineProperties(this, descriptors);
|
|
5591
|
-
}
|
|
5592
|
-
this.$app = app;
|
|
5593
|
-
if (app != null && isFunction$1(app.onLaunch)) {
|
|
5594
|
-
app.onLaunch(options);
|
|
5595
|
-
}
|
|
5596
|
-
}
|
|
5597
|
-
},
|
|
5598
|
-
onShow: {
|
|
5599
|
-
enumerable: true,
|
|
5600
|
-
writable: true,
|
|
5601
|
-
value(options) {
|
|
5602
|
-
const app = ref.current;
|
|
5603
|
-
Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
|
|
5604
|
-
if (app != null && isFunction$1(app.componentDidShow)) {
|
|
5605
|
-
app.componentDidShow(options);
|
|
5606
|
-
}
|
|
5607
|
-
// app useDidShow
|
|
5608
|
-
triggerAppHook('onShow');
|
|
5609
|
-
}
|
|
5610
|
-
},
|
|
5611
|
-
onHide: {
|
|
5612
|
-
enumerable: true,
|
|
5613
|
-
writable: true,
|
|
5614
|
-
value(options) {
|
|
5615
|
-
const app = ref.current;
|
|
5616
|
-
if (app != null && isFunction$1(app.componentDidHide)) {
|
|
5617
|
-
app.componentDidHide(options);
|
|
5618
|
-
}
|
|
5619
|
-
// app useDidHide
|
|
5620
|
-
triggerAppHook('onHide');
|
|
5621
|
-
}
|
|
5622
|
-
},
|
|
5623
|
-
onPageNotFound: {
|
|
5624
|
-
enumerable: true,
|
|
5625
|
-
writable: true,
|
|
5626
|
-
value(res) {
|
|
5627
|
-
const app = ref.current;
|
|
5628
|
-
if (app != null && isFunction$1(app.onPageNotFound)) {
|
|
5629
|
-
app.onPageNotFound(res);
|
|
5630
|
-
}
|
|
5631
|
-
}
|
|
5632
|
-
}
|
|
5633
|
-
});
|
|
5634
|
-
function triggerAppHook(lifecycle) {
|
|
5635
|
-
const instance = getPageInstance(HOOKS_APP_ID);
|
|
5636
|
-
if (instance) {
|
|
5637
|
-
const app = ref.current;
|
|
5638
|
-
const func = hooks$3.getLifecycle(instance, lifecycle);
|
|
5639
|
-
if (Array.isArray(func)) {
|
|
5640
|
-
func.forEach(cb => cb.apply(app));
|
|
5641
|
-
}
|
|
5642
|
-
}
|
|
5643
|
-
}
|
|
5644
|
-
Current.app = app;
|
|
5645
|
-
return Current.app;
|
|
5646
|
-
}
|
|
5647
|
-
const getNativeCompId = incrementId();
|
|
5648
|
-
function initNativeComponentEntry(R, ReactDOM) {
|
|
5649
|
-
class NativeComponentWrapper extends R.Component {
|
|
5650
|
-
constructor() {
|
|
5651
|
-
super(...arguments);
|
|
5652
|
-
this.root = R.createRef();
|
|
5653
|
-
this.ctx = this.props.getCtx();
|
|
5654
|
-
}
|
|
5655
|
-
componentDidMount() {
|
|
5656
|
-
this.ctx.component = this;
|
|
5657
|
-
const rootElement = this.root.current;
|
|
5658
|
-
rootElement.ctx = this.ctx;
|
|
5659
|
-
rootElement.performUpdate(true);
|
|
5660
|
-
}
|
|
5661
|
-
render() {
|
|
5662
|
-
return (R.createElement('root', {
|
|
5663
|
-
ref: this.root
|
|
5664
|
-
}, this.props.renderComponent(this.ctx)));
|
|
5665
|
-
}
|
|
5666
|
-
}
|
|
5667
|
-
class Entry extends R.Component {
|
|
5668
|
-
constructor() {
|
|
5669
|
-
super(...arguments);
|
|
5670
|
-
this.state = {
|
|
5671
|
-
components: []
|
|
5672
|
-
};
|
|
5673
|
-
}
|
|
5674
|
-
componentDidMount() {
|
|
5675
|
-
Current.app = this;
|
|
5676
|
-
}
|
|
5677
|
-
mount(Component, compId, getCtx) {
|
|
5678
|
-
const isReactComponent = isClassComponent(R, Component);
|
|
5679
|
-
const inject = (node) => node && injectPageInstance(node, compId);
|
|
5680
|
-
const refs = isReactComponent ? { ref: inject } : {
|
|
5681
|
-
forwardedRef: inject,
|
|
5682
|
-
reactReduxForwardedRef: inject
|
|
5683
|
-
};
|
|
5684
|
-
const item = {
|
|
5685
|
-
compId,
|
|
5686
|
-
element: R.createElement(NativeComponentWrapper, {
|
|
5687
|
-
key: compId,
|
|
5688
|
-
getCtx,
|
|
5689
|
-
renderComponent(ctx) {
|
|
5690
|
-
return R.createElement(Component, Object.assign(Object.assign({}, (ctx.data || (ctx.data = {})).props), refs));
|
|
5691
|
-
}
|
|
5692
|
-
})
|
|
5693
|
-
};
|
|
5694
|
-
this.setState({
|
|
5695
|
-
components: [...this.state.components, item]
|
|
5696
|
-
});
|
|
5697
|
-
}
|
|
5698
|
-
unmount(compId) {
|
|
5699
|
-
const components = this.state.components;
|
|
5700
|
-
const index = components.findIndex(item => item.compId === compId);
|
|
5701
|
-
const next = [...components.slice(0, index), ...components.slice(index + 1)];
|
|
5702
|
-
this.setState({
|
|
5703
|
-
components: next
|
|
5704
|
-
});
|
|
5705
|
-
}
|
|
5706
|
-
render() {
|
|
5707
|
-
const components = this.state.components;
|
|
5708
|
-
return (components.map(({ element }) => element));
|
|
5709
|
-
}
|
|
5710
|
-
}
|
|
5711
|
-
setReconciler();
|
|
5712
|
-
const app = document$2.getElementById('app');
|
|
5713
|
-
ReactDOM.render(R.createElement(Entry, {}), app);
|
|
5714
|
-
}
|
|
5715
|
-
function createNativeComponentConfig(Component, react, reactdom, componentConfig) {
|
|
5716
|
-
R = react;
|
|
5717
|
-
ReactDOM = reactdom;
|
|
5718
|
-
setReconciler();
|
|
5719
|
-
const config = {
|
|
5720
|
-
properties: {
|
|
5721
|
-
props: {
|
|
5722
|
-
type: null,
|
|
5723
|
-
value: null,
|
|
5724
|
-
observer(_newVal, oldVal) {
|
|
5725
|
-
oldVal && this.component.forceUpdate();
|
|
5726
|
-
}
|
|
5727
|
-
}
|
|
5728
|
-
},
|
|
5729
|
-
created() {
|
|
5730
|
-
if (!Current.app) {
|
|
5731
|
-
initNativeComponentEntry(R, ReactDOM);
|
|
5732
|
-
}
|
|
5733
|
-
},
|
|
5734
|
-
attached() {
|
|
5735
|
-
setCurrent();
|
|
5736
|
-
this.compId = getNativeCompId();
|
|
5737
|
-
this.config = componentConfig;
|
|
5738
|
-
Current.app.mount(Component, this.compId, () => this);
|
|
5739
|
-
},
|
|
5740
|
-
ready() {
|
|
5741
|
-
safeExecute(this.compId, 'onReady');
|
|
5742
|
-
},
|
|
5743
|
-
detached() {
|
|
5744
|
-
Current.app.unmount(this.compId);
|
|
5745
|
-
},
|
|
5746
|
-
pageLifetimes: {
|
|
5747
|
-
show() {
|
|
5748
|
-
safeExecute(this.compId, 'onShow');
|
|
5749
|
-
},
|
|
5750
|
-
hide() {
|
|
5751
|
-
safeExecute(this.compId, 'onHide');
|
|
5752
|
-
}
|
|
4385
|
+
virtualHost: componentName !== CUSTOM_WRAPPER
|
|
5753
4386
|
},
|
|
5754
4387
|
methods: {
|
|
5755
4388
|
eh: eventHandler
|
|
5756
4389
|
}
|
|
5757
4390
|
};
|
|
5758
|
-
function setCurrent() {
|
|
5759
|
-
const pages = getCurrentPages();
|
|
5760
|
-
const currentPage = pages[pages.length - 1];
|
|
5761
|
-
if (Current.page === currentPage)
|
|
5762
|
-
return;
|
|
5763
|
-
Current.page = currentPage;
|
|
5764
|
-
const route = currentPage.route || currentPage.__route__;
|
|
5765
|
-
const router = {
|
|
5766
|
-
params: currentPage.options || {},
|
|
5767
|
-
path: addLeadingSlash(route),
|
|
5768
|
-
onReady: '',
|
|
5769
|
-
onHide: '',
|
|
5770
|
-
onShow: ''
|
|
5771
|
-
};
|
|
5772
|
-
Current.router = router;
|
|
5773
|
-
if (!currentPage.options) {
|
|
5774
|
-
// 例如在微信小程序中,页面 options 的设置时机比组件 attached 慢
|
|
5775
|
-
Object.defineProperty(currentPage, 'options', {
|
|
5776
|
-
enumerable: true,
|
|
5777
|
-
configurable: true,
|
|
5778
|
-
get() {
|
|
5779
|
-
return this._optionsValue;
|
|
5780
|
-
},
|
|
5781
|
-
set(value) {
|
|
5782
|
-
router.params = value;
|
|
5783
|
-
this._optionsValue = value;
|
|
5784
|
-
}
|
|
5785
|
-
});
|
|
5786
|
-
}
|
|
5787
|
-
}
|
|
5788
|
-
return config;
|
|
5789
4391
|
}
|
|
5790
4392
|
|
|
5791
|
-
function connectVuePage(Vue, id) {
|
|
5792
|
-
return (component) => {
|
|
5793
|
-
const injectedPage = Vue.extend({
|
|
5794
|
-
props: {
|
|
5795
|
-
tid: String
|
|
5796
|
-
},
|
|
5797
|
-
mixins: [component, {
|
|
5798
|
-
created() {
|
|
5799
|
-
injectPageInstance(this, id);
|
|
5800
|
-
}
|
|
5801
|
-
}]
|
|
5802
|
-
});
|
|
5803
|
-
const options = {
|
|
5804
|
-
render(h) {
|
|
5805
|
-
return h(isBrowser ? 'div' : 'root', {
|
|
5806
|
-
attrs: {
|
|
5807
|
-
id,
|
|
5808
|
-
class: isBrowser ? 'taro_page' : ''
|
|
5809
|
-
}
|
|
5810
|
-
}, [
|
|
5811
|
-
h(injectedPage, { props: { tid: id } })
|
|
5812
|
-
]);
|
|
5813
|
-
}
|
|
5814
|
-
};
|
|
5815
|
-
return options;
|
|
5816
|
-
};
|
|
5817
|
-
}
|
|
5818
|
-
function setReconciler$1() {
|
|
5819
|
-
const hooks = container.get(SERVICE_IDENTIFIER.Hooks);
|
|
5820
|
-
const onRemoveAttribute = function (dom, qualifiedName) {
|
|
5821
|
-
// 处理原因: https://github.com/NervJS/taro/pull/5990
|
|
5822
|
-
const props = dom.props;
|
|
5823
|
-
if (!props.hasOwnProperty(qualifiedName) || isBoolean(props[qualifiedName])) {
|
|
5824
|
-
dom.setAttribute(qualifiedName, false);
|
|
5825
|
-
return true;
|
|
5826
|
-
}
|
|
5827
|
-
};
|
|
5828
|
-
const getLifecycle = function (instance, lifecycle) {
|
|
5829
|
-
return instance.$options[lifecycle];
|
|
5830
|
-
};
|
|
5831
|
-
hooks.onRemoveAttribute = onRemoveAttribute;
|
|
5832
|
-
hooks.getLifecycle = getLifecycle;
|
|
5833
|
-
if (process.env.TARO_ENV === 'h5') {
|
|
5834
|
-
hooks.createPullDownComponent = (el, path, vue) => {
|
|
5835
|
-
const injectedPage = vue.extend({
|
|
5836
|
-
props: {
|
|
5837
|
-
tid: String
|
|
5838
|
-
},
|
|
5839
|
-
mixins: [el, {
|
|
5840
|
-
created() {
|
|
5841
|
-
injectPageInstance(this, path);
|
|
5842
|
-
}
|
|
5843
|
-
}]
|
|
5844
|
-
});
|
|
5845
|
-
const options = {
|
|
5846
|
-
name: 'PullToRefresh',
|
|
5847
|
-
render(h) {
|
|
5848
|
-
return h('taro-pull-to-refresh', {
|
|
5849
|
-
class: ['hydrated']
|
|
5850
|
-
}, [h(injectedPage, this.$slots.default)]);
|
|
5851
|
-
}
|
|
5852
|
-
};
|
|
5853
|
-
return options;
|
|
5854
|
-
};
|
|
5855
|
-
hooks.getDOMNode = (el) => {
|
|
5856
|
-
return el.$el;
|
|
5857
|
-
};
|
|
5858
|
-
}
|
|
5859
|
-
}
|
|
5860
|
-
let Vue;
|
|
5861
|
-
function createVueApp(App, vue, config) {
|
|
5862
|
-
Vue = vue;
|
|
5863
|
-
ensure(!!Vue, '构建 Vue 项目请把 process.env.FRAMEWORK 设置为 \'vue\'');
|
|
5864
|
-
setReconciler$1();
|
|
5865
|
-
Vue.config.getTagNamespace = noop;
|
|
5866
|
-
const elements = [];
|
|
5867
|
-
const pages = [];
|
|
5868
|
-
let appInstance;
|
|
5869
|
-
const wrapper = new Vue({
|
|
5870
|
-
render(h) {
|
|
5871
|
-
while (pages.length > 0) {
|
|
5872
|
-
const page = pages.pop();
|
|
5873
|
-
elements.push(page(h));
|
|
5874
|
-
}
|
|
5875
|
-
return h(App, { ref: 'app' }, elements.slice());
|
|
5876
|
-
},
|
|
5877
|
-
methods: {
|
|
5878
|
-
mount(component, id, cb) {
|
|
5879
|
-
pages.push((h) => h(component, { key: id }));
|
|
5880
|
-
this.updateSync(cb);
|
|
5881
|
-
},
|
|
5882
|
-
updateSync(cb) {
|
|
5883
|
-
this._update(this._render(), false);
|
|
5884
|
-
this.$children.forEach((child) => child._update(child._render(), false));
|
|
5885
|
-
cb();
|
|
5886
|
-
},
|
|
5887
|
-
unmount(id, cb) {
|
|
5888
|
-
for (let i = 0; i < elements.length; i++) {
|
|
5889
|
-
const element = elements[i];
|
|
5890
|
-
if (element.key === id) {
|
|
5891
|
-
elements.splice(i, 1);
|
|
5892
|
-
break;
|
|
5893
|
-
}
|
|
5894
|
-
}
|
|
5895
|
-
this.updateSync(cb);
|
|
5896
|
-
}
|
|
5897
|
-
}
|
|
5898
|
-
});
|
|
5899
|
-
if (!isBrowser) {
|
|
5900
|
-
wrapper.$mount(document$2.getElementById('app'));
|
|
5901
|
-
}
|
|
5902
|
-
const app = Object.create({
|
|
5903
|
-
mount(component, id, cb) {
|
|
5904
|
-
const page = connectVuePage(Vue, id)(component);
|
|
5905
|
-
wrapper.mount(page, id, cb);
|
|
5906
|
-
},
|
|
5907
|
-
unmount(id, cb) {
|
|
5908
|
-
wrapper.unmount(id, cb);
|
|
5909
|
-
}
|
|
5910
|
-
}, {
|
|
5911
|
-
config: {
|
|
5912
|
-
writable: true,
|
|
5913
|
-
enumerable: true,
|
|
5914
|
-
configurable: true,
|
|
5915
|
-
value: config
|
|
5916
|
-
},
|
|
5917
|
-
onLaunch: {
|
|
5918
|
-
writable: true,
|
|
5919
|
-
enumerable: true,
|
|
5920
|
-
value(options) {
|
|
5921
|
-
Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
|
|
5922
|
-
if (isBrowser) {
|
|
5923
|
-
// 由于 H5 路由初始化的时候会清除 app 下的 dom 元素,所以需要在路由初始化后再执行 render
|
|
5924
|
-
wrapper.$mount(document$2.getElementById('app'));
|
|
5925
|
-
}
|
|
5926
|
-
appInstance = wrapper.$refs.app;
|
|
5927
|
-
if (appInstance != null && isFunction$1(appInstance.$options.onLaunch)) {
|
|
5928
|
-
appInstance.$options.onLaunch.call(appInstance, options);
|
|
5929
|
-
}
|
|
5930
|
-
}
|
|
5931
|
-
},
|
|
5932
|
-
onShow: {
|
|
5933
|
-
writable: true,
|
|
5934
|
-
enumerable: true,
|
|
5935
|
-
value(options) {
|
|
5936
|
-
Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
|
|
5937
|
-
if (appInstance != null && isFunction$1(appInstance.$options.onShow)) {
|
|
5938
|
-
appInstance.$options.onShow.call(appInstance, options);
|
|
5939
|
-
}
|
|
5940
|
-
}
|
|
5941
|
-
},
|
|
5942
|
-
onHide: {
|
|
5943
|
-
writable: true,
|
|
5944
|
-
enumerable: true,
|
|
5945
|
-
value(options) {
|
|
5946
|
-
if (appInstance != null && isFunction$1(appInstance.$options.onHide)) {
|
|
5947
|
-
appInstance.$options.onHide.call(appInstance, options);
|
|
5948
|
-
}
|
|
5949
|
-
}
|
|
5950
|
-
}
|
|
5951
|
-
});
|
|
5952
|
-
Current.app = app;
|
|
5953
|
-
return Current.app;
|
|
5954
|
-
}
|
|
5955
|
-
|
|
5956
|
-
function createVue3Page(h, id) {
|
|
5957
|
-
return function (component) {
|
|
5958
|
-
var _a;
|
|
5959
|
-
const inject = {
|
|
5960
|
-
props: {
|
|
5961
|
-
tid: String
|
|
5962
|
-
},
|
|
5963
|
-
created() {
|
|
5964
|
-
injectPageInstance(this, id);
|
|
5965
|
-
// vue3 组件 created 时机比小程序页面 onShow 慢,因此在 created 后再手动触发一次 onShow。
|
|
5966
|
-
this.$nextTick(() => {
|
|
5967
|
-
safeExecute(id, 'onShow');
|
|
5968
|
-
});
|
|
5969
|
-
}
|
|
5970
|
-
};
|
|
5971
|
-
if (isArray$1(component.mixins)) {
|
|
5972
|
-
const mixins = component.mixins;
|
|
5973
|
-
const idx = mixins.length - 1;
|
|
5974
|
-
if (!((_a = mixins[idx].props) === null || _a === void 0 ? void 0 : _a.tid)) {
|
|
5975
|
-
// mixins 里还没注入过,直接推入数组
|
|
5976
|
-
component.mixins.push(inject);
|
|
5977
|
-
}
|
|
5978
|
-
else {
|
|
5979
|
-
// mixins 里已经注入过,代替前者
|
|
5980
|
-
component.mixins[idx] = inject;
|
|
5981
|
-
}
|
|
5982
|
-
}
|
|
5983
|
-
else {
|
|
5984
|
-
component.mixins = [inject];
|
|
5985
|
-
}
|
|
5986
|
-
return h(isBrowser ? 'div' : 'root', {
|
|
5987
|
-
key: id,
|
|
5988
|
-
id,
|
|
5989
|
-
class: isBrowser ? 'taro_page' : ''
|
|
5990
|
-
}, [
|
|
5991
|
-
h(Object.assign({}, component), {
|
|
5992
|
-
tid: id
|
|
5993
|
-
})
|
|
5994
|
-
]);
|
|
5995
|
-
};
|
|
5996
|
-
}
|
|
5997
|
-
function setReconciler$2() {
|
|
5998
|
-
const hooks = container.get(SERVICE_IDENTIFIER.Hooks);
|
|
5999
|
-
const getLifecycle = function (instance, lifecycle) {
|
|
6000
|
-
return instance.$options[lifecycle];
|
|
6001
|
-
};
|
|
6002
|
-
const modifyMpEvent = function (event) {
|
|
6003
|
-
event.type = event.type.replace(/-/g, '');
|
|
6004
|
-
};
|
|
6005
|
-
hooks.getLifecycle = getLifecycle;
|
|
6006
|
-
hooks.modifyMpEvent = modifyMpEvent;
|
|
6007
|
-
if (process.env.TARO_ENV === 'h5') {
|
|
6008
|
-
hooks.createPullDownComponent = (component, path, h) => {
|
|
6009
|
-
const inject = {
|
|
6010
|
-
props: {
|
|
6011
|
-
tid: String
|
|
6012
|
-
},
|
|
6013
|
-
created() {
|
|
6014
|
-
injectPageInstance(this, path);
|
|
6015
|
-
}
|
|
6016
|
-
};
|
|
6017
|
-
component.mixins = isArray$1(component.mixins)
|
|
6018
|
-
? component.mixins.push(inject)
|
|
6019
|
-
: [inject];
|
|
6020
|
-
return {
|
|
6021
|
-
render() {
|
|
6022
|
-
return h('taro-pull-to-refresh', {
|
|
6023
|
-
class: 'hydrated'
|
|
6024
|
-
}, [h(component, this.$slots.default)]);
|
|
6025
|
-
}
|
|
6026
|
-
};
|
|
6027
|
-
};
|
|
6028
|
-
hooks.getDOMNode = (el) => {
|
|
6029
|
-
return el.$el;
|
|
6030
|
-
};
|
|
6031
|
-
}
|
|
6032
|
-
}
|
|
6033
|
-
function createVue3App(app, h, config) {
|
|
6034
|
-
let pages = [];
|
|
6035
|
-
let appInstance;
|
|
6036
|
-
ensure(!isFunction$1(app._component), '入口组件不支持使用函数式组件');
|
|
6037
|
-
setReconciler$2();
|
|
6038
|
-
app._component.render = function () {
|
|
6039
|
-
return pages.slice();
|
|
6040
|
-
};
|
|
6041
|
-
if (!isBrowser) {
|
|
6042
|
-
appInstance = app.mount('#app');
|
|
6043
|
-
}
|
|
6044
|
-
const appConfig = Object.create({
|
|
6045
|
-
mount(component, id, cb) {
|
|
6046
|
-
const page = createVue3Page(h, id)(component);
|
|
6047
|
-
pages.push(page);
|
|
6048
|
-
this.updateAppInstance(cb);
|
|
6049
|
-
},
|
|
6050
|
-
unmount(id, cb) {
|
|
6051
|
-
pages = pages.filter(page => page.key !== id);
|
|
6052
|
-
this.updateAppInstance(cb);
|
|
6053
|
-
},
|
|
6054
|
-
updateAppInstance(cb) {
|
|
6055
|
-
appInstance.$forceUpdate();
|
|
6056
|
-
appInstance.$nextTick(cb);
|
|
6057
|
-
}
|
|
6058
|
-
}, {
|
|
6059
|
-
config: {
|
|
6060
|
-
writable: true,
|
|
6061
|
-
enumerable: true,
|
|
6062
|
-
configurable: true,
|
|
6063
|
-
value: config
|
|
6064
|
-
},
|
|
6065
|
-
onLaunch: {
|
|
6066
|
-
writable: true,
|
|
6067
|
-
enumerable: true,
|
|
6068
|
-
value(options) {
|
|
6069
|
-
var _a;
|
|
6070
|
-
Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
|
|
6071
|
-
if (isBrowser) {
|
|
6072
|
-
appInstance = app.mount('#app');
|
|
6073
|
-
}
|
|
6074
|
-
// 把 App Class 上挂载的额外属性同步到全局 app 对象中
|
|
6075
|
-
// eslint-disable-next-line dot-notation
|
|
6076
|
-
if (app['taroGlobalData']) {
|
|
6077
|
-
// eslint-disable-next-line dot-notation
|
|
6078
|
-
const globalData = app['taroGlobalData'];
|
|
6079
|
-
const keys = Object.keys(globalData);
|
|
6080
|
-
const descriptors = Object.getOwnPropertyDescriptors(globalData);
|
|
6081
|
-
keys.forEach(key => {
|
|
6082
|
-
Object.defineProperty(this, key, {
|
|
6083
|
-
configurable: true,
|
|
6084
|
-
enumerable: true,
|
|
6085
|
-
get() {
|
|
6086
|
-
return globalData[key];
|
|
6087
|
-
},
|
|
6088
|
-
set(value) {
|
|
6089
|
-
globalData[key] = value;
|
|
6090
|
-
}
|
|
6091
|
-
});
|
|
6092
|
-
});
|
|
6093
|
-
Object.defineProperties(this, descriptors);
|
|
6094
|
-
}
|
|
6095
|
-
const onLaunch = (_a = appInstance === null || appInstance === void 0 ? void 0 : appInstance.$options) === null || _a === void 0 ? void 0 : _a.onLaunch;
|
|
6096
|
-
isFunction$1(onLaunch) && onLaunch.call(appInstance, options);
|
|
6097
|
-
}
|
|
6098
|
-
},
|
|
6099
|
-
onShow: {
|
|
6100
|
-
writable: true,
|
|
6101
|
-
enumerable: true,
|
|
6102
|
-
value(options) {
|
|
6103
|
-
var _a;
|
|
6104
|
-
Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
|
|
6105
|
-
const onShow = (_a = appInstance === null || appInstance === void 0 ? void 0 : appInstance.$options) === null || _a === void 0 ? void 0 : _a.onShow;
|
|
6106
|
-
isFunction$1(onShow) && onShow.call(appInstance, options);
|
|
6107
|
-
}
|
|
6108
|
-
},
|
|
6109
|
-
onHide: {
|
|
6110
|
-
writable: true,
|
|
6111
|
-
enumerable: true,
|
|
6112
|
-
value(options) {
|
|
6113
|
-
var _a;
|
|
6114
|
-
const onHide = (_a = appInstance === null || appInstance === void 0 ? void 0 : appInstance.$options) === null || _a === void 0 ? void 0 : _a.onHide;
|
|
6115
|
-
isFunction$1(onHide) && onHide.call(appInstance, options);
|
|
6116
|
-
}
|
|
6117
|
-
}
|
|
6118
|
-
});
|
|
6119
|
-
Current.app = appConfig;
|
|
6120
|
-
return Current.app;
|
|
6121
|
-
}
|
|
6122
|
-
|
|
6123
|
-
const taroHooks = (lifecycle) => {
|
|
6124
|
-
return (fn) => {
|
|
6125
|
-
const id = R.useContext(PageContext) || HOOKS_APP_ID;
|
|
6126
|
-
// hold fn ref and keep up to date
|
|
6127
|
-
const fnRef = R.useRef(fn);
|
|
6128
|
-
if (fnRef.current !== fn)
|
|
6129
|
-
fnRef.current = fn;
|
|
6130
|
-
R.useLayoutEffect(() => {
|
|
6131
|
-
let inst = getPageInstance(id);
|
|
6132
|
-
let first = false;
|
|
6133
|
-
if (inst == null) {
|
|
6134
|
-
first = true;
|
|
6135
|
-
inst = Object.create(null);
|
|
6136
|
-
}
|
|
6137
|
-
inst = inst;
|
|
6138
|
-
// callback is immutable but inner function is up to date
|
|
6139
|
-
const callback = (...args) => fnRef.current(...args);
|
|
6140
|
-
if (isFunction$1(inst[lifecycle])) {
|
|
6141
|
-
inst[lifecycle] = [inst[lifecycle], callback];
|
|
6142
|
-
}
|
|
6143
|
-
else {
|
|
6144
|
-
inst[lifecycle] = [
|
|
6145
|
-
...(inst[lifecycle] || []),
|
|
6146
|
-
callback
|
|
6147
|
-
];
|
|
6148
|
-
}
|
|
6149
|
-
if (first) {
|
|
6150
|
-
injectPageInstance(inst, id);
|
|
6151
|
-
}
|
|
6152
|
-
return () => {
|
|
6153
|
-
const inst = getPageInstance(id);
|
|
6154
|
-
const list = inst[lifecycle];
|
|
6155
|
-
if (list === callback) {
|
|
6156
|
-
inst[lifecycle] = undefined;
|
|
6157
|
-
}
|
|
6158
|
-
else if (isArray$1(list)) {
|
|
6159
|
-
inst[lifecycle] = list.filter(item => item !== callback);
|
|
6160
|
-
}
|
|
6161
|
-
};
|
|
6162
|
-
}, []);
|
|
6163
|
-
};
|
|
6164
|
-
};
|
|
6165
|
-
const useDidShow = taroHooks('componentDidShow');
|
|
6166
|
-
const useDidHide = taroHooks('componentDidHide');
|
|
6167
|
-
const usePullDownRefresh = taroHooks('onPullDownRefresh');
|
|
6168
|
-
const useReachBottom = taroHooks('onReachBottom');
|
|
6169
|
-
const usePageScroll = taroHooks('onPageScroll');
|
|
6170
|
-
const useResize = taroHooks('onResize');
|
|
6171
|
-
const useShareAppMessage = taroHooks('onShareAppMessage');
|
|
6172
|
-
const useTabItemTap = taroHooks('onTabItemTap');
|
|
6173
|
-
const useTitleClick = taroHooks('onTitleClick');
|
|
6174
|
-
const useOptionMenuClick = taroHooks('onOptionMenuClick');
|
|
6175
|
-
const usePullIntercept = taroHooks('onPullIntercept');
|
|
6176
|
-
const useShareTimeline = taroHooks('onShareTimeline');
|
|
6177
|
-
const useAddToFavorites = taroHooks('onAddToFavorites');
|
|
6178
|
-
const useReady = taroHooks('onReady');
|
|
6179
|
-
const useRouter = (dynamic = false) => {
|
|
6180
|
-
return dynamic ? Current.router : R.useMemo(() => Current.router, []);
|
|
6181
|
-
};
|
|
6182
|
-
const useScope = () => undefined;
|
|
6183
|
-
|
|
6184
4393
|
function removeLeadingSlash(path) {
|
|
6185
4394
|
if (path == null) {
|
|
6186
4395
|
return '';
|
|
@@ -6198,9 +4407,9 @@ const nextTick = (cb, ctx) => {
|
|
|
6198
4407
|
if (router !== null) {
|
|
6199
4408
|
let pageElement = null;
|
|
6200
4409
|
const path = getPath(removeLeadingSlash(router.path), router.params);
|
|
6201
|
-
pageElement = document$
|
|
4410
|
+
pageElement = document$1.getElementById(path);
|
|
6202
4411
|
if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) {
|
|
6203
|
-
if (
|
|
4412
|
+
if (process.env.TARO_ENV === 'h5') {
|
|
6204
4413
|
// eslint-disable-next-line dot-notation
|
|
6205
4414
|
(_c = (_b = (_a = pageElement.firstChild) === null || _a === void 0 ? void 0 : _a['componentOnReady']) === null || _b === void 0 ? void 0 : _b.call(_a).then(() => {
|
|
6206
4415
|
timerFunc();
|
|
@@ -6219,5 +4428,5 @@ const nextTick = (cb, ctx) => {
|
|
|
6219
4428
|
}
|
|
6220
4429
|
};
|
|
6221
4430
|
|
|
6222
|
-
export { Current, ElementNames, Events, FormElement, SERVICE_IDENTIFIER, SVGElement, Style, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, caf as cancelAnimationFrame,
|
|
4431
|
+
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 };
|
|
6223
4432
|
//# sourceMappingURL=runtime.esm.js.map
|