@build-qube/takeoff-calculator 2.1.0 → 3.1.0

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 (5) hide show
  1. package/README.md +4 -0
  2. package/browser.js +1 -1
  3. package/index.d.ts +640 -271
  4. package/index.js +766 -750
  5. package/package.json +15 -13
package/index.d.ts CHANGED
@@ -1,348 +1,717 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+ export declare class GeometryClient {
4
+ constructor(
5
+ svg: string,
6
+ pageBackgroundColor?: Array<number> | undefined | null,
7
+ );
8
+ /** Get the geometry stats */
9
+ getGeometryStats(): JsGeometryStats;
10
+ /** Initialize the geometry */
11
+ initializeGeometry(): Promise<JsGeometryStats>;
12
+ /** Query the snap points near a point */
13
+ querySnapPointsNear(x: number, y: number, radius: number): Array<JsSnapPoint>;
14
+ /** Query the nearest snap point */
15
+ queryNearestSnapPoint(x: number, y: number): JsSnapPoint | null;
16
+ queryNearestNSnapPoints(x: number, y: number, n: number): Array<JsSnapPoint>;
17
+ queryElementsNear(
18
+ x: number,
19
+ y: number,
20
+ radius: number,
21
+ ): Array<JsGeometryElement>;
22
+ detectClosedRegionsAsync(
23
+ config?: JsMergeConfig | undefined | null,
24
+ ): Promise<Array<JsDetectedPolygon>>;
25
+ detectClosedRegions(
26
+ config?: JsMergeConfig | undefined | null,
27
+ ): Array<JsDetectedPolygon>;
28
+ identifyContourLine(
29
+ tracePoints: Array<JsTracePoint>,
30
+ config?: JsContourDetectConfig | undefined | null,
31
+ ): JsContourDetectionResult;
32
+ detectContourAtPoint(
33
+ x: number,
34
+ y: number,
35
+ radius?: number | undefined | null,
36
+ config?: JsContourDetectConfig | undefined | null,
37
+ ): JsDetectedContourLine | null;
38
+ clearContourSignature(): void;
39
+ /**
40
+ * Build the topology graph off the main thread. Requires geometry to be
41
+ * initialized first. Idempotent: returns cached stats on later calls.
42
+ */
43
+ initializeTopology(
44
+ config?: JsTopologyConfig | undefined | null,
45
+ ): Promise<JsTopologyStats>;
46
+ /** Stats of the built topology graph, or None if not initialized yet. */
47
+ getTopologyStats(): JsTopologyStats | null;
48
+ /**
49
+ * Rank likely next drawing points from the node nearest (lastX, lastY),
50
+ * scored by cursor heading, style continuity with the arrival direction
51
+ * (prevX/prevY), and edge trust. Returns [] until topology is initialized.
52
+ */
53
+ suggestNextPoints(
54
+ lastX: number,
55
+ lastY: number,
56
+ cursorX: number,
57
+ cursorY: number,
58
+ prevX?: number | undefined | null,
59
+ prevY?: number | undefined | null,
60
+ radius?: number | undefined | null,
61
+ maxResults?: number | undefined | null,
62
+ ): Array<JsSuggestedPoint>;
63
+ /**
64
+ * Trace the closed region containing (x, y) by walking the topology
65
+ * graph's faces. Returns None until topology is initialized, if no edge
66
+ * lies within `radius`, or if the point is not inside a bounded region.
67
+ * The boundary is Douglas-Peucker simplified with `simplify_tolerance`
68
+ * (PDF units, 0 disables); area and perimeter reflect the full walk.
69
+ */
70
+ detectFaceAtPoint(
71
+ x: number,
72
+ y: number,
73
+ radius?: number | undefined | null,
74
+ minArea?: number | undefined | null,
75
+ simplifyTolerance?: number | undefined | null,
76
+ ): JsDetectedFace | null;
77
+ /**
78
+ * Detect door symbols (swing arc + leaf + jambs) across the page.
79
+ * Detection runs once and is cached; `min_confidence` (default 0.7)
80
+ * filters the cached results. Rotation-invariant; thresholds give the
81
+ * jamb-to-jamb opening segment in PDF units.
82
+ */
83
+ detectDoors(minConfidence?: number | undefined | null): Array<JsDetectedDoor>;
84
+ }
85
+
86
+ export interface ElementStyle {
87
+ stroke?: StrokeStyle;
88
+ fill?: FillStyle;
89
+ visible: boolean;
90
+ opacity: number;
91
+ strokeMatchesBackground: boolean;
92
+ fillMatchesBackground: boolean;
93
+ matchesBackground: boolean;
94
+ }
95
+
96
+ export type FillRule = 'NonZero' | 'EvenOdd';
97
+
98
+ export interface FillStyle {
99
+ color: Array<number>;
100
+ opacity: number;
101
+ rule: FillRule;
102
+ }
103
+
104
+ export interface JsContourDetectConfig {
105
+ corridorWidth?: number;
106
+ colorTolerance?: number;
107
+ widthTolerance?: number;
108
+ dashRatioTolerance?: number;
109
+ directionThreshold?: number;
110
+ maxGapMultiplier?: number;
111
+ loopClosureTolerance?: number;
112
+ }
113
+
114
+ export interface JsContourDetectionResult {
115
+ detected: boolean;
116
+ contour?: JsDetectedContourLine;
117
+ mode: string;
118
+ }
119
+
120
+ export interface JsDetectedContourLine {
121
+ points: Array<Array<number>>;
122
+ elementIndices: Array<number>;
123
+ }
124
+
125
+ export interface JsDetectedDoor {
126
+ /** "single" or "double". */
127
+ kind: string;
128
+ confidence: number;
129
+ /** Opening width (threshold length, PDF units). */
130
+ width: number;
131
+ /** Hinge-side jamb as [x, y]. */
132
+ hinge: Array<number>;
133
+ /**
134
+ * Jamb-to-jamb opening segment as [x1, y1, x2, y2] — the room boundary
135
+ * at this door.
136
+ */
137
+ threshold: Array<number>;
138
+ /**
139
+ * Oriented box covering threshold plus swing: [cx, cy, ax, ay, hw, hh]
140
+ * where (ax, ay) is the unit threshold axis and hw/hh the half-extents
141
+ * along axis/normal (normal points toward the swing side).
142
+ */
143
+ obb: Array<number>;
144
+ /** Indices of the elements whose swing arcs produced this door. */
145
+ arcElements: Array<number>;
146
+ }
147
+
148
+ export interface JsDetectedFace {
149
+ /** Closed boundary ring as [x, y] pairs (first point repeated at the end). */
150
+ points: Array<Array<number>>;
151
+ sourceElements: Array<number>;
152
+ confidence: number;
153
+ area: number;
154
+ perimeter: number;
155
+ /** Gap spans synthesized to close the region, as [x1, y1, x2, y2]. */
156
+ bridgedSpans: Array<Array<number>>;
157
+ }
158
+
159
+ export interface JsDetectedPolygon {
160
+ points: Array<Array<number>>;
161
+ sourceElements: Array<number>;
162
+ confidence: number;
163
+ area: number;
164
+ perimeter: number;
165
+ }
166
+
167
+ export interface JsGeometryElement {
168
+ id: string;
169
+ geometryType: JsGeometryType;
170
+ bbox: Array<number>;
171
+ style: ElementStyle;
172
+ }
173
+
174
+ export interface JsGeometryStats {
175
+ elementCount: number;
176
+ snapPointCount: number;
177
+ }
178
+
179
+ export type JsGeometryType =
180
+ | { type: 'Point'; points: [Point] }
181
+ | { type: 'LineString'; points: Array<Point> }
182
+ | { type: 'Polygon'; points: Array<Point> }
183
+ | { type: 'MultiLineString'; points: Array<Array<Point>> };
184
+
185
+ export interface JsMergeConfig {
186
+ endpointTolerance?: number;
187
+ minEdges?: number;
188
+ minArea?: number;
189
+ maxEdgeLength?: number;
190
+ minSegmentLength?: number;
191
+ styleMustMatch?: boolean;
192
+ }
193
+
194
+ export interface JsSnapPoint {
195
+ x: number;
196
+ y: number;
197
+ snapType: SnapType;
198
+ elementIndex: number;
199
+ }
200
+
201
+ export interface JsSuggestedPoint {
202
+ x: number;
203
+ y: number;
204
+ score: number;
205
+ bridged: boolean;
206
+ /** Source element index of the suggested edge; absent for bridged gaps. */
207
+ elementIndex?: number;
208
+ nodeDegree: number;
209
+ }
210
+
211
+ export interface JsTopologyConfig {
212
+ nodeTolerance?: number;
213
+ bridgeTolerance?: number;
214
+ extensionTolerance?: number;
215
+ bridgeStyleMatch?: boolean;
216
+ sealDoorways?: boolean;
217
+ doorwayMinConfidence?: number;
218
+ minElementExtent?: number;
219
+ simplifyTolerance?: number;
220
+ maxSegments?: number;
221
+ }
222
+
223
+ export interface JsTopologyStats {
224
+ nodeCount: number;
225
+ edgeCount: number;
226
+ bridgedEdges: number;
227
+ doorwayEdges: number;
228
+ tJunctions: number;
229
+ elementsUsed: number;
230
+ elementsFiltered: number;
231
+ buildMs: number;
232
+ }
233
+
234
+ export interface JsTracePoint {
235
+ x: number;
236
+ y: number;
237
+ }
238
+
239
+ export type LineCap = 'Butt' | 'Round' | 'Square';
240
+
241
+ export type LineJoin = 'Miter' | 'MiterClip' | 'Round' | 'Bevel';
242
+
243
+ export declare function scaleGeometry(
244
+ geometry: JsGeometryType,
245
+ x: number,
246
+ y: number,
247
+ ): JsGeometryType;
248
+
249
+ export type SnapType = 'Endpoint' | 'Vertex' | 'Midpoint';
250
+
251
+ export interface StrokeStyle {
252
+ color: Array<number>;
253
+ width: number;
254
+ opacity: number;
255
+ linecap: LineCap;
256
+ linejoin: LineJoin;
257
+ dasharray?: Array<number>;
258
+ dashoffset: number;
259
+ }
260
+ export declare class PdfPage {
261
+ pageNumber: number;
262
+ get svg(): string;
263
+ getGeometryClient(
264
+ options?: JsGeometryClientOptions | undefined | null,
265
+ ): GeometryClient;
266
+ renderPage(scale: number): Array<number>;
267
+ renderPageToBase64(scale: number): string;
268
+ getScaledDimensions(scale: number): [number, number];
269
+ renderPageWithOptions(
270
+ scale: number,
271
+ format: ImageOutputFormat,
272
+ quality: number,
273
+ ): Array<number>;
274
+ }
275
+
276
+ export declare class PdfReader {
277
+ constructor(blob: Uint8Array);
278
+ getPage(pageNumber: number): PdfPage;
279
+ get pageCount(): number;
280
+ }
281
+
282
+ export type ImageOutputFormat = 'Jpeg' | 'Png' | 'Webp';
283
+
284
+ export interface JsGeometryClientOptions {
285
+ backgroundColor?: Array<number>;
286
+ }
3
287
  export declare class ContourWrapper {
4
- constructor(contour: ContourInput);
5
- /** Get the surface points for the contour. */
6
- getSurfacePoints(): Array<Point3D> | null;
7
- /**
8
- * Compute cut/fill volume against a reference surface.
9
- * Returns None if the surface mesh is not available (e.g. contour conversion failed).
10
- */
11
- volumeAgainst(
12
- reference: ReferenceSurfaceInput,
13
- cellSize?: number | undefined | null,
14
- ): VolumetricResult | null;
15
- /**
16
- * Get the z value at a given x, y coordinate.
17
- * Returns None if the surface mesh is not available (e.g. contour conversion failed).
18
- */
19
- getZAt(x: number, y: number): number | null;
20
- /**
21
- * Get scatter data for the contour.
22
- * Returns None if the surface mesh is not available (e.g. contour conversion failed).
23
- *
24
- * # Arguments
25
- *
26
- * * `step` - The step size for the scatter data.
27
- *
28
- * # Returns
29
- *
30
- * * `Vec<Point3D>` - The scatter data.
31
- * * `None` - If the surface mesh is not available (e.g. contour conversion failed).
32
- */
33
- getScatterData(step: number): Array<Point3D> | null;
288
+ /** Create a new contour wrapper from a contour input. */
289
+ constructor(contour: ContourInput);
290
+ /**
291
+ * Set the scale of the contour.
292
+ * This will rebuild the surface mesh.
293
+ */
294
+ setScale(scale: Scale): void;
295
+ /** Get the id of the contour. */
296
+ get id(): string;
297
+ /** Get the page id of the contour. */
298
+ get pageId(): string;
299
+ /** Get the scale of the contour. */
300
+ get scale(): Scale | null;
301
+ /** Get the surface points of the contour. */
302
+ getSurfacePoints(): Array<Point3D> | null;
303
+ /** Get the z value at the given x and y coordinates. */
304
+ getZAt(x: number, y: number): number | null;
305
+ /** Get the scatter data of the contour. */
306
+ getScatterData(step: number): Array<Point3D> | null;
307
+ /** Get scaled scatter data of the contour. */
308
+ getRealWorldScatterData(step: number): Array<Point3D> | null;
309
+ /** Compute raw cut/fill volume (pixel-space values) against a reference surface. */
310
+ rawVolumeAgainst(
311
+ reference: ReferenceSurfaceInput,
312
+ cellSize?: number | undefined | null,
313
+ ): VolumetricResult | null;
314
+ /**
315
+ * Compute unit-aware cut/fill volume against a reference surface.
316
+ * Returns None if surface mesh or scale is not available.
317
+ */
318
+ volumeAgainst(
319
+ reference: ReferenceSurfaceInput,
320
+ cellSize?: number | undefined | null,
321
+ ): VolumetricUnitResult | null;
34
322
  }
