template-replacement 3.5.2 → 3.5.4

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.5.2",
4
+ "version": "3.5.4",
5
5
  "author": "fushiliang <994301536@qq.com>",
6
6
  "type": "module",
7
7
  "main": "index.ts",
@@ -15,18 +15,18 @@
15
15
  "fflate": "^0.8.2",
16
16
  "file-type": "^19.6.0",
17
17
  "streamsaver": "^2.0.6",
18
- "template-replacement-core-wasm": "^1.8.0",
19
- "template-replacement-sign-core-wasm": "^1.8.0"
18
+ "template-replacement-core-wasm": "^1.8.1",
19
+ "template-replacement-sign-core-wasm": "^1.8.1"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@rollup/pluginutils": "^5.3.0",
23
23
  "@types/streamsaver": "^2.0.5",
24
- "@typescript-eslint/eslint-plugin": "^8.50.0",
25
- "@typescript-eslint/parser": "^8.50.0",
24
+ "@typescript-eslint/eslint-plugin": "^8.51.0",
25
+ "@typescript-eslint/parser": "^8.51.0",
26
26
  "eslint": "^9.39.2",
27
- "eslint-plugin-oxlint": "^1.33.0",
27
+ "eslint-plugin-oxlint": "^1.36.0",
28
28
  "oxfmt": "^0.16.0",
29
- "oxlint": "^1.34.0",
29
+ "oxlint": "^1.36.0",
30
30
  "terser": "^5.44.1",
31
31
  "typescript": "^5.9.3",
32
32
  "vite": "^7.3.0"
package/replace/image.ts CHANGED
@@ -12,6 +12,7 @@ export enum textWrapTypes {
12
12
  aboveText = 'AboveText', //嵌于文字上方
13
13
  }
14
14
 
15
+ //获取文件扩展名
15
16
  function getFileExtension(filename: string): string {
16
17
  const ext = filename.split('.').pop()
17
18
  if (ext === undefined) {
@@ -30,10 +31,11 @@ export type extent = {
30
31
  cx: number
31
32
  }
32
33
 
33
- //允许设置的属性
34
+ //允许导出和设置的属性
34
35
  const allowSetPropertyKeys = new Set([
35
36
  'file',
36
37
  'id',
38
+ 'suffix',
37
39
  'wpExtent',
38
40
  'textWrap',
39
41
  'relationship',
@@ -44,6 +46,7 @@ export default class image {
44
46
  file: Blob
45
47
  relationship = 'image'
46
48
  id?: string
49
+ suffix?: string
47
50
 
48
51
  wpExtent?: extent //图片宽高
49
52
  textWrap = textWrapTypes.embed //文字环绕
@@ -51,7 +54,11 @@ export default class image {
51
54
  private _awaitInitQueue?: ((value?: unknown) => void)[] = []
52
55
 
53
56
  constructor(file: Blob) {
54
- if (file instanceof Blob) {
57
+ if (file instanceof File) {
58
+ this.file = file
59
+ this.suffix = getFileExtension(file.name)
60
+ this.init()
61
+ } else if (file instanceof Blob) {
55
62
  this.file = file
56
63
  this.init()
57
64
  } else {
@@ -62,7 +62,7 @@ export default class paramsData {
62
62
  Image: {
63
63
  index,
64
64
  id,
65
- suffix: '',
65
+ suffix: value.suffix ?? '',
66
66
  wp_extent: value.wpExtent ?? { cx: 0, cy: 0 },
67
67
  text_wrap: value.textWrap,
68
68
  },
@@ -98,7 +98,7 @@ export default class paramsData {
98
98
  Image: {
99
99
  index,
100
100
  id,
101
- suffix: '',
101
+ suffix: value.suffix ?? '',
102
102
  wp_extent: value.wpExtent ?? { cx: 0, cy: 0 },
103
103
  text_wrap: value.textWrap,
104
104
  },