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