@predy-js/render-interface 0.2.0-beta.1 → 0.2.0-beta.11
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/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -2
- package/dist/index.mjs.map +1 -1
- package/dist/src/render/MarsTextureFactory.d.ts +1 -1
- package/dist/statistic.js +1 -1
- package/dist/types/native/PredyNativeInternal.d.ts +13 -19
- package/dist/types/native/RendererInternal.d.ts +13 -0
- package/package.json +1 -1
- package/types/native/PredyNativeInternal.ts +15 -20
- package/types/native/RendererInternal.ts +16 -0
@@ -5,7 +5,7 @@ export declare class MarsTextureFactory implements TextureFactory {
|
|
5
5
|
[key: string]: Promise<Texture>;
|
6
6
|
};
|
7
7
|
constructor();
|
8
|
-
loadMipmapImagesAsync(pointers: vec2[], bin: ArrayBuffer): Promise<(
|
8
|
+
loadMipmapImagesAsync(pointers: vec2[], bin: ArrayBuffer): Promise<(HTMLImageElement | ImageBitmap)[]>;
|
9
9
|
loadImageAsync(url: string | HTMLImageElement | Blob): Promise<HTMLImageElement | ImageBitmap>;
|
10
10
|
requestBinaryAsync(url: string): Promise<ArrayBuffer>;
|
11
11
|
loadImageBinaryAsync(binary: ArrayBuffer | TypedArray | Blob, mime?: string): Promise<HTMLImageElement | ImageBitmap>;
|
package/dist/statistic.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
|
2
|
-
import type { TypedArray
|
2
|
+
import type { TypedArray } from '../type';
|
3
3
|
import type { GPUCapability } from '../GPUCapability';
|
4
|
-
import type {
|
4
|
+
import type { PredyResizeTemplate, SDFImageOptions, SDFImage } from '@predy-js/specification';
|
5
5
|
import type { ImageBitmapInternal } from './ImageBitmapInternal';
|
6
6
|
export interface PredyRequestOptions {
|
7
7
|
url: string;
|
@@ -39,25 +39,19 @@ export interface PredyNativeInternal {
|
|
39
39
|
* @param template
|
40
40
|
*/
|
41
41
|
renderImageTemplate(template: PredyResizeTemplate): ImageBitmapInternal;
|
42
|
-
}
|
43
|
-
export interface PredyResizeTemplate {
|
44
|
-
/**
|
45
|
-
* 要替换的文案
|
46
|
-
*/
|
47
|
-
content: StringTemplate;
|
48
|
-
/**
|
49
|
-
* 要绘制的图片
|
50
|
-
*/
|
51
|
-
images: Array<{
|
52
|
-
s: ImageBitmap;
|
53
|
-
frame: vec4;
|
54
|
-
}>;
|
55
42
|
/**
|
56
|
-
*
|
43
|
+
* 异步绘制图片的模板
|
44
|
+
* @param options
|
45
|
+
* @param callback 如果传入callback就是异步绘制,否则会直接返回结果
|
57
46
|
*/
|
58
|
-
|
47
|
+
generateSDFImage(options: SDFImageOptions, callback?: renderSDFImageCallback): SDFImage | undefined;
|
59
48
|
/**
|
60
|
-
*
|
49
|
+
* 下载并且执行脚本文件,此方法会缓存https的脚本内容
|
50
|
+
* 对于http的请求(开发环境),每次都重新请求
|
51
|
+
* @param url
|
52
|
+
* @param callback
|
61
53
|
*/
|
62
|
-
|
54
|
+
evaluateScriptURL(url: string, callback: (err: Error, result: any) => void): void;
|
63
55
|
}
|
56
|
+
type renderSDFImageCallback = (img: SDFImage) => void;
|
57
|
+
export {};
|
@@ -29,6 +29,11 @@ export interface RendererInternalCompleteInfo {
|
|
29
29
|
frame: number;
|
30
30
|
cpuTime?: number;
|
31
31
|
}
|
32
|
+
export declare enum RendererLostReason {
|
33
|
+
unknown = 0,
|
34
|
+
removeByParent = 1,
|
35
|
+
glContextLost = 2
|
36
|
+
}
|
32
37
|
export declare abstract class RendererInternal implements ResourceInternal {
|
33
38
|
readonly isDestroyed: boolean;
|
34
39
|
readonly platform: ResourcePlatform;
|
@@ -60,6 +65,14 @@ export declare abstract class RendererInternal implements ResourceInternal {
|
|
60
65
|
abstract getResourceInfo(): InternalResInfo;
|
61
66
|
abstract requestAnimationFrame(callback: FrameRequestCallback): number;
|
62
67
|
abstract cancelAnimationFrame(id: number): void;
|
68
|
+
/**
|
69
|
+
* 当view被从客户端移除时,会触发此回调
|
70
|
+
* 如果丢失GL Context也会触发此函数
|
71
|
+
* 当此函数发生时,需要立刻销毁Renderer对象
|
72
|
+
* 如果renderer已经被销毁了,这个回调不会被调用
|
73
|
+
* @param callback
|
74
|
+
*/
|
75
|
+
abstract setRendererLostCallback(callback: (reason: RendererLostReason) => void): void;
|
63
76
|
/**
|
64
77
|
* 下一帧渲染完成后的回调,在调用removeRenderCompleteCallback前,不需要重复注册
|
65
78
|
*/
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
|
2
|
-
import type { TypedArray
|
2
|
+
import type { TypedArray } from '../type';
|
3
3
|
import type { GPUCapability } from '../GPUCapability';
|
4
|
-
import type {
|
4
|
+
import type { PredyResizeTemplate, SDFImageOptions, SDFImage } from '@predy-js/specification';
|
5
5
|
import type { ImageBitmapInternal } from './ImageBitmapInternal';
|
6
6
|
export interface PredyRequestOptions {
|
7
7
|
url: string,
|
@@ -28,6 +28,7 @@ export type PredyRequestCallback = (err: string | undefined, res: PredyRequestRe
|
|
28
28
|
|
29
29
|
export interface PredyNativeInternal {
|
30
30
|
webpDisabled?: boolean,
|
31
|
+
|
31
32
|
createImageBitmap (data: TypedArray | string, //图片文件的数据
|
32
33
|
options: ImageBitmapConstructor, callback: ImageBitmapCallback): void,
|
33
34
|
|
@@ -48,27 +49,21 @@ export interface PredyNativeInternal {
|
|
48
49
|
* @param template
|
49
50
|
*/
|
50
51
|
renderImageTemplate (template: PredyResizeTemplate): ImageBitmapInternal,
|
51
|
-
}
|
52
|
-
export interface PredyResizeTemplate {
|
53
|
-
/**
|
54
|
-
* 要替换的文案
|
55
|
-
*/
|
56
|
-
content: StringTemplate,
|
57
52
|
|
58
53
|
/**
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
s: ImageBitmap,
|
63
|
-
//图片绘制区域,尺寸可能和image不一样
|
64
|
-
frame: vec4,
|
65
|
-
}>,
|
66
|
-
/**
|
67
|
-
* 画布尺寸
|
54
|
+
* 异步绘制图片的模板
|
55
|
+
* @param options
|
56
|
+
* @param callback 如果传入callback就是异步绘制,否则会直接返回结果
|
68
57
|
*/
|
69
|
-
|
58
|
+
generateSDFImage (options: SDFImageOptions, callback?: renderSDFImageCallback): SDFImage | undefined,
|
59
|
+
|
70
60
|
/**
|
71
|
-
*
|
61
|
+
* 下载并且执行脚本文件,此方法会缓存https的脚本内容
|
62
|
+
* 对于http的请求(开发环境),每次都重新请求
|
63
|
+
* @param url
|
64
|
+
* @param callback
|
72
65
|
*/
|
73
|
-
|
66
|
+
evaluateScriptURL (url: string, callback: (err: Error, result: any) => void): void,
|
74
67
|
}
|
68
|
+
|
69
|
+
type renderSDFImageCallback = (img: SDFImage) => void;
|
@@ -35,6 +35,12 @@ export interface RendererInternalCompleteInfo {
|
|
35
35
|
cpuTime?: number,
|
36
36
|
}
|
37
37
|
|
38
|
+
export enum RendererLostReason {
|
39
|
+
unknown = 0,
|
40
|
+
removeByParent = 1,
|
41
|
+
glContextLost = 2,
|
42
|
+
}
|
43
|
+
|
38
44
|
export abstract class RendererInternal implements ResourceInternal {
|
39
45
|
readonly isDestroyed: boolean;
|
40
46
|
readonly platform: ResourcePlatform;
|
@@ -81,6 +87,16 @@ export abstract class RendererInternal implements ResourceInternal {
|
|
81
87
|
abstract requestAnimationFrame (callback: FrameRequestCallback): number;
|
82
88
|
|
83
89
|
abstract cancelAnimationFrame (id: number): void;
|
90
|
+
|
91
|
+
/**
|
92
|
+
* 当view被从客户端移除时,会触发此回调
|
93
|
+
* 如果丢失GL Context也会触发此函数
|
94
|
+
* 当此函数发生时,需要立刻销毁Renderer对象
|
95
|
+
* 如果renderer已经被销毁了,这个回调不会被调用
|
96
|
+
* @param callback
|
97
|
+
*/
|
98
|
+
abstract setRendererLostCallback (callback: (reason: RendererLostReason) => void): void;
|
99
|
+
|
84
100
|
/**
|
85
101
|
* 下一帧渲染完成后的回调,在调用removeRenderCompleteCallback前,不需要重复注册
|
86
102
|
*/
|