@vida-global/core 2.0.7 → 2.0.8
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.
|
@@ -231,11 +231,13 @@ const InstanceMethods = {
|
|
|
231
231
|
if (!this._isStreaming) throw new NoActiveStreamError();
|
|
232
232
|
if (this._streamAbortController?.signal?.aborted || this.writableEnded) return;
|
|
233
233
|
|
|
234
|
+
let msg;
|
|
234
235
|
if (evt) {
|
|
235
|
-
|
|
236
|
+
msg = `event: ${evt}\ndata: ${data}\n\n`;
|
|
237
|
+
} else {
|
|
238
|
+
msg = `data: ${data}\n\n`;
|
|
236
239
|
}
|
|
237
240
|
|
|
238
|
-
const msg = `data: ${data}\n\n`;
|
|
239
241
|
this._response.write(msg);
|
|
240
242
|
}
|
|
241
243
|
}
|
package/package.json
CHANGED
|
@@ -1786,12 +1786,12 @@ describe('VidaServerController', () => {
|
|
|
1786
1786
|
.toThrow(NoActiveStreamError);
|
|
1787
1787
|
});
|
|
1788
1788
|
|
|
1789
|
-
it ('writes
|
|
1789
|
+
it ('writes the event and data lines as a single atomic frame when an event name is provided', async () => {
|
|
1790
1790
|
await controller.streamSseResponse(async () => {
|
|
1791
1791
|
response.write.mockClear();
|
|
1792
1792
|
controller.writeStreamEvent('progress', 'halfway');
|
|
1793
|
-
expect(response.write).
|
|
1794
|
-
expect(response.write).
|
|
1793
|
+
expect(response.write).toHaveBeenCalledTimes(1);
|
|
1794
|
+
expect(response.write).toHaveBeenCalledWith('event: progress\ndata: halfway\n\n');
|
|
1795
1795
|
}, jest.fn());
|
|
1796
1796
|
});
|
|
1797
1797
|
|