template-replacement 3.4.0 → 3.5.1
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/README.md +8 -2
- package/core/base.ts +5 -5
- package/dist/main/general.js +1667 -1737
- package/dist/main/sign.js +1933 -2006
- package/dist/replace/general.js +234 -307
- package/dist/replace/sign.js +275 -351
- package/package.json +4 -4
- package/replace/image.ts +16 -6
- package/replace/sign.ts +8 -17
- package/worker/main/index.ts +1 -1
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ const replaceInstance = tr()
|
|
|
34
34
|
需要同时替换大量文件时使用
|
|
35
35
|
``` javascript
|
|
36
36
|
import tr from 'template-replacement'
|
|
37
|
-
const worker = 4 //线程数量,建议<=CPU核心数
|
|
37
|
+
const worker = navigator.hardwareConcurrency ?? 4 //线程数量,建议<=CPU核心数
|
|
38
38
|
const replaceInstance = tr(worker)
|
|
39
39
|
```
|
|
40
40
|
3、模板替换并校验签名:
|
|
@@ -56,7 +56,7 @@ const replaceInstance = tr(0, getSignature)
|
|
|
56
56
|
4、多线程模板替换并校验签名:
|
|
57
57
|
``` javascript
|
|
58
58
|
import tr from 'template-replacement'
|
|
59
|
-
const worker = 4 //线程数量,建议<=CPU核心数
|
|
59
|
+
const worker = navigator.hardwareConcurrency ?? 4 //线程数量,建议<=CPU核心数
|
|
60
60
|
const replaceInstance = tr(worker, getSignature)
|
|
61
61
|
```
|
|
62
62
|
|
|
@@ -179,6 +179,12 @@ media.setPxExtent(width: number, height: number)
|
|
|
179
179
|
* 设置图片的宽高(厘米)
|
|
180
180
|
*/
|
|
181
181
|
media.setCmExtent(width: number, height: number)
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* 等待媒体数据初始化完成
|
|
185
|
+
* 数据初始化完成后才能使用媒体数据进行替换(重要!!!)
|
|
186
|
+
*/
|
|
187
|
+
await media.awaitInit();
|
|
182
188
|
```
|
|
183
189
|
|
|
184
190
|
2、文件加密,需要防止被第三方获取到模板文件的场景可以使用(配合class Temp中的isDecode属性进行解码使用)
|
package/core/base.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export interface rawCoreInterface {
|
|
2
2
|
add_media(file: Uint8Array): string
|
|
3
|
-
add_template(file_data: Uint8Array, is_decode: boolean):
|
|
4
|
-
extract_medias(files: Uint8Array[], encode_files: Uint8Array[]):
|
|
5
|
-
extract_one_file_medias(data: Uint8Array, is_decode: boolean):
|
|
3
|
+
add_template(file_data: Uint8Array, is_decode: boolean): number
|
|
4
|
+
extract_medias(files: Uint8Array[], encode_files: Uint8Array[]): unknown
|
|
5
|
+
extract_one_file_medias(data: Uint8Array, is_decode: boolean): unknown
|
|
6
6
|
extract_one_file_variable_names(
|
|
7
7
|
data: Uint8Array,
|
|
8
8
|
is_decode: boolean,
|
|
9
|
-
):
|
|
9
|
+
): string[]
|
|
10
10
|
extract_variable_names(
|
|
11
11
|
files: Uint8Array[],
|
|
12
12
|
encode_files: Uint8Array[],
|
|
13
|
-
):
|
|
13
|
+
): string[]
|
|
14
14
|
file_encrypt(file: Uint8Array): Uint8Array
|
|
15
15
|
files_encrypt(files: Uint8Array[]): Uint8Array[]
|
|
16
16
|
}
|