@welldot/render 0.1.0-next.20260509.039db95 → 0.2.2
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/README.md +82 -33
- package/dist/{fgdcTextures-5IIUV7QV.js → fgdcTextures-P5DTFNPT.js} +1 -1
- package/dist/{fgdcTextures-5IIUV7QV.js.map → fgdcTextures-P5DTFNPT.js.map} +1 -1
- package/dist/index.cjs +461 -146
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +209 -10
- package/dist/index.d.ts +209 -10
- package/dist/index.js +455 -139
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Well, Lithology, Fracture, Cave, BoreHole, WellCase, WellScreen, HoleFill, SurfaceCase, Reduction, Units, DiameterUnits, LengthUnits } from '@welldot/core';
|
|
2
2
|
|
|
3
3
|
type PadTextureConfig = {
|
|
4
4
|
background: string;
|
|
@@ -71,6 +71,7 @@ type Highlights = {
|
|
|
71
71
|
hole_fill?: HighlightItem[];
|
|
72
72
|
well_case?: HighlightItem[];
|
|
73
73
|
well_screen?: HighlightItem[];
|
|
74
|
+
reduction?: HighlightItem[];
|
|
74
75
|
};
|
|
75
76
|
type LithologyTheme = {
|
|
76
77
|
stroke: string;
|
|
@@ -129,6 +130,11 @@ type ConstructionTheme = {
|
|
|
129
130
|
stroke: string;
|
|
130
131
|
strokeWidth: number;
|
|
131
132
|
};
|
|
133
|
+
reduction: {
|
|
134
|
+
fill: string;
|
|
135
|
+
stroke: string;
|
|
136
|
+
strokeWidth: number;
|
|
137
|
+
};
|
|
132
138
|
conflict: {
|
|
133
139
|
stroke: string;
|
|
134
140
|
strokeWidth: number;
|
|
@@ -256,6 +262,10 @@ type ComponentsClassNames = {
|
|
|
256
262
|
group: string;
|
|
257
263
|
rect: string;
|
|
258
264
|
};
|
|
265
|
+
reduction: {
|
|
266
|
+
group: string;
|
|
267
|
+
item: string;
|
|
268
|
+
};
|
|
259
269
|
conflict: {
|
|
260
270
|
group: string;
|
|
261
271
|
rect: string;
|
|
@@ -286,15 +296,113 @@ type ComponentsClassNames = {
|
|
|
286
296
|
};
|
|
287
297
|
};
|
|
288
298
|
/** Keys identifying which tooltip types are active. Pass to `RenderConfig.tooltips` to control visibility. */
|
|
289
|
-
type TooltipKey = 'geology' | 'hole' | 'surfaceCase' | 'holeFill' | 'wellCase' | 'wellScreen' | 'conflict' | 'fracture' | 'cementPad' | 'cave';
|
|
299
|
+
type TooltipKey = 'geology' | 'hole' | 'surfaceCase' | 'holeFill' | 'wellCase' | 'wellScreen' | 'reduction' | 'conflict' | 'fracture' | 'cementPad' | 'cave';
|
|
300
|
+
/**
|
|
301
|
+
* A paired-locale string for renderer-drawn text, or a bare string when the
|
|
302
|
+
* value doesn't vary by locale. `pt` is the required fallback locale in the
|
|
303
|
+
* object form; `en` is optional. Resolve via `resolveRenderLabel()` — never
|
|
304
|
+
* read `.pt`/`.en` directly, since the value may be a plain string.
|
|
305
|
+
*/
|
|
306
|
+
type RenderLocalizedText = {
|
|
307
|
+
pt: string;
|
|
308
|
+
en?: string;
|
|
309
|
+
} | string;
|
|
310
|
+
/**
|
|
311
|
+
* Shape shared by `RenderConfig.tooltipLabels` (resolved, `T = string`) and
|
|
312
|
+
* `RenderLabelPack.tooltipLabels` (authoring, `T = RenderLocalizedText`) —
|
|
313
|
+
* defined once via the generic so the two shapes can't drift apart.
|
|
314
|
+
*/
|
|
315
|
+
type TooltipLabels<T = string> = {
|
|
316
|
+
common: {
|
|
317
|
+
from: T;
|
|
318
|
+
to: T;
|
|
319
|
+
description: T;
|
|
320
|
+
diameter: T;
|
|
321
|
+
type: T;
|
|
322
|
+
};
|
|
323
|
+
geology: {
|
|
324
|
+
title: T;
|
|
325
|
+
geologicUnit: T;
|
|
326
|
+
aquiferUnit: T;
|
|
327
|
+
};
|
|
328
|
+
hole: {
|
|
329
|
+
title: T;
|
|
330
|
+
};
|
|
331
|
+
surfaceCase: {
|
|
332
|
+
title: T;
|
|
333
|
+
};
|
|
334
|
+
holeFill: {
|
|
335
|
+
title: T;
|
|
336
|
+
};
|
|
337
|
+
wellCase: {
|
|
338
|
+
title: T;
|
|
339
|
+
};
|
|
340
|
+
wellScreen: {
|
|
341
|
+
title: T;
|
|
342
|
+
slot: T;
|
|
343
|
+
};
|
|
344
|
+
reduction: {
|
|
345
|
+
title: T;
|
|
346
|
+
};
|
|
347
|
+
conflict: {
|
|
348
|
+
title: T;
|
|
349
|
+
};
|
|
350
|
+
fracture: {
|
|
351
|
+
title: T;
|
|
352
|
+
titleSwarm: T;
|
|
353
|
+
depth: T;
|
|
354
|
+
waterIntake: T;
|
|
355
|
+
dip: T;
|
|
356
|
+
azimuth: T;
|
|
357
|
+
};
|
|
358
|
+
cementPad: {
|
|
359
|
+
title: T;
|
|
360
|
+
thickness: T;
|
|
361
|
+
width: T;
|
|
362
|
+
length: T;
|
|
363
|
+
};
|
|
364
|
+
cave: {
|
|
365
|
+
title: T;
|
|
366
|
+
waterIntake: T;
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* Canonical, paired-locale source for every string `@welldot/render` draws.
|
|
371
|
+
* `RENDER_LABELS` (in `configs/render.configs.ts`) is the sole instance;
|
|
372
|
+
* `applyRenderLocale()` resolves it down to a plain-string `DeepPartial<RenderConfig>`.
|
|
373
|
+
*/
|
|
374
|
+
type RenderLabelPack = {
|
|
375
|
+
constructionLabels: {
|
|
376
|
+
wellCasePrefix: RenderLocalizedText;
|
|
377
|
+
wellScreenPrefix: RenderLocalizedText;
|
|
378
|
+
wellScreenSlotPrefix: RenderLocalizedText;
|
|
379
|
+
};
|
|
380
|
+
legend: {
|
|
381
|
+
title: RenderLocalizedText;
|
|
382
|
+
labels: Record<keyof LegendRenderConfig['labels'], RenderLocalizedText>;
|
|
383
|
+
};
|
|
384
|
+
tooltipLabels: TooltipLabels<RenderLocalizedText>;
|
|
385
|
+
typeLabels: {
|
|
386
|
+
fracture: RenderLocalizedText;
|
|
387
|
+
fractureWater: RenderLocalizedText;
|
|
388
|
+
cave: RenderLocalizedText;
|
|
389
|
+
caveWater: RenderLocalizedText;
|
|
390
|
+
};
|
|
391
|
+
};
|
|
290
392
|
/** Full rendering behaviour configuration. Use `INTERACTIVE_RENDER_CONFIG` or `STATIC_RENDER_CONFIG` as a starting point. */
|
|
291
393
|
type RenderConfig = {
|
|
292
394
|
zoom: boolean;
|
|
293
395
|
pan: boolean;
|
|
294
396
|
/** Initial zoom scale applied on first render (1 = fit all, 2 = start 2× zoomed in). */
|
|
295
397
|
zoomLevel?: number;
|
|
398
|
+
/** Upper bound for zoom scale, enforced for wheel/drag and `zoomBy`/`resetZoom` alike (default 150 = 15000%). */
|
|
399
|
+
maxZoomScale?: number;
|
|
400
|
+
/** Lower bound for zoom scale, enforced for wheel/drag and `zoomBy`/`resetZoom` alike (default 0 = 0%). */
|
|
401
|
+
minZoomScale?: number;
|
|
296
402
|
/** undefined = show all; false or [] = show none; array = show only listed keys */
|
|
297
403
|
tooltips?: TooltipKey[] | false;
|
|
404
|
+
/** Resolved (plain-string) tooltip titles/field labels — see `TooltipLabels`. */
|
|
405
|
+
tooltipLabels: TooltipLabels;
|
|
298
406
|
animation: {
|
|
299
407
|
duration: number;
|
|
300
408
|
ease: (t: number) => number;
|
|
@@ -355,7 +463,9 @@ type RenderConfig = {
|
|
|
355
463
|
lithology?: boolean | ('depth' | 'description' | 'dividers')[];
|
|
356
464
|
typeLabels?: {
|
|
357
465
|
fracture?: string;
|
|
466
|
+
fractureWater?: string;
|
|
358
467
|
cave?: string;
|
|
468
|
+
caveWater?: string;
|
|
359
469
|
};
|
|
360
470
|
depthTipHeight: number;
|
|
361
471
|
depthTipPadX: number;
|
|
@@ -415,6 +525,7 @@ type LegendRenderConfig = {
|
|
|
415
525
|
holeFillSeal: string;
|
|
416
526
|
wellCase: string;
|
|
417
527
|
wellScreen: string;
|
|
528
|
+
reduction: string;
|
|
418
529
|
cementPad: string;
|
|
419
530
|
conflict: string;
|
|
420
531
|
};
|
|
@@ -437,7 +548,54 @@ type SvgInstance = {
|
|
|
437
548
|
bottom: number;
|
|
438
549
|
};
|
|
439
550
|
};
|
|
551
|
+
/**
|
|
552
|
+
* Attaches an optional stable render identity to any feature type.
|
|
553
|
+
*
|
|
554
|
+
* **`key` is runtime-only.** It exists solely in memory while the renderer is
|
|
555
|
+
* running and must never be written to a `.well` file. It is not part of the
|
|
556
|
+
* `.well` v2 spec — persisting it would produce a non-conformant file.
|
|
557
|
+
*/
|
|
558
|
+
type WithKey<T> = T & {
|
|
559
|
+
key?: string | number;
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* A `Well` profile where every feature array element may carry an optional `key`.
|
|
563
|
+
*
|
|
564
|
+
* When `key` is present the renderer uses it as the D3 data-join key,
|
|
565
|
+
* giving fully stable DOM identity regardless of depth edits or array reordering.
|
|
566
|
+
* When absent the renderer falls back to coordinate-based keys (`from:to` or
|
|
567
|
+
* `depth:index`).
|
|
568
|
+
*
|
|
569
|
+
* **`key` is runtime-only** — generate it once per feature (e.g.
|
|
570
|
+
* `crypto.randomUUID()`) and keep it in memory across edits, but always strip
|
|
571
|
+
* it before serializing to a `.well` file.
|
|
572
|
+
*/
|
|
573
|
+
type RenderableWell = Omit<Well, 'lithology' | 'fractures' | 'caves' | 'bore_hole' | 'well_case' | 'well_screen' | 'hole_fill' | 'surface_case' | 'reduction'> & {
|
|
574
|
+
lithology: WithKey<Lithology>[];
|
|
575
|
+
fractures: WithKey<Fracture>[];
|
|
576
|
+
caves: WithKey<Cave>[];
|
|
577
|
+
bore_hole: WithKey<BoreHole>[];
|
|
578
|
+
well_case: WithKey<WellCase>[];
|
|
579
|
+
well_screen: WithKey<WellScreen>[];
|
|
580
|
+
hole_fill: WithKey<HoleFill>[];
|
|
581
|
+
surface_case: WithKey<SurfaceCase>[];
|
|
582
|
+
reduction: WithKey<Reduction>[];
|
|
583
|
+
};
|
|
440
584
|
|
|
585
|
+
/**
|
|
586
|
+
* Canonical, paired-locale source for every string `@welldot/render` draws
|
|
587
|
+
* (construction-label prefixes, legend entries, tooltip titles/fields,
|
|
588
|
+
* fracture/cave type words). `pt` values must match the literals historically
|
|
589
|
+
* hardcoded in `tooltips.utils.ts`/`annotation-labels.renderer.ts` exactly —
|
|
590
|
+
* this is the single source of truth `applyRenderLocale()` resolves from.
|
|
591
|
+
*/
|
|
592
|
+
declare const RENDER_LABELS: RenderLabelPack;
|
|
593
|
+
/**
|
|
594
|
+
* Returns a copy of `config` with `constructionLabels.labels`, `legend.labels`,
|
|
595
|
+
* `tooltipLabels`, and `labels.typeLabels` resolved from `RENDER_LABELS` for
|
|
596
|
+
* `locale`. Every other field of `config` is preserved unchanged.
|
|
597
|
+
*/
|
|
598
|
+
declare function applyRenderLocale(config: RenderConfig, locale: 'en' | 'pt'): RenderConfig;
|
|
441
599
|
declare const DEFAULT_WELL_THEME: WellTheme;
|
|
442
600
|
declare const STATIC_RENDER_CONFIG: RenderConfig;
|
|
443
601
|
declare const INTERACTIVE_RENDER_CONFIG: RenderConfig;
|
|
@@ -472,28 +630,50 @@ declare class WellRenderer {
|
|
|
472
630
|
private instanceStates;
|
|
473
631
|
private textures;
|
|
474
632
|
private onError?;
|
|
633
|
+
private onZoom?;
|
|
475
634
|
classes: ComponentsClassNames;
|
|
476
635
|
private renderConfig;
|
|
477
636
|
private theme;
|
|
478
637
|
private units;
|
|
638
|
+
private locale;
|
|
479
639
|
/**
|
|
480
640
|
* @param svgs - One entry per SVG panel; multi-entry for split-panel layouts.
|
|
481
641
|
* @param options.classNames - Override default BEM CSS class names.
|
|
482
642
|
* @param options.units - Active measurement units (`length` and `diameter`).
|
|
643
|
+
* @param options.locale - Locale for renderer-drawn text (diameter symbol, and any `RenderConfig` fields resolved via `applyRenderLocale`). Defaults to `'pt'`, matching the package's historical output.
|
|
483
644
|
* @param options.renderConfig - Rendering behaviour (zoom, pan, animation, layout). Defaults to `INTERACTIVE_RENDER_CONFIG`.
|
|
484
645
|
* @param options.theme - Visual theme overrides. Merged on top of `DEFAULT_WELL_THEME`.
|
|
485
646
|
* @param options.onError - Called when a draw error occurs (e.g., a renderer throws). Falls back to `console.error` if omitted.
|
|
647
|
+
* @param options.onZoom - Called with the current zoom scale (`1` = initial/fit) whenever the user zooms or pans, and whenever `zoomBy`/`resetZoom` are called. No-op if `renderConfig.zoom`/`pan` are both disabled.
|
|
486
648
|
*/
|
|
487
649
|
constructor(svgs: SvgInstance[], options?: {
|
|
488
650
|
classNames?: DeepPartial<ComponentsClassNames>;
|
|
489
651
|
units?: Units;
|
|
652
|
+
locale?: 'en' | 'pt';
|
|
490
653
|
renderConfig?: DeepPartial<RenderConfig>;
|
|
491
654
|
theme?: DeepPartial<WellTheme>;
|
|
492
655
|
onError?: (err: Error) => void;
|
|
656
|
+
onZoom?: (scale: number) => void;
|
|
493
657
|
});
|
|
494
658
|
private initInstanceSvg;
|
|
495
659
|
/** Renders a standalone legend into the element matched by `selector`. */
|
|
496
660
|
renderLegend(selector: string, profile: Well): void;
|
|
661
|
+
/**
|
|
662
|
+
* Multiplies the current zoom scale by `factor` (e.g. `1.25` to zoom in,
|
|
663
|
+
* `1 / 1.25` to zoom out) on every panel. No-op if both `renderConfig.zoom`
|
|
664
|
+
* and `renderConfig.pan` are disabled (no zoom behavior was attached).
|
|
665
|
+
*/
|
|
666
|
+
zoomBy(factor: number): void;
|
|
667
|
+
/**
|
|
668
|
+
* Resets zoom/pan on every panel back to `renderConfig.zoomLevel`
|
|
669
|
+
* (defaults to `1`, i.e. the initial fit-to-container view).
|
|
670
|
+
*/
|
|
671
|
+
resetZoom(): void;
|
|
672
|
+
/**
|
|
673
|
+
* Current zoom scale factor of the first panel (`1` = initial/fit).
|
|
674
|
+
* Returns `1` if zoom/pan is disabled or `prepareSvg()` hasn't run yet.
|
|
675
|
+
*/
|
|
676
|
+
getZoomScale(): number;
|
|
497
677
|
/**
|
|
498
678
|
* Initialises the SVG DOM structure and preloads FGDC textures.
|
|
499
679
|
* Must be called once before the first `draw()`.
|
|
@@ -503,10 +683,12 @@ declare class WellRenderer {
|
|
|
503
683
|
* Renders the well profile into all configured SVG panels.
|
|
504
684
|
* @param profile - The well data to render.
|
|
505
685
|
* @param options.units - Override the instance-level measurement units for this render.
|
|
686
|
+
* @param options.locale - Override the instance-level locale for this render.
|
|
506
687
|
* @param options.highlights - Highlight overlays to display on top of the profile.
|
|
507
688
|
*/
|
|
508
|
-
draw(profile:
|
|
689
|
+
draw(profile: RenderableWell, options?: {
|
|
509
690
|
units?: Units;
|
|
691
|
+
locale?: 'en' | 'pt';
|
|
510
692
|
highlights?: Highlights;
|
|
511
693
|
}): void;
|
|
512
694
|
private drawLogToInstance;
|
|
@@ -519,13 +701,30 @@ declare function drawWellLegend(selector: string, profile: Well, options?: {
|
|
|
519
701
|
textures?: TexturesConfig;
|
|
520
702
|
}): void;
|
|
521
703
|
|
|
522
|
-
/**
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
704
|
+
/**
|
|
705
|
+
* Formats a depth value in metres to the active length unit string, rounded
|
|
706
|
+
* (never raw floating-point) and using the target locale's decimal separator.
|
|
707
|
+
*/
|
|
708
|
+
declare function formatLength(m: number, units: LengthUnits, locale: 'en' | 'pt'): string;
|
|
709
|
+
/**
|
|
710
|
+
* Formats a diameter value in millimetres to the active diameter unit
|
|
711
|
+
* string, rounded (never raw floating-point) and using the target locale's
|
|
712
|
+
* decimal separator.
|
|
713
|
+
*/
|
|
714
|
+
declare function formatDiameter(mm: number, units: DiameterUnits, locale: 'en' | 'pt'): string;
|
|
526
715
|
/** Returns the display label for the active length unit (e.g. `"m"` or `"ft"`). */
|
|
527
716
|
declare function getLengthUnit(units: LengthUnits): string;
|
|
528
|
-
/**
|
|
529
|
-
|
|
717
|
+
/**
|
|
718
|
+
* Returns the display symbol for the active diameter unit. `mm` is
|
|
719
|
+
* locale-invariant; `inches` is `'"'` unless `locale` is `'en'`, in which
|
|
720
|
+
* case it's `'in.'`. Omitting `locale` preserves the historical `'"'` default.
|
|
721
|
+
*/
|
|
722
|
+
declare function getDiameterUnit(units: DiameterUnits, locale?: 'en' | 'pt'): string;
|
|
723
|
+
/**
|
|
724
|
+
* Resolves a paired-locale render label to a plain string. A bare string is
|
|
725
|
+
* returned as-is (locale-invariant); for the `{ pt, en }` object form, `pt`
|
|
726
|
+
* is always the fallback — mirrors the org-wide `resolveLanguageText()` contract.
|
|
727
|
+
*/
|
|
728
|
+
declare function resolveRenderLabel(value: RenderLocalizedText, locale: 'en' | 'pt'): string;
|
|
530
729
|
|
|
531
|
-
export { type CaveTheme, type ComponentsClassNames, type ConstructionTheme, DEFAULT_WELL_THEME, type DeepPartial, type FractureTheme, type HighlightItem, type Highlights, INTERACTIVE_RENDER_CONFIG, type LabelsTheme, type LegendRenderConfig, type LegendTheme, type LithologyTextureTheme, type LithologyTheme, type RenderConfig, STATIC_RENDER_CONFIG, type SvgInstance, type TooltipKey, WellRenderer, type WellTheme, drawWellLegend, formatDiameter, formatLength, getDiameterUnit, getLengthUnit, importFgdcTextures };
|
|
730
|
+
export { type CaveTheme, type ComponentsClassNames, type ConstructionTheme, DEFAULT_WELL_THEME, type DeepPartial, type FractureTheme, type HighlightItem, type Highlights, INTERACTIVE_RENDER_CONFIG, type LabelsTheme, type LegendRenderConfig, type LegendTheme, type LithologyTextureTheme, type LithologyTheme, RENDER_LABELS, type RenderConfig, type RenderLabelPack, type RenderLocalizedText, type RenderableWell, STATIC_RENDER_CONFIG, type SvgInstance, type TooltipKey, type TooltipLabels, WellRenderer, type WellTheme, type WithKey, applyRenderLocale, drawWellLegend, formatDiameter, formatLength, getDiameterUnit, getLengthUnit, importFgdcTextures, resolveRenderLabel };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Well, Lithology, Fracture, Cave, BoreHole, WellCase, WellScreen, HoleFill, SurfaceCase, Reduction, Units, DiameterUnits, LengthUnits } from '@welldot/core';
|
|
2
2
|
|
|
3
3
|
type PadTextureConfig = {
|
|
4
4
|
background: string;
|
|
@@ -71,6 +71,7 @@ type Highlights = {
|
|
|
71
71
|
hole_fill?: HighlightItem[];
|
|
72
72
|
well_case?: HighlightItem[];
|
|
73
73
|
well_screen?: HighlightItem[];
|
|
74
|
+
reduction?: HighlightItem[];
|
|
74
75
|
};
|
|
75
76
|
type LithologyTheme = {
|
|
76
77
|
stroke: string;
|
|
@@ -129,6 +130,11 @@ type ConstructionTheme = {
|
|
|
129
130
|
stroke: string;
|
|
130
131
|
strokeWidth: number;
|
|
131
132
|
};
|
|
133
|
+
reduction: {
|
|
134
|
+
fill: string;
|
|
135
|
+
stroke: string;
|
|
136
|
+
strokeWidth: number;
|
|
137
|
+
};
|
|
132
138
|
conflict: {
|
|
133
139
|
stroke: string;
|
|
134
140
|
strokeWidth: number;
|
|
@@ -256,6 +262,10 @@ type ComponentsClassNames = {
|
|
|
256
262
|
group: string;
|
|
257
263
|
rect: string;
|
|
258
264
|
};
|
|
265
|
+
reduction: {
|
|
266
|
+
group: string;
|
|
267
|
+
item: string;
|
|
268
|
+
};
|
|
259
269
|
conflict: {
|
|
260
270
|
group: string;
|
|
261
271
|
rect: string;
|
|
@@ -286,15 +296,113 @@ type ComponentsClassNames = {
|
|
|
286
296
|
};
|
|
287
297
|
};
|
|
288
298
|
/** Keys identifying which tooltip types are active. Pass to `RenderConfig.tooltips` to control visibility. */
|
|
289
|
-
type TooltipKey = 'geology' | 'hole' | 'surfaceCase' | 'holeFill' | 'wellCase' | 'wellScreen' | 'conflict' | 'fracture' | 'cementPad' | 'cave';
|
|
299
|
+
type TooltipKey = 'geology' | 'hole' | 'surfaceCase' | 'holeFill' | 'wellCase' | 'wellScreen' | 'reduction' | 'conflict' | 'fracture' | 'cementPad' | 'cave';
|
|
300
|
+
/**
|
|
301
|
+
* A paired-locale string for renderer-drawn text, or a bare string when the
|
|
302
|
+
* value doesn't vary by locale. `pt` is the required fallback locale in the
|
|
303
|
+
* object form; `en` is optional. Resolve via `resolveRenderLabel()` — never
|
|
304
|
+
* read `.pt`/`.en` directly, since the value may be a plain string.
|
|
305
|
+
*/
|
|
306
|
+
type RenderLocalizedText = {
|
|
307
|
+
pt: string;
|
|
308
|
+
en?: string;
|
|
309
|
+
} | string;
|
|
310
|
+
/**
|
|
311
|
+
* Shape shared by `RenderConfig.tooltipLabels` (resolved, `T = string`) and
|
|
312
|
+
* `RenderLabelPack.tooltipLabels` (authoring, `T = RenderLocalizedText`) —
|
|
313
|
+
* defined once via the generic so the two shapes can't drift apart.
|
|
314
|
+
*/
|
|
315
|
+
type TooltipLabels<T = string> = {
|
|
316
|
+
common: {
|
|
317
|
+
from: T;
|
|
318
|
+
to: T;
|
|
319
|
+
description: T;
|
|
320
|
+
diameter: T;
|
|
321
|
+
type: T;
|
|
322
|
+
};
|
|
323
|
+
geology: {
|
|
324
|
+
title: T;
|
|
325
|
+
geologicUnit: T;
|
|
326
|
+
aquiferUnit: T;
|
|
327
|
+
};
|
|
328
|
+
hole: {
|
|
329
|
+
title: T;
|
|
330
|
+
};
|
|
331
|
+
surfaceCase: {
|
|
332
|
+
title: T;
|
|
333
|
+
};
|
|
334
|
+
holeFill: {
|
|
335
|
+
title: T;
|
|
336
|
+
};
|
|
337
|
+
wellCase: {
|
|
338
|
+
title: T;
|
|
339
|
+
};
|
|
340
|
+
wellScreen: {
|
|
341
|
+
title: T;
|
|
342
|
+
slot: T;
|
|
343
|
+
};
|
|
344
|
+
reduction: {
|
|
345
|
+
title: T;
|
|
346
|
+
};
|
|
347
|
+
conflict: {
|
|
348
|
+
title: T;
|
|
349
|
+
};
|
|
350
|
+
fracture: {
|
|
351
|
+
title: T;
|
|
352
|
+
titleSwarm: T;
|
|
353
|
+
depth: T;
|
|
354
|
+
waterIntake: T;
|
|
355
|
+
dip: T;
|
|
356
|
+
azimuth: T;
|
|
357
|
+
};
|
|
358
|
+
cementPad: {
|
|
359
|
+
title: T;
|
|
360
|
+
thickness: T;
|
|
361
|
+
width: T;
|
|
362
|
+
length: T;
|
|
363
|
+
};
|
|
364
|
+
cave: {
|
|
365
|
+
title: T;
|
|
366
|
+
waterIntake: T;
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* Canonical, paired-locale source for every string `@welldot/render` draws.
|
|
371
|
+
* `RENDER_LABELS` (in `configs/render.configs.ts`) is the sole instance;
|
|
372
|
+
* `applyRenderLocale()` resolves it down to a plain-string `DeepPartial<RenderConfig>`.
|
|
373
|
+
*/
|
|
374
|
+
type RenderLabelPack = {
|
|
375
|
+
constructionLabels: {
|
|
376
|
+
wellCasePrefix: RenderLocalizedText;
|
|
377
|
+
wellScreenPrefix: RenderLocalizedText;
|
|
378
|
+
wellScreenSlotPrefix: RenderLocalizedText;
|
|
379
|
+
};
|
|
380
|
+
legend: {
|
|
381
|
+
title: RenderLocalizedText;
|
|
382
|
+
labels: Record<keyof LegendRenderConfig['labels'], RenderLocalizedText>;
|
|
383
|
+
};
|
|
384
|
+
tooltipLabels: TooltipLabels<RenderLocalizedText>;
|
|
385
|
+
typeLabels: {
|
|
386
|
+
fracture: RenderLocalizedText;
|
|
387
|
+
fractureWater: RenderLocalizedText;
|
|
388
|
+
cave: RenderLocalizedText;
|
|
389
|
+
caveWater: RenderLocalizedText;
|
|
390
|
+
};
|
|
391
|
+
};
|
|
290
392
|
/** Full rendering behaviour configuration. Use `INTERACTIVE_RENDER_CONFIG` or `STATIC_RENDER_CONFIG` as a starting point. */
|
|
291
393
|
type RenderConfig = {
|
|
292
394
|
zoom: boolean;
|
|
293
395
|
pan: boolean;
|
|
294
396
|
/** Initial zoom scale applied on first render (1 = fit all, 2 = start 2× zoomed in). */
|
|
295
397
|
zoomLevel?: number;
|
|
398
|
+
/** Upper bound for zoom scale, enforced for wheel/drag and `zoomBy`/`resetZoom` alike (default 150 = 15000%). */
|
|
399
|
+
maxZoomScale?: number;
|
|
400
|
+
/** Lower bound for zoom scale, enforced for wheel/drag and `zoomBy`/`resetZoom` alike (default 0 = 0%). */
|
|
401
|
+
minZoomScale?: number;
|
|
296
402
|
/** undefined = show all; false or [] = show none; array = show only listed keys */
|
|
297
403
|
tooltips?: TooltipKey[] | false;
|
|
404
|
+
/** Resolved (plain-string) tooltip titles/field labels — see `TooltipLabels`. */
|
|
405
|
+
tooltipLabels: TooltipLabels;
|
|
298
406
|
animation: {
|
|
299
407
|
duration: number;
|
|
300
408
|
ease: (t: number) => number;
|
|
@@ -355,7 +463,9 @@ type RenderConfig = {
|
|
|
355
463
|
lithology?: boolean | ('depth' | 'description' | 'dividers')[];
|
|
356
464
|
typeLabels?: {
|
|
357
465
|
fracture?: string;
|
|
466
|
+
fractureWater?: string;
|
|
358
467
|
cave?: string;
|
|
468
|
+
caveWater?: string;
|
|
359
469
|
};
|
|
360
470
|
depthTipHeight: number;
|
|
361
471
|
depthTipPadX: number;
|
|
@@ -415,6 +525,7 @@ type LegendRenderConfig = {
|
|
|
415
525
|
holeFillSeal: string;
|
|
416
526
|
wellCase: string;
|
|
417
527
|
wellScreen: string;
|
|
528
|
+
reduction: string;
|
|
418
529
|
cementPad: string;
|
|
419
530
|
conflict: string;
|
|
420
531
|
};
|
|
@@ -437,7 +548,54 @@ type SvgInstance = {
|
|
|
437
548
|
bottom: number;
|
|
438
549
|
};
|
|
439
550
|
};
|
|
551
|
+
/**
|
|
552
|
+
* Attaches an optional stable render identity to any feature type.
|
|
553
|
+
*
|
|
554
|
+
* **`key` is runtime-only.** It exists solely in memory while the renderer is
|
|
555
|
+
* running and must never be written to a `.well` file. It is not part of the
|
|
556
|
+
* `.well` v2 spec — persisting it would produce a non-conformant file.
|
|
557
|
+
*/
|
|
558
|
+
type WithKey<T> = T & {
|
|
559
|
+
key?: string | number;
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* A `Well` profile where every feature array element may carry an optional `key`.
|
|
563
|
+
*
|
|
564
|
+
* When `key` is present the renderer uses it as the D3 data-join key,
|
|
565
|
+
* giving fully stable DOM identity regardless of depth edits or array reordering.
|
|
566
|
+
* When absent the renderer falls back to coordinate-based keys (`from:to` or
|
|
567
|
+
* `depth:index`).
|
|
568
|
+
*
|
|
569
|
+
* **`key` is runtime-only** — generate it once per feature (e.g.
|
|
570
|
+
* `crypto.randomUUID()`) and keep it in memory across edits, but always strip
|
|
571
|
+
* it before serializing to a `.well` file.
|
|
572
|
+
*/
|
|
573
|
+
type RenderableWell = Omit<Well, 'lithology' | 'fractures' | 'caves' | 'bore_hole' | 'well_case' | 'well_screen' | 'hole_fill' | 'surface_case' | 'reduction'> & {
|
|
574
|
+
lithology: WithKey<Lithology>[];
|
|
575
|
+
fractures: WithKey<Fracture>[];
|
|
576
|
+
caves: WithKey<Cave>[];
|
|
577
|
+
bore_hole: WithKey<BoreHole>[];
|
|
578
|
+
well_case: WithKey<WellCase>[];
|
|
579
|
+
well_screen: WithKey<WellScreen>[];
|
|
580
|
+
hole_fill: WithKey<HoleFill>[];
|
|
581
|
+
surface_case: WithKey<SurfaceCase>[];
|
|
582
|
+
reduction: WithKey<Reduction>[];
|
|
583
|
+
};
|
|
440
584
|
|
|
585
|
+
/**
|
|
586
|
+
* Canonical, paired-locale source for every string `@welldot/render` draws
|
|
587
|
+
* (construction-label prefixes, legend entries, tooltip titles/fields,
|
|
588
|
+
* fracture/cave type words). `pt` values must match the literals historically
|
|
589
|
+
* hardcoded in `tooltips.utils.ts`/`annotation-labels.renderer.ts` exactly —
|
|
590
|
+
* this is the single source of truth `applyRenderLocale()` resolves from.
|
|
591
|
+
*/
|
|
592
|
+
declare const RENDER_LABELS: RenderLabelPack;
|
|
593
|
+
/**
|
|
594
|
+
* Returns a copy of `config` with `constructionLabels.labels`, `legend.labels`,
|
|
595
|
+
* `tooltipLabels`, and `labels.typeLabels` resolved from `RENDER_LABELS` for
|
|
596
|
+
* `locale`. Every other field of `config` is preserved unchanged.
|
|
597
|
+
*/
|
|
598
|
+
declare function applyRenderLocale(config: RenderConfig, locale: 'en' | 'pt'): RenderConfig;
|
|
441
599
|
declare const DEFAULT_WELL_THEME: WellTheme;
|
|
442
600
|
declare const STATIC_RENDER_CONFIG: RenderConfig;
|
|
443
601
|
declare const INTERACTIVE_RENDER_CONFIG: RenderConfig;
|
|
@@ -472,28 +630,50 @@ declare class WellRenderer {
|
|
|
472
630
|
private instanceStates;
|
|
473
631
|
private textures;
|
|
474
632
|
private onError?;
|
|
633
|
+
private onZoom?;
|
|
475
634
|
classes: ComponentsClassNames;
|
|
476
635
|
private renderConfig;
|
|
477
636
|
private theme;
|
|
478
637
|
private units;
|
|
638
|
+
private locale;
|
|
479
639
|
/**
|
|
480
640
|
* @param svgs - One entry per SVG panel; multi-entry for split-panel layouts.
|
|
481
641
|
* @param options.classNames - Override default BEM CSS class names.
|
|
482
642
|
* @param options.units - Active measurement units (`length` and `diameter`).
|
|
643
|
+
* @param options.locale - Locale for renderer-drawn text (diameter symbol, and any `RenderConfig` fields resolved via `applyRenderLocale`). Defaults to `'pt'`, matching the package's historical output.
|
|
483
644
|
* @param options.renderConfig - Rendering behaviour (zoom, pan, animation, layout). Defaults to `INTERACTIVE_RENDER_CONFIG`.
|
|
484
645
|
* @param options.theme - Visual theme overrides. Merged on top of `DEFAULT_WELL_THEME`.
|
|
485
646
|
* @param options.onError - Called when a draw error occurs (e.g., a renderer throws). Falls back to `console.error` if omitted.
|
|
647
|
+
* @param options.onZoom - Called with the current zoom scale (`1` = initial/fit) whenever the user zooms or pans, and whenever `zoomBy`/`resetZoom` are called. No-op if `renderConfig.zoom`/`pan` are both disabled.
|
|
486
648
|
*/
|
|
487
649
|
constructor(svgs: SvgInstance[], options?: {
|
|
488
650
|
classNames?: DeepPartial<ComponentsClassNames>;
|
|
489
651
|
units?: Units;
|
|
652
|
+
locale?: 'en' | 'pt';
|
|
490
653
|
renderConfig?: DeepPartial<RenderConfig>;
|
|
491
654
|
theme?: DeepPartial<WellTheme>;
|
|
492
655
|
onError?: (err: Error) => void;
|
|
656
|
+
onZoom?: (scale: number) => void;
|
|
493
657
|
});
|
|
494
658
|
private initInstanceSvg;
|
|
495
659
|
/** Renders a standalone legend into the element matched by `selector`. */
|
|
496
660
|
renderLegend(selector: string, profile: Well): void;
|
|
661
|
+
/**
|
|
662
|
+
* Multiplies the current zoom scale by `factor` (e.g. `1.25` to zoom in,
|
|
663
|
+
* `1 / 1.25` to zoom out) on every panel. No-op if both `renderConfig.zoom`
|
|
664
|
+
* and `renderConfig.pan` are disabled (no zoom behavior was attached).
|
|
665
|
+
*/
|
|
666
|
+
zoomBy(factor: number): void;
|
|
667
|
+
/**
|
|
668
|
+
* Resets zoom/pan on every panel back to `renderConfig.zoomLevel`
|
|
669
|
+
* (defaults to `1`, i.e. the initial fit-to-container view).
|
|
670
|
+
*/
|
|
671
|
+
resetZoom(): void;
|
|
672
|
+
/**
|
|
673
|
+
* Current zoom scale factor of the first panel (`1` = initial/fit).
|
|
674
|
+
* Returns `1` if zoom/pan is disabled or `prepareSvg()` hasn't run yet.
|
|
675
|
+
*/
|
|
676
|
+
getZoomScale(): number;
|
|
497
677
|
/**
|
|
498
678
|
* Initialises the SVG DOM structure and preloads FGDC textures.
|
|
499
679
|
* Must be called once before the first `draw()`.
|
|
@@ -503,10 +683,12 @@ declare class WellRenderer {
|
|
|
503
683
|
* Renders the well profile into all configured SVG panels.
|
|
504
684
|
* @param profile - The well data to render.
|
|
505
685
|
* @param options.units - Override the instance-level measurement units for this render.
|
|
686
|
+
* @param options.locale - Override the instance-level locale for this render.
|
|
506
687
|
* @param options.highlights - Highlight overlays to display on top of the profile.
|
|
507
688
|
*/
|
|
508
|
-
draw(profile:
|
|
689
|
+
draw(profile: RenderableWell, options?: {
|
|
509
690
|
units?: Units;
|
|
691
|
+
locale?: 'en' | 'pt';
|
|
510
692
|
highlights?: Highlights;
|
|
511
693
|
}): void;
|
|
512
694
|
private drawLogToInstance;
|
|
@@ -519,13 +701,30 @@ declare function drawWellLegend(selector: string, profile: Well, options?: {
|
|
|
519
701
|
textures?: TexturesConfig;
|
|
520
702
|
}): void;
|
|
521
703
|
|
|
522
|
-
/**
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
704
|
+
/**
|
|
705
|
+
* Formats a depth value in metres to the active length unit string, rounded
|
|
706
|
+
* (never raw floating-point) and using the target locale's decimal separator.
|
|
707
|
+
*/
|
|
708
|
+
declare function formatLength(m: number, units: LengthUnits, locale: 'en' | 'pt'): string;
|
|
709
|
+
/**
|
|
710
|
+
* Formats a diameter value in millimetres to the active diameter unit
|
|
711
|
+
* string, rounded (never raw floating-point) and using the target locale's
|
|
712
|
+
* decimal separator.
|
|
713
|
+
*/
|
|
714
|
+
declare function formatDiameter(mm: number, units: DiameterUnits, locale: 'en' | 'pt'): string;
|
|
526
715
|
/** Returns the display label for the active length unit (e.g. `"m"` or `"ft"`). */
|
|
527
716
|
declare function getLengthUnit(units: LengthUnits): string;
|
|
528
|
-
/**
|
|
529
|
-
|
|
717
|
+
/**
|
|
718
|
+
* Returns the display symbol for the active diameter unit. `mm` is
|
|
719
|
+
* locale-invariant; `inches` is `'"'` unless `locale` is `'en'`, in which
|
|
720
|
+
* case it's `'in.'`. Omitting `locale` preserves the historical `'"'` default.
|
|
721
|
+
*/
|
|
722
|
+
declare function getDiameterUnit(units: DiameterUnits, locale?: 'en' | 'pt'): string;
|
|
723
|
+
/**
|
|
724
|
+
* Resolves a paired-locale render label to a plain string. A bare string is
|
|
725
|
+
* returned as-is (locale-invariant); for the `{ pt, en }` object form, `pt`
|
|
726
|
+
* is always the fallback — mirrors the org-wide `resolveLanguageText()` contract.
|
|
727
|
+
*/
|
|
728
|
+
declare function resolveRenderLabel(value: RenderLocalizedText, locale: 'en' | 'pt'): string;
|
|
530
729
|
|
|
531
|
-
export { type CaveTheme, type ComponentsClassNames, type ConstructionTheme, DEFAULT_WELL_THEME, type DeepPartial, type FractureTheme, type HighlightItem, type Highlights, INTERACTIVE_RENDER_CONFIG, type LabelsTheme, type LegendRenderConfig, type LegendTheme, type LithologyTextureTheme, type LithologyTheme, type RenderConfig, STATIC_RENDER_CONFIG, type SvgInstance, type TooltipKey, WellRenderer, type WellTheme, drawWellLegend, formatDiameter, formatLength, getDiameterUnit, getLengthUnit, importFgdcTextures };
|
|
730
|
+
export { type CaveTheme, type ComponentsClassNames, type ConstructionTheme, DEFAULT_WELL_THEME, type DeepPartial, type FractureTheme, type HighlightItem, type Highlights, INTERACTIVE_RENDER_CONFIG, type LabelsTheme, type LegendRenderConfig, type LegendTheme, type LithologyTextureTheme, type LithologyTheme, RENDER_LABELS, type RenderConfig, type RenderLabelPack, type RenderLocalizedText, type RenderableWell, STATIC_RENDER_CONFIG, type SvgInstance, type TooltipKey, type TooltipLabels, WellRenderer, type WellTheme, type WithKey, applyRenderLocale, drawWellLegend, formatDiameter, formatLength, getDiameterUnit, getLengthUnit, importFgdcTextures, resolveRenderLabel };
|