wxapkg

repository·main·Indexed 26 days ago

https://github.com/wux1an/wxapkg

A desktop application built with Wails for Windows and macOS used to decrypt and unpack WeChat Mini Program (.wxapkg) files. It allows developers to restore original source code structures and provides code beautification for JSON, HTML, and JavaScript files. Key features include automatic scanning of installation directories, manual file specification, and system-level integration for file management.

Tokens
1K
Snippets
0
Records
12
Agent score
37%

What's inside wxapkg

  1. Overview of wxapkg features

    main

    wxapkg is a desktop tool built on Wails designed for decrypting and unpacking WeChat Mini Programs (.wxapkg). It supports both Windows and macOS.

    Key features include:

    • Automatic scanning of WeChat Mini Program installation directories.
    • Manual specification of Mini Program files, directories, or installation paths.
    • Parsing and restoring the original source code file structure.
    • Code beautification for JSON, HTML, and JavaScript files.
  2. Install wxapkg via pre-compiled binaries

    main
    To use wxapkg without building from source, download the pre-compiled version for your platform (Windows or macOS) from the latest Releases page. Once downloaded, simply double-click the executable to run the tool.
  3. Open directory and file dialogs

    main

    Access system file dialogs to allow users to select folders or files.

    • OpenDirectoryDialog(title string, root string) (string, error): Opens a folder selection dialog. Returns the selected path.
    • OpenFileDialog(title string, root string, filters []FileFilter) (string, error): Opens a file selection dialog with specific file type filters.

    FileFilter Structure:

    interface FileFilter {
      DisplayName: string; // Human-readable name (e.g., "WeChat Packages")
      Pattern: string;      // File pattern (e.g., "*.wxapkg")
    }
  4. Unpack a WeChat Wxapkg item

    main

    The UnpackWxapkgItem method initiates the unpacking process for a specific package. It uses a background process and emits a Wails event whenever the progress changes.

    • UnpackWxapkgItem(item wechat.WxapkgItem, options wechat.UnpackOptions): Starts unpacking.
    • Event Notification: The application emits the unpack:progress-changed event via Wails runtime, passing the item.UUID as the payload. Listen for this event in your frontend to update progress bars or status indicators.
  5. Manage WeChat Wxapkg items in AppService

    main

    The AppService maintains an internal state of wechat.WxapkgItem objects using a UUID-based push-pull pattern. You can store items to track their progress and retrieve their latest state using their unique identifier.

    • storeItem(item *wechat.WxapkgItem) *wechat.WxapkgItem: Stores an item in the internal map and returns it.
    • GetWxapkgItem(uuid string) *wechat.WxapkgItem: Retrieves the most recent state of an item by its UUID.
  6. Get default WeChat paths

    main

    Retrieve the standard system paths where WeChat stores its application data using GetDefaultPaths.

    • GetDefaultPaths() wechat.PathScanResult: Returns a result object containing the platform-specific default paths.
  7. Open system paths and URLs

    main

    Perform system-level actions like opening folders in the file explorer or opening URLs in a browser.

    • OpenPath(path string) error: Opens the specified path using the OS default handler (explorer on Windows, open on macOS, xdg-open on Linux).
    • OpenUrl(url string) error: Opens the specified URL in the default web browser.
    • ClipboardSetText(text string) error: Copies the provided string to the system clipboard.
  8. Compute a save path for unpacked content

    main

    Use ComputeSavePath to determine a logical destination directory for unpacked files. It creates a directory name based on the original package name followed by _unpacked.

    • ComputeSavePath(outputDir string, wxapkgPath string) string:
      • outputDir: The base directory where the new folder should be created.
      • wxapkgPath: The full path to the source .wxapkg file.
  9. Scan for WeChat Wxapkg items

    main

    Use ScanWxapkgItem to search a specific directory for WeChat mini-program package files (.wxapkg).

    • ScanWxapkgItem(path string, scan bool) ([]wechat.WxapkgItem, error): Scans the provided path. The scan boolean parameter controls the scanning behavior (refer to wechat package for specific logic).