@jjlmoya/utils-motor 1.2.0 → 1.3.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 +3 -1
- package/src/entries.ts +7 -1
- package/src/index.ts +10 -0
- package/src/tests/locale_completeness.test.ts +1 -1
- package/src/tests/seo_translation_completeness.test.ts +69 -0
- package/src/tests/tool_validation.test.ts +1 -1
- package/src/tool/carMotorcycleGearRatioCalculator/bibliography.astro +6 -0
- package/src/tool/carMotorcycleGearRatioCalculator/bibliography.ts +12 -0
- package/src/tool/carMotorcycleGearRatioCalculator/car-motorcycle-gear-ratio-rpm-speed-calculator.css +668 -0
- package/src/tool/carMotorcycleGearRatioCalculator/component.astro +137 -0
- package/src/tool/carMotorcycleGearRatioCalculator/controller.ts +209 -0
- package/src/tool/carMotorcycleGearRatioCalculator/dom-views.ts +121 -0
- package/src/tool/carMotorcycleGearRatioCalculator/entry.ts +30 -0
- package/src/tool/carMotorcycleGearRatioCalculator/evaluator.ts +28 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/de.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/en.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/es.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/fr.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/id.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/it.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/ja.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/ko.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/nl.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/pl.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/pt.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/ru.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/sv.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/tr.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/i18n/zh.ts +162 -0
- package/src/tool/carMotorcycleGearRatioCalculator/index.ts +10 -0
- package/src/tool/carMotorcycleGearRatioCalculator/logic.test.ts +51 -0
- package/src/tool/carMotorcycleGearRatioCalculator/logic.ts +91 -0
- package/src/tool/carMotorcycleGearRatioCalculator/seo.astro +15 -0
- package/src/tool/carMotorcycleGearRatioCalculator/storage.ts +46 -0
- package/src/tool/carMotorcycleGearRatioCalculator/ui.ts +50 -0
- package/src/tool/tirePressureConverter/bibliography.astro +6 -0
- package/src/tool/tirePressureConverter/bibliography.ts +12 -0
- package/src/tool/tirePressureConverter/component.astro +82 -0
- package/src/tool/tirePressureConverter/controller.ts +120 -0
- package/src/tool/tirePressureConverter/dom-views.ts +31 -0
- package/src/tool/tirePressureConverter/entry.ts +30 -0
- package/src/tool/tirePressureConverter/evaluator.ts +8 -0
- package/src/tool/tirePressureConverter/i18n/de.ts +96 -0
- package/src/tool/tirePressureConverter/i18n/en.ts +96 -0
- package/src/tool/tirePressureConverter/i18n/es.ts +96 -0
- package/src/tool/tirePressureConverter/i18n/fr.ts +96 -0
- package/src/tool/tirePressureConverter/i18n/id.ts +95 -0
- package/src/tool/tirePressureConverter/i18n/it.ts +95 -0
- package/src/tool/tirePressureConverter/i18n/ja.ts +95 -0
- package/src/tool/tirePressureConverter/i18n/ko.ts +95 -0
- package/src/tool/tirePressureConverter/i18n/nl.ts +95 -0
- package/src/tool/tirePressureConverter/i18n/pl.ts +95 -0
- package/src/tool/tirePressureConverter/i18n/pt.ts +95 -0
- package/src/tool/tirePressureConverter/i18n/ru.ts +95 -0
- package/src/tool/tirePressureConverter/i18n/sv.ts +95 -0
- package/src/tool/tirePressureConverter/i18n/tr.ts +95 -0
- package/src/tool/tirePressureConverter/i18n/zh.ts +95 -0
- package/src/tool/tirePressureConverter/index.ts +10 -0
- package/src/tool/tirePressureConverter/logic.test.ts +37 -0
- package/src/tool/tirePressureConverter/logic.ts +47 -0
- package/src/tool/tirePressureConverter/seo.astro +15 -0
- package/src/tool/tirePressureConverter/storage.ts +27 -0
- package/src/tool/tirePressureConverter/tire-pressure-converter-psi-bar-kpa-kgf-cm2.css +293 -0
- package/src/tool/tirePressureConverter/ui.ts +20 -0
- package/src/tools.ts +3 -1
package/package.json
CHANGED
package/src/category/index.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { MotorCategoryEntry, MotorToolEntry } from '../types';
|
|
2
2
|
import { brakingDistanceCalculator } from '../tool/brakingDistanceCalculator/entry';
|
|
3
|
+
import { carMotorcycleGearRatioCalculator } from '../tool/carMotorcycleGearRatioCalculator/entry';
|
|
3
4
|
import { realFuelConsumptionCalculator } from '../tool/realFuelConsumptionCalculator/entry';
|
|
5
|
+
import { tirePressureConverter } from '../tool/tirePressureConverter/entry';
|
|
4
6
|
|
|
5
7
|
export const motorCategory: MotorCategoryEntry = {
|
|
6
8
|
icon: 'mdi:car-cog',
|
|
7
|
-
tools: [brakingDistanceCalculator, realFuelConsumptionCalculator] as unknown as MotorToolEntry<Record<string, string>>[],
|
|
9
|
+
tools: [brakingDistanceCalculator, realFuelConsumptionCalculator, carMotorcycleGearRatioCalculator, tirePressureConverter] as unknown as MotorToolEntry<Record<string, string>>[],
|
|
8
10
|
i18n: {
|
|
9
11
|
es: () => import('./i18n/es').then((module) => module.content),
|
|
10
12
|
en: () => import('./i18n/en').then((module) => module.content),
|
package/src/entries.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
export { brakingDistanceCalculator } from './tool/brakingDistanceCalculator/entry';
|
|
2
2
|
export type { BrakingDistanceCalculatorLocaleContent } from './tool/brakingDistanceCalculator/entry';
|
|
3
|
+
export { carMotorcycleGearRatioCalculator } from './tool/carMotorcycleGearRatioCalculator/entry';
|
|
4
|
+
export type { CarMotorcycleGearRatioCalculatorLocaleContent } from './tool/carMotorcycleGearRatioCalculator/entry';
|
|
3
5
|
export { realFuelConsumptionCalculator } from './tool/realFuelConsumptionCalculator/entry';
|
|
4
6
|
export type { RealFuelConsumptionCalculatorLocaleContent } from './tool/realFuelConsumptionCalculator/entry';
|
|
7
|
+
export { tirePressureConverter } from './tool/tirePressureConverter/entry';
|
|
8
|
+
export type { TirePressureConverterLocaleContent } from './tool/tirePressureConverter/entry';
|
|
5
9
|
export { motorCategory } from './category';
|
|
6
10
|
|
|
7
11
|
import { brakingDistanceCalculator } from './tool/brakingDistanceCalculator/entry';
|
|
12
|
+
import { carMotorcycleGearRatioCalculator } from './tool/carMotorcycleGearRatioCalculator/entry';
|
|
8
13
|
import { realFuelConsumptionCalculator } from './tool/realFuelConsumptionCalculator/entry';
|
|
14
|
+
import { tirePressureConverter } from './tool/tirePressureConverter/entry';
|
|
9
15
|
|
|
10
|
-
export const ALL_ENTRIES = [brakingDistanceCalculator, realFuelConsumptionCalculator];
|
|
16
|
+
export const ALL_ENTRIES = [brakingDistanceCalculator, realFuelConsumptionCalculator, carMotorcycleGearRatioCalculator, tirePressureConverter];
|
package/src/index.ts
CHANGED
|
@@ -26,3 +26,13 @@ export type {
|
|
|
26
26
|
FuelLogUI,
|
|
27
27
|
RealFuelConsumptionCalculatorLocaleContent,
|
|
28
28
|
} from './tool/realFuelConsumptionCalculator';
|
|
29
|
+
export { CAR_MOTORCYCLE_GEAR_RATIO_CALCULATOR_TOOL, carMotorcycleGearRatioCalculator } from './tool/carMotorcycleGearRatioCalculator';
|
|
30
|
+
export type {
|
|
31
|
+
CarMotorcycleGearRatioCalculatorUI,
|
|
32
|
+
CarMotorcycleGearRatioCalculatorLocaleContent,
|
|
33
|
+
} from './tool/carMotorcycleGearRatioCalculator';
|
|
34
|
+
export { TIRE_PRESSURE_CONVERTER_TOOL, tirePressureConverter } from './tool/tirePressureConverter';
|
|
35
|
+
export type {
|
|
36
|
+
TirePressureConverterUI,
|
|
37
|
+
TirePressureConverterLocaleContent,
|
|
38
|
+
} from './tool/tirePressureConverter';
|
|
@@ -4,7 +4,7 @@ import type { ToolLocaleContent } from '../types';
|
|
|
4
4
|
|
|
5
5
|
describe('Locale Completeness and Slug Validation', () => {
|
|
6
6
|
it('all tools registered in ALL_TOOLS', () => {
|
|
7
|
-
expect(ALL_TOOLS.length).toBe(
|
|
7
|
+
expect(ALL_TOOLS.length).toBe(4);
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
ALL_TOOLS.forEach((tool) => {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { ALL_TOOLS } from '../tools';
|
|
3
|
+
|
|
4
|
+
const ASIAN_LOCALES = ['ja', 'ko', 'zh'];
|
|
5
|
+
|
|
6
|
+
function getSimpleSectionLength(section: any): number {
|
|
7
|
+
if (section.type === 'title') return section.text ? section.text.length : 0;
|
|
8
|
+
if (section.type === 'paragraph') return section.html ? section.html.replace(/<[^>]*>/g, '').length : 0;
|
|
9
|
+
if (section.type === 'list') return section.items ? section.items.join('').length : 0;
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getComplexSectionLength(section: any): number {
|
|
14
|
+
if (section.type === 'diagnostic' || section.type === 'tip') {
|
|
15
|
+
return (section.title ? section.title.length : 0) + (section.html ? section.html.replace(/<[^>]*>/g, '').length : 0);
|
|
16
|
+
}
|
|
17
|
+
if (section.type === 'table') {
|
|
18
|
+
return ((section.headers || []).join('').length) + ((section.rows || []).flat().join('').length);
|
|
19
|
+
}
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getSectionLength(section: any): number {
|
|
24
|
+
return getSimpleSectionLength(section) || getComplexSectionLength(section);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function calculateSeoTextLength(seoSections: any[]): number {
|
|
28
|
+
return seoSections.reduce((acc, section) => acc + getSectionLength(section), 0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function checkLocaleSeoLength(toolId: string, locale: string, localeLen: number, enLen: number): void {
|
|
32
|
+
const isAsian = ASIAN_LOCALES.includes(locale);
|
|
33
|
+
const minLength = Math.floor(enLen * (isAsian ? 0.25 : 0.70));
|
|
34
|
+
const msgType = isAsian ? 'suspiciously short' : 'truncated/lazy';
|
|
35
|
+
|
|
36
|
+
expect(
|
|
37
|
+
localeLen,
|
|
38
|
+
`[LAZY SEO TRANSLATION] Tool "${toolId}" locale "${locale}" SEO text is ${msgType} (${localeLen} chars vs EN ${enLen} chars, expected min ${minLength})`,
|
|
39
|
+
).toBeGreaterThanOrEqual(minLength);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function auditSingleLocale(toolId: string, locale: string, loader: any, enSeoLength: number): Promise<void> {
|
|
43
|
+
if (locale === 'en' || !loader) return;
|
|
44
|
+
const content = await loader();
|
|
45
|
+
if (!content.seo || !Array.isArray(content.seo)) return;
|
|
46
|
+
|
|
47
|
+
checkLocaleSeoLength(toolId, locale, calculateSeoTextLength(content.seo), enSeoLength);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
describe('SEO Translation Completeness & Laziness Audit', () => {
|
|
51
|
+
ALL_TOOLS.forEach(({ entry }) => {
|
|
52
|
+
describe(`Tool: ${entry.id}`, () => {
|
|
53
|
+
it('should not have lazy or truncated SEO content compared to English reference', async () => {
|
|
54
|
+
const enLoader = entry.i18n['en' as keyof typeof entry.i18n];
|
|
55
|
+
if (!enLoader) return;
|
|
56
|
+
|
|
57
|
+
const enContent = await enLoader();
|
|
58
|
+
if (!enContent.seo || !Array.isArray(enContent.seo)) return;
|
|
59
|
+
|
|
60
|
+
const enSeoLength = calculateSeoTextLength(enContent.seo);
|
|
61
|
+
|
|
62
|
+
for (const [locale, loader] of Object.entries(entry.i18n)) {
|
|
63
|
+
await auditSingleLocale(entry.id, locale, loader, enSeoLength);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
@@ -5,7 +5,7 @@ import { motorCategory } from '../data';
|
|
|
5
5
|
describe('Tool Validation Suite', () => {
|
|
6
6
|
describe('Library Registration', () => {
|
|
7
7
|
it('should have tools registered in ALL_TOOLS', () => {
|
|
8
|
-
expect(ALL_TOOLS.length).toBe(
|
|
8
|
+
expect(ALL_TOOLS.length).toBe(4);
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
it('motorCategory should be defined', () => {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BibliographyEntry } from '../../types';
|
|
2
|
+
|
|
3
|
+
export const bibliographyEntries: BibliographyEntry[] = [
|
|
4
|
+
{
|
|
5
|
+
name: 'Brooklyn College drivetrain equations for vehicle speed and wheel RPM',
|
|
6
|
+
url: 'https://www.sci.brooklyn.cuny.edu/~goetz/agents/courses/corc3303/papers/b1-reyenga-2009.pdf',
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
name: 'Firgelli Engineering vehicle speed and final drive ratio formula',
|
|
10
|
+
url: 'https://www.firgelliauto.com/blogs/engineering-calculators/gear-ratio-speed-calculator-final-drive',
|
|
11
|
+
},
|
|
12
|
+
];
|