@predy-js/render-interface 0.1.78 → 0.1.79

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.
@@ -19,5 +19,6 @@ export declare class MarsRenderer implements GPURenderer {
19
19
  resize(width: number, height: number): void;
20
20
  cancelAnimationFrame(id: number): void;
21
21
  getErrors(): string[];
22
+ invalid(): void;
22
23
  requestAnimationFrame(cb: FrameRequestCallback): number;
23
24
  }
package/dist/statistic.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Name: @predy-js/render-interface
3
3
  * Description: undefined
4
4
  * Author: undefined
5
- * Version: v0.1.78
5
+ * Version: v0.1.79
6
6
  */
7
7
 
8
8
  // https://github.com/greggman/webgl-memory/blob/main/src/texture-utils.js
@@ -59,4 +59,8 @@ export declare class GPURenderer implements IGPURenderer {
59
59
  * @param haltGL if true, this method will call webgl lose context extension which leads webgl absolutely halt
60
60
  */
61
61
  destroy(haltGL?: boolean): void;
62
+ /**
63
+ * 此帧需要进行绘制
64
+ */
65
+ invalid(): void;
62
66
  }
@@ -1,7 +1,8 @@
1
1
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
2
- import type { TypedArray, vec2 } from '../type';
2
+ import type { TypedArray, vec2, vec4 } from '../type';
3
3
  import type { GPUCapability } from '../GPUCapability';
4
4
  import type { StringTemplate } from '@predy-js/specification';
