GenericProvider.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.GenericProvider = void 0;
  6. function _bluebirdLst() {
  7. const data = require("bluebird-lst");
  8. _bluebirdLst = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _builderUtilRuntime() {
  14. const data = require("builder-util-runtime");
  15. _builderUtilRuntime = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _main() {
  21. const data = require("./main");
  22. _main = function () {
  23. return data;
  24. };
  25. return data;
  26. }
  27. function _Provider() {
  28. const data = require("./Provider");
  29. _Provider = function () {
  30. return data;
  31. };
  32. return data;
  33. }
  34. class GenericProvider extends _main().Provider {
  35. constructor(configuration, updater, useMultipleRangeRequest = true) {
  36. super(updater.httpExecutor, useMultipleRangeRequest);
  37. this.configuration = configuration;
  38. this.updater = updater;
  39. this.baseUrl = (0, _main().newBaseUrl)(this.configuration.url);
  40. }
  41. get channel() {
  42. const result = this.updater.channel || this.configuration.channel;
  43. return result == null ? (0, _main().getDefaultChannelName)() : (0, _main().getCustomChannelName)(result);
  44. }
  45. getLatestVersion() {
  46. var _this = this;
  47. return (0, _bluebirdLst().coroutine)(function* () {
  48. let result;
  49. const channelFile = (0, _main().getChannelFilename)(_this.channel);
  50. const channelUrl = (0, _main().newUrlFromBase)(channelFile, _this.baseUrl, true);
  51. for (let attemptNumber = 0;; attemptNumber++) {
  52. try {
  53. result = (0, _Provider().parseUpdateInfo)((yield _this.httpRequest(channelUrl)), channelFile, channelUrl);
  54. break;
  55. } catch (e) {
  56. if (e instanceof _builderUtilRuntime().HttpError && e.statusCode === 404) {
  57. throw (0, _builderUtilRuntime().newError)(`Cannot find channel "${channelFile}" update info: ${e.stack || e.message}`, "ERR_UPDATER_CHANNEL_FILE_NOT_FOUND");
  58. } else if (e.code === "ECONNREFUSED") {
  59. if (attemptNumber < 3) {
  60. yield new Promise((resolve, reject) => {
  61. try {
  62. setTimeout(resolve, 1000 * attemptNumber);
  63. } catch (e) {
  64. reject(e);
  65. }
  66. });
  67. continue;
  68. }
  69. }
  70. throw e;
  71. }
  72. }
  73. if ((0, _main().isUseOldMacProvider)()) {
  74. result.releaseJsonUrl = channelUrl.href;
  75. }
  76. return result;
  77. })();
  78. }
  79. resolveFiles(updateInfo) {
  80. return (0, _Provider().resolveFiles)(updateInfo, this.baseUrl);
  81. }
  82. } exports.GenericProvider = GenericProvider;
  83. //# sourceMappingURL=GenericProvider.js.map