35
323
 
36
324
  export declare class GroupWrapper {
37
- /** Get the id of the group. */
38
- get id(): string;
39
- get area(): UnitValue | null;
40
- get length(): UnitValue | null;
41
- get points(): number | null;
42
- get count(): number | null;
43
- get group(): Group;
325
+ /** Get the id of the group. */
326
+ get id(): string;
327
+ /**
328
+ * Get the area for this group.
329
+ *
330
+ * Returns `None` if the area has not been computed or if the mutex is poisoned.
331
+ */
332
+ get area(): UnitValue | null;
333
+ /**
334
+ * Get the length for this group.
335
+ *
336
+ * Returns `None` if the length has not been computed or if the mutex is poisoned.
337
+ */
338
+ get length(): UnitValue | null;
339
+ /**
340
+ * Get the points count for this group.
341
+ *
342
+ * Returns `None` if the points count has not been computed or if the mutex is poisoned.
343
+ */
344
+ get points(): number | null;
345
+ /**
346
+ * Get the count for this group.
347
+ *
348
+ * Returns `None` if the count has not been computed or if the mutex is poisoned.
349
+ */
350
+ get count(): number | null;
351
+ get group(): Group;
44
352
  }
45
353
 
46
354
  export declare class MeasurementWrapper {
47
- get points(): number;
48
- get measurement(): Measurement;
49
- get area(): UnitValue | null;
50
- convertArea(unit: Unit): number | null;
51
- convertLength(unit: Unit): number | null;
52
- get length(): UnitValue | null;
53
- get scale(): Scale | null;
54
- get id(): string;
55
- get pageId(): string;
56
- get groupId(): string;
57
- get rawArea(): number;
58
- get rawPerimeter(): number;
355
+ get points(): number;
356
+ get count(): number;
357
+ get measurement(): Measurement;
358
+ get area(): UnitValue | null;
359
+ convertArea(unit: Unit): number | null;
360
+ convertLength(unit: Unit): number | null;
361
+ get length(): UnitValue | null;
362
+ get scale(): Scale | null;
363
+ get id(): string;
364
+ get pageId(): string;
365
+ get groupId(): string;
366
+ get rawArea(): number;
367
+ get rawPerimeter(): number;
59
368
  }
