@jjlmoya/utils-motor 1.1.0 → 1.2.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 (39) hide show
  1. package/package.json +1 -1
  2. package/src/category/index.ts +2 -1
  3. package/src/entries.ts +4 -1
  4. package/src/index.ts +5 -0
  5. package/src/tests/i18n_coverage.test.ts +5 -3
  6. package/src/tests/locale_completeness.test.ts +1 -1
  7. package/src/tests/tool_validation.test.ts +1 -2
  8. package/src/tool/realFuelConsumptionCalculator/bibliography.astro +6 -0
  9. package/src/tool/realFuelConsumptionCalculator/bibliography.ts +12 -0
  10. package/src/tool/realFuelConsumptionCalculator/component.astro +111 -0
  11. package/src/tool/realFuelConsumptionCalculator/controller.ts +175 -0
  12. package/src/tool/realFuelConsumptionCalculator/dom-views.ts +132 -0
  13. package/src/tool/realFuelConsumptionCalculator/entry.ts +30 -0
  14. package/src/tool/realFuelConsumptionCalculator/evaluator.ts +15 -0
  15. package/src/tool/realFuelConsumptionCalculator/i18n/de.ts +119 -0
  16. package/src/tool/realFuelConsumptionCalculator/i18n/en.ts +119 -0
  17. package/src/tool/realFuelConsumptionCalculator/i18n/es.ts +119 -0
  18. package/src/tool/realFuelConsumptionCalculator/i18n/factory.ts +110 -0
  19. package/src/tool/realFuelConsumptionCalculator/i18n/fr.ts +119 -0
  20. package/src/tool/realFuelConsumptionCalculator/i18n/id.ts +119 -0
  21. package/src/tool/realFuelConsumptionCalculator/i18n/it.ts +119 -0
  22. package/src/tool/realFuelConsumptionCalculator/i18n/ja.ts +119 -0
  23. package/src/tool/realFuelConsumptionCalculator/i18n/ko.ts +119 -0
  24. package/src/tool/realFuelConsumptionCalculator/i18n/nl.ts +119 -0
  25. package/src/tool/realFuelConsumptionCalculator/i18n/pl.ts +119 -0
  26. package/src/tool/realFuelConsumptionCalculator/i18n/pt.ts +119 -0
  27. package/src/tool/realFuelConsumptionCalculator/i18n/ru.ts +119 -0
  28. package/src/tool/realFuelConsumptionCalculator/i18n/sv.ts +119 -0
  29. package/src/tool/realFuelConsumptionCalculator/i18n/tr.ts +119 -0
  30. package/src/tool/realFuelConsumptionCalculator/i18n/zh.ts +119 -0
  31. package/src/tool/realFuelConsumptionCalculator/index.ts +10 -0
  32. package/src/tool/realFuelConsumptionCalculator/logic.test.ts +72 -0
  33. package/src/tool/realFuelConsumptionCalculator/logic.ts +142 -0
  34. package/src/tool/realFuelConsumptionCalculator/real-fuel-consumption-calculator.css +692 -0
  35. package/src/tool/realFuelConsumptionCalculator/seo.astro +15 -0
  36. package/src/tool/realFuelConsumptionCalculator/storage.ts +54 -0
  37. package/src/tool/realFuelConsumptionCalculator/ui.ts +72 -0
  38. package/src/tools.ts +2 -1
  39. package/src/tests/faq_count.test.ts +0 -19
