@reekon-tools/boldr-utils 1.6.10 → 1.6.12

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 (81) hide show
  1. package/dist/{canvas → annotation/canvas}/AnnotationCanvasInner.d.ts +2 -2
  2. package/dist/{canvas → annotation/canvas}/AnnotationCanvasInner.js +19 -14
  3. package/dist/{canvas → annotation/canvas}/AnnotationCanvasInner.native.d.ts +2 -2
  4. package/dist/annotation/canvas/AnnotationCanvasInner.native.js +668 -0
  5. package/dist/annotation/canvas/AnnotationCanvasSkia.d.ts +46 -0
  6. package/dist/annotation/canvas/AnnotationCanvasSkia.js +129 -0
  7. package/dist/{canvas → annotation/canvas}/Tool.d.ts +23 -1
  8. package/dist/{canvas → annotation/canvas}/elements/BackgroundImageElement.d.ts +2 -2
  9. package/dist/{canvas → annotation/canvas}/elements/BackgroundImageElement.js +13 -6
  10. package/dist/annotation/canvas/elements/ShapeElement.d.ts +7 -0
  11. package/dist/{canvas → annotation/canvas}/elements/ShapeElement.js +5 -3
  12. package/dist/annotation/canvas/elements/StrokeElement.d.ts +7 -0
  13. package/dist/annotation/canvas/elements/StrokeElement.js +40 -0
  14. package/dist/annotation/canvas/measurementGeometry.d.ts +23 -0
  15. package/dist/annotation/canvas/measurementGeometry.js +74 -0
  16. package/dist/{canvas → annotation/canvas}/measurementPicker.d.ts +1 -1
  17. package/dist/{canvas → annotation/canvas}/measurementStampOverlay.d.ts +2 -2
  18. package/dist/annotation/canvas/stampLayout.d.ts +1 -0
  19. package/dist/annotation/canvas/stampLayout.js +11 -0
  20. package/dist/annotation/canvas/strokeGeometry.d.ts +4 -0
  21. package/dist/annotation/canvas/strokeGeometry.js +33 -0
  22. package/dist/{canvas → annotation/canvas}/tools/measurementStampTool.d.ts +1 -1
  23. package/dist/{canvas → annotation/canvas}/tools/measurementStampTool.js +1 -1
  24. package/dist/{canvas → annotation/canvas}/tools/panTool.js +3 -0
  25. package/dist/{canvas → annotation/canvas}/tools/penTool.d.ts +2 -1
  26. package/dist/{canvas → annotation/canvas}/tools/penTool.js +32 -5
  27. package/dist/annotation/canvas/tools/selectTool.js +310 -0
  28. package/dist/{canvas → annotation/canvas}/useAnnotationCanvasState.d.ts +9 -2
  29. package/dist/{canvas → annotation/canvas}/useAnnotationCanvasState.js +115 -1
  30. package/dist/{canvas → annotation/canvas}/viewport.d.ts +1 -1
  31. package/dist/{data → annotation/data}/AnnotationDataProvider.d.ts +1 -1
  32. package/dist/{data → annotation/data}/InMemoryAnnotationProvider.d.ts +1 -1
  33. package/dist/{data → annotation/data}/InMemoryAnnotationProvider.js +1 -1
  34. package/dist/{data → annotation/data}/canvasPersistence.d.ts +1 -1
  35. package/dist/{data → annotation/data}/canvasPersistence.js +1 -1
  36. package/dist/{data → annotation/data}/hooks/useAnnotationCanvasDoc.d.ts +1 -1
  37. package/dist/{data → annotation/data}/hooks/useAnnotationCanvasDoc.js +2 -2
  38. package/dist/exports.d.ts +21 -19
  39. package/dist/exports.js +16 -14
  40. package/dist/index.d.ts +2 -2
  41. package/dist/index.js +2 -2
  42. package/dist/index.native.d.ts +1 -1
  43. package/dist/index.native.js +1 -1
  44. package/dist/types/annotation.d.ts +15 -3
  45. package/dist/{hooks → utils}/useParseMeasurement.js +1 -1
  46. package/package.json +1 -1
  47. package/dist/canvas/AnnotationCanvasInner.native.js +0 -138
  48. package/dist/canvas/AnnotationCanvasSkia.d.ts +0 -27
  49. package/dist/canvas/AnnotationCanvasSkia.js +0 -20
  50. package/dist/canvas/elements/MeasurementStampElement.d.ts +0 -13
  51. package/dist/canvas/elements/MeasurementStampElement.js +0 -30
  52. package/dist/canvas/elements/ShapeElement.d.ts +0 -7
  53. package/dist/canvas/elements/StrokeElement.d.ts +0 -7
  54. package/dist/canvas/elements/StrokeElement.js +0 -18
  55. package/dist/canvas/stampLayout.d.ts +0 -5
  56. package/dist/canvas/stampLayout.js +0 -14
  57. package/dist/canvas/tools/selectTool.js +0 -182
  58. package/dist/utils/evaluateFormula.d.ts +0 -20
  59. package/dist/utils/evaluateFormula.js +0 -31
  60. /package/dist/{canvas → annotation/canvas}/AnnotationCanvas.d.ts +0 -0
  61. /package/dist/{canvas → annotation/canvas}/AnnotationCanvas.js +0 -0
  62. /package/dist/{canvas → annotation/canvas}/AnnotationCanvas.native.d.ts +0 -0
  63. /package/dist/{canvas → annotation/canvas}/AnnotationCanvas.native.js +0 -0
  64. /package/dist/{canvas → annotation/canvas}/Tool.js +0 -0
  65. /package/dist/{canvas → annotation/canvas}/measurementPicker.js +0 -0
  66. /package/dist/{canvas → annotation/canvas}/measurementStampOverlay.js +0 -0
  67. /package/dist/{canvas → annotation/canvas}/pointerAdapter.d.ts +0 -0
  68. /package/dist/{canvas → annotation/canvas}/pointerAdapter.js +0 -0
  69. /package/dist/{canvas → annotation/canvas}/tools/panTool.d.ts +0 -0
  70. /package/dist/{canvas → annotation/canvas}/tools/selectTool.d.ts +0 -0
  71. /package/dist/{canvas → annotation/canvas}/viewport.js +0 -0
  72. /package/dist/{data → annotation/data}/AnnotationDataContext.d.ts +0 -0
  73. /package/dist/{data → annotation/data}/AnnotationDataContext.js +0 -0
  74. /package/dist/{data → annotation/data}/AnnotationDataProvider.js +0 -0
  75. /package/dist/{data → annotation/data}/hooks/useAnnotationDoc.d.ts +0 -0
  76. /package/dist/{data → annotation/data}/hooks/useAnnotationDoc.js +0 -0
  77. /package/dist/{data → annotation/data}/hooks/useAnnotationList.d.ts +0 -0
  78. /package/dist/{data → annotation/data}/hooks/useAnnotationList.js +0 -0
  79. /package/dist/{data → annotation/data}/hooks/useAnnotationMutations.d.ts +0 -0
  80. /package/dist/{data → annotation/data}/hooks/useAnnotationMutations.js +0 -0
  81. /package/dist/{hooks → utils}/useParseMeasurement.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  import { type CSSProperties, type MutableRefObject } from 'react';
