download.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __export = (target, all) => {
  7. for (var name in all)
  8. __defProp(target, name, { get: all[name], enumerable: true });
  9. };
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") {
  12. for (let key of __getOwnPropNames(from))
  13. if (!__hasOwnProp.call(to, key) && key !== except)
  14. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  15. }
  16. return to;
  17. };
  18. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  19. var download_exports = {};
  20. __export(download_exports, {
  21. Download: () => Download
  22. });
  23. module.exports = __toCommonJS(download_exports);
  24. class Download {
  25. constructor(page, url, suggestedFilename, artifact) {
  26. this._page = page;
  27. this._url = url;
  28. this._suggestedFilename = suggestedFilename;
  29. this._artifact = artifact;
  30. }
  31. page() {
  32. return this._page;
  33. }
  34. url() {
  35. return this._url;
  36. }
  37. suggestedFilename() {
  38. return this._suggestedFilename;
  39. }
  40. async path() {
  41. return await this._artifact.pathAfterFinished();
  42. }
  43. async saveAs(path) {
  44. return await this._artifact.saveAs(path);
  45. }
  46. async failure() {
  47. return await this._artifact.failure();
  48. }
  49. async createReadStream() {
  50. return await this._artifact.createReadStream();
  51. }
  52. async cancel() {
  53. return await this._artifact.cancel();
  54. }
  55. async delete() {
  56. return await this._artifact.delete();
  57. }
  58. }
  59. // Annotate the CommonJS export names for ESM import in node:
  60. 0 && (module.exports = {
  61. Download
  62. });