Browse Source

ref: reorder dev cmd init

Sv443 1 year ago
parent
commit
94a572e8a3
2 changed files with 11 additions and 8 deletions
  1. 4 1
      src/config.ts
  2. 7 7
      src/index.ts

+ 4 - 1
src/config.ts

@@ -1,7 +1,8 @@
-import { ConfigManager, type ConfigMigrationsDict } from "@sv443-network/userutils";
+import { ConfigManager, compress, type ConfigMigrationsDict, decompress } from "@sv443-network/userutils";
 import { featInfo } from "./features/index";
 import { info, log } from "./utils";
 import { emitSiteEvent } from "./siteEvents";
+import { compressionFormat } from "./constants";
 import type { FeatureConfig } from "./types";
 
 /** If this number is incremented, the features object data will be migrated to the new format */
@@ -64,6 +65,8 @@ const cfgMgr = new ConfigManager({
   formatVersion,
   defaultConfig,
   migrations,
+  encodeData: (data) => compress(data, compressionFormat, "string"),
+  decodeData: (data) => decompress(data, compressionFormat, "string"),
 });
 
 /** Initializes the ConfigManager instance and loads persistent data into memory */

+ 7 - 7
src/index.ts

@@ -78,13 +78,6 @@ function preInit() {
 }
 
 async function init() {
-  try {
-    registerMenuCommands();
-  }
-  catch(e) {
-    void e;
-  }
-
   try {
     document.addEventListener("DOMContentLoaded", () => {
       domLoaded = true;
@@ -203,6 +196,13 @@ async function onDomLoad() {
 
     Promise.allSettled(ftInit).then(() => {
       emitInterface("bytm:ready");
+
+      try {
+        registerMenuCommands();
+      }
+      catch(e) {
+        void e;
+      }
     });
   }
   catch(err) {