react-streaming
Advanced tools
Comparing version 0.3.33-commit-2cf1712 to 0.3.33-commit-cf9cdf3
@@ -9,2 +9,3 @@ "use strict"; | ||
let state = 'UNSTARTED'; | ||
let writePermission = null; // Set to `null` because React fails to hydrate if something is injected before the first react write | ||
return { injectToStream, onBeforeWrite, onBeforeEnd, hasStreamEnded }; | ||
@@ -22,2 +23,5 @@ function injectToStream(chunk, options) { | ||
function flushBuffer() { | ||
if (!writePermission) { | ||
return; | ||
} | ||
if (buffer.length === 0) { | ||
@@ -49,8 +53,22 @@ return; | ||
if (debug.isEnabled) { | ||
debug(`react write`, getChunkAsString(chunk)); | ||
debug(`react write${!writePermission ? '' : ' (allowed)'}`, getChunkAsString(chunk)); | ||
} | ||
state = 'STREAMING'; | ||
flushBuffer(); | ||
if (writePermission) { | ||
flushBuffer(); | ||
} | ||
if (writePermission === null) { | ||
writePermission = false; | ||
debug('writePermission =', writePermission); | ||
setTimeout(() => { | ||
debug('>>> setTimeout()'); | ||
writePermission = true; | ||
debug('writePermission =', writePermission); | ||
flushBuffer(); | ||
}, 0); | ||
} | ||
} | ||
function onBeforeEnd() { | ||
writePermission = true; | ||
debug('writePermission =', writePermission); | ||
flushBuffer(); | ||
@@ -57,0 +75,0 @@ (0, utils_1.assert)(buffer.length === 0); |
@@ -5,3 +5,3 @@ "use strict"; | ||
const getGlobalObject_1 = require("./getGlobalObject"); | ||
const PROJECT_VERSION = '0.3.33-commit-2cf1712'; | ||
const PROJECT_VERSION = '0.3.33-commit-cf9cdf3'; | ||
const projectInfo = { | ||
@@ -8,0 +8,0 @@ projectName: 'react-streaming', |
@@ -7,2 +7,3 @@ export { createBuffer }; | ||
let state = 'UNSTARTED'; | ||
let writePermission = null; // Set to `null` because React fails to hydrate if something is injected before the first react write | ||
return { injectToStream, onBeforeWrite, onBeforeEnd, hasStreamEnded }; | ||
@@ -20,2 +21,5 @@ function injectToStream(chunk, options) { | ||
function flushBuffer() { | ||
if (!writePermission) { | ||
return; | ||
} | ||
if (buffer.length === 0) { | ||
@@ -47,8 +51,22 @@ return; | ||
if (debug.isEnabled) { | ||
debug(`react write`, getChunkAsString(chunk)); | ||
debug(`react write${!writePermission ? '' : ' (allowed)'}`, getChunkAsString(chunk)); | ||
} | ||
state = 'STREAMING'; | ||
flushBuffer(); | ||
if (writePermission) { | ||
flushBuffer(); | ||
} | ||
if (writePermission === null) { | ||
writePermission = false; | ||
debug('writePermission =', writePermission); | ||
setTimeout(() => { | ||
debug('>>> setTimeout()'); | ||
writePermission = true; | ||
debug('writePermission =', writePermission); | ||
flushBuffer(); | ||
}, 0); | ||
} | ||
} | ||
function onBeforeEnd() { | ||
writePermission = true; | ||
debug('writePermission =', writePermission); | ||
flushBuffer(); | ||
@@ -55,0 +73,0 @@ assert(buffer.length === 0); |
export { projectInfo }; | ||
import { getGlobalObject } from './getGlobalObject'; | ||
const PROJECT_VERSION = '0.3.33-commit-2cf1712'; | ||
const PROJECT_VERSION = '0.3.33-commit-cf9cdf3'; | ||
const projectInfo = { | ||
@@ -5,0 +5,0 @@ projectName: 'react-streaming', |
{ | ||
"name": "react-streaming", | ||
"description": "React 18 Streaming. Full-fledged & Easy.", | ||
"version": "0.3.33-commit-2cf1712", | ||
"version": "0.3.33-commit-cf9cdf3", | ||
"peerDependencies": { | ||
@@ -6,0 +6,0 @@ "react": ">=18", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
144617
3069