Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
dingtalk-h5package-opensdk
Advanced tools
npm install dingtalk-h5package-opensdk --save-dev
npm install dingtalk-h5package-opensdk --save-dev
// localresource.json
{
"miniAppId": "离线包ID",
"accessToken": "开放平台网关ApiToken"
}
{
// key为应用的URL路径地址,值为本地文件或目录
"assets: {
// 目录
"https://www.example.com/myapp": "./dist",
// 文件
"https://www.example.com/myapp/hello.html": "./dist/hello.html"
},
}
{
"externalAssets": [
"https://unpkg.com/react@16.7.0/umd/react.production.min.js"
]
}
{
"scripts": {
"create-h5package": "npx h5package packAndDeploy"
}
}
npm run create-h5package
本地离线包资源打包,在本地输出打包后的离线资源文件,文件格式为.zip。离线包ID自动在 localresource.json 文件中查找。 用法:
npx h5package pack
将指定版本的H5离线包发布到线上。离线包ID和accessToken自动在 localresource.json 文件中查找。 用法:
npx h5package deploy <version>
打包离线包资源,上传并发布到线上。离线包ID和打包配置自动在 localresource.json 文件中查找。
npx h5package packAndDeploy
{
// 离线包ID
miniAppId: string;
// 访问凭证API TOKEN。上传请求开放平台网关时需要。
accessToken: string;
// 线上资源URL和本地文件、目录映射关系。key 为线上资源URL地址,值 为本地文件地址。支持 文件 和 目录
// 示例:
// {
// assets: {
// 键值为目录。将 ./dist 目录下的资源添加到 https://www.example.com/myapp 下
// "https://www.example.com/myapp": "./dist",
// 键值为文件。将 ./favorite.icon 添加到 https://www.example.com/myapp/favorite.ico
// "https://www.example.com/myapp/favorite.ico": "./favorite.ico",
// }
// }
assets: Record<string, string>;
// 依赖的外部URL列表。
// 应用中往往会依赖一些外部资源,如react、vue等外部公共库CDN资源。
// 添加到此配置后,打包脚本会自动通过HTTP GET请求从网络下载资源内容进行打包。
// 示例:
// {
// "externalAssets": [
// "https://unpkg.com/react@16.7.0/umd/react.production.min.js",
// "https://unpkg.com/vue@3.2.45/dist/vue.global.js",
// "https://unpkg.com/jquery@3.6.1/dist/jquery.js"
// ]
// }
externalAssets: string[];
}
import { PackagePacker, H5PackageOpenSDK } from 'dingtalk-package-opensdk';
const miniAppId = '离线包ID';
const accessToken = 'your api token';
const sdk = new H5PackageOpenSDK();
const packer = new PackagePacker({
filename: 'dist.zip',
});
sdk.setConfig({ accessToken });
// 添加本地文件或目录到指定URL
await packer.appendFile('https://www.example.com/myapp', './dist');
// 添加外部文件
await packer.appendUrl('https://unpkg.com/jquery@3.6.1/dist/jquery.js');
// 添加自定义数据,自定义数据在调用 biz.resource.getInfo 时返回
await packer.addBizData({
assetVersion: 'x.y.z',
});
const file = await packer.finalize();
// 创建离线包
const { version } = await sdk.createPackage({ miniAppId, file });
// 发布离线包
await sdk.publishPackage({ miniAppId, version });
FAQs
钉钉H5离线包工具
The npm package dingtalk-h5package-opensdk receives a total of 1 weekly downloads. As such, dingtalk-h5package-opensdk popularity was classified as not popular.
We found that dingtalk-h5package-opensdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.