@leafer-ui/external 1.0.0-beta.9 → 1.0.0-rc.10
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 +6 -7
- package/src/index.ts +15 -10
- package/types/index.d.ts +11 -0
- package/src/Animate.ts +0 -3
- package/src/Effect.ts +0 -6
- package/src/Export.ts +0 -82
- package/src/Paint.ts +0 -6
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/external",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.10",
|
|
4
4
|
"description": "@leafer-ui/external",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
8
9
|
"files": [
|
|
9
|
-
"src"
|
|
10
|
+
"src",
|
|
11
|
+
"types",
|
|
12
|
+
"dist"
|
|
10
13
|
],
|
|
11
14
|
"repository": {
|
|
12
15
|
"type": "git",
|
|
@@ -18,11 +21,7 @@
|
|
|
18
21
|
"leafer-ui",
|
|
19
22
|
"leaferjs"
|
|
20
23
|
],
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@leafer-ui/paint": "1.0.0-beta.9",
|
|
23
|
-
"@leafer-ui/effect": "1.0.0-beta.9"
|
|
24
|
-
},
|
|
25
24
|
"devDependencies": {
|
|
26
|
-
"@leafer-ui/interface": "1.0.0-
|
|
25
|
+
"@leafer-ui/interface": "1.0.0-rc.10"
|
|
27
26
|
}
|
|
28
27
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Implemented in partner
|
|
2
|
+
import { IPaintModule, IPaintImageModule, IPaintGradientModule, IEffectModule, ITextConvertModule, IExportModule, IColorConvertModule } from "@leafer-ui/interface"
|
|
3
3
|
|
|
4
|
-
export { Animate } from './Animate'
|
|
5
|
-
export { Export } from './Export'
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
import { Paint } from './Paint'
|
|
9
|
-
import * as UIEffect from '@leafer-ui/effect'
|
|
10
|
-
import * as UIPaint from '@leafer-ui/paint'
|
|
5
|
+
export const TextConvert = {} as ITextConvertModule
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
export const ColorConvert = {} as IColorConvertModule
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export const Paint = {} as IPaintModule
|
|
11
|
+
|
|
12
|
+
export const PaintImage = {} as IPaintImageModule
|
|
13
|
+
|
|
14
|
+
export const PaintGradient = {} as IPaintGradientModule
|
|
15
|
+
|
|
16
|
+
export const Effect = {} as IEffectModule
|
|
17
|
+
|
|
18
|
+
export const Export = {} as IExportModule
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ITextConvertModule, IColorConvertModule, IPaintModule, IPaintImageModule, IPaintGradientModule, IEffectModule, IExportModule } from '@leafer-ui/interface';
|
|
2
|
+
|
|
3
|
+
declare const TextConvert: ITextConvertModule;
|
|
4
|
+
declare const ColorConvert: IColorConvertModule;
|
|
5
|
+
declare const Paint: IPaintModule;
|
|
6
|
+
declare const PaintImage: IPaintImageModule;
|
|
7
|
+
declare const PaintGradient: IPaintGradientModule;
|
|
8
|
+
declare const Effect: IEffectModule;
|
|
9
|
+
declare const Export: IExportModule;
|
|
10
|
+
|
|
11
|
+
export { ColorConvert, Effect, Export, Paint, PaintGradient, PaintImage, TextConvert };
|
package/src/Animate.ts
DELETED
package/src/Effect.ts
DELETED
package/src/Export.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { ILeaf, IExportFileType, IBlob, IFunction } from '@leafer/interface'
|
|
2
|
-
import { TaskProcessor } from '@leafer/core'
|
|
3
|
-
|
|
4
|
-
import { IExportModule, IExportOptions, IExportResult, IExportResultFunction } from '@leafer-ui/interface'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const Export: IExportModule = {
|
|
8
|
-
|
|
9
|
-
export(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult> {
|
|
10
|
-
|
|
11
|
-
return addTask((success: IExportResultFunction) =>
|
|
12
|
-
|
|
13
|
-
new Promise((resolve: IFunction) => {
|
|
14
|
-
|
|
15
|
-
const { leafer } = leaf
|
|
16
|
-
if (leafer) {
|
|
17
|
-
|
|
18
|
-
leafer.waitViewLoaded(async () => {
|
|
19
|
-
|
|
20
|
-
let quality, blob: boolean
|
|
21
|
-
let { canvas } = leafer
|
|
22
|
-
let { unreal } = canvas
|
|
23
|
-
|
|
24
|
-
if (unreal) {
|
|
25
|
-
canvas = canvas.getSameCanvas()
|
|
26
|
-
canvas.backgroundColor = leafer.config.fill
|
|
27
|
-
leafer.__render(canvas, {})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
switch (typeof options) {
|
|
31
|
-
case 'object':
|
|
32
|
-
if (options.quality) quality = options.quality
|
|
33
|
-
if (options.blob) blob = true
|
|
34
|
-
break
|
|
35
|
-
case 'number':
|
|
36
|
-
quality = options
|
|
37
|
-
break
|
|
38
|
-
case 'boolean':
|
|
39
|
-
blob = options
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
let data: IBlob | string | boolean
|
|
43
|
-
|
|
44
|
-
if (filename.includes('.')) {
|
|
45
|
-
data = await canvas.saveAs(filename, quality)
|
|
46
|
-
} else if (blob) {
|
|
47
|
-
data = await canvas.toBlob(filename, quality)
|
|
48
|
-
} else {
|
|
49
|
-
data = canvas.toDataURL(filename, quality)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
success({ data })
|
|
53
|
-
resolve()
|
|
54
|
-
|
|
55
|
-
if (unreal) canvas.recycle()
|
|
56
|
-
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
} else {
|
|
60
|
-
success({ data: false })
|
|
61
|
-
resolve()
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
let tasker: TaskProcessor
|
|
74
|
-
|
|
75
|
-
function addTask(task: IFunction): Promise<IExportResult> {
|
|
76
|
-
if (!tasker) tasker = new TaskProcessor()
|
|
77
|
-
|
|
78
|
-
return new Promise((resolve: IExportResultFunction) => {
|
|
79
|
-
tasker.add(async () => await task(resolve))
|
|
80
|
-
if (!tasker.running) tasker.start()
|
|
81
|
-
})
|
|
82
|
-
}
|