2
- import type { DecimalTolerance, FractionalTolerance, Measurement, Units } from '../types/firestore.js';
3
- import type { AnnotationCanvasState, AnnotationDocumentPatch, Selection } from '../types/annotation.js';
2
+ import type { DecimalTolerance, FractionalTolerance, Measurement, Units } from '../../types/firestore.js';
3
+ import type { AnnotationCanvasState, AnnotationDocumentPatch, Selection } from '../../types/annotation.js';
4
4
  import type { MeasurementRef } from './measurementPicker.js';
5
5
  import type { Tool } from './Tool.js';
6
6
  import { type AnnotationCanvasHandle } from './useAnnotationCanvasState.js';
@@ -2,18 +2,21 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useFont } from '@shopify/react-native-skia';
3
3
  import { useCallback, useEffect, useRef, } from 'react';
4
4
  import { AnnotationCanvasSkia } from './AnnotationCanvasSkia.js';
5
+ import { buildRemoveMeasurementOps } from './measurementGeometry.js';
5
6
  import { useAnnotationCanvasState, } from './useAnnotationCanvasState.js';
6
7
  import { STAMP_TILE_SIZE } from './stampLayout.js';
8
+ // Screen-px radius of a measurement-annotation endpoint handle (matches the
9
+ // native HANDLE_RADIUS_PX). Divided by zoom for a constant on-screen size.
10
+ const HANDLE_PX = 7;
7
11
  const DEFAULT_PAN_TRIGGERS = ['middleMouse', 'space'];
