@tarojs/with-weapp 4.0.1-alpha.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +8 -8
- package/dist/index.esm.js +895 -847
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +908 -846
- package/dist/index.js.map +1 -1
- package/dist/with-weapp.js +901 -850
- package/dist/with-weapp.js.map +1 -1
- package/package.json +28 -18
- package/src/index.ts +0 -25
package/dist/with-weapp.js
CHANGED
|
@@ -1,114 +1,127 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tarojs/runtime'), require('@tarojs/taro')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@tarojs/runtime', '@tarojs/taro'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TaroWithWeapp = {}, global.runtime, global.taro));
|
|
5
|
-
})(this, (function (exports, runtime, taro) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/defineProperty'), require('@babel/runtime/helpers/toConsumableArray'), require('@babel/runtime/helpers/slicedToArray'), require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('@babel/runtime/helpers/assertThisInitialized'), require('@babel/runtime/helpers/get'), require('@babel/runtime/helpers/inherits'), require('@babel/runtime/helpers/possibleConstructorReturn'), require('@babel/runtime/helpers/getPrototypeOf'), require('@babel/runtime/helpers/typeof'), require('@tarojs/runtime'), require('@tarojs/taro')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/defineProperty', '@babel/runtime/helpers/toConsumableArray', '@babel/runtime/helpers/slicedToArray', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', '@babel/runtime/helpers/assertThisInitialized', '@babel/runtime/helpers/get', '@babel/runtime/helpers/inherits', '@babel/runtime/helpers/possibleConstructorReturn', '@babel/runtime/helpers/getPrototypeOf', '@babel/runtime/helpers/typeof', '@tarojs/runtime', '@tarojs/taro'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TaroWithWeapp = {}, global._defineProperty, global._toConsumableArray, global._slicedToArray, global._classCallCheck, global._createClass, global._assertThisInitialized, global._get, global._inherits, global._possibleConstructorReturn, global._getPrototypeOf, global._typeof, global.runtime, global.taro));
|
|
5
|
+
})(this, (function (exports, _defineProperty, _toConsumableArray, _slicedToArray, _classCallCheck, _createClass, _assertThisInitialized, _get, _inherits, _possibleConstructorReturn, _getPrototypeOf, _typeof, runtime, taro) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
10
|
+
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
11
|
+
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
12
|
+
var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
|
|
13
|
+
var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
|
|
14
|
+
var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
|
|
15
|
+
var _get__default = /*#__PURE__*/_interopDefaultLegacy(_get);
|
|
16
|
+
var _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);
|
|
17
|
+
var _possibleConstructorReturn__default = /*#__PURE__*/_interopDefaultLegacy(_possibleConstructorReturn);
|
|
18
|
+
var _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeOf);
|
|
19
|
+
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
|
10
20
|
|
|
11
|
-
|
|
12
|
-
|
|
21
|
+
var json = JSON;
|
|
22
|
+
var clone = function clone(obj) {
|
|
23
|
+
return json.parse(stringify(obj));
|
|
13
24
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
var isArray = Array.isArray || function (x) {
|
|
26
|
+
return {}.toString.call(x) === '[object Array]';
|
|
27
|
+
};
|
|
28
|
+
var objectKeys = Object.keys || function (obj) {
|
|
29
|
+
var has = Object.prototype.hasOwnProperty || function () {
|
|
30
|
+
return true;
|
|
31
|
+
};
|
|
32
|
+
var keys = [];
|
|
33
|
+
for (var key in obj) {
|
|
19
34
|
if (has.call(obj, key)) keys.push(key);
|
|
20
35
|
}
|
|
21
|
-
return keys
|
|
36
|
+
return keys;
|
|
22
37
|
};
|
|
23
|
-
|
|
24
|
-
function stringify (obj, opts) {
|
|
38
|
+
function stringify(obj, opts) {
|
|
25
39
|
if (!opts) opts = {};
|
|
26
|
-
if (typeof opts === 'function') opts = {
|
|
27
|
-
|
|
40
|
+
if (typeof opts === 'function') opts = {
|
|
41
|
+
cmp: opts
|
|
42
|
+
};
|
|
43
|
+
var space = opts.space || '';
|
|
28
44
|
if (typeof space === 'number') space = Array(space + 1).join(' ');
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
var cycles = typeof opts.cycles === 'boolean' ? opts.cycles : false;
|
|
46
|
+
var replacer = opts.replacer || function (key, value) {
|
|
47
|
+
return value;
|
|
48
|
+
};
|
|
49
|
+
var cmp = opts.cmp && function (f) {
|
|
33
50
|
return function (node) {
|
|
34
51
|
return function (a, b) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
var aobj = {
|
|
53
|
+
key: a,
|
|
54
|
+
value: node[a]
|
|
55
|
+
};
|
|
56
|
+
var bobj = {
|
|
57
|
+
key: b,
|
|
58
|
+
value: node[b]
|
|
59
|
+
};
|
|
60
|
+
return f(aobj, bobj);
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
}(opts.cmp);
|
|
64
|
+
var seen = [];
|
|
65
|
+
return function stringify(parent, key, node, level) {
|
|
66
|
+
var indent = space ? '\n' + new Array(level + 1).join(space) : '';
|
|
67
|
+
var colonSeparator = space ? ': ' : ':';
|
|
47
68
|
if (node && node.toJSON && typeof node.toJSON === 'function') {
|
|
48
69
|
node = node.toJSON();
|
|
49
70
|
}
|
|
50
|
-
|
|
51
71
|
node = replacer.call(parent, key, node);
|
|
52
|
-
|
|
53
72
|
if (node === undefined) {
|
|
54
|
-
return
|
|
73
|
+
return;
|
|
55
74
|
}
|
|
56
|
-
if (
|
|
57
|
-
return json.stringify(node)
|
|
75
|
+
if (_typeof__default["default"](node) !== 'object' || node === null) {
|
|
76
|
+
return json.stringify(node);
|
|
58
77
|
}
|
|
59
78
|
if (isArray(node)) {
|
|
60
|
-
|
|
61
|
-
for (
|
|
62
|
-
|
|
79
|
+
var out = [];
|
|
80
|
+
for (var i = 0; i < node.length; i++) {
|
|
81
|
+
var item = stringify(node, i, node[i], level + 1) || json.stringify(null);
|
|
63
82
|
out.push(indent + space + item);
|
|
64
83
|
}
|
|
65
|
-
return '[' + out.join(',') + indent + ']'
|
|
84
|
+
return '[' + out.join(',') + indent + ']';
|
|
66
85
|
} else {
|
|
67
86
|
if (seen.indexOf(node) !== -1) {
|
|
68
|
-
if (cycles) return json.stringify('__cycle__')
|
|
69
|
-
throw new TypeError('Converting circular structure to JSON')
|
|
87
|
+
if (cycles) return json.stringify('__cycle__');
|
|
88
|
+
throw new TypeError('Converting circular structure to JSON');
|
|
70
89
|
} else seen.push(node);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const keyValue = json.stringify(key) +
|
|
81
|
-
colonSeparator +
|
|
82
|
-
value;
|
|
83
|
-
|
|
84
|
-
out.push(indent + space + keyValue);
|
|
90
|
+
var keys = objectKeys(node).sort(cmp && cmp(node));
|
|
91
|
+
var _out = [];
|
|
92
|
+
for (var _i = 0; _i < keys.length; _i++) {
|
|
93
|
+
var _key = keys[_i];
|
|
94
|
+
var value = stringify(node, _key, node[_key], level + 1);
|
|
95
|
+
if (!value) continue;
|
|
96
|
+
var keyValue = json.stringify(_key) + colonSeparator + value;
|
|
97
|
+
_out.push(indent + space + keyValue);
|
|
85
98
|
}
|
|
86
99
|
seen.splice(seen.indexOf(node), 1);
|
|
87
|
-
return '{' +
|
|
100
|
+
return '{' + _out.join(',') + indent + '}';
|
|
88
101
|
}
|
|
89
|
-
}
|
|
102
|
+
}({
|
|
103
|
+
'': obj
|
|
104
|
+
}, '', obj, 0);
|
|
90
105
|
}
|
|
91
106
|
|
|
92
107
|
/*eslint-disable*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const result = {};
|
|
108
|
+
var ARRAYTYPE = '[object Array]';
|
|
109
|
+
var OBJECTTYPE = '[object Object]';
|
|
110
|
+
var FUNCTIONTYPE = '[object Function]';
|
|
111
|
+
function diff(current, pre) {
|
|
112
|
+
var result = {};
|
|
99
113
|
syncKeys(current, pre);
|
|
100
114
|
_diff(current, pre, '', result);
|
|
101
|
-
return result
|
|
115
|
+
return result;
|
|
102
116
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const rootPreType = type(pre);
|
|
117
|
+
function syncKeys(current, pre) {
|
|
118
|
+
if (current === pre) return;
|
|
119
|
+
var rootCurrentType = type(current);
|
|
120
|
+
var rootPreType = type(pre);
|
|
108
121
|
if (rootCurrentType == OBJECTTYPE && rootPreType == OBJECTTYPE) {
|
|
109
122
|
// if(Object.keys(current).length >= Object.keys(pre).length){
|
|
110
|
-
for (
|
|
111
|
-
|
|
123
|
+
for (var key in pre) {
|
|
124
|
+
var currentValue = current[key];
|
|
112
125
|
if (currentValue === undefined) {
|
|
113
126
|
current[key] = null;
|
|
114
127
|
} else {
|
|
@@ -118,26 +131,25 @@
|
|
|
118
131
|
// }
|
|
119
132
|
} else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) {
|
|
120
133
|
if (current.length >= pre.length) {
|
|
121
|
-
pre.forEach((item, index)
|
|
134
|
+
pre.forEach(function (item, index) {
|
|
122
135
|
syncKeys(current[index], item);
|
|
123
136
|
});
|
|
124
137
|
}
|
|
125
138
|
}
|
|
126
139
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const rootPreType = type(pre);
|
|
140
|
+
function _diff(current, pre, path, result) {
|
|
141
|
+
if (current === pre) return;
|
|
142
|
+
var rootCurrentType = type(current);
|
|
143
|
+
var rootPreType = type(pre);
|
|
132
144
|
if (rootCurrentType == OBJECTTYPE) {
|
|
133
145
|
if (rootPreType != OBJECTTYPE || Object.keys(current).length < Object.keys(pre).length) {
|
|
134
146
|
setResult(result, path, current);
|
|
135
147
|
} else {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
148
|
+
var _loop = function _loop(key) {
|
|
149
|
+
var currentValue = current[key];
|
|
150
|
+
var preValue = pre[key];
|
|
151
|
+
var currentType = type(currentValue);
|
|
152
|
+
var preType = type(preValue);
|
|
141
153
|
if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) {
|
|
142
154
|
if (currentValue != pre[key]) {
|
|
143
155
|
setResult(result, (path == '' ? '' : path + '.') + key, currentValue);
|
|
@@ -149,7 +161,7 @@
|
|
|
149
161
|
if (currentValue.length < preValue.length) {
|
|
150
162
|
setResult(result, (path == '' ? '' : path + '.') + key, currentValue);
|
|
151
163
|
} else {
|
|
152
|
-
currentValue.forEach((item, index)
|
|
164
|
+
currentValue.forEach(function (item, index) {
|
|
153
165
|
_diff(item, preValue[index], (path == '' ? '' : path + '.') + key + '[' + index + ']', result);
|
|
154
166
|
});
|
|
155
167
|
}
|
|
@@ -158,11 +170,14 @@
|
|
|
158
170
|
if (preType != OBJECTTYPE || Object.keys(currentValue).length < Object.keys(preValue).length) {
|
|
159
171
|
setResult(result, (path == '' ? '' : path + '.') + key, currentValue);
|
|
160
172
|
} else {
|
|
161
|
-
for (
|
|
173
|
+
for (var subKey in currentValue) {
|
|
162
174
|
_diff(currentValue[subKey], preValue[subKey], (path == '' ? '' : path + '.') + key + '.' + subKey, result);
|
|
163
175
|
}
|
|
164
176
|
}
|
|
165
177
|
}
|
|
178
|
+
};
|
|
179
|
+
for (var key in current) {
|
|
180
|
+
_loop(key);
|
|
166
181
|
}
|
|
167
182
|
}
|
|
168
183
|
} else if (rootCurrentType == ARRAYTYPE) {
|
|
@@ -172,7 +187,7 @@
|
|
|
172
187
|
if (current.length < pre.length) {
|
|
173
188
|
setResult(result, path, current);
|
|
174
189
|
} else {
|
|
175
|
-
current.forEach((item, index)
|
|
190
|
+
current.forEach(function (item, index) {
|
|
176
191
|
_diff(item, pre[index], path + '[' + index + ']', result);
|
|
177
192
|
});
|
|
178
193
|
}
|
|
@@ -181,854 +196,890 @@
|
|
|
181
196
|
setResult(result, path, current);
|
|
182
197
|
}
|
|
183
198
|
}
|
|
184
|
-
|
|
185
|
-
function setResult (result, k, v) {
|
|
199
|
+
function setResult(result, k, v) {
|
|
186
200
|
if (type(v) != FUNCTIONTYPE) {
|
|
187
201
|
result[k] = v;
|
|
188
202
|
}
|
|
189
203
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return Object.prototype.toString.call(obj)
|
|
204
|
+
function type(obj) {
|
|
205
|
+
return Object.prototype.toString.call(obj);
|
|
193
206
|
}
|
|
194
207
|
|
|
208
|
+
var _lifecycleMap;
|
|
195
209
|
var TaroLifeCycles;
|
|
196
210
|
(function (TaroLifeCycles) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
211
|
+
TaroLifeCycles["WillMount"] = "componentWillMount";
|
|
212
|
+
TaroLifeCycles["DidMount"] = "componentDidMount";
|
|
213
|
+
TaroLifeCycles["DidShow"] = "componentDidShow";
|
|
214
|
+
TaroLifeCycles["DidHide"] = "componentDidHide";
|
|
215
|
+
TaroLifeCycles["WillUnmount"] = "componentWillUnmount";
|
|
202
216
|
})(TaroLifeCycles || (TaroLifeCycles = {}));
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const lifecycles = new Set(['ready']);
|
|
211
|
-
for (const key in lifecycleMap) {
|
|
212
|
-
const lifecycle = lifecycleMap[key];
|
|
213
|
-
lifecycle.forEach(l => lifecycles.add(l));
|
|
217
|
+
var lifecycleMap = (_lifecycleMap = {}, _defineProperty__default["default"](_lifecycleMap, TaroLifeCycles.WillMount, ['created']), _defineProperty__default["default"](_lifecycleMap, TaroLifeCycles.DidMount, ['attached']), _defineProperty__default["default"](_lifecycleMap, TaroLifeCycles.DidShow, ['onShow']), _defineProperty__default["default"](_lifecycleMap, TaroLifeCycles.DidHide, ['onHide']), _defineProperty__default["default"](_lifecycleMap, TaroLifeCycles.WillUnmount, ['detached', 'onUnload']), _lifecycleMap);
|
|
218
|
+
var lifecycles = new Set(['ready']);
|
|
219
|
+
for (var key in lifecycleMap) {
|
|
220
|
+
var lifecycle = lifecycleMap[key];
|
|
221
|
+
lifecycle.forEach(function (l) {
|
|
222
|
+
return lifecycles.add(l);
|
|
223
|
+
});
|
|
214
224
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
'onReachBottom',
|
|
218
|
-
'onShareAppMessage',
|
|
219
|
-
'onShareTimeline',
|
|
220
|
-
'onAddToFavorites',
|
|
221
|
-
'onPageScroll',
|
|
222
|
-
'onResize',
|
|
223
|
-
'onTabItemTap'
|
|
224
|
-
];
|
|
225
|
-
const appOptions = [
|
|
226
|
-
'onLaunch',
|
|
227
|
-
'onShow',
|
|
228
|
-
'onHide',
|
|
229
|
-
'onError',
|
|
230
|
-
'onPageNotFound',
|
|
231
|
-
'onUnhandledRejection',
|
|
232
|
-
'onThemeChange'
|
|
233
|
-
];
|
|
225
|
+
var uniquePageLifecycle = ['onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onShareTimeline', 'onAddToFavorites', 'onPageScroll', 'onResize', 'onTabItemTap'];
|
|
226
|
+
var appOptions = ['onLaunch', 'onShow', 'onHide', 'onError', 'onPageNotFound', 'onUnhandledRejection', 'onThemeChange'];
|
|
234
227
|
|
|
235
228
|
/**
|
|
236
229
|
* Simple bind, faster than native
|
|
237
230
|
*/
|
|
238
231
|
function bind(fn /*: Function */, ctx /*: Object */) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return boundFn;
|
|
232
|
+
if (!fn) return false;
|
|
233
|
+
function boundFn(a) {
|
|
234
|
+
var l /*: number */ = arguments.length;
|
|
235
|
+
return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx);
|
|
236
|
+
}
|
|
237
|
+
// record original fn length
|
|
238
|
+
boundFn._length = fn.length;
|
|
239
|
+
return boundFn;
|
|
248
240
|
}
|
|
249
241
|
function isEqual(obj1, obj2) {
|
|
250
|
-
|
|
242
|
+
return JSON.stringify(obj1) === JSON.stringify(obj2);
|
|
251
243
|
}
|
|
252
244
|
function safeGet(obj, propsArg, defaultValue) {
|
|
245
|
+
if (!obj) {
|
|
246
|
+
return defaultValue;
|
|
247
|
+
}
|
|
248
|
+
var props, prop;
|
|
249
|
+
if (Array.isArray(propsArg)) {
|
|
250
|
+
props = propsArg.slice(0);
|
|
251
|
+
}
|
|
252
|
+
if (typeof propsArg === 'string') {
|
|
253
|
+
props = propsArg.replace(/\[(.+?)\]/g, '.$1');
|
|
254
|
+
props = props.split('.');
|
|
255
|
+
}
|
|
256
|
+
if (_typeof__default["default"](propsArg) === 'symbol') {
|
|
257
|
+
props = [propsArg];
|
|
258
|
+
}
|
|
259
|
+
if (!Array.isArray(props)) {
|
|
260
|
+
throw new Error('props arg must be an array, a string or a symbol');
|
|
261
|
+
}
|
|
262
|
+
while (props.length) {
|
|
263
|
+
prop = props.shift();
|
|
253
264
|
if (!obj) {
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
let props, prop;
|
|
257
|
-
if (Array.isArray(propsArg)) {
|
|
258
|
-
props = propsArg.slice(0);
|
|
259
|
-
}
|
|
260
|
-
if (typeof propsArg === 'string') {
|
|
261
|
-
props = propsArg.replace(/\[(.+?)\]/g, '.$1');
|
|
262
|
-
props = props.split('.');
|
|
263
|
-
}
|
|
264
|
-
if (typeof propsArg === 'symbol') {
|
|
265
|
-
props = [propsArg];
|
|
265
|
+
return defaultValue;
|
|
266
266
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
while (props.length) {
|
|
271
|
-
prop = props.shift();
|
|
272
|
-
if (!obj) {
|
|
273
|
-
return defaultValue;
|
|
274
|
-
}
|
|
275
|
-
obj = obj[prop];
|
|
276
|
-
if (obj === undefined) {
|
|
277
|
-
return defaultValue;
|
|
278
|
-
}
|
|
267
|
+
obj = obj[prop];
|
|
268
|
+
if (obj === undefined) {
|
|
269
|
+
return defaultValue;
|
|
279
270
|
}
|
|
280
|
-
|
|
271
|
+
}
|
|
272
|
+
return obj;
|
|
281
273
|
}
|
|
282
274
|
function safeSet(obj, props, value) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
275
|
+
if (typeof props === 'string') {
|
|
276
|
+
props = props.replace(/\[(.+?)\]/g, '.$1');
|
|
277
|
+
props = props.split('.');
|
|
278
|
+
}
|
|
279
|
+
if (_typeof__default["default"](props) === 'symbol') {
|
|
280
|
+
props = [props];
|
|
281
|
+
}
|
|
282
|
+
var lastProp = props.pop();
|
|
283
|
+
if (!lastProp) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
var thisProp;
|
|
287
|
+
while (thisProp = props.shift()) {
|
|
288
|
+
if (typeof obj[thisProp] === 'undefined') {
|
|
289
|
+
obj[thisProp] = {};
|
|
289
290
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
// 直接按路径修改 this.state 可能会导致 nextProps 也被修改
|
|
292
|
+
// 因此按路径寻找时,每一层都复制一遍
|
|
293
|
+
if (Array.isArray(obj[thisProp])) {
|
|
294
|
+
obj[thisProp] = _toConsumableArray__default["default"](obj[thisProp]);
|
|
295
|
+
} else if (_typeof__default["default"](obj[thisProp]) === 'object') {
|
|
296
|
+
obj[thisProp] = Object.assign({}, obj[thisProp]);
|
|
293
297
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
obj[thisProp] = {};
|
|
298
|
-
}
|
|
299
|
-
// 直接按路径修改 this.state 可能会导致 nextProps 也被修改
|
|
300
|
-
// 因此按路径寻找时,每一层都复制一遍
|
|
301
|
-
if (Array.isArray(obj[thisProp])) {
|
|
302
|
-
obj[thisProp] = [...obj[thisProp]];
|
|
303
|
-
}
|
|
304
|
-
else if (typeof obj[thisProp] === 'object') {
|
|
305
|
-
obj[thisProp] = Object.assign({}, obj[thisProp]);
|
|
306
|
-
}
|
|
307
|
-
obj = obj[thisProp];
|
|
308
|
-
if (!obj || typeof obj !== 'object') {
|
|
309
|
-
return false;
|
|
310
|
-
}
|
|
298
|
+
obj = obj[thisProp];
|
|
299
|
+
if (!obj || _typeof__default["default"](obj) !== 'object') {
|
|
300
|
+
return false;
|
|
311
301
|
}
|
|
312
|
-
|
|
313
|
-
|
|
302
|
+
}
|
|
303
|
+
obj[lastProp] = value;
|
|
304
|
+
return true;
|
|
314
305
|
}
|
|
315
306
|
function report(msg) {
|
|
316
|
-
|
|
307
|
+
console.warn('[Taro Convert Warning] ' + msg);
|
|
317
308
|
}
|
|
318
|
-
|
|
319
|
-
['onError', '不支持 App 的 onError 生命周期方法。'],
|
|
320
|
-
['onPageNotFound', '不支持 App 的 onPageNotFound 生命周期方法。'],
|
|
321
|
-
['onUnhandledRejection', '不支持 App 的 onUnhandledRejection 生命周期方法。'],
|
|
322
|
-
['onThemeChange', '不支持 App 的 onThemeChange 生命周期方法。'],
|
|
323
|
-
['moved', '不支持自定义组件的 moved 生命周期。'],
|
|
324
|
-
['externalClasses', '不支持自定义组件的 externalClasses 功能。'],
|
|
325
|
-
['relations', '不支持自定义组件的 relations 功能。'],
|
|
326
|
-
['options', '不支持自定义组件的 options 功能。'],
|
|
327
|
-
['definitionFilter', '不支持自定义组件的 definitionFilter 功能。'],
|
|
328
|
-
['selectComponent', 'selectComponent 方法产生不到目标效果,请使用 React 的 ref 进行重构。'],
|
|
329
|
-
['selectAllComponents', 'selectAllComponents 方法产生不到目标效果,请使用 React 的 ref 进行重构。'],
|
|
330
|
-
['selectOwnerComponent', 'selectOwnerComponent 方法产生不到目标效果,请使用 React 语法重构。'],
|
|
331
|
-
['groupSetData', 'groupSetData 方法产生不到目标效果,请使用 React 语法重构。']
|
|
332
|
-
]);
|
|
309
|
+
var nonsupport = new Map([['onError', '不支持 App 的 onError 生命周期方法。'], ['onPageNotFound', '不支持 App 的 onPageNotFound 生命周期方法。'], ['onUnhandledRejection', '不支持 App 的 onUnhandledRejection 生命周期方法。'], ['onThemeChange', '不支持 App 的 onThemeChange 生命周期方法。'], ['moved', '不支持自定义组件的 moved 生命周期。'], ['externalClasses', '不支持自定义组件的 externalClasses 功能。'], ['relations', '不支持自定义组件的 relations 功能。'], ['options', '不支持自定义组件的 options 功能。'], ['definitionFilter', '不支持自定义组件的 definitionFilter 功能。'], ['selectComponent', 'selectComponent 方法产生不到目标效果,请使用 React 的 ref 进行重构。'], ['selectAllComponents', 'selectAllComponents 方法产生不到目标效果,请使用 React 的 ref 进行重构。'], ['selectOwnerComponent', 'selectOwnerComponent 方法产生不到目标效果,请使用 React 语法重构。'], ['groupSetData', 'groupSetData 方法产生不到目标效果,请使用 React 语法重构。']]);
|
|
333
310
|
function flattenBehaviors(behavior, behaviorMap) {
|
|
334
|
-
|
|
335
|
-
|
|
311
|
+
if (typeof behavior === 'string') {
|
|
312
|
+
return report("\u4E0D\u652F\u6301\u4F7F\u7528\u5185\u7F6E Behavior: [".concat(behavior, "]"));
|
|
313
|
+
}
|
|
314
|
+
var subBehaviors = behavior.behaviors;
|
|
315
|
+
if (subBehaviors === null || subBehaviors === void 0 ? void 0 : subBehaviors.length) {
|
|
316
|
+
subBehaviors.forEach(function (subBehavior) {
|
|
317
|
+
return flattenBehaviors(subBehavior, behaviorMap);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
Object.keys(behavior).forEach(function (key) {
|
|
321
|
+
// 不支持的属性
|
|
322
|
+
if (nonsupport.has(key)) {
|
|
323
|
+
var advise = nonsupport.get(key);
|
|
324
|
+
return report(advise);
|
|
336
325
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
326
|
+
if (behaviorMap.has(key)) {
|
|
327
|
+
var list = behaviorMap.get(key);
|
|
328
|
+
var value = behavior[key];
|
|
329
|
+
list.push(value);
|
|
340
330
|
}
|
|
341
|
-
|
|
342
|
-
// 不支持的属性
|
|
343
|
-
if (nonsupport.has(key)) {
|
|
344
|
-
const advise = nonsupport.get(key);
|
|
345
|
-
return report(advise);
|
|
346
|
-
}
|
|
347
|
-
if (behaviorMap.has(key)) {
|
|
348
|
-
const list = behaviorMap.get(key);
|
|
349
|
-
const value = behavior[key];
|
|
350
|
-
list.push(value);
|
|
351
|
-
}
|
|
352
|
-
});
|
|
331
|
+
});
|
|
353
332
|
}
|
|
354
333
|
|
|
355
334
|
/**
|
|
356
335
|
* 该模块仅存放 convert 转换时用到的工具函数或变量
|
|
357
336
|
*/
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
getOptionsFromCache: function () {
|
|
366
|
-
return this.cacheOptions;
|
|
337
|
+
var cacheOptions = {
|
|
338
|
+
cacheOptions: {},
|
|
339
|
+
setOptionsToCache: function setOptionsToCache(options) {
|
|
340
|
+
if (Object.keys(options).length !== 0) {
|
|
341
|
+
this.cacheOptions = options;
|
|
367
342
|
}
|
|
343
|
+
},
|
|
344
|
+
getOptionsFromCache: function getOptionsFromCache() {
|
|
345
|
+
return this.cacheOptions;
|
|
346
|
+
}
|
|
368
347
|
};
|
|
369
348
|
function toCamelCase(s) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
nextCap = true;
|
|
379
|
-
}
|
|
349
|
+
var camel = '';
|
|
350
|
+
var nextCap = false;
|
|
351
|
+
for (var i = 0; i < s.length; i++) {
|
|
352
|
+
if (s[i] !== '-') {
|
|
353
|
+
camel += nextCap ? s[i].toUpperCase() : s[i];
|
|
354
|
+
nextCap = false;
|
|
355
|
+
} else {
|
|
356
|
+
nextCap = true;
|
|
380
357
|
}
|
|
381
|
-
|
|
358
|
+
}
|
|
359
|
+
return camel;
|
|
382
360
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
361
|
+
var convertToArray = function convertToArray(value, fn) {
|
|
362
|
+
if (value instanceof Array) {
|
|
363
|
+
return value.map(fn);
|
|
364
|
+
} else if (typeof value === 'number') {
|
|
365
|
+
return Array.from({
|
|
366
|
+
length: value
|
|
367
|
+
}, function (_, index) {
|
|
368
|
+
return index;
|
|
369
|
+
}).map(fn);
|
|
370
|
+
} else if (typeof value === 'string') {
|
|
371
|
+
return Array.from(value).map(fn);
|
|
372
|
+
} else if (_typeof__default["default"](value) === 'object' && value !== null && Object.getPrototypeOf(value) === Object.prototype) {
|
|
373
|
+
var result = Object.keys(value).map(function (item) {
|
|
374
|
+
return fn(value[item], item);
|
|
375
|
+
});
|
|
376
|
+
return result;
|
|
377
|
+
}
|
|
401
378
|
};
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
379
|
+
var getTarget = function getTarget(target, Taro) {
|
|
380
|
+
if (!target) {
|
|
381
|
+
return {
|
|
382
|
+
dataset: {}
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
if (Taro.getEnv() === Taro.ENV_TYPE.HARMONYHYBRID || Taro.getEnv() === Taro.ENV_TYPE.WEB) {
|
|
386
|
+
if (target.fullDataset) {
|
|
387
|
+
return {
|
|
388
|
+
dataset: target.fullDataset
|
|
389
|
+
};
|
|
405
390
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
for (let i = 0; i < targetAttrKeys.length; i++) {
|
|
415
|
-
if (targetAttrKeys[i].startsWith('data-')) {
|
|
416
|
-
fullDataset[toCamelCase(targetAttrKeys[i].replace(/^data-/, '').toLowerCase())] = target[targetAttrKeys[i]];
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
target.fullDataset = fullDataset;
|
|
420
|
-
return { dataset: fullDataset };
|
|
391
|
+
var fullDataset = {};
|
|
392
|
+
// 获取元素的所有属性
|
|
393
|
+
var targetAttrKeys = Object.keys(target);
|
|
394
|
+
// 遍历所有属性
|
|
395
|
+
for (var i = 0; i < targetAttrKeys.length; i++) {
|
|
396
|
+
if (targetAttrKeys[i].startsWith('data-')) {
|
|
397
|
+
fullDataset[toCamelCase(targetAttrKeys[i].replace(/^data-/, '').toLowerCase())] = target[targetAttrKeys[i]];
|
|
398
|
+
}
|
|
421
399
|
}
|
|
422
|
-
|
|
400
|
+
target.fullDataset = fullDataset;
|
|
401
|
+
return {
|
|
402
|
+
dataset: fullDataset
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
return target;
|
|
423
406
|
};
|
|
424
407
|
|
|
408
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
409
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
410
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
411
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf__default["default"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default["default"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default["default"](this, result); }; }
|
|
412
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
425
413
|
function defineGetter(component, key, getter) {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
414
|
+
Object.defineProperty(component, key, {
|
|
415
|
+
enumerable: true,
|
|
416
|
+
configurable: true,
|
|
417
|
+
get: function get() {
|
|
418
|
+
if (getter === 'props') {
|
|
419
|
+
return component.props;
|
|
420
|
+
}
|
|
421
|
+
return component.state;
|
|
422
|
+
// return {
|
|
423
|
+
// ...component.state,
|
|
424
|
+
// ...component.props
|
|
425
|
+
// }
|
|
426
|
+
}
|
|
427
|
+
});
|
|
440
428
|
}
|
|
429
|
+
|
|
441
430
|
function propToState(newValue, _oldValue, key) {
|
|
442
|
-
|
|
431
|
+
this.state[key] = newValue;
|
|
443
432
|
}
|
|
444
433
|
function isFunction(o) {
|
|
445
|
-
|
|
434
|
+
return typeof o === 'function';
|
|
446
435
|
}
|
|
447
|
-
function withWeapp(weappConf
|
|
448
|
-
|
|
449
|
-
|
|
436
|
+
function withWeapp(weappConf) {
|
|
437
|
+
var isApp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
438
|
+
if (_typeof__default["default"](weappConf) === 'object' && Object.keys(weappConf).length === 0) {
|
|
439
|
+
report('withWeapp 请传入“App/页面/组件“的配置对象。如果原生写法使用了基类,请将基类组合后的配置对象传入,详情请参考文档。');
|
|
440
|
+
}
|
|
441
|
+
return function (ConnectComponent) {
|
|
442
|
+
var _a;
|
|
443
|
+
var behaviorMap = new Map([['properties', []], ['data', []], ['methods', []], ['created', []], ['attached', []], ['ready', []], ['detached', []], ['lifetimes', []]]);
|
|
444
|
+
var behaviorProperties = {};
|
|
445
|
+
if ((_a = weappConf.behaviors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
446
|
+
var behaviors = weappConf.behaviors;
|
|
447
|
+
behaviors.forEach(function (behavior) {
|
|
448
|
+
return flattenBehaviors(behavior, behaviorMap);
|
|
449
|
+
});
|
|
450
|
+
var propertiesList = behaviorMap.get('properties');
|
|
451
|
+
if (propertiesList.length) {
|
|
452
|
+
propertiesList.forEach(function (property) {
|
|
453
|
+
Object.assign(behaviorProperties, property);
|
|
454
|
+
});
|
|
455
|
+
Object.keys(behaviorProperties).forEach(function (propName) {
|
|
456
|
+
var propValue = behaviorProperties[propName];
|
|
457
|
+
if (!weappConf.properties) {
|
|
458
|
+
weappConf.properties = {};
|
|
459
|
+
}
|
|
460
|
+
if (!weappConf.properties.hasOwnProperty(propName)) {
|
|
461
|
+
if (propValue && _typeof__default["default"](propValue) === 'object' && propValue.value) {
|
|
462
|
+
propValue.value = clone(propValue.value);
|
|
463
|
+
}
|
|
464
|
+
weappConf.properties[propName] = propValue;
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
450
468
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
]
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
469
|
+
var BaseComponent = /*#__PURE__*/function (_ConnectComponent) {
|
|
470
|
+
_inherits__default["default"](BaseComponent, _ConnectComponent);
|
|
471
|
+
var _super = _createSuper(BaseComponent);
|
|
472
|
+
function BaseComponent(props) {
|
|
473
|
+
var _this;
|
|
474
|
+
_classCallCheck__default["default"](this, BaseComponent);
|
|
475
|
+
_this = _super.call(this, props);
|
|
476
|
+
_this._observeProps = [];
|
|
477
|
+
// mixins 可以多次调用生命周期
|
|
478
|
+
_this.willMounts = [];
|
|
479
|
+
_this.didMounts = [];
|
|
480
|
+
_this.didHides = [];
|
|
481
|
+
_this.didShows = [];
|
|
482
|
+
_this.willUnmounts = [];
|
|
483
|
+
_this.eventDestroyList = [];
|
|
484
|
+
_this.current = runtime.getCurrentInstance();
|
|
485
|
+
_this.taroGlobalData = Object.create(null);
|
|
486
|
+
_this.safeExecute = function (func) {
|
|
487
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
488
|
+
args[_key - 1] = arguments[_key];
|
|
489
|
+
}
|
|
490
|
+
if (isFunction(func)) func.apply(_assertThisInitialized__default["default"](_this), args);
|
|
491
|
+
};
|
|
492
|
+
_this.setData = function (obj, callback) {
|
|
493
|
+
var oldState;
|
|
494
|
+
if (_this.observers && Object.keys(Object.keys(_this.observers))) {
|
|
495
|
+
oldState = clone(_this.state);
|
|
496
|
+
}
|
|
497
|
+
Object.keys(obj).forEach(function (key) {
|
|
498
|
+
safeSet(_this.state, key, obj[key]);
|
|
499
|
+
});
|
|
500
|
+
_this.setState(_this.state, function () {
|
|
501
|
+
_this.triggerObservers(_this.state, oldState);
|
|
502
|
+
if (callback) {
|
|
503
|
+
callback.call(_assertThisInitialized__default["default"](_this));
|
|
484
504
|
}
|
|
505
|
+
});
|
|
506
|
+
};
|
|
507
|
+
_this.triggerEvent = function (eventName, detail, options) {
|
|
508
|
+
if (options) {
|
|
509
|
+
report('triggerEvent 不支持事件选项。');
|
|
510
|
+
}
|
|
511
|
+
// eventName support kebab case
|
|
512
|
+
if (eventName.match(/[a-z]+-[a-z]+/g)) {
|
|
513
|
+
eventName = eventName.replace(/-[a-z]/g, function (match) {
|
|
514
|
+
return match[1].toUpperCase();
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
var props = _this.props;
|
|
518
|
+
var dataset = {};
|
|
519
|
+
for (var key in props) {
|
|
520
|
+
if (!key.startsWith('data-')) continue;
|
|
521
|
+
dataset[key.replace(/^data-/, '')] = props[key];
|
|
522
|
+
}
|
|
523
|
+
var func = props["on".concat(eventName[0].toUpperCase()).concat(eventName.slice(1))];
|
|
524
|
+
if (isFunction(func)) {
|
|
525
|
+
func.call(_assertThisInitialized__default["default"](_this), {
|
|
526
|
+
type: eventName,
|
|
527
|
+
detail: detail,
|
|
528
|
+
target: {
|
|
529
|
+
id: props.id || '',
|
|
530
|
+
dataset: dataset
|
|
531
|
+
},
|
|
532
|
+
currentTarget: {
|
|
533
|
+
id: props.id || '',
|
|
534
|
+
dataset: dataset
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
_this.hasBehavior = _this.componentMethodsProxy('hasBehavior');
|
|
540
|
+
_this.createSelectorQuery = _this.componentMethodsProxy('createSelectorQuery');
|
|
541
|
+
_this.createIntersectionObserver = _this.componentMethodsProxy('createIntersectionObserver');
|
|
542
|
+
_this.createMediaQueryObserver = _this.componentMethodsProxy('createMediaQueryObserver');
|
|
543
|
+
_this.getRelationNodes = _this.componentMethodsProxy('getRelationNodes');
|
|
544
|
+
_this.getTabBar = _this.componentMethodsProxy('getTabBar');
|
|
545
|
+
_this.getPageId = _this.componentMethodsProxy('getPageId');
|
|
546
|
+
_this.animate = _this.componentMethodsProxy('animate');
|
|
547
|
+
_this.clearAnimation = _this.componentMethodsProxy('clearAnimation');
|
|
548
|
+
_this.setUpdatePerformanceListener = _this.componentMethodsProxy('setUpdatePerformanceListener');
|
|
549
|
+
_this.state = _this.state || {};
|
|
550
|
+
_this.init(weappConf);
|
|
551
|
+
defineGetter(_assertThisInitialized__default["default"](_this), 'data', 'state');
|
|
552
|
+
defineGetter(_assertThisInitialized__default["default"](_this), 'properties', 'props');
|
|
553
|
+
return _this;
|
|
554
|
+
}
|
|
555
|
+
_createClass__default["default"](BaseComponent, [{
|
|
556
|
+
key: "initProps",
|
|
557
|
+
value: function initProps(props) {
|
|
558
|
+
var properties = {};
|
|
559
|
+
for (var propKey in props) {
|
|
560
|
+
if (props.hasOwnProperty(propKey)) {
|
|
561
|
+
var propValue = props[propKey];
|
|
562
|
+
// propValue 可能是 null, 构造函数, 对象
|
|
563
|
+
var observers = [propToState];
|
|
564
|
+
if (propValue === null || propValue === undefined) {
|
|
565
|
+
// propValue为null、undefined情况
|
|
566
|
+
properties[propKey] = null;
|
|
567
|
+
} else if (isFunction(propValue)) {
|
|
568
|
+
// propValue为Function,即Array、String、Boolean等情况时
|
|
569
|
+
if (propValue.name === 'Array') {
|
|
570
|
+
properties[propKey] = [];
|
|
571
|
+
} else if (propValue.name === 'String') {
|
|
572
|
+
properties[propKey] = '';
|
|
573
|
+
} else if (propValue.name === 'Boolean') {
|
|
574
|
+
properties[propKey] = false;
|
|
575
|
+
} else if (propValue.name === 'Number') {
|
|
576
|
+
properties[propKey] = 0;
|
|
577
|
+
} else {
|
|
578
|
+
properties[propKey] = null;
|
|
579
|
+
}
|
|
580
|
+
} else if (_typeof__default["default"](propValue) === 'object') {
|
|
581
|
+
// propValue为对象时
|
|
582
|
+
properties[propKey] = propValue.value;
|
|
583
|
+
if (propValue.observer) {
|
|
584
|
+
observers.push(propValue.observer);
|
|
585
|
+
}
|
|
586
|
+
} else {
|
|
587
|
+
properties[propKey] = null;
|
|
588
|
+
}
|
|
589
|
+
this._observeProps.push({
|
|
590
|
+
name: propKey,
|
|
591
|
+
observers: observers
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
this.state = Object.assign(Object.assign({}, properties), this.state);
|
|
485
596
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
Object.keys(obj).forEach(key => {
|
|
509
|
-
safeSet(this.state, key, obj[key]);
|
|
510
|
-
});
|
|
511
|
-
this.setState(this.state, () => {
|
|
512
|
-
this.triggerObservers(this.state, oldState);
|
|
513
|
-
if (callback) {
|
|
514
|
-
callback.call(this);
|
|
515
|
-
}
|
|
597
|
+
}, {
|
|
598
|
+
key: "init",
|
|
599
|
+
value: function init(options) {
|
|
600
|
+
var _this2 = this;
|
|
601
|
+
var _a, _b, _c;
|
|
602
|
+
// 处理 Behaviors
|
|
603
|
+
if ((_a = options.behaviors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
604
|
+
var _iterator = _createForOfIteratorHelper(behaviorMap.entries()),
|
|
605
|
+
_step;
|
|
606
|
+
try {
|
|
607
|
+
var _loop = function _loop() {
|
|
608
|
+
var _step$value = _slicedToArray__default["default"](_step.value, 2),
|
|
609
|
+
key = _step$value[0],
|
|
610
|
+
list = _step$value[1];
|
|
611
|
+
switch (key) {
|
|
612
|
+
case 'created':
|
|
613
|
+
case 'attached':
|
|
614
|
+
case 'detached':
|
|
615
|
+
case 'ready':
|
|
616
|
+
list.forEach(function (fn) {
|
|
617
|
+
return _this2.initLifeCycles(key, fn);
|
|
516
618
|
});
|
|
517
|
-
|
|
518
|
-
this.triggerEvent = (eventName, detail, options) => {
|
|
519
|
-
if (options) {
|
|
520
|
-
report('triggerEvent 不支持事件选项。');
|
|
521
|
-
}
|
|
522
|
-
// eventName support kebab case
|
|
523
|
-
if (eventName.match(/[a-z]+-[a-z]+/g)) {
|
|
524
|
-
eventName = eventName.replace(/-[a-z]/g, function (match) {
|
|
525
|
-
return match[1].toUpperCase();
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
const props = this.props;
|
|
529
|
-
const dataset = {};
|
|
530
|
-
for (const key in props) {
|
|
531
|
-
if (!key.startsWith('data-'))
|
|
532
|
-
continue;
|
|
533
|
-
dataset[key.replace(/^data-/, '')] = props[key];
|
|
534
|
-
}
|
|
535
|
-
const func = props[`on${eventName[0].toUpperCase()}${eventName.slice(1)}`];
|
|
536
|
-
if (isFunction(func)) {
|
|
537
|
-
func.call(this, {
|
|
538
|
-
type: eventName,
|
|
539
|
-
detail,
|
|
540
|
-
target: {
|
|
541
|
-
id: props.id || '',
|
|
542
|
-
dataset
|
|
543
|
-
},
|
|
544
|
-
currentTarget: {
|
|
545
|
-
id: props.id || '',
|
|
546
|
-
dataset
|
|
547
|
-
}
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
};
|
|
551
|
-
this.hasBehavior = this.componentMethodsProxy('hasBehavior');
|
|
552
|
-
this.createSelectorQuery = this.componentMethodsProxy('createSelectorQuery');
|
|
553
|
-
this.createIntersectionObserver = this.componentMethodsProxy('createIntersectionObserver');
|
|
554
|
-
this.createMediaQueryObserver = this.componentMethodsProxy('createMediaQueryObserver');
|
|
555
|
-
this.getRelationNodes = this.componentMethodsProxy('getRelationNodes');
|
|
556
|
-
this.getTabBar = this.componentMethodsProxy('getTabBar');
|
|
557
|
-
this.getPageId = this.componentMethodsProxy('getPageId');
|
|
558
|
-
this.animate = this.componentMethodsProxy('animate');
|
|
559
|
-
this.clearAnimation = this.componentMethodsProxy('clearAnimation');
|
|
560
|
-
this.setUpdatePerformanceListener = this.componentMethodsProxy('setUpdatePerformanceListener');
|
|
561
|
-
this.state = this.state || {};
|
|
562
|
-
this.init(weappConf);
|
|
563
|
-
defineGetter(this, 'data', 'state');
|
|
564
|
-
defineGetter(this, 'properties', 'props');
|
|
565
|
-
this.initComputed(weappConf);
|
|
566
|
-
}
|
|
567
|
-
initProps(props) {
|
|
568
|
-
const properties = {};
|
|
569
|
-
for (const propKey in props) {
|
|
570
|
-
if (props.hasOwnProperty(propKey)) {
|
|
571
|
-
const propValue = props[propKey];
|
|
572
|
-
// propValue 可能是 null, 构造函数, 对象
|
|
573
|
-
const observers = [propToState];
|
|
574
|
-
if (propValue === null || propValue === undefined) { // propValue为null、undefined情况
|
|
575
|
-
properties[propKey] = null;
|
|
576
|
-
}
|
|
577
|
-
else if (isFunction(propValue)) { // propValue为Function,即Array、String、Boolean等情况时
|
|
578
|
-
if (propValue.name === 'Array') {
|
|
579
|
-
properties[propKey] = [];
|
|
580
|
-
}
|
|
581
|
-
else if (propValue.name === 'String') {
|
|
582
|
-
properties[propKey] = '';
|
|
583
|
-
}
|
|
584
|
-
else if (propValue.name === 'Boolean') {
|
|
585
|
-
properties[propKey] = false;
|
|
586
|
-
}
|
|
587
|
-
else if (propValue.name === 'Number') {
|
|
588
|
-
properties[propKey] = 0;
|
|
589
|
-
}
|
|
590
|
-
else {
|
|
591
|
-
properties[propKey] = null;
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
else if (typeof propValue === 'object') { // propValue为对象时
|
|
595
|
-
properties[propKey] = propValue.value;
|
|
596
|
-
if (propValue.observer) {
|
|
597
|
-
observers.push(propValue.observer);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
else {
|
|
601
|
-
properties[propKey] = null;
|
|
602
|
-
}
|
|
603
|
-
this._observeProps.push({
|
|
604
|
-
name: propKey,
|
|
605
|
-
observers: observers
|
|
606
|
-
});
|
|
607
|
-
}
|
|
619
|
+
break;
|
|
608
620
|
}
|
|
609
|
-
|
|
621
|
+
};
|
|
622
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
623
|
+
_loop();
|
|
624
|
+
}
|
|
625
|
+
} catch (err) {
|
|
626
|
+
_iterator.e(err);
|
|
627
|
+
} finally {
|
|
628
|
+
_iterator.f();
|
|
610
629
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
case 'created':
|
|
618
|
-
case 'attached':
|
|
619
|
-
case 'detached':
|
|
620
|
-
case 'ready':
|
|
621
|
-
list.forEach(fn => this.initLifeCycles(key, fn));
|
|
622
|
-
break;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
for (const confKey in options) {
|
|
627
|
-
// 不支持的属性
|
|
628
|
-
if (nonsupport.has(confKey)) {
|
|
629
|
-
const advise = nonsupport.get(confKey);
|
|
630
|
-
report(advise);
|
|
631
|
-
}
|
|
632
|
-
const confValue = options[confKey];
|
|
633
|
-
switch (confKey) {
|
|
634
|
-
case 'behaviors':
|
|
635
|
-
break;
|
|
636
|
-
case 'data': {
|
|
637
|
-
if (isApp) {
|
|
638
|
-
this[confKey] = confValue;
|
|
639
|
-
if (!appOptions.includes(confKey)) {
|
|
640
|
-
this.defineProperty(this.taroGlobalData, confKey, this);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
else {
|
|
644
|
-
this.state = Object.assign(Object.assign({}, confValue), this.state);
|
|
645
|
-
}
|
|
646
|
-
break;
|
|
647
|
-
}
|
|
648
|
-
case 'properties':
|
|
649
|
-
this.initProps(Object.assign(behaviorProperties, confValue));
|
|
650
|
-
break;
|
|
651
|
-
case 'methods':
|
|
652
|
-
this.methods = confValue;
|
|
653
|
-
for (const key in confValue) {
|
|
654
|
-
const method = confValue[key];
|
|
655
|
-
this[key] = bind(method, this);
|
|
656
|
-
}
|
|
657
|
-
break;
|
|
658
|
-
case 'lifetimes':
|
|
659
|
-
for (const key in confValue) {
|
|
660
|
-
this.initLifeCycles(key, confValue[key]);
|
|
661
|
-
}
|
|
662
|
-
break;
|
|
663
|
-
case 'pageLifetimes':
|
|
664
|
-
for (const key in confValue) {
|
|
665
|
-
const cb = confValue[key];
|
|
666
|
-
switch (key) {
|
|
667
|
-
case 'show': {
|
|
668
|
-
this.initLifeCycleListener('show', cb);
|
|
669
|
-
break;
|
|
670
|
-
}
|
|
671
|
-
case 'hide': {
|
|
672
|
-
this.initLifeCycleListener('hide', cb);
|
|
673
|
-
break;
|
|
674
|
-
}
|
|
675
|
-
case 'resize': {
|
|
676
|
-
report('不支持组件所在页面的生命周期 pageLifetimes.resize。');
|
|
677
|
-
break;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
break;
|
|
682
|
-
default:
|
|
683
|
-
if (lifecycles.has(confKey)) {
|
|
684
|
-
// 优先使用 lifetimes 中定义的生命周期
|
|
685
|
-
if ((_b = options.lifetimes) === null || _b === void 0 ? void 0 : _b[confKey]) {
|
|
686
|
-
break;
|
|
687
|
-
}
|
|
688
|
-
const lifecycle = options[confKey];
|
|
689
|
-
this.initLifeCycles(confKey, lifecycle);
|
|
690
|
-
}
|
|
691
|
-
else if (isFunction(confValue)) {
|
|
692
|
-
this[confKey] = bind(confValue, this);
|
|
693
|
-
if (isApp && !appOptions.includes(confKey)) {
|
|
694
|
-
this.defineProperty(this.taroGlobalData, confKey, this);
|
|
695
|
-
}
|
|
696
|
-
// 原生页面和 Taro 页面中共计只能定义一次的生命周期
|
|
697
|
-
if (uniquePageLifecycle.includes(confKey) && ConnectComponent.prototype[confKey]) {
|
|
698
|
-
report(`生命周期 ${confKey} 已在原生部分进行定义,React 部分的定义将不会被执行。`);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
else {
|
|
702
|
-
this[confKey] = confValue;
|
|
703
|
-
if (isApp && !appOptions.includes(confKey)) {
|
|
704
|
-
this.defineProperty(this.taroGlobalData, confKey, this);
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
break;
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
// 处理 Behaviors
|
|
711
|
-
if ((_c = options.behaviors) === null || _c === void 0 ? void 0 : _c.length) {
|
|
712
|
-
const behaviorData = {};
|
|
713
|
-
const methods = {};
|
|
714
|
-
for (const [key, list] of behaviorMap.entries()) {
|
|
715
|
-
switch (key) {
|
|
716
|
-
case 'data':
|
|
717
|
-
[...list, this.state].forEach((dataObject, index) => {
|
|
718
|
-
Object.keys(dataObject).forEach(dataKey => {
|
|
719
|
-
const value = dataObject[dataKey];
|
|
720
|
-
const preValue = behaviorData[dataKey];
|
|
721
|
-
const valueType = typeof value;
|
|
722
|
-
const preValueType = typeof preValue;
|
|
723
|
-
if (valueType === 'object') {
|
|
724
|
-
if (!value) {
|
|
725
|
-
behaviorData[dataKey] = value;
|
|
726
|
-
}
|
|
727
|
-
else if (preValueType !== 'object' || !preValueType || Array.isArray(value)) {
|
|
728
|
-
behaviorData[dataKey] = index === list.length ? value : clone(value);
|
|
729
|
-
}
|
|
730
|
-
else {
|
|
731
|
-
const newVal = Object.assign({}, preValue, value);
|
|
732
|
-
behaviorData[dataKey] = index === list.length ? newVal : clone(newVal);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
else {
|
|
736
|
-
behaviorData[dataKey] = value;
|
|
737
|
-
}
|
|
738
|
-
});
|
|
739
|
-
});
|
|
740
|
-
this.state = behaviorData;
|
|
741
|
-
break;
|
|
742
|
-
case 'methods':
|
|
743
|
-
list.forEach(methodsObject => {
|
|
744
|
-
Object.assign(methods, methodsObject);
|
|
745
|
-
});
|
|
746
|
-
Object.keys(methods).forEach(methodName => {
|
|
747
|
-
if (!this[methodName]) {
|
|
748
|
-
const method = methods[methodName];
|
|
749
|
-
this[methodName] = bind(method, this);
|
|
750
|
-
}
|
|
751
|
-
});
|
|
752
|
-
break;
|
|
753
|
-
case 'lifetimes':
|
|
754
|
-
list.forEach(lifetimesObject => {
|
|
755
|
-
for (const key in lifetimesObject) {
|
|
756
|
-
this.initLifeCycles(key, lifetimesObject[key]);
|
|
757
|
-
}
|
|
758
|
-
});
|
|
759
|
-
break;
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
}
|
|
630
|
+
}
|
|
631
|
+
for (var confKey in options) {
|
|
632
|
+
// 不支持的属性
|
|
633
|
+
if (nonsupport.has(confKey)) {
|
|
634
|
+
var advise = nonsupport.get(confKey);
|
|
635
|
+
report(advise);
|
|
763
636
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
return getter.call(Object.assign(Object.assign({}, this.state), this.methods));
|
|
775
|
-
},
|
|
776
|
-
enumerable: true, // 这将确保属性是可枚举的,如果你希望它出现在 for...in 循环中
|
|
777
|
-
configurable: true // 这将确保属性是可配置的,比如可以被删除
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
else {
|
|
781
|
-
report('computed 属性值必须是函数。');
|
|
782
|
-
}
|
|
637
|
+
var confValue = options[confKey];
|
|
638
|
+
switch (confKey) {
|
|
639
|
+
case 'behaviors':
|
|
640
|
+
break;
|
|
641
|
+
case 'data':
|
|
642
|
+
{
|
|
643
|
+
if (isApp) {
|
|
644
|
+
this[confKey] = confValue;
|
|
645
|
+
if (!appOptions.includes(confKey)) {
|
|
646
|
+
this.defineProperty(this.taroGlobalData, confKey, this);
|
|
783
647
|
}
|
|
648
|
+
} else {
|
|
649
|
+
this.state = Object.assign(Object.assign({}, confValue), this.state);
|
|
650
|
+
}
|
|
651
|
+
break;
|
|
784
652
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
if (lifecycleName === 'ready') {
|
|
793
|
-
// 如果组件是延时渲染的,页面 onReady 的事件已经 emit 了,因此使用 componentDidMount + nextTick 模拟
|
|
794
|
-
if (this.current.page.onReady.called) {
|
|
795
|
-
this.didMounts.push(function (...args) {
|
|
796
|
-
taro.nextTick(() => {
|
|
797
|
-
if (isFunction(lifecycle)) {
|
|
798
|
-
lifecycle.apply(this, args);
|
|
799
|
-
}
|
|
800
|
-
});
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
else {
|
|
804
|
-
this.initLifeCycleListener('ready', lifecycle);
|
|
805
|
-
}
|
|
653
|
+
case 'properties':
|
|
654
|
+
this.initProps(Object.assign(behaviorProperties, confValue));
|
|
655
|
+
break;
|
|
656
|
+
case 'methods':
|
|
657
|
+
for (var key in confValue) {
|
|
658
|
+
var method = confValue[key];
|
|
659
|
+
this[key] = bind(method, this);
|
|
806
660
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
switch (lifecycleKey) {
|
|
812
|
-
case TaroLifeCycles.DidHide:
|
|
813
|
-
this.didHides.push(lifecycle);
|
|
814
|
-
break;
|
|
815
|
-
case TaroLifeCycles.DidMount:
|
|
816
|
-
this.didMounts.push(lifecycle);
|
|
817
|
-
break;
|
|
818
|
-
case TaroLifeCycles.DidShow:
|
|
819
|
-
this.didShows.push(lifecycle);
|
|
820
|
-
break;
|
|
821
|
-
case TaroLifeCycles.WillMount:
|
|
822
|
-
this.willMounts.push(lifecycle);
|
|
823
|
-
break;
|
|
824
|
-
case TaroLifeCycles.WillUnmount:
|
|
825
|
-
this.willUnmounts.push(lifecycle);
|
|
826
|
-
break;
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
}
|
|
661
|
+
break;
|
|
662
|
+
case 'lifetimes':
|
|
663
|
+
for (var _key2 in confValue) {
|
|
664
|
+
this.initLifeCycles(_key2, confValue[_key2]);
|
|
830
665
|
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
666
|
+
break;
|
|
667
|
+
case 'pageLifetimes':
|
|
668
|
+
for (var _key3 in confValue) {
|
|
669
|
+
var cb = confValue[_key3];
|
|
670
|
+
switch (_key3) {
|
|
671
|
+
case 'show':
|
|
672
|
+
{
|
|
673
|
+
this.initLifeCycleListener('show', cb);
|
|
674
|
+
break;
|
|
675
|
+
}
|
|
676
|
+
case 'hide':
|
|
677
|
+
{
|
|
678
|
+
this.initLifeCycleListener('hide', cb);
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
681
|
+
case 'resize':
|
|
682
|
+
{
|
|
683
|
+
report('不支持组件所在页面的生命周期 pageLifetimes.resize。');
|
|
684
|
+
break;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
834
687
|
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
688
|
+
break;
|
|
689
|
+
default:
|
|
690
|
+
if (lifecycles.has(confKey)) {
|
|
691
|
+
// 优先使用 lifetimes 中定义的生命周期
|
|
692
|
+
if ((_b = options.lifetimes) === null || _b === void 0 ? void 0 : _b[confKey]) {
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
var lifecycle = options[confKey];
|
|
696
|
+
this.initLifeCycles(confKey, lifecycle);
|
|
697
|
+
} else if (isFunction(confValue)) {
|
|
698
|
+
this[confKey] = bind(confValue, this);
|
|
699
|
+
if (isApp && !appOptions.includes(confKey)) {
|
|
700
|
+
this.defineProperty(this.taroGlobalData, confKey, this);
|
|
701
|
+
}
|
|
702
|
+
// 原生页面和 Taro 页面中共计只能定义一次的生命周期
|
|
703
|
+
if (uniquePageLifecycle.includes(confKey) && ConnectComponent.prototype[confKey]) {
|
|
704
|
+
report("\u751F\u547D\u5468\u671F ".concat(confKey, " \u5DF2\u5728\u539F\u751F\u90E8\u5206\u8FDB\u884C\u5B9A\u4E49\uFF0CReact \u90E8\u5206\u7684\u5B9A\u4E49\u5C06\u4E0D\u4F1A\u88AB\u6267\u884C\u3002"));
|
|
705
|
+
}
|
|
706
|
+
} else {
|
|
707
|
+
this[confKey] = confValue;
|
|
708
|
+
if (isApp && !appOptions.includes(confKey)) {
|
|
709
|
+
this.defineProperty(this.taroGlobalData, confKey, this);
|
|
710
|
+
}
|
|
849
711
|
}
|
|
712
|
+
break;
|
|
850
713
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
return;
|
|
883
|
-
}
|
|
884
|
-
for (const observerKey in observers) {
|
|
885
|
-
if (/\*\*/.test(observerKey)) {
|
|
886
|
-
report('数据监听器 observers 不支持使用通配符 **。');
|
|
887
|
-
continue;
|
|
888
|
-
}
|
|
889
|
-
const keys = observerKey.split(',').map(k => k.trim());
|
|
890
|
-
let isModified = false;
|
|
891
|
-
for (let i = 0; i < keys.length; i++) {
|
|
892
|
-
const key = keys[i];
|
|
893
|
-
for (let j = 0; j < resultKeys.length; j++) {
|
|
894
|
-
const resultKey = resultKeys[j];
|
|
895
|
-
if (resultKey.startsWith(key) ||
|
|
896
|
-
(key.startsWith(resultKey) && key.endsWith(']'))) {
|
|
897
|
-
isModified = true;
|
|
898
|
-
}
|
|
714
|
+
}
|
|
715
|
+
// 处理 Behaviors
|
|
716
|
+
if ((_c = options.behaviors) === null || _c === void 0 ? void 0 : _c.length) {
|
|
717
|
+
var behaviorData = {};
|
|
718
|
+
var methods = {};
|
|
719
|
+
var _iterator2 = _createForOfIteratorHelper(behaviorMap.entries()),
|
|
720
|
+
_step2;
|
|
721
|
+
try {
|
|
722
|
+
var _loop2 = function _loop2() {
|
|
723
|
+
var _step2$value = _slicedToArray__default["default"](_step2.value, 2),
|
|
724
|
+
key = _step2$value[0],
|
|
725
|
+
list = _step2$value[1];
|
|
726
|
+
switch (key) {
|
|
727
|
+
case 'data':
|
|
728
|
+
[].concat(_toConsumableArray__default["default"](list), [_this2.state]).forEach(function (dataObject, index) {
|
|
729
|
+
Object.keys(dataObject).forEach(function (dataKey) {
|
|
730
|
+
var value = dataObject[dataKey];
|
|
731
|
+
var preValue = behaviorData[dataKey];
|
|
732
|
+
var valueType = _typeof__default["default"](value);
|
|
733
|
+
var preValueType = _typeof__default["default"](preValue);
|
|
734
|
+
if (valueType === 'object') {
|
|
735
|
+
if (!value) {
|
|
736
|
+
behaviorData[dataKey] = value;
|
|
737
|
+
} else if (preValueType !== 'object' || !preValueType || Array.isArray(value)) {
|
|
738
|
+
behaviorData[dataKey] = index === list.length ? value : clone(value);
|
|
739
|
+
} else {
|
|
740
|
+
var newVal = Object.assign({}, preValue, value);
|
|
741
|
+
behaviorData[dataKey] = index === list.length ? newVal : clone(newVal);
|
|
742
|
+
}
|
|
743
|
+
} else {
|
|
744
|
+
behaviorData[dataKey] = value;
|
|
899
745
|
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
746
|
+
});
|
|
747
|
+
});
|
|
748
|
+
_this2.state = behaviorData;
|
|
749
|
+
break;
|
|
750
|
+
case 'methods':
|
|
751
|
+
list.forEach(function (methodsObject) {
|
|
752
|
+
Object.assign(methods, methodsObject);
|
|
753
|
+
});
|
|
754
|
+
Object.keys(methods).forEach(function (methodName) {
|
|
755
|
+
if (!_this2[methodName]) {
|
|
756
|
+
var _method = methods[methodName];
|
|
757
|
+
_this2[methodName] = bind(_method, _this2);
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
break;
|
|
761
|
+
case 'lifetimes':
|
|
762
|
+
list.forEach(function (lifetimesObject) {
|
|
763
|
+
for (var _key4 in lifetimesObject) {
|
|
764
|
+
_this2.initLifeCycles(_key4, lifetimesObject[_key4]);
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
break;
|
|
768
|
+
default:
|
|
769
|
+
break;
|
|
904
770
|
}
|
|
771
|
+
};
|
|
772
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
773
|
+
_loop2();
|
|
774
|
+
}
|
|
775
|
+
} catch (err) {
|
|
776
|
+
_iterator2.e(err);
|
|
777
|
+
} finally {
|
|
778
|
+
_iterator2.f();
|
|
905
779
|
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}, {
|
|
783
|
+
key: "initLifeCycles",
|
|
784
|
+
value: function initLifeCycles(lifecycleName, lifecycle) {
|
|
785
|
+
// 不支持的生命周期
|
|
786
|
+
if (nonsupport.has(lifecycleName)) {
|
|
787
|
+
var advise = nonsupport.get(lifecycleName);
|
|
788
|
+
return report(advise);
|
|
789
|
+
}
|
|
790
|
+
if (lifecycleName === 'ready') {
|
|
791
|
+
// 如果组件是延时渲染的,页面 onReady 的事件已经 emit 了,因此使用 componentDidMount + nextTick 模拟
|
|
792
|
+
if (this.current.page.onReady.called) {
|
|
793
|
+
this.didMounts.push(function () {
|
|
794
|
+
var _this3 = this;
|
|
795
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key5 = 0; _key5 < _len2; _key5++) {
|
|
796
|
+
args[_key5] = arguments[_key5];
|
|
797
|
+
}
|
|
798
|
+
taro.nextTick(function () {
|
|
799
|
+
if (isFunction(lifecycle)) {
|
|
800
|
+
lifecycle.apply(_this3, args);
|
|
801
|
+
}
|
|
916
802
|
});
|
|
803
|
+
});
|
|
804
|
+
} else {
|
|
805
|
+
this.initLifeCycleListener('ready', lifecycle);
|
|
917
806
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
807
|
+
} else {
|
|
808
|
+
for (var lifecycleKey in lifecycleMap) {
|
|
809
|
+
var cycleNames = lifecycleMap[lifecycleKey];
|
|
810
|
+
if (cycleNames.indexOf(lifecycleName) !== -1) {
|
|
811
|
+
switch (lifecycleKey) {
|
|
812
|
+
case TaroLifeCycles.DidHide:
|
|
813
|
+
this.didHides.push(lifecycle);
|
|
814
|
+
break;
|
|
815
|
+
case TaroLifeCycles.DidMount:
|
|
816
|
+
this.didMounts.push(lifecycle);
|
|
817
|
+
break;
|
|
818
|
+
case TaroLifeCycles.DidShow:
|
|
819
|
+
this.didShows.push(lifecycle);
|
|
820
|
+
break;
|
|
821
|
+
case TaroLifeCycles.WillMount:
|
|
822
|
+
this.willMounts.push(lifecycle);
|
|
823
|
+
break;
|
|
824
|
+
case TaroLifeCycles.WillUnmount:
|
|
825
|
+
this.willUnmounts.push(lifecycle);
|
|
826
|
+
break;
|
|
930
827
|
}
|
|
931
|
-
|
|
932
|
-
isFunction(fn) && fn(e);
|
|
933
|
-
}
|
|
934
|
-
// ================ React 生命周期 ================
|
|
935
|
-
componentWillMount() {
|
|
936
|
-
this.safeExecute(super.componentWillMount);
|
|
937
|
-
this.executeLifeCycles(this.willMounts, this.current.router || {});
|
|
938
|
-
this.triggerObservers(this.data, BaseComponent.defaultProps);
|
|
939
|
-
this.triggerPropertiesObservers(BaseComponent.defaultProps, this.props);
|
|
940
|
-
}
|
|
941
|
-
componentDidMount() {
|
|
942
|
-
this.safeExecute(super.componentDidMount);
|
|
943
|
-
this.executeLifeCycles(this.didMounts);
|
|
944
|
-
}
|
|
945
|
-
componentWillUnmount() {
|
|
946
|
-
this.eventDestroyList.forEach(fn => fn());
|
|
947
|
-
this.safeExecute(super.componentWillUnmount);
|
|
948
|
-
this.executeLifeCycles(this.willUnmounts);
|
|
828
|
+
}
|
|
949
829
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
830
|
+
}
|
|
831
|
+
// mixins 不会覆盖已经设置的生命周期,加入到 this 是为了形如 this.created() 的调用
|
|
832
|
+
if (!isFunction(this[lifecycleName])) {
|
|
833
|
+
this[lifecycleName] = lifecycle;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}, {
|
|
837
|
+
key: "initLifeCycleListener",
|
|
838
|
+
value: function initLifeCycleListener(name, cb) {
|
|
839
|
+
// 组件的 ready、show、hide 需要利用页面事件触发
|
|
840
|
+
var router = this.current.router;
|
|
841
|
+
var lifecycleName = "on".concat(name[0].toUpperCase()).concat(name.slice(1));
|
|
842
|
+
cb = cb.bind(this);
|
|
843
|
+
(router === null || router === void 0 ? void 0 : router[lifecycleName]) && taro.eventCenter.on(router[lifecycleName], cb);
|
|
844
|
+
// unMount 时需要取消事件监听
|
|
845
|
+
this.eventDestroyList.push(function () {
|
|
846
|
+
return taro.eventCenter.off(router[lifecycleName], cb);
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
}, {
|
|
850
|
+
key: "executeLifeCycles",
|
|
851
|
+
value: function executeLifeCycles(funcs) {
|
|
852
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key6 = 1; _key6 < _len3; _key6++) {
|
|
853
|
+
args[_key6 - 1] = arguments[_key6];
|
|
854
|
+
}
|
|
855
|
+
for (var i = 0; i < funcs.length; i++) {
|
|
856
|
+
var func = funcs[i];
|
|
857
|
+
this.safeExecute.apply(this, [func].concat(args));
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}, {
|
|
861
|
+
key: "triggerPropertiesObservers",
|
|
862
|
+
value: function triggerPropertiesObservers(prevProps, nextProps) {
|
|
863
|
+
var _this4 = this;
|
|
864
|
+
this._observeProps.forEach(function (_ref) {
|
|
865
|
+
var key = _ref.name,
|
|
866
|
+
observers = _ref.observers;
|
|
867
|
+
var prop = prevProps === null || prevProps === void 0 ? void 0 : prevProps[key];
|
|
868
|
+
var nextProp = nextProps[key];
|
|
869
|
+
// 小程序是深比较不同之后才 trigger observer
|
|
870
|
+
if (!isEqual(prop, nextProp)) {
|
|
871
|
+
observers.forEach(function (observer) {
|
|
872
|
+
if (typeof observer === 'string') {
|
|
873
|
+
var ob = _this4[observer];
|
|
874
|
+
if (isFunction(ob)) {
|
|
875
|
+
ob.call(_this4, nextProp, prop, key);
|
|
876
|
+
}
|
|
877
|
+
} else if (isFunction(observer)) {
|
|
878
|
+
observer.call(_this4, nextProp, prop, key);
|
|
879
|
+
}
|
|
880
|
+
});
|
|
996
881
|
}
|
|
997
|
-
|
|
998
|
-
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
}, {
|
|
885
|
+
key: "triggerObservers",
|
|
886
|
+
value: function triggerObservers(current, prev) {
|
|
887
|
+
var observers = this.observers;
|
|
888
|
+
if (observers == null) {
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
if (Object.keys(observers).length === 0) {
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
var result = diff(current, prev);
|
|
895
|
+
var resultKeys = Object.keys(result);
|
|
896
|
+
if (resultKeys.length === 0) {
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
for (var observerKey in observers) {
|
|
900
|
+
if (/\*\*/.test(observerKey)) {
|
|
901
|
+
report('数据监听器 observers 不支持使用通配符 **。');
|
|
902
|
+
continue;
|
|
999
903
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
904
|
+
var keys = observerKey.split(',').map(function (k) {
|
|
905
|
+
return k.trim();
|
|
906
|
+
});
|
|
907
|
+
var isModified = false;
|
|
908
|
+
for (var i = 0; i < keys.length; i++) {
|
|
909
|
+
var key = keys[i];
|
|
910
|
+
for (var j = 0; j < resultKeys.length; j++) {
|
|
911
|
+
var resultKey = resultKeys[j];
|
|
912
|
+
if (resultKey.startsWith(key) || key.startsWith(resultKey) && key.endsWith(']')) {
|
|
913
|
+
isModified = true;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
1002
916
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
917
|
+
if (isModified) {
|
|
918
|
+
observers[observerKey].apply(this, keys.map(function (key) {
|
|
919
|
+
return safeGet(current, key);
|
|
920
|
+
}));
|
|
1005
921
|
}
|
|
922
|
+
}
|
|
1006
923
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
924
|
+
}, {
|
|
925
|
+
key: "defineProperty",
|
|
926
|
+
value: function defineProperty(target, key, data) {
|
|
927
|
+
Object.defineProperty(target, key, {
|
|
928
|
+
configurable: true,
|
|
929
|
+
enumerable: true,
|
|
930
|
+
set: function set(value) {
|
|
931
|
+
data[key] = value;
|
|
932
|
+
},
|
|
933
|
+
get: function get() {
|
|
934
|
+
return data[key];
|
|
1016
935
|
}
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
}, {
|
|
939
|
+
key: "privateStopNoop",
|
|
940
|
+
value: function privateStopNoop() {
|
|
941
|
+
var e;
|
|
942
|
+
var fn;
|
|
943
|
+
if (arguments.length === 2) {
|
|
944
|
+
fn = arguments.length <= 0 ? undefined : arguments[0];
|
|
945
|
+
e = arguments.length <= 1 ? undefined : arguments[1];
|
|
946
|
+
} else if (arguments.length === 1) {
|
|
947
|
+
e = arguments.length <= 0 ? undefined : arguments[0];
|
|
948
|
+
}
|
|
949
|
+
if (e.type === 'touchmove') {
|
|
950
|
+
report('catchtouchmove 转换后只能停止回调函数的冒泡,不能阻止滚动穿透。如要阻止滚动穿透,可以手动给编译后的 View 组件加上 catchMove 属性');
|
|
951
|
+
}
|
|
952
|
+
e.stopPropagation();
|
|
953
|
+
isFunction(fn) && fn(e);
|
|
954
|
+
}
|
|
955
|
+
// ================ React 生命周期 ================
|
|
956
|
+
}, {
|
|
957
|
+
key: "componentWillMount",
|
|
958
|
+
value: function componentWillMount() {
|
|
959
|
+
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentWillMount", this));
|
|
960
|
+
this.executeLifeCycles(this.willMounts, this.current.router || {});
|
|
961
|
+
this.triggerObservers(this.data, BaseComponent.defaultProps);
|
|
962
|
+
this.triggerPropertiesObservers(BaseComponent.defaultProps, this.props);
|
|
963
|
+
}
|
|
964
|
+
}, {
|
|
965
|
+
key: "componentDidMount",
|
|
966
|
+
value: function componentDidMount() {
|
|
967
|
+
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentDidMount", this));
|
|
968
|
+
this.executeLifeCycles(this.didMounts);
|
|
969
|
+
}
|
|
970
|
+
}, {
|
|
971
|
+
key: "componentWillUnmount",
|
|
972
|
+
value: function componentWillUnmount() {
|
|
973
|
+
this.eventDestroyList.forEach(function (fn) {
|
|
974
|
+
return fn();
|
|
975
|
+
});
|
|
976
|
+
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentWillUnmount", this));
|
|
977
|
+
this.executeLifeCycles(this.willUnmounts);
|
|
1017
978
|
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
979
|
+
}, {
|
|
980
|
+
key: "componentDidHide",
|
|
981
|
+
value: function componentDidHide() {
|
|
982
|
+
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentDidHide", this));
|
|
983
|
+
this.executeLifeCycles(this.didHides);
|
|
984
|
+
}
|
|
985
|
+
}, {
|
|
986
|
+
key: "componentDidShow",
|
|
987
|
+
value: function componentDidShow() {
|
|
988
|
+
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentDidShow", this), this.current.router || {});
|
|
989
|
+
this.executeLifeCycles(this.didShows, this.current.router || {});
|
|
990
|
+
}
|
|
991
|
+
}, {
|
|
992
|
+
key: "componentWillReceiveProps",
|
|
993
|
+
value: function componentWillReceiveProps(nextProps) {
|
|
994
|
+
this.triggerObservers(nextProps, this.props);
|
|
995
|
+
this.triggerPropertiesObservers(this.props, nextProps);
|
|
996
|
+
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentWillReceiveProps", this));
|
|
997
|
+
}
|
|
998
|
+
// ================ 小程序 App, Page, Component 实例属性与方法 ================
|
|
999
|
+
}, {
|
|
1000
|
+
key: "is",
|
|
1001
|
+
get: function get() {
|
|
1002
|
+
return this.current.page.is;
|
|
1003
|
+
}
|
|
1004
|
+
}, {
|
|
1005
|
+
key: "id",
|
|
1006
|
+
get: function get() {
|
|
1007
|
+
return this.current.page.id;
|
|
1008
|
+
}
|
|
1009
|
+
}, {
|
|
1010
|
+
key: "dataset",
|
|
1011
|
+
get: function get() {
|
|
1012
|
+
return this.current.page.dataset;
|
|
1013
|
+
}
|
|
1014
|
+
}, {
|
|
1015
|
+
key: "componentMethodsProxy",
|
|
1016
|
+
value: function componentMethodsProxy(method) {
|
|
1017
|
+
var _this5 = this;
|
|
1018
|
+
return function () {
|
|
1019
|
+
var page = _this5.current.page;
|
|
1020
|
+
if (page === null || page === void 0 ? void 0 : page[method]) {
|
|
1021
|
+
return page[method].apply(page, arguments);
|
|
1022
|
+
} else if (method === 'createSelectorQuery') {
|
|
1023
|
+
return taro.createSelectorQuery();
|
|
1024
|
+
} else if (method === 'createIntersectionObserver') {
|
|
1025
|
+
// @ts-ignore
|
|
1026
|
+
return taro.createIntersectionObserver.apply(void 0, arguments);
|
|
1027
|
+
} else if (method === 'createMediaQueryObserver') {
|
|
1028
|
+
return taro.createMediaQueryObserver();
|
|
1029
|
+
} else {
|
|
1030
|
+
console.error("page \u4E0B\u6CA1\u6709 ".concat(method, " \u65B9\u6CD5"));
|
|
1023
1031
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
}, {
|
|
1035
|
+
key: "selectComponent",
|
|
1036
|
+
value: function selectComponent() {
|
|
1037
|
+
report(nonsupport.get('selectComponent'));
|
|
1038
|
+
}
|
|
1039
|
+
}, {
|
|
1040
|
+
key: "selectAllComponents",
|
|
1041
|
+
value: function selectAllComponents() {
|
|
1042
|
+
report(nonsupport.get('selectAllComponents'));
|
|
1043
|
+
}
|
|
1044
|
+
}, {
|
|
1045
|
+
key: "selectOwnerComponent",
|
|
1046
|
+
value: function selectOwnerComponent() {
|
|
1047
|
+
report(nonsupport.get('selectOwnerComponent'));
|
|
1048
|
+
}
|
|
1049
|
+
}, {
|
|
1050
|
+
key: "groupSetData",
|
|
1051
|
+
value: function groupSetData() {
|
|
1052
|
+
report(nonsupport.get('groupSetData'));
|
|
1053
|
+
}
|
|
1054
|
+
}]);
|
|
1055
|
+
return BaseComponent;
|
|
1056
|
+
}(ConnectComponent);
|
|
1057
|
+
var props = weappConf.properties;
|
|
1058
|
+
if (props) {
|
|
1059
|
+
for (var propKey in props) {
|
|
1060
|
+
var propValue = props[propKey];
|
|
1061
|
+
if (propValue != null && !isFunction(propValue)) {
|
|
1062
|
+
if (propValue.value !== undefined) {
|
|
1063
|
+
// 如果是 null 也赋值到 defaultProps
|
|
1064
|
+
BaseComponent.defaultProps = Object.assign(_defineProperty__default["default"]({}, propKey, propValue.value), BaseComponent.defaultProps);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
var staticOptions = ['externalClasses', 'relations', 'options'];
|
|
1070
|
+
staticOptions.forEach(function (option) {
|
|
1071
|
+
var value = weappConf[option];
|
|
1072
|
+
if (value != null) {
|
|
1073
|
+
BaseComponent[option] = value;
|
|
1074
|
+
}
|
|
1075
|
+
});
|
|
1076
|
+
return BaseComponent;
|
|
1077
|
+
};
|
|
1027
1078
|
}
|
|
1028
1079
|
|
|
1029
1080
|
exports.cacheOptions = cacheOptions;
|
|
1030
1081
|
exports.convertToArray = convertToArray;
|
|
1031
|
-
exports
|
|
1082
|
+
exports["default"] = withWeapp;
|
|
1032
1083
|
exports.getTarget = getTarget;
|
|
1033
1084
|
|
|
1034
1085
|
Object.defineProperty(exports, '__esModule', { value: true });
|