dsh-wx-preview: Discover, Precompile, and Debug Native WeChat Mini Programs in DSH

Preface

When modifying native WeChat Mini Programs within DSH, the common practice is to open WeChat DevTools or start a separate preview service in the browser. The toolchain and the conversation interface are often separated: it is difficult for the model to view the page, switch routes, or compare WXML directly within the same sidebar. If mapping DOM selections back to the source code is required, a layer of custom debugging scripts usually needs to be stacked on top.

dsh-wx-preview (maintained by zhxnix, categorized as a networking tool in the community directory) is a portable DSH plugin: it reads the project directory you specify, starts a browser-compatible preview runtime locally, and places the preview page into the DSH right sidebar. It is not bound to a specific business repository, port, or user directory; the target project source code is read-only, and caches are written to an independent DSH_WX_PREVIEW_HOME (default ~/.dsh-wx-preview).

What is this

In short: dsh-wx-preview is used to discover, precompile, open, and debug native WeChat Mini Program projects. It parses project.config.json and app.json, precompiles pages, subpackages, components, and WXML/WXSS/JS/JSON, and provides an interactive local preview and a set of DSH tools within DSH.

Preview identity, storage, login status, and the results of wx.getSetting / wx.authorize are all local fixtures; the plugin will not call real WeChat login, read WeChat accounts, write to CloudBase, or modify project source code. The current npm package version is 0.1.1 (see the repository’s package.json), and the license is MIT.

Core Features

The following introduces the capabilities explicitly listed in the plugin’s documentation.

Project Identification and Precompilation

  • Identify any native Mini Program project, as well as the source directory pointed to by miniprogramRoot in project.config.json.
  • Precompile pages, subpackages, components, WXML/WXSS/JS/JSON, and common wx.* APIs.
  • Explicitly reject non-native projects such as UniApp and Taro.

DSH Right Sidebar Preview

  • Start an interactive local preview in the DSH right sidebar, supporting page switching, back navigation, refresh, and hot updates.
  • Even without the annotation plugin, a standalone iframe basic preview can be used, and HTTP(S) preview addresses can be manually entered.

DSH Tools

The plugin registers the following tools with DSH (the model can trigger them via natural language in the session, e.g., “Discover / Open path”):

  • wxpreview_discover
  • wxpreview_precompile
  • wxpreview_open
  • wxpreview_status
  • wxpreview_logs
  • wxpreview_update_identity
  • wxpreview_stop

The url / openInDshSidebar returned by wxpreview_open are local loopback addresses; the preview panel mapping is saved according to the DSH session calling the tool. When the right sidebar requests /dsh-wx-preview/config?sessionId=..., it only returns the preview for the current session, avoiding cross-project interference between multiple sessions.

Collaboration with Annotation Plugins

If dsh-sidebar-annotations is installed, this plugin will use the shared BrowserPanel with the panel type dsh-wx-preview. Web click annotations, continuous multiple annotations, context annotations, console, and DevTools can reuse the same experience. It is recommended to load the annotation plugin first, then load this plugin; this plugin listens for hot update events from the shared panel, and both can be upgraded independently.

The preview DOM will mark source code locations for the annotation plugin to map back to WXML:

data-dsh-source-file="/absolute/path/to/pages/index/index.wxml"
data-dsh-source-line="12"
data-dsh-source-kind="wxml"

This is the actual starting line of the template element, not an inference of JS business logic. Third-party annotation/debugging plugins only need to rely on the above three attributes without needing to understand the internal compilation structure of this plugin.

Command Line (Standalone from DSH)

The plugin provides the CLI dsh-wx-preview, which shares the same preview engine as DSH but does not load DSH tools or the right sidebar UI:

npm install
npx dsh-wx-preview discover ./my-mini-program
npx dsh-wx-preview precompile ./my-mini-program --force
npx dsh-wx-preview serve ./my-mini-program --route pages/index/index

serve starts a local service and runs continuously; press Ctrl-C to stop it.

Installation and Activation

Marketplace inclusion is under review; currently, pre-built packages can be installed from GitHub Releases. The entry is planned to be submitted to awesome-dsh-plugin. The DSH community plugin directory can be found at the SkillHub entry page (this is an independent site for the community ecosystem “Everything is a Plugin” and is not officially affiliated with DeepSeek / Highfity).

Non-managed profile (DSH CLI)

Replace web with the non-managed profile you are actually using:

dsh plugin --profile web add \
  https://github.com/zhxnix/dsh-wx-preview/releases/latest/download/dsh-wx-preview.tgz

Restart DSH after installation and start a new session.

DSH Desktop (managed desktop profile)

For Desktop, please use the repository-provided checkout installer (README requires installation from checkout, not just tgz):

git clone https://github.com/zhxnix/dsh-wx-preview.git
cd dsh-wx-preview
npm install
node scripts/install.mjs --profile desktop

Uninstall:

node scripts/install.mjs --uninstall --profile desktop

If not using the installer, you can manually add the following to the DSH profile’s cordis.patch.yml (adjust paths according to the actual checkout location):

- insert:
    - id: dsh-wx-preview
      name: './plugins/dsh-wx-preview/lib/index.js'

Runtime environment: package.json requires Node ^20.19.0 || >=22.12.0.

Typical Usage

In a DSH Session

State the project path directly in the session, for example:

Discover /Users/me/projects/example-mini
Open /Users/me/projects/example-mini

The model will call the tools with parameters in the following form:

wxpreview_discover({ projectPath })
wxpreview_precompile({ projectPath, force? })
wxpreview_open({ projectPath, route?, port?, force? })
wxpreview_status({ projectPath?, sessionId? })
wxpreview_logs({ projectPath?, sessionId?, limit? })
wxpreview_update_identity({ projectPath, ...fixturePatch })
wxpreview_stop({ projectPath?, sessionId?, all? })

Minimal Repository Example

The repository examples/native-mini-miniprogram is a native Mini Program fixture that does not depend on business projects:

npx dsh-wx-preview discover examples/native-mini-miniprogram
npx dsh-wx-preview precompile examples/native-mini-miniprogram
npx dsh-wx-preview serve examples/native-mini-miniprogram

Project Requirements and Capability Boundaries

  1. The project root directory must contain project.config.json or app.json; if project.config.json exists, the plugin locates the source code according to miniprogramRoot. The source root must have app.json, and app.json must declare at least one pages page.
  2. Native pages, components, and subpackages can use .js, .ts, .json, .wxml, .wxss, .wxs.
  3. WXS, WeChat Plugins, Workers, Maps, Bluetooth, Payment, Canvas, real authorization, CloudBase, and full device capabilities will be indicated in compatibility reports or runtime logs; final verification still requires WeChat DevTools or a real device.

Use Cases and Notes

Who it is for: Developers working on native WeChat Mini Program development or troubleshooting within DSH, who want the model to call unified tools to complete discovery/precompilation/preview opening, and compare WXML in the right sidebar (optionally combined with annotation plugins).

Runtime Permissions: The plugin runs with the permissions of the current DSH process. It will read the project paths you pass and write caches to DSH_WX_PREVIEW_HOME. Please check the GitHub source code and the MIT license (LICENSE) yourself before installation; the general preview engine is adapted from the wxpreview package in the local DSH environment, see NOTICE for source details.

Conclusion

dsh-wx-preview integrates the discovery, precompilation, and local preview of native Mini Programs into DSH tools and the right sidebar, and exposes WXML source mapping on the DOM to facilitate linkage with annotation plugins. Directory and details: SkillHub; Source code and README: github.com/zhxnix/dsh-wx-preview.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye