Socket
Socket
Sign inDemoInstall

react-streaming

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-streaming - npm Package Compare versions

Comparing version 0.3.24 to 0.3.25

dist/cjs/utils/isVikeReactApp.d.ts

2

dist/cjs/client/useAsync.js

@@ -34,3 +34,3 @@ "use strict";

needsWorkaround: true,
asyncFnName: asyncFn.name
asyncFnName: asyncFn.name,
});

@@ -37,0 +37,0 @@ }

@@ -39,3 +39,3 @@ "use strict";

renderToNodeStream: null,
renderToWebStream: null
renderToWebStream: null,
});

@@ -45,3 +45,3 @@ assertReact();

.__react_streaming || {
disable: false
disable: false,
});

@@ -63,4 +63,4 @@ function disable() {

injectToStream(chunk);
}
}
},
},
}, element);

@@ -67,0 +67,0 @@ const disable = globalConfig.disable || ((_a = options.disable) !== null && _a !== void 0 ? _a : (0, resolveSeoStrategy_1.resolveSeoStrategy)(options).disableStream);

@@ -11,3 +11,3 @@ "use strict";

const streamOperations = {
operations: null
operations: null,
};

@@ -51,3 +51,3 @@ const { injectToStream, onBeforeWrite, onBeforeEnd } = (0, createBuffer_1.createBuffer)(streamOperations);

onEnded();
}
},
});

@@ -65,3 +65,3 @@ const flush = () => {

writableFromUser.write(chunk);
}
},
};

@@ -68,0 +68,0 @@ writableForReact.flush = flush;

@@ -10,3 +10,3 @@ "use strict";

const streamOperations = {
operations: null
operations: null,
};

@@ -22,3 +22,3 @@ let controllerOfUserStream;

onReady(onEnded);
}
},
});

@@ -32,3 +32,3 @@ const { injectToStream, onBeforeWrite, onBeforeEnd } = (0, createBuffer_1.createBuffer)(streamOperations);

},
flush: null
flush: null,
};

@@ -35,0 +35,0 @@ const reader = readableFromReact.getReader();

@@ -61,3 +61,3 @@ "use strict";

}
}
},
});

@@ -77,5 +77,5 @@ await shellReady;

streamEnd: (0, common_1.wrapStreamEnd)(streamEnd, didError),
injectToStream
injectToStream,
};
}
exports.renderToNodeStream = renderToNodeStream;

@@ -59,5 +59,5 @@ "use strict";

streamEnd: (0, common_1.wrapStreamEnd)(streamEnd, didError),
injectToStream
injectToStream,
};
}
exports.renderToWebStream = renderToWebStream;

@@ -15,3 +15,9 @@ "use strict";

if (!options.userAgent) {
(0, utils_1.assertWarning)(false, 'Streaming disabled. Provide `options.userAgent` to enable streaming. (react-streaming needs the User Agent string in order to be able to disable streaming for bots, e.g. for Google Bot.) Or set `options.disable` to `true` to get rid of this warning.', { onlyOnce: true });
(0, utils_1.assertWarning)(false, [
'HTML Streaming disabled because User Agent is unknown: make sure to provide',
(0, utils_1.isVikeReactApp)()
? 'pageContext.userAgent (typically with `renderPage({ userAgent: req.userAgent })`, see https://vike.dev/renderPage)'
: 'options.userAgent',
'(so that react-streaming is able to disable HTML streaming for bots such as Google Bot). Or set options.disable to `true` to suppress this warning.',
].join(' '), { onlyOnce: true });
return { disableStream: true };

@@ -18,0 +24,0 @@ }

@@ -30,3 +30,3 @@ "use strict";

const globalObject = (0, utils_1.getGlobalObject)('useStream.ts', {
StreamContext: react_1.default.createContext(null)
StreamContext: react_1.default.createContext(null),
});

@@ -37,5 +37,7 @@ const StreamProvider = globalObject.StreamContext.Provider;