60
369
 
61
370
  export declare class TakeoffStateHandler {
62
- /**
63
- * Creates a new state.
64
- *
65
- * # Arguments
66
- *
67
- * * `options` - The options for the state.
68
- *
69
- * # Returns
70
- *
71
- * * `State` - The new state.
72
- */
73
- constructor(options?: StateOptions | undefined | null);
74
- getMeasurementsByGroupId(groupId: string): Array<MeasurementWrapper>;
75
- /**
76
- * Get the scale for a measurement.
77
- *
78
- * # Arguments
79
- *
80
- * * `measurement_id` - The id of the measurement.
81
- *
82
- * # Returns
83
- *
84
- * * `None` - If the measurement was not found.
85
- * * `Some(scale)` - If the scale was found.
86
- */
87
- getMeasurementScale(measurementId: string): Scale | null;
88
- /**
89
- * Inserts or updates a page in the state.
90
- *
91
- * # Arguments
92
- *
93
- * * `page` - The page to insert or update.
94
- *
95
- * # Returns
96
- *
97
- * * `None` - If the page was not found.
98
- * * `Some(page)` - If the page was found and updated.
99
- */
100
- upsertPage(page: Page): Page | null;
101
- removePage(pageId: string): Page | null;
102
- getGroup(groupId: string): GroupWrapper | null;
103
- /**
104
- * Inserts or updates a group in the state.
105
- *
106
- * # Arguments
107
- *
108
- * * `group` - The group to insert or update.
109
- *
110
- * # Returns
111
- *
112
- * * `None` - If the group was not found.
113
- * * `Some(group)` - If the group was found and updated.
114
- */
115
- upsertGroup(group: Group): Group | null;
116
- /**
117
- * Removes a group from the state.
118
- *
119
- * # Arguments
120
- *
121
- * * `group_id` - The id of the group to remove.
122
- *
123
- * # Returns
124
- * * `None` - If the group was not found.
125
- * * `Some(group)` - If the group was found and removed.
126
- */
127
- removeGroup(groupId: string): Group | null;
128
- /**
129
- * Inserts or updates a measurement in the state.
130
- *
131
- * # Arguments
132
- *
133
- * * `measurement` - The measurement to insert or update.
134
- *
135
- * # Returns
136
- *
137
- * * `None` - If the measurement was not found.
138
- * * `Some(measurement)` - If the measurement was found and updated.
139
- */
140
- upsertMeasurement(measurement: Measurement): Measurement | null;
141
- /**
142
- * Removes a measurement from the state.
143
- *
144
- * # Arguments
145
- *
146
- * * `measurement_id` - The id of the measurement to remove.
147
- *
148
- * # Returns
149
- *
150
- * * `None` - If the measurement was not found.
151
- * * `Some(measurement)` - If the measurement was found and removed.
152
- */
153
- removeMeasurement(measurementId: string): Measurement | null;
154
- getMeasurement(measurementId: string): MeasurementWrapper | null;
155
- /**
156
- * Inserts or updates a scale in the state.
157
- *
158
- * # Arguments
159
- *
160
- * * `scale` - The scale to insert or update.
161
- *
162
- * # Returns
163
- *
164
- * * `None` - If the scale was not found.
165
- * * `Some(scale)` - If the scale was found and updated.
166
- */
167
- upsertScale(scale: Scale): Scale | null;
168
- /**
169
- * Removes a scale from the state.
170
- *
171
- * # Arguments
172
- *
173
- * * `scale_id` - The id of the scale to remove.
174
- *
175
- * # Returns
176
- * * `None` - If the scale was not found.
177
- * * `Some(scale)` - If the scale was found and removed.
178
- */
179
- removeScale(scaleId: string): Scale | null;
180
- /**
181
- * Get the measurements that are missing a scale.
182
- *
183
- * # Returns
184
- *
185
- * * `Vec<MeasurementWrapper>` - The measurements that are missing a scale.
186
- */
187
- getMeasurementsMissingScale(): Array<MeasurementWrapper>;
371
+ /**
372
+ * Creates a new state.
373
+ *
374
+ * # Arguments
375
+ *
376
+ * * `options` - The options for the state.
377
+ *
378
+ * # Returns
379
+ *
380
+ * * `State` - The new state.
381
+ */
382
+ constructor(options?: StateOptions | undefined | null);
383
+ getMeasurementsByGroupId(groupId: string): Array<MeasurementWrapper>;
384
+ /**
385
+ * Get the measurements by page id.
386
+ *
387
+ * # Arguments
388
+ *
389
+ * * `page_id` - The id of the page.
390
+ *
391
+ * # Returns
392
+ *
393
+ * * `Vec<MeasurementWrapper>` - The measurements that are on the page.
394
+ */
395
+ getMeasurementsByPageId(pageId: string): Array<MeasurementWrapper>;
396
+ /**
397
+ * Get the scale for a measurement.
398
+ *
399
+ * # Arguments
400
+ *
401
+ * * `measurement_id` - The id of the measurement.
402
+ *
403
+ * # Returns
404
+ *
405
+ * * `None` - If the measurement was not found.
406
+ * * `Some(scale)` - If the scale was found.
407
+ */
408
+ getMeasurementScale(measurementId: string): Scale | null;
409
+ /**
410
+ * Inserts or updates a page in the state.
411
+ *
412
+ * # Arguments
413
+ *
414
+ * * `page` - The page to insert or update.
415
+ *
416
+ * # Returns
417
+ *
418
+ * * `None` - If the page was not found.
419
+ * * `Some(page)` - If the page was found and updated.
420
+ */
421
+ upsertPage(page: Page): Page | null;
422
+ removePage(pageId: string): Page | null;
423
+ getGroup(groupId: string): GroupWrapper | null;
424
+ /**
425
+ * Inserts or updates a group in the state.
426
+ *
427
+ * # Arguments
428
+ *
429
+ * * `group` - The group to insert or update.
430
+ *
431
+ * # Returns
432
+ *
433
+ * * `None` - If the group was not found.
434
+ * * `Some(group)` - If the group was found and updated.
435
+ */
436
+ upsertGroup(group: Group): Group | null;
437
+ /**
438
+ * Removes a group from the state.
439
+ *
440
+ * # Arguments
441
+ *
442
+ * * `group_id` - The id of the group to remove.
443
+ *
444
+ * # Returns
445
+ * * `None` - If the group was not found.
446
+ * * `Some(group)` - If the group was found and removed.
447
+ */
448
+ removeGroup(groupId: string): Group | null;
449
+ /**
450
+ * Inserts or updates a measurement in the state.
451
+ *
452
+ * # Arguments
453
+ *
454
+ * * `measurement` - The measurement to insert or update.
455
+ *
456
+ * # Returns
457
+ *
458
+ * * `None` - If the measurement was not found.
459
+ * * `Some(measurement)` - If the measurement was found and updated.
460
+ */
461
+ upsertMeasurement(measurement: Measurement): Measurement | null;
462
+ /**
463
+ * Removes a measurement from the state.
464
+ *
465
+ * # Arguments
466
+ *
467
+ * * `measurement_id` - The id of the measurement to remove.
468
+ *
469
+ * # Returns
470
+ *
471
+ * * `None` - If the measurement was not found.
472
+ * * `Some(measurement)` - If the measurement was found and removed.
473
+ */
474
+ removeMeasurement(measurementId: string): Measurement | null;
475
+ getMeasurement(measurementId: string): MeasurementWrapper | null;
476
+ /**
477
+ * Inserts or updates a scale in the state.
478
+ *
479
+ * # Arguments
480
+ *
481
+ * * `scale` - The scale to insert or update.
482
+ *
483
+ * # Returns
484
+ *
485
+ * * `None` - If the scale was not found.
486
+ * * `Some(scale)` - If the scale was found and updated.
487
+ */
488
+ upsertScale(scale: Scale): Scale | null;
489
+ /**
490
+ * Removes a scale from the state.
491
+ *
492
+ * # Arguments
493
+ *
494
+ * * `scale_id` - The id of the scale to remove.
495
+ *
496
+ * # Returns
497
+ * * `None` - If the scale was not found.
498
+ * * `Some(scale)` - If the scale was found and removed.
499
+ */
500
+ removeScale(scaleId: string): Scale | null;
501
+ /**
502
+ * Get the measurements that are missing a scale.
503
+ *
504
+ * # Returns
505
+ *
506
+ * * `Vec<MeasurementWrapper>` - The measurements that are missing a scale.
507
+ */
508
+ getMeasurementsMissingScale(): Array<MeasurementWrapper>;
509
+ upsertContour(input: ContourInput): void;
510
+ removeContour(contourId: string): boolean;
511
+ getContour(contourId: string): ContourWrapper | null;
512
+ getContoursByPageId(pageId: string): Array<ContourWrapper>;
513
+ getContoursMissingScale(): Array<ContourWrapper>;
514
+ }
515
+
516
+ export declare class VolumetricUnitResult {
517
+ get cut(): UnitValue;
518
+ get fill(): UnitValue;
519
+ get uncoveredArea(): UnitValue;
188
520
  }
