react-dom 16.10.0 → 16.12.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.
Files changed (42) hide show
  1. package/build-info.json +4 -4
  2. package/cjs/react-dom-server.browser.development.js +122 -177
  3. package/cjs/react-dom-server.browser.production.min.js +29 -29
  4. package/cjs/react-dom-server.node.development.js +116 -167
  5. package/cjs/react-dom-server.node.production.min.js +17 -17
  6. package/cjs/react-dom-test-utils.development.js +55 -91
  7. package/cjs/react-dom-test-utils.production.min.js +9 -9
  8. package/cjs/react-dom-unstable-fizz.browser.development.js +9 -5
  9. package/cjs/react-dom-unstable-fizz.browser.production.min.js +3 -3
  10. package/cjs/react-dom-unstable-fizz.node.development.js +23 -10
  11. package/cjs/react-dom-unstable-fizz.node.production.min.js +4 -3
  12. package/cjs/react-dom-unstable-flight-client.development.js +357 -0
  13. package/cjs/react-dom-unstable-flight-client.production.min.js +16 -0
  14. package/cjs/react-dom-unstable-flight-server.browser.development.js +392 -0
  15. package/cjs/react-dom-unstable-flight-server.browser.production.min.js +16 -0
  16. package/cjs/react-dom-unstable-flight-server.node.development.js +415 -0
  17. package/cjs/react-dom-unstable-flight-server.node.production.min.js +16 -0
  18. package/cjs/react-dom-unstable-native-dependencies.development.js +28 -48
  19. package/cjs/react-dom-unstable-native-dependencies.production.min.js +15 -15
  20. package/cjs/react-dom.development.js +1912 -2046
  21. package/cjs/react-dom.production.min.js +266 -269
  22. package/cjs/react-dom.profiling.min.js +252 -255
  23. package/package.json +8 -3
  24. package/umd/react-dom-server.browser.development.js +122 -177
  25. package/umd/react-dom-server.browser.production.min.js +36 -36
  26. package/umd/react-dom-test-utils.development.js +55 -91
  27. package/umd/react-dom-test-utils.production.min.js +9 -9
  28. package/umd/react-dom-unstable-fizz.browser.development.js +9 -5
  29. package/umd/react-dom-unstable-fizz.browser.production.min.js +3 -3
  30. package/umd/react-dom-unstable-flight-client.development.js +357 -0
  31. package/umd/react-dom-unstable-flight-client.production.min.js +14 -0
  32. package/umd/react-dom-unstable-flight-server.browser.development.js +390 -0
  33. package/umd/react-dom-unstable-flight-server.browser.production.min.js +14 -0
  34. package/umd/react-dom-unstable-native-dependencies.development.js +28 -48
  35. package/umd/react-dom-unstable-native-dependencies.production.min.js +22 -22
  36. package/umd/react-dom.development.js +1916 -2050
  37. package/umd/react-dom.production.min.js +230 -232
  38. package/umd/react-dom.profiling.min.js +237 -239
  39. package/unstable-flight-client.js +7 -0
  40. package/unstable-flight-server.browser.js +7 -0
  41. package/unstable-flight-server.js +3 -0
  42. package/unstable-flight-server.node.js +7 -0
