@leafer/worker 1.0.0-rc.9 → 1.0.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 +5 -6
- package/src/index.ts +5 -9
- package/types/index.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/worker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "@leafer/worker",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,12 +22,11 @@
|
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.0.
|
|
26
|
-
"@leafer/
|
|
27
|
-
"@leafer/
|
|
28
|
-
"@leafer/image-worker": "1.0.0-rc.9"
|
|
25
|
+
"@leafer/core": "1.0.1",
|
|
26
|
+
"@leafer/canvas-worker": "1.0.1",
|
|
27
|
+
"@leafer/image-worker": "1.0.1"
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|
|
31
|
-
"@leafer/interface": "1.0.
|
|
30
|
+
"@leafer/interface": "1.0.1"
|
|
32
31
|
}
|
|
33
32
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export * from '@leafer/core'
|
|
2
|
-
export * from '@leafer/partner'
|
|
3
2
|
|
|
4
3
|
export * from '@leafer/canvas-worker'
|
|
5
4
|
export * from '@leafer/image-worker'
|
|
6
5
|
|
|
7
6
|
import { ICreator, IFunction, IExportImageType, IExportFileType, IObject, ICanvasType } from '@leafer/interface'
|
|
8
|
-
import { Platform, Creator, FileHelper,
|
|
7
|
+
import { Platform, Creator, FileHelper, defineKey } from '@leafer/core'
|
|
9
8
|
|
|
10
9
|
import { LeaferCanvas } from '@leafer/canvas-worker'
|
|
11
10
|
import { LeaferImage } from '@leafer/image-worker'
|
|
@@ -15,10 +14,7 @@ const { mineType } = FileHelper
|
|
|
15
14
|
|
|
16
15
|
Object.assign(Creator, {
|
|
17
16
|
canvas: (options?, manager?) => new LeaferCanvas(options, manager),
|
|
18
|
-
image: (options) => new LeaferImage(options)
|
|
19
|
-
hitCanvas: (options?, manager?) => new LeaferCanvas(options, manager),
|
|
20
|
-
|
|
21
|
-
interaction: (target, canvas, selector, options?) => new InteractionBase(target, canvas, selector, options),
|
|
17
|
+
image: (options) => new LeaferImage(options)
|
|
22
18
|
} as ICreator)
|
|
23
19
|
|
|
24
20
|
|
|
@@ -39,11 +35,11 @@ export function useCanvas(_canvasType: ICanvasType, _power?: IObject): void {
|
|
|
39
35
|
},
|
|
40
36
|
canvasToBolb: (canvas: OffscreenCanvas, type?: IExportFileType, quality?: number) => (canvas as any).convertToBlob({ type: mineType(type), quality }),
|
|
41
37
|
canvasSaveAs: (_canvas: OffscreenCanvas, _filename: string, _quality?: any) => new Promise((resolve) => resolve()),
|
|
38
|
+
download(_url: string, _filename: string): Promise<void> { return undefined },
|
|
42
39
|
loadImage(src: any): Promise<ImageBitmap> {
|
|
43
40
|
return new Promise((resolve, reject) => {
|
|
44
|
-
if (!src.startsWith('data:') && Platform.image.suffix) src += (src.includes("?") ? "&" : "?") + Platform.image.suffix
|
|
45
41
|
let req = new XMLHttpRequest()
|
|
46
|
-
req.open('GET', src, true)
|
|
42
|
+
req.open('GET', Platform.image.getRealURL(src), true)
|
|
47
43
|
req.responseType = "blob"
|
|
48
44
|
req.onload = () => {
|
|
49
45
|
createImageBitmap(req.response).then(img => {
|
|
@@ -65,7 +61,7 @@ export function useCanvas(_canvasType: ICanvasType, _power?: IObject): void {
|
|
|
65
61
|
Platform.name = 'web'
|
|
66
62
|
Platform.isWorker = true
|
|
67
63
|
Platform.requestRender = function (render: IFunction): void { requestAnimationFrame(render) }
|
|
68
|
-
Platform
|
|
64
|
+
defineKey(Platform, 'devicePixelRatio', { get() { return 1 } })
|
|
69
65
|
|
|
70
66
|
|
|
71
67
|
// same as web
|