@predy-js/render-interface 0.3.3-beta.31 → 0.3.3-beta.34

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.3.3-beta.31
5
+ * Version: v0.3.3-beta.34
6
6
  */
7
7
 
8
8
  // https://github.com/greggman/webgl-memory/blob/main/src/texture-utils.js
@@ -3,8 +3,6 @@ import type { TypedArray, vec2 } from '../type';
3
3
  import type { GPUCapability } from '../GPUCapability';
4
4
  import type { PredyResizeTemplate, SDFImageOptions, SDFImage } from '@predy-js/specification';
5
5
  import type { ImageBitmapInternal } from './ImageBitmapInternal';
6
- import type { PredyVideoDecoder, PredyVideoDecoderConstructor } from './VideoDecoder';
7
- import type { ResourcePlatform } from './ResourceInternal';
8
6
  export interface PredyRequestOptions {
9
7
  url: string;
10
8
  disableCache?: boolean;
@@ -31,18 +29,8 @@ export declare enum PredyTextEncoding {
31
29
  utf8 = 0,
32
30
  ascii = 1
33
31
  }
34
- export declare enum PredyVideoCodec {
35
- h264 = "avc1",
36
- h265 = "hev1",
37
- av1 = "av1"
38
- }
39
32
  export interface PredyNativeInternal {
40
33
  webpDisabled?: boolean;
41
- /**
42
- * 是否支持获取gles3,但如果获取es3失败,会降级到es2
43
- */
44
- supportGLES3?: boolean;
45
- platform: ResourcePlatform;
46
34
  createImageBitmap(data: TypedArray | string, //图片文件的数据
47
35
  options: ImageBitmapConstructor, callback: ImageBitmapCallback): void;
48
36
  getDefaultGPUCapability(): GPUCapability;
@@ -95,20 +83,10 @@ export interface PredyNativeInternal {
95
83
  */
96
84
  inflateData(data: Uint8Array, method: DataCompressMethod): Uint8Array | undefined;
97
85
  /**
98
- * 恢复当前的主JSContext,多个JSContext执行的时候会发生抢占,
99
- * 调用此函数后,当前的JSContext会被恢复
100
- */
86
+ * 恢复当前的主JSContext,多个JSContext执行的时候会发生抢占,
87
+ * 调用此函数后,当前的JSContext会被恢复
88
+ */
101
89
  restoreJSContext(): boolean;
102
- /**
103
- * 创建 video decoder
104
- * @param options
105
- */
106
- createVideoDecoder(options: PredyVideoDecoderConstructor): PredyVideoDecoder;
107
- /**
108
- * 是否支持视频编码
109
- * @param codec
110
- */
111
- supportVideoCodec(codec: PredyVideoCodec): boolean;
112
90
  }
113
91
  type renderSDFImageCallback = (img: SDFImage) => void;
114
92
  export {};
@@ -23,7 +23,6 @@ export declare abstract class TextureInternal implements ResourceInternal {
23
23
  readonly height: number;
24
24
  readonly name: string;
25
25
  readonly options: TextureInternalOptions;
26
- readonly error?: number;
27
26
  protected constructor(options: TextureInternalConstructOptions);
28
27
  abstract resize(width: number, height: number): boolean;
29
28
  abstract destroy(): void;
@@ -13,4 +13,3 @@ export * from './TextureInternal';
13
13
  export * from './AndGLContext';
14
14
  export * from './PredyNativeInternal';
15
15
  export * from './PredyNativeModule';
16
- export * from './VideoDecoder';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predy-js/render-interface",
3
- "version": "0.3.3-beta.31",
3
+ "version": "0.3.3-beta.34",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
@@ -3,8 +3,6 @@ import type { TypedArray, vec2 } from '../type';
3
3
  import type { GPUCapability } from '../GPUCapability';
4
4
  import type { PredyResizeTemplate, SDFImageOptions, SDFImage } from '@predy-js/specification';
5
5
  import type { ImageBitmapInternal } from './ImageBitmapInternal';
6
- import type { PredyVideoDecoder, PredyVideoDecoderConstructor } from './VideoDecoder';
7
- import type { ResourcePlatform } from './ResourceInternal';
8
6
 
9
7
  export interface PredyRequestOptions {
10
8
  url: string,
@@ -44,29 +42,23 @@ export enum PredyTextEncoding {
44
42
  ascii = 1,
45
43
  }
46
44
 
47
- export enum PredyVideoCodec {
48
- h264 = 'avc1',
49
- h265 = 'hev1',
50
- av1 = 'av1'
51
- }
52
-
53
45
  export interface PredyNativeInternal {
54
46
  webpDisabled?: boolean,
55
- /**
56
- * 是否支持获取gles3,但如果获取es3失败,会降级到es2
57
- */
58
- supportGLES3?: boolean,
59
- platform: ResourcePlatform,
47
+
60
48
  createImageBitmap(data: TypedArray | string, //图片文件的数据
61
49
  options: ImageBitmapConstructor, callback: ImageBitmapCallback): void,
50
+
62
51
  getDefaultGPUCapability(): GPUCapability,
52
+
63
53
  requestWithCache(options: PredyRequestOptions, callback: PredyRequestCallback): void,
54
+
64
55
  /**
65
56
  * decode text from data
66
57
  * @param data
67
58
  * @param encoding 默认utf8
68
59
  */
69
60
  decodeText(data: Uint8Array, encoding?: PredyTextEncoding): string,
61
+
70
62
  /**
71
63
  * 将图片绘制到画布上,同时替换文案,绘制的顺序如下
72
64
  * 创建template.size尺寸的画布, 接下来的绘制均应用 template.offset
@@ -75,12 +67,14 @@ export interface PredyNativeInternal {
75
67
  * @param template
76
68
  */
77
69
  renderImageTemplate(template: PredyResizeTemplate): ImageBitmapInternal,
70
+
78
71
  /**
79
72
  * 异步绘制图片的模板
80
73
  * @param options
81
74
  * @param callback 如果传入callback就是异步绘制,否则会直接返回结果
82
75
  */
83
76
  generateSDFImage(options: SDFImageOptions, callback?: renderSDFImageCallback): SDFImage | undefined,
77
+
84
78
  /**
85
79
  * 下载并且执行脚本文件,此方法会缓存https的脚本内容
86
80
  * 对于http的请求(开发环境),每次都重新请求
@@ -88,6 +82,7 @@ export interface PredyNativeInternal {
88
82
  * @param callback
89
83
  */
90
84
  evaluateScriptURL(url: string, callback: (err: Error, result: any) => void): void,
85
+
91
86
  /**
92
87
  * 将float32Array转换为half float,写入Uint16Array中,
93
88
  * 如果提供了range参数,代表float16会被重新map到range中,以此提高精度范围
@@ -112,22 +107,10 @@ export interface PredyNativeInternal {
112
107
  inflateData(data: Uint8Array, method: DataCompressMethod): Uint8Array | undefined,
113
108
 
114
109
  /**
115
- * 恢复当前的主JSContext,多个JSContext执行的时候会发生抢占,
116
- * 调用此函数后,当前的JSContext会被恢复
117
- */
110
+ * 恢复当前的主JSContext,多个JSContext执行的时候会发生抢占,
111
+ * 调用此函数后,当前的JSContext会被恢复
112
+ */
118
113
  restoreJSContext(): boolean,
119
-
120
- /**
121
- * 创建 video decoder
122
- * @param options
123
- */
124
- createVideoDecoder(options: PredyVideoDecoderConstructor): PredyVideoDecoder,
125
-
126
- /**
127
- * 是否支持视频编码
128
- * @param codec
129
- */
130
- supportVideoCodec(codec: PredyVideoCodec): boolean,
131
114
  }
132
115
 
133
116
  type renderSDFImageCallback = (img: SDFImage) => void;
@@ -32,8 +32,6 @@ export abstract class TextureInternal implements ResourceInternal {
32
32
 
33
33
  readonly options: TextureInternalOptions;
34
34
 
35
- readonly error?: number;
36
-
37
35
  protected constructor (options: TextureInternalConstructOptions) {
38
36
  }
39
37
 
@@ -13,4 +13,3 @@ export * from './TextureInternal';
13
13
  export * from './AndGLContext';
14
14
  export * from './PredyNativeInternal';
15
15
  export * from './PredyNativeModule';
16
- export * from './VideoDecoder';
@@ -1,75 +0,0 @@
1
- import type { VideoFrameFormat } from '@predy-js/specification';
2
- export interface PredyVideoDecoderFrameData {
3
- width: number;
4
- height: number;
5
- data: Uint8Array;
6
- idx: number;
7
- keyframe: boolean;
8
- }
9
- export declare enum PredyVideoDecoderStatus {
10
- init = 0,
11
- loading = 1,
12
- metadataReady = 2,
13
- seekingFrame = 3,
14
- frameReady = 4,
15
- destroyed = 5,
16
- error = 44
17
- }
18
- /**
19
- * 视频解码的通用class,在native和web端有不同的实现
20
- */
21
- export interface PredyVideoDecoderMetadata {
22
- width: number;
23
- height: number;
24
- duration: number;
25
- frameCount: number;
26
- format: VideoFrameFormat;
27
- frameBufferSize: number;
28
- }
29
- /**
30
- * VideoDecoder创建参数
31
- */
32
- export interface PredyVideoDecoderConstructor {
33
- name: string;
34
- prefetchOnly?: boolean;
35
- }
36
- export type PredyVideoDecoderLoadedCallback = (error?: Error, metadata?: PredyVideoDecoderMetadata) => void;
37
- export type PredyVideoDecoderSeekFrameCallback = (error?: Error, frame?: PredyVideoDecoderFrameData) => void;
38
- export interface PredyVideoDecoder {
39
- readonly name: string;
40
- readonly status: PredyVideoDecoderStatus;
41
- readonly metadata?: PredyVideoDecoderMetadata;
42
- /**
43
- * 只做资源请求,不进行视频解码,
44
- * 这种情况下,seekFrame永远返回error(prefetch only)
45
- */
46
- readonly prefetchOnly: boolean;
47
- /**
48
- * 是否要跳播/回播,如果不需要的话,Decoder可以自行释放已经播放的帧
49
- */
50
- readonly willReverseTime: boolean;
51
- readonly currentFrame: number;
52
- /**
53
- * 加载视频,解析视频的metadata,设置frame数组,
54
- * 此函数只能调用一次,如果需要解析其他的视频,需要重新创建对象
55
- * @param url 视频地址
56
- * @param callback 解析回调
57
- */
58
- loadVideo(url: string, callback: PredyVideoDecoderLoadedCallback): void;
59
- /**
60
- * 如果当前正在解析,中断解析,并且之前的callback返回error(abort)
61
- * 调用后回到frameReady状态
62
- */
63
- abortSeeking(): void;
64
- /**
65
- * 解析视频的下一帧,获得图像数据。如果调用的时候正在解析,callback直接返回error
66
- * @param frameIndex frame的index
67
- * @param data 图像数据buffer,数据将被写入到此Buffer中,如果buffer尺寸不对,解析会失败
68
- * @param callback 图像数据回调
69
- */
70
- seekFrame(frameIndex: number, data: Uint8Array, callback: PredyVideoDecoderSeekFrameCallback): void;
71
- /**
72
- * 释放资源
73
- */
74
- destroy(): void;
75
- }
@@ -1,85 +0,0 @@
1
- import type { VideoFrameFormat } from '@predy-js/specification';
2
-
3
- export interface PredyVideoDecoderFrameData {
4
- width: number,
5
- height: number,
6
- data: Uint8Array,
7
- idx: number,
8
- keyframe: boolean,
9
- }
10
-
11
- export enum PredyVideoDecoderStatus {
12
- init = 0, // 创建对象
13
- loading = 1, // 正在解析metadata,解析过程任何函数调用都会导致error
14
- metadataReady = 2, // metadata 解析完成,此时 currentFrame = -1
15
- seekingFrame = 3, // 正在解析某一帧,解析过程任何函数调用都会导致error
16
- frameReady = 4, // 解析某一帧完成,此时 currentFrame = frame.index
17
- destroyed = 5, // 对象已经销毁
18
- error = 44, // 发生错误
19
- }
20
-
21
- /**
22
- * 视频解码的通用class,在native和web端有不同的实现
23
- */
24
- export interface PredyVideoDecoderMetadata {
25
- width: number,
26
- height: number,
27
- duration: number,
28
- frameCount: number,
29
- format: VideoFrameFormat,
30
- frameBufferSize: number, // 每帧的buffer大小
31
- }
32
-
33
- /**
34
- * VideoDecoder创建参数
35
- */
36
- export interface PredyVideoDecoderConstructor {
37
- name: string,
38
- prefetchOnly?: boolean,
39
- }
40
-
41
- export type PredyVideoDecoderLoadedCallback = (error?: Error, metadata?: PredyVideoDecoderMetadata) => void;
42
- export type PredyVideoDecoderSeekFrameCallback = (error?: Error, frame?: PredyVideoDecoderFrameData) => void;
43
-
44
- export interface PredyVideoDecoder {
45
- readonly name: string,
46
- readonly status: PredyVideoDecoderStatus,
47
- readonly metadata?: PredyVideoDecoderMetadata,
48
-
49
- /**
50
- * 只做资源请求,不进行视频解码,
51
- * 这种情况下,seekFrame永远返回error(prefetch only)
52
- */
53
- readonly prefetchOnly: boolean,
54
- /**
55
- * 是否要跳播/回播,如果不需要的话,Decoder可以自行释放已经播放的帧
56
- */
57
- readonly willReverseTime: boolean,
58
- readonly currentFrame: number,
59
-
60
- /**
61
- * 加载视频,解析视频的metadata,设置frame数组,
62
- * 此函数只能调用一次,如果需要解析其他的视频,需要重新创建对象
63
- * @param url 视频地址
64
- * @param callback 解析回调
65
- */
66
- loadVideo(url: string, callback: PredyVideoDecoderLoadedCallback): void,
67
-
68
- /**
69
- * 如果当前正在解析,中断解析,并且之前的callback返回error(abort)
70
- * 调用后回到frameReady状态
71
- */
72
- abortSeeking(): void,
73
- /**
74
- * 解析视频的下一帧,获得图像数据。如果调用的时候正在解析,callback直接返回error
75
- * @param frameIndex frame的index
76
- * @param data 图像数据buffer,数据将被写入到此Buffer中,如果buffer尺寸不对,解析会失败
77
- * @param callback 图像数据回调
78
- */
79
- seekFrame(frameIndex: number, data: Uint8Array, callback: PredyVideoDecoderSeekFrameCallback): void,
80
-
81
- /**
82
- * 释放资源
83
- */
84
- destroy(): void,
85
- }