Refacto du code coté Python, java et coté angular afin de mieux séparer les responsabilité et d'avoir moins de répétitivité dans le code.
Some checks failed
E2E Tests / e2e (push) Waiting to run
Tests unitaires / Web (Angular · vitest + couverture) (push) Successful in 26s
Build & Push Images / tests (push) Failing after 13s
Build & Push Images / build (brain) (push) Has been skipped
Build & Push Images / build (core) (push) Has been skipped
Build & Push Images / build (web) (push) Has been skipped
Build & Push Images / build-switcher (push) Has been skipped
Tests unitaires / Brain (Python · pytest + couverture) (push) Successful in 1m12s
Tests unitaires / Core (Java · mvn test + JaCoCo) (push) Failing after 1m28s
Some checks failed
E2E Tests / e2e (push) Waiting to run
Tests unitaires / Web (Angular · vitest + couverture) (push) Successful in 26s
Build & Push Images / tests (push) Failing after 13s
Build & Push Images / build (brain) (push) Has been skipped
Build & Push Images / build (core) (push) Has been skipped
Build & Push Images / build (web) (push) Has been skipped
Build & Push Images / build-switcher (push) Has been skipped
Tests unitaires / Brain (Python · pytest + couverture) (push) Successful in 1m12s
Tests unitaires / Core (Java · mvn test + JaCoCo) (push) Failing after 1m28s
Mise en place de tests unitaires coté Python et Angular Mise en place de la couverture de test directement dans le workflow : le programme ne build pas si jamais un test échoue Passage en v0.16.2 en conséquence
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, Subscriber } from 'rxjs';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { LanguageService } from './language.service';
|
||||
import { parseSseStream, sseFetch } from '../shared/sse.util';
|
||||
|
||||
/**
|
||||
* Un message d'une conversation IA (vue front).
|
||||
@@ -105,108 +106,43 @@ export class AiChatService {
|
||||
|
||||
/** Plumbing SSE mutualisé entre les endpoints (Lore / Campaign / Session). */
|
||||
private streamSse(endpoint: string, body: Record<string, unknown>): Observable<ChatStreamEvent> {
|
||||
return new Observable<ChatStreamEvent>((subscriber) => {
|
||||
const controller = new AbortController();
|
||||
|
||||
fetch(endpoint, {
|
||||
return sseFetch<ChatStreamEvent>(
|
||||
endpoint,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'text/event-stream',
|
||||
'X-User-Language': this.language.current
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
signal: controller.signal
|
||||
})
|
||||
.then(async (response) => {
|
||||
if (!response.ok || !response.body) {
|
||||
subscriber.error(new Error(`HTTP ${response.status}`));
|
||||
return;
|
||||
}
|
||||
await this.consumeSseStream(response.body, subscriber);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (controller.signal.aborted) return; // annulation volontaire, silencieuse
|
||||
subscriber.error(err);
|
||||
});
|
||||
|
||||
return () => controller.abort();
|
||||
});
|
||||
body: JSON.stringify(body)
|
||||
},
|
||||
(responseBody, subscriber) => this.consumeSseStream(responseBody, subscriber)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Consomme un ReadableStream SSE ligne par ligne.
|
||||
* Format attendu (un événement = un bloc séparé par `\n\n`) :
|
||||
* event: done (optionnel, défaut = 'message')
|
||||
* data: {...} (une ou plusieurs lignes, concaténées avec '\n')
|
||||
* <ligne vide> (séparateur d'événements)
|
||||
*/
|
||||
/** Mappe les événements SSE bruts vers les `ChatStreamEvent` typés. */
|
||||
private async consumeSseStream(
|
||||
body: ReadableStream<Uint8Array>,
|
||||
subscriber: { next: (e: ChatStreamEvent) => void; error: (e: unknown) => void; complete: () => void }
|
||||
subscriber: Subscriber<ChatStreamEvent>
|
||||
): Promise<void> {
|
||||
const reader = body.getReader();
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
let buffer = '';
|
||||
|
||||
// Événement SSE en cours de construction (accumulé entre lignes vides).
|
||||
let currentEvent: string | null = null;
|
||||
let currentData = '';
|
||||
|
||||
const dispatchCurrentEvent = () => {
|
||||
const eventName = currentEvent ?? 'message';
|
||||
// DEBUG jauge de contexte — à retirer une fois stabilisé.
|
||||
if (eventName !== 'message') {
|
||||
console.log('[AiChatService] SSE event:', eventName, 'data:', currentData);
|
||||
}
|
||||
if (eventName === 'error') {
|
||||
const message = this.safeParseMessage(currentData);
|
||||
subscriber.error(new Error(message));
|
||||
} else if (eventName === 'done') {
|
||||
subscriber.next({ type: 'done' });
|
||||
subscriber.complete();
|
||||
} else if (eventName === 'usage') {
|
||||
const usage = this.safeParseUsage(currentData);
|
||||
if (usage) subscriber.next({ type: 'usage', usage });
|
||||
} else {
|
||||
// Événement 'message' (défaut) : JSON {"token": "..."}
|
||||
const token = this.safeParseToken(currentData);
|
||||
if (token) subscriber.next({ type: 'token', value: token });
|
||||
}
|
||||
currentEvent = null;
|
||||
currentData = '';
|
||||
};
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
buffer += decoder.decode(value, { stream: true });
|
||||
|
||||
// On découpe par lignes ; la dernière (potentiellement incomplète) reste dans buffer.
|
||||
let newlineIdx: number;
|
||||
while ((newlineIdx = buffer.indexOf('\n')) >= 0) {
|
||||
const line = buffer.slice(0, newlineIdx).replace(/\r$/, '');
|
||||
buffer = buffer.slice(newlineIdx + 1);
|
||||
|
||||
if (line === '') {
|
||||
// Ligne vide = fin d'un événement SSE : on dispatch ce qu'on a accumulé.
|
||||
if (currentEvent !== null || currentData !== '') {
|
||||
dispatchCurrentEvent();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith('event:')) {
|
||||
currentEvent = line.slice(6).trim();
|
||||
} else if (line.startsWith('data:')) {
|
||||
const chunk = line.slice(5).replace(/^ /, '');
|
||||
currentData = currentData ? `${currentData}\n${chunk}` : chunk;
|
||||
}
|
||||
// Autres champs SSE (id:, retry:) ignorés pour le MVP.
|
||||
await parseSseStream(body, ({ event, data }) => {
|
||||
if (event === 'error') {
|
||||
subscriber.error(new Error(this.safeParseMessage(data)));
|
||||
} else if (event === 'done') {
|
||||
subscriber.next({ type: 'done' });
|
||||
subscriber.complete();
|
||||
} else if (event === 'usage') {
|
||||
const usage = this.safeParseUsage(data);
|
||||
if (usage) subscriber.next({ type: 'usage', usage });
|
||||
} else {
|
||||
// Événement 'message' (défaut) : JSON {"token": "..."}
|
||||
const token = this.safeParseToken(data);
|
||||
if (token) subscriber.next({ type: 'token', value: token });
|
||||
}
|
||||
}
|
||||
});
|
||||
// Fin de stream côté réseau sans event: done explicite → on complete quand même.
|
||||
if (currentEvent !== null || currentData !== '') dispatchCurrentEvent();
|
||||
subscriber.complete();
|
||||
} catch (err) {
|
||||
subscriber.error(err);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, Subscriber } from 'rxjs';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import {
|
||||
CampaignImportApplyResult,
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
CampaignImportStreamEvent
|
||||
} from './campaign-import.model';
|
||||
import { LanguageService } from './language.service';
|
||||
import { parseSseStream, sseFetch } from '../shared/sse.util';
|
||||
|
||||
/**
|
||||
* Service HTTP pour l'import d'un PDF de campagne.
|
||||
@@ -21,31 +22,17 @@ export class CampaignImportService {
|
||||
constructor(private http: HttpClient, private translate: TranslateService, private language: LanguageService) {}
|
||||
|
||||
importStructureStream(campaignId: string, file: File): Observable<CampaignImportStreamEvent> {
|
||||
return new Observable<CampaignImportStreamEvent>((subscriber) => {
|
||||
const controller = new AbortController();
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
|
||||
fetch(`/api/campaigns/${campaignId}/import-structure/stream`, {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
return sseFetch<CampaignImportStreamEvent>(
|
||||
`/api/campaigns/${campaignId}/import-structure/stream`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'Accept': 'text/event-stream', 'X-User-Language': this.language.current },
|
||||
body: form,
|
||||
signal: controller.signal
|
||||
})
|
||||
.then(async (response) => {
|
||||
if (!response.ok || !response.body) {
|
||||
subscriber.error(new Error(`HTTP ${response.status}`));
|
||||
return;
|
||||
}
|
||||
await this.consumeSse(response.body, subscriber);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (controller.signal.aborted) return;
|
||||
subscriber.error(err);
|
||||
});
|
||||
|
||||
return () => controller.abort();
|
||||
});
|
||||
body: form
|
||||
},
|
||||
(body, subscriber) => this.consumeSse(body, subscriber)
|
||||
);
|
||||
}
|
||||
|
||||
applyStructure(campaignId: string, proposal: CampaignImportProposal): Observable<CampaignImportApplyResult> {
|
||||
@@ -53,39 +40,33 @@ export class CampaignImportService {
|
||||
`/api/campaigns/${campaignId}/import-structure/apply`, proposal);
|
||||
}
|
||||
|
||||
/** Décode un ReadableStream SSE et émet les évènements d'import typés. */
|
||||
/** Mappe les évènements SSE bruts vers les évènements d'import typés. */
|
||||
private async consumeSse(
|
||||
body: ReadableStream<Uint8Array>,
|
||||
subscriber: { next: (e: CampaignImportStreamEvent) => void; error: (e: unknown) => void; complete: () => void }
|
||||
subscriber: Subscriber<CampaignImportStreamEvent>
|
||||
): Promise<void> {
|
||||
const reader = body.getReader();
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
let buffer = '';
|
||||
let currentEvent: string | null = null;
|
||||
let currentData = '';
|
||||
// Le flux s'est-il terminé PROPREMENT (évènement done ou error reçu) ?
|
||||
// Sans ce suivi, une connexion coupée en plein import (timeout serveur,
|
||||
// proxy, Core redémarré) terminait l'Observable en silence : barre de
|
||||
// progression figée et aucun message pour l'utilisateur.
|
||||
let terminated = false;
|
||||
|
||||
const dispatch = () => {
|
||||
const name = currentEvent ?? 'message';
|
||||
if (name === 'error') {
|
||||
const dispatch = ({ event, data }: { event: string; data: string }) => {
|
||||
if (event === 'error') {
|
||||
let message = this.translate.instant('services.importFailed');
|
||||
try { message = (JSON.parse(currentData) as { message?: string }).message ?? message; } catch { /* défaut */ }
|
||||
try { message = (JSON.parse(data) as { message?: string }).message ?? message; } catch { /* défaut */ }
|
||||
terminated = true;
|
||||
subscriber.error(new Error(message));
|
||||
} else if (name === 'status') {
|
||||
} else if (event === 'status') {
|
||||
// Message d'attente lisible (fournisseur saturé, morceau re-découpé…).
|
||||
try {
|
||||
const obj = JSON.parse(currentData) as { message?: string };
|
||||
const obj = JSON.parse(data) as { message?: string };
|
||||
if (obj.message) subscriber.next({ type: 'status', message: obj.message });
|
||||
} catch { /* bloc malformé ignoré */ }
|
||||
} else if (name === 'progress' || name === 'done') {
|
||||
} else if (event === 'progress' || event === 'done') {
|
||||
try {
|
||||
const obj = JSON.parse(currentData);
|
||||
if (name === 'done') {
|
||||
const obj = JSON.parse(data);
|
||||
if (event === 'done') {
|
||||
terminated = true;
|
||||
subscriber.next({ type: 'done', arcs: obj.arcs ?? [], npcs: obj.npcs ?? [] });
|
||||
subscriber.complete();
|
||||
@@ -94,32 +75,10 @@ export class CampaignImportService {
|
||||
}
|
||||
} catch { /* bloc malformé ignoré */ }
|
||||
}
|
||||
currentEvent = null;
|
||||
currentData = '';
|
||||
};
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
buffer += decoder.decode(value, { stream: true });
|
||||
let idx: number;
|
||||
while ((idx = buffer.indexOf('\n')) >= 0) {
|
||||
const line = buffer.slice(0, idx).replace(/\r$/, '');
|
||||
buffer = buffer.slice(idx + 1);
|
||||
if (line === '') {
|
||||
if (currentEvent !== null || currentData !== '') dispatch();
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith('event:')) {
|
||||
currentEvent = line.slice(6).trim();
|
||||
} else if (line.startsWith('data:')) {
|
||||
const chunk = line.slice(5).replace(/^ /, '');
|
||||
currentData = currentData ? `${currentData}\n${chunk}` : chunk;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentEvent !== null || currentData !== '') dispatch();
|
||||
await parseSseStream(body, dispatch);
|
||||
if (!terminated) {
|
||||
subscriber.error(new Error(
|
||||
this.translate.instant('services.importInterrupted')));
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, Subscriber } from 'rxjs';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { GameSystem, GameSystemCreate, RulesImportResponse, RulesImportStreamEvent } from './game-system.model';
|
||||
import { LanguageService } from './language.service';
|
||||
import { parseSseStream, sseFetch } from '../shared/sse.util';
|
||||
|
||||
/**
|
||||
* Service HTTP pour les GameSystems (systèmes de JDR).
|
||||
@@ -57,66 +58,46 @@ export class GameSystemService {
|
||||
* subscription annule le fetch (AbortController).
|
||||
*/
|
||||
importRulesStream(file: File): Observable<RulesImportStreamEvent> {
|
||||
return new Observable<RulesImportStreamEvent>((subscriber) => {
|
||||
const controller = new AbortController();
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
|
||||
fetch(`${this.apiUrl}/import-rules/stream`, {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
return sseFetch<RulesImportStreamEvent>(
|
||||
`${this.apiUrl}/import-rules/stream`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'Accept': 'text/event-stream', 'X-User-Language': this.language.current },
|
||||
body: form,
|
||||
signal: controller.signal
|
||||
})
|
||||
.then(async (response) => {
|
||||
if (!response.ok || !response.body) {
|
||||
subscriber.error(new Error(`HTTP ${response.status}`));
|
||||
return;
|
||||
}
|
||||
await this.consumeImportSse(response.body, subscriber);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (controller.signal.aborted) return;
|
||||
subscriber.error(err);
|
||||
});
|
||||
|
||||
return () => controller.abort();
|
||||
});
|
||||
body: form
|
||||
},
|
||||
(body, subscriber) => this.consumeImportSse(body, subscriber)
|
||||
);
|
||||
}
|
||||
|
||||
/** Décode un ReadableStream SSE et émet les évènements d'import typés. */
|
||||
/** Mappe les évènements SSE bruts vers les évènements d'import typés. */
|
||||
private async consumeImportSse(
|
||||
body: ReadableStream<Uint8Array>,
|
||||
subscriber: { next: (e: RulesImportStreamEvent) => void; error: (e: unknown) => void; complete: () => void }
|
||||
subscriber: Subscriber<RulesImportStreamEvent>
|
||||
): Promise<void> {
|
||||
const reader = body.getReader();
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
let buffer = '';
|
||||
let currentEvent: string | null = null;
|
||||
let currentData = '';
|
||||
// Le flux s'est-il terminé PROPREMENT (évènement done ou error reçu) ?
|
||||
// Sans ce suivi, une connexion coupée en plein import (timeout serveur,
|
||||
// proxy, Core redémarré) terminait l'Observable en silence : barre de
|
||||
// progression figée et aucun message pour l'utilisateur.
|
||||
let terminated = false;
|
||||
|
||||
const dispatch = () => {
|
||||
const name = currentEvent ?? 'message';
|
||||
if (name === 'error') {
|
||||
const dispatch = ({ event, data }: { event: string; data: string }) => {
|
||||
if (event === 'error') {
|
||||
let message = this.translate.instant('services.importFailed');
|
||||
try { message = (JSON.parse(currentData) as { message?: string }).message ?? message; } catch { /* garde le défaut */ }
|
||||
try { message = (JSON.parse(data) as { message?: string }).message ?? message; } catch { /* garde le défaut */ }
|
||||
terminated = true;
|
||||
subscriber.error(new Error(message));
|
||||
} else if (name === 'status') {
|
||||
} else if (event === 'status') {
|
||||
// Message d'attente lisible (fournisseur saturé, morceau re-découpé…).
|
||||
try {
|
||||
const obj = JSON.parse(currentData) as { message?: string };
|
||||
const obj = JSON.parse(data) as { message?: string };
|
||||
if (obj.message) subscriber.next({ type: 'status', message: obj.message });
|
||||
} catch { /* bloc malformé ignoré */ }
|
||||
} else if (name === 'progress' || name === 'done') {
|
||||
} else if (event === 'progress' || event === 'done') {
|
||||
try {
|
||||
const obj = JSON.parse(currentData);
|
||||
if (name === 'done') {
|
||||
const obj = JSON.parse(data);
|
||||
if (event === 'done') {
|
||||
terminated = true;
|
||||
subscriber.next({ type: 'done', ...obj });
|
||||
subscriber.complete();
|
||||
@@ -125,32 +106,10 @@ export class GameSystemService {
|
||||
}
|
||||
} catch { /* bloc malformé ignoré */ }
|
||||
}
|
||||
currentEvent = null;
|
||||
currentData = '';
|
||||
};
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
buffer += decoder.decode(value, { stream: true });
|
||||
let idx: number;
|
||||
while ((idx = buffer.indexOf('\n')) >= 0) {
|
||||
const line = buffer.slice(0, idx).replace(/\r$/, '');
|
||||
buffer = buffer.slice(idx + 1);
|
||||
if (line === '') {
|
||||
if (currentEvent !== null || currentData !== '') dispatch();
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith('event:')) {
|
||||
currentEvent = line.slice(6).trim();
|
||||
} else if (line.startsWith('data:')) {
|
||||
const chunk = line.slice(5).replace(/^ /, '');
|
||||
currentData = currentData ? `${currentData}\n${chunk}` : chunk;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentEvent !== null || currentData !== '') dispatch();
|
||||
await parseSseStream(body, dispatch);
|
||||
if (!terminated) {
|
||||
subscriber.error(new Error(
|
||||
this.translate.instant('services.importInterrupted')));
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Observable } from 'rxjs';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { Notebook, NotebookArchive, NotebookDetail, NotebookSource, NotebookChatEvent } from './notebook.model';
|
||||
import { LanguageService } from './language.service';
|
||||
import { parseSseStream } from '../shared/sse.util';
|
||||
|
||||
/**
|
||||
* Service des notebooks (atelier RAG) : CRUD, upload/indexation de sources,
|
||||
@@ -88,20 +89,13 @@ export class NotebookService {
|
||||
this.zone.run(() => subscriber.complete());
|
||||
return;
|
||||
}
|
||||
const reader = response.body.getReader();
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
let buffer = '';
|
||||
let currentEvent: string | null = null;
|
||||
let currentData = '';
|
||||
|
||||
const dispatch = () => {
|
||||
const name = currentEvent ?? 'message';
|
||||
if (name === 'token') {
|
||||
try { emit({ type: 'token', value: (JSON.parse(currentData) as { token?: string }).token ?? '' }); }
|
||||
await parseSseStream(response.body, ({ event, data }) => {
|
||||
if (event === 'token') {
|
||||
try { emit({ type: 'token', value: (JSON.parse(data) as { token?: string }).token ?? '' }); }
|
||||
catch { /* ignore */ }
|
||||
} else if (name === 'sources') {
|
||||
} else if (event === 'sources') {
|
||||
try {
|
||||
const o = JSON.parse(currentData) as { sources?: { source_id?: string; page?: number | null; score?: number }[] };
|
||||
const o = JSON.parse(data) as { sources?: { source_id?: string; page?: number | null; score?: number }[] };
|
||||
emit({
|
||||
type: 'sources',
|
||||
sources: (o.sources ?? []).map(s => ({
|
||||
@@ -109,39 +103,19 @@ export class NotebookService {
|
||||
}))
|
||||
});
|
||||
} catch { /* ignore */ }
|
||||
} else if (name === 'progress') {
|
||||
} else if (event === 'progress') {
|
||||
try {
|
||||
const o = JSON.parse(currentData) as { current?: number; total?: number };
|
||||
const o = JSON.parse(data) as { current?: number; total?: number };
|
||||
emit({ type: 'progress', current: o.current ?? 0, total: o.total ?? 0 });
|
||||
} catch { /* ignore */ }
|
||||
} else if (name === 'done') {
|
||||
} else if (event === 'done') {
|
||||
emit({ type: 'done' });
|
||||
} else if (name === 'error') {
|
||||
} else if (event === 'error') {
|
||||
let msg = 'Erreur du chat.';
|
||||
try { msg = (JSON.parse(currentData) as { message?: string }).message ?? msg; } catch { /* garde */ }
|
||||
try { msg = (JSON.parse(data) as { message?: string }).message ?? msg; } catch { /* garde */ }
|
||||
emit({ type: 'error', message: msg });
|
||||
}
|
||||
currentEvent = null;
|
||||
currentData = '';
|
||||
};
|
||||
|
||||
while (true) {
|
||||
const { value, done } = await reader.read();
|
||||
if (done) break;
|
||||
buffer += decoder.decode(value, { stream: true });
|
||||
let idx: number;
|
||||
while ((idx = buffer.indexOf('\n')) >= 0) {
|
||||
const line = buffer.slice(0, idx).replace(/\r$/, '');
|
||||
buffer = buffer.slice(idx + 1);
|
||||
if (line === '') { if (currentEvent !== null || currentData !== '') dispatch(); continue; }
|
||||
if (line.startsWith('event:')) currentEvent = line.slice(6).trim();
|
||||
else if (line.startsWith('data:')) {
|
||||
const chunk = line.slice(5).replace(/^ /, '');
|
||||
currentData = currentData ? `${currentData}\n${chunk}` : chunk;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentEvent !== null || currentData !== '') dispatch();
|
||||
});
|
||||
this.zone.run(() => subscriber.complete());
|
||||
} catch (err) {
|
||||
if ((err as Error).name !== 'AbortError') {
|
||||
|
||||
Reference in New Issue
Block a user