@anu3ev/fabric-image-editor 0.1.46 → 0.1.48

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.
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-restricted-globals */
2
2
 
3
- self.onmessage = async(e) => {
3
+ self.onmessage = async(e: MessageEvent): Promise<void> => {
4
4
  const { action, payload, requestId } = e.data
5
5
 
6
6
  try {
@@ -23,9 +23,14 @@ self.onmessage = async(e) => {
23
23
  // рисуем изображение в offscreen
24
24
  const offscreen = new OffscreenCanvas(width, height)
25
25
  const ctx = offscreen.getContext('2d')
26
+
27
+ if (!ctx) {
28
+ throw new Error('Failed to get 2D context from OffscreenCanvas')
29
+ }
30
+
26
31
  ctx.drawImage(imgBitmap, 0, 0, width, height)
27
32
 
28
- // конвертим обратно в dataURL
33
+ // конвертим в blob
29
34
  const resizedBlob = await offscreen.convertToBlob()
30
35
 
31
36
  self.postMessage({ requestId, action, success: true, data: resizedBlob })
@@ -39,6 +44,11 @@ self.onmessage = async(e) => {
39
44
  // рисуем изображение в offscreen
40
45
  const off = new OffscreenCanvas(bitmap.width, bitmap.height)
41
46
  const ctx = off.getContext('2d')
47
+
48
+ if (!ctx) {
49
+ throw new Error('Failed to get 2D context from OffscreenCanvas')
50
+ }
51
+
42
52
  ctx.drawImage(bitmap, 0, 0, width, height)
43
53
 
44
54
  // конвертируем в blob, а затем в dataURL
@@ -63,6 +73,6 @@ self.onmessage = async(e) => {
63
73
  throw new Error(`Unknown action ${action}`)
64
74
  }
65
75
  } catch (err) {
66
- self.postMessage({ requestId, action, success: false, error: err.message })
76
+ self.postMessage({ requestId, action, success: false, error: (err as Error).message })
67
77
  }
68
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anu3ev/fabric-image-editor",
3
- "version": "0.1.46",
3
+ "version": "0.1.48",
4
4
  "description": "JavaScript image editor built on FabricJS, allowing you to create instances with an integrated montage area and providing an API to modify and manage state.",
5
5
  "module": "dist/main.js",
6
6
  "files": [