@jjlmoya/utils-diy 1.26.0 → 1.28.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.
- package/package.json +1 -1
- package/src/category/index.ts +2 -1
- package/src/entries.ts +4 -1
- package/src/tests/bibliography_wellformed_export.test.ts +46 -0
- package/src/tests/locale_completeness.test.ts +2 -3
- package/src/tests/seo_translation_completeness.test.ts +69 -0
- package/src/tests/seo_wellformed_export.test.ts +65 -0
- package/src/tests/tool_validation.test.ts +2 -2
- package/src/tool/drywallCalculator/i18n/de.ts +1 -1
- package/src/tool/drywallCalculator/i18n/id.ts +2 -2
- package/src/tool/drywallCalculator/i18n/it.ts +2 -2
- package/src/tool/drywallCalculator/i18n/ja.ts +1 -1
- package/src/tool/drywallCalculator/i18n/ko.ts +1 -1
- package/src/tool/drywallCalculator/i18n/nl.ts +2 -2
- package/src/tool/drywallCalculator/i18n/pl.ts +3 -3
- package/src/tool/drywallCalculator/i18n/pt.ts +3 -3
- package/src/tool/drywallCalculator/i18n/ru.ts +2 -2
- package/src/tool/drywallCalculator/i18n/sv.ts +3 -3
- package/src/tool/drywallCalculator/i18n/tr.ts +3 -3
- package/src/tool/drywallCalculator/i18n/zh.ts +3 -3
- package/src/tool/drywallCalculator/seo.astro +12 -11
- package/src/tool/excavationVolumeCalculator/bibliography.astro +6 -0
- package/src/tool/excavationVolumeCalculator/bibliography.ts +12 -0
- package/src/tool/excavationVolumeCalculator/component.astro +80 -0
- package/src/tool/excavationVolumeCalculator/controller.ts +69 -0
- package/src/tool/excavationVolumeCalculator/dom-views.ts +63 -0
- package/src/tool/excavationVolumeCalculator/entry.ts +26 -0
- package/src/tool/excavationVolumeCalculator/evaluator.ts +21 -0
- package/src/tool/excavationVolumeCalculator/excavation-volume-calculator.css +442 -0
- package/src/tool/excavationVolumeCalculator/i18n/de.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/en.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/es.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/fr.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/id.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/it.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/ja.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/ko.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/nl.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/pl.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/pt.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/ru.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/sv.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/tr.ts +120 -0
- package/src/tool/excavationVolumeCalculator/i18n/zh.ts +120 -0
- package/src/tool/excavationVolumeCalculator/index.ts +11 -0
- package/src/tool/excavationVolumeCalculator/logic.test.ts +29 -0
- package/src/tool/excavationVolumeCalculator/logic.ts +35 -0
- package/src/tool/excavationVolumeCalculator/seo.astro +15 -0
- package/src/tool/excavationVolumeCalculator/storage.ts +28 -0
- package/src/tool/excavationVolumeCalculator/ui.ts +66 -0
- package/src/tools.ts +2 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ExcavationInput, ExcavationOutput, SoilBand, SoilProfile } from './ui';
|
|
2
|
+
|
|
3
|
+
const SOIL_BANDS: Record<SoilProfile, SoilBand> = {
|
|
4
|
+
sand: { low: 0.1, high: 0.15 },
|
|
5
|
+
topsoil: { low: 0.15, high: 0.25 },
|
|
6
|
+
clay: { low: 0.25, high: 0.4 },
|
|
7
|
+
gravel: { low: 0.15, high: 0.25 },
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function getSoilBand(soil: SoilProfile): SoilBand {
|
|
11
|
+
return SOIL_BANDS[soil];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function calculateExcavation(input: ExcavationInput): ExcavationOutput {
|
|
15
|
+
const dimensions = [input.length, input.width, input.depth].map((value) => Math.max(0, value));
|
|
16
|
+
const bankVolume = dimensions.reduce((total, value) => total * value, 1);
|
|
17
|
+
const soilBand = getSoilBand(input.soil);
|
|
18
|
+
return {
|
|
19
|
+
bankVolume,
|
|
20
|
+
looseLow: bankVolume * (1 + soilBand.low),
|
|
21
|
+
looseHigh: bankVolume * (1 + soilBand.high),
|
|
22
|
+
soilBand,
|
|
23
|
+
expansionLow: soilBand.low,
|
|
24
|
+
expansionHigh: soilBand.high,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function convertDimension(value: number, from: 'metric' | 'imperial', to: 'metric' | 'imperial'): number {
|
|
29
|
+
if (from === to) return value;
|
|
30
|
+
return from === 'metric' ? value * 3.280839895 : value / 3.280839895;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function convertVolume(value: number, system: 'metric' | 'imperial'): number {
|
|
34
|
+
return system === 'metric' ? value : value * 35.31466672;
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { SEORenderer } from '@jjlmoya/utils-shared';
|
|
3
|
+
import { excavationVolumeCalculator } from './entry';
|
|
4
|
+
import type { KnownLocale } from '../../types';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
locale?: KnownLocale;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { locale = 'es' } = Astro.props;
|
|
11
|
+
const loader = excavationVolumeCalculator.i18n[locale as KnownLocale] ?? excavationVolumeCalculator.i18n.es ?? excavationVolumeCalculator.i18n.en;
|
|
12
|
+
const content = loader ? await loader() : null;
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
{content?.seo && content.seo.length > 0 && <SEORenderer content={{ locale, sections: content.seo }} />}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ExcavationInput, ExcavationUnitSystem, SoilProfile } from './ui';
|
|
2
|
+
|
|
3
|
+
const STORAGE_KEY = 'jjlmoya-excavation-volume-calculator';
|
|
4
|
+
|
|
5
|
+
interface StoredState {
|
|
6
|
+
unitSystem: ExcavationUnitSystem;
|
|
7
|
+
length: number;
|
|
8
|
+
width: number;
|
|
9
|
+
depth: number;
|
|
10
|
+
soil: SoilProfile;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function readExcavationState(fallback: ExcavationInput): ExcavationInput {
|
|
14
|
+
try {
|
|
15
|
+
const raw = localStorage.getItem(STORAGE_KEY);
|
|
16
|
+
if (!raw) return fallback;
|
|
17
|
+
const parsed = JSON.parse(raw) as Partial<StoredState>;
|
|
18
|
+
if (!parsed.unitSystem || !parsed.soil) return fallback;
|
|
19
|
+
return { ...fallback, ...parsed };
|
|
20
|
+
} catch {}
|
|
21
|
+
return fallback;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function writeExcavationState(input: ExcavationInput): void {
|
|
25
|
+
try {
|
|
26
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(input));
|
|
27
|
+
} catch {}
|
|
28
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export type ExcavationUnitSystem = 'metric' | 'imperial';
|
|
2
|
+
export type SoilProfile = 'sand' | 'topsoil' | 'clay' | 'gravel';
|
|
3
|
+
|
|
4
|
+
export interface ExcavationInput {
|
|
5
|
+
unitSystem: ExcavationUnitSystem;
|
|
6
|
+
length: number;
|
|
7
|
+
width: number;
|
|
8
|
+
depth: number;
|
|
9
|
+
soil: SoilProfile;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SoilBand {
|
|
13
|
+
low: number;
|
|
14
|
+
high: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ExcavationOutput {
|
|
18
|
+
bankVolume: number;
|
|
19
|
+
looseLow: number;
|
|
20
|
+
looseHigh: number;
|
|
21
|
+
soilBand: SoilBand;
|
|
22
|
+
expansionLow: number;
|
|
23
|
+
expansionHigh: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ExcavationCalculatorUI extends Record<string, string> {
|
|
27
|
+
unitSystemLabel: string;
|
|
28
|
+
unitMetric: string;
|
|
29
|
+
unitImperial: string;
|
|
30
|
+
onboarding: string;
|
|
31
|
+
dimensionLabel: string;
|
|
32
|
+
lengthLabel: string;
|
|
33
|
+
widthLabel: string;
|
|
34
|
+
depthLabel: string;
|
|
35
|
+
soilLabel: string;
|
|
36
|
+
soilSand: string;
|
|
37
|
+
soilTopsoil: string;
|
|
38
|
+
soilClay: string;
|
|
39
|
+
soilGravel: string;
|
|
40
|
+
soilSandBand: string;
|
|
41
|
+
soilTopsoilBand: string;
|
|
42
|
+
soilClayBand: string;
|
|
43
|
+
soilGravelBand: string;
|
|
44
|
+
bankVolumeLabel: string;
|
|
45
|
+
bankVolumeHelp: string;
|
|
46
|
+
looseVolumeLabel: string;
|
|
47
|
+
looseVolumeHelp: string;
|
|
48
|
+
expansionLabel: string;
|
|
49
|
+
expansionHelp: string;
|
|
50
|
+
sceneTitle: string;
|
|
51
|
+
sceneBank: string;
|
|
52
|
+
sceneLoose: string;
|
|
53
|
+
sceneGround: string;
|
|
54
|
+
sceneCut: string;
|
|
55
|
+
interpretationTitle: string;
|
|
56
|
+
interpretationText: string;
|
|
57
|
+
warning: string;
|
|
58
|
+
unitLengthMetric: string;
|
|
59
|
+
unitLengthImperial: string;
|
|
60
|
+
unitVolumeMetric: string;
|
|
61
|
+
unitVolumeImperial: string;
|
|
62
|
+
soilStatusLow: string;
|
|
63
|
+
soilStatusMedium: string;
|
|
64
|
+
soilStatusHigh: string;
|
|
65
|
+
soilStatusLabel: string;
|
|
66
|
+
}
|
package/src/tools.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { WORKSHOP_FRACTION_CONVERTER_TOOL } from './tool/workshopFractionConvert
|
|
|
17
17
|
import { PYTHAGOREAN_RIGHT_ANGLE_CALCULATOR_TOOL } from './tool/pythagoreanRightAngleCalculator/index';
|
|
18
18
|
import { TWO_STROKE_MIXTURE_CALCULATOR_TOOL } from './tool/twoStrokeMixtureCalculator/index';
|
|
19
19
|
import { DRYWALL_CALCULATOR_TOOL } from './tool/drywallCalculator/index';
|
|
20
|
+
import { EXCAVATION_VOLUME_CALCULATOR_TOOL } from './tool/excavationVolumeCalculator/index';
|
|
20
21
|
|
|
21
|
-
export const ALL_TOOLS: ToolDefinition[] = [CLAY_CALCULATOR_TOOL, EPOXY_CALCULATOR_TOOL, BALUSTER_CALCULATOR_TOOL, MORTAR_CALCULATOR_TOOL, PASSEPARTOUT_CALCULATOR_TOOL, CONCRETE_CALCULATOR_TOOL, CUT_OPTIMIZER_TOOL, VOLTAGE_DROP_CALCULATOR_TOOL, FURNITURE_FIT_TOOL, THERMAL_EXPANSION_CALCULATOR_TOOL, DRILL_CALCULATOR_TOOL, STAIR_CALCULATOR_TOOL, DRILL_SHARPENER_TOOL, WORKSHOP_FRACTION_CONVERTER_TOOL, PYTHAGOREAN_RIGHT_ANGLE_CALCULATOR_TOOL, TWO_STROKE_MIXTURE_CALCULATOR_TOOL, DRYWALL_CALCULATOR_TOOL];
|
|
22
|
+
export const ALL_TOOLS: ToolDefinition[] = [CLAY_CALCULATOR_TOOL, EPOXY_CALCULATOR_TOOL, BALUSTER_CALCULATOR_TOOL, MORTAR_CALCULATOR_TOOL, PASSEPARTOUT_CALCULATOR_TOOL, CONCRETE_CALCULATOR_TOOL, CUT_OPTIMIZER_TOOL, VOLTAGE_DROP_CALCULATOR_TOOL, FURNITURE_FIT_TOOL, THERMAL_EXPANSION_CALCULATOR_TOOL, DRILL_CALCULATOR_TOOL, STAIR_CALCULATOR_TOOL, DRILL_SHARPENER_TOOL, WORKSHOP_FRACTION_CONVERTER_TOOL, PYTHAGOREAN_RIGHT_ANGLE_CALCULATOR_TOOL, TWO_STROKE_MIXTURE_CALCULATOR_TOOL, DRYWALL_CALCULATOR_TOOL, EXCAVATION_VOLUME_CALCULATOR_TOOL];
|
|
22
23
|
|