1 |
3a515b92
|
cagy
|
/** @license React v16.13.1
|
2 |
|
|
* react-dom-unstable-fizz.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 |
|
|
function scheduleWork(callback) {
|
19 |
|
|
callback();
|
20 |
|
|
}
|
21 |
|
|
function flushBuffered(destination) {// WHATWG Streams do not yet have a way to flush the underlying
|
22 |
|
|
// transform streams. https://github.com/whatwg/streams/issues/960
|
23 |
|
|
}
|
24 |
|
|
function writeChunk(destination, buffer) {
|
25 |
|
|
destination.enqueue(buffer);
|
26 |
|
|
return destination.desiredSize > 0;
|
27 |
|
|
}
|
28 |
|
|
function close(destination) {
|
29 |
|
|
destination.close();
|
30 |
|
|
}
|
31 |
|
|
var textEncoder = new TextEncoder();
|
32 |
|
|
function convertStringToBuffer(content) {
|
33 |
|
|
return textEncoder.encode(content);
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
function formatChunkAsString(type, props) {
|
37 |
|
|
var str = '<' + type + '>';
|
38 |
|
|
|
39 |
|
|
if (typeof props.children === 'string') {
|
40 |
|
|
str += props.children;
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
str += '</' + type + '>';
|
44 |
|
|
return str;
|
45 |
|
|
}
|
46 |
|
|
function formatChunk(type, props) {
|
47 |
|
|
return convertStringToBuffer(formatChunkAsString(type, props));
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
51 |
|
|
// nor polyfill, then a plain number is used for performance.
|
52 |
|
|
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
53 |
|
|
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
54 |
|
|
|
55 |
|
|
function createRequest(children, destination) {
|
56 |
|
|
return {
|
57 |
|
|
destination: destination,
|
58 |
|
|
children: children,
|
59 |
|
|
completedChunks: [],
|
60 |
|
|
flowing: false
|
61 |
|
|
};
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
function performWork(request) {
|
65 |
|
|
var element = request.children;
|
66 |
|
|
request.children = null;
|
67 |
|
|
|
68 |
|
|
if (element && element.$$typeof !== REACT_ELEMENT_TYPE) {
|
69 |
|
|
return;
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
var type = element.type;
|
73 |
|
|
var props = element.props;
|
74 |
|
|
|
75 |
|
|
if (typeof type !== 'string') {
|
76 |
|
|
return;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
request.completedChunks.push(formatChunk(type, props));
|
80 |
|
|
|
81 |
|
|
if (request.flowing) {
|
82 |
|
|
flushCompletedChunks(request);
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
flushBuffered(request.destination);
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
function flushCompletedChunks(request) {
|
89 |
|
|
var destination = request.destination;
|
90 |
|
|
var chunks = request.completedChunks;
|
91 |
|
|
request.completedChunks = [];
|
92 |
|
|
|
93 |
|
|
try {
|
94 |
|
|
for (var i = 0; i < chunks.length; i++) {
|
95 |
|
|
var chunk = chunks[i];
|
96 |
|
|
writeChunk(destination, chunk);
|
97 |
|
|
}
|
98 |
|
|
} finally {
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
close(destination);
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
function startWork(request) {
|
105 |
|
|
request.flowing = true;
|
106 |
|
|
scheduleWork(function () {
|
107 |
|
|
return performWork(request);
|
108 |
|
|
});
|
109 |
|
|
}
|
110 |
|
|
function startFlowing(request) {
|
111 |
|
|
request.flowing = false;
|
112 |
|
|
flushCompletedChunks(request);
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
function renderToReadableStream(children) {
|
116 |
|
|
var request;
|
117 |
|
|
return new ReadableStream({
|
118 |
|
|
start: function (controller) {
|
119 |
|
|
request = createRequest(children, controller);
|
120 |
|
|
startWork(request);
|
121 |
|
|
},
|
122 |
|
|
pull: function (controller) {
|
123 |
|
|
startFlowing(request);
|
124 |
|
|
},
|
125 |
|
|
cancel: function (reason) {}
|
126 |
|
|
});
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
var ReactDOMFizzServerBrowser = {
|
130 |
|
|
renderToReadableStream: renderToReadableStream
|
131 |
|
|
};
|
132 |
|
|
|
133 |
|
|
// TODO: decide on the top-level export form.
|
134 |
|
|
// This is hacky but makes it work with both Rollup and Jest
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
var unstableFizz_browser = ReactDOMFizzServerBrowser.default || ReactDOMFizzServerBrowser;
|
138 |
|
|
|
139 |
|
|
module.exports = unstableFizz_browser;
|
140 |
|
|
})();
|
141 |
|
|
}
|