@tscircuit/cli 0.1.306 → 0.1.307

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.
Files changed (2) hide show
  1. package/dist/main.js +434 -382
  2. package/package.json +3 -3
package/dist/main.js CHANGED
@@ -69,7 +69,7 @@ var require_argument = __commonJS((exports2) => {
69
69
  this._name = name;
70
70
  break;
71
71
  }
72
- if (this._name.length > 3 && this._name.slice(-3) === "...") {
72
+ if (this._name.endsWith("...")) {
73
73
  this.variadic = true;
74
74
  this._name = this._name.slice(0, -3);
75
75
  }
@@ -77,11 +77,12 @@ var require_argument = __commonJS((exports2) => {
77
77
  name() {
78
78
  return this._name;
79
79
  }
80
- _concatValue(value, previous) {
80
+ _collectValue(value, previous) {
81
81
  if (previous === this.defaultValue || !Array.isArray(previous)) {
82
82
  return [value];
83
83
  }
84
- return previous.concat(value);
84
+ previous.push(value);
85
+ return previous;
85
86
  }
86
87
  default(value, description) {
87
88
  this.defaultValue = value;
@@ -99,7 +100,7 @@ var require_argument = __commonJS((exports2) => {
99
100
  throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
100
101
  }
101
102
  if (this.variadic) {
102
- return this._concatValue(arg, previous);
103
+ return this._collectValue(arg, previous);
103
104
  }
104
105
  return arg;
105
106
  };
@@ -546,11 +547,12 @@ var require_option = __commonJS((exports2) => {
546
547
  this.hidden = !!hide;
547
548
  return this;
548
549
  }
549
- _concatValue(value, previous) {
550
+ _collectValue(value, previous) {
550
551
  if (previous === this.defaultValue || !Array.isArray(previous)) {
551
552
  return [value];
552
553
  }
553
- return previous.concat(value);
554
+ previous.push(value);
555
+ return previous;
554
556
  }
555
557
  choices(values) {
556
558
  this.argChoices = values.slice();
@@ -559,7 +561,7 @@ var require_option = __commonJS((exports2) => {
559
561
  throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
560
562
  }
561
563
  if (this.variadic) {
562
- return this._concatValue(arg, previous);
564
+ return this._collectValue(arg, previous);
563
565
  }
564
566
  return arg;
565
567
  };
@@ -865,7 +867,10 @@ var require_command = __commonJS((exports2) => {
865
867
  configureOutput(configuration) {
866
868
  if (configuration === undefined)
867
869
  return this._outputConfiguration;
868
- this._outputConfiguration = Object.assign({}, this._outputConfiguration, configuration);
870
+ this._outputConfiguration = {
871
+ ...this._outputConfiguration,
872
+ ...configuration
873
+ };
869
874
  return this;
870
875
  }
871
876
  showHelpAfterError(displayHelp = true) {
@@ -914,7 +919,7 @@ var require_command = __commonJS((exports2) => {
914
919
  }
915
920
  addArgument(argument) {
916
921
  const previousArgument = this.registeredArguments.slice(-1)[0];
917
- if (previousArgument && previousArgument.variadic) {
922
+ if (previousArgument?.variadic) {
918
923
  throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
919
924
  }
920
925
  if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) {
@@ -1069,7 +1074,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1069
1074
  if (val !== null && option.parseArg) {
1070
1075
  val = this._callParseArg(option, val, oldValue, invalidValueMessage);
1071
1076
  } else if (val !== null && option.variadic) {
1072
- val = option._concatValue(val, oldValue);
1077
+ val = option._collectValue(val, oldValue);
1073
1078
  }
1074
1079
  if (val == null) {
1075
1080
  if (option.negate) {
@@ -1444,7 +1449,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1444
1449
  this.processedArgs = processedArgs;
1445
1450
  }
1446
1451
  _chainOrCall(promise, fn) {
1447
- if (promise && promise.then && typeof promise.then === "function") {
1452
+ if (promise?.then && typeof promise.then === "function") {
1448
1453
  return promise.then(() => fn());
1449
1454
  }
1450
1455
  return fn();
@@ -1521,7 +1526,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1521
1526
  promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
1522
1527
  return promiseChain;
1523
1528
  }
1524
- if (this.parent && this.parent.listenerCount(commandEvent)) {
1529
+ if (this.parent?.listenerCount(commandEvent)) {
1525
1530
  checkForUnknownOptions();
1526
1531
  this._processArguments();
1527
1532
  this.parent.emit(commandEvent, operands, unknown);
@@ -1583,11 +1588,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
1583
1588
  cmd._checkForConflictingLocalOptions();
1584
1589
  });
1585
1590
  }
1586
- parseOptions(argv) {
1591
+ parseOptions(args) {
1587
1592
  const operands = [];
1588
1593
  const unknown = [];
1589
1594
  let dest = operands;
1590
- const args = argv.slice();
1591
1595
  function maybeOption(arg) {
1592
1596
  return arg.length > 1 && arg[0] === "-";
1593
1597
  }
@@ -1597,12 +1601,15 @@ Expecting one of '${allowedValues.join("', '")}'`);
1597
1601
  return !this._getCommandAndAncestors().some((cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short)));
1598
1602
  };
1599
1603
  let activeVariadicOption = null;
1600
- while (args.length) {
1601
- const arg = args.shift();
1604
+ let activeGroup = null;
1605
+ let i = 0;
1606
+ while (i < args.length || activeGroup) {
1607
+ const arg = activeGroup ?? args[i++];
1608
+ activeGroup = null;
1602
1609
  if (arg === "--") {
1603
1610
  if (dest === unknown)
1604
1611
  dest.push(arg);
1605
- dest.push(...args);
1612
+ dest.push(...args.slice(i));
1606
1613
  break;
1607
1614
  }
1608
1615
  if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
@@ -1614,14 +1621,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
1614
1621
  const option = this._findOption(arg);
1615
1622
  if (option) {
1616
1623
  if (option.required) {
1617
- const value = args.shift();
1624
+ const value = args[i++];
1618
1625
  if (value === undefined)
1619
1626
  this.optionMissingArgument(option);
1620
1627
  this.emit(`option:${option.name()}`, value);
1621
1628
  } else if (option.optional) {
1622
1629
  let value = null;
1623
- if (args.length > 0 && (!maybeOption(args[0]) || negativeNumberArg(args[0]))) {
1624
- value = args.shift();
1630
+ if (i < args.length && (!maybeOption(args[i]) || negativeNumberArg(args[i]))) {
1631
+ value = args[i++];
1625
1632
  }
1626
1633
  this.emit(`option:${option.name()}`, value);
1627
1634
  } else {
@@ -1638,7 +1645,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1638
1645
  this.emit(`option:${option.name()}`, arg.slice(2));
1639
1646
  } else {
1640
1647
  this.emit(`option:${option.name()}`);
1641
- args.unshift(`-${arg.slice(2)}`);
1648
+ activeGroup = `-${arg.slice(2)}`;
1642
1649
  }
1643
1650
  continue;
1644
1651
  }
@@ -1657,25 +1664,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
1657
1664
  if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
1658
1665
  if (this._findCommand(arg)) {
1659
1666
  operands.push(arg);
1660
- if (args.length > 0)
1661
- unknown.push(...args);
1667
+ unknown.push(...args.slice(i));
1662
1668
  break;
1663
1669
  } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
1664
- operands.push(arg);
1665
- if (args.length > 0)
1666
- operands.push(...args);
1670
+ operands.push(arg, ...args.slice(i));
1667
1671
  break;
1668
1672
  } else if (this._defaultCommandName) {
1669
- unknown.push(arg);
1670
- if (args.length > 0)
1671
- unknown.push(...args);
1673
+ unknown.push(arg, ...args.slice(i));
1672
1674
  break;
1673
1675
  }
1674
1676
  }
1675
1677
  if (this._passThroughOptions) {
1676
- dest.push(arg);
1677
- if (args.length > 0)
1678
- dest.push(...args);
1678
+ dest.push(arg, ...args.slice(i));
1679
1679
  break;
1680
1680
  }
1681
1681
  dest.push(arg);
@@ -5114,91 +5114,60 @@ var require_data = __commonJS((exports2, module2) => {
5114
5114
  };
5115
5115
  });
5116
5116
 
5117
- // node_modules/fast-uri/lib/scopedChars.js
5118
- var require_scopedChars = __commonJS((exports2, module2) => {
5119
- var HEX = {
5120
- 0: 0,
5121
- 1: 1,
5122
- 2: 2,
5123
- 3: 3,
5124
- 4: 4,
5125
- 5: 5,
5126
- 6: 6,
5127
- 7: 7,
5128
- 8: 8,
5129
- 9: 9,
5130
- a: 10,
5131
- A: 10,
5132
- b: 11,
5133
- B: 11,
5134
- c: 12,
5135
- C: 12,
5136
- d: 13,
5137
- D: 13,
5138
- e: 14,
5139
- E: 14,
5140
- f: 15,
5141
- F: 15
5142
- };
5143
- module2.exports = {
5144
- HEX
5145
- };
5146
- });
5147
-
5148
5117
  // node_modules/fast-uri/lib/utils.js
5149
5118
  var require_utils = __commonJS((exports2, module2) => {
5150
- var { HEX } = require_scopedChars();
5151
- var IPV4_REG = /^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u;
5152
- function normalizeIPv4(host) {
5153
- if (findToken(host, ".") < 3) {
5154
- return { host, isIPV4: false };
5155
- }
5156
- const matches = host.match(IPV4_REG) || [];
5157
- const [address] = matches;
5158
- if (address) {
5159
- return { host: stripLeadingZeros(address, "."), isIPV4: true };
5160
- } else {
5161
- return { host, isIPV4: false };
5162
- }
5163
- }
5164
- function stringArrayToHexStripped(input, keepZero = false) {
5119
+ var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
5120
+ var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
5121
+ function stringArrayToHexStripped(input) {
5165
5122
  let acc = "";
5166
- let strip = true;
5167
- for (const c of input) {
5168
- if (HEX[c] === undefined)
5169
- return;
5170
- if (c !== "0" && strip === true)
5171
- strip = false;
5172
- if (!strip)
5173
- acc += c;
5123
+ let code = 0;
5124
+ let i = 0;
5125
+ for (i = 0;i < input.length; i++) {
5126
+ code = input[i].charCodeAt(0);
5127
+ if (code === 48) {
5128
+ continue;
5129
+ }
5130
+ if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) {
5131
+ return "";
5132
+ }
5133
+ acc += input[i];
5134
+ break;
5135
+ }
5136
+ for (i += 1;i < input.length; i++) {
5137
+ code = input[i].charCodeAt(0);
5138
+ if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) {
5139
+ return "";
5140
+ }
5141
+ acc += input[i];
5174
5142
  }
5175
- if (keepZero && acc.length === 0)
5176
- acc = "0";
5177
5143
  return acc;
5178
5144
  }
5145
+ var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
5146
+ function consumeIsZone(buffer) {
5147
+ buffer.length = 0;
5148
+ return true;
5149
+ }
5150
+ function consumeHextets(buffer, address, output) {
5151
+ if (buffer.length) {
5152
+ const hex = stringArrayToHexStripped(buffer);
5153
+ if (hex !== "") {
5154
+ address.push(hex);
5155
+ } else {
5156
+ output.error = true;
5157
+ return false;
5158
+ }
5159
+ buffer.length = 0;
5160
+ }
5161
+ return true;
5162
+ }
5179
5163
  function getIPV6(input) {
5180
5164
  let tokenCount = 0;
5181
5165
  const output = { error: false, address: "", zone: "" };
5182
5166
  const address = [];
5183
5167
  const buffer = [];
5184
- let isZone = false;
5185
5168
  let endipv6Encountered = false;
5186
5169
  let endIpv6 = false;
5187
- function consume() {
5188
- if (buffer.length) {
5189
- if (isZone === false) {
5190
- const hex = stringArrayToHexStripped(buffer);
5191
- if (hex !== undefined) {
5192
- address.push(hex);
5193
- } else {
5194
- output.error = true;
5195
- return false;
5196
- }
5197
- }
5198
- buffer.length = 0;
5199
- }
5200
- return true;
5201
- }
5170
+ let consume = consumeHextets;
5202
5171
  for (let i = 0;i < input.length; i++) {
5203
5172
  const cursor = input[i];
5204
5173
  if (cursor === "[" || cursor === "]") {
@@ -5208,31 +5177,30 @@ var require_utils = __commonJS((exports2, module2) => {
5208
5177
  if (endipv6Encountered === true) {
5209
5178
  endIpv6 = true;
5210
5179
  }
5211
- if (!consume()) {
5180
+ if (!consume(buffer, address, output)) {
5212
5181
  break;
5213
5182
  }
5214
- tokenCount++;
5215
- address.push(":");
5216
- if (tokenCount > 7) {
5183
+ if (++tokenCount > 7) {
5217
5184
  output.error = true;
5218
5185
  break;
5219
5186
  }
5220
- if (i - 1 >= 0 && input[i - 1] === ":") {
5187
+ if (i > 0 && input[i - 1] === ":") {
5221
5188
  endipv6Encountered = true;
5222
5189
  }
5190
+ address.push(":");
5223
5191
  continue;
5224
5192
  } else if (cursor === "%") {
5225
- if (!consume()) {
5193
+ if (!consume(buffer, address, output)) {
5226
5194
  break;
5227
5195
  }
5228
- isZone = true;
5196
+ consume = consumeIsZone;
5229
5197
  } else {
5230
5198
  buffer.push(cursor);
5231
5199
  continue;
5232
5200
  }
5233
5201
  }
5234
5202
  if (buffer.length) {
5235
- if (isZone) {
5203
+ if (consume === consumeIsZone) {
5236
5204
  output.zone = buffer.join("");
5237
5205
  } else if (endIpv6) {
5238
5206
  address.push(buffer.join(""));
@@ -5255,33 +5223,11 @@ var require_utils = __commonJS((exports2, module2) => {
5255
5223
  newHost += "%" + ipv6.zone;
5256
5224
  escapedHost += "%25" + ipv6.zone;
5257
5225
  }
5258
- return { host: newHost, escapedHost, isIPV6: true };
5226
+ return { host: newHost, isIPV6: true, escapedHost };
5259
5227
  } else {
5260
5228
  return { host, isIPV6: false };
5261
5229
  }
5262
5230
  }
5263
- function stripLeadingZeros(str, token) {
5264
- let out = "";
5265
- let skip = true;
5266
- const l = str.length;
5267
- for (let i = 0;i < l; i++) {
5268
- const c = str[i];
5269
- if (c === "0" && skip) {
5270
- if (i + 1 <= l && str[i + 1] === token || i + 1 === l) {
5271
- out += c;
5272
- skip = false;
5273
- }
5274
- } else {
5275
- if (c === token) {
5276
- skip = true;
5277
- } else {
5278
- skip = false;
5279
- }
5280
- out += c;
5281
- }
5282
- }
5283
- return out;
5284
- }
5285
5231
  function findToken(str, token) {
5286
5232
  let ind = 0;
5287
5233
  for (let i = 0;i < str.length; i++) {
@@ -5290,89 +5236,134 @@ var require_utils = __commonJS((exports2, module2) => {
5290
5236
  }
5291
5237
  return ind;
5292
5238
  }
5293
- var RDS1 = /^\.\.?\//u;
5294
- var RDS2 = /^\/\.(?:\/|$)/u;
5295
- var RDS3 = /^\/\.\.(?:\/|$)/u;
5296
- var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/u;
5297
- function removeDotSegments(input) {
5239
+ function removeDotSegments(path8) {
5240
+ let input = path8;
5298
5241
  const output = [];
5299
- while (input.length) {
5300
- if (input.match(RDS1)) {
5301
- input = input.replace(RDS1, "");
5302
- } else if (input.match(RDS2)) {
5303
- input = input.replace(RDS2, "/");
5304
- } else if (input.match(RDS3)) {
5305
- input = input.replace(RDS3, "/");
5306
- output.pop();
5307
- } else if (input === "." || input === "..") {
5308
- input = "";
5309
- } else {
5310
- const im = input.match(RDS5);
5311
- if (im) {
5312
- const s = im[0];
5313
- input = input.slice(s.length);
5314
- output.push(s);
5242
+ let nextSlash = -1;
5243
+ let len = 0;
5244
+ while (len = input.length) {
5245
+ if (len === 1) {
5246
+ if (input === ".") {
5247
+ break;
5248
+ } else if (input === "/") {
5249
+ output.push("/");
5250
+ break;
5315
5251
  } else {
5316
- throw new Error("Unexpected dot segment condition");
5252
+ output.push(input);
5253
+ break;
5254
+ }
5255
+ } else if (len === 2) {
5256
+ if (input[0] === ".") {
5257
+ if (input[1] === ".") {
5258
+ break;
5259
+ } else if (input[1] === "/") {
5260
+ input = input.slice(2);
5261
+ continue;
5262
+ }
5263
+ } else if (input[0] === "/") {
5264
+ if (input[1] === "." || input[1] === "/") {
5265
+ output.push("/");
5266
+ break;
5267
+ }
5268
+ }
5269
+ } else if (len === 3) {
5270
+ if (input === "/..") {
5271
+ if (output.length !== 0) {
5272
+ output.pop();
5273
+ }
5274
+ output.push("/");
5275
+ break;
5276
+ }
5277
+ }
5278
+ if (input[0] === ".") {
5279
+ if (input[1] === ".") {
5280
+ if (input[2] === "/") {
5281
+ input = input.slice(3);
5282
+ continue;
5283
+ }
5284
+ } else if (input[1] === "/") {
5285
+ input = input.slice(2);
5286
+ continue;
5287
+ }
5288
+ } else if (input[0] === "/") {
5289
+ if (input[1] === ".") {
5290
+ if (input[2] === "/") {
5291
+ input = input.slice(2);
5292
+ continue;
5293
+ } else if (input[2] === ".") {
5294
+ if (input[3] === "/") {
5295
+ input = input.slice(3);
5296
+ if (output.length !== 0) {
5297
+ output.pop();
5298
+ }
5299
+ continue;
5300
+ }
5301
+ }
5317
5302
  }
5318
5303
  }
5304
+ if ((nextSlash = input.indexOf("/", 1)) === -1) {
5305
+ output.push(input);
5306
+ break;
5307
+ } else {
5308
+ output.push(input.slice(0, nextSlash));
5309
+ input = input.slice(nextSlash);
5310
+ }
5319
5311
  }
5320
5312
  return output.join("");
5321
5313
  }
5322
- function normalizeComponentEncoding(components, esc) {
5314
+ function normalizeComponentEncoding(component, esc) {
5323
5315
  const func = esc !== true ? escape : unescape;
5324
- if (components.scheme !== undefined) {
5325
- components.scheme = func(components.scheme);
5316
+ if (component.scheme !== undefined) {
5317
+ component.scheme = func(component.scheme);
5326
5318
  }
5327
- if (components.userinfo !== undefined) {
5328
- components.userinfo = func(components.userinfo);
5319
+ if (component.userinfo !== undefined) {
5320
+ component.userinfo = func(component.userinfo);
5329
5321
  }
5330
- if (components.host !== undefined) {
5331
- components.host = func(components.host);
5322
+ if (component.host !== undefined) {
5323
+ component.host = func(component.host);
5332
5324
  }
5333
- if (components.path !== undefined) {
5334
- components.path = func(components.path);
5325
+ if (component.path !== undefined) {
5326
+ component.path = func(component.path);
5335
5327
  }
5336
- if (components.query !== undefined) {
5337
- components.query = func(components.query);
5328
+ if (component.query !== undefined) {
5329
+ component.query = func(component.query);
5338
5330
  }
5339
- if (components.fragment !== undefined) {
5340
- components.fragment = func(components.fragment);
5331
+ if (component.fragment !== undefined) {
5332
+ component.fragment = func(component.fragment);
5341
5333
  }
5342
- return components;
5334
+ return component;
5343
5335
  }
5344
- function recomposeAuthority(components) {
5336
+ function recomposeAuthority(component) {
5345
5337
  const uriTokens = [];
5346
- if (components.userinfo !== undefined) {
5347
- uriTokens.push(components.userinfo);
5338
+ if (component.userinfo !== undefined) {
5339
+ uriTokens.push(component.userinfo);
5348
5340
  uriTokens.push("@");
5349
5341
  }
5350
- if (components.host !== undefined) {
5351
- let host = unescape(components.host);
5352
- const ipV4res = normalizeIPv4(host);
5353
- if (ipV4res.isIPV4) {
5354
- host = ipV4res.host;
5355
- } else {
5356
- const ipV6res = normalizeIPv6(ipV4res.host);
5342
+ if (component.host !== undefined) {
5343
+ let host = unescape(component.host);
5344
+ if (!isIPv4(host)) {
5345
+ const ipV6res = normalizeIPv6(host);
5357
5346
  if (ipV6res.isIPV6 === true) {
5358
5347
  host = `[${ipV6res.escapedHost}]`;
5359
5348
  } else {
5360
- host = components.host;
5349
+ host = component.host;
5361
5350
  }
5362
5351
  }
5363
5352
  uriTokens.push(host);
5364
5353
  }
5365
- if (typeof components.port === "number" || typeof components.port === "string") {
5354
+ if (typeof component.port === "number" || typeof component.port === "string") {
5366
5355
  uriTokens.push(":");
5367
- uriTokens.push(String(components.port));
5356
+ uriTokens.push(String(component.port));
5368
5357
  }
5369
5358
  return uriTokens.length ? uriTokens.join("") : undefined;
5370
5359
  }
5371
5360
  module2.exports = {
5361
+ nonSimpleDomain,
5372
5362
  recomposeAuthority,
5373
5363
  normalizeComponentEncoding,
5374
5364
  removeDotSegments,
5375
- normalizeIPv4,
5365
+ isIPv4,
5366
+ isUUID,
5376
5367
  normalizeIPv6,
5377
5368
  stringArrayToHexStripped
5378
5369
  };
@@ -5380,99 +5371,121 @@ var require_utils = __commonJS((exports2, module2) => {
5380
5371
 
5381
5372
  // node_modules/fast-uri/lib/schemes.js
5382
5373
  var require_schemes = __commonJS((exports2, module2) => {
5383
- var UUID_REG = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu;
5374
+ var { isUUID } = require_utils();
5384
5375
  var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
5385
- function isSecure(wsComponents) {
5386
- return typeof wsComponents.secure === "boolean" ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss";
5376
+ var supportedSchemeNames = [
5377
+ "http",
5378
+ "https",
5379
+ "ws",
5380
+ "wss",
5381
+ "urn",
5382
+ "urn:uuid"
5383
+ ];
5384
+ function isValidSchemeName(name) {
5385
+ return supportedSchemeNames.indexOf(name) !== -1;
5387
5386
  }
5388
- function httpParse(components) {
5389
- if (!components.host) {
5390
- components.error = components.error || "HTTP URIs must have a host.";
5387
+ function wsIsSecure(wsComponent) {
5388
+ if (wsComponent.secure === true) {
5389
+ return true;
5390
+ } else if (wsComponent.secure === false) {
5391
+ return false;
5392
+ } else if (wsComponent.scheme) {
5393
+ return wsComponent.scheme.length === 3 && (wsComponent.scheme[0] === "w" || wsComponent.scheme[0] === "W") && (wsComponent.scheme[1] === "s" || wsComponent.scheme[1] === "S") && (wsComponent.scheme[2] === "s" || wsComponent.scheme[2] === "S");
5394
+ } else {
5395
+ return false;
5396
+ }
5397
+ }
5398
+ function httpParse(component) {
5399
+ if (!component.host) {
5400
+ component.error = component.error || "HTTP URIs must have a host.";
5391
5401
  }
5392
- return components;
5402
+ return component;
5393
5403
  }
5394
- function httpSerialize(components) {
5395
- const secure = String(components.scheme).toLowerCase() === "https";
5396
- if (components.port === (secure ? 443 : 80) || components.port === "") {
5397
- components.port = undefined;
5404
+ function httpSerialize(component) {
5405
+ const secure = String(component.scheme).toLowerCase() === "https";
5406
+ if (component.port === (secure ? 443 : 80) || component.port === "") {
5407
+ component.port = undefined;
5398
5408
  }
5399
- if (!components.path) {
5400
- components.path = "/";
5409
+ if (!component.path) {
5410
+ component.path = "/";
5401
5411
  }
5402
- return components;
5412
+ return component;
5403
5413
  }
5404
- function wsParse(wsComponents) {
5405
- wsComponents.secure = isSecure(wsComponents);
5406
- wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
5407
- wsComponents.path = undefined;
5408
- wsComponents.query = undefined;
5409
- return wsComponents;
5414
+ function wsParse(wsComponent) {
5415
+ wsComponent.secure = wsIsSecure(wsComponent);
5416
+ wsComponent.resourceName = (wsComponent.path || "/") + (wsComponent.query ? "?" + wsComponent.query : "");
5417
+ wsComponent.path = undefined;
5418
+ wsComponent.query = undefined;
5419
+ return wsComponent;
5410
5420
  }
5411
- function wsSerialize(wsComponents) {
5412
- if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
5413
- wsComponents.port = undefined;
5421
+ function wsSerialize(wsComponent) {
5422
+ if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === "") {
5423
+ wsComponent.port = undefined;
5414
5424
  }
5415
- if (typeof wsComponents.secure === "boolean") {
5416
- wsComponents.scheme = wsComponents.secure ? "wss" : "ws";
5417
- wsComponents.secure = undefined;
5425
+ if (typeof wsComponent.secure === "boolean") {
5426
+ wsComponent.scheme = wsComponent.secure ? "wss" : "ws";
5427
+ wsComponent.secure = undefined;
5418
5428
  }
5419
- if (wsComponents.resourceName) {
5420
- const [path8, query] = wsComponents.resourceName.split("?");
5421
- wsComponents.path = path8 && path8 !== "/" ? path8 : undefined;
5422
- wsComponents.query = query;
5423
- wsComponents.resourceName = undefined;
5429
+ if (wsComponent.resourceName) {
5430
+ const [path8, query] = wsComponent.resourceName.split("?");
5431
+ wsComponent.path = path8 && path8 !== "/" ? path8 : undefined;
5432
+ wsComponent.query = query;
5433
+ wsComponent.resourceName = undefined;
5424
5434
  }
5425
- wsComponents.fragment = undefined;
5426
- return wsComponents;
5435
+ wsComponent.fragment = undefined;
5436
+ return wsComponent;
5427
5437
  }
5428
- function urnParse(urnComponents, options) {
5429
- if (!urnComponents.path) {
5430
- urnComponents.error = "URN can not be parsed";
5431
- return urnComponents;
5438
+ function urnParse(urnComponent, options) {
5439
+ if (!urnComponent.path) {
5440
+ urnComponent.error = "URN can not be parsed";
5441
+ return urnComponent;
5432
5442
  }
5433
- const matches = urnComponents.path.match(URN_REG);
5443
+ const matches = urnComponent.path.match(URN_REG);
5434
5444
  if (matches) {
5435
- const scheme = options.scheme || urnComponents.scheme || "urn";
5436
- urnComponents.nid = matches[1].toLowerCase();
5437
- urnComponents.nss = matches[2];
5438
- const urnScheme = `${scheme}:${options.nid || urnComponents.nid}`;
5439
- const schemeHandler = SCHEMES[urnScheme];
5440
- urnComponents.path = undefined;
5445
+ const scheme = options.scheme || urnComponent.scheme || "urn";
5446
+ urnComponent.nid = matches[1].toLowerCase();
5447
+ urnComponent.nss = matches[2];
5448
+ const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`;
5449
+ const schemeHandler = getSchemeHandler(urnScheme);
5450
+ urnComponent.path = undefined;
5441
5451
  if (schemeHandler) {
5442
- urnComponents = schemeHandler.parse(urnComponents, options);
5452
+ urnComponent = schemeHandler.parse(urnComponent, options);
5443
5453
  }
5444
5454
  } else {
5445
- urnComponents.error = urnComponents.error || "URN can not be parsed.";
5455
+ urnComponent.error = urnComponent.error || "URN can not be parsed.";
5446
5456
  }
5447
- return urnComponents;
5457
+ return urnComponent;
5448
5458
  }
5449
- function urnSerialize(urnComponents, options) {
5450
- const scheme = options.scheme || urnComponents.scheme || "urn";
5451
- const nid = urnComponents.nid.toLowerCase();
5459
+ function urnSerialize(urnComponent, options) {
5460
+ if (urnComponent.nid === undefined) {
5461
+ throw new Error("URN without nid cannot be serialized");
5462
+ }
5463
+ const scheme = options.scheme || urnComponent.scheme || "urn";
5464
+ const nid = urnComponent.nid.toLowerCase();
5452
5465
  const urnScheme = `${scheme}:${options.nid || nid}`;
5453
- const schemeHandler = SCHEMES[urnScheme];
5466
+ const schemeHandler = getSchemeHandler(urnScheme);
5454
5467
  if (schemeHandler) {
5455
- urnComponents = schemeHandler.serialize(urnComponents, options);
5468
+ urnComponent = schemeHandler.serialize(urnComponent, options);
5456
5469
  }
5457
- const uriComponents = urnComponents;
5458
- const nss = urnComponents.nss;
5459
- uriComponents.path = `${nid || options.nid}:${nss}`;
5470
+ const uriComponent = urnComponent;
5471
+ const nss = urnComponent.nss;
5472
+ uriComponent.path = `${nid || options.nid}:${nss}`;
5460
5473
  options.skipEscape = true;
5461
- return uriComponents;
5474
+ return uriComponent;
5462
5475
  }
5463
- function urnuuidParse(urnComponents, options) {
5464
- const uuidComponents = urnComponents;
5465
- uuidComponents.uuid = uuidComponents.nss;
5466
- uuidComponents.nss = undefined;
5467
- if (!options.tolerant && (!uuidComponents.uuid || !UUID_REG.test(uuidComponents.uuid))) {
5468
- uuidComponents.error = uuidComponents.error || "UUID is not valid.";
5476
+ function urnuuidParse(urnComponent, options) {
5477
+ const uuidComponent = urnComponent;
5478
+ uuidComponent.uuid = uuidComponent.nss;
5479
+ uuidComponent.nss = undefined;
5480
+ if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) {
5481
+ uuidComponent.error = uuidComponent.error || "UUID is not valid.";
5469
5482
  }
5470
- return uuidComponents;
5483
+ return uuidComponent;
5471
5484
  }
5472
- function urnuuidSerialize(uuidComponents) {
5473
- const urnComponents = uuidComponents;
5474
- urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
5475
- return urnComponents;
5485
+ function urnuuidSerialize(uuidComponent) {
5486
+ const urnComponent = uuidComponent;
5487
+ urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
5488
+ return urnComponent;
5476
5489
  }
5477
5490
  var http = {
5478
5491
  scheme: "http",
@@ -5518,13 +5531,22 @@ var require_schemes = __commonJS((exports2, module2) => {
5518
5531
  urn,
5519
5532
  "urn:uuid": urnuuid
5520
5533
  };
5521
- module2.exports = SCHEMES;
5534
+ Object.setPrototypeOf(SCHEMES, null);
5535
+ function getSchemeHandler(scheme) {
5536
+ return scheme && (SCHEMES[scheme] || SCHEMES[scheme.toLowerCase()]) || undefined;
5537
+ }
5538
+ module2.exports = {
5539
+ wsIsSecure,
5540
+ SCHEMES,
5541
+ isValidSchemeName,
5542
+ getSchemeHandler
5543
+ };
5522
5544
  });
5523
5545
 
5524
5546
  // node_modules/fast-uri/index.js
5525
5547
  var require_fast_uri = __commonJS((exports2, module2) => {
5526
- var { normalizeIPv6, normalizeIPv4, removeDotSegments, recomposeAuthority, normalizeComponentEncoding } = require_utils();
5527
- var SCHEMES = require_schemes();
5548
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
5549
+ var { SCHEMES, getSchemeHandler } = require_schemes();
5528
5550
  function normalize(uri, options) {
5529
5551
  if (typeof uri === "string") {
5530
5552
  uri = serialize(parse(uri, options), options);
@@ -5534,11 +5556,12 @@ var require_fast_uri = __commonJS((exports2, module2) => {
5534
5556
  return uri;
5535
5557
  }
5536
5558
  function resolve(baseURI, relativeURI, options) {
5537
- const schemelessOptions = Object.assign({ scheme: "null" }, options);
5538
- const resolved = resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
5539
- return serialize(resolved, { ...schemelessOptions, skipEscape: true });
5559
+ const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
5560
+ const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
5561
+ schemelessOptions.skipEscape = true;
5562
+ return serialize(resolved, schemelessOptions);
5540
5563
  }
5541
- function resolveComponents(base, relative, options, skipNormalization) {
5564
+ function resolveComponent(base, relative, options, skipNormalization) {
5542
5565
  const target = {};
5543
5566
  if (!skipNormalization) {
5544
5567
  base = parse(serialize(base, options), options);
@@ -5568,7 +5591,7 @@ var require_fast_uri = __commonJS((exports2, module2) => {
5568
5591
  target.query = base.query;
5569
5592
  }
5570
5593
  } else {
5571
- if (relative.path.charAt(0) === "/") {
5594
+ if (relative.path[0] === "/") {
5572
5595
  target.path = removeDotSegments(relative.path);
5573
5596
  } else {
5574
5597
  if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
@@ -5607,7 +5630,7 @@ var require_fast_uri = __commonJS((exports2, module2) => {
5607
5630
  return uriA.toLowerCase() === uriB.toLowerCase();
5608
5631
  }
5609
5632
  function serialize(cmpts, opts) {
5610
- const components = {
5633
+ const component = {
5611
5634
  host: cmpts.host,
5612
5635
  scheme: cmpts.scheme,
5613
5636
  userinfo: cmpts.userinfo,
@@ -5625,61 +5648,50 @@ var require_fast_uri = __commonJS((exports2, module2) => {
5625
5648
  };
5626
5649
  const options = Object.assign({}, opts);
5627
5650
  const uriTokens = [];
5628
- const schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
5651
+ const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
5629
5652
  if (schemeHandler && schemeHandler.serialize)
5630
- schemeHandler.serialize(components, options);
5631
- if (components.path !== undefined) {
5653
+ schemeHandler.serialize(component, options);
5654
+ if (component.path !== undefined) {
5632
5655
  if (!options.skipEscape) {
5633
- components.path = escape(components.path);
5634
- if (components.scheme !== undefined) {
5635
- components.path = components.path.split("%3A").join(":");
5656
+ component.path = escape(component.path);
5657
+ if (component.scheme !== undefined) {
5658
+ component.path = component.path.split("%3A").join(":");
5636
5659
  }
5637
5660
  } else {
5638
- components.path = unescape(components.path);
5661
+ component.path = unescape(component.path);
5639
5662
  }
5640
5663
  }
5641
- if (options.reference !== "suffix" && components.scheme) {
5642
- uriTokens.push(components.scheme, ":");
5664
+ if (options.reference !== "suffix" && component.scheme) {
5665
+ uriTokens.push(component.scheme, ":");
5643
5666
  }
5644
- const authority = recomposeAuthority(components);
5667
+ const authority = recomposeAuthority(component);
5645
5668
  if (authority !== undefined) {
5646
5669
  if (options.reference !== "suffix") {
5647
5670
  uriTokens.push("//");
5648
5671
  }
5649
5672
  uriTokens.push(authority);
5650
- if (components.path && components.path.charAt(0) !== "/") {
5673
+ if (component.path && component.path[0] !== "/") {
5651
5674
  uriTokens.push("/");
5652
5675
  }
5653
5676
  }
5654
- if (components.path !== undefined) {
5655
- let s = components.path;
5677
+ if (component.path !== undefined) {
5678
+ let s = component.path;
5656
5679
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
5657
5680
  s = removeDotSegments(s);
5658
5681
  }
5659
- if (authority === undefined) {
5660
- s = s.replace(/^\/\//u, "/%2F");
5682
+ if (authority === undefined && s[0] === "/" && s[1] === "/") {
5683
+ s = "/%2F" + s.slice(2);
5661
5684
  }
5662
5685
  uriTokens.push(s);
5663
5686
  }
5664
- if (components.query !== undefined) {
5665
- uriTokens.push("?", components.query);
5687
+ if (component.query !== undefined) {
5688
+ uriTokens.push("?", component.query);
5666
5689
  }
5667
- if (components.fragment !== undefined) {
5668
- uriTokens.push("#", components.fragment);
5690
+ if (component.fragment !== undefined) {
5691
+ uriTokens.push("#", component.fragment);
5669
5692
  }
5670
5693
  return uriTokens.join("");
5671
5694
  }
5672
- var hexLookUp = Array.from({ length: 127 }, (_v, k) => /[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(k)));
5673
- function nonSimpleDomain(value) {
5674
- let code = 0;
5675
- for (let i = 0, len = value.length;i < len; ++i) {
5676
- code = value.charCodeAt(i);
5677
- if (code > 126 || hexLookUp[code]) {
5678
- return true;
5679
- }
5680
- }
5681
- return false;
5682
- }
5683
5695
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
5684
5696
  function parse(uri, opts) {
5685
5697
  const options = Object.assign({}, opts);
@@ -5692,10 +5704,14 @@ var require_fast_uri = __commonJS((exports2, module2) => {
5692
5704
  query: undefined,
5693
5705
  fragment: undefined
5694
5706
  };
5695
- const gotEncoding = uri.indexOf("%") !== -1;
5696
5707
  let isIP = false;
5697
- if (options.reference === "suffix")
5698
- uri = (options.scheme ? options.scheme + ":" : "") + "//" + uri;
5708
+ if (options.reference === "suffix") {
5709
+ if (options.scheme) {
5710
+ uri = options.scheme + ":" + uri;
5711
+ } else {
5712
+ uri = "//" + uri;
5713
+ }
5714
+ }
5699
5715
  const matches = uri.match(URI_PARSE);
5700
5716
  if (matches) {
5701
5717
  parsed.scheme = matches[1];
@@ -5709,13 +5725,12 @@ var require_fast_uri = __commonJS((exports2, module2) => {
5709
5725
  parsed.port = matches[5];
5710
5726
  }
5711
5727
  if (parsed.host) {
5712
- const ipv4result = normalizeIPv4(parsed.host);
5713
- if (ipv4result.isIPV4 === false) {
5714
- const ipv6result = normalizeIPv6(ipv4result.host);
5728
+ const ipv4result = isIPv4(parsed.host);
5729
+ if (ipv4result === false) {
5730
+ const ipv6result = normalizeIPv6(parsed.host);
5715
5731
  parsed.host = ipv6result.host.toLowerCase();
5716
5732
  isIP = ipv6result.isIPV6;
5717
5733
  } else {
5718
- parsed.host = ipv4result.host;
5719
5734
  isIP = true;
5720
5735
  }
5721
5736
  }
@@ -5731,7 +5746,7 @@ var require_fast_uri = __commonJS((exports2, module2) => {
5731
5746
  if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) {
5732
5747
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
5733
5748
  }
5734
- const schemeHandler = SCHEMES[(options.scheme || parsed.scheme || "").toLowerCase()];
5749
+ const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
5735
5750
  if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
5736
5751
  if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
5737
5752
  try {
@@ -5742,11 +5757,13 @@ var require_fast_uri = __commonJS((exports2, module2) => {
5742
5757
  }
5743
5758
  }
5744
5759
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
5745
- if (gotEncoding && parsed.scheme !== undefined) {
5746
- parsed.scheme = unescape(parsed.scheme);
5747
- }
5748
- if (gotEncoding && parsed.host !== undefined) {
5749
- parsed.host = unescape(parsed.host);
5760
+ if (uri.indexOf("%") !== -1) {
5761
+ if (parsed.scheme !== undefined) {
5762
+ parsed.scheme = unescape(parsed.scheme);
5763
+ }
5764
+ if (parsed.host !== undefined) {
5765
+ parsed.host = unescape(parsed.host);
5766
+ }
5750
5767
  }
5751
5768
  if (parsed.path) {
5752
5769
  parsed.path = escape(unescape(parsed.path));
@@ -5767,7 +5784,7 @@ var require_fast_uri = __commonJS((exports2, module2) => {
5767
5784
  SCHEMES,
5768
5785
  normalize,
5769
5786
  resolve,
5770
- resolveComponents,
5787
+ resolveComponent,
5771
5788
  equal,
5772
5789
  serialize,
5773
5790
  parse
@@ -9460,6 +9477,9 @@ var require_parse_options = __commonJS((exports2, module2) => {
9460
9477
  var require_identifiers = __commonJS((exports2, module2) => {
9461
9478
  var numeric = /^[0-9]+$/;
9462
9479
  var compareIdentifiers = (a, b) => {
9480
+ if (typeof a === "number" && typeof b === "number") {
9481
+ return a === b ? 0 : a < b ? -1 : 1;
9482
+ }
9463
9483
  const anum = numeric.test(a);
9464
9484
  const bnum = numeric.test(b);
9465
9485
  if (anum && bnum) {
@@ -9562,7 +9582,25 @@ var require_semver = __commonJS((exports2, module2) => {
9562
9582
  if (!(other instanceof SemVer)) {
9563
9583
  other = new SemVer(other, this.options);
9564
9584
  }
9565
- return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
9585
+ if (this.major < other.major) {
9586
+ return -1;
9587
+ }
9588
+ if (this.major > other.major) {
9589
+ return 1;
9590
+ }
9591
+ if (this.minor < other.minor) {
9592
+ return -1;
9593
+ }
9594
+ if (this.minor > other.minor) {
9595
+ return 1;
9596
+ }
9597
+ if (this.patch < other.patch) {
9598
+ return -1;
9599
+ }
9600
+ if (this.patch > other.patch) {
9601
+ return 1;
9602
+ }
9603
+ return 0;
9566
9604
  }
9567
9605
  comparePre(other) {
9568
9606
  if (!(other instanceof SemVer)) {
@@ -10239,6 +10277,7 @@ var require_range = __commonJS((exports2, module2) => {
10239
10277
  return result;
10240
10278
  };
10241
10279
  var parseComparator = (comp, options) => {
10280
+ comp = comp.replace(re[t.BUILD], "");
10242
10281
  debug("comp", comp, options);
10243
10282
  comp = replaceCarets(comp, options);
10244
10283
  debug("caret", comp);
@@ -32698,9 +32737,9 @@ var crypto = new Crypto();
32698
32737
  };
32699
32738
  }
32700
32739
  function buildToReadableStream(dependencies) {
32701
- const { ReadableStream: ReadableStream2, Uint8Array: Uint8Array2 } = dependencies;
32740
+ const { ReadableStream, Uint8Array: Uint8Array2 } = dependencies;
32702
32741
  return function toReadableStream(stream) {
32703
- return new ReadableStream2({
32742
+ return new ReadableStream({
32704
32743
  start(controller) {
32705
32744
  stream.on("data", (chunk) => {
32706
32745
  controller.enqueue(new Uint8Array2([...new Uint8Array2(chunk)]));
@@ -71527,7 +71566,7 @@ class HTTPError extends Error {
71527
71566
  options;
71528
71567
  constructor(response, request, options) {
71529
71568
  const code = response.status || response.status === 0 ? response.status : "";
71530
- const title = response.statusText || "";
71569
+ const title = response.statusText ?? "";
71531
71570
  const status = `${code} ${title}`.trim();
71532
71571
  const reason = status ? `status code ${status}` : "an unknown error";
71533
71572
  super(`Request failed with ${reason}: ${request.method} ${request.url}`);
@@ -71587,7 +71626,8 @@ var responseTypes = {
71587
71626
  text: "text/*",
71588
71627
  formData: "multipart/form-data",
71589
71628
  arrayBuffer: "*/*",
71590
- blob: "*/*"
71629
+ blob: "*/*",
71630
+ bytes: "*/*"
71591
71631
  };
71592
71632
  var maxSafeTimeout = 2147483647;
71593
71633
  var usualFormBoundarySize = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length;
@@ -71664,78 +71704,56 @@ var getBodySize = (body) => {
71664
71704
  }
71665
71705
  return 0;
71666
71706
  };
71667
- var streamResponse = (response, onDownloadProgress) => {
71668
- const totalBytes = Number(response.headers.get("content-length")) || 0;
71707
+ var withProgress = (stream, totalBytes, onProgress) => {
71708
+ let previousChunk;
71669
71709
  let transferredBytes = 0;
71670
- if (response.status === 204) {
71671
- if (onDownloadProgress) {
71672
- onDownloadProgress({ percent: 1, totalBytes, transferredBytes }, new Uint8Array);
71710
+ return stream.pipeThrough(new TransformStream({
71711
+ transform(currentChunk, controller) {
71712
+ controller.enqueue(currentChunk);
71713
+ if (previousChunk) {
71714
+ transferredBytes += previousChunk.byteLength;
71715
+ let percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
71716
+ if (percent >= 1) {
71717
+ percent = 1 - Number.EPSILON;
71718
+ }
71719
+ onProgress?.({ percent, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
71720
+ }
71721
+ previousChunk = currentChunk;
71722
+ },
71723
+ flush() {
71724
+ if (previousChunk) {
71725
+ transferredBytes += previousChunk.byteLength;
71726
+ onProgress?.({ percent: 1, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
71727
+ }
71673
71728
  }
71729
+ }));
71730
+ };
71731
+ var streamResponse = (response, onDownloadProgress) => {
71732
+ if (!response.body) {
71733
+ return response;
71734
+ }
71735
+ if (response.status === 204) {
71674
71736
  return new Response(null, {
71675
71737
  status: response.status,
71676
71738
  statusText: response.statusText,
71677
71739
  headers: response.headers
71678
71740
  });
71679
71741
  }
71680
- return new Response(new ReadableStream({
71681
- async start(controller) {
71682
- const reader = response.body.getReader();
71683
- if (onDownloadProgress) {
71684
- onDownloadProgress({ percent: 0, transferredBytes: 0, totalBytes }, new Uint8Array);
71685
- }
71686
- async function read() {
71687
- const { done, value } = await reader.read();
71688
- if (done) {
71689
- controller.close();
71690
- return;
71691
- }
71692
- if (onDownloadProgress) {
71693
- transferredBytes += value.byteLength;
71694
- const percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
71695
- onDownloadProgress({ percent, transferredBytes, totalBytes }, value);
71696
- }
71697
- controller.enqueue(value);
71698
- await read();
71699
- }
71700
- await read();
71701
- }
71702
- }), {
71742
+ const totalBytes = Number(response.headers.get("content-length")) || 0;
71743
+ return new Response(withProgress(response.body, totalBytes, onDownloadProgress), {
71703
71744
  status: response.status,
71704
71745
  statusText: response.statusText,
71705
71746
  headers: response.headers
71706
71747
  });
71707
71748
  };
71708
- var streamRequest = (request, onUploadProgress) => {
71709
- const totalBytes = getBodySize(request.body);
71710
- let transferredBytes = 0;
71749
+ var streamRequest = (request, onUploadProgress, originalBody) => {
71750
+ if (!request.body) {
71751
+ return request;
71752
+ }
71753
+ const totalBytes = getBodySize(originalBody ?? request.body);
71711
71754
  return new Request(request, {
71712
71755
  duplex: "half",
71713
- body: new ReadableStream({
71714
- async start(controller) {
71715
- const reader = request.body instanceof ReadableStream ? request.body.getReader() : new Response("").body.getReader();
71716
- async function read() {
71717
- const { done, value } = await reader.read();
71718
- if (done) {
71719
- if (onUploadProgress) {
71720
- onUploadProgress({ percent: 1, transferredBytes, totalBytes: Math.max(totalBytes, transferredBytes) }, new Uint8Array);
71721
- }
71722
- controller.close();
71723
- return;
71724
- }
71725
- transferredBytes += value.byteLength;
71726
- let percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
71727
- if (totalBytes < transferredBytes || percent === 1) {
71728
- percent = 0.99;
71729
- }
71730
- if (onUploadProgress) {
71731
- onUploadProgress({ percent: Number(percent.toFixed(2)), transferredBytes, totalBytes }, value);
71732
- }
71733
- controller.enqueue(value);
71734
- await read();
71735
- }
71736
- await read();
71737
- }
71738
- })
71756
+ body: withProgress(request.body, totalBytes, onUploadProgress)
71739
71757
  });
71740
71758
  };
71741
71759
 
@@ -71879,6 +71897,24 @@ var findUnknownOptions = (request, options) => {
71879
71897
  }
71880
71898
  return unknownOptions;
71881
71899
  };
71900
+ var hasSearchParameters = (search) => {
71901
+ if (search === undefined) {
71902
+ return false;
71903
+ }
71904
+ if (Array.isArray(search)) {
71905
+ return search.length > 0;
71906
+ }
71907
+ if (search instanceof URLSearchParams) {
71908
+ return search.size > 0;
71909
+ }
71910
+ if (typeof search === "object") {
71911
+ return Object.keys(search).length > 0;
71912
+ }
71913
+ if (typeof search === "string") {
71914
+ return search.trim().length > 0;
71915
+ }
71916
+ return Boolean(search);
71917
+ };
71882
71918
 
71883
71919
  // node_modules/ky/distribution/core/Ky.js
71884
71920
  class Ky {
@@ -71917,11 +71953,20 @@ class Ky {
71917
71953
  };
71918
71954
  const isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());
71919
71955
  const result = (isRetriableMethod ? ky._retry(function_) : function_()).finally(async () => {
71956
+ const originalRequest = ky._originalRequest;
71957
+ const cleanupPromises = [];
71958
+ if (originalRequest && !originalRequest.bodyUsed) {
71959
+ cleanupPromises.push(originalRequest.body?.cancel());
71960
+ }
71920
71961
  if (!ky.request.bodyUsed) {
71921
- await ky.request.body?.cancel();
71962
+ cleanupPromises.push(ky.request.body?.cancel());
71922
71963
  }
71964
+ await Promise.all(cleanupPromises);
71923
71965
  });
71924
71966
  for (const [type, mimeType] of Object.entries(responseTypes)) {
71967
+ if (type === "bytes" && typeof globalThis.Response?.prototype?.bytes !== "function") {
71968
+ continue;
71969
+ }
71925
71970
  result[type] = async () => {
71926
71971
  ky.request.headers.set("accept", ky.request.headers.get("accept") || mimeType);
71927
71972
  const response = await result;
@@ -71929,25 +71974,32 @@ class Ky {
71929
71974
  if (response.status === 204) {
71930
71975
  return "";
71931
71976
  }
71932
- const arrayBuffer = await response.clone().arrayBuffer();
71933
- const responseSize = arrayBuffer.byteLength;
71934
- if (responseSize === 0) {
71977
+ const text = await response.text();
71978
+ if (text === "") {
71935
71979
  return "";
71936
71980
  }
71937
71981
  if (options.parseJson) {
71938
- return options.parseJson(await response.text());
71982
+ return options.parseJson(text);
71939
71983
  }
71984
+ return JSON.parse(text);
71940
71985
  }
71941
71986
  return response[type]();
71942
71987
  };
71943
71988
  }
71944
71989
  return result;
71945
71990
  }
71991
+ static #normalizeSearchParams(searchParams) {
71992
+ if (searchParams && typeof searchParams === "object" && !Array.isArray(searchParams) && !(searchParams instanceof URLSearchParams)) {
71993
+ return Object.fromEntries(Object.entries(searchParams).filter(([, value]) => value !== undefined));
71994
+ }
71995
+ return searchParams;
71996
+ }
71946
71997
  request;
71947
71998
  abortController;
71948
71999
  _retryCount = 0;
71949
72000
  _input;
71950
72001
  _options;
72002
+ _originalRequest;
71951
72003
  constructor(input, options = {}) {
71952
72004
  this._input = input;
71953
72005
  this._options = {
@@ -71991,8 +72043,8 @@ class Ky {
71991
72043
  this._options.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json");
71992
72044
  }
71993
72045
  this.request = new globalThis.Request(this._input, this._options);
71994
- if (this._options.searchParams) {
71995
- const textSearchParams = typeof this._options.searchParams === "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString();
72046
+ if (hasSearchParameters(this._options.searchParams)) {
72047
+ const textSearchParams = typeof this._options.searchParams === "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(Ky.#normalizeSearchParams(this._options.searchParams)).toString();
71996
72048
  const searchParams = "?" + textSearchParams;
71997
72049
  const url = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, searchParams);
71998
72050
  if ((supportsFormData && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"])) {
@@ -72009,7 +72061,7 @@ class Ky {
72009
72061
  }
72010
72062
  const originalBody = this.request.body;
72011
72063
  if (originalBody) {
72012
- this.request = streamRequest(this.request, this._options.onUploadProgress);
72064
+ this.request = streamRequest(this.request, this._options.onUploadProgress, this._options.body);
72013
72065
  }
72014
72066
  }
72015
72067
  }
@@ -72081,12 +72133,12 @@ class Ky {
72081
72133
  }
72082
72134
  }
72083
72135
  const nonRequestOptions = findUnknownOptions(this.request, this._options);
72084
- const mainRequest = this.request;
72085
- this.request = mainRequest.clone();
72136
+ this._originalRequest = this.request;
72137
+ this.request = this._originalRequest.clone();
72086
72138
  if (this._options.timeout === false) {
72087
- return this._options.fetch(mainRequest, nonRequestOptions);
72139
+ return this._options.fetch(this._originalRequest, nonRequestOptions);
72088
72140
  }
72089
- return timeout(mainRequest, nonRequestOptions, this.abortController, this._options);
72141
+ return timeout(this._originalRequest, nonRequestOptions, this.abortController, this._options);
72090
72142
  }
72091
72143
  }
72092
72144
 
@@ -72128,7 +72180,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
72128
72180
  import { execSync as execSync2 } from "node:child_process";
72129
72181
  var import_semver2 = __toESM2(require_semver2(), 1);
72130
72182
  // package.json
72131
- var version = "0.1.305";
72183
+ var version = "0.1.306";
72132
72184
  var package_default = {
72133
72185
  name: "@tscircuit/cli",
72134
72186
  version,
@@ -72173,7 +72225,7 @@ var package_default = {
72173
72225
  jsonwebtoken: "^9.0.2",
72174
72226
  jszip: "^3.10.1",
72175
72227
  "jwt-decode": "^4.0.0",
72176
- "kicad-component-converter": "^0.1.14",
72228
+ "kicad-component-converter": "^0.1.22",
72177
72229
  kicadts: "^0.0.9",
72178
72230
  kleur: "^4.1.5",
72179
72231
  ky: "^1.7.4",
@@ -72187,7 +72239,7 @@ var package_default = {
72187
72239
  semver: "^7.6.3",
72188
72240
  sharp: "0.32.6",
72189
72241
  tempy: "^3.1.0",
72190
- tscircuit: "^0.0.732",
72242
+ tscircuit: "^0.0.735-libonly",
72191
72243
  tsx: "^4.7.1",
72192
72244
  "typed-ky": "^0.0.4",
72193
72245
  "circuit-json": "^0.0.275",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.306",
3
+ "version": "0.1.307",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",
@@ -42,7 +42,7 @@
42
42
  "jsonwebtoken": "^9.0.2",
43
43
  "jszip": "^3.10.1",
44
44
  "jwt-decode": "^4.0.0",
45
- "kicad-component-converter": "^0.1.14",
45
+ "kicad-component-converter": "^0.1.22",
46
46
  "kicadts": "^0.0.9",
47
47
  "kleur": "^4.1.5",
48
48
  "ky": "^1.7.4",
@@ -56,7 +56,7 @@
56
56
  "semver": "^7.6.3",
57
57
  "sharp": "0.32.6",
58
58
  "tempy": "^3.1.0",
59
- "tscircuit": "^0.0.732",
59
+ "tscircuit": "^0.0.735-libonly",
60
60
  "tsx": "^4.7.1",
61
61
  "typed-ky": "^0.0.4",
62
62
  "circuit-json": "^0.0.275",