@blotoutio/providers-shop-gpt-sdk 1.9.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -4251,13 +4251,22 @@ if (!customElements.get('chat-section')) {
4251
4251
  customElements.define('chat-section', ChatSection);
4252
4252
  }
4253
4253
 
4254
+ async function* streamToIterable(stream) {
4255
+ const reader = stream.getReader();
4256
+ while (true) {
4257
+ const { done, value } = await reader.read();
4258
+ if (done)
4259
+ return;
4260
+ yield value;
4261
+ }
4262
+ }
4254
4263
  const handleEventSource = async (response, onEvent) => {
4255
4264
  var _a, _b;
4256
4265
  if (!response.body) {
4257
4266
  throw new Error('No body found in response');
4258
4267
  }
4259
4268
  let buffer = '';
4260
- for await (const chunk of response.body.pipeThrough(new TextDecoderStream())) {
4269
+ for await (const chunk of streamToIterable(response.body.pipeThrough(new TextDecoderStream()))) {
4261
4270
  buffer += chunk;
4262
4271
  const sections = buffer.split('\n\n');
4263
4272
  buffer = sections.pop() || '';
package/index.js CHANGED
@@ -4252,13 +4252,22 @@ ${this.comment ? this.comment : E}</textarea
4252
4252
  customElements.define('chat-section', ChatSection);
4253
4253
  }
4254
4254
 
4255
+ async function* streamToIterable(stream) {
4256
+ const reader = stream.getReader();
4257
+ while (true) {
4258
+ const { done, value } = await reader.read();
4259
+ if (done)
4260
+ return;
4261
+ yield value;
4262
+ }
4263
+ }
4255
4264
  const handleEventSource = async (response, onEvent) => {
4256
4265
  var _a, _b;
4257
4266
  if (!response.body) {
4258
4267
  throw new Error('No body found in response');
4259
4268
  }
4260
4269
  let buffer = '';
4261
- for await (const chunk of response.body.pipeThrough(new TextDecoderStream())) {
4270
+ for await (const chunk of streamToIterable(response.body.pipeThrough(new TextDecoderStream()))) {
4262
4271
  buffer += chunk;
4263
4272
  const sections = buffer.split('\n\n');
4264
4273
  buffer = sections.pop() || '';
package/index.mjs CHANGED
@@ -4249,13 +4249,22 @@ if (!customElements.get('chat-section')) {
4249
4249
  customElements.define('chat-section', ChatSection);
4250
4250
  }
4251
4251
 
4252
+ async function* streamToIterable(stream) {
4253
+ const reader = stream.getReader();
4254
+ while (true) {
4255
+ const { done, value } = await reader.read();
4256
+ if (done)
4257
+ return;
4258
+ yield value;
4259
+ }
4260
+ }
4252
4261
  const handleEventSource = async (response, onEvent) => {
4253
4262
  var _a, _b;
4254
4263
  if (!response.body) {
4255
4264
  throw new Error('No body found in response');
4256
4265
  }
4257
4266
  let buffer = '';
4258
- for await (const chunk of response.body.pipeThrough(new TextDecoderStream())) {
4267
+ for await (const chunk of streamToIterable(response.body.pipeThrough(new TextDecoderStream()))) {
4259
4268
  buffer += chunk;
4260
4269
  const sections = buffer.split('\n\n');
4261
4270
  buffer = sections.pop() || '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-shop-gpt-sdk",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "Shop GPT SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",