@predy-js/render-interface 0.3.0-beta.190 → 0.3.0-beta.193
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 +8 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -3
- package/dist/index.mjs.map +1 -1
- package/dist/statistic.js +1 -1
- package/dist/types/Texture.d.ts +1 -0
- package/dist/types/native/PredyNativeInternal.d.ts +38 -32
- package/package.json +1 -1
- package/types/Texture.ts +1 -0
- package/types/native/PredyNativeInternal.ts +47 -38
package/dist/statistic.js
CHANGED
package/dist/types/Texture.d.ts
CHANGED
@@ -23,6 +23,10 @@ export interface PredyRequestResponse {
|
|
23
23
|
export type PredyRequestCallback = (err: string | undefined, res: PredyRequestResponse) => void;
|
24
24
|
export declare const DataCompressMethodZlib = 1;
|
25
25
|
type DataCompressMethod = typeof DataCompressMethodZlib;
|
26
|
+
export declare enum PredyTextEncoding {
|
27
|
+
utf8 = 0,
|
28
|
+
ascii = 1
|
29
|
+
}
|
26
30
|
export interface PredyNativeInternal {
|
27
31
|
webpDisabled?: boolean;
|
28
32
|
createImageBitmap(data: TypedArray | string, //图片文件的数据
|
@@ -30,49 +34,51 @@ export interface PredyNativeInternal {
|
|
30
34
|
getDefaultGPUCapability(): GPUCapability;
|
31
35
|
requestWithCache(options: PredyRequestOptions, callback: PredyRequestCallback): void;
|
32
36
|
/**
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
* decode text from data
|
38
|
+
* @param data
|
39
|
+
* @param encoding 默认utf8
|
40
|
+
*/
|
41
|
+
decodeText(data: Uint8Array, encoding?: PredyTextEncoding): string;
|
37
42
|
/**
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
* 将图片绘制到画布上,同时替换文案,绘制的顺序如下
|
44
|
+
* 创建template.size尺寸的画布, 接下来的绘制均应用 template.offset
|
45
|
+
* 将images绘制到画布上,images的尺寸由image.frame决定
|
46
|
+
* 将数据模板content绘制到画布上,使用variables替换文案
|
47
|
+
* @param template
|
48
|
+
*/
|
44
49
|
renderImageTemplate(template: PredyResizeTemplate): ImageBitmapInternal;
|
45
50
|
/**
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
51
|
+
* 异步绘制图片的模板
|
52
|
+
* @param options
|
53
|
+
* @param callback 如果传入callback就是异步绘制,否则会直接返回结果
|
54
|
+
*/
|
50
55
|
generateSDFImage(options: SDFImageOptions, callback?: renderSDFImageCallback): SDFImage | undefined;
|
51
56
|
/**
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
+
* 下载并且执行脚本文件,此方法会缓存https的脚本内容
|
58
|
+
* 对于http的请求(开发环境),每次都重新请求
|
59
|
+
* @param url
|
60
|
+
* @param callback
|
61
|
+
*/
|
57
62
|
evaluateScriptURL(url: string, callback: (err: Error, result: any) => void): void;
|
58
63
|
/**
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
+
* 将float32Array转换为half float,写入Uint16Array中,
|
65
|
+
* 如果提供了range参数,代表float16会被重新map到range中,以此提高精度范围
|
66
|
+
* 提供range参数后,算法求出source的最大最小值,然后将float16重新映射到range中
|
67
|
+
* 如果source和target的长度不匹配,返回false
|
68
|
+
*/
|
64
69
|
float32ToFloat16(source: Float32Array, target: Uint16Array, range?: vec2): boolean;
|
65
70
|
/**
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
+
* 将half float转换为float32,通过Float32Array返回,
|
72
|
+
* 如果提供了range参数,代表float16会被重新map到range中,以此提高精度范围
|
73
|
+
* 如果没有提供,float16会被直接转化为float32
|
74
|
+
* 如果source和target的长度不匹配,返回false
|
75
|
+
*/
|
71
76
|
float16ToFloat32(source: Uint16Array, target: Float32Array, range?: vec2): boolean;
|
72
77
|
/**
|
73
|
-
|
74
|
-
|
75
|
-
|
78
|
+
* 解压数据
|
79
|
+
* @param data
|
80
|
+
* @param method
|
81
|
+
*/
|
76
82
|
inflateData(data: Uint8Array, method: DataCompressMethod): Uint8Array | undefined;
|
77
83
|
}
|
78
84
|
type renderSDFImageCallback = (img: SDFImage) => void;
|
package/package.json
CHANGED
package/types/Texture.ts
CHANGED
@@ -16,6 +16,7 @@ export interface PredyRequestOptions {
|
|
16
16
|
//使用系统网络库(仅用于试验)
|
17
17
|
useSystemNetwork?: boolean,
|
18
18
|
}
|
19
|
+
|
19
20
|
export enum PredyResourceCacheStatus {
|
20
21
|
noCache = 0, // 没有缓存,走网络请求
|
21
22
|
cached = 1, // 命中缓存,如果请求同一个url,在关闭APP之前,一定会命中缓存,关闭APP后,清理时间由系统决定
|
@@ -34,65 +35,73 @@ export const DataCompressMethodZlib = 1;
|
|
34
35
|
|
35
36
|
type DataCompressMethod = typeof DataCompressMethodZlib;
|
36
37
|
|
38
|
+
export enum PredyTextEncoding {
|
39
|
+
utf8 = 0,
|
40
|
+
ascii = 1,
|
41
|
+
}
|
42
|
+
|
37
43
|
export interface PredyNativeInternal {
|
38
44
|
webpDisabled?: boolean,
|
39
45
|
|
40
|
-
createImageBitmap
|
46
|
+
createImageBitmap(data: TypedArray | string, //图片文件的数据
|
41
47
|
options: ImageBitmapConstructor, callback: ImageBitmapCallback): void,
|
42
48
|
|
43
|
-
getDefaultGPUCapability
|
49
|
+
getDefaultGPUCapability(): GPUCapability,
|
44
50
|
|
45
|
-
requestWithCache
|
51
|
+
requestWithCache(options: PredyRequestOptions, callback: PredyRequestCallback): void,
|
46
52
|
|
47
53
|
/**
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
54
|
+
* decode text from data
|
55
|
+
* @param data
|
56
|
+
* @param encoding 默认utf8
|
57
|
+
*/
|
58
|
+
decodeText(data: Uint8Array, encoding?: PredyTextEncoding): string,
|
59
|
+
|
52
60
|
/**
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
renderImageTemplate
|
61
|
+
* 将图片绘制到画布上,同时替换文案,绘制的顺序如下
|
62
|
+
* 创建template.size尺寸的画布, 接下来的绘制均应用 template.offset
|
63
|
+
* 将images绘制到画布上,images的尺寸由image.frame决定
|
64
|
+
* 将数据模板content绘制到画布上,使用variables替换文案
|
65
|
+
* @param template
|
66
|
+
*/
|
67
|
+
renderImageTemplate(template: PredyResizeTemplate): ImageBitmapInternal,
|
60
68
|
|
61
69
|
/**
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
generateSDFImage
|
70
|
+
* 异步绘制图片的模板
|
71
|
+
* @param options
|
72
|
+
* @param callback 如果传入callback就是异步绘制,否则会直接返回结果
|
73
|
+
*/
|
74
|
+
generateSDFImage(options: SDFImageOptions, callback?: renderSDFImageCallback): SDFImage | undefined,
|
67
75
|
|
68
76
|
/**
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
evaluateScriptURL
|
77
|
+
* 下载并且执行脚本文件,此方法会缓存https的脚本内容
|
78
|
+
* 对于http的请求(开发环境),每次都重新请求
|
79
|
+
* @param url
|
80
|
+
* @param callback
|
81
|
+
*/
|
82
|
+
evaluateScriptURL(url: string, callback: (err: Error, result: any) => void): void,
|
75
83
|
|
76
84
|
/**
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
85
|
+
* 将float32Array转换为half float,写入Uint16Array中,
|
86
|
+
* 如果提供了range参数,代表float16会被重新map到range中,以此提高精度范围
|
87
|
+
* 提供range参数后,算法求出source的最大最小值,然后将float16重新映射到range中
|
88
|
+
* 如果source和target的长度不匹配,返回false
|
89
|
+
*/
|
82
90
|
float32ToFloat16(source: Float32Array, target: Uint16Array, range?: vec2): boolean,
|
83
91
|
|
84
92
|
/**
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
93
|
+
* 将half float转换为float32,通过Float32Array返回,
|
94
|
+
* 如果提供了range参数,代表float16会被重新map到range中,以此提高精度范围
|
95
|
+
* 如果没有提供,float16会被直接转化为float32
|
96
|
+
* 如果source和target的长度不匹配,返回false
|
97
|
+
*/
|
90
98
|
float16ToFloat32(source: Uint16Array, target: Float32Array, range?: vec2): boolean,
|
91
99
|
|
92
100
|
/**
|
93
|
-
|
94
|
-
|
95
|
-
|
101
|
+
* 解压数据
|
102
|
+
* @param data
|
103
|
+
* @param method
|
104
|
+
*/
|
96
105
|
inflateData(data: Uint8Array, method: DataCompressMethod): Uint8Array | undefined,
|
97
106
|
}
|
98
107
|
|