@tarojs/with-weapp 3.5.0-canary.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +226 -226
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +250 -250
- package/dist/index.js.map +1 -1
- package/dist/with-weapp.js +254 -254
- 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
87
|
|
|
108
|
-
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
if (Array.isArray(obj[thisProp])) {
|
|
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; } } }; }
|
|
@@ -404,7 +404,7 @@
|
|
|
404
404
|
|
|
405
405
|
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; }
|
|
406
406
|
|
|
407
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf__default[
|
|
407
|
+
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); }; }
|
|
408
408
|
|
|
409
409
|
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; } }
|
|
410
410
|
|
|
@@ -429,7 +429,7 @@
|
|
|
429
429
|
function withWeapp(weappConf) {
|
|
430
430
|
var isApp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
431
431
|
|
|
432
|
-
if (_typeof__default[
|
|
432
|
+
if (_typeof__default["default"](weappConf) === 'object' && Object.keys(weappConf).length === 0) {
|
|
433
433
|
report('withWeapp 请传入“App/页面/组件“的配置对象。如果原生写法使用了基类,请将基类组合后的配置对象传入,详情请参考文档。');
|
|
434
434
|
}
|
|
435
435
|
|
|
@@ -458,7 +458,7 @@
|
|
|
458
458
|
}
|
|
459
459
|
|
|
460
460
|
if (!weappConf.properties.hasOwnProperty(propName)) {
|
|
461
|
-
if (propValue && _typeof__default[
|
|
461
|
+
if (propValue && _typeof__default["default"](propValue) === 'object' && propValue.value) {
|
|
462
462
|
propValue.value = clone(propValue.value);
|
|
463
463
|
}
|
|
464
464
|
|
|
@@ -469,14 +469,14 @@
|
|
|
469
469
|
}
|
|
470
470
|
|
|
471
471
|
var BaseComponent = /*#__PURE__*/function (_ConnectComponent) {
|
|
472
|
-
_inherits__default[
|
|
472
|
+
_inherits__default["default"](BaseComponent, _ConnectComponent);
|
|
473
473
|
|
|
474
474
|
var _super = _createSuper(BaseComponent);
|
|
475
475
|
|
|
476
476
|
function BaseComponent(props) {
|
|
477
477
|
var _this;
|
|
478
478
|
|
|
479
|
-
_classCallCheck__default[
|
|
479
|
+
_classCallCheck__default["default"](this, BaseComponent);
|
|
480
480
|
|
|
481
481
|
_this = _super.call(this, props);
|
|
482
482
|
_this._observeProps = []; // mixins 可以多次调用生命周期
|
|
@@ -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
|
|
|
@@ -495,7 +495,7 @@
|
|
|
495
495
|
args[_key - 1] = arguments[_key];
|
|
496
496
|
}
|
|
497
497
|
|
|
498
|
-
if (isFunction(func)) func.apply(_assertThisInitialized__default[
|
|
498
|
+
if (isFunction(func)) func.apply(_assertThisInitialized__default["default"](_this), args);
|
|
499
499
|
};
|
|
500
500
|
|
|
501
501
|
_this.setData = function (obj, callback) {
|
|
@@ -513,7 +513,7 @@
|
|
|
513
513
|
_this.triggerObservers(_this.state, oldState);
|
|
514
514
|
|
|
515
515
|
if (callback) {
|
|
516
|
-
callback.call(_assertThisInitialized__default[
|
|
516
|
+
callback.call(_assertThisInitialized__default["default"](_this));
|
|
517
517
|
}
|
|
518
518
|
});
|
|
519
519
|
};
|
|
@@ -534,7 +534,7 @@
|
|
|
534
534
|
var func = props["on".concat(eventName[0].toUpperCase()).concat(eventName.slice(1))];
|
|
535
535
|
|
|
536
536
|
if (isFunction(func)) {
|
|
537
|
-
func.call(_assertThisInitialized__default[
|
|
537
|
+
func.call(_assertThisInitialized__default["default"](_this), {
|
|
538
538
|
type: eventName,
|
|
539
539
|
detail: detail,
|
|
540
540
|
target: {
|
|
@@ -563,12 +563,12 @@
|
|
|
563
563
|
|
|
564
564
|
_this.init(weappConf);
|
|
565
565
|
|
|
566
|
-
defineGetter(_assertThisInitialized__default[
|
|
567
|
-
defineGetter(_assertThisInitialized__default[
|
|
566
|
+
defineGetter(_assertThisInitialized__default["default"](_this), 'data', 'state');
|
|
567
|
+
defineGetter(_assertThisInitialized__default["default"](_this), 'properties', 'props');
|
|
568
568
|
return _this;
|
|
569
569
|
}
|
|
570
570
|
|
|
571
|
-
_createClass__default[
|
|
571
|
+
_createClass__default["default"](BaseComponent, [{
|
|
572
572
|
key: "initProps",
|
|
573
573
|
value: function initProps(props) {
|
|
574
574
|
for (var propKey in props) {
|
|
@@ -600,7 +600,7 @@
|
|
|
600
600
|
|
|
601
601
|
try {
|
|
602
602
|
var _loop = function _loop() {
|
|
603
|
-
var _step$value = _slicedToArray__default[
|
|
603
|
+
var _step$value = _slicedToArray__default["default"](_step.value, 2),
|
|
604
604
|
key = _step$value[0],
|
|
605
605
|
list = _step$value[1];
|
|
606
606
|
|
|
@@ -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
|
|
|
@@ -743,20 +743,20 @@
|
|
|
743
743
|
|
|
744
744
|
try {
|
|
745
745
|
var _loop2 = function _loop2() {
|
|
746
|
-
var _step2$value = _slicedToArray__default[
|
|
746
|
+
var _step2$value = _slicedToArray__default["default"](_step2.value, 2),
|
|
747
747
|
key = _step2$value[0],
|
|
748
748
|
list = _step2$value[1];
|
|
749
749
|
|
|
750
750
|
switch (key) {
|
|
751
751
|
case 'data':
|
|
752
|
-
[].concat(_toConsumableArray__default[
|
|
752
|
+
[].concat(_toConsumableArray__default["default"](list), [_this2.state]).forEach(function (dataObject, index) {
|
|
753
753
|
Object.keys(dataObject).forEach(function (dataKey) {
|
|
754
754
|
var value = dataObject[dataKey];
|
|
755
755
|
var preValue = behaviorData[dataKey];
|
|
756
756
|
|
|
757
|
-
var valueType = _typeof__default[
|
|
757
|
+
var valueType = _typeof__default["default"](value);
|
|
758
758
|
|
|
759
|
-
var preValueType = _typeof__default[
|
|
759
|
+
var preValueType = _typeof__default["default"](preValue);
|
|
760
760
|
|
|
761
761
|
if (valueType === 'object') {
|
|
762
762
|
if (!value) {
|
|
@@ -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
|
}
|
|
@@ -1003,7 +1003,7 @@
|
|
|
1003
1003
|
}, {
|
|
1004
1004
|
key: "componentWillMount",
|
|
1005
1005
|
value: function componentWillMount() {
|
|
1006
|
-
this.safeExecute(_get__default[
|
|
1006
|
+
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentWillMount", this));
|
|
1007
1007
|
this.executeLifeCycles(this.willMounts, this.current.router || {});
|
|
1008
1008
|
this.triggerObservers(this.data, BaseComponent.defaultProps);
|
|
1009
1009
|
this.triggerPropertiesObservers(BaseComponent.defaultProps, this.props);
|
|
@@ -1011,28 +1011,28 @@
|
|
|
1011
1011
|
}, {
|
|
1012
1012
|
key: "componentDidMount",
|
|
1013
1013
|
value: function componentDidMount() {
|
|
1014
|
-
this.safeExecute(_get__default[
|
|
1014
|
+
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentDidMount", this));
|
|
1015
1015
|
this.executeLifeCycles(this.didMounts);
|
|
1016
1016
|
}
|
|
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
|
-
this.safeExecute(_get__default[
|
|
1023
|
+
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentWillUnmount", this));
|
|
1024
1024
|
this.executeLifeCycles(this.willUnmounts);
|
|
1025
1025
|
}
|
|
1026
1026
|
}, {
|
|
1027
1027
|
key: "componentDidHide",
|
|
1028
1028
|
value: function componentDidHide() {
|
|
1029
|
-
this.safeExecute(_get__default[
|
|
1029
|
+
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentDidHide", this));
|
|
1030
1030
|
this.executeLifeCycles(this.didHides);
|
|
1031
1031
|
}
|
|
1032
1032
|
}, {
|
|
1033
1033
|
key: "componentDidShow",
|
|
1034
1034
|
value: function componentDidShow() {
|
|
1035
|
-
this.safeExecute(_get__default[
|
|
1035
|
+
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentDidShow", this), this.current.router || {});
|
|
1036
1036
|
this.executeLifeCycles(this.didShows, this.current.router || {});
|
|
1037
1037
|
}
|
|
1038
1038
|
}, {
|
|
@@ -1040,7 +1040,7 @@
|
|
|
1040
1040
|
value: function componentWillReceiveProps(nextProps) {
|
|
1041
1041
|
this.triggerObservers(nextProps, this.props);
|
|
1042
1042
|
this.triggerPropertiesObservers(this.props, nextProps);
|
|
1043
|
-
this.safeExecute(_get__default[
|
|
1043
|
+
this.safeExecute(_get__default["default"](_getPrototypeOf__default["default"](BaseComponent.prototype), "componentWillReceiveProps", this));
|
|
1044
1044
|
} // ================ 小程序 App, Page, Component 实例属性与方法 ================
|
|
1045
1045
|
|
|
1046
1046
|
}, {
|
|
@@ -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
|
|
|
@@ -1107,7 +1107,7 @@
|
|
|
1107
1107
|
if (propValue != null && !isFunction(propValue)) {
|
|
1108
1108
|
if (propValue.value !== undefined) {
|
|
1109
1109
|
// 如果是 null 也赋值到 defaultProps
|
|
1110
|
-
BaseComponent.defaultProps = Object.assign(_defineProperty__default[
|
|
1110
|
+
BaseComponent.defaultProps = Object.assign(_defineProperty__default["default"]({}, propKey, propValue.value), BaseComponent.defaultProps);
|
|
1111
1111
|
}
|
|
1112
1112
|
}
|
|
1113
1113
|
}
|
|
@@ -1125,9 +1125,9 @@
|
|
|
1125
1125
|
};
|
|
1126
1126
|
}
|
|
1127
1127
|
|
|
1128
|
-
exports[
|
|
1128
|
+
exports["default"] = withWeapp;
|
|
1129
1129
|
|
|
1130
1130
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1131
1131
|
|
|
1132
|
-
}))
|
|
1132
|
+
}));
|
|
1133
1133
|
//# sourceMappingURL=with-weapp.js.map
|