Installations
npm install harmony-app-parser
Developer Guide
BETA
Typescript
No
Module System
CommonJS, ESM, UMD
Min. Node Version
>=14.0.0
Node Version
18.20.4
NPM Version
10.7.0
Score
58.6
Supply Chain
94.5
Quality
85.2
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Total Downloads
Cumulative downloads
Total Downloads
594
Last day
0%
1
Compared to previous day
Last week
0%
5
Compared to previous week
Last month
-90.7%
25
Compared to previous month
Last year
0%
594
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
No dependencies detected.
Versions
harmony-app-parser
- 解析鸿蒙安装包[.app/.hap/.hsp/.har文件的pack.info/module.json]的信息
- 支持 browser 和 node 环境
- 支持读取包中任何文本文件内容,支持入参指定文件名
安装
1 npm i harmony-app-parser
API
宝子们注意下啊, 浏览器和node环境入参类型有差异,个人觉得更实用一点
浏览器API
1 harmonyParser(file:File, fileList?: Array<FileInfo>):Promise
nodeAPI
1harmonyParser(filePath:String, fileList?: Array<FileInfo>):Promise
公共API
1isHarmonyAPP(fileName: String):Boolean // 文件名是否以.app结尾
类型
FileList (指定读取包中的哪些文本文件的内容,默认读取pack.info 和 module.json)
1 interface FileInfo {key: string, fileName: string} 2 3 // 默认设置的入参,不可覆盖且不可重名 4 [ 5 { 6 key: 'packInfo', 7 fileName: 'pack.info', 8 }, 9 { 10 key: 'moduleInfo', 11 fileName: 'module.json' 12 } 13 ]
使用
浏览器
- 注入widnow
1<body> 2 <input type="file" name="file" id="file"> 3 <script src="./node_modules/harmony-app-parser/dist/harmonyParser-browser.js"></script> 4 <script> 5 let inputFile = document.querySelector('input'); 6 inputFile.onchange = function () { 7 harmonyParser(this.files[0]).then(res => { 8 console.log('res:', res); 9 }).catch(err => { 10 console.log('err:', err) 11 }) 12 } 13 </script> 14</body>
- esmodule
1<body> 2 <input type="file" name="file" id="file"> 3 <script type="module"> 4 import { harmonyParser } from '../dist/harmonyParser-esm.js' 5 let inputFile = document.querySelector('input'); 6 inputFile.onchange = function () { 7 harmonyParser(this.files[0]).then(res => { 8 console.log('res:', res); 9 }).catch(err => { 10 console.log('err:', err) 11 }) 12 } 13 </script> 14</body>
- 或者
1import { harmonyParser } from 'harmony-app-parser'; 2 3function parserApp(e){ 4 let file = document.querySelector('input').files[0]; 5 harmonyParser(file, [{ fileName: 'map.json', key: 'mapInfo'}]).then(res=> { 6 console.log('res:', res) 7 }).catch(err=> { 8 console.log('err:', err); 9 }) 10} 11
nodejs
1const { isHarmonyApp, harmonyParser } = require('harmony-app-parser') 2const path = require('path'); 3 4harmonyParser(path.join(__dirname, './module-router-harmony-default-signed.app')).then(res => { 5 console.log('res:', res) 6}).catch(err => { 7 console.log('err:', err) 8})
联系方式:
邮箱: 724228803@qq.com
No vulnerabilities found.
No security vulnerabilities found.