@@ -0,0 +1,392 @@
1
+ /** @license React v16.12.0
2
+ * react-dom-unstable-flight-server.browser.development.js
3
+ *
4
+ * Copyright (c) Facebook, Inc. and its affiliates.
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
+ var ReactDOMServer = require('react-dom/server');
19
+
20
+ function scheduleWork(callback) {
21
+ callback();
22
+ }
23
+
24
+
25
+ function writeChunk(destination, buffer) {
26
+ destination.enqueue(buffer);
27
+ return destination.desiredSize > 0;
28
+ }
29
+
30
+ function close(destination) {
31
+ destination.close();
32
+ }
33
+ var textEncoder = new TextEncoder();
34
+ function convertStringToBuffer(content) {
35
+ return textEncoder.encode(content);
36
+ }
37
+
38
+ function renderHostChildrenToString(children) {
39
+ // TODO: This file is used to actually implement a server renderer
40
+ // so we can't actually reference the renderer here. Instead, we
41
+ // should replace this method with a reference to Fizz which
42
+ // then uses this file to implement the server renderer.
43
+ return ReactDOMServer.renderToStaticMarkup(children);
44
+ }
45
+
46
+ // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
47
+ // nor polyfill, then a plain number is used for performance.
48
+ var hasSymbol = typeof Symbol === 'function' && Symbol.for;
49
+ var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
50
+
51
+
52
+
53
+
54
+
55
+ // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
56
+ // (unstable) APIs that have been removed. Can we remove the symbols?
57
+
58
+ /*
59
+
60
+ FLIGHT PROTOCOL GRAMMAR
61
+
62
+ Response
63
+ - JSONData RowSequence
64
+ - JSONData
65
+
66
+ RowSequence
67
+ - Row RowSequence
68
+ - Row
69
+
70
+ Row
71
+ - "J" RowID JSONData
72
+ - "H" RowID HTMLData
73
+ - "B" RowID BlobData
74
+ - "U" RowID URLData
75
+ - "E" RowID ErrorData
76
+
77
+ RowID
78
+ - HexDigits ":"
79
+
80
+ HexDigits
81
+ - HexDigit HexDigits
82
+ - HexDigit
83
+
84
+ HexDigit
85
+ - 0-F
86
+
87
+ URLData
88
+ - (UTF8 encoded URL) "\n"
89
+
90
+ ErrorData
91
+ - (UTF8 encoded JSON: {message: "...", stack: "..."}) "\n"
92
+
93
+ JSONData
94
+ - (UTF8 encoded JSON) "\n"
95
+ - String values that begin with $ are escaped with a "$" prefix.
96
+ - References to other rows are encoding as JSONReference strings.
97
+
98
+ JSONReference
99
+ - "$" HexDigits
100
+
101
+ HTMLData
102
+ - ByteSize (UTF8 encoded HTML)
103
+
104
+ BlobData
105
+ - ByteSize (Binary Data)
106
+
107
+ ByteSize
108
+ - (unsigned 32-bit integer)
109
+ */
110
+ // TODO: Implement HTMLData, BlobData and URLData.
111
+
112
+ var stringify = JSON.stringify;
113
+ function createRequest(model, destination) {
114
+ var pingedSegments = [];
115
+ var request = {
116
+ destination: destination,
117
+ nextChunkId: 0,
118
+ pendingChunks: 0,
119
+ pingedSegments: pingedSegments,
120
+ completedJSONChunks: [],
121
+ completedErrorChunks: [],
122
+ flowing: false,
123
+ toJSON: function (key, value) {
124
+ return resolveModelToJSON(request, value);
125
+ }
126
+ };
127
+ request.pendingChunks++;
128
+ var rootSegment = createSegment(request, model);
129
+ pingedSegments.push(rootSegment);
130
+ return request;
131
+ }
132
+
133
+ function attemptResolveModelComponent(element) {
134
+ var type = element.type;
135
+ var props = element.props;
136
+
137
+ if (typeof type === 'function') {
138
+ // This is a nested view model.
139
+ return type(props);
140
+ } else if (typeof type === 'string') {
141
+ // This is a host element. E.g. HTML.
142
+ return renderHostChildrenToString(element);
143
+ } else {
144
+ throw new Error('Unsupported type.');
145
+ }
146
+ }
147
+
148
+ function pingSegment(request, segment) {
149
+ var pingedSegments = request.pingedSegments;
150
+ pingedSegments.push(segment);
151
+
152
+ if (pingedSegments.length === 1) {
153
+ scheduleWork(function () {
154
+ return performWork(request);
155
+ });
156
+ }
157
+ }
158
+
159
+ function createSegment(request, model) {
160
+ var id = request.nextChunkId++;
161
+ var segment = {
162
+ id: id,
163
+ model: model,
164
+ ping: function () {
165
+ return pingSegment(request, segment);
166
+ }
167
+ };
168
+ return segment;
169
+ }
170
+
171
+ function serializeIDRef(id) {
172
+ return '$' + id.toString(16);
173
+ }
174
+
175
+ function serializeRowHeader(tag, id) {
176
+ return tag + id.toString(16) + ':';
177
+ }
178
+
179
+ function escapeStringValue(value) {
180
+ if (value[0] === '$') {
181
+ // We need to escape $ prefixed strings since we use that to encode
182
+ // references to IDs.
183
+ return '$' + value;
184
+ } else {
185
+ return value;
186
+ }
187
+ }
188
+
189
+ function resolveModelToJSON(request, value) {
190
+ if (typeof value === 'string') {
191
+ return escapeStringValue(value);
192
+ }
193
+
194
+ while (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
195
+ var element = value;
196
+
197
+ try {
198
+ value = attemptResolveModelComponent(element);
199
+ } catch (x) {
200
+ if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
201
+ // Something suspended, we'll need to create a new segment and resolve it later.
202
+ request.pendingChunks++;
203
+ var newSegment = createSegment(request, element);
204
+ var ping = newSegment.ping;
205
+ x.then(ping, ping);
206
+ return serializeIDRef(newSegment.id);
207
+ } else {
208
+ request.pendingChunks++;
209
+ var errorId = request.nextChunkId++;
210
+ emitErrorChunk(request, errorId, x);
211
+ return serializeIDRef(errorId);
212
+ }
213
+ }
214
+ }
215
+
216
+ return value;
217
+ }
218
+
219
+ function emitErrorChunk(request, id, error) {
220
+ // TODO: We should not leak error messages to the client in prod.
221
+ // Give this an error code instead and log on the server.
222
+ // We can serialize the error in DEV as a convenience.
223
+ var message;
224
+ var stack = '';
225
+
226
+ try {
227
+ if (error instanceof Error) {
228
+ message = '' + error.message;
229
+ stack = '' + error.stack;
230
+ } else {
231
+ message = 'Error: ' + error;
232
+ }
233
+ } catch (x) {
234
+ message = 'An error occurred but serializing the error message failed.';
235
+ }
236
+
237
+ var errorInfo = {
238
+ message: message,
239
+ stack: stack
240
+ };
241
+ var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n';
242
+ request.completedErrorChunks.push(convertStringToBuffer(row));
243
+ }
244
+
245
+ function retrySegment(request, segment) {
246
+ var value = segment.model;
247
+
248
+ try {
249
+ while (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
250
+ // If this is a nested model, there's no need to create another chunk,
251
+ // we can reuse the existing one and try again.
252
+ var element = value;
253
+ segment.model = element;
254
+ value = attemptResolveModelComponent(element);
255
+ }
256
+
257
+ var json = stringify(value, request.toJSON);
258
+ var row;
259
+ var id = segment.id;
260
+
261
+ if (id === 0) {
262
+ row = json + '\n';
263
+ } else {
264
+ row = serializeRowHeader('J', id) + json + '\n';
265
+ }
266
+
267
+ request.completedJSONChunks.push(convertStringToBuffer(row));
268
+ } catch (x) {
269
+ if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
270
+ // Something suspended again, let's pick it back up later.
271
+ var ping = segment.ping;
272
+ x.then(ping, ping);
273
+ return;
274
+ } else {
275
+ // This errored, we need to serialize this error to the
276
+ emitErrorChunk(request, segment.id, x);
277
+ }
278
+ }
279
+ }
280
+
281
+ function performWork(request) {
282
+ var pingedSegments = request.pingedSegments;
283
+ request.pingedSegments = [];
284
+
285
+ for (var i = 0; i < pingedSegments.length; i++) {
286
+ var segment = pingedSegments[i];
287
+ retrySegment(request, segment);
288
+ }
289
+
290
+ if (request.flowing) {
291
+ flushCompletedChunks(request);
292
+ }
293
+ }
294
+
295
+ var reentrant = false;
296
+
297
+ function flushCompletedChunks(request) {
298
+ if (reentrant) {
299
+ return;
300
+ }
301
+
302
+ reentrant = true;
303
+ var destination = request.destination;
304
+ try {
305
+ var jsonChunks = request.completedJSONChunks;
306
+ var i = 0;
307
+
308
+ for (; i < jsonChunks.length; i++) {
309
+ request.pendingChunks--;
310
+ var chunk = jsonChunks[i];
311
+
312
+ if (!writeChunk(destination, chunk)) {
313
+ request.flowing = false;
314
+ i++;
315
+ break;
316
+ }
317
+ }
318
+
319
+ jsonChunks.splice(0, i);
320
+ var errorChunks = request.completedErrorChunks;
321
+ i = 0;
322
+
323
+ for (; i < errorChunks.length; i++) {
324
+ request.pendingChunks--;
325
+ var _chunk = errorChunks[i];
326
+
327
+ if (!writeChunk(destination, _chunk)) {
328
+ request.flowing = false;
329
+ i++;
330
+ break;
331
+ }
332
+ }
333
+
334
+ errorChunks.splice(0, i);
335
+ } finally {
336
+ reentrant = false;
337
+
338
+ }
339
+
340
+ if (request.pendingChunks === 0) {
341
+ // We're done.
342
+ close(destination);
343
+ }
344
+ }
345
+
346
+ function startWork(request) {
347
+ request.flowing = true;
348
+ scheduleWork(function () {
349
+ return performWork(request);
350
+ });
351
+ }
352
+ function startFlowing(request) {
353
+ request.flowing = true;
354
+ flushCompletedChunks(request);
355
+ }
356
+
357
+ // This file intentionally does *not* have the Flow annotation.
358
+ // Don't add it. See `./inline-typed.js` for an explanation.
359
+
360
+ function renderToReadableStream(model) {
361
+ var request;
362
+ return new ReadableStream({
363
+ start: function (controller) {
364
+ request = createRequest(model, controller);
365
+ startWork(request);
366
+ },
367
+ pull: function (controller) {
368
+ startFlowing(request);
369
+ },
370
+ cancel: function (reason) {}
371
+ });
372
+ }
373
+
374
+ var ReactFlightDOMServerBrowser = {
375
+ renderToReadableStream: renderToReadableStream
376
+ };
377
+
378
+ var ReactFlightDOMServerBrowser$1 = Object.freeze({
379
+ default: ReactFlightDOMServerBrowser
380
+ });
381
+
382
+ var ReactFlightDOMServerBrowser$2 = ( ReactFlightDOMServerBrowser$1 && ReactFlightDOMServerBrowser ) || ReactFlightDOMServerBrowser$1;
383
+
384
+ // TODO: decide on the top-level export form.
385
+ // This is hacky but makes it work with both Rollup and Jest
386
+
387
+
388
+ var unstableFlightServer_browser = ReactFlightDOMServerBrowser$2.default || ReactFlightDOMServerBrowser$2;
389
+
390
+ module.exports = unstableFlightServer_browser;
391
+ })();
392
+ }
@@ -0,0 +1,16 @@
1
+ /** @license React v16.12.0
2
+ * react-dom-unstable-flight-server.browser.production.min.js
3
+ *
4
+ * Copyright (c) Facebook, Inc. and its affiliates.
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';var k=require("react-dom/server"),l=new TextEncoder,m="function"===typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103,n=JSON.stringify;function p(a,b){var c=[],d={destination:b,nextChunkId:0,pendingChunks:0,pingedSegments:c,completedJSONChunks:[],completedErrorChunks:[],flowing:!1,toJSON:function(a,b){return q(d,b)}};d.pendingChunks++;a=r(d,a);c.push(a);return d}
11
+ function t(a){var b=a.type,c=a.props;if("function"===typeof b)return b(c);if("string"===typeof b)return k.renderToStaticMarkup(a);throw Error("Unsupported type.");}function r(a,b){var c={id:a.nextChunkId++,model:b,ping:function(){var b=a.pingedSegments;b.push(c);1===b.length&&x(a)}};return c}
12
+ function q(a,b){if("string"===typeof b)return a="$"===b[0]?"$"+b:b,a;for(;"object"===typeof b&&null!==b&&b.$$typeof===m;){var c=b;try{b=t(c)}catch(d){if("object"===typeof d&&null!==d&&"function"===typeof d.then)return a.pendingChunks++,a=r(a,c),b=a.ping,d.then(b,b),"$"+a.id.toString(16);a.pendingChunks++;b=a.nextChunkId++;y(a,b,d);return"$"+b.toString(16)}}return b}
13
+ function y(a,b,c){var d="";try{if(c instanceof Error){var e=""+c.message;d=""+c.stack}else e="Error: "+c}catch(f){e="An error occurred but serializing the error message failed."}c={message:e,stack:d};b="E"+b.toString(16)+":"+n(c)+"\n";a.completedErrorChunks.push(l.encode(b))}
14
+ function x(a){var b=a.pingedSegments;a.pingedSegments=[];for(var c=0;c<b.length;c++){var d=void 0,e=a,f=b[c],g=f.model;try{for(;"object"===typeof g&&null!==g&&g.$$typeof===m;){var u=g;f.model=u;g=t(u)}var v=n(g,e.toJSON),w=f.id;d=0===w?v+"\n":"J"+w.toString(16)+":"+v+"\n";e.completedJSONChunks.push(l.encode(d))}catch(h){"object"===typeof h&&null!==h&&"function"===typeof h.then?(d=f.ping,h.then(d,d)):y(e,f.id,h)}}a.flowing&&z(a)}var A=!1;
15
+ function z(a){if(!A){A=!0;var b=a.destination;try{for(var c=a.completedJSONChunks,d=0;d<c.length;d++){a.pendingChunks--;var e=b;e.enqueue(c[d]);if(!(0<e.desiredSize)){a.flowing=!1;d++;break}}c.splice(0,d);var f=a.completedErrorChunks;for(d=0;d<f.length;d++)if(a.pendingChunks--,c=b,c.enqueue(f[d]),!(0<c.desiredSize)){a.flowing=!1;d++;break}f.splice(0,d)}finally{A=!1}0===a.pendingChunks&&b.close()}}
16
+ var B={renderToReadableStream:function(a){var b;return new ReadableStream({start:function(c){c=b=p(a,c);c.flowing=!0;x(c)},pull:function(){var a=b;a.flowing=!0;z(a)},cancel:function(){}})}},C={default:B},D=C&&B||C;module.exports=D.default||D;