react-screenshots 0.5.9 → 0.5.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.
Files changed (65) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +145 -145
  3. package/electron/assets/index.7793f29e.js +222 -0
  4. package/electron/assets/{index.95e77ee2.css → index.78c5dcbf.css} +1 -1
  5. package/electron/electron.html +14 -15
  6. package/lib/react-screenshots.cjs.js +4 -4
  7. package/lib/react-screenshots.es.js +188 -190
  8. package/lib/style.css +1 -1
  9. package/lib/types/ScreenshotsBackground/getBoundsByPoints.d.ts +2 -2
  10. package/lib/types/ScreenshotsBackground/index.d.ts +4 -4
  11. package/lib/types/ScreenshotsButton/index.d.ts +12 -12
  12. package/lib/types/ScreenshotsCanvas/getBoundsByPoints.d.ts +2 -2
  13. package/lib/types/ScreenshotsCanvas/getPoints.d.ts +2 -2
  14. package/lib/types/ScreenshotsCanvas/index.d.ts +15 -15
  15. package/lib/types/ScreenshotsCanvas/isPointInDraw.d.ts +2 -2
  16. package/lib/types/ScreenshotsColor/index.d.ts +8 -8
  17. package/lib/types/ScreenshotsContext.d.ts +29 -29
  18. package/lib/types/ScreenshotsMagnifier/index.d.ts +8 -8
  19. package/lib/types/ScreenshotsOperations/index.d.ts +6 -6
  20. package/lib/types/ScreenshotsOption/index.d.ts +15 -15
  21. package/lib/types/ScreenshotsSize/index.d.ts +8 -8
  22. package/lib/types/ScreenshotsSizeColor/index.d.ts +10 -10
  23. package/lib/types/ScreenshotsTextarea/calculateNodeSize.d.ts +17 -17
  24. package/lib/types/ScreenshotsTextarea/index.d.ts +15 -15
  25. package/lib/types/composeImage.d.ts +10 -10
  26. package/lib/types/exports.d.ts +3 -3
  27. package/lib/types/hooks/useBounds.d.ts +7 -7
  28. package/lib/types/hooks/useCall.d.ts +2 -2
  29. package/lib/types/hooks/useCanvasContextRef.d.ts +2 -2
  30. package/lib/types/hooks/useCanvasMousedown.d.ts +1 -1
  31. package/lib/types/hooks/useCanvasMousemove.d.ts +1 -1
  32. package/lib/types/hooks/useCanvasMouseup.d.ts +1 -1
  33. package/lib/types/hooks/useCursor.d.ts +6 -6
  34. package/lib/types/hooks/useDispatcher.d.ts +2 -2
  35. package/lib/types/hooks/useDrawSelect.d.ts +2 -2
  36. package/lib/types/hooks/useEmiter.d.ts +8 -8
  37. package/lib/types/hooks/useHistory.d.ts +16 -16
  38. package/lib/types/hooks/useLang.d.ts +2 -2
  39. package/lib/types/hooks/useOperation.d.ts +6 -6
  40. package/lib/types/hooks/useReset.d.ts +2 -2
  41. package/lib/types/hooks/useStore.d.ts +2 -2
  42. package/lib/types/index.d.ts +13 -13
  43. package/lib/types/operations/Arrow/draw.d.ts +11 -11
  44. package/lib/types/operations/Arrow/index.d.ts +22 -22
  45. package/lib/types/operations/Brush/draw.d.ts +3 -3
  46. package/lib/types/operations/Brush/index.d.ts +14 -14
  47. package/lib/types/operations/Cancel/index.d.ts +2 -2
  48. package/lib/types/operations/Ellipse/draw.d.ts +11 -11
  49. package/lib/types/operations/Ellipse/index.d.ts +28 -28
  50. package/lib/types/operations/Mosaic/index.d.ts +11 -11
  51. package/lib/types/operations/Ok/index.d.ts +2 -2
  52. package/lib/types/operations/Rectangle/draw.d.ts +11 -11
  53. package/lib/types/operations/Rectangle/index.d.ts +28 -28
  54. package/lib/types/operations/Redo/index.d.ts +2 -2
  55. package/lib/types/operations/Save/index.d.ts +2 -2
  56. package/lib/types/operations/Text/index.d.ts +22 -22
  57. package/lib/types/operations/Undo/index.d.ts +2 -2
  58. package/lib/types/operations/index.d.ts +3 -3
  59. package/lib/types/operations/utils.d.ts +4 -4
  60. package/lib/types/types.d.ts +39 -39
  61. package/lib/types/useGetLoadedImage.d.ts +1 -1
  62. package/lib/types/zh_CN.d.ts +16 -16
  63. package/package.json +2 -2
  64. package/electron/assets/index.c68b977f.js +0 -14
  65. package/electron/assets/vendor.e3c417b2.js +0 -209
@@ -1,41 +1,10 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
1
  import React, { useContext, useCallback, memo, useState, useRef, useLayoutEffect, useEffect, forwardRef, useImperativeHandle, cloneElement } from "react";