189
521
 
522
+ export declare function asyncMultiTwo(arg: number): Promise<number>;
523
+
190
524
  /** Add 100 to the input */
191
525
  export declare function plus100(input: number): number;
192
526
 
193
527
  /** Add 200 to the input */
194
528
  export declare function plus200(input: number): number;
529
+
530
+ /** Input for creating a reference surface from JS/TS. */
531
+ export type ReferenceSurfaceInputJs =
532
+ | { type: 'Polygon'; points: Array<Point>; elevation: number; unit: Unit }
533
+ | {
534
+ type: 'Rectangle';
535
+ points: [Point, Point];
536
+ elevation: number;
537
+ unit: Unit;
538
+ };
539
+
540
+ export declare function withinAsyncRuntimeIfAvailable(): void;
195
541
  export declare class UnitValue {
196
- constructor(value: number, unit: Unit, magnitude: UnitValueItemType);
197
- display(unit: Unit): string;
198
- getConvertedValue(to: Unit): number;
542
+ constructor(value: number, unit: Unit, magnitude: UnitValueItemType);
543
+ display(unit: Unit): string;
544
+ getConvertedValue(to: Unit): number;
199
545
  }
200
546
 
201
547
  export interface ContourInput {
202
- id: string;
203
- name?: string;
204
- pageId: string;
205
- /** The lines that make up the contour map */
206
- lines: Array<ContourLineInput>;
207
- /** The points of interest that are used to create the contour map */
208
- pointsOfInterest: Array<ContourPointOfInterestInput>;
548
+ id: string;
549
+ name?: string;
550
+ pageId: string;
551
+ /** The lines that make up the contour map */
552
+ lines: Array<ContourLineInput>;
553
+ /** The points of interest that are used to create the contour map */
554
+ pointsOfInterest: Array<ContourPointOfInterestInput>;
209
555
  }
