@phpsandbox/sdk 0.1.18 → 0.1.19
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/dist/browser/phpsandbox-sdk.esm.js +17 -3
- package/dist/browser/phpsandbox-sdk.esm.min.js +2 -2
- package/dist/browser/phpsandbox-sdk.iife.js +17 -3
- package/dist/browser/phpsandbox-sdk.iife.min.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/publications.d.ts +3 -0
- package/dist/publications.js +15 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -340,7 +340,7 @@ declare class ClientImplementation {
|
|
|
340
340
|
data: T;
|
|
341
341
|
}>;
|
|
342
342
|
stream(path: string): Promise<ReadableStream<Uint8Array>>;
|
|
343
|
-
sse(url: string): Promise<ReadableStream<Uint8Array>>;
|
|
343
|
+
sse(url: string, signal?: AbortSignal): Promise<ReadableStream<Uint8Array>>;
|
|
344
344
|
private makeRequest;
|
|
345
345
|
private fetchResponse;
|
|
346
346
|
}
|
package/dist/index.js
CHANGED
|
@@ -124,13 +124,14 @@ class ClientImplementation {
|
|
|
124
124
|
}
|
|
125
125
|
return response.body;
|
|
126
126
|
}
|
|
127
|
-
async sse(url) {
|
|
127
|
+
async sse(url, signal) {
|
|
128
128
|
const response = await this.fetchResponse(authenticatedRequest(url, {
|
|
129
129
|
method: 'GET',
|
|
130
130
|
headers: {
|
|
131
131
|
...this.headers,
|
|
132
132
|
'Accept': 'text/event-stream',
|
|
133
133
|
},
|
|
134
|
+
...(signal === undefined ? {} : { signal }),
|
|
134
135
|
}));
|
|
135
136
|
if (!response.ok) {
|
|
136
137
|
throw await responseError(response);
|
package/dist/publications.d.ts
CHANGED
|
@@ -146,6 +146,7 @@ export declare class PublicationApi {
|
|
|
146
146
|
export declare class PublicationRun<TProvider extends PublicationProviderName = PublicationProviderName> {
|
|
147
147
|
readonly initial: PublicationInstance<TProvider>;
|
|
148
148
|
private readonly client;
|
|
149
|
+
private readonly streamAbort;
|
|
149
150
|
private started;
|
|
150
151
|
private completed;
|
|
151
152
|
private finalError;
|
|
@@ -160,6 +161,8 @@ export declare class PublicationRun<TProvider extends PublicationProviderName =
|
|
|
160
161
|
result(): Promise<PublishStreamResult>;
|
|
161
162
|
publication(): Promise<PublicationInstance<TProvider>>;
|
|
162
163
|
start(): this;
|
|
164
|
+
/** Stop observing this run; the server-side publication continues. */
|
|
165
|
+
dispose(): void;
|
|
163
166
|
private subscribe;
|
|
164
167
|
private consumeStream;
|
|
165
168
|
private publish;
|
package/dist/publications.js
CHANGED
|
@@ -33,6 +33,7 @@ export class PublicationRun {
|
|
|
33
33
|
constructor(initial, client) {
|
|
34
34
|
this.initial = initial;
|
|
35
35
|
this.client = client;
|
|
36
|
+
this.streamAbort = new AbortController();
|
|
36
37
|
this.started = false;
|
|
37
38
|
this.completed = false;
|
|
38
39
|
this.finalError = null;
|
|
@@ -81,6 +82,19 @@ export class PublicationRun {
|
|
|
81
82
|
void this.consumeStream(eventStreamUrl);
|
|
82
83
|
return this;
|
|
83
84
|
}
|
|
85
|
+
/** Stop observing this run; the server-side publication continues. */
|
|
86
|
+
dispose() {
|
|
87
|
+
if (this.completed)
|
|
88
|
+
return;
|
|
89
|
+
const error = new DOMException('Stopped observing publication; deployment continues.', 'AbortError');
|
|
90
|
+
if (!this.started) {
|
|
91
|
+
this.started = true;
|
|
92
|
+
this.resultPromise = Promise.reject(error);
|
|
93
|
+
this.resultPromise.catch(() => undefined);
|
|
94
|
+
}
|
|
95
|
+
this.streamAbort.abort(error);
|
|
96
|
+
this.fail(error);
|
|
97
|
+
}
|
|
84
98
|
subscribe() {
|
|
85
99
|
const queue = new AsyncPublishEventQueue();
|
|
86
100
|
for (const event of this.bufferedEvents) {
|
|
@@ -99,7 +113,7 @@ export class PublicationRun {
|
|
|
99
113
|
}
|
|
100
114
|
async consumeStream(eventStreamUrl) {
|
|
101
115
|
try {
|
|
102
|
-
const stream = await this.client.sse(eventStreamUrl);
|
|
116
|
+
const stream = await this.client.sse(eventStreamUrl, this.streamAbort.signal);
|
|
103
117
|
for await (const event of readPublishStreamEvents(stream)) {
|
|
104
118
|
this.publish(event);
|
|
105
119
|
if (event.type === 'result') {
|