@tscircuit/cli 0.1.1578 → 0.1.1579
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/cli/main.js +1044 -914
- package/dist/lib/index.js +1 -1
- package/package.json +1 -1
package/dist/cli/main.js
CHANGED
|
@@ -17156,8 +17156,8 @@ var require_keyword = __commonJS((exports2) => {
|
|
|
17156
17156
|
var _a;
|
|
17157
17157
|
const { gen, keyword, schema, parentSchema, $data, it } = cxt;
|
|
17158
17158
|
checkAsyncKeyword(it, def);
|
|
17159
|
-
const
|
|
17160
|
-
const validateRef = useKeyword(gen, keyword,
|
|
17159
|
+
const validate2 = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate;
|
|
17160
|
+
const validateRef = useKeyword(gen, keyword, validate2);
|
|
17161
17161
|
const valid = gen.let("valid");
|
|
17162
17162
|
cxt.block$data(valid, validateKeyword);
|
|
17163
17163
|
cxt.ok((_a = def.valid) !== null && _a !== undefined ? _a : valid);
|
|
@@ -18216,28 +18216,28 @@ var require_compile2 = __commonJS((exports2) => {
|
|
|
18216
18216
|
if (this.opts.code.process)
|
|
18217
18217
|
sourceCode = this.opts.code.process(sourceCode, sch);
|
|
18218
18218
|
const makeValidate = new Function(`${names_1.default.self}`, `${names_1.default.scope}`, sourceCode);
|
|
18219
|
-
const
|
|
18220
|
-
this.scope.value(validateName, { ref:
|
|
18221
|
-
|
|
18222
|
-
|
|
18223
|
-
|
|
18219
|
+
const validate2 = makeValidate(this, this.scope.get());
|
|
18220
|
+
this.scope.value(validateName, { ref: validate2 });
|
|
18221
|
+
validate2.errors = null;
|
|
18222
|
+
validate2.schema = sch.schema;
|
|
18223
|
+
validate2.schemaEnv = sch;
|
|
18224
18224
|
if (sch.$async)
|
|
18225
|
-
|
|
18225
|
+
validate2.$async = true;
|
|
18226
18226
|
if (this.opts.code.source === true) {
|
|
18227
|
-
|
|
18227
|
+
validate2.source = { validateName, validateCode, scopeValues: gen._values };
|
|
18228
18228
|
}
|
|
18229
18229
|
if (this.opts.unevaluated) {
|
|
18230
18230
|
const { props, items } = schemaCxt;
|
|
18231
|
-
|
|
18231
|
+
validate2.evaluated = {
|
|
18232
18232
|
props: props instanceof codegen_1.Name ? undefined : props,
|
|
18233
18233
|
items: items instanceof codegen_1.Name ? undefined : items,
|
|
18234
18234
|
dynamicProps: props instanceof codegen_1.Name,
|
|
18235
18235
|
dynamicItems: items instanceof codegen_1.Name
|
|
18236
18236
|
};
|
|
18237
|
-
if (
|
|
18238
|
-
|
|
18237
|
+
if (validate2.source)
|
|
18238
|
+
validate2.source.evaluated = (0, codegen_1.stringify)(validate2.evaluated);
|
|
18239
18239
|
}
|
|
18240
|
-
sch.validate =
|
|
18240
|
+
sch.validate = validate2;
|
|
18241
18241
|
return sch;
|
|
18242
18242
|
} catch (e) {
|
|
18243
18243
|
delete sch.validate;
|
|
@@ -21191,8 +21191,8 @@ var require_dynamicAnchor = __commonJS((exports2) => {
|
|
|
21191
21191
|
const { gen, it } = cxt;
|
|
21192
21192
|
it.schemaEnv.root.dynamicAnchors[anchor] = true;
|
|
21193
21193
|
const v = (0, codegen_1._)`${names_1.default.dynamicAnchors}${(0, codegen_1.getProperty)(anchor)}`;
|
|
21194
|
-
const
|
|
21195
|
-
gen.if((0, codegen_1._)`!${v}`, () => gen.assign(v,
|
|
21194
|
+
const validate2 = it.errSchemaPath === "#" ? it.validateName : _getValidate(cxt);
|
|
21195
|
+
gen.if((0, codegen_1._)`!${v}`, () => gen.assign(v, validate2));
|
|
21196
21196
|
}
|
|
21197
21197
|
exports2.dynamicAnchor = dynamicAnchor;
|
|
21198
21198
|
function _getValidate(cxt) {
|
|
@@ -21238,11 +21238,11 @@ var require_dynamicRef = __commonJS((exports2) => {
|
|
|
21238
21238
|
_callRef(it.validateName, valid)();
|
|
21239
21239
|
}
|
|
21240
21240
|
}
|
|
21241
|
-
function _callRef(
|
|
21241
|
+
function _callRef(validate2, valid) {
|
|
21242
21242
|
return valid ? () => gen.block(() => {
|
|
21243
|
-
(0, ref_1.callRef)(cxt,
|
|
21243
|
+
(0, ref_1.callRef)(cxt, validate2);
|
|
21244
21244
|
gen.let(valid, true);
|
|
21245
|
-
}) : () => (0, ref_1.callRef)(cxt,
|
|
21245
|
+
}) : () => (0, ref_1.callRef)(cxt, validate2);
|
|
21246
21246
|
}
|
|
21247
21247
|
}
|
|
21248
21248
|
exports2.dynamicRef = dynamicRef;
|
|
@@ -22169,8 +22169,8 @@ var require_2020 = __commonJS((exports2, module2) => {
|
|
|
22169
22169
|
var require_formats = __commonJS((exports2) => {
|
|
22170
22170
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
22171
22171
|
exports2.formatNames = exports2.fastFormats = exports2.fullFormats = undefined;
|
|
22172
|
-
function fmtDef(
|
|
22173
|
-
return { validate, compare };
|
|
22172
|
+
function fmtDef(validate2, compare) {
|
|
22173
|
+
return { validate: validate2, compare };
|
|
22174
22174
|
}
|
|
22175
22175
|
exports2.fullFormats = {
|
|
22176
22176
|
date: fmtDef(date, compareDate),
|
|
@@ -93628,7 +93628,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
|
93628
93628
|
// lib/getVersion.ts
|
|
93629
93629
|
import { createRequire as createRequire2 } from "node:module";
|
|
93630
93630
|
// package.json
|
|
93631
|
-
var version = "0.1.
|
|
93631
|
+
var version = "0.1.1578";
|
|
93632
93632
|
var package_default = {
|
|
93633
93633
|
name: "@tscircuit/cli",
|
|
93634
93634
|
version,
|
|
@@ -94926,6 +94926,965 @@ var registerAdd = (program2) => {
|
|
|
94926
94926
|
});
|
|
94927
94927
|
};
|
|
94928
94928
|
|
|
94929
|
+
// cli/agent/ensure-latest-tsci-agent.ts
|
|
94930
|
+
var import_semver4 = __toESM2(require_semver2(), 1);
|
|
94931
|
+
import { execSync as execSync2 } from "node:child_process";
|
|
94932
|
+
|
|
94933
|
+
// lib/shared/get-dep-install-command.ts
|
|
94934
|
+
var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
94935
|
+
switch (packageManager) {
|
|
94936
|
+
case "yarn":
|
|
94937
|
+
return `yarn global add ${deps}`;
|
|
94938
|
+
case "pnpm":
|
|
94939
|
+
return `pnpm add -g ${deps}`;
|
|
94940
|
+
case "bun":
|
|
94941
|
+
return `bun install -g ${deps}`;
|
|
94942
|
+
default:
|
|
94943
|
+
return `npm install -g ${deps}`;
|
|
94944
|
+
}
|
|
94945
|
+
};
|
|
94946
|
+
|
|
94947
|
+
// cli/agent/confirm-install-or-update.ts
|
|
94948
|
+
var import_prompts3 = __toESM2(require_prompts3(), 1);
|
|
94949
|
+
async function confirmInstallOrUpdate(message) {
|
|
94950
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
94951
|
+
return false;
|
|
94952
|
+
}
|
|
94953
|
+
const { confirmed } = await import_prompts3.default({
|
|
94954
|
+
type: "confirm",
|
|
94955
|
+
name: "confirmed",
|
|
94956
|
+
message,
|
|
94957
|
+
initial: false
|
|
94958
|
+
});
|
|
94959
|
+
return confirmed === true;
|
|
94960
|
+
}
|
|
94961
|
+
|
|
94962
|
+
// cli/agent/constants.ts
|
|
94963
|
+
var TSCI_AGENT_PACKAGE_NAME = "tsci-agent";
|
|
94964
|
+
var TSCI_AGENT_BINARY_NAME = "tsci-agent";
|
|
94965
|
+
|
|
94966
|
+
// cli/agent/get-installed-tsci-agent-version.ts
|
|
94967
|
+
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
94968
|
+
import { spawnSync } from "node:child_process";
|
|
94969
|
+
function getInstalledTsciAgentVersion() {
|
|
94970
|
+
const result = spawnSync(TSCI_AGENT_BINARY_NAME, ["--version"], {
|
|
94971
|
+
encoding: "utf8",
|
|
94972
|
+
shell: process.platform === "win32"
|
|
94973
|
+
});
|
|
94974
|
+
if (result.error && result.error.code === "ENOENT") {
|
|
94975
|
+
return { isInstalled: false, version: null };
|
|
94976
|
+
}
|
|
94977
|
+
if (result.error) {
|
|
94978
|
+
return { isInstalled: false, version: null };
|
|
94979
|
+
}
|
|
94980
|
+
const output = `${result.stdout ?? ""}
|
|
94981
|
+
${result.stderr ?? ""}`;
|
|
94982
|
+
const version2 = import_semver2.default.valid(output.trim()) ?? import_semver2.default.coerce(output)?.version ?? null;
|
|
94983
|
+
return { isInstalled: true, version: version2 };
|
|
94984
|
+
}
|
|
94985
|
+
|
|
94986
|
+
// node_modules/ky/distribution/errors/HTTPError.js
|
|
94987
|
+
class HTTPError extends Error {
|
|
94988
|
+
response;
|
|
94989
|
+
request;
|
|
94990
|
+
options;
|
|
94991
|
+
constructor(response, request, options) {
|
|
94992
|
+
const code = response.status || response.status === 0 ? response.status : "";
|
|
94993
|
+
const title = response.statusText ?? "";
|
|
94994
|
+
const status = `${code} ${title}`.trim();
|
|
94995
|
+
const reason = status ? `status code ${status}` : "an unknown error";
|
|
94996
|
+
super(`Request failed with ${reason}: ${request.method} ${request.url}`);
|
|
94997
|
+
this.name = "HTTPError";
|
|
94998
|
+
this.response = response;
|
|
94999
|
+
this.request = request;
|
|
95000
|
+
this.options = options;
|
|
95001
|
+
}
|
|
95002
|
+
}
|
|
95003
|
+
|
|
95004
|
+
// node_modules/ky/distribution/errors/NonError.js
|
|
95005
|
+
class NonError extends Error {
|
|
95006
|
+
name = "NonError";
|
|
95007
|
+
value;
|
|
95008
|
+
constructor(value) {
|
|
95009
|
+
let message = "Non-error value was thrown";
|
|
95010
|
+
try {
|
|
95011
|
+
if (typeof value === "string") {
|
|
95012
|
+
message = value;
|
|
95013
|
+
} else if (value && typeof value === "object" && "message" in value && typeof value.message === "string") {
|
|
95014
|
+
message = value.message;
|
|
95015
|
+
}
|
|
95016
|
+
} catch {}
|
|
95017
|
+
super(message);
|
|
95018
|
+
this.value = value;
|
|
95019
|
+
}
|
|
95020
|
+
}
|
|
95021
|
+
|
|
95022
|
+
// node_modules/ky/distribution/errors/ForceRetryError.js
|
|
95023
|
+
class ForceRetryError extends Error {
|
|
95024
|
+
name = "ForceRetryError";
|
|
95025
|
+
customDelay;
|
|
95026
|
+
code;
|
|
95027
|
+
customRequest;
|
|
95028
|
+
constructor(options) {
|
|
95029
|
+
const cause = options?.cause ? options.cause instanceof Error ? options.cause : new NonError(options.cause) : undefined;
|
|
95030
|
+
super(options?.code ? `Forced retry: ${options.code}` : "Forced retry", cause ? { cause } : undefined);
|
|
95031
|
+
this.customDelay = options?.delay;
|
|
95032
|
+
this.code = options?.code;
|
|
95033
|
+
this.customRequest = options?.request;
|
|
95034
|
+
}
|
|
95035
|
+
}
|
|
95036
|
+
|
|
95037
|
+
// node_modules/ky/distribution/core/constants.js
|
|
95038
|
+
var supportsRequestStreams = (() => {
|
|
95039
|
+
let duplexAccessed = false;
|
|
95040
|
+
let hasContentType = false;
|
|
95041
|
+
const supportsReadableStream = typeof globalThis.ReadableStream === "function";
|
|
95042
|
+
const supportsRequest = typeof globalThis.Request === "function";
|
|
95043
|
+
if (supportsReadableStream && supportsRequest) {
|
|
95044
|
+
try {
|
|
95045
|
+
hasContentType = new globalThis.Request("https://empty.invalid", {
|
|
95046
|
+
body: new globalThis.ReadableStream,
|
|
95047
|
+
method: "POST",
|
|
95048
|
+
get duplex() {
|
|
95049
|
+
duplexAccessed = true;
|
|
95050
|
+
return "half";
|
|
95051
|
+
}
|
|
95052
|
+
}).headers.has("Content-Type");
|
|
95053
|
+
} catch (error) {
|
|
95054
|
+
if (error instanceof Error && error.message === "unsupported BodyInit type") {
|
|
95055
|
+
return false;
|
|
95056
|
+
}
|
|
95057
|
+
throw error;
|
|
95058
|
+
}
|
|
95059
|
+
}
|
|
95060
|
+
return duplexAccessed && !hasContentType;
|
|
95061
|
+
})();
|
|
95062
|
+
var supportsAbortController = typeof globalThis.AbortController === "function";
|
|
95063
|
+
var supportsAbortSignal = typeof globalThis.AbortSignal === "function" && typeof globalThis.AbortSignal.any === "function";
|
|
95064
|
+
var supportsResponseStreams = typeof globalThis.ReadableStream === "function";
|
|
95065
|
+
var supportsFormData = typeof globalThis.FormData === "function";
|
|
95066
|
+
var requestMethods = ["get", "post", "put", "patch", "head", "delete"];
|
|
95067
|
+
var validate = () => {
|
|
95068
|
+
return;
|
|
95069
|
+
};
|
|
95070
|
+
validate();
|
|
95071
|
+
var responseTypes = {
|
|
95072
|
+
json: "application/json",
|
|
95073
|
+
text: "text/*",
|
|
95074
|
+
formData: "multipart/form-data",
|
|
95075
|
+
arrayBuffer: "*/*",
|
|
95076
|
+
blob: "*/*",
|
|
95077
|
+
bytes: "*/*"
|
|
95078
|
+
};
|
|
95079
|
+
var maxSafeTimeout = 2147483647;
|
|
95080
|
+
var usualFormBoundarySize = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length;
|
|
95081
|
+
var stop = Symbol("stop");
|
|
95082
|
+
|
|
95083
|
+
class RetryMarker {
|
|
95084
|
+
options;
|
|
95085
|
+
constructor(options) {
|
|
95086
|
+
this.options = options;
|
|
95087
|
+
}
|
|
95088
|
+
}
|
|
95089
|
+
var retry = (options) => new RetryMarker(options);
|
|
95090
|
+
var kyOptionKeys = {
|
|
95091
|
+
json: true,
|
|
95092
|
+
parseJson: true,
|
|
95093
|
+
stringifyJson: true,
|
|
95094
|
+
searchParams: true,
|
|
95095
|
+
prefixUrl: true,
|
|
95096
|
+
retry: true,
|
|
95097
|
+
timeout: true,
|
|
95098
|
+
hooks: true,
|
|
95099
|
+
throwHttpErrors: true,
|
|
95100
|
+
onDownloadProgress: true,
|
|
95101
|
+
onUploadProgress: true,
|
|
95102
|
+
fetch: true,
|
|
95103
|
+
context: true
|
|
95104
|
+
};
|
|
95105
|
+
var vendorSpecificOptions = {
|
|
95106
|
+
next: true
|
|
95107
|
+
};
|
|
95108
|
+
var requestOptionsRegistry = {
|
|
95109
|
+
method: true,
|
|
95110
|
+
headers: true,
|
|
95111
|
+
body: true,
|
|
95112
|
+
mode: true,
|
|
95113
|
+
credentials: true,
|
|
95114
|
+
cache: true,
|
|
95115
|
+
redirect: true,
|
|
95116
|
+
referrer: true,
|
|
95117
|
+
referrerPolicy: true,
|
|
95118
|
+
integrity: true,
|
|
95119
|
+
keepalive: true,
|
|
95120
|
+
signal: true,
|
|
95121
|
+
window: true,
|
|
95122
|
+
duplex: true
|
|
95123
|
+
};
|
|
95124
|
+
|
|
95125
|
+
// node_modules/ky/distribution/utils/body.js
|
|
95126
|
+
var getBodySize = (body) => {
|
|
95127
|
+
if (!body) {
|
|
95128
|
+
return 0;
|
|
95129
|
+
}
|
|
95130
|
+
if (body instanceof FormData) {
|
|
95131
|
+
let size = 0;
|
|
95132
|
+
for (const [key, value] of body) {
|
|
95133
|
+
size += usualFormBoundarySize;
|
|
95134
|
+
size += new TextEncoder().encode(`Content-Disposition: form-data; name="${key}"`).length;
|
|
95135
|
+
size += typeof value === "string" ? new TextEncoder().encode(value).length : value.size;
|
|
95136
|
+
}
|
|
95137
|
+
return size;
|
|
95138
|
+
}
|
|
95139
|
+
if (body instanceof Blob) {
|
|
95140
|
+
return body.size;
|
|
95141
|
+
}
|
|
95142
|
+
if (body instanceof ArrayBuffer) {
|
|
95143
|
+
return body.byteLength;
|
|
95144
|
+
}
|
|
95145
|
+
if (typeof body === "string") {
|
|
95146
|
+
return new TextEncoder().encode(body).length;
|
|
95147
|
+
}
|
|
95148
|
+
if (body instanceof URLSearchParams) {
|
|
95149
|
+
return new TextEncoder().encode(body.toString()).length;
|
|
95150
|
+
}
|
|
95151
|
+
if ("byteLength" in body) {
|
|
95152
|
+
return body.byteLength;
|
|
95153
|
+
}
|
|
95154
|
+
if (typeof body === "object" && body !== null) {
|
|
95155
|
+
try {
|
|
95156
|
+
const jsonString = JSON.stringify(body);
|
|
95157
|
+
return new TextEncoder().encode(jsonString).length;
|
|
95158
|
+
} catch {
|
|
95159
|
+
return 0;
|
|
95160
|
+
}
|
|
95161
|
+
}
|
|
95162
|
+
return 0;
|
|
95163
|
+
};
|
|
95164
|
+
var withProgress = (stream, totalBytes, onProgress) => {
|
|
95165
|
+
let previousChunk;
|
|
95166
|
+
let transferredBytes = 0;
|
|
95167
|
+
return stream.pipeThrough(new TransformStream({
|
|
95168
|
+
transform(currentChunk, controller) {
|
|
95169
|
+
controller.enqueue(currentChunk);
|
|
95170
|
+
if (previousChunk) {
|
|
95171
|
+
transferredBytes += previousChunk.byteLength;
|
|
95172
|
+
let percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
|
|
95173
|
+
if (percent >= 1) {
|
|
95174
|
+
percent = 1 - Number.EPSILON;
|
|
95175
|
+
}
|
|
95176
|
+
onProgress?.({ percent, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
|
|
95177
|
+
}
|
|
95178
|
+
previousChunk = currentChunk;
|
|
95179
|
+
},
|
|
95180
|
+
flush() {
|
|
95181
|
+
if (previousChunk) {
|
|
95182
|
+
transferredBytes += previousChunk.byteLength;
|
|
95183
|
+
onProgress?.({ percent: 1, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
|
|
95184
|
+
}
|
|
95185
|
+
}
|
|
95186
|
+
}));
|
|
95187
|
+
};
|
|
95188
|
+
var streamResponse = (response, onDownloadProgress) => {
|
|
95189
|
+
if (!response.body) {
|
|
95190
|
+
return response;
|
|
95191
|
+
}
|
|
95192
|
+
if (response.status === 204) {
|
|
95193
|
+
return new Response(null, {
|
|
95194
|
+
status: response.status,
|
|
95195
|
+
statusText: response.statusText,
|
|
95196
|
+
headers: response.headers
|
|
95197
|
+
});
|
|
95198
|
+
}
|
|
95199
|
+
const totalBytes = Math.max(0, Number(response.headers.get("content-length")) || 0);
|
|
95200
|
+
return new Response(withProgress(response.body, totalBytes, onDownloadProgress), {
|
|
95201
|
+
status: response.status,
|
|
95202
|
+
statusText: response.statusText,
|
|
95203
|
+
headers: response.headers
|
|
95204
|
+
});
|
|
95205
|
+
};
|
|
95206
|
+
var streamRequest = (request, onUploadProgress, originalBody) => {
|
|
95207
|
+
if (!request.body) {
|
|
95208
|
+
return request;
|
|
95209
|
+
}
|
|
95210
|
+
const totalBytes = getBodySize(originalBody ?? request.body);
|
|
95211
|
+
return new Request(request, {
|
|
95212
|
+
duplex: "half",
|
|
95213
|
+
body: withProgress(request.body, totalBytes, onUploadProgress)
|
|
95214
|
+
});
|
|
95215
|
+
};
|
|
95216
|
+
|
|
95217
|
+
// node_modules/ky/distribution/utils/is.js
|
|
95218
|
+
var isObject = (value) => value !== null && typeof value === "object";
|
|
95219
|
+
|
|
95220
|
+
// node_modules/ky/distribution/utils/merge.js
|
|
95221
|
+
var validateAndMerge = (...sources) => {
|
|
95222
|
+
for (const source of sources) {
|
|
95223
|
+
if ((!isObject(source) || Array.isArray(source)) && source !== undefined) {
|
|
95224
|
+
throw new TypeError("The `options` argument must be an object");
|
|
95225
|
+
}
|
|
95226
|
+
}
|
|
95227
|
+
return deepMerge({}, ...sources);
|
|
95228
|
+
};
|
|
95229
|
+
var mergeHeaders = (source1 = {}, source2 = {}) => {
|
|
95230
|
+
const result = new globalThis.Headers(source1);
|
|
95231
|
+
const isHeadersInstance = source2 instanceof globalThis.Headers;
|
|
95232
|
+
const source = new globalThis.Headers(source2);
|
|
95233
|
+
for (const [key, value] of source.entries()) {
|
|
95234
|
+
if (isHeadersInstance && value === "undefined" || value === undefined) {
|
|
95235
|
+
result.delete(key);
|
|
95236
|
+
} else {
|
|
95237
|
+
result.set(key, value);
|
|
95238
|
+
}
|
|
95239
|
+
}
|
|
95240
|
+
return result;
|
|
95241
|
+
};
|
|
95242
|
+
function newHookValue(original, incoming, property) {
|
|
95243
|
+
return Object.hasOwn(incoming, property) && incoming[property] === undefined ? [] : deepMerge(original[property] ?? [], incoming[property] ?? []);
|
|
95244
|
+
}
|
|
95245
|
+
var mergeHooks = (original = {}, incoming = {}) => ({
|
|
95246
|
+
beforeRequest: newHookValue(original, incoming, "beforeRequest"),
|
|
95247
|
+
beforeRetry: newHookValue(original, incoming, "beforeRetry"),
|
|
95248
|
+
afterResponse: newHookValue(original, incoming, "afterResponse"),
|
|
95249
|
+
beforeError: newHookValue(original, incoming, "beforeError")
|
|
95250
|
+
});
|
|
95251
|
+
var appendSearchParameters = (target, source) => {
|
|
95252
|
+
const result = new URLSearchParams;
|
|
95253
|
+
for (const input of [target, source]) {
|
|
95254
|
+
if (input === undefined) {
|
|
95255
|
+
continue;
|
|
95256
|
+
}
|
|
95257
|
+
if (input instanceof URLSearchParams) {
|
|
95258
|
+
for (const [key, value] of input.entries()) {
|
|
95259
|
+
result.append(key, value);
|
|
95260
|
+
}
|
|
95261
|
+
} else if (Array.isArray(input)) {
|
|
95262
|
+
for (const pair of input) {
|
|
95263
|
+
if (!Array.isArray(pair) || pair.length !== 2) {
|
|
95264
|
+
throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
|
|
95265
|
+
}
|
|
95266
|
+
result.append(String(pair[0]), String(pair[1]));
|
|
95267
|
+
}
|
|
95268
|
+
} else if (isObject(input)) {
|
|
95269
|
+
for (const [key, value] of Object.entries(input)) {
|
|
95270
|
+
if (value !== undefined) {
|
|
95271
|
+
result.append(key, String(value));
|
|
95272
|
+
}
|
|
95273
|
+
}
|
|
95274
|
+
} else {
|
|
95275
|
+
const parameters = new URLSearchParams(input);
|
|
95276
|
+
for (const [key, value] of parameters.entries()) {
|
|
95277
|
+
result.append(key, value);
|
|
95278
|
+
}
|
|
95279
|
+
}
|
|
95280
|
+
}
|
|
95281
|
+
return result;
|
|
95282
|
+
};
|
|
95283
|
+
var deepMerge = (...sources) => {
|
|
95284
|
+
let returnValue = {};
|
|
95285
|
+
let headers = {};
|
|
95286
|
+
let hooks = {};
|
|
95287
|
+
let searchParameters;
|
|
95288
|
+
const signals = [];
|
|
95289
|
+
for (const source of sources) {
|
|
95290
|
+
if (Array.isArray(source)) {
|
|
95291
|
+
if (!Array.isArray(returnValue)) {
|
|
95292
|
+
returnValue = [];
|
|
95293
|
+
}
|
|
95294
|
+
returnValue = [...returnValue, ...source];
|
|
95295
|
+
} else if (isObject(source)) {
|
|
95296
|
+
for (let [key, value] of Object.entries(source)) {
|
|
95297
|
+
if (key === "signal" && value instanceof globalThis.AbortSignal) {
|
|
95298
|
+
signals.push(value);
|
|
95299
|
+
continue;
|
|
95300
|
+
}
|
|
95301
|
+
if (key === "context") {
|
|
95302
|
+
if (value !== undefined && value !== null && (!isObject(value) || Array.isArray(value))) {
|
|
95303
|
+
throw new TypeError("The `context` option must be an object");
|
|
95304
|
+
}
|
|
95305
|
+
returnValue = {
|
|
95306
|
+
...returnValue,
|
|
95307
|
+
context: value === undefined || value === null ? {} : { ...returnValue.context, ...value }
|
|
95308
|
+
};
|
|
95309
|
+
continue;
|
|
95310
|
+
}
|
|
95311
|
+
if (key === "searchParams") {
|
|
95312
|
+
if (value === undefined || value === null) {
|
|
95313
|
+
searchParameters = undefined;
|
|
95314
|
+
} else {
|
|
95315
|
+
searchParameters = searchParameters === undefined ? value : appendSearchParameters(searchParameters, value);
|
|
95316
|
+
}
|
|
95317
|
+
continue;
|
|
95318
|
+
}
|
|
95319
|
+
if (isObject(value) && key in returnValue) {
|
|
95320
|
+
value = deepMerge(returnValue[key], value);
|
|
95321
|
+
}
|
|
95322
|
+
returnValue = { ...returnValue, [key]: value };
|
|
95323
|
+
}
|
|
95324
|
+
if (isObject(source.hooks)) {
|
|
95325
|
+
hooks = mergeHooks(hooks, source.hooks);
|
|
95326
|
+
returnValue.hooks = hooks;
|
|
95327
|
+
}
|
|
95328
|
+
if (isObject(source.headers)) {
|
|
95329
|
+
headers = mergeHeaders(headers, source.headers);
|
|
95330
|
+
returnValue.headers = headers;
|
|
95331
|
+
}
|
|
95332
|
+
}
|
|
95333
|
+
}
|
|
95334
|
+
if (searchParameters !== undefined) {
|
|
95335
|
+
returnValue.searchParams = searchParameters;
|
|
95336
|
+
}
|
|
95337
|
+
if (signals.length > 0) {
|
|
95338
|
+
if (signals.length === 1) {
|
|
95339
|
+
returnValue.signal = signals[0];
|
|
95340
|
+
} else if (supportsAbortSignal) {
|
|
95341
|
+
returnValue.signal = AbortSignal.any(signals);
|
|
95342
|
+
} else {
|
|
95343
|
+
returnValue.signal = signals.at(-1);
|
|
95344
|
+
}
|
|
95345
|
+
}
|
|
95346
|
+
return returnValue;
|
|
95347
|
+
};
|
|
95348
|
+
|
|
95349
|
+
// node_modules/ky/distribution/utils/normalize.js
|
|
95350
|
+
var normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;
|
|
95351
|
+
var retryMethods = ["get", "put", "head", "delete", "options", "trace"];
|
|
95352
|
+
var retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
|
|
95353
|
+
var retryAfterStatusCodes = [413, 429, 503];
|
|
95354
|
+
var defaultRetryOptions = {
|
|
95355
|
+
limit: 2,
|
|
95356
|
+
methods: retryMethods,
|
|
95357
|
+
statusCodes: retryStatusCodes,
|
|
95358
|
+
afterStatusCodes: retryAfterStatusCodes,
|
|
95359
|
+
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
95360
|
+
backoffLimit: Number.POSITIVE_INFINITY,
|
|
95361
|
+
delay: (attemptCount) => 0.3 * 2 ** (attemptCount - 1) * 1000,
|
|
95362
|
+
jitter: undefined,
|
|
95363
|
+
retryOnTimeout: false
|
|
95364
|
+
};
|
|
95365
|
+
var normalizeRetryOptions = (retry2 = {}) => {
|
|
95366
|
+
if (typeof retry2 === "number") {
|
|
95367
|
+
return {
|
|
95368
|
+
...defaultRetryOptions,
|
|
95369
|
+
limit: retry2
|
|
95370
|
+
};
|
|
95371
|
+
}
|
|
95372
|
+
if (retry2.methods && !Array.isArray(retry2.methods)) {
|
|
95373
|
+
throw new Error("retry.methods must be an array");
|
|
95374
|
+
}
|
|
95375
|
+
retry2.methods &&= retry2.methods.map((method) => method.toLowerCase());
|
|
95376
|
+
if (retry2.statusCodes && !Array.isArray(retry2.statusCodes)) {
|
|
95377
|
+
throw new Error("retry.statusCodes must be an array");
|
|
95378
|
+
}
|
|
95379
|
+
const normalizedRetry = Object.fromEntries(Object.entries(retry2).filter(([, value]) => value !== undefined));
|
|
95380
|
+
return {
|
|
95381
|
+
...defaultRetryOptions,
|
|
95382
|
+
...normalizedRetry
|
|
95383
|
+
};
|
|
95384
|
+
};
|
|
95385
|
+
|
|
95386
|
+
// node_modules/ky/distribution/errors/TimeoutError.js
|
|
95387
|
+
class TimeoutError extends Error {
|
|
95388
|
+
request;
|
|
95389
|
+
constructor(request) {
|
|
95390
|
+
super(`Request timed out: ${request.method} ${request.url}`);
|
|
95391
|
+
this.name = "TimeoutError";
|
|
95392
|
+
this.request = request;
|
|
95393
|
+
}
|
|
95394
|
+
}
|
|
95395
|
+
|
|
95396
|
+
// node_modules/ky/distribution/utils/timeout.js
|
|
95397
|
+
async function timeout(request, init2, abortController, options) {
|
|
95398
|
+
return new Promise((resolve, reject) => {
|
|
95399
|
+
const timeoutId = setTimeout(() => {
|
|
95400
|
+
if (abortController) {
|
|
95401
|
+
abortController.abort();
|
|
95402
|
+
}
|
|
95403
|
+
reject(new TimeoutError(request));
|
|
95404
|
+
}, options.timeout);
|
|
95405
|
+
options.fetch(request, init2).then(resolve).catch(reject).then(() => {
|
|
95406
|
+
clearTimeout(timeoutId);
|
|
95407
|
+
});
|
|
95408
|
+
});
|
|
95409
|
+
}
|
|
95410
|
+
|
|
95411
|
+
// node_modules/ky/distribution/utils/delay.js
|
|
95412
|
+
async function delay(ms, { signal }) {
|
|
95413
|
+
return new Promise((resolve, reject) => {
|
|
95414
|
+
if (signal) {
|
|
95415
|
+
signal.throwIfAborted();
|
|
95416
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
95417
|
+
}
|
|
95418
|
+
function abortHandler() {
|
|
95419
|
+
clearTimeout(timeoutId);
|
|
95420
|
+
reject(signal.reason);
|
|
95421
|
+
}
|
|
95422
|
+
const timeoutId = setTimeout(() => {
|
|
95423
|
+
signal?.removeEventListener("abort", abortHandler);
|
|
95424
|
+
resolve();
|
|
95425
|
+
}, ms);
|
|
95426
|
+
});
|
|
95427
|
+
}
|
|
95428
|
+
|
|
95429
|
+
// node_modules/ky/distribution/utils/options.js
|
|
95430
|
+
var findUnknownOptions = (request, options) => {
|
|
95431
|
+
const unknownOptions = {};
|
|
95432
|
+
for (const key in options) {
|
|
95433
|
+
if (!Object.hasOwn(options, key)) {
|
|
95434
|
+
continue;
|
|
95435
|
+
}
|
|
95436
|
+
if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && (!(key in request) || (key in vendorSpecificOptions))) {
|
|
95437
|
+
unknownOptions[key] = options[key];
|
|
95438
|
+
}
|
|
95439
|
+
}
|
|
95440
|
+
return unknownOptions;
|
|
95441
|
+
};
|
|
95442
|
+
var hasSearchParameters = (search) => {
|
|
95443
|
+
if (search === undefined) {
|
|
95444
|
+
return false;
|
|
95445
|
+
}
|
|
95446
|
+
if (Array.isArray(search)) {
|
|
95447
|
+
return search.length > 0;
|
|
95448
|
+
}
|
|
95449
|
+
if (search instanceof URLSearchParams) {
|
|
95450
|
+
return search.size > 0;
|
|
95451
|
+
}
|
|
95452
|
+
if (typeof search === "object") {
|
|
95453
|
+
return Object.keys(search).length > 0;
|
|
95454
|
+
}
|
|
95455
|
+
if (typeof search === "string") {
|
|
95456
|
+
return search.trim().length > 0;
|
|
95457
|
+
}
|
|
95458
|
+
return Boolean(search);
|
|
95459
|
+
};
|
|
95460
|
+
|
|
95461
|
+
// node_modules/ky/distribution/utils/type-guards.js
|
|
95462
|
+
function isHTTPError(error) {
|
|
95463
|
+
return error instanceof HTTPError || error?.name === HTTPError.name;
|
|
95464
|
+
}
|
|
95465
|
+
function isTimeoutError(error) {
|
|
95466
|
+
return error instanceof TimeoutError || error?.name === TimeoutError.name;
|
|
95467
|
+
}
|
|
95468
|
+
|
|
95469
|
+
// node_modules/ky/distribution/core/Ky.js
|
|
95470
|
+
class Ky {
|
|
95471
|
+
static create(input, options) {
|
|
95472
|
+
const ky = new Ky(input, options);
|
|
95473
|
+
const function_ = async () => {
|
|
95474
|
+
if (typeof ky.#options.timeout === "number" && ky.#options.timeout > maxSafeTimeout) {
|
|
95475
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
|
|
95476
|
+
}
|
|
95477
|
+
await Promise.resolve();
|
|
95478
|
+
let response = await ky.#fetch();
|
|
95479
|
+
for (const hook of ky.#options.hooks.afterResponse) {
|
|
95480
|
+
const clonedResponse = ky.#decorateResponse(response.clone());
|
|
95481
|
+
let modifiedResponse;
|
|
95482
|
+
try {
|
|
95483
|
+
modifiedResponse = await hook(ky.request, ky.#getNormalizedOptions(), clonedResponse, { retryCount: ky.#retryCount });
|
|
95484
|
+
} catch (error) {
|
|
95485
|
+
ky.#cancelResponseBody(clonedResponse);
|
|
95486
|
+
ky.#cancelResponseBody(response);
|
|
95487
|
+
throw error;
|
|
95488
|
+
}
|
|
95489
|
+
if (modifiedResponse instanceof RetryMarker) {
|
|
95490
|
+
ky.#cancelResponseBody(clonedResponse);
|
|
95491
|
+
ky.#cancelResponseBody(response);
|
|
95492
|
+
throw new ForceRetryError(modifiedResponse.options);
|
|
95493
|
+
}
|
|
95494
|
+
const nextResponse = modifiedResponse instanceof globalThis.Response ? modifiedResponse : response;
|
|
95495
|
+
if (clonedResponse !== nextResponse) {
|
|
95496
|
+
ky.#cancelResponseBody(clonedResponse);
|
|
95497
|
+
}
|
|
95498
|
+
if (response !== nextResponse) {
|
|
95499
|
+
ky.#cancelResponseBody(response);
|
|
95500
|
+
}
|
|
95501
|
+
response = nextResponse;
|
|
95502
|
+
}
|
|
95503
|
+
ky.#decorateResponse(response);
|
|
95504
|
+
if (!response.ok && (typeof ky.#options.throwHttpErrors === "function" ? ky.#options.throwHttpErrors(response.status) : ky.#options.throwHttpErrors)) {
|
|
95505
|
+
let error = new HTTPError(response, ky.request, ky.#getNormalizedOptions());
|
|
95506
|
+
for (const hook of ky.#options.hooks.beforeError) {
|
|
95507
|
+
error = await hook(error, { retryCount: ky.#retryCount });
|
|
95508
|
+
}
|
|
95509
|
+
throw error;
|
|
95510
|
+
}
|
|
95511
|
+
if (ky.#options.onDownloadProgress) {
|
|
95512
|
+
if (typeof ky.#options.onDownloadProgress !== "function") {
|
|
95513
|
+
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
95514
|
+
}
|
|
95515
|
+
if (!supportsResponseStreams) {
|
|
95516
|
+
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
95517
|
+
}
|
|
95518
|
+
const progressResponse = response.clone();
|
|
95519
|
+
ky.#cancelResponseBody(response);
|
|
95520
|
+
return streamResponse(progressResponse, ky.#options.onDownloadProgress);
|
|
95521
|
+
}
|
|
95522
|
+
return response;
|
|
95523
|
+
};
|
|
95524
|
+
const result = ky.#retry(function_).finally(() => {
|
|
95525
|
+
const originalRequest = ky.#originalRequest;
|
|
95526
|
+
ky.#cancelBody(originalRequest?.body ?? undefined);
|
|
95527
|
+
ky.#cancelBody(ky.request.body ?? undefined);
|
|
95528
|
+
});
|
|
95529
|
+
for (const [type, mimeType] of Object.entries(responseTypes)) {
|
|
95530
|
+
if (type === "bytes" && typeof globalThis.Response?.prototype?.bytes !== "function") {
|
|
95531
|
+
continue;
|
|
95532
|
+
}
|
|
95533
|
+
result[type] = async () => {
|
|
95534
|
+
ky.request.headers.set("accept", ky.request.headers.get("accept") || mimeType);
|
|
95535
|
+
const response = await result;
|
|
95536
|
+
if (type === "json") {
|
|
95537
|
+
if (response.status === 204) {
|
|
95538
|
+
return "";
|
|
95539
|
+
}
|
|
95540
|
+
const text = await response.text();
|
|
95541
|
+
if (text === "") {
|
|
95542
|
+
return "";
|
|
95543
|
+
}
|
|
95544
|
+
if (options.parseJson) {
|
|
95545
|
+
return options.parseJson(text);
|
|
95546
|
+
}
|
|
95547
|
+
return JSON.parse(text);
|
|
95548
|
+
}
|
|
95549
|
+
return response[type]();
|
|
95550
|
+
};
|
|
95551
|
+
}
|
|
95552
|
+
return result;
|
|
95553
|
+
}
|
|
95554
|
+
static #normalizeSearchParams(searchParams) {
|
|
95555
|
+
if (searchParams && typeof searchParams === "object" && !Array.isArray(searchParams) && !(searchParams instanceof URLSearchParams)) {
|
|
95556
|
+
return Object.fromEntries(Object.entries(searchParams).filter(([, value]) => value !== undefined));
|
|
95557
|
+
}
|
|
95558
|
+
return searchParams;
|
|
95559
|
+
}
|
|
95560
|
+
request;
|
|
95561
|
+
#abortController;
|
|
95562
|
+
#retryCount = 0;
|
|
95563
|
+
#input;
|
|
95564
|
+
#options;
|
|
95565
|
+
#originalRequest;
|
|
95566
|
+
#userProvidedAbortSignal;
|
|
95567
|
+
#cachedNormalizedOptions;
|
|
95568
|
+
constructor(input, options = {}) {
|
|
95569
|
+
this.#input = input;
|
|
95570
|
+
this.#options = {
|
|
95571
|
+
...options,
|
|
95572
|
+
headers: mergeHeaders(this.#input.headers, options.headers),
|
|
95573
|
+
hooks: mergeHooks({
|
|
95574
|
+
beforeRequest: [],
|
|
95575
|
+
beforeRetry: [],
|
|
95576
|
+
beforeError: [],
|
|
95577
|
+
afterResponse: []
|
|
95578
|
+
}, options.hooks),
|
|
95579
|
+
method: normalizeRequestMethod(options.method ?? this.#input.method ?? "GET"),
|
|
95580
|
+
prefixUrl: String(options.prefixUrl || ""),
|
|
95581
|
+
retry: normalizeRetryOptions(options.retry),
|
|
95582
|
+
throwHttpErrors: options.throwHttpErrors ?? true,
|
|
95583
|
+
timeout: options.timeout ?? 1e4,
|
|
95584
|
+
fetch: options.fetch ?? globalThis.fetch.bind(globalThis),
|
|
95585
|
+
context: options.context ?? {}
|
|
95586
|
+
};
|
|
95587
|
+
if (typeof this.#input !== "string" && !(this.#input instanceof URL || this.#input instanceof globalThis.Request)) {
|
|
95588
|
+
throw new TypeError("`input` must be a string, URL, or Request");
|
|
95589
|
+
}
|
|
95590
|
+
if (this.#options.prefixUrl && typeof this.#input === "string") {
|
|
95591
|
+
if (this.#input.startsWith("/")) {
|
|
95592
|
+
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
95593
|
+
}
|
|
95594
|
+
if (!this.#options.prefixUrl.endsWith("/")) {
|
|
95595
|
+
this.#options.prefixUrl += "/";
|
|
95596
|
+
}
|
|
95597
|
+
this.#input = this.#options.prefixUrl + this.#input;
|
|
95598
|
+
}
|
|
95599
|
+
if (supportsAbortController && supportsAbortSignal) {
|
|
95600
|
+
this.#userProvidedAbortSignal = this.#options.signal ?? this.#input.signal;
|
|
95601
|
+
this.#abortController = new globalThis.AbortController;
|
|
95602
|
+
this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
|
|
95603
|
+
}
|
|
95604
|
+
if (supportsRequestStreams) {
|
|
95605
|
+
this.#options.duplex = "half";
|
|
95606
|
+
}
|
|
95607
|
+
if (this.#options.json !== undefined) {
|
|
95608
|
+
this.#options.body = this.#options.stringifyJson?.(this.#options.json) ?? JSON.stringify(this.#options.json);
|
|
95609
|
+
this.#options.headers.set("content-type", this.#options.headers.get("content-type") ?? "application/json");
|
|
95610
|
+
}
|
|
95611
|
+
const userProvidedContentType = options.headers && new globalThis.Headers(options.headers).has("content-type");
|
|
95612
|
+
if (this.#input instanceof globalThis.Request && (supportsFormData && this.#options.body instanceof globalThis.FormData || this.#options.body instanceof URLSearchParams) && !userProvidedContentType) {
|
|
95613
|
+
this.#options.headers.delete("content-type");
|
|
95614
|
+
}
|
|
95615
|
+
this.request = new globalThis.Request(this.#input, this.#options);
|
|
95616
|
+
if (hasSearchParameters(this.#options.searchParams)) {
|
|
95617
|
+
const textSearchParams = typeof this.#options.searchParams === "string" ? this.#options.searchParams.replace(/^\?/, "") : new URLSearchParams(Ky.#normalizeSearchParams(this.#options.searchParams)).toString();
|
|
95618
|
+
const searchParams = "?" + textSearchParams;
|
|
95619
|
+
const url = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, searchParams);
|
|
95620
|
+
this.request = new globalThis.Request(url, this.#options);
|
|
95621
|
+
}
|
|
95622
|
+
if (this.#options.onUploadProgress) {
|
|
95623
|
+
if (typeof this.#options.onUploadProgress !== "function") {
|
|
95624
|
+
throw new TypeError("The `onUploadProgress` option must be a function");
|
|
95625
|
+
}
|
|
95626
|
+
if (!supportsRequestStreams) {
|
|
95627
|
+
throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
|
|
95628
|
+
}
|
|
95629
|
+
this.request = this.#wrapRequestWithUploadProgress(this.request, this.#options.body ?? undefined);
|
|
95630
|
+
}
|
|
95631
|
+
}
|
|
95632
|
+
#calculateDelay() {
|
|
95633
|
+
const retryDelay = this.#options.retry.delay(this.#retryCount);
|
|
95634
|
+
let jitteredDelay = retryDelay;
|
|
95635
|
+
if (this.#options.retry.jitter === true) {
|
|
95636
|
+
jitteredDelay = Math.random() * retryDelay;
|
|
95637
|
+
} else if (typeof this.#options.retry.jitter === "function") {
|
|
95638
|
+
jitteredDelay = this.#options.retry.jitter(retryDelay);
|
|
95639
|
+
if (!Number.isFinite(jitteredDelay) || jitteredDelay < 0) {
|
|
95640
|
+
jitteredDelay = retryDelay;
|
|
95641
|
+
}
|
|
95642
|
+
}
|
|
95643
|
+
const backoffLimit = this.#options.retry.backoffLimit ?? Number.POSITIVE_INFINITY;
|
|
95644
|
+
return Math.min(backoffLimit, jitteredDelay);
|
|
95645
|
+
}
|
|
95646
|
+
async#calculateRetryDelay(error) {
|
|
95647
|
+
this.#retryCount++;
|
|
95648
|
+
if (this.#retryCount > this.#options.retry.limit) {
|
|
95649
|
+
throw error;
|
|
95650
|
+
}
|
|
95651
|
+
const errorObject = error instanceof Error ? error : new NonError(error);
|
|
95652
|
+
if (errorObject instanceof ForceRetryError) {
|
|
95653
|
+
return errorObject.customDelay ?? this.#calculateDelay();
|
|
95654
|
+
}
|
|
95655
|
+
if (!this.#options.retry.methods.includes(this.request.method.toLowerCase())) {
|
|
95656
|
+
throw error;
|
|
95657
|
+
}
|
|
95658
|
+
if (this.#options.retry.shouldRetry !== undefined) {
|
|
95659
|
+
const result = await this.#options.retry.shouldRetry({ error: errorObject, retryCount: this.#retryCount });
|
|
95660
|
+
if (result === false) {
|
|
95661
|
+
throw error;
|
|
95662
|
+
}
|
|
95663
|
+
if (result === true) {
|
|
95664
|
+
return this.#calculateDelay();
|
|
95665
|
+
}
|
|
95666
|
+
}
|
|
95667
|
+
if (isTimeoutError(error) && !this.#options.retry.retryOnTimeout) {
|
|
95668
|
+
throw error;
|
|
95669
|
+
}
|
|
95670
|
+
if (isHTTPError(error)) {
|
|
95671
|
+
if (!this.#options.retry.statusCodes.includes(error.response.status)) {
|
|
95672
|
+
throw error;
|
|
95673
|
+
}
|
|
95674
|
+
const retryAfter = error.response.headers.get("Retry-After") ?? error.response.headers.get("RateLimit-Reset") ?? error.response.headers.get("X-RateLimit-Retry-After") ?? error.response.headers.get("X-RateLimit-Reset") ?? error.response.headers.get("X-Rate-Limit-Reset");
|
|
95675
|
+
if (retryAfter && this.#options.retry.afterStatusCodes.includes(error.response.status)) {
|
|
95676
|
+
let after = Number(retryAfter) * 1000;
|
|
95677
|
+
if (Number.isNaN(after)) {
|
|
95678
|
+
after = Date.parse(retryAfter) - Date.now();
|
|
95679
|
+
} else if (after >= Date.parse("2024-01-01")) {
|
|
95680
|
+
after -= Date.now();
|
|
95681
|
+
}
|
|
95682
|
+
const max = this.#options.retry.maxRetryAfter ?? after;
|
|
95683
|
+
return after < max ? after : max;
|
|
95684
|
+
}
|
|
95685
|
+
if (error.response.status === 413) {
|
|
95686
|
+
throw error;
|
|
95687
|
+
}
|
|
95688
|
+
}
|
|
95689
|
+
return this.#calculateDelay();
|
|
95690
|
+
}
|
|
95691
|
+
#decorateResponse(response) {
|
|
95692
|
+
if (this.#options.parseJson) {
|
|
95693
|
+
response.json = async () => this.#options.parseJson(await response.text());
|
|
95694
|
+
}
|
|
95695
|
+
return response;
|
|
95696
|
+
}
|
|
95697
|
+
#cancelBody(body) {
|
|
95698
|
+
if (!body) {
|
|
95699
|
+
return;
|
|
95700
|
+
}
|
|
95701
|
+
body.cancel().catch(() => {
|
|
95702
|
+
return;
|
|
95703
|
+
});
|
|
95704
|
+
}
|
|
95705
|
+
#cancelResponseBody(response) {
|
|
95706
|
+
this.#cancelBody(response.body ?? undefined);
|
|
95707
|
+
}
|
|
95708
|
+
async#retry(function_) {
|
|
95709
|
+
try {
|
|
95710
|
+
return await function_();
|
|
95711
|
+
} catch (error) {
|
|
95712
|
+
const ms = Math.min(await this.#calculateRetryDelay(error), maxSafeTimeout);
|
|
95713
|
+
if (this.#retryCount < 1) {
|
|
95714
|
+
throw error;
|
|
95715
|
+
}
|
|
95716
|
+
await delay(ms, this.#userProvidedAbortSignal ? { signal: this.#userProvidedAbortSignal } : {});
|
|
95717
|
+
if (error instanceof ForceRetryError && error.customRequest) {
|
|
95718
|
+
const managedRequest = this.#options.signal ? new globalThis.Request(error.customRequest, { signal: this.#options.signal }) : new globalThis.Request(error.customRequest);
|
|
95719
|
+
this.#assignRequest(managedRequest);
|
|
95720
|
+
}
|
|
95721
|
+
for (const hook of this.#options.hooks.beforeRetry) {
|
|
95722
|
+
const hookResult = await hook({
|
|
95723
|
+
request: this.request,
|
|
95724
|
+
options: this.#getNormalizedOptions(),
|
|
95725
|
+
error,
|
|
95726
|
+
retryCount: this.#retryCount
|
|
95727
|
+
});
|
|
95728
|
+
if (hookResult instanceof globalThis.Request) {
|
|
95729
|
+
this.#assignRequest(hookResult);
|
|
95730
|
+
break;
|
|
95731
|
+
}
|
|
95732
|
+
if (hookResult instanceof globalThis.Response) {
|
|
95733
|
+
return hookResult;
|
|
95734
|
+
}
|
|
95735
|
+
if (hookResult === stop) {
|
|
95736
|
+
return;
|
|
95737
|
+
}
|
|
95738
|
+
}
|
|
95739
|
+
return this.#retry(function_);
|
|
95740
|
+
}
|
|
95741
|
+
}
|
|
95742
|
+
async#fetch() {
|
|
95743
|
+
if (this.#abortController?.signal.aborted) {
|
|
95744
|
+
this.#abortController = new globalThis.AbortController;
|
|
95745
|
+
this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
|
|
95746
|
+
this.request = new globalThis.Request(this.request, { signal: this.#options.signal });
|
|
95747
|
+
}
|
|
95748
|
+
for (const hook of this.#options.hooks.beforeRequest) {
|
|
95749
|
+
const result = await hook(this.request, this.#getNormalizedOptions(), { retryCount: this.#retryCount });
|
|
95750
|
+
if (result instanceof Response) {
|
|
95751
|
+
return result;
|
|
95752
|
+
}
|
|
95753
|
+
if (result instanceof globalThis.Request) {
|
|
95754
|
+
this.#assignRequest(result);
|
|
95755
|
+
break;
|
|
95756
|
+
}
|
|
95757
|
+
}
|
|
95758
|
+
const nonRequestOptions = findUnknownOptions(this.request, this.#options);
|
|
95759
|
+
this.#originalRequest = this.request;
|
|
95760
|
+
this.request = this.#originalRequest.clone();
|
|
95761
|
+
if (this.#options.timeout === false) {
|
|
95762
|
+
return this.#options.fetch(this.#originalRequest, nonRequestOptions);
|
|
95763
|
+
}
|
|
95764
|
+
return timeout(this.#originalRequest, nonRequestOptions, this.#abortController, this.#options);
|
|
95765
|
+
}
|
|
95766
|
+
#getNormalizedOptions() {
|
|
95767
|
+
if (!this.#cachedNormalizedOptions) {
|
|
95768
|
+
const { hooks, ...normalizedOptions } = this.#options;
|
|
95769
|
+
this.#cachedNormalizedOptions = Object.freeze(normalizedOptions);
|
|
95770
|
+
}
|
|
95771
|
+
return this.#cachedNormalizedOptions;
|
|
95772
|
+
}
|
|
95773
|
+
#assignRequest(request) {
|
|
95774
|
+
this.#cachedNormalizedOptions = undefined;
|
|
95775
|
+
this.request = this.#wrapRequestWithUploadProgress(request);
|
|
95776
|
+
}
|
|
95777
|
+
#wrapRequestWithUploadProgress(request, originalBody) {
|
|
95778
|
+
if (!this.#options.onUploadProgress || !request.body) {
|
|
95779
|
+
return request;
|
|
95780
|
+
}
|
|
95781
|
+
return streamRequest(request, this.#options.onUploadProgress, originalBody ?? this.#options.body ?? undefined);
|
|
95782
|
+
}
|
|
95783
|
+
}
|
|
95784
|
+
// node_modules/ky/distribution/index.js
|
|
95785
|
+
/*! MIT License © Sindre Sorhus */
|
|
95786
|
+
var createInstance = (defaults) => {
|
|
95787
|
+
const ky = (input, options) => Ky.create(input, validateAndMerge(defaults, options));
|
|
95788
|
+
for (const method of requestMethods) {
|
|
95789
|
+
ky[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));
|
|
95790
|
+
}
|
|
95791
|
+
ky.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));
|
|
95792
|
+
ky.extend = (newDefaults) => {
|
|
95793
|
+
if (typeof newDefaults === "function") {
|
|
95794
|
+
newDefaults = newDefaults(defaults ?? {});
|
|
95795
|
+
}
|
|
95796
|
+
return createInstance(validateAndMerge(defaults, newDefaults));
|
|
95797
|
+
};
|
|
95798
|
+
ky.stop = stop;
|
|
95799
|
+
ky.retry = retry;
|
|
95800
|
+
return ky;
|
|
95801
|
+
};
|
|
95802
|
+
var ky = createInstance();
|
|
95803
|
+
var distribution_default = ky;
|
|
95804
|
+
|
|
95805
|
+
// cli/agent/get-latest-tsci-agent-version.ts
|
|
95806
|
+
var import_semver3 = __toESM2(require_semver2(), 1);
|
|
95807
|
+
async function getLatestTsciAgentVersion() {
|
|
95808
|
+
try {
|
|
95809
|
+
const { version: version2 } = await distribution_default.get(`https://registry.npmjs.org/${TSCI_AGENT_PACKAGE_NAME}/latest`, { throwHttpErrors: false }).json();
|
|
95810
|
+
return version2 && import_semver3.default.valid(version2) ? version2 : null;
|
|
95811
|
+
} catch {
|
|
95812
|
+
return null;
|
|
95813
|
+
}
|
|
95814
|
+
}
|
|
95815
|
+
|
|
95816
|
+
// cli/agent/ensure-latest-tsci-agent.ts
|
|
95817
|
+
async function ensureLatestTsciAgent() {
|
|
95818
|
+
const installedAgent = getInstalledTsciAgentVersion();
|
|
95819
|
+
const latestVersion = await getLatestTsciAgentVersion();
|
|
95820
|
+
if (!latestVersion && installedAgent.isInstalled) {
|
|
95821
|
+
console.warn(kleur_default.yellow("Could not check the latest tsci-agent version. Running the installed tsci-agent."));
|
|
95822
|
+
return true;
|
|
95823
|
+
}
|
|
95824
|
+
const shouldInstall = !installedAgent.isInstalled;
|
|
95825
|
+
const shouldUpdate = Boolean(installedAgent.isInstalled && latestVersion && (!installedAgent.version || import_semver4.default.gt(latestVersion, installedAgent.version)));
|
|
95826
|
+
if (!shouldInstall && !shouldUpdate)
|
|
95827
|
+
return true;
|
|
95828
|
+
const installCommand = getGlobalDepsInstallCommand(getPackageManager().name, `${TSCI_AGENT_PACKAGE_NAME}@latest`);
|
|
95829
|
+
const action = shouldInstall ? "install" : "update";
|
|
95830
|
+
const actionGerund = shouldInstall ? "installing" : "updating";
|
|
95831
|
+
const versionDescription = shouldInstall ? latestVersion ? `v${latestVersion}` : "the latest version" : `${installedAgent.version ?? "unknown"} → ${latestVersion}`;
|
|
95832
|
+
const confirmed = await confirmInstallOrUpdate(`${TSCI_AGENT_PACKAGE_NAME} ${versionDescription} is required. ${action[0].toUpperCase()}${action.slice(1)} it globally using \`${installCommand}\`?`);
|
|
95833
|
+
if (!confirmed) {
|
|
95834
|
+
console.error(kleur_default.red(`Cannot run \`tsci agent\` without ${actionGerund} ${TSCI_AGENT_PACKAGE_NAME}.`));
|
|
95835
|
+
console.error(`You can run this manually: ${installCommand}`);
|
|
95836
|
+
return false;
|
|
95837
|
+
}
|
|
95838
|
+
try {
|
|
95839
|
+
console.log(kleur_default.gray(`> ${installCommand}`));
|
|
95840
|
+
execSync2(installCommand, { stdio: "inherit" });
|
|
95841
|
+
return true;
|
|
95842
|
+
} catch {
|
|
95843
|
+
console.error(kleur_default.red(`Failed to ${action} ${TSCI_AGENT_PACKAGE_NAME}.`));
|
|
95844
|
+
console.error(`You can try running this manually: ${installCommand}`);
|
|
95845
|
+
return false;
|
|
95846
|
+
}
|
|
95847
|
+
}
|
|
95848
|
+
|
|
95849
|
+
// cli/agent/run-tsci-agent.ts
|
|
95850
|
+
import { spawn } from "node:child_process";
|
|
95851
|
+
async function runTsciAgent(args) {
|
|
95852
|
+
return new Promise((resolve) => {
|
|
95853
|
+
const child = spawn(TSCI_AGENT_BINARY_NAME, args, {
|
|
95854
|
+
stdio: "inherit",
|
|
95855
|
+
shell: process.platform === "win32"
|
|
95856
|
+
});
|
|
95857
|
+
child.on("error", (error) => {
|
|
95858
|
+
if (error.code === "ENOENT") {
|
|
95859
|
+
console.error(kleur_default.red(`Could not find ${TSCI_AGENT_BINARY_NAME}. Make sure your global npm bin directory is on PATH.`));
|
|
95860
|
+
} else {
|
|
95861
|
+
console.error(kleur_default.red(`Failed to run ${TSCI_AGENT_BINARY_NAME}: ${error.message}`));
|
|
95862
|
+
}
|
|
95863
|
+
resolve(1);
|
|
95864
|
+
});
|
|
95865
|
+
child.on("close", (code, signal) => {
|
|
95866
|
+
if (signal) {
|
|
95867
|
+
console.error(kleur_default.red(`${TSCI_AGENT_BINARY_NAME} exited with signal ${signal}`));
|
|
95868
|
+
resolve(1);
|
|
95869
|
+
return;
|
|
95870
|
+
}
|
|
95871
|
+
resolve(code ?? 0);
|
|
95872
|
+
});
|
|
95873
|
+
});
|
|
95874
|
+
}
|
|
95875
|
+
|
|
95876
|
+
// cli/agent/register.ts
|
|
95877
|
+
function registerAgent(program2) {
|
|
95878
|
+
program2.command("agent [args...]").description("Install/update and run tsci-agent").allowUnknownOption(true).helpOption(false).action(async (args) => {
|
|
95879
|
+
const canRunAgent = await ensureLatestTsciAgent();
|
|
95880
|
+
if (!canRunAgent) {
|
|
95881
|
+
process.exitCode = 1;
|
|
95882
|
+
return;
|
|
95883
|
+
}
|
|
95884
|
+
process.exitCode = await runTsciAgent(args);
|
|
95885
|
+
});
|
|
95886
|
+
}
|
|
95887
|
+
|
|
94929
95888
|
// node_modules/conf/dist/source/index.js
|
|
94930
95889
|
import { isDeepStrictEqual } from "node:util";
|
|
94931
95890
|
import process9 from "node:process";
|
|
@@ -94935,7 +95894,7 @@ import crypto2 from "node:crypto";
|
|
|
94935
95894
|
import assert from "node:assert";
|
|
94936
95895
|
|
|
94937
95896
|
// node_modules/dot-prop/index.js
|
|
94938
|
-
var
|
|
95897
|
+
var isObject2 = (value) => {
|
|
94939
95898
|
const type = typeof value;
|
|
94940
95899
|
return value !== null && (type === "object" || type === "function");
|
|
94941
95900
|
};
|
|
@@ -95073,7 +96032,7 @@ function assertNotStringIndex(object, key) {
|
|
|
95073
96032
|
}
|
|
95074
96033
|
}
|
|
95075
96034
|
function getProperty(object, path9, value) {
|
|
95076
|
-
if (!
|
|
96035
|
+
if (!isObject2(object) || typeof path9 !== "string") {
|
|
95077
96036
|
return value === undefined ? object : value;
|
|
95078
96037
|
}
|
|
95079
96038
|
const pathArray = getPathSegments(path9);
|
|
@@ -95097,7 +96056,7 @@ function getProperty(object, path9, value) {
|
|
|
95097
96056
|
return object === undefined ? value : object;
|
|
95098
96057
|
}
|
|
95099
96058
|
function setProperty(object, path9, value) {
|
|
95100
|
-
if (!
|
|
96059
|
+
if (!isObject2(object) || typeof path9 !== "string") {
|
|
95101
96060
|
return object;
|
|
95102
96061
|
}
|
|
95103
96062
|
const root = object;
|
|
@@ -95107,7 +96066,7 @@ function setProperty(object, path9, value) {
|
|
|
95107
96066
|
assertNotStringIndex(object, key);
|
|
95108
96067
|
if (index === pathArray.length - 1) {
|
|
95109
96068
|
object[key] = value;
|
|
95110
|
-
} else if (!
|
|
96069
|
+
} else if (!isObject2(object[key])) {
|
|
95111
96070
|
object[key] = typeof pathArray[index + 1] === "number" ? [] : {};
|
|
95112
96071
|
}
|
|
95113
96072
|
object = object[key];
|
|
@@ -95115,7 +96074,7 @@ function setProperty(object, path9, value) {
|
|
|
95115
96074
|
return root;
|
|
95116
96075
|
}
|
|
95117
96076
|
function deleteProperty(object, path9) {
|
|
95118
|
-
if (!
|
|
96077
|
+
if (!isObject2(object) || typeof path9 !== "string") {
|
|
95119
96078
|
return false;
|
|
95120
96079
|
}
|
|
95121
96080
|
const pathArray = getPathSegments(path9);
|
|
@@ -95127,13 +96086,13 @@ function deleteProperty(object, path9) {
|
|
|
95127
96086
|
return true;
|
|
95128
96087
|
}
|
|
95129
96088
|
object = object[key];
|
|
95130
|
-
if (!
|
|
96089
|
+
if (!isObject2(object)) {
|
|
95131
96090
|
return false;
|
|
95132
96091
|
}
|
|
95133
96092
|
}
|
|
95134
96093
|
}
|
|
95135
96094
|
function hasProperty(object, path9) {
|
|
95136
|
-
if (!
|
|
96095
|
+
if (!isObject2(object) || typeof path9 !== "string") {
|
|
95137
96096
|
return false;
|
|
95138
96097
|
}
|
|
95139
96098
|
const pathArray = getPathSegments(path9);
|
|
@@ -95141,7 +96100,7 @@ function hasProperty(object, path9) {
|
|
|
95141
96100
|
return false;
|
|
95142
96101
|
}
|
|
95143
96102
|
for (const key of pathArray) {
|
|
95144
|
-
if (!
|
|
96103
|
+
if (!isObject2(object) || !(key in object) || isStringIndex(object, key)) {
|
|
95145
96104
|
return false;
|
|
95146
96105
|
}
|
|
95147
96106
|
object = object[key];
|
|
@@ -95239,18 +96198,18 @@ var RETRY_INTERVAL = 250;
|
|
|
95239
96198
|
var retryifyAsync = (fn, options) => {
|
|
95240
96199
|
const { isRetriable } = options;
|
|
95241
96200
|
return function retryified(options2) {
|
|
95242
|
-
const { timeout } = options2;
|
|
96201
|
+
const { timeout: timeout2 } = options2;
|
|
95243
96202
|
const interval = options2.interval ?? RETRY_INTERVAL;
|
|
95244
|
-
const timestamp = Date.now() +
|
|
96203
|
+
const timestamp = Date.now() + timeout2;
|
|
95245
96204
|
return function attempt(...args) {
|
|
95246
96205
|
return fn.apply(undefined, args).catch((error) => {
|
|
95247
96206
|
if (!isRetriable(error))
|
|
95248
96207
|
throw error;
|
|
95249
96208
|
if (Date.now() >= timestamp)
|
|
95250
96209
|
throw error;
|
|
95251
|
-
const
|
|
95252
|
-
if (
|
|
95253
|
-
const delayPromise = new Promise((resolve) => setTimeout(resolve,
|
|
96210
|
+
const delay2 = Math.round(interval * Math.random());
|
|
96211
|
+
if (delay2 > 0) {
|
|
96212
|
+
const delayPromise = new Promise((resolve) => setTimeout(resolve, delay2));
|
|
95254
96213
|
return delayPromise.then(() => attempt.apply(undefined, args));
|
|
95255
96214
|
} else {
|
|
95256
96215
|
return attempt.apply(undefined, args);
|
|
@@ -95265,8 +96224,8 @@ var retryify_async_default = retryifyAsync;
|
|
|
95265
96224
|
var retryifySync = (fn, options) => {
|
|
95266
96225
|
const { isRetriable } = options;
|
|
95267
96226
|
return function retryified(options2) {
|
|
95268
|
-
const { timeout } = options2;
|
|
95269
|
-
const timestamp = Date.now() +
|
|
96227
|
+
const { timeout: timeout2 } = options2;
|
|
96228
|
+
const timestamp = Date.now() + timeout2;
|
|
95270
96229
|
return function attempt(...args) {
|
|
95271
96230
|
while (true) {
|
|
95272
96231
|
try {
|
|
@@ -95518,8 +96477,8 @@ var temp_default = Temp;
|
|
|
95518
96477
|
function writeFileSync3(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
|
|
95519
96478
|
if (isString(options))
|
|
95520
96479
|
return writeFileSync3(filePath, data, { encoding: options });
|
|
95521
|
-
const
|
|
95522
|
-
const retryOptions = { timeout };
|
|
96480
|
+
const timeout2 = options.timeout ?? DEFAULT_TIMEOUT_SYNC;
|
|
96481
|
+
const retryOptions = { timeout: timeout2 };
|
|
95523
96482
|
let tempDisposer = null;
|
|
95524
96483
|
let tempPath = null;
|
|
95525
96484
|
let fd = null;
|
|
@@ -95659,13 +96618,13 @@ var debounceFunction = (inputFunction, options = {}) => {
|
|
|
95659
96618
|
if (!before && !after) {
|
|
95660
96619
|
throw new Error("Both `before` and `after` are false, function wouldn't be called.");
|
|
95661
96620
|
}
|
|
95662
|
-
let
|
|
96621
|
+
let timeout2;
|
|
95663
96622
|
let maxTimeout;
|
|
95664
96623
|
let result;
|
|
95665
96624
|
const debouncedFunction = function(...arguments_) {
|
|
95666
96625
|
const context = this;
|
|
95667
96626
|
const later = () => {
|
|
95668
|
-
|
|
96627
|
+
timeout2 = undefined;
|
|
95669
96628
|
if (maxTimeout) {
|
|
95670
96629
|
clearTimeout(maxTimeout);
|
|
95671
96630
|
maxTimeout = undefined;
|
|
@@ -95676,17 +96635,17 @@ var debounceFunction = (inputFunction, options = {}) => {
|
|
|
95676
96635
|
};
|
|
95677
96636
|
const maxLater = () => {
|
|
95678
96637
|
maxTimeout = undefined;
|
|
95679
|
-
if (
|
|
95680
|
-
clearTimeout(
|
|
95681
|
-
|
|
96638
|
+
if (timeout2) {
|
|
96639
|
+
clearTimeout(timeout2);
|
|
96640
|
+
timeout2 = undefined;
|
|
95682
96641
|
}
|
|
95683
96642
|
if (after) {
|
|
95684
96643
|
result = inputFunction.apply(context, arguments_);
|
|
95685
96644
|
}
|
|
95686
96645
|
};
|
|
95687
|
-
const shouldCallNow = before && !
|
|
95688
|
-
clearTimeout(
|
|
95689
|
-
|
|
96646
|
+
const shouldCallNow = before && !timeout2;
|
|
96647
|
+
clearTimeout(timeout2);
|
|
96648
|
+
timeout2 = setTimeout(later, wait);
|
|
95690
96649
|
if (maxWait > 0 && maxWait !== Number.POSITIVE_INFINITY && !maxTimeout) {
|
|
95691
96650
|
maxTimeout = setTimeout(maxLater, maxWait);
|
|
95692
96651
|
}
|
|
@@ -95697,9 +96656,9 @@ var debounceFunction = (inputFunction, options = {}) => {
|
|
|
95697
96656
|
};
|
|
95698
96657
|
mimicFunction(debouncedFunction, inputFunction);
|
|
95699
96658
|
debouncedFunction.cancel = () => {
|
|
95700
|
-
if (
|
|
95701
|
-
clearTimeout(
|
|
95702
|
-
|
|
96659
|
+
if (timeout2) {
|
|
96660
|
+
clearTimeout(timeout2);
|
|
96661
|
+
timeout2 = undefined;
|
|
95703
96662
|
}
|
|
95704
96663
|
if (maxTimeout) {
|
|
95705
96664
|
clearTimeout(maxTimeout);
|
|
@@ -95711,7 +96670,7 @@ var debounceFunction = (inputFunction, options = {}) => {
|
|
|
95711
96670
|
var debounce_fn_default = debounceFunction;
|
|
95712
96671
|
|
|
95713
96672
|
// node_modules/conf/dist/source/index.js
|
|
95714
|
-
var
|
|
96673
|
+
var import_semver5 = __toESM2(require_semver2(), 1);
|
|
95715
96674
|
|
|
95716
96675
|
// node_modules/uint8array-extras/index.js
|
|
95717
96676
|
var objectToString = Object.prototype.toString;
|
|
@@ -96096,7 +97055,7 @@ class Conf {
|
|
|
96096
97055
|
throw new Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${error}`);
|
|
96097
97056
|
}
|
|
96098
97057
|
}
|
|
96099
|
-
if (this._isVersionInRangeFormat(previousMigratedVersion) || !
|
|
97058
|
+
if (this._isVersionInRangeFormat(previousMigratedVersion) || !import_semver5.default.eq(previousMigratedVersion, versionToMigrate)) {
|
|
96100
97059
|
this._set(MIGRATION_KEY, versionToMigrate);
|
|
96101
97060
|
}
|
|
96102
97061
|
}
|
|
@@ -96119,19 +97078,19 @@ class Conf {
|
|
|
96119
97078
|
return false;
|
|
96120
97079
|
}
|
|
96121
97080
|
_isVersionInRangeFormat(version2) {
|
|
96122
|
-
return
|
|
97081
|
+
return import_semver5.default.clean(version2) === null;
|
|
96123
97082
|
}
|
|
96124
97083
|
_shouldPerformMigration(candidateVersion, previousMigratedVersion, versionToMigrate) {
|
|
96125
97084
|
if (this._isVersionInRangeFormat(candidateVersion)) {
|
|
96126
|
-
if (previousMigratedVersion !== "0.0.0" &&
|
|
97085
|
+
if (previousMigratedVersion !== "0.0.0" && import_semver5.default.satisfies(previousMigratedVersion, candidateVersion)) {
|
|
96127
97086
|
return false;
|
|
96128
97087
|
}
|
|
96129
|
-
return
|
|
97088
|
+
return import_semver5.default.satisfies(versionToMigrate, candidateVersion);
|
|
96130
97089
|
}
|
|
96131
|
-
if (
|
|
97090
|
+
if (import_semver5.default.lte(candidateVersion, previousMigratedVersion)) {
|
|
96132
97091
|
return false;
|
|
96133
97092
|
}
|
|
96134
|
-
if (
|
|
97093
|
+
if (import_semver5.default.gt(candidateVersion, versionToMigrate)) {
|
|
96135
97094
|
return false;
|
|
96136
97095
|
}
|
|
96137
97096
|
return true;
|
|
@@ -96293,827 +97252,8 @@ function createDelay({ clearTimeout: defaultClear, setTimeout: defaultSet } = {}
|
|
|
96293
97252
|
return delayPromise;
|
|
96294
97253
|
};
|
|
96295
97254
|
}
|
|
96296
|
-
var
|
|
96297
|
-
var delay_default =
|
|
96298
|
-
|
|
96299
|
-
// node_modules/ky/distribution/errors/HTTPError.js
|
|
96300
|
-
class HTTPError extends Error {
|
|
96301
|
-
response;
|
|
96302
|
-
request;
|
|
96303
|
-
options;
|
|
96304
|
-
constructor(response, request, options) {
|
|
96305
|
-
const code = response.status || response.status === 0 ? response.status : "";
|
|
96306
|
-
const title = response.statusText ?? "";
|
|
96307
|
-
const status = `${code} ${title}`.trim();
|
|
96308
|
-
const reason = status ? `status code ${status}` : "an unknown error";
|
|
96309
|
-
super(`Request failed with ${reason}: ${request.method} ${request.url}`);
|
|
96310
|
-
this.name = "HTTPError";
|
|
96311
|
-
this.response = response;
|
|
96312
|
-
this.request = request;
|
|
96313
|
-
this.options = options;
|
|
96314
|
-
}
|
|
96315
|
-
}
|
|
96316
|
-
|
|
96317
|
-
// node_modules/ky/distribution/errors/NonError.js
|
|
96318
|
-
class NonError extends Error {
|
|
96319
|
-
name = "NonError";
|
|
96320
|
-
value;
|
|
96321
|
-
constructor(value) {
|
|
96322
|
-
let message = "Non-error value was thrown";
|
|
96323
|
-
try {
|
|
96324
|
-
if (typeof value === "string") {
|
|
96325
|
-
message = value;
|
|
96326
|
-
} else if (value && typeof value === "object" && "message" in value && typeof value.message === "string") {
|
|
96327
|
-
message = value.message;
|
|
96328
|
-
}
|
|
96329
|
-
} catch {}
|
|
96330
|
-
super(message);
|
|
96331
|
-
this.value = value;
|
|
96332
|
-
}
|
|
96333
|
-
}
|
|
96334
|
-
|
|
96335
|
-
// node_modules/ky/distribution/errors/ForceRetryError.js
|
|
96336
|
-
class ForceRetryError extends Error {
|
|
96337
|
-
name = "ForceRetryError";
|
|
96338
|
-
customDelay;
|
|
96339
|
-
code;
|
|
96340
|
-
customRequest;
|
|
96341
|
-
constructor(options) {
|
|
96342
|
-
const cause = options?.cause ? options.cause instanceof Error ? options.cause : new NonError(options.cause) : undefined;
|
|
96343
|
-
super(options?.code ? `Forced retry: ${options.code}` : "Forced retry", cause ? { cause } : undefined);
|
|
96344
|
-
this.customDelay = options?.delay;
|
|
96345
|
-
this.code = options?.code;
|
|
96346
|
-
this.customRequest = options?.request;
|
|
96347
|
-
}
|
|
96348
|
-
}
|
|
96349
|
-
|
|
96350
|
-
// node_modules/ky/distribution/core/constants.js
|
|
96351
|
-
var supportsRequestStreams = (() => {
|
|
96352
|
-
let duplexAccessed = false;
|
|
96353
|
-
let hasContentType = false;
|
|
96354
|
-
const supportsReadableStream = typeof globalThis.ReadableStream === "function";
|
|
96355
|
-
const supportsRequest = typeof globalThis.Request === "function";
|
|
96356
|
-
if (supportsReadableStream && supportsRequest) {
|
|
96357
|
-
try {
|
|
96358
|
-
hasContentType = new globalThis.Request("https://empty.invalid", {
|
|
96359
|
-
body: new globalThis.ReadableStream,
|
|
96360
|
-
method: "POST",
|
|
96361
|
-
get duplex() {
|
|
96362
|
-
duplexAccessed = true;
|
|
96363
|
-
return "half";
|
|
96364
|
-
}
|
|
96365
|
-
}).headers.has("Content-Type");
|
|
96366
|
-
} catch (error) {
|
|
96367
|
-
if (error instanceof Error && error.message === "unsupported BodyInit type") {
|
|
96368
|
-
return false;
|
|
96369
|
-
}
|
|
96370
|
-
throw error;
|
|
96371
|
-
}
|
|
96372
|
-
}
|
|
96373
|
-
return duplexAccessed && !hasContentType;
|
|
96374
|
-
})();
|
|
96375
|
-
var supportsAbortController = typeof globalThis.AbortController === "function";
|
|
96376
|
-
var supportsAbortSignal = typeof globalThis.AbortSignal === "function" && typeof globalThis.AbortSignal.any === "function";
|
|
96377
|
-
var supportsResponseStreams = typeof globalThis.ReadableStream === "function";
|
|
96378
|
-
var supportsFormData = typeof globalThis.FormData === "function";
|
|
96379
|
-
var requestMethods = ["get", "post", "put", "patch", "head", "delete"];
|
|
96380
|
-
var validate = () => {
|
|
96381
|
-
return;
|
|
96382
|
-
};
|
|
96383
|
-
validate();
|
|
96384
|
-
var responseTypes = {
|
|
96385
|
-
json: "application/json",
|
|
96386
|
-
text: "text/*",
|
|
96387
|
-
formData: "multipart/form-data",
|
|
96388
|
-
arrayBuffer: "*/*",
|
|
96389
|
-
blob: "*/*",
|
|
96390
|
-
bytes: "*/*"
|
|
96391
|
-
};
|
|
96392
|
-
var maxSafeTimeout = 2147483647;
|
|
96393
|
-
var usualFormBoundarySize = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length;
|
|
96394
|
-
var stop = Symbol("stop");
|
|
96395
|
-
|
|
96396
|
-
class RetryMarker {
|
|
96397
|
-
options;
|
|
96398
|
-
constructor(options) {
|
|
96399
|
-
this.options = options;
|
|
96400
|
-
}
|
|
96401
|
-
}
|
|
96402
|
-
var retry = (options) => new RetryMarker(options);
|
|
96403
|
-
var kyOptionKeys = {
|
|
96404
|
-
json: true,
|
|
96405
|
-
parseJson: true,
|
|
96406
|
-
stringifyJson: true,
|
|
96407
|
-
searchParams: true,
|
|
96408
|
-
prefixUrl: true,
|
|
96409
|
-
retry: true,
|
|
96410
|
-
timeout: true,
|
|
96411
|
-
hooks: true,
|
|
96412
|
-
throwHttpErrors: true,
|
|
96413
|
-
onDownloadProgress: true,
|
|
96414
|
-
onUploadProgress: true,
|
|
96415
|
-
fetch: true,
|
|
96416
|
-
context: true
|
|
96417
|
-
};
|
|
96418
|
-
var vendorSpecificOptions = {
|
|
96419
|
-
next: true
|
|
96420
|
-
};
|
|
96421
|
-
var requestOptionsRegistry = {
|
|
96422
|
-
method: true,
|
|
96423
|
-
headers: true,
|
|
96424
|
-
body: true,
|
|
96425
|
-
mode: true,
|
|
96426
|
-
credentials: true,
|
|
96427
|
-
cache: true,
|
|
96428
|
-
redirect: true,
|
|
96429
|
-
referrer: true,
|
|
96430
|
-
referrerPolicy: true,
|
|
96431
|
-
integrity: true,
|
|
96432
|
-
keepalive: true,
|
|
96433
|
-
signal: true,
|
|
96434
|
-
window: true,
|
|
96435
|
-
duplex: true
|
|
96436
|
-
};
|
|
96437
|
-
|
|
96438
|
-
// node_modules/ky/distribution/utils/body.js
|
|
96439
|
-
var getBodySize = (body) => {
|
|
96440
|
-
if (!body) {
|
|
96441
|
-
return 0;
|
|
96442
|
-
}
|
|
96443
|
-
if (body instanceof FormData) {
|
|
96444
|
-
let size = 0;
|
|
96445
|
-
for (const [key, value] of body) {
|
|
96446
|
-
size += usualFormBoundarySize;
|
|
96447
|
-
size += new TextEncoder().encode(`Content-Disposition: form-data; name="${key}"`).length;
|
|
96448
|
-
size += typeof value === "string" ? new TextEncoder().encode(value).length : value.size;
|
|
96449
|
-
}
|
|
96450
|
-
return size;
|
|
96451
|
-
}
|
|
96452
|
-
if (body instanceof Blob) {
|
|
96453
|
-
return body.size;
|
|
96454
|
-
}
|
|
96455
|
-
if (body instanceof ArrayBuffer) {
|
|
96456
|
-
return body.byteLength;
|
|
96457
|
-
}
|
|
96458
|
-
if (typeof body === "string") {
|
|
96459
|
-
return new TextEncoder().encode(body).length;
|
|
96460
|
-
}
|
|
96461
|
-
if (body instanceof URLSearchParams) {
|
|
96462
|
-
return new TextEncoder().encode(body.toString()).length;
|
|
96463
|
-
}
|
|
96464
|
-
if ("byteLength" in body) {
|
|
96465
|
-
return body.byteLength;
|
|
96466
|
-
}
|
|
96467
|
-
if (typeof body === "object" && body !== null) {
|
|
96468
|
-
try {
|
|
96469
|
-
const jsonString = JSON.stringify(body);
|
|
96470
|
-
return new TextEncoder().encode(jsonString).length;
|
|
96471
|
-
} catch {
|
|
96472
|
-
return 0;
|
|
96473
|
-
}
|
|
96474
|
-
}
|
|
96475
|
-
return 0;
|
|
96476
|
-
};
|
|
96477
|
-
var withProgress = (stream, totalBytes, onProgress) => {
|
|
96478
|
-
let previousChunk;
|
|
96479
|
-
let transferredBytes = 0;
|
|
96480
|
-
return stream.pipeThrough(new TransformStream({
|
|
96481
|
-
transform(currentChunk, controller) {
|
|
96482
|
-
controller.enqueue(currentChunk);
|
|
96483
|
-
if (previousChunk) {
|
|
96484
|
-
transferredBytes += previousChunk.byteLength;
|
|
96485
|
-
let percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
|
|
96486
|
-
if (percent >= 1) {
|
|
96487
|
-
percent = 1 - Number.EPSILON;
|
|
96488
|
-
}
|
|
96489
|
-
onProgress?.({ percent, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
|
|
96490
|
-
}
|
|
96491
|
-
previousChunk = currentChunk;
|
|
96492
|
-
},
|
|
96493
|
-
flush() {
|
|
96494
|
-
if (previousChunk) {
|
|
96495
|
-
transferredBytes += previousChunk.byteLength;
|
|
96496
|
-
onProgress?.({ percent: 1, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
|
|
96497
|
-
}
|
|
96498
|
-
}
|
|
96499
|
-
}));
|
|
96500
|
-
};
|
|
96501
|
-
var streamResponse = (response, onDownloadProgress) => {
|
|
96502
|
-
if (!response.body) {
|
|
96503
|
-
return response;
|
|
96504
|
-
}
|
|
96505
|
-
if (response.status === 204) {
|
|
96506
|
-
return new Response(null, {
|
|
96507
|
-
status: response.status,
|
|
96508
|
-
statusText: response.statusText,
|
|
96509
|
-
headers: response.headers
|
|
96510
|
-
});
|
|
96511
|
-
}
|
|
96512
|
-
const totalBytes = Math.max(0, Number(response.headers.get("content-length")) || 0);
|
|
96513
|
-
return new Response(withProgress(response.body, totalBytes, onDownloadProgress), {
|
|
96514
|
-
status: response.status,
|
|
96515
|
-
statusText: response.statusText,
|
|
96516
|
-
headers: response.headers
|
|
96517
|
-
});
|
|
96518
|
-
};
|
|
96519
|
-
var streamRequest = (request, onUploadProgress, originalBody) => {
|
|
96520
|
-
if (!request.body) {
|
|
96521
|
-
return request;
|
|
96522
|
-
}
|
|
96523
|
-
const totalBytes = getBodySize(originalBody ?? request.body);
|
|
96524
|
-
return new Request(request, {
|
|
96525
|
-
duplex: "half",
|
|
96526
|
-
body: withProgress(request.body, totalBytes, onUploadProgress)
|
|
96527
|
-
});
|
|
96528
|
-
};
|
|
96529
|
-
|
|
96530
|
-
// node_modules/ky/distribution/utils/is.js
|
|
96531
|
-
var isObject2 = (value) => value !== null && typeof value === "object";
|
|
96532
|
-
|
|
96533
|
-
// node_modules/ky/distribution/utils/merge.js
|
|
96534
|
-
var validateAndMerge = (...sources) => {
|
|
96535
|
-
for (const source of sources) {
|
|
96536
|
-
if ((!isObject2(source) || Array.isArray(source)) && source !== undefined) {
|
|
96537
|
-
throw new TypeError("The `options` argument must be an object");
|
|
96538
|
-
}
|
|
96539
|
-
}
|
|
96540
|
-
return deepMerge({}, ...sources);
|
|
96541
|
-
};
|
|
96542
|
-
var mergeHeaders = (source1 = {}, source2 = {}) => {
|
|
96543
|
-
const result = new globalThis.Headers(source1);
|
|
96544
|
-
const isHeadersInstance = source2 instanceof globalThis.Headers;
|
|
96545
|
-
const source = new globalThis.Headers(source2);
|
|
96546
|
-
for (const [key, value] of source.entries()) {
|
|
96547
|
-
if (isHeadersInstance && value === "undefined" || value === undefined) {
|
|
96548
|
-
result.delete(key);
|
|
96549
|
-
} else {
|
|
96550
|
-
result.set(key, value);
|
|
96551
|
-
}
|
|
96552
|
-
}
|
|
96553
|
-
return result;
|
|
96554
|
-
};
|
|
96555
|
-
function newHookValue(original, incoming, property) {
|
|
96556
|
-
return Object.hasOwn(incoming, property) && incoming[property] === undefined ? [] : deepMerge(original[property] ?? [], incoming[property] ?? []);
|
|
96557
|
-
}
|
|
96558
|
-
var mergeHooks = (original = {}, incoming = {}) => ({
|
|
96559
|
-
beforeRequest: newHookValue(original, incoming, "beforeRequest"),
|
|
96560
|
-
beforeRetry: newHookValue(original, incoming, "beforeRetry"),
|
|
96561
|
-
afterResponse: newHookValue(original, incoming, "afterResponse"),
|
|
96562
|
-
beforeError: newHookValue(original, incoming, "beforeError")
|
|
96563
|
-
});
|
|
96564
|
-
var appendSearchParameters = (target, source) => {
|
|
96565
|
-
const result = new URLSearchParams;
|
|
96566
|
-
for (const input of [target, source]) {
|
|
96567
|
-
if (input === undefined) {
|
|
96568
|
-
continue;
|
|
96569
|
-
}
|
|
96570
|
-
if (input instanceof URLSearchParams) {
|
|
96571
|
-
for (const [key, value] of input.entries()) {
|
|
96572
|
-
result.append(key, value);
|
|
96573
|
-
}
|
|
96574
|
-
} else if (Array.isArray(input)) {
|
|
96575
|
-
for (const pair of input) {
|
|
96576
|
-
if (!Array.isArray(pair) || pair.length !== 2) {
|
|
96577
|
-
throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
|
|
96578
|
-
}
|
|
96579
|
-
result.append(String(pair[0]), String(pair[1]));
|
|
96580
|
-
}
|
|
96581
|
-
} else if (isObject2(input)) {
|
|
96582
|
-
for (const [key, value] of Object.entries(input)) {
|
|
96583
|
-
if (value !== undefined) {
|
|
96584
|
-
result.append(key, String(value));
|
|
96585
|
-
}
|
|
96586
|
-
}
|
|
96587
|
-
} else {
|
|
96588
|
-
const parameters = new URLSearchParams(input);
|
|
96589
|
-
for (const [key, value] of parameters.entries()) {
|
|
96590
|
-
result.append(key, value);
|
|
96591
|
-
}
|
|
96592
|
-
}
|
|
96593
|
-
}
|
|
96594
|
-
return result;
|
|
96595
|
-
};
|
|
96596
|
-
var deepMerge = (...sources) => {
|
|
96597
|
-
let returnValue = {};
|
|
96598
|
-
let headers = {};
|
|
96599
|
-
let hooks = {};
|
|
96600
|
-
let searchParameters;
|
|
96601
|
-
const signals = [];
|
|
96602
|
-
for (const source of sources) {
|
|
96603
|
-
if (Array.isArray(source)) {
|
|
96604
|
-
if (!Array.isArray(returnValue)) {
|
|
96605
|
-
returnValue = [];
|
|
96606
|
-
}
|
|
96607
|
-
returnValue = [...returnValue, ...source];
|
|
96608
|
-
} else if (isObject2(source)) {
|
|
96609
|
-
for (let [key, value] of Object.entries(source)) {
|
|
96610
|
-
if (key === "signal" && value instanceof globalThis.AbortSignal) {
|
|
96611
|
-
signals.push(value);
|
|
96612
|
-
continue;
|
|
96613
|
-
}
|
|
96614
|
-
if (key === "context") {
|
|
96615
|
-
if (value !== undefined && value !== null && (!isObject2(value) || Array.isArray(value))) {
|
|
96616
|
-
throw new TypeError("The `context` option must be an object");
|
|
96617
|
-
}
|
|
96618
|
-
returnValue = {
|
|
96619
|
-
...returnValue,
|
|
96620
|
-
context: value === undefined || value === null ? {} : { ...returnValue.context, ...value }
|
|
96621
|
-
};
|
|
96622
|
-
continue;
|
|
96623
|
-
}
|
|
96624
|
-
if (key === "searchParams") {
|
|
96625
|
-
if (value === undefined || value === null) {
|
|
96626
|
-
searchParameters = undefined;
|
|
96627
|
-
} else {
|
|
96628
|
-
searchParameters = searchParameters === undefined ? value : appendSearchParameters(searchParameters, value);
|
|
96629
|
-
}
|
|
96630
|
-
continue;
|
|
96631
|
-
}
|
|
96632
|
-
if (isObject2(value) && key in returnValue) {
|
|
96633
|
-
value = deepMerge(returnValue[key], value);
|
|
96634
|
-
}
|
|
96635
|
-
returnValue = { ...returnValue, [key]: value };
|
|
96636
|
-
}
|
|
96637
|
-
if (isObject2(source.hooks)) {
|
|
96638
|
-
hooks = mergeHooks(hooks, source.hooks);
|
|
96639
|
-
returnValue.hooks = hooks;
|
|
96640
|
-
}
|
|
96641
|
-
if (isObject2(source.headers)) {
|
|
96642
|
-
headers = mergeHeaders(headers, source.headers);
|
|
96643
|
-
returnValue.headers = headers;
|
|
96644
|
-
}
|
|
96645
|
-
}
|
|
96646
|
-
}
|
|
96647
|
-
if (searchParameters !== undefined) {
|
|
96648
|
-
returnValue.searchParams = searchParameters;
|
|
96649
|
-
}
|
|
96650
|
-
if (signals.length > 0) {
|
|
96651
|
-
if (signals.length === 1) {
|
|
96652
|
-
returnValue.signal = signals[0];
|
|
96653
|
-
} else if (supportsAbortSignal) {
|
|
96654
|
-
returnValue.signal = AbortSignal.any(signals);
|
|
96655
|
-
} else {
|
|
96656
|
-
returnValue.signal = signals.at(-1);
|
|
96657
|
-
}
|
|
96658
|
-
}
|
|
96659
|
-
return returnValue;
|
|
96660
|
-
};
|
|
96661
|
-
|
|
96662
|
-
// node_modules/ky/distribution/utils/normalize.js
|
|
96663
|
-
var normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;
|
|
96664
|
-
var retryMethods = ["get", "put", "head", "delete", "options", "trace"];
|
|
96665
|
-
var retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
|
|
96666
|
-
var retryAfterStatusCodes = [413, 429, 503];
|
|
96667
|
-
var defaultRetryOptions = {
|
|
96668
|
-
limit: 2,
|
|
96669
|
-
methods: retryMethods,
|
|
96670
|
-
statusCodes: retryStatusCodes,
|
|
96671
|
-
afterStatusCodes: retryAfterStatusCodes,
|
|
96672
|
-
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
96673
|
-
backoffLimit: Number.POSITIVE_INFINITY,
|
|
96674
|
-
delay: (attemptCount) => 0.3 * 2 ** (attemptCount - 1) * 1000,
|
|
96675
|
-
jitter: undefined,
|
|
96676
|
-
retryOnTimeout: false
|
|
96677
|
-
};
|
|
96678
|
-
var normalizeRetryOptions = (retry2 = {}) => {
|
|
96679
|
-
if (typeof retry2 === "number") {
|
|
96680
|
-
return {
|
|
96681
|
-
...defaultRetryOptions,
|
|
96682
|
-
limit: retry2
|
|
96683
|
-
};
|
|
96684
|
-
}
|
|
96685
|
-
if (retry2.methods && !Array.isArray(retry2.methods)) {
|
|
96686
|
-
throw new Error("retry.methods must be an array");
|
|
96687
|
-
}
|
|
96688
|
-
retry2.methods &&= retry2.methods.map((method) => method.toLowerCase());
|
|
96689
|
-
if (retry2.statusCodes && !Array.isArray(retry2.statusCodes)) {
|
|
96690
|
-
throw new Error("retry.statusCodes must be an array");
|
|
96691
|
-
}
|
|
96692
|
-
const normalizedRetry = Object.fromEntries(Object.entries(retry2).filter(([, value]) => value !== undefined));
|
|
96693
|
-
return {
|
|
96694
|
-
...defaultRetryOptions,
|
|
96695
|
-
...normalizedRetry
|
|
96696
|
-
};
|
|
96697
|
-
};
|
|
96698
|
-
|
|
96699
|
-
// node_modules/ky/distribution/errors/TimeoutError.js
|
|
96700
|
-
class TimeoutError extends Error {
|
|
96701
|
-
request;
|
|
96702
|
-
constructor(request) {
|
|
96703
|
-
super(`Request timed out: ${request.method} ${request.url}`);
|
|
96704
|
-
this.name = "TimeoutError";
|
|
96705
|
-
this.request = request;
|
|
96706
|
-
}
|
|
96707
|
-
}
|
|
96708
|
-
|
|
96709
|
-
// node_modules/ky/distribution/utils/timeout.js
|
|
96710
|
-
async function timeout(request, init2, abortController, options) {
|
|
96711
|
-
return new Promise((resolve, reject) => {
|
|
96712
|
-
const timeoutId = setTimeout(() => {
|
|
96713
|
-
if (abortController) {
|
|
96714
|
-
abortController.abort();
|
|
96715
|
-
}
|
|
96716
|
-
reject(new TimeoutError(request));
|
|
96717
|
-
}, options.timeout);
|
|
96718
|
-
options.fetch(request, init2).then(resolve).catch(reject).then(() => {
|
|
96719
|
-
clearTimeout(timeoutId);
|
|
96720
|
-
});
|
|
96721
|
-
});
|
|
96722
|
-
}
|
|
96723
|
-
|
|
96724
|
-
// node_modules/ky/distribution/utils/delay.js
|
|
96725
|
-
async function delay2(ms, { signal }) {
|
|
96726
|
-
return new Promise((resolve, reject) => {
|
|
96727
|
-
if (signal) {
|
|
96728
|
-
signal.throwIfAborted();
|
|
96729
|
-
signal.addEventListener("abort", abortHandler, { once: true });
|
|
96730
|
-
}
|
|
96731
|
-
function abortHandler() {
|
|
96732
|
-
clearTimeout(timeoutId);
|
|
96733
|
-
reject(signal.reason);
|
|
96734
|
-
}
|
|
96735
|
-
const timeoutId = setTimeout(() => {
|
|
96736
|
-
signal?.removeEventListener("abort", abortHandler);
|
|
96737
|
-
resolve();
|
|
96738
|
-
}, ms);
|
|
96739
|
-
});
|
|
96740
|
-
}
|
|
96741
|
-
|
|
96742
|
-
// node_modules/ky/distribution/utils/options.js
|
|
96743
|
-
var findUnknownOptions = (request, options) => {
|
|
96744
|
-
const unknownOptions = {};
|
|
96745
|
-
for (const key in options) {
|
|
96746
|
-
if (!Object.hasOwn(options, key)) {
|
|
96747
|
-
continue;
|
|
96748
|
-
}
|
|
96749
|
-
if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && (!(key in request) || (key in vendorSpecificOptions))) {
|
|
96750
|
-
unknownOptions[key] = options[key];
|
|
96751
|
-
}
|
|
96752
|
-
}
|
|
96753
|
-
return unknownOptions;
|
|
96754
|
-
};
|
|
96755
|
-
var hasSearchParameters = (search) => {
|
|
96756
|
-
if (search === undefined) {
|
|
96757
|
-
return false;
|
|
96758
|
-
}
|
|
96759
|
-
if (Array.isArray(search)) {
|
|
96760
|
-
return search.length > 0;
|
|
96761
|
-
}
|
|
96762
|
-
if (search instanceof URLSearchParams) {
|
|
96763
|
-
return search.size > 0;
|
|
96764
|
-
}
|
|
96765
|
-
if (typeof search === "object") {
|
|
96766
|
-
return Object.keys(search).length > 0;
|
|
96767
|
-
}
|
|
96768
|
-
if (typeof search === "string") {
|
|
96769
|
-
return search.trim().length > 0;
|
|
96770
|
-
}
|
|
96771
|
-
return Boolean(search);
|
|
96772
|
-
};
|
|
96773
|
-
|
|
96774
|
-
// node_modules/ky/distribution/utils/type-guards.js
|
|
96775
|
-
function isHTTPError(error) {
|
|
96776
|
-
return error instanceof HTTPError || error?.name === HTTPError.name;
|
|
96777
|
-
}
|
|
96778
|
-
function isTimeoutError(error) {
|
|
96779
|
-
return error instanceof TimeoutError || error?.name === TimeoutError.name;
|
|
96780
|
-
}
|
|
96781
|
-
|
|
96782
|
-
// node_modules/ky/distribution/core/Ky.js
|
|
96783
|
-
class Ky {
|
|
96784
|
-
static create(input, options) {
|
|
96785
|
-
const ky = new Ky(input, options);
|
|
96786
|
-
const function_ = async () => {
|
|
96787
|
-
if (typeof ky.#options.timeout === "number" && ky.#options.timeout > maxSafeTimeout) {
|
|
96788
|
-
throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
|
|
96789
|
-
}
|
|
96790
|
-
await Promise.resolve();
|
|
96791
|
-
let response = await ky.#fetch();
|
|
96792
|
-
for (const hook of ky.#options.hooks.afterResponse) {
|
|
96793
|
-
const clonedResponse = ky.#decorateResponse(response.clone());
|
|
96794
|
-
let modifiedResponse;
|
|
96795
|
-
try {
|
|
96796
|
-
modifiedResponse = await hook(ky.request, ky.#getNormalizedOptions(), clonedResponse, { retryCount: ky.#retryCount });
|
|
96797
|
-
} catch (error) {
|
|
96798
|
-
ky.#cancelResponseBody(clonedResponse);
|
|
96799
|
-
ky.#cancelResponseBody(response);
|
|
96800
|
-
throw error;
|
|
96801
|
-
}
|
|
96802
|
-
if (modifiedResponse instanceof RetryMarker) {
|
|
96803
|
-
ky.#cancelResponseBody(clonedResponse);
|
|
96804
|
-
ky.#cancelResponseBody(response);
|
|
96805
|
-
throw new ForceRetryError(modifiedResponse.options);
|
|
96806
|
-
}
|
|
96807
|
-
const nextResponse = modifiedResponse instanceof globalThis.Response ? modifiedResponse : response;
|
|
96808
|
-
if (clonedResponse !== nextResponse) {
|
|
96809
|
-
ky.#cancelResponseBody(clonedResponse);
|
|
96810
|
-
}
|
|
96811
|
-
if (response !== nextResponse) {
|
|
96812
|
-
ky.#cancelResponseBody(response);
|
|
96813
|
-
}
|
|
96814
|
-
response = nextResponse;
|
|
96815
|
-
}
|
|
96816
|
-
ky.#decorateResponse(response);
|
|
96817
|
-
if (!response.ok && (typeof ky.#options.throwHttpErrors === "function" ? ky.#options.throwHttpErrors(response.status) : ky.#options.throwHttpErrors)) {
|
|
96818
|
-
let error = new HTTPError(response, ky.request, ky.#getNormalizedOptions());
|
|
96819
|
-
for (const hook of ky.#options.hooks.beforeError) {
|
|
96820
|
-
error = await hook(error, { retryCount: ky.#retryCount });
|
|
96821
|
-
}
|
|
96822
|
-
throw error;
|
|
96823
|
-
}
|
|
96824
|
-
if (ky.#options.onDownloadProgress) {
|
|
96825
|
-
if (typeof ky.#options.onDownloadProgress !== "function") {
|
|
96826
|
-
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
96827
|
-
}
|
|
96828
|
-
if (!supportsResponseStreams) {
|
|
96829
|
-
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
96830
|
-
}
|
|
96831
|
-
const progressResponse = response.clone();
|
|
96832
|
-
ky.#cancelResponseBody(response);
|
|
96833
|
-
return streamResponse(progressResponse, ky.#options.onDownloadProgress);
|
|
96834
|
-
}
|
|
96835
|
-
return response;
|
|
96836
|
-
};
|
|
96837
|
-
const result = ky.#retry(function_).finally(() => {
|
|
96838
|
-
const originalRequest = ky.#originalRequest;
|
|
96839
|
-
ky.#cancelBody(originalRequest?.body ?? undefined);
|
|
96840
|
-
ky.#cancelBody(ky.request.body ?? undefined);
|
|
96841
|
-
});
|
|
96842
|
-
for (const [type, mimeType] of Object.entries(responseTypes)) {
|
|
96843
|
-
if (type === "bytes" && typeof globalThis.Response?.prototype?.bytes !== "function") {
|
|
96844
|
-
continue;
|
|
96845
|
-
}
|
|
96846
|
-
result[type] = async () => {
|
|
96847
|
-
ky.request.headers.set("accept", ky.request.headers.get("accept") || mimeType);
|
|
96848
|
-
const response = await result;
|
|
96849
|
-
if (type === "json") {
|
|
96850
|
-
if (response.status === 204) {
|
|
96851
|
-
return "";
|
|
96852
|
-
}
|
|
96853
|
-
const text = await response.text();
|
|
96854
|
-
if (text === "") {
|
|
96855
|
-
return "";
|
|
96856
|
-
}
|
|
96857
|
-
if (options.parseJson) {
|
|
96858
|
-
return options.parseJson(text);
|
|
96859
|
-
}
|
|
96860
|
-
return JSON.parse(text);
|
|
96861
|
-
}
|
|
96862
|
-
return response[type]();
|
|
96863
|
-
};
|
|
96864
|
-
}
|
|
96865
|
-
return result;
|
|
96866
|
-
}
|
|
96867
|
-
static #normalizeSearchParams(searchParams) {
|
|
96868
|
-
if (searchParams && typeof searchParams === "object" && !Array.isArray(searchParams) && !(searchParams instanceof URLSearchParams)) {
|
|
96869
|
-
return Object.fromEntries(Object.entries(searchParams).filter(([, value]) => value !== undefined));
|
|
96870
|
-
}
|
|
96871
|
-
return searchParams;
|
|
96872
|
-
}
|
|
96873
|
-
request;
|
|
96874
|
-
#abortController;
|
|
96875
|
-
#retryCount = 0;
|
|
96876
|
-
#input;
|
|
96877
|
-
#options;
|
|
96878
|
-
#originalRequest;
|
|
96879
|
-
#userProvidedAbortSignal;
|
|
96880
|
-
#cachedNormalizedOptions;
|
|
96881
|
-
constructor(input, options = {}) {
|
|
96882
|
-
this.#input = input;
|
|
96883
|
-
this.#options = {
|
|
96884
|
-
...options,
|
|
96885
|
-
headers: mergeHeaders(this.#input.headers, options.headers),
|
|
96886
|
-
hooks: mergeHooks({
|
|
96887
|
-
beforeRequest: [],
|
|
96888
|
-
beforeRetry: [],
|
|
96889
|
-
beforeError: [],
|
|
96890
|
-
afterResponse: []
|
|
96891
|
-
}, options.hooks),
|
|
96892
|
-
method: normalizeRequestMethod(options.method ?? this.#input.method ?? "GET"),
|
|
96893
|
-
prefixUrl: String(options.prefixUrl || ""),
|
|
96894
|
-
retry: normalizeRetryOptions(options.retry),
|
|
96895
|
-
throwHttpErrors: options.throwHttpErrors ?? true,
|
|
96896
|
-
timeout: options.timeout ?? 1e4,
|
|
96897
|
-
fetch: options.fetch ?? globalThis.fetch.bind(globalThis),
|
|
96898
|
-
context: options.context ?? {}
|
|
96899
|
-
};
|
|
96900
|
-
if (typeof this.#input !== "string" && !(this.#input instanceof URL || this.#input instanceof globalThis.Request)) {
|
|
96901
|
-
throw new TypeError("`input` must be a string, URL, or Request");
|
|
96902
|
-
}
|
|
96903
|
-
if (this.#options.prefixUrl && typeof this.#input === "string") {
|
|
96904
|
-
if (this.#input.startsWith("/")) {
|
|
96905
|
-
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
96906
|
-
}
|
|
96907
|
-
if (!this.#options.prefixUrl.endsWith("/")) {
|
|
96908
|
-
this.#options.prefixUrl += "/";
|
|
96909
|
-
}
|
|
96910
|
-
this.#input = this.#options.prefixUrl + this.#input;
|
|
96911
|
-
}
|
|
96912
|
-
if (supportsAbortController && supportsAbortSignal) {
|
|
96913
|
-
this.#userProvidedAbortSignal = this.#options.signal ?? this.#input.signal;
|
|
96914
|
-
this.#abortController = new globalThis.AbortController;
|
|
96915
|
-
this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
|
|
96916
|
-
}
|
|
96917
|
-
if (supportsRequestStreams) {
|
|
96918
|
-
this.#options.duplex = "half";
|
|
96919
|
-
}
|
|
96920
|
-
if (this.#options.json !== undefined) {
|
|
96921
|
-
this.#options.body = this.#options.stringifyJson?.(this.#options.json) ?? JSON.stringify(this.#options.json);
|
|
96922
|
-
this.#options.headers.set("content-type", this.#options.headers.get("content-type") ?? "application/json");
|
|
96923
|
-
}
|
|
96924
|
-
const userProvidedContentType = options.headers && new globalThis.Headers(options.headers).has("content-type");
|
|
96925
|
-
if (this.#input instanceof globalThis.Request && (supportsFormData && this.#options.body instanceof globalThis.FormData || this.#options.body instanceof URLSearchParams) && !userProvidedContentType) {
|
|
96926
|
-
this.#options.headers.delete("content-type");
|
|
96927
|
-
}
|
|
96928
|
-
this.request = new globalThis.Request(this.#input, this.#options);
|
|
96929
|
-
if (hasSearchParameters(this.#options.searchParams)) {
|
|
96930
|
-
const textSearchParams = typeof this.#options.searchParams === "string" ? this.#options.searchParams.replace(/^\?/, "") : new URLSearchParams(Ky.#normalizeSearchParams(this.#options.searchParams)).toString();
|
|
96931
|
-
const searchParams = "?" + textSearchParams;
|
|
96932
|
-
const url = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, searchParams);
|
|
96933
|
-
this.request = new globalThis.Request(url, this.#options);
|
|
96934
|
-
}
|
|
96935
|
-
if (this.#options.onUploadProgress) {
|
|
96936
|
-
if (typeof this.#options.onUploadProgress !== "function") {
|
|
96937
|
-
throw new TypeError("The `onUploadProgress` option must be a function");
|
|
96938
|
-
}
|
|
96939
|
-
if (!supportsRequestStreams) {
|
|
96940
|
-
throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
|
|
96941
|
-
}
|
|
96942
|
-
this.request = this.#wrapRequestWithUploadProgress(this.request, this.#options.body ?? undefined);
|
|
96943
|
-
}
|
|
96944
|
-
}
|
|
96945
|
-
#calculateDelay() {
|
|
96946
|
-
const retryDelay = this.#options.retry.delay(this.#retryCount);
|
|
96947
|
-
let jitteredDelay = retryDelay;
|
|
96948
|
-
if (this.#options.retry.jitter === true) {
|
|
96949
|
-
jitteredDelay = Math.random() * retryDelay;
|
|
96950
|
-
} else if (typeof this.#options.retry.jitter === "function") {
|
|
96951
|
-
jitteredDelay = this.#options.retry.jitter(retryDelay);
|
|
96952
|
-
if (!Number.isFinite(jitteredDelay) || jitteredDelay < 0) {
|
|
96953
|
-
jitteredDelay = retryDelay;
|
|
96954
|
-
}
|
|
96955
|
-
}
|
|
96956
|
-
const backoffLimit = this.#options.retry.backoffLimit ?? Number.POSITIVE_INFINITY;
|
|
96957
|
-
return Math.min(backoffLimit, jitteredDelay);
|
|
96958
|
-
}
|
|
96959
|
-
async#calculateRetryDelay(error) {
|
|
96960
|
-
this.#retryCount++;
|
|
96961
|
-
if (this.#retryCount > this.#options.retry.limit) {
|
|
96962
|
-
throw error;
|
|
96963
|
-
}
|
|
96964
|
-
const errorObject = error instanceof Error ? error : new NonError(error);
|
|
96965
|
-
if (errorObject instanceof ForceRetryError) {
|
|
96966
|
-
return errorObject.customDelay ?? this.#calculateDelay();
|
|
96967
|
-
}
|
|
96968
|
-
if (!this.#options.retry.methods.includes(this.request.method.toLowerCase())) {
|
|
96969
|
-
throw error;
|
|
96970
|
-
}
|
|
96971
|
-
if (this.#options.retry.shouldRetry !== undefined) {
|
|
96972
|
-
const result = await this.#options.retry.shouldRetry({ error: errorObject, retryCount: this.#retryCount });
|
|
96973
|
-
if (result === false) {
|
|
96974
|
-
throw error;
|
|
96975
|
-
}
|
|
96976
|
-
if (result === true) {
|
|
96977
|
-
return this.#calculateDelay();
|
|
96978
|
-
}
|
|
96979
|
-
}
|
|
96980
|
-
if (isTimeoutError(error) && !this.#options.retry.retryOnTimeout) {
|
|
96981
|
-
throw error;
|
|
96982
|
-
}
|
|
96983
|
-
if (isHTTPError(error)) {
|
|
96984
|
-
if (!this.#options.retry.statusCodes.includes(error.response.status)) {
|
|
96985
|
-
throw error;
|
|
96986
|
-
}
|
|
96987
|
-
const retryAfter = error.response.headers.get("Retry-After") ?? error.response.headers.get("RateLimit-Reset") ?? error.response.headers.get("X-RateLimit-Retry-After") ?? error.response.headers.get("X-RateLimit-Reset") ?? error.response.headers.get("X-Rate-Limit-Reset");
|
|
96988
|
-
if (retryAfter && this.#options.retry.afterStatusCodes.includes(error.response.status)) {
|
|
96989
|
-
let after = Number(retryAfter) * 1000;
|
|
96990
|
-
if (Number.isNaN(after)) {
|
|
96991
|
-
after = Date.parse(retryAfter) - Date.now();
|
|
96992
|
-
} else if (after >= Date.parse("2024-01-01")) {
|
|
96993
|
-
after -= Date.now();
|
|
96994
|
-
}
|
|
96995
|
-
const max = this.#options.retry.maxRetryAfter ?? after;
|
|
96996
|
-
return after < max ? after : max;
|
|
96997
|
-
}
|
|
96998
|
-
if (error.response.status === 413) {
|
|
96999
|
-
throw error;
|
|
97000
|
-
}
|
|
97001
|
-
}
|
|
97002
|
-
return this.#calculateDelay();
|
|
97003
|
-
}
|
|
97004
|
-
#decorateResponse(response) {
|
|
97005
|
-
if (this.#options.parseJson) {
|
|
97006
|
-
response.json = async () => this.#options.parseJson(await response.text());
|
|
97007
|
-
}
|
|
97008
|
-
return response;
|
|
97009
|
-
}
|
|
97010
|
-
#cancelBody(body) {
|
|
97011
|
-
if (!body) {
|
|
97012
|
-
return;
|
|
97013
|
-
}
|
|
97014
|
-
body.cancel().catch(() => {
|
|
97015
|
-
return;
|
|
97016
|
-
});
|
|
97017
|
-
}
|
|
97018
|
-
#cancelResponseBody(response) {
|
|
97019
|
-
this.#cancelBody(response.body ?? undefined);
|
|
97020
|
-
}
|
|
97021
|
-
async#retry(function_) {
|
|
97022
|
-
try {
|
|
97023
|
-
return await function_();
|
|
97024
|
-
} catch (error) {
|
|
97025
|
-
const ms = Math.min(await this.#calculateRetryDelay(error), maxSafeTimeout);
|
|
97026
|
-
if (this.#retryCount < 1) {
|
|
97027
|
-
throw error;
|
|
97028
|
-
}
|
|
97029
|
-
await delay2(ms, this.#userProvidedAbortSignal ? { signal: this.#userProvidedAbortSignal } : {});
|
|
97030
|
-
if (error instanceof ForceRetryError && error.customRequest) {
|
|
97031
|
-
const managedRequest = this.#options.signal ? new globalThis.Request(error.customRequest, { signal: this.#options.signal }) : new globalThis.Request(error.customRequest);
|
|
97032
|
-
this.#assignRequest(managedRequest);
|
|
97033
|
-
}
|
|
97034
|
-
for (const hook of this.#options.hooks.beforeRetry) {
|
|
97035
|
-
const hookResult = await hook({
|
|
97036
|
-
request: this.request,
|
|
97037
|
-
options: this.#getNormalizedOptions(),
|
|
97038
|
-
error,
|
|
97039
|
-
retryCount: this.#retryCount
|
|
97040
|
-
});
|
|
97041
|
-
if (hookResult instanceof globalThis.Request) {
|
|
97042
|
-
this.#assignRequest(hookResult);
|
|
97043
|
-
break;
|
|
97044
|
-
}
|
|
97045
|
-
if (hookResult instanceof globalThis.Response) {
|
|
97046
|
-
return hookResult;
|
|
97047
|
-
}
|
|
97048
|
-
if (hookResult === stop) {
|
|
97049
|
-
return;
|
|
97050
|
-
}
|
|
97051
|
-
}
|
|
97052
|
-
return this.#retry(function_);
|
|
97053
|
-
}
|
|
97054
|
-
}
|
|
97055
|
-
async#fetch() {
|
|
97056
|
-
if (this.#abortController?.signal.aborted) {
|
|
97057
|
-
this.#abortController = new globalThis.AbortController;
|
|
97058
|
-
this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
|
|
97059
|
-
this.request = new globalThis.Request(this.request, { signal: this.#options.signal });
|
|
97060
|
-
}
|
|
97061
|
-
for (const hook of this.#options.hooks.beforeRequest) {
|
|
97062
|
-
const result = await hook(this.request, this.#getNormalizedOptions(), { retryCount: this.#retryCount });
|
|
97063
|
-
if (result instanceof Response) {
|
|
97064
|
-
return result;
|
|
97065
|
-
}
|
|
97066
|
-
if (result instanceof globalThis.Request) {
|
|
97067
|
-
this.#assignRequest(result);
|
|
97068
|
-
break;
|
|
97069
|
-
}
|
|
97070
|
-
}
|
|
97071
|
-
const nonRequestOptions = findUnknownOptions(this.request, this.#options);
|
|
97072
|
-
this.#originalRequest = this.request;
|
|
97073
|
-
this.request = this.#originalRequest.clone();
|
|
97074
|
-
if (this.#options.timeout === false) {
|
|
97075
|
-
return this.#options.fetch(this.#originalRequest, nonRequestOptions);
|
|
97076
|
-
}
|
|
97077
|
-
return timeout(this.#originalRequest, nonRequestOptions, this.#abortController, this.#options);
|
|
97078
|
-
}
|
|
97079
|
-
#getNormalizedOptions() {
|
|
97080
|
-
if (!this.#cachedNormalizedOptions) {
|
|
97081
|
-
const { hooks, ...normalizedOptions } = this.#options;
|
|
97082
|
-
this.#cachedNormalizedOptions = Object.freeze(normalizedOptions);
|
|
97083
|
-
}
|
|
97084
|
-
return this.#cachedNormalizedOptions;
|
|
97085
|
-
}
|
|
97086
|
-
#assignRequest(request) {
|
|
97087
|
-
this.#cachedNormalizedOptions = undefined;
|
|
97088
|
-
this.request = this.#wrapRequestWithUploadProgress(request);
|
|
97089
|
-
}
|
|
97090
|
-
#wrapRequestWithUploadProgress(request, originalBody) {
|
|
97091
|
-
if (!this.#options.onUploadProgress || !request.body) {
|
|
97092
|
-
return request;
|
|
97093
|
-
}
|
|
97094
|
-
return streamRequest(request, this.#options.onUploadProgress, originalBody ?? this.#options.body ?? undefined);
|
|
97095
|
-
}
|
|
97096
|
-
}
|
|
97097
|
-
// node_modules/ky/distribution/index.js
|
|
97098
|
-
/*! MIT License © Sindre Sorhus */
|
|
97099
|
-
var createInstance = (defaults) => {
|
|
97100
|
-
const ky = (input, options) => Ky.create(input, validateAndMerge(defaults, options));
|
|
97101
|
-
for (const method of requestMethods) {
|
|
97102
|
-
ky[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));
|
|
97103
|
-
}
|
|
97104
|
-
ky.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));
|
|
97105
|
-
ky.extend = (newDefaults) => {
|
|
97106
|
-
if (typeof newDefaults === "function") {
|
|
97107
|
-
newDefaults = newDefaults(defaults ?? {});
|
|
97108
|
-
}
|
|
97109
|
-
return createInstance(validateAndMerge(defaults, newDefaults));
|
|
97110
|
-
};
|
|
97111
|
-
ky.stop = stop;
|
|
97112
|
-
ky.retry = retry;
|
|
97113
|
-
return ky;
|
|
97114
|
-
};
|
|
97115
|
-
var ky = createInstance();
|
|
97116
|
-
var distribution_default = ky;
|
|
97255
|
+
var delay2 = createDelay();
|
|
97256
|
+
var delay_default = delay2;
|
|
97117
97257
|
|
|
97118
97258
|
// lib/registry-api/get-ky.ts
|
|
97119
97259
|
class PrettyHttpError extends Error {
|
|
@@ -104144,7 +104284,7 @@ var validateMainInDist = (projectDir, distDir) => {
|
|
|
104144
104284
|
};
|
|
104145
104285
|
|
|
104146
104286
|
// cli/build/build-ci.ts
|
|
104147
|
-
import { execSync as
|
|
104287
|
+
import { execSync as execSync3 } from "node:child_process";
|
|
104148
104288
|
|
|
104149
104289
|
// lib/shared/install-project-dependencies.ts
|
|
104150
104290
|
import fs23 from "node:fs";
|
|
@@ -104292,7 +104432,7 @@ async function installProjectDependencies({
|
|
|
104292
104432
|
// cli/build/build-ci.ts
|
|
104293
104433
|
var runCommand = (command, cwd) => {
|
|
104294
104434
|
console.log(kleur_default.cyan(`Running: ${command}`));
|
|
104295
|
-
|
|
104435
|
+
execSync3(command, {
|
|
104296
104436
|
stdio: "inherit",
|
|
104297
104437
|
cwd,
|
|
104298
104438
|
env: { ...process.env, TSCIRCUIT_INSIDE_BUILD_COMMAND: "1" }
|
|
@@ -213293,7 +213433,7 @@ var package_default4 = {
|
|
|
213293
213433
|
};
|
|
213294
213434
|
var import_react = __toESM3(require_react(), 1);
|
|
213295
213435
|
var import_react_reconciler = __toESM3(require_react_reconciler(), 1);
|
|
213296
|
-
var
|
|
213436
|
+
var import_constants18 = __toESM3(require_constants6(), 1);
|
|
213297
213437
|
var import_react2 = __toESM3(require_react(), 1);
|
|
213298
213438
|
function createMap() {
|
|
213299
213439
|
return new IndexedMap;
|
|
@@ -238550,9 +238690,9 @@ var hostConfig = {
|
|
|
238550
238690
|
detachDeletedInstance: (node) => {
|
|
238551
238691
|
throw new Error("Function not implemented.");
|
|
238552
238692
|
},
|
|
238553
|
-
getCurrentEventPriority: () =>
|
|
238554
|
-
getCurrentUpdatePriority: () =>
|
|
238555
|
-
resolveUpdatePriority: () =>
|
|
238693
|
+
getCurrentEventPriority: () => import_constants18.DefaultEventPriority,
|
|
238694
|
+
getCurrentUpdatePriority: () => import_constants18.DefaultEventPriority,
|
|
238695
|
+
resolveUpdatePriority: () => import_constants18.DefaultEventPriority,
|
|
238556
238696
|
setCurrentUpdatePriority: () => {},
|
|
238557
238697
|
maySuspendCommit: () => false,
|
|
238558
238698
|
supportsHydration: false
|
|
@@ -258103,18 +258243,18 @@ import * as path48 from "node:path";
|
|
|
258103
258243
|
|
|
258104
258244
|
// cli/clone/clone-bug-report.ts
|
|
258105
258245
|
var import_jszip3 = __toESM2(require_lib4(), 1);
|
|
258106
|
-
var
|
|
258246
|
+
var import_prompts5 = __toESM2(require_prompts3(), 1);
|
|
258107
258247
|
import * as fs44 from "node:fs";
|
|
258108
258248
|
import * as path47 from "node:path";
|
|
258109
258249
|
|
|
258110
258250
|
// cli/clone/handle-existing-directory.ts
|
|
258111
|
-
var
|
|
258251
|
+
var import_prompts4 = __toESM2(require_prompts3(), 1);
|
|
258112
258252
|
import * as fs43 from "node:fs";
|
|
258113
258253
|
import * as path46 from "node:path";
|
|
258114
258254
|
var handleExistingDirectory = async (dirPath) => {
|
|
258115
258255
|
if (!fs43.existsSync(dirPath))
|
|
258116
258256
|
return;
|
|
258117
|
-
const response = await
|
|
258257
|
+
const response = await import_prompts4.default({
|
|
258118
258258
|
type: "select",
|
|
258119
258259
|
name: "action",
|
|
258120
258260
|
message: `Directory "${path46.basename(dirPath)}" already exists. What would you like to do?`,
|
|
@@ -258222,7 +258362,7 @@ var cloneBugReport = async ({
|
|
|
258222
258362
|
const sanitizedName = packageName.replace(/[^a-zA-Z0-9]/g, "_");
|
|
258223
258363
|
const suggestedDirPath = path47.resolve(`${sanitizedName}_${trimmedBugReportId.slice(7)}`);
|
|
258224
258364
|
if (suggestedDirPath !== dirPath) {
|
|
258225
|
-
const response = await
|
|
258365
|
+
const response = await import_prompts5.default({
|
|
258226
258366
|
type: "confirm",
|
|
258227
258367
|
name: "rename",
|
|
258228
258368
|
initial: true,
|
|
@@ -263065,7 +263205,7 @@ var createHttpServer = async ({
|
|
|
263065
263205
|
};
|
|
263066
263206
|
|
|
263067
263207
|
// lib/shared/push-snippet.ts
|
|
263068
|
-
var
|
|
263208
|
+
var import_semver6 = __toESM2(require_semver2(), 1);
|
|
263069
263209
|
import * as fs51 from "node:fs";
|
|
263070
263210
|
import * as path56 from "node:path";
|
|
263071
263211
|
import Debug2 from "debug";
|
|
@@ -263387,7 +263527,7 @@ var pushSnippet = async ({
|
|
|
263387
263527
|
if (!releaseExists) {
|
|
263388
263528
|
break;
|
|
263389
263529
|
}
|
|
263390
|
-
const bumpedVersion =
|
|
263530
|
+
const bumpedVersion = import_semver6.default.inc(packageVersion, "patch");
|
|
263391
263531
|
if (!bumpedVersion) {
|
|
263392
263532
|
onError(`Failed to increment version from ${packageVersion}`);
|
|
263393
263533
|
return onExit(1);
|
|
@@ -263909,12 +264049,12 @@ var checkLoggedIn = () => {
|
|
|
263909
264049
|
};
|
|
263910
264050
|
|
|
263911
264051
|
// cli/doctor/checks/check-npmrc-registry.ts
|
|
263912
|
-
import { spawnSync } from "node:child_process";
|
|
264052
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
263913
264053
|
import fs54 from "node:fs";
|
|
263914
264054
|
import os7 from "node:os";
|
|
263915
264055
|
import path59 from "node:path";
|
|
263916
264056
|
var hasBunInstalled = () => {
|
|
263917
|
-
const result =
|
|
264057
|
+
const result = spawnSync2("bun", ["--version"], { stdio: "ignore" });
|
|
263918
264058
|
return result.status === 0;
|
|
263919
264059
|
};
|
|
263920
264060
|
var createTempProject = (tempDir) => {
|
|
@@ -263941,7 +264081,7 @@ var checkGlobalNpmrcRegistry = async () => {
|
|
|
263941
264081
|
const tempDir = fs54.mkdtempSync(path59.join(os7.tmpdir(), "tsci-doctor-"));
|
|
263942
264082
|
try {
|
|
263943
264083
|
createTempProject(tempDir);
|
|
263944
|
-
const result =
|
|
264084
|
+
const result = spawnSync2("bun", ["install"], {
|
|
263945
264085
|
cwd: tempDir,
|
|
263946
264086
|
env: {
|
|
263947
264087
|
...process.env,
|
|
@@ -286410,24 +286550,10 @@ async function setupTscircuitSkill(projectDir, skipPrompt = false) {
|
|
|
286410
286550
|
}
|
|
286411
286551
|
}
|
|
286412
286552
|
|
|
286413
|
-
// lib/shared/get-dep-install-command.ts
|
|
286414
|
-
var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
286415
|
-
switch (packageManager) {
|
|
286416
|
-
case "yarn":
|
|
286417
|
-
return `yarn global add ${deps}`;
|
|
286418
|
-
case "pnpm":
|
|
286419
|
-
return `pnpm add -g ${deps}`;
|
|
286420
|
-
case "bun":
|
|
286421
|
-
return `bun install -g ${deps}`;
|
|
286422
|
-
default:
|
|
286423
|
-
return `npm install -g ${deps}`;
|
|
286424
|
-
}
|
|
286425
|
-
};
|
|
286426
|
-
|
|
286427
286553
|
// lib/shared/check-for-cli-update.ts
|
|
286428
|
-
import { execSync as
|
|
286429
|
-
var
|
|
286430
|
-
var currentCliVersion = () => program2?.version() ??
|
|
286554
|
+
import { execSync as execSync4 } from "node:child_process";
|
|
286555
|
+
var import_semver7 = __toESM2(require_semver2(), 1);
|
|
286556
|
+
var currentCliVersion = () => program2?.version() ?? import_semver7.default.inc(version, "patch") ?? version;
|
|
286431
286557
|
var getLatestVersion = async () => {
|
|
286432
286558
|
const { version: latestCliVersion } = await distribution_default.get("https://registry.npmjs.org/@tscircuit/cli/latest", { throwHttpErrors: false }).json();
|
|
286433
286559
|
return latestCliVersion;
|
|
@@ -286440,7 +286566,7 @@ var checkForTsciUpdates = async () => {
|
|
|
286440
286566
|
const latestCliVersion = await getLatestVersion();
|
|
286441
286567
|
if (!latestCliVersion)
|
|
286442
286568
|
return false;
|
|
286443
|
-
if (
|
|
286569
|
+
if (import_semver7.default.gt(latestCliVersion, currentCliVersion())) {
|
|
286444
286570
|
const { userWantsToUpdate } = await prompts({
|
|
286445
286571
|
type: "confirm",
|
|
286446
286572
|
name: "userWantsToUpdate",
|
|
@@ -286457,7 +286583,7 @@ var updateTsciIfNewVersionIsAvailable = async () => {
|
|
|
286457
286583
|
const latestCliVersion = await getLatestVersion();
|
|
286458
286584
|
if (!latestCliVersion)
|
|
286459
286585
|
return false;
|
|
286460
|
-
if (
|
|
286586
|
+
if (import_semver7.default.gt(latestCliVersion, currentCliVersion())) {
|
|
286461
286587
|
return await updateTsci();
|
|
286462
286588
|
}
|
|
286463
286589
|
return false;
|
|
@@ -286467,7 +286593,7 @@ var updateTsci = async () => {
|
|
|
286467
286593
|
const installCommand = getGlobalDepsInstallCommand(packageManager.name, "tscircuit@latest");
|
|
286468
286594
|
try {
|
|
286469
286595
|
console.log(`Updating tsci using: ${installCommand}`);
|
|
286470
|
-
|
|
286596
|
+
execSync4(installCommand, { stdio: "inherit" });
|
|
286471
286597
|
console.log(kleur_default.green("tsci has been updated successfully!"));
|
|
286472
286598
|
} catch {
|
|
286473
286599
|
console.warn("Update failed. You can try updating manually by running:");
|
|
@@ -289423,6 +289549,7 @@ registerExport(program2);
|
|
|
289423
289549
|
registerBuild(program2);
|
|
289424
289550
|
registerTranspile(program2);
|
|
289425
289551
|
registerAdd(program2);
|
|
289552
|
+
registerAgent(program2);
|
|
289426
289553
|
registerRemove(program2);
|
|
289427
289554
|
registerSnapshot(program2);
|
|
289428
289555
|
registerSetup(program2);
|
|
@@ -289445,8 +289572,11 @@ registerSearch(program2);
|
|
|
289445
289572
|
registerImport(program2);
|
|
289446
289573
|
registerConvert(program2);
|
|
289447
289574
|
registerSimulate(program2);
|
|
289448
|
-
|
|
289449
|
-
|
|
289575
|
+
var cliArgs = process.argv.slice(2);
|
|
289576
|
+
var firstCommandIndex = cliArgs.findIndex((arg) => !arg.startsWith("-"));
|
|
289577
|
+
var topLevelArgs = firstCommandIndex === -1 ? cliArgs : cliArgs.slice(0, firstCommandIndex);
|
|
289578
|
+
if (topLevelArgs.includes("--version") || topLevelArgs.includes("-v") || topLevelArgs.includes("-V")) {
|
|
289579
|
+
console.log(getVersion({ verbose: topLevelArgs.includes("--verbose") }));
|
|
289450
289580
|
process.exit(0);
|
|
289451
289581
|
}
|
|
289452
289582
|
program2.command("version").description("Print CLI version").option("--verbose", "Print tscircuit + CLI dependency versions").action((options) => {
|