210
556
 
211
557
  export interface ContourLineInput {
212
- /** The elevation of the contour line (in pixels) */
213
- elevation: number;
214
- points: Array<Point>;
558
+ /** The elevation of the contour line (real-world value) */
559
+ elevation: number;
560
+ points: Array<Point>;
561
+ unit: Unit;
215
562
  }
216
563
 
217
564
  export interface ContourPointOfInterestInput {
218
- /** The elevation of the point of interest (in pixels) */
219
- elevation: number;
220
- point: Point;
565
+ /** The elevation of the point of interest (real-world value) */
566
+ elevation: number;
567
+ point: Point;
568
+ unit: Unit;
221
569
  }
222
570
 
223
571
  /** Calculate distance between two points */
224
572
  export declare function distance(
225
- points: [Point, Point] | [Point3D, Point3D],
573
+ points: [Point, Point] | [Point3D, Point3D],
226
574
  ): number;
227
575
 
228
- /** Get the centroid of a measurement */
576
+ /** Generate a random id */
577
+ export declare function generateRandomId(): string;
578
+
579
+ /**
580
+ * Get the centroid of a measurement
581
+ *
582
+ * Returns `None` if the measurement has invalid geometry.
583
+ * For more detailed error information, use `measurement.get_centroid()` directly.
584
+ */
229
585
  export declare function getCentroid(measurement: Measurement): Point | null;
