template-replacement 3.3.0 → 3.3.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "template-replacement",
3
3
  "description": "模板文件替换",
4
- "version": "3.3.0",
4
+ "version": "3.3.1",
5
5
  "author": "fushiliang <994301536@qq.com>",
6
6
  "type": "module",
7
7
  "main": "index.ts",
package/replace/image.ts CHANGED
@@ -76,11 +76,19 @@ export default class image {
76
76
 
77
77
  async getExtent(): Promise<extent> {
78
78
  if (!this.wpExtent) {
79
- const bitmap = await createImageBitmap(this.file)
80
- !this.wpExtent && this.setPxExtent(bitmap.width, bitmap.height)
81
- bitmap.close()
79
+ if (this.file.size) {
80
+ try {
81
+ const bitmap = await createImageBitmap(this.file)
82
+ !this.wpExtent && this.setPxExtent(bitmap.width, bitmap.height)
83
+ bitmap.close()
84
+ return this.wpExtent!
85
+ } catch (error) {
86
+ console.error(error)
87
+ }
88
+ }
89
+ !this.wpExtent && this.setPxExtent(0, 0)
82
90
  }
83
- return this.wpExtent as extent
91
+ return this.wpExtent!
84
92
  }
85
93
 
86
94
  //设置图片范围(像素)
@@ -48,7 +48,7 @@ export default class WorkerReplace implements ReplaceInterface {
48
48
  if (!allowCallMethodNames[method]) {
49
49
  return
50
50
  }
51
- const fun = this[method]
51
+ const fun = this[method] as Function | undefined
52
52
  if (!fun) {
53
53
  return
54
54
  }