@merittdev/horus-lens 0.6.0 → 0.6.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.
@@ -5,7 +5,7 @@ import {
5
5
  SDK_VERSION,
6
6
  Transport,
7
7
  installConsole
8
- } from "./chunk-XGZ7BZTS.js";
8
+ } from "./chunk-KRNRUQ7I.js";
9
9
 
10
10
  // ../react-native/dist/index.js
11
11
  import { AppState as AppState2 } from "react-native";
@@ -684,6 +684,7 @@ var NativeLensClient = class {
684
684
  }
685
685
  };
686
686
  var tools = [
687
+ ["pan", "Move"],
687
688
  ["rect", "Rectangle"],
688
689
  ["ellipse", "Ellipse"],
689
690
  ["arrow", "Arrow"],
@@ -863,6 +864,10 @@ function AnnotationEditor({
863
864
  const [exporting, setExporting] = useState(false);
864
865
  const [error, setError] = useState("");
865
866
  const canvas = useRef(null);
867
+ const viewport = useRef(null);
868
+ const scrollOffset = useRef(0);
869
+ const scrollStart = useRef(0);
870
+ const scrollTouchY = useRef(0);
866
871
  const mounted = useRef(true);
867
872
  useEffect(() => {
868
873
  mounted.current = true;
@@ -873,16 +878,30 @@ function AnnotationEditor({
873
878
  const points = useRef([]);
874
879
  const screen = useWindowDimensions();
875
880
  const [stageSize, setStageSize] = useState({ width: 0, height: 0 });
876
- const scale = Math.min(
877
- Math.max(1, (stageSize.width || screen.width) - 32) / image.width,
878
- Math.max(1, (stageSize.height || screen.height - 260) - 16) / image.height
879
- );
881
+ const scale = exporting ? 1 : Math.max(1, (stageSize.width || screen.width) - 32) / image.width;
880
882
  const shownCrop = exporting ? crop : null;
883
+ function moveScreenshot(pageY) {
884
+ const maxOffset = Math.max(
885
+ 0,
886
+ image.height * scale - (stageSize.height - 16)
887
+ );
888
+ const y = Math.max(
889
+ 0,
890
+ Math.min(maxOffset, scrollStart.current + scrollTouchY.current - pageY)
891
+ );
892
+ scrollOffset.current = y;
893
+ viewport.current?.scrollTo({ y, animated: false });
894
+ }
881
895
  const responder = useMemo(
882
896
  () => PanResponder.create({
883
897
  onStartShouldSetPanResponder: () => !exporting,
884
898
  onMoveShouldSetPanResponder: () => !exporting,
885
899
  onPanResponderGrant: (event) => {
900
+ if (tool === "pan") {
901
+ scrollStart.current = scrollOffset.current;
902
+ scrollTouchY.current = event.nativeEvent.pageY;
903
+ return;
904
+ }
886
905
  const { locationX, locationY } = event.nativeEvent;
887
906
  points.current = [
888
907
  {
@@ -901,6 +920,10 @@ function AnnotationEditor({
901
920
  );
902
921
  },
903
922
  onPanResponderMove: (event) => {
923
+ if (tool === "pan") {
924
+ moveScreenshot(event.nativeEvent.pageY);
925
+ return;
926
+ }
904
927
  const { locationX, locationY } = event.nativeEvent;
905
928
  const p = {
906
929
  x: Math.max(0, Math.min(image.width, locationX / scale)),
@@ -920,6 +943,10 @@ function AnnotationEditor({
920
943
  );
921
944
  },
922
945
  onPanResponderRelease: (event) => {
946
+ if (tool === "pan") {
947
+ moveScreenshot(event.nativeEvent.pageY);
948
+ return;
949
+ }
923
950
  const first = points.current[0];
924
951
  if (first && tool !== "text" && tool !== "step") {
925
952
  const { locationX, locationY } = event.nativeEvent;
@@ -963,7 +990,17 @@ function AnnotationEditor({
963
990
  points.current = [];
964
991
  }
965
992
  }),
966
- [color, exporting, image.height, image.width, marks, scale, text, tool]
993
+ [
994
+ color,
995
+ exporting,
996
+ image.height,
997
+ image.width,
998
+ marks,
999
+ scale,
1000
+ stageSize.height,
1001
+ text,
1002
+ tool
1003
+ ]
967
1004
  );
968
1005
  async function done() {
969
1006
  if (exporting) return;
@@ -1111,95 +1148,109 @@ function AnnotationEditor({
1111
1148
  (current) => current.width === layout.width && current.height === layout.height ? current : { width: layout.width, height: layout.height }
1112
1149
  );
1113
1150
  },
1114
- children: /* @__PURE__ */ jsxs(
1115
- View,
1151
+ children: /* @__PURE__ */ jsx(
1152
+ ScrollView,
1116
1153
  {
1117
- ref: canvas,
1118
- collapsable: false,
1119
- style: {
1120
- width: (shownCrop?.width ?? image.width) * scale,
1121
- height: (shownCrop?.height ?? image.height) * scale,
1122
- overflow: "hidden",
1123
- backgroundColor: "#fff"
1154
+ ref: viewport,
1155
+ style: s.viewport,
1156
+ contentContainerStyle: s.canvasContent,
1157
+ scrollEnabled: false,
1158
+ bounces: false,
1159
+ onScroll: (event) => {
1160
+ scrollOffset.current = event.nativeEvent.contentOffset.y;
1124
1161
  },
1125
- children: [
1126
- /* @__PURE__ */ jsxs(
1127
- View,
1128
- {
1129
- style: {
1130
- position: "absolute",
1131
- left: -(shownCrop?.x ?? 0) * scale,
1132
- top: -(shownCrop?.y ?? 0) * scale,
1133
- width: image.width * scale,
1134
- height: image.height * scale
1135
- },
1136
- children: [
1137
- /* @__PURE__ */ jsx(
1138
- Image,
1139
- {
1140
- source: { uri: image.uri },
1141
- style: {
1142
- width: image.width * scale,
1143
- height: image.height * scale
1144
- },
1145
- resizeMode: "stretch"
1146
- }
1147
- ),
1148
- /* @__PURE__ */ jsxs(
1149
- Svg,
1150
- {
1151
- pointerEvents: "none",
1152
- style: StyleSheet.absoluteFill,
1162
+ scrollEventThrottle: 16,
1163
+ children: /* @__PURE__ */ jsxs(
1164
+ View,
1165
+ {
1166
+ ref: canvas,
1167
+ collapsable: false,
1168
+ style: {
1169
+ width: (shownCrop?.width ?? image.width) * scale,
1170
+ height: (shownCrop?.height ?? image.height) * scale,
1171
+ overflow: "hidden",
1172
+ backgroundColor: "#fff"
1173
+ },
1174
+ children: [
1175
+ /* @__PURE__ */ jsxs(
1176
+ View,
1177
+ {
1178
+ style: {
1179
+ position: "absolute",
1180
+ left: -(shownCrop?.x ?? 0) * scale,
1181
+ top: -(shownCrop?.y ?? 0) * scale,
1153
1182
  width: image.width * scale,
1154
- height: image.height * scale,
1155
- viewBox: `0 0 ${image.width} ${image.height}`,
1156
- children: [
1157
- /* @__PURE__ */ jsx(
1158
- AnnotationShapes,
1159
- {
1160
- annotations: [...marks, ...draft ? [draft] : []]
1161
- }
1162
- ),
1163
- !exporting && crop && /* @__PURE__ */ jsx(
1164
- Rect,
1165
- {
1166
- ...crop,
1167
- fill: "none",
1168
- stroke: "#3b82f6",
1169
- strokeWidth: 2,
1170
- strokeDasharray: "6 4"
1171
- }
1172
- ),
1173
- target?.boundingRect && /* @__PURE__ */ jsx(
1174
- Rect,
1175
- {
1176
- ...target.boundingRect,
1177
- fill: "none",
1178
- stroke: "#22c55e",
1179
- strokeWidth: 2,
1180
- strokeDasharray: "4 4"
1181
- }
1182
- )
1183
- ]
1184
- }
1185
- )
1186
- ]
1187
- }
1188
- ),
1189
- !exporting && /* @__PURE__ */ jsx(
1190
- View,
1191
- {
1192
- style: StyleSheet.absoluteFill,
1193
- ...responder.panHandlers,
1194
- accessibilityLabel: "Screenshot annotation canvas"
1195
- }
1196
- )
1197
- ]
1183
+ height: image.height * scale
1184
+ },
1185
+ children: [
1186
+ /* @__PURE__ */ jsx(
1187
+ Image,
1188
+ {
1189
+ source: { uri: image.uri },
1190
+ style: {
1191
+ width: image.width * scale,
1192
+ height: image.height * scale
1193
+ },
1194
+ resizeMode: "stretch"
1195
+ }
1196
+ ),
1197
+ /* @__PURE__ */ jsxs(
1198
+ Svg,
1199
+ {
1200
+ pointerEvents: "none",
1201
+ style: StyleSheet.absoluteFill,
1202
+ width: image.width * scale,
1203
+ height: image.height * scale,
1204
+ viewBox: `0 0 ${image.width} ${image.height}`,
1205
+ children: [
1206
+ /* @__PURE__ */ jsx(
1207
+ AnnotationShapes,
1208
+ {
1209
+ annotations: [...marks, ...draft ? [draft] : []]
1210
+ }
1211
+ ),
1212
+ !exporting && crop && /* @__PURE__ */ jsx(
1213
+ Rect,
1214
+ {
1215
+ ...crop,
1216
+ fill: "none",
1217
+ stroke: "#3b82f6",
1218
+ strokeWidth: 2,
1219
+ strokeDasharray: "6 4"
1220
+ }
1221
+ ),
1222
+ target?.boundingRect && /* @__PURE__ */ jsx(
1223
+ Rect,
1224
+ {
1225
+ ...target.boundingRect,
1226
+ fill: "none",
1227
+ stroke: "#22c55e",
1228
+ strokeWidth: 2,
1229
+ strokeDasharray: "4 4"
1230
+ }
1231
+ )
1232
+ ]
1233
+ }
1234
+ )
1235
+ ]
1236
+ }
1237
+ ),
1238
+ !exporting && /* @__PURE__ */ jsx(
1239
+ View,
1240
+ {
1241
+ style: StyleSheet.absoluteFill,
1242
+ ...responder.panHandlers,
1243
+ accessibilityLabel: "Screenshot annotation canvas"
1244
+ }
1245
+ )
1246
+ ]
1247
+ }
1248
+ )
1198
1249
  }
1199
1250
  )
1200
1251
  }
1201
1252
  ),
1202
- /* @__PURE__ */ jsx(Text, { style: s.hint, children: error || (tool === "target" ? "Mark the native screen region related to the issue." : tool === "blur" ? "Redaction permanently covers screenshot pixels and removes earlier recording frames." : "Draw on the screenshot. Changes are attached when you submit.") })
1253
+ /* @__PURE__ */ jsx(Text, { style: s.hint, children: error || (tool === "pan" ? "Scroll to another part of the screenshot, then select a drawing tool." : tool === "target" ? "Mark the native screen region related to the issue." : tool === "blur" ? "Redaction permanently covers screenshot pixels and removes earlier recording frames." : "Draw on the screenshot. Use Move to scroll. Changes are attached when you submit.") })
1203
1254
  ] });
1204
1255
  }
1205
1256
  var s = StyleSheet.create({
@@ -1244,11 +1295,11 @@ var s = StyleSheet.create({
1244
1295
  swatch: { width: 24, height: 24, borderRadius: 12, borderColor: "#a1a1aa" },
1245
1296
  stage: {
1246
1297
  flex: 1,
1247
- alignItems: "flex-start",
1248
- justifyContent: "flex-start",
1249
1298
  paddingHorizontal: 16,
1250
1299
  paddingVertical: 8
1251
1300
  },
1301
+ viewport: { flex: 1 },
1302
+ canvasContent: { alignItems: "center" },
1252
1303
  hint: {
1253
1304
  paddingHorizontal: 16,
1254
1305
  fontSize: 12,