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