Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

react-dom-unstable-fizz.browser.development.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /** @license React v16.12.0
  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. 'use strict';
  10. if (process.env.NODE_ENV !== "production") {
  11. (function() {
  12. 'use strict';
  13. function scheduleWork(callback) {
  14. callback();
  15. }
  16. function flushBuffered(destination) {// WHATWG Streams do not yet have a way to flush the underlying
  17. // transform streams. https://github.com/whatwg/streams/issues/960
  18. }
  19. function writeChunk(destination, buffer) {
  20. destination.enqueue(buffer);
  21. return destination.desiredSize > 0;
  22. }
  23. function close(destination) {
  24. destination.close();
  25. }
  26. var textEncoder = new TextEncoder();
  27. function convertStringToBuffer(content) {
  28. return textEncoder.encode(content);
  29. }
  30. function formatChunkAsString(type, props) {
  31. var str = '<' + type + '>';
  32. if (typeof props.children === 'string') {
  33. str += props.children;
  34. }
  35. str += '</' + type + '>';
  36. return str;
  37. }
  38. function formatChunk(type, props) {
  39. return convertStringToBuffer(formatChunkAsString(type, props));
  40. }
  41. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  42. // nor polyfill, then a plain number is used for performance.
  43. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  44. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  45. // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  46. // (unstable) APIs that have been removed. Can we remove the symbols?
  47. function createRequest(children, destination) {
  48. return {
  49. destination: destination,
  50. children: children,
  51. completedChunks: [],
  52. flowing: false
  53. };
  54. }
  55. function performWork(request) {
  56. var element = request.children;
  57. request.children = null;
  58. if (element && element.$$typeof !== REACT_ELEMENT_TYPE) {
  59. return;
  60. }
  61. var type = element.type;
  62. var props = element.props;
  63. if (typeof type !== 'string') {
  64. return;
  65. }
  66. request.completedChunks.push(formatChunk(type, props));
  67. if (request.flowing) {
  68. flushCompletedChunks(request);
  69. }
  70. flushBuffered(request.destination);
  71. }
  72. function flushCompletedChunks(request) {
  73. var destination = request.destination;
  74. var chunks = request.completedChunks;
  75. request.completedChunks = [];
  76. try {
  77. for (var i = 0; i < chunks.length; i++) {
  78. var chunk = chunks[i];
  79. writeChunk(destination, chunk);
  80. }
  81. } finally {
  82. }
  83. close(destination);
  84. }
  85. function startWork(request) {
  86. request.flowing = true;
  87. scheduleWork(function () {
  88. return performWork(request);
  89. });
  90. }
  91. function startFlowing(request) {
  92. request.flowing = false;
  93. flushCompletedChunks(request);
  94. }
  95. // This file intentionally does *not* have the Flow annotation.
  96. // Don't add it. See `./inline-typed.js` for an explanation.
  97. function renderToReadableStream(children) {
  98. var request;
  99. return new ReadableStream({
  100. start: function (controller) {
  101. request = createRequest(children, controller);
  102. startWork(request);
  103. },
  104. pull: function (controller) {
  105. startFlowing(request);
  106. },
  107. cancel: function (reason) {}
  108. });
  109. }
  110. var ReactDOMFizzServerBrowser = {
  111. renderToReadableStream: renderToReadableStream
  112. };
  113. var ReactDOMFizzServerBrowser$1 = Object.freeze({
  114. default: ReactDOMFizzServerBrowser
  115. });
  116. var ReactDOMFizzServerBrowser$2 = ( ReactDOMFizzServerBrowser$1 && ReactDOMFizzServerBrowser ) || ReactDOMFizzServerBrowser$1;
  117. // TODO: decide on the top-level export form.
  118. // This is hacky but makes it work with both Rollup and Jest
  119. var unstableFizz_browser = ReactDOMFizzServerBrowser$2.default || ReactDOMFizzServerBrowser$2;
  120. module.exports = unstableFizz_browser;
  121. })();
  122. }