npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cordova-ohos/cordova-hot-code-push-plugin

v1.5.3

Published

Cordova Hot code Plugin

Downloads

155

Readme

cordova-hot-code-push-plugin

插件简介

cordova-hot-code-push-plugin 是一款高性能 Cordova 热更新插件,专为混合移动应用设计,提供无需应用商店审核的跨平台代码更新解决方案。插件通过对比本地与服务器端的代码版本,实现 HTML、CSS、JavaScript、图片等静态资源的增量 / 全量更新,无需重新打包 IPA/APK/HAR,无需用户手动下载新版本,适用于紧急 Bug 修复、功能快速迭代、资源优化等场景,大幅缩短更新周期、降低发布成本。

插件核心优势:

  • 跨平台兼容:统一 Android/iOS/HarmonyOS 热更新逻辑,API 调用无需区分平台

  • 增量更新:仅传输变更文件(差异补丁),更新体积缩减 70%-90%

  • 灵活可控:支持自动更新、手动触发更新、强制更新、灰度发布

  • 安全可靠:支持 HTTPS 传输加密、文件校验(MD5)、更新失败回滚

  • 低侵入式:不影响原生代码逻辑,仅作用于 Web 资源,集成成本低

  • 完整监控:提供更新进度回调、成功 / 失败状态通知,支持日志上报

核心概念

  • 本地版本:应用安装时内置的 Web 资源版本(存储在 config.xml 中)

  • 服务器版本:部署在远程服务器的最新 Web 资源版本(通过 chcp.json 声明)

  • 全量更新包:包含完整 Web 资源的压缩包(chcp.zip,适用于版本差异较大时)

  • 热更新配置文件chcp.json(版本信息)、chcp.manifest(文件清单与校验值)

安装与卸载

安装步骤

1. 安装核心插件

在 Cordova 项目根目录执行以下命令:

# 安装hcordova
npm install -g hcordova

# 基础安装(推荐稳定版)
hcordova plugin add cordova-hot-code-push-plugin

#指定HarmonyOS安装
hcordova plugin add cordova-hot-code-push-plugin --platform ohos

# 从 GitCode 安装(获取最新开发版)
hcordova plugin add https://gitcode.com/OpenHarmony-Cordova/cordova-hot-code-push-plugin.git --platform ohos

# 安装指定版本
hcordova plugin add [email protected]  --platform ohos

2. 安装 CLI 工具(可选,用于生成配置文件)

# 全局安装 CLI 工具

npm install -g cordova-hot-code-push-plugin-cli

卸载步骤

# 卸载核心插件

hcordova plugin remove cordova-hot-code-push-plugin

# 指定HarmonyOS平台卸载
hcordova plugin remove cordova-hot-code-push-plugin --platform ohos

# 卸载 CLI 工具(如需)

npm uninstall -g cordova-hot-code-push-plugin-cli

工作原理

本地配置

在项目的 config.xml 中配置插件和更新服务器地址。

服务器端配置

在服务器上放置两个文件:

chcp.json:定义版本、更新内容 URL 等。

chcp.manifest:列出所有文件及其哈希值(用于校验)。

更新流程

应用启动 → 检查服务器 chcp.json → 对比版本 → 下载差异文件 → 安装更新。

基本配置步骤

修改 config.xml,增加如下配置

<chcp>
    <!--当前版本不支持自动下载和安装,需调用fetchUpdate检测更新和安装 -->
    <auto-download enabled="false" />
    <auto-install enabled="true" />
    <config-file url="https://www.chuzhitong.com/chcp/www/chcp.json" />
</chcp>

chcp.json配置文件示例

该文件在本地rawfile/www目录下存放一份,然后在服务器存储一份

  • release: 版本号,chcp会判断该版本号和本地版本号比较,判断是否要更新
  • content_url: 更新文件的存储位置
  • 其他参数: 其他参数chcp暂不使用
{
  "name": "cordova",
  "autogenerated": true,
  "ios_identifier": "",
  "android_identifier": "",
  "update": "now",
  "min_native_interface": 1,
  "content_url": "https://www.chuzhitong.com/chcp/www",
  "release": "2024.03.05-16.47.30"
}

chcp.manifest配置文件(可通过插件 CLI 工具生成)

该文件在本地rawfile/www目录下存放一份,然后在服务器存储一份,服务端存储在chcp.json项目目录内

[
  {
    "file": "css/jquery.mobile-1.4.5.min.css",
    "hash": "d6ce4358ecdfe0463a7dddf2d82e3fd7"
  },
  {
    "file": "js/jquery.mobile-1.4.5.min.js",
    "hash": "f5cf4358ecdfe0463a7rfdf2d82e3f4f"
  }
]

js代码部分

function chcpUpdate() {
    //配置新的更新地址,如果不传option,更新地址使用www/chcp.json配置的地址
    var options = {"config-file":"https://www.chuzhitong.com/chcp/www/chcp.json","request-headers":{"userName":"chenlh"}};
    chcp.fetchUpdate(function(action, error, data){
        if(action == "chcp_updateIsReadyToInstall") {
            //检测到更新,更新成功后会自动重启app,每次更新间隔周期需大于1分钟
            //如果要进行测试,修改www/chcp.json的release版本号,修改www/chcp.manifest文件内,其中文件对应的md5值
            if(confirm("是否立即更新")) {
                chcp.installUpdate();
            }
        } else {
            document.getElementById("updateAppInfo").innerHTML = "无更新";
        }

    },options);
}

许可证

本插件基于 Apache License 开源,详见 LICENSE 文件。

联系方式

OHOS Cordova https://gitcode.com/OpenHarmony-Cordova/cordova-hot-code-push-plugin

Android/iOS:https://npmjs.com/cordova-hot-code-push-plugin/issues