From 38d30f3be565e2c6616d79b77344c19151bd1781 Mon Sep 17 00:00:00 2001
From: Jonas Jenwald <jonas.jenwald@gmail.com>
Date: Wed, 2 Mar 2022 11:21:47 +0100
Subject: [PATCH] Remove the deprecated `PDFFindController.executeCommand`
 method

This *partially* reverts commit fa8c0ef6164c7abfd5236e97823102a89517f8a4, since it's now been included in two official releases.
---
 examples/components/simpleviewer.js     |  6 +-----
 examples/components/singlepageviewer.js |  6 +-----
 web/pdf_find_controller.js              | 25 ++++---------------------
 3 files changed, 6 insertions(+), 31 deletions(-)

diff --git a/examples/components/simpleviewer.js b/examples/components/simpleviewer.js
index 0ea8e5a38..bab0ab00e 100644
--- a/examples/components/simpleviewer.js
+++ b/examples/components/simpleviewer.js
@@ -77,11 +77,7 @@ eventBus.on("pagesinit", function () {
 
   // We can try searching for things.
   if (SEARCH_FOR) {
-    if (!pdfFindController._onFind) {
-      pdfFindController.executeCommand("find", { query: SEARCH_FOR });
-    } else {
-      eventBus.dispatch("find", { type: "", query: SEARCH_FOR });
-    }
+    eventBus.dispatch("find", { type: "", query: SEARCH_FOR });
   }
 });
 
diff --git a/examples/components/singlepageviewer.js b/examples/components/singlepageviewer.js
index c22db3003..c18f99ebc 100644
--- a/examples/components/singlepageviewer.js
+++ b/examples/components/singlepageviewer.js
@@ -77,11 +77,7 @@ eventBus.on("pagesinit", function () {
 
   // We can try searching for things.
   if (SEARCH_FOR) {
-    if (!pdfFindController._onFind) {
-      pdfFindController.executeCommand("find", { query: SEARCH_FOR });
-    } else {
-      eventBus.dispatch("find", { type: "", query: SEARCH_FOR });
-    }
+    eventBus.dispatch("find", { type: "", query: SEARCH_FOR });
   }
 });
 
diff --git a/web/pdf_find_controller.js b/web/pdf_find_controller.js
index 7b63da6ef..067968e5b 100644
--- a/web/pdf_find_controller.js
+++ b/web/pdf_find_controller.js
@@ -261,22 +261,8 @@ class PDFFindController {
     this._eventBus = eventBus;
 
     this._reset();
-    eventBus._on("find", this._onFind.bind(this));
-    eventBus._on("findbarclose", this._onFindBarClose.bind(this));
-
-    if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
-      this.executeCommand = (cmd, state) => {
-        console.error(
-          "Deprecated method `PDFFindController.executeCommand` called, " +
-            'please dispatch a "find"-event using the EventBus instead.'
-        );
-
-        const eventState = Object.assign(Object.create(null), state, {
-          type: cmd.substring("find".length),
-        });
-        this._onFind(eventState);
-      };
-    }
+    eventBus._on("find", this.#onFind.bind(this));
+    eventBus._on("findbarclose", this.#onFindBarClose.bind(this));
   }
 
   get highlightMatches() {
@@ -316,10 +302,7 @@ class PDFFindController {
     this._firstPageCapability.resolve();
   }
 
-  /**
-   * @private
-   */
-  _onFind(state) {
+  #onFind(state) {
     if (!state) {
       return;
     }
@@ -895,7 +878,7 @@ class PDFFindController {
     }
   }
 
-  _onFindBarClose(evt) {
+  #onFindBarClose(evt) {
     const pdfDocument = this._pdfDocument;
     // Since searching is asynchronous, ensure that the removal of highlighted
     // matches (from the UI) is async too such that the 'updatetextlayermatches'