feat:android support ArrayBuffer Resource
This commit is contained in:
5
doric-js/lib/src/native/imageDecoder.d.ts
vendored
5
doric-js/lib/src/native/imageDecoder.d.ts
vendored
@@ -1,9 +1,10 @@
|
||||
import { Resource } from "../util/resource";
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
export declare function imageDecoder(context: BridgeContext): {
|
||||
decode: (resource: Resource) => Promise<{
|
||||
getImageInfo: (resource: Resource) => Promise<{
|
||||
width: number;
|
||||
height: number;
|
||||
format: string;
|
||||
mimeType: string;
|
||||
}>;
|
||||
decodeToPixels: (resource: Resource) => Promise<ArrayBuffer>;
|
||||
};
|
||||
|
@@ -24,12 +24,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
};
|
||||
export function imageDecoder(context) {
|
||||
return {
|
||||
decode: (resource) => __awaiter(this, void 0, void 0, function* () {
|
||||
yield context.callNative('imageDecoder', 'loadResource', resource);
|
||||
const imageInfo = yield context.callNative('imageDecoder', 'getImageInfo', resource.resId);
|
||||
const pixels = yield context.callNative('imageDecoder', 'decodeToPixels', resource.resId);
|
||||
yield context.callNative('imageDecoder', 'releaseResource', resource.resId);
|
||||
return Object.assign(Object.assign({}, imageInfo), { pixels });
|
||||
getImageInfo: (resource) => {
|
||||
return context.callNative('imageDecoder', 'getImageInfo', resource);
|
||||
},
|
||||
decodeToPixels: (resource) => __awaiter(this, void 0, void 0, function* () {
|
||||
return context.callNative('imageDecoder', 'decodeToPixels', resource);
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
1
doric-js/lib/src/native/index.native.d.ts
vendored
1
doric-js/lib/src/native/index.native.d.ts
vendored
@@ -11,3 +11,4 @@ export * from './coordinator';
|
||||
export * from './notch';
|
||||
export * from './keyboard';
|
||||
export * from './resourceLoader';
|
||||
export * from './imageDecoder';
|
||||
|
@@ -26,3 +26,4 @@ export * from './coordinator';
|
||||
export * from './notch';
|
||||
export * from './keyboard';
|
||||
export * from './resourceLoader';
|
||||
export * from './imageDecoder';
|
||||
|
3
doric-js/lib/src/util/resource.d.ts
vendored
3
doric-js/lib/src/util/resource.d.ts
vendored
@@ -50,3 +50,6 @@ export declare class MainBundleResource extends iOSResource {
|
||||
export declare class BundleResource extends iOSResource {
|
||||
constructor(bundleName: string, fileName: string);
|
||||
}
|
||||
export declare class ArrayBufferResource extends Resource {
|
||||
constructor(data: ArrayBuffer);
|
||||
}
|
||||
|
@@ -71,3 +71,8 @@ export class BundleResource extends iOSResource {
|
||||
super("bundle", `${bundleName}://${fileName}`);
|
||||
}
|
||||
}
|
||||
export class ArrayBufferResource extends Resource {
|
||||
constructor(data) {
|
||||
super("arrayBuffer", "");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user