From 8a17b9ce0b23cdcc4b5b08ae3a7a4ce931ce6a60 Mon Sep 17 00:00:00 2001 From: SuperMonster003 <30370009+SuperMonster003@users.noreply.github.com> Date: Tue, 1 Sep 2026 19:31:05 +0800 Subject: [PATCH] feat(mediainfo): declare snapshot v2 APIs --- declarations/autojs6/aj6-int-mediainfo.d.ts | 118 ++++++++++++++++++++ declarations/autojs6/index.d.ts | 3 +- docs/smoke/mediainfo-snapshot-v2-smoke.ts | 15 +++ 3 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 declarations/autojs6/aj6-int-mediainfo.d.ts create mode 100644 docs/smoke/mediainfo-snapshot-v2-smoke.ts diff --git a/declarations/autojs6/aj6-int-mediainfo.d.ts b/declarations/autojs6/aj6-int-mediainfo.d.ts new file mode 100644 index 0000000..c1c28cc --- /dev/null +++ b/declarations/autojs6/aj6-int-mediainfo.d.ts @@ -0,0 +1,118 @@ +// Type definitions for AutoJs6 internal module mediainfo +// +// Definitions by: SuperMonster003 +// TypeScript Version: 5.1.3 +// +// Last modified: Sep 1, 2026 + +/// + +/** + * @Source %AutoJs6%/app/src/main/java/org/autojs/autojs/runtime/api/augment/mediainfo/Mediainfo.kt + * @Source %AutoJs6%/app/src/main/java/org/autojs/autojs/runtime/api/augment/mediainfo/MediainfoNativeObject.kt + * @Source %AutoJs6%/app/src/main/java/org/autojs/autojs/core/plugin/mediainfo/MediainfoPluginHost.kt + */ + +declare namespace Internal { + + interface Mediainfo { + (path: string): Mediainfo.Result; + + readonly SNAPSHOT_SCHEMA_V1: 'autojs6-plugin-mediainfo-snapshot-v1'; + readonly SNAPSHOT_SCHEMA_V2: 'autojs6-plugin-mediainfo-snapshot-v2'; + + read(path: string): Mediainfo.Result; + + snapshot(path: string, options: Mediainfo.SnapshotOptions & { readonly schema: 'autojs6-plugin-mediainfo-snapshot-v1' }): Mediainfo.SnapshotV1; + snapshot(path: string, options: Mediainfo.SnapshotOptions & { readonly schema: 'autojs6-plugin-mediainfo-snapshot-v2' }): Mediainfo.SnapshotV2; + snapshot(path: string, options?: Mediainfo.DefaultSnapshotOptions): Mediainfo.SnapshotV1; + snapshot(path: string, options: Mediainfo.SnapshotOptions): Mediainfo.Snapshot; + + capabilities(): Mediainfo.Capabilities; + } + +} + +declare namespace Mediainfo { + + type StreamKind = 'general' | 'video' | 'audio' | 'text' | 'other' | 'image' | 'menu' | 'max'; + + type SnapshotSchema = + | 'autojs6-plugin-mediainfo-snapshot-v1' + | 'autojs6-plugin-mediainfo-snapshot-v2'; + + type SnapshotJsonPrimitive = string | number | boolean | null; + type SnapshotJsonValue = SnapshotJsonPrimitive | SnapshotJsonValue[] | { [key: string]: SnapshotJsonValue }; + + interface SnapshotOptions { + readonly includeInform?: boolean; + readonly includeSections?: boolean; + readonly schema?: SnapshotSchema; + } + + interface DefaultSnapshotOptions extends SnapshotOptions { + readonly schema?: undefined; + } + + interface SnapshotV1 { + readonly schema: 'autojs6-plugin-mediainfo-snapshot-v1'; + readonly fileName: string; + readonly sizeBytes: number; + readonly inform: string; + readonly sections: Record>>; + } + + interface SnapshotV2Track { + readonly fields: Record; + readonly attributes?: Record; + readonly extra?: Record; + } + + interface SnapshotV2 { + readonly schema: 'autojs6-plugin-mediainfo-snapshot-v2'; + readonly file: { + readonly name: string; + readonly sizeBytes: number; + }; + readonly engine: { + readonly name: string; + readonly version: string; + readonly url?: string; + }; + readonly inform: string; + readonly tracks: Record; + } + + type Snapshot = SnapshotV1 | SnapshotV2; + + interface Capabilities { + readonly snapshotSchemas: SnapshotSchema[]; + readonly defaultSnapshotSchema: SnapshotSchema; + readonly engineVersion?: string; + } + + interface StreamAccessor { + (parameter?: string): string; + + [property: string]: string | ((parameter?: string) => string); + } + + interface Result { + readonly path: string; + readonly inform: string; + + readonly general: StreamAccessor; + readonly video: StreamAccessor; + readonly audio: StreamAccessor; + readonly text: StreamAccessor; + readonly other: StreamAccessor; + readonly image: StreamAccessor; + readonly menu: StreamAccessor; + readonly max: StreamAccessor; + + toString(): string; + + [section: string]: any; + } + +} diff --git a/declarations/autojs6/index.d.ts b/declarations/autojs6/index.d.ts index f12c808..be43686 100644 --- a/declarations/autojs6/index.d.ts +++ b/declarations/autojs6/index.d.ts @@ -22,6 +22,7 @@ /// /// /// +/// /// /// /// @@ -56,4 +57,4 @@ /// /// /// -/// \ No newline at end of file +/// diff --git a/docs/smoke/mediainfo-snapshot-v2-smoke.ts b/docs/smoke/mediainfo-snapshot-v2-smoke.ts new file mode 100644 index 0000000..c904699 --- /dev/null +++ b/docs/smoke/mediainfo-snapshot-v2-smoke.ts @@ -0,0 +1,15 @@ +declare const mediainfoApi: Internal.Mediainfo; + +const legacyResult: Mediainfo.Result = mediainfoApi('./sample.mp4'); +const defaultSnapshot: Mediainfo.SnapshotV1 = mediainfoApi.snapshot('./sample.mp4'); +const snapshotV1: Mediainfo.SnapshotV1 = mediainfoApi.snapshot('./sample.mp4', { + schema: mediainfoApi.SNAPSHOT_SCHEMA_V1, + includeSections: true, +}); +const snapshotV2: Mediainfo.SnapshotV2 = mediainfoApi.snapshot('./sample.mp4', { + schema: mediainfoApi.SNAPSHOT_SCHEMA_V2, + includeInform: false, +}); +const capabilities: Mediainfo.Capabilities = mediainfoApi.capabilities(); + +void [legacyResult, defaultSnapshot, snapshotV1, snapshotV2, capabilities];