@reekon-tools/boldr-utils 1.25.0 → 1.26.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.
- package/dist/canvas/AnnotationCanvas.d.ts +11 -0
- package/dist/canvas/AnnotationCanvas.js +10 -0
- package/dist/canvas/AnnotationCanvas.native.d.ts +8 -0
- package/dist/canvas/AnnotationCanvas.native.js +6 -0
- package/dist/canvas/AnnotationCanvasInner.d.ts +39 -0
- package/dist/canvas/AnnotationCanvasInner.js +219 -0
- package/dist/canvas/AnnotationCanvasInner.native.d.ts +35 -0
- package/dist/canvas/AnnotationCanvasInner.native.js +138 -0
- package/dist/canvas/AnnotationCanvasSkia.d.ts +27 -0
- package/dist/canvas/AnnotationCanvasSkia.js +20 -0
- package/dist/canvas/Tool.d.ts +38 -0
- package/dist/canvas/Tool.js +1 -0
- package/dist/canvas/elements/BackgroundImageElement.d.ts +9 -0
- package/dist/canvas/elements/BackgroundImageElement.js +37 -0
- package/dist/canvas/elements/MeasurementStampElement.d.ts +13 -0
- package/dist/canvas/elements/MeasurementStampElement.js +30 -0
- package/dist/canvas/elements/ShapeElement.d.ts +7 -0
- package/dist/canvas/elements/ShapeElement.js +62 -0
- package/dist/canvas/elements/StrokeElement.d.ts +7 -0
- package/dist/canvas/elements/StrokeElement.js +18 -0
- package/dist/canvas/measurementPicker.d.ts +10 -0
- package/dist/canvas/measurementPicker.js +1 -0
- package/dist/canvas/measurementStampOverlay.d.ts +11 -0
- package/dist/canvas/measurementStampOverlay.js +1 -0
- package/dist/canvas/pointerAdapter.d.ts +3 -0
- package/dist/canvas/pointerAdapter.js +19 -0
- package/dist/canvas/stampLayout.d.ts +5 -0
- package/dist/canvas/stampLayout.js +14 -0
- package/dist/canvas/tools/measurementStampTool.d.ts +9 -0
- package/dist/canvas/tools/measurementStampTool.js +37 -0
- package/dist/canvas/tools/panTool.d.ts +5 -0
- package/dist/canvas/tools/panTool.js +25 -0
- package/dist/canvas/tools/penTool.d.ts +13 -0
- package/dist/canvas/tools/penTool.js +68 -0
- package/dist/canvas/tools/selectTool.d.ts +2 -0
- package/dist/canvas/tools/selectTool.js +182 -0
- package/dist/canvas/useAnnotationCanvasState.d.ts +54 -0
- package/dist/canvas/useAnnotationCanvasState.js +210 -0
- package/dist/canvas/viewport.d.ts +16 -0
- package/dist/canvas/viewport.js +54 -0
- package/dist/data/AnnotationDataContext.d.ts +8 -0
- package/dist/data/AnnotationDataContext.js +11 -0
- package/dist/data/AnnotationDataProvider.d.ts +65 -0
- package/dist/data/AnnotationDataProvider.js +4 -0
- package/dist/data/InMemoryAnnotationProvider.d.ts +30 -0
- package/dist/data/InMemoryAnnotationProvider.js +197 -0
- package/dist/data/canvasPersistence.d.ts +3 -0
- package/dist/data/canvasPersistence.js +26 -0
- package/dist/data/hooks/useAnnotationCanvasDoc.d.ts +33 -0
- package/dist/data/hooks/useAnnotationCanvasDoc.js +314 -0
- package/dist/data/hooks/useAnnotationDoc.d.ts +7 -0
- package/dist/data/hooks/useAnnotationDoc.js +33 -0
- package/dist/data/hooks/useAnnotationList.d.ts +7 -0
- package/dist/data/hooks/useAnnotationList.js +26 -0
- package/dist/data/hooks/useAnnotationMutations.d.ts +9 -0
- package/dist/data/hooks/useAnnotationMutations.js +11 -0
- package/dist/export/buildJobCsv.js +2 -3
- package/dist/exports.d.ts +2 -2
- package/dist/exports.js +2 -2
- package/dist/formulas/calculateFormula.d.ts +1 -1
- package/dist/formulas/calculateFormula.js +22 -24
- package/dist/formulas/evaluateFormula.d.ts +10 -0
- package/dist/formulas/evaluateFormula.js +17 -2
- package/dist/hooks/useParseMeasurement.d.ts +4 -0
- package/dist/hooks/useParseMeasurement.js +14 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/server.d.ts +3 -3
- package/dist/server.js +7 -3
- package/dist/types/firestore.d.ts +17 -0
- package/dist/utils/evaluateFormula.d.ts +20 -0
- package/dist/utils/evaluateFormula.js +31 -0
- package/dist/utils/micrometersToUnit.d.ts +11 -0
- package/dist/utils/micrometersToUnit.js +27 -0
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// root barrel, whose module graph statically pulls in `react` and
|
|
4
4
|
// `@shopify/react-native-skia`. Only modules with no React/Skia anywhere
|
|
5
5
|
// in their import graph may be re-exported from this file.
|
|
6
|
-
export { evaluateFormula, createFormulaScope, createEnhancedFormulaScope, clearFormulaCache, } from './formulas/evaluateFormula.js';
|
|
6
|
+
export { evaluateFormula, createFormulaScope, createEnhancedFormulaScope, clearFormulaCache, micrometersToUnitNumber, } from './formulas/evaluateFormula.js';
|
|
7
7
|
export { calculateFormula } from './formulas/calculateFormula.js';
|
|
8
|
-
export { convertMicrometers } from './utils/micrometersToUnit.js';
|
|
8
|
+
export { convertMicrometers, resultDisplayUnit, } from './utils/micrometersToUnit.js';
|
|
9
9
|
export { parseMeasurement } from './utils/parseMeasurement.js';
|
|
10
10
|
export * from './types/firestore.js';
|
|
11
11
|
export * from './types/layout.js';
|
|
@@ -25,5 +25,9 @@ export * from './calculator/index.js';
|
|
|
25
25
|
// Canvas → annotated PDF export (Cloud Function renderer). Pure pdf-lib; no
|
|
26
26
|
// React or Skia anywhere in its import graph.
|
|
27
27
|
export * from './export/pdf/index.js';
|
|
28
|
-
|
|
28
|
+
// groupFormula's own micrometersToUnitNumber (integer constants, NaN on
|
|
29
|
+
// unknown units) stays module-local: the canonical export of that name is the
|
|
30
|
+
// mathjs-exact one from evaluateFormula.js above, and no consumer imported
|
|
31
|
+
// the groupFormula variant.
|
|
32
|
+
export { applyGroupFormulaUm, groupFormulaExpression, unitNumberToMicrometers, } from './formulas/groupFormula.js';
|
|
29
33
|
export { MEASUREMENT_LINE_COLOR, MEASUREMENT_LINE_WIDTH, MEASUREMENT_RECT_WIDTH, } from './annotation/canvas/measurementLineStyle.js';
|
|
@@ -435,6 +435,15 @@ interface ColumnConfigBase {
|
|
|
435
435
|
export type ColumnConfig = ColumnConfigBase & ({
|
|
436
436
|
type: ColumnType.Formula;
|
|
437
437
|
columnData: FormulaColumnData;
|
|
438
|
+
/**
|
|
439
|
+
* Renders the computed result in the decimal/fractional counterpart
|
|
440
|
+
* of each viewer's unit (in_frac ⇄ in, ft_in_frac ⇄ ft_in_decimal;
|
|
441
|
+
* no-op for units with no counterpart). Absent = follow the unit's
|
|
442
|
+
* own format. Lives on the union member — NOT inside columnData,
|
|
443
|
+
* which every formula-editor save rebuilds wholesale. Clearing
|
|
444
|
+
* removes the key.
|
|
445
|
+
*/
|
|
446
|
+
resultDisplay?: 'decimal' | 'fractional';
|
|
438
447
|
} | {
|
|
439
448
|
type: ColumnType.SingleSelect;
|
|
440
449
|
columnData: SelectColumnData;
|
|
@@ -453,6 +462,14 @@ export type ColumnConfig = ColumnConfigBase & ({
|
|
|
453
462
|
} | {
|
|
454
463
|
type: ColumnType.Measurement;
|
|
455
464
|
columnData?: undefined;
|
|
465
|
+
/**
|
|
466
|
+
* Locks the column to a fixed display/input unit for all users;
|
|
467
|
+
* absent = follow each viewer's default unit. Formula operands from
|
|
468
|
+
* this column resolve in this unit (calculateFormula). Clearing the
|
|
469
|
+
* lock removes the key (present-as-undefined is rejected by RN
|
|
470
|
+
* Firebase and stripped by desktop's sanitizer).
|
|
471
|
+
*/
|
|
472
|
+
unitOverride?: Units;
|
|
456
473
|
} | {
|
|
457
474
|
type: ColumnType.Boolean;
|
|
458
475
|
columnData?: undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type MeasurementMap = Map<string, {
|
|
2
|
+
id: string;
|
|
3
|
+
value: number;
|
|
4
|
+
}[]>;
|
|
5
|
+
interface FormulaEvaluationOptions {
|
|
6
|
+
expression: string;
|
|
7
|
+
mappings: Record<string, string>;
|
|
8
|
+
group: {
|
|
9
|
+
id: string;
|
|
10
|
+
columns: Map<string, any>;
|
|
11
|
+
};
|
|
12
|
+
columns: {
|
|
13
|
+
id: string;
|
|
14
|
+
type: string;
|
|
15
|
+
}[];
|
|
16
|
+
measurementMap: MeasurementMap;
|
|
17
|
+
defaultUnit?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function evaluateFormula({ expression, mappings, group, columns, measurementMap, defaultUnit, }: FormulaEvaluationOptions): number | string;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { create, all } from 'mathjs';
|
|
2
|
+
const math = create(all);
|
|
3
|
+
export function evaluateFormula({ expression, mappings, group, columns, measurementMap, defaultUnit = 'um', }) {
|
|
4
|
+
const scope = {};
|
|
5
|
+
for (const [variable, columnId] of Object.entries(mappings)) {
|
|
6
|
+
const rawValue = group.columns.get(columnId);
|
|
7
|
+
const columnDef = columns.find((c) => c.id === columnId);
|
|
8
|
+
if (columnDef?.type === 'Measurement') {
|
|
9
|
+
const groupMeasurements = measurementMap.get(group.id) || [];
|
|
10
|
+
const measurement = groupMeasurements.find((m) => m.id === rawValue);
|
|
11
|
+
if (measurement?.value !== undefined) {
|
|
12
|
+
scope[variable] = math.unit(measurement.value, defaultUnit);
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const parsedValue = typeof rawValue === 'number' ? rawValue : parseFloat(rawValue || '');
|
|
17
|
+
scope[variable] = isNaN(parsedValue) ? 0 : parsedValue;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const compiled = math.compile(expression);
|
|
21
|
+
const result = compiled.evaluate(scope);
|
|
22
|
+
if (math.typeOf(result) === 'Unit') {
|
|
23
|
+
return result.toNumber(defaultUnit);
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
console.error(`Formula evaluation failed:`, err);
|
|
29
|
+
return 'Error';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { DecimalTolerance, FractionalTolerance, Units } from '../types/firestore.js';
|
|
2
|
+
/**
|
|
3
|
+
* The display unit for a formula column's result under its per-column
|
|
4
|
+
* decimal/fractional switch. Fraction-vs-decimal is decided entirely by the
|
|
5
|
+
* Units value (convertMicrometers has no format parameter), so the switch is
|
|
6
|
+
* a substitution between same-scale counterparts: in_frac ⇄ in and
|
|
7
|
+
* ft_in_frac ⇄ ft_in_decimal. Units with no counterpart — metric, and plain
|
|
8
|
+
* ft (the enum has no fractional-feet form) — pass through unchanged, so the
|
|
9
|
+
* setting is a no-op for those viewers. Same physical scale both ways: this
|
|
10
|
+
* can never change a computed number, only its rendering.
|
|
11
|
+
*/
|
|
12
|
+
export declare const resultDisplayUnit: (unit: Units, resultDisplay?: "decimal" | "fractional") => Units;
|
|
2
13
|
export declare const roundToT1Values: (value: number, u: Units) => number;
|
|
3
14
|
export declare const convertMicrometers: (micrometers: number | null | undefined, unit: Units, fractionalTolerance?: FractionalTolerance, decimalTolerance?: DecimalTolerance, device?: string) => {
|
|
4
15
|
value: string;
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { DecimalTolerance, FractionalTolerance, Units, convertUnitsToReadable, } from '../types/firestore.js';
|
|
2
2
|
import { create, all } from 'mathjs';
|
|
3
3
|
const math = create(all);
|
|
4
|
+
/**
|
|
5
|
+
* The display unit for a formula column's result under its per-column
|
|
6
|
+
* decimal/fractional switch. Fraction-vs-decimal is decided entirely by the
|
|
7
|
+
* Units value (convertMicrometers has no format parameter), so the switch is
|
|
8
|
+
* a substitution between same-scale counterparts: in_frac ⇄ in and
|
|
9
|
+
* ft_in_frac ⇄ ft_in_decimal. Units with no counterpart — metric, and plain
|
|
10
|
+
* ft (the enum has no fractional-feet form) — pass through unchanged, so the
|
|
11
|
+
* setting is a no-op for those viewers. Same physical scale both ways: this
|
|
12
|
+
* can never change a computed number, only its rendering.
|
|
13
|
+
*/
|
|
14
|
+
export const resultDisplayUnit = (unit, resultDisplay) => {
|
|
15
|
+
if (resultDisplay === 'decimal') {
|
|
16
|
+
if (unit === Units.FractionalInches)
|
|
17
|
+
return Units.Inches;
|
|
18
|
+
if (unit === Units.FeetInchesFractional)
|
|
19
|
+
return Units.FeetInchesDecimal;
|
|
20
|
+
return unit;
|
|
21
|
+
}
|
|
22
|
+
if (resultDisplay === 'fractional') {
|
|
23
|
+
if (unit === Units.Inches)
|
|
24
|
+
return Units.FractionalInches;
|
|
25
|
+
if (unit === Units.FeetInchesDecimal)
|
|
26
|
+
return Units.FeetInchesFractional;
|
|
27
|
+
return unit;
|
|
28
|
+
}
|
|
29
|
+
return unit;
|
|
30
|
+
};
|
|
4
31
|
// The T1 rounds differently depending on the selected measurement unit.
|
|
5
32
|
// This function mirrors the rounding behavior implemented on the firmware.
|
|
6
33
|
// The value being rounded is in microns.
|