8
12
  export const AnnotationCanvasInner = (props) => {
9
- const { fallbackUnit, fractionalTolerance, decimalTolerance, resolveImageUrl, stampFontSource, stampValueFontSize = 14, stampLabelFontSize = 11, gestures, width, height, style, activeToolId, tools, } = props;
13
+ const { resolveImageUrl, stampFontSource, stampValueFontSize = 14, gestures, width, height, style, activeToolId, tools, } = props;
10
14
  const wheelMode = gestures?.wheel ?? 'auto';
11
15
  const panTriggers = gestures?.panTriggers ?? DEFAULT_PAN_TRIGGERS;
12
16
  const allowSpacePan = panTriggers.includes('space');
13
17
  const allowMiddlePan = panTriggers.includes('middleMouse');
14
18
  const allowRightPan = panTriggers.includes('rightMouse');
15
19
  const valueFont = useFont(stampFontSource, stampValueFontSize);
16
- const labelFont = useFont(stampFontSource, stampLabelFontSize);
17
20
  const state = useAnnotationCanvasState(props);
18
21
  const containerRef = useRef(null);
19
22
  const panGestureRef = useRef(null);
@@ -168,15 +171,14 @@ export const AnnotationCanvasInner = (props) => {
168
171
  height,
169
172
  effectiveCanvas: state.effectiveCanvas,
170
173
  worldTransform: state.worldTransform,
171
- measurementsById: state.measurementsById,
172
- fallbackUnit,
173
- fractionalTolerance,
174
- decimalTolerance,
175
174
  resolveImageUrl,
176
175
  valueFont,
177
- labelFont,
178
- hideMeasurementStamps: !!renderMeasurementStamp,
179
176
  penDrawingStroke: state.penDrawingStroke,
177
+ // Endpoint handles on the selected line annotation. Web drives endpoint
178
+ // drag through selectTool's pointer handlers (preview patches update the
179
+ // line, so the handles follow via re-render); no live geometry needed.
180
+ selectedId: selection?.ids[0] ?? null,
181
+ handleRadius: HANDLE_PX / state.viewport.zoom,
180
182
  customPreview,
181
183
  }), renderMeasurementStamp && (_jsx("div", { style: {
182
184
  position: 'absolute',
@@ -187,6 +189,9 @@ export const AnnotationCanvasInner = (props) => {
187
189
  const cx = (placed.anchor.x - state.viewport.pan.x) * state.viewport.zoom;
188
190
  const cy = (placed.anchor.y - state.viewport.pan.y) * state.viewport.zoom;
189
191
  const isSelected = selection?.ids.includes(placed.id) ?? false;
192
+ const measurement = placed.measurementId
193
+ ? state.measurementsById.get(placed.measurementId) ?? null
194
+ : null;
190
195
  return (_jsxs("div", { style: {
191
196
  position: 'absolute',
192
197
  left: 0,
@@ -196,16 +201,16 @@ export const AnnotationCanvasInner = (props) => {
196
201
  transform: `translate(${cx - size / 2}px, ${cy - size / 2}px)`,
197
202
  }, children: [renderMeasurementStamp({
198
203
  placed,
199
- measurement: state.measurementsById.get(placed.measurementId) ?? null,
204
+ measurement,
200
205
  selected: isSelected,
201
206
  size,
202
207
  zoom: state.viewport.zoom,
203
- }), isSelected && (_jsx("div", { role: "button", "aria-label": "Remove measurement", onPointerDown: (e) => {
208
+ }), isSelected && measurement && (_jsx("div", { role: "button", "aria-label": "Remove measurement", onPointerDown: (e) => {
204
209
  e.stopPropagation();
205
- state.ctx.commit({
206
- ops: [{ op: 'removeMeasurement', id: placed.id }],
207
- });
208
- state.ctx.setSelection(null);
210
+ const { ops, keepSelection } = buildRemoveMeasurementOps(placed);
211
+ state.ctx.commit({ ops });
212
+ if (!keepSelection)
213
+ state.ctx.setSelection(null);
209
214
  }, style: {
210
215
  position: 'absolute',
211
216
  top: -10,
@@ -1,8 +1,8 @@
1
1
  import { type MutableRefObject } from 'react';
2
2
  import { type ViewStyle } from 'react-native';
3
3
  import type { RenderMeasurementStamp } from './measurementStampOverlay.js';
4
- import type { DecimalTolerance, FractionalTolerance, Measurement, Units } from '../types/firestore.js';
5
- import type { AnnotationCanvasState, AnnotationDocumentPatch, Selection } from '../types/annotation.js';
4
+ import type { DecimalTolerance, FractionalTolerance, Measurement, Units } from '../../types/firestore.js';
5
+ import { type AnnotationCanvasState, type AnnotationDocumentPatch, type Selection } from '../../types/annotation.js';
6
6
  import type { MeasurementRef } from './measurementPicker.js';
7
7
  import type { Tool } from './Tool.js';
8
8
  import { type AnnotationCanvasHandle } from './useAnnotationCanvasState.js';