/**
 * migrate.js
 */

import {
  getStorage, removeStorage, updateCommand,
} from "./browser.js";

/* constants */
import {EDITOR_EXEC, OPTIONS_OPEN} from "./constant.js";
const KEY_ACCESS = "accessKey";
const KEY_EDITOR = "editorShortCut";
const KEY_OPTIONS = "optionsShortCut";

/**
 * migrate old storage
 * @returns {Promise.<Array>} - results of each handler
 */
export const migrateStorage = async () => {
  const store = await getStorage([
    EDITOR_EXEC,
    KEY_ACCESS,
    KEY_EDITOR,
    KEY_OPTIONS,
    OPTIONS_OPEN,
  ]);
  const func = [];
  if (store[EDITOR_EXEC]) {
    const {value} = store[EDITOR_EXEC];
    await updateCommand(EDITOR_EXEC, value);
    func.push(removeStorage(EDITOR_EXEC));
  }
  if (store[OPTIONS_OPEN]) {
    const {value} = store[OPTIONS_OPEN];
    await updateCommand(OPTIONS_OPEN, value);
    func.push(removeStorage(OPTIONS_OPEN));
  }
  if (store[KEY_ACCESS]) {
    func.push(removeStorage(KEY_ACCESS));
  }
  if (store[KEY_EDITOR]) {
    func.push(removeStorage(KEY_EDITOR));
  }
  if (store[KEY_OPTIONS]) {
    func.push(removeStorage(KEY_OPTIONS));
  }
  return Promise.all(func);
};

@@ -26,24 +26,27 @@
 port %7B%0A  get
+All
 Storage, rem
@@ -72,16 +72,16 @@
 ommand,%0A
-
 %7D from %22
@@ -169,16 +169,46 @@
 nt.js%22;%0A
+const ENABLE_PB = %22enablePB%22;%0A
 const KE
@@ -464,24 +464,27 @@
 wait get
+All
 Storage(
 %5B%0A    ED
@@ -479,97 +479,8 @@
 age(
-%5B%0A    EDITOR_EXEC,%0A    KEY_ACCESS,%0A    KEY_EDITOR,%0A    KEY_OPTIONS,%0A    OPTIONS_OPEN,%0A  %5D
 );%0A 
@@ -765,32 +765,32 @@
 S_OPEN, value);%0A
-
     func.push(re
@@ -813,32 +813,103 @@
 ONS_OPEN));%0A  %7D%0A
+  if (store%5BENABLE_PB%5D) %7B%0A    func.push(removeStorage(ENABLE_PB));%0A  %7D%0A
   if (store%5BKEY_

Update migrate.js