1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
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 | setImmediate(callback);
|
20 | }
|
21 |
|
22 | function flushBuffered(destination) {
|
23 |
|
24 |
|
25 | if (typeof destination.flush === 'function') {
|
26 |
|
27 | destination.flush();
|
28 | }
|
29 | }
|
30 |
|
31 | function beginWriting(destination) {
|
32 | destination.cork();
|
33 | }
|
34 |
|
35 | function writeChunk(destination, buffer) {
|
36 | var nodeBuffer = buffer;
|
37 | destination.write(nodeBuffer);
|
38 | }
|
39 |
|
40 | function completeWriting(destination) {
|
41 | destination.uncork();
|
42 | }
|
43 |
|
44 | function close(destination) {
|
45 | destination.end();
|
46 | }
|
47 |
|
48 | function convertStringToBuffer(content) {
|
49 | return Buffer.from(content, 'utf8');
|
50 | }
|
51 |
|
52 | function formatChunk(type, props) {
|
53 | var str = '<' + type + '>';
|
54 | if (typeof props.children === 'string') {
|
55 | str += props.children;
|
56 | }
|
57 | str += '</' + type + '>';
|
58 | return convertStringToBuffer(str);
|
59 | }
|
60 |
|
61 |
|
62 |
|
63 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
64 |
|
65 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | function createRequest(children, destination) {
|
76 | return { destination: destination, children: children, completedChunks: [], flowing: false };
|
77 | }
|
78 |
|
79 | function performWork(request) {
|
80 | var element = request.children;
|
81 | request.children = null;
|
82 | if (element && element.$$typeof !== REACT_ELEMENT_TYPE) {
|
83 | return;
|
84 | }
|
85 | var type = element.type;
|
86 | var props = element.props;
|
87 | if (typeof type !== 'string') {
|
88 | return;
|
89 | }
|
90 | request.completedChunks.push(formatChunk(type, props));
|
91 | if (request.flowing) {
|
92 | flushCompletedChunks(request);
|
93 | }
|
94 |
|
95 | flushBuffered(request.destination);
|
96 | }
|
97 |
|
98 | function flushCompletedChunks(request) {
|
99 | var destination = request.destination;
|
100 | var chunks = request.completedChunks;
|
101 | request.completedChunks = [];
|
102 |
|
103 | beginWriting(destination);
|
104 | try {
|
105 | for (var i = 0; i < chunks.length; i++) {
|
106 | var chunk = chunks[i];
|
107 | writeChunk(destination, chunk);
|
108 | }
|
109 | } finally {
|
110 | completeWriting(destination);
|
111 | }
|
112 | close(destination);
|
113 | }
|
114 |
|
115 | function startWork(request) {
|
116 | request.flowing = true;
|
117 | scheduleWork(function () {
|
118 | return performWork(request);
|
119 | });
|
120 | }
|
121 |
|
122 | function startFlowing(request, desiredBytes) {
|
123 | request.flowing = false;
|
124 | flushCompletedChunks(request);
|
125 | }
|
126 |
|
127 |
|
128 |
|
129 |
|
130 | function createDrainHandler(destination, request) {
|
131 | return function () {
|
132 | return startFlowing(request, 0);
|
133 | };
|
134 | }
|
135 |
|
136 | function pipeToNodeWritable(children, destination) {
|
137 | var request = createRequest(children, destination);
|
138 | destination.on('drain', createDrainHandler(destination, request));
|
139 | startWork(request);
|
140 | }
|
141 |
|
142 | var ReactDOMFizzServerNode = {
|
143 | pipeToNodeWritable: pipeToNodeWritable
|
144 | };
|
145 |
|
146 | var ReactDOMFizzServerNode$1 = Object.freeze({
|
147 | default: ReactDOMFizzServerNode
|
148 | });
|
149 |
|
150 | var ReactDOMFizzServerNode$2 = ( ReactDOMFizzServerNode$1 && ReactDOMFizzServerNode ) || ReactDOMFizzServerNode$1;
|
151 |
|
152 |
|
153 |
|
154 | var unstableFizz_node = ReactDOMFizzServerNode$2.default || ReactDOMFizzServerNode$2;
|
155 |
|
156 | module.exports = unstableFizz_node;
|
157 | })();
|
158 | }
|