For reference:
https://github.com/mozilla/pdf.js/issues/15571#issuecomment-1278141781
cmd,
    undo,
    mustExec,
    type = NaN,
    overwriteIfSameType = false,
    keepUndo = false,
  }) {
    if (mustExec) {
      cmd();
    }
    if (this.#locked) {
      return;
    }
    const save = { cmd, undo, type };
    if (this.#position === -1) {
      if (this.#commands.length > 0) {
        
        
        this.#commands.length = 0;