@leafer/web 1.3.3 → 1.4.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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/index.ts +7 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/web",
3
- "version": "1.3.3",
3
+ "version": "1.4.1",
4
4
  "description": "@leafer/web",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,11 +22,11 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.3.3",
26
- "@leafer/canvas-web": "1.3.3",
27
- "@leafer/image-web": "1.3.3"
25
+ "@leafer/core": "1.4.1",
26
+ "@leafer/canvas-web": "1.4.1",
27
+ "@leafer/image-web": "1.4.1"
28
28
  },
29
29
  "devDependencies": {
30
- "@leafer/interface": "1.3.3"
30
+ "@leafer/interface": "1.4.1"
31
31
  }
32
32
  }
package/src/index.ts CHANGED
@@ -26,7 +26,10 @@ export function useCanvas(_canvasType: ICanvasType, _power?: IObject): void {
26
26
  canvas.height = height
27
27
  return canvas
28
28
  },
29
- canvasToDataURL: (canvas: HTMLCanvasElement, type?: IExportImageType, quality?: number) => canvas.toDataURL(mineType(type), quality),
29
+ canvasToDataURL: (canvas: HTMLCanvasElement, type?: IExportImageType, quality?: number) => {
30
+ const imageType = mineType(type), url = canvas.toDataURL(imageType, quality)
31
+ return imageType === 'image/bmp' ? url.replace('image/png;', 'image/bmp;') : url
32
+ },
30
33
  canvasToBolb: (canvas: HTMLCanvasElement, type?: IExportFileType, quality?: number) => new Promise((resolve) => canvas.toBlob(resolve, mineType(type), quality)),
31
34
  canvasSaveAs: (canvas: HTMLCanvasElement, filename: string, quality?: any) => {
32
35
  const url = canvas.toDataURL(mineType(fileType(filename)), quality)
@@ -74,7 +77,7 @@ export function useCanvas(_canvasType: ICanvasType, _power?: IObject): void {
74
77
  Platform.name = 'web'
75
78
  Platform.isMobile = 'ontouchstart' in window
76
79
  Platform.requestRender = function (render: IFunction): void { window.requestAnimationFrame(render) }
77
- defineKey(Platform, 'devicePixelRatio', { get() { return Math.max(1, devicePixelRatio) } })
80
+ defineKey(Platform, 'devicePixelRatio', { get() { return devicePixelRatio } })
78
81
 
79
82
 
80
83
  // same as worker
@@ -85,8 +88,8 @@ if (userAgent.indexOf("Firefox") > -1) {
85
88
  Platform.conicGradientRotate90 = true
86
89
  Platform.intWheelDeltaY = true
87
90
  Platform.syncDomFont = true
88
- } else if (userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") === -1) {
89
- Platform.fullImageShadow = true
91
+ } else if (userAgent.indexOf("AppleWebKit") > -1) {
92
+ Platform.fullImageShadow = true // 苹果内核渲染阴影
90
93
  }
91
94
 
92
95
  if (userAgent.indexOf('Windows') > -1) {