@@ -0,0 +1,54 @@
1
+ import type { ComparisonInput, Currency, EnergyMode } from './logic';
2
+
3
+ export interface FuelLogState {
4
+ distance: number;
5
+ used: number;
6
+ price: number;
7
+ rated: number;
8
+ mode: EnergyMode;
9
+ currency: Currency;
10
+ rememberComparisons: boolean;
11
+ comparisons: Record<EnergyMode, ComparisonInput>;
12
+ }
13
+
14
+ export const DEFAULT_FUEL_LOG_STATE: FuelLogState = {
15
+ distance: 100,
16
+ used: 6.5,
17
+ price: 1.8,
18
+ rated: 5.8,
19
+ mode: 'gasoline',
20
+ currency: 'EUR',
21
+ rememberComparisons: false,
22
+ comparisons: {
23
+ gasoline: { ratio: 1, price: 1.8 },
24
+ diesel: { ratio: 0.82, price: 1.72 },
25
+ electric: { ratio: 2.6, price: 0.22 },
26
+ },
27
+ };
28
+
29
+ const STORAGE_KEY = 'real-fuel-consumption-calculator-v7';
30
+
31
+ export function loadFuelLogState(): FuelLogState | null {
32
+ try {
33
+ const raw = localStorage.getItem(STORAGE_KEY);
34
+ if (!raw) return null;
35
+ const parsed = JSON.parse(raw) as Partial<FuelLogState>;
36
+ const rememberComparisons = parsed.rememberComparisons === true;
37
+ return {
38
+ ...DEFAULT_FUEL_LOG_STATE,
39
+ ...parsed,
40
+ rememberComparisons,
41
+ comparisons: rememberComparisons ? { ...DEFAULT_FUEL_LOG_STATE.comparisons, ...parsed.comparisons } : DEFAULT_FUEL_LOG_STATE.comparisons,
42
+ };
43
+ } catch {
44
+ return null;
45
+ }
46
+ }
47
+
48
+ export function saveFuelLogState(state: FuelLogState): void {
49
+ try {
50
+ const payload: Partial<FuelLogState> = { ...state };
51
+ if (!state.rememberComparisons) delete payload.comparisons;
52
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(payload));
53
+ } catch {}
54
+ }
@@ -0,0 +1,72 @@
1
+ export interface FuelLogUI extends Record<string, string> {
2
+ fuelTypeLabel: string;
3
+ gasolineLabel: string;
4
+ dieselLabel: string;
5
+ electricLabel: string;
6
+ currencyLabel: string;
7
+ resetLabel: string;
8
+ measurementTitle: string;
9
+ intakeQuestion: string;
10
+ distanceLabel: string;
11
+ distanceHint: string;
12
+ distanceUnit: string;
13
+ usedLabel: string;
14
+ gasolineUsedLabel: string;
15
+ gasolineUsedHint: string;
16
+ dieselUsedLabel: string;
17
+ dieselUsedHint: string;
18
+ electricUsedLabel: string;
19
+ electricUsedHint: string;
20
+ fuelUnit: string;
21
+ energyUnit: string;
22
+ fuelConsumptionUnit: string;
23
+ energyConsumptionUnit: string;
24
+ priceLabel: string;
25
+ priceHint: string;
26
+ gasolinePriceLabel: string;
27
+ dieselPriceLabel: string;
28
+ electricPriceLabel: string;
29
+ optionalDetails: string;
30
+ ratedLabel: string;
31
+ gasolineRatedLabel: string;
32
+ dieselRatedLabel: string;
33
+ electricRatedLabel: string;
34
+ ratedHint: string;
35
+ currencyRateLabel: string;
36
+ readingTitle: string;
37
+ comparisonTitle: string;
38
+ comparisonQuestion: string;
39
+ comparisonHint: string;
40
+ comparisonCostLabel: string;
41
+ comparisonNotSet: string;
42
+ comparisonReady: string;
43
+ comparisonCheapest: string;
44
+ comparisonMostExpensive: string;
45
+ comparisonPunchline: string;
46
+ comparisonSettingsTitle: string;
47
+ comparisonSettingsHint: string;
48
+ rememberComparisonsLabel: string;
49
+ resetComparisonsLabel: string;
50
+ compareConsumptionLabel: string;
51
+ compareRatioLabel: string;
52
+ comparePriceLabel: string;
53
+ efficiencyLabel: string;
54
+ mpgLabel: string;
55
+ tripCostLabel: string;
56
+ costPer100Label: string;
57
+ savedLabel: string;
58
+ extraLabel: string;
59
+ gasolineStatusBetter: string;
60
+ gasolineStatusClose: string;
61
+ gasolineStatusHigher: string;
62
+ dieselStatusBetter: string;
63
+ dieselStatusClose: string;
64
+ dieselStatusHigher: string;
65
+ electricStatusBetter: string;
66
+ electricStatusClose: string;
67
+ electricStatusHigher: string;
68
+ formulaLabel: string;
69
+ fuelFormula: string;
70
+ electricFormula: string;
71
+ localNotice: string;
72
+ }
package/src/tools.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { ALL_ENTRIES } from './entries';
2
2
  import { BRAKING_DISTANCE_CALCULATOR_TOOL } from './tool/brakingDistanceCalculator';
3
+ import { REAL_FUEL_CONSUMPTION_CALCULATOR_TOOL } from './tool/realFuelConsumptionCalculator';
3
4
 
4
- export const ALL_TOOLS = [BRAKING_DISTANCE_CALCULATOR_TOOL];
5
+ export const ALL_TOOLS = [BRAKING_DISTANCE_CALCULATOR_TOOL, REAL_FUEL_CONSUMPTION_CALCULATOR_TOOL];
@@ -1,19 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import * as DATA from '../data';
3
-
4
- const TOOLS = DATA.motorCategory.tools;
5
-
6
- describe('FAQ Content Validation', () => {
7
- TOOLS.forEach((entry) => {
8
- describe(`Tool: ${entry.id}`, () => {
9
- it('has a registered locale map', () => {
10
- expect(entry.i18n).toBeDefined();
11
- });
12
- });
13
- });
14
-
15
- it('has one initial motor tool', () => {
16
- expect(TOOLS.length).toBe(1);
17
- });
18
- });
19
-