@predy-js/render-interface 0.1.75 → 0.1.76-beta.2

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/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.75
5
+ * Version: v0.1.76-beta.2
6
6
  */
7
7
 
8
8
  // https://github.com/greggman/webgl-memory/blob/main/src/texture-utils.js
@@ -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,33 @@ 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;
27
29
  /**
28
30
  * 将图片绘制到画布上,同时替换文案,绘制的顺序如下
29
- * 创建 template.size尺寸的画布, 接下来的绘制均应用 template.offset
30
- * 将source绘制到画布上,绘制的尺寸为template.sourceSize
31
- * content绘制到画布上,使用variables替换文案
32
- * @param source
31
+ * 创建template.size尺寸的画布, 接下来的绘制均应用 template.offset
32
+ * 将images绘制到画布上,images的尺寸由image.frame决定
33
+ * 将数据模板content绘制到画布上,使用variables替换文案
33
34
  * @param template
34
- * @param variables
35
35
  */
36
- abstract renderImageTemplate(source: ImageBitmap, template: PredyResizeTemplate, variables: Record<string, string | number>): ImageBitmap;
36
+ renderImageTemplate(template: PredyResizeTemplate): ImageBitmapInternal;
37
37
  }
38
38
  export interface PredyResizeTemplate {
39
39
  /**
40
40
  * 要替换的文案
41
41
  */
42
42
  content: StringTemplate;
43
+ /**
44
+ * 要绘制的图片
45
+ */
46
+ images: Array<{
47
+ s: ImageBitmap;
48
+ frame: vec4;
49
+ }>;
43
50
  /**
44
51
  * 画布尺寸
45
52
  */
@@ -47,9 +54,5 @@ export interface PredyResizeTemplate {
47
54
  /**
48
55
  * 画布绘制的offset 默认[0,0]
49
56
  */
50
- offset: vec2;
51
- /**
52
- * source image绘制到画布的尺寸
53
- */
54
- sourceSize: vec2;
57
+ offset?: vec2;
55
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predy-js/render-interface",
3
- "version": "0.1.75",
3
+ "version": "0.1.76-beta.2",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
@@ -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,38 @@ 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
 
36
38
  /**
37
39
  * 将图片绘制到画布上,同时替换文案,绘制的顺序如下
38
- * 创建 template.size尺寸的画布, 接下来的绘制均应用 template.offset
39
- * 将source绘制到画布上,绘制的尺寸为template.sourceSize
40
- * content绘制到画布上,使用variables替换文案
41
- * @param source
40
+ * 创建template.size尺寸的画布, 接下来的绘制均应用 template.offset
41
+ * 将images绘制到画布上,images的尺寸由image.frame决定
42
+ * 将数据模板content绘制到画布上,使用variables替换文案
42
43
  * @param template
43
- * @param variables
44
44
  */
45
- abstract renderImageTemplate (source: ImageBitmap, template: PredyResizeTemplate, variables: Record<string, string | number>): ImageBitmap;
45
+ renderImageTemplate (template: PredyResizeTemplate): ImageBitmapInternal,
46
46
  }
47
47
  export interface PredyResizeTemplate {
48
48
  /**
49
49
  * 要替换的文案
50
50
  */
51
51
  content: StringTemplate,
52
+
53
+ /**
54
+ * 要绘制的图片
55
+ */
56
+ images: Array<{
57
+ s: ImageBitmap,
58
+ //图片绘制区域,尺寸可能和image不一样
59
+ frame: vec4,
60
+ }>,
52
61
  /**
53
62
  * 画布尺寸
54
63
  */
@@ -56,9 +65,5 @@ export interface PredyResizeTemplate {
56
65
  /**
57
66
  * 画布绘制的offset 默认[0,0]
58
67
  */
59
- offset: vec2,
60
- /**
61
- * source image绘制到画布的尺寸
62
- */
63
- sourceSize: vec2,
68
+ offset?: vec2,
64
69
  }