230
586
 
231
587
  export interface Group {
232
- id: string;
233
- name?: string;
234
- measurementType: MeasurementType;
588
+ id: string;
589
+ name?: string;
590
+ measurementType: MeasurementType;
235
591
  }
236
592
 
237
593
  export type Measurement =
238
- | {
239
- type: "Count";
240
- id: string;
241
- pageId: string;
242
- groupId: string;
243
- points: [Point];
244
- }
245
- | {
246
- type: "Polygon";
247
- id: string;
248
- pageId: string;
249
- groupId: string;
250
- points: Array<Point>;
251
- }
252
- | {
253
- type: "Polyline";
254
- id: string;
255
- pageId: string;
256
- groupId: string;
257
- points: Array<Point>;
258
- }
259
- | {
260
- type: "Rectangle";
261
- id: string;
262
- pageId: string;
263
- groupId: string;
264
- points: [Point, Point];
265
- };
266
-
267
- export type MeasurementType = "Area" | "Linear" | "Count";
594
+ | {
595
+ type: 'Count';
596
+ id: string;
597
+ pageId: string;
598
+ groupId: string;
599
+ points: [Point];
600
+ }
601
+ | {
602
+ type: 'Polygon';
603
+ id: string;
604
+ pageId: string;
605
+ groupId: string;
606
+ points: Array<Point>;
607
+ }
608
+ | {
609
+ type: 'Polyline';
610
+ id: string;
611
+ pageId: string;
612
+ groupId: string;
613
+ points: Array<Point>;
614
+ }
615
+ | {
616
+ type: 'Rectangle';
617
+ id: string;
618
+ pageId: string;
619
+ groupId: string;
620
+ points: [Point, Point];
621
+ };
622
+
623
+ export type MeasurementType = 'Area' | 'Linear' | 'Count';
268
624
 
