react-reconciler 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,334 @@
1
+ /** @license React v16.2.0
2
+ * react-reconciler-reflection.development.js
3
+ *
4
+ * Copyright (c) 2013-present, Facebook, Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ 'use strict';
11
+
12
+
13
+
14
+ if (process.env.NODE_ENV !== "production") {
15
+ (function() {
16
+ 'use strict';
17
+
18
+ Object.defineProperty(exports, '__esModule', { value: true });
19
+
20
+ var invariant = require('fbjs/lib/invariant');
21
+ var warning = require('fbjs/lib/warning');
22
+ var React = require('react');
23
+
24
+ /**
25
+ * WARNING: DO NOT manually require this module.
26
+ * This is a replacement for `invariant(...)` used by the error code system
27
+ * and will _only_ be required by the corresponding babel pass.
28
+ * It always throws.
29
+ */
30
+
31
+ /**
32
+ * `ReactInstanceMap` maintains a mapping from a public facing stateful
33
+ * instance (key) and the internal representation (value). This allows public
34
+ * methods to accept the user facing instance as an argument and map them back
35
+ * to internal methods.
36
+ *
37
+ * Note that this module is currently shared and assumed to be stateless.
38
+ * If this becomes an actual Map, that will break.
39
+ */
40
+
41
+ /**
42
+ * This API should be called `delete` but we'd have to make sure to always
43
+ * transform these to strings for IE support. When this transform is fully
44
+ * supported we can rename it.
45
+ */
46
+
47
+
48
+ function get(key) {
49
+ return key._reactInternalFiber;
50
+ }
51
+
52
+ var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
53
+
54
+ var ReactCurrentOwner = ReactInternals.ReactCurrentOwner;
55
+ var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame;
56
+
57
+ function getComponentName(fiber) {
58
+ var type = fiber.type;
59
+
60
+ if (typeof type === 'string') {
61
+ return type;
62
+ }
63
+ if (typeof type === 'function') {
64
+ return type.displayName || type.name;
65
+ }
66
+ return null;
67
+ }
68
+
69
+ // Before we know whether it is functional or class
70
+
71
+ var ClassComponent = 2;
72
+ var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
73
+ var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
74
+ var HostComponent = 5;
75
+ var HostText = 6;
76
+
77
+ // Don't change these two values:
78
+ var NoEffect = 0; // 0b00000000
79
+ // 0b00000001
80
+
81
+ // You can change the rest (and add more).
82
+ var Placement = 2; // 0b00000010
83
+ // 0b00000100
84
+ // 0b00000110
85
+ // 0b00001000
86
+ // 0b00010000
87
+ // 0b00100000
88
+ // 0b01000000
89
+ // 0b10000000
90
+
91
+ var MOUNTING = 1;
92
+ var MOUNTED = 2;
93
+ var UNMOUNTED = 3;
94
+
95
+ function isFiberMountedImpl(fiber) {
96
+ var node = fiber;
97
+ if (!fiber.alternate) {
98
+ // If there is no alternate, this might be a new tree that isn't inserted
99
+ // yet. If it is, then it will have a pending insertion effect on it.
100
+ if ((node.effectTag & Placement) !== NoEffect) {
101
+ return MOUNTING;
102
+ }
103
+ while (node['return']) {
104
+ node = node['return'];
105
+ if ((node.effectTag & Placement) !== NoEffect) {
106
+ return MOUNTING;
107
+ }
108
+ }
109
+ } else {
110
+ while (node['return']) {
111
+ node = node['return'];
112
+ }
113
+ }
114
+ if (node.tag === HostRoot) {
115
+ // TODO: Check if this was a nested HostRoot when used with
116
+ // renderContainerIntoSubtree.
117
+ return MOUNTED;
118
+ }
119
+ // If we didn't hit the root, that means that we're in an disconnected tree
120
+ // that has been unmounted.
121
+ return UNMOUNTED;
122
+ }
123
+
124
+ function isFiberMounted(fiber) {
125
+ return isFiberMountedImpl(fiber) === MOUNTED;
126
+ }
127
+
128
+ function isMounted(component) {
129
+ {
130
+ var owner = ReactCurrentOwner.current;
131
+ if (owner !== null && owner.tag === ClassComponent) {
132
+ var ownerFiber = owner;
133
+ var instance = ownerFiber.stateNode;
134
+ warning(instance._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber) || 'A component');
135
+ instance._warnedAboutRefsInRender = true;
136
+ }
137
+ }
138
+
139
+ var fiber = get(component);
140
+ if (!fiber) {
141
+ return false;
142
+ }
143
+ return isFiberMountedImpl(fiber) === MOUNTED;
144
+ }
145
+
146
+ function assertIsMounted(fiber) {
147
+ !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
148
+ }
149
+
150
+ function findCurrentFiberUsingSlowPath(fiber) {
151
+ var alternate = fiber.alternate;
152
+ if (!alternate) {
153
+ // If there is no alternate, then we only need to check if it is mounted.
154
+ var state = isFiberMountedImpl(fiber);
155
+ !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
156
+ if (state === MOUNTING) {
157
+ return null;
158
+ }
159
+ return fiber;
160
+ }
161
+ // If we have two possible branches, we'll walk backwards up to the root
162
+ // to see what path the root points to. On the way we may hit one of the
163
+ // special cases and we'll deal with them.
164
+ var a = fiber;
165
+ var b = alternate;
166
+ while (true) {
167
+ var parentA = a['return'];
168
+ var parentB = parentA ? parentA.alternate : null;
169
+ if (!parentA || !parentB) {
170
+ // We're at the root.
171
+ break;
172
+ }
173
+
174
+ // If both copies of the parent fiber point to the same child, we can
175
+ // assume that the child is current. This happens when we bailout on low
176
+ // priority: the bailed out fiber's child reuses the current child.
177
+ if (parentA.child === parentB.child) {
178
+ var child = parentA.child;
179
+ while (child) {
180
+ if (child === a) {
181
+ // We've determined that A is the current branch.
182
+ assertIsMounted(parentA);
183
+ return fiber;
184
+ }
185
+ if (child === b) {
186
+ // We've determined that B is the current branch.
187
+ assertIsMounted(parentA);
188
+ return alternate;
189
+ }
190
+ child = child.sibling;
191
+ }
192
+ // We should never have an alternate for any mounting node. So the only
193
+ // way this could possibly happen is if this was unmounted, if at all.
194
+ invariant(false, 'Unable to find node on an unmounted component.');
195
+ }
196
+
197
+ if (a['return'] !== b['return']) {
198
+ // The return pointer of A and the return pointer of B point to different
199
+ // fibers. We assume that return pointers never criss-cross, so A must
200
+ // belong to the child set of A.return, and B must belong to the child
201
+ // set of B.return.
202
+ a = parentA;
203
+ b = parentB;
204
+ } else {
205
+ // The return pointers point to the same fiber. We'll have to use the
206
+ // default, slow path: scan the child sets of each parent alternate to see
207
+ // which child belongs to which set.
208
+ //
209
+ // Search parent A's child set
210
+ var didFindChild = false;
211
+ var _child = parentA.child;
212
+ while (_child) {
213
+ if (_child === a) {
214
+ didFindChild = true;
215
+ a = parentA;
216
+ b = parentB;
217
+ break;
218
+ }
219
+ if (_child === b) {
220
+ didFindChild = true;
221
+ b = parentA;
222
+ a = parentB;
223
+ break;
224
+ }
225
+ _child = _child.sibling;
226
+ }
227
+ if (!didFindChild) {
228
+ // Search parent B's child set
229
+ _child = parentB.child;
230
+ while (_child) {
231
+ if (_child === a) {
232
+ didFindChild = true;
233
+ a = parentB;
234
+ b = parentA;
235
+ break;
236
+ }
237
+ if (_child === b) {
238
+ didFindChild = true;
239
+ b = parentB;
240
+ a = parentA;
241
+ break;
242
+ }
243
+ _child = _child.sibling;
244
+ }
245
+ !didFindChild ? invariant(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0;
246
+ }
247
+ }
248
+
249
+ !(a.alternate === b) ? invariant(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0;
250
+ }
251
+ // If the root is not a host container, we're in a disconnected tree. I.e.
252
+ // unmounted.
253
+ !(a.tag === HostRoot) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
254
+ if (a.stateNode.current === a) {
255
+ // We've determined that A is the current branch.
256
+ return fiber;
257
+ }
258
+ // Otherwise B has to be current branch.
259
+ return alternate;
260
+ }
261
+
262
+ function findCurrentHostFiber(parent) {
263
+ var currentParent = findCurrentFiberUsingSlowPath(parent);
264
+ if (!currentParent) {
265
+ return null;
266
+ }
267
+
268
+ // Next we'll drill down this component to find the first HostComponent/Text.
269
+ var node = currentParent;
270
+ while (true) {
271
+ if (node.tag === HostComponent || node.tag === HostText) {
272
+ return node;
273
+ } else if (node.child) {
274
+ node.child['return'] = node;
275
+ node = node.child;
276
+ continue;
277
+ }
278
+ if (node === currentParent) {
279
+ return null;
280
+ }
281
+ while (!node.sibling) {
282
+ if (!node['return'] || node['return'] === currentParent) {
283
+ return null;
284
+ }
285
+ node = node['return'];
286
+ }
287
+ node.sibling['return'] = node['return'];
288
+ node = node.sibling;
289
+ }
290
+ // Flow needs the return null here, but ESLint complains about it.
291
+ // eslint-disable-next-line no-unreachable
292
+ return null;
293
+ }
294
+
295
+ function findCurrentHostFiberWithNoPortals(parent) {
296
+ var currentParent = findCurrentFiberUsingSlowPath(parent);
297
+ if (!currentParent) {
298
+ return null;
299
+ }
300
+
301
+ // Next we'll drill down this component to find the first HostComponent/Text.
302
+ var node = currentParent;
303
+ while (true) {
304
+ if (node.tag === HostComponent || node.tag === HostText) {
305
+ return node;
306
+ } else if (node.child && node.tag !== HostPortal) {
307
+ node.child['return'] = node;
308
+ node = node.child;
309
+ continue;
310
+ }
311
+ if (node === currentParent) {
312
+ return null;
313
+ }
314
+ while (!node.sibling) {
315
+ if (!node['return'] || node['return'] === currentParent) {
316
+ return null;
317
+ }
318
+ node = node['return'];
319
+ }
320
+ node.sibling['return'] = node['return'];
321
+ node = node.sibling;
322
+ }
323
+ // Flow needs the return null here, but ESLint complains about it.
324
+ // eslint-disable-next-line no-unreachable
325
+ return null;
326
+ }
327
+
328
+ exports.isFiberMounted = isFiberMounted;
329
+ exports.isMounted = isMounted;
330
+ exports.findCurrentFiberUsingSlowPath = findCurrentFiberUsingSlowPath;
331
+ exports.findCurrentHostFiber = findCurrentHostFiber;
332
+ exports.findCurrentHostFiberWithNoPortals = findCurrentHostFiberWithNoPortals;
333
+ })();
334
+ }
@@ -0,0 +1,15 @@
1
+ /** @license React v16.2.0
2
+ * react-reconciler-reflection.production.min.js
3
+ *
4
+ * Copyright (c) 2013-present, Facebook, Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ 'use strict';Object.defineProperty(exports,"__esModule",{value:!0});function k(b){for(var a=arguments.length-1,c="Minified React error #"+b+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant\x3d"+b,d=0;d<a;d++)c+="\x26args[]\x3d"+encodeURIComponent(arguments[d+1]);a=Error(c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");a.name="Invariant Violation";a.framesToPop=1;throw a;}require("react");
11
+ function l(b){var a=b;if(b.alternate)for(;a["return"];)a=a["return"];else{if(0!==(a.effectTag&2))return 1;for(;a["return"];)if(a=a["return"],0!==(a.effectTag&2))return 1}return 3===a.tag?2:3}function m(b){2!==l(b)?k("188"):void 0}
12
+ function n(b){var a=b.alternate;if(!a)return a=l(b),3===a?k("188"):void 0,1===a?null:b;for(var c=b,d=a;;){var e=c["return"],h=e?e.alternate:null;if(!e||!h)break;if(e.child===h.child){for(var f=e.child;f;){if(f===c)return m(e),b;if(f===d)return m(e),a;f=f.sibling}k("188")}if(c["return"]!==d["return"])c=e,d=h;else{f=!1;for(var g=e.child;g;){if(g===c){f=!0;c=e;d=h;break}if(g===d){f=!0;d=e;c=h;break}g=g.sibling}if(!f){for(g=h.child;g;){if(g===c){f=!0;c=h;d=e;break}if(g===d){f=!0;d=h;c=e;break}g=g.sibling}f?
13
+ void 0:k("189")}}c.alternate!==d?k("190"):void 0}3!==c.tag?k("188"):void 0;return c.stateNode.current===c?b:a}exports.isFiberMounted=function(b){return 2===l(b)};exports.isMounted=function(b){return(b=b._reactInternalFiber)?2===l(b):!1};exports.findCurrentFiberUsingSlowPath=n;
14
+ exports.findCurrentHostFiber=function(b){b=n(b);if(!b)return null;for(var a=b;;){if(5===a.tag||6===a.tag)return a;if(a.child)a.child["return"]=a,a=a.child;else{if(a===b)break;for(;!a.sibling;){if(!a["return"]||a["return"]===b)return null;a=a["return"]}a.sibling["return"]=a["return"];a=a.sibling}}return null};
15
+ exports.findCurrentHostFiberWithNoPortals=function(b){b=n(b);if(!b)return null;for(var a=b;;){if(5===a.tag||6===a.tag)return a;if(a.child&&4!==a.tag)a.child["return"]=a,a=a.child;else{if(a===b)break;for(;!a.sibling;){if(!a["return"]||a["return"]===b)return null;a=a["return"]}a.sibling["return"]=a["return"];a=a.sibling}}return null};