@kb-labs/shared-cli-ui 2.88.0 → 2.93.0
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 +37 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -5
- package/dist/index.d.ts +16 -5
- package/dist/index.js +37 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2265,6 +2265,42 @@ function toPosixPath(input) {
|
|
|
2265
2265
|
return input.replace(/\\/g, "/");
|
|
2266
2266
|
}
|
|
2267
2267
|
|
|
2268
|
+
// src/utils/retry.ts
|
|
2269
|
+
async function sleepForRetry(attempt, delay, backoff) {
|
|
2270
|
+
if (delay <= 0) {
|
|
2271
|
+
return;
|
|
2272
|
+
}
|
|
2273
|
+
const wait = backoff === "exponential" ? delay * 2 ** (attempt - 1) : delay;
|
|
2274
|
+
await new Promise((resolve) => {
|
|
2275
|
+
setTimeout(resolve, wait);
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
2278
|
+
async function withRetry(fn, options = {}) {
|
|
2279
|
+
if (typeof fn !== "function") {
|
|
2280
|
+
throw new TypeError("fn must be a function");
|
|
2281
|
+
}
|
|
2282
|
+
const { attempts = 3, delay = 0, backoff = "fixed", onRetry } = options;
|
|
2283
|
+
if (attempts < 1) {
|
|
2284
|
+
throw new RangeError(`attempts must be >= 1, got ${attempts}`);
|
|
2285
|
+
}
|
|
2286
|
+
if (delay < 0) {
|
|
2287
|
+
throw new RangeError(`delay must be >= 0, got ${delay}`);
|
|
2288
|
+
}
|
|
2289
|
+
let lastError;
|
|
2290
|
+
for (let attempt = 1; attempt <= attempts; attempt++) {
|
|
2291
|
+
try {
|
|
2292
|
+
return await fn();
|
|
2293
|
+
} catch (err) {
|
|
2294
|
+
lastError = err;
|
|
2295
|
+
if (attempt < attempts) {
|
|
2296
|
+
onRetry?.(err, attempt);
|
|
2297
|
+
await sleepForRetry(attempt, delay, backoff);
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
throw lastError;
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2268
2304
|
// src/modern-format.ts
|
|
2269
2305
|
function sideBorderBox(options) {
|
|
2270
2306
|
const { title, sections, footer, status, timing } = options;
|
|
@@ -2698,5 +2734,6 @@ exports.truncate = truncate;
|
|
|
2698
2734
|
exports.useLoader = useLoader;
|
|
2699
2735
|
exports.validateSuggestions = validateSuggestions;
|
|
2700
2736
|
exports.warningResult = warningResult;
|
|
2737
|
+
exports.withRetry = withRetry;
|
|
2701
2738
|
//# sourceMappingURL=index.cjs.map
|
|
2702
2739
|
//# sourceMappingURL=index.cjs.map
|