269
625
  export interface Page {
270
- id: string;
271
- name?: string;
272
- width?: number;
273
- height?: number;
274
- viewport?: PageViewport;
626
+ id: string;
627
+ name?: string;
628
+ width?: number;
629
+ height?: number;
630
+ viewport?: PageViewport;
275
631
  }
276
632
 
277
633
  export interface PageViewport {
278
- width: number;
279
- height: number;
634
+ width: number;
635
+ height: number;
280
636
  }
281
637
 
282
638
  /** Represents a 2D point with floating point coordinates */
283
639
  export interface Point {
284
- x: number;
285
- y: number;
640
+ x: number;
641
+ y: number;
286
642
  }
287
643
 
288
644
  export interface Point3D {
289
- x: number;
290
- y: number;
291
- z: number;
645
+ x: number;
646
+ y: number;
647
+ z: number;
292
648
  }
293
649
 
294
650
  /** Input for creating a reference surface from JS/TS. */
295
651
  export type ReferenceSurfaceInput =
296
- | { type: "Polygon"; points: Array<Point>; elevation: number }
297
- | { type: "Rectangle"; points: [Point, Point]; elevation: number };
652
+ | { type: 'Polygon'; points: Array<Point>; elevation: number }
653
+ | { type: 'Rectangle'; points: [Point, Point]; elevation: number };
654
+
655
+ /**
656
+ * Reposition a measurement so its centroid is at the given point.
657
+ * Returns a new measurement (same kind and metadata); area, length, and count are unchanged.
658
+ *
659
+ * # Errors
660
+ *
661
+ * Returns an error if the measurement has invalid or empty geometry (e.g. `EmptyGeometry`).
662
+ */
663
+ export declare function repositionMeasurementToCentroid(
664
+ measurement: Measurement,
665
+ newCentroid: Point,
666
+ ): Measurement;
298
667
 
