@jjlmoya/utils-nautical 1.5.0 → 1.7.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 (99) hide show
  1. package/package.json +72 -71
  2. package/src/tests/i18n_coverage.test.ts +36 -0
  3. package/src/tests/locale_completeness.test.ts +42 -0
  4. package/src/tests/no_h1_in_components.test.ts +48 -0
  5. package/src/tests/schemas_fulfillment.test.ts +23 -0
  6. package/src/tests/slug_uniqueness.test.ts +81 -0
  7. package/src/tests/title_quality.test.ts +55 -0
  8. package/src/tool/endurance/component.astro +340 -1
  9. package/src/tool/endurance/i18n/de.ts +249 -0
  10. package/src/tool/endurance/i18n/id.ts +249 -0
  11. package/src/tool/endurance/i18n/it.ts +249 -0
  12. package/src/tool/endurance/i18n/ja.ts +249 -0
  13. package/src/tool/endurance/i18n/ko.ts +249 -0
  14. package/src/tool/endurance/i18n/nl.ts +249 -0
  15. package/src/tool/endurance/i18n/pl.ts +249 -0
  16. package/src/tool/endurance/i18n/pt.ts +249 -0
  17. package/src/tool/endurance/i18n/ru.ts +249 -0
  18. package/src/tool/endurance/i18n/sv.ts +249 -0
  19. package/src/tool/endurance/i18n/tr.ts +249 -0
  20. package/src/tool/endurance/i18n/zh.ts +249 -0
  21. package/src/tool/endurance/index.ts +12 -0
  22. package/src/tool/nauticalConverter/component.astro +208 -1
  23. package/src/tool/nauticalConverter/i18n/de.ts +239 -0
  24. package/src/tool/nauticalConverter/i18n/id.ts +239 -0
  25. package/src/tool/nauticalConverter/i18n/it.ts +239 -0
  26. package/src/tool/nauticalConverter/i18n/ja.ts +239 -0
  27. package/src/tool/nauticalConverter/i18n/ko.ts +239 -0
  28. package/src/tool/nauticalConverter/i18n/nl.ts +239 -0
  29. package/src/tool/nauticalConverter/i18n/pl.ts +239 -0
  30. package/src/tool/nauticalConverter/i18n/pt.ts +239 -0
  31. package/src/tool/nauticalConverter/i18n/ru.ts +239 -0
  32. package/src/tool/nauticalConverter/i18n/sv.ts +239 -0
  33. package/src/tool/nauticalConverter/i18n/tr.ts +239 -0
  34. package/src/tool/nauticalConverter/i18n/zh.ts +239 -0
  35. package/src/tool/nauticalConverter/index.ts +12 -0
  36. package/src/tool/sailArea/component.astro +355 -2
  37. package/src/tool/sailArea/i18n/de.ts +275 -0
  38. package/src/tool/sailArea/i18n/id.ts +275 -0
  39. package/src/tool/sailArea/i18n/it.ts +275 -0
  40. package/src/tool/sailArea/i18n/ja.ts +275 -0
  41. package/src/tool/sailArea/i18n/ko.ts +275 -0
  42. package/src/tool/sailArea/i18n/nl.ts +275 -0
  43. package/src/tool/sailArea/i18n/pl.ts +275 -0
  44. package/src/tool/sailArea/i18n/pt.ts +275 -0
  45. package/src/tool/sailArea/i18n/ru.ts +275 -0
  46. package/src/tool/sailArea/i18n/sv.ts +275 -0
  47. package/src/tool/sailArea/i18n/tr.ts +275 -0
  48. package/src/tool/sailArea/i18n/zh.ts +275 -0
  49. package/src/tool/sailArea/index.ts +12 -0
  50. package/src/tool/speedConverter/component.astro +242 -1
  51. package/src/tool/speedConverter/i18n/de.ts +271 -0
  52. package/src/tool/speedConverter/i18n/id.ts +271 -0
  53. package/src/tool/speedConverter/i18n/it.ts +271 -0
  54. package/src/tool/speedConverter/i18n/ja.ts +271 -0
  55. package/src/tool/speedConverter/i18n/ko.ts +271 -0
  56. package/src/tool/speedConverter/i18n/nl.ts +271 -0
  57. package/src/tool/speedConverter/i18n/pl.ts +271 -0
  58. package/src/tool/speedConverter/i18n/pt.ts +271 -0
  59. package/src/tool/speedConverter/i18n/ru.ts +194 -0
  60. package/src/tool/speedConverter/i18n/sv.ts +271 -0
  61. package/src/tool/speedConverter/i18n/tr.ts +225 -0
  62. package/src/tool/speedConverter/i18n/zh.ts +271 -0
  63. package/src/tool/speedConverter/index.ts +12 -0
  64. package/src/tool/tideCalculator/component.astro +313 -1
  65. package/src/tool/tideCalculator/i18n/de.ts +203 -0
  66. package/src/tool/tideCalculator/i18n/id.ts +203 -0
  67. package/src/tool/tideCalculator/i18n/it.ts +203 -0
  68. package/src/tool/tideCalculator/i18n/ja.ts +203 -0
  69. package/src/tool/tideCalculator/i18n/ko.ts +203 -0
  70. package/src/tool/tideCalculator/i18n/nl.ts +203 -0
  71. package/src/tool/tideCalculator/i18n/pl.ts +203 -0
  72. package/src/tool/tideCalculator/i18n/pt.ts +203 -0
  73. package/src/tool/tideCalculator/i18n/ru.ts +203 -0
  74. package/src/tool/tideCalculator/i18n/sv.ts +203 -0
  75. package/src/tool/tideCalculator/i18n/tr.ts +203 -0
  76. package/src/tool/tideCalculator/i18n/zh.ts +203 -0
  77. package/src/tool/tideCalculator/index.ts +12 -0
  78. package/src/tool/underKeel/component.astro +321 -1
  79. package/src/tool/underKeel/i18n/de.ts +189 -0
  80. package/src/tool/underKeel/i18n/en.ts +2 -2
  81. package/src/tool/underKeel/i18n/fr.ts +2 -2
  82. package/src/tool/underKeel/i18n/id.ts +189 -0
  83. package/src/tool/underKeel/i18n/it.ts +176 -0
  84. package/src/tool/underKeel/i18n/ja.ts +185 -0
  85. package/src/tool/underKeel/i18n/ko.ts +185 -0
  86. package/src/tool/underKeel/i18n/nl.ts +176 -0
  87. package/src/tool/underKeel/i18n/pl.ts +176 -0
  88. package/src/tool/underKeel/i18n/pt.ts +176 -0
  89. package/src/tool/underKeel/i18n/ru.ts +176 -0
  90. package/src/tool/underKeel/i18n/sv.ts +176 -0
  91. package/src/tool/underKeel/i18n/tr.ts +185 -0
  92. package/src/tool/underKeel/i18n/zh.ts +185 -0
  93. package/src/tool/underKeel/index.ts +12 -0
  94. package/src/tool/endurance/style.css +0 -337
  95. package/src/tool/nauticalConverter/style.css +0 -205
  96. package/src/tool/sailArea/style.css +0 -351
  97. package/src/tool/speedConverter/style.css +0 -239
  98. package/src/tool/tideCalculator/style.css +0 -310
  99. package/src/tool/underKeel/style.css +0 -318
