@leafer/file 2.0.0 → 2.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/file",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "@leafer/file",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,12 +22,12 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/platform": "2.0.0",
26
- "@leafer/task": "2.0.0",
27
- "@leafer/data": "2.0.0",
28
- "@leafer/debug": "2.0.0"
25
+ "@leafer/platform": "2.0.2",
26
+ "@leafer/task": "2.0.2",
27
+ "@leafer/data": "2.0.2",
28
+ "@leafer/debug": "2.0.2"
29
29
  },
30
30
  "devDependencies": {
31
- "@leafer/interface": "2.0.0"
31
+ "@leafer/interface": "2.0.2"
32
32
  }
33
33
  }
package/src/FileHelper.ts CHANGED
@@ -6,10 +6,10 @@ export const FileHelper = {
6
6
 
7
7
  upperCaseTypeMap: {} as IStringMap,
8
8
 
9
- mineType(type: string): string {
10
- if (!type || type.startsWith('image')) return type
9
+ mimeType(type: string, base: string = 'image'): string {
10
+ if (!type || type.startsWith(base)) return type
11
11
  if (type === 'jpg') type = 'jpeg'
12
- return 'image/' + type
12
+ return base + '/' + type
13
13
  },
14
14
 
15
15
  fileType(filename: string): string {
@@ -33,6 +33,7 @@ export const FileHelper = {
33
33
 
34
34
  }
35
35
 
36
- const F = FileHelper
36
+ const F = FileHelper;
37
+ (F as any).mineType = F.mimeType // 兼容老代码,后面可以移除
37
38
 
38
39
  F.alphaPixelTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase())
package/src/Resource.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeaferImage, IResource, IObject, ILeaferCanvas, IExportFileType, ILeaferImageConfig } from '@leafer/interface'
1
+ import { ILeaferImage, ILeaferFilm, ILeaferVideo, IFilmFileType, IVideoFileType, IResource, IObject, ILeaferCanvas, IExportFileType, ILeaferImageConfig } from '@leafer/interface'
2
2
 
3
3
  import { Creator } from '@leafer/platform'
4
4
  import { TaskProcessor } from '@leafer/task'
@@ -10,7 +10,9 @@ const debug = Debug.get('Resource')
10
10
 
11
11
  export const Resource: IResource = {
12
12
 
13
- tasker: new TaskProcessor(),
13
+ tasker: new TaskProcessor(), // 会并行的异步加载任务
14
+
15
+ queue: new TaskProcessor({ parallel: 1 }), // 全局按顺序执行的任务队列,防止阻塞主线程
14
16
 
15
17
  map: {},
16
18
 
@@ -53,6 +55,13 @@ export const Resource: IResource = {
53
55
  return value as ILeaferImage
54
56
  },
55
57
 
58
+ // film
59
+
60
+ loadFilm(_key: string, _format?: IFilmFileType): Promise<ILeaferFilm> { return undefined },
61
+
62
+ // video
63
+
64
+ loadVideo(_key: string, _format?: IVideoFileType): Promise<ILeaferVideo> { return undefined },
56
65
 
57
66
  destroy(): void {
58
67
  R.map = {}
package/types/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { IExportFileType, IStringMap, IExportOptions, IResource } from '@leafer/
3
3
  declare const FileHelper: {
4
4
  alphaPixelTypes: IExportFileType[];
5
5
  upperCaseTypeMap: IStringMap;
6
- mineType(type: string): string;
6
+ mimeType(type: string, base?: string): string;
7
7
  fileType(filename: string): string;
8
8
  isOpaqueImage(filename: string): boolean;
9
9
  getExportOptions(options?: IExportOptions | number | boolean): IExportOptions;