chromium.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. "use strict";
  2. /**
  3. * Copyright 2023 Google Inc. All rights reserved.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. var __importDefault = (this && this.__importDefault) || function (mod) {
  18. return (mod && mod.__esModule) ? mod : { "default": mod };
  19. };
  20. Object.defineProperty(exports, "__esModule", { value: true });
  21. exports.resolveBuildId = exports.relativeExecutablePath = exports.resolveDownloadPath = exports.resolveDownloadUrl = void 0;
  22. const path_1 = __importDefault(require("path"));
  23. const httpUtil_js_1 = require("../httpUtil.js");
  24. const types_js_1 = require("./types.js");
  25. function archive(platform, buildId) {
  26. switch (platform) {
  27. case types_js_1.BrowserPlatform.LINUX:
  28. return 'chrome-linux';
  29. case types_js_1.BrowserPlatform.MAC_ARM:
  30. case types_js_1.BrowserPlatform.MAC:
  31. return 'chrome-mac';
  32. case types_js_1.BrowserPlatform.WIN32:
  33. case types_js_1.BrowserPlatform.WIN64:
  34. // Windows archive name changed at r591479.
  35. return parseInt(buildId, 10) > 591479 ? 'chrome-win' : 'chrome-win32';
  36. }
  37. }
  38. function folder(platform) {
  39. switch (platform) {
  40. case types_js_1.BrowserPlatform.LINUX:
  41. return 'Linux_x64';
  42. case types_js_1.BrowserPlatform.MAC_ARM:
  43. return 'Mac_Arm';
  44. case types_js_1.BrowserPlatform.MAC:
  45. return 'Mac';
  46. case types_js_1.BrowserPlatform.WIN32:
  47. return 'Win';
  48. case types_js_1.BrowserPlatform.WIN64:
  49. return 'Win_x64';
  50. }
  51. }
  52. function resolveDownloadUrl(platform, buildId, baseUrl = 'https://storage.googleapis.com/chromium-browser-snapshots') {
  53. return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
  54. }
  55. exports.resolveDownloadUrl = resolveDownloadUrl;
  56. function resolveDownloadPath(platform, buildId) {
  57. return [folder(platform), buildId, `${archive(platform, buildId)}.zip`];
  58. }
  59. exports.resolveDownloadPath = resolveDownloadPath;
  60. function relativeExecutablePath(platform, _buildId) {
  61. switch (platform) {
  62. case types_js_1.BrowserPlatform.MAC:
  63. case types_js_1.BrowserPlatform.MAC_ARM:
  64. return path_1.default.join('chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium');
  65. case types_js_1.BrowserPlatform.LINUX:
  66. return path_1.default.join('chrome-linux', 'chrome');
  67. case types_js_1.BrowserPlatform.WIN32:
  68. case types_js_1.BrowserPlatform.WIN64:
  69. return path_1.default.join('chrome-win', 'chrome.exe');
  70. }
  71. }
  72. exports.relativeExecutablePath = relativeExecutablePath;
  73. async function resolveBuildId(platform) {
  74. return await (0, httpUtil_js_1.getText)(new URL(`https://storage.googleapis.com/chromium-browser-snapshots/${folder(platform)}/LAST_CHANGE`));
  75. }
  76. exports.resolveBuildId = resolveBuildId;
  77. //# sourceMappingURL=chromium.js.map