package/package.json CHANGED
@@ -1,75 +1,76 @@
1
1
  {
2
- "name": "@jjlmoya/utils-nautical",
3
- "version": "1.5.0",
4
- "type": "module",
5
- "main": "./src/index.ts",
6
- "types": "./src/index.ts",
7
- "exports": {
8
- ".": "./src/index.ts",
9
- "./data": "./src/data.ts"
10
- },
11
- "files": [
12
- "src"
13
- ],
14
- "publishConfig": {
15
- "access": "public"
16
- },
17
- "scripts": {
18
- "dev": "astro dev",
19
- "start": "astro dev",
20
- "build": "astro build",
21
- "preview": "astro preview",
22
- "astro": "astro",
23
- "lint": "eslint src/ --max-warnings 0 && stylelint \"src/**/*.{css,astro}\"",
24
- "check": "astro check",
25
- "type-check": "astro check",
26
- "test": "vitest run",
27
- "preversion": "npm run lint && npm run test",
28
- "postversion": "git push && git push --tags",
29
- "patch": "npm version patch",
30
- "minor": "npm version minor",
31
- "major": "npm version major"
32
- },
33
- "lint-staged": {
34
- "*.{ts,tsx,astro}": [
35
- "eslint --fix"
36
- ]
37
- },
38
- "dependencies": {
39
- "@iconify-json/mdi": "^1.2.3",
40
- "@jjlmoya/utils-shared": "^1.1.0",
41
- "astro": "^6.1.2",
42
- "astro-icon": "^1.1.0",
43
- "chart.js": "^4.5.1"
44
- },
45
- "peerDependencies": {
46
- "html2canvas": ">=1.4.0",
47
- "jspdf": ">=2.0.0"
48
- },
49
- "peerDependenciesMeta": {
50
- "html2canvas": {
51
- "optional": true
2
+ "name": "@jjlmoya/utils-nautical",
3
+ "version": "1.7.0",
4
+ "type": "module",
5
+ "main": "./src/index.ts",
6
+ "types": "./src/index.ts",
7
+ "exports": {
8
+ ".": "./src/index.ts",
9
+ "./data": "./src/data.ts"
52
10
  },
53
- "jspdf": {
54
- "optional": true
11
+ "files": [
12
+ "src"
13
+ ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "scripts": {
18
+ "dev": "astro dev",
19
+ "start": "astro dev",
20
+ "build": "astro build",
21
+ "preview": "astro preview",
22
+ "astro": "astro",
23
+ "lint": "eslint src/ --max-warnings 0 && stylelint \"src/**/*.{css,astro}\"",
24
+ "check": "astro check",
25
+ "type-check": "astro check",
26
+ "test": "vitest run",
27
+ "preversion": "npm run lint && npm run test",
28
+ "postversion": "git push && git push --tags",
29
+ "patch": "npm version patch",
30
+ "minor": "npm version minor",
31
+ "major": "npm version major"
32
+ },
33
+ "lint-staged": {
34
+ "*.{ts,tsx,astro}": [
35
+ "eslint --fix"
36
+ ]
37
+ },
38
+ "dependencies": {
39
+ "@iconify-json/mdi": "^1.2.3",
40
+ "@jjlmoya/prompagate": "^1.1.0",
41
+ "@jjlmoya/utils-shared": "1.2.0",
42
+ "astro": "^6.1.2",
43
+ "astro-icon": "^1.1.0",
44
+ "chart.js": "^4.5.1"
45
+ },
46
+ "peerDependencies": {
47
+ "html2canvas": ">=1.4.0",
48
+ "jspdf": ">=2.0.0"
49
+ },
50
+ "peerDependenciesMeta": {
51
+ "html2canvas": {
52
+ "optional": true
53
+ },
54
+ "jspdf": {
55
+ "optional": true
56
+ }
57
+ },
58
+ "devDependencies": {
59
+ "@astrojs/check": "^0.9.8",
60
+ "eslint": "^9.39.4",
61
+ "eslint-plugin-astro": "^1.6.0",
62
+ "eslint-plugin-no-comments": "^1.1.10",
63
+ "html2canvas": "^1.4.1",
64
+ "husky": "^9.1.7",
65
+ "jspdf": "^4.2.1",
66
+ "lint-staged": "^16.4.0",
67
+ "postcss-html": "^1.8.1",
68
+ "schema-dts": "^1.1.2",
69
+ "stylelint": "^17.6.0",
70
+ "stylelint-config-standard": "^40.0.0",
71
+ "stylelint-declaration-strict-value": "^1.11.1",
72
+ "typescript": "^5.4.0",
73
+ "typescript-eslint": "^8.58.0",
74
+ "vitest": "^4.1.2"
55
75
  }
56
- },
57
- "devDependencies": {
58
- "@astrojs/check": "^0.9.8",
59
- "eslint": "^9.39.4",
60
- "eslint-plugin-astro": "^1.6.0",
61
- "eslint-plugin-no-comments": "^1.1.10",
62
- "html2canvas": "^1.4.1",
63
- "husky": "^9.1.7",
64
- "jspdf": "^4.2.1",
65
- "lint-staged": "^16.4.0",
66
- "postcss-html": "^1.8.1",
67
- "schema-dts": "^1.1.2",
68
- "stylelint": "^17.6.0",
69
- "stylelint-config-standard": "^40.0.0",
70
- "stylelint-declaration-strict-value": "^1.11.1",
71
- "typescript": "^5.4.0",
72
- "typescript-eslint": "^8.58.0",
73
- "vitest": "^4.1.2"
74
- }
75
76
  }
@@ -0,0 +1,36 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { ALL_TOOLS } from '../tools';
3
+
4
+ const EXPECTED_LOCALES = [
5
+ 'de', 'en', 'es', 'fr', 'id', 'it', 'ja', 'ko', 'nl', 'pl', 'pt', 'ru', 'sv', 'tr', 'zh'
6
+ ];
7
+
8
+ describe('I18n Coverage Validation', () => {
9
+ it('all tools should be registered', () => {
10
+ expect(ALL_TOOLS.length).toBeGreaterThan(0);
11
+ });
12
+
13
+ ALL_TOOLS.forEach(({ entry }: { entry: any }) => {
14
+ describe(`Tool: ${entry.id}`, () => {
15
+ it('should have all 15 required locales', () => {
16
+ const registeredLocales = Object.keys(entry.i18n);
17
+ EXPECTED_LOCALES.forEach((locale) => {
18
+ expect(
19
+ registeredLocales,
20
+ `Tool "${entry.id}" is missing locale "${locale}"`,
21
+ ).toContain(locale);
22
+ });
23
+ });
24
+
25
+ it('all locale loaders should be functions', () => {
26
+ EXPECTED_LOCALES.forEach((locale) => {
27
+ const loader = entry.i18n[locale as keyof typeof entry.i18n];
28
+ expect(
29
+ typeof loader,
30
+ `Tool "${entry.id}" locale "${locale}" loader is not a function`,
31
+ ).toBe('function');
32
+ });
33
+ });
34
+ });
35
+ });
36
+ });
@@ -0,0 +1,42 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { ALL_TOOLS } from '../tools';
3
+ import type { ToolLocaleContent } from '../types';
4
+
5
+ describe('Locale Completeness Validation', () => {
6
+ ALL_TOOLS.forEach((tool) => {
7
+ describe(`Tool: ${tool.entry.id}`, () => {
8
+ Object.keys(tool.entry.i18n).forEach((locale) => {
9
+ describe(`Locale: ${locale}`, () => {
10
+ it('faqTitle should be defined when faq items exist', async () => {
11
+ const loader = tool.entry.i18n[locale as keyof typeof tool.entry.i18n];
12
+ const content = (await loader?.()) as ToolLocaleContent;
13
+
14
+ if (content.faq.length > 0) {
15
+ expect(
16
+ content.ui.faqTitle,
17
+ `Tool "${tool.entry.id}" locale "${locale}" has ${content.faq.length} FAQ items but is missing faqTitle in ui`,
18
+ ).toBeTruthy();
19
+ }
20
+ });
21
+
22
+ it('bibliographyTitle should be defined when bibliography items exist', async () => {
23
+ const loader = tool.entry.i18n[locale as keyof typeof tool.entry.i18n];
24
+ const content = (await loader?.()) as ToolLocaleContent;
25
+
26
+ if (content.bibliography.length > 0) {
27
+ expect(
28
+ content.ui.bibliographyTitle,
29
+ `Tool "${tool.entry.id}" locale "${locale}" has ${content.bibliography.length} bibliography items but is missing bibliographyTitle in ui`,
30
+ ).toBeTruthy();
31
+ }
32
+ });
33
+ });
34
+ });
35
+ });
36
+ });
37
+
38
+ it('all 10 tools registered', () => {
39
+ expect(ALL_TOOLS.length).toBe(6);
40
+ });
41
+ });
42
+
@@ -0,0 +1,48 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { readdirSync, readFileSync } from 'fs';
3
+ import { join } from 'path';
4
+
5
+ const EXCLUDED_DIRS = ['node_modules', 'pages', 'layouts'];
6
+
7
+ function findAstroFiles(dir: string): string[] {
8
+ const files: string[] = [];
9
+ const entries = readdirSync(dir, { withFileTypes: true });
10
+
11
+ for (const entry of entries) {
12
+ const fullPath = join(dir, entry.name);
13
+ if (entry.isDirectory() && !EXCLUDED_DIRS.includes(entry.name)) {
14
+ files.push(...findAstroFiles(fullPath));
15
+ } else if (entry.isFile() && entry.name.endsWith('.astro')) {
16
+ files.push(fullPath);
17
+ }
18
+ }
19
+
20
+ return files;
21
+ }
22
+
23
+ function hasH1(content: string): boolean {
24
+ return /<h1[\s>]/i.test(content);
25
+ }
26
+
27
+ const srcDir = join(process.cwd(), 'src');
28
+ const astroFiles = findAstroFiles(srcDir);
29
+
30
+ describe('No H1 in Components', () => {
31
+ if (astroFiles.length === 0) {
32
+ it('no astro components found', () => {
33
+ expect(true).toBe(true);
34
+ });
35
+ }
36
+
37
+ astroFiles.forEach((file) => {
38
+ const relativePath = file.replace(process.cwd(), '');
39
+ it(`${relativePath} should not contain <h1>`, () => {
40
+ const content = readFileSync(file, 'utf-8');
41
+ expect(
42
+ hasH1(content),
43
+ `File "${relativePath}" contains a <h1> element. Use <h2> or lower inside components — h1 belongs to the page layout.`,
44
+ ).toBe(false);
45
+ });
46
+ });
47
+ });
48
+
@@ -0,0 +1,23 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { ALL_TOOLS } from '../tools';
3
+ import type { ToolLocaleContent } from '../types';
4
+
5
+ describe('Schemas Fulfillment Validation', () => {
6
+ ALL_TOOLS.forEach((tool) => {
7
+ describe(`Tool: ${tool.entry.id}`, () => {
8
+ Object.keys(tool.entry.i18n).forEach((locale) => {
9
+ it(`Locale: ${locale} should have faqSchema, appSchema and howToSchema`, async () => {
10
+ const loader = tool.entry.i18n[locale as keyof typeof tool.entry.i18n];
11
+ if (!loader) return;
12
+ const content = (await loader()) as ToolLocaleContent;
13
+
14
+ const schemaTypes = content.schemas.map((s: any) => s['@type']);
15
+
16
+ expect(schemaTypes, `Tool "${tool.entry.id}" locale "${locale}" is missing FAQPage schema`).toContain('FAQPage');
17
+ expect(schemaTypes, `Tool "${tool.entry.id}" locale "${locale}" is missing SoftwareApplication schema`).toContain('SoftwareApplication');
18
+ expect(schemaTypes, `Tool "${tool.entry.id}" locale "${locale}" is missing HowTo schema`).toContain('HowTo');
19
+ });
20
+ });
21
+ });
22
+ });
23
+ });
@@ -0,0 +1,81 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { ALL_TOOLS } from '../tools';
3
+ import type { ToolLocaleContent } from '../types';
4
+
5
+ const sharingLocales = ['ja', 'ko', 'zh'];
6
+
7
+ interface ValidateParams {
8
+ toolId: string;
9
+ locale: string;
10
+ content: ToolLocaleContent;
11
+ enSlug: string;
12
+ slugs: Map<string, string>;
13
+ }
14
+
15
+ const validateLocaleSlug = ({
16
+ toolId,
17
+ locale,
18
+ content,
19
+ enSlug,
20
+ slugs,
21
+ }: ValidateParams) => {
22
+ expect(
23
+ content.slug,
24
+ `Tool "${toolId}" locale "${locale}" has an invalid slug ("${content.slug}"). Slugs must be transliterated (only a-z, 0-9, and -).`,
25
+ ).toMatch(/^[a-z0-9-]+$/);
26
+
27
+ if (locale === 'en') {
28
+ return;
29
+ }
30
+
31
+ if (sharingLocales.includes(locale)) {
32
+ expect(
33
+ content.slug,
34
+ `Tool "${toolId}" locale "${locale}" must use the same slug as "en" ("${enSlug}").`,
35
+ ).toBe(enSlug);
36
+ } else {
37
+ expect(
38
+ content.slug,
39
+ `Tool "${toolId}" locale "${locale}" has the same slug as "en" ("${enSlug}"). Cada slug tiene que estar en su propia idioma`,
40
+ ).not.toBe(enSlug);
41
+
42
+ if (slugs.has(content.slug)) {
43
+ const previousLocale = slugs.get(content.slug);
44
+ expect(
45
+ false,
46
+ `Tool "${toolId}" locales "${locale}" and "${previousLocale}" share the same slug ("${content.slug}"). Cada slug tiene que estar en su propia idioma`,
47
+ ).toBe(true);
48
+ }
49
+ slugs.set(content.slug, locale);
50
+ }
51
+ };
52
+
53
+ describe('Slug Localization and Uniqueness Validation', () => {
54
+ ALL_TOOLS.forEach((tool) => {
55
+ describe(`Tool: ${tool.entry.id}`, () => {
56
+ it('every locale should have a unique, translated slug', async () => {
57
+ const slugs = new Map<string, string>();
58
+ const locales = Object.keys(tool.entry.i18n);
59
+
60
+ let enSlug = '';
61
+ if (locales.includes('en')) {
62
+ const enLoader = tool.entry.i18n['en' as keyof typeof tool.entry.i18n];
63
+ const enContent = (await enLoader?.()) as ToolLocaleContent;
64
+ enSlug = enContent.slug;
65
+ }
66
+
67
+ for (const locale of locales) {
68
+ const loader = tool.entry.i18n[locale as keyof typeof tool.entry.i18n];
69
+ const content = (await loader?.()) as ToolLocaleContent;
70
+ validateLocaleSlug({
71
+ toolId: tool.entry.id,
72
+ locale,
73
+ content,
74
+ enSlug,
75
+ slugs,
76
+ });
77
+ }
78
+ });
79
+ });
80
+ });
81
+ });
@@ -0,0 +1,55 @@
1
+ import { describe, it } from 'vitest';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+
5
+ function getFiles(dir: string, ext: string[]): string[] {
6
+ const results: string[] = [];
7
+ if (!fs.existsSync(dir)) return results;
8
+ const list = fs.readdirSync(dir);
9
+ for (const file of list) {
10
+ const fullPath = path.join(dir, file);
11
+ const stat = fs.statSync(fullPath);
12
+ if (stat && stat.isDirectory()) {
13
+ results.push(...getFiles(fullPath, ext));
14
+ } else if (ext.some((e) => file.endsWith(e))) {
15
+ results.push(fullPath);
16
+ }
17
+ }
18
+ return results;
19
+ }
20
+
21
+ const SRC_DIR = path.join(process.cwd(), 'src');
22
+
23
+ describe('Project Titles - Separator Validation', () => {
24
+ const files = [
25
+ ...getFiles(path.join(SRC_DIR, 'tool'), ['.ts']),
26
+ ...getFiles(path.join(SRC_DIR, 'category'), ['.ts']),
27
+ ].filter(f => f.includes('i18n'));
28
+
29
+ it.each(files)('Verify that titles in %s do not contain | or -', (filePath) => {
30
+ const content = fs.readFileSync(filePath, 'utf-8');
31
+ const relativePath = path.relative(process.cwd(), filePath);
32
+
33
+ const titlePatterns = [
34
+ /const\s+title\s*=\s*['"]([^'"]+)['"]/g,
35
+ /title\s*:\s*['"]([^'"]+)['"]/g,
36
+ ];
37
+
38
+ const findings: string[] = [];
39
+
40
+ for (const pattern of titlePatterns) {
41
+ let match;
42
+ while ((match = pattern.exec(content)) !== null) {
43
+ const title = match[1];
44
+ if (title.includes('|') || title.includes('-')) {
45
+ findings.push(title);
46
+ }
47
+ }
48
+ }
49
+
50
+ if (findings.length > 0) {
51
+ const list = findings.map((f) => ` - "${f}"`).join('\n');
52
+ throw new Error(`Forbidden separators (| or -) found in titles in ${relativePath}:\n${list}`);
53
+ }
54
+ });
55
+ });