299
668
  export type Scale =
300
- | {
301
- type: "Area";
302
- id: string;
303
- pageId: string;
304
- scale: ScaleDefinition;
305
- boundingBox: [Point, Point];
306
- }
307
- | { type: "Default"; id: string; pageId: string; scale: ScaleDefinition };
669
+ | {
670
+ type: 'Area';
671
+ id: string;
672
+ pageId: string;
673
+ scale: ScaleDefinition;
674
+ boundingBox: [Point, Point];
675
+ }
676
+ | { type: 'Default'; id: string; pageId: string; scale: ScaleDefinition };
308
677
 
309
678
  export interface ScaleDefinition {
310
- pixelDistance: number;
311
- realDistance: number;
312
- unit: Unit;
679
+ pixelDistance: number;
680
+ realDistance: number;
681
+ unit: Unit;
313
682
  }
314
683
 
315
684
  /** Simplify a polyline using the Ramer-Douglas-Peucker algorithm */
316
685
  export declare function simplifyPolyline(
317
- points: Array<Point>,
318
- tolerance: number,
686
+ points: Array<Point>,
687
+ tolerance: number,
319
688
  ): Array<Point>;
320
689
 
321
690
  export interface StateOptions {
322
- pages: Array<Page>;
323
- groups: Array<Group>;
324
- measurements: Array<Measurement>;
325
- scales: Array<Scale>;
691
+ pages: Array<Page>;
692
+ groups: Array<Group>;
693
+ measurements: Array<Measurement>;
694
+ scales: Array<Scale>;
326
695
  }
327
696
 
328
697
  /** Measurement units supported by the system */
329
698
  export type Unit =
330
- /** Imperial units */
331
- | "Yards"
332
- | "Feet"
333
- | "Inches"
334
- /** Metric units */
335
- | "Meters"
336
- | "Centimeters";
699
+ /** Imperial units */
700
+ | 'Yards'
701
+ | 'Feet'
702
+ | 'Inches'
703
+ /** Metric units */
704
+ | 'Meters'
705
+ | 'Centimeters';
337
706
 
338
- export type UnitValueItemType = "Area" | "Length";
707
+ export type UnitValueItemType = 'Area' | 'Length' | 'Volume';
339
708
 
340
709
  /** Result of a volumetric cut/fill calculation. */
341
710
  export interface VolumetricResult {
342
- /** Volume to remove (terrain above reference). */
343
- cut: number;
344
- /** Volume to add (terrain below reference). */
345
- fill: number;
346
- /** Area where terrain data was unavailable (z_at returned None). */
347
- uncoveredArea: number;
711
+ /** Volume to remove (terrain above reference). */
712
+ cut: number;
713
+ /** Volume to add (terrain below reference). */
714
+ fill: number;
715
+ /** Area where terrain data was unavailable (z_at returned None). */
716
+ uncoveredArea: number;
348
717
  }