@reekon-tools/boldr-utils 1.6.25 → 1.6.26

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 (67) hide show
  1. package/dist/canvas/AnnotationCanvas.d.ts +11 -0
  2. package/dist/canvas/AnnotationCanvas.js +10 -0
  3. package/dist/canvas/AnnotationCanvas.native.d.ts +8 -0
  4. package/dist/canvas/AnnotationCanvas.native.js +6 -0
  5. package/dist/canvas/AnnotationCanvasInner.d.ts +39 -0
  6. package/dist/canvas/AnnotationCanvasInner.js +219 -0
  7. package/dist/canvas/AnnotationCanvasInner.native.d.ts +35 -0
  8. package/dist/canvas/AnnotationCanvasInner.native.js +138 -0
  9. package/dist/canvas/AnnotationCanvasSkia.d.ts +27 -0
  10. package/dist/canvas/AnnotationCanvasSkia.js +20 -0
  11. package/dist/canvas/Tool.d.ts +38 -0
  12. package/dist/canvas/Tool.js +1 -0
  13. package/dist/canvas/elements/BackgroundImageElement.d.ts +9 -0
  14. package/dist/canvas/elements/BackgroundImageElement.js +37 -0
  15. package/dist/canvas/elements/MeasurementStampElement.d.ts +13 -0
  16. package/dist/canvas/elements/MeasurementStampElement.js +30 -0
  17. package/dist/canvas/elements/ShapeElement.d.ts +7 -0
  18. package/dist/canvas/elements/ShapeElement.js +62 -0
  19. package/dist/canvas/elements/StrokeElement.d.ts +7 -0
  20. package/dist/canvas/elements/StrokeElement.js +18 -0
  21. package/dist/canvas/measurementPicker.d.ts +10 -0
  22. package/dist/canvas/measurementPicker.js +1 -0
  23. package/dist/canvas/measurementStampOverlay.d.ts +11 -0
  24. package/dist/canvas/measurementStampOverlay.js +1 -0
  25. package/dist/canvas/pointerAdapter.d.ts +3 -0
  26. package/dist/canvas/pointerAdapter.js +19 -0
  27. package/dist/canvas/stampLayout.d.ts +5 -0
  28. package/dist/canvas/stampLayout.js +14 -0
  29. package/dist/canvas/tools/measurementStampTool.d.ts +9 -0
  30. package/dist/canvas/tools/measurementStampTool.js +37 -0
  31. package/dist/canvas/tools/panTool.d.ts +5 -0
  32. package/dist/canvas/tools/panTool.js +25 -0
  33. package/dist/canvas/tools/penTool.d.ts +13 -0
  34. package/dist/canvas/tools/penTool.js +68 -0
  35. package/dist/canvas/tools/selectTool.d.ts +2 -0
  36. package/dist/canvas/tools/selectTool.js +182 -0
  37. package/dist/canvas/useAnnotationCanvasState.d.ts +54 -0
  38. package/dist/canvas/useAnnotationCanvasState.js +210 -0
  39. package/dist/canvas/viewport.d.ts +16 -0
  40. package/dist/canvas/viewport.js +54 -0
  41. package/dist/data/AnnotationDataContext.d.ts +8 -0
  42. package/dist/data/AnnotationDataContext.js +11 -0
  43. package/dist/data/AnnotationDataProvider.d.ts +65 -0
  44. package/dist/data/AnnotationDataProvider.js +4 -0
  45. package/dist/data/InMemoryAnnotationProvider.d.ts +30 -0
  46. package/dist/data/InMemoryAnnotationProvider.js +197 -0
  47. package/dist/data/canvasPersistence.d.ts +3 -0
  48. package/dist/data/canvasPersistence.js +26 -0
  49. package/dist/data/hooks/useAnnotationCanvasDoc.d.ts +33 -0
  50. package/dist/data/hooks/useAnnotationCanvasDoc.js +314 -0
  51. package/dist/data/hooks/useAnnotationDoc.d.ts +7 -0
  52. package/dist/data/hooks/useAnnotationDoc.js +33 -0
  53. package/dist/data/hooks/useAnnotationList.d.ts +7 -0
  54. package/dist/data/hooks/useAnnotationList.js +26 -0
  55. package/dist/data/hooks/useAnnotationMutations.d.ts +9 -0
  56. package/dist/data/hooks/useAnnotationMutations.js +11 -0
  57. package/dist/exports.d.ts +1 -0
  58. package/dist/exports.js +1 -0
  59. package/dist/hooks/useParseMeasurement.d.ts +4 -0
  60. package/dist/hooks/useParseMeasurement.js +14 -0
  61. package/dist/utils/evaluateFormula.d.ts +20 -0
  62. package/dist/utils/evaluateFormula.js +31 -0
  63. package/dist/utils/indexLabels.d.ts +3 -0
  64. package/dist/utils/indexLabels.js +40 -0
  65. package/package.json +1 -1
  66. package/dist/annotation/canvas/tools/measurementLineTool.d.ts +0 -12
  67. package/dist/annotation/canvas/tools/measurementLineTool.js +0 -95