const streamUtils = (0, react_1.useContext)(globalObject.StreamContext);
(0, utils_1.assertUsage)(streamUtils, `react-streaming isn't installed`);
(0, utils_1.assertUsage)(streamUtils, (0, utils_1.isVikeReactApp)()
? 'HTML Streaming is disabled: set the option https://vike.dev/stream to true'
: "react-streaming isn't installed: make sure to use renderToStream() to render your root React component, see https://github.com/brillout/react-streaming#get-started");
return streamUtils;
}
exports.useStream = useStream;

@@ -6,1 +6,2 @@ export * from '../utils/assert';

export * from '../utils/getGlobalObject';
export * from '../utils/isVikeReactApp';

@@ -22,1 +22,2 @@ "use strict";

__exportStar(require("../utils/getGlobalObject"), exports);
__exportStar(require("../utils/isVikeReactApp"), exports);

@@ -16,3 +16,3 @@ export { useSuspense };

};
declare function useSuspense<T>({ key, elementId, suspenses, resolver, resolverSync, needsWorkaround, asyncFnName }: {
declare function useSuspense<T>({ key, elementId, suspenses, resolver, resolverSync, needsWorkaround, asyncFnName, }: {
key: string;

@@ -19,0 +19,0 @@ elementId: string;

@@ -7,3 +7,3 @@ "use strict";

const globalObject = (0, utils_1.getGlobalObject)('useSuspense.ts', {
workaroundCache: {}
workaroundCache: {},
});

@@ -16,3 +16,3 @@ const { workaroundCache } = globalObject;

//*/
function useSuspense({ key, elementId, suspenses, resolver, resolverSync, needsWorkaround, asyncFnName }) {
function useSuspense({ key, elementId, suspenses, resolver, resolverSync, needsWorkaround, asyncFnName, }) {
DEBUG && console.log('=== useSuspense()');

@@ -70,3 +70,3 @@ const suspenseId = getSuspenseId(key, elementId);

suspense,
cacheTimeout: null
cacheTimeout: null,
};

@@ -83,3 +83,3 @@ };

onlyOnce: true,
showStackTrace: true
showStackTrace: true,
});

@@ -86,0 +86,0 @@ suspense = suspenses[suspenseId] = { state: 'done', value: ret };

@@ -28,3 +28,3 @@ "use strict";

`Do not hesitate to reach out as it makes ${projectInfo_1.projectInfo.projectName} more robust.`,
debugStr
debugStr,
].join(' '), numberOfStackTraceLinesToRemove);

@@ -31,0 +31,0 @@ throw internalError;

@@ -5,3 +5,3 @@ "use strict";

const getGlobalObject_1 = require("./getGlobalObject");
const PROJECT_VERSION = '0.3.24';
const PROJECT_VERSION = '0.3.25';
const projectInfo = {

@@ -11,7 +11,7 @@ projectName: 'react-streaming',

npmPackageName: 'react-streaming',
githubRepository: 'https://github.com/brillout/react-streaming'
githubRepository: 'https://github.com/brillout/react-streaming',
};
exports.projectInfo = projectInfo;
const { versions } = (0, getGlobalObject_1.getGlobalObject)('projectInfo.ts', {
versions: new Set()
versions: new Set(),
});

@@ -18,0 +18,0 @@ versions.add(projectInfo.projectVersion);

@@ -32,3 +32,3 @@ export { useAsync };

needsWorkaround: true,
asyncFnName: asyncFn.name
asyncFnName: asyncFn.name,
});

@@ -35,0 +35,0 @@ }

@@ -14,3 +14,3 @@ export { renderToStream };

renderToNodeStream: null,
renderToWebStream: null
renderToWebStream: null,
});

@@ -20,3 +20,3 @@ assertReact();

.__react_streaming || {
disable: false
disable: false,
});

@@ -37,4 +37,4 @@ function disable() {

injectToStream(chunk);
}
}
},
},
}, element);