33
2
  import { createPortal } from "react-dom";
34
- var HistoryItemType;
35
- (function(HistoryItemType2) {
3
+ var HistoryItemType = /* @__PURE__ */ ((HistoryItemType2) => {
36
4
  HistoryItemType2[HistoryItemType2["Edit"] = 0] = "Edit";
37
5
  HistoryItemType2[HistoryItemType2["Source"] = 1] = "Source";
38
- })(HistoryItemType || (HistoryItemType = {}));
6
+ return HistoryItemType2;
7
+ })(HistoryItemType || {});
39
8
  function composeImage({ image, width, height, history, bounds }) {
40
9
  return new Promise((resolve, reject) => {
41
10
  const $canvas = document.createElement("canvas");
@@ -53,7 +22,17 @@ function composeImage({ image, width, height, history, bounds }) {
53
22
  ctx.imageSmoothingQuality = "low";
54
23
  ctx.setTransform(window.devicePixelRatio, 0, 0, window.devicePixelRatio, 0, 0);
55
24
  ctx.clearRect(0, 0, bounds.width, bounds.height);
56
- ctx.drawImage(image, bounds.x * rx, bounds.y * ry, bounds.width * rx, bounds.height * ry, 0, 0, bounds.width, bounds.height);
25
+ ctx.drawImage(
26
+ image,
27
+ bounds.x * rx,
28
+ bounds.y * ry,
29
+ bounds.width * rx,
30
+ bounds.height * ry,
31
+ 0,
32
+ 0,
33
+ bounds.width,
34
+ bounds.height
35
+ );
57
36
  history.stack.slice(0, history.index + 1).forEach((item) => {
58
37
  if (item.type === HistoryItemType.Source) {
59
38
  item.draw(ctx, item);
@@ -119,9 +98,12 @@ function useStore() {
119
98
  function useBounds() {
120
99
  const { bounds } = useStore();
121
100
  const { setBounds } = useDispatcher();
122
- const set = useCallback((bounds2) => {
123
- setBounds == null ? void 0 : setBounds(bounds2);
124
- }, [setBounds]);
101
+ const set = useCallback(
102
+ (bounds2) => {
103
+ setBounds == null ? void 0 : setBounds(bounds2);
104
+ },
105
+ [setBounds]
106
+ );
125
107
  const reset = useCallback(() => {
126
108
  setBounds == null ? void 0 : setBounds(null);
127
109
  }, [setBounds]);
@@ -138,7 +120,7 @@ function useLang() {
138
120
  return lang;
139
121
  }
140
122
  var index$9 = "";
141
- var _jsxFileName$l = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsMagnifier/index.tsx";
123
+ var _jsxFileName$l = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\ScreenshotsMagnifier\\index.tsx";
142
124
  const magnifierWidth = 100;
143
125
  const magnifierHeight = 80;
144
126
  var ScreenshotsMagnifier = memo(function ScreenshotsMagnifier2({
@@ -286,7 +268,7 @@ function getBoundsByPoints$2({ x: x1, y: y1 }, { x: x2, y: y2 }, width, height)
286
268
  };
287
269
  }
288
270
  var index$8 = "";
289
- var _jsxFileName$k = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsBackground/index.tsx";
271
+ var _jsxFileName$k = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\ScreenshotsBackground\\index.tsx";
290
272
  var ScreenshotsBackground = memo(function ScreenshotsBackground2() {
291
273
  const {
292
274
  url,
@@ -416,9 +398,12 @@ var ScreenshotsBackground = memo(function ScreenshotsBackground2() {
416
398
  function useCursor() {
417
399
  const { cursor } = useStore();
418
400
  const { setCursor } = useDispatcher();
419
- const set = useCallback((cursor2) => {
420
- setCursor == null ? void 0 : setCursor(cursor2);
421
- }, [setCursor]);
401
+ const set = useCallback(
402
+ (cursor2) => {
403
+ setCursor == null ? void 0 : setCursor(cursor2);
404
+ },
405
+ [setCursor]
406
+ );
422
407
  const reset = useCallback(() => {
423
408
  setCursor == null ? void 0 : setCursor("move");
424
409
  }, [setCursor]);
@@ -432,29 +417,38 @@ function useCursor() {
432
417
  }
433
418
  function useEmiter() {
434
419
  const { emiterRef } = useStore();
435
- const on = useCallback((event, listener) => {
436
- const emiter = emiterRef.current;
437
- if (Array.isArray(emiter[event])) {
438
- emiter[event].push(listener);
439
- } else {
440
- emiter[event] = [listener];
441
- }
442
- }, [emiterRef]);
443
- const off = useCallback((event, listener) => {
444
- const emiter = emiterRef.current;
445
- if (Array.isArray(emiter[event])) {
446
- const index2 = emiter[event].findIndex((item) => item === listener);
447
- if (index2 !== -1) {
448
- emiter[event].splice(index2, 1);
420
+ const on = useCallback(
421
+ (event, listener) => {
422
+ const emiter = emiterRef.current;
423
+ if (Array.isArray(emiter[event])) {
424
+ emiter[event].push(listener);
425
+ } else {
426
+ emiter[event] = [listener];
449
427
  }
450
- }
451
- }, [emiterRef]);
452
- const emit = useCallback((event, ...args) => {
453
- const emiter = emiterRef.current;
454
- if (Array.isArray(emiter[event])) {
455
- emiter[event].forEach((listener) => listener(...args));
456
- }
457
- }, [emiterRef]);
428
+ },
429
+ [emiterRef]
430
+ );
431
+ const off = useCallback(
432
+ (event, listener) => {
433
+ const emiter = emiterRef.current;
434
+ if (Array.isArray(emiter[event])) {
435
+ const index2 = emiter[event].findIndex((item) => item === listener);
436
+ if (index2 !== -1) {
437
+ emiter[event].splice(index2, 1);
438
+ }
439
+ }
440
+ },
441
+ [emiterRef]
442
+ );
443
+ const emit = useCallback(
444
+ (event, ...args) => {
445
+ const emiter = emiterRef.current;
446
+ if (Array.isArray(emiter[event])) {
447
+ emiter[event].forEach((listener) => listener(...args));
448
+ }
449
+ },
450
+ [emiterRef]
451
+ );
458
452
  const reset = useCallback(() => {
459
453
  emiterRef.current = {};
460
454
  }, [emiterRef]);
@@ -468,25 +462,28 @@ function useEmiter() {
468
462
  function useHistory() {
469
463
  const { history } = useStore();
470
464
  const { setHistory } = useDispatcher();
471
- const push = useCallback((action) => {
472
- const { index: index2, stack } = history;
473
- stack.forEach((item) => {
474
- if (item.type === HistoryItemType.Source) {
475
- item.isSelected = false;
465
+ const push = useCallback(
466
+ (action) => {
467
+ const { index: index2, stack } = history;
468
+ stack.forEach((item) => {
469
+ if (item.type === HistoryItemType.Source) {
470
+ item.isSelected = false;
471
+ }
472
+ });
473
+ if (action.type === HistoryItemType.Source) {
474
+ action.isSelected = true;
475
+ } else if (action.type === HistoryItemType.Edit) {
476
+ action.source.isSelected = true;
476
477
  }
477
- });
478
- if (action.type === HistoryItemType.Source) {
479
- action.isSelected = true;
480
- } else if (action.type === HistoryItemType.Edit) {
481
- action.source.isSelected = true;
482
- }
483
- stack.splice(index2 + 1);
484
- stack.push(action);
485
- setHistory == null ? void 0 : setHistory({
486
- index: stack.length - 1,
487
- stack
488
- });
489
- }, [history, setHistory]);
478
+ stack.splice(index2 + 1);
479
+ stack.push(action);
480
+ setHistory == null ? void 0 : setHistory({
481
+ index: stack.length - 1,
482
+ stack
483
+ });
484
+ },
485
+ [history, setHistory]
486
+ );
490
487
  const pop = useCallback(() => {
491
488
  const { stack } = history;
492
489
  stack.pop();
@@ -525,28 +522,34 @@ function useHistory() {
525
522
  stack
526
523
  });
527
524
  }, [history, setHistory]);
528
- const set = useCallback((history2) => {
529
- setHistory == null ? void 0 : setHistory(__spreadValues({}, history2));
530
- }, [setHistory]);
531
- const select = useCallback((action) => {
532
- history.stack.forEach((item) => {
533
- if (item.type === HistoryItemType.Source) {
534
- if (item === action) {
535
- item.isSelected = true;
536
- } else {
537
- item.isSelected = false;
525
+ const set = useCallback(
526
+ (history2) => {
527
+ setHistory == null ? void 0 : setHistory({ ...history2 });
528
+ },
529
+ [setHistory]
530
+ );
531
+ const select = useCallback(
532
+ (action) => {
533
+ history.stack.forEach((item) => {
534
+ if (item.type === HistoryItemType.Source) {
535
+ if (item === action) {
536
+ item.isSelected = true;
537
+ } else {
538
+ item.isSelected = false;
539
+ }
538
540
  }
539
- }
540
- });
541
- setHistory == null ? void 0 : setHistory(__spreadValues({}, history));
542
- }, [history, setHistory]);
541
+ });
542
+ setHistory == null ? void 0 : setHistory({ ...history });
543
+ },
544
+ [history, setHistory]
545
+ );
543
546
  const clearSelect = useCallback(() => {
544
547
  history.stack.forEach((item) => {
545
548
  if (item.type === HistoryItemType.Source) {
546
549
  item.isSelected = false;
547
550
  }
548
551
  });
549
- setHistory == null ? void 0 : setHistory(__spreadValues({}, history));
552
+ setHistory == null ? void 0 : setHistory({ ...history });
550
553
  }, [history, setHistory]);
551
554
  const reset = useCallback(() => {
552
555
  setHistory == null ? void 0 : setHistory({
@@ -575,9 +578,12 @@ function useHistory() {
575
578
  function useOperation() {
576
579
  const { operation } = useStore();
577
580
  const { setOperation } = useDispatcher();
578
- const set = useCallback((operation2) => {
579
- setOperation == null ? void 0 : setOperation(operation2);
580
- }, [setOperation]);
581
+ const set = useCallback(
582
+ (operation2) => {
583
+ setOperation == null ? void 0 : setOperation(operation2);
584
+ },
585
+ [setOperation]
586
+ );
581
587
  const reset = useCallback(() => {
582
588
  setOperation == null ? void 0 : setOperation(void 0);
583
589
  }, [setOperation]);
@@ -706,21 +712,9 @@ function isPointInDraw(bounds, canvas, history, e) {
706
712
  return (_a = item.isHit) == null ? void 0 : _a.call(item, ctx, item, { x, y });
707
713
  });
708
714
  }
709
- var _jsxFileName$j = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsCanvas/index.tsx";
715
+ var _jsxFileName$j = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\ScreenshotsCanvas\\index.tsx";
710
716
  const borders = ["top", "right", "bottom", "left"];
711
- var ResizePoints;
712
- (function(ResizePoints2) {
713
- ResizePoints2["ResizeTop"] = "top";
714
- ResizePoints2["ResizetopRight"] = "top-right";
715
- ResizePoints2["ResizeRight"] = "right";
716
- ResizePoints2["ResizeRightBottom"] = "right-bottom";
717
- ResizePoints2["ResizeBottom"] = "bottom";
718
- ResizePoints2["ResizeBottomLeft"] = "bottom-left";
719
- ResizePoints2["ResizeLeft"] = "left";
720
- ResizePoints2["ResizeLeftTop"] = "left-top";
721
- ResizePoints2["Move"] = "move";
722
- })(ResizePoints || (ResizePoints = {}));
723
- const resizePoints = [ResizePoints.ResizeTop, ResizePoints.ResizetopRight, ResizePoints.ResizeRight, ResizePoints.ResizeRightBottom, ResizePoints.ResizeBottom, ResizePoints.ResizeBottomLeft, ResizePoints.ResizeLeft, ResizePoints.ResizeLeftTop];
717
+ const resizePoints = ["top", "top-right", "right", "right-bottom", "bottom", "bottom-left", "left", "left-top"];
724
718
  var ScreenshotsCanvas = memo(forwardRef(function ScreenshotsCanvas2(props, ref) {
725
719
  const {
726
720
  url,
@@ -911,10 +905,13 @@ var ScreenshotsCanvas = memo(forwardRef(function ScreenshotsCanvas2(props, ref)
911
905
  }));
912
906
  function useCall() {
913
907
  const dispatcher = useDispatcher();
914
- const call = useCallback((funcName, ...args) => {
915
- var _a;
916
- (_a = dispatcher.call) == null ? void 0 : _a.call(dispatcher, funcName, ...args);
917
- }, [dispatcher]);
908
+ const call = useCallback(
909
+ (funcName, ...args) => {
910
+ var _a;
911
+ (_a = dispatcher.call) == null ? void 0 : _a.call(dispatcher, funcName, ...args);
912
+ },
913
+ [dispatcher]
914
+ );
918
915
  return call;
919
916
  }
920
917
  function useCanvasContextRef() {
@@ -937,12 +934,7 @@ function useReset() {
937
934
  return reset;
938
935
  }
939
936
  var index$6 = "";
940
- var _jsxFileName$i = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsOption/index.tsx";
941
- var Placement;
942
- (function(Placement2) {
943
- Placement2["Bottom"] = "bottom";
944
- Placement2["Top"] = "top";
945
- })(Placement || (Placement = {}));
937
+ var _jsxFileName$i = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\ScreenshotsOption\\index.tsx";
946
938
  var ScreenshotsOption = memo(function ScreenshotsOption2({
947
939
  open,
948
940
  content,
@@ -953,7 +945,7 @@ var ScreenshotsOption = memo(function ScreenshotsOption2({
953
945
  const popoverRef = useRef(null);
954
946
  const contentRef = useRef(null);
955
947
  const operationsRect = useContext(ScreenshotsOperationsCtx);
956
- const [placement, setPlacement] = useState(Placement.Bottom);
948
+ const [placement, setPlacement] = useState("bottom");
957
949
  const [position, setPosition] = useState(null);
958
950
  const [offsetX, setOffsetX] = useState(0);
959
951
  const getPopoverEl = () => {
@@ -992,14 +984,14 @@ var ScreenshotsOption = memo(function ScreenshotsOption2({
992
984
  currentOffsetX = ox - x;
993
985
  }
994
986
  if (y > window.innerHeight - contentRect.height) {
995
- if (currentPlacement === Placement.Bottom) {
996
- currentPlacement = Placement.Top;
987
+ if (currentPlacement === "bottom") {
988
+ currentPlacement = "top";
997
989
  }
998
990
  y = childrenRect.top - contentRect.height;
999
991
  }
1000
992
  if (y < 0) {
1001
- if (currentPlacement === Placement.Top) {
1002
- currentPlacement = Placement.Bottom;
993
+ if (currentPlacement === "top") {
994
+ currentPlacement = "bottom";
1003
995
  }
1004
996
  y = childrenRect.top + childrenRect.height;
1005
997
  }
@@ -1054,7 +1046,7 @@ var ScreenshotsOption = memo(function ScreenshotsOption2({
1054
1046
  })), getPopoverEl()));
1055
1047
  });
1056
1048
  var index$5 = "";
1057
- var _jsxFileName$h = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsButton/index.tsx";
1049
+ var _jsxFileName$h = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\ScreenshotsButton\\index.tsx";
1058
1050
  var ScreenshotsButton = memo(function ScreenshotsButton2({
1059
1051
  title,
1060
1052
  icon,
@@ -1105,7 +1097,7 @@ var ScreenshotsButton = memo(function ScreenshotsButton2({
1105
1097
  }
1106
1098
  })));
1107
1099
  });
1108
- var _jsxFileName$g = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/operations/Ok/index.tsx";
1100
+ var _jsxFileName$g = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\operations\\Ok\\index.tsx";
1109
1101
  function Ok() {
1110
1102
  const {
1111
1103
  image,
@@ -1149,7 +1141,7 @@ function Ok() {
1149
1141
  }
1150
1142
  });
1151
1143
  }
1152
- var _jsxFileName$f = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/operations/Cancel/index.tsx";
1144
+ var _jsxFileName$f = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\operations\\Cancel\\index.tsx";
1153
1145
  function Cancel() {
1154
1146
  const call = useCall();
1155
1147
  const reset = useReset();
@@ -1170,7 +1162,7 @@ function Cancel() {
1170
1162
  }
1171
1163
  });
1172
1164
  }
1173
- var _jsxFileName$e = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/operations/Save/index.tsx";
1165
+ var _jsxFileName$e = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\operations\\Save\\index.tsx";
1174
1166
  function Save() {
1175
1167
  const {
1176
1168
  image,
@@ -1214,7 +1206,7 @@ function Save() {
1214
1206
  }
1215
1207
  });
1216
1208
  }
1217
- var _jsxFileName$d = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/operations/Redo/index.tsx";
1209
+ var _jsxFileName$d = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\operations\\Redo\\index.tsx";
1218
1210
  function Redo() {
1219
1211
  const lang = useLang();
1220
1212
  const [history, historyDispatcher] = useHistory();
@@ -1234,7 +1226,7 @@ function Redo() {
1234
1226
  }
1235
1227
  });
1236
1228
  }
1237
- var _jsxFileName$c = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/operations/Undo/index.tsx";
1229
+ var _jsxFileName$c = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\operations\\Undo\\index.tsx";
1238
1230
  function Undo() {
1239
1231
  const lang = useLang();
1240
1232
  const [history, historyDispatcher] = useHistory();
@@ -1255,7 +1247,7 @@ function Undo() {
1255
1247
  });
1256
1248
  }
1257
1249
  var index$4 = "";
1258
- var _jsxFileName$b = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsSize/index.tsx";
1250
+ var _jsxFileName$b = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\ScreenshotsSize\\index.tsx";
1259
1251
  var ScreenshotsSize = memo(function ScreenshotsSize2({
1260
1252
  value,
1261
1253
  onChange
@@ -1326,7 +1318,7 @@ function useCanvasMouseup(onMouseup) {
1326
1318
  };
1327
1319
  }, [onMouseup, emiter]);
1328
1320
  }
1329
- var _jsxFileName$a = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/operations/Mosaic/index.tsx";
1321
+ var _jsxFileName$a = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\operations\\Mosaic\\index.tsx";
1330
1322
  function getColor(x, y, imageData) {
1331
1323
  if (!imageData) {
1332
1324
  return [0, 0, 0, 0];
@@ -1498,7 +1490,7 @@ function Mosaic() {
1498
1490
  });
1499
1491
  }
1500
1492
  var index$3 = "";
1501
- var _jsxFileName$9 = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsColor/index.tsx";
1493
+ var _jsxFileName$9 = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\ScreenshotsColor\\index.tsx";
1502
1494
  var ScreenshotsColor = memo(function ScreenshotsColor2({
1503
1495
  value,
1504
1496
  onChange
@@ -1534,7 +1526,7 @@ var ScreenshotsColor = memo(function ScreenshotsColor2({
1534
1526
  }));
1535
1527
  });
1536
1528
  var index$2 = "";
1537
- var _jsxFileName$8 = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsSizeColor/index.tsx";
1529
+ var _jsxFileName$8 = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\ScreenshotsSizeColor\\index.tsx";
1538
1530
  var ScreenshotsSizeColor = memo(function ScreenshotsSizeColor2({
1539
1531
  size,
1540
1532
  color,
@@ -1621,7 +1613,10 @@ function calculateNodeSize(textarea, value, maxWidth, maxHeight) {
1621
1613
  document.body.appendChild(hiddenTextarea);
1622
1614
  }
1623
1615
  const { paddingSize, borderSize, boxSizing, sizingStyle } = getComputedSizeInfo(textarea);
1624
- hiddenTextarea.setAttribute("style", `${sizingStyle};${hiddenTextareaStyle};max-width:${maxWidth}px;max-height:${maxHeight}px`);
1616
+ hiddenTextarea.setAttribute(
1617
+ "style",
1618
+ `${sizingStyle};${hiddenTextareaStyle};max-width:${maxWidth}px;max-height:${maxHeight}px`
1619
+ );
1625
1620
  hiddenTextarea.value = value || " ";
1626
1621
  let width = hiddenTextarea.scrollWidth;
1627
1622
  let height = hiddenTextarea.scrollHeight;
@@ -1638,7 +1633,7 @@ function calculateNodeSize(textarea, value, maxWidth, maxHeight) {
1638
1633
  };
1639
1634
  }
1640
1635
  var index$1 = "";
1641
- var _jsxFileName$7 = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsTextarea/index.tsx";
1636
+ var _jsxFileName$7 = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\ScreenshotsTextarea\\index.tsx";
1642
1637
  var ScreenshotsTextarea = memo(function ScreenshotsTextarea2({
1643
1638
  x,
1644
1639
  y,
@@ -1717,7 +1712,7 @@ function useDrawSelect(onDrawSelect) {
1717
1712
  };
1718
1713
  }, [onDrawSelect, emiter]);
1719
1714
  }
1720
- var _jsxFileName$6 = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/operations/Text/index.tsx";
1715
+ var _jsxFileName$6 = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\operations\\Text\\index.tsx";
1721
1716
  const sizes = {
1722
1717
  3: 18,
1723
1718
  6: 32,
@@ -1977,10 +1972,13 @@ function draw$3(ctx, action) {
1977
1972
  ctx.lineJoin = "round";
1978
1973
  ctx.lineWidth = size;
1979
1974
  ctx.strokeStyle = color;
1980
- const distance = action.editHistory.reduce((distance2, { data }) => ({
1981
- x: distance2.x + data.x2 - data.x1,
1982
- y: distance2.y + data.y2 - data.y1
1983
- }), { x: 0, y: 0 });
1975
+ const distance = action.editHistory.reduce(
1976
+ (distance2, { data }) => ({
1977
+ x: distance2.x + data.x2 - data.x1,
1978
+ y: distance2.y + data.y2 - data.y1
1979
+ }),
1980
+ { x: 0, y: 0 }
1981
+ );
1984
1982
  ctx.beginPath();
1985
1983
  points.forEach((item, index2) => {
1986
1984
  if (index2 === 0) {
@@ -2004,7 +2002,7 @@ function draw$3(ctx, action) {
2004
2002
  ctx.stroke();
2005
2003
  }
2006
2004
  }
2007
- var _jsxFileName$5 = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/operations/Brush/index.tsx";
2005
+ var _jsxFileName$5 = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\operations\\Brush\\index.tsx";
2008
2006
  function Brush() {
2009
2007
  const lang = useLang();
2010
2008
  const [, cursorDispatcher] = useCursor();
@@ -2154,12 +2152,13 @@ function getEditedArrowData(action) {
2154
2152
  y2 += y;
2155
2153
  }
2156
2154
  });
2157
- return __spreadProps(__spreadValues({}, action.data), {
2155
+ return {
2156
+ ...action.data,
2158
2157
  x1,
2159
2158
  x2,
2160
2159
  y1,
2161
2160
  y2
2162
- });
2161
+ };
2163
2162
  }
2164
2163
  function draw$2(ctx, action) {
2165
2164
  const { size, color, x1, x2, y1, y2 } = getEditedArrowData(action);
@@ -2183,13 +2182,13 @@ function draw$2(ctx, action) {
2183
2182
  drawDragCircle(ctx, x2, y2);
2184
2183
  }
2185
2184
  }
2186
- var _jsxFileName$4 = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/operations/Arrow/index.tsx";
2187
- var ArrowEditType;
2188
- (function(ArrowEditType2) {
2185
+ var _jsxFileName$4 = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\operations\\Arrow\\index.tsx";
2186
+ var ArrowEditType = /* @__PURE__ */ ((ArrowEditType2) => {
2189
2187
  ArrowEditType2[ArrowEditType2["Move"] = 0] = "Move";
2190
2188
  ArrowEditType2[ArrowEditType2["MoveStart"] = 1] = "MoveStart";
2191
2189
  ArrowEditType2[ArrowEditType2["MoveEnd"] = 2] = "MoveEnd";
2192
- })(ArrowEditType || (ArrowEditType = {}));
2190
+ return ArrowEditType2;
2191
+ })(ArrowEditType || {});
2193
2192
  function Arrow() {
2194
2193
  const lang = useLang();
2195
2194
  const [, cursorDispatcher] = useCursor();
@@ -2371,12 +2370,13 @@ function getEditedEllipseData(action) {
2371
2370
  y1 += y;
2372
2371
  }
2373
2372
  });
2374
- return __spreadProps(__spreadValues({}, action.data), {
2373
+ return {
2374
+ ...action.data,
2375
2375
  x1,
2376
2376
  x2,
2377
2377
  y1,
2378
2378
  y2
2379
- });
2379
+ };
2380
2380
  }
2381
2381
  function draw$1(ctx, action) {
2382
2382
  const { size, color, x1, y1, x2, y2 } = getEditedEllipseData(action);
@@ -2420,9 +2420,8 @@ function draw$1(ctx, action) {
2420
2420
  drawDragCircle(ctx, x1, y1);
2421
2421
  }
2422
2422
  }
2423
- var _jsxFileName$3 = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/operations/Ellipse/index.tsx";
2424
- var EllipseEditType;
2425
- (function(EllipseEditType2) {
2423
+ var _jsxFileName$3 = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\operations\\Ellipse\\index.tsx";
2424
+ var EllipseEditType = /* @__PURE__ */ ((EllipseEditType2) => {
2426
2425
  EllipseEditType2[EllipseEditType2["Move"] = 0] = "Move";
2427
2426
  EllipseEditType2[EllipseEditType2["ResizeTop"] = 1] = "ResizeTop";
2428
2427
  EllipseEditType2[EllipseEditType2["ResizeRightTop"] = 2] = "ResizeRightTop";
@@ -2432,7 +2431,8 @@ var EllipseEditType;
2432
2431
  EllipseEditType2[EllipseEditType2["ResizeLeftBottom"] = 6] = "ResizeLeftBottom";
2433
2432
  EllipseEditType2[EllipseEditType2["ResizeLeft"] = 7] = "ResizeLeft";
2434
2433
  EllipseEditType2[EllipseEditType2["ResizeLeftTop"] = 8] = "ResizeLeftTop";
2435
- })(EllipseEditType || (EllipseEditType = {}));
2434
+ return EllipseEditType2;
2435
+ })(EllipseEditType || {});
2436
2436
  function Ellipse() {
2437
2437
  const lang = useLang();
2438
2438
  const [history, historyDispatcher] = useHistory();
@@ -2646,12 +2646,13 @@ function getEditedRectangleData(action) {
2646
2646
  y1 += y;
2647
2647
  }
2648
2648
  });
2649
- return __spreadProps(__spreadValues({}, action.data), {
2649
+ return {
2650
+ ...action.data,
2650
2651
  x1,
2651
2652
  x2,
2652
2653
  y1,
2653
2654
  y2
2654
- });
2655
+ };
2655
2656
  }
2656
2657
  function draw(ctx, action) {
2657
2658
  const { size, color, x1, y1, x2, y2 } = getEditedRectangleData(action);
@@ -2680,9 +2681,8 @@ function draw(ctx, action) {
2680
2681
  drawDragCircle(ctx, x1, y1);
2681
2682
  }
2682
2683
  }
2683
- var _jsxFileName$2 = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/operations/Rectangle/index.tsx";
2684
- var RectangleEditType;
2685
- (function(RectangleEditType2) {
2684
+ var _jsxFileName$2 = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\operations\\Rectangle\\index.tsx";
2685
+ var RectangleEditType = /* @__PURE__ */ ((RectangleEditType2) => {
2686
2686
  RectangleEditType2[RectangleEditType2["Move"] = 0] = "Move";
2687
2687
  RectangleEditType2[RectangleEditType2["ResizeTop"] = 1] = "ResizeTop";
2688
2688
  RectangleEditType2[RectangleEditType2["ResizeRightTop"] = 2] = "ResizeRightTop";
@@ -2692,7 +2692,8 @@ var RectangleEditType;
2692
2692
  RectangleEditType2[RectangleEditType2["ResizeLeftBottom"] = 6] = "ResizeLeftBottom";
2693
2693
  RectangleEditType2[RectangleEditType2["ResizeLeft"] = 7] = "ResizeLeft";
2694
2694
  RectangleEditType2[RectangleEditType2["ResizeLeftTop"] = 8] = "ResizeLeftTop";
2695
- })(RectangleEditType || (RectangleEditType = {}));
2695
+ return RectangleEditType2;
2696
+ })(RectangleEditType || {});
2696
2697
  function Rectangle() {
2697
2698
  const lang = useLang();
2698
2699
  const [history, historyDispatcher] = useHistory();
@@ -2877,7 +2878,7 @@ function Rectangle() {
2877
2878
  }
2878
2879
  var OperationButtons = [Rectangle, Ellipse, Arrow, Brush, Text, Mosaic, "|", Undo, Redo, "|", Save, Cancel, Ok];
2879
2880
  var index = "";
2880
- var _jsxFileName$1 = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/ScreenshotsOperations/index.tsx";
2881
+ var _jsxFileName$1 = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\ScreenshotsOperations\\index.tsx";
2881
2882
  const ScreenshotsOperationsCtx = React.createContext(null);
2882
2883
  var ScreenshotsOperations = memo(function ScreenshotsOperations2() {
2883
2884
  var _a, _b;
@@ -2912,13 +2913,13 @@ var ScreenshotsOperations = memo(function ScreenshotsOperations2() {
2912
2913
  if (y > height - elRect.height) {
2913
2914
  y = height - elRect.height - 10;
2914
2915
  }
2915
- if ((position == null ? void 0 : position.x) !== x || position.y !== y) {
2916
+ if (!position || Math.abs(position.x - x) > 1 || Math.abs(position.y - y) > 1) {
2916
2917
  setPosition({
2917
2918
  x,
2918
2919
  y
2919
2920
  });
2920
2921
  }
2921
- if ((operationsRect == null ? void 0 : operationsRect.x) !== elRect.x || operationsRect.y !== elRect.y || operationsRect.width !== elRect.width || operationsRect.height !== elRect.height) {
2922
+ if (!operationsRect || Math.abs(operationsRect.x - elRect.x) > 1 || Math.abs(operationsRect.y - elRect.y) > 1 || Math.abs(operationsRect.width - elRect.width) > 1 || Math.abs(operationsRect.height - elRect.height) > 1) {
2922
2923
  setOperationsRect({
2923
2924
  x: elRect.x,
2924
2925
  y: elRect.y,
@@ -2935,7 +2936,7 @@ var ScreenshotsOperations = memo(function ScreenshotsOperations2() {
2935
2936
  __self: this,
2936
2937
  __source: {
2937
2938
  fileName: _jsxFileName$1,
2938
- lineNumber: 76,
2939
+ lineNumber: 79,
2939
2940
  columnNumber: 5
2940
2941
  }
2941
2942
  }, /* @__PURE__ */ React.createElement("div", {
@@ -2950,7 +2951,7 @@ var ScreenshotsOperations = memo(function ScreenshotsOperations2() {
2950
2951
  __self: this,
2951
2952
  __source: {
2952
2953
  fileName: _jsxFileName$1,
2953
- lineNumber: 77,
2954
+ lineNumber: 80,
2954
2955
  columnNumber: 7
2955
2956
  }
2956
2957
  }, /* @__PURE__ */ React.createElement("div", {
@@ -2958,7 +2959,7 @@ var ScreenshotsOperations = memo(function ScreenshotsOperations2() {
2958
2959
  __self: this,
2959
2960
  __source: {
2960
2961
  fileName: _jsxFileName$1,
2961
- lineNumber: 87,
2962
+ lineNumber: 90,
2962
2963
  columnNumber: 9
2963
2964
  }
2964
2965
  }, OperationButtons.map((OperationButton, index2) => {
@@ -2969,7 +2970,7 @@ var ScreenshotsOperations = memo(function ScreenshotsOperations2() {
2969
2970
  __self: this,
2970
2971
  __source: {
2971
2972
  fileName: _jsxFileName$1,
2972
- lineNumber: 90,
2973
+ lineNumber: 93,
2973
2974
  columnNumber: 22
2974
2975
  }
2975
2976
  });
@@ -2979,7 +2980,7 @@ var ScreenshotsOperations = memo(function ScreenshotsOperations2() {
2979
2980
  __self: this,
2980
2981
  __source: {
2981
2982
  fileName: _jsxFileName$1,
2982
- lineNumber: 92,
2983
+ lineNumber: 95,
2983
2984
  columnNumber: 22
2984
2985
  }
2985
2986
  });
@@ -3006,21 +3007,15 @@ function useGetLoadedImage(url) {
3006
3007
  }, [url]);
3007
3008
  return image;
3008
3009
  }
3009
- var _jsxFileName = "/Users/nashaofu/Documents/GitHub/screenshots/packages/react-screenshots/src/Screenshots/index.tsx";
3010
- function Screenshots(_a) {
3011
- var _b = _a, {
3012
- url,
3013
- width,
3014
- height,
3015
- lang,
3016
- className
3017
- } = _b, props = __objRest(_b, [
3018
- "url",
3019
- "width",
3020
- "height",
3021
- "lang",
3022
- "className"
3023
- ]);
3010
+ var _jsxFileName = "C:\\Users\\nashaofu\\Documents\\Github\\screenshots\\packages\\react-screenshots\\src\\Screenshots\\index.tsx";
3011
+ function Screenshots({
3012
+ url,
3013
+ width,
3014
+ height,
3015
+ lang,
3016
+ className,
3017
+ ...props
3018
+ }) {
3024
3019
  const image = useGetLoadedImage(url);
3025
3020
  const canvasContextRef = useRef(null);
3026
3021
  const emiterRef = useRef({});
@@ -3036,7 +3031,10 @@ function Screenshots(_a) {
3036
3031
  width,
3037
3032
  height,
3038
3033
  image,
3039
- lang: __spreadValues(__spreadValues({}, zhCN), lang),
3034
+ lang: {
3035
+ ...zhCN,
3036
+ ...lang
3037
+ },
3040
3038
  emiterRef,
3041
3039
  canvasContextRef,
3042
3040
  history,