5
+ import type { ImageBitmapInternal } from './ImageBitmapInternal';
5
6
  export interface PredyRequestOptions {
6
7
  url: string;
7
8
  disableCache?: boolean;
@@ -19,27 +20,38 @@ export interface PredyRequestResponse {
19
20
  time: number;
20
21
  }
21
22
  export type PredyRequestCallback = (err: string | undefined, res: PredyRequestResponse) => void;
22
- export declare abstract class PredyNativeInternal {
23
- abstract createImageBitmap(data: TypedArray | string, //图片文件的数据
23
+ export interface PredyNativeInternal {
24
+ webpDisabled?: boolean;
25
+ createImageBitmap(data: TypedArray | string, //图片文件的数据
24
26
  options: ImageBitmapConstructor, callback: ImageBitmapCallback): void;
25
- abstract getDefaultGPUCapability(): GPUCapability;
26
- abstract requestWithCache(options: PredyRequestOptions, callback: PredyRequestCallback): void;
27
+ getDefaultGPUCapability(): GPUCapability;
28
+ requestWithCache(options: PredyRequestOptions, callback: PredyRequestCallback): void;
29
+ /**
30
+ * decode utf8 text from data
31
+ * @param data
32
+ */
33
+ decodeText(data: Uint8Array): string;
27
34
  /**
28
35
  * 将图片绘制到画布上,同时替换文案,绘制的顺序如下
29
- * 创建 template.size尺寸的画布, 接下来的绘制均应用 template.offset
30
- * 将source绘制到画布上,绘制的尺寸为template.sourceSize
31
- * content绘制到画布上,使用variables替换文案
32
- * @param source
36
+ * 创建template.size尺寸的画布, 接下来的绘制均应用 template.offset
37
+ * 将images绘制到画布上,images的尺寸由image.frame决定
38
+ * 将数据模板content绘制到画布上,使用variables替换文案
33
39
  * @param template
34
- * @param variables
35
40
  */
36
- abstract renderImageTemplate(source: ImageBitmap, template: PredyResizeTemplate, variables: Record<string, string | number>): ImageBitmap;
41
+ renderImageTemplate(template: PredyResizeTemplate): ImageBitmapInternal;
37
42
  }
38
43
  export interface PredyResizeTemplate {
39
44
  /**
40
45
  * 要替换的文案
41
46
  */
42
47
  content: StringTemplate;
48
+ /**
49
+ * 要绘制的图片
50
+ */
51
+ images: Array<{
52
+ s: ImageBitmap;
53
+ frame: vec4;
54
+ }>;
43
55
  /**
44
56
  * 画布尺寸
45
57
  */
@@ -47,9 +59,5 @@ export interface PredyResizeTemplate {
47
59
  /**
48
60
  * 画布绘制的offset 默认[0,0]
49
61
  */
50
- offset: vec2;
51
- /**
52
- * source image绘制到画布的尺寸
53
- */
54
- sourceSize: vec2;
62
+ offset?: vec2;
55
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predy-js/render-interface",
3
- "version": "0.1.78",
3
+ "version": "0.1.79",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
package/types/Renderer.ts CHANGED
@@ -72,4 +72,9 @@ export declare class GPURenderer implements IGPURenderer {
72
72
  */
73
73
  destroy (haltGL?: boolean): void;
74
74
 
75
+ /**
76
+ * 此帧需要进行绘制
77
+ */
78
+ invalid (): void;
79
+
75
80
  }
@@ -1,7 +1,8 @@
1
1
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
2
- import type { TypedArray, vec2 } from '../type';
2
+ import type { TypedArray, vec2, vec4 } from '../type';
3
3
  import type { GPUCapability } from '../GPUCapability';
4
4
  import type { StringTemplate } from '@predy-js/specification';
5
+ import type { ImageBitmapInternal } from './ImageBitmapInternal';
5
6
  export interface PredyRequestOptions {
6
7
  url: string,
7
8
  //用于测试缓存,生产中不要使用
@@ -25,30 +26,43 @@ export interface PredyRequestResponse {
25
26
 
26
27
  export type PredyRequestCallback = (err: string | undefined, res: PredyRequestResponse) => void;
27
28
 
28
- export declare abstract class PredyNativeInternal {
29
- abstract createImageBitmap (data: TypedArray | string, //图片文件的数据
30
- options: ImageBitmapConstructor, callback: ImageBitmapCallback): void;
29
+ export interface PredyNativeInternal {
30
+ webpDisabled?: boolean,
31
+ createImageBitmap (data: TypedArray | string, //图片文件的数据
32
+ options: ImageBitmapConstructor, callback: ImageBitmapCallback): void,
31
33
 
32
- abstract getDefaultGPUCapability (): GPUCapability;
34
+ getDefaultGPUCapability (): GPUCapability,
33
35
 
34
- abstract requestWithCache (options: PredyRequestOptions, callback: PredyRequestCallback): void;
36
+ requestWithCache (options: PredyRequestOptions, callback: PredyRequestCallback): void,
35
37
 
38
+ /**
39
+ * decode utf8 text from data
40
+ * @param data
41
+ */
42
+ decodeText(data: Uint8Array): string,
36
43
  /**
37
44
  * 将图片绘制到画布上,同时替换文案,绘制的顺序如下
38
- * 创建 template.size尺寸的画布, 接下来的绘制均应用 template.offset
39
- * 将source绘制到画布上,绘制的尺寸为template.sourceSize
40
- * content绘制到画布上,使用variables替换文案
41
- * @param source
45
+ * 创建template.size尺寸的画布, 接下来的绘制均应用 template.offset
46
+ * 将images绘制到画布上,images的尺寸由image.frame决定
47
+ * 将数据模板content绘制到画布上,使用variables替换文案
42
48
  * @param template
43
- * @param variables
44
49
  */
45
- abstract renderImageTemplate (source: ImageBitmap, template: PredyResizeTemplate, variables: Record<string, string | number>): ImageBitmap;
50
+ renderImageTemplate (template: PredyResizeTemplate): ImageBitmapInternal,
46
51
  }
47
52
  export interface PredyResizeTemplate {
48
53
  /**
49
54
  * 要替换的文案
50
55
  */
51
56
  content: StringTemplate,
57
+
58
+ /**
59
+ * 要绘制的图片
60
+ */
61
+ images: Array<{
62
+ s: ImageBitmap,
63
+ //图片绘制区域,尺寸可能和image不一样
64
+ frame: vec4,
65
+ }>,
52
66
  /**
53
67
  * 画布尺寸
54
68
  */
@@ -56,9 +70,5 @@ export interface PredyResizeTemplate {
56
70
  /**
57
71
  * 画布绘制的offset 默认[0,0]
58
72
  */
59
- offset: vec2,
60
- /**
61
- * source image绘制到画布的尺寸
62
- */
63
- sourceSize: vec2,
73
+ offset?: vec2,
64
74
  }