@rebilly/instruments 9.77.0 → 9.77.2
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/CHANGELOG.md +1 -6
- package/dist/index.js +80 -52
- package/dist/index.min.js +11 -11
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
## [9.77.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Features
|
|
5
|
-
|
|
6
|
-
* **js-sdk:** improve reb-api-consumer header usage by allowing custom app name ([#7202](https://github.com/Rebilly/rebilly/issues/7202)) ([c2a7cfb](https://github.com/Rebilly/rebilly/commit/c2a7cfba2a173eb041999d043e5a6f7c5e75d8ca))
|
|
1
|
+
## [9.77.2](https://github.com/Rebilly/rebilly/compare/instruments/core-v9.77.1...instruments/core-v9.77.2) (2024-09-02)
|
package/dist/index.js
CHANGED
|
@@ -4986,36 +4986,37 @@ const xhrAdapter = isXHRAdapterSupported && function(config) {
|
|
|
4986
4986
|
});
|
|
4987
4987
|
};
|
|
4988
4988
|
const composeSignals = (signals, timeout) => {
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
const unsubscribe = () => {
|
|
5003
|
-
if (signals) {
|
|
5004
|
-
timer && clearTimeout(timer);
|
|
4989
|
+
const { length } = signals = signals ? signals.filter(Boolean) : [];
|
|
4990
|
+
if (timeout || length) {
|
|
4991
|
+
let controller = new AbortController();
|
|
4992
|
+
let aborted;
|
|
4993
|
+
const onabort = function(reason) {
|
|
4994
|
+
if (!aborted) {
|
|
4995
|
+
aborted = true;
|
|
4996
|
+
unsubscribe();
|
|
4997
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
4998
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
4999
|
+
}
|
|
5000
|
+
};
|
|
5001
|
+
let timer = timeout && setTimeout(() => {
|
|
5005
5002
|
timer = null;
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
signals
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5003
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
|
5004
|
+
}, timeout);
|
|
5005
|
+
const unsubscribe = () => {
|
|
5006
|
+
if (signals) {
|
|
5007
|
+
timer && clearTimeout(timer);
|
|
5008
|
+
timer = null;
|
|
5009
|
+
signals.forEach((signal2) => {
|
|
5010
|
+
signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
|
|
5011
|
+
});
|
|
5012
|
+
signals = null;
|
|
5013
|
+
}
|
|
5014
|
+
};
|
|
5015
|
+
signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
|
|
5016
|
+
const { signal } = controller;
|
|
5017
|
+
signal.unsubscribe = () => utils$2.asap(unsubscribe);
|
|
5018
|
+
return signal;
|
|
5019
|
+
}
|
|
5019
5020
|
};
|
|
5020
5021
|
const streamChunk = function* (chunk, chunkSize) {
|
|
5021
5022
|
let len = chunk.byteLength;
|
|
@@ -5031,13 +5032,31 @@ const streamChunk = function* (chunk, chunkSize) {
|
|
|
5031
5032
|
pos = end;
|
|
5032
5033
|
}
|
|
5033
5034
|
};
|
|
5034
|
-
const readBytes = async function* (iterable, chunkSize
|
|
5035
|
-
for await (const chunk of iterable) {
|
|
5036
|
-
yield* streamChunk(
|
|
5035
|
+
const readBytes = async function* (iterable, chunkSize) {
|
|
5036
|
+
for await (const chunk of readStream(iterable)) {
|
|
5037
|
+
yield* streamChunk(chunk, chunkSize);
|
|
5037
5038
|
}
|
|
5038
5039
|
};
|
|
5039
|
-
const
|
|
5040
|
-
|
|
5040
|
+
const readStream = async function* (stream) {
|
|
5041
|
+
if (stream[Symbol.asyncIterator]) {
|
|
5042
|
+
yield* stream;
|
|
5043
|
+
return;
|
|
5044
|
+
}
|
|
5045
|
+
const reader = stream.getReader();
|
|
5046
|
+
try {
|
|
5047
|
+
for (; ; ) {
|
|
5048
|
+
const { done, value } = await reader.read();
|
|
5049
|
+
if (done) {
|
|
5050
|
+
break;
|
|
5051
|
+
}
|
|
5052
|
+
yield value;
|
|
5053
|
+
}
|
|
5054
|
+
} finally {
|
|
5055
|
+
await reader.cancel();
|
|
5056
|
+
}
|
|
5057
|
+
};
|
|
5058
|
+
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
5059
|
+
const iterator = readBytes(stream, chunkSize);
|
|
5041
5060
|
let bytes = 0;
|
|
5042
5061
|
let done;
|
|
5043
5062
|
let _onFinish = (e2) => {
|
|
@@ -5116,7 +5135,11 @@ const getBodyLength = async (body) => {
|
|
|
5116
5135
|
return body.size;
|
|
5117
5136
|
}
|
|
5118
5137
|
if (utils$2.isSpecCompliantForm(body)) {
|
|
5119
|
-
|
|
5138
|
+
const _request = new Request(platform.origin, {
|
|
5139
|
+
method: "POST",
|
|
5140
|
+
body
|
|
5141
|
+
});
|
|
5142
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
5120
5143
|
}
|
|
5121
5144
|
if (utils$2.isArrayBufferView(body) || utils$2.isArrayBuffer(body)) {
|
|
5122
5145
|
return body.byteLength;
|
|
@@ -5148,14 +5171,11 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
5148
5171
|
fetchOptions
|
|
5149
5172
|
} = resolveConfig(config);
|
|
5150
5173
|
responseType = responseType ? (responseType + "").toLowerCase() : "text";
|
|
5151
|
-
let
|
|
5152
|
-
let
|
|
5153
|
-
const
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
});
|
|
5157
|
-
finished = true;
|
|
5158
|
-
};
|
|
5174
|
+
let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
5175
|
+
let request;
|
|
5176
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
5177
|
+
composedSignal.unsubscribe();
|
|
5178
|
+
});
|
|
5159
5179
|
let requestContentLength;
|
|
5160
5180
|
try {
|
|
5161
5181
|
if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
|
|
@@ -5173,7 +5193,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
5173
5193
|
requestContentLength,
|
|
5174
5194
|
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
5175
5195
|
);
|
|
5176
|
-
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush
|
|
5196
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
5177
5197
|
}
|
|
5178
5198
|
}
|
|
5179
5199
|
if (!utils$2.isString(withCredentials)) {
|
|
@@ -5191,7 +5211,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
5191
5211
|
});
|
|
5192
5212
|
let response = await fetch(request);
|
|
5193
5213
|
const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
|
|
5194
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
|
5214
|
+
if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
|
|
5195
5215
|
const options = {};
|
|
5196
5216
|
["status", "statusText", "headers"].forEach((prop) => {
|
|
5197
5217
|
options[prop] = response[prop];
|
|
@@ -5204,15 +5224,14 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
5204
5224
|
response = new Response(
|
|
5205
5225
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
5206
5226
|
flush && flush();
|
|
5207
|
-
|
|
5208
|
-
}
|
|
5227
|
+
unsubscribe && unsubscribe();
|
|
5228
|
+
}),
|
|
5209
5229
|
options
|
|
5210
5230
|
);
|
|
5211
5231
|
}
|
|
5212
5232
|
responseType = responseType || "text";
|
|
5213
5233
|
let responseData = await resolvers[utils$2.findKey(resolvers, responseType) || "text"](response, config);
|
|
5214
|
-
!isStreamResponse &&
|
|
5215
|
-
stopTimeout && stopTimeout();
|
|
5234
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
5216
5235
|
return await new Promise((resolve2, reject) => {
|
|
5217
5236
|
settle(resolve2, reject, {
|
|
5218
5237
|
data: responseData,
|
|
@@ -5224,7 +5243,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
5224
5243
|
});
|
|
5225
5244
|
});
|
|
5226
5245
|
} catch (err) {
|
|
5227
|
-
|
|
5246
|
+
unsubscribe && unsubscribe();
|
|
5228
5247
|
if (err && err.name === "TypeError" && /fetch/i.test(err.message)) {
|
|
5229
5248
|
throw Object.assign(
|
|
5230
5249
|
new AxiosError("Network Error", AxiosError.ERR_NETWORK, config, request),
|
|
@@ -5331,7 +5350,7 @@ function dispatchRequest(config) {
|
|
|
5331
5350
|
return Promise.reject(reason);
|
|
5332
5351
|
});
|
|
5333
5352
|
}
|
|
5334
|
-
const VERSION = "1.7.
|
|
5353
|
+
const VERSION = "1.7.7";
|
|
5335
5354
|
const validators$1 = {};
|
|
5336
5355
|
["object", "boolean", "number", "function", "string", "symbol"].forEach((type2, i) => {
|
|
5337
5356
|
validators$1[type2] = function validator2(thing) {
|
|
@@ -5619,6 +5638,15 @@ class CancelToken {
|
|
|
5619
5638
|
this._listeners.splice(index2, 1);
|
|
5620
5639
|
}
|
|
5621
5640
|
}
|
|
5641
|
+
toAbortSignal() {
|
|
5642
|
+
const controller = new AbortController();
|
|
5643
|
+
const abort = (err) => {
|
|
5644
|
+
controller.abort(err);
|
|
5645
|
+
};
|
|
5646
|
+
this.subscribe(abort);
|
|
5647
|
+
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
|
5648
|
+
return controller.signal;
|
|
5649
|
+
}
|
|
5622
5650
|
/**
|
|
5623
5651
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
5624
5652
|
* cancels the `CancelToken`.
|
|
@@ -6192,7 +6220,7 @@ function C$1({ options: t2 }) {
|
|
|
6192
6220
|
}
|
|
6193
6221
|
function o2() {
|
|
6194
6222
|
const i = {
|
|
6195
|
-
"REB-API-CONSUMER": `${["Rebilly", t2.appName, "js-sdk"].filter((g) => g).join("/")}@
|
|
6223
|
+
"REB-API-CONSUMER": `${["Rebilly", t2.appName, "js-sdk"].filter((g) => g).join("/")}@9ff7468`
|
|
6196
6224
|
};
|
|
6197
6225
|
return t2.apiKey && (i["REB-APIKEY"] = t2.apiKey), i;
|
|
6198
6226
|
}
|