For reference:
https://github.com/mozilla/pdf.js/issues/15571#issuecomment-1278141781
if (this.#position === -1) {
      
      return;
    }
    
    this.#locked = true;
    this.#commands[this.#position].undo();
    this.#locked = false;
    this.#position -= 1;
  }
  /**
   * Redo the last command.
   */
  redo() {
    if (this.#position < this.#commands.length - 1) {
      this.#position += 1;
      
      this.#locked = true;
      this.#commands[this.#position].cmd();
      this.#locked = false;
    }
  }
  /**
   * Check if there is something to undo.
   * @returns {boolean}
   */
  hasSomethingToUndo() {