@seayoo-web/app-info 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -41
- package/dist/index.js +1047 -944
- package/package.json +1 -1
- package/types/index.d.ts +1 -1
- package/types/src/file.apk.d.ts +17 -10
- package/types/src/file.app.d.ts +17 -11
- package/types/src/file.ipa.d.ts +18 -18
- package/types/src/utils/base.d.ts +19 -0
- package/types/src/utils/cgbi.d.ts +18 -0
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from "./src/file.app";
|
|
2
2
|
export * from "./src/file.apk";
|
|
3
3
|
export * from "./src/file.ipa";
|
|
4
|
-
export type { AppCommonInfo, ParserOptions, FileInput } from "./src/utils/base";
|
|
4
|
+
export type { AppCommonInfo, ParserOptions, FileInput, OutputType } from "./src/utils/base";
|
package/types/src/file.apk.d.ts
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import type { AppCommonInfo, FileInput, ParserOptions } from "./utils/base";
|
|
2
|
-
import type {
|
|
3
|
-
export type { Manifest, CollapsedAttributes,
|
|
1
|
+
import type { AppCommonInfo, FileInput, OutputByType, OutputType, ParserOptions } from "./utils/base";
|
|
2
|
+
import type { Manifest } from "./utils/manifest";
|
|
3
|
+
export type { Manifest, CollapsedAttributes, Application } from "./utils/manifest";
|
|
4
4
|
/**
|
|
5
|
-
* Android APK
|
|
5
|
+
* Android APK 应用信息
|
|
6
6
|
*/
|
|
7
|
-
export interface
|
|
7
|
+
export interface AndroidAppInfo extends AppCommonInfo {
|
|
8
8
|
/** Manifest 信息 */
|
|
9
9
|
manifest: Manifest;
|
|
10
|
-
/** Manifest.Application 信息 */
|
|
11
|
-
application?: Application;
|
|
12
|
-
/** Manifest.Application.metaData 信息 */
|
|
13
|
-
metaData?: CollapsedAttributes[];
|
|
14
10
|
}
|
|
15
|
-
export declare
|
|
11
|
+
export declare class AndroidAppParser {
|
|
12
|
+
private zip;
|
|
13
|
+
constructor(file: FileInput);
|
|
14
|
+
parse(options?: ParserOptions): Promise<AndroidAppInfo | Error>;
|
|
15
|
+
/**
|
|
16
|
+
* 读取指定文件的内容
|
|
17
|
+
*/
|
|
18
|
+
readFile<T extends OutputType>(filePath: string, output: T): Promise<{
|
|
19
|
+
name: string;
|
|
20
|
+
content: OutputByType[T];
|
|
21
|
+
} | Error>;
|
|
22
|
+
}
|
package/types/src/file.app.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import type { FileInput, AppCommonInfo, ParserOptions } from "./utils/base";
|
|
2
|
-
import type {
|
|
3
|
-
export type { HosAppPackInfo, Summary, PackageInfo,
|
|
1
|
+
import type { FileInput, AppCommonInfo, ParserOptions, OutputType, OutputByType } from "./utils/base";
|
|
2
|
+
import type { HosAppPackInfo } from "./utils/pack.info";
|
|
3
|
+
export type { HosAppPackInfo, Summary, PackageInfo, DeviceType } from "./utils/pack.info";
|
|
4
4
|
export interface HosAppInfo extends AppCommonInfo {
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
/** 包体信息 */
|
|
6
|
+
pack: HosAppPackInfo;
|
|
7
|
+
}
|
|
8
|
+
export declare class HosAppParser {
|
|
9
|
+
private zip;
|
|
10
|
+
constructor(file: FileInput);
|
|
11
|
+
parse(options?: ParserOptions): Promise<HosAppInfo | Error>;
|
|
12
|
+
/**
|
|
13
|
+
* 读取指定文件的内容
|
|
14
|
+
*/
|
|
15
|
+
readFile<T extends OutputType>(filePath: string, output: T): Promise<{
|
|
16
|
+
name: string;
|
|
17
|
+
content: OutputByType[T];
|
|
18
|
+
} | Error>;
|
|
9
19
|
}
|
|
10
|
-
/**
|
|
11
|
-
* 分析鸿蒙 app 应用的 pack.info 文件
|
|
12
|
-
*/
|
|
13
|
-
export declare function parseHosApp(file: FileInput, options?: ParserOptions): Promise<HosAppInfo | Error>;
|
package/types/src/file.ipa.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import type { AppCommonInfo, FileInput, ParserOptions } from "./utils/base";
|
|
1
|
+
import type { AppCommonInfo, FileInput, OutputByType, OutputType, ParserOptions } from "./utils/base";
|
|
2
2
|
import type { PlistInfo } from "./utils/plist";
|
|
3
|
-
export type { PlistInfo
|
|
3
|
+
export type { PlistInfo } from "./utils/plist";
|
|
4
4
|
/**
|
|
5
5
|
* iOS IPA 应用信息接口
|
|
6
6
|
*/
|
|
7
7
|
export interface IosAppInfo extends AppCommonInfo {
|
|
8
8
|
/** Info.plist 原始数据 */
|
|
9
|
-
plist
|
|
10
|
-
/** 额外的模块 plist 信息 */
|
|
11
|
-
frameworks?: Record<string, PlistInfo | Error | undefined>;
|
|
12
|
-
/** 额外的文件信息 */
|
|
13
|
-
files?: Record<string, ArrayBuffer | Error | undefined>;
|
|
9
|
+
plist: PlistInfo;
|
|
14
10
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* @returns Promise<IosAppInfo | Error>
|
|
19
|
-
*/
|
|
20
|
-
export declare function parseIpa(file: FileInput, options?: ParserOptions & {
|
|
11
|
+
export declare class IosAppParser {
|
|
12
|
+
private zip;
|
|
13
|
+
constructor(file: FileInput);
|
|
21
14
|
/**
|
|
22
|
-
*
|
|
15
|
+
* 解析应用 plist 信息
|
|
23
16
|
*/
|
|
24
|
-
|
|
17
|
+
parse(options?: ParserOptions): Promise<IosAppInfo | Error>;
|
|
25
18
|
/**
|
|
26
|
-
*
|
|
19
|
+
* 读取指定模块的 plist 信息
|
|
27
20
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
parseFramework(name: string): Promise<PlistInfo | Error>;
|
|
22
|
+
/**
|
|
23
|
+
* 读取指定文件的内容
|
|
24
|
+
*/
|
|
25
|
+
readFile<T extends OutputType>(filePath: string, output: T): Promise<{
|
|
26
|
+
name: string;
|
|
27
|
+
content: OutputByType[T];
|
|
28
|
+
} | Error>;
|
|
29
|
+
}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
|
+
import type { PromiseValue } from "@seayoo-web/utils";
|
|
2
|
+
import type { loadAsync } from "jszip";
|
|
1
3
|
export type FileInput = Uint8Array | ArrayBuffer | Blob;
|
|
2
4
|
export type ParserOptions = {
|
|
3
5
|
/** 是否忽略图标,设置为 true 可以节约解析时间 */
|
|
4
6
|
ignoreIcon?: boolean;
|
|
5
7
|
};
|
|
8
|
+
export type JSZip = PromiseValue<ReturnType<typeof loadAsync>>;
|
|
9
|
+
export interface OutputByType {
|
|
10
|
+
base64: string;
|
|
11
|
+
string: string;
|
|
12
|
+
text: string;
|
|
13
|
+
binarystring: string;
|
|
14
|
+
array: number[];
|
|
15
|
+
uint8array: Uint8Array;
|
|
16
|
+
arraybuffer: ArrayBuffer;
|
|
17
|
+
blob: Blob;
|
|
18
|
+
}
|
|
19
|
+
export type OutputType = keyof OutputByType;
|
|
6
20
|
export interface AppCommonInfo {
|
|
7
21
|
/** 包名 */
|
|
8
22
|
package: string;
|
|
@@ -12,8 +26,13 @@ export interface AppCommonInfo {
|
|
|
12
26
|
versionName: string;
|
|
13
27
|
/** dataURI 格式的图标 */
|
|
14
28
|
icon?: string;
|
|
29
|
+
iconPath?: string;
|
|
15
30
|
}
|
|
16
31
|
export declare function toString(d: unknown): string;
|
|
17
32
|
export declare function toNumber(d: unknown): number;
|
|
18
33
|
export declare function formatError(e: unknown): Error;
|
|
19
34
|
export declare function base64Icon(data: string): string;
|
|
35
|
+
export declare function readFile<T extends keyof OutputByType>(zip: JSZip, filePath: string, output: T): Promise<{
|
|
36
|
+
name: string;
|
|
37
|
+
content: OutputByType[T];
|
|
38
|
+
} | Error>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** CgBI PNG 处理工具*/
|
|
2
|
+
/**
|
|
3
|
+
* 将 iOS CgBI PNG 转换为标准 PNG
|
|
4
|
+
* CgBI 是 iOS 特有的 PNG 优化格式,在 PNG 签名后插入了 CgBI 坊块
|
|
5
|
+
* 标准 PNG 解码器无法正确处理这种格式
|
|
6
|
+
*
|
|
7
|
+
* @param arrayBuffer - PNG 文件的 ArrayBuffer 数据
|
|
8
|
+
* @returns 修复后的 ArrayBuffer
|
|
9
|
+
*/
|
|
10
|
+
export declare function fixCgbiPng(arrayBuffer: ArrayBuffer): ArrayBuffer;
|
|
11
|
+
/**
|
|
12
|
+
* 检查 ArrayBuffer 是否为 CgBI PNG
|
|
13
|
+
*/
|
|
14
|
+
export declare function isCgbiPng(arrayBuffer: ArrayBuffer): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 将 ArrayBuffer 转换为 Base64 字符串
|
|
17
|
+
*/
|
|
18
|
+
export declare function arrayBufferToBase64(buffer: ArrayBuffer): string;
|