@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.
- package/dist/{canvas → annotation/canvas}/AnnotationCanvasInner.d.ts +2 -2
- package/dist/{canvas → annotation/canvas}/AnnotationCanvasInner.js +19 -14
- package/dist/{canvas → annotation/canvas}/AnnotationCanvasInner.native.d.ts +2 -2
- package/dist/annotation/canvas/AnnotationCanvasInner.native.js +668 -0
- package/dist/annotation/canvas/AnnotationCanvasSkia.d.ts +46 -0
- package/dist/annotation/canvas/AnnotationCanvasSkia.js +129 -0
- package/dist/{canvas → annotation/canvas}/Tool.d.ts +23 -1
- package/dist/{canvas → annotation/canvas}/elements/BackgroundImageElement.d.ts +2 -2
- package/dist/{canvas → annotation/canvas}/elements/BackgroundImageElement.js +13 -6
- package/dist/annotation/canvas/elements/ShapeElement.d.ts +7 -0
- package/dist/{canvas → annotation/canvas}/elements/ShapeElement.js +5 -3
- package/dist/annotation/canvas/elements/StrokeElement.d.ts +7 -0
- package/dist/annotation/canvas/elements/StrokeElement.js +40 -0
- package/dist/annotation/canvas/measurementGeometry.d.ts +23 -0
- package/dist/annotation/canvas/measurementGeometry.js +74 -0
- package/dist/{canvas → annotation/canvas}/measurementPicker.d.ts +1 -1
- package/dist/{canvas → annotation/canvas}/measurementStampOverlay.d.ts +2 -2
- package/dist/annotation/canvas/stampLayout.d.ts +1 -0
- package/dist/annotation/canvas/stampLayout.js +11 -0
- package/dist/annotation/canvas/strokeGeometry.d.ts +4 -0
- package/dist/annotation/canvas/strokeGeometry.js +33 -0
- package/dist/{canvas → annotation/canvas}/tools/measurementStampTool.d.ts +1 -1
- package/dist/{canvas → annotation/canvas}/tools/measurementStampTool.js +1 -1
- package/dist/{canvas → annotation/canvas}/tools/panTool.js +3 -0
- package/dist/{canvas → annotation/canvas}/tools/penTool.d.ts +2 -1
- package/dist/{canvas → annotation/canvas}/tools/penTool.js +32 -5
- package/dist/annotation/canvas/tools/selectTool.js +310 -0
- package/dist/{canvas → annotation/canvas}/useAnnotationCanvasState.d.ts +9 -2
- package/dist/{canvas → annotation/canvas}/useAnnotationCanvasState.js +115 -1
- package/dist/{canvas → annotation/canvas}/viewport.d.ts +1 -1
- package/dist/{data → annotation/data}/AnnotationDataProvider.d.ts +1 -1
- package/dist/{data → annotation/data}/InMemoryAnnotationProvider.d.ts +1 -1
- package/dist/{data → annotation/data}/InMemoryAnnotationProvider.js +1 -1
- package/dist/{data → annotation/data}/canvasPersistence.d.ts +1 -1
- package/dist/{data → annotation/data}/canvasPersistence.js +1 -1
- package/dist/{data → annotation/data}/hooks/useAnnotationCanvasDoc.d.ts +1 -1
- package/dist/{data → annotation/data}/hooks/useAnnotationCanvasDoc.js +2 -2
- package/dist/exports.d.ts +21 -19
- package/dist/exports.js +16 -14
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.native.d.ts +1 -1
- package/dist/index.native.js +1 -1
- package/dist/types/annotation.d.ts +15 -3
- package/dist/{hooks → utils}/useParseMeasurement.js +1 -1
- package/package.json +1 -1
- package/dist/canvas/AnnotationCanvasInner.native.js +0 -138
- package/dist/canvas/AnnotationCanvasSkia.d.ts +0 -27
- package/dist/canvas/AnnotationCanvasSkia.js +0 -20
- package/dist/canvas/elements/MeasurementStampElement.d.ts +0 -13
- package/dist/canvas/elements/MeasurementStampElement.js +0 -30
- package/dist/canvas/elements/ShapeElement.d.ts +0 -7
- package/dist/canvas/elements/StrokeElement.d.ts +0 -7
- package/dist/canvas/elements/StrokeElement.js +0 -18
- package/dist/canvas/stampLayout.d.ts +0 -5
- package/dist/canvas/stampLayout.js +0 -14
- package/dist/canvas/tools/selectTool.js +0 -182
- package/dist/utils/evaluateFormula.d.ts +0 -20
- package/dist/utils/evaluateFormula.js +0 -31
- /package/dist/{canvas → annotation/canvas}/AnnotationCanvas.d.ts +0 -0
- /package/dist/{canvas → annotation/canvas}/AnnotationCanvas.js +0 -0
- /package/dist/{canvas → annotation/canvas}/AnnotationCanvas.native.d.ts +0 -0
- /package/dist/{canvas → annotation/canvas}/AnnotationCanvas.native.js +0 -0
- /package/dist/{canvas → annotation/canvas}/Tool.js +0 -0
- /package/dist/{canvas → annotation/canvas}/measurementPicker.js +0 -0
- /package/dist/{canvas → annotation/canvas}/measurementStampOverlay.js +0 -0
- /package/dist/{canvas → annotation/canvas}/pointerAdapter.d.ts +0 -0
- /package/dist/{canvas → annotation/canvas}/pointerAdapter.js +0 -0
- /package/dist/{canvas → annotation/canvas}/tools/panTool.d.ts +0 -0
- /package/dist/{canvas → annotation/canvas}/tools/selectTool.d.ts +0 -0
- /package/dist/{canvas → annotation/canvas}/viewport.js +0 -0
- /package/dist/{data → annotation/data}/AnnotationDataContext.d.ts +0 -0
- /package/dist/{data → annotation/data}/AnnotationDataContext.js +0 -0
- /package/dist/{data → annotation/data}/AnnotationDataProvider.js +0 -0
- /package/dist/{data → annotation/data}/hooks/useAnnotationDoc.d.ts +0 -0
- /package/dist/{data → annotation/data}/hooks/useAnnotationDoc.js +0 -0
- /package/dist/{data → annotation/data}/hooks/useAnnotationList.d.ts +0 -0
- /package/dist/{data → annotation/data}/hooks/useAnnotationList.js +0 -0
- /package/dist/{data → annotation/data}/hooks/useAnnotationMutations.d.ts +0 -0
- /package/dist/{data → annotation/data}/hooks/useAnnotationMutations.js +0 -0
- /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 '
|
|
3
|
-
import type { AnnotationCanvasState, AnnotationDocumentPatch, Selection } from '
|
|
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 {
|
|
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
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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 '
|
|
5
|
-
import type
|
|
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';
|