@leafer/web 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 CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@leafer/web",
3
- "version": "1.0.0-beta.9",
3
+ "version": "1.0.0-rc.10",
4
4
  "description": "@leafer/web",
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",
@@ -19,13 +22,11 @@
19
22
  "leaferjs"
20
23
  ],
21
24
  "dependencies": {
22
- "@leafer/core": "1.0.0-beta.9",
23
- "@leafer/partner": "1.0.0-beta.9",
24
- "@leafer/canvas-web": "1.0.0-beta.9",
25
- "@leafer/interaction-web": "1.0.0-beta.9",
26
- "@leafer/image-web": "1.0.0-beta.9"
25
+ "@leafer/core": "1.0.0-rc.10",
26
+ "@leafer/canvas-web": "1.0.0-rc.10",
27
+ "@leafer/image-web": "1.0.0-rc.10"
27
28
  },
28
29
  "devDependencies": {
29
- "@leafer/interface": "1.0.0-beta.9"
30
+ "@leafer/interface": "1.0.0-rc.10"
30
31
  }
31
32
  }
package/src/index.ts CHANGED
@@ -1,16 +1,13 @@
1
1
  export * from '@leafer/core'
2
- export * from '@leafer/partner'
3
2
 
4
3
  export * from '@leafer/canvas-web'
5
4
  export * from '@leafer/image-web'
6
- export * from '@leafer/interaction-web'
7
5
 
8
6
  import { ICreator, IFunction, IExportImageType, IExportFileType, IObject, ICanvasType } from '@leafer/interface'
9
7
  import { Platform, Creator, FileHelper } from '@leafer/core'
10
8
 
11
9
  import { LeaferCanvas } from '@leafer/canvas-web'
12
10
  import { LeaferImage } from '@leafer/image-web'
13
- import { Interaction } from '@leafer/interaction-web'
14
11
 
15
12
 
16
13
  const { mineType, fileType } = FileHelper
@@ -18,10 +15,7 @@ const { mineType, fileType } = FileHelper
18
15
 
19
16
  Object.assign(Creator, {
20
17
  canvas: (options?, manager?) => new LeaferCanvas(options, manager),
21
- image: (options) => new LeaferImage(options),
22
- hitCanvas: (options?, manager?) => new LeaferCanvas(options, manager),
23
-
24
- interaction: (target, canvas, selector, options?) => new Interaction(target, canvas, selector, options),
18
+ image: (options) => new LeaferImage(options)
25
19
  } as ICreator)
26
20
 
27
21
 
@@ -49,30 +43,43 @@ export function useCanvas(_canvasType: ICanvasType, _power?: IObject): void {
49
43
  loadImage(src: any): Promise<HTMLImageElement> {
50
44
  return new Promise((resolve, reject) => {
51
45
  const img = new Image()
52
- img.setAttribute('crossOrigin', 'anonymous')
53
- img.crossOrigin = 'anonymous'
46
+ const { suffix, crossOrigin } = Platform.image
47
+ if (crossOrigin) {
48
+ img.setAttribute('crossOrigin', crossOrigin)
49
+ img.crossOrigin = crossOrigin
50
+ }
54
51
  img.onload = () => { resolve(img) }
55
52
  img.onerror = (e) => { reject(e) }
56
- if (!src.startsWith('data:')) src.includes("?") ? src + "&xhr" : src + "?xhr" // 需要带上xhr区分image标签的缓存,否则导致浏览器跨域问题
53
+ if (!src.startsWith('data:') && !src.startsWith('blob:') && suffix) src += (src.includes("?") ? "&" : "?") + suffix
57
54
  img.src = src
58
55
  })
59
56
  }
60
57
  }
61
58
 
59
+ Platform.event = {
60
+ stopDefault(origin: Event): void { origin.preventDefault() },
61
+ stopNow(origin: Event): void { origin.stopImmediatePropagation() },
62
+ stop(origin: Event): void { origin.stopPropagation() }
63
+ }
64
+
62
65
  Platform.canvas = Creator.canvas()
63
66
  Platform.conicGradientSupport = !!Platform.canvas.context.createConicGradient
64
67
  }
65
68
 
66
69
  Platform.name = 'web'
70
+ Platform.isMobile = 'ontouchstart' in window
67
71
  Platform.requestRender = function (render: IFunction): void { window.requestAnimationFrame(render) }
68
- Platform.devicePixelRatio = devicePixelRatio
69
- Platform.realtimeLayout = true
72
+ Platform.devicePixelRatio = Math.max(1, devicePixelRatio)
73
+
74
+
75
+ // same as worker
70
76
 
71
77
  const { userAgent } = navigator
72
78
 
73
79
  if (userAgent.indexOf("Firefox") > -1) {
74
80
  Platform.conicGradientRotate90 = true
75
81
  Platform.intWheelDeltaY = true
82
+ Platform.syncDomFont = true
76
83
  } else if (userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") === -1) {
77
84
  Platform.fullImageShadow = true
78
85
  }
@@ -0,0 +1,8 @@
1
+ export * from '@leafer/core';
2
+ export * from '@leafer/canvas-web';
3
+ export * from '@leafer/image-web';
4
+ import { ICanvasType, IObject } from '@leafer/interface';
5
+
6
+ declare function useCanvas(_canvasType: ICanvasType, _power?: IObject): void;
7
+
8
+ export { useCanvas };