@tarojs/with-weapp 3.5.0-beta.2 → 3.5.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +226 -226
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +226 -226
- package/dist/index.js.map +1 -1
- package/dist/with-weapp.js +229 -229
- package/dist/with-weapp.js.map +1 -1
- package/index.js +1 -0
- package/package.json +10 -11
- package/src/index.ts +20 -22
- package/src/utils.ts +3 -3
package/dist/with-weapp.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
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/
|
|
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/
|
|
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.
|
|
5
|
-
})(this, (function (exports, _defineProperty, _toConsumableArray, _slicedToArray, _classCallCheck, _createClass, _assertThisInitialized, _get, _inherits, _possibleConstructorReturn, _getPrototypeOf, _typeof,
|
|
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
|
|
|
@@ -18,166 +18,110 @@
|
|
|
18
18
|
var _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeOf);
|
|
19
19
|
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
|
20
20
|
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(function (TaroLifeCycles) {
|
|
26
|
-
TaroLifeCycles["WillMount"] = "componentWillMount";
|
|
27
|
-
TaroLifeCycles["DidMount"] = "componentDidMount";
|
|
28
|
-
TaroLifeCycles["DidShow"] = "componentDidShow";
|
|
29
|
-
TaroLifeCycles["DidHide"] = "componentDidHide";
|
|
30
|
-
TaroLifeCycles["WillUnmount"] = "componentWillUnmount";
|
|
31
|
-
})(TaroLifeCycles || (TaroLifeCycles = {}));
|
|
32
|
-
|
|
33
|
-
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);
|
|
34
|
-
var lifecycles = new Set(['ready']);
|
|
35
|
-
|
|
36
|
-
for (var key in lifecycleMap) {
|
|
37
|
-
var lifecycle = lifecycleMap[key];
|
|
38
|
-
lifecycle.forEach(function (l) {
|
|
39
|
-
return lifecycles.add(l);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
var uniquePageLifecycle = ['onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onShareTimeline', 'onAddToFavorites', 'onPageScroll', 'onResize', 'onTabItemTap'];
|
|
44
|
-
var appOptions = ['onLaunch', 'onShow', 'onHide', 'onError', 'onPageNotFound', 'onUnhandledRejection', 'onThemeChange'];
|
|
21
|
+
var json = JSON;
|
|
22
|
+
var clone = function clone(obj) {
|
|
23
|
+
return json.parse(stringify(obj));
|
|
24
|
+
};
|
|
45
25
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
function bind(fn
|
|
50
|
-
/*: Function */
|
|
51
|
-
, ctx
|
|
52
|
-
/*: Object */
|
|
53
|
-
) {
|
|
54
|
-
if (!fn) return false;
|
|
26
|
+
var isArray = Array.isArray || function (x) {
|
|
27
|
+
return {}.toString.call(x) === '[object Array]';
|
|
28
|
+
};
|
|
55
29
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx);
|
|
61
|
-
} // record original fn length
|
|
30
|
+
var objectKeys = Object.keys || function (obj) {
|
|
31
|
+
var has = Object.prototype.hasOwnProperty || function () {
|
|
32
|
+
return true;
|
|
33
|
+
};
|
|
62
34
|
|
|
35
|
+
var keys = [];
|
|
63
36
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
function isEqual(obj1, obj2) {
|
|
68
|
-
return JSON.stringify(obj1) === JSON.stringify(obj2);
|
|
69
|
-
}
|
|
70
|
-
function safeGet(obj, propsArg, defaultValue) {
|
|
71
|
-
if (!obj) {
|
|
72
|
-
return defaultValue;
|
|
37
|
+
for (var key in obj) {
|
|
38
|
+
if (has.call(obj, key)) keys.push(key);
|
|
73
39
|
}
|
|
74
40
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (Array.isArray(propsArg)) {
|
|
78
|
-
props = propsArg.slice(0);
|
|
79
|
-
}
|
|
41
|
+
return keys;
|
|
42
|
+
};
|
|
80
43
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
44
|
+
function stringify(obj, opts) {
|
|
45
|
+
if (!opts) opts = {};
|
|
46
|
+
if (typeof opts === 'function') opts = {
|
|
47
|
+
cmp: opts
|
|
48
|
+
};
|
|
49
|
+
var space = opts.space || '';
|
|
50
|
+
if (typeof space === 'number') space = Array(space + 1).join(' ');
|
|
51
|
+
var cycles = typeof opts.cycles === 'boolean' ? opts.cycles : false;
|
|
85
52
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
53
|
+
var replacer = opts.replacer || function (key, value) {
|
|
54
|
+
return value;
|
|
55
|
+
};
|
|
89
56
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
57
|
+
var cmp = opts.cmp && function (f) {
|
|
58
|
+
return function (node) {
|
|
59
|
+
return function (a, b) {
|
|
60
|
+
var aobj = {
|
|
61
|
+
key: a,
|
|
62
|
+
value: node[a]
|
|
63
|
+
};
|
|
64
|
+
var bobj = {
|
|
65
|
+
key: b,
|
|
66
|
+
value: node[b]
|
|
67
|
+
};
|
|
68
|
+
return f(aobj, bobj);
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
}(opts.cmp);
|
|
93
72
|
|
|
94
|
-
|
|
95
|
-
|
|
73
|
+
var seen = [];
|
|
74
|
+
return function stringify(parent, key, node, level) {
|
|
75
|
+
var indent = space ? '\n' + new Array(level + 1).join(space) : '';
|
|
76
|
+
var colonSeparator = space ? ': ' : ':';
|
|
96
77
|
|
|
97
|
-
if (
|
|
98
|
-
|
|
78
|
+
if (node && node.toJSON && typeof node.toJSON === 'function') {
|
|
79
|
+
node = node.toJSON();
|
|
99
80
|
}
|
|
100
81
|
|
|
101
|
-
|
|
82
|
+
node = replacer.call(parent, key, node);
|
|
102
83
|
|
|
103
|
-
if (
|
|
104
|
-
return
|
|
84
|
+
if (node === undefined) {
|
|
85
|
+
return;
|
|
105
86
|
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return obj;
|
|
109
|
-
}
|
|
110
|
-
function safeSet(obj, props, value) {
|
|
111
|
-
if (typeof props === 'string') {
|
|
112
|
-
props = props.replace(/\[(.+?)\]/g, '.$1');
|
|
113
|
-
props = props.split('.');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (_typeof__default["default"](props) === 'symbol') {
|
|
117
|
-
props = [props];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
var lastProp = props.pop();
|
|
121
|
-
|
|
122
|
-
if (!lastProp) {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
var thisProp;
|
|
127
|
-
|
|
128
|
-
while (thisProp = props.shift()) {
|
|
129
|
-
if (typeof obj[thisProp] === 'undefined') {
|
|
130
|
-
obj[thisProp] = {};
|
|
131
|
-
} // 直接按路径修改 this.state 可能会导致 nextProps 也被修改
|
|
132
|
-
// 因此按路径寻找时,每一层都复制一遍
|
|
133
87
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
obj[thisProp] = _toConsumableArray__default["default"](obj[thisProp]);
|
|
137
|
-
} else if (_typeof__default["default"](obj[thisProp]) === 'object') {
|
|
138
|
-
obj[thisProp] = Object.assign({}, obj[thisProp]);
|
|
88
|
+
if (_typeof__default["default"](node) !== 'object' || node === null) {
|
|
89
|
+
return json.stringify(node);
|
|
139
90
|
}
|
|
140
91
|
|
|
141
|
-
|
|
92
|
+
if (isArray(node)) {
|
|
93
|
+
var out = [];
|
|
142
94
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
95
|
+
for (var i = 0; i < node.length; i++) {
|
|
96
|
+
var item = stringify(node, i, node[i], level + 1) || json.stringify(null);
|
|
97
|
+
out.push(indent + space + item);
|
|
98
|
+
}
|
|
147
99
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
var unsupport = 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 语法重构。']]);
|
|
155
|
-
function flattenBehaviors(behavior, behaviorMap) {
|
|
156
|
-
if (typeof behavior === 'string') {
|
|
157
|
-
return report("\u4E0D\u652F\u6301\u4F7F\u7528\u5185\u7F6E Behavior: [".concat(behavior, "]"));
|
|
158
|
-
}
|
|
100
|
+
return '[' + out.join(',') + indent + ']';
|
|
101
|
+
} else {
|
|
102
|
+
if (seen.indexOf(node) !== -1) {
|
|
103
|
+
if (cycles) return json.stringify('__cycle__');
|
|
104
|
+
throw new TypeError('Converting circular structure to JSON');
|
|
105
|
+
} else seen.push(node);
|
|
159
106
|
|
|
160
|
-
|
|
107
|
+
var keys = objectKeys(node).sort(cmp && cmp(node));
|
|
108
|
+
var _out = [];
|
|
161
109
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
110
|
+
for (var _i = 0; _i < keys.length; _i++) {
|
|
111
|
+
var _key = keys[_i];
|
|
112
|
+
var value = stringify(node, _key, node[_key], level + 1);
|
|
113
|
+
if (!value) continue;
|
|
114
|
+
var keyValue = json.stringify(_key) + colonSeparator + value;
|
|
167
115
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (unsupport.has(key)) {
|
|
171
|
-
var advise = unsupport.get(key);
|
|
172
|
-
return report(advise);
|
|
173
|
-
}
|
|
116
|
+
_out.push(indent + space + keyValue);
|
|
117
|
+
}
|
|
174
118
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
var value = behavior[key];
|
|
178
|
-
list.push(value);
|
|
119
|
+
seen.splice(seen.indexOf(node), 1);
|
|
120
|
+
return '{' + _out.join(',') + indent + '}';
|
|
179
121
|
}
|
|
180
|
-
}
|
|
122
|
+
}({
|
|
123
|
+
'': obj
|
|
124
|
+
}, '', obj, 0);
|
|
181
125
|
}
|
|
182
126
|
|
|
183
127
|
/*eslint-disable*/
|
|
@@ -292,110 +236,166 @@
|
|
|
292
236
|
return Object.prototype.toString.call(obj);
|
|
293
237
|
}
|
|
294
238
|
|
|
295
|
-
var
|
|
296
|
-
var clone = function clone(obj) {
|
|
297
|
-
return json.parse(stringify(obj));
|
|
298
|
-
};
|
|
239
|
+
var _lifecycleMap;
|
|
299
240
|
|
|
300
|
-
var
|
|
301
|
-
return {}.toString.call(x) === '[object Array]';
|
|
302
|
-
};
|
|
241
|
+
var TaroLifeCycles;
|
|
303
242
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
243
|
+
(function (TaroLifeCycles) {
|
|
244
|
+
TaroLifeCycles["WillMount"] = "componentWillMount";
|
|
245
|
+
TaroLifeCycles["DidMount"] = "componentDidMount";
|
|
246
|
+
TaroLifeCycles["DidShow"] = "componentDidShow";
|
|
247
|
+
TaroLifeCycles["DidHide"] = "componentDidHide";
|
|
248
|
+
TaroLifeCycles["WillUnmount"] = "componentWillUnmount";
|
|
249
|
+
})(TaroLifeCycles || (TaroLifeCycles = {}));
|
|
308
250
|
|
|
309
|
-
|
|
251
|
+
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);
|
|
252
|
+
var lifecycles = new Set(['ready']);
|
|
310
253
|
|
|
311
|
-
|
|
312
|
-
|
|
254
|
+
for (var key in lifecycleMap) {
|
|
255
|
+
var lifecycle = lifecycleMap[key];
|
|
256
|
+
lifecycle.forEach(function (l) {
|
|
257
|
+
return lifecycles.add(l);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
var uniquePageLifecycle = ['onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onShareTimeline', 'onAddToFavorites', 'onPageScroll', 'onResize', 'onTabItemTap'];
|
|
262
|
+
var appOptions = ['onLaunch', 'onShow', 'onHide', 'onError', 'onPageNotFound', 'onUnhandledRejection', 'onThemeChange'];
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Simple bind, faster than native
|
|
266
|
+
*/
|
|
267
|
+
function bind(fn
|
|
268
|
+
/*: Function */
|
|
269
|
+
, ctx
|
|
270
|
+
/*: Object */
|
|
271
|
+
) {
|
|
272
|
+
if (!fn) return false;
|
|
273
|
+
|
|
274
|
+
function boundFn(a) {
|
|
275
|
+
var l
|
|
276
|
+
/*: number */
|
|
277
|
+
= arguments.length;
|
|
278
|
+
return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx);
|
|
279
|
+
} // record original fn length
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
boundFn._length = fn.length;
|
|
283
|
+
return boundFn;
|
|
284
|
+
}
|
|
285
|
+
function isEqual(obj1, obj2) {
|
|
286
|
+
return JSON.stringify(obj1) === JSON.stringify(obj2);
|
|
287
|
+
}
|
|
288
|
+
function safeGet(obj, propsArg, defaultValue) {
|
|
289
|
+
if (!obj) {
|
|
290
|
+
return defaultValue;
|
|
313
291
|
}
|
|
314
292
|
|
|
315
|
-
|
|
316
|
-
};
|
|
293
|
+
var props, prop;
|
|
317
294
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
cmp: opts
|
|
322
|
-
};
|
|
323
|
-
var space = opts.space || '';
|
|
324
|
-
if (typeof space === 'number') space = Array(space + 1).join(' ');
|
|
325
|
-
var cycles = typeof opts.cycles === 'boolean' ? opts.cycles : false;
|
|
295
|
+
if (Array.isArray(propsArg)) {
|
|
296
|
+
props = propsArg.slice(0);
|
|
297
|
+
}
|
|
326
298
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
299
|
+
if (typeof propsArg === 'string') {
|
|
300
|
+
props = propsArg.replace(/\[(.+?)\]/g, '.$1');
|
|
301
|
+
props = props.split('.');
|
|
302
|
+
}
|
|
330
303
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
var aobj = {
|
|
335
|
-
key: a,
|
|
336
|
-
value: node[a]
|
|
337
|
-
};
|
|
338
|
-
var bobj = {
|
|
339
|
-
key: b,
|
|
340
|
-
value: node[b]
|
|
341
|
-
};
|
|
342
|
-
return f(aobj, bobj);
|
|
343
|
-
};
|
|
344
|
-
};
|
|
345
|
-
}(opts.cmp);
|
|
304
|
+
if (_typeof__default["default"](propsArg) === 'symbol') {
|
|
305
|
+
props = [propsArg];
|
|
306
|
+
}
|
|
346
307
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
var colonSeparator = space ? ': ' : ':';
|
|
308
|
+
if (!Array.isArray(props)) {
|
|
309
|
+
throw new Error('props arg must be an array, a string or a symbol');
|
|
310
|
+
}
|
|
351
311
|
|
|
352
|
-
|
|
353
|
-
|
|
312
|
+
while (props.length) {
|
|
313
|
+
prop = props.shift();
|
|
314
|
+
|
|
315
|
+
if (!obj) {
|
|
316
|
+
return defaultValue;
|
|
354
317
|
}
|
|
355
318
|
|
|
356
|
-
|
|
319
|
+
obj = obj[prop];
|
|
357
320
|
|
|
358
|
-
if (
|
|
359
|
-
return;
|
|
321
|
+
if (obj === undefined) {
|
|
322
|
+
return defaultValue;
|
|
360
323
|
}
|
|
324
|
+
}
|
|
361
325
|
|
|
362
|
-
|
|
363
|
-
|
|
326
|
+
return obj;
|
|
327
|
+
}
|
|
328
|
+
function safeSet(obj, props, value) {
|
|
329
|
+
if (typeof props === 'string') {
|
|
330
|
+
props = props.replace(/\[(.+?)\]/g, '.$1');
|
|
331
|
+
props = props.split('.');
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (_typeof__default["default"](props) === 'symbol') {
|
|
335
|
+
props = [props];
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
var lastProp = props.pop();
|
|
339
|
+
|
|
340
|
+
if (!lastProp) {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
var thisProp;
|
|
345
|
+
|
|
346
|
+
while (thisProp = props.shift()) {
|
|
347
|
+
if (typeof obj[thisProp] === 'undefined') {
|
|
348
|
+
obj[thisProp] = {};
|
|
349
|
+
} // 直接按路径修改 this.state 可能会导致 nextProps 也被修改
|
|
350
|
+
// 因此按路径寻找时,每一层都复制一遍
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
if (Array.isArray(obj[thisProp])) {
|
|
354
|
+
obj[thisProp] = _toConsumableArray__default["default"](obj[thisProp]);
|
|
355
|
+
} else if (_typeof__default["default"](obj[thisProp]) === 'object') {
|
|
356
|
+
obj[thisProp] = Object.assign({}, obj[thisProp]);
|
|
364
357
|
}
|
|
365
358
|
|
|
366
|
-
|
|
367
|
-
var out = [];
|
|
359
|
+
obj = obj[thisProp];
|
|
368
360
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
361
|
+
if (!obj || _typeof__default["default"](obj) !== 'object') {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
373
365
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
366
|
+
obj[lastProp] = value;
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
function report(msg) {
|
|
370
|
+
console.warn('[Taro Convert Warning] ' + msg);
|
|
371
|
+
}
|
|
372
|
+
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 语法重构。']]);
|
|
373
|
+
function flattenBehaviors(behavior, behaviorMap) {
|
|
374
|
+
if (typeof behavior === 'string') {
|
|
375
|
+
return report("\u4E0D\u652F\u6301\u4F7F\u7528\u5185\u7F6E Behavior: [".concat(behavior, "]"));
|
|
376
|
+
}
|
|
380
377
|
|
|
381
|
-
|
|
382
|
-
var _out = [];
|
|
378
|
+
var subBehaviors = behavior.behaviors;
|
|
383
379
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
380
|
+
if (subBehaviors === null || subBehaviors === void 0 ? void 0 : subBehaviors.length) {
|
|
381
|
+
subBehaviors.forEach(function (subBehavior) {
|
|
382
|
+
return flattenBehaviors(subBehavior, behaviorMap);
|
|
383
|
+
});
|
|
384
|
+
}
|
|
389
385
|
|
|
390
|
-
|
|
391
|
-
|
|
386
|
+
Object.keys(behavior).forEach(function (key) {
|
|
387
|
+
// 不支持的属性
|
|
388
|
+
if (nonsupport.has(key)) {
|
|
389
|
+
var advise = nonsupport.get(key);
|
|
390
|
+
return report(advise);
|
|
391
|
+
}
|
|
392
392
|
|
|
393
|
-
|
|
394
|
-
|
|
393
|
+
if (behaviorMap.has(key)) {
|
|
394
|
+
var list = behaviorMap.get(key);
|
|
395
|
+
var value = behavior[key];
|
|
396
|
+
list.push(value);
|
|
395
397
|
}
|
|
396
|
-
}
|
|
397
|
-
'': obj
|
|
398
|
-
}, '', obj, 0);
|
|
398
|
+
});
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
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; } } }; }
|
|
@@ -486,7 +486,7 @@
|
|
|
486
486
|
_this.didHides = [];
|
|
487
487
|
_this.didShows = [];
|
|
488
488
|
_this.willUnmounts = [];
|
|
489
|
-
_this.
|
|
489
|
+
_this.eventDestroyList = [];
|
|
490
490
|
_this.current = runtime.getCurrentInstance();
|
|
491
491
|
_this.taroGlobalData = Object.create(null);
|
|
492
492
|
|
|
@@ -628,8 +628,8 @@
|
|
|
628
628
|
|
|
629
629
|
for (var confKey in options) {
|
|
630
630
|
// 不支持的属性
|
|
631
|
-
if (
|
|
632
|
-
var advise =
|
|
631
|
+
if (nonsupport.has(confKey)) {
|
|
632
|
+
var advise = nonsupport.get(confKey);
|
|
633
633
|
report(advise);
|
|
634
634
|
}
|
|
635
635
|
|
|
@@ -807,8 +807,8 @@
|
|
|
807
807
|
key: "initLifeCycles",
|
|
808
808
|
value: function initLifeCycles(lifecycleName, lifecycle) {
|
|
809
809
|
// 不支持的生命周期
|
|
810
|
-
if (
|
|
811
|
-
var advise =
|
|
810
|
+
if (nonsupport.has(lifecycleName)) {
|
|
811
|
+
var advise = nonsupport.get(lifecycleName);
|
|
812
812
|
return report(advise);
|
|
813
813
|
}
|
|
814
814
|
|
|
@@ -875,7 +875,7 @@
|
|
|
875
875
|
cb = cb.bind(this);
|
|
876
876
|
(router === null || router === void 0 ? void 0 : router[lifecycleName]) && taro.eventCenter.on(router[lifecycleName], cb); // unMount 时需要取消事件监听
|
|
877
877
|
|
|
878
|
-
this.
|
|
878
|
+
this.eventDestroyList.push(function () {
|
|
879
879
|
return taro.eventCenter.off(router[lifecycleName], cb);
|
|
880
880
|
});
|
|
881
881
|
}
|
|
@@ -1017,7 +1017,7 @@
|
|
|
1017
1017
|
}, {
|
|
1018
1018
|
key: "componentWillUnmount",
|
|
1019
1019
|
value: function componentWillUnmount() {
|
|
1020
|
-
this.
|
|
1020
|
+
this.eventDestroyList.forEach(function (fn) {
|
|
1021
1021
|
return fn();
|
|
1022
1022
|
});
|
|
1023
1023
|
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentWillUnmount", this));
|
|
@@ -1076,22 +1076,22 @@
|
|
|
1076
1076
|
}, {
|
|
1077
1077
|
key: "selectComponent",
|
|
1078
1078
|
value: function selectComponent() {
|
|
1079
|
-
report(
|
|
1079
|
+
report(nonsupport.get('selectComponent'));
|
|
1080
1080
|
}
|
|
1081
1081
|
}, {
|
|
1082
1082
|
key: "selectAllComponents",
|
|
1083
1083
|
value: function selectAllComponents() {
|
|
1084
|
-
report(
|
|
1084
|
+
report(nonsupport.get('selectAllComponents'));
|
|
1085
1085
|
}
|
|
1086
1086
|
}, {
|
|
1087
1087
|
key: "selectOwnerComponent",
|
|
1088
1088
|
value: function selectOwnerComponent() {
|
|
1089
|
-
report(
|
|
1089
|
+
report(nonsupport.get('selectOwnerComponent'));
|
|
1090
1090
|
}
|
|
1091
1091
|
}, {
|
|
1092
1092
|
key: "groupSetData",
|
|
1093
1093
|
value: function groupSetData() {
|
|
1094
|
-
report(
|
|
1094
|
+
report(nonsupport.get('groupSetData'));
|
|
1095
1095
|
}
|
|
1096
1096
|
}]);
|
|
1097
1097
|
|