@upyo/lettermint 0.5.0-dev.0 → 0.5.0-dev.119

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 CHANGED
@@ -10,7 +10,7 @@
10
10
  function createLettermintConfig(config) {
11
11
  return {
12
12
  apiToken: config.apiToken,
13
- baseUrl: config.baseUrl ?? "https://api.lettermint.co",
13
+ baseUrl: normalizeBaseUrl(config.baseUrl ?? "https://api.lettermint.co"),
14
14
  timeout: config.timeout ?? 3e4,
15
15
  retries: config.retries ?? 3,
16
16
  headers: config.headers ?? {},
@@ -20,6 +20,9 @@ function createLettermintConfig(config) {
20
20
  settings: config.settings == null ? void 0 : { ...config.settings }
21
21
  };
22
22
  }
23
+ function normalizeBaseUrl(baseUrl) {
24
+ return baseUrl.replace(/\/+$/, "");
25
+ }
23
26
 
24
27
  //#endregion
25
28
  //#region src/http-client.ts
@@ -293,11 +296,19 @@ async function convertAttachment(attachment) {
293
296
  return converted;
294
297
  }
295
298
  function uint8ArrayToBase64(bytes) {
299
+ const nativeToBase64 = getNativeToBase64(bytes);
300
+ if (nativeToBase64 != null) return nativeToBase64();
296
301
  const chunkSize = 32768;
297
302
  const chunks = [];
298
303
  for (let offset = 0; offset < bytes.length; offset += chunkSize) chunks.push(String.fromCharCode(...bytes.subarray(offset, offset + chunkSize)));
299
304
  return btoa(chunks.join(""));
300
305
  }
306
+ function getNativeToBase64(bytes) {
307
+ const candidate = bytes;
308
+ const toBase64 = candidate.toBase64;
309
+ if (typeof toBase64 !== "function") return void 0;
310
+ return () => toBase64.call(bytes);
311
+ }
301
312
  function isStandardHeader(headerName) {
302
313
  return STANDARD_HEADERS.has(headerName.toLowerCase());
303
314
  }
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@
9
9
  function createLettermintConfig(config) {
10
10
  return {
11
11
  apiToken: config.apiToken,
12
- baseUrl: config.baseUrl ?? "https://api.lettermint.co",
12
+ baseUrl: normalizeBaseUrl(config.baseUrl ?? "https://api.lettermint.co"),
13
13
  timeout: config.timeout ?? 3e4,
14
14
  retries: config.retries ?? 3,
15
15
  headers: config.headers ?? {},
@@ -19,6 +19,9 @@ function createLettermintConfig(config) {
19
19
  settings: config.settings == null ? void 0 : { ...config.settings }
20
20
  };
21
21
  }
22
+ function normalizeBaseUrl(baseUrl) {
23
+ return baseUrl.replace(/\/+$/, "");
24
+ }
22
25
 
23
26
  //#endregion
24
27
  //#region src/http-client.ts
@@ -292,11 +295,19 @@ async function convertAttachment(attachment) {
292
295
  return converted;
293
296
  }
294
297
  function uint8ArrayToBase64(bytes) {
298
+ const nativeToBase64 = getNativeToBase64(bytes);
299
+ if (nativeToBase64 != null) return nativeToBase64();
295
300
  const chunkSize = 32768;
296
301
  const chunks = [];
297
302
  for (let offset = 0; offset < bytes.length; offset += chunkSize) chunks.push(String.fromCharCode(...bytes.subarray(offset, offset + chunkSize)));
298
303
  return btoa(chunks.join(""));
299
304
  }
305
+ function getNativeToBase64(bytes) {
306
+ const candidate = bytes;
307
+ const toBase64 = candidate.toBase64;
308
+ if (typeof toBase64 !== "function") return void 0;
309
+ return () => toBase64.call(bytes);
310
+ }
300
311
  function isStandardHeader(headerName) {
301
312
  return STANDARD_HEADERS.has(headerName.toLowerCase());
302
313
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upyo/lettermint",
3
- "version": "0.5.0-dev.0",
3
+ "version": "0.5.0-dev.119",
4
4
  "description": "Lettermint 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"
56
+ "@upyo/core": "0.5.0-dev.119+b190ca07"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@dotenvx/dotenvx": "^1.47.3",