@leafer-ui/external 1.0.0-beta.12 → 1.0.0-beta.15
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 +5 -7
- package/src/index.ts +11 -10
- package/types/index.d.ts +10 -0
- package/src/Animate.ts +0 -3
- package/src/Effect.ts +0 -6
- package/src/Export.ts +0 -81
- package/src/Paint.ts +0 -6
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/external",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.15",
|
|
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
|
-
"
|
|
10
|
+
"types",
|
|
11
|
+
"dist"
|
|
10
12
|
],
|
|
11
13
|
"repository": {
|
|
12
14
|
"type": "git",
|
|
@@ -18,11 +20,7 @@
|
|
|
18
20
|
"leafer-ui",
|
|
19
21
|
"leaferjs"
|
|
20
22
|
],
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@leafer-ui/paint": "1.0.0-beta.12",
|
|
23
|
-
"@leafer-ui/effect": "1.0.0-beta.12"
|
|
24
|
-
},
|
|
25
23
|
"devDependencies": {
|
|
26
|
-
"@leafer-ui/interface": "1.0.0-beta.
|
|
24
|
+
"@leafer-ui/interface": "1.0.0-beta.15"
|
|
27
25
|
}
|
|
28
26
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Implemented in partner
|
|
2
|
+
import { IPaintModule, IEffectModule, ITextConvertModule, IExportModule, IColorConvertModule } from "@leafer-ui/interface"
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
export { Export } from './Export'
|
|
4
|
+
export const Effect: IEffectModule = {}
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
import { Paint } from './Paint'
|
|
9
|
-
import * as UIEffect from '@leafer-ui/effect'
|
|
10
|
-
import * as UIPaint from '@leafer-ui/paint'
|
|
6
|
+
export const Paint: IPaintModule = {}
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
export const Animate = {}
|
|
9
|
+
|
|
10
|
+
export const TextConvert: ITextConvertModule = {}
|
|
11
|
+
|
|
12
|
+
export const ColorConvert: IColorConvertModule = {}
|
|
13
|
+
|
|
14
|
+
export const Export: IExportModule = {}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IEffectModule, IPaintModule, ITextConvertModule, IColorConvertModule, IExportModule } from '@leafer-ui/interface';
|
|
2
|
+
|
|
3
|
+
declare const Effect: IEffectModule;
|
|
4
|
+
declare const Paint: IPaintModule;
|
|
5
|
+
declare const Animate: {};
|
|
6
|
+
declare const TextConvert: ITextConvertModule;
|
|
7
|
+
declare const ColorConvert: IColorConvertModule;
|
|
8
|
+
declare const Export: IExportModule;
|
|
9
|
+
|
|
10
|
+
export { Animate, ColorConvert, Effect, Export, Paint, TextConvert };
|
package/src/Animate.ts
DELETED
package/src/Effect.ts
DELETED
package/src/Export.ts
DELETED
|
@@ -1,81 +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 = await 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), { parallel: false })
|
|
80
|
-
})
|
|
81
|
-
}
|