@@ -1,95 +0,0 @@
1
- import { DEFAULT_LAYER_ID } from '../../../types/annotation.js';
2
- import { DEFAULT_LINE_POS, recomputeAnchor } from '../measurementGeometry.js';
3
- let counter = 0;
4
- const makeId = () => `annotation-${Date.now().toString(36)}-${(counter++).toString(36)}`;
5
- const firstLayerId = (doc) => doc.layers[0]?.id ?? DEFAULT_LAYER_ID;
6
- // Build the blank line-measurement annotation for a drag from `a` to `b`: a
7
- // 2-point line with a value tile magnetized to its center (linePos 0.5). The
8
- // payload mirrors useAnnotationCanvasState's placeAnnotationAtCenter so a drawn
9
- // line and a (legacy) center-placed one are byte-identical once committed.
10
- const buildLineMeasurement = (opts) => {
11
- const line = { a: opts.a, b: opts.b };
12
- return {
13
- id: opts.id,
14
- layerId: opts.layerId,
15
- placement: 'line',
16
- line,
17
- linePos: DEFAULT_LINE_POS,
18
- // Center of the line; recomputeAnchor keeps this in sync on edits.
19
- anchor: recomputeAnchor(line, 'line', DEFAULT_LINE_POS, {
20
- x: (opts.a.x + opts.b.x) / 2,
21
- y: (opts.a.y + opts.b.y) / 2,
22
- }),
23
- showLabel: true,
24
- showValue: true,
25
- createdAt: Date.now(),
26
- };
27
- };
28
- // Drag-to-draw measurement-line tool. Press-drag rubber-bands a measurement
29
- // annotation (a line with a blank value tile at its center); release commits
30
- // it. Mirrors createShapeTool's interaction so "input lines" are placed the
31
- // same way as shapes — draw to add, not tap-the-icon-to-add — replacing the
32
- // old center-place affordance. The annotation stays blank (no measurement
33
- // associated) until the user fills it via the tile / picker. Skia-free, like
34
- // every tool factory; it renders its live preview through ctx.preview, so it
35
- // works on web and (via the generic tool-pan dispatch) on native.
36
- export const createMeasurementLineTool = (options = {}) => {
37
- const minDragPx = options.minDragPx ?? 4;
38
- const autoSwitchToSelect = options.autoSwitchToSelect ?? true;
39
- const selectToolId = options.selectToolId ?? 'select';
40
- return {
41
- id: options.id ?? 'measure-line',
42
- label: options.label ?? 'Measurement line',
43
- cursor: 'crosshair',
44
- onPointerDown(event) {
45
- return {
46
- kind: 'measurement-line-drawing',
47
- id: makeId(),
48
- startWorld: event.world,
49
- startScreen: event.screen,
50
- moved: false,
51
- };
52
- },
53
- onPointerMove(event, ctx, state) {
54
- const s = state;
55
- if (s?.kind !== 'measurement-line-drawing')
56
- return s;
57
- const measurement = buildLineMeasurement({
58
- id: s.id,
59
- layerId: firstLayerId(ctx.document),
60
- a: s.startWorld,
61
- b: event.world,
62
- });
63
- ctx.preview({ ops: [{ op: 'addMeasurement', measurement }] });
64
- return { ...s, moved: true };
65
- },
66
- onPointerUp(event, ctx, state) {
67
- const s = state;
68
- if (s?.kind !== 'measurement-line-drawing')
69
- return;
70
- const dx = event.screen.x - s.startScreen.x;
71
- const dy = event.screen.y - s.startScreen.y;
72
- if (!s.moved || dx * dx + dy * dy < minDragPx * minDragPx) {
73
- // Accidental tap — discard the rubber-band, commit nothing.
74
- ctx.preview({ ops: [] });
75
- return;
76
- }
77
- const measurement = buildLineMeasurement({
78
- id: s.id,
79
- layerId: firstLayerId(ctx.document),
80
- a: s.startWorld,
81
- b: event.world,
82
- });
83
- ctx.commit({ ops: [{ op: 'addMeasurement', measurement }] });
84
- // Leave it selected (and hand back to select) so the blank line can be
85
- // filled / moved straight away — the same flow as the text tool.
86
- ctx.setSelection({ ids: [measurement.id] });
87
- options.onPlaced?.(measurement);
88
- if (autoSwitchToSelect)
89
- options.onAutoSwitch?.(selectToolId);
90
- },
91
- onCancel(_state, ctx) {
92
- ctx.preview({ ops: [] });
93
- },
94
- };
95
- };