@@ -41,0 +41,0 @@ const disable = globalConfig.disable || ((_a = options.disable) !== null && _a !== void 0 ? _a : resolveSeoStrategy(options).disableStream);

@@ -9,3 +9,3 @@ export { createPipeWrapper };

const streamOperations = {
operations: null
operations: null,
};

@@ -49,3 +49,3 @@ const { injectToStream, onBeforeWrite, onBeforeEnd } = createBuffer(streamOperations);

onEnded();
}
},
});

@@ -63,3 +63,3 @@ const flush = () => {

writableFromUser.write(chunk);
}
},
};

@@ -66,0 +66,0 @@ writableForReact.flush = flush;

@@ -8,3 +8,3 @@ export { createReadableWrapper };

const streamOperations = {
operations: null
operations: null,
};

@@ -20,3 +20,3 @@ let controllerOfUserStream;

onReady(onEnded);
}
},
});

@@ -30,3 +30,3 @@ const { injectToStream, onBeforeWrite, onBeforeEnd } = createBuffer(streamOperations);

},
flush: null
flush: null,
};

@@ -33,0 +33,0 @@ const reader = readableFromReact.getReader();

@@ -49,3 +49,3 @@ export { renderToNodeStream };

onShellError: onError,
onError
onError,
});

@@ -65,3 +65,3 @@ const stopTimeout = startTimeout(() => abort(), options);

}
}
},
});

@@ -81,4 +81,4 @@ await shellReady;

streamEnd: wrapStreamEnd(streamEnd, didError),
injectToStream
injectToStream,
};
}

@@ -32,3 +32,3 @@ export { renderToWebStream };

signal: controller.signal,
...options.streamOptions
...options.streamOptions,
});

@@ -62,4 +62,4 @@ const { allReady } = readableOriginal;

streamEnd: wrapStreamEnd(streamEnd, didError),
injectToStream
injectToStream,
};
}

@@ -6,7 +6,13 @@ export { resolveSeoStrategy };

import isBot from 'isbot-fast';
import { assertWarning } from '../utils';
import { assertWarning, isVikeReactApp } from '../utils';
function resolveSeoStrategy(options = {}) {
const seoStrategy = options.seoStrategy || 'conservative';
if (!options.userAgent) {
assertWarning(false, 'Streaming disabled. Provide `options.userAgent` to enable streaming. (react-streaming needs the User Agent string in order to be able to disable streaming for bots, e.g. for Google Bot.) Or set `options.disable` to `true` to get rid of this warning.', { onlyOnce: true });
assertWarning(false, [
'HTML Streaming disabled because User Agent is unknown: make sure to provide',
isVikeReactApp()
? 'pageContext.userAgent (typically with `renderPage({ userAgent: req.userAgent })`, see https://vike.dev/renderPage)'
: 'options.userAgent',
'(so that react-streaming is able to disable HTML streaming for bots such as Google Bot). Or set options.disable to `true` to suppress this warning.',
].join(' '), { onlyOnce: true });
return { disableStream: true };

@@ -13,0 +19,0 @@ }

export { useStream };
export { StreamProvider };
import React, { useContext } from 'react';
import { assertUsage, getGlobalObject } from './utils';
import { assertUsage, getGlobalObject, isVikeReactApp } from './utils';
const globalObject = getGlobalObject('useStream.ts', {
StreamContext: React.createContext(null)
StreamContext: React.createContext(null),
});

@@ -11,4 +11,6 @@ const StreamProvider = globalObject.StreamContext.Provider;

const streamUtils = useContext(globalObject.StreamContext);
assertUsage(streamUtils, `react-streaming isn't installed`);
assertUsage(streamUtils, isVikeReactApp()
? 'HTML Streaming is disabled: set the option https://vike.dev/stream to true'
: "react-streaming isn't installed: make sure to use renderToStream() to render your root React component, see https://github.com/brillout/react-streaming#get-started");
return streamUtils;
}

@@ -6,1 +6,2 @@ export * from '../utils/assert';

export * from '../utils/getGlobalObject';
export * from '../utils/isVikeReactApp';

@@ -6,1 +6,2 @@ export * from '../utils/assert';

export * from '../utils/getGlobalObject';
export * from '../utils/isVikeReactApp';

@@ -16,3 +16,3 @@ export { useSuspense };

};
declare function useSuspense<T>({ key, elementId, suspenses, resolver, resolverSync, needsWorkaround, asyncFnName }: {
declare function useSuspense<T>({ key, elementId, suspenses, resolver, resolverSync, needsWorkaround, asyncFnName, }: {
key: string;

@@ -19,0 +19,0 @@ elementId: string;

@@ -5,3 +5,3 @@ export { useSuspense };

const globalObject = getGlobalObject('useSuspense.ts', {
workaroundCache: {}
workaroundCache: {},
});

@@ -14,3 +14,3 @@ const { workaroundCache } = globalObject;

//*/
function useSuspense({ key, elementId, suspenses, resolver, resolverSync, needsWorkaround, asyncFnName }) {
function useSuspense({ key, elementId, suspenses, resolver, resolverSync, needsWorkaround, asyncFnName, }) {
DEBUG && console.log('=== useSuspense()');

@@ -68,3 +68,3 @@ const suspenseId = getSuspenseId(key, elementId);

suspense,
cacheTimeout: null
cacheTimeout: null,
};

@@ -81,3 +81,3 @@ };

onlyOnce: true,
showStackTrace: true
showStackTrace: true,
});

@@ -84,0 +84,0 @@ suspense = suspenses[suspenseId] = { state: 'done', value: ret };

@@ -30,3 +30,3 @@ export { assert };

`Do not hesitate to reach out as it makes ${projectInfo.projectName} more robust.`,
debugStr
debugStr,
].join(' '), numberOfStackTraceLinesToRemove);

@@ -33,0 +33,0 @@ throw internalError;

export { projectInfo };
import { getGlobalObject } from './getGlobalObject';
const PROJECT_VERSION = '0.3.24';
const PROJECT_VERSION = '0.3.25';
const projectInfo = {

@@ -8,6 +8,6 @@ projectName: 'react-streaming',

npmPackageName: 'react-streaming',
githubRepository: 'https://github.com/brillout/react-streaming'
githubRepository: 'https://github.com/brillout/react-streaming',
};
const { versions } = getGlobalObject('projectInfo.ts', {
versions: new Set()
versions: new Set(),
});

@@ -14,0 +14,0 @@ versions.add(projectInfo.projectVersion);

{
"name": "react-streaming",
"description": "React 18 Streaming. Full-fledged & Easy.",
"version": "0.3.24",
"version": "0.3.25",
"peerDependencies": {

@@ -56,12 +56,21 @@ "react": ">=18",

"clean": "rm -rf dist/",
"========= Formatting": "",
"format": "pnpm run format:biome",
"format:prettier": "git ls-files | egrep '\\.(json|js|jsx|css|ts|tsx|vue|mjs|cjs)$' | grep --invert-match package.json | xargs pnpm exec prettier --write",
"format:biome": "biome format --write .",
"format:check": "biome format . || echo Fix formatting by running: $ pnpm run format",
"// === Release ===": "",
"release": "release-me patch",
"release:commit": "release-me commit"
"release:commit": "release-me commit",
"========= Only allow pnpm; forbid yarn & npm": "",
"preinstall": "npx only-allow pnpm"
},
"devDependencies": {
"@biomejs/biome": "^1.7.0",
"@brillout/part-regex": "^0.1.2",
"@brillout/release-me": "^0.1.6",
"@brillout/release-me": "^0.1.14",
"@types/node": "^15.12.2",
"@types/react": "^18.0.9",
"@types/react-dom": "^18.2.4",
"prettier": "^3.2.5",
"react": "18.2.0",

@@ -72,2 +81,3 @@ "react-dom": "18.2.0",

},
"packageManager": "pnpm@8.15.4",
"files": [

@@ -74,0 +84,0 @@ "dist/",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc