@upyo/resend 0.5.0-dev.154 → 0.5.0-dev.158
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/index.cjs +25 -18
- package/dist/index.js +25 -18
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -185,38 +185,45 @@ var ResendHttpClient = class {
|
|
|
185
185
|
for (const [key, value] of Object.entries(this.config.headers)) headers.set(key, value);
|
|
186
186
|
const controller = new AbortController();
|
|
187
187
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
188
|
-
|
|
189
|
-
let cleanup = () => {};
|
|
190
|
-
if (options.signal) {
|
|
191
|
-
const combinedController = new AbortController();
|
|
192
|
-
const onAbort = () => combinedController.abort();
|
|
193
|
-
if (options.signal.aborted || controller.signal.aborted) combinedController.abort();
|
|
194
|
-
else {
|
|
195
|
-
options.signal.addEventListener("abort", onAbort, { once: true });
|
|
196
|
-
controller.signal.addEventListener("abort", onAbort, { once: true });
|
|
197
|
-
}
|
|
198
|
-
cleanup = () => {
|
|
199
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
200
|
-
controller.signal.removeEventListener("abort", onAbort);
|
|
201
|
-
};
|
|
202
|
-
signal = combinedController.signal;
|
|
203
|
-
} else signal = controller.signal;
|
|
188
|
+
const combinedSignal = combineSignals(controller.signal, options.signal);
|
|
204
189
|
try {
|
|
205
190
|
const response = await fetch(url, {
|
|
206
191
|
...options,
|
|
207
192
|
headers,
|
|
208
|
-
signal
|
|
193
|
+
signal: combinedSignal.signal
|
|
209
194
|
});
|
|
210
195
|
return response;
|
|
211
196
|
} catch (error) {
|
|
212
197
|
if (isAbortError$1(error) && controller.signal.aborted && !options.signal?.aborted) throw new Error(`Resend API request timed out after ${this.config.timeout} ms.`);
|
|
213
198
|
throw error;
|
|
214
199
|
} finally {
|
|
215
|
-
cleanup();
|
|
200
|
+
combinedSignal.cleanup();
|
|
216
201
|
clearTimeout(timeoutId);
|
|
217
202
|
}
|
|
218
203
|
}
|
|
219
204
|
};
|
|
205
|
+
function combineSignals(timeoutSignal, externalSignal) {
|
|
206
|
+
if (externalSignal == null) return {
|
|
207
|
+
signal: timeoutSignal,
|
|
208
|
+
cleanup: () => {}
|
|
209
|
+
};
|
|
210
|
+
if (typeof AbortSignal.any === "function") return {
|
|
211
|
+
signal: AbortSignal.any([timeoutSignal, externalSignal]),
|
|
212
|
+
cleanup: () => {}
|
|
213
|
+
};
|
|
214
|
+
const controller = new AbortController();
|
|
215
|
+
const abort = () => controller.abort();
|
|
216
|
+
timeoutSignal.addEventListener("abort", abort, { once: true });
|
|
217
|
+
externalSignal.addEventListener("abort", abort, { once: true });
|
|
218
|
+
if (timeoutSignal.aborted || externalSignal.aborted) controller.abort();
|
|
219
|
+
return {
|
|
220
|
+
signal: controller.signal,
|
|
221
|
+
cleanup: () => {
|
|
222
|
+
timeoutSignal.removeEventListener("abort", abort);
|
|
223
|
+
externalSignal.removeEventListener("abort", abort);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
220
227
|
function isAbortError$1(error) {
|
|
221
228
|
return error instanceof Error && error.name === "AbortError";
|
|
222
229
|
}
|
package/dist/index.js
CHANGED
|
@@ -162,38 +162,45 @@ var ResendHttpClient = class {
|
|
|
162
162
|
for (const [key, value] of Object.entries(this.config.headers)) headers.set(key, value);
|
|
163
163
|
const controller = new AbortController();
|
|
164
164
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
165
|
-
|
|
166
|
-
let cleanup = () => {};
|
|
167
|
-
if (options.signal) {
|
|
168
|
-
const combinedController = new AbortController();
|
|
169
|
-
const onAbort = () => combinedController.abort();
|
|
170
|
-
if (options.signal.aborted || controller.signal.aborted) combinedController.abort();
|
|
171
|
-
else {
|
|
172
|
-
options.signal.addEventListener("abort", onAbort, { once: true });
|
|
173
|
-
controller.signal.addEventListener("abort", onAbort, { once: true });
|
|
174
|
-
}
|
|
175
|
-
cleanup = () => {
|
|
176
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
177
|
-
controller.signal.removeEventListener("abort", onAbort);
|
|
178
|
-
};
|
|
179
|
-
signal = combinedController.signal;
|
|
180
|
-
} else signal = controller.signal;
|
|
165
|
+
const combinedSignal = combineSignals(controller.signal, options.signal);
|
|
181
166
|
try {
|
|
182
167
|
const response = await fetch(url, {
|
|
183
168
|
...options,
|
|
184
169
|
headers,
|
|
185
|
-
signal
|
|
170
|
+
signal: combinedSignal.signal
|
|
186
171
|
});
|
|
187
172
|
return response;
|
|
188
173
|
} catch (error) {
|
|
189
174
|
if (isAbortError$1(error) && controller.signal.aborted && !options.signal?.aborted) throw new Error(`Resend API request timed out after ${this.config.timeout} ms.`);
|
|
190
175
|
throw error;
|
|
191
176
|
} finally {
|
|
192
|
-
cleanup();
|
|
177
|
+
combinedSignal.cleanup();
|
|
193
178
|
clearTimeout(timeoutId);
|
|
194
179
|
}
|
|
195
180
|
}
|
|
196
181
|
};
|
|
182
|
+
function combineSignals(timeoutSignal, externalSignal) {
|
|
183
|
+
if (externalSignal == null) return {
|
|
184
|
+
signal: timeoutSignal,
|
|
185
|
+
cleanup: () => {}
|
|
186
|
+
};
|
|
187
|
+
if (typeof AbortSignal.any === "function") return {
|
|
188
|
+
signal: AbortSignal.any([timeoutSignal, externalSignal]),
|
|
189
|
+
cleanup: () => {}
|
|
190
|
+
};
|
|
191
|
+
const controller = new AbortController();
|
|
192
|
+
const abort = () => controller.abort();
|
|
193
|
+
timeoutSignal.addEventListener("abort", abort, { once: true });
|
|
194
|
+
externalSignal.addEventListener("abort", abort, { once: true });
|
|
195
|
+
if (timeoutSignal.aborted || externalSignal.aborted) controller.abort();
|
|
196
|
+
return {
|
|
197
|
+
signal: controller.signal,
|
|
198
|
+
cleanup: () => {
|
|
199
|
+
timeoutSignal.removeEventListener("abort", abort);
|
|
200
|
+
externalSignal.removeEventListener("abort", abort);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
197
204
|
function isAbortError$1(error) {
|
|
198
205
|
return error instanceof Error && error.name === "AbortError";
|
|
199
206
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upyo/resend",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.158",
|
|
4
4
|
"description": "Resend transport for Upyo email library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"sideEffects": false,
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@upyo/core": "0.5.0-dev.
|
|
56
|
+
"@upyo/core": "0.5.0-dev.158+468b767c"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"tsdown": "^0.12.7",
|