1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | Object.defineProperty(exports, '__esModule', { value: true });
|
7 |
|
8 | var arrayPush = Array.prototype.push;
|
9 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
10 | var gSBU = 'getSnapshotBeforeUpdate';
|
11 | var gDSFP = 'getDerivedStateFromProps';
|
12 | var hasSymbol = typeof Symbol === 'function' && Symbol['for'];
|
13 | var effects = [];
|
14 | var topFibers = [];
|
15 | var topNodes = [];
|
16 | var emptyObject = {};
|
17 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol['for']('react.element') : 0xeac7;
|
18 | function noop() {}
|
19 | function Fragment(props) {
|
20 | return props.children;
|
21 | }
|
22 | function returnFalse() {
|
23 | return false;
|
24 | }
|
25 | function returnTrue() {
|
26 | return true;
|
27 | }
|
28 | function resetStack(info) {
|
29 | keepLast(info.containerStack);
|
30 | keepLast(info.contextStack);
|
31 | }
|
32 | function keepLast(list) {
|
33 | var n = list.length;
|
34 | list.splice(0, n - 1);
|
35 | }
|
36 | function get(key) {
|
37 | return key._reactInternalFiber;
|
38 | }
|
39 | var __type = Object.prototype.toString;
|
40 | var fakeWindow = {};
|
41 | function getWindow() {
|
42 | try {
|
43 | if (window) {
|
44 | return window;
|
45 | }
|
46 | } catch (e) { }
|
47 | try {
|
48 | if (global) {
|
49 | return global;
|
50 | }
|
51 | } catch (e) { }
|
52 | return fakeWindow;
|
53 | }
|
54 | function isMounted(instance) {
|
55 | var fiber = get(instance);
|
56 | return !!(fiber && fiber.hasMounted);
|
57 | }
|
58 | function toWarnDev(msg, deprecated) {
|
59 | msg = deprecated ? msg + ' is deprecated' : msg;
|
60 | var process = getWindow().process;
|
61 | if (process && process.env.NODE_ENV === 'development') {
|
62 | throw msg;
|
63 | }
|
64 | }
|
65 | function extend(obj, props) {
|
66 | for (var i in props) {
|
67 | if (hasOwnProperty.call(props, i)) {
|
68 | obj[i] = props[i];
|
69 | }
|
70 | }
|
71 | return obj;
|
72 | }
|
73 | function inherit(SubClass, SupClass) {
|
74 | function Bridge() {}
|
75 | var orig = SubClass.prototype;
|
76 | Bridge.prototype = SupClass.prototype;
|
77 | var fn = SubClass.prototype = new Bridge();
|
78 | extend(fn, orig);
|
79 | fn.constructor = SubClass;
|
80 | return fn;
|
81 | }
|
82 | try {
|
83 | var supportEval = Function('a', 'return a + 1')(2) == 3;
|
84 | } catch (e) {}
|
85 | var rname = /function\s+(\w+)/;
|
86 | function miniCreateClass(ctor, superClass, methods, statics) {
|
87 | var className = ctor.name || (ctor.toString().match(rname) || ['', 'Anonymous'])[1];
|
88 | var Ctor = supportEval ? Function('superClass', 'ctor', 'return function ' + className + ' (props, context) {\n superClass.apply(this, arguments); \n ctor.apply(this, arguments);\n }')(superClass, ctor) : function ReactInstance() {
|
89 | superClass.apply(this, arguments);
|
90 | ctor.apply(this, arguments);
|
91 | };
|
92 | Ctor.displayName = className;
|
93 | var proto = inherit(Ctor, superClass);
|
94 | extend(proto, methods);
|
95 | extend(Ctor, superClass);
|
96 | if (statics) {
|
97 | extend(Ctor, statics);
|
98 | }
|
99 | return Ctor;
|
100 | }
|
101 | var lowerCache = {};
|
102 | function toLowerCase(s) {
|
103 | return lowerCache[s] || (lowerCache[s] = s.toLowerCase());
|
104 | }
|
105 | function isFn(obj) {
|
106 | return __type.call(obj) === '[object Function]';
|
107 | }
|
108 | var numberMap = {
|
109 | '[object Boolean]': 2,
|
110 | '[object Number]': 3,
|
111 | '[object String]': 4,
|
112 | '[object Function]': 5,
|
113 | '[object Symbol]': 6,
|
114 | '[object Array]': 7
|
115 | };
|
116 | function typeNumber(data) {
|
117 | if (data === null) {
|
118 | return 1;
|
119 | }
|
120 | if (data === void 666) {
|
121 | return 0;
|
122 | }
|
123 | var a = numberMap[__type.call(data)];
|
124 | return a || 8;
|
125 | }
|
126 |
|
127 | function createRenderer(methods) {
|
128 | return extend(Renderer, methods);
|
129 | }
|
130 | var middlewares = [];
|
131 | var Renderer = {
|
132 | controlledCbs: [],
|
133 | mountOrder: 1,
|
134 | macrotasks: [],
|
135 | boundaries: [],
|
136 | onBeforeRender: noop,
|
137 | onAfterRender: noop,
|
138 | onDispose: noop,
|
139 | middleware: function middleware(obj) {
|
140 | if (obj.begin && obj.end) {
|
141 | middlewares.push(obj);
|
142 | }
|
143 | },
|
144 | updateControlled: function updateControlled() {},
|
145 | fireMiddlewares: function fireMiddlewares(begin) {
|
146 | var index = begin ? middlewares.length - 1 : 0,
|
147 | delta = begin ? -1 : 1,
|
148 | method = begin ? "begin" : "end",
|
149 | obj = void 0;
|
150 | while (obj = middlewares[index]) {
|
151 | obj[method]();
|
152 | index += delta;
|
153 | }
|
154 | },
|
155 | currentOwner: null
|
156 | };
|
157 |
|
158 | var fakeObject = {
|
159 | enqueueSetState: returnFalse,
|
160 | isMounted: returnFalse
|
161 | };
|
162 | function Component(props, context) {
|
163 | Renderer.currentOwner = this;
|
164 | this.context = context;
|
165 | this.props = props;
|
166 | this.refs = {};
|
167 | this.updater = fakeObject;
|
168 | this.state = null;
|
169 | }
|
170 | Component.prototype = {
|
171 | constructor: Component,
|
172 | replaceState: function replaceState() {
|
173 | toWarnDev("replaceState", true);
|
174 | },
|
175 | isReactComponent: returnTrue,
|
176 | isMounted: function isMounted$$1() {
|
177 | toWarnDev("isMounted", true);
|
178 | return this.updater.isMounted(this);
|
179 | },
|
180 | setState: function setState(state, cb) {
|
181 | this.updater.enqueueSetState(get(this), state, cb);
|
182 | },
|
183 | forceUpdate: function forceUpdate(cb) {
|
184 | this.updater.enqueueSetState(get(this), true, cb);
|
185 | },
|
186 | render: function render() {
|
187 | throw "must implement render";
|
188 | }
|
189 | };
|
190 |
|
191 | var RESERVED_PROPS = {
|
192 | key: true,
|
193 | ref: true,
|
194 | __self: true,
|
195 | __source: true
|
196 | };
|
197 | function makeProps(type, config, props, children, len) {
|
198 | var defaultProps = void 0,
|
199 | propName = void 0;
|
200 | for (propName in config) {
|
201 | if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
202 | props[propName] = config[propName];
|
203 | }
|
204 | }
|
205 | if (type && type.defaultProps) {
|
206 | defaultProps = type.defaultProps;
|
207 | for (propName in defaultProps) {
|
208 | if (props[propName] === undefined) {
|
209 | props[propName] = defaultProps[propName];
|
210 | }
|
211 | }
|
212 | }
|
213 | if (len === 1) {
|
214 | props.children = children[0];
|
215 | } else if (len > 1) {
|
216 | props.children = children;
|
217 | }
|
218 | return props;
|
219 | }
|
220 | function hasValidRef(config) {
|
221 | return config.ref !== undefined;
|
222 | }
|
223 | function hasValidKey(config) {
|
224 | return config.key !== undefined;
|
225 | }
|
226 | function createElement(type, config) {
|
227 | for (var _len = arguments.length, children = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
228 | children[_key - 2] = arguments[_key];
|
229 | }
|
230 | var props = {},
|
231 | tag = 5,
|
232 | key = null,
|
233 | ref = null,
|
234 | argsLen = children.length;
|
235 | if (type && type.call) {
|
236 | tag = type.prototype && type.prototype.render ? 2 : 1;
|
237 | } else if (type + '' !== type) {
|
238 | toWarnDev('React.createElement: type is invalid.');
|
239 | }
|
240 | if (config != null) {
|
241 | if (hasValidRef(config)) {
|
242 | ref = config.ref;
|
243 | }
|
244 | if (hasValidKey(config)) {
|
245 | key = '' + config.key;
|
246 | }
|
247 | }
|
248 | props = makeProps(type, config || {}, props, children, argsLen);
|
249 | return ReactElement(type, tag, props, key, ref, Renderer.currentOwner);
|
250 | }
|
251 | function createFactory(type) {
|
252 | var factory = createElement.bind(null, type);
|
253 | factory.type = type;
|
254 | return factory;
|
255 | }
|
256 | function ReactElement(type, tag, props, key, ref, owner) {
|
257 | var ret = {
|
258 | type: type,
|
259 | tag: tag,
|
260 | props: props
|
261 | };
|
262 | if (tag !== 6) {
|
263 | ret.$$typeof = REACT_ELEMENT_TYPE;
|
264 | ret.key = key || null;
|
265 | var refType = typeNumber(ref);
|
266 | if (refType === 2 || refType === 3 || refType === 4 || refType === 5 || refType === 8) {
|
267 | if (refType < 4) {
|
268 | ref += '';
|
269 | }
|
270 | ret.ref = ref;
|
271 | } else {
|
272 | ret.ref = null;
|
273 | }
|
274 | ret._owner = owner;
|
275 | }
|
276 | return ret;
|
277 | }
|
278 | function isValidElement(vnode) {
|
279 | return !!vnode && vnode.$$typeof === REACT_ELEMENT_TYPE;
|
280 | }
|
281 | function createVText(text) {
|
282 | return ReactElement('#text', 6, text + '');
|
283 | }
|
284 | function escape(key) {
|
285 | var escapeRegex = /[=:]/g;
|
286 | var escaperLookup = {
|
287 | '=': '=0',
|
288 | ':': '=2'
|
289 | };
|
290 | var escapedString = ('' + key).replace(escapeRegex, function (match) {
|
291 | return escaperLookup[match];
|
292 | });
|
293 | return '$' + escapedString;
|
294 | }
|
295 | var lastText = void 0,
|
296 | flattenIndex = void 0,
|
297 | flattenObject = void 0;
|
298 | function flattenCb(context, child, key, childType) {
|
299 | if (child === null) {
|
300 | lastText = null;
|
301 | return;
|
302 | }
|
303 | if (childType === 3 || childType === 4) {
|
304 | if (lastText) {
|
305 | lastText.props += child;
|
306 | return;
|
307 | }
|
308 | lastText = child = createVText(child);
|
309 | } else {
|
310 | lastText = null;
|
311 | }
|
312 | if (!flattenObject[key]) {
|
313 | flattenObject[key] = child;
|
314 | } else {
|
315 | key = '.' + flattenIndex;
|
316 | flattenObject[key] = child;
|
317 | }
|
318 | flattenIndex++;
|
319 | }
|
320 | function fiberizeChildren(children, fiber) {
|
321 | flattenObject = {};
|
322 | flattenIndex = 0;
|
323 | if (children !== void 666) {
|
324 | lastText = null;
|
325 | traverseAllChildren(children, '', flattenCb);
|
326 | }
|
327 | flattenIndex = 0;
|
328 | return fiber.children = flattenObject;
|
329 | }
|
330 | function getComponentKey(component, index) {
|
331 | if (Object(component).key != null) {
|
332 | return escape(component.key);
|
333 | }
|
334 | return index.toString(36);
|
335 | }
|
336 | var SEPARATOR = '.';
|
337 | var SUBSEPARATOR = ':';
|
338 | function traverseAllChildren(children, nameSoFar, callback, bookKeeping) {
|
339 | var childType = typeNumber(children);
|
340 | var invokeCallback = false;
|
341 | switch (childType) {
|
342 | case 0:
|
343 | case 1:
|
344 | case 2:
|
345 | case 5:
|
346 | case 6:
|
347 | children = null;
|
348 | invokeCallback = true;
|
349 | break;
|
350 | case 3:
|
351 | case 4:
|
352 | invokeCallback = true;
|
353 | break;
|
354 | case 8:
|
355 | if (children.$$typeof || children instanceof Component) {
|
356 | invokeCallback = true;
|
357 | } else if (children.hasOwnProperty('toString')) {
|
358 | children = children + '';
|
359 | invokeCallback = true;
|
360 | childType = 3;
|
361 | }
|
362 | break;
|
363 | }
|
364 | if (invokeCallback) {
|
365 | callback(bookKeeping, children,
|
366 | nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar, childType);
|
367 | return 1;
|
368 | }
|
369 | var subtreeCount = 0;
|
370 | var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
371 | if (children.forEach) {
|
372 | children.forEach(function (child, i) {
|
373 | var nextName = nextNamePrefix + getComponentKey(child, i);
|
374 | subtreeCount += traverseAllChildren(child, nextName, callback, bookKeeping);
|
375 | });
|
376 | return subtreeCount;
|
377 | }
|
378 | var iteratorFn = getIteractor(children);
|
379 | if (iteratorFn) {
|
380 | var iterator = iteratorFn.call(children),
|
381 | child = void 0,
|
382 | ii = 0,
|
383 | step = void 0,
|
384 | nextName = void 0;
|
385 | while (!(step = iterator.next()).done) {
|
386 | child = step.value;
|
387 | nextName = nextNamePrefix + getComponentKey(child, ii++);
|
388 | subtreeCount += traverseAllChildren(child, nextName, callback, bookKeeping);
|
389 | }
|
390 | return subtreeCount;
|
391 | }
|
392 | throw 'children: type is invalid.';
|
393 | }
|
394 | var REAL_SYMBOL = hasSymbol && Symbol.iterator;
|
395 | var FAKE_SYMBOL = '@@iterator';
|
396 | function getIteractor(a) {
|
397 | var iteratorFn = REAL_SYMBOL && a[REAL_SYMBOL] || a[FAKE_SYMBOL];
|
398 | if (iteratorFn && iteratorFn.call) {
|
399 | return iteratorFn;
|
400 | }
|
401 | }
|
402 |
|
403 | var Children = {
|
404 | only: function only(children) {
|
405 | if (isValidElement(children)) {
|
406 | return children;
|
407 | }
|
408 | throw new Error("expect only one child");
|
409 | },
|
410 | count: function count(children) {
|
411 | if (children == null) {
|
412 | return 0;
|
413 | }
|
414 | return traverseAllChildren(children, "", noop);
|
415 | },
|
416 | map: function map(children, func, context) {
|
417 | return proxyIt(children, func, [], context);
|
418 | },
|
419 | forEach: function forEach(children, func, context) {
|
420 | return proxyIt(children, func, null, context);
|
421 | },
|
422 | toArray: function toArray$$1(children) {
|
423 | return proxyIt(children, K, []);
|
424 | }
|
425 | };
|
426 | function proxyIt(children, func, result, context) {
|
427 | if (children == null) {
|
428 | return [];
|
429 | }
|
430 | mapChildren(children, null, func, result, context);
|
431 | return result;
|
432 | }
|
433 | function K(el) {
|
434 | return el;
|
435 | }
|
436 | function mapChildren(children, prefix, func, result, context) {
|
437 | var keyPrefix = "";
|
438 | if (prefix != null) {
|
439 | keyPrefix = escapeUserProvidedKey(prefix) + "/";
|
440 | }
|
441 | traverseAllChildren(children, "", traverseCallback, {
|
442 | context: context,
|
443 | keyPrefix: keyPrefix,
|
444 | func: func,
|
445 | result: result,
|
446 | count: 0
|
447 | });
|
448 | }
|
449 | var userProvidedKeyEscapeRegex = /\/+/g;
|
450 | function escapeUserProvidedKey(text) {
|
451 | return ("" + text).replace(userProvidedKeyEscapeRegex, "$&/");
|
452 | }
|
453 | function traverseCallback(bookKeeping, child, childKey) {
|
454 | var result = bookKeeping.result,
|
455 | keyPrefix = bookKeeping.keyPrefix,
|
456 | func = bookKeeping.func,
|
457 | context = bookKeeping.context;
|
458 | var mappedChild = func.call(context, child, bookKeeping.count++);
|
459 | if (!result) {
|
460 | return;
|
461 | }
|
462 | if (Array.isArray(mappedChild)) {
|
463 | mapChildren(mappedChild, childKey, K, result);
|
464 | } else if (mappedChild != null) {
|
465 | if (isValidElement(mappedChild)) {
|
466 | mappedChild = extend({}, mappedChild);
|
467 | mappedChild.key = keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + "/" : "") + childKey;
|
468 | }
|
469 | result.push(mappedChild);
|
470 | }
|
471 | }
|
472 |
|
473 | var check = function check() {
|
474 | return check;
|
475 | };
|
476 | check.isRequired = check;
|
477 | var PropTypes = {
|
478 | array: check,
|
479 | bool: check,
|
480 | func: check,
|
481 | number: check,
|
482 | object: check,
|
483 | string: check,
|
484 | any: check,
|
485 | arrayOf: check,
|
486 | element: check,
|
487 | instanceOf: check,
|
488 | node: check,
|
489 | objectOf: check,
|
490 | oneOf: check,
|
491 | oneOfType: check,
|
492 | shape: check
|
493 | };
|
494 |
|
495 | function shallowEqual(objA, objB) {
|
496 | if (Object.is(objA, objB)) {
|
497 | return true;
|
498 | }
|
499 | if (typeNumber(objA) < 7 || typeNumber(objB) < 7) {
|
500 | return false;
|
501 | }
|
502 | var keysA = Object.keys(objA);
|
503 | var keysB = Object.keys(objB);
|
504 | if (keysA.length !== keysB.length) {
|
505 | return false;
|
506 | }
|
507 | for (var i = 0; i < keysA.length; i++) {
|
508 | if (!hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
|
509 | return false;
|
510 | }
|
511 | }
|
512 | return true;
|
513 | }
|
514 |
|
515 | var PureComponent = miniCreateClass(function PureComponent() {
|
516 | this.isPureComponent = true;
|
517 | }, Component, {
|
518 | shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) {
|
519 | var a = shallowEqual(this.props, nextProps);
|
520 | var b = shallowEqual(this.state, nextState);
|
521 | return !a || !b;
|
522 | }
|
523 | });
|
524 |
|
525 | var MAX_NUMBER = 1073741823;
|
526 | function createContext(defaultValue, calculateChangedBits) {
|
527 | if (calculateChangedBits == void 0) {
|
528 | calculateChangedBits = null;
|
529 | }
|
530 | var instance = {
|
531 | value: defaultValue,
|
532 | subscribers: []
|
533 | };
|
534 | var Provider = miniCreateClass(function Provider(props) {
|
535 | this.value = props.value;
|
536 | getContext.subscribers = this.subscribers = [];
|
537 | instance = this;
|
538 | }, Component, {
|
539 | componentWillUnmount: function componentWillUnmount() {
|
540 | this.subscribers.length = 0;
|
541 | },
|
542 | UNSAFE_componentWillReceiveProps: function UNSAFE_componentWillReceiveProps(nextProps) {
|
543 | if (this.props.value !== nextProps.value) {
|
544 | var oldValue = this.props.value;
|
545 | var newValue = nextProps.value;
|
546 | var changedBits = void 0;
|
547 | if (Object.is(oldValue, newValue)) {
|
548 | changedBits = 0;
|
549 | } else {
|
550 | this.value = newValue;
|
551 | changedBits = isFn(calculateChangedBits) ? calculateChangedBits(oldValue, newValue) : MAX_NUMBER;
|
552 | changedBits |= 0;
|
553 | if (changedBits !== 0) {
|
554 | instance.subscribers.forEach(function (fiber) {
|
555 | if (fiber.setState) {
|
556 | fiber.setState({ value: newValue });
|
557 | fiber = get(fiber);
|
558 | }
|
559 | Renderer.updateComponent(fiber, true);
|
560 | });
|
561 | }
|
562 | }
|
563 | }
|
564 | },
|
565 | render: function render() {
|
566 | return this.props.children;
|
567 | }
|
568 | });
|
569 | var Consumer = miniCreateClass(function Consumer() {
|
570 | instance.subscribers.push(this);
|
571 | this.observedBits = 0;
|
572 | this.state = {
|
573 | value: instance.value
|
574 | };
|
575 | }, Component, {
|
576 | componentWillUnmount: function componentWillUnmount() {
|
577 | var i = instance.subscribers.indexOf(this);
|
578 | instance.subscribers.splice(i, 1);
|
579 | },
|
580 | render: function render() {
|
581 | return this.props.children(getContext(get(this)));
|
582 | }
|
583 | });
|
584 | function getContext(fiber) {
|
585 | while (fiber.return) {
|
586 | if (fiber.type == Provider) {
|
587 | return instance.value;
|
588 | }
|
589 | fiber = fiber.return;
|
590 | }
|
591 | return defaultValue;
|
592 | }
|
593 | getContext.subscribers = [];
|
594 | getContext.Provider = Provider;
|
595 | getContext.Consumer = Consumer;
|
596 | return getContext;
|
597 | }
|
598 |
|
599 | function createRef() {
|
600 | return {
|
601 | current: null
|
602 | };
|
603 | }
|
604 |
|
605 | var onAndSyncApis = {
|
606 | onSocketOpen: true,
|
607 | onSocketError: true,
|
608 | onSocketMessage: true,
|
609 | onSocketClose: true,
|
610 | onBackgroundAudioPlay: true,
|
611 | onBackgroundAudioPause: true,
|
612 | onBackgroundAudioStop: true,
|
613 | onNetworkStatusChange: true,
|
614 | onAccelerometerChange: true,
|
615 | onCompassChange: true,
|
616 | onBluetoothAdapterStateChange: true,
|
617 | onBluetoothDeviceFound: true,
|
618 | onBLEConnectionStateChange: true,
|
619 | onBLECharacteristicValueChange: true,
|
620 | onBeaconUpdate: true,
|
621 | onBeaconServiceChange: true,
|
622 | onUserCaptureScreen: true,
|
623 | onHCEMessage: true,
|
624 | onGetWifiList: true,
|
625 | onWifiConnected: true,
|
626 | setStorageSync: true,
|
627 | getStorageSync: true,
|
628 | getStorageInfoSync: true,
|
629 | removeStorageSync: true,
|
630 | clearStorageSync: true,
|
631 | getSystemInfoSync: true,
|
632 | getExtConfigSync: true,
|
633 | getLogManager: true
|
634 | };
|
635 | var noPromiseApis = {
|
636 | stopRecord: true,
|
637 | getRecorderManager: true,
|
638 | pauseVoice: true,
|
639 | stopVoice: true,
|
640 | pauseBackgroundAudio: true,
|
641 | stopBackgroundAudio: true,
|
642 | getBackgroundAudioManager: true,
|
643 | createAudioContext: true,
|
644 | createInnerAudioContext: true,
|
645 | createVideoContext: true,
|
646 | createCameraContext: true,
|
647 | wxpayGetType: true,
|
648 | navigateBack: true,
|
649 | createMapContext: true,
|
650 | canIUse: true,
|
651 | startAccelerometer: true,
|
652 | stopAccelerometer: true,
|
653 | startCompass: true,
|
654 | stopCompass: true,
|
655 | hideToast: true,
|
656 | hideLoading: true,
|
657 | showNavigationBarLoading: true,
|
658 | hideNavigationBarLoading: true,
|
659 | createAnimation: true,
|
660 | pageScrollTo: true,
|
661 | createSelectorQuery: true,
|
662 | createCanvasContext: true,
|
663 | createContext: true,
|
664 | drawCanvas: true,
|
665 | hideKeyboard: true,
|
666 | stopPullDownRefresh: true,
|
667 | arrayBufferToBase64: true,
|
668 | base64ToArrayBuffer: true,
|
669 | getUpdateManager: true,
|
670 | createWorker: true,
|
671 | getPushProvider: true,
|
672 | getProvider: true,
|
673 | canvasToTempFilePath: true,
|
674 | createModal: true
|
675 | };
|
676 | var otherApis = {
|
677 | uploadFile: true,
|
678 | downloadFile: true,
|
679 | connectSocket: true,
|
680 | sendSocketMessage: true,
|
681 | closeSocket: true,
|
682 | chooseImage: true,
|
683 | previewImage: true,
|
684 | getImageInfo: true,
|
685 | saveImageToPhotosAlbum: true,
|
686 | startRecord: true,
|
687 | playVoice: true,
|
688 | getBackgroundAudioPlayerState: true,
|
689 | playBackgroundAudio: true,
|
690 | seekBackgroundAudio: true,
|
691 | chooseVideo: true,
|
692 | saveVideoToPhotosAlbum: true,
|
693 | loadFontFace: true,
|
694 | saveFile: true,
|
695 | getFileInfo: true,
|
696 | getSavedFileList: true,
|
697 | getSavedFileInfo: true,
|
698 | removeSavedFile: true,
|
699 | openDocument: true,
|
700 | setStorage: true,
|
701 | getStorage: true,
|
702 | getStorageInfo: true,
|
703 | removeStorage: true,
|
704 | clearStorage: true,
|
705 | navigateTo: true,
|
706 | redirectTo: true,
|
707 | switchTab: true,
|
708 | reLaunch: true,
|
709 | getLocation: true,
|
710 | chooseLocation: true,
|
711 | openLocation: true,
|
712 | getSystemInfo: true,
|
713 | getNetworkType: true,
|
714 | makePhoneCall: true,
|
715 | scanCode: true,
|
716 | setClipboardData: true,
|
717 | getClipboardData: true,
|
718 | openBluetoothAdapter: true,
|
719 | closeBluetoothAdapter: true,
|
720 | getBluetoothAdapterState: true,
|
721 | startBluetoothDevicesDiscovery: true,
|
722 | stopBluetoothDevicesDiscovery: true,
|
723 | getBluetoothDevices: true,
|
724 | getConnectedBluetoothDevices: true,
|
725 | createBLEConnection: true,
|
726 | closeBLEConnection: true,
|
727 | getBLEDeviceServices: true,
|
728 | getBLEDeviceCharacteristics: true,
|
729 | readBLECharacteristicValue: true,
|
730 | writeBLECharacteristicValue: true,
|
731 | notifyBLECharacteristicValueChange: true,
|
732 | startBeaconDiscovery: true,
|
733 | stopBeaconDiscovery: true,
|
734 | getBeacons: true,
|
735 | setScreenBrightness: true,
|
736 | getScreenBrightness: true,
|
737 | setKeepScreenOn: true,
|
738 | vibrateLong: true,
|
739 | vibrateShort: true,
|
740 | addPhoneContact: true,
|
741 | getHCEState: true,
|
742 | startHCE: true,
|
743 | stopHCE: true,
|
744 | sendHCEMessage: true,
|
745 | startWifi: true,
|
746 | stopWifi: true,
|
747 | connectWifi: true,
|
748 | getWifiList: true,
|
749 | setWifiList: true,
|
750 | getConnectedWifi: true,
|
751 | showToast: true,
|
752 | showLoading: true,
|
753 | showModal: true,
|
754 | showActionSheet: true,
|
755 | setNavigationBarTitle: true,
|
756 | setNavigationBarColor: true,
|
757 | setTabBarBadge: true,
|
758 | removeTabBarBadge: true,
|
759 | showTabBarRedDot: true,
|
760 | hideTabBarRedDot: true,
|
761 | setTabBarStyle: true,
|
762 | setTabBarItem: true,
|
763 | showTabBar: true,
|
764 | hideTabBar: true,
|
765 | setTopBarText: true,
|
766 | startPullDownRefresh: true,
|
767 | canvasGetImageData: true,
|
768 | canvasPutImageData: true,
|
769 | getExtConfig: true,
|
770 | request: true,
|
771 | login: true,
|
772 | checkSession: true,
|
773 | authorize: true,
|
774 | getUserInfo: true,
|
775 | requestPayment: true,
|
776 | showShareMenu: true,
|
777 | hideShareMenu: true,
|
778 | updateShareMenu: true,
|
779 | getShareInfo: true,
|
780 | chooseAddress: true,
|
781 | addCard: true,
|
782 | openCard: true,
|
783 | openSetting: true,
|
784 | getSetting: true,
|
785 | getWeRunData: true,
|
786 | navigateToMiniProgram: true,
|
787 | navigateBackMiniProgram: true,
|
788 | chooseInvoiceTitle: true,
|
789 | checkIsSupportSoterAuthentication: true,
|
790 | startSoterAuthentication: true,
|
791 | checkIsSoterEnrolledInDevice: true,
|
792 | setBackgroundColor: true,
|
793 | setBackgroundTextStyle: true
|
794 | };
|
795 |
|
796 | function promisefyApis(ReactWX, facade, more) {
|
797 | var weApis = Object.assign({}, onAndSyncApis, noPromiseApis, otherApis, more);
|
798 | Object.keys(weApis).forEach(function (key) {
|
799 | var needWrapper = more[key] || facade[key] || noop;
|
800 | if (!onAndSyncApis[key] && !noPromiseApis[key]) {
|
801 | ReactWX.api[key] = function (options) {
|
802 | var args = [].slice.call(arguments);
|
803 | if (!options || Object(options) !== options) {
|
804 | return needWrapper.apply(facade, args);
|
805 | }
|
806 | var task = null;
|
807 | var obj = Object.assign({}, options);
|
808 | args[0] = obj;
|
809 | var p = new Promise(function (resolve, reject) {
|
810 | ['fail', 'success', 'complete'].forEach(function (k) {
|
811 | obj[k] = function (res) {
|
812 | options[k] && options[k](res);
|
813 | if (k === 'success') {
|
814 | resolve(key === 'connectSocket' ? task : res);
|
815 | } else if (k === 'fail') {
|
816 | reject(res);
|
817 | }
|
818 | };
|
819 | });
|
820 | if (needWrapper === noop) {
|
821 | console.warn('平台未不支持', key, '方法');
|
822 | } else {
|
823 | task = needWrapper.apply(facade, args);
|
824 | if (task && options.getRawResult) {
|
825 | options.getRawResult(task);
|
826 | }
|
827 | }
|
828 | });
|
829 | return p;
|
830 | };
|
831 | } else {
|
832 | if (needWrapper == noop) {
|
833 | ReactWX.api[key] = noop;
|
834 | } else {
|
835 | ReactWX.api[key] = function () {
|
836 | return needWrapper.apply(facade, arguments);
|
837 | };
|
838 | }
|
839 | }
|
840 | });
|
841 | }
|
842 | function pxTransform(size) {
|
843 | var deviceRatio = this.api.deviceRatio;
|
844 | return parseInt(size, 10) / deviceRatio + 'rpx';
|
845 | }
|
846 | function initPxTransform(facade) {
|
847 | function fallback(windowWidth) {
|
848 | facade.designWidth = windowWidth;
|
849 | facade.deviceRatio = 750 / windowWidth / 2;
|
850 | }
|
851 | if (facade.getSystemInfo) {
|
852 | facade.getSystemInfo({
|
853 | success: function success(res) {
|
854 | fallback(res.windowWidth);
|
855 | }
|
856 | });
|
857 | } else {
|
858 | fallback(375);
|
859 | }
|
860 | }
|
861 | function registerAPIs(ReactWX, facade, override) {
|
862 | registerAPIsQuick(ReactWX, facade, override);
|
863 | initPxTransform(ReactWX.api);
|
864 | ReactWX.api.pxTransform = ReactWX.pxTransform = pxTransform.bind(ReactWX);
|
865 | }
|
866 | function registerAPIsQuick(ReactWX, facade, override) {
|
867 | if (!ReactWX.api) {
|
868 | ReactWX.api = {};
|
869 | promisefyApis(ReactWX, facade, override(facade));
|
870 | }
|
871 | }
|
872 |
|
873 | var RequestQueue = {
|
874 | MAX_REQUEST: 10,
|
875 | queue: [],
|
876 | request: function request(options) {
|
877 | this.push(options);
|
878 | return this.run();
|
879 | },
|
880 | push: function push(options) {
|
881 | this.queue.push(options);
|
882 | },
|
883 | run: function run() {
|
884 | if (!this.queue.length) {
|
885 | return;
|
886 | }
|
887 | if (this.queue.length <= this.MAX_REQUEST) {
|
888 | var options = this.queue.shift();
|
889 | var completeFn = options.complete;
|
890 | var self = this;
|
891 | options.complete = function () {
|
892 | completeFn && completeFn.apply(null, arguments);
|
893 | self.run();
|
894 | };
|
895 | return this.facade.request(options);
|
896 | }
|
897 | }
|
898 | };
|
899 | var more = function more(api) {
|
900 | return {
|
901 | request: function request(_a) {
|
902 | RequestQueue.facade = api;
|
903 | return RequestQueue.request(_a);
|
904 | },
|
905 | uploadFile: function _(a) {
|
906 | var cb = a.success || Number;
|
907 | a.success = function (res) {
|
908 | cb(res);
|
909 | };
|
910 | return api.uploadFile(a);
|
911 | },
|
912 | getStorage: function getStorage(_ref) {
|
913 | var key = _ref.key,
|
914 | success = _ref.success,
|
915 | complete = _ref.complete;
|
916 | return api.getStorage({
|
917 | key: key,
|
918 | complete: complete,
|
919 | success: success,
|
920 | fail: function fail(e) {
|
921 | success && success({});
|
922 | }
|
923 | });
|
924 | }
|
925 | };
|
926 | };
|
927 |
|
928 | var fakeApp = {
|
929 | app: {
|
930 | globalData: {}
|
931 | }
|
932 | };
|
933 | function _getApp() {
|
934 | if (isFn(getApp)) {
|
935 | return getApp();
|
936 | }
|
937 | return fakeApp;
|
938 | }
|
939 | function getWrappedComponent(fiber, instance) {
|
940 | var ctor = instance.constructor;
|
941 | if (ctor.WrappedComponent) {
|
942 | if (ctor.contextTypes) {
|
943 | instance = fiber.child.stateNode;
|
944 | } else {
|
945 | instance = fiber.child.child.stateNode;
|
946 | }
|
947 | }
|
948 | return instance;
|
949 | }
|
950 | if (typeof getApp === 'function') {
|
951 | _getApp = getApp;
|
952 | }
|
953 | function callGlobalHook(method, e) {
|
954 | var app = _getApp();
|
955 | if (app && app[method]) {
|
956 | return app[method](e);
|
957 | }
|
958 | }
|
959 | var delayMounts = [];
|
960 | var usingComponents = [];
|
961 | var registeredComponents = {};
|
962 | function getCurrentPage() {
|
963 | var app = _getApp();
|
964 | return app.$$page && app.$$page.reactInstance;
|
965 | }
|
966 | function _getCurrentPages() {
|
967 | console.warn('getCurrentPages存在严重的平台差异性,不建议再使用');
|
968 | if (typeof getCurrentPages !== 'undefined') {
|
969 | return getCurrentPages();
|
970 | }
|
971 | return [];
|
972 | }
|
973 | function updateMiniApp(instance) {
|
974 | if (!instance || !instance.wx) {
|
975 | return;
|
976 | }
|
977 | var data = safeClone({
|
978 | props: instance.props,
|
979 | state: instance.state || null,
|
980 | context: instance.context
|
981 | });
|
982 | if (instance.wx.setData) {
|
983 | instance.wx.setData(data);
|
984 | } else {
|
985 | updateQuickApp(instance.wx, data);
|
986 | }
|
987 | }
|
988 | function refreshComponent(instances, wx, uuid) {
|
989 | if (wx.disposed) {
|
990 | return;
|
991 | }
|
992 | var pagePath = Object(_getApp()).$$pagePath;
|
993 | for (var i = 0, n = instances.length; i < n; i++) {
|
994 | var instance = instances[i];
|
995 | if (instance.$$pagePath === pagePath && !instance.wx && instance.instanceUid === uuid) {
|
996 | var fiber = get(instance);
|
997 | if (fiber.disposed) {
|
998 | console.log("fiber.disposed by nanachi");
|
999 | continue;
|
1000 | }
|
1001 | if (fiber.child && fiber.type.wrappedComponent) {
|
1002 | instance = fiber.child.stateNode;
|
1003 | } else {
|
1004 | instance = getWrappedComponent(fiber, instance);
|
1005 | }
|
1006 | instance.wx = wx;
|
1007 | wx.reactInstance = instance;
|
1008 | updateMiniApp(instance);
|
1009 | return instances.splice(i, 1);
|
1010 | }
|
1011 | }
|
1012 | }
|
1013 | function detachComponent() {
|
1014 | var t = this.reactInstance;
|
1015 | this.disposed = true;
|
1016 | if (t) {
|
1017 | t.wx = null;
|
1018 | this.reactInstance = null;
|
1019 | }
|
1020 | }
|
1021 | function updateQuickApp(quick, data) {
|
1022 | for (var i in data) {
|
1023 | quick.$set(i, data[i]);
|
1024 | }
|
1025 | }
|
1026 | function isReferenceType(val) {
|
1027 | return typeNumber(val) > 6;
|
1028 | }
|
1029 | function useComponent(props) {
|
1030 | var is = props.is;
|
1031 | var clazz = registeredComponents[is];
|
1032 | props.key = this.key != null ? this.key : props['data-instance-uid'] || new Date() - 0;
|
1033 | clazz.displayName = is;
|
1034 | if (this.ref !== null) {
|
1035 | props.ref = this.ref;
|
1036 | }
|
1037 | var owner = Renderer.currentOwner;
|
1038 | if (owner) {
|
1039 | Renderer.currentOwner = get(owner)._owner;
|
1040 | }
|
1041 | return createElement(clazz, props);
|
1042 | }
|
1043 | function safeClone(originVal) {
|
1044 | var temp = originVal instanceof Array ? [] : {};
|
1045 | for (var item in originVal) {
|
1046 | if (hasOwnProperty.call(originVal, item)) {
|
1047 | var value = originVal[item];
|
1048 | if (isReferenceType(value)) {
|
1049 | if (value.$$typeof) {
|
1050 | continue;
|
1051 | }
|
1052 | temp[item] = safeClone(value);
|
1053 | } else {
|
1054 | temp[item] = value;
|
1055 | }
|
1056 | }
|
1057 | }
|
1058 | return temp;
|
1059 | }
|
1060 |
|
1061 | var webview = {};
|
1062 | var rbeaconType = /click|tap|change|blur|input/i;
|
1063 | function dispatchEvent(e) {
|
1064 | var eventType = toLowerCase(e.type);
|
1065 | if (eventType == "message") {
|
1066 | if (webview.instance && webview.cb) {
|
1067 | webview.cb.call(webview.instance, e);
|
1068 | }
|
1069 | return;
|
1070 | }
|
1071 | var instance = this.reactInstance;
|
1072 | if (!instance || !instance.$$eventCached) {
|
1073 | console.log(eventType, "没有实例");
|
1074 | return;
|
1075 | }
|
1076 | var app = _getApp();
|
1077 | var target = e.currentTarget;
|
1078 | var dataset = target.dataset || {};
|
1079 | if (dataset[eventType + "Alias"]) {
|
1080 | eventType = dataset[eventType + "Alias"];
|
1081 | }
|
1082 | var eventUid = dataset[eventType + "Uid"];
|
1083 | var fiber = instance.$$eventCached[eventUid + "Fiber"] || {
|
1084 | props: {},
|
1085 | type: "unknown"
|
1086 | };
|
1087 | var value = Object(e.detail).value;
|
1088 | if (eventType == "change" && !Array.isArray(value) && fiber.props.value + "" == value) {
|
1089 | return;
|
1090 | }
|
1091 | var safeTarget = {
|
1092 | dataset: dataset,
|
1093 | nodeName: target.tagName || fiber.type,
|
1094 | value: value
|
1095 | };
|
1096 | if (app && app.onCollectLogs && rbeaconType.test(eventType)) {
|
1097 | app.onCollectLogs(dataset, eventType, fiber.stateNode);
|
1098 | }
|
1099 | Renderer.batchedUpdates(function () {
|
1100 | try {
|
1101 | var fn = instance.$$eventCached[eventUid];
|
1102 | fn && fn.call(instance, createEvent(e, safeTarget));
|
1103 | } catch (err) {
|
1104 | console.log(err.stack);
|
1105 | }
|
1106 | }, e);
|
1107 | }
|
1108 | function createEvent(e, target) {
|
1109 | var event = Object.assign({}, e);
|
1110 | if (e.detail) {
|
1111 | Object.assign(event, e.detail);
|
1112 | }
|
1113 | event.stopPropagation = function () {
|
1114 | console.warn("小程序不支持这方法,请使用catchXXX");
|
1115 | };
|
1116 | event.nativeEvent = e;
|
1117 | event.preventDefault = returnFalse;
|
1118 | event.target = target;
|
1119 | event.timeStamp = Date.now();
|
1120 | var touch = e.touches && e.touches[0];
|
1121 | if (touch) {
|
1122 | event.pageX = touch.pageX;
|
1123 | event.pageY = touch.pageY;
|
1124 | }
|
1125 | return event;
|
1126 | }
|
1127 |
|
1128 | function AnuPortal(props) {
|
1129 | return props.children;
|
1130 | }
|
1131 |
|
1132 | function UpdateQueue() {
|
1133 | return {
|
1134 | pendingStates: [],
|
1135 | pendingCbs: []
|
1136 | };
|
1137 | }
|
1138 | function createInstance(fiber, context) {
|
1139 | var updater = {
|
1140 | mountOrder: Renderer.mountOrder++,
|
1141 | enqueueSetState: returnFalse,
|
1142 | isMounted: isMounted
|
1143 | };
|
1144 | var props = fiber.props,
|
1145 | type = fiber.type,
|
1146 | tag = fiber.tag,
|
1147 | ref = fiber.ref,
|
1148 | key = fiber.key,
|
1149 | isStateless = tag === 1,
|
1150 | lastOwn = Renderer.currentOwner,
|
1151 | instance = {
|
1152 | refs: {},
|
1153 | props: props,
|
1154 | key: key,
|
1155 | context: context,
|
1156 | ref: ref,
|
1157 | _reactInternalFiber: fiber,
|
1158 | __proto__: type.prototype
|
1159 | };
|
1160 | fiber.updateQueue = UpdateQueue();
|
1161 | fiber.errorHook = 'constructor';
|
1162 | try {
|
1163 | if (isStateless) {
|
1164 | Renderer.currentOwner = instance;
|
1165 | extend(instance, {
|
1166 | __isStateless: true,
|
1167 | renderImpl: type,
|
1168 | render: function f1() {
|
1169 | return this.renderImpl(this.props, this.context);
|
1170 | }
|
1171 | });
|
1172 | Renderer.currentOwner = instance;
|
1173 | } else {
|
1174 | instance = new type(props, context);
|
1175 | if (!(instance instanceof Component)) {
|
1176 | if (!instance.updater || !instance.updater.enqueueSetState) {
|
1177 | throw type.name + ' doesn\'t extend React.Component';
|
1178 | }
|
1179 | }
|
1180 | }
|
1181 | } finally {
|
1182 | Renderer.currentOwner = lastOwn;
|
1183 | fiber.stateNode = instance;
|
1184 | instance._reactInternalFiber = fiber;
|
1185 | instance.updater = updater;
|
1186 | instance.context = context;
|
1187 | updater.enqueueSetState = Renderer.updateComponent;
|
1188 | if (type[gDSFP] || instance[gSBU]) {
|
1189 | instance.__useNewHooks = true;
|
1190 | }
|
1191 | }
|
1192 | return instance;
|
1193 | }
|
1194 |
|
1195 | function Fiber(vnode) {
|
1196 | extend(this, vnode);
|
1197 | var type = vnode.type || "ProxyComponent(react-hot-loader)";
|
1198 | this.name = type.displayName || type.name || type;
|
1199 | this.effectTag = 1;
|
1200 | }
|
1201 |
|
1202 | var NOWORK = 1;
|
1203 | var WORKING = 2;
|
1204 | var PLACE = 3;
|
1205 | var CONTENT = 5;
|
1206 | var ATTR = 7;
|
1207 | var DUPLEX = 11;
|
1208 | var DETACH = 13;
|
1209 | var HOOK = 17;
|
1210 | var REF = 19;
|
1211 | var CALLBACK = 23;
|
1212 | var PASSIVE = 29;
|
1213 | var CAPTURE = 31;
|
1214 | var effectNames = [DUPLEX, HOOK, REF, DETACH, CALLBACK, PASSIVE, CAPTURE].sort(function (a, b) {
|
1215 | return a - b;
|
1216 | });
|
1217 | var effectLength = effectNames.length;
|
1218 |
|
1219 | function pushError(fiber, hook, error) {
|
1220 | var names = [];
|
1221 | var boundary = findCatchComponent(fiber, names, hook);
|
1222 | var stack = describeError(names, hook);
|
1223 | if (boundary) {
|
1224 | if (fiber.hasMounted) ; else {
|
1225 | fiber.stateNode = {
|
1226 | updater: fakeObject
|
1227 | };
|
1228 | fiber.effectTag = NOWORK;
|
1229 | }
|
1230 | var values = boundary.capturedValues || (boundary.capturedValues = []);
|
1231 | values.push(error, {
|
1232 | componentStack: stack
|
1233 | });
|
1234 | } else {
|
1235 | var p = fiber.return;
|
1236 | for (var i in p.children) {
|
1237 | if (p.children[i] == fiber) {
|
1238 | fiber.type = noop;
|
1239 | }
|
1240 | }
|
1241 | while (p) {
|
1242 | p._hydrating = false;
|
1243 | p = p.return;
|
1244 | }
|
1245 | if (!Renderer.catchError) {
|
1246 | Renderer.catchStack = stack;
|
1247 | Renderer.catchError = error;
|
1248 | }
|
1249 | }
|
1250 | }
|
1251 | function guardCallback(host, hook, args) {
|
1252 | try {
|
1253 | return applyCallback(host, hook, args);
|
1254 | } catch (error) {
|
1255 | pushError(get(host), hook, error);
|
1256 | }
|
1257 | }
|
1258 | function applyCallback(host, hook, args) {
|
1259 | var fiber = host._reactInternalFiber;
|
1260 | fiber.errorHook = hook;
|
1261 | var fn = host[hook];
|
1262 | if (hook == "componentWillUnmount") {
|
1263 | host[hook] = noop;
|
1264 | }
|
1265 | if (fn) {
|
1266 | return fn.apply(host, args);
|
1267 | }
|
1268 | return true;
|
1269 | }
|
1270 | function describeError(names, hook) {
|
1271 | var segments = ["**" + hook + "** method occur error "];
|
1272 | names.forEach(function (name, i) {
|
1273 | if (names[i + 1]) {
|
1274 | segments.push("in " + name + " (created By " + names[i + 1] + ")");
|
1275 | }
|
1276 | });
|
1277 | return segments.join("\n\r").trim();
|
1278 | }
|
1279 | function findCatchComponent(fiber, names, hook) {
|
1280 | var instance = void 0,
|
1281 | name = void 0,
|
1282 | topFiber = fiber,
|
1283 | retry = void 0,
|
1284 | boundary = void 0;
|
1285 | while (fiber) {
|
1286 | name = fiber.name;
|
1287 | if (fiber.tag < 4) {
|
1288 | names.push(name);
|
1289 | instance = fiber.stateNode || {};
|
1290 | if (instance.componentDidCatch && !boundary) {
|
1291 | if (!fiber.caughtError && topFiber !== fiber) {
|
1292 | boundary = fiber;
|
1293 | } else if (fiber.caughtError) {
|
1294 | retry = fiber;
|
1295 | }
|
1296 | }
|
1297 | } else if (fiber.tag === 5) {
|
1298 | names.push(name);
|
1299 | }
|
1300 | fiber = fiber.return;
|
1301 | if (boundary) {
|
1302 | var boundaries = Renderer.boundaries;
|
1303 | if (!retry || retry !== boundary) {
|
1304 | var effectTag = boundary.effectTag;
|
1305 | var f = boundary.alternate;
|
1306 | if (f && !f.catchError) {
|
1307 | f.forward = boundary.forward;
|
1308 | f.sibling = boundary.sibling;
|
1309 | if (boundary.return.child == boundary) {
|
1310 | boundary.return.child = f;
|
1311 | }
|
1312 | boundary = f;
|
1313 | }
|
1314 | if (!boundary.catchError) {
|
1315 | if (hook == "componentWillUnmount" || hook == "componentDidUpdate") {
|
1316 | boundary.effectTag = CAPTURE;
|
1317 | } else {
|
1318 | boundary.effectTag = effectTag * CAPTURE;
|
1319 | }
|
1320 | boundaries.unshift(boundary);
|
1321 | boundary.catchError = true;
|
1322 | }
|
1323 | if (retry) {
|
1324 | var arr = boundary.effects || (boundary.effects = []);
|
1325 | arr.push(retry);
|
1326 | }
|
1327 | }
|
1328 | return boundary;
|
1329 | }
|
1330 | }
|
1331 | }
|
1332 | function removeFormBoundaries(fiber) {
|
1333 | delete fiber.catchError;
|
1334 | var arr = Renderer.boundaries;
|
1335 | var index = arr.indexOf(fiber);
|
1336 | if (index !== -1) {
|
1337 | arr.splice(index, 1);
|
1338 | }
|
1339 | }
|
1340 | function detachFiber(fiber, effects$$1) {
|
1341 | fiber.effectTag = DETACH;
|
1342 | effects$$1.push(fiber);
|
1343 | fiber.disposed = true;
|
1344 | for (var child = fiber.child; child; child = child.sibling) {
|
1345 | detachFiber(child, effects$$1);
|
1346 | }
|
1347 | }
|
1348 |
|
1349 | function setter(compute, cursor, value) {
|
1350 | var _this = this;
|
1351 | Renderer.batchedUpdates(function () {
|
1352 | _this.updateQueue[cursor] = compute(cursor, value);
|
1353 | Renderer.updateComponent(_this, true);
|
1354 | });
|
1355 | }
|
1356 | var hookCursor = 0;
|
1357 | function resetCursor() {
|
1358 | hookCursor = 0;
|
1359 | }
|
1360 | function getCurrentKey() {
|
1361 | var key = hookCursor + 'Hook';
|
1362 | hookCursor++;
|
1363 | return key;
|
1364 | }
|
1365 | function useContext(getContext) {
|
1366 | if (isFn(getContext)) {
|
1367 | var fiber = getCurrentFiber();
|
1368 | var context = getContext(fiber);
|
1369 | var list = getContext.subscribers;
|
1370 | if (list.indexOf(fiber) === -1) {
|
1371 | list.push(fiber);
|
1372 | }
|
1373 | return context;
|
1374 | }
|
1375 | return null;
|
1376 | }
|
1377 | function useReducerImpl(reducer, initValue, initAction) {
|
1378 | var fiber = getCurrentFiber();
|
1379 | var key = getCurrentKey();
|
1380 | var updateQueue = fiber.updateQueue;
|
1381 | var compute = reducer ? function (cursor, action) {
|
1382 | return reducer(updateQueue[cursor], action || { type: Math.random() });
|
1383 | } : function (cursor, value) {
|
1384 | var other = updateQueue[cursor];
|
1385 | return isFn(value) ? value(other) : value;
|
1386 | };
|
1387 | var dispatch = setter.bind(fiber, compute, key);
|
1388 | if (key in updateQueue) {
|
1389 | delete updateQueue.isForced;
|
1390 | return [updateQueue[key], dispatch];
|
1391 | }
|
1392 | var value = updateQueue[key] = initAction ? reducer(initValue, initAction) : initValue;
|
1393 | return [value, dispatch];
|
1394 | }
|
1395 | function useCallbackImpl(create, deps, isMemo, isEffect) {
|
1396 | var fiber = getCurrentFiber();
|
1397 | var key = getCurrentKey();
|
1398 | var updateQueue = fiber.updateQueue;
|
1399 | var nextInputs = Array.isArray(deps) ? deps : [create];
|
1400 | var prevState = updateQueue[key];
|
1401 | if (prevState) {
|
1402 | var prevInputs = prevState[1];
|
1403 | if (areHookInputsEqual(nextInputs, prevInputs)) {
|
1404 | return isEffect ? null : prevState[0];
|
1405 | }
|
1406 | }
|
1407 | var fn = isMemo ? create() : create;
|
1408 | updateQueue[key] = [fn, nextInputs];
|
1409 | return fn;
|
1410 | }
|
1411 | function useEffectImpl(create, deps, EffectTag, createList, destroyList) {
|
1412 | var fiber = getCurrentFiber();
|
1413 | var updateQueue = fiber.updateQueue;
|
1414 | if (useCallbackImpl(create, deps, false, true)) {
|
1415 | if (fiber.effectTag % EffectTag) {
|
1416 | fiber.effectTag *= EffectTag;
|
1417 | }
|
1418 | var list = updateQueue[createList] || (updateQueue[createList] = []);
|
1419 | updateQueue[destroyList] || (updateQueue[destroyList] = []);
|
1420 | list.push(create);
|
1421 | }
|
1422 | }
|
1423 | function useRef(initValue) {
|
1424 | var fiber = getCurrentFiber();
|
1425 | var key = getCurrentKey();
|
1426 | var updateQueue = fiber.updateQueue;
|
1427 | if (key in updateQueue) {
|
1428 | return updateQueue[key];
|
1429 | }
|
1430 | return updateQueue[key] = { current: initValue };
|
1431 | }
|
1432 | function getCurrentFiber() {
|
1433 | return get(Renderer.currentOwner);
|
1434 | }
|
1435 | function areHookInputsEqual(arr1, arr2) {
|
1436 | for (var i = 0; i < arr1.length; i++) {
|
1437 | if (Object.is(arr1[i], arr2[i])) {
|
1438 | continue;
|
1439 | }
|
1440 | return false;
|
1441 | }
|
1442 | return true;
|
1443 | }
|
1444 |
|
1445 | function getInsertPoint(fiber) {
|
1446 | var parent = fiber.parent;
|
1447 | while (fiber) {
|
1448 | if (fiber.stateNode === parent || fiber.isPortal) {
|
1449 | return null;
|
1450 | }
|
1451 | var found = forward(fiber);
|
1452 | if (found) {
|
1453 | return found;
|
1454 | }
|
1455 | fiber = fiber.return;
|
1456 | }
|
1457 | }
|
1458 | function setInsertPoints(children) {
|
1459 | for (var i in children) {
|
1460 | var child = children[i];
|
1461 | if (child.disposed) {
|
1462 | continue;
|
1463 | }
|
1464 | if (child.tag > 4) {
|
1465 | var p = child.parent;
|
1466 | child.effectTag = PLACE;
|
1467 | child.forwardFiber = p.insertPoint;
|
1468 | p.insertPoint = child;
|
1469 | for (var pp = child.return; pp && pp.effectTag === NOWORK; pp = pp.return) {
|
1470 | pp.effectTag = WORKING;
|
1471 | }
|
1472 | } else {
|
1473 | if (child.child) {
|
1474 | setInsertPoints(child.children);
|
1475 | }
|
1476 | }
|
1477 | }
|
1478 | }
|
1479 | function forward(fiber) {
|
1480 | var found;
|
1481 | while (fiber.forward) {
|
1482 | fiber = fiber.forward;
|
1483 | if (fiber.disposed || fiber.isPortal) {
|
1484 | continue;
|
1485 | }
|
1486 | if (fiber.tag > 3) {
|
1487 | return fiber;
|
1488 | }
|
1489 | if (fiber.child) {
|
1490 | found = downward(fiber);
|
1491 | if (found) {
|
1492 | return found;
|
1493 | }
|
1494 | }
|
1495 | }
|
1496 | }
|
1497 | function downward(fiber) {
|
1498 | var found;
|
1499 | while (fiber.lastChild) {
|
1500 | fiber = fiber.lastChild;
|
1501 | if (fiber.disposed || fiber.isPortal) {
|
1502 | return;
|
1503 | }
|
1504 | if (fiber.tag > 3) {
|
1505 | return fiber;
|
1506 | }
|
1507 | if (fiber.forward) {
|
1508 | found = forward(fiber);
|
1509 | if (found) {
|
1510 | return found;
|
1511 | }
|
1512 | }
|
1513 | }
|
1514 | }
|
1515 |
|
1516 | function reconcileDFS(fiber, info, deadline, ENOUGH_TIME) {
|
1517 | var topWork = fiber;
|
1518 | outerLoop: while (fiber) {
|
1519 | if (fiber.disposed || deadline.timeRemaining() <= ENOUGH_TIME) {
|
1520 | break;
|
1521 | }
|
1522 | var occurError = void 0;
|
1523 | if (fiber.tag < 3) {
|
1524 | var keepbook = Renderer.currentOwner;
|
1525 | try {
|
1526 | updateClassComponent(fiber, info);
|
1527 | } catch (e) {
|
1528 | occurError = true;
|
1529 | pushError(fiber, fiber.errorHook, e);
|
1530 | }
|
1531 | Renderer.currentOwner = keepbook;
|
1532 | if (fiber.batching) {
|
1533 | delete fiber.updateFail;
|
1534 | delete fiber.batching;
|
1535 | }
|
1536 | } else {
|
1537 | updateHostComponent(fiber, info);
|
1538 | }
|
1539 | if (fiber.child && !fiber.updateFail && !occurError) {
|
1540 | fiber = fiber.child;
|
1541 | continue outerLoop;
|
1542 | }
|
1543 | var f = fiber;
|
1544 | while (f) {
|
1545 | var instance = f.stateNode;
|
1546 | if (f.tag > 3 || f.shiftContainer) {
|
1547 | if (f.shiftContainer) {
|
1548 | delete f.shiftContainer;
|
1549 | info.containerStack.shift();
|
1550 | }
|
1551 | } else {
|
1552 | var updater = instance && instance.updater;
|
1553 | if (f.shiftContext) {
|
1554 | delete f.shiftContext;
|
1555 | info.contextStack.shift();
|
1556 | }
|
1557 | if (f.hasMounted && instance[gSBU]) {
|
1558 | updater.snapshot = guardCallback(instance, gSBU, [updater.prevProps, updater.prevState]);
|
1559 | }
|
1560 | }
|
1561 | if (f === topWork) {
|
1562 | break outerLoop;
|
1563 | }
|
1564 | if (f.sibling) {
|
1565 | fiber = f.sibling;
|
1566 | continue outerLoop;
|
1567 | }
|
1568 | f = f.return;
|
1569 | }
|
1570 | }
|
1571 | }
|
1572 | function updateHostComponent(fiber, info) {
|
1573 | var props = fiber.props,
|
1574 | tag = fiber.tag,
|
1575 | prev = fiber.alternate;
|
1576 | if (!fiber.stateNode) {
|
1577 | fiber.parent = info.containerStack[0];
|
1578 | fiber.stateNode = Renderer.createElement(fiber);
|
1579 | }
|
1580 | var parent = fiber.parent;
|
1581 | fiber.forwardFiber = parent.insertPoint;
|
1582 | parent.insertPoint = fiber;
|
1583 | fiber.effectTag = PLACE;
|
1584 | if (tag === 5) {
|
1585 | fiber.stateNode.insertPoint = null;
|
1586 | info.containerStack.unshift(fiber.stateNode);
|
1587 | fiber.shiftContainer = true;
|
1588 | fiber.effectTag *= ATTR;
|
1589 | if (fiber.ref) {
|
1590 | fiber.effectTag *= REF;
|
1591 | }
|
1592 | diffChildren(fiber, props.children);
|
1593 | } else {
|
1594 | if (!prev || prev.props !== props) {
|
1595 | fiber.effectTag *= CONTENT;
|
1596 | }
|
1597 | }
|
1598 | }
|
1599 | function mergeStates(fiber, nextProps) {
|
1600 | var instance = fiber.stateNode,
|
1601 | pendings = fiber.updateQueue.pendingStates,
|
1602 | n = pendings.length,
|
1603 | state = fiber.memoizedState || instance.state;
|
1604 | if (n === 0) {
|
1605 | return state;
|
1606 | }
|
1607 | var nextState = extend({}, state);
|
1608 | var fail = true;
|
1609 | for (var i = 0; i < n; i++) {
|
1610 | var pending = pendings[i];
|
1611 | if (pending) {
|
1612 | if (isFn(pending)) {
|
1613 | var a = pending.call(instance, nextState, nextProps);
|
1614 | if (!a) {
|
1615 | continue;
|
1616 | } else {
|
1617 | pending = a;
|
1618 | }
|
1619 | }
|
1620 | fail = false;
|
1621 | extend(nextState, pending);
|
1622 | }
|
1623 | }
|
1624 | if (fail) {
|
1625 | return state;
|
1626 | } else {
|
1627 | return fiber.memoizedState = nextState;
|
1628 | }
|
1629 | }
|
1630 | function updateClassComponent(fiber, info) {
|
1631 | var type = fiber.type,
|
1632 | instance = fiber.stateNode,
|
1633 | props = fiber.props;
|
1634 | var contextStack = info.contextStack,
|
1635 | containerStack = info.containerStack;
|
1636 | var getContext = type.contextType;
|
1637 | var unmaskedContext = contextStack[0];
|
1638 | var isStaticContextType = isFn(type.contextType);
|
1639 | var newContext = isStaticContextType ? getContext(fiber) : getMaskedContext(instance, type.contextTypes, unmaskedContext);
|
1640 | if (instance == null) {
|
1641 | fiber.parent = type === AnuPortal ? props.parent : containerStack[0];
|
1642 | instance = createInstance(fiber, newContext);
|
1643 | if (isStaticContextType) {
|
1644 | getContext.subscribers.push(instance);
|
1645 | }
|
1646 | }
|
1647 | if (!isStaticContextType) {
|
1648 | cacheContext(instance, unmaskedContext, newContext);
|
1649 | }
|
1650 | var isStateful = !instance.__isStateless;
|
1651 | instance._reactInternalFiber = fiber;
|
1652 | if (isStateful) {
|
1653 | var updateQueue = fiber.updateQueue;
|
1654 | delete fiber.updateFail;
|
1655 | if (fiber.hasMounted) {
|
1656 | applybeforeUpdateHooks(fiber, instance, props, newContext, contextStack);
|
1657 | } else {
|
1658 | applybeforeMountHooks(fiber, instance, props);
|
1659 | }
|
1660 | if (fiber.memoizedState) {
|
1661 | instance.state = fiber.memoizedState;
|
1662 | }
|
1663 | fiber.batching = updateQueue.batching;
|
1664 | var cbs = updateQueue.pendingCbs;
|
1665 | if (cbs.length) {
|
1666 | fiber.pendingCbs = cbs;
|
1667 | fiber.effectTag *= CALLBACK;
|
1668 | }
|
1669 | if (fiber.ref) {
|
1670 | fiber.effectTag *= REF;
|
1671 | }
|
1672 | } else if (type === AnuPortal) {
|
1673 | containerStack.unshift(fiber.parent);
|
1674 | fiber.shiftContainer = true;
|
1675 | }
|
1676 | instance.context = newContext;
|
1677 | fiber.memoizedProps = instance.props = props;
|
1678 | fiber.memoizedState = instance.state;
|
1679 | if (instance.getChildContext) {
|
1680 | var context = instance.getChildContext();
|
1681 | context = Object.assign({}, unmaskedContext, context);
|
1682 | fiber.shiftContext = true;
|
1683 | contextStack.unshift(context);
|
1684 | }
|
1685 | if (fiber.parent && fiber.hasMounted && fiber.dirty) {
|
1686 | fiber.parent.insertPoint = getInsertPoint(fiber);
|
1687 | }
|
1688 | if (isStateful) {
|
1689 | if (fiber.updateFail) {
|
1690 | cloneChildren(fiber);
|
1691 | fiber._hydrating = false;
|
1692 | return;
|
1693 | }
|
1694 | delete fiber.dirty;
|
1695 | fiber.effectTag *= HOOK;
|
1696 | } else if (fiber.effectTag == 1) {
|
1697 | fiber.effectTag = WORKING;
|
1698 | }
|
1699 | if (fiber.catchError) {
|
1700 | return;
|
1701 | }
|
1702 | Renderer.onBeforeRender(fiber);
|
1703 | fiber._hydrating = true;
|
1704 | Renderer.currentOwner = instance;
|
1705 | var rendered = applyCallback(instance, 'render', []);
|
1706 | resetCursor();
|
1707 | diffChildren(fiber, rendered);
|
1708 | Renderer.onAfterRender(fiber);
|
1709 | }
|
1710 | function applybeforeMountHooks(fiber, instance, newProps) {
|
1711 | fiber.setout = true;
|
1712 | if (instance.__useNewHooks) {
|
1713 | setStateByProps(fiber, newProps, instance.state);
|
1714 | } else {
|
1715 | callUnsafeHook(instance, 'componentWillMount', []);
|
1716 | }
|
1717 | delete fiber.setout;
|
1718 | mergeStates(fiber, newProps);
|
1719 | fiber.updateQueue = UpdateQueue();
|
1720 | }
|
1721 | function applybeforeUpdateHooks(fiber, instance, newProps, newContext, contextStack) {
|
1722 | var oldProps = fiber.memoizedProps;
|
1723 | var oldState = fiber.memoizedState;
|
1724 | var updater = instance.updater;
|
1725 | updater.prevProps = oldProps;
|
1726 | updater.prevState = oldState;
|
1727 | var propsChanged = oldProps !== newProps;
|
1728 | fiber.setout = true;
|
1729 | if (!instance.__useNewHooks) {
|
1730 | var contextChanged = instance.context !== newContext;
|
1731 | if (propsChanged || contextChanged) {
|
1732 | var prevState = instance.state;
|
1733 | callUnsafeHook(instance, 'componentWillReceiveProps', [newProps, newContext]);
|
1734 | if (prevState !== instance.state) {
|
1735 | fiber.memoizedState = instance.state;
|
1736 | }
|
1737 | }
|
1738 | }
|
1739 | var newState = instance.state = oldState;
|
1740 | var updateQueue = fiber.updateQueue;
|
1741 | mergeStates(fiber, newProps);
|
1742 | newState = fiber.memoizedState;
|
1743 | setStateByProps(fiber, newProps, newState);
|
1744 | newState = fiber.memoizedState;
|
1745 | delete fiber.setout;
|
1746 | fiber._hydrating = true;
|
1747 | if (!propsChanged && newState === oldState && contextStack.length == 1 && !updateQueue.isForced) {
|
1748 | fiber.updateFail = true;
|
1749 | } else {
|
1750 | var args = [newProps, newState, newContext];
|
1751 | fiber.updateQueue = UpdateQueue();
|
1752 | if (!updateQueue.isForced && !applyCallback(instance, 'shouldComponentUpdate', args)) {
|
1753 | fiber.updateFail = true;
|
1754 | } else if (!instance.__useNewHooks) {
|
1755 | callUnsafeHook(instance, 'componentWillUpdate', args);
|
1756 | }
|
1757 | }
|
1758 | }
|
1759 | function callUnsafeHook(a, b, c) {
|
1760 | applyCallback(a, b, c);
|
1761 | applyCallback(a, 'UNSAFE_' + b, c);
|
1762 | }
|
1763 | function isSameNode(a, b) {
|
1764 | if (a.type === b.type && a.key === b.key) {
|
1765 | return true;
|
1766 | }
|
1767 | }
|
1768 | function setStateByProps(fiber, nextProps, prevState) {
|
1769 | fiber.errorHook = gDSFP;
|
1770 | var fn = fiber.type[gDSFP];
|
1771 | if (fn) {
|
1772 | var partialState = fn.call(null, nextProps, prevState);
|
1773 | if (typeNumber(partialState) === 8) {
|
1774 | fiber.memoizedState = Object.assign({}, prevState, partialState);
|
1775 | }
|
1776 | }
|
1777 | }
|
1778 | function cloneChildren(fiber) {
|
1779 | var prev = fiber.alternate;
|
1780 | if (prev && prev.child) {
|
1781 | var pc = prev.children;
|
1782 | var cc = fiber.children = {};
|
1783 | fiber.child = prev.child;
|
1784 | fiber.lastChild = prev.lastChild;
|
1785 | for (var i in pc) {
|
1786 | var a = pc[i];
|
1787 | a.return = fiber;
|
1788 | cc[i] = a;
|
1789 | }
|
1790 | setInsertPoints(cc);
|
1791 | }
|
1792 | }
|
1793 | function cacheContext(instance, unmaskedContext, context) {
|
1794 | instance.__unmaskedContext = unmaskedContext;
|
1795 | instance.__maskedContext = context;
|
1796 | }
|
1797 | function getMaskedContext(instance, contextTypes, unmaskedContext) {
|
1798 | var noContext = !contextTypes;
|
1799 | if (instance) {
|
1800 | if (noContext) {
|
1801 | return instance.context;
|
1802 | }
|
1803 | var cachedUnmasked = instance.__unmaskedContext;
|
1804 | if (cachedUnmasked === unmaskedContext) {
|
1805 | return instance.__maskedContext;
|
1806 | }
|
1807 | }
|
1808 | var context = {};
|
1809 | if (noContext) {
|
1810 | return context;
|
1811 | }
|
1812 | for (var key in contextTypes) {
|
1813 | if (contextTypes.hasOwnProperty(key)) {
|
1814 | context[key] = unmaskedContext[key];
|
1815 | }
|
1816 | }
|
1817 | return context;
|
1818 | }
|
1819 | function diffChildren(parentFiber, children) {
|
1820 | var oldFibers = parentFiber.children;
|
1821 | if (oldFibers) {
|
1822 | parentFiber.oldChildren = oldFibers;
|
1823 | } else {
|
1824 | oldFibers = {};
|
1825 | }
|
1826 | var newFibers = fiberizeChildren(children, parentFiber);
|
1827 | var effects$$1 = parentFiber.effects || (parentFiber.effects = []);
|
1828 | var matchFibers = new Object();
|
1829 | delete parentFiber.child;
|
1830 | for (var i in oldFibers) {
|
1831 | var newFiber = newFibers[i];
|
1832 | var oldFiber = oldFibers[i];
|
1833 | if (newFiber && newFiber.type === oldFiber.type) {
|
1834 | matchFibers[i] = oldFiber;
|
1835 | if (newFiber.key != null) {
|
1836 | oldFiber.key = newFiber.key;
|
1837 | }
|
1838 | continue;
|
1839 | }
|
1840 | detachFiber(oldFiber, effects$$1);
|
1841 | }
|
1842 | var prevFiber = void 0,
|
1843 | index = 0;
|
1844 | for (var _i in newFibers) {
|
1845 | var _newFiber = newFibers[_i];
|
1846 | var _oldFiber = matchFibers[_i];
|
1847 | var alternate = null;
|
1848 | if (_oldFiber) {
|
1849 | if (isSameNode(_oldFiber, _newFiber)) {
|
1850 | alternate = new Fiber(_oldFiber);
|
1851 | var oldRef = _oldFiber.ref;
|
1852 | _newFiber = extend(_oldFiber, _newFiber);
|
1853 | delete _newFiber.disposed;
|
1854 | _newFiber.alternate = alternate;
|
1855 | if (_newFiber.ref && _newFiber.deleteRef) {
|
1856 | delete _newFiber.ref;
|
1857 | delete _newFiber.deleteRef;
|
1858 | }
|
1859 | if (oldRef && oldRef !== _newFiber.ref) {
|
1860 | effects$$1.push(alternate);
|
1861 | }
|
1862 | if (_newFiber.tag === 5) {
|
1863 | _newFiber.lastProps = alternate.props;
|
1864 | }
|
1865 | } else {
|
1866 | detachFiber(_oldFiber, effects$$1);
|
1867 | }
|
1868 | } else {
|
1869 | _newFiber = new Fiber(_newFiber);
|
1870 | }
|
1871 | newFibers[_i] = _newFiber;
|
1872 | _newFiber.index = index++;
|
1873 | _newFiber.return = parentFiber;
|
1874 | if (prevFiber) {
|
1875 | prevFiber.sibling = _newFiber;
|
1876 | _newFiber.forward = prevFiber;
|
1877 | } else {
|
1878 | parentFiber.child = _newFiber;
|
1879 | _newFiber.forward = null;
|
1880 | }
|
1881 | prevFiber = _newFiber;
|
1882 | }
|
1883 | parentFiber.lastChild = prevFiber;
|
1884 | if (prevFiber) {
|
1885 | prevFiber.sibling = null;
|
1886 | }
|
1887 | }
|
1888 |
|
1889 | function getDOMNode() {
|
1890 | return this;
|
1891 | }
|
1892 | var Refs = {
|
1893 | fireRef: function fireRef(fiber, dom) {
|
1894 | var ref = fiber.ref;
|
1895 | var owner = fiber._owner;
|
1896 | try {
|
1897 | var number = typeNumber(ref);
|
1898 | refStrategy[number](owner, ref, dom);
|
1899 | if (owner && owner.__isStateless) {
|
1900 | delete fiber.ref;
|
1901 | fiber.deleteRef = true;
|
1902 | }
|
1903 | } catch (e) {
|
1904 | pushError(fiber, 'ref', e);
|
1905 | }
|
1906 | }
|
1907 | };
|
1908 | var refStrategy = {
|
1909 | 4: function _(owner, ref, dom) {
|
1910 | if (dom === null) {
|
1911 | delete owner.refs[ref];
|
1912 | } else {
|
1913 | if (dom.nodeType) {
|
1914 | dom.getDOMNode = getDOMNode;
|
1915 | }
|
1916 | owner.refs[ref] = dom;
|
1917 | }
|
1918 | },
|
1919 | 5: function _(owner, ref, dom) {
|
1920 | ref(dom);
|
1921 | },
|
1922 | 8: function _(owner, ref, dom) {
|
1923 | ref.current = dom;
|
1924 | }
|
1925 | };
|
1926 |
|
1927 | var domFns = ['insertElement', 'updateContent', 'updateAttribute'];
|
1928 | var domEffects = [PLACE, CONTENT, ATTR];
|
1929 | var domRemoved = [];
|
1930 | var passiveFibers = [];
|
1931 | function commitDFSImpl(fiber) {
|
1932 | var topFiber = fiber;
|
1933 | outerLoop: while (true) {
|
1934 | if (fiber.effects && fiber.effects.length) {
|
1935 | fiber.effects.forEach(disposeFiber);
|
1936 | delete fiber.effects;
|
1937 | }
|
1938 | if (fiber.effectTag % PLACE == 0) {
|
1939 | domEffects.forEach(function (effect, i) {
|
1940 | if (fiber.effectTag % effect == 0) {
|
1941 | Renderer[domFns[i]](fiber);
|
1942 | fiber.effectTag /= effect;
|
1943 | }
|
1944 | });
|
1945 | fiber.hasMounted = true;
|
1946 | } else {
|
1947 | if (fiber.catchError) {
|
1948 | removeFormBoundaries(fiber);
|
1949 | disposeFibers(fiber);
|
1950 | }
|
1951 | }
|
1952 | if (fiber.updateFail) {
|
1953 | delete fiber.updateFail;
|
1954 | }
|
1955 | if (fiber.child && fiber.child.effectTag > NOWORK) {
|
1956 | fiber = fiber.child;
|
1957 | continue;
|
1958 | }
|
1959 | var f = fiber;
|
1960 | while (f) {
|
1961 | if (f.effectTag === WORKING) {
|
1962 | f.effectTag = NOWORK;
|
1963 | f.hasMounted = true;
|
1964 | } else if (f.effectTag > WORKING) {
|
1965 | commitEffects(f);
|
1966 | f.hasMounted = true;
|
1967 | if (f.capturedValues) {
|
1968 | f.effectTag = CAPTURE;
|
1969 | }
|
1970 | }
|
1971 | if (f === topFiber || f.hostRoot) {
|
1972 | break outerLoop;
|
1973 | }
|
1974 | if (f.sibling) {
|
1975 | fiber = f.sibling;
|
1976 | continue outerLoop;
|
1977 | }
|
1978 | f = f.return;
|
1979 | }
|
1980 | }
|
1981 | }
|
1982 | function commitDFS(effects$$1) {
|
1983 | Renderer.batchedUpdates(function () {
|
1984 | var el;
|
1985 | while (el = effects$$1.shift()) {
|
1986 | if (el.effectTag === DETACH && el.caughtError) {
|
1987 | disposeFiber(el);
|
1988 | } else {
|
1989 | commitDFSImpl(el);
|
1990 | }
|
1991 | if (passiveFibers.length) {
|
1992 | passiveFibers.forEach(function (fiber) {
|
1993 | safeInvokeHooks(fiber.updateQueue, 'passive', 'unpassive');
|
1994 | });
|
1995 | passiveFibers.length = 0;
|
1996 | }
|
1997 | if (domRemoved.length) {
|
1998 | domRemoved.forEach(Renderer.removeElement);
|
1999 | domRemoved.length = 0;
|
2000 | }
|
2001 | }
|
2002 | }, {});
|
2003 | var error = Renderer.catchError;
|
2004 | if (error) {
|
2005 | delete Renderer.catchError;
|
2006 | throw error;
|
2007 | }
|
2008 | }
|
2009 | function commitEffects(fiber) {
|
2010 | var instance = fiber.stateNode || emptyObject;
|
2011 | var amount = fiber.effectTag;
|
2012 | var updater = instance.updater || fakeObject;
|
2013 | for (var i = 0; i < effectLength; i++) {
|
2014 | var effectNo = effectNames[i];
|
2015 | if (effectNo > amount) {
|
2016 | break;
|
2017 | }
|
2018 | if (amount % effectNo === 0) {
|
2019 | amount /= effectNo;
|
2020 | switch (effectNo) {
|
2021 | case WORKING:
|
2022 | break;
|
2023 | case DUPLEX:
|
2024 | Renderer.updateControlled(fiber);
|
2025 | break;
|
2026 | case HOOK:
|
2027 | if (instance.__isStateless) {
|
2028 | safeInvokeHooks(fiber.updateQueue, 'layout', 'unlayout');
|
2029 | } else if (fiber.hasMounted) {
|
2030 | guardCallback(instance, 'componentDidUpdate', [updater.prevProps, updater.prevState, updater.snapshot]);
|
2031 | } else {
|
2032 | fiber.hasMounted = true;
|
2033 | guardCallback(instance, 'componentDidMount', []);
|
2034 | }
|
2035 | delete fiber._hydrating;
|
2036 | if (fiber.catchError) {
|
2037 | fiber.effectTag = amount;
|
2038 | return;
|
2039 | }
|
2040 | break;
|
2041 | case PASSIVE:
|
2042 | passiveFibers.push(fiber);
|
2043 | break;
|
2044 | case REF:
|
2045 | Refs.fireRef(fiber, instance);
|
2046 | break;
|
2047 | case CALLBACK:
|
2048 | var queue = fiber.pendingCbs;
|
2049 | fiber._hydrating = true;
|
2050 | queue.forEach(function (fn) {
|
2051 | fn.call(instance);
|
2052 | });
|
2053 | delete fiber._hydrating;
|
2054 | delete fiber.pendingCbs;
|
2055 | break;
|
2056 | case CAPTURE:
|
2057 | var values = fiber.capturedValues;
|
2058 | fiber.caughtError = true;
|
2059 | var a = values.shift();
|
2060 | var b = values.shift();
|
2061 | if (!values.length) {
|
2062 | fiber.effectTag = amount;
|
2063 | delete fiber.capturedValues;
|
2064 | }
|
2065 | instance.componentDidCatch(a, b);
|
2066 | break;
|
2067 | }
|
2068 | }
|
2069 | }
|
2070 | fiber.effectTag = NOWORK;
|
2071 | }
|
2072 | function disposeFibers(fiber) {
|
2073 | var list = [fiber.oldChildren, fiber.children];
|
2074 | for (var i = 0; i < 2; i++) {
|
2075 | var c = list[i];
|
2076 | if (c) {
|
2077 | for (var _i in c) {
|
2078 | var child = c[_i];
|
2079 | if (!child.disposed && child.hasMounted) {
|
2080 | disposeFiber(child, true);
|
2081 | disposeFibers(child);
|
2082 | }
|
2083 | }
|
2084 | }
|
2085 | }
|
2086 | delete fiber.child;
|
2087 | delete fiber.lastChild;
|
2088 | delete fiber.oldChildren;
|
2089 | fiber.children = {};
|
2090 | }
|
2091 | function safeInvokeHooks(upateQueue, create, destory) {
|
2092 | var uneffects = upateQueue[destory],
|
2093 | effects$$1 = upateQueue[create],
|
2094 | fn;
|
2095 | if (!uneffects) {
|
2096 | return;
|
2097 | }
|
2098 | while (fn = uneffects.shift()) {
|
2099 | try {
|
2100 | fn();
|
2101 | } catch (e) { }
|
2102 | }
|
2103 | while (fn = effects$$1.shift()) {
|
2104 | try {
|
2105 | var f = fn();
|
2106 | if (typeof f === 'function') {
|
2107 | uneffects.push(f);
|
2108 | }
|
2109 | } catch (e) { }
|
2110 | }
|
2111 | }
|
2112 | function disposeFiber(fiber, force) {
|
2113 | var stateNode = fiber.stateNode,
|
2114 | effectTag = fiber.effectTag;
|
2115 | if (!stateNode) {
|
2116 | return;
|
2117 | }
|
2118 | var isStateless = stateNode.__isStateless;
|
2119 | if (!isStateless && fiber.ref) {
|
2120 | Refs.fireRef(fiber, null);
|
2121 | }
|
2122 | if (effectTag % DETACH == 0 || force === true) {
|
2123 | if (fiber.tag > 3) {
|
2124 | domRemoved.push(fiber);
|
2125 | } else {
|
2126 | Renderer.onDispose(fiber);
|
2127 | if (fiber.hasMounted) {
|
2128 | if (isStateless) {
|
2129 | safeInvokeHooks(fiber.updateQueue, 'layout', 'unlayout');
|
2130 | safeInvokeHooks(fiber.updateQueue, 'passive', 'unpassive');
|
2131 | }
|
2132 | stateNode.updater.enqueueSetState = returnFalse;
|
2133 | guardCallback(stateNode, 'componentWillUnmount', []);
|
2134 | delete fiber.stateNode;
|
2135 | }
|
2136 | }
|
2137 | delete fiber.alternate;
|
2138 | delete fiber.hasMounted;
|
2139 | fiber.disposed = true;
|
2140 | }
|
2141 | fiber.effectTag = NOWORK;
|
2142 | }
|
2143 |
|
2144 | var Unbatch = miniCreateClass(function Unbatch(props) {
|
2145 | this.state = {
|
2146 | child: props.child
|
2147 | };
|
2148 | }, Component, {
|
2149 | render: function f3() {
|
2150 | return this.state.child;
|
2151 | }
|
2152 | });
|
2153 |
|
2154 | var macrotasks = Renderer.macrotasks;
|
2155 | var boundaries = Renderer.boundaries;
|
2156 | var batchedtasks = [];
|
2157 | function render(vnode, root, callback) {
|
2158 | var container = createContainer(root),
|
2159 | immediateUpdate = false;
|
2160 | if (!container.hostRoot) {
|
2161 | var fiber = new Fiber({
|
2162 | type: Unbatch,
|
2163 | tag: 2,
|
2164 | props: {},
|
2165 | hasMounted: true,
|
2166 | memoizedState: {},
|
2167 | return: container
|
2168 | });
|
2169 | fiber.index = 0;
|
2170 | container.child = fiber;
|
2171 | var instance = createInstance(fiber, {});
|
2172 | container.hostRoot = instance;
|
2173 | immediateUpdate = true;
|
2174 | Renderer.emptyElement(container);
|
2175 | }
|
2176 | var carrier = {};
|
2177 | updateComponent(container.child, {
|
2178 | child: vnode
|
2179 | }, wrapCb(callback, carrier), immediateUpdate);
|
2180 | return carrier.instance;
|
2181 | }
|
2182 | function wrapCb(fn, carrier) {
|
2183 | return function () {
|
2184 | var fiber = get(this);
|
2185 | var target = fiber.child ? fiber.child.stateNode : null;
|
2186 | fn && fn.call(target);
|
2187 | carrier.instance = target;
|
2188 | };
|
2189 | }
|
2190 | function performWork(deadline) {
|
2191 | workLoop(deadline);
|
2192 | if (boundaries.length) {
|
2193 | macrotasks.unshift.apply(macrotasks, boundaries);
|
2194 | boundaries.length = 0;
|
2195 | }
|
2196 | topFibers.forEach(function (el) {
|
2197 | var microtasks = el.microtasks;
|
2198 | while (el = microtasks.shift()) {
|
2199 | if (!el.disposed) {
|
2200 | macrotasks.push(el);
|
2201 | }
|
2202 | }
|
2203 | });
|
2204 | if (macrotasks.length) {
|
2205 | requestIdleCallback(performWork);
|
2206 | }
|
2207 | }
|
2208 | var ENOUGH_TIME = 1;
|
2209 | var deadline = {
|
2210 | didTimeout: false,
|
2211 | timeRemaining: function timeRemaining() {
|
2212 | return 2;
|
2213 | }
|
2214 | };
|
2215 | function requestIdleCallback(fn) {
|
2216 | fn(deadline);
|
2217 | }
|
2218 | Renderer.scheduleWork = function () {
|
2219 | performWork(deadline);
|
2220 | };
|
2221 | var isBatching = false;
|
2222 | Renderer.batchedUpdates = function (callback, event) {
|
2223 | var keepbook = isBatching;
|
2224 | isBatching = true;
|
2225 | try {
|
2226 | event && Renderer.fireMiddlewares(true);
|
2227 | return callback(event);
|
2228 | } finally {
|
2229 | isBatching = keepbook;
|
2230 | if (!isBatching) {
|
2231 | var el = void 0;
|
2232 | while (el = batchedtasks.shift()) {
|
2233 | if (!el.disabled) {
|
2234 | macrotasks.push(el);
|
2235 | }
|
2236 | }
|
2237 | event && Renderer.fireMiddlewares();
|
2238 | Renderer.scheduleWork();
|
2239 | }
|
2240 | }
|
2241 | };
|
2242 | function workLoop(deadline) {
|
2243 | var fiber = macrotasks.shift(),
|
2244 | info = void 0;
|
2245 | if (fiber) {
|
2246 | if (fiber.type === Unbatch) {
|
2247 | info = fiber.return;
|
2248 | } else {
|
2249 | var dom = getContainer(fiber);
|
2250 | info = {
|
2251 | containerStack: [dom],
|
2252 | contextStack: [fiber.stateNode.__unmaskedContext]
|
2253 | };
|
2254 | }
|
2255 | reconcileDFS(fiber, info, deadline, ENOUGH_TIME);
|
2256 | updateCommitQueue(fiber);
|
2257 | resetStack(info);
|
2258 | if (macrotasks.length && deadline.timeRemaining() > ENOUGH_TIME) {
|
2259 | workLoop(deadline);
|
2260 | } else {
|
2261 | commitDFS(effects);
|
2262 | }
|
2263 | }
|
2264 | }
|
2265 | function updateCommitQueue(fiber) {
|
2266 | var hasBoundary = boundaries.length;
|
2267 | if (fiber.type !== Unbatch) {
|
2268 | if (hasBoundary) {
|
2269 | arrayPush.apply(effects, boundaries);
|
2270 | } else {
|
2271 | effects.push(fiber);
|
2272 | }
|
2273 | } else {
|
2274 | effects.push(fiber);
|
2275 | }
|
2276 | boundaries.length = 0;
|
2277 | }
|
2278 | function mergeUpdates(fiber, state, isForced, callback) {
|
2279 | var updateQueue = fiber.updateQueue;
|
2280 | if (isForced) {
|
2281 | updateQueue.isForced = true;
|
2282 | }
|
2283 | if (state) {
|
2284 | updateQueue.pendingStates.push(state);
|
2285 | }
|
2286 | if (isFn(callback)) {
|
2287 | updateQueue.pendingCbs.push(callback);
|
2288 | }
|
2289 | }
|
2290 | function fiberContains(p, son) {
|
2291 | while (son.return) {
|
2292 | if (son.return === p) {
|
2293 | return true;
|
2294 | }
|
2295 | son = son.return;
|
2296 | }
|
2297 | }
|
2298 | function getQueue(fiber) {
|
2299 | while (fiber) {
|
2300 | if (fiber.microtasks) {
|
2301 | return fiber.microtasks;
|
2302 | }
|
2303 | fiber = fiber.return;
|
2304 | }
|
2305 | }
|
2306 | function pushChildQueue(fiber, queue) {
|
2307 | var maps = {};
|
2308 | for (var i = queue.length, el; el = queue[--i];) {
|
2309 | if (fiber === el) {
|
2310 | queue.splice(i, 1);
|
2311 | continue;
|
2312 | } else if (fiberContains(fiber, el)) {
|
2313 | queue.splice(i, 1);
|
2314 | continue;
|
2315 | }
|
2316 | maps[el.stateNode.updater.mountOrder] = true;
|
2317 | }
|
2318 | var enqueue = true,
|
2319 | p = fiber,
|
2320 | hackSCU = [];
|
2321 | while (p.return) {
|
2322 | p = p.return;
|
2323 | var instance = p.stateNode;
|
2324 | if (instance.refs && !instance.__isStateless && p.type !== Unbatch) {
|
2325 | hackSCU.push(p);
|
2326 | var u = instance.updater;
|
2327 | if (maps[u.mountOrder]) {
|
2328 | enqueue = false;
|
2329 | break;
|
2330 | }
|
2331 | }
|
2332 | }
|
2333 | hackSCU.forEach(function (el) {
|
2334 | el.updateQueue.batching = true;
|
2335 | });
|
2336 | if (enqueue) {
|
2337 | queue.push(fiber);
|
2338 | }
|
2339 | }
|
2340 | function updateComponent(fiber, state, callback, immediateUpdate) {
|
2341 | fiber.dirty = true;
|
2342 | var sn = typeNumber(state);
|
2343 | var isForced = state === true;
|
2344 | var microtasks = getQueue(fiber);
|
2345 | state = isForced ? null : sn === 5 || sn === 8 ? state : null;
|
2346 | if (fiber.setout) {
|
2347 | immediateUpdate = false;
|
2348 | } else if (isBatching && !immediateUpdate || fiber._hydrating) {
|
2349 | pushChildQueue(fiber, batchedtasks);
|
2350 | } else {
|
2351 | immediateUpdate = immediateUpdate || !fiber._hydrating;
|
2352 | pushChildQueue(fiber, microtasks);
|
2353 | }
|
2354 | mergeUpdates(fiber, state, isForced, callback);
|
2355 | if (immediateUpdate) {
|
2356 | Renderer.scheduleWork();
|
2357 | }
|
2358 | }
|
2359 | Renderer.updateComponent = updateComponent;
|
2360 | function validateTag(el) {
|
2361 | return el && el.appendChild;
|
2362 | }
|
2363 | function createContainer(root, onlyGet, validate) {
|
2364 | validate = validate || validateTag;
|
2365 | if (!validate(root)) {
|
2366 | throw 'container is not a element';
|
2367 | }
|
2368 | root.anuProp = 2018;
|
2369 | var useProp = root.anuProp === 2018;
|
2370 | if (useProp) {
|
2371 | root.anuProp = void 0;
|
2372 | if (get(root)) {
|
2373 | return get(root);
|
2374 | }
|
2375 | } else {
|
2376 | var index = topNodes.indexOf(root);
|
2377 | if (index !== -1) {
|
2378 | return topFibers[index];
|
2379 | }
|
2380 | }
|
2381 | if (onlyGet) {
|
2382 | return null;
|
2383 | }
|
2384 | var container = new Fiber({
|
2385 | stateNode: root,
|
2386 | tag: 5,
|
2387 | name: 'hostRoot',
|
2388 | contextStack: [{}],
|
2389 | containerStack: [root],
|
2390 | microtasks: [],
|
2391 | type: root.nodeName || root.type
|
2392 | });
|
2393 | if (useProp) {
|
2394 | root._reactInternalFiber = container;
|
2395 | }
|
2396 | topNodes.push(root);
|
2397 | topFibers.push(container);
|
2398 | return container;
|
2399 | }
|
2400 | function getContainer(p) {
|
2401 | if (p.parent) {
|
2402 | return p.parent;
|
2403 | }
|
2404 | while (p = p.return) {
|
2405 | if (p.tag === 5) {
|
2406 | return p.stateNode;
|
2407 | }
|
2408 | }
|
2409 | }
|
2410 |
|
2411 | var onEvent = /(?:on|catch)[A-Z]/;
|
2412 | function getEventUid(name, props) {
|
2413 | var n = name.charAt(0) == 'o' ? 2 : 5;
|
2414 | var type = toLowerCase(name.slice(n));
|
2415 | return props['data-' + type + '-uid'];
|
2416 | }
|
2417 | var Renderer$1 = createRenderer({
|
2418 | render: render,
|
2419 | updateAttribute: function updateAttribute(fiber) {
|
2420 | var props = fiber.props,
|
2421 | lastProps = fiber.lastProps;
|
2422 | var beaconId = props['data-beacon-uid'];
|
2423 | var instance = fiber._owner;
|
2424 | if (instance && beaconId) {
|
2425 | var cached = instance.$$eventCached || (instance.$$eventCached = {});
|
2426 | for (var name in props) {
|
2427 | if (onEvent.test(name) && isFn(props[name])) {
|
2428 | var code = getEventUid(name, props);
|
2429 | cached[code] = props[name];
|
2430 | cached[code + 'Fiber'] = fiber;
|
2431 | }
|
2432 | }
|
2433 | if (lastProps) {
|
2434 | for (var _name in lastProps) {
|
2435 | if (onEvent.test(_name) && !props[_name]) {
|
2436 | var _code = getEventUid(_name, lastProps);
|
2437 | delete cached[_code];
|
2438 | delete cached[_code + 'Fiber'];
|
2439 | }
|
2440 | }
|
2441 | }
|
2442 | }
|
2443 | },
|
2444 | updateContent: function updateContent(fiber) {
|
2445 | fiber.stateNode.props = fiber.props;
|
2446 | },
|
2447 | onBeforeRender: function onBeforeRender(fiber) {
|
2448 | var type = fiber.type;
|
2449 | var instance = fiber.stateNode;
|
2450 | var app = _getApp();
|
2451 | if (type.reactInstances) {
|
2452 | var uuid = fiber.props['data-instance-uid'] || null;
|
2453 | if (!instance.instanceUid) {
|
2454 | instance.instanceUid = uuid;
|
2455 | }
|
2456 | if (type.isMPComponent) {
|
2457 | if (!instance.wx) {
|
2458 | instance.$$pagePath = Object(_getApp()).$$pagePath;
|
2459 | type.reactInstances.push(instance);
|
2460 | }
|
2461 | }
|
2462 | }
|
2463 | if (!app.$$pageIsReady && instance.componentDidMount) {
|
2464 | delayMounts.push({
|
2465 | instance: instance,
|
2466 | fn: instance.componentDidMount
|
2467 | });
|
2468 | instance.componentDidMount = Boolean;
|
2469 | }
|
2470 | },
|
2471 | onAfterRender: function onAfterRender(fiber) {
|
2472 | updateMiniApp(fiber.stateNode);
|
2473 | },
|
2474 | createElement: function createElement(fiber) {
|
2475 | return fiber.tag === 5 ? {
|
2476 | type: fiber.type,
|
2477 | props: fiber.props || {},
|
2478 | children: []
|
2479 | } : {
|
2480 | type: fiber.type,
|
2481 | props: fiber.props
|
2482 | };
|
2483 | },
|
2484 | insertElement: function insertElement() {},
|
2485 | emptyElement: function emptyElement() {},
|
2486 | removeElement: function removeElement() {}
|
2487 | });
|
2488 |
|
2489 | var rhyphen = /([a-z\d])([A-Z]+)/g;
|
2490 | function hyphen(target) {
|
2491 | return target.replace(rhyphen, '$1-$2').toLowerCase();
|
2492 | }
|
2493 | function transform(React, obj) {
|
2494 | var pxTransform = React.api.pxTransform || React.pxTransform;
|
2495 | return Object.keys(obj).map(function (item) {
|
2496 | var value = obj[item] + '';
|
2497 | value = value.replace(/(\d+)px/g, function (str, match) {
|
2498 | return pxTransform(match);
|
2499 | });
|
2500 | return hyphen(item) + ': ' + value;
|
2501 | }).join(';');
|
2502 | }
|
2503 | function toStyle(obj, props, key) {
|
2504 | if (props) {
|
2505 | if (Object(obj) == obj) {
|
2506 | var str = transform(this, obj);
|
2507 | } else {
|
2508 | str = obj;
|
2509 | }
|
2510 | props[key] = str;
|
2511 | } else {
|
2512 | console.warn('toStyle生成样式失败,key为', key);
|
2513 | }
|
2514 | return obj;
|
2515 | }
|
2516 |
|
2517 | var GlobalApp = void 0;
|
2518 | function _getGlobalApp(app) {
|
2519 | return GlobalApp || app.globalData._GlobalApp;
|
2520 | }
|
2521 | function registerApp(app) {
|
2522 | GlobalApp = app.constructor;
|
2523 | return app;
|
2524 | }
|
2525 |
|
2526 | function onLoad(PageClass, path, query, isLoad) {
|
2527 | var app = _getApp();
|
2528 | var container = this.reactContainer || {
|
2529 | type: "page",
|
2530 | props: {},
|
2531 | children: [],
|
2532 | root: true,
|
2533 | appendChild: noop
|
2534 | };
|
2535 | var GlobalApp = _getGlobalApp(app);
|
2536 | app.$$pageIsReady = false;
|
2537 | app.$$page = this;
|
2538 | app.$$pagePath = path;
|
2539 | var pageInstance;
|
2540 | if (typeof GlobalApp === "function") {
|
2541 | this.needReRender = true;
|
2542 | render(createElement(GlobalApp, {}, createElement(PageClass, {
|
2543 | path: path,
|
2544 | key: path,
|
2545 | query: query,
|
2546 | isPageComponent: true
|
2547 | })), container, function () {
|
2548 | var fiber = get(this).child;
|
2549 | while (!fiber.stateNode.classUid) {
|
2550 | fiber = fiber.child;
|
2551 | }
|
2552 | pageInstance = fiber.stateNode;
|
2553 | });
|
2554 | } else {
|
2555 | pageInstance = render(
|
2556 | createElement(PageClass, {
|
2557 | path: path,
|
2558 | query: query,
|
2559 | isPageComponent: true
|
2560 | }), container);
|
2561 | }
|
2562 | if (isLoad) {
|
2563 | callGlobalHook("onGlobalLoad");
|
2564 | }
|
2565 | this.reactContainer = container;
|
2566 | this.reactInstance = pageInstance;
|
2567 | pageInstance.wx = this;
|
2568 | updateMiniApp(pageInstance);
|
2569 | return pageInstance;
|
2570 | }
|
2571 | function onReady() {
|
2572 | var app = _getApp();
|
2573 | app.$$pageIsReady = true;
|
2574 | var el = void 0;
|
2575 | while (el = delayMounts.pop()) {
|
2576 | el.fn.call(el.instance);
|
2577 | el.instance.componentDidMount = el.fn;
|
2578 | }
|
2579 | callGlobalHook("onGlobalReady");
|
2580 | }
|
2581 | function onUnload() {
|
2582 | for (var i in usingComponents) {
|
2583 | var a = usingComponents[i];
|
2584 | if (a.reactInstances) {
|
2585 | a.reactInstances.length = 0;
|
2586 | }
|
2587 | delete usingComponents[i];
|
2588 | }
|
2589 | var root = this.reactContainer;
|
2590 | var container = root && root._reactInternalFiber;
|
2591 | if (container) {
|
2592 | Renderer.updateComponent(container.child, {
|
2593 | child: null
|
2594 | }, function () {
|
2595 | root._reactInternalFiber = null;
|
2596 | var j = topNodes.indexOf(root);
|
2597 | if (j !== -1) {
|
2598 | topFibers.splice(j, 1);
|
2599 | topNodes.splice(j, 1);
|
2600 | }
|
2601 | }, true);
|
2602 | }
|
2603 | callGlobalHook("onGlobalUnload");
|
2604 | this.reactContainer = null;
|
2605 | }
|
2606 |
|
2607 | function registerPageHook(appHooks, pageHook, app, instance, args) {
|
2608 | for (var i = 0; i < 2; i++) {
|
2609 | var method = i ? appHooks[pageHook] : pageHook;
|
2610 | var host = i ? app : instance;
|
2611 | if (host && host[method] && isFn(host[method])) {
|
2612 | var ret = host[method](args);
|
2613 | if (ret !== void 0) {
|
2614 | if (ret && ret.then && ret['catch']) {
|
2615 | continue;
|
2616 | }
|
2617 | return ret;
|
2618 | }
|
2619 | }
|
2620 | }
|
2621 | }
|
2622 |
|
2623 | var appHooks = {
|
2624 | onShow: 'onGlobalShow',
|
2625 | onHide: 'onGlobalHide'
|
2626 | };
|
2627 | function registerPage(PageClass, path, testObject) {
|
2628 | PageClass.reactInstances = [];
|
2629 | var config = {
|
2630 | data: {},
|
2631 | dispatchEvent: dispatchEvent,
|
2632 | onLoad: function onLoad$$1(query) {
|
2633 | onLoad.call(this, PageClass, path, query, true);
|
2634 | },
|
2635 | onReady: onReady,
|
2636 | onUnload: onUnload
|
2637 | };
|
2638 | Array('onShareAppMessage', 'onPageScroll', 'onReachBottom', 'onPullDownRefresh', 'onTabItemTap', 'onResize', 'onShow', 'onHide').forEach(function (hook) {
|
2639 | config[hook] = function (e) {
|
2640 | var instance = this.reactInstance,
|
2641 | pageHook = hook,
|
2642 | app = _getApp(),
|
2643 | param = e;
|
2644 | if (pageHook === 'onShareAppMessage') {
|
2645 | if (!instance.onShare) {
|
2646 | instance.onShare = instance[pageHook];
|
2647 | }
|
2648 | var shareObject = instance.onShare && instance.onShare(param);
|
2649 | if (!shareObject) {
|
2650 | shareObject = app.onGlobalShare && app.onGlobalShare(param);
|
2651 | }
|
2652 | return shareObject;
|
2653 | } else if (pageHook === 'onShow') {
|
2654 | if (this.options) {
|
2655 | instance.props.query = this.options;
|
2656 | }
|
2657 | param = instance.props.query;
|
2658 | app.$$page = this;
|
2659 | var path = app.$$pagePath = instance.props.path;
|
2660 | if (this.needReRender) {
|
2661 | onLoad.call(this, PageClass, path, param);
|
2662 | }
|
2663 | }
|
2664 | return registerPageHook(appHooks, pageHook, app, instance, param);
|
2665 | };
|
2666 | });
|
2667 | if (testObject) {
|
2668 | config.setData = function (obj) {
|
2669 | config.data = obj;
|
2670 | };
|
2671 | config.onLoad();
|
2672 | return config;
|
2673 | }
|
2674 | return config;
|
2675 | }
|
2676 |
|
2677 | var defer = Promise.resolve().then.bind(Promise.resolve());
|
2678 | function registerComponent(type, name) {
|
2679 | type.isMPComponent = true;
|
2680 | registeredComponents[name] = type;
|
2681 | type.reactInstances = [];
|
2682 | var config = {
|
2683 | data: {
|
2684 | props: {},
|
2685 | state: {},
|
2686 | context: {}
|
2687 | },
|
2688 | options: type.options,
|
2689 | lifetimes: {
|
2690 | attached: function attached() {
|
2691 | var wx = this;
|
2692 | defer(function () {
|
2693 | usingComponents[name] = type;
|
2694 | var uuid = wx.dataset.instanceUid || null;
|
2695 | refreshComponent(type.reactInstances, wx, uuid);
|
2696 | });
|
2697 | },
|
2698 | detached: detachComponent,
|
2699 | error: function error(e) {
|
2700 | console.log(e, name);
|
2701 | }
|
2702 | },
|
2703 | methods: {
|
2704 | dispatchEvent: dispatchEvent
|
2705 | }
|
2706 | };
|
2707 | Object.assign(config, config.lifetimes);
|
2708 | return config;
|
2709 | }
|
2710 |
|
2711 | function useState(initValue) {
|
2712 | return useReducerImpl(null, initValue);
|
2713 | }
|
2714 | function useReducer(reducer, initValue, initAction) {
|
2715 | return useReducerImpl(reducer, initValue, initAction);
|
2716 | }
|
2717 | function useEffect(create, deps) {
|
2718 | return useEffectImpl(create, deps, PASSIVE, "passive", "unpassive");
|
2719 | }
|
2720 | function useMemo(create, deps) {
|
2721 | return useCallbackImpl(create, deps, true);
|
2722 | }
|
2723 | function useCallback(create, deps) {
|
2724 | return useCallbackImpl(create, deps);
|
2725 | }
|
2726 |
|
2727 | var MemoComponent = miniCreateClass(function MemoComponent(obj) {
|
2728 | this.render = obj.render;
|
2729 | this.shouldComponentUpdate = obj.shouldComponentUpdate;
|
2730 | }, Component, {});
|
2731 | function memo(render, shouldComponentUpdate) {
|
2732 | return function (props) {
|
2733 | return createElement(MemoComponent, Object.assign(props, {
|
2734 | render: render.bind(this, props),
|
2735 | shouldComponentUpdate: shouldComponentUpdate
|
2736 | }));
|
2737 | };
|
2738 | }
|
2739 |
|
2740 | var render$1 = Renderer$1.render;
|
2741 | var React = getWindow().React = {
|
2742 | eventSystem: {
|
2743 | dispatchEvent: dispatchEvent
|
2744 | },
|
2745 | findDOMNode: function findDOMNode() {
|
2746 | console.log("小程序不支持findDOMNode");
|
2747 | },
|
2748 | render: render$1,
|
2749 | hydrate: render$1,
|
2750 | webview: webview,
|
2751 | Fragment: Fragment,
|
2752 | PropTypes: PropTypes,
|
2753 | createRef: createRef,
|
2754 | Component: Component,
|
2755 | createElement: createElement,
|
2756 | createFactory: createFactory,
|
2757 | PureComponent: PureComponent,
|
2758 | isValidElement: isValidElement,
|
2759 | createContext: createContext,
|
2760 | toClass: miniCreateClass,
|
2761 | registerComponent: registerComponent,
|
2762 | getCurrentPage: getCurrentPage,
|
2763 | getCurrentPages: _getCurrentPages,
|
2764 | getApp: _getApp,
|
2765 | registerApp: registerApp,
|
2766 | registerPage: registerPage,
|
2767 | toStyle: toStyle,
|
2768 | memo: memo,
|
2769 | useState: useState,
|
2770 | useReducer: useReducer,
|
2771 | useCallback: useCallback,
|
2772 | useMemo: useMemo,
|
2773 | useEffect: useEffect,
|
2774 | useContext: useContext,
|
2775 | useComponent: useComponent,
|
2776 | useRef: useRef,
|
2777 | appType: "wx"
|
2778 | };
|
2779 | var apiContainer = {};
|
2780 | if (typeof wx != "undefined") {
|
2781 | apiContainer = wx;
|
2782 | } else if (typeof qq != "undefined") {
|
2783 | apiContainer = qq;
|
2784 | React.appType = "qq";
|
2785 | } else if (typeof tt != "undefined") {
|
2786 | apiContainer = tt;
|
2787 | React.appType = "tt";
|
2788 | }
|
2789 | registerAPIs(React, apiContainer, more);
|
2790 |
|
2791 | exports.default = React;
|
2792 | exports.Children = Children;
|
2793 | exports.createElement = createElement;
|
2794 | exports.Component = Component;
|
2795 | exports.PureComponent = PureComponent;
|
2796 | exports.memo = memo;
|
2797 | exports.createRef = createRef;
|
2798 | exports.useState = useState;
|
2799 | exports.useReducer = useReducer;
|
2800 | exports.useCallback = useCallback;
|
2801 | exports.useMemo = useMemo;
|
2802 | exports.useEffect = useEffect;
|
2803 | exports.useContext = useContext;
|
2804 | exports.useComponent = useComponent;
|
2805 | exports.useRef = useRef;
|