@reekon-tools/boldr-utils 1.8.2 → 1.8.4
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/exports.d.ts +1 -0
- package/dist/exports.js +2 -0
- package/dist/hooks/useParseMeasurement.d.ts +4 -0
- package/dist/hooks/useParseMeasurement.js +14 -0
- package/dist/theme/colors.d.ts +101 -0
- package/dist/theme/colors.js +101 -0
- package/dist/types/firestore.d.ts +18 -0
- package/dist/utils/evaluateFormula.d.ts +20 -0
- package/dist/utils/evaluateFormula.js +31 -0
- package/package.json +7 -2
|
@@ -355,6 +355,10 @@ export interface Measurement extends FirestoreDoc, Timestamps, CreatedBy {
|
|
|
355
355
|
relative?: boolean;
|
|
356
356
|
measureBack?: boolean;
|
|
357
357
|
centerFinding?: boolean;
|
|
358
|
+
markingLaser?: boolean;
|
|
359
|
+
measureSpecial?: boolean;
|
|
360
|
+
offsetActive?: boolean;
|
|
361
|
+
isLdmReading?: boolean;
|
|
358
362
|
isCompleted?: boolean;
|
|
359
363
|
type?: MeasurementType;
|
|
360
364
|
source?: MeasurementSource;
|
|
@@ -379,6 +383,10 @@ export interface Label extends FirestoreDoc, Timestamps {
|
|
|
379
383
|
rows: LabelRow[];
|
|
380
384
|
rowSizes: number[];
|
|
381
385
|
isPublic: boolean;
|
|
386
|
+
/** Print-template category for public labels. A typed label is offered in
|
|
387
|
+
* the matching print-settings selector (measurement/QR/image) instead of
|
|
388
|
+
* the public label library. Absent/null = ordinary library label. */
|
|
389
|
+
templateType?: 'measurement' | 'qr' | 'image' | null;
|
|
382
390
|
}
|
|
383
391
|
export interface LabelRow {
|
|
384
392
|
id: string;
|
|
@@ -510,6 +518,16 @@ export interface UserDocument extends FirestoreDoc, Timestamps {
|
|
|
510
518
|
showWizard: boolean;
|
|
511
519
|
printLabelSize: string;
|
|
512
520
|
printLogoFileId: string;
|
|
521
|
+
/** Public label template id used as the default measurement print format.
|
|
522
|
+
* Absent/null = classic composed label. */
|
|
523
|
+
measurementPrintLabelId?: string | null;
|
|
524
|
+
/** Public label template id used for QR-only prints (file/group/entity QR).
|
|
525
|
+
* Absent/null = classic composed label. */
|
|
526
|
+
qrPrintLabelId?: string | null;
|
|
527
|
+
/** Public label template id used when printing an image or PDF file (the
|
|
528
|
+
* file's snapshot is injected into the template's image cells).
|
|
529
|
+
* Absent/null = fall back to the QR template, then classic. */
|
|
530
|
+
imagePrintLabelId?: string | null;
|
|
513
531
|
devices?: Record<string, string>;
|
|
514
532
|
/** Four-digit birth year. Optional — not required during registration. */
|
|
515
533
|
birthYear?: number;
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reekon-tools/boldr-utils",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.4",
|
|
4
4
|
"description": "Shared utilities for formulas and measurement conversion used in Reekon apps",
|
|
5
5
|
"author": "REEKON Tools",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
"import": "./dist/index.js",
|
|
20
20
|
"default": "./dist/index.js"
|
|
21
21
|
},
|
|
22
|
+
"./theme": {
|
|
23
|
+
"types": "./dist/theme/colors.d.ts",
|
|
24
|
+
"import": "./dist/theme/colors.js",
|
|
25
|
+
"default": "./dist/theme/colors.js"
|
|
26
|
+
},
|
|
22
27
|
"./package.json": "./package.json"
|
|
23
28
|
},
|
|
24
29
|
"scripts": {
|
|
@@ -30,7 +35,7 @@
|
|
|
30
35
|
"coverage": "vitest run --coverage",
|
|
31
36
|
"format": "prettier --write .",
|
|
32
37
|
"check-format": "prettier --check .",
|
|
33
|
-
"check-exports": "attw --pack . --
|
|
38
|
+
"check-exports": "attw --pack . --profile esm-only",
|
|
34
39
|
"ci": "yarn run check-format && vitest run && yarn run build && yarn run check-exports"
|
|
35
40
|
},
|
|
36
